feat: version bêta 1.3.2fr

This commit is contained in:
Nicolas Hordé 2007-03-31 18:50:14 +00:00
parent 2eee63e178
commit 9e47321c92
5 changed files with 2771 additions and 0 deletions

20
lib/MAKEFILE Normal file
View File

@ -0,0 +1,20 @@
asm= lzasm /z/t
lnk= elink
all: detect.lib video.lib str0.lib bmp.lib
.asm.obj:
$(asm) $<
.obj.lib:
$(lnk) $< $*.lib
clean:
del *.obj
del *.ce
del *.bak
del *.lib
del *.com
del *.bin
del *.sys
del *.err

105
lib/bmp.asm Normal file
View File

@ -0,0 +1,105 @@
model tiny,stdcall
p586N
locals
jumps
codeseg
option procalign:byte
include "..\include\mem.h"
include "..\include\divers.h"
include "..\include\bmp.h"
org 0h
start:
header exe <"CE",1,0,0,offset exports,offset imports,,>
exporting
declare showbmp
declare loadbmppalet
ende
importing
use VIDEO,showpixel
endi
;==========SHOWBMP=========
;Affiche le BMP pointée par DS:%0 en %1, %2
;<- DS:%0 BMP, %1 coordonnées X, %2 coordonnées Y
;->
;==========================
PROC showbmp FAR
ARG @pointer:word, @x:word, @y:word
USES ax,bx,cx,dx,si,di
mov si,[@pointer]
cmp [word ptr (bmp_file si).bmp_filetype],"MB"
jne @@errorshowing
mov edi,[(bmp_file si).bmp_bitmapoffset]
add di,400h
add di,si
xor ebx,ebx
mov ecx,[(bmp_file si).bmp_height]
mov edx,[(bmp_file si).bmp_width]
;and dx,11111100b
cmp edx,[(bmp_file si).bmp_width]
;jae @@noadjust
;add dx,4
@@noadjust:
sub edx,[(bmp_file si).bmp_width]
@@bouclette:
push bx cx
add bx,[@x]
add cx,[@y]
call [cs:showpixel],bx,cx,[word ptr di]
pop cx bx
inc bx
inc di
cmp ebx,[(bmp_file si).bmp_width]
jb @@bouclette
xor bx,bx
;add di,dx
dec cx
cmp cx,0
jne @@bouclette
clc
ret
@@errorshowing:
stc
ret
ENDP showbmp
;==========LOADBMPPALET=========
;Charge la palette du BMP pointée par DS:%0
;-> DS:%0 BMP
;<-
;===============================
PROC loadbmppalet FAR
ARG @pointer:word
USES ax,bx,cx,dx,si
mov si,[@pointer]
mov bx,0400h+36h-4
mov cx,100h
mov dx, 3c8h
@@paletteload:
mov al, cl
dec al
out dx, al
inc dx
mov al,[bx+si+2]
shr al,2
out dx, al
mov al,[bx+si+1]
shr al,2
out dx, al
mov al,[bx+si]
shr al,2
out dx, al
sub bx,4
dec dx
dec cl
jnz @@paletteload
ret
ENDP loadbmppalet

762
lib/detect.asm Normal file
View File

@ -0,0 +1,762 @@
model tiny,stdcall
p586
locals
jumps
codeseg
option procalign:byte
include "..\include\mem.h"
include "..\include\cpu.h"
include "..\include\pci.h"
org 0h
header exe <"CE",1,0,0,offset exports,,,>
exporting
declare cpuinfo
declare setinfo
declare pciinfo
declare getpciclass
declare getpcisubclass
declare getcardinfo
declare pcireadbyte
declare pcireadword
declare pcireaddword
declare detectvmware
ende
PROC detectvmware FAR
USES eax,ebx,ecx,edx
mov eax,564D5868h
mov ebx,12345h
mov ecx,00Ah
mov edx,5658h
in ax,dx
cmp ebx,564D5868h
ret
endp detectvmware
;renvoie un pointer dx:ax vers la classe %0
PROC getpciclass FAR
ARG @class:word
USES di
mov di,[@class]
and di,0FFh
shl di,1
mov ax,[cs:offset classes+di]
mov dx,cs
ret
endp getpciclass
;renvoie un pointer dx:ax vers la sous-classe de %1 et de classe %0
PROC getpcisubclass FAR
ARG @class:word,@subclass:word
USES di
mov di,[@class]
and di,0FFh
shl di,1
mov di,[cs:offset classesd+di]
mov dx,[@subclass]
and dx,0FFh
cmp dx,80h
jne @@suiteac
mov ax,offset divers
jmp @@found
@@suiteac:
shl dx,1
add di,dx
mov ax,[cs:di]
@@found:
mov dx,cs
ret
endp getpcisubclass
divers db 'divers',0
classes:
dw offset class0
dw offset class1
dw offset class2
dw offset class3
dw offset class4
dw offset class5
dw offset class6
dw offset class7
dw offset class8
dw offset class9
dw offset class10
dw offset class11
dw offset class12
dw offset class13
dw offset class14
dw offset class15
dw offset class16
dw offset class17
class0 db 'ancien',0
class1 db 'stockage',0
class2 db 'reseau',0
class3 db 'affichage',0
class4 db 'multimedia',0
class5 db 'memoire',0
class6 db 'pont',0
class7 db 'communication',0
class8 db 'systeme',0
class9 db 'acquisition',0
class10 db 'dock',0
class11 db 'processeur',0
class12 db 'bus serie',0
class13 db 'sans fil',0
class14 db 'intelligent',0
class15 db 'satellite',0
class16 db 'cryptage',0
class17 db 'traitement signal',0
;Classes et sous classes
classesd:
dw offset class0d
dw offset class1d
dw offset class2d
dw offset class3d
dw offset class4d
dw offset class5d
dw offset class6d
dw offset class7d
dw offset class8d
dw offset class9d
dw offset class10d
dw offset class11d
dw offset class12d
dw offset class13d
dw offset class14d
dw offset class15d
dw offset class16d
dw offset class17d
class0d:
dw offset subclass00
dw offset subclass01
subclass00 db 'divers',0
subclass01 db 'vga',0
class1d:
dw offset subclass10
dw offset subclass11
dw offset subclass12
dw offset subclass13
dw offset subclass14
subclass10 db 'scsi',0
subclass11 db 'ide',0
subclass12 db 'disquette',0
subclass13 db 'ipi',0
subclass14 db 'raid',0
class2d:
dw offset subclass20
dw offset subclass21
dw offset subclass22
dw offset subclass23
dw offset subclass24
subclass20 db 'ethernet',0
subclass21 db 'token ring',0
subclass22 db 'fddi',0
subclass23 db 'atm',0
subclass24 db 'isdn',0
class3d:
dw offset subclass30
dw offset subclass31
dw offset subclass32
subclass30 db 'vga',0
subclass31 db 'xga',0
subclass32 db '3D',0
class4d:
dw offset subclass40
dw offset subclass41
dw offset subclass42
subclass40 db 'video',0
subclass41 db 'audio',0
subclass42 db 'telephonie',0
class5d:
dw offset subclass50
dw offset subclass51
subclass50 db 'ram',0
subclass51 db 'flash',0
class6d:
dw offset subclass60
dw offset subclass61
dw offset subclass62
dw offset subclass63
dw offset subclass64
dw offset subclass65
dw offset subclass66
dw offset subclass67
dw offset subclass68
subclass60 db 'hote',0
subclass61 db 'isa',0
subclass62 db 'eisa',0
subclass63 db 'mca',0
subclass64 db 'pci',0
subclass65 db 'pcmcia',0
subclass66 db 'nubus',0
subclass67 db 'cardbus',0
subclass68 db 'RACEway',0
class7d:
dw offset subclass70
dw offset subclass71
dw offset subclass72
dw offset subclass73
subclass70 db 'serie',0
subclass71 db 'parallele',0
subclass72 db 'serie multiport',0
subclass73 db 'modem',0
class8d:
dw offset subclass80
dw offset subclass81
dw offset subclass82
dw offset subclass83
dw offset subclass84
subclass80 db 'pic',0
subclass81 db 'dma',0
subclass82 db 'timer',0
subclass83 db 'rtc',0
subclass84 db 'hotplug',0
class9d:
dw offset subclass90
dw offset subclass91
dw offset subclass92
dw offset subclass93
dw offset subclass94
subclass90 db 'clavier',0
subclass91 db 'stylo',0
subclass92 db 'souris',0
subclass93 db 'scanner',0
subclass94 db 'joystick',0
class10d:
dw offset subclass100
subclass100 db 'station',0
class11d:
dw offset subclass110
dw offset subclass111
dw offset subclass112
dw offset subclass113
dw offset subclass114
subclass110 db '386',0
subclass111 db '486',0
subclass112 db 'pentium',0
subclass113 db 'alpha',0
subclass114 db 'coprocesseur',0
class12d:
dw offset subclass120
dw offset subclass121
dw offset subclass122
dw offset subclass123
dw offset subclass124
dw offset subclass125
subclass120 db 'firewire',0
subclass121 db 'access',0
subclass122 db 'ssa',0
subclass123 db 'usb',0
subclass124 db 'fibre',0
subclass125 db 'smbus',0
class13d:
dw offset subclass130
dw offset subclass131
dw offset subclass132
subclass130 db 'irda',0
subclass131 db 'ir',0
subclass132 db 'rf',0
class14d:
dw offset subclass140
subclass140 db 'IO arch',0
class15d:
dw offset subclass150
dw offset subclass151
dw offset subclass152
dw offset subclass153
subclass150 db 'tv',0
subclass151 db 'audio',0
subclass152 db 'voix',0
subclass153 db 'donnees',0
class16d:
dw offset subclass160
dw offset subclass161
subclass160 db 'reseau',0
subclass161 db 'jeux',0
class17d:
dw offset subclass170
subclass170 db 'dpio',0
;al=bus cl=deviceid ch=func es:di
PROC getcardinfo FAR
ARG @bus:word,@device:word,@function:word,@pointer:word
USES eax,bx,di
mov di,[@pointer]
cmp [@function],0
je @@amultiorfirst
call pcireadbyte,[@bus],[@device],0,offset (pcidata).typed
and al,multifunction
cmp al,0
jne @@amultiorfirst
mov [word ptr di],0000h
jmp @@notexist
@@amultiorfirst:
xor bx,bx
@@goinfos:
call pcireadword,[@bus],[@device],[@function],bx
inc bl
inc bl
cmp bl,2
ja @@notzarb
cmp ax,0FFFFh
je @@notexist
cmp ax,00000h
je @@notexist
@@notzarb:
mov [ds:di],ax
inc di
inc di
cmp bl,40h
jbe @@goinfos
clc
ret
@@notexist:
stc
ret
endp getcardinfo
;lit un octet du bus %0 device %1 function %2 nø %3 et le met en AL
PROC pcireadbyte FAR
ARG @bus:word,@device:word,@function:word,@pointer:word
USES bx,dx
mov al,[byte ptr @bus]
mov ah,80h
shl eax,16
mov ah,[byte ptr @device]
shl ah,3
or ah,[byte ptr @function]
mov bl,[byte ptr @pointer]
mov al,bl
and al,0fch
mov dx,config1addr
out dx,eax
mov dx,config1data
and bl,3
or dl,bl
in al,dx
ret
endp pcireadbyte
;lit 2 octet du bus %0 device %1 function %2 nø %3 et le met en AX
PROC pcireadword FAR
ARG @bus:word,@device:word,@function:word,@pointer:word
USES bx,dx
mov al,[byte ptr @bus]
mov ah,80h
shl eax,16
mov ah,[byte ptr @device]
shl ah,3
or ah,[byte ptr @function]
mov bl,[byte ptr @pointer]
mov al,bl
and al,0fch
mov dx,config1addr
out dx,eax
mov dx,config1data
and bl,3
or dl,bl
in ax,dx
ret
endp pcireadword
;lit 4 octet du bus %0 device %1 function %2 nø %3 et le met en EAX
PROC pcireaddword FAR
ARG @bus:word,@device:word,@function:word,@pointer:word
USES bx,dx
mov al,[byte ptr @bus]
mov ah,80h
shl eax,16
mov ah,[byte ptr @device]
shl ah,3
or ah,[byte ptr @function]
mov bl,[byte ptr @pointer]
mov al,bl
and al,0fch
mov dx,config1addr
out dx,eax
mov dx,config1data
and bl,3
or dl,bl
in eax,dx
ret
endp pcireaddword
;Prob avec str pci
;renvoie en %0 la structure pciinf carry if error
PROC pciinfo FAR
ARG @pointer:word
USES ax,bx,cx,edx,edi
mov ax,0B101h
xor edi,edi
mov edx," PCI"
int 1Ah
jc @@errorpci
cmp dx,04350h
jne @@errorpci
cmp ah,0
jne @@errorpci
mov di,[@pointer]
mov [(pciinf di).version_major],bh
mov [(pciinf di).version_minor],bl
mov [(pciinf di).types],al
mov [(pciinf di).maxbus],cl
clc
ret
@@errorpci:
stc
ret
endp pciinfo
;retourne en DS:%1 les set supporté du processeur par rapport a la struct %0
PROC setinfo FAR
ARG @pointer:word,@set:word
USES bx,si,di
mov di,[@set]
lea si,[ds:cpu.mmx]
add si,[@pointer]
mov bx,offset @@theset
@@set:
cmp [word ptr cs:bx],0FFFFh
je @@endofset
cmp [byte ptr si],1
jne @@nextset
push bx
mov bx,[cs:bx]
@@put:
mov al,[cs:bx]
cmp al,0
je @@enofput
mov [di],al
inc bx
inc di
jmp @@put
@@enofput:
pop bx
@@nextset:
inc bx
inc bx
inc si
jmp @@set
@@endofset:
mov [byte ptr di],0
ret
@@theset dw offset @@mmx
dw offset @@mmx2
dw offset @@sse
dw offset @@sse2
dw offset @@sse3
dw offset @@fpu
dw offset @@now3d
dw offset @@now3d2
dw offset @@htt
dw offset @@apic
dw 0FFFFh
@@mmx db "MMX ",0
@@mmx2 db "MMX2 ",0
@@now3d db "3dNow! ",0
@@now3d2 db "3dNow Extended! ",0
@@htt db "HyperThreading",0
@@sse db "SSE ",0
@@sse2 db "SSE2 ",0
@@sse3 db "SSE3 ",0
@@apic db "APIC ",0
@@fpu db "FPU ",0
endp setinfo
;retourne en DS:%0 les capacités du processeur
PROC cpuinfo FAR
ARG @pointer:word
USES eax,ebx,ecx,edx,si,di,ds,es
push ds
pop es
mov di,[@pointer]
mov al,0
mov cx,size cpu
cld
rep stosb
mov di,[@pointer]
call nocpuid ;Test si cpuid est dispo
je @@nocpuidatall
xor eax,eax
cpuid ;Fonction 0 de CPUID
mov [dword ptr (cpu di).vendor],ebx ;Vendeur sur 13 octets
mov [dword ptr (cpu di+4).vendor],edx
mov [dword ptr (cpu di+8).vendor],ecx
mov [byte ptr (cpu di+12).vendor],0
cmp eax,1
jb @@nofonc1
mov eax,1
cpuid ;Fonction 1 de CPUID
mov ebx,eax ;infos de model
and ebx,1111b
mov [(cpu di).stepping],bl
shr eax,4
mov ebx,eax
and ebx,1111b
mov [(cpu di).models],bl
shr eax,4
mov ebx,eax
and ebx,1111b
mov [(cpu di).family],bl
shr eax,4
mov ebx,eax
and ebx,11b
mov [(cpu di).types],bl
shr eax,2
mov ebx,eax
and ebx,1111b
mov [(cpu di).emodels],bl
shr eax,4
mov [(cpu di).efamily],al
mov ebx,edx
and ebx,1 ;infos de jeu d'instruction
setnz [(cpu di).fpu]
mov ebx,edx
and ebx,100000000000000000000000b
setnz [(cpu di).mmx]
mov ebx,edx
and ebx,10000000000000000000000000b
setnz [(cpu di).sse]
mov ebx,edx
and ebx,100000000000000000000000000b
setnz [(cpu di).sse2]
mov ebx,ecx
and ebx,1b
setnz [(cpu di).sse3]
mov ebx,edx
and ebx,10000000000000000000000000000b
setnz [(cpu di).htt]
@@nofonc1:
mov eax,80000000h ;Fonction 80000000 de CPUID
cpuid
cmp eax,80000001h
jb @@nofonc8
mov eax,80000001h ;Fonction 80000000 de CPUID
cpuid
mov ebx,edx
and ebx,10000000000000000000000b
setnz [(cpu di).mmx2]
mov ebx,edx
and ebx,1000000000000000000000000000000b
setnz [(cpu di).now3d]
mov ebx,edx
and ebx,10000000000000000000000000000000b
setnz [(cpu di).now3d2]
mov ebx,edx
and ebx,1000000000b
setnz [(cpu di).apic]
@@nofonc8:
mov si,offset @@marks
push cs
pop ds
@@search:
mov di,[@pointer]
mov cx,12
cld
rep cmpsb
jne @@notthegood
cmp cx,0
jne @@notthegood
mov cl,[si]
inc si
mov di,[@pointer]
cld
rep movsb
mov al,0
stosb
mov di,[@pointer]
cmp [es:(cpu di).family],15
jne @@notextended
mov al,[es:(cpu di).efamily]
mov ah,[es:(cpu di).emodels]
mov di,[si+2]
jmp @@searchmodel
@@notextended:
mov al,[es:(cpu di).family]
mov ah,[es:(cpu di).models]
mov di,[si]
@@searchmodel:
cmp [di],ax
jne @@notgoodfamily
mov si,di
inc si
inc si
lea di,[es:cpu.names]
add di,[@pointer]
@@copystr:
mov al,[si]
mov [es:di],al
inc si
inc di
cmp al,0
jne @@copystr
jmp @@endofsearch
@@notgoodfamily:
inc di
@@nextelement:
inc di
cmp [byte ptr di-1],0
jne @@nextelement
jmp @@searchmodel
@@notthegood:
inc si
cmp [word ptr si],0FFFFh
jne @@notthegood
inc si
inc si
cmp [word ptr si],0FFFFh
je @@endofsearch
jmp @@search
@@endofsearch:
ret
@@nocpuidatall:
ret
;tableau avec vendeur taille + chainereelle + pointeur famille + pointeur famille etendue
@@marks db "GenuineIntel",5,"Intel"
dw @@intelfamily,@@intelfamilye
dw 0FFFFh
db "AuthenticAMD",3,"Amd"
dw @@amdfamily,@@amdfamilye
dw 0FFFFh
db "CyrixInstead",5,"Cyrix"
dw @@cyrixfamily,@@cyrixfamilye
dw 0FFFFh
dw 0FFFFh
;tableau avec famille modele et chaine 0
@@intelfamily:
db 4,0,"486 DX-25/33",0
db 4,1,"486 DX-50",0
db 4,2,"486 SX",0
db 4,3,"486 DX/2",0
db 4,4,"486 SL",0
db 4,5,"486 SX/2",0
db 4,7,"486 DX/2-WB",0
db 4,8,"486 DX/4",0
db 4,9,"486 DX/4-WB",0
db 5,0,"Pentium 60/66 A-step",0
db 5,1,"Pentium 60/66",0
db 5,2,"Pentium 75 - 200",0
db 5,3,"OverDrive PODP5V83",0
db 5,4,"Pentium MMX",0
db 5,7,"Mobile Pentium 75-200",0
db 5,8,"Mobile Pentium MMX",0
db 6,0,"Pentium Pro A-step",0
db 6,1,"Pentium Pro",0
db 6,3,"Pentium II (Klamath)",0
db 6,5,"Pentium II (Deschutes)",0
db 6,6,"Mobile Pentium II",0
db 6,7,"Pentium III (Katmai)",0
db 6,8,"Pentium III (Coppermine)",0
db 6,9,"Mobile Pentium III",0
db 6,10,"Pentium III (0.18 µm)",0
db 6,11,"Pentium III (0.13 µm)",0
db 7,0,"Itanium (IA-64)",0
db 0FFh,0FFh,"Inconnu",0
@@intelfamilye:
db 0,0,"Pentium IV (0.18 µm)",0
db 0,1,"Pentium IV (0.18 µm)",0
db 0,2,"Pentium IV (0.13 µm)",0
db 0,3,"Pentium IV (0.09 µm)",0
db 1,0,"Itanium 2 (IA-64)",0
db 0FFh,0FFh,"Inconnu",0
@@amdfamily:
db 4,3,"486 DX/2",0
db 4,7,"486 DX/2-WB",0
db 4,8,"486 DX/4",0
db 4,9,"486 DX/4-WB",0
db 4,14,"Am5x86-WT",0
db 4,15,"Am5x86-WB",0
db 5,0,"K5/SSA5",0
db 5,1,"K5 (PR120/133)",0
db 5,2,"K5 (PR166)",0
db 5,3,"K5 (PR200)",0
db 5,6,"K6 (0.30 µm)",0
db 5,7,"K6 (0.25 µm)",0
db 5,8,"K6-2",0
db 5,9,"K6-3",0
db 5,13,"K6-2+/K6-III+ (0.18 µm)",0
db 6,0,"Athlon (25 µm)",0
db 6,1,"Athlon (25 µm)",0
db 6,2,"Athlon (18 µm)",0
db 6,3,"Duron",0
db 6,4,"Athlon (Thunderbird)",0
db 6,6,"Athlon (Palamino)",0
db 6,7,"Duron (Morgan)",0
db 6,8,"Athlon (Thoroughbred)",0
db 6,10,"Athlon (Barton)",0
db 0FFh,0FFh,"Inconnu",0
@@amdfamilye:
db 0,4,"Athlon 64",0
db 0,5,"Athlon 64 FX/Opteron",0
db 0FFh,0FFh,"Inconnu",0
@@cyrixfamily:
db 4,4,"MediaGX",0
db 5,2,"6x86/6x86L",0
db 5,4,"MediaGX MMX Enhanced",0
db 6,0,"MII (6x86MX)",0
db 6,5,"VIA Cyrix M2 core",0
db 6,6,"WinChip C5A",0
db 6,7,"WinChip C5B/WinChip C5C",0
db 6,8,"WinChip C5N",0
db 6,9,"WinChip C5XL/WinChip C5P",0
db 0FFh,0FFh,"Inconnu",0
@@cyrixfamilye:
db 0FFh,0FFh,"Inconnu",0
endp cpuinfo
;Test si CPUID est supporté oui=not Equal
nocpuid:
pushfd
pop eax
xor eax,00200000h
push eax
popfd
pushfd
pop eax
cmp eax,ebx
ret

993
lib/str0.asm Normal file
View File

@ -0,0 +1,993 @@
model tiny,stdcall
p586N
locals
jumps
codeseg
option procalign:byte
include "..\include\mem.h"
include "..\include\divers.h"
org 0h
header exe <"CE",1,0,0,offset exports,,,>
exporting
declare checksyntax
declare cmpitems
declare gettypeditem
declare gettyped
declare whatisitem
declare whatis
declare strtoadress
declare strisadress
declare strisname
declare strisbase
declare strtoint
declare left
declare right
declare middle
declare fill
declare replaceallchar
declare searchchar
declare invert
declare cmpstr
declare evalue
declare insert
declare delete
declare copy
declare concat
declare compressdelimiter
declare setnbitems
declare getitemsize
declare getitem
declare getpointeritem
declare getnbitems
declare getlength
declare setlength
declare uppercase
declare onecase
declare lowercase
declare invertcase
ende
;Librairie qui prend en charge le format de STR ASCIIZ
;# nombre 8
;? str 7
;& nom 6
;High Low
;0 variable 4 hex
;1 byte 3 dec
;2 word 2 oct
;3 3 octets 1 bin
;4 dword 5 adresse
;5 5 octets 6 nom
;6 ... 7 str
; 8 nombre
;Renvoie carry si la syntaxe de ds:si n'est pas respect par rapport a es:di
PROC checksyntax FAR
ARG @src:word,@dest:word,@delim:word
USES ax,bx,cx,dx,si,di,ds,es
LOCAL @@temp:word:256
push ss
pop es
lea si,[@@temp]
mov di,[@dest]
call copy,[@src],si
call xch
call compressdelimiter,si,[@delim]
call getnbitems,si,[@delim]
mov bx,ax
call xch
call getnbitems,di,[@delim]
cmp bx,ax
jne @@notequalatall
xor cx,cx
@@itemer:
call xch
call whatisitem,si,cx,[@delim]
mov dx,ax
call xch
call whatisitem,di,cx,[@delim]
cmp ax,dx
jne @@prob
cmp al,6
jb @@equal
call cmpitems
je @@equal
@@prob:
cmp dl,4
ja @@nonumber
cmp dl,8
je @@equal
;cmp al,4
;jne @@notequalatall
cmp dh,ah
ja @@notequalatall
jmp @@equal
@@nonumber:
cmp al,7
jne @@nostr
cmp ah,0
jne @@notequalatall
jmp @@equal
@@nostr:
cmp al,6
jne @@noname
cmp dl,6
jne @@noname
cmp ah,0
jne @@notequalatall
jmp @@equal
@@noname:
cmp al,8
je @@equal
jmp @@notequalatall
@@equal:
inc cx
cmp cx,bx
jne @@itemer
cld
@@ackno:
ret
@@notequalatall:
stc
jmp @@ackno
endp checksyntax
xch:
push es
push ds
pop es
pop ds
ret
;Compare les lments cx de deux chaine ds:si et es:di
PROC cmpitems FAR
ARG @src:word,@dest:word,@item:word,@delim:word
USES ax,cx,si,di,es
push ds
pop es
call getpointeritem,[@src],[@item],[@delim]
mov si,ax
call getitemsize,[@src],[@item],[@delim]
mov di,[@dest]
mov cx,ax
cld
rep cmpsb
clc
ret
endp cmpitems
;Renvoie l'lment cx de ds:si dans edx si nb et dans es:di si str ou name
PROC gettypeditem FAR
ARG @src:word,@item:word,@delim:word
USES bx,cx,si,di
mov si,[@src]
mov cx,[@item]
call getpointeritem,si,cx,[@delim]
mov di,ax
inc cx
call getpointeritem,si,cx,[@delim]
mov si,ax
dec si
mov cl,0
xchg cl,[ds:si]
call gettyped,di
xchg cl,[ds:si]
clc
ret
endp gettypeditem
;Renvoie eax si nb et dans ds:eax si str ou name
PROC gettyped FAR
ARG @src:word
USES si
mov si,[@src]
xor eax,eax
call whatis,si
cmp al,1
je @@bin
cmp al,2
je @@oct
cmp al,3
je @@dec
cmp al,4
je @@hex
cmp al,5
je @@pointer
mov ax,si
jmp @@endofgettypeditem
@@bin:
call strtoint,si,2
jmp @@endofgettypeditem
@@oct:
call strtoint,si,8
jmp @@endofgettypeditem
@@dec:
call strtoint,si,10
jmp @@endofgettypeditem
@@hex:
call strtoint,si,16
jmp @@endofgettypeditem
@@pointer:
call strtoadress,si
@@endofgettypeditem:
clc
ret
endp gettyped
;Renvoie dans ax le type de la str0 pointe par ds:%0 lment %1 delim %3
PROC whatisitem FAR
ARG @src:word,@item:word,@delim:word
USES bx,cx,si,di
mov si,[@src]
mov cx,[@item]
call getpointeritem,si,cx,[@delim]
mov di,ax
inc cx
call getpointeritem,si,cx,[@delim]
mov si,ax
dec si
mov cl,0
xchg cl,[ds:si]
call whatis,di
xchg cl,[ds:si]
clc
ret
endp whatisitem
;Renvoie dans ax le type de la str0 pointe par ds:%0
;High Low
;0 variable 4 hex
;1 byte 3 dec
;2 word 2 oct
;3 3 octets 1 bin
;4 dword 5 adresse
;5 5 octets 6 name
;6 ... 7 str
PROC whatis FAR
ARG @src:word
USES bx,cx,edx,si
mov si,[@src]
xor cx,cx
mov cl,2
call strisbase,si,cx
jnc @@finbase
mov cl,8
call strisbase,si,cx
jnc @@finbase
mov cl,10
call strisbase,si,cx
jnc @@finbase
mov cl,16
call strisbase,si,cx
jc @@testadress
@@finbase:
mov bx,cx
xor ch,ch
mov al,[cs:bx+offset basenn-2]
push eax
call strtoint,si,cx
mov edx,eax
pop eax
cmp edx,0000FFFFh
ja @@bits32
cmp dx,00FFh
ja @@bits16
mov ah,1
jmp @@endofwhat
@@bits16:
mov ah,2
jmp @@endofwhat
@@bits32:
mov ah,4
jmp @@endofwhat
@@testadress:
call strisadress,si
jc @@testname
mov ax,0005h
jmp @@endofwhat
@@testname:
call strisname
jc @@testnumber
xor ah,ah
cmp [byte ptr si],'&'
je @@okname
call getlength,si
mov ah,al
@@okname:
mov al,06h
jmp @@endofwhat
@@testnumber:
cmp [byte ptr si],'#'
jne @@testvarstr
xor ah,ah
mov al,08h
jmp @@endofwhat
@@testvarstr:
xor ah,ah
cmp [byte ptr si],'?'
je @@okvarstr
call getlength,si
mov ah,al
@@okvarstr:
mov al,07h
@@endofwhat:
clc
ret
endp whatis
;Renvoie non carry si la str ds:si pointe peut ˆtre une adresse
PROC strtoadress FAR
;push
stc
;pop
ret
endp strtoadress
;Renvoie en es:di le pointeur str0 ds:si
PROC strisadress FAR
;push
stc
;pop
ret
endp strisadress
;Renvoie non carry si la str ds:%0 pointe peut ˆtre un nom de fichier
PROC strisname FAR
ARG @src:word
USES ax,si,di
mov si,[@src]
@@isname:
mov al,[si]
inc si
cmp al,0
je @@itsok
mov di,offset non
@@verify:
mov ah,[cs:di]
inc di
cmp ah,0FFh
je @@isname
cmp ah,al
jne @@verify
stc
jmp @@itsdead
@@itsok:
clc
@@itsdead:
ret
endp strisname
non db '/<>|"?*:\',01,0FFh
;Renvoie non carry si le texte point par %0 est de la base %1
PROC strisbase FAR
ARG @src:word,@base:word
USES ax,cx,si,di,es
push cs
pop es
mov si,[@src]
@@isstrbase:
mov al,[si]
cmp al,0
je @@okbase
mov cx,[@base]
xor ch,ch
mov di,cx
cmp al,[es:di-2+offset basen]
je @@verifbase
xor ch,ch
inc cl
mov di,offset base
cld
repne scasb
cmp cx,0
je @@nobase
inc si
jmp @@isstrbase
@@okbase:
clc
@@endbase:
ret
@@verifbase:
cmp [byte ptr si+1],0
je @@okbase
@@nobase:
stc
jmp @@endbase
endp strisbase
base db '0123456789ABCDEF'
basen db 'b o d h'
basenn db 1,0,0,0,0,0,2,0,3,0,0,0,0,0,4
;Converti un str %0 de base %1 en int dans eax
PROC strtoint FAR
ARG @src:word,@base:word
USES ebx,ecx,edx,si,edi,es
push cs
pop es
mov si,[@src]
@@gotos:
cmp [byte ptr si+1], 0
je @@oklo
inc si
jmp @@gotos
@@oklo:
mov edi,1
xor ebx,ebx
@@baseto:
cmp [@src],si
ja @@endbaseto
mov al,[si]
xor ecx,ecx
mov cl,[byte ptr @base]
inc cl
push di
mov di,offset base
cld
repne scasb
pop di
jne @@noop
sub cl,[byte ptr @base]
neg cl
mov eax,edi
mul ecx
add ebx,eax
mov eax,edi
mov cl,[byte ptr @base]
mul ecx
mov edi,eax
@@noop:
dec si
jmp @@baseto
@@endbaseto:
mov eax,ebx
clc
ret
endp strtoint
;Renvoie en ds:%1 la partie de %2 caractŠres a partir de la gauche de ds:%0
PROC left FAR
ARG @src:word,@dest:word,@nb:word
USES ax,cx,si,di,es
push ds
pop es
mov si,[@src]
mov di,[@dest]
mov cx,[@nb]
cld
rep movsb
mov al,0
stosb
clc
ret
endp left
;Renvoie en ds:%1 la partie de %2 caractŠres a partir de la droite de ds:%0
PROC right FAR
ARG @src:word,@dest:word,@nb:word
USES ax,cx,si,di,es
push ds
pop es
mov si,[@src]
mov di,[@dest]
call getlength,si
add si,ax
sub si,[@nb]
mov cx,[@nb]
cld
rep movsb
mov al,0
stosb
clc
ret
endp right
;Renvoie en ds:%1 la partie de %3 caractŠres a partir de la position %2 de ds:%0
PROC middle FAR
ARG @src:word,@dest:word,@item:word,@nb:word
USES ax,cx,si,di,es
push ds
pop es
mov si,[@src]
mov di,[@dest]
mov cx,[@nb]
add si,[@item]
cld
rep movsb
mov al,0
stosb
clc
ret
endp middle
;Rempli de %3 caractŠres %2 a partir de la position %1 de ds:%0
PROC fill FAR
ARG @src:word,@item:word,@char:word,@nb:word
USES ax,cx,si,di,es
push ds
pop es
mov di,[@src]
add di,[@item]
mov ax,[@char]
mov cx,[@nb]
cld
rep stosb
clc
ret
endp fill
;Remplace tout les caractŠres %1 de ds:%0 par des caractŠres %2
PROC replaceallchar FAR
ARG @src:word,@char1:word,@char2:word
USES ax,cx,dx,di,es
mov di,[@src]
call getlength,di
mov cx,ax
mov ax,[@char1]
mov dx,[@char2]
push ds
pop es
@@findandchange:
repne scasb
cmp cx,0
je @@endofchange
mov [es:di-1],dl
jmp @@findandchange
@@endofchange:
clc
ret
endp replaceallchar
;Recherche un caractŠre dl dans la chaŒne ds:%0
PROC searchchar FAR
ARG @src:word,@char:word
USES cx,di,es
mov di,[@src]
call getlength,di
mov cx,ax
push ds
pop es
mov ax,[@char]
repne scasb
mov ax,di
dec ax
clc
ret
endp searchchar
;Inverse la chaine pointe en ds:%0
PROC invert FAR
ARG @src:word
USES ax,cx,si,di
mov si,[@src]
call getlength,si
mov di,si
add di,ax
dec di
@@revert:
mov al,[si]
xchg al,[di]
mov [si],al
inc si
dec di
cmp si,di
ja @@finishinvert
dec di
cmp si,di
ja @@finishinvert
inc di
jmp @@revert
@@finishinvert:
clc
ret
endp invert
;Compares 2 chaines de caractŠres DS:%0 et DS:%1 zerof si non equal
PROC cmpstr FAR
ARG @src:word,@dest:word
USES cx,dx,si,di
push ds
pop es
mov si,[@src]
mov di,[@dest]
call getlength,di
mov cx,ax
call getlength,si
cmp cx,ax
jne @@notequal
repe cmpsb
@@notequal:
ret
endp cmpstr
;Compares 2 chaines de caractŠres DS:%0 et DS:%1 zerof si non equal et renvoie le nb de caractŠre egaux dans ax
PROC evalue FAR
ARG @src:word,@dest:word
USES cx,si,di,es
push ds
pop es
mov si,[@src]
mov di,[@dest]
call getlength ,di
mov cx,ax
repe cmpsb
pushf
jne @@noident
sub ax,cx
popf
clc
ret
@@noident:
sub ax,cx
dec ax
popf
clc
ret
endp evalue
;Insert une chaine ds:%0 en ds:%1 a partir du caractŠre %2
PROC insert FAR
ARG @src:word,@dest:word,@item:word
USES ax,cx,si,di,es
push es
pop ds
mov si,[@dest]
call getlength,si
mov cx,ax
add si,ax
mov di,si
call getlength,[@src]
add di,ax
sub cx,[@item]
inc cx
std
rep movsb
mov si,[@src]
mov di,[@dest]
add di,[@item]
mov cx,ax
cld
rep movsb
clc
ret
endp insert
;Detruit %2 caractŠres a partir du caractŠre %1 de DS:%0
PROC delete FAR
ARG @src:word,@item:word,@size:word
USES ax,cx,dx,si,di,es
push ds
pop es
mov si,[@src]
call getlength,si
mov cx,ax
sub cx,[@size]
sub cx,[@item]
inc cx
add si,[@item]
mov di,si
add si,[@size]
cld
rep movsb
clc
ret
endp delete
;Copie une chaine de ds:si en es:di
PROC copy FAR
ARG @src:word,@dest:word
USES ax,cx,si,di
mov si,[@src]
mov di,[@dest]
call getlength,si
mov cx,ax
cld
rep movsb
mov al,0
stosb
clc
ret
endp copy
;ConcatŠne le chaine ds:si avec ds:di
PROC concat FAR
ARG @src:word,@dest:word
USES ax,cx,si,di,es
push ds
pop es
mov si,[@src]
call getlength,si
mov cx,ax
mov di,[@dest]
call getlength,di
add di,ax
cld
rep movsb
mov al,0
stosb
clc
ret
endp concat
;Dtruit les dlimiteur qui sont conscutifs dans ds:%0 -> renvoie le nb d'item
PROC compressdelimiter FAR
ARG @src:word,@delim:word
USES cx,dx,si,di,es
mov di,[@src]
call getlength,di
mov cx,ax
push ds
pop es
mov ax,[@delim]
xor dx,dx
@@compressitems:
repne scasb
inc dx
@@againcomp:
cmp [di],al
jne @@nosup
call delete,di,0,1
jmp @@againcomp
@@nosup:
cmp cx,0
jne @@compressitems
mov ax,dx
clc
ret
endp compressdelimiter
;Met le nombre d'lments de ds:%0 à %1
PROC setnbitems FAR
ARG @src:word,@size:word,@delim:word
USES ax,cx,di,es
mov di,[@src]
cmp [@size],0
je @@onlyzero
call getnbitems,di,[@delim]
cmp [@size],ax
je @@noadjust
jb @@subsome
push ds
pop es
sub ax,[@size]
neg ax
mov cx,ax
call getlength,di
add di,ax
mov ax,[@delim]
mov ah,'a'
rep stosw
xor al,al
stosb
jmp @@noadjust
@@subsome:
call getpointeritem,[@src],[@size],[@delim]
dec ax
mov di,ax
@@onlyzero:
mov [byte ptr di],0
@@noadjust:
clc
ret
endp setnbitems
;Renvoie la taille ax de l'lment %0
PROC getitemsize FAR
ARG @src:word,@item:word,@delim:word
USES cx,dx
mov cx,[@item]
call getpointeritem,[@src],cx,[@delim]
mov dx,ax
inc cx
call getpointeritem,[@src],cx,[@delim]
sub ax,dx
dec ax
clc
ret
endp getitemsize
;Renvoie en ds:%1 l'lment %2 de ds:%0
PROC getitem FAR
ARG @src:word,@dest:word,@item:word,@delim:word
USES ax,cx,si,di,es
push ds
pop es
call getpointeritem,[@src],[@item],[@delim]
mov si,ax
call getitemsize,[@src],[@item],[@delim]
mov di,[@dest]
mov cx,ax
cld
rep movsb
mov al,0
stosb
clc
ret
endp getitem
;renvoi un pointeur ax sur l'lment %1 de ds:%0
PROC getpointeritem FAR
ARG @src:word,@item:word,@delim:word
USES cx,dx,di,es
mov di,[@src]
cmp [@item],0
je @@finishpointer
push ds
pop es
call getlength,di
mov cx,ax
push ds
pop es
mov ax,[@delim]
xor dx,dx
@@countnbitems:
cmp [@item],dx
je @@finishpointer
cld
repne scasb
inc dx
cmp cx,0
jne @@countnbitems
inc di
@@finishpointer:
mov ax,di
clc
ret
endp getpointeritem
;Renvoie le nombre d'lments ax de ds:%0
PROC getnbitems FAR
ARG @src:word,@delim:word
USES cx,dx,di,es
mov di,[@src]
call getlength,di
mov cx,ax
push ds
pop es
mov ax,[@delim]
xor dx,dx
cld
@@countitems:
repne scasb
inc dx
cmp cx,0
jne @@countitems
mov ax,dx
clc
ret
endp getnbitems
;renvoie la taille en octets AX de la chaine pointe en ds:%0
PROC getlength FAR
ARG @src:word
USES cx,di,es
push ds
pop es
mov di,[@src]
mov al,0
mov cx,0FFFFh
cld
repne scasb
neg cx
dec cx
dec cx
mov ax,cx
clc
ret
endp getlength
;Met la taille en octets de la chaine pointe ds:%0 a %1
PROC setlength FAR
ARG @src:word,@size:word
USES si
mov si,[@src]
add si,[@size]
mov [byte ptr si],0
clc
ret
endp setlength
;met en majuscule la chaine ds:%0
PROC uppercase FAR
ARG @src:word
USES si,ax
mov si,[@src]
@@uppercase:
mov al,[ds:si]
inc si
cmp al,0
je @@enduppercase
cmp al,'a'
jb @@uppercase
cmp al,'z'
ja @@uppercase
sub [byte ptr si-1],'a'-'A'
jmp @@uppercase
@@enduppercase:
clc
ret
endp uppercase
;met en majuscule la premiŠre lettre chaine ds:%0
PROC onecase FAR
ARG @src:word
USES ax
mov si,[@src]
mov al,[ds:si]
cmp al,'a'
jb @@oneenduppercase
cmp al,'z'
ja @@oneenduppercase
sub [byte ptr si],'a'-'A'
@@oneenduppercase:
clc
ret
endp onecase
;met en minuscule la chaine ds:%0
PROC lowercase FAR
ARG @src:word
USES si,ax
mov si,[@src]
@@lowercase:
mov al,[ds:si]
inc si
cmp al,0
je @@endlowercase
cmp al,'A'
jb @@lowercase
cmp al,'Z'
ja @@lowercase
add [byte ptr si-1],'a'-'A'
jmp @@lowercase
@@endlowercase:
clc
ret
endp lowercase
;Inverse la casse la chaine ds:%0
PROC invertcase FAR
ARG @src:word
USES si,ax
mov si,[@src]
@@invertcase:
mov al,[ds:si]
inc si
cmp al,0
je @@endinvertcase
cmp al,'A'
jb @@invertcase
cmp al,'Z'
jbe @@goinvertcase
cmp al,'a'
jb @@invertcase
cmp al,'z'
ja @@invertcase
sub [byte ptr si-1],'a'-'A'
jmp @@invertcase
@@goinvertcase:
add [byte ptr si-1],'a'-'A'
jmp @@invertcase
@@endinvertcase:
clc
ret
endp invertcase

891
lib/video.asm Normal file
View File

@ -0,0 +1,891 @@
model tiny,stdcall
p486
locals
jumps
codeseg
option procalign:byte
include "..\include\mem.h"
org 0h
header exe <"CE",1,0,0,offset exports,offset imports,,>
exporting
declare print
declare showdate
declare showtime
declare showname
declare showattr
declare showsize
declare showspace
declare showint
declare showsigned
declare showhex
declare showbin
declare showbcd
declare showstring
declare showstring0
declare showintr
declare showintl
declare showchar
ende
importing
use VIDEO,addline
use VIDEO,setcolor
use VIDEO,getxy
use VIDEO,setxy
use VIDEO,setvideomode
use VIDEO,setfont
use VIDEO,clearscreen
use VIDEO,enablescroll
use VIDEO,disablescroll
use VIDEO,showchars
use VIDEO,savestate
use VIDEO,restorestate
endi
;================PRINT==============
;Affiche la chaine %0 en utilisant les parametres de formatage %x....%x
;-> %0 %x
;<-
;===================================
PROC print FAR
ARG @@pointer:word
push ax bx cx si di
xor di,di
mov si,[@@pointer]
@@strinaize0:
mov cl,[si]
cmp cl,0
je @@no0
cmp cl,'%'
je @@special
cmp cl,'\'
je @@special2
@@showit:
xor ch,ch
call [cs:showchars],cx,0FFFFh
inc si
jmp @@strinaize0
@@special:
cmp [byte ptr si+1],'%'
jne @@notshowit
inc si
jmp @@showit
@@notshowit:
mov cl,[byte ptr si+1]
cmp cl,'c'
je @@showchars
cmp cl,'u'
je @@showint
cmp cl,'v'
je @@showfixint
cmp cl,'w'
je @@showintr
cmp cl,'i'
je @@showsigned
cmp cl,'h'
je @@showhex
cmp cl,'b'
je @@showbin
cmp cl,'s'
je @@showstring
cmp cl,'0'
je @@showstring0
cmp cl,'y'
je @@showbcd
cmp cl,'z'
je @@showsize
cmp cl,'a'
je @@showattr
cmp cl,'n'
je @@showname
cmp cl,'t'
je @@showtime
cmp cl,'d'
je @@showdate
clc
jmp @@no0
@@showchars:
cmp [byte ptr si+2],'M'
je @@showmultchar
call [cs:showchars],[word ptr @@pointer+di+2],0FFFFh
add si,2
add di,2
jmp @@strinaize0
@@showmultchar:
mov cx,[offset @@pointer+di+2+2]
cmp cx,0
je @@nextfunc
@@showcharsx:
call [cs:showchars],[word ptr @@pointer+di+2],0FFFFh
dec cx
jnz @@showcharsx
@@nextfunc:
add si,3
add di,4
jmp @@strinaize0
@@showint:
call showint,[dword ptr @@pointer+di+2]
add si,2
add di,4
jmp @@strinaize0
@@showfixint:
call showintl,[word ptr @@pointer+di+6],[dword ptr @@pointer+di+2]
add di,6
add si,2
jmp @@strinaize0
@@showintr:
call showintr,[word ptr @@pointer+di+6],[dword ptr @@pointer+di+2]
add di,6
add si,2
jmp @@strinaize0
@@showsigned:
call @@Chosesize
call showsigned
jmp @@strinaize0
@@showhex:
call @@Chosesize
call showhex
jmp @@strinaize0
@@showbin:
call @@Chosesize
call showbin
jmp @@strinaize0
@@showstring:
cmp [byte ptr si+2],'P'
je @@showstring@@pointer
call showstring,[word ptr @@pointer+di+2]
add si,2
add di,2
jmp @@strinaize0
@@showstring@@pointer:
push ds
mov ds,[offset @@pointer+di+2+2]
call showstring,[word ptr @@pointer+di+2]
add si,3
add di,4
pop ds
jmp @@strinaize0
@@showstring0:
cmp [byte ptr si+2],'P'
je @@showstring0@@pointer
call showstring0,[word ptr offset @@pointer+di+2]
add si,2
add di,2
jmp @@strinaize0
@@showstring0@@pointer:
push ds
mov ds,[offset @@pointer+di+2+2]
call showstring0,[word ptr offset @@pointer+di+2]
add si,3
add di,4
pop ds
jmp @@strinaize0
@@showbcd:
call @@Chosesize
call showbcd
jmp @@strinaize0
@@showsize:
call showsize,[dword ptr offset @@pointer+di+2]
add si,2
add di,4
jmp @@strinaize0
@@showattr:
call showattr,[word ptr offset @@pointer+di+2]
add si,2
add di,2
jmp @@strinaize0
@@showname:
call showname,[word ptr offset @@pointer+di+2]
add si,2
add di,2
jmp @@strinaize0
@@showtime:
call showtime,[word ptr offset @@pointer+di+2]
add si,2
add di,2
jmp @@strinaize0
@@showdate:
call showdate,[word ptr offset @@pointer+di+2]
add si,2
add di,2
jmp @@strinaize0
@@Chosesize:
pop cx
push [dword ptr offset @@pointer+di+2]
add di,4
cmp [byte ptr si+2],'B'
je @@byte
cmp [byte ptr si+2],'W'
je @@word
cmp [byte ptr si+2],'D'
je @@dword
dec si
@@word:
push 16
add si,3
push cx
retn
@@byte:
push 8
add si,3
push cx
retn
@@dword:
push 32
add si,3
push cx
retn
@@special2:
cmp [byte ptr si+1],'\'
jne @@notshowit2
inc si
jmp @@showit
@@notshowit2:
mov cl,[byte ptr si+1]
cmp cl,'l'
je @@showline
cmp cl,'g'
je @@goto
cmp cl,'h'
je @@gotox
cmp cl,'c'
je @@color
cmp cl,'m'
je @@setvideomode
cmp cl,'e'
je @@clearscreen
cmp cl,'s'
je @@savestate
cmp cl,'r'
je @@restorestate
cmp cl,'i'
je @@enablescroll
cmp cl,'j'
je @@disablescroll
cmp cl,'f'
je @@setfont
clc
jmp @@no0
@@color:
mov al,[si+2]
sub al,'0'
shl al,4
add al,[si+3]
sub al,'0'
xor ah,ah
call [cs:setcolor],ax
add si,4
jmp @@strinaize0
@@gotox:
mov bh,[si+2]
sub bh,'0'
mov bl,bh
shl bl,3
add bl,bh
add bl,bh
add bl,[si+3]
sub bl,'0'
xor bh,bh
call [cs:getxy]
xor ah,ah
call [cs:setxy],bx,ax
add si,4
jmp @@strinaize0
@@setvideomode:
mov ah,[si+2]
sub ah,'0'
mov al,ah
shl al,3
add al,ah
add al,ah
add al,[si+3]
sub al,'0'
xor ah,ah
call [cs:setvideomode],ax
add si,4
jmp @@strinaize0
@@setfont:
mov ah,[si+2]
sub ah,'0'
mov al,ah
shl al,3
add al,ah
add al,ah
add al,[si+3]
sub al,'0'
xor ah,ah
call [cs:setfont],ax
add si,4
jmp @@strinaize0
@@showline:
call [cs:addline]
add si,2
jmp @@strinaize0
@@clearscreen:
call [cs:clearscreen]
add si,2
jmp @@strinaize0
@@savestate:
call [cs:savestate]
add si,2
jmp @@strinaize0
@@restorestate:
call [cs:restorestate]
add si,2
jmp @@strinaize0
@@enablescroll:
call [cs:enablescroll]
add si,2
jmp @@strinaize0
@@disablescroll:
call [cs:disablescroll]
add si,2
jmp @@strinaize0
@@goto:
mov ah,[si+2]
sub ah,'0'
mov al,ah
shl al,3
add al,ah
add al,ah
add al,[si+3]
sub al,'0'
xor ah,ah
;
mov bh,[si+5]
sub bh,'0'
mov bl,bh
shl bl,3
add bl,bh
add bl,bh
add bl,[si+6]
sub bl,'0'
xor bh,bh
call [cs:setxy],ax,bx
add si,7
jmp @@strinaize0
@@no0:
add di,bp
mov ax,[ss:bp] ;BP
mov bx,[ss:bp+2] ;IP
mov cx,[ss:bp+4] ;CS
mov [ss:di],ax
mov [ss:di+2],bx
mov [ss:di+4],cx
mov bp,di
pop di si cx bx ax
mov sp,bp
ret
ENDP print
;================SHOWDATE==============
;Affiche la date contenu en %0
;-> %0
;<-
;======================================
PROC showdate FAR
ARG @dates:word
USES edx
xor edx,edx
mov dx,[@dates]
and dx,11111b
call showintl,2,edx
call [cs:showchars],'/',0FFFFh
mov dx,[@dates]
shr dx,5
and dx,111b
call showintl,2,edx
call [cs:showchars],'/',0FFFFh
mov dx,[@dates]
shr dx,8
and dx,11111111b
add dx,1956
call showintl,2,edx
ret
ENDP showdate
;================SHOWTIME==============
;Affiche l'heure contenu en %0
;-> %0
;<-
;======================================
PROC showtime FAR
ARG @times:word
USES edx
xor edx,edx
mov dx,[@times]
shr dx,11
and dx,11111b
call showintl,2,edx
call [cs:showchars],':',0FFFFh
mov dx,[@times]
shr dx,5
and dx,111111b
call showintl,2,edx
call [cs:showchars],':',0FFFFh
mov dx,[@times]
and dx,11111b
shl dx,1
call showintl,2,edx
ret
ENDP showtime
;================SHOWNAME==============
;Affiche le nom pointé par ds:%0
;-> ds:%0
;<-
;======================================
PROC showname FAR
ARG @thename:word
USES cx,si
mov si,[@thename]
xor cx,cx
@@showthename:
call [cs:showchars],[word ptr ds:si],0FFFFh
inc si
inc cx
cmp cx,8
jne @@suiteaname
call [cs:showchars],' ',0FFFFh
@@suiteaname:
cmp cx,8+3
jb @@showthename
ret
ENDP showname
;================SHOWATTR==============
;Affiche les attributs spécifié par %0
;-> %0
;<-
;======================================
PROC showattr FAR
ARG @attr:word
push 0FFFFh
test [@attr],00000001b
je @@noreadonly
push 'L'
jmp @@readonly
@@noreadonly:
push '-'
@@readonly:
call [cs:showchars]
push 0FFFFh
test [@attr],00000010b
je @@nohidden
push 'C'
jmp @@hidden
@@nohidden:
push '-'
@@hidden:
call [cs:showchars]
push 0FFFFh
test [@attr],00000100b
je @@nosystem
push 'S'
jmp @@system
@@nosystem:
push '-'
@@system:
call [cs:showchars]
push 0FFFFh
test [@attr],00100000b
je @@noarchive
push 'A'
jmp @@archive
@@noarchive:
push '-'
@@archive:
call [cs:showchars]
push 0FFFFh
test [@attr],00010000b
je @@nodirectory
push 'R'
jmp @@directory
@@nodirectory:
push '-'
@@directory:
call [cs:showchars]
ret
ENDP showattr
;================SHOWSIZE==============
;Affiche le nom pointé par %0
;-> %0
;<-
;======================================
PROC showsize FAR
ARG @thesize:dword
USES edx,ds
push cs
pop ds
mov edx,[@thesize]
cmp edx,1073741824
ja @@giga
cmp edx,1048576*9
ja @@mega
cmp edx,1024*9
ja @@kilo
call showintr,4,edx
call showstring0,offset unit
jmp @@finsize
@@kilo:
shr edx,10
call showintr,4,edx
call showstring0,offset unitkilo
jmp @@finsize
@@mega:
shr edx,20
call showintr,4,edx
call showstring0,offset unitmega
jmp @@finsize
@@giga:
shr edx,30
call showintr,4,edx
call showstring0,offset unitgiga
@@finsize:
ret
unit db ' o ',0
unitkilo db ' ko',0
unitmega db ' mo',0
unitgiga db ' go',0
ENDP showsize
;==========SHOWSPACE===========
;met un espace aprés le curseur
;->
;<-
;==============================
PROC showspace FAR
call [cs:showchars],' ',0FFFFh
clc
ret
ENDP showspace
;==========SHOWINT===========
;Affiche un entier %0 aprés le curseur
;-> %0
;<-
;============================
PROC showint FAR
ARG @integer:dword
USES eax,bx,cx,edx,esi
xor cx,cx
mov eax,[@integer]
mov esi,10
mov bx,offset showbuffer+27
@@decint:
xor edx,edx
div esi
add dl,'0'
inc cx
mov [cs:bx],dl
dec bx
cmp ax,0
jne @@decint
mov ax,cx
@@showinteger:
inc bx
mov cl,[cs:bx]
call [cs:showchars],cx,0FFFFh
dec ax
jnz @@showinteger
ret
showbuffer db 50 dup (0FFh)
ENDP showint
;==========SHOWINTL===========
;Affiche un entier %0 aprés le curseur de taille %1 caractère centré a gauche
;-> %0 un entier % taille en caractères
;<-
;===============================
PROC showintl FAR
ARG @sizeofint:word,@integer:dword
USES eax,bx,cx,edx,esi,di
mov di,[@sizeofint]
xor cx,cx
mov eax,[@integer]
mov esi,10
mov bx,offset showbuffer+27
@@decint:
xor edx,edx
div esi
add dl,'0'
inc cx
mov [cs:bx],dl
dec bx
cmp cx,di
jae @@nomuch
cmp ax,0
jne @@decint
mov ax,di
xchg cx,di
sub cx,di
@@rego:
mov [byte ptr cs:bx],'0'
dec bx
dec cx
jnz @@rego
jmp @@finishim
@@nomuch:
mov ax,di
@@finishim:
@@showinteger:
inc bx
mov cl,[cs:bx]
call [cs:showchars],cx,0FFFFh
dec ax
jnz @@showinteger
ret
ENDP showintl
;==========SHOWINTR===========
;Affiche un entier %0 aprés le curseur de taille %1 caractère centré a droite
;-> %0 un entier % taille en caractères
;<-
;===============================
PROC showintr FAR
ARG @sizeofint:word,@integer:dword
USES eax,bx,cx,edx,esi,di
mov di,[@sizeofint]
xor cx,cx
mov eax,[@integer]
mov esi,10
mov bx,offset showbuffer+27
@@decint:
xor edx,edx
div esi
add dl,'0'
inc cx
mov [cs:bx],dl
dec bx
cmp cx,di
jae @@nomuch
cmp ax,0
jne @@decint
mov ax,di
xchg cx,di
sub cx,di
@@rego:
mov [byte ptr cs:bx],' '
dec bx
dec cx
jnz @@rego
jmp @@finishim
@@nomuch:
mov ax,di
@@finishim:
@@showinteger:
inc bx
mov cl,[cs:bx]
call [cs:showchars],cx,0FFFFh
dec ax
jnz @@showinteger
ret
ENDP showintr
;==========SHOWSIGNED===========
;Affiche un entier %0 de taille %1 aprés le curseur
;-> %0 un entier, %1 la taille
;<-
;===============================
PROC showsigned FAR
ARG @sizeofint:word,@integer:dword=taille
USES ebx,cx,edx
mov ebx,[@integer]
mov cx,[@sizeofint]
xor edx,edx
cmp cx,1
ja @@signed16
mov dl,bl
cmp dl,7Fh
jbe @@notsigned
neg dl
jmp @@showminus
@@signed16:
cmp cx,2
ja @@signed32
mov dx,bx
cmp dx,7FFFh
jbe @@notsigned
neg dx
jmp @@showminus
@@signed32:
mov edx,ebx
cmp edx,7FFFFFFFh
jbe @@notsigned
neg edx
@@showminus:
call [cs:showchars],'-',0FFFFh
@@notsigned:
call showint,edx
ret
ENDP showsigned
;==========SHOWHEX===========
;Affiche un nombre hexadécimal %0 de taille %1 aprés le curseur
;-> %0 un entier, %1 la taille
;<-
;============================
PROC showhex FAR
ARG @sizeofint:word,@integer:dword=taille
USES ax,bx,cx,edx
mov edx,[@integer]
mov cx,[@sizeofint]
mov ax,cx
shr ax,2
sub cx,32
neg cx
shl edx,cl
@@Hexaize:
rol edx,4
mov bx,dx
and bx,0fh
mov cl,[cs:bx+offset Tab]
call [cs:showchars],cx,0FFFFh
dec al
jnz @@Hexaize
ret
Tab db '0123456789ABCDEF'
ENDP showhex
;==========SHOWBIN===========
;Affiche un nombre binaire %0 de taille %1 aprés le curseur
;-> %0 un entier, %1 la taille
;<-
;============================
PROC showbin FAR
ARG @sizeofint:word,@integer:dword=taille
USES ax,cx,edx
mov edx,[@integer]
mov cx,[@sizeofint]
sub cx,32
neg cx
shl edx,cl
mov ax,[@sizeofint]
@@binaize:
rol edx,1
mov cl,'0'
adc cl,0
call [cs:showchars],cx,0FFFFh
dec al
jnz @@binaize
ret
ENDP showbin
;==========SHOWBCD===========
;Affiche un nombre en BCD %0 de taille %1 aprés le curseur
;-> %0 un entier, %1 la taille
;<-
;============================
PROC showbcd FAR
ARG @sizeofint:word,@integer:dword
USES ax,cx,edx
mov edx,[@integer]
mov ax,[@sizeofint]
mov cx,ax
shr ax,2
sub cx,32
neg cx
shl edx,cl
@@BCDaize:
rol edx,4
mov cl,dl
and cl,0fh
add cl,'0'
call [cs:showchars],cx,0FFFFh
dec al
jnz @@BCDaize
ret
ENDP showbcd
;==========SHOWSTRING===========
;Affiche une chaine de caractère pointée par ds:%1 aprés le curseur
;-> ds:%1 pointeur chaine type pascal
;<-
;===============================
PROC showstring FAR
ARG @pointer:word
USES bx,si
mov si,[@pointer]
mov bl,[si]
@@strinaize:
inc si
call [cs:showchars],[word ptr si],0FFFFh
dec bl
jnz @@strinaize
ret
ENDP showstring
;==========showchars===========
;Affiche un caractère %0 aprés le curseur
;-> %0 caractère
;<-
;===============================
PROC showchar FAR
ARG @pointer:word
call [cs:showchars],[@pointer],0FFFFh
ret
ENDP showchar
;==========SHOWSTRING0===========
;Affiche une chaine de caractère pointée par ds:%1 aprés le curseur
;-> ds:%1 pointeur chaine type zéro terminal
;<-
;================================
PROC showstring0 FAR
ARG @pointer:word
USES cx,si
mov si,[@pointer]
@@strinaize0:
mov cl,[si]
cmp cl,0
je @@no0
call [cs:showchars],cx,0FFFFh
inc si
jmp @@strinaize0
@@no0:
ret
ENDP showstring0