feat: déclaration des imports et exports en utilisant les macros

This commit is contained in:
Nicolas Hordé 2007-03-14 11:18:58 +00:00
parent 4d03b78533
commit d920b35473
2 changed files with 405 additions and 431 deletions

View File

@ -1,49 +1,32 @@
db "biosprint",0 exporting
dw biosprint declare biosprinth
db "mbinit",0 declare biosprint
dw mbinit declare mbinit
db "mbcreate",0 declare mbcreate
dw mbcreate declare mbfree
db "mbfree",0 declare mbclean
dw mbfree declare mbresident
db "mbclean",0 declare mbnonresident
dw mbclean declare mbchown
db "mbresident",0 declare mballoc
dw mbresident declare mbfind
db "mbnonresident",0 declare mbfindsb
dw mbnonresident declare mbget
db "mbchown",0 declare mbloadfuncs
dw mbchown declare mbsearchfunc
db "mballoc",0 declare bioswaitkey
dw mballoc declare mbloadsection
db "mbfind",0 declare enableirq
dw mbfind declare enableirq
db "mbfindsb",0 declare readmaskirq
dw mbfindsb declare readirr
db "mbget",0 declare readisr
dw mbget declare seteoi
db "mbloadfuncs",0 declare enablea20
dw mbloadfuncs declare disablea20
db "mbsearchfunc",0 declare flatmode
dw mbsearchfunc ende
db "bioswaitkey",0
dw bioswaitkey
db "mbloadsection",0
dw mbloadsection
db "enableirq",0
dw enableirq
db "disableirq",0
dw enableirq
db "readmaskirq",0
dw readmaskirq
db "readirr",0
dw readirr
db "readisr",0
dw readisr
db "seteoi",0
dw seteoi
dd 0
include "8259a.asm" include "8259a.asm"
@ -97,31 +80,81 @@ PROC biosprint FAR
ret ret
endp biosprint endp biosprint
;PROC flatmode FAR PROC enablea20 FAR
; USES eax,bx,edx USES ax
; ; first, calculate the linear address of GDT mov al,0d1h
; xor edx,edx out 64h,al
; xor eax,eax call a20wait
; mov dx,cs mov al,0dfh
; shl edx,4 out 60h,al
; add [dword ptr cs:offset @@gdt+2],edx ; store as GDT linear base addr call a20wait
; ; now load the GDT into the GDTR ;mov al,0ffh
; lgdt [fword ptr cs:offset @@gdt] ; load GDT base (286-style 24-bit load) ;out 64h,al
; mov bx,1 * size descriptor ; point to first descriptor ;call a20wait
; mov eax,cr0 ; prepare to enter protected mode ret
; or al,1 ; flip the PE bit endp enablea20
; cli ; turn off interrupts
; mov cr0,eax ; we're now in protected mode PROC disablea20 FAR
; mov fs,bx ; load the FS segment register USES ax
; and al,0FEh ; clear the PE bit again mov al,0d1h
; mov cr0,eax ; back to real mode out 64h,al
; sti ; resume handling interrupts call a20wait
; ret ; mov al,0DDh
out 60h,al
call a20wait
;mov al,0ffh
;out 64h,al
;call a20wait
ret
endp disablea20
a20wait:
in al,64h
jmp @@suite
@@suite:
and al,2
jnz a20wait
ret
;par le system control port A
;in al,92h
;or al,2
;out 92h,al
;par le system control port A
;in al,92h
;and al,not 2
;out 92h,al
PROC flatmode FAR
USES eax,bx,ds
push cs
pop ds
; first, calculate the linear address of GDT
xor eax,eax
mov ax,ds
shl eax,4
add [dword ptr offset @@gdt+2],eax ; store as GDT linear base addr
; now load the GDT into the GDTR
lgdt [fword ptr offset @@gdt] ; load GDT base
mov bx,1 * size descriptor ; point to first descriptor
cli ; turn off interrupts
mov eax,cr0 ; prepare to enter protected mode
or al,1 ; flip the PE bit
mov cr0,eax ; we're now in protected mode
jmp @@suite
@@suite:
mov fs,bx ; load the FS segment register
and al,0FEh ; clear the PE bit again
mov cr0,eax ; back to real mode
jmp @@suite2
@@suite2:
sti ; resume handling interrupts
ret ;
;@@gdt descriptor <@@gdtend - @@gdt - 1, @@gdt, 0, 0, 0, 0> ; the GDT itself @@gdt descriptor <offset @@gdtend - offset @@gdt - 1, offset @@gdt, 0, 0, 0, 0> ; the GDT itself
; descriptor <0ffffh, 0, 0, 091h, 0cfh, 0> ; 4G data segment descriptor <0ffffh, 0, 0, 091h, 0cfh, 0> ; 4G data segment
;@@gdtend: @@gdtend:
;endp flatmode endp flatmode
;Attend l'appuie sur une touche ;Attend l'appuie sur une touche
PROC bioswaitkey FAR PROC bioswaitkey FAR
@ -153,6 +186,9 @@ PROC mbloadsection FAR
je @@finishloading je @@finishloading
mov ax,bx mov ax,bx
add ax,4 add ax,4
pushad
call biosprint,ax
popad
call mbcreate,ax,[word ptr bx+2] call mbcreate,ax,[word ptr bx+2]
jc @@error jc @@error
inc si inc si
@ -174,11 +210,6 @@ PROC mbloadsection FAR
inc bx inc bx
jmp @@loading jmp @@loading
@@finishloading: @@finishloading:
pushad
xor eax,eax
mov ax,[word ptr ss:si]
call biosprinth,eax
popad
cmp [word ptr ss:si],0FFFFh cmp [word ptr ss:si],0FFFFh
je @@finishdepands je @@finishdepands
call mbloadfuncs,[word ptr ss:si] call mbloadfuncs,[word ptr ss:si]
@ -244,21 +275,19 @@ PROC mbcreate FAR
cmp [word ptr es:mb.check],"NH" cmp [word ptr es:mb.check],"NH"
jne @@memoryerror jne @@memoryerror
cmp [es:mb.isnotlast],true cmp [es:mb.isnotlast],true
sete dl sete dl
cmp [es:mb.reference],free cmp [es:mb.reference],free
jne @@notsogood jne @@notsogood
mov ax,[es:mb.sizes] mov ax,[es:mb.sizes]
cmp cx,ax cmp cx,ax
ja @@notsogood ja @@notsogood
;mov [word ptr es:mb.check],"NH" mov [word ptr es:mb.check],"NH"
mov [es:mb.isnotlast],true mov [es:mb.isnotlast],true
mov [es:mb.reference],gs mov [es:mb.reference],gs
mov [es:mb.isresident],false mov [es:mb.isresident],false
lea di,[es:mb.names] lea di,[es:mb.names]
push cx push cx
mov cx,24/4 mov cx,24/4
push cs
pop ds
mov si,[@blocks] mov si,[@blocks]
cld cld
rep movsd rep movsd
@ -276,14 +305,16 @@ PROC mbcreate FAR
mov si,offset afree mov si,offset afree
xor di,di xor di,di
mov cx,size mb mov cx,size mb
push cs
pop ds
cld cld
rep movsb rep movsb
mov [es:mb.isnotlast],dl mov [es:mb.isnotlast],dl
mov [es:mb.sizes],ax mov [es:mb.sizes],ax
@@nofree: @@nofree:
mov ax,bx mov ax,bx
clc
pop gs pop gs
clc
ret ret
@@notsogood: @@notsogood:
inc bx inc bx
@ -291,8 +322,8 @@ PROC mbcreate FAR
add bx,[es:mb.sizes] add bx,[es:mb.sizes]
jmp @@searchfree jmp @@searchfree
@@memoryerror: @@memoryerror:
stc
pop gs pop gs
stc
ret ret
@@notenougtmem: @@notenougtmem:
pop gs pop gs
@ -532,9 +563,9 @@ PROC mbfind FAR
dec bx dec bx
dec bx dec bx
mov si,[@blocks] mov si,[@blocks]
lea di,[es:mb.names]
@@search: @@search:
mov es,bx mov es,bx
lea di,[es:mb.names]
cmp [word ptr es:mb.check],"NH" cmp [word ptr es:mb.check],"NH"
jne @@memoryerror jne @@memoryerror
inc bx inc bx
@ -636,6 +667,9 @@ PROC mbloadfuncs FAR
@@loadfuncs: @@loadfuncs:
cmp [word ptr si],0 cmp [word ptr si],0
je @@endofloading je @@endofloading
pushad
call biosprint,si
popad
call mbsearchfunc,si call mbsearchfunc,si
jnc @@toendoftext jnc @@toendoftext
mov bx,si mov bx,si

