widget bug fixing

This commit is contained in:
Frater 2026-02-22 23:52:33 +01:00
commit 36e72bb399
9 changed files with 374 additions and 628 deletions

View file

@ -1,274 +0,0 @@
; =============================================================================
; Project : Custom BIOS / ROM
; File : boot.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/>.
;
; =============================================================================
bits 16
; ---------------------------------------------------------------------------
;
; configuration du bios
;
; ---------------------------------------------------------------------------
; initial stack
%define STACK_SEG 0x0800 ; segment de base
%define GFX_DRIVERS 'CGA'
section .text
bits 16
%include "./common/chartable.asm"
%include "./common/cursor.asm"
%include "./common/patterns.asm"
%include "./common/generic.asm"
%include "./common/string.asm"
; definition du BDA
%include "./common/bda.asm"
; drivers
%if GFX_DRIVERS == 'VGA'
%include "./drivers/gfx_vga.asm"
%else
; default drivers
%include "./drivers/gfx_cgam.asm"
%endif
%include "./drivers/mouse_ps2.asm"
%include "./drivers/keyboard_ps2.asm"
%include "./common/debug_gfx.asm"
; GUI
%include "./gui/lib-api.asm"
; --- Données texte ---
str_quit db "Quitter", 0
str_hello db "Hello", 0
str_option1 db "option 1", 0
str_option2 db "option 2", 0
str_option3 db "option 3", 0
entrycode:
cli
mov ax, STACK_SEG ; creation du stack par défaut
mov ss, ax
mov sp, 0xFFFE ; haut du segment (64ko de stack), mot-aligné
cld
call ivt_setup ; configuration d'une table d'interruption "dummy"
call bda_setup ; initialisation du BDA
ISADBG ISA_GREEN, 0x01
; Install IRQ 0 : timer_isr
mov ax,cs
mov dx,ax
mov bx,timer_isr
mov ax,i8259_MASTER_INT
call ivt_setvector
ISADBG ISA_GREEN, 0x02
; initialisation des PIC 8259A
call pic_init
ISADBG ISA_GREEN, 0x04
; load Roms
call setup_load_rom
ISADBG ISA_GREEN, 0x08
; on vérifie que le BIOS VGA a installé une INT 10h
call setup_check_vga
ISADBG ISA_GREEN, 0x10
; enable IRQ 0
mov ah,IRQ_ENABLED
mov al,0
call pic_set_irq_mask
call kbd_init
sti
DEBUG 0xFADE
ISADBG ISA_GREEN, 0x20
; on active le mode graphique
GFX INIT
ISADBG ISA_GREEN, 0xFF
; call mouse_reset
call mouse_init
GFX MOUSE_MOVE
GFX MOUSE_SHOW
ISADBG ISA_RED, 0x81
xor ax,ax
.loops:
call main_loop
nop
jmp .loops
; --- Callbacks (Fonctions appelées par le moteur) ---
on_click_quit:
hlt
jmp on_click_quit
ret
on_click_hello:
ret
%define .oldval word [bp-2]
%define .my_slider word [bp-4]
%define .value word [bp-6]
main_loop:
push bp
mov bp, sp
sub sp, 6
push cs
pop ds
DEBUG 1
ISADBG ISA_LEFT, 1
; Init du système GUI
call gui_init_system
DEBUG 2
ISADBG ISA_LEFT, 2
; --- CRÉATION DYNAMIQUE DES BOUTONS ---
; Créer Bouton 1 "QUITTER"
GUI OBJ_CREATE, OBJ_TYPE_BUTTON_ROUNDED, 10, 10, 80, 16
GUI OBJ_SET_TEXT, ax, cs, str_quit
; Créer Bouton 2 "HELLO"
GUI OBJ_CREATE, OBJ_TYPE_BUTTON_ROUNDED, 100, 50, 80, 16
GUI OBJ_SET_TEXT, ax, cs, str_hello
; Créer 3 checkbox "option"
GUI OBJ_CREATE, OBJ_TYPE_CHECKBOX, 200, 50, 100, 15
GUI OBJ_SET_TEXT, ax, cs, str_option1
GUI OBJ_CREATE, OBJ_TYPE_CHECKBOX, 200, 50+16, 100, 15
GUI OBJ_SET_TEXT, ax, cs, str_option2
GUI OBJ_CREATE, OBJ_TYPE_CHECKBOX, 200, 50+16*2, 100, 15
GUI OBJ_SET_TEXT, ax, cs, str_option3
DEBUG 3
ISADBG ISA_LEFT, 3
; Créer Slider (Drag)
GUI OBJ_CREATE, OBJ_TYPE_SLIDER, 10, 100, 150, 12
GUI OBJ_SET_MODE, ax, SLIDER_HORIZONTAL
GUI OBJ_SLIDER_SET_ATTR, ax, 10, 140, 10, 15
GUI OBJ_CREATE, OBJ_TYPE_SLIDER, 400, 10, 16, 150
mov .my_slider, ax
GUI OBJ_SET_MODE, .my_slider, SLIDER_VERTICAL
GUI OBJ_SLIDER_SET_ATTR, .my_slider, 0, 31, 0, 12
mov .oldval, 0x1256
mov .value, 0xFADE
DEBUG 4
ISADBG ISA_LEFT, 4
.loop:
call gui_process_all
GUI OBJ_GET_VAL, .my_slider
mov .value, ax
cmp ax,.oldval
je .loop
; debug
mov .oldval, ax
GFX RECTANGLE_FILL,0,148,50,166, PATTERN_WHITE
GFX GOTOXY, 8, 150
mov ax, .value
call print_word_hex
; end debug
; change palette...
;and ax, 0x00FF
;mov bh, 0x00
;mov bl, al
;mov ah, 0x0b
;mov al, 0x00
;int 0x10
mov dx, CRTC_COLOR_DATA
and ax, 0x001F
out dx, ax
jmp .loop
leave
ret
; -----------------------------------------------------------
; timer ISR (IRQ -> INT)
; -----------------------------------------------------------
timer_isr:
push ax
push fs
mov ax,SEG_BDA_CUSTOM
mov fs,ax
; exemple de fonctionnement:
; inc byte [fs:BDA_TIMER]
mov al, PIC_EOI ; EOI master
out i8259_MASTER_CMD, al
pop fs
pop ax
iret
; ------------------------------------------------------------------
; Padding jusqu'au reset vector
; ------------------------------------------------------------------
times 0xFFF0 - ($ - $$) db 0xFF
; ------------------------------------------------------------------
; RESET VECTOR (exécuté par le CPU)
; ------------------------------------------------------------------
section .resetvect
bits 16
global reset_vector
reset_vector:
; code minimal au reset
jmp 0xF000:entrycode
builddate:
db __DATE__
times 16-($-$$) db 0 ; le stub tient dans 16 octets (ou moins)

View file

@ -1,280 +0,0 @@
; =============================================================================
; Project : Custom BIOS / ROM
; File : boot.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/>.
;
; =============================================================================
bits 16
; ---------------------------------------------------------------------------
;
; configuration du bios
;
; ---------------------------------------------------------------------------
; initial stack
%define STACK_SEG 0x0800 ; segment de base
%define GFX_DRIVERS 'VGA'
%define DEBUGER_ENABLED
section .text
bits 16
%include "./common/chartable.asm"
%include "./common/cursor.asm"
%include "./common/patterns.asm"
%include "./common/generic.asm"
%include "./common/string.asm"
; definition du BDA
%include "./common/bda.asm"
; drivers
%if GFX_DRIVERS == 'VGA'
%include "./drivers/gfx_vga.asm"
%else
; default drivers
%include "./drivers/gfx_cgam.asm"
%endif
%include "./drivers/mouse_ps2.asm"
%include "./drivers/keyboard_ps2.asm"
%include "./common/debug_gfx.asm"
%include "./common/debug_txt.asm"
; GUI
%include "./gui/lib-api.asm"
; --- Données texte ---
str_quit db "Quitter", 0
str_hello db "Hello", 0
str_option1 db "option 1", 0
str_option2 db "option 2", 0
str_option3 db "option 3", 0
entrycode:
cli
mov ax, STACK_SEG ; creation du stack par défaut
mov ss, ax
mov sp, 0xFFFE ; haut du segment (64ko de stack), mot-aligné
cld
call ivt_setup ; configuration d'une table d'interruption "dummy"
call bda_setup ; initialisation du BDA
ISADBG ISA_GREEN, 1
; Install IRQ 0 : timer_isr
mov ax,cs
mov dx,ax
mov bx,timer_isr
mov ax,i8259_MASTER_INT
call ivt_setvector
; initialisation des PIC 8259A
call pic_init
; load Roms
call setup_load_rom
; on vérifie que le BIOS VGA a installé une INT 10h
call setup_check_vga
; enable IRQ 0
mov ah,IRQ_ENABLED
mov al,0
call pic_set_irq_mask
call kbd_init
sti
; on active le mode graphique
GFX INIT
call mouse_init
GFX MOUSE_SHOW
call main_loop
.loops:
hlt
jmp .loops
; --- Callbacks (Fonctions appelées par le moteur) ---
on_click_quit:
hlt
jmp on_click_quit
ret
on_click_hello:
ret
main_test:
; GFX RECTANGLE_FILL, 10,10,50,20, PATTERN_WHITE, 15, 0
; GUI OBJ_CREATE, OBJ_TYPE_CHECKBOX, 200, 50, 100, 15
mov ax, 200
add ax, 4
mov bx, 50
; centrage vertical
mov cx, 15
sub cx, GUI_CHECKBOX_SIZE
shr cx, 1
add bx, cx ; bx = Y1 + (h/2)
mov cx, ax ; x
add cx, GUI_CHECKBOX_SIZE ; cx = X2
mov dx, bx
add dx, GUI_CHECKBOX_SIZE ; Y2
; Fond blanc + Bordure noire
GFX RECTANGLE_FILL, ax, bx, cx, dx, PATTERN_WHITE, 15, 0
GFX RECTANGLE, ax, bx, cx, dx, 0
; Dessin du X (Diagonales)
add ax, 2 ; x1
add bx, 2 ; y1
sub cx, 2 ; x2
sub dx, 2 ; y2
; Optimisation : Utilisation de LINE au lieu de PUTPIXEL en boucle
; Diagonale 1 : (ax, bx) -> (cx, dx)
GFX LINE, ax, bx, cx, dx, 0
; Diagonale 2 : (ax, dx) -> (cx, bx)
GFX LINE, ax, dx, cx, bx, 0
ret
%define .oldval word [bp-2]
%define .my_slider word [bp-4]
%define .value word [bp-6]
main_loop:
push bp
mov bp, sp
sub sp, 6
push cs
pop ds
; Init du système GUI
call gui_init_system
; --- CRÉATION DYNAMIQUE DES BOUTONS ---
; Créer Bouton 1 "QUITTER"
GUI OBJ_CREATE, OBJ_TYPE_BUTTON_ROUNDED, 10, 10, 80, 16
GUI OBJ_SET_TEXT, ax, cs, str_quit
; Créer Bouton 2 "HELLO"
GUI OBJ_CREATE, OBJ_TYPE_BUTTON_ROUNDED, 100, 50, 80, 16
GUI OBJ_SET_TEXT, ax, cs, str_hello
; Créer 3 checkbox "option"
GUI OBJ_CREATE, OBJ_TYPE_CHECKBOX, 200, 50, 100, 15
GUI OBJ_SET_TEXT, ax, cs, str_option1
GUI OBJ_CREATE, OBJ_TYPE_CHECKBOX, 200, 50+16, 100, 15
GUI OBJ_SET_TEXT, ax, cs, str_option2
GUI OBJ_CREATE, OBJ_TYPE_CHECKBOX, 200, 50+16*2, 100, 15
GUI OBJ_SET_TEXT, ax, cs, str_option3
; Créer Slider (Drag)
GUI OBJ_CREATE, OBJ_TYPE_SLIDER, 10, 100, 150, 12
GUI OBJ_SET_MODE, ax, SLIDER_HORIZONTAL
GUI OBJ_SLIDER_SET_ATTR, ax, 10, 140, 10, 15
GUI OBJ_CREATE, OBJ_TYPE_SLIDER, 400, 10, 16, 150
mov .my_slider, ax
GUI OBJ_SET_MODE, .my_slider, SLIDER_VERTICAL
GUI OBJ_SLIDER_SET_ATTR, .my_slider, 0, 31, 0, 12
mov .oldval, 0x1256
mov .value, 0xFADE
.loop:
call gui_process_all
GUI OBJ_GET_VAL, .my_slider
mov .value, ax
cmp ax,.oldval
je .loop
; debug
;mov .oldval, ax
;GFX RECTANGLE_FILL,0,148,50,166, PATTERN_WHITE
;GFX GOTOXY, 8, 150
;mov ax, .value
;call print_word_hex
; end debug
; change palette...
;and ax, 0x00FF
;mov bh, 0x00
;mov bl, al
;mov ah, 0x0b
;mov al, 0x00
;int 0x10
mov dx, CRTC_COLOR_DATA
and ax, 0x001F
out dx, ax
jmp .loop
leave
ret
; -----------------------------------------------------------
; timer ISR (IRQ -> INT)
; -----------------------------------------------------------
timer_isr:
push ax
push fs
mov ax,SEG_BDA_CUSTOM
mov fs,ax
; exemple de fonctionnement:
; inc byte [fs:BDA_TIMER]
mov al, PIC_EOI ; EOI master
out i8259_MASTER_CMD, al
pop fs
pop ax
iret
; ------------------------------------------------------------------
; Padding jusqu'au reset vector
; ------------------------------------------------------------------
times 0xFFF0 - ($ - $$) db 0xFF
; ------------------------------------------------------------------
; RESET VECTOR (exécuté par le CPU)
; ------------------------------------------------------------------
section .resetvect
bits 16
global reset_vector
reset_vector:
; code minimal au reset
jmp 0xF000:entrycode
builddate:
db __DATE__
times 16-($-$$) db 0 ; le stub tient dans 16 octets (ou moins)

View file

@ -19,4 +19,264 @@
; along with this program. If not, see <https://www.gnu.org/licenses/>. ; along with this program. If not, see <https://www.gnu.org/licenses/>.
; ;
; ============================================================================= ; =============================================================================
%include "./boot-vga.asm"
bits 16
; ---------------------------------------------------------------------------
;
; configuration du bios
;
; ---------------------------------------------------------------------------
; initial stack
%define STACK_SEG 0x0800 ; segment de base
; pilote graphique de base: CGA, VGA
%define GFX_DRIVERS 'VGA'
%define DEBUGER_ENABLED
section .text
bits 16
%include "./common/chartable.asm"
%include "./common/cursor.asm"
%include "./common/patterns.asm"
%include "./common/generic.asm"
%include "./common/string.asm"
; definition du BDA
%include "./common/bda.asm"
; drivers
%if GFX_DRIVERS == 'VGA'
%include "./drivers/gfx_vga.asm"
%else
; default drivers
%include "./drivers/gfx_cgam.asm"
%endif
%include "./drivers/mouse_ps2.asm"
%include "./drivers/keyboard_ps2.asm"
%include "./common/debug_gfx.asm"
%include "./common/debug_txt.asm"
; GUI
%include "./gui/lib-api.asm"
; --- Données texte ---
str_quit db "Quitter", 0
str_hello db "Hello", 0
str_option1 db "option 1", 0
str_option2 db "option 2", 0
str_option3 db "option 3", 0
entrycode:
cli
mov ax, STACK_SEG ; creation du stack par défaut
mov ss, ax
mov sp, 0xFFFE ; haut du segment (64ko de stack), mot-aligné
cld
call ivt_setup ; configuration d'une table d'interruption "dummy"
call bda_setup ; initialisation du BDA
ISADBG ISA_GREEN, 1
; Install IRQ 0 : timer_isr
mov ax,cs
mov dx,ax
mov bx,timer_isr
mov ax,i8259_MASTER_INT
call ivt_setvector
; initialisation des PIC 8259A
call pic_init
; load Roms
call setup_load_rom
; on vérifie que le BIOS VGA a installé une INT 10h
call setup_check_vga
; enable IRQ 0
mov ah,IRQ_ENABLED
mov al,0
call pic_set_irq_mask
call kbd_init
sti
; on active le mode graphique
GFX INIT
call mouse_init
GFX MOUSE_SHOW
call main_loop
.loops:
hlt
jmp .loops
; --- Callbacks (Fonctions appelées par le moteur) ---
on_click_quit:
hlt
jmp on_click_quit
ret
on_click_hello:
ret
main_test:
; GFX RECTANGLE_FILL, 10,10,50,20, PATTERN_WHITE, 15, 0
; GUI OBJ_CREATE, OBJ_TYPE_CHECKBOX, 200, 50, 100, 15
mov ax, 200
add ax, 4
mov bx, 50
; centrage vertical
mov cx, 15
sub cx, GUI_CHECKBOX_SIZE
shr cx, 1
add bx, cx ; bx = Y1 + (h/2)
mov cx, ax ; x
add cx, GUI_CHECKBOX_SIZE ; cx = X2
mov dx, bx
add dx, GUI_CHECKBOX_SIZE ; Y2
; Fond blanc + Bordure noire
GFX RECTANGLE_FILL, ax, bx, cx, dx, PATTERN_WHITE, 15, 0
GFX RECTANGLE, ax, bx, cx, dx, 0
; Dessin du X (Diagonales)
add ax, 2 ; x1
add bx, 2 ; y1
sub cx, 2 ; x2
sub dx, 2 ; y2
; Optimisation : Utilisation de LINE au lieu de PUTPIXEL en boucle
; Diagonale 1 : (ax, bx) -> (cx, dx)
GFX LINE, ax, bx, cx, dx, 0
; Diagonale 2 : (ax, dx) -> (cx, bx)
GFX LINE, ax, dx, cx, bx, 0
ret
%define .oldval word [bp-2]
%define .my_slider word [bp-4]
%define .value word [bp-6]
main_loop:
push bp
mov bp, sp
sub sp, 6
push cs
pop ds
; Init du système GUI
call gui_init_system
; --- CRÉATION DYNAMIQUE DES BOUTONS ---
; Créer Bouton 1 "QUITTER"
GUI OBJ_CREATE, OBJ_TYPE_BUTTON_ROUNDED, 10, 10, 80, 16
GUI OBJ_SET_TEXT, ax, cs, str_quit
; Créer Bouton 2 "HELLO"
GUI OBJ_CREATE, OBJ_TYPE_BUTTON_ROUNDED, 100, 50, 80, 16
GUI OBJ_SET_TEXT, ax, cs, str_hello
; Créer 3 checkbox "option"
GUI OBJ_CREATE, OBJ_TYPE_CHECKBOX, 200, 50, 100, 15
GUI OBJ_SET_TEXT, ax, cs, str_option1
GUI OBJ_CREATE, OBJ_TYPE_CHECKBOX, 200, 50+16, 100, 15
GUI OBJ_SET_TEXT, ax, cs, str_option2
GUI OBJ_CREATE, OBJ_TYPE_CHECKBOX, 200, 50+16*2, 100, 15
GUI OBJ_SET_TEXT, ax, cs, str_option3
; Créer Slider (Drag)
GUI OBJ_CREATE, OBJ_TYPE_SLIDER, 10, 100, 150, 12
GUI OBJ_SET_MODE, ax, SLIDER_HORIZONTAL
GUI OBJ_SLIDER_SET_ATTR, ax, 10, 140, 10, 15
GUI OBJ_CREATE, OBJ_TYPE_SLIDER, 400, 10, 16, 150
mov .my_slider, ax
GUI OBJ_SET_MODE, .my_slider, SLIDER_VERTICAL
GUI OBJ_SLIDER_SET_ATTR, .my_slider, 0, 31, 0, 12
mov .oldval, 0x1256
mov .value, 0xFADE
.loop:
call gui_process_all
GUI OBJ_GET_VAL, .my_slider
mov .value, ax
cmp ax,.oldval
je .loop
; debug
;mov .oldval, ax
;GFX RECTANGLE_FILL,0,148,50,166, PATTERN_WHITE
;GFX GOTOXY, 8, 150
;mov ax, .value
;call print_word_hex
; end debug
; change palette...
;and ax, 0x00FF
;mov bh, 0x00
;mov bl, al
;mov ah, 0x0b
;mov al, 0x00
;int 0x10
mov dx, CRTC_COLOR_DATA
and ax, 0x001F
out dx, ax
jmp .loop
leave
ret
; -----------------------------------------------------------
; timer ISR (IRQ -> INT)
; -----------------------------------------------------------
timer_isr:
push ax
push fs
mov ax,SEG_BDA_CUSTOM
mov fs,ax
; exemple de fonctionnement:
; inc byte [fs:BDA_TIMER]
mov al, PIC_EOI ; EOI master
out i8259_MASTER_CMD, al
pop fs
pop ax
iret
; ------------------------------------------------------------------
; Padding jusqu'au reset vector
; ------------------------------------------------------------------
times 0xFFF0 - ($ - $$) db 0xFF
; ------------------------------------------------------------------
; RESET VECTOR (exécuté par le CPU)
; ------------------------------------------------------------------
section .resetvect
bits 16
global reset_vector
reset_vector:
; code minimal au reset
jmp 0xF000:entrycode
builddate:
db __DATE__
times 16-($-$$) db 0 ; le stub tient dans 16 octets (ou moins)

View file

@ -24,9 +24,9 @@
; https://wiki.nox-rhea.org/back2root/ibm-pc-ms-dos/hardware/informations/bios_data_area ; https://wiki.nox-rhea.org/back2root/ibm-pc-ms-dos/hardware/informations/bios_data_area
; ;
%define BDA_SEGMENT 0x0040 ; segment BDA (historically) %define SEG_BDA 0x0040 ; segment BDA (historically)
%define SEG_BDA_CUSTOM 0x0050 ; custom data (mouse, gfx cursor, etc..) %define SEG_BDA_CUSTOM 0x0050 ; custom data (mouse, gfx cursor, etc..)
%define BDA_GUI_WIDGET 0x0070 ; Segment de données UI (Safe: après Stack, avant Heap) %define SEG_GUI 0x0070 ; Segment de données UI (Safe: après Stack, avant Heap)
%define PTR_MOUSE 0x0000 %define PTR_MOUSE 0x0000
%define PTR_GFX (PTR_MOUSE + mouse_size) %define PTR_GFX (PTR_MOUSE + mouse_size)

View file

@ -39,20 +39,20 @@ strcpy:
%undef .src_seg %undef .src_seg
%undef .src_ofs %undef .src_ofs
; ----------------------------------------------------------------------------- ; -----------------------------------------------------------------------------
; strlen ; strlen
; Calcule la longueur d'une chaine [es:di] ; Calcule la longueur d'une chaine [es:di]
; Out: CX = Length ; Out: AX = Length
; ----------------------------------------------------------------------------- ; -----------------------------------------------------------------------------
%define .str_seg word [bp+4] %define .str_seg word [bp+4]
%define .str_ofs word [bp+6] %define .str_ofs word [bp+6]
strlen: strlen:
push bp push bp
mov bp, sp mov bp, sp
push ax push ax
push es push es
push di push di
xor cx, cx xor cx, cx
mov ax, .str_seg mov ax, .str_seg
mov es, ax mov es, ax
@ -68,7 +68,7 @@ strlen:
.done: .done:
pop di pop di
pop es pop es
pop ax pop ax
leave leave
ret ret
%undef .str_seg %undef .str_seg

View file

@ -121,8 +121,6 @@ themes:
db 0,4,12,15 ; HELL db 0,4,12,15 ; HELL
db 0,3,11,15 ; Hi Sky db 0,3,11,15 ; Hi Sky
; ------------------------------------------------------------ ; ------------------------------------------------------------
; dummy function ; dummy function
; ;
@ -151,6 +149,7 @@ vga_init:
PATTERN_PTR PATTERN_GRAY_LIGHT PATTERN_PTR PATTERN_GRAY_LIGHT
mov bl, 15 mov bl, 15
call vga_background call vga_background
ret ret
; ------------------------------------------------------------ ; ------------------------------------------------------------
@ -289,8 +288,9 @@ vga_set_writemode:
pop ax pop ax
pop fs pop fs
leave leave
ret
%undef .mode %undef .mode
ret
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; gfx_set_charpos (x,y) ; gfx_set_charpos (x,y)
@ -330,10 +330,10 @@ vga_set_charpos:
popa popa
leave leave
ret
; clean defs ; clean defs
%undef .x %undef .x
%undef .y %undef .y
ret
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; vga_putc_unalign (car) ; vga_putc_unalign (car)
@ -472,10 +472,10 @@ vga_putc:
pop gs pop gs
popa popa
leave leave
ret
; clean defs ; clean defs
%undef .cpt %undef .cpt
%undef .glyph_row %undef .glyph_row
ret
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; write string from [DS:SI] to screen ; write string from [DS:SI] to screen
@ -499,16 +499,16 @@ vga_write:
je .done je .done
push ax push ax
call vga_putc call vga_putc
; pop ax pop ax
jmp .loops jmp .loops
.done: .done:
pop ds pop ds
pop ax pop ax
leave leave
ret
%undef .txt_seg %undef .txt_seg
%undef .txt_ofs %undef .txt_ofs
ret
; ------------------------------------------------------------ ; ------------------------------------------------------------
; vga_line (x1, y1, x2, y2, color) ; vga_line (x1, y1, x2, y2, color)
@ -577,13 +577,13 @@ vga_line:
call vga_mouse_show call vga_mouse_show
popa popa
leave leave
ret
; clean defs ; clean defs
%undef .x1 %undef .x1
%undef .y1 %undef .y1
%undef .x2 %undef .x2
%undef .y2 %undef .y2
%undef .color %undef .color
ret
%ifdef ____CLASSIC_LINE_____ %ifdef ____CLASSIC_LINE_____
; ------------------------------------------------------------ ; ------------------------------------------------------------
@ -709,7 +709,7 @@ vga_line_bresenham:
pop es pop es
popa popa
leave leave
ret ; clean defs
%undef .x1 %undef .x1
%undef .y1 %undef .y1
%undef .x2 %undef .x2
@ -721,7 +721,7 @@ vga_line_bresenham:
%undef _sy %undef _sy
%undef _err %undef _err
%undef _e2 %undef _e2
; clean defs ret
%endif %endif
; ------------------------------------------------------------ ; ------------------------------------------------------------
@ -902,7 +902,6 @@ vga_line_fast:
pop es pop es
popa popa
leave leave
ret
; clean defs ; clean defs
%undef .x1 %undef .x1
%undef .y1 %undef .y1
@ -914,6 +913,7 @@ vga_line_fast:
%undef _err %undef _err
%undef _sy_offset %undef _sy_offset
%undef _count %undef _count
ret
; ------------------------------------------------------------ ; ------------------------------------------------------------
; vga_line_horizontal (y, x1, x2, color) ; vga_line_horizontal (y, x1, x2, color)
@ -1042,12 +1042,12 @@ vga_line_horizontal:
pop es pop es
popa popa
leave leave
ret
; clean defs ; clean defs
%undef .y %undef .y
%undef .x1 %undef .x1
%undef .x2 %undef .x2
%undef .color %undef .color
ret
; ------------------------------------------------------------ ; ------------------------------------------------------------
; vga_line_vertical (x, y1, y2, color) ; vga_line_vertical (x, y1, y2, color)
@ -1118,13 +1118,13 @@ vga_line_vertical:
pop es pop es
popa popa
leave ; Nettoie la variable locale (mov sp, bp / pop bp) leave ; Nettoie la variable locale (mov sp, bp / pop bp)
ret
; clean defs ; clean defs
%undef .x %undef .x
%undef .y1 %undef .y1
%undef .y2 %undef .y2
%undef .color %undef .color
%undef .height %undef .height
ret
; ------------------------------------------------------------ ; ------------------------------------------------------------
; vga_draw_rect ; vga_draw_rect
@ -1176,13 +1176,13 @@ vga_draw_rect:
call vga_mouse_show call vga_mouse_show
popa popa
leave leave
ret
; clean defs ; clean defs
%undef .x1 %undef .x1
%undef .y1 %undef .y1
%undef .x2 %undef .x2
%undef .y2 %undef .y2
%undef .color %undef .color
ret
; ------------------------------------------------------------ ; ------------------------------------------------------------
; cga_draw_rounded_frame ; cga_draw_rounded_frame
@ -1254,12 +1254,14 @@ vga_draw_rounded_frame:
popa popa
leave leave
ret
%undef .x1 %undef .x1
%undef .y1 %undef .y1
%undef .x2 %undef .x2
%undef .y2 %undef .y2
%undef .color %undef .color
%undef .coord1
%undef .coord2
ret
; ------------------------------------------------------------ ; ------------------------------------------------------------
; vga_fill_rect ; vga_fill_rect
@ -1282,6 +1284,8 @@ vga_fill_rect:
pusha pusha
push es push es
call vga_mouse_hide
; --- 1. Trier Y1 et Y2 --- ; --- 1. Trier Y1 et Y2 ---
mov ax, .y1 mov ax, .y1
mov bx, .y2 mov bx, .y2
@ -1414,11 +1418,11 @@ vga_fill_rect:
mov ax, 0xFF08 ; Reset Bit Mask mov ax, 0xFF08 ; Reset Bit Mask
out dx, ax out dx, ax
call vga_mouse_show
pop es pop es
popa popa
leave leave
ret
; Clean defs ; Clean defs
%undef .x1 %undef .x1
%undef .y1 %undef .y1
@ -1428,8 +1432,7 @@ vga_fill_rect:
%undef _left_mask %undef _left_mask
%undef _right_mask %undef _right_mask
%undef _width %undef _width
ret
; ------------------------------------------------------------ ; ------------------------------------------------------------
; vga_fill_rect_32 ; vga_fill_rect_32
@ -1456,10 +1459,12 @@ vga_fill_rect_32:
push es push es
push fs push fs
push cs call vga_mouse_hide
pop fs
; calcul de l'offset du pattern push cs
pop fs ; fs = CS
; calcul de l'offset du pattern
mov ax, .pat_id mov ax, .pat_id
shl ax, 3 shl ax, 3
add ax, pattern_8x8 add ax, pattern_8x8
@ -1656,12 +1661,12 @@ vga_fill_rect_32:
mov ax, 0x0001 ; Reset Enable Set/Reset mov ax, 0x0001 ; Reset Enable Set/Reset
out dx, ax out dx, ax
call vga_mouse_show
pop fs pop fs
pop es pop es
popad popad
leave leave
ret
; Clean defs ; Clean defs
%undef .x1 %undef .x1
%undef .y1 %undef .y1
@ -1673,6 +1678,8 @@ vga_fill_rect_32:
%undef _left_mask %undef _left_mask
%undef _right_mask %undef _right_mask
%undef _width %undef _width
ret
; ------------------------------------------------------------ ; ------------------------------------------------------------
; vga_putpixel ; vga_putpixel
%define .x word [bp+4] %define .x word [bp+4]
@ -1727,11 +1734,11 @@ vga_putpixel:
pop es pop es
popa popa
leave leave
ret
; clean defs ; clean defs
%undef .x %undef .x
%undef .y %undef .y
%undef .color %undef .color
ret
; ------------------------------------------------------------ ; ------------------------------------------------------------
; GESTION DU CURSEUR ; GESTION DU CURSEUR
@ -1805,6 +1812,7 @@ vga_mouse_cursor_move:
pusha pusha
push ds push ds
push es push es
cld
; BDA Data Segment ; BDA Data Segment
mov ax, SEG_BDA_CUSTOM mov ax, SEG_BDA_CUSTOM
@ -1837,6 +1845,7 @@ vga_cursor_savebg:
push es push es
mov ax, SEG_VIDEO mov ax, SEG_VIDEO
mov es, ax mov es, ax
cld
; Calculer l'adresse de départ (y * 80 + x / 8) ; Calculer l'adresse de départ (y * 80 + x / 8)
mov cx, [PTR_MOUSE + mouse.x] mov cx, [PTR_MOUSE + mouse.x]
@ -1889,6 +1898,7 @@ vga_cursor_restorebg:
push es push es
mov ax, SEG_VIDEO mov ax, SEG_VIDEO
mov es, ax mov es, ax
cld
mov di, [PTR_MOUSE + mouse.cur_addr_start] mov di, [PTR_MOUSE + mouse.cur_addr_start]
lea si, [PTR_MOUSE + mouse.bkg_buffer] lea si, [PTR_MOUSE + mouse.bkg_buffer]
@ -1945,7 +1955,7 @@ vga_cursor_restorebg:
; ============================================================ ; ============================================================
; vga_cursor_draw ; vga_cursor_draw
; Détruit: registres sauvegardés/restaurés (PUSHA/POPA) ; Détruit: registres sauvegardés/restaurés (PUSHAD/POPAD)
; ============================================================ ; ============================================================
%define BYTES_SHIFT 3 %define BYTES_SHIFT 3
vga_cursor_draw: vga_cursor_draw:
@ -1961,9 +1971,8 @@ vga_cursor_draw:
push ds push ds
push es push es
push gs push gs
; Note: pushad sauvegarde déjà tous les registres généraux (EAX...EDI)
cld ; Sécurité : Direction avant cld ; Sécurité : Direction avant
mov ax, SEG_BDA_CUSTOM mov ax, SEG_BDA_CUSTOM
mov ds, ax mov ds, ax
mov ax, SEG_VIDEO mov ax, SEG_VIDEO
@ -2110,7 +2119,7 @@ vga_cursor_draw:
pop ds pop ds
popad popad
leave leave
ret
%undef .height %undef .height
%undef .bit_ofs %undef .bit_ofs
%undef .mask %undef .mask
ret

View file

@ -137,10 +137,11 @@ endstruc
gui_api_slider_attr: gui_api_slider_attr:
push bp push bp
mov bp, sp mov bp, sp
push gs
push ax push ax
push .id ; ID mov ax, .id
call gui_get_widget_ptr call gui_get_widget_ptr_internal
jc .err jc .err
mov ax, .min mov ax, .min
@ -156,6 +157,7 @@ gui_api_slider_attr:
.err: .err:
pop ax pop ax
pop gs
leave leave
ret ret
%undef .id %undef .id
@ -169,16 +171,18 @@ gui_api_slider_attr:
gui_api_set_mode: gui_api_set_mode:
push bp push bp
mov bp, sp mov bp, sp
push gs
push ax push ax
push .id mov ax, .id
call gui_get_widget_ptr call gui_get_widget_ptr_internal
jc .err jc .err
mov ax, .mode mov ax, .mode
mov byte [gs:si + widget.attr_mode], al mov byte [gs:si + widget.attr_mode], al
.err: .err:
pop gs
pop ax pop ax
leave leave
ret ret
@ -194,10 +198,11 @@ gui_api_set_mode:
gui_api_set_text: gui_api_set_text:
push bp push bp
mov bp, sp mov bp, sp
push gs
push ax push ax
push .id mov ax, .id
call gui_get_widget_ptr call gui_get_widget_ptr_internal
jc .err jc .err
mov ax, .segmt mov ax, .segmt
@ -206,6 +211,7 @@ gui_api_set_text:
mov word [gs:si + widget.text_ofs], ax mov word [gs:si + widget.text_ofs], ax
.err: .err:
pop gs
pop ax pop ax
leave leave
ret ret
@ -231,7 +237,7 @@ gui_api_create:
mov bp, sp mov bp, sp
push gs push gs
mov ax, BDA_GUI_WIDGET mov ax, SEG_GUI
mov gs, ax mov gs, ax
call gui_alloc_widget ; Returns GS:SI call gui_alloc_widget ; Returns GS:SI
mov ax, -1 mov ax, -1
@ -275,9 +281,10 @@ gui_api_create:
gui_api_get_state: gui_api_get_state:
push bp push bp
mov bp, sp mov bp, sp
push gs
mov ax, .id ; ID mov ax, .id
call gui_get_widget_ptr call gui_get_widget_ptr_internal
jc .err jc .err
xor ax, ax xor ax, ax
@ -287,6 +294,7 @@ gui_api_get_state:
.err: .err:
mov ax, -1 mov ax, -1
.done: .done:
pop gs
leave leave
ret ret
%undef .id %undef .id
@ -300,9 +308,10 @@ gui_api_get_state:
gui_api_get_type: gui_api_get_type:
push bp push bp
mov bp, sp mov bp, sp
push gs
mov ax, .id ; ID mov ax,.id
call gui_get_widget_ptr call gui_get_widget_ptr_internal
jc .err jc .err
xor ax, ax xor ax, ax
@ -312,6 +321,7 @@ gui_api_get_type:
.err: .err:
mov ax, -1 mov ax, -1
.done: .done:
pop gs
leave leave
ret ret
%undef .id %undef .id
@ -325,9 +335,11 @@ gui_api_get_type:
gui_api_get_val: gui_api_get_val:
push bp push bp
mov bp, sp mov bp, sp
push gs
call gui_get_widget_ptr mov ax,.id
;jc .err call gui_get_widget_ptr_internal
jc .err
call gui_slider_update_value call gui_slider_update_value
mov ax, [gs:si + widget.attr_val] mov ax, [gs:si + widget.attr_val]
@ -336,6 +348,7 @@ gui_api_get_val:
.err: .err:
mov ax, -1 mov ax, -1
.done: .done:
pop gs
leave leave
ret ret
%undef .id %undef .id
@ -350,15 +363,17 @@ gui_api_get_val:
gui_api_set_val: gui_api_set_val:
push bp push bp
mov bp, sp mov bp, sp
push gs
mov ax, .id ; ID mov ax,.id
call gui_get_widget_ptr call gui_get_widget_ptr_internal
jc .err jc .err
mov ax, .val mov ax, .val
mov [gs:si + widget.thumb_pos], ax mov [gs:si + widget.thumb_pos], ax
.err: .err:
pop gs
leave leave
ret ret
%undef .id %undef .id
@ -374,9 +389,10 @@ gui_api_set_val:
gui_api_destroy: gui_api_destroy:
push bp push bp
mov bp, sp mov bp, sp
push gs
mov ax, .id ; ID mov ax,.id
call gui_get_widget_ptr call gui_get_widget_ptr_internal
jc .err jc .err
call gui_free_widget call gui_free_widget
@ -386,6 +402,7 @@ gui_api_destroy:
.err: .err:
mov ax, -1 mov ax, -1
.done: .done:
pop gs
leave leave
ret ret
%undef .id %undef .id
@ -393,17 +410,29 @@ gui_api_destroy:
; ----------------------------------------------------------------------------- ; -----------------------------------------------------------------------------
; gui_get_widget_ptr ; gui_get_widget_ptr
; Helper interne : Convertit ID en Pointeur ; Helper interne : Convertit ID en Pointeur
; In: ID
; Out: GS:SI = Ptr, CF=1 if error ; Out: GS:SI = Ptr, CF=1 if error
; -----------------------------------------------------------------------------
%define .id word [bp+4] %define .id word [bp+4]
; -----------------------------------------------------------------------------
gui_get_widget_ptr: gui_get_widget_ptr:
push bp push bp
mov bp, sp mov bp, sp
push ax push ax
push cx
mov ax, .id mov ax, .id
call gui_get_widget_ptr_internal
pop ax
leave
ret
%undef .id
; -----------------------------------------------------------------------------
; gui_get_widget_ptr_internal
; Helper interne : Convertit ax en Pointeur
; Out: GS:SI = Ptr, CF=1 if error
; -----------------------------------------------------------------------------
gui_get_widget_ptr_internal:
push cx
push dx
cmp ax, GUI_MAX_WIDGETS cmp ax, GUI_MAX_WIDGETS
jae .error jae .error
@ -412,7 +441,7 @@ gui_get_widget_ptr:
mul cx ; AX = Offset mul cx ; AX = Offset
mov si, ax mov si, ax
mov ax, BDA_GUI_WIDGET mov ax, SEG_GUI
mov gs, ax mov gs, ax
clc clc
@ -420,12 +449,9 @@ gui_get_widget_ptr:
.error: .error:
stc stc
.done: .done:
pop dx
pop cx pop cx
pop ax
leave
ret ret
%undef .id
; ============================================================================= ; =============================================================================
; SECTION : GESTION MÉMOIRE (ALLOCATION / LIBÉRATION) ; SECTION : GESTION MÉMOIRE (ALLOCATION / LIBÉRATION)
@ -434,7 +460,7 @@ gui_get_widget_ptr:
; ----------------------------------------------------------------------------- ; -----------------------------------------------------------------------------
; gui_init_system ; gui_init_system
; Initialise toute la mémoire des widgets à 0 (Libre) ; Initialise toute la mémoire des widgets à 0 (Libre)
; Entrée : DS doit pointer vers BDA_GUI_WIDGET ; Entrée : DS doit pointer vers SEG_GUI
; ----------------------------------------------------------------------------- ; -----------------------------------------------------------------------------
gui_init_system: gui_init_system:
push eax push eax
@ -442,7 +468,7 @@ gui_init_system:
push es push es
push di push di
mov ax, BDA_GUI_WIDGET mov ax, SEG_GUI
mov es, ax mov es, ax
cld cld
@ -468,8 +494,9 @@ gui_alloc_widget:
push ax push ax
push cx push cx
push bx push bx
push gs
mov ax, BDA_GUI_WIDGET mov ax, SEG_GUI
mov gs, ax mov gs, ax
mov si, 0 ; Début du pool mov si, 0 ; Début du pool
@ -496,9 +523,12 @@ gui_alloc_widget:
mov word [gs:si + widget.event_click], 0 mov word [gs:si + widget.event_click], 0
mov word [gs:si + widget.event_drag], 0 mov word [gs:si + widget.event_drag], 0
mov byte [gs:si + widget.thumb_pct], 10 ; 10% par défaut mov byte [gs:si + widget.thumb_pct], 10 ; 10% par défaut
mov word [gs:si + widget.thumb_pos], 0
mov word [gs:si + widget.attr_val], 0
clc ; Clear Carry Flag clc ; Clear Carry Flag
.done: .done:
pop gs
pop bx pop bx
pop cx pop cx
pop ax pop ax
@ -513,15 +543,15 @@ gui_free_widget:
push eax push eax
push es push es
mov ax, BDA_GUI_WIDGET mov ax, SEG_GUI
mov es, ax mov es, ax
cld cld
mov di, si mov di, si
mov cx, (widget_size) mov cx, (widget_size)
shr cx, 2 ; cx / 4 shr cx, 1 ; cx / 4
xor eax, eax xor ax, ax
rep stosd ; Remplit tout de 0 rep stosw ; Remplit tout de 0
; On efface le widget ; On efface le widget
mov byte [es:si + widget.state], GUI_STATE_FREE mov byte [es:si + widget.state], GUI_STATE_FREE

View file

@ -37,10 +37,11 @@
gui_draw_single_widget: gui_draw_single_widget:
pusha pusha
push es push es
push gs
GFX MOUSE_HIDE ; On cache la souris AVANT de commencer le dessin du widget GFX MOUSE_HIDE ; On cache la souris AVANT de commencer le dessin du widget
mov ax, BDA_GUI_WIDGET mov ax, SEG_GUI
mov gs, ax mov gs, ax
mov al, [gs:si + widget.state] mov al, [gs:si + widget.state]
@ -98,6 +99,7 @@ gui_draw_single_widget:
.done: .done:
GFX MOUSE_SHOW ; On réaffiche la souris APRES, capturant le widget fini GFX MOUSE_SHOW ; On réaffiche la souris APRES, capturant le widget fini
pop gs
pop es pop es
popa popa
ret ret
@ -447,7 +449,7 @@ draw_checkbox:
GFX RECTANGLE, ax, bx, cx, dx, 0 GFX RECTANGLE, ax, bx, cx, dx, 0
; Check if checked ; Check if checked
cmp word [gs:si + widget.thumb_pos], 0 cmp word [gs:si + widget.attr_val], 0
je .draw_label je .draw_label
push ax push ax
@ -509,7 +511,6 @@ draw_text:
; --- Centrage Texte --- ; --- Centrage Texte ---
mov es, [gs:si + widget.text_seg] mov es, [gs:si + widget.text_seg]
mov di, [gs:si + widget.text_ofs] mov di, [gs:si + widget.text_ofs]
xor cx, cx
push di push di
push es push es

View file

@ -16,7 +16,7 @@ gui_process_all:
push ds push ds
push gs push gs
mov ax, BDA_GUI_WIDGET mov ax, SEG_GUI
mov gs, ax mov gs, ax
; Charger l'état de la souris pour toute la passe ; Charger l'état de la souris pour toute la passe
@ -87,7 +87,7 @@ gui_update_logic:
mov ax, SEG_BDA_CUSTOM mov ax, SEG_BDA_CUSTOM
mov ds, ax mov ds, ax
mov ax, BDA_GUI_WIDGET mov ax, SEG_GUI
mov gs, ax mov gs, ax
mov al, byte [gs:si + widget.state] mov al, byte [gs:si + widget.state]
@ -520,7 +520,7 @@ gui_logic_checkbox:
jne .hover jne .hover
; Clic validé ! Toggle value ; Clic validé ! Toggle value
xor word [gs:si + widget.thumb_pos], 1 xor word [gs:si + widget.attr_val], 1
mov byte [gs:si + widget.oldstate], 255 ; Force redraw mov byte [gs:si + widget.oldstate], 255 ; Force redraw
mov al, 1 mov al, 1