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
|
||||
|
||||
struc mouse
|
||||
.buffer resb 4 ; i8042 input buffer
|
||||
.idx resb 1 ; index in the buffer
|
||||
.packetlen resb 1 ; max buffer len (3 ou 4)
|
||||
.buffer resb 4 ; i8042 input buffer 0..3
|
||||
.idx resb 1 ; index in the buffer 4
|
||||
.packetlen resb 1 ; max buffer len (3 ou 4) 5
|
||||
|
||||
.status resb 1 ; mouse status (button etc)
|
||||
.wheel resb 1 ; if a packet size is 4; experimental
|
||||
.x resw 1 ;
|
||||
.y resw 1
|
||||
.status resb 1 ; mouse status (button etc) 6
|
||||
.wheel resb 1 ; if a packet size is 4; experimental 7
|
||||
.x resw 1 ; 8..9
|
||||
.y resw 1 ; A..B
|
||||
; cursor management
|
||||
.cur_x resw 1 ; preservation des x,y du background
|
||||
.cur_y resw 1
|
||||
.cur_addr_start resw 1 ; adresse de départ de la sauvegarde
|
||||
.cur_bank_add resw 1 ; + ou - 0x2000
|
||||
.cur_drawing resb 1
|
||||
.cur_visible resb 1
|
||||
.cur_seg resw 1 ; segment / offset of the pointer
|
||||
.cur_ofs resw 1
|
||||
.cur_mask resb 1 ; pixels mask (bit per pixel)
|
||||
.cur_bit_ofs resb 1 ; 0..7 bits d'offset (x&7)
|
||||
.bkg_saved resb 1 ; background saved
|
||||
alignb 4 ; alignement 4 bytes
|
||||
.cur_x resw 1 ; preservation des x,y du background C..D
|
||||
.cur_y resw 1 ; E..F
|
||||
.cur_addr_start resw 1 ; adresse de départ de la sauvegarde 10..11
|
||||
.cur_bank_add resw 1 ; + ou - 0x2000 12..13
|
||||
|
||||
.cur_drawing resb 1 ; 14
|
||||
.cur_visible resb 1 ; 15
|
||||
.cur_seg resw 1 ; segment / offset of the pointer 16..17
|
||||
.cur_ofs resw 1 ; 18..19
|
||||
.cur_mask resb 1 ; pixels mask (bit per pixel) 1A
|
||||
.cur_bit_ofs resb 1 ; 0..7 bits d'offset (x&7) 1B
|
||||
.bkg_saved resb 1 ; background saved 1C
|
||||
alignb 4 ; alignement 4 bytes 1D
|
||||
.bkg_buffer resd 16 ; buffer for saved background
|
||||
endstruc
|
||||
|
||||
|
|
@ -95,6 +96,8 @@ endstruc
|
|||
%define BDA_MOUSE 0x0000
|
||||
%define BDA_GFX (BDA_MOUSE + mouse_size)
|
||||
|
||||
%warning offset Mouse: BAD_MOUSE, Gfx : BDA_GFX
|
||||
|
||||
;
|
||||
; memory map
|
||||
;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
; =============================================================================
|
||||
80; =============================================================================
|
||||
; Project : Custom BIOS / ROM
|
||||
; File : gfx_cgam.asm
|
||||
; Author : frater
|
||||
|
|
@ -131,7 +131,7 @@ cga_init:
|
|||
int 0x10
|
||||
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"
|
||||
call cga_background
|
||||
ret
|
||||
|
|
@ -703,103 +703,64 @@ cga_cursor_draw:
|
|||
mov ax, VIDEO_SEG
|
||||
mov es, ax
|
||||
|
||||
; --- 1. CLIPPING VERTICAL ---
|
||||
; --- CLIPPING VERTICAL ---
|
||||
mov dx, [ds:BDA_MOUSE + mouse.y]
|
||||
cmp dx, 200
|
||||
jae .exit_total
|
||||
|
||||
mov bp, 16
|
||||
mov ax, 200
|
||||
sub ax, dx
|
||||
sub ax, dx ; 200-y
|
||||
cmp bp, ax
|
||||
jbe .y_ok
|
||||
jbe .y_ok ; y<= 200-16
|
||||
mov bp, ax
|
||||
.y_ok:
|
||||
|
||||
; --- 2. ADRESSAGE ---
|
||||
mov cx, [ds:BDA_MOUSE + mouse.x]
|
||||
mov dx, [ds:BDA_MOUSE + mouse.y]
|
||||
; --- ADRESSAGE ---
|
||||
mov cx, [BDA_MOUSE + mouse.x]
|
||||
mov dx, [BDA_MOUSE + mouse.y]
|
||||
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 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 dx, -0x2000 + 80 ; Retour + ligne suivante
|
||||
test word [ds:BDA_MOUSE + mouse.y], 1
|
||||
test word [BDA_MOUSE + mouse.y], 1
|
||||
jz .setup_done
|
||||
xchg bx, dx
|
||||
neg bx
|
||||
.setup_done:
|
||||
|
||||
and cx, 7 ; CL = Shift (0..7)
|
||||
mov [BDA_MOUSE + mouse.cur_bank_add], bx ; interligne + ou - 0x2000
|
||||
|
||||
.row_loop:
|
||||
; --- CONSTRUCTION DES MASQUES (EAX/EBX) ---
|
||||
; On force l'ordre [GAUCHE][DROITE] visuel en lisant par octet
|
||||
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
|
||||
mov bx, [gs:si+32] ; Octet GAUCHE du masque XOR
|
||||
|
||||
;mov bh, [gs:si+33] ; Octet GAUCHE du masque XOR
|
||||
;mov bl, [gs:si+32] ; Octet DROITE du masque XOR
|
||||
shl ebx, 8 ; EBX = [00][GAUCHE][DROITE][00]
|
||||
mov ax, [gs:si] ; masque AND
|
||||
xchg al, ah
|
||||
; 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) ---
|
||||
; Octet 0 (Gauche)
|
||||
mov dl, [es:di]
|
||||
push eax
|
||||
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
|
||||
mov bx, [gs:si+32] ; masque XOR
|
||||
xchg bl, bh
|
||||
; expansion 16 bits -> 32 bits avec padding
|
||||
;shl ebx, 8 ; EBX = [00][GAUCHE][DROITE][00]
|
||||
|
||||
; 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 ax, [ds:BDA_MOUSE + mouse.x]
|
||||
shr ax, 3
|
||||
cmp ax, 78
|
||||
jae .next_line
|
||||
mov dx, [es:di] ; lecture des 16 bits a la position du curseur
|
||||
and dx, ax ; application du masque AND (AX)
|
||||
xor dx, bx ; application du masque XOR (BX)
|
||||
|
||||
mov dl, [es:di+2]
|
||||
and dl, al ; Bits 7-0
|
||||
xor dl, bl
|
||||
mov [es:di+2], dl
|
||||
mov [es:di], dx ; ecriture du résultat
|
||||
|
||||
.next_line:
|
||||
add di, bx
|
||||
xchg bx, dx
|
||||
add di, CGA_STRIDE
|
||||
; [BDA_MOUSE + mouse.cur_bank_add]
|
||||
|
||||
add si, 2 ; Prochaine ligne du sprite
|
||||
dec bp
|
||||
jnz .row_loop
|
||||
|
|
|
|||
|
|
@ -33,30 +33,20 @@ kbd_flush:
|
|||
kbd_init:
|
||||
push ds
|
||||
push ax
|
||||
|
||||
call kbd_flush
|
||||
|
||||
; 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 bx,kbd_isr
|
||||
|
||||
mov bx,kbd_isr ; Event handler
|
||||
mov ax, i8259_MASTER_INT ; base offset IRQ 0
|
||||
inc ax ; IRQ 1
|
||||
|
||||
call ivt_setvector
|
||||
|
||||
; enable IRQ 1
|
||||
mov ah,IRQ_ENABLED
|
||||
mov al,1
|
||||
call pic_set_irq_mask
|
||||
|
||||
pop ax
|
||||
pop ds
|
||||
ret
|
||||
|
|
@ -70,10 +60,6 @@ kbd_isr:
|
|||
|
||||
in al, 0x60 ; consomme scancode (obligatoire)
|
||||
|
||||
mov ax,BDA_DATA_SEG
|
||||
mov ds,ax
|
||||
inc byte [0x0000]
|
||||
|
||||
mov al, PIC_EOI ; EOI master
|
||||
out i8259_MASTER_CMD, al
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ mouse_reset:
|
|||
mov word [fs:BDA_MOUSE + mouse.cur_ofs], mouse_arrow
|
||||
|
||||
; experiemntal
|
||||
mov word [fs:BDA_MOUSE + mouse.wheel],0
|
||||
mov byte [fs:BDA_MOUSE + mouse.wheel],0
|
||||
ret
|
||||
|
||||
; ------------------------------------------------------------
|
||||
|
|
@ -139,6 +139,7 @@ mouse_init:
|
|||
pop ax
|
||||
pop ds
|
||||
ret
|
||||
|
||||
; ------------------------------------------------------------
|
||||
; detect la taille du "payload" de la souris.
|
||||
;
|
||||
|
|
|
|||
Loading…
Reference in a new issue