View File

@ -12,77 +12,42 @@ org 0h
header exe <"CE",1,0,0,offset exports,,,> header exe <"CE",1,0,0,offset exports,,,>
exporting
exports: declare setvideomode
db "setvideomode",0 declare getvideomode
dw setvideomode declare clearscreen
db "getvideomode",0 declare setfont
dw getvideomode declare loadfont
db "clearscreen",0 declare getfont
dw clearscreen declare addline
db "setfont",0 declare showchar
dw setfont declare showpixel
db "loadfont",0 declare getpixel
dw loadfont declare setstyle
db "getfont",0 declare getstyle
dw getfont declare enablecursor
db "addline",0 declare disablecursor
dw addline declare setcolor
db "showchar",0 declare getcolor
dw showchar declare scrolldown
db "showpixel",0 declare getxy
dw showpixel declare setxy
db "getpixel",0 declare savescreen
dw getpixel declare restorescreen
db "setstyle",0 declare page2to1
dw setstyle declare page1to2
db "getstyle",0 declare xchgpages
dw getstyle declare waithretrace
db "enablecursor",0 declare waitretrace
dw enablecursor declare getvideoinfos
db "disablecursor",0 declare savedac
dw disablecursor declare restoredac
db "setcolor",0 declare savestate
dw setcolor declare restorestate
db "getcolor",0 declare enablescroll
dw getcolor declare disablescroll
db "scrolldown",0 declare getchar
dw scrolldown ende
db "getxy",0
dw getxy
db "setxy",0
dw setxy
db "savescreen",0
dw savescreen
db "restorescreen",0
dw restorescreen
db "page2to1",0
dw page2to1
db "page1to2",0
dw page1to2
;db "xchgPages",0
;dw xchgpages
db "waithretrace",0
dw waithretrace
db "waitretrace",0
dw waitretrace
db "getvgainfos",0
dw getvgainfos
;db "savedac",0
;dw savedac
;db "restoredac",0
;dw restoredac
;db "savestate",0
;dw savestate
;db "restorestate",0
;dw restorestate
db "enablescroll",0
dw enablescroll
db "disablescroll",0
dw disablescroll
db "getchar",0
dw getchar
;================================Table des modes videos (64 BYTES) ============================================ ;================================Table des modes videos (64 BYTES) ============================================
;40*25 16 couleurs ;40*25 16 couleurs
mode0 DB 67H,00H, 03H,08H,03H,00H,02H mode0 DB 67H,00H, 03H,08H,03H,00H,02H
@ -192,32 +157,8 @@ mode11 DB 0E7H
DB 00H,01H,02H,03H,04H,05H,06H,07H,10H,11H,3AH,3BH,3CH,3DH,3EH,3FH,01H,00H,0FH,00H,00H DB 00H,01H,02H,03H,04H,05H,06H,07H,10H,11H,3AH,3BH,3CH,3DH,3EH,3FH,01H,00H,0FH,00H,00H
DB 100,75 DB 100,75
datablocksize equ 40
datablock equ $
;============================================DATABLOCK========================================================= ;============================================DATABLOCK=========================================================
lines db 0 datablock vgainf <0,0,0,0,0,7,0FFh,0,0,0,0,0,0,0,0,0,0,0,1>
columns db 0
x db 0
y db 0
xy dw 0
colors db 7
mode db 0FFh
pagesize dw 0
style db 0
font db 0
graphic db 0
reserved1 dw 0
reserved2 dw 0
reserved3 dw 0
nbpage db 0
color db 0
cursor db 0
segments dw 0
linesize dw 0
adress dw 0
base dw 0
scrolling db 1
;=======================================Equivalence pour la clarté du code======================================== ;=======================================Equivalence pour la clarté du code========================================
sequencer equ 03C4h sequencer equ 03C4h
@ -238,7 +179,7 @@ planesize equ 65000
;<- ;<-
;===================================== ;=====================================
PROC enablescroll FAR PROC enablescroll FAR
mov [cs:scrolling],1 mov [cs:datablock.scrolling],1
ret ret
endp enablescroll endp enablescroll
@ -248,7 +189,7 @@ endp enablescroll
;<- ;<-
;====================================== ;======================================
PROC disablescroll FAR PROC disablescroll FAR
mov [cs:scrolling],0 mov [cs:datablock.scrolling],0
ret ret
endp disablescroll endp disablescroll
@ -259,7 +200,7 @@ endp disablescroll
;====================================== ;======================================
PROC enablecursor FAR PROC enablecursor FAR
USES ax,dx USES ax,dx
mov [cs:cursor],1 mov [cs:datablock.cursor],1
mov dx,ccrt mov dx,ccrt
mov al,0Ah mov al,0Ah
out dx,al out dx,al
@ -270,9 +211,9 @@ PROC enablecursor FAR
dec dx dec dx
mov al,0Ah mov al,0Ah
out dx,ax out dx,ax
mov al,[cs:x] mov al,[cs:datablock.x]
xor ah,ah xor ah,ah
mov dl,[cs:y] mov dl,[cs:datablock.y]
xor dh,dh xor dh,dh
call setxy,ax,dx call setxy,ax,dx
ret ret
@ -285,7 +226,7 @@ endp enablecursor
;======================================= ;=======================================
PROC disablecursor FAR PROC disablecursor FAR
USES ax,dx USES ax,dx
mov [cs:cursor],0 mov [cs:datablock.cursor],0
mov dx,ccrt mov dx,ccrt
mov al,0Ah mov al,0Ah
out dx,al out dx,al
@ -308,7 +249,7 @@ PROC setstyle FAR
ARG @style:word ARG @style:word
USES cx USES cx
mov ax,[@style] mov ax,[@style]
mov [cs:style],al mov [cs:datablock.style],al
ret ret
endp setstyle endp setstyle
@ -318,7 +259,7 @@ endp setstyle
;<- AX style ;<- AX style
;=========================== ;===========================
PROC getstyle FAR PROC getstyle FAR
mov al,[cs:style] mov al,[cs:datablock.style]
xor ah,ah xor ah,ah
ret ret
endp getstyle endp getstyle
@ -335,17 +276,17 @@ PROC setvideomode FAR
xor ah,ah xor ah,ah
cmp al,maxmode cmp al,maxmode
ja @@errorsetvideomode ja @@errorsetvideomode
cmp [cs:mode],5h cmp [cs:datablock.mode],5h
jb @@nographic jb @@nographic
cmp al,5h cmp al,5h
jae @@nographic jae @@nographic
call initfont call initfont
@@nographic: @@nographic:
cmp [cs:mode],0FFh cmp [cs:datablock.mode],0FFh
jne @@noinit jne @@noinit
call initfont call initfont
@@noinit: @@noinit:
mov [cs:mode],al mov [cs:datablock.mode],al
xor ah,ah xor ah,ah
mov di,ax mov di,ax
shl di,6 shl di,6
@ -407,47 +348,47 @@ PROC setvideomode FAR
mov al,20h mov al,20h
out dx,al out dx,al
mov al,[cs:di] mov al,[cs:di]
mov [cs:columns],al mov [cs:datablock.columns],al
mov ah,[cs:di+1] mov ah,[cs:di+1]
mov [cs:lines],ah mov [cs:datablock.lines],ah
mul ah mul ah
mov cl,[cs:di-5] mov cl,[cs:di-5]
and cl,01000000b and cl,01000000b
cmp cl,0 cmp cl,0
je @@colors16 je @@colors16
mov [cs:color],8 mov [cs:datablock.color],8
mov cl,4 mov cl,4
jmp @@colors256 jmp @@colors256
@@colors16: @@colors16:
mov [cs:color],4 mov [cs:datablock.color],4
mov cl,3 mov cl,3
@@colors256: @@colors256:
cmp [cs:mode],5 cmp [cs:datablock.mode],5
setae [cs:graphic] setae [cs:datablock.graphic]
jb @@istext jb @@istext
shl ax,cl shl ax,cl
mov [cs:segments],0A000h mov [cs:datablock.segments],0A000h
jmp @@wasgraph jmp @@wasgraph
@@istext: @@istext:
mov [cs:segments],0B800h mov [cs:datablock.segments],0B800h
shl ax,1 shl ax,1
@@wasgraph: @@wasgraph:
mov [cs:pagesize],ax mov [cs:datablock.pagesize],ax
mov ax,planesize mov ax,planesize
xor dx,dx xor dx,dx
div [cs:pagesize] div [cs:datablock.pagesize]
mov [cs:nbpage],al mov [cs:datablock.nbpage],al
mov al,[cs:di-36] mov al,[cs:di-36]
xor ah,ah xor ah,ah
shl ax,2 shl ax,2
mov cl,[cs:graphic] mov cl,[cs:datablock.graphic]
shr ax,cl shr ax,cl
mov [cs:linesize],ax mov [cs:datablock.linesize],ax
mov ax,[cs:di-43] mov ax,[cs:di-43]
mov [cs:adress],ax mov [cs:datablock.adress],ax
mov [cs:base],ax mov [cs:datablock.base],ax
mov [cs:cursor],1 mov [cs:datablock.cursor],1
mov [cs:style],0 mov [cs:datablock.style],0
ret ret
@@errorsetvideomode: @@errorsetvideomode:
ret ret
@ -470,7 +411,7 @@ initfont:
;<- AX ;<- AX
;================================== ;==================================
PROC getvideomode FAR PROC getvideomode FAR
mov al,[cs:mode] mov al,[cs:datablock.mode]
xor ah,ah xor ah,ah
ret ret
endp getvideomode endp getvideomode
@ -483,9 +424,9 @@ endp getvideomode
PROC clearscreen FAR PROC clearscreen FAR
USES eax,cx,dx,di,es USES eax,cx,dx,di,es
mov cx,planesize mov cx,planesize
mov di,[cs:adress] mov di,[cs:datablock.adress]
shr cx,2 shr cx,2
cmp [cs:graphic],1 cmp [cs:datablock.graphic],1
jne @@erasetext jne @@erasetext
mov ax,0A000h mov ax,0A000h
mov es,ax mov es,ax
@ -504,7 +445,7 @@ PROC clearscreen FAR
cld cld
rep stosd rep stosd
mov ax,0005h mov ax,0005h
cmp [cs:color],4 cmp [cs:datablock.color],4
je @@not256 je @@not256
mov ax,4005h mov ax,4005h
@@not256: @@not256:
@ -537,7 +478,7 @@ PROC setfont FAR
xor ch,ch xor ch,ch
cmp cl,7 cmp cl,7
ja @@errorsetfont ja @@errorsetfont
mov [cs:font],cl mov [cs:datablock.font],cl
mov ah,cl mov ah,cl
and cl,11b and cl,11b
and ah,0100b and ah,0100b
@ -557,7 +498,7 @@ endp setfont
;<- CL n° font, Carry if error ;<- CL n° font, Carry if error
;============================= ;=============================
PROC getfont FAR PROC getfont FAR
mov al,[cs:font] mov al,[cs:datablock.font]
xor ah,ah xor ah,ah
endp getfont endp getfont
@ -570,7 +511,6 @@ endp getfont
PROC loadfont FAR PROC loadfont FAR
ARG @pointer:word,@size:word,@font:word ARG @pointer:word,@size:word,@font:word
USES ax,bx,cx,dx,si,di,es USES ax,bx,cx,dx,si,di,es
LOCAL @poppop:dword
mov si,[@pointer] mov si,[@pointer]
mov cx,[@size] mov cx,[@size]
mov bx,[@font] mov bx,[@font]
@ -659,15 +599,15 @@ endp loadfont
;================================= ;=================================
PROC addline FAR PROC addline FAR
USES bx,cx USES bx,cx
mov bl,[cs:y] mov bl,[cs:datablock.y]
xor bh,bh xor bh,bh
mov cl,[cs:lines] mov cl,[cs:datablock.lines]
sub cl,2 sub cl,2
cmp bl,cl cmp bl,cl
jne @@scro jne @@scro
dec bl dec bl
mov cx,1 mov cx,1
cmp [cs:graphic],0 cmp [cs:datablock.graphic],0
je @@okscro je @@okscro
mov cx,8 mov cx,8
@@okscro: @@okscro:
@ -687,7 +627,7 @@ PROC setcolor FAR
ARG @color:word ARG @color:word
USES cx USES cx
mov cx,[@color] mov cx,[@color]
mov [cs:colors],cl mov [cs:datablock.colors],cl
ret ret
endp setcolor endp setcolor
@ -697,7 +637,7 @@ endp setcolor
;<- AX couleur ;<- AX couleur
;=========================== ;===========================
PROC getcolor FAR PROC getcolor FAR
mov al,[cs:colors] mov al,[cs:datablock.colors]
xor ah,ah xor ah,ah
ret ret
endp getcolor endp getcolor
@ -710,16 +650,16 @@ endp getcolor
PROC scrolldown FAR PROC scrolldown FAR
ARG @line:word ARG @line:word
USES ax,cx,dx,si,di,ds,es USES ax,cx,dx,si,di,ds,es
cmp [cs:scrolling],0 cmp [cs:datablock.scrolling],0
je @@graphp je @@graphp
mov ax,[@line] mov ax,[@line]
mul [cs:linesize] mul [cs:datablock.linesize]
mov si,ax mov si,ax
mov cx,[cs:pagesize] mov cx,[cs:datablock.pagesize]
sub cx,si sub cx,si
mov di,[cs:adress] mov di,[cs:datablock.adress]
cld cld
cmp [cs:graphic],1 cmp [cs:datablock.graphic],1
jne @@textp jne @@textp
mov ax,0A000h mov ax,0A000h
mov es,ax mov es,ax
@ -733,7 +673,7 @@ PROC scrolldown FAR
cld cld
rep movsb rep movsb
mov ax,0005h mov ax,0005h
cmp [cs:color],4 cmp [cs:datablock.color],4
je @@not256ok je @@not256ok
mov ax,4005h mov ax,4005h
@@not256ok: @@not256ok:
@ -761,8 +701,8 @@ PROC getxy FAR
ARG @pointer:word ARG @pointer:word
USES bx USES bx
mov bx,[@pointer] mov bx,[@pointer]
mov ah,[cs:x] mov ah,[cs:datablock.x]
mov al,[cs:y] mov al,[cs:datablock.y]
ret ret
endp getxy endp getxy
@ -776,14 +716,14 @@ PROC setxy FAR
USES ax,bx,dx,di USES ax,bx,dx,di
mov ax,[@y] mov ax,[@y]
mov bx,[@x] mov bx,[@x]
mov [cs:x],bl mov [cs:datablock.x],bl
mov [cs:y],al mov [cs:datablock.y],al
mov di,[cs:adress] mov di,[cs:datablock.adress]
add di,bx add di,bx
mul [cs:columns] mul [cs:datablock.columns]
add di,ax add di,ax
shl di,1 shl di,1
mov [cs:xy],di mov [cs:datablock.xy],di
call setcursor call setcursor
ret ret
endp setxy endp setxy
@ -799,16 +739,16 @@ PROC showpixel FAR
mov bx,[@x] mov bx,[@x]
mov cx,[@y] mov cx,[@y]
mov ax,[@color] mov ax,[@color]
cmp [cs:color],4 cmp [cs:datablock.color],4
je @@showpixel4 je @@showpixel4
mov si,ax mov si,ax
mov ax,cx mov ax,cx
mov cl,bl mov cl,bl
mul [cs:linesize] mul [cs:datablock.linesize]
shr bx,2 shr bx,2
add ax,bx add ax,bx
mov di,ax mov di,ax
add di,[cs:adress] add di,[cs:datablock.adress]
and cl,3 and cl,3
mov ah,1 mov ah,1
shl ah,cl shl ah,cl
@ -826,11 +766,11 @@ PROC showpixel FAR
mov ax,cx mov ax,cx
mov ch,dl mov ch,dl
mov cl,bl mov cl,bl
mul [cs:linesize] mul [cs:datablock.linesize]
shr bx,3 shr bx,3
add ax,bx add ax,bx
mov di,ax mov di,ax
add di,[cs:adress] add di,[cs:datablock.adress]
and cl,111b and cl,111b
xor cl,111b xor cl,111b
mov ah,1 mov ah,1
@ -863,11 +803,11 @@ PROC getpixel FAR
mov cx,[@y] mov cx,[@y]
mov ax,cx mov ax,cx
mov cl,bl mov cl,bl
mul [cs:linesize] mul [cs:datablock.linesize]
shr bx,2 shr bx,2
add ax,bx add ax,bx
mov di,ax mov di,ax
add di,[cs:adress] add di,[cs:datablock.adress]
and cl,3 and cl,3
mov ah,cl mov ah,cl
mov al,4 mov al,4
@ -884,18 +824,18 @@ endp getpixel
;<- ES:%0 pointeur ;<- ES:%0 pointeur
;-> ;->
;============================================= ;=============================================
PROC getvgainfos FAR PROC getvideoinfos FAR
ARG @pointer:word ARG @pointer:word
USES cx,si,di,ds USES cx,si,di,ds
push cs push cs
pop ds pop ds
mov cx,datablocksize mov cx,size datablock
mov si,offset datablock mov si,offset datablock
mov di,[@pointer] mov di,[@pointer]
cld cld
rep movsb rep movsb
ret ret
endp getvgainfos endp getvideoinfos
;==========WAITRETRACE========= ;==========WAITRETRACE=========
;Synchronisation avec la retrace verticale ;Synchronisation avec la retrace verticale
@ -936,7 +876,7 @@ PROC getchar FAR
USES di,es USES di,es
mov ax,0B800h mov ax,0B800h
mov es,ax mov es,ax
mov di,[cs:xy] mov di,[cs:datablock.xy]
mov al,[es:di] mov al,[es:di]
xor ah,ah xor ah,ah
ret ret
@ -954,22 +894,22 @@ PROC showchar FAR
mov ch,[byte ptr @attr] mov ch,[byte ptr @attr]
cmp [@attr],0FFFFh cmp [@attr],0FFFFh
jne @@notlastattr jne @@notlastattr
mov ch,[cs:colors] mov ch,[cs:datablock.colors]
@@notlastattr: @@notlastattr:
cmp [cs:graphic],1 cmp [cs:datablock.graphic],1
jne @@textaccess jne @@textaccess
call emulatechar call emulatechar
jmp @@adjusttext jmp @@adjusttext
@@textaccess: @@textaccess:
mov ax,0B800h mov ax,0B800h
mov es,ax mov es,ax
mov di,[cs:xy] mov di,[cs:datablock.xy]
mov [es:di],cx mov [es:di],cx
add [cs:xy],2 add [cs:datablock.xy],2
@@adjusttext: @@adjusttext:
inc [cs:x] inc [cs:datablock.x]
mov cl,[cs:columns] mov cl,[cs:datablock.columns]
cmp [cs:x],cl cmp [cs:datablock.x],cl
jb @@noadjusted jb @@noadjusted
call addline call addline
@@noadjusted: @@noadjusted:
@ -979,11 +919,11 @@ endp showchar
setcursor: setcursor:
push ax cx dx push ax cx dx
cmp [cs:cursor],1 cmp [cs:datablock.cursor],1
jne notshow jne notshow
mov dx,ccrt mov dx,ccrt
mov al,0Eh mov al,0Eh
mov cx,[cs:xy] mov cx,[cs:datablock.xy]
shr cx,1 shr cx,1
mov ah,ch mov ah,ch
out dx,ax out dx,ax
@ -1003,8 +943,8 @@ emulatechar:
and di,11111111b and di,11111111b
shl di,3 shl di,3
add di,offset font8x8 add di,offset font8x8
mov bl,[cs:x] mov bl,[cs:datablock.x]
mov cl,[cs:y] mov cl,[cs:datablock.y]
xor bh,bh xor bh,bh
xor ch,ch xor ch,ch
shl bx,3 shl bx,3
@ -1016,7 +956,7 @@ bouclet:
push ax push ax
jc colored jc colored
shr al,4 shr al,4
cmp [cs:style],0 cmp [cs:datablock.style],0
jnz transparent jnz transparent
colored: colored:
and ax,1111b and ax,1111b
@ -1047,7 +987,7 @@ push ax cx dx si di bp ds es gs
mov bp,sp mov bp,sp
mov dx,[ss:bp+22] mov dx,[ss:bp+22]
mov ah,2 mov ah,2
mov cx,[cs:pagesize] mov cx,[cs:datablock.pagesize]
push cs push cs
pop ds pop ds
mov si,offset data3 mov si,offset data3
@ -1070,7 +1010,7 @@ savescreento:
mov cx,0B800h mov cx,0B800h
mov ds,cx mov ds,cx
xor ecx,ecx xor ecx,ecx
mov cx,[cs:pagesize] mov cx,[cs:datablock.pagesize]
shr cx,2 shr cx,2
xor si,si xor si,si
cld cld
@ -1084,7 +1024,7 @@ saveparamto:
push cs push cs
pop ds pop ds
xor ecx,ecx xor ecx,ecx
mov cx,datablocksize mov cx,size datablock
mov si,offset datablock mov si,offset datablock
cld cld
rep movsb rep movsb
@ -1097,7 +1037,7 @@ restoreparamfrom:
push cs push cs
pop es pop es
xor ecx,ecx xor ecx,ecx
mov cx,datablocksize mov cx,size datablock
mov di,offset datablock mov di,offset datablock
cld cld
rep movsb rep movsb
@ -1127,7 +1067,7 @@ restorescreenfrom:
mov cx,0B800H mov cx,0B800H
mov es,cx mov es,cx
xor ecx,ecx xor ecx,ecx
mov cx,[cs:pagesize] mov cx,[cs:datablock.pagesize]
shr cx,2 shr cx,2
xor di,di xor di,di
cld cld
@ -1144,9 +1084,9 @@ page2to1:
mov es,cx mov es,cx
mov ds,cx mov ds,cx
xor ecx,ecx xor ecx,ecx
mov cx,[cs:pagesize] mov cx,[cs:datablock.pagesize]
shr cx,2 shr cx,2
mov si,[cs:pagesize] mov si,[cs:datablock.pagesize]
xor di,di xor di,di
cld cld
rep movsd rep movsd
@ -1160,9 +1100,9 @@ page1to2:
mov es,cx mov es,cx
mov ds,cx mov ds,cx
xor ecx,ecx xor ecx,ecx
mov cx,[cs:pagesize] mov cx,[cs:datablock.pagesize]
shr cx,2 shr cx,2
mov di,[cs:pagesize] mov di,[cs:datablock.pagesize]
xor si,si xor si,si
cld cld
rep movsd rep movsd
@ -1170,190 +1110,190 @@ page1to2:
ret ret
;===============================xchgPages============================ ;===============================xchgPages============================
;xchgpages: xchgpages:
;push ax cx dx si di bp ds es gs push ax cx dx si di bp ds es gs
;mov bp,sp mov bp,sp
;mov dx,[ss:bp+22] mov dx,[ss:bp+22]
;mov ah,2 mov ah,2
;mov cx,datablocksize mov cx,size datablock
;add cx,[cs:pagesize] add cx,[cs:datablock.pagesize]
;add cx,3*256 add cx,3*256
;push cs push cs
;pop ds pop ds
;mov si,offset data4 mov si,offset data4
;int 49h int 49h
;mov ah,6 mov ah,6
;int 49h int 49h
;push gs push gs
;pop es pop es
;xor di,di xor di,di
;call savescreento call savescreento
;call page2to1 call page2to1
;push gs push gs
;pop ds pop ds
;xor si,si xor si,si
;mov cx,0B800H mov cx,0B800H
;mov es,cx mov es,cx
;mov di,[cs:pagesize] mov di,[cs:datablock.pagesize]
;xor ecx,ecx xor ecx,ecx
;mov cx,[cs:pagesize] mov cx,[cs:datablock.pagesize]
;shr cx,2 shr cx,2
;cld cld
;rep movsd rep movsd
;mov ah,01h mov ah,01h
;int 49h int 49h
;pop gs es ds bp di si dx cx ax pop gs es ds bp di si dx cx ax
;ret ret
;
;data4 db '/vgatemp',0 data4 db '/vgatemp',0
;Sauve l'tat de la carte dans un bloc mémoire ;Sauve l'tat de la carte dans un bloc mémoire
;savestate: savestate:
;push ax cx dx si di bp ds es gs push ax cx dx si di bp ds es gs
;mov bp,sp mov bp,sp
;mov dx,[ss:bp+22] mov dx,[ss:bp+22]
;mov ah,2 mov ah,2
;mov cx,datablocksize mov cx,size datablock
;add cx,[cs:pagesize] add cx,[cs:datablock.pagesize]
;add cx,3*256 add cx,3*256
;push cs push cs
;pop ds pop ds
;mov si,offset data mov si,offset data
;int 49h int 49h
;mov ah,6 mov ah,6
;int 49h int 49h
;push gs push gs
;pop es pop es
;xor di,di xor di,di
;call saveparamto call saveparamto
;add di,datablocksize add di,size datablock
;call savescreento call savescreento
;add di,[cs:pagesize] add di,[cs:datablock.pagesize]
;call savedacto call savedacto
;pop gs es ds bp di si dx cx ax pop gs es ds bp di si dx cx ax
;ret ret
;data db '/vga',0 data db '/vga',0
;RcupŠre l'tat de la carte depuis son bloc mémoire ;RcupŠre l'tat de la carte depuis son bloc mémoire
;restorestate: restorestate:
;push ax dx si bp ds gs push ax dx si bp ds gs
;mov bp,sp mov bp,sp
;mov dx,[ss:bp+16] mov dx,[ss:bp+16]
;push cs push cs
;pop ds pop ds
;mov si,offset data mov si,offset data
;mov ah,9 mov ah,9
;int 49h int 49h
;push gs push gs
;pop ds pop ds
;mov al,[ds:7] mov al,[ds:7]
;cmp [cs:mode],al cmp [cs:datablock.mode],al
;je nochangemode je nochangemode
;mov ah,0 mov ah,0
;call setvideomode call setvideomode
;nochangemode: nochangemode:
;xor si,si xor si,si
;call restoreparamfrom call restoreparamfrom
;add si,datablocksize add si,size datablock
;call restorescreenfrom call restorescreenfrom
;add si,[cs:pagesize] add si,[cs:datablock.pagesize]
;call restoredacfrom call restoredacfrom
;pop gs ds bp si dx ax pop gs ds bp si dx ax
;ret ret
;sauve le DAC dans un bloc de mémoire ;sauve le DAC dans un bloc de mémoire
;savedac: savedac:
;push ax cx dx si di bp ds es gs push ax cx dx si di bp ds es gs
;mov bp,sp mov bp,sp
;mov dx,[ss:bp+22] mov dx,[ss:bp+22]
;mov ah,2 mov ah,2
;mov cx,3*256 mov cx,3*256
;push cs push cs
;pop ds pop ds
;mov si,offset data2 mov si,offset data2
;int 49h int 49h
;mov ah,6 mov ah,6
;int 49h int 49h
;push gs push gs
;pop es pop es
;xor di,di xor di,di
;call savedacto call savedacto
;pop gs es ds bp di si dx cx ax pop gs es ds bp di si dx cx ax
;ret ret
;data2 db '/vgadac',0 data2 db '/vgadac',0
;RcupŠre le dac depuis son bloc mémoire ;RcupŠre le dac depuis son bloc mémoire
;restoredac: restoredac:
;push ax dx si bp ds gs push ax dx si bp ds gs
;mov bp,sp mov bp,sp
;mov dx,[ss:bp+16] mov dx,[ss:bp+16]
;push cs push cs
;pop ds pop ds
;mov si,offset data2 mov si,offset data2
;mov ah,9 mov ah,9
;int 49h int 49h
;push gs push gs
;pop ds pop ds
;xor si,si xor si,si
;call restoredacfrom call restoredacfrom
;pop gs ds bp si dx ax pop gs ds bp si dx ax
;ret ret
;sauve le DAC en es:di ;sauve le DAC en es:di
;savedacto: savedacto:
;push ax cx dx di push ax cx dx di
;mov dx,3C7h mov dx,3C7h
;mov cx,256 mov cx,256
;save: save:
;mov al,cl mov al,cl
;dec al dec al
;out dx,al out dx,al
;inc dx inc dx
;inc dx inc dx
;in al,dx in al,dx
;mov [es:di],al mov [es:di],al
;inc di inc di
;in al,dx in al,dx
;mov [es:di],al mov [es:di],al
;inc di inc di
;in al,dx in al,dx
;mov [es:di],al mov [es:di],al
;inc di inc di
;dec dx dec dx
;dec dx dec dx
;dec cx dec cx
;jne save jne save
;pop di dx cx ax pop di dx cx ax
;ret ret
;restore le DAC depuis ds:si ;restore le DAC depuis ds:si
;restoredacfrom: restoredacfrom:
;push ax cx dx si push ax cx dx si
;xor ax,ax xor ax,ax
;mov dx,3C8h mov dx,3C8h
;mov cx,256 mov cx,256
;save2: save2:
;mov al,cl mov al,cl
;dec al dec al
;out dx,al out dx,al
;inc dx inc dx
;mov al,[ds:si] mov al,[ds:si]
;inc si inc si
;out dx,al out dx,al
;mov al,[ds:si] mov al,[ds:si]
;inc si inc si
;out dx,al out dx,al
;mov al,[ds:si] mov al,[ds:si]
;inc si inc si
;out dx,al out dx,al
;dec dx dec dx
;dec cx dec cx
;jne save2 jne save2
;pop si dx cx ax pop si dx cx ax
;ret ret
font8x8: font8x8: