draw ok seulement si x est modulo de 8
This commit is contained in:
parent
633b630b92
commit
88d4cb076b
4 changed files with 161 additions and 120 deletions
|
|
@ -47,7 +47,6 @@
|
||||||
;
|
;
|
||||||
; information relative à la souris
|
; information relative à la souris
|
||||||
;
|
;
|
||||||
|
|
||||||
%define BDA_DATA_SEG 0x0050
|
%define BDA_DATA_SEG 0x0050
|
||||||
%define BDA_MOUSE 0x0000
|
%define BDA_MOUSE 0x0000
|
||||||
|
|
||||||
|
|
@ -65,6 +64,7 @@ struc mouse
|
||||||
.cur_y resw 1
|
.cur_y resw 1
|
||||||
.cur_addr_start resw 1 ; adresse de départ de la sauvegarde
|
.cur_addr_start resw 1 ; adresse de départ de la sauvegarde
|
||||||
.cur_bank_add resw 1 ; + ou - 0x2000
|
.cur_bank_add resw 1 ; + ou - 0x2000
|
||||||
|
.cur_drawing resb 1
|
||||||
.cur_visible resb 1
|
.cur_visible resb 1
|
||||||
.cur_seg resw 1 ; segment / offset of the pointer
|
.cur_seg resw 1 ; segment / offset of the pointer
|
||||||
.cur_ofs resw 1
|
.cur_ofs resw 1
|
||||||
|
|
@ -74,6 +74,8 @@ struc mouse
|
||||||
.bkg_buffer resb 16*3 ; buffer for saved background
|
.bkg_buffer resb 16*3 ; buffer for saved background
|
||||||
endstruc
|
endstruc
|
||||||
|
|
||||||
|
%define BDA_TIMER (BDA_MOUSE + mouse_size)
|
||||||
|
|
||||||
; -----------------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------------
|
||||||
; PC components I/O ports
|
; PC components I/O ports
|
||||||
; -----------------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
59
src/boot.asm
59
src/boot.asm
|
|
@ -102,21 +102,48 @@ endless:
|
||||||
mov ax,BDA_DATA_SEG
|
mov ax,BDA_DATA_SEG
|
||||||
mov ds,ax
|
mov ds,ax
|
||||||
|
|
||||||
; mov ax, [BDA_MOUSE + mouse.x]
|
mov dx,0x300
|
||||||
; add ax, 80
|
call scr_gotoxy
|
||||||
; cmp ax,640
|
|
||||||
; jb .moveok
|
|
||||||
;
|
|
||||||
; mov ax,0
|
|
||||||
;.moveok:
|
|
||||||
; mov [BDA_MOUSE + mouse.x],ax
|
|
||||||
;
|
|
||||||
; call gfx_cursor_move
|
|
||||||
|
|
||||||
|
mov al, byte [BDA_TIMER]
|
||||||
|
call scr_puthex8
|
||||||
|
|
||||||
|
cmp byte [BDA_TIMER],5
|
||||||
|
ja .skip2
|
||||||
|
|
||||||
|
mov ax, [BDA_MOUSE + mouse.x]
|
||||||
|
add ax, 25
|
||||||
|
cmp ax,640
|
||||||
|
jb .moveok
|
||||||
|
;
|
||||||
|
mov ax,0
|
||||||
|
.moveok:
|
||||||
|
mov [BDA_MOUSE + mouse.x],ax
|
||||||
|
;
|
||||||
|
call gfx_cursor_move
|
||||||
|
|
||||||
|
cmp byte [BDA_MOUSE + mouse.buffer+1], 0
|
||||||
|
jge .skip
|
||||||
|
|
||||||
|
mov dx,0x400
|
||||||
|
call scr_gotoxy
|
||||||
|
|
||||||
|
mov al, byte [BDA_MOUSE + mouse.buffer+1]
|
||||||
|
call scr_puthex8
|
||||||
|
.skip:
|
||||||
|
cmp byte [BDA_MOUSE + mouse.buffer+2], 0
|
||||||
|
jge .skip2
|
||||||
|
|
||||||
|
mov dx,0x404
|
||||||
|
call scr_gotoxy
|
||||||
|
|
||||||
|
mov al, byte [BDA_MOUSE + mouse.buffer+2]
|
||||||
|
call scr_puthex8
|
||||||
|
.skip2:
|
||||||
mov dx,0
|
mov dx,0
|
||||||
call scr_gotoxy
|
call scr_gotoxy
|
||||||
|
|
||||||
mov ax,0 ; adresse début dump
|
mov ax,[BDA_MOUSE] ; adresse début dump
|
||||||
mov si,ax
|
mov si,ax
|
||||||
mov cx, 0x20
|
mov cx, 0x20
|
||||||
.dump:
|
.dump:
|
||||||
|
|
@ -150,14 +177,14 @@ endless:
|
||||||
test_isr:
|
test_isr:
|
||||||
push ax
|
push ax
|
||||||
|
|
||||||
; push fs
|
push fs
|
||||||
;mov ax,BDA_DATA_SEG
|
mov ax,BDA_DATA_SEG
|
||||||
;mov fs,ax
|
mov fs,ax
|
||||||
;inc byte [fs:0x0005]
|
inc byte [fs:BDA_TIMER]
|
||||||
|
|
||||||
mov al, PIC_EOI ; EOI master
|
mov al, PIC_EOI ; EOI master
|
||||||
out i8259_MASTER_CMD, al
|
out i8259_MASTER_CMD, al
|
||||||
; pop fs
|
pop fs
|
||||||
|
|
||||||
pop ax
|
pop ax
|
||||||
iret
|
iret
|
||||||
|
|
|
||||||
|
|
@ -252,11 +252,16 @@ gfx_getpixel_fast:
|
||||||
gfx_cursor_move:
|
gfx_cursor_move:
|
||||||
pusha
|
pusha
|
||||||
push ds
|
push ds
|
||||||
|
push es
|
||||||
|
|
||||||
; move Data Segment
|
; move Data Segment
|
||||||
mov ax, BDA_DATA_SEG
|
mov ax, BDA_DATA_SEG
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
|
|
||||||
|
cmp byte [BDA_MOUSE + mouse.cur_drawing],0
|
||||||
|
jne .done
|
||||||
|
mov byte [BDA_MOUSE + mouse.cur_drawing],1
|
||||||
|
|
||||||
mov ax, VIDEO_SEG
|
mov ax, VIDEO_SEG
|
||||||
mov es, ax
|
mov es, ax
|
||||||
|
|
||||||
|
|
@ -265,32 +270,39 @@ gfx_cursor_move:
|
||||||
call gfx_cursor_savebg
|
call gfx_cursor_savebg
|
||||||
|
|
||||||
call gfx_cursor_draw
|
call gfx_cursor_draw
|
||||||
|
mov byte [BDA_MOUSE + mouse.cur_drawing],0
|
||||||
|
.done:
|
||||||
|
pop es
|
||||||
pop ds
|
pop ds
|
||||||
|
|
||||||
popa
|
popa
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; ------------------------------------------------------------
|
; ------------------------------------------------------------
|
||||||
; Dessine le curseur 16x16 AND/XOR à [BDA_CURSOR_NEWX],[BDA_CURSOR_NEWY]
|
; Dessine le curseur 16x16 AND/XOR à [mouse.x,mouse.y]
|
||||||
;
|
;
|
||||||
; CS:SI = base du sprite (AND[16] suivi de XOR[16] à +32 bytes)
|
; sprite (AND[16] suivi de XOR[16] à +32 bytes)
|
||||||
; Uses: BDA_CURSOR_BITOFF/BDA_CURSOR_BYTES (via gfx_cursor_calc_align)
|
|
||||||
; ------------------------------------------------------------
|
; ------------------------------------------------------------
|
||||||
gfx_cursor_draw:
|
gfx_cursor_draw:
|
||||||
; pusha
|
; pusha
|
||||||
|
|
||||||
mov ax, BDA_DATA_SEG
|
mov ax, BDA_DATA_SEG
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
|
|
||||||
mov ax, VIDEO_SEG
|
mov ax, VIDEO_SEG
|
||||||
mov es, ax
|
mov es, ax
|
||||||
|
|
||||||
mov ax, word [BDA_MOUSE + mouse.cur_ofs]
|
mov ax, word [BDA_MOUSE + mouse.cur_ofs]
|
||||||
mov si, ax
|
mov si, ax
|
||||||
|
|
||||||
|
mov ax, word [BDA_MOUSE + mouse.cur_seg]
|
||||||
|
mov gs, ax
|
||||||
|
|
||||||
mov cx, word [BDA_MOUSE + mouse.x]
|
mov cx, word [BDA_MOUSE + mouse.x]
|
||||||
mov dx, word [BDA_MOUSE + mouse.y]
|
mov dx, word [BDA_MOUSE + mouse.y]
|
||||||
|
|
||||||
|
mov word [BDA_MOUSE + mouse.cur_x], cx ; sauvegarde la nouvelle position
|
||||||
|
mov word [BDA_MOUSE + mouse.cur_y], dx
|
||||||
|
|
||||||
; calcule offset et bytes/ligne (2 ou 3)
|
; calcule offset et bytes/ligne (2 ou 3)
|
||||||
call gfx_cursor_calc_align
|
call gfx_cursor_calc_align
|
||||||
mov bl, byte [BDA_MOUSE + mouse.cur_bit_ofs]; 0..7
|
mov bl, byte [BDA_MOUSE + mouse.cur_bit_ofs]; 0..7
|
||||||
|
|
@ -310,20 +322,20 @@ gfx_cursor_draw:
|
||||||
mov dh, 8
|
mov dh, 8
|
||||||
.pair:
|
.pair:
|
||||||
; ----- ligne row (bank courant) -----
|
; ----- ligne row (bank courant) -----
|
||||||
push di
|
; push di
|
||||||
push si
|
; push si
|
||||||
call .draw_line ; utilise DI, row=BX
|
call .draw_line ; utilise DI, row=BX
|
||||||
pop si
|
; pop si
|
||||||
pop di
|
; pop di
|
||||||
|
|
||||||
; ----- ligne row+1 (autre bank) -----
|
; ----- ligne row+1 (autre bank) -----
|
||||||
add di, bp
|
add di, bp
|
||||||
inc bh
|
inc bh
|
||||||
push di
|
; push di
|
||||||
push si
|
; push si
|
||||||
call .draw_line
|
call .draw_line
|
||||||
pop si
|
; pop si
|
||||||
pop di
|
; pop di
|
||||||
sub di, bp
|
sub di, bp
|
||||||
|
|
||||||
; avancer de 2 lignes (dans le bank courant): +80 bytes
|
; avancer de 2 lignes (dans le bank courant): +80 bytes
|
||||||
|
|
@ -340,13 +352,12 @@ gfx_cursor_draw:
|
||||||
; .draw_line: applique AND/XOR sur une ligne de 16 pixels à ES:DI
|
; .draw_line: applique AND/XOR sur une ligne de 16 pixels à ES:DI
|
||||||
; row index dans BX (0..15)
|
; row index dans BX (0..15)
|
||||||
; offset dans BL (0..7)
|
; offset dans BL (0..7)
|
||||||
; sprite base CS:SI
|
; sprite base GS:SI
|
||||||
; ------------------------------------------------------------
|
; ------------------------------------------------------------
|
||||||
.draw_line:
|
.draw_line:
|
||||||
push ax
|
push ax
|
||||||
push cx
|
push cx
|
||||||
push dx
|
push dx
|
||||||
push bp
|
|
||||||
push di
|
push di
|
||||||
|
|
||||||
; charger masks de la ligne: AND = [SI + row*2], XOR = [SI + 32 + row*2]
|
; charger masks de la ligne: AND = [SI + row*2], XOR = [SI + 32 + row*2]
|
||||||
|
|
@ -356,9 +367,9 @@ gfx_cursor_draw:
|
||||||
|
|
||||||
push si
|
push si
|
||||||
add si, ax
|
add si, ax
|
||||||
mov cx, [cs:si] ; AND mask
|
mov cx, [gs:si] ; AND mask
|
||||||
add si, 32
|
add si, 32
|
||||||
mov dx, [cs:si] ; XOR mask
|
mov dx, [gs:si] ; XOR mask
|
||||||
pop si
|
pop si
|
||||||
|
|
||||||
; lire bytes source
|
; lire bytes source
|
||||||
|
|
@ -470,13 +481,11 @@ gfx_cursor_draw:
|
||||||
mov [es:di], al ; low
|
mov [es:di], al ; low
|
||||||
.done:
|
.done:
|
||||||
pop di
|
pop di
|
||||||
pop bp
|
|
||||||
pop dx
|
pop dx
|
||||||
pop cx
|
pop cx
|
||||||
pop ax
|
pop ax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
; ------------------------------------------------------------
|
; ------------------------------------------------------------
|
||||||
; Sauvegarde le background (24x16) sous le curseur
|
; Sauvegarde le background (24x16) sous le curseur
|
||||||
;
|
;
|
||||||
|
|
@ -491,14 +500,12 @@ gfx_cursor_savebg:
|
||||||
mov cx, [BDA_MOUSE + mouse.x] ;
|
mov cx, [BDA_MOUSE + mouse.x] ;
|
||||||
mov dx, [BDA_MOUSE + mouse.y]
|
mov dx, [BDA_MOUSE + mouse.y]
|
||||||
|
|
||||||
mov word [BDA_MOUSE + mouse.cur_x], cx ; sauvegarde la nouvelle position
|
|
||||||
mov word [BDA_MOUSE + mouse.cur_y], dx
|
|
||||||
|
|
||||||
call gfx_calc_addr ; ES:DI = byteaddr pour (X,Y)
|
call gfx_calc_addr ; ES:DI = byteaddr pour (X,Y)
|
||||||
mov dx,0x2000 ; offset pour lignes impaire
|
mov dx,0x2000 ; offset pour lignes impaire
|
||||||
cmp di,dx
|
cmp di,dx
|
||||||
jl .no_odd_bank
|
jl .no_odd_bank
|
||||||
neg dx ; Y est déja une ligne impaire, on retire l'offset
|
neg dx ; Y est déja une ligne impaire, on retire l'offset
|
||||||
|
|
||||||
.no_odd_bank:
|
.no_odd_bank:
|
||||||
mov ax, di ; préserver l'address de départ
|
mov ax, di ; préserver l'address de départ
|
||||||
mov word [BDA_MOUSE + mouse.cur_addr_start],ax
|
mov word [BDA_MOUSE + mouse.cur_addr_start],ax
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ mouse_reset:
|
||||||
mov byte [fs:BDA_MOUSE + mouse.cur_visible], 1
|
mov byte [fs:BDA_MOUSE + mouse.cur_visible], 1
|
||||||
mov word [fs:BDA_MOUSE + mouse.cur_x], 0
|
mov word [fs:BDA_MOUSE + mouse.cur_x], 0
|
||||||
mov word [fs:BDA_MOUSE + mouse.cur_y], 0
|
mov word [fs:BDA_MOUSE + mouse.cur_y], 0
|
||||||
|
mov byte [fs:BDA_MOUSE + mouse.cur_drawing], 0
|
||||||
|
|
||||||
mov ax, cs
|
mov ax, cs
|
||||||
mov word [fs:BDA_MOUSE + mouse.cur_seg], ax
|
mov word [fs:BDA_MOUSE + mouse.cur_seg], ax
|
||||||
|
|
@ -301,6 +302,7 @@ isr_mouse_handler:
|
||||||
|
|
||||||
; lire un octet depuis le contrôleur et le stocker dans le buffer
|
; lire un octet depuis le contrôleur et le stocker dans le buffer
|
||||||
in al, i8042_PS2_DATA ; lire octet souris
|
in al, i8042_PS2_DATA ; lire octet souris
|
||||||
|
|
||||||
movzx bx, byte [BDA_MOUSE + mouse.idx]
|
movzx bx, byte [BDA_MOUSE + mouse.idx]
|
||||||
mov byte [BDA_MOUSE + mouse.buffer + bx], al
|
mov byte [BDA_MOUSE + mouse.buffer + bx], al
|
||||||
inc byte [BDA_MOUSE + mouse.idx]
|
inc byte [BDA_MOUSE + mouse.idx]
|
||||||
|
|
@ -308,20 +310,29 @@ isr_mouse_handler:
|
||||||
; vérifier si le packet est complet
|
; vérifier si le packet est complet
|
||||||
mov al, [BDA_MOUSE + mouse.packetlen]
|
mov al, [BDA_MOUSE + mouse.packetlen]
|
||||||
cmp byte [BDA_MOUSE + mouse.idx], al
|
cmp byte [BDA_MOUSE + mouse.idx], al
|
||||||
jne .done
|
jb .done
|
||||||
|
|
||||||
; packet complet, on decode les données
|
; packet complet, on decode les données
|
||||||
mov byte [BDA_MOUSE + mouse.idx], 0
|
mov byte [BDA_MOUSE + mouse.idx], 0
|
||||||
mov al, [BDA_MOUSE + mouse.buffer] ; status
|
mov bl, [BDA_MOUSE + mouse.buffer] ; status
|
||||||
mov [BDA_MOUSE + mouse.status], al
|
mov [BDA_MOUSE + mouse.status], bl
|
||||||
|
|
||||||
xor ax,ax
|
xor ax,ax
|
||||||
mov al, byte [BDA_MOUSE + mouse.buffer+1] ; delta X
|
mov al, byte [BDA_MOUSE + mouse.buffer+1] ; delta X
|
||||||
|
test bl,00010000b ; signe X
|
||||||
|
jz .x_pos
|
||||||
|
or al, 0xF0
|
||||||
|
.x_pos:
|
||||||
cbw
|
cbw
|
||||||
add [BDA_MOUSE + mouse.x], ax
|
add [BDA_MOUSE + mouse.x], ax
|
||||||
|
|
||||||
|
|
||||||
xor ax,ax
|
xor ax,ax
|
||||||
mov al, byte [BDA_MOUSE + mouse.buffer+2] ; delta Y
|
mov al, byte [BDA_MOUSE + mouse.buffer+2] ; delta Y
|
||||||
|
test bl,00100000b ; signe Y
|
||||||
|
jz .y_pos
|
||||||
|
or al, 0xF0
|
||||||
|
.y_pos:
|
||||||
cbw
|
cbw
|
||||||
sub [BDA_MOUSE + mouse.y], ax
|
sub [BDA_MOUSE + mouse.y], ax
|
||||||
|
|
||||||
|
|
@ -349,14 +360,8 @@ isr_mouse_handler:
|
||||||
jle .y_ok_high
|
jle .y_ok_high
|
||||||
mov word [BDA_MOUSE + mouse.y], 199
|
mov word [BDA_MOUSE + mouse.y], 199
|
||||||
.y_ok_high:
|
.y_ok_high:
|
||||||
; restaurer l'ancien arrière plan du curseur
|
|
||||||
call gfx_cursor_restorebg
|
|
||||||
|
|
||||||
; sauvegarder le nouvel arrière plan du curseur
|
|
||||||
call gfx_cursor_savebg
|
|
||||||
|
|
||||||
call gfx_cursor_draw
|
|
||||||
|
|
||||||
|
;call gfx_cursor_move
|
||||||
.done:
|
.done:
|
||||||
mov al, 0x20
|
mov al, 0x20
|
||||||
out i8259_SLAVE_CMD, al ; EOI PIC esclave
|
out i8259_SLAVE_CMD, al ; EOI PIC esclave
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue