bug fix init mouse + redraw cursor
This commit is contained in:
parent
fdea690f53
commit
ab52449591
5 changed files with 348 additions and 397 deletions
41
src/bda.asm
41
src/bda.asm
|
|
@ -55,27 +55,28 @@
|
||||||
%define BKG_TOTAL_BYTES (BKG_TOTAL_DWORDS * 4) ; 64
|
%define BKG_TOTAL_BYTES (BKG_TOTAL_DWORDS * 4) ; 64
|
||||||
|
|
||||||
struc mouse
|
struc mouse
|
||||||
.buffer resb 4 ; i8042 input buffer
|
.buffer resb 4 ; i8042 input buffer 0..3
|
||||||
.idx resb 1 ; index in the buffer
|
.idx resb 1 ; index in the buffer 4
|
||||||
.packetlen resb 1 ; max buffer len (3 ou 4)
|
.packetlen resb 1 ; max buffer len (3 ou 4) 5
|
||||||
|
|
||||||
.status resb 1 ; mouse status (button etc)
|
.status resb 1 ; mouse status (button etc) 6
|
||||||
.wheel resb 1 ; if a packet size is 4; experimental
|
.wheel resb 1 ; if a packet size is 4; experimental 7
|
||||||
.x resw 1 ;
|
.x resw 1 ; 8..9
|
||||||
.y resw 1
|
.y resw 1 ; A..B
|
||||||
; cursor management
|
; cursor management
|
||||||
.cur_x resw 1 ; preservation des x,y du background
|
.cur_x resw 1 ; preservation des x,y du background C..D
|
||||||
.cur_y resw 1
|
.cur_y resw 1 ; E..F
|
||||||
.cur_addr_start resw 1 ; adresse de départ de la sauvegarde
|
.cur_addr_start resw 1 ; adresse de départ de la sauvegarde 10..11
|
||||||
.cur_bank_add resw 1 ; + ou - 0x2000
|
.cur_bank_add resw 1 ; + ou - 0x2000 12..13
|
||||||
.cur_drawing resb 1
|
|
||||||
.cur_visible resb 1
|
.cur_drawing resb 1 ; 14
|
||||||
.cur_seg resw 1 ; segment / offset of the pointer
|
.cur_visible resb 1 ; 15
|
||||||
.cur_ofs resw 1
|
.cur_seg resw 1 ; segment / offset of the pointer 16..17
|
||||||
.cur_mask resb 1 ; pixels mask (bit per pixel)
|
.cur_ofs resw 1 ; 18..19
|
||||||
.cur_bit_ofs resb 1 ; 0..7 bits d'offset (x&7)
|
.cur_mask resb 1 ; pixels mask (bit per pixel) 1A
|
||||||
.bkg_saved resb 1 ; background saved
|
.cur_bit_ofs resb 1 ; 0..7 bits d'offset (x&7) 1B
|
||||||
alignb 4 ; alignement 4 bytes
|
.bkg_saved resb 1 ; background saved 1C
|
||||||
|
alignb 4 ; alignement 4 bytes 1D
|
||||||
.bkg_buffer resd 16 ; buffer for saved background
|
.bkg_buffer resd 16 ; buffer for saved background
|
||||||
endstruc
|
endstruc
|
||||||
|
|
||||||
|
|
@ -95,6 +96,8 @@ endstruc
|
||||||
%define BDA_MOUSE 0x0000
|
%define BDA_MOUSE 0x0000
|
||||||
%define BDA_GFX (BDA_MOUSE + mouse_size)
|
%define BDA_GFX (BDA_MOUSE + mouse_size)
|
||||||
|
|
||||||
|
%warning offset Mouse: BAD_MOUSE, Gfx : BDA_GFX
|
||||||
|
|
||||||
;
|
;
|
||||||
; memory map
|
; memory map
|
||||||
;
|
;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
; =============================================================================
|
80; =============================================================================
|
||||||
; Project : Custom BIOS / ROM
|
; Project : Custom BIOS / ROM
|
||||||
; File : gfx_cgam.asm
|
; File : gfx_cgam.asm
|
||||||
; Author : frater
|
; Author : frater
|
||||||
|
|
@ -131,7 +131,7 @@ cga_init:
|
||||||
int 0x10
|
int 0x10
|
||||||
mov byte [BDA_MOUSE + mouse.bkg_saved],0 ; flag image saved
|
mov byte [BDA_MOUSE + mouse.bkg_saved],0 ; flag image saved
|
||||||
|
|
||||||
mov byte [BDA_GFX + gfx.cur_mode], 1
|
; mov byte [BDA_GFX + gfx.cur_mode], 1
|
||||||
; dessine un background "check-board"
|
; dessine un background "check-board"
|
||||||
call cga_background
|
call cga_background
|
||||||
ret
|
ret
|
||||||
|
|
@ -703,103 +703,64 @@ cga_cursor_draw:
|
||||||
mov ax, VIDEO_SEG
|
mov ax, VIDEO_SEG
|
||||||
mov es, ax
|
mov es, ax
|
||||||
|
|
||||||
; --- 1. CLIPPING VERTICAL ---
|
; --- CLIPPING VERTICAL ---
|
||||||
mov dx, [ds:BDA_MOUSE + mouse.y]
|
mov dx, [ds:BDA_MOUSE + mouse.y]
|
||||||
cmp dx, 200
|
cmp dx, 200
|
||||||
jae .exit_total
|
jae .exit_total
|
||||||
|
|
||||||
mov bp, 16
|
mov bp, 16
|
||||||
mov ax, 200
|
mov ax, 200
|
||||||
sub ax, dx
|
sub ax, dx ; 200-y
|
||||||
cmp bp, ax
|
cmp bp, ax
|
||||||
jbe .y_ok
|
jbe .y_ok ; y<= 200-16
|
||||||
mov bp, ax
|
mov bp, ax
|
||||||
.y_ok:
|
.y_ok:
|
||||||
|
|
||||||
; --- 2. ADRESSAGE ---
|
; --- ADRESSAGE ---
|
||||||
mov cx, [ds:BDA_MOUSE + mouse.x]
|
mov cx, [BDA_MOUSE + mouse.x]
|
||||||
mov dx, [ds:BDA_MOUSE + mouse.y]
|
mov dx, [BDA_MOUSE + mouse.y]
|
||||||
call cga_calc_addr ; DI = Offset VRAM
|
call cga_calc_addr ; DI = Offset VRAM
|
||||||
|
|
||||||
mov ax, [ds:BDA_MOUSE + mouse.cur_seg]
|
mov ax, [BDA_MOUSE + mouse.cur_seg]
|
||||||
mov gs, ax
|
mov gs, ax
|
||||||
mov si, [ds:BDA_MOUSE + mouse.cur_ofs]
|
mov si, [BDA_MOUSE + mouse.cur_ofs]
|
||||||
|
|
||||||
; --- 3. CALCUL DES STRIDES ---
|
; --- CALCUL de l'offset entre 2 lignes +0x2000 ou -0x2000 ---
|
||||||
mov bx, 0x2000 ; Banque opposée
|
mov bx, 0x2000 ; Banque opposée
|
||||||
mov dx, -0x2000 + 80 ; Retour + ligne suivante
|
test word [BDA_MOUSE + mouse.y], 1
|
||||||
test word [ds:BDA_MOUSE + mouse.y], 1
|
|
||||||
jz .setup_done
|
jz .setup_done
|
||||||
xchg bx, dx
|
neg bx
|
||||||
.setup_done:
|
.setup_done:
|
||||||
|
mov [BDA_MOUSE + mouse.cur_bank_add], bx ; interligne + ou - 0x2000
|
||||||
and cx, 7 ; CL = Shift (0..7)
|
|
||||||
|
|
||||||
.row_loop:
|
.row_loop:
|
||||||
; --- CONSTRUCTION DES MASQUES (EAX/EBX) ---
|
; --- CONSTRUCTION DES MASQUES (EAX/EBX) ---
|
||||||
; On force l'ordre [GAUCHE][DROITE] visuel en lisant par octet
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
;mov ah, [gs:si+1] ; Octet GAUCHE du masque AND
|
|
||||||
;mov al, [gs:si] ; Octet DROITE du masque AND
|
|
||||||
mov ax, [gs:si] ; Octet DROITE du masque AND
|
|
||||||
; Ton sprite cursor.asm utilise 0 pour le curseur, donc PAS de NOT
|
|
||||||
shl eax, 8
|
|
||||||
or eax, 0xFF0000FF ; Bourrage de 1 (fond transparent)
|
|
||||||
|
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
mov bx, [gs:si+32] ; Octet GAUCHE du masque XOR
|
|
||||||
|
|
||||||
;mov bh, [gs:si+33] ; Octet GAUCHE du masque XOR
|
mov ax, [gs:si] ; masque AND
|
||||||
;mov bl, [gs:si+32] ; Octet DROITE du masque XOR
|
xchg al, ah
|
||||||
shl ebx, 8 ; EBX = [00][GAUCHE][DROITE][00]
|
; expansion 16 bits -> 32 bits avec padding
|
||||||
|
;shl eax, 8
|
||||||
|
;or eax, 0xFF0000FF ; EAX = [FF][GAUCHE][DROITE][FF]
|
||||||
|
|
||||||
; --- DECALAGE (SHIFT) ---
|
|
||||||
push edx
|
|
||||||
mov edx, 0xFFFFFFFF
|
|
||||||
shrd eax, edx, cl ; Injecte du fond (1) à gauche
|
|
||||||
xor edx, edx
|
|
||||||
shrd ebx, edx, cl ; Injecte du vide (0) à gauche
|
|
||||||
pop edx
|
|
||||||
|
|
||||||
; --- RMW SUR 3 OCTETS (Fenêtre de 24 bits) ---
|
mov bx, [gs:si+32] ; masque XOR
|
||||||
; Octet 0 (Gauche)
|
xchg bl, bh
|
||||||
mov dl, [es:di]
|
; expansion 16 bits -> 32 bits avec padding
|
||||||
push eax
|
;shl ebx, 8 ; EBX = [00][GAUCHE][DROITE][00]
|
||||||
shr eax, 16 ; Récupère bits 23-16
|
|
||||||
and dl, al
|
|
||||||
push ebx
|
|
||||||
shr ebx, 16
|
|
||||||
xor dl, bl
|
|
||||||
mov [es:di], dl
|
|
||||||
pop ebx
|
|
||||||
pop eax
|
|
||||||
|
|
||||||
; Octet 1 (Milieu)
|
|
||||||
mov dl, [es:di+1]
|
|
||||||
push eax
|
|
||||||
shr eax, 8
|
|
||||||
and dl, al ; Bits 15-8
|
|
||||||
push ebx
|
|
||||||
shr ebx, 8
|
|
||||||
xor dl, bl
|
|
||||||
mov [es:di+1], dl
|
|
||||||
pop ebx
|
|
||||||
pop eax
|
|
||||||
|
|
||||||
; Octet 2 (Droite + Clipping X)
|
mov dx, [es:di] ; lecture des 16 bits a la position du curseur
|
||||||
mov ax, [ds:BDA_MOUSE + mouse.x]
|
and dx, ax ; application du masque AND (AX)
|
||||||
shr ax, 3
|
xor dx, bx ; application du masque XOR (BX)
|
||||||
cmp ax, 78
|
|
||||||
jae .next_line
|
|
||||||
|
|
||||||
mov dl, [es:di+2]
|
mov [es:di], dx ; ecriture du résultat
|
||||||
and dl, al ; Bits 7-0
|
|
||||||
xor dl, bl
|
|
||||||
mov [es:di+2], dl
|
|
||||||
|
|
||||||
.next_line:
|
.next_line:
|
||||||
add di, bx
|
add di, CGA_STRIDE
|
||||||
xchg bx, dx
|
; [BDA_MOUSE + mouse.cur_bank_add]
|
||||||
|
|
||||||
add si, 2 ; Prochaine ligne du sprite
|
add si, 2 ; Prochaine ligne du sprite
|
||||||
dec bp
|
dec bp
|
||||||
jnz .row_loop
|
jnz .row_loop
|
||||||
|
|
|
||||||
|
|
@ -33,30 +33,20 @@ kbd_flush:
|
||||||
kbd_init:
|
kbd_init:
|
||||||
push ds
|
push ds
|
||||||
push ax
|
push ax
|
||||||
|
|
||||||
call kbd_flush
|
call kbd_flush
|
||||||
|
|
||||||
; gestion du buffer clavier
|
; gestion du buffer clavier
|
||||||
mov ax, BDA_SEGMENT
|
|
||||||
mov ds, ax
|
|
||||||
mov byte [BDA_KBD_HEAD], 0
|
|
||||||
mov byte [BDA_KBD_TAIL], 0
|
|
||||||
mov byte [BDA_KBD_FLAGS], 0
|
|
||||||
|
|
||||||
mov ax,cs
|
mov ax,cs ; get current CS
|
||||||
mov dx,ax
|
mov dx,ax
|
||||||
mov bx,kbd_isr
|
mov bx,kbd_isr ; Event handler
|
||||||
|
|
||||||
mov ax, i8259_MASTER_INT ; base offset IRQ 0
|
mov ax, i8259_MASTER_INT ; base offset IRQ 0
|
||||||
inc ax ; IRQ 1
|
inc ax ; IRQ 1
|
||||||
|
|
||||||
call ivt_setvector
|
call ivt_setvector
|
||||||
|
|
||||||
; enable IRQ 1
|
; enable IRQ 1
|
||||||
mov ah,IRQ_ENABLED
|
mov ah,IRQ_ENABLED
|
||||||
mov al,1
|
mov al,1
|
||||||
call pic_set_irq_mask
|
call pic_set_irq_mask
|
||||||
|
|
||||||
pop ax
|
pop ax
|
||||||
pop ds
|
pop ds
|
||||||
ret
|
ret
|
||||||
|
|
@ -70,10 +60,6 @@ kbd_isr:
|
||||||
|
|
||||||
in al, 0x60 ; consomme scancode (obligatoire)
|
in al, 0x60 ; consomme scancode (obligatoire)
|
||||||
|
|
||||||
mov ax,BDA_DATA_SEG
|
|
||||||
mov ds,ax
|
|
||||||
inc byte [0x0000]
|
|
||||||
|
|
||||||
mov al, PIC_EOI ; EOI master
|
mov al, PIC_EOI ; EOI master
|
||||||
out i8259_MASTER_CMD, al
|
out i8259_MASTER_CMD, al
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ mouse_reset:
|
||||||
mov word [fs:BDA_MOUSE + mouse.cur_ofs], mouse_arrow
|
mov word [fs:BDA_MOUSE + mouse.cur_ofs], mouse_arrow
|
||||||
|
|
||||||
; experiemntal
|
; experiemntal
|
||||||
mov word [fs:BDA_MOUSE + mouse.wheel],0
|
mov byte [fs:BDA_MOUSE + mouse.wheel],0
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; ------------------------------------------------------------
|
; ------------------------------------------------------------
|
||||||
|
|
@ -139,6 +139,7 @@ mouse_init:
|
||||||
pop ax
|
pop ax
|
||||||
pop ds
|
pop ds
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; ------------------------------------------------------------
|
; ------------------------------------------------------------
|
||||||
; detect la taille du "payload" de la souris.
|
; detect la taille du "payload" de la souris.
|
||||||
;
|
;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue