api change done
This commit is contained in:
parent
2cf3a817dd
commit
1a283222f7
7 changed files with 900 additions and 356 deletions
|
|
@ -27,25 +27,26 @@
|
|||
; Si une ROM est détectée, le code de la ROM sera appelé.
|
||||
; ---------------------------------------------------------------------------
|
||||
setup_load_rom:
|
||||
mov bx, 0xC000
|
||||
.scanloop:
|
||||
mov ds, bx
|
||||
cmp word[0x0000],0xAA55 ; ROM signature
|
||||
jne .norom
|
||||
mov bx, 0xC000
|
||||
|
||||
; appel le code (en 0x0003) de la ROM
|
||||
push cs
|
||||
push word .norom ; address de retour
|
||||
.scanloop:
|
||||
mov ds, bx
|
||||
cmp word[0x0000],0xAA55 ; ROM signature
|
||||
jne .norom
|
||||
|
||||
push ds
|
||||
push 0x0003
|
||||
retf ; call far ds:0x0003
|
||||
.norom:
|
||||
add bx, 0x80 ; add 2kb
|
||||
cmp bx, 0xE000
|
||||
jbe .scanloop
|
||||
.end:
|
||||
ret
|
||||
; appel le code (en 0x0003) de la ROM
|
||||
push cs
|
||||
push word .norom ; address de retour
|
||||
|
||||
push ds
|
||||
push 0x0003
|
||||
retf ; call far ds:0x0003
|
||||
.norom:
|
||||
add bx, 0x80 ; add 2kb
|
||||
cmp bx, 0xE000
|
||||
jbe .scanloop
|
||||
.end:
|
||||
ret
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Test si le vecteur INT 10h à été modifié (par la ROM)
|
||||
|
|
@ -54,47 +55,48 @@ setup_load_rom:
|
|||
; été chargée.
|
||||
; ---------------------------------------------------------------------------
|
||||
setup_check_vga:
|
||||
; vérification de l'offset 0x0000:0x0040 qui DOIT etre différent de @default_isr
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
; Lire INT10: offset+segment depuis 0000:0040
|
||||
mov bx, [es:0x0040] ; BX = offset INT10
|
||||
mov cx, [es:0x0042] ; CX = segment INT10
|
||||
mov ax, cs
|
||||
; vérification de l'offset 0x0000:0x0040 qui DOIT etre différent de @default_isr
|
||||
xor ax,ax
|
||||
mov es,ax
|
||||
; Lire INT10: offset+segment depuis 0000:0040
|
||||
mov bx, [es:0x0040] ; BX = offset INT10
|
||||
mov cx, [es:0x0042] ; CX = segment INT10
|
||||
mov ax, cs
|
||||
|
||||
; Comparer avec default_isr (offset) et CS (segment)
|
||||
mov dx, default_isr ; DX = offset default_isr (dans notre CS)
|
||||
cmp bx, dx
|
||||
jne .init_ok ; vecteur different, bios initialisé
|
||||
cmp cx, ax
|
||||
jne .init_ok
|
||||
; Comparer avec default_isr (offset) et CS (segment)
|
||||
mov dx, default_isr ; DX = offset default_isr (dans notre CS)
|
||||
cmp bx, dx
|
||||
jne .init_ok ; vecteur different, bios initialisé
|
||||
cmp cx, ax
|
||||
jne .init_ok
|
||||
|
||||
mov ax,cs ; vecteur identique, sans doute pas d'initialisation
|
||||
mov ds,ax
|
||||
.init_ok:
|
||||
ret
|
||||
mov ax,cs ; vecteur identique, sans doute pas d'initialisation
|
||||
mov ds,ax
|
||||
.init_ok:
|
||||
ret
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; IVT install (8088, mode réel) - remplit les 256 vecteurs avec un handler IRET
|
||||
; ---------------------------------------------------------------------------
|
||||
ivt_setup:
|
||||
; installation de la table d'interrupts
|
||||
xor ax, ax
|
||||
mov es, ax ; ES = 0000h -> base IVT
|
||||
xor di, di ; DI = 0000h -> offset IVT
|
||||
; installation de la table d'interrupts
|
||||
xor ax, ax
|
||||
mov es, ax ; ES = 0000h -> base IVT
|
||||
xor di, di ; DI = 0000h -> offset IVT
|
||||
|
||||
mov ax, default_isr ; offset du handler
|
||||
mov dx, cs ; segment du handler (ROM)
|
||||
mov ax, default_isr ; offset du handler
|
||||
mov dx, cs ; segment du handler (ROM)
|
||||
|
||||
mov cx, 256 ; 256 vecteurs
|
||||
.fill:
|
||||
stosw ; write offset (AX) -> [ES:DI], DI += 2
|
||||
xchg ax, dx ; AX = segment, DX = offset
|
||||
stosw ; write segment (AX) -> [ES:DI], DI += 2
|
||||
xchg ax, dx ; AX = offset, DX = segment
|
||||
loop .fill
|
||||
; fin de la table d'interrupt
|
||||
ret
|
||||
mov cx, 256 ; 256 vecteurs
|
||||
|
||||
.fill:
|
||||
stosw ; write offset (AX) -> [ES:DI], DI += 2
|
||||
xchg ax, dx ; AX = segment, DX = offset
|
||||
stosw ; write segment (AX) -> [ES:DI], DI += 2
|
||||
xchg ax, dx ; AX = offset, DX = segment
|
||||
loop .fill
|
||||
; fin de la table d'interrupt
|
||||
ret
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; IVT install (8088, mode réel) - installe un handler a une interrupt calculée
|
||||
|
|
@ -104,30 +106,30 @@ ivt_setup:
|
|||
; bx = offset handler
|
||||
; ---------------------------------------------------------------------------
|
||||
ivt_setvector:
|
||||
push es
|
||||
push di
|
||||
push es
|
||||
push di
|
||||
|
||||
shl ax,2 ; ax=id *4
|
||||
mov di,ax
|
||||
shl ax,2 ; ax=id *4
|
||||
mov di,ax
|
||||
|
||||
xor ax,ax
|
||||
mov es, ax ; ES = 0000h -> base IVT
|
||||
xor ax,ax
|
||||
mov es, ax ; ES = 0000h -> base IVT
|
||||
|
||||
mov ax, bx ; offset du handler
|
||||
cli
|
||||
stosw ; write offset (AX) -> [ES:DI], DI += 2
|
||||
xchg ax, dx ; AX = segment, DX = offset
|
||||
stosw ; write segment (AX) -> [ES:DI], DI += 2
|
||||
sti
|
||||
mov ax, bx ; offset du handler
|
||||
cli
|
||||
stosw ; write offset (AX) -> [ES:DI], DI += 2
|
||||
xchg ax, dx ; AX = segment, DX = offset
|
||||
stosw ; write segment (AX) -> [ES:DI], DI += 2
|
||||
sti
|
||||
|
||||
pop di
|
||||
pop es
|
||||
ret
|
||||
pop di
|
||||
pop es
|
||||
ret
|
||||
|
||||
io_wait:
|
||||
xor al,al
|
||||
out 0x80,al
|
||||
ret
|
||||
xor al,al
|
||||
out 0x80,al
|
||||
ret
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Initialise les PIC 8259 (PC/AT):
|
||||
|
|
@ -137,39 +139,39 @@ io_wait:
|
|||
; https://wiki.nox-rhea.org/back2root/ibm-pc-ms-dos/hardware/8259
|
||||
; ---------------------------------------------------------------------------
|
||||
pic_init:
|
||||
cli
|
||||
push ax
|
||||
cli
|
||||
push ax
|
||||
|
||||
; force un End Of Interrupt sur les 2 PIC
|
||||
mov al, 0x20
|
||||
out i8259_SLAVE_CMD, al ; EOI PIC esclave
|
||||
out i8259_MASTER_CMD, al ; EOI PIC maître
|
||||
; force un End Of Interrupt sur les 2 PIC
|
||||
mov al, 0x20
|
||||
out i8259_SLAVE_CMD, al ; EOI PIC esclave
|
||||
out i8259_MASTER_CMD, al ; EOI PIC maître
|
||||
|
||||
; starts the initialization sequence (in cascade mode)
|
||||
mov al, ICW1_INIT | ICW1_ICW4
|
||||
out i8259_MASTER_CMD, al
|
||||
out i8259_SLAVE_CMD, al
|
||||
; starts the initialization sequence (in cascade mode)
|
||||
mov al, ICW1_INIT | ICW1_ICW4
|
||||
out i8259_MASTER_CMD, al
|
||||
out i8259_SLAVE_CMD, al
|
||||
|
||||
mov al, i8259_MASTER_INT
|
||||
out i8259_MASTER_DATA, al ; ICW2: Master PIC vector offset
|
||||
mov al, i8259_SLAVE_INT
|
||||
out i8259_SLAVE_DATA, al ; ICW2: Slave PIC vector offset
|
||||
mov al, i8259_MASTER_INT
|
||||
out i8259_MASTER_DATA, al ; ICW2: Master PIC vector offset
|
||||
mov al, i8259_SLAVE_INT
|
||||
out i8259_SLAVE_DATA, al ; ICW2: Slave PIC vector offset
|
||||
|
||||
; Master: cascade (IRQ2 => 1 << IRQ2 = 0x04)
|
||||
mov al, 0x04 ; master: slave on IRQ2: 0100b
|
||||
out i8259_MASTER_DATA, al ; ICW3: tell Master PIC that there is a slave PIC at IRQ2
|
||||
; Master: cascade (IRQ2 => 1 << IRQ2 = 0x04)
|
||||
mov al, 0x04 ; master: slave on IRQ2: 0100b
|
||||
out i8259_MASTER_DATA, al ; ICW3: tell Master PIC that there is a slave PIC at IRQ2
|
||||
|
||||
; Slave: numéro de ligne sur master (2)
|
||||
mov al, 0x02 ; slave: cascade identity 2
|
||||
out i8259_SLAVE_DATA, al ; ICW3: tell Slave PIC its cascade identity (0000 0010)
|
||||
; Slave: numéro de ligne sur master (2)
|
||||
mov al, 0x02 ; slave: cascade identity 2
|
||||
out i8259_SLAVE_DATA, al ; ICW3: tell Slave PIC its cascade identity (0000 0010)
|
||||
|
||||
; ICW4: 8086 mode
|
||||
mov al, ICW4_8086
|
||||
out i8259_MASTER_DATA, al
|
||||
out i8259_SLAVE_DATA, al
|
||||
; ICW4: 8086 mode
|
||||
mov al, ICW4_8086
|
||||
out i8259_MASTER_DATA, al
|
||||
out i8259_SLAVE_DATA, al
|
||||
|
||||
pop ax
|
||||
ret
|
||||
pop ax
|
||||
ret
|
||||
|
||||
; ------------------------------------------------------------------
|
||||
; set_irq_mask
|
||||
|
|
@ -177,54 +179,48 @@ pic_init:
|
|||
; AL = Numéro de l'IRQ (0 à 15)
|
||||
; ------------------------------------------------------------------
|
||||
pic_set_irq_mask:
|
||||
push bx
|
||||
push cx
|
||||
push dx
|
||||
push ax ; Sauvegarde AX pour récupérer AH plus tard
|
||||
pusha
|
||||
|
||||
mov cl, al ; CL = numéro d'IRQ
|
||||
; Par défaut, PIC Maître (Data port)
|
||||
mov dx, i8259_MASTER_DATA
|
||||
mov cl, al ; CL = numéro d'IRQ
|
||||
; Par défaut, PIC Maître (Data port)
|
||||
mov dx, i8259_MASTER_DATA
|
||||
|
||||
cmp cl, 8
|
||||
jl .is_master
|
||||
cmp cl, 8
|
||||
jl .is_master
|
||||
|
||||
; Si IRQ >= 8, on passe sur le PIC Esclave
|
||||
sub cl, 8 ; Ajuste l'index du bit (8-15 -> 0-7)
|
||||
; Port Data du PIC Esclave
|
||||
mov dx, i8259_SLAVE_DATA
|
||||
; Si IRQ >= 8, on passe sur le PIC Esclave
|
||||
sub cl, 8 ; Ajuste l'index du bit (8-15 -> 0-7)
|
||||
; Port Data du PIC Esclave
|
||||
mov dx, i8259_SLAVE_DATA
|
||||
|
||||
.is_master:
|
||||
; Préparation du masque de bit
|
||||
mov bl, 1
|
||||
shl bl, cl ; BL contient maintenant le bit correspondant (ex: IRQ 3 -> 00001000)
|
||||
; Préparation du masque de bit
|
||||
mov bl, 1
|
||||
shl bl, cl ; BL contient maintenant le bit correspondant (ex: IRQ 3 -> 00001000)
|
||||
|
||||
in al, dx ; Lire l'IMR actuel depuis le port (0x21 ou 0xA1)
|
||||
in al, dx ; Lire l'IMR actuel depuis le port (0x21 ou 0xA1)
|
||||
|
||||
test ah, ah ; AH est-il à 1 (Disable) ?
|
||||
jnz .do_disable
|
||||
test ah, ah ; AH est-il à 1 (Disable) ?
|
||||
jnz .do_disable
|
||||
|
||||
.do_enable:
|
||||
not bl ; Inverser le masque (ex: 11110111)
|
||||
and al, bl ; Mettre le bit à 0 (Unmask)
|
||||
jmp .write_back
|
||||
.do_enable:
|
||||
not bl ; Inverser le masque (ex: 11110111)
|
||||
and al, bl ; Mettre le bit à 0 (Unmask)
|
||||
jmp .write_back
|
||||
|
||||
.do_disable:
|
||||
or al, bl ; Mettre le bit à 1 (Mask)
|
||||
.do_disable:
|
||||
or al, bl ; Mettre le bit à 1 (Mask)
|
||||
|
||||
.write_back:
|
||||
out dx, al ; Écrire le nouveau masque dans l'IMR
|
||||
.write_back:
|
||||
out dx, al ; Écrire le nouveau masque dans l'IMR
|
||||
|
||||
pop ax ; Restaurer AX
|
||||
pop dx
|
||||
pop cx
|
||||
pop bx
|
||||
ret
|
||||
popa
|
||||
ret
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Handler par défaut: fait juste IRET
|
||||
; IMPORTANT: doit être FAR (appelé par le CPU via IVT), et terminer par IRET
|
||||
; ---------------------------------------------------------------------------
|
||||
default_isr:
|
||||
iret
|
||||
iret
|
||||
|
||||
|
|
|
|||
315
src/services/gui_window.asm
Normal file
315
src/services/gui_window.asm
Normal file
|
|
@ -0,0 +1,315 @@
|
|||
; =============================================================================
|
||||
; Project : Custom BIOS / ROM
|
||||
; File : gui_window.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/>.
|
||||
;
|
||||
; =============================================================================
|
||||
|
||||
%macro GUI 1-*
|
||||
; %1 est l'index de la fonction
|
||||
; On itère sur les arguments suivants en sens inverse (Convention C)
|
||||
|
||||
%rep %0 - 1 ; Répéter pour (Nombre d'args - 1)
|
||||
%rotate -1 ; Prend le dernier argument
|
||||
push %1 ; L'empile
|
||||
%endrep
|
||||
|
||||
%rotate -1 ; On revient au premier argument (l'index de fonction)
|
||||
call word [cs:graph_driver + ((%1)*2)]
|
||||
|
||||
; Nettoyage de la pile (Convention CDECL: l'appelant nettoie)
|
||||
; Chaque argument = 2 octets (1 word).
|
||||
add sp, (%0 - 1) * 2
|
||||
%endmacro
|
||||
|
||||
; ------------------------------------------------------------
|
||||
; TABLE DE SAUT (VECTEURS API)
|
||||
; Cette table doit être située au début du driver pour être
|
||||
; accessible par la GUI à des offsets fixes.
|
||||
; ------------------------------------------------------------
|
||||
%define WINDOW 0
|
||||
|
||||
; ------------------------------------------------------------
|
||||
; COMMENTAIRE SUR LA MÉTHODE D'APPEL
|
||||
;
|
||||
; GFX FUNCTION, Arg1, Arg2, Arg3
|
||||
;
|
||||
; GFX GFX_PUTPIXEL, 320, 100, 1
|
||||
;
|
||||
; Si vous changez le code du driver, tant que la table au début
|
||||
; ne change pas d'ordre, la GUI n'a pas besoin d'être recompilée.
|
||||
; ------------------------------------------------------------
|
||||
|
||||
gui_driver:
|
||||
dw draw_white
|
||||
|
||||
; =============================================================================
|
||||
; Fonction : draw_window
|
||||
; Description : Dessine une fenêtre style Mac System 1.0
|
||||
; Entrées (Pile) :
|
||||
; Arg1 : X (Word)
|
||||
; Arg2 : Y (Word)
|
||||
; Arg3 : Largeur (Word)
|
||||
; Arg4 : Hauteur (Word)
|
||||
; Arg5 : Pointeur vers titre (DS:Offset) (Word)
|
||||
; =============================================================================
|
||||
draw_window:
|
||||
push bp
|
||||
mov bp, sp
|
||||
|
||||
; --- Arguments ---
|
||||
%define .x word [bp+4]
|
||||
%define .y word [bp+6]
|
||||
%define .w word [bp+8]
|
||||
%define .h word [bp+10]
|
||||
%define .title word [bp+12]
|
||||
|
||||
pusha
|
||||
|
||||
; Variables locales (registres)
|
||||
; BX = x2, DX = y2
|
||||
|
||||
; ----------------------------------------------------
|
||||
; Ombre Portée (Drop Shadow)
|
||||
; ----------------------------------------------------
|
||||
; On dessine un rectangle noir décalé de +1,+1
|
||||
; x1+1, y1+1, x2+1, y2+1 -> NOIR
|
||||
mov ax, .x
|
||||
add ax, .w
|
||||
inc ax ; x2 + 1
|
||||
mov bx, ax ; BX = right limit
|
||||
|
||||
mov ax, .y
|
||||
add ax, .h
|
||||
inc ax ; y2 + 1
|
||||
mov dx, ax ; DX = bottom limit
|
||||
|
||||
mov ax, .x
|
||||
inc ax ; x1 + 1
|
||||
mov cx, .y
|
||||
inc cx ; y1 + 1
|
||||
|
||||
; Appel cga_fill_rect(x+1, y+1, x+w+1, y+h+1, BLACK)
|
||||
push word 0 ; Couleur 0 (Noir) pour l'ombre
|
||||
push dx ; y2
|
||||
push bx ; x2
|
||||
push cx ; y1
|
||||
push ax ; x1
|
||||
call cga_fill_rect
|
||||
add sp, 10
|
||||
|
||||
; ----------------------------------------------------
|
||||
; Corps de la Fenêtre (Main Body)
|
||||
; ----------------------------------------------------
|
||||
; On dessine un rectangle BLANC par dessus l'ombre
|
||||
; Cela crée le corps et "découpe" l'ombre pour ne laisser que le bord visible.
|
||||
|
||||
mov bx, .x
|
||||
add bx, .w ; BX = x2
|
||||
mov dx, .y
|
||||
add dx, .h ; DX = y2
|
||||
|
||||
; Remplissage Blanc (Corps)
|
||||
push word 1 ; Couleur 1 (Blanc)
|
||||
push dx
|
||||
push bx
|
||||
push word .y
|
||||
push word .x
|
||||
call cga_fill_rect
|
||||
add sp, 10
|
||||
|
||||
; Contour Noir (Border)
|
||||
push word 0 ; Couleur 0 (Noir)
|
||||
push dx
|
||||
push bx
|
||||
push word .y
|
||||
push word .x
|
||||
call cga_draw_rect
|
||||
add sp, 10
|
||||
|
||||
; ----------------------------------------------------
|
||||
; Barre de Titre (Title Bar)
|
||||
; ----------------------------------------------------
|
||||
; Hauteur standard ~18 pixels
|
||||
%define TITLE_HEIGHT 18
|
||||
|
||||
; Dessiner la ligne de séparation sous le titre
|
||||
mov cx, .y
|
||||
add cx, TITLE_HEIGHT
|
||||
|
||||
push word 0 ; Couleur Noir
|
||||
push cx ; Y de la ligne
|
||||
push bx ; X2 (largeur fenêtre)
|
||||
push word .x ; X1
|
||||
call cga_line_horizontal
|
||||
add sp, 8
|
||||
|
||||
; --- Pinstripes (Lignes horizontales) ---
|
||||
; On dessine une ligne noire une ligne sur deux à l'intérieur du titre
|
||||
; De y+1 à y+17, step 2
|
||||
|
||||
mov si, .y
|
||||
inc si ; Commence à y+1
|
||||
inc si ; Premier trait noir à y+2 (laissons 1px blanc sous le cadre haut)
|
||||
|
||||
mov di, .y
|
||||
add di, TITLE_HEIGHT
|
||||
dec di ; Fin juste avant la ligne de séparation
|
||||
|
||||
.pinstripe_loop:
|
||||
cmp si, di
|
||||
jae .pinstripe_done
|
||||
|
||||
push word 0 ; Noir
|
||||
push si ; Y courant
|
||||
push bx ; X2
|
||||
push word .x ; X1
|
||||
call cga_line_horizontal
|
||||
add sp, 8
|
||||
|
||||
add si, 2 ; Sauter 2 pixels (1 blanc, 1 noir)
|
||||
jmp .pinstripe_loop
|
||||
.pinstripe_done:
|
||||
|
||||
; ----------------------------------------------------
|
||||
; Le Carré de Fermeture (Close Box)
|
||||
; ----------------------------------------------------
|
||||
; Petit carré blanc à gauche avec contour noir
|
||||
; Position: x+6, y+4, taille 9x9 (exemple)
|
||||
|
||||
mov cx, .x
|
||||
add cx, 6 ; Box X1
|
||||
mov dx, .y
|
||||
add dx, 4 ; Box Y1
|
||||
|
||||
mov si, cx
|
||||
add si, 9 ; Box X2
|
||||
mov di, dx
|
||||
add di, 9 ; Box Y2
|
||||
|
||||
; Remplir en blanc (pour effacer les pinstripes)
|
||||
push word 1
|
||||
push di
|
||||
push si
|
||||
push dx
|
||||
push cx
|
||||
call cga_fill_rect
|
||||
add sp, 10
|
||||
|
||||
; Contour noir
|
||||
push word 0
|
||||
push di
|
||||
push si
|
||||
push dx
|
||||
push cx
|
||||
call cga_draw_rect
|
||||
add sp, 10
|
||||
|
||||
; ----------------------------------------------------
|
||||
; Le Titre (Texte)
|
||||
; ----------------------------------------------------
|
||||
; Il faut centrer le texte et effacer les lignes derrière lui.
|
||||
|
||||
; a) Calculer la longueur du titre
|
||||
mov si, .title
|
||||
xor cx, cx ; CX = longueur
|
||||
.strlen:
|
||||
lodsb
|
||||
test al, al
|
||||
jz .calc_center
|
||||
inc cx
|
||||
jmp .strlen
|
||||
|
||||
.calc_center:
|
||||
; b) Calcul X Centré = X_win + (W_win/2) - (Len * 8 / 2)
|
||||
mov ax, .w
|
||||
shr ax, 1 ; W / 2
|
||||
add ax, .x ; Centre de la fenêtre
|
||||
|
||||
mov bx, cx ; Sauver Len
|
||||
shl cx, 2 ; Len * 4 (car Len * 8 / 2 = Len * 4)
|
||||
sub ax, cx ; AX = X de départ du texte
|
||||
|
||||
; c) Effacer la zone derrière le texte (Remplir Blanc)
|
||||
; On ajoute un padding de 4px autour du texte
|
||||
mov cx, ax ; Text X start
|
||||
sub cx, 4 ; Padding gauche (Rect X1)
|
||||
|
||||
mov dx, .y
|
||||
add dx, 2 ; Rect Y1 (juste sous le cadre haut)
|
||||
|
||||
push bx ; Sauve longueur char pour plus tard
|
||||
|
||||
; Calcul Rect X2 = Text X + (Len * 8) + 4
|
||||
mov si, ax ; Start Text
|
||||
mov ax, bx ; Len
|
||||
shl ax, 3 ; Len * 8 (largeur pixel texte)
|
||||
add si, ax
|
||||
add si, 4 ; Padding droite (Rect X2)
|
||||
|
||||
mov di, .y
|
||||
add di, TITLE_HEIGHT
|
||||
dec di ; Rect Y2 (juste au dessus ligne séparation)
|
||||
|
||||
; Dessiner le rectangle blanc de masquage
|
||||
push word 1 ; Blanc
|
||||
push di ; Y2
|
||||
push si ; X2
|
||||
push dx ; Y1
|
||||
push cx ; X1
|
||||
call cga_fill_rect
|
||||
add sp, 10
|
||||
|
||||
pop bx ; Récupérer longueur
|
||||
|
||||
; d) Écrire le texte
|
||||
; Recalculer position X exacte (CX avait X1 du rect, on veut X1 + 4)
|
||||
add cx, 4
|
||||
|
||||
; GFX GOTOXY (X, Y) -> Y centré dans la barre de titre
|
||||
; Centre barre ~9px. Font 8px. Y = Win_Y + 5
|
||||
mov dx, .y
|
||||
add dx, 5
|
||||
|
||||
; Note: GFX GOTOXY utilise des arguments pile, attention à l'ordre API
|
||||
; On suppose que vous utilisez votre macro GFX ou appel direct
|
||||
|
||||
; GFX GOTOXY, cx, dx
|
||||
push dx ; Y
|
||||
push cx ; X
|
||||
push word 3 ; ID GOTOXY
|
||||
call cga_set_charpos ; Appel direct driver ou via vecteur
|
||||
add sp, 6
|
||||
|
||||
; Mode texte Noir sur Blanc (ou Transparent, car on a mis un fond blanc)
|
||||
; GFX TXT_MODE, GFX_TXT_BLACK
|
||||
push word 3 ; GFX_TXT_BLACK_ON_WHITE (ou transparent)
|
||||
push word 4 ; ID TXT_MODE
|
||||
call cga_set_writemode
|
||||
add sp, 4
|
||||
|
||||
; GFX WRITE, cs, title
|
||||
push word .title ; Offset
|
||||
push ds ; Segment (supposé DS, sinon passer le seg en arg)
|
||||
push word 6 ; ID WRITE
|
||||
call cga_write
|
||||
add sp, 6
|
||||
|
||||
popa
|
||||
leave
|
||||
ret
|
||||
Loading…
Reference in a new issue