Mouse interrupt handler + debug

This commit is contained in:
Frater 2026-01-29 13:46:35 +01:00
commit 4cf1a0b7a2
6 changed files with 389 additions and 235 deletions

View file

@ -20,158 +20,178 @@
;
; =============================================================================
bits 16
bits 16
; ---------------------------------------------------------------------------
;
; configuration du bios
;
; ---------------------------------------------------------------------------
%define DEBUG_PORT 0xe9 ; 0x402 ou 0xe9
%define DEBUG_PORT 0xe9 ; 0x402 ou 0xe9
; 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
bits 16
;%include "./common/chartable.asm"
;%include "./common/cursor.asm"
;%include "./common/chartable.asm"
;%include "./common/cursor.asm"
; definition du BDA
%include "./bda.asm"
%include "./bda.asm"
; %include "./services/macros.asm"
%include "./drivers/debug.asm"
%include "./drivers/gfx_cgam.asm"
%include "./drivers/mouse_ps2.asm"
%include "./drivers/keyboard_ps2.asm"
%include "./services/generic.asm"
; %include "./services/macros.asm"
%include "./common/debug_cga.asm"
%include "./drivers/gfx_cgam.asm"
%include "./drivers/mouse_ps2.asm"
%include "./drivers/keyboard_ps2.asm"
%include "./services/generic.asm"
err_vganok db 'VGA Not Initialized',0
err_vganok db 'VGA Not Initialized',0
cpt_txt db '0123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789',0
helloworld db 'Hello World !',0
centre db 'TEXTEAUCENTR',0
cpt_txt db '0123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789',0
helloworld db 'Hello World !',0
centre db 'TEXTEAUCENTR',0
reset:
cli
; il n'existe aucun 'stack' par défaut
mov ax, STACK_SEG
mov ss, ax
mov sp, 0xFFFE ; haut du segment (64ko de stack), mot-aligné
cld
cli
; il n'existe aucun 'stack' par défaut
mov ax, STACK_SEG
mov ss, ax
mov sp, 0xFFFE ; haut du segment (64ko de stack), mot-aligné
cld
; installé une table d'interruption "dummy"
call ivt_setup
call bda_setup
; installé une table d'interruption "dummy"
call ivt_setup
call bda_setup
; Install IRQ 0 : timer_isr
mov ax,cs
mov dx,ax
mov bx,timer_isr
mov ax,i8259_MASTER_INT
; Install IRQ 0 : timer_isr
mov ax,cs
mov dx,ax
mov bx,timer_isr
mov ax,i8259_MASTER_INT
call ivt_setvector
call ivt_setvector
; initialisation des PIC 8259A
call pic_init
; initialisation des PIC 8259A
call pic_init
; load Roms
call setup_load_rom
; load Roms
call setup_load_rom
; on vérifie que le BIOS VGA a installé une INT 10h
call setup_check_vga
; on vérifie que le BIOS VGA a installé une INT 10h
call setup_check_vga
; on initialise le mode texte 80x25 par défaut DEBUG
;mov ax, 0x0003
;int 10h
; enable IRQ 0
mov ah,IRQ_ENABLED
mov al,0
call pic_set_irq_mask
; enable IRQ 0
mov ah,IRQ_ENABLED
mov al,0
call pic_set_irq_mask
call kbd_init
sti
call kbd_init
sti
; on active le mode graphique
GFX_DRV GFX_INIT
; on active le mode graphique
GFX_DRV GFX_INIT
mov cx, 300
mov dx, 102
GFX_DRV GFX_GOTOXY
mov cx, 300
mov dx, 102
GFX_DRV GFX_GOTOXY
GFX_SET_WRTIE_MODE GFX_TXT_WHITE_TRANSPARENT
GFX_SET_WRTIE_MODE GFX_TXT_WHITE_TRANSPARENT
push cs
pop ds
mov si, centre
GFX_DRV GFX_WRITE
push cs
pop ds
mov si, centre
GFX_DRV GFX_WRITE
; call mouse_reset
call mouse_init
; call mouse_reset
call mouse_init
GFX_DRV GFX_CRS_UPDATE
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
mov dx,0
GFX_DRV GFX_GOTOXY
push cs
pop ds
mov si, cpt_txt
GFX_DRV GFX_WRITE
push cs
pop ds
mov si, cpt_txt
GFX_DRV GFX_WRITE
GFX_SET_WRTIE_MODE GFX_TXT_WHITE_TRANSPARENT
GFX_SET_WRTIE_MODE GFX_TXT_WHITE_TRANSPARENT
mov cx,8
mov dx,8
GFX_DRV GFX_GOTOXY
mov cx,8
mov dx,8
GFX_DRV GFX_GOTOXY
mov si, helloworld
GFX_DRV GFX_WRITE
mov si, helloworld
GFX_DRV GFX_WRITE
mov cx,8
mov dx,24
GFX_SET_WRTIE_MODE 0
mov cx,8
mov dx,24
GFX_SET_WRTIE_MODE 0
.loopshift:
GFX_DRV GFX_GOTOXY
mov si, helloworld
GFX_DRV GFX_WRITE
add dx,8
inc cx
cmp cx,16
jbe .loopshift
GFX_DRV GFX_GOTOXY
mov si, helloworld
GFX_DRV GFX_WRITE
add dx,8
inc cx
cmp cx,16
jbe .loopshift
mov ax,BDA_DATA_SEG
mov ds,ax
endless:
mov ax,BDA_DATA_SEG
mov ds,ax
mov ax,0
xor cx,cx
mov dx,180
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:
push ax
push ax
push fs
mov ax,BDA_DATA_SEG
mov fs,ax
push fs
mov ax,BDA_DATA_SEG
mov fs,ax
; inc byte [fs:BDA_TIMER]
mov al, PIC_EOI ; EOI master
out i8259_MASTER_CMD, al
pop fs
mov al, PIC_EOI ; EOI master
out i8259_MASTER_CMD, al
pop fs
pop ax
iret
pop ax
iret
; ------------------------------------------------------------------
; Padding jusqu'au reset vector
@ -181,16 +201,16 @@ times 0xFFF0 - ($ - $$) db 0xFF
; ------------------------------------------------------------------
; RESET VECTOR (exécuté par le CPU)
; ------------------------------------------------------------------
section .resetvect
section .resetvect
bits 16
global reset_vector
global reset_vector
reset_vector:
; code minimal au reset
jmp 0xF000:reset
; code minimal au reset
jmp 0xF000:reset
builddate:
db '06/01/2026'
times 16-($-$$) db 0 ; le stub tient dans 16 octets (ou moins)
db '06/01/2026'
times 16-($-$$) db 0 ; le stub tient dans 16 octets (ou moins)