Mouse interrupt handler + debug
This commit is contained in:
parent
c97c844329
commit
4cf1a0b7a2
6 changed files with 389 additions and 235 deletions
|
|
@ -58,6 +58,7 @@ struc mouse
|
||||||
.buffer resb 4 ; i8042 input buffer 0..3
|
.buffer resb 4 ; i8042 input buffer 0..3
|
||||||
.idx resb 1 ; index in the buffer 4
|
.idx resb 1 ; index in the buffer 4
|
||||||
.packetlen resb 1 ; max buffer len (3 ou 4) 5
|
.packetlen resb 1 ; max buffer len (3 ou 4) 5
|
||||||
|
.blinker resb 1 ;
|
||||||
|
|
||||||
.status resb 1 ; mouse status (button etc) 6
|
.status resb 1 ; mouse status (button etc) 6
|
||||||
.wheel resb 1 ; if a packet size is 4; experimental 7
|
.wheel resb 1 ; if a packet size is 4; experimental 7
|
||||||
|
|
@ -85,11 +86,7 @@ struc gfx
|
||||||
.cur_y resw 1
|
.cur_y resw 1
|
||||||
.cur_offset resw 1 ; offset calculé pour le prochain caractère
|
.cur_offset resw 1 ; offset calculé pour le prochain caractère
|
||||||
.cur_line_ofs resw 1 ; "interligne" +2000h ou -2000h
|
.cur_line_ofs resw 1 ; "interligne" +2000h ou -2000h
|
||||||
; .cur_xbyte resb 1 ; x>>3 (0..79)
|
|
||||||
.cur_shift resb 1 ; x&7 (0..7)
|
.cur_shift resb 1 ; x&7 (0..7)
|
||||||
; .cur_parity resb 1
|
|
||||||
; .cur_color resb 1 ; 0 = texte en noir, autre = texte en blanc
|
|
||||||
; .cur_trans resb 1 ; 0 = fond transparent, autre = fond inversé .txt_color
|
|
||||||
.cur_mode resb 1 ;
|
.cur_mode resb 1 ;
|
||||||
endstruc
|
endstruc
|
||||||
|
|
||||||
|
|
|
||||||
228
src/boot.asm
228
src/boot.asm
|
|
@ -20,158 +20,178 @@
|
||||||
;
|
;
|
||||||
; =============================================================================
|
; =============================================================================
|
||||||
|
|
||||||
bits 16
|
bits 16
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
;
|
;
|
||||||
; configuration du bios
|
; configuration du bios
|
||||||
;
|
;
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
%define DEBUG_PORT 0xe9 ; 0x402 ou 0xe9
|
%define DEBUG_PORT 0xe9 ; 0x402 ou 0xe9
|
||||||
|
|
||||||
; initial stack
|
; initial stack
|
||||||
%define STACK_SEG 0x0800 ; segment de base
|
%define STACK_SEG 0x0800 ; segment de base
|
||||||
|
|
||||||
|
;section .text
|
||||||
|
; bits 16
|
||||||
|
;
|
||||||
|
; db 'EXTRA CODE Section',0
|
||||||
|
;
|
||||||
|
; times 0xFFFF - ($ - $$) db 0xFF
|
||||||
|
|
||||||
section .text
|
section .text
|
||||||
bits 16
|
bits 16
|
||||||
|
|
||||||
;%include "./common/chartable.asm"
|
;%include "./common/chartable.asm"
|
||||||
;%include "./common/cursor.asm"
|
;%include "./common/cursor.asm"
|
||||||
|
|
||||||
; definition du BDA
|
; definition du BDA
|
||||||
%include "./bda.asm"
|
%include "./bda.asm"
|
||||||
|
|
||||||
; %include "./services/macros.asm"
|
; %include "./services/macros.asm"
|
||||||
%include "./drivers/debug.asm"
|
%include "./common/debug_cga.asm"
|
||||||
%include "./drivers/gfx_cgam.asm"
|
%include "./drivers/gfx_cgam.asm"
|
||||||
%include "./drivers/mouse_ps2.asm"
|
%include "./drivers/mouse_ps2.asm"
|
||||||
%include "./drivers/keyboard_ps2.asm"
|
%include "./drivers/keyboard_ps2.asm"
|
||||||
%include "./services/generic.asm"
|
%include "./services/generic.asm"
|
||||||
|
|
||||||
err_vganok db 'VGA Not Initialized',0
|
err_vganok db 'VGA Not Initialized',0
|
||||||
|
|
||||||
cpt_txt db '0123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789',0
|
cpt_txt db '0123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789',0
|
||||||
helloworld db 'Hello World !',0
|
helloworld db 'Hello World !',0
|
||||||
centre db 'TEXTEAUCENTR',0
|
centre db 'TEXTEAUCENTR',0
|
||||||
|
|
||||||
reset:
|
reset:
|
||||||
cli
|
cli
|
||||||
; il n'existe aucun 'stack' par défaut
|
; il n'existe aucun 'stack' par défaut
|
||||||
mov ax, STACK_SEG
|
mov ax, STACK_SEG
|
||||||
mov ss, ax
|
mov ss, ax
|
||||||
mov sp, 0xFFFE ; haut du segment (64ko de stack), mot-aligné
|
mov sp, 0xFFFE ; haut du segment (64ko de stack), mot-aligné
|
||||||
cld
|
cld
|
||||||
|
|
||||||
; installé une table d'interruption "dummy"
|
; installé une table d'interruption "dummy"
|
||||||
call ivt_setup
|
call ivt_setup
|
||||||
call bda_setup
|
call bda_setup
|
||||||
|
|
||||||
; Install IRQ 0 : timer_isr
|
; Install IRQ 0 : timer_isr
|
||||||
mov ax,cs
|
mov ax,cs
|
||||||
mov dx,ax
|
mov dx,ax
|
||||||
mov bx,timer_isr
|
mov bx,timer_isr
|
||||||
mov ax,i8259_MASTER_INT
|
mov ax,i8259_MASTER_INT
|
||||||
|
|
||||||
call ivt_setvector
|
call ivt_setvector
|
||||||
|
|
||||||
; initialisation des PIC 8259A
|
; initialisation des PIC 8259A
|
||||||
call pic_init
|
call pic_init
|
||||||
|
|
||||||
; load Roms
|
; load Roms
|
||||||
call setup_load_rom
|
call setup_load_rom
|
||||||
|
|
||||||
; on vérifie que le BIOS VGA a installé une INT 10h
|
; on vérifie que le BIOS VGA a installé une INT 10h
|
||||||
call setup_check_vga
|
call setup_check_vga
|
||||||
|
|
||||||
; on initialise le mode texte 80x25 par défaut DEBUG
|
; enable IRQ 0
|
||||||
;mov ax, 0x0003
|
mov ah,IRQ_ENABLED
|
||||||
;int 10h
|
mov al,0
|
||||||
|
call pic_set_irq_mask
|
||||||
|
|
||||||
; enable IRQ 0
|
call kbd_init
|
||||||
mov ah,IRQ_ENABLED
|
sti
|
||||||
mov al,0
|
|
||||||
call pic_set_irq_mask
|
|
||||||
|
|
||||||
call kbd_init
|
; on active le mode graphique
|
||||||
sti
|
GFX_DRV GFX_INIT
|
||||||
|
|
||||||
; on active le mode graphique
|
mov cx, 300
|
||||||
GFX_DRV GFX_INIT
|
mov dx, 102
|
||||||
|
GFX_DRV GFX_GOTOXY
|
||||||
|
|
||||||
mov cx, 300
|
GFX_SET_WRTIE_MODE GFX_TXT_WHITE_TRANSPARENT
|
||||||
mov dx, 102
|
|
||||||
GFX_DRV GFX_GOTOXY
|
|
||||||
|
|
||||||
GFX_SET_WRTIE_MODE GFX_TXT_WHITE_TRANSPARENT
|
push cs
|
||||||
|
pop ds
|
||||||
|
mov si, centre
|
||||||
|
GFX_DRV GFX_WRITE
|
||||||
|
|
||||||
push cs
|
; call mouse_reset
|
||||||
pop ds
|
call mouse_init
|
||||||
mov si, centre
|
|
||||||
GFX_DRV GFX_WRITE
|
|
||||||
|
|
||||||
; call mouse_reset
|
GFX_DRV GFX_CRS_UPDATE
|
||||||
call mouse_init
|
|
||||||
|
|
||||||
GFX_DRV GFX_CRS_UPDATE
|
GFX_SET_WRTIE_MODE GFX_TXT_BLACK_ON_WHITE
|
||||||
|
|
||||||
GFX_SET_WRTIE_MODE GFX_TXT_BLACK_ON_WHITE
|
xor cx,cx
|
||||||
|
mov dx,0
|
||||||
|
GFX_DRV GFX_GOTOXY
|
||||||
|
|
||||||
xor cx,cx
|
push cs
|
||||||
mov dx,0
|
pop ds
|
||||||
GFX_DRV GFX_GOTOXY
|
mov si, cpt_txt
|
||||||
|
GFX_DRV GFX_WRITE
|
||||||
|
|
||||||
push cs
|
GFX_SET_WRTIE_MODE GFX_TXT_WHITE_TRANSPARENT
|
||||||
pop ds
|
|
||||||
mov si, cpt_txt
|
|
||||||
GFX_DRV GFX_WRITE
|
|
||||||
|
|
||||||
GFX_SET_WRTIE_MODE GFX_TXT_WHITE_TRANSPARENT
|
mov cx,8
|
||||||
|
mov dx,8
|
||||||
|
GFX_DRV GFX_GOTOXY
|
||||||
|
|
||||||
mov cx,8
|
mov si, helloworld
|
||||||
mov dx,8
|
GFX_DRV GFX_WRITE
|
||||||
GFX_DRV GFX_GOTOXY
|
|
||||||
|
|
||||||
mov si, helloworld
|
mov cx,8
|
||||||
GFX_DRV GFX_WRITE
|
mov dx,24
|
||||||
|
GFX_SET_WRTIE_MODE 0
|
||||||
mov cx,8
|
|
||||||
mov dx,24
|
|
||||||
|
|
||||||
GFX_SET_WRTIE_MODE 0
|
|
||||||
|
|
||||||
.loopshift:
|
.loopshift:
|
||||||
GFX_DRV GFX_GOTOXY
|
GFX_DRV GFX_GOTOXY
|
||||||
mov si, helloworld
|
mov si, helloworld
|
||||||
GFX_DRV GFX_WRITE
|
GFX_DRV GFX_WRITE
|
||||||
add dx,8
|
add dx,8
|
||||||
inc cx
|
inc cx
|
||||||
cmp cx,16
|
cmp cx,16
|
||||||
jbe .loopshift
|
jbe .loopshift
|
||||||
|
|
||||||
|
mov ax,BDA_DATA_SEG
|
||||||
|
mov ds,ax
|
||||||
endless:
|
endless:
|
||||||
mov ax,BDA_DATA_SEG
|
xor cx,cx
|
||||||
mov ds,ax
|
mov dx,180
|
||||||
mov ax,0
|
GFX_DRV GFX_GOTOXY
|
||||||
|
|
||||||
jmp endless
|
mov ax, [BDA_MOUSE + mouse.x]
|
||||||
|
call print_word_hex
|
||||||
|
|
||||||
|
mov al,' '
|
||||||
|
call cga_putc
|
||||||
|
|
||||||
|
mov ax, [BDA_MOUSE + mouse.y]
|
||||||
|
call print_word_hex
|
||||||
|
|
||||||
|
mov al,' '
|
||||||
|
call cga_putc
|
||||||
|
|
||||||
|
xor ah,ah
|
||||||
|
mov al, [BDA_MOUSE + mouse.blinker]
|
||||||
|
call print_word_hex
|
||||||
|
|
||||||
|
jmp endless
|
||||||
|
|
||||||
|
|
||||||
; -----------------------------------------------------------
|
; -----------------------------------------------------------
|
||||||
; timer ISR (IRQ -> INT)
|
; timer ISR (IRQ -> INT)
|
||||||
; -----------------------------------------------------------
|
; -----------------------------------------------------------
|
||||||
timer_isr:
|
timer_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:BDA_TIMER]
|
; 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
|
||||||
|
|
||||||
; ------------------------------------------------------------------
|
; ------------------------------------------------------------------
|
||||||
; Padding jusqu'au reset vector
|
; Padding jusqu'au reset vector
|
||||||
|
|
@ -181,16 +201,16 @@ times 0xFFF0 - ($ - $$) db 0xFF
|
||||||
; ------------------------------------------------------------------
|
; ------------------------------------------------------------------
|
||||||
; RESET VECTOR (exécuté par le CPU)
|
; RESET VECTOR (exécuté par le CPU)
|
||||||
; ------------------------------------------------------------------
|
; ------------------------------------------------------------------
|
||||||
section .resetvect
|
section .resetvect
|
||||||
bits 16
|
bits 16
|
||||||
global reset_vector
|
global reset_vector
|
||||||
|
|
||||||
reset_vector:
|
reset_vector:
|
||||||
; code minimal au reset
|
; code minimal au reset
|
||||||
jmp 0xF000:reset
|
jmp 0xF000:reset
|
||||||
|
|
||||||
builddate:
|
builddate:
|
||||||
db '06/01/2026'
|
db '06/01/2026'
|
||||||
times 16-($-$$) db 0 ; le stub tient dans 16 octets (ou moins)
|
times 16-($-$$) db 0 ; le stub tient dans 16 octets (ou moins)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
105
src/common/debug_cga.asm
Normal file
105
src/common/debug_cga.asm
Normal file
|
|
@ -0,0 +1,105 @@
|
||||||
|
; =============================================================================
|
||||||
|
; Project : Custom BIOS / ROM
|
||||||
|
; File : cga_debug.asm
|
||||||
|
; Author : frater
|
||||||
|
;
|
||||||
|
; License : GNU General Public License v3.0 or later (GPL-3.0+)
|
||||||
|
;
|
||||||
|
; This program is free software: you can redistribute it and/or modify
|
||||||
|
; it under the terms of the GNU General Public License as published by
|
||||||
|
; the Free Software Foundation, either version 3 of the License, or
|
||||||
|
; (at your option) any later version.
|
||||||
|
;
|
||||||
|
; This program is distributed in the hope that it will be useful,
|
||||||
|
; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
; GNU General Public License for more details.
|
||||||
|
;
|
||||||
|
; You should have received a copy of the GNU General Public License
|
||||||
|
; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
;
|
||||||
|
; =============================================================================
|
||||||
|
|
||||||
|
; =============================================================================
|
||||||
|
; Fonction : dump_ram_words
|
||||||
|
; Description : Lit des mots (16 bits) depuis DS:SI et les affiche en Hexa
|
||||||
|
; Entrées :
|
||||||
|
; DS:SI = Adresse de départ en RAM
|
||||||
|
; CX = Nombre de mots (words) à lire et afficher
|
||||||
|
; =============================================================================
|
||||||
|
|
||||||
|
dump_ram_words:
|
||||||
|
jcxz .done ; Sécurité : si CX=0, on sort
|
||||||
|
|
||||||
|
.loop:
|
||||||
|
lodsw ; Charge [DS:SI] dans AX et incrémente SI de 2
|
||||||
|
; Note: x86 est Little Endian. Si RAM = 12 34,
|
||||||
|
; AX vaudra 0x3412.
|
||||||
|
|
||||||
|
push cx ; Sauvegarde le compteur de boucle principal
|
||||||
|
push si ; Sauvegarde le pointeur (si cga_putc le modifie)
|
||||||
|
|
||||||
|
call print_word_hex ; Affiche AX sous forme "XXXX"
|
||||||
|
|
||||||
|
; (Optionnel) Ajouter un espace entre chaque mot pour la lisibilité
|
||||||
|
mov al, ' '
|
||||||
|
call cga_putc
|
||||||
|
|
||||||
|
pop si ; Restaure SI
|
||||||
|
pop cx ; Restaure CX
|
||||||
|
|
||||||
|
loop .loop ; Décrémente CX et boucle si != 0
|
||||||
|
|
||||||
|
.done:
|
||||||
|
ret
|
||||||
|
|
||||||
|
; =============================================================================
|
||||||
|
; Fonction : print_word_hex
|
||||||
|
; Description : Convertit AX en 4 caractères Hexa et les affiche
|
||||||
|
; Entrée : AX = Valeur 16 bits (ex: 0x1A2B)
|
||||||
|
; Sortie : Affiche "1A2B" via cga_putc
|
||||||
|
; =============================================================================
|
||||||
|
print_word_hex:
|
||||||
|
push ax ; Sauvegarde AX car on va le modifier (rotation)
|
||||||
|
push cx
|
||||||
|
push bx
|
||||||
|
|
||||||
|
mov cx, 4 ; 4 caractères hex dans un mot de 16 bits
|
||||||
|
|
||||||
|
.next_digit:
|
||||||
|
; On veut afficher les bits 12-15 d'abord.
|
||||||
|
; L'astuce est de faire une rotation à gauche de 4 bits.
|
||||||
|
; Le quartet de poids fort se retrouve en bas (bits 0-3).
|
||||||
|
rol ax, 4
|
||||||
|
|
||||||
|
mov bx, ax ; Copie temporaire
|
||||||
|
and bl, 0x0F ; On isole les 4 derniers bits (0 à 15)
|
||||||
|
|
||||||
|
mov al, bl ; AL contient la valeur numérique (0-15)
|
||||||
|
call nibble_to_ascii ; Convertit AL en caractère ASCII
|
||||||
|
|
||||||
|
call cga_putc ; Affiche le caractère
|
||||||
|
|
||||||
|
loop .next_digit ; Répète 4 fois
|
||||||
|
|
||||||
|
pop bx
|
||||||
|
pop cx
|
||||||
|
pop ax ; Restaure l'état original de AX
|
||||||
|
ret
|
||||||
|
|
||||||
|
; =============================================================================
|
||||||
|
; Fonction : nibble_to_ascii
|
||||||
|
; Description : Convertit les 4 bits de poids faible de AL en ASCII Hex
|
||||||
|
; Entrée : AL (valeur 0-15)
|
||||||
|
; Sortie : AL (caractère '0'-'9' ou 'A'-'F')
|
||||||
|
; =============================================================================
|
||||||
|
nibble_to_ascii:
|
||||||
|
cmp al, 9
|
||||||
|
ja .letter ; Si > 9, c'est une lettre (A-F)
|
||||||
|
|
||||||
|
add al, '0' ; Sinon c'est un chiffre : 0x0 -> '0'
|
||||||
|
ret
|
||||||
|
|
||||||
|
.letter:
|
||||||
|
add al, 'A' - 10 ; Convertit 10 -> 'A', 11 -> 'B', etc.
|
||||||
|
ret
|
||||||
127
src/common/debug_txt.asm
Normal file
127
src/common/debug_txt.asm
Normal file
|
|
@ -0,0 +1,127 @@
|
||||||
|
; =============================================================================
|
||||||
|
; Project : Custom BIOS / ROM
|
||||||
|
; File : debug.asm
|
||||||
|
; Author : frater
|
||||||
|
; Created : 06 jan 2026
|
||||||
|
;
|
||||||
|
; License : GNU General Public License v3.0 or later (GPL-3.0+)
|
||||||
|
;
|
||||||
|
; This program is free software: you can redistribute it and/or modify
|
||||||
|
; it under the terms of the GNU General Public License as published by
|
||||||
|
; the Free Software Foundation, either version 3 of the License, or
|
||||||
|
; (at your option) any later version.
|
||||||
|
;
|
||||||
|
; This program is distributed in the hope that it will be useful,
|
||||||
|
; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
; GNU General Public License for more details.
|
||||||
|
;
|
||||||
|
; You should have received a copy of the GNU General Public License
|
||||||
|
; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
;
|
||||||
|
; =============================================================================
|
||||||
|
|
||||||
|
debug_puts:
|
||||||
|
.next:
|
||||||
|
push dx
|
||||||
|
mov dx, DEBUG_PORT
|
||||||
|
lodsb ; AL = *SI++
|
||||||
|
test al, al
|
||||||
|
jz .done
|
||||||
|
out dx, al
|
||||||
|
jmp .next
|
||||||
|
.done:
|
||||||
|
pop dx
|
||||||
|
ret
|
||||||
|
|
||||||
|
debug_putc:
|
||||||
|
push dx
|
||||||
|
mov dx, DEBUG_PORT
|
||||||
|
out dx, al
|
||||||
|
pop dx
|
||||||
|
ret
|
||||||
|
|
||||||
|
; AL = 0..15 -> print hex digit
|
||||||
|
debug_puthex4:
|
||||||
|
and al, 0Fh
|
||||||
|
cmp al, 9
|
||||||
|
jbe .num
|
||||||
|
add al, 'A' - 10
|
||||||
|
jmp .pout
|
||||||
|
.num:
|
||||||
|
add al, '0'
|
||||||
|
.pout:
|
||||||
|
call debug_putc
|
||||||
|
ret
|
||||||
|
|
||||||
|
; AL = byte -> print 2 hex digits
|
||||||
|
debug_puthex8:
|
||||||
|
push ax
|
||||||
|
mov ah, al
|
||||||
|
shr al, 4
|
||||||
|
call debug_puthex4
|
||||||
|
mov al, ah
|
||||||
|
call debug_puthex4
|
||||||
|
pop ax
|
||||||
|
ret
|
||||||
|
|
||||||
|
; AX = word -> print 4 hex digits
|
||||||
|
debug_puthex16:
|
||||||
|
push ax
|
||||||
|
mov al, ah
|
||||||
|
call debug_puthex8
|
||||||
|
pop ax
|
||||||
|
call debug_puthex8
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
; --- screen text functions ---
|
||||||
|
; AH = page
|
||||||
|
; DH = row
|
||||||
|
; DL = column
|
||||||
|
scr_gotoxy:
|
||||||
|
mov ah, 02h
|
||||||
|
mov bh, 0 ; page 0
|
||||||
|
int 10h
|
||||||
|
ret
|
||||||
|
|
||||||
|
scr_putc:
|
||||||
|
mov ah, 0x0E
|
||||||
|
int 10h
|
||||||
|
ret
|
||||||
|
|
||||||
|
; AL = 0..15 -> print hex digit
|
||||||
|
scr_puthex4:
|
||||||
|
and al, 0Fh ; mask 4 bits low
|
||||||
|
cmp al, 9 ; is it 0..9 ?
|
||||||
|
jbe .num ; yes
|
||||||
|
add al, 'A' - 10 ; convert to 'A'..'F'
|
||||||
|
jmp .pout
|
||||||
|
.num:
|
||||||
|
add al, '0' ; convert to '0'..'9'
|
||||||
|
.pout:
|
||||||
|
mov ah, 0x0E
|
||||||
|
int 10h
|
||||||
|
ret
|
||||||
|
|
||||||
|
; AL = byte -> print 2 hex digits
|
||||||
|
scr_puthex8:
|
||||||
|
push ax
|
||||||
|
push bx
|
||||||
|
mov bl, al ; save al
|
||||||
|
shr al, 4 ; 4 bits plus significatifs
|
||||||
|
call scr_puthex4
|
||||||
|
mov al, bl ; restore al
|
||||||
|
call scr_puthex4
|
||||||
|
pop bx
|
||||||
|
pop ax
|
||||||
|
ret
|
||||||
|
|
||||||
|
; AX = word -> print 4 hex digits
|
||||||
|
scr_puthex16:
|
||||||
|
push ax
|
||||||
|
mov al, ah
|
||||||
|
call scr_puthex8
|
||||||
|
pop ax
|
||||||
|
call scr_puthex8
|
||||||
|
ret
|
||||||
|
|
@ -1,127 +0,0 @@
|
||||||
; =============================================================================
|
|
||||||
; Project : Custom BIOS / ROM
|
|
||||||
; File : debug.asm
|
|
||||||
; Author : frater
|
|
||||||
; Created : 06 jan 2026
|
|
||||||
;
|
|
||||||
; License : GNU General Public License v3.0 or later (GPL-3.0+)
|
|
||||||
;
|
|
||||||
; This program is free software: you can redistribute it and/or modify
|
|
||||||
; it under the terms of the GNU General Public License as published by
|
|
||||||
; the Free Software Foundation, either version 3 of the License, or
|
|
||||||
; (at your option) any later version.
|
|
||||||
;
|
|
||||||
; This program is distributed in the hope that it will be useful,
|
|
||||||
; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
; GNU General Public License for more details.
|
|
||||||
;
|
|
||||||
; You should have received a copy of the GNU General Public License
|
|
||||||
; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
;
|
|
||||||
; =============================================================================
|
|
||||||
|
|
||||||
debug_puts:
|
|
||||||
.next:
|
|
||||||
push dx
|
|
||||||
mov dx, DEBUG_PORT
|
|
||||||
lodsb ; AL = *SI++
|
|
||||||
test al, al
|
|
||||||
jz .done
|
|
||||||
out dx, al
|
|
||||||
jmp .next
|
|
||||||
.done:
|
|
||||||
pop dx
|
|
||||||
ret
|
|
||||||
|
|
||||||
debug_putc:
|
|
||||||
push dx
|
|
||||||
mov dx, DEBUG_PORT
|
|
||||||
out dx, al
|
|
||||||
pop dx
|
|
||||||
ret
|
|
||||||
|
|
||||||
; AL = 0..15 -> print hex digit
|
|
||||||
debug_puthex4:
|
|
||||||
and al, 0Fh
|
|
||||||
cmp al, 9
|
|
||||||
jbe .num
|
|
||||||
add al, 'A' - 10
|
|
||||||
jmp .pout
|
|
||||||
.num:
|
|
||||||
add al, '0'
|
|
||||||
.pout:
|
|
||||||
call debug_putc
|
|
||||||
ret
|
|
||||||
|
|
||||||
; AL = byte -> print 2 hex digits
|
|
||||||
debug_puthex8:
|
|
||||||
push ax
|
|
||||||
mov ah, al
|
|
||||||
shr al, 4
|
|
||||||
call debug_puthex4
|
|
||||||
mov al, ah
|
|
||||||
call debug_puthex4
|
|
||||||
pop ax
|
|
||||||
ret
|
|
||||||
|
|
||||||
; AX = word -> print 4 hex digits
|
|
||||||
debug_puthex16:
|
|
||||||
push ax
|
|
||||||
mov al, ah
|
|
||||||
call debug_puthex8
|
|
||||||
pop ax
|
|
||||||
call debug_puthex8
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
; --- screen text functions ---
|
|
||||||
; AH = page
|
|
||||||
; DH = row
|
|
||||||
; DL = column
|
|
||||||
scr_gotoxy:
|
|
||||||
mov ah, 02h
|
|
||||||
mov bh, 0 ; page 0
|
|
||||||
int 10h
|
|
||||||
ret
|
|
||||||
|
|
||||||
scr_putc:
|
|
||||||
mov ah, 0x0E
|
|
||||||
int 10h
|
|
||||||
ret
|
|
||||||
|
|
||||||
; AL = 0..15 -> print hex digit
|
|
||||||
scr_puthex4:
|
|
||||||
and al, 0Fh ; mask 4 bits low
|
|
||||||
cmp al, 9 ; is it 0..9 ?
|
|
||||||
jbe .num ; yes
|
|
||||||
add al, 'A' - 10 ; convert to 'A'..'F'
|
|
||||||
jmp .pout
|
|
||||||
.num:
|
|
||||||
add al, '0' ; convert to '0'..'9'
|
|
||||||
.pout:
|
|
||||||
mov ah, 0x0E
|
|
||||||
int 10h
|
|
||||||
ret
|
|
||||||
|
|
||||||
; AL = byte -> print 2 hex digits
|
|
||||||
scr_puthex8:
|
|
||||||
push ax
|
|
||||||
push bx
|
|
||||||
mov bl, al ; save al
|
|
||||||
shr al, 4 ; 4 bits plus significatifs
|
|
||||||
call scr_puthex4
|
|
||||||
mov al, bl ; restore al
|
|
||||||
call scr_puthex4
|
|
||||||
pop bx
|
|
||||||
pop ax
|
|
||||||
ret
|
|
||||||
|
|
||||||
; AX = word -> print 4 hex digits
|
|
||||||
scr_puthex16:
|
|
||||||
push ax
|
|
||||||
mov al, ah
|
|
||||||
call scr_puthex8
|
|
||||||
pop ax
|
|
||||||
call scr_puthex8
|
|
||||||
ret
|
|
||||||
|
|
@ -66,6 +66,9 @@ mouse_reset:
|
||||||
|
|
||||||
; experiemntal
|
; experiemntal
|
||||||
mov byte [fs:BDA_MOUSE + mouse.wheel],0
|
mov byte [fs:BDA_MOUSE + mouse.wheel],0
|
||||||
|
|
||||||
|
; debug
|
||||||
|
mov byte [fs:BDA_MOUSE + mouse.blinker],0
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; ------------------------------------------------------------
|
; ------------------------------------------------------------
|
||||||
|
|
@ -85,6 +88,7 @@ mouse_init:
|
||||||
call ps2_wait_ready_write
|
call ps2_wait_ready_write
|
||||||
mov al, I8042_CMD_DIS_MOUSE ; Disable Mouse
|
mov al, I8042_CMD_DIS_MOUSE ; Disable Mouse
|
||||||
out i8042_PS2_CTRL, al
|
out i8042_PS2_CTRL, al
|
||||||
|
|
||||||
; Vider tout ce qui traîne
|
; Vider tout ce qui traîne
|
||||||
call ps2_flush_output
|
call ps2_flush_output
|
||||||
; Activer le port souris (AUX)
|
; Activer le port souris (AUX)
|
||||||
|
|
@ -283,6 +287,8 @@ 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
|
||||||
|
|
||||||
|
inc byte [BDA_MOUSE + mouse.blinker]
|
||||||
|
|
||||||
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]
|
||||||
|
|
@ -323,6 +329,32 @@ isr_mouse_handler:
|
||||||
.y_pos:
|
.y_pos:
|
||||||
sub [BDA_MOUSE + mouse.y], ax
|
sub [BDA_MOUSE + mouse.y], ax
|
||||||
|
|
||||||
|
; --- CLAMPING X ---
|
||||||
|
; Check minimum (0)
|
||||||
|
cmp word [fs:BDA_MOUSE + mouse.x], 0
|
||||||
|
jge .check_x_max
|
||||||
|
mov word [fs:BDA_MOUSE + mouse.x], 0
|
||||||
|
jmp .done_x
|
||||||
|
.check_x_max:
|
||||||
|
; Check maximum (e.g., 639 for graphics, or pixel width)
|
||||||
|
cmp word [fs:BDA_MOUSE + mouse.x], GFX_WIDTH-1 ; Replace with variable or define
|
||||||
|
jle .done_x
|
||||||
|
mov word [fs:BDA_MOUSE + mouse.x], GFX_WIDTH-1
|
||||||
|
.done_x:
|
||||||
|
|
||||||
|
; --- CLAMPING Y ---
|
||||||
|
; Check minimum (0)
|
||||||
|
cmp word [fs:BDA_MOUSE + mouse.y], 0
|
||||||
|
jge .check_y_max
|
||||||
|
mov word [fs:BDA_MOUSE + mouse.y], 0
|
||||||
|
jmp .done_y
|
||||||
|
.check_y_max:
|
||||||
|
; Check maximum
|
||||||
|
cmp word [fs:BDA_MOUSE + mouse.y], GFX_HEIGHT-1 ; Replace with variable or define
|
||||||
|
jle .done_y
|
||||||
|
mov word [fs:BDA_MOUSE + mouse.y], GFX_HEIGHT-1
|
||||||
|
.done_y:
|
||||||
|
|
||||||
; check si il y a un 4eme byte a traiter
|
; check si il y a un 4eme byte a traiter
|
||||||
mov al, [BDA_MOUSE + mouse.packetlen]
|
mov al, [BDA_MOUSE + mouse.packetlen]
|
||||||
cmp al,4
|
cmp al,4
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue