From 53b445a65239b09d71633bb8b5e1d0164bb42bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Tue, 9 Jul 2019 18:30:00 +0200 Subject: [PATCH] =?UTF-8?q?refactor:=20mise=20=C3=A0=20jour=20vers=20fasm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- boot/boot12.bin | Bin 512 -> 0 bytes boot/makefile | 1 + include/3d.h | 69 +- include/bmp.h | 70 +- include/graphic.h | 2 + include/mem.h | 3 +- lib/3d.asm | 2434 +++++++++++++------------- lib/bmp.asm | 66 +- lib/graphic.asm | 456 +++-- programs/exem-lib.asm => lib/lib.asm | 10 +- lib/makefile | 26 +- lib/math.asm | 38 - lib/str0.asm | 951 +++++----- lib/video.asm | 94 +- makefile | 9 +- noyau/8259a.asm | 206 ++- noyau/makefile | 9 +- noyau/mcb.asm | 216 ++- noyau/systeme.asm | 97 +- programs/commande.asm | 724 ++++---- programs/editeur.asm | 88 +- programs/{exem-ce.asm => exem.asm} | 14 +- programs/gestion.asm | 59 +- programs/isa.asm | 9 +- programs/logo.asm | 39 +- programs/lpt/com.asm | 471 ----- programs/lpt/project1.dpr | 12 - programs/lpt/project1.opt | 34 - programs/lpt/project1.res | Bin 794 -> 0 bytes programs/lpt/unit1.dcu | Bin 18160 -> 0 bytes programs/lpt/unit1.dfm | Bin 6125 -> 0 bytes programs/lpt/unit1.pas | 517 ------ programs/makefile | 29 +- programs/pmode.asm | 9 +- programs/souris.asm | 15 +- programs/test.asm | 91 +- programs/test2d.asm | 103 +- programs/test3d.asm | 475 +++-- programs/verifier.asm | 33 +- programs/volume.asm | 104 +- 40 files changed, 3222 insertions(+), 4361 deletions(-) delete mode 100644 boot/boot12.bin rename programs/exem-lib.asm => lib/lib.asm (58%) rename programs/{exem-ce.asm => exem.asm} (51%) delete mode 100644 programs/lpt/com.asm delete mode 100644 programs/lpt/project1.dpr delete mode 100644 programs/lpt/project1.opt delete mode 100644 programs/lpt/project1.res delete mode 100644 programs/lpt/unit1.dcu delete mode 100644 programs/lpt/unit1.dfm delete mode 100644 programs/lpt/unit1.pas diff --git a/boot/boot12.bin b/boot/boot12.bin deleted file mode 100644 index 84e13df5adffce0f0349c6bb09d49c742c773c6d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 512 zcmaFa%i!!EY-C_y;K;zl$jHF-fWd+L11EzJ0}}%RXtFRfF+$ZT0D+rhh@laP5$#%3 zlv-L8%ge?`PIU}(s zJvBEquS9`Ck71u(&5L-(EevPH&PsNOsnq=1!7!ok!k+*CfAjIN%Nri(0*aj#F1oSL ztLB9{V>cgP4KtrijWC~FO<=d2Sj~QhwioLdigr3O+i}-;mwt{kJg`8Z1|;+SG2_7< z3Jl-X1Z%#Van~@OXnw)8ShdFR(td`z7u5_!ZHBiSY#I1lYX3LbJ}r@KuyrgE+1FI_ z;u1r6;J)~po!ktcmqo^xNHiZ;Xg;jqWGyCG!`~k8-&&5lrs$aC>z(_uYhEm4==PP` z!O+lmfNehmLzVzgzu|$#pC9;(r2?7xRBK)cGeq(?N&k0vQNsXo;0t?(;s>V#f&+uX zI!_p0`fess^Y2i{We`iMrtMni!M3vp9ZsFU_&Tv-X^`|(XVCX6UCrQJ( diff --git a/boot/makefile b/boot/makefile index a1539f2..cebb126 100644 --- a/boot/makefile +++ b/boot/makefile @@ -2,6 +2,7 @@ ASM=fasm CLEAN=rm -rf all: boot12.bin + sync boot12.bin: boot12.asm $(ASM) $< diff --git a/include/3d.h b/include/3d.h index 88e6c09..e8c72d1 100644 --- a/include/3d.h +++ b/include/3d.h @@ -1,32 +1,37 @@ -struc vertex3d -tx dd ? -ty dd ? -tz dd ? -ends vertex3d - -struc mat -p1 dd ? -p2 dd ? -p3 dd ? -p4 dd ? -p5 dd ? -p6 dd ? -p7 dd ? -p8 dd ? -p9 dd ? -p10 dd ? -p11 dd ? -p12 dd ? -p13 dd ? -p14 dd ? -p15 dd ? -p16 dd ? -ends mat - -main equ 4D4Dh -edit equ 3D3Dh -object equ 4000h -mesh equ 4100h -vertex equ 4110h -face equ 4120h -locale equ 4160h +struc vertex3d tx,ty,tz +{ +.tx dd ? +.ty dd ? +.tz dd ? +.sizeof = $ - .tx +} + +struc mat +{ +.p1 dd ? +.p2 dd ? +.p3 dd ? +.p4 dd ? +.p5 dd ? +.p6 dd ? +.p7 dd ? +.p8 dd ? +.p9 dd ? +.p10 dd ? +.p11 dd ? +.p12 dd ? +.p13 dd ? +.p14 dd ? +.p15 dd ? +.p16 dd ? +.sizeof = $ - .p1 +} + +main equ 4D4Dh +edit equ 3D3Dh +object equ 4000h +mesh equ 4100h +vertex equ 4110h +face equ 4120h +locale equ 4160h + diff --git a/include/bmp.h b/include/bmp.h index 02025f7..a6700b6 100644 --- a/include/bmp.h +++ b/include/bmp.h @@ -1,39 +1,41 @@ struc bmp_file -bmp_filetype db 'bm' -bmp_filesize dd ? ; taille du fichier -bmp_reserved dd 0 ; toujours 0 -bmp_bitmapoffset dd ? ; offset de l'image -bmp_headersize dd ? ; taille de l'entete en octects -bmp_width dd ? ; largeur en pixels de l'image -bmp_height dd ? ; hauteur en pixels de l'image -bmp_planes dw 1 ; nombre de plan utilisés -bmp_bitsperpixel dw ? ; nombre de bits par pixels -bmp_compression dd ? ; méthode de compression -bmp_sizeofbitmap dd ? ; taille de l'image en octects -bmp_horzresolution dd ? ; resolution horizontale en pixels par mètre -bmp_vertresolution dd ? ; resolution verticale en pixels par mètre -bmp_colorsused dd ? ; nombre de couleur dans la palette si 0: palette entière si bitperpixel<=8 -bmp_colorsimportant dd ? ; nombre de couleurs importantes masques pour les modes de plus de 8 bits par pixels -bmp_redmask dd ? -bmp_greenmask dd ? -bmp_bluemask dd ? -bmp_alphamask dd ? -bmp_colorspacetype dd ? -bmp_redx dd ? -bmp_redy dd ? -bmp_redz dd ? -bmp_greenx dd ? -bmp_greeny dd ? -bmp_greenz dd ? -bmp_bluex dd ? -bmp_bluey dd ? -bmp_bluez dd ? -bmp_gammared dd ? -bmp_gammagreen dd ? -bmp_gammeblue dd ? -ends bmp_file +{ +.bmp_filetype db 'bm' +.bmp_filesize dd ? ; taille du fichier +.bmp_reserved dd 0 ; toujours 0 +.bmp_bitmapoffset dd ? ; offset de l'image +.bmp_headersize dd ? ; taille de l'entete en octects +.bmp_width dd ? ; largeur en pixels de l'image +.bmp_height dd ? ; hauteur en pixels de l'image +.bmp_planes dw 1 ; nombre de plan utilisés +.bmp_bitsperpixel dw ? ; nombre de bits par pixels +.bmp_compression dd ? ; méthode de compression +.bmp_sizeofbitmap dd ? ; taille de l'image en octects +.bmp_horzresolution dd ? ; resolution horizontale en pixels par mètre +.bmp_vertresolution dd ? ; resolution verticale en pixels par mètre +.bmp_colorsused dd ? ; nombre de couleur dans la palette si 0: palette entière si bitperpixel<=8 +.bmp_colorsimportant dd ? ; nombre de couleurs importantes masques pour les modes de plus de 8 bits par pixels +.bmp_redmask dd ? +.bmp_greenmask dd ? +.bmp_bluemask dd ? +.bmp_alphamask dd ? +.bmp_colorspacetype dd ? +.bmp_redx dd ? +.bmp_redy dd ? +.bmp_redz dd ? +.bmp_greenx dd ? +.bmp_greeny dd ? +.bmp_greenz dd ? +.bmp_bluex dd ? +.bmp_bluey dd ? +.bmp_bluez dd ? +.bmp_gammared dd ? +.bmp_gammagreen dd ? +.bmp_gammeblue dd ? +.sizeof = $ - .bmp_filetype +} -;bmp_compression peut prendre les valeurs suivantes: +;.bmp_compression peut prendre les valeurs suivantes: bmp_comp_uncomp equ 0 ; pas de compression bmp_comp_rle8 equ 1 ; 8-bit run length encoding bmp_comp_rle4 equ 2 ; 4-bit tun length encoding diff --git a/include/graphic.h b/include/graphic.h index 25deb5f..899b1e2 100644 --- a/include/graphic.h +++ b/include/graphic.h @@ -2,6 +2,7 @@ struc point { .coordx db 0 .coordy db 0 +.sizeof = $ - .coordx } struc vgainf @@ -33,4 +34,5 @@ struc vertex2d { .px dw ? .py dw ? +.sizeof = $ - .px } diff --git a/include/mem.h b/include/mem.h index 27df6bf..ed0228b 100644 --- a/include/mem.h +++ b/include/mem.h @@ -15,7 +15,7 @@ struc regs .sfs dw 0 .sgs dw 0 .sss dw 0 -;.seflags dd 0 +.seflags dd 0 ;.sst0 dt 0 ;;sst1 dt 0 ;.sst2 dt 0 @@ -37,6 +37,7 @@ struc vector off,seg .data tuple off,seg virtual at .data .content dd 0 +.sizeof = $ - .data end virtual } diff --git a/lib/3d.asm b/lib/3d.asm index 85f2dbf..718efd5 100644 --- a/lib/3d.asm +++ b/lib/3d.asm @@ -1,1222 +1,1212 @@ -model tiny,stdcall -p586 -locals -jumps -codeseg -option procalign:byte - -include "..\include\mem.h" -include "..\include\graphic.h" -include "..\include\3d.h" - -org 0h - -header exe <"CE",1,0,0,offset exports,offset imports,,> - -exporting -declare draw3d_point -declare draw3d_line -declare draw3d_hidden -declare draw3d_hidden_fill -declare load3ds -declare translate -declare translatex -declare translatey -declare translatez -declare scale -declare rescale -declare copy -declare fill -declare identity -declare rotationx -declare rotationy -declare rotationz -declare rotation -declare project -declare transform -declare multiply -ende - -importing -use GRAPHIC.LIB,line -use GRAPHIC.LIB,polyfill -use VIDEO,showpixel -endi - -;affiche liste vertex %0 -PROC draw3d_point FAR - ARG @vertex3d:word,@vertex2d:word,@camera:word,@color:word - USES cx,si - mov si,[@vertex2d] - call project,si,[@vertex3d],[@camera] - mov cx,[si] - inc si - inc si -@@draw: - call [cs:showpixel],[(vertex2d si).px],[(vertex2d si).py],[@color] - add si,4 - dec cx - jnz @@draw - ret -endp draw3d_point - -;affiche liste vertex %0 -PROC draw3d_line FAR - ARG @type:word,@faces:word,@vertex3d:word,@vertex2d:word,@camera:word,@color:word - USES ax,bx,cx,dx,si,di - mov di,[@faces] - mov si,[@vertex2d] - call project,si,[@vertex3d],[@camera] - mov cx,[di] - inc si - inc si - inc di - inc di -@@draw: - mov ax,[@type] - dec al - mov dx,di -@@drawset: - mov bx,[di] - shl bx,2 - push [@color] - push [(vertex2d bx+si).py] - push [(vertex2d bx+si).px] - add di,2 - mov bx,[di] - shl bx,2 - push [(vertex2d bx+si).py] - push [(vertex2d bx+si).px] - call [cs:line] - dec al - jnz @@drawset - push di - mov di,dx - mov bx,[di] - pop di - shl bx,2 - push [@color] - push [(vertex2d bx+si).py] - push [(vertex2d bx+si).px] - mov bx,[di] - shl bx,2 - push [word ptr bx+si+2] - push [word ptr bx+si] - call [cs:line] - add di,2 - dec cx - jnz @@draw - ret -endp draw3d_line - -;affiche liste vertex %0 -PROC draw3d_hidden FAR - ARG @type:word,@faces:word,@vertex3d:word,@vertex2d:word,@camera:word,@color:word - LOCAL @@a1:word,@@a2:word,@@b1:word - USES ax,bx,cx,dx,si,di - mov di,[@faces] - mov si,[@vertex2d] - call project,si,[@vertex3d],[@camera] - mov cx,[di] - inc si - inc si - inc di - inc di -@@draw: - push cx - mov si,[@vertex2d] - inc si - inc si - mov bx,[di+2] - shl bx,2 - mov cx,[(vertex2d bx+si).px] - mov dx,[(vertex2d bx+si).py] - mov bx,[di] - shl bx,2 - mov ax,[(vertex2d bx+si).px] - sub ax,cx - mov [@@a1],ax - mov ax,[(vertex2d bx+si).py] - sub ax,dx - mov [@@b1],ax - mov bx,[di+4] - shl bx,2 - mov ax,[(vertex2d bx+si).px] - sub ax,cx - mov [@@a2],ax - mov ax,[(vertex2d bx+si).py] - sub ax,dx - xor edx,edx - imul [@@a1] - and eax,0FFFFh - rol eax,16 - add eax,edx - rol eax,16 - mov ecx,eax - mov ax,[@@b1] - imul [@@a2] - and eax,0FFFFh - rol eax,16 - add eax,edx - rol eax,16 - sub ecx,eax - pop cx - jge @@nohidden - mov ax,[@type] - shl ax,1 - add di,ax - dec cx - jnz @@draw - jmp @@endof -@@nohidden: - mov ax,[@type] - dec al - mov dx,di -@@drawset: - mov bx,[di] - shl bx,2 - push [@color] - push [(vertex2d bx+si).py] - push [(vertex2d bx+si).px] - add di,2 - mov bx,[di] - shl bx,2 - push [(vertex2d bx+si).py] - push [(vertex2d bx+si).px] - call [cs:line] - dec al - jnz @@drawset - push di - mov di,dx - mov bx,[di] - pop di - shl bx,2 - push [@color] - push [(vertex2d bx+si).py] - push [(vertex2d bx+si).px] - mov bx,[di] - shl bx,2 - push [word ptr bx+si+2] - push [word ptr bx+si] - call [cs:line] - add di,2 - dec cx - jnz @@draw -@@endof: - ret -endp draw3d_hidden - -;creer table pour face caché %0 -PROC draw3d_hidden_fill FAR - ARG @type:word,@faces:word,@vertex3d:word,@vertex2d:word,@camera:word,@color:word - USES eax,bx,ecx,edx,si,di - LOCAL @@a1:word,@@a2:word,@@b1:word - mov di,[@faces] - call project,[@vertex2d],[@vertex3d],[@camera] - mov cx,[di] - inc di - inc di -@@calculvect: - push cx - mov si,[@vertex2d] - inc si - inc si - mov bx,[di+2] - shl bx,2 - mov cx,[(vertex2d bx+si).px] - mov dx,[(vertex2d bx+si).py] - mov bx,[di] - shl bx,2 - mov ax,[(vertex2d bx+si).px] - sub ax,cx - mov [@@a1],ax - mov ax,[(vertex2d bx+si).py] - sub ax,dx - mov [@@b1],ax - mov bx,[di+4] - shl bx,2 - mov ax,[(vertex2d bx+si).px] - sub ax,cx - mov [@@a2],ax - mov ax,[(vertex2d bx+si).py] - sub ax,dx - xor edx,edx - imul [@@a1] - rol eax,16 - add eax,edx - rol eax,16 - mov ecx,eax - mov ax,[@@b1] - imul [@@a2] - rol eax,16 - add eax,edx - rol eax,16 - sub ecx,eax - pop cx - jl @@hidden - mov ax,[@type] - mov si,[@vertex3d] - inc si - inc si - fld [cs:zero] -@@calcz: - mov bx,[di] - mov dx,bx - shl dx,2 - shl bx,3 - add bx,dx - fadd [(vertex3d bx+si).tz] - add di,2 - dec al - jnz @@calcz -@@hidden: - mov ax,[@type] - shl ax,1 - add di,ax -@@enofvalue: - dec cx - jnz @@calculvect - ret -endp draw3d_hidden_fill - - -;charge un fichier 3ds logé en %0 renvoie error -;sauvegarde en : -;- %1 le nom de l'objet -;- %2 les vertex 3D de l'objet -;- %3 la matrice de transformation de l'objet -;- %4 les faces de l'objet -;- %5 le type de face de l'objet -;1 non 3ds -;2 non 3 et > -PROC load3ds FAR - ARG @seg:word,@add:word,@objectname:word,@vertex:word,@matrix:word,@face:word - USES eax,bx,cx,si,di,ds,es,fs - push ds - pop fs - mov si,[@add] - mov ds,[@seg] - cmp [word ptr si],main - jne @@error1 - cmp [word ptr si+28],3 - jb @@error2 -@@reading: - mov ax,[si] - mov bx,[si+2] - cmp ax,main - je @@enter - cmp ax,edit - je @@enter - cmp ax,mesh - je @@enter - cmp ax,object - je @@readobject - cmp ax,vertex - je @@readvertex - cmp ax,locale - je @@readmatrix - cmp ax,face - je @@readfaces -@@next: - add si,bx - jmp @@reading -@@enter: - add si,6 - jmp @@reading -@@readobject: - add si,6 - mov di,si - mov al,0 - mov es,[@seg] - mov cx,12 - cld - repne scasb - mov cx,di - sub cx,si - mov di,[@objectname] - push fs - pop es - cld - rep movsb - jmp @@reading -@@readvertex: - add si,6 - mov ax,[si] - mov di,[@vertex] - mov [fs:di],ax - inc si - inc si - mov cx,ax - shl ax,1 - add cx,ax - add di,2 - cld - push fs - pop es - cld - rep movsd - jmp @@reading -@@readmatrix: - add si,6 - mov di,[@matrix] - mov eax,[si] - mov [fs:(mat di).p1],eax - mov eax,[si+4*1] - mov [fs:(mat di).p5],eax - mov eax,[si+4*2] - mov [fs:(mat di).p9],eax - mov eax,[si+4*3] - mov [fs:(mat di).p2],eax - mov eax,[si+4*4] - mov [fs:(mat di).p6],eax - mov eax,[si+4*5] - mov [fs:(mat di).p10],eax - mov eax,[si+4*6] - mov [fs:(mat di).p3],eax - mov eax,[si+4*7] - mov [fs:(mat di).p7],eax - mov eax,[si+4*8] - mov [fs:(mat di).p11],eax - mov eax,[si+4*9] - mov [fs:(mat di).p4],eax - mov eax,[si+4*10] - mov [fs:(mat di).p8],eax - mov eax,[si+4*11] - mov [fs:(mat di).p12],eax - mov eax,[cs:un] - mov [fs:(mat di).p16],eax - mov eax,0 - mov [fs:(mat di).p13],eax - mov [fs:(mat di).p14],eax - mov [fs:(mat di).p15],eax - add si,12*4 - jmp @@reading -@@readfaces: - add si,6 - mov ax,[si] - mov di,[@face] - mov [fs:di],ax - inc si - inc si - add di,2 - push fs - pop es - cld -@@readall: - mov cx,3 - rep movsw - inc si - inc si - dec ax - jnz @@readall - ;;jmp @@reading -@@error1: -@@error2: - ret -endp load3ds - -un dd 1.0 -zero dd 0.0 - -;initialise une matrice de translation pour une translation TX,TY,TZ (%1,%2,%3) dans MATRICE %0 -; mat[ 0] = 1.0 -; mat[ 5] = 1.0 -; mat[10] = 1.0 -; mat[15] = 1.0 -; mat[ 3] = vecteur->x -; mat[ 7] = vecteur->y -; mat[11] = vecteur->z -PROC translate FAR - ARG @mat:word,@x:dword,@y:dword,@z:dword - USES eax,ecx,di,es - mov di,[@mat] - mov ecx,16 - mov eax,0 - push ds - pop es - cld - rep stosd - mov di,[@mat] - mov eax,[cs:un] - mov [di+0*4],eax - mov [di+5*4],eax - mov [di+10*4],eax - mov [di+15*4],eax - mov eax,[@x] - mov [di+3*4],eax - mov eax,[@y] - mov [di+7*4],eax - mov eax,[@z] - mov [di+11*4],eax - ret -ENDP translate - -;initialise une matrice de translation pour une translation TX %1 dans MATRICE %0 -; mat[ 0] = 1.0 -; mat[ 5] = 1.0 -; mat[10] = 1.0 -; mat[15] = 1.0 -; mat[ 3] = value -; mat[ 7] = 1 -; mat[11] = 1 -PROC translatex FAR - ARG @mat:word,@value:dword - USES eax,ecx,di,es - mov di,[@mat] - mov ecx,16 - mov eax,0 - push ds - pop es - cld - rep stosd - mov di,[@mat] - mov eax,[cs:un] - mov [di+0*4],eax - mov [di+5*4],eax - mov [di+10*4],eax - mov [di+15*4],eax - mov [di+7*4],eax - mov [di+11*4],eax - mov eax,[@value] - mov [di+3*4],eax - ret -ENDP translatex - - -;initialise une matrice de translation pour une translation TY %1 dans MATRICE %0 -; mat[ 0] = 1.0 -; mat[ 5] = 1.0 -; mat[10] = 1.0 -; mat[15] = 1.0 -; mat[ 3] = 1 -; mat[ 7] = value -; mat[11] = 1 -PROC translatey FAR - ARG @mat:word,@value:dword - USES eax,ecx,di,es - mov di,[@mat] - mov ecx,16 - mov eax,0 - push ds - pop es - cld - rep stosd - mov di,[@mat] - mov eax,[cs:un] - mov [di+0*4],eax - mov [di+5*4],eax - mov [di+10*4],eax - mov [di+15*4],eax - mov [di+3*4],eax - mov [di+11*4],eax - mov eax,[@value] - mov [di+7*4],eax - ret -ENDP translatey - -;initialise une matrice de translation pour une translation TZ %1 dans MATRICE %0 -; mat[ 0] = 1.0 -; mat[ 5] = 1.0 -; mat[10] = 1.0 -; mat[15] = 1.0 -; mat[ 3] = 1 -; mat[ 7] = 1 -; mat[11] = value -PROC translatez FAR - ARG @mat:word,@value:dword - USES eax,ecx,di,es - mov di,[@mat] - mov ecx,16 - mov eax,0 - push ds - pop es - cld - rep stosd - mov di,[@mat] - mov eax,[cs:un] - mov [di+0*4],eax - mov [di+5*4],eax - mov [di+10*4],eax - mov [di+15*4],eax - mov [di+3*4],eax - mov [di+7*4],eax - mov eax,[@value] - mov [di+11*4],eax - ret -ENDP translatez - -;initialise une matrice d'echelle %0 de facteur (x,y,z) %1-%3 -; mat[ 0] = factorx -; mat[ 5] = factory -; mat[10] = factorz -; mat[15] = 1.0 -; reste a 0 -PROC scale FAR - ARG @mat:word,@x:dword,@y:dword,@z:dword - USES eax,ecx,di,es - mov di,[@mat] - mov ecx,16 - mov eax,0 - push ds - pop es - cld - rep stosd - mov di,[@mat] - mov eax,[@x] - mov [di+0*4],eax - mov eax,[@y] - mov [di+5*4],eax - mov eax,[@z] - mov [di+10*4],eax - mov eax,[cs:un] - mov [di+15*4],eax - ret -ENDP scale - -;initialise une matrice d'echelle %0 de facteur value %1 -; mat[ 0] = factor -; mat[ 5] = factor -; mat[10] = factor -; mat[15] = 1.0 -; reste a 0 -PROC rescale FAR - ARG @mat:word,@value:dword - USES eax,ecx,di,es - mov di,[@mat] - mov ecx,16 - mov eax,0 - push ds - pop es - cld - rep stosd - mov di,[@mat] - mov eax,[@value] - mov [di+0*4],eax - mov [di+5*4],eax - mov [di+10*4],eax - mov eax,[cs:un] - mov [di+15*4],eax - ret -ENDP rescale - -;copy une matrice %0 en %1 -;mat2=mat1 -PROC copy FAR - ARG @mat1:word,@mat2:word - USES ecx,si,di,es - mov si,[@mat1] - mov di,[@mat2] - mov ecx,16 - push ds - pop es - cld - rep stosd - ret -ENDP copy - -;initialise une matrice %0 avec la valeur %1 -;mat[i]=value -PROC fill FAR - ARG @mat:word,@value:dword - USES eax,ecx,di,es - mov di,[@mat] - mov eax,[@value] - mov ecx,16 - push ds - pop es - cld - rep stosd - ret -ENDP fill - -;initialise une matrice d'identité %0 -; mat[0] = 1.0 -; mat[5] = 1.0 -; mat[10] = 1.0 -; mat[15] = 1.0 -; reste a 0 -PROC identity FAR - ARG @mat:word - USES eax,ecx,di,es - mov di,[@mat] - mov ecx,16 - mov eax,0 - push ds - pop es - cld - rep stosd - mov di,[@mat] - mov eax,[cs:un] - mov [di+0*4],eax - mov [di+5*4],eax - mov [di+10*4],eax - mov [di+15*4],eax - ret -ENDP identity - - -;initialise une matrice de rotation %0 autour de X de %1 degrees -; mat[ 5] = cos(angle) -; mat[ 6] = -sin(angle) -; mat[ 9] = sin(angle) -; mat[10] = cos(angle) -; mat[ 0] = 1.0 -; mat[15] = 1.0 -; reste a 0 -PROC rotationx FAR - ARG @mat:word,@value:dword - USES eax,ecx,di,es - mov di,[@mat] - mov ecx,16 - mov eax,0 - push ds - pop es - cld - rep stosd - mov di,[@mat] - fld [@value] - fsincos -;mat[ 5] = cos(angle); - fst [dword ptr di+5*4] -;mat[ 10] = cos(angle); - fstp [dword ptr di+10*4] -;mat[ 9] = sin(angle); - fst [dword ptr di+9*4] -;mat[ 6] = -sin(angle); - fchs - fstp [dword ptr di+6*4] -;mat[ 0] = 1.0 -;mat[15] = 1.0 - mov eax,[cs:un] - mov [di+0*4],eax - mov [di+15*4],eax - ret -endp rotationx - -;initialise une matrice de rotation BX autour de Y de %0 degrees -; mat[ 0] = cos(angle) -; mat[ 8] = -sin(angle) -; mat[ 2] = sin(angle) -; mat[10] = cos(angle) -; mat[ 5] = 1.0 -; mat[15] = 1.0 -; reste a 0 -PROC rotationy FAR - ARG @mat:word,@value:dword - USES eax,ecx,di,es - mov di,[@mat] - mov ecx,16 - mov eax,0 - push ds - pop es - cld - rep stosd - mov di,[@mat] - fld [@value] - fsincos -;mat[ 0] = cos(angle) - fst [dword ptr di+0*4] -;mat[ 10] = cos(angle) - fstp [dword ptr di+10*4] -;mat[ 2] = sin(angle) - fst [dword ptr di+2*4] - fchs -;mat[ 8] = -sin(angle) - fstp [dword ptr di+8*4] -;mat[ 5] = 1.0 -;mat[15] = 1.0 - mov eax,[cs:un] - mov [di+5*4],eax - mov [di+15*4],eax - ret -endp rotationy - -;initialise une matrice de rotation %0 autour de Z de %1 degrees -; mat[ 0] = cos(angle) -; mat[ 1] = -sin(angle) -; mat[ 4] = sin(angle) -; mat[ 5] = cos(angle) -; mat[10] = 1.0 -; mat[15] = 1.0 -; reste a 0 -PROC rotationz FAR - ARG @mat:word,@value:dword - USES eax,ecx,di,es - mov di,[@mat] - mov ecx,16 - mov eax,0 - push ds - pop es - cld - rep stosd - mov di,[@mat] - fld [@value] - fsincos -;mat[ 0] = cos(angle) - fst [dword ptr di+0*4] -;mat[ 5] = cos(angle) - fstp [dword ptr di+5*4] -;mat[ 4] = sin(angle) - fst [dword ptr di+4*4] - fchs -;mat[ 1] = -sin(angle) - fstp [dword ptr di+1*4] -;mat[10] = 1.0 -;mat[15] = 1.0 - mov eax,[cs:un] - mov [di+10*4],eax - mov [di+15*4],eax - ret -endp rotationz - -;initialise une matrice de rotation %0 autour de X,Y,Z de %0-%3 degrees -; mat[ 0] = cos(angleY)*cos(angleZ) -; mat[ 1] = cos(angleY)*sin(angleZ) -; mat[ 2] = -sin(angleY) -; mat[ 4] = sin(angleX)*sin(angleY)*cos(angleZ)+cos(angleX)*-sin(angleZ) -; mat[ 5] = sin(angleX)*sin(angleY)*sin(angleZ)+cos(angleX)*cos(angleZ) -; mat[ 6] = sin(angleX)*cos(angleY) -; mat[ 8] = cos(angleX)*sin(angleY)*cos(angleZ)+sin(angleX)*sin(angleZ) -; mat[ 9] = cos(angleX)*sin(angleY)*sin(angleZ)-sin(angleX)*cos(angleZ) -; mat[ 10] = cos(angleX)*cos(angleY) -; mat[3] = 0.0 -; mat[7] = 0.0 -; mat[11] = 0.0 -; mat[12] = 0.0 -; mat[13] = 0.0 -; mat[14] = 0.0 -; mat[15] = 1.0 -; reste a 0 -PROC rotation FAR - ARG @mat:word,@anglex:dword,@angley:dword,@anglez:dword - USES eax,ecx,di,es - mov di,[@mat] - mov ecx,16 - mov eax,0 - push ds - pop es - cld - rep stosd - mov di,[@mat] -;st(1) sin(angleZ) -;st(2) cos(angleZ) -;st(3) sin(angleY) -;st(4) cos(angleY) -;st(5) sin(angleX) -;st(6) cos(angleX) - fld [@anglex] - fsincos - fld [@angley] - fsincos - fld [@anglez] - fsincos -;Cos(angleY)*Cos(angleZ) - fld st(3) - fmul st(0),st(2) -;mat[0] - fstp [dword ptr di+0*4] -;Cos(angleY)*Sin(angleZ) - fld st(3) - fmul st(0),st(1) -;mat[1] - fstp [dword ptr di+1*4] -;-Sin(angley) - fld st(2) - fchs -;mat[2] - fstp [dword ptr di+2*4] - mov eax,[cs:un] - mov [di+15*4],eax - ret -endp rotation - - -factor dd 128.0 - -;Transforme la liste de vertex 3D pointé par %0 en vertex 2D dans %1 en utilisant %2 comme origine pour %3 valeurs -; vertex2d[i].px=int((vertex3d[i].tx*factor)/(vertex3d[i].tz+origin.Z)+origin.X) -; vertex2d[i].py=int((vertex3d[i].ty*factor)/(vertex3d[i].tz+origin.Z)+origin.Y) -PROC project FAR - ARG @vertex2d:word,@vertex3d:word,@origin:word - USES cx,bx,si,di - mov si,[@vertex3d] - mov bx,[@vertex2d] - mov di,[@origin] - mov cx,[si] - mov [bx],cx - inc si - inc si - inc bx - inc bx -@@boucle: -;(vertex3d[i].z+origZ) - fld [(vertex3d si).tz] - fadd [(vertex3d di).tz] -;(vertex3d[i].tx*factor) - fld [(vertex3d si).tx] - fmul [cs:factor] -;(vertex3d[i].tx*factor)/(vertex3d[i].tz+origZ) - fdiv st,st(1) -;(vertex3d[i].tx*factor)/(vertex3d[i].tz+origZ)+origX - fadd [(vertex3d di).tx] -;vertex2d[i].tx=int((vertex3d[i].tx*factor)/(vertex3d[i].tz+origZ)+origX) - fistp [(vertex2d bx).px] -;(vertex3d[i].z+origZ) -;(vertex3d[i].ty*factor) - fld [(vertex3d si).ty] - fmul [cs:factor] -;(vertex3d[i].ty*factor)/(vertex3d[i].tz+origZ) - fdivrp st(1) -;(vertex3d[i].ty*factor)/(vertex3d[i].tz+origZ)+origY - fadd [(vertex3d di).ty] -;vertex2d[i].ty=int((vertex3d[i].ty*factor)/(vertex3d[i].tz+origZ)+origY) - fistp [(vertex2d bx).py] - add si,size vertex3d - add bx,size vertex2d - dec cx - jnz @@boucle - ret -endp project - - -;transforme les points %0 avec la matrice %1 - -; vertex3d_2 = mat * vertex3d - -; w = mat[12]*vertex3d[i].tx + mat[13]*vertex3d[i].ty + mat[14]*vertex3d[i].tz + mat[15] -; vertex3d_2[i].tx = mat[ 0]*vertex3d[i].tx + mat[ 1]*vertex3d[i].ty + mat[ 2]*vertex3d[i].tz + mat[ 3] -; vertex3d_2[i].ty = mat[ 4]*vertex3d[i].tx + mat[ 5]*vertex3d[i].ty + mat[ 6]*vertex3d[i].tz + mat[ 7] -; vertex3d_2[i].tz = mat[ 8]*vertex3d[i].tx + mat[ 9]*vertex3d[i].ty + mat[10]*vertex3d[i].tz + mat[11] -PROC transform FAR - ARG @vertex3d:word,@mat:word - USES cx,si,di - mov si,[@vertex3d] - mov cx,[si] - inc si - inc si - mov di,[@mat] -@@boucle: -;Calcul du facteur echelle -;mat[12]*vertex3d[i].tx - fld [(vertex3d si).tx] - fmul [dword ptr di+12*4] -;mat[13]*vertex3d[i].ty - fld [(vertex3d si).ty] - fmul [dword ptr di+13*4] -;mat[12]*vertex3d[i].tx + mat[13]*vertex3d[i].ty - faddp st(1) -;mat[14]*vertex3d.tz - fld [(vertex3d si).tz] - fmul [dword ptr di+14*4] -;mat[12]*vertex3d[i].tx + mat[13]*vertex3d[i].ty + mat[14]*vertex3d[i].tz - faddp st(1) -;mat[12]*vertex3d[i].tx + mat[13]*vertex3d[i].ty + mat[14]*vertex3d[i].tz + mat[15] - fadd [dword ptr di+15*4] -;w=0.0 ?? - ftst -;-> AX - fstsw ax - -;vertex3d.tx vertex3d.ty et vertex3d.tz - fld [(vertex3d si).tx] - fmul [dword ptr di+0*4] - fld [(vertex3d si).ty] - fmul [dword ptr di+1*4] - faddp st(1) - fld [(vertex3d si).tz] - fmul [dword ptr di+2*4] - faddp st(1) - fadd [dword ptr di+3*4] - - fld [(vertex3d si).tx] - fmul [dword ptr di+4*4] - fld [(vertex3d si).ty] - fmul [dword ptr di+5*4] - faddp st(1) - fld [(vertex3d si).tz] - fmul [dword ptr di+6*4] - faddp st(1) - fadd [dword ptr di+7*4] - - fld [(vertex3d si).tx] - fmul [dword ptr di+8*4] - fld [(vertex3d si).ty] - fmul [dword ptr di+9*4] - faddp st(1) - fld [(vertex3d si).tz] - fmul [dword ptr di+10*4] - faddp st(1) - fadd [dword ptr di+11*4] - -;w=0.0 - sahf - jz @@divby0 -;vertex3d.tx=vertex3d[i].tz/w - fdiv st,st(3) - fstp [(vertex3d si).tz] -;vertex3d.ty=vertex3d[i].ty/w - fdiv st,st(2) - fstp [(vertex3d si).ty] -;vertex3d.tz=vertex3d[i].tx/w - fdivrp st(1),st - fstp [(vertex3d si).tx] -;No div by 0 - jmp @@nodiv -@@divby0: - fstp [(vertex3d si).tz] - fstp [(vertex3d si).ty] - fstp [(vertex3d si).tx] - ffree -@@nodiv: - add si,size vertex3d - dec cx - jnz @@boucle - ret -endp transform - -;Multiplie la matrice de transformation %0 par celle en %1 et met les resultat en %2 - -; mat = p1 * p2 - -; mat[ 0] = (p1[ 0]*p2[ 0])+(p1[ 1]*p2[ 4])+(p1[ 2]*p2[ 8])+(p1[ 3]*p2[12]); -; mat[ 4] = (p1[ 4]*p2[ 0])+(p1[ 5]*p2[ 4])+(p1[ 6]*p2[ 8])+(p1[ 7]*p2[12]); -; mat[ 8] = (p1[ 8]*p2[ 0])+(p1[ 9]*p2[ 4])+(p1[10]*p2[ 8])+(p1[11]*p2[12]); -; mat[12] = (p1[12]*p2[ 0])+(p1[13]*p2[ 4])+(p1[14]*p2[ 8])+(p1[15]*p2[12]); -; mat[ 1] = (p1[ 0]*p2[ 1])+(p1[ 1]*p2[ 5])+(p1[ 2]*p2[ 9])+(p1[ 3]*p2[13]); -; mat[ 5] = (p1[ 4]*p2[ 1])+(p1[ 5]*p2[ 5])+(p1[ 6]*p2[ 9])+(p1[ 7]*p2[13]); -; mat[ 9] = (p1[ 8]*p2[ 1])+(p1[ 9]*p2[ 5])+(p1[10]*p2[ 9])+(p1[11]*p2[13]); -; mat[13] = (p1[12]*p2[ 1])+(p1[13]*p2[ 5])+(p1[14]*p2[ 9])+(p1[15]*p2[13]); -; mat[ 2] = (p1[ 0]*p2[ 2])+(p1[ 1]*p2[ 6])+(p1[ 2]*p2[10])+(p1[ 3]*p2[14]); -; mat[ 6] = (p1[ 4]*p2[ 2])+(p1[ 5]*p2[ 6])+(p1[ 6]*p2[10])+(p1[ 7]*p2[14]); -; mat[10] = (p1[ 8]*p2[ 2])+(p1[ 9]*p2[ 6])+(p1[10]*p2[10])+(p1[11]*p2[14]); -; mat[14] = (p1[12]*p2[ 2])+(p1[13]*p2[ 6])+(p1[14]*p2[10])+(p1[15]*p2[14]); -; mat[ 3] = (p1[ 0]*p2[ 3])+(p1[ 1]*p2[ 7])+(p1[ 2]*p2[11])+(p1[ 3]*p2[15]); -; mat[ 7] = (p1[ 4]*p2[ 3])+(p1[ 5]*p2[ 7])+(p1[ 6]*p2[11])+(p1[ 7]*p2[15]); -; mat[11] = (p1[ 8]*p2[ 3])+(p1[ 9]*p2[ 7])+(p1[10]*p2[11])+(p1[11]*p2[15]); -; mat[15] = (p1[12]*p2[ 3])+(p1[13]*p2[ 7])+(p1[14]*p2[11])+(p1[15]*p2[15]); - -PROC multiply FAR - ARG @p1:word,@p2:word,@mat:word - USES bx,si,di - mov si,[@p1] - mov di,[@p2] - mov bx,[@mat] -;0,0 -;p1[ 0]*p2[ 0] - fld [dword ptr si+0*4] - fmul [dword ptr di+0*4] -;p1[ 1]*p2[ 4] - fld [dword ptr si+1*4] - fmul [dword ptr di+4*4] -;(p1[ 0]*p2[ 0])+(p1[ 1]*p2[ 4]) - faddp st(1) -;p1[ 2]*p2[ 8] - fld [dword ptr si+2*4] - fmul [dword ptr di+8*4] -;(p1[ 0]*p2[ 0])+(p1[ 1]*p2[ 4])+(p1[ 2]*p2[ 8]) - faddp st(1) -;p1[ 3]*p2[12] - fld [dword ptr si+3*4] - fmul [dword ptr di+12*4] -;(p1[ 0]*p2[ 0])+(p1[ 1]*p2[ 4])+(p1[ 2]*p2[ 8])+(p1[ 3]*p2[12]) - faddp st(1) - fstp [dword ptr bx+0*4] -;mat[ 0] - -;1,0 - fld [dword ptr si+0*4] - fmul [dword ptr di+1*4] - fld [dword ptr si+1*4] - fmul [dword ptr di+5*4] - faddp st(1) - fld [dword ptr si+2*4] - fmul [dword ptr di+9*4] - faddp st(1) - fld [dword ptr si+3*4] - fmul [dword ptr di+13*4] - faddp st(1) - fstp [dword ptr bx+1*4] -;2,0 - fld [dword ptr si+0*4] - fmul [dword ptr di+2*4] - fld [dword ptr si+1*4] - fmul [dword ptr di+6*4] - faddp st(1) - fld [dword ptr si+2*4] - fmul [dword ptr di+10*4] - faddp st(1) - fld [dword ptr si+3*4] - fmul [dword ptr di+14*4] - faddp st(1) - fstp [dword ptr bx+2*4] -;3,0 - fld [dword ptr si+0*4] - fmul [dword ptr di+3*4] - fld [dword ptr si+1*4] - fmul [dword ptr di+7*4] - faddp st(1) - fld [dword ptr si+2*4] - fmul [dword ptr di+11*4] - faddp st(1) - fld [dword ptr si+3*4] - fmul [dword ptr di+15*4] - faddp st(1) - fstp [dword ptr bx+3*4] -;0,1 - fld [dword ptr si+4*4] - fmul [dword ptr di+0*4] - fld [dword ptr si+5*4] - fmul [dword ptr di+4*4] - faddp st(1) - fld [dword ptr si+6*4] - fmul [dword ptr di+8*4] - faddp st(1) - fld [dword ptr si+7*4] - fmul [dword ptr di+12*4] - faddp st(1) - fstp [dword ptr bx+4*4] -;1,1 - fld [dword ptr si+4*4] - fmul [dword ptr di+1*4] - fld [dword ptr si+5*4] - fmul [dword ptr di+5*4] - faddp st(1) - fld [dword ptr si+6*4] - fmul [dword ptr di+9*4] - faddp st(1) - fld [dword ptr si+7*4] - fmul [dword ptr di+13*4] - faddp st(1) - fstp [dword ptr bx+5*4] -;2,1 - fld [dword ptr si+4*4] - fmul [dword ptr di+2*4] - fld [dword ptr si+5*4] - fmul [dword ptr di+6*4] - faddp st(1) - fld [dword ptr si+6*4] - fmul [dword ptr di+10*4] - faddp st(1) - fld [dword ptr si+7*4] - fmul [dword ptr di+14*4] - faddp st(1) - fstp [dword ptr bx+6*4] -;3,1 - fld [dword ptr si+4*4] - fmul [dword ptr di+3*4] - fld [dword ptr si+5*4] - fmul [dword ptr di+7*4] - faddp st(1) - fld [dword ptr si+6*4] - fmul [dword ptr di+11*4] - faddp st(1) - fld [dword ptr si+7*4] - fmul [dword ptr di+15*4] - faddp st(1) - fstp [dword ptr bx+7*4] -;0,2 - fld [dword ptr si+8*4] - fmul [dword ptr di+0*4] - fld [dword ptr si+9*4] - fmul [dword ptr di+4*4] - faddp st(1) - fld [dword ptr si+10*4] - fmul [dword ptr di+8*4] - faddp st(1) - fld [dword ptr si+11*4] - fmul [dword ptr di+12*4] - faddp st(1) - fstp [dword ptr bx+8*4] -;1,2 - fld [dword ptr si+8*4] - fmul [dword ptr di+1*4] - fld [dword ptr si+9*4] - fmul [dword ptr di+5*4] - faddp st(1) - fld [dword ptr si+10*4] - fmul [dword ptr di+9*4] - faddp st(1) - fld [dword ptr si+11*4] - fmul [dword ptr di+13*4] - faddp st(1) - fstp [dword ptr bx+9*4] -;2,2 - fld [dword ptr si+8*4] - fmul [dword ptr di+2*4] - fld [dword ptr si+9*4] - fmul [dword ptr di+6*4] - faddp st(1) - fld [dword ptr si+10*4] - fmul [dword ptr di+10*4] - faddp st(1) - fld [dword ptr si+11*4] - fmul [dword ptr di+14*4] - faddp st(1) - fstp [dword ptr bx+10*4] -;3,2 - fld [dword ptr si+8*4] - fmul [dword ptr di+3*4] - fld [dword ptr si+9*4] - fmul [dword ptr di+7*4] - faddp st(1) - fld [dword ptr si+10*4] - fmul [dword ptr di+11*4] - faddp st(1) - fld [dword ptr si+11*4] - fmul [dword ptr di+15*4] - faddp st(1) - fstp [dword ptr bx+11*4] -;0,3 - fld [dword ptr si+12*4] - fmul [dword ptr di+0*4] - fld [dword ptr si+13*4] - fmul [dword ptr di+4*4] - faddp st(1) - fld [dword ptr si+14*4] - fmul [dword ptr di+8*4] - faddp st(1) - fld [dword ptr si+15*4] - fmul [dword ptr di+12*4] - faddp st(1) - fstp [dword ptr bx+12*4] -;1,3 - fld [dword ptr si+12*4] - fmul [dword ptr di+1*4] - fld [dword ptr si+13*4] - fmul [dword ptr di+5*4] - faddp st(1) - fld [dword ptr si+14*4] - fmul [dword ptr di+9*4] - faddp st(1) - fld [dword ptr si+15*4] - fmul [dword ptr di+13*4] - faddp st(1) - fstp [dword ptr bx+13*4] -;2,3 - fld [dword ptr si+12*4] - fmul [dword ptr di+2*4] - fld [dword ptr si+13*4] - fmul [dword ptr di+6*4] - faddp st(1) - fld [dword ptr si+14*4] - fmul [dword ptr di+10*4] - faddp st(1) - fld [dword ptr si+15*4] - fmul [dword ptr di+14*4] - faddp st(1) - fstp [dword ptr bx+14*4] -;3,3 - fld [dword ptr si+12*4] - fmul [dword ptr di+3*4] - fld [dword ptr si+13*4] - fmul [dword ptr di+7*4] - faddp st(1) - fld [dword ptr si+14*4] - fmul [dword ptr di+11*4] - faddp st(1) - fld [dword ptr si+15*4] - fmul [dword ptr di+15*4] - faddp st(1) - fstp [dword ptr bx+15*4] - ret -endp multiply +include "..\include\mem.h" +include "..\include\graphic.h" +include "..\include\3d.h" + +org 0h + +header exe 1 + +exporting +declare draw3d_point +declare draw3d_line +declare draw3d_hidden +declare draw3d_hidden_fill +declare load3ds +declare translate +declare translatex +declare translatey +declare translatez +declare scale +declare rescale +declare copy +declare fill +declare identity +declare rotationx +declare rotationy +declare rotationz +declare rotation +declare project +declare transform +declare multiply +ende + +importing +use GRAPHIC.LIB,line +use GRAPHIC.LIB,polyfill +use VIDEO,showpixel +endi + +;affiche liste vertex %0 +proc draw3d_point uses cx si, vertex3d:word,vertex2d:word,camera:word,color:word + mov si,[vertex2d] + stdcall project,si,[vertex3d],[camera] + mov cx,[si] + inc si + inc si +.draw: + virtual at si + .vertex2d vertex2d + end virtual + invoke showpixel,[.vertex2d.px],[.vertex2d.py],[color] + add si,4 + dec cx + jnz .draw + retf +endp + +;affiche liste vertex %0 +proc draw3d_line uses ax bx cx dx si di, type:word,faces:word,vertex3d:word,vertex2d:word,camera:word,color:word + mov di,[faces] + mov si,[vertex2d] + stdcall project,si,[vertex3d],[camera] + mov cx,[di] + inc si + inc si + inc di + inc di +.draw: + mov ax,[type] + dec al + mov dx,di +.drawset: + mov bx,[di] + shl bx,2 + push [color] + virtual at bx+si + .vertex2d vertex2d + end virtual + push [.vertex2d.py] + push [.vertex2d.px] + add di,2 + mov bx,[di] + shl bx,2 + push [.vertex2d.py] + push [.vertex2d.px] + invoke line + dec al + jnz .drawset + push di + mov di,dx + mov bx,[di] + pop di + shl bx,2 + push [color] + push [.vertex2d.py] + push [.vertex2d.px] + mov bx,[di] + shl bx,2 + push word [bx+si+2] + push word [bx+si] + invoke line + add di,2 + dec cx + jnz .draw + retf +endp + +;affiche liste vertex %0 +proc draw3d_hidden uses ax bx cx dx si di, type:word,faces:word,vertex3d:word,vertex2d:word,camera:word,color:word + local a1:WORD,a2:WORD,b1:WORD + mov di,[faces] + mov si,[vertex2d] + stdcall project,si,[vertex3d],[camera] + mov cx,[di] + inc si + inc si + inc di + inc di +.draw: + push cx + mov si,[vertex2d] + inc si + inc si + mov bx,[di+2] + shl bx,2 + virtual at bx+si + .vertex2d vertex2d + end virtual + mov cx,[.vertex2d.px] + mov dx,[.vertex2d.py] + mov bx,[di] + shl bx,2 + mov ax,[.vertex2d.px] + sub ax,cx + mov [a1],ax + mov ax,[.vertex2d.py] + sub ax,dx + mov [b1],ax + mov bx,[di+4] + shl bx,2 + mov ax,[.vertex2d.px] + sub ax,cx + mov [a2],ax + mov ax,[.vertex2d.py] + sub ax,dx + xor edx,edx + imul [a1] + and eax,0FFFFh + rol eax,16 + add eax,edx + rol eax,16 + mov ecx,eax + mov ax,[b1] + imul [a2] + and eax,0FFFFh + rol eax,16 + add eax,edx + rol eax,16 + sub ecx,eax + pop cx + jge .nohidden + mov ax,[type] + shl ax,1 + add di,ax + dec cx + jnz .draw + jmp .endof +.nohidden: + mov ax,[type] + dec al + mov dx,di +.drawset: + mov bx,[di] + shl bx,2 + push [color] + push [.vertex2d.py] + push [.vertex2d.px] + add di,2 + mov bx,[di] + shl bx,2 + push [.vertex2d.py] + push [.vertex2d.px] + invoke line + dec al + jnz .drawset + push di + mov di,dx + mov bx,[di] + pop di + shl bx,2 + push [color] + push [.vertex2d.py] + push [.vertex2d.px] + mov bx,[di] + shl bx,2 + push word [bx+si+2] + push word [bx+si] + invoke line + add di,2 + dec cx + jnz .draw +.endof: + retf +endp + +;creer table pour face caché %0 +proc draw3d_hidden_fill uses eax bx ecx edx si di, type:word,faces:word,vertex3d:word,vertex2d:word,camera:word,color:word + local a1:WORD,a2:WORD,b1:WORD + mov di,[faces] + stdcall project,[vertex2d],[vertex3d],[camera] + mov cx,[di] + inc di + inc di +.calculvect: + push cx + mov si,[vertex2d] + inc si + inc si + mov bx,[di+2] + shl bx,2 + virtual at bx+si + .vertex2d vertex2d + end virtual + mov cx,[.vertex2d.px] + mov dx,[.vertex2d.py] + mov bx,[di] + shl bx,2 + mov ax,[.vertex2d.px] + sub ax,cx + mov [a1],ax + mov ax,[.vertex2d.py] + sub ax,dx + mov [b1],ax + mov bx,[di+4] + shl bx,2 + mov ax,[.vertex2d.px] + sub ax,cx + mov [a2],ax + mov ax,[.vertex2d.py] + sub ax,dx + xor edx,edx + imul [a1] + rol eax,16 + add eax,edx + rol eax,16 + mov ecx,eax + mov ax,[b1] + imul [a2] + rol eax,16 + add eax,edx + rol eax,16 + sub ecx,eax + pop cx + jl .hidden + mov ax,[type] + mov si,[vertex3d] + inc si + inc si + fld [cs:zero] +.calcz: + mov bx,[di] + mov dx,bx + shl dx,2 + shl bx,3 + add bx,dx + virtual at bx+si + .vertex3d vertex3d + end virtual + fadd [.vertex3d.tz] + add di,2 + dec al + jnz .calcz +.hidden: + mov ax,[type] + shl ax,1 + add di,ax +.enofvalue: + dec cx + jnz .calculvect + retf +endp + + +;charge un fichier 3ds logé en %0 renvoie error +;sauvegarde en : +;- %1 le nom de l'objet +;- %2 les vertex 3D de l'objet +;- %3 la matrice de transformation de l'objet +;- %4 les faces de l'objet +;- %5 le type de face de l'objet +;1 non 3ds +;2 non 3 et > +proc load3ds uses eax bx cx si di ds es fs, seg:word,addt:word,objectname:word,vertex:word,matrix:word,face:word + push ds + pop fs + mov si,[addt] + mov ds,[seg] + cmp word [si],main + jne .error1 + cmp word [si+28],3 + jb .error2 +.reading: + mov ax,[si] + mov bx,[si+2] + cmp ax,main + je .enter + cmp ax,edit + je .enter + cmp ax,mesh + je .enter + cmp ax,object + je .readobject + cmp ax,vertex + je .readvertex + cmp ax,locale + je .readmatrix + cmp ax,face + je .readfaces +.next: + add si,bx + jmp .reading +.enter: + add si,6 + jmp .reading +.readobject: + add si,6 + mov di,si + mov al,0 + mov es,[seg] + mov cx,12 + cld + repne scasb + mov cx,di + sub cx,si + mov di,[objectname] + push fs + pop es + cld + rep movsb + jmp .reading +.readvertex: + add si,6 + mov ax,[si] + mov di,[vertex] + mov [fs:di],ax + inc si + inc si + mov cx,ax + shl ax,1 + add cx,ax + add di,2 + cld + push fs + pop es + cld + rep movsd + jmp .reading +.readmatrix: + add si,6 + mov di,[matrix] + mov eax,[si] + virtual at di + .mat mat + end virtual + mov [fs:.mat.p1],eax + mov eax,[si+4*1] + mov [fs:.mat.p5],eax + mov eax,[si+4*2] + mov [fs:.mat.p9],eax + mov eax,[si+4*3] + mov [fs:.mat.p2],eax + mov eax,[si+4*4] + mov [fs:.mat.p6],eax + mov eax,[si+4*5] + mov [fs:.mat.p10],eax + mov eax,[si+4*6] + mov [fs:.mat.p3],eax + mov eax,[si+4*7] + mov [fs:.mat.p7],eax + mov eax,[si+4*8] + mov [fs:.mat.p11],eax + mov eax,[si+4*9] + mov [fs:.mat.p4],eax + mov eax,[si+4*10] + mov [fs:.mat.p8],eax + mov eax,[si+4*11] + mov [fs:.mat.p12],eax + mov eax,[cs:un] + mov [fs:.mat.p16],eax + mov eax,0 + mov [fs:.mat.p13],eax + mov [fs:.mat.p14],eax + mov [fs:.mat.p15],eax + add si,12*4 + jmp .reading +.readfaces: + add si,6 + mov ax,[si] + mov di,[face] + mov [fs:di],ax + inc si + inc si + add di,2 + push fs + pop es + cld +.readall: + mov cx,3 + rep movsw + inc si + inc si + dec ax + jnz .readall + ;;jmp .reading +.error1: +.error2: + retf +endp + +un dd 1.0 +zero dd 0.0 + +;initialise une matrice de translation pour une translation TX,TY,TZ (%1,%2,%3) dans MATRICE %0 +; mat[ 0] = 1.0 +; mat[ 5] = 1.0 +; mat[10] = 1.0 +; mat[15] = 1.0 +; mat[ 3] = vecteur->x +; mat[ 7] = vecteur->y +; mat[11] = vecteur->z +proc translate uses eax ecx di es, mat:word,x:dword,y:dword,z:dword + mov di,[mat] + mov ecx,16 + mov eax,0 + push ds + pop es + cld + rep stosd + mov di,[mat] + mov eax,[cs:un] + mov [di+0*4],eax + mov [di+5*4],eax + mov [di+10*4],eax + mov [di+15*4],eax + mov eax,[x] + mov [di+3*4],eax + mov eax,[y] + mov [di+7*4],eax + mov eax,[z] + mov [di+11*4],eax + retf +endp + +;initialise une matrice de translation pour une translation TX %1 dans MATRICE %0 +; mat[ 0] = 1.0 +; mat[ 5] = 1.0 +; mat[10] = 1.0 +; mat[15] = 1.0 +; mat[ 3] = value +; mat[ 7] = 1 +; mat[11] = 1 +proc translatex uses eax ecx di es, mat:word,value:dword + mov di,[mat] + mov ecx,16 + mov eax,0 + push ds + pop es + cld + rep stosd + mov di,[mat] + mov eax,[cs:un] + mov [di+0*4],eax + mov [di+5*4],eax + mov [di+10*4],eax + mov [di+15*4],eax + mov [di+7*4],eax + mov [di+11*4],eax + mov eax,[value] + mov [di+3*4],eax + retf +endp + + +;initialise une matrice de translation pour une translation TY %1 dans MATRICE %0 +; mat[ 0] = 1.0 +; mat[ 5] = 1.0 +; mat[10] = 1.0 +; mat[15] = 1.0 +; mat[ 3] = 1 +; mat[ 7] = value +; mat[11] = 1 +proc translatey uses eax ecx di es, mat:word,value:dword + mov di,[mat] + mov ecx,16 + mov eax,0 + push ds + pop es + cld + rep stosd + mov di,[mat] + mov eax,[cs:un] + mov [di+0*4],eax + mov [di+5*4],eax + mov [di+10*4],eax + mov [di+15*4],eax + mov [di+3*4],eax + mov [di+11*4],eax + mov eax,[value] + mov [di+7*4],eax + retf +endp + +;initialise une matrice de translation pour une translation TZ %1 dans MATRICE %0 +; mat[ 0] = 1.0 +; mat[ 5] = 1.0 +; mat[10] = 1.0 +; mat[15] = 1.0 +; mat[ 3] = 1 +; mat[ 7] = 1 +; mat[11] = value +proc translatez uses eax ecx di es, mat:word,value:dword + mov di,[mat] + mov ecx,16 + mov eax,0 + push ds + pop es + cld + rep stosd + mov di,[mat] + mov eax,[cs:un] + mov [di+0*4],eax + mov [di+5*4],eax + mov [di+10*4],eax + mov [di+15*4],eax + mov [di+3*4],eax + mov [di+7*4],eax + mov eax,[value] + mov [di+11*4],eax + retf +endp + +;initialise une matrice d'echelle %0 de facteur (x,y,z) %1-%3 +; mat[ 0] = factorx +; mat[ 5] = factory +; mat[10] = factorz +; mat[15] = 1.0 +; reste a 0 +proc scale uses eax ecx di es, mat:word,x:dword,y:dword,z:dword + mov di,[mat] + mov ecx,16 + mov eax,0 + push ds + pop es + cld + rep stosd + mov di,[mat] + mov eax,[x] + mov [di+0*4],eax + mov eax,[y] + mov [di+5*4],eax + mov eax,[z] + mov [di+10*4],eax + mov eax,[cs:un] + mov [di+15*4],eax + retf +endp + +;initialise une matrice d'echelle %0 de facteur value %1 +; mat[ 0] = factor +; mat[ 5] = factor +; mat[10] = factor +; mat[15] = 1.0 +; reste a 0 +proc rescale uses eax ecx di es, mat:word,value:dword + mov di,[mat] + mov ecx,16 + mov eax,0 + push ds + pop es + cld + rep stosd + mov di,[mat] + mov eax,[value] + mov [di+0*4],eax + mov [di+5*4],eax + mov [di+10*4],eax + mov eax,[cs:un] + mov [di+15*4],eax + retf +endp + +;copy une matrice %0 en %1 +;mat2=mat1 +proc copy uses ecx si di es, mat1:word,mat2:word + mov si,[mat1] + mov di,[mat2] + mov ecx,16 + push ds + pop es + cld + rep stosd + retf +endp + +;initialise une matrice %0 avec la valeur %1 +;mat[i]=value +proc fill uses eax ecx di es, mat:word,value:dword + mov di,[mat] + mov eax,[value] + mov ecx,16 + push ds + pop es + cld + rep stosd + retf +endp + +;initialise une matrice d'identité %0 +; mat[0] = 1.0 +; mat[5] = 1.0 +; mat[10] = 1.0 +; mat[15] = 1.0 +; reste a 0 +proc identity uses eax ecx di es, mat:word + mov di,[mat] + mov ecx,16 + mov eax,0 + push ds + pop es + cld + rep stosd + mov di,[mat] + mov eax,[cs:un] + mov [di+0*4],eax + mov [di+5*4],eax + mov [di+10*4],eax + mov [di+15*4],eax + retf +endp + + +;initialise une matrice de rotation %0 autour de X de %1 degrees +; mat[ 5] = cos(angle) +; mat[ 6] = -sin(angle) +; mat[ 9] = sin(angle) +; mat[10] = cos(angle) +; mat[ 0] = 1.0 +; mat[15] = 1.0 +; reste a 0 +proc rotationx uses eax ecx di es, mat:word,value:dword + mov di,[mat] + mov ecx,16 + mov eax,0 + push ds + pop es + cld + rep stosd + mov di,[mat] + fld [value] + fsincos +;mat[ 5] = cos(angle); + fst dword [di+5*4] +;mat[ 10] = cos(angle); + fstp dword [di+10*4] +;mat[ 9] = sin(angle); + fst dword [di+9*4] +;mat[ 6] = -sin(angle); + fchs + fstp dword [di+6*4] +;mat[ 0] = 1.0 +;mat[15] = 1.0 + mov eax,[cs:un] + mov [di+0*4],eax + mov [di+15*4],eax + retf +endp + +;initialise une matrice de rotation BX autour de Y de %0 degrees +; mat[ 0] = cos(angle) +; mat[ 8] = -sin(angle) +; mat[ 2] = sin(angle) +; mat[10] = cos(angle) +; mat[ 5] = 1.0 +; mat[15] = 1.0 +; reste a 0 +proc rotationy uses eax ecx di es, mat:word,value:dword + mov di,[mat] + mov ecx,16 + mov eax,0 + push ds + pop es + cld + rep stosd + mov di,[mat] + fld [value] + fsincos +;mat[ 0] = cos(angle) + fst dword [di+0*4] +;mat[ 10] = cos(angle) + fstp dword [di+10*4] +;mat[ 2] = sin(angle) + fst dword [di+2*4] + fchs +;mat[ 8] = -sin(angle) + fstp dword [ di+8*4] +;mat[ 5] = 1.0 +;mat[15] = 1.0 + mov eax,[cs:un] + mov [di+5*4],eax + mov [di+15*4],eax + retf +endp + +;initialise une matrice de rotation %0 autour de Z de %1 degrees +; mat[ 0] = cos(angle) +; mat[ 1] = -sin(angle) +; mat[ 4] = sin(angle) +; mat[ 5] = cos(angle) +; mat[10] = 1.0 +; mat[15] = 1.0 +; reste a 0 +proc rotationz uses eax ecx di es, mat:word,value:dword + mov di,[mat] + mov ecx,16 + mov eax,0 + push ds + pop es + cld + rep stosd + mov di,[mat] + fld [value] + fsincos +;mat[ 0] = cos(angle) + fst dword [ di+0*4] +;mat[ 5] = cos(angle) + fstp dword [ di+5*4] +;mat[ 4] = sin(angle) + fst dword [ di+4*4] + fchs +;mat[ 1] = -sin(angle) + fstp dword [ di+1*4] +;mat[10] = 1.0 +;mat[15] = 1.0 + mov eax,[cs:un] + mov [di+10*4],eax + mov [di+15*4],eax + retf +endp + +;initialise une matrice de rotation %0 autour de X,Y,Z de %0-%3 degrees +; mat[ 0] = cos(angleY)*cos(angleZ) +; mat[ 1] = cos(angleY)*sin(angleZ) +; mat[ 2] = -sin(angleY) +; mat[ 4] = sin(angleX)*sin(angleY)*cos(angleZ)+cos(angleX)*-sin(angleZ) +; mat[ 5] = sin(angleX)*sin(angleY)*sin(angleZ)+cos(angleX)*cos(angleZ) +; mat[ 6] = sin(angleX)*cos(angleY) +; mat[ 8] = cos(angleX)*sin(angleY)*cos(angleZ)+sin(angleX)*sin(angleZ) +; mat[ 9] = cos(angleX)*sin(angleY)*sin(angleZ)-sin(angleX)*cos(angleZ) +; mat[ 10] = cos(angleX)*cos(angleY) +; mat[3] = 0.0 +; mat[7] = 0.0 +; mat[11] = 0.0 +; mat[12] = 0.0 +; mat[13] = 0.0 +; mat[14] = 0.0 +; mat[15] = 1.0 +; reste a 0 +proc rotation uses eax ecx di es, mat:word,anglex:dword,angley:dword,anglez:dword + mov di,[mat] + mov ecx,16 + mov eax,0 + push ds + pop es + cld + rep stosd + mov di,[mat] +;st1 sin(angleZ) +;st2 cos(angleZ) +;st3 sin(angleY) +;st4 cos(angleY) +;st5 sin(angleX) +;st6 cos(angleX) + fld [anglex] + fsincos + fld [angley] + fsincos + fld [anglez] + fsincos +;Cos(angleY)*Cos(angleZ) + fld st3 + fmul st0,st2 +;mat[0] + fstp dword [ di+0*4] +;Cos(angleY)*Sin(angleZ) + fld st3 + fmul st0,st1 +;mat[1] + fstp dword [ di+1*4] +;-Sin(angley) + fld st2 + fchs +;mat[2] + fstp dword [ di+2*4] + mov eax,[cs:un] + mov [di+15*4],eax + retf +endp + + +factor dd 128.0 + +;Transforme la liste de vertex 3D pointé par %0 en vertex 2D dans %1 en utilisant %2 comme origine pour %3 valeurs +; vertex2d[i].px=int((vertex3d[i].tx*factor)/(vertex3d[i].tz+origin.Z)+origin.X) +; vertex2d[i].py=int((vertex3d[i].ty*factor)/(vertex3d[i].tz+origin.Z)+origin.Y) +proc project uses bx cx si di, vertex2d:word,vertex3d:word,origin:word + mov si,[vertex3d] + mov bx,[vertex2d] + mov di,[origin] + mov cx,[si] + mov [bx],cx + inc si + inc si + inc bx + inc bx +.boucle: + virtual at 0 + .vertex3d vertex3d + end virtual + virtual at 0 + .vertex2d vertex2d + end virtual + virtual at si + .vertex3dsrc vertex3d + end virtual + virtual at di + .vertex3ddst vertex3d + end virtual + virtual at bx + .vertex2dsrc vertex2d + end virtual +;(vertex3d[i].z+origZ) + fld [.vertex3dsrc.tz] + fadd [.vertex3ddst.tz] +;(vertex3d[i].tx*factor) + fld [.vertex3dsrc.tx] + fmul [cs:factor] +;(vertex3d[i].tx*factor)/(vertex3d[i].tz+origZ) + fdiv st,st1 +;(vertex3d[i].tx*factor)/(vertex3d[i].tz+origZ)+origX + fadd [.vertex3ddst.tx] +;vertex2d[i].tx=int((vertex3d[i].tx*factor)/(vertex3d[i].tz+origZ)+origX) + fistp [.vertex2dsrc.px] +;(vertex3d[i].z+origZ) +;(vertex3d[i].ty*factor) + fld [.vertex3dsrc.ty] + fmul [cs:factor] +;(vertex3d[i].ty*factor)/(vertex3d[i].tz+origZ) + ;fdivrp st1 +;(vertex3d[i].ty*factor)/(vertex3d[i].tz+origZ)+origY + fadd [.vertex3ddst.ty] +;vertex2d[i].ty=int((vertex3d[i].ty*factor)/(vertex3d[i].tz+origZ)+origY) + fistp [.vertex2dsrc.py] + add si,.vertex3d.sizeof + add bx,.vertex2d.sizeof + dec cx + jnz .boucle + retf +endp + + +;transforme les points %0 avec la matrice %1 + +; vertex3d_2 = mat * vertex3d + +; w = mat[12]*vertex3d[i].tx + mat[13]*vertex3d[i].ty + mat[14]*vertex3d[i].tz + mat[15] +; vertex3d_2[i].tx = mat[ 0]*vertex3d[i].tx + mat[ 1]*vertex3d[i].ty + mat[ 2]*vertex3d[i].tz + mat[ 3] +; vertex3d_2[i].ty = mat[ 4]*vertex3d[i].tx + mat[ 5]*vertex3d[i].ty + mat[ 6]*vertex3d[i].tz + mat[ 7] +; vertex3d_2[i].tz = mat[ 8]*vertex3d[i].tx + mat[ 9]*vertex3d[i].ty + mat[10]*vertex3d[i].tz + mat[11] +proc transform uses cx si di, vertex3d:word,mat:word + mov si,[vertex3d] + mov cx,[si] + inc si + inc si + mov di,[mat] +.boucle: +;Calcul du facteur echelle +;mat[12]*vertex3d[i].tx + virtual at si + .vertex3d vertex3d + end virtual + fld [.vertex3d.tx] + fmul dword [ di+12*4] +;mat[13]*vertex3d[i].ty + fld [.vertex3d.ty] + fmul dword [ di+13*4] +;mat[12]*vertex3d[i].tx + mat[13]*vertex3d[i].ty + ;faddp st1 +;mat[14]*vertex3d.tz + fld [.vertex3d.tz] + fmul dword [ di+14*4] +;mat[12]*vertex3d[i].tx + mat[13]*vertex3d[i].ty + mat[14]*vertex3d[i].tz + ;faddp st1 +;mat[12]*vertex3d[i].tx + mat[13]*vertex3d[i].ty + mat[14]*vertex3d[i].tz + mat[15] + fadd dword [ di+15*4] +;w=0.0 ?? + ftst +;-> AX + fstsw ax + +;vertex3d.tx vertex3d.ty et vertex3d.tz + fld [.vertex3d.tx] + fmul dword [ di+0*4] + fld [.vertex3d.ty] + fmul dword [ di+1*4] + ;faddp st1 + fld [.vertex3d.tz] + fmul dword [ di+2*4] + ;faddp st1 + fadd dword [ di+3*4] + + fld [.vertex3d.tx] + fmul dword [ di+4*4] + fld [.vertex3d.ty] + fmul dword [ di+5*4] + ;faddp st1 + fld [.vertex3d.tz] + fmul dword [ di+6*4] + ;faddp st1 + fadd dword [ di+7*4] + + fld [.vertex3d.tx] + fmul dword [ di+8*4] + fld [.vertex3d.ty] + fmul dword [ di+9*4] + ;faddp st1 + fld [.vertex3d.tz] + fmul dword [ di+10*4] + ;faddp st1 + fadd dword [ di+11*4] + +;w=0.0 + sahf + jz .divby0 +;vertex3d.tx=vertex3d[i].tz/w + fdiv st,st3 + fstp [.vertex3d.tz] +;vertex3d.ty=vertex3d[i].ty/w + fdiv st,st2 + fstp [.vertex3d.ty] +;vertex3d.tz=vertex3d[i].tx/w + fdivrp st1,st + fstp [.vertex3d.tx] +;No div by 0 + jmp .nodiv +.divby0: + fstp [.vertex3d.tz] + fstp [.vertex3d.ty] + fstp [.vertex3d.tx] + ;ffree +.nodiv: + virtual at 0 + .vertex3dori vertex3d + end virtual + add si,.vertex3dori.sizeof + dec cx + jnz .boucle + retf +endp + +;Multiplie la matrice de transformation %0 par celle en %1 et met les resultat en %2 + +; mat = p1 * p2 + +; mat[ 0] = (p1[ 0]*p2[ 0])+(p1[ 1]*p2[ 4])+(p1[ 2]*p2[ 8])+(p1[ 3]*p2[12]); +; mat[ 4] = (p1[ 4]*p2[ 0])+(p1[ 5]*p2[ 4])+(p1[ 6]*p2[ 8])+(p1[ 7]*p2[12]); +; mat[ 8] = (p1[ 8]*p2[ 0])+(p1[ 9]*p2[ 4])+(p1[10]*p2[ 8])+(p1[11]*p2[12]); +; mat[12] = (p1[12]*p2[ 0])+(p1[13]*p2[ 4])+(p1[14]*p2[ 8])+(p1[15]*p2[12]); +; mat[ 1] = (p1[ 0]*p2[ 1])+(p1[ 1]*p2[ 5])+(p1[ 2]*p2[ 9])+(p1[ 3]*p2[13]); +; mat[ 5] = (p1[ 4]*p2[ 1])+(p1[ 5]*p2[ 5])+(p1[ 6]*p2[ 9])+(p1[ 7]*p2[13]); +; mat[ 9] = (p1[ 8]*p2[ 1])+(p1[ 9]*p2[ 5])+(p1[10]*p2[ 9])+(p1[11]*p2[13]); +; mat[13] = (p1[12]*p2[ 1])+(p1[13]*p2[ 5])+(p1[14]*p2[ 9])+(p1[15]*p2[13]); +; mat[ 2] = (p1[ 0]*p2[ 2])+(p1[ 1]*p2[ 6])+(p1[ 2]*p2[10])+(p1[ 3]*p2[14]); +; mat[ 6] = (p1[ 4]*p2[ 2])+(p1[ 5]*p2[ 6])+(p1[ 6]*p2[10])+(p1[ 7]*p2[14]); +; mat[10] = (p1[ 8]*p2[ 2])+(p1[ 9]*p2[ 6])+(p1[10]*p2[10])+(p1[11]*p2[14]); +; mat[14] = (p1[12]*p2[ 2])+(p1[13]*p2[ 6])+(p1[14]*p2[10])+(p1[15]*p2[14]); +; mat[ 3] = (p1[ 0]*p2[ 3])+(p1[ 1]*p2[ 7])+(p1[ 2]*p2[11])+(p1[ 3]*p2[15]); +; mat[ 7] = (p1[ 4]*p2[ 3])+(p1[ 5]*p2[ 7])+(p1[ 6]*p2[11])+(p1[ 7]*p2[15]); +; mat[11] = (p1[ 8]*p2[ 3])+(p1[ 9]*p2[ 7])+(p1[10]*p2[11])+(p1[11]*p2[15]); +; mat[15] = (p1[12]*p2[ 3])+(p1[13]*p2[ 7])+(p1[14]*p2[11])+(p1[15]*p2[15]); + +proc multiply uses bx si di, p1:word,p2:word,mat:word + mov si,[p1] + mov di,[p2] + mov bx,[mat] +;0,0 +;p1[ 0]*p2[ 0] + fld dword [ si+0*4] + fmul dword [ di+0*4] +;p1[ 1]*p2[ 4] + fld dword [ si+1*4] + fmul dword [ di+4*4] +;(p1[ 0]*p2[ 0])+(p1[ 1]*p2[ 4]) + ;;faddp st1 +;p1[ 2]*p2[ 8] + fld dword [ si+2*4] + fmul dword [ di+8*4] +;(p1[ 0]*p2[ 0])+(p1[ 1]*p2[ 4])+(p1[ 2]*p2[ 8]) + ;;faddp st1 +;p1[ 3]*p2[12] + fld dword [ si+3*4] + fmul dword [ di+12*4] +;(p1[ 0]*p2[ 0])+(p1[ 1]*p2[ 4])+(p1[ 2]*p2[ 8])+(p1[ 3]*p2[12]) + ;;faddp st1 + fstp dword [ bx+0*4] +;mat[ 0] + +;1,0 + fld dword [ si+0*4] + fmul dword [ di+1*4] + fld dword [ si+1*4] + fmul dword [ di+5*4] + ;faddp st1 + fld dword [ si+2*4] + fmul dword [ di+9*4] + ;faddp st1 + fld dword [ si+3*4] + fmul dword [ di+13*4] + ;faddp st1 + fstp dword [ bx+1*4] +;2,0 + fld dword [ si+0*4] + fmul dword [ di+2*4] + fld dword [ si+1*4] + fmul dword [ di+6*4] + ;faddp st1 + fld dword [ si+2*4] + fmul dword [ di+10*4] + ;faddp st1 + fld dword [ si+3*4] + fmul dword [ di+14*4] + ;faddp st1 + fstp dword [ bx+2*4] +;3,0 + fld dword [ si+0*4] + fmul dword [ di+3*4] + fld dword [ si+1*4] + fmul dword [ di+7*4] + ;faddp st1 + fld dword [ si+2*4] + fmul dword [ di+11*4] + ;faddp st1 + fld dword [ si+3*4] + fmul dword [ di+15*4] + ;faddp st1 + fstp dword [ bx+3*4] +;0,1 + fld dword [ si+4*4] + fmul dword [ di+0*4] + fld dword [ si+5*4] + fmul dword [ di+4*4] + ;faddp st1 + fld dword [ si+6*4] + fmul dword [ di+8*4] + ;faddp st1 + fld dword [ si+7*4] + fmul dword [ di+12*4] + ;faddp st1 + fstp dword [ bx+4*4] +;1,1 + fld dword [ si+4*4] + fmul dword [ di+1*4] + fld dword [ si+5*4] + fmul dword [ di+5*4] + ;faddp st1 + fld dword [ si+6*4] + fmul dword [ di+9*4] + ;faddp st1 + fld dword [ si+7*4] + fmul dword [ di+13*4] + ;faddp st1 + fstp dword [ bx+5*4] +;2,1 + fld dword [ si+4*4] + fmul dword [ di+2*4] + fld dword [ si+5*4] + fmul dword [ di+6*4] + ;faddp st1 + fld dword [ si+6*4] + fmul dword [ di+10*4] + ;faddp st1 + fld dword [ si+7*4] + fmul dword [ di+14*4] + ;faddp st1 + fstp dword [ bx+6*4] +;3,1 + fld dword [ si+4*4] + fmul dword [ di+3*4] + fld dword [ si+5*4] + fmul dword [ di+7*4] + ;faddp st1 + fld dword [ si+6*4] + fmul dword [ di+11*4] + ;faddp st1 + fld dword [ si+7*4] + fmul dword [ di+15*4] + ;faddp st1 + fstp dword [ bx+7*4] +;0,2 + fld dword [ si+8*4] + fmul dword [ di+0*4] + fld dword [ si+9*4] + fmul dword [ di+4*4] + ;faddp st1 + fld dword [ si+10*4] + fmul dword [ di+8*4] + ;faddp st1 + fld dword [ si+11*4] + fmul dword [ di+12*4] + ;faddp st1 + fstp dword [ bx+8*4] +;1,2 + fld dword [ si+8*4] + fmul dword [ di+1*4] + fld dword [ si+9*4] + fmul dword [ di+5*4] + ;faddp st1 + fld dword [ si+10*4] + fmul dword [ di+9*4] + ;faddp st1 + fld dword [ si+11*4] + fmul dword [ di+13*4] + ;faddp st1 + fstp dword [ bx+9*4] +;2,2 + fld dword [ si+8*4] + fmul dword [ di+2*4] + fld dword [ si+9*4] + fmul dword [ di+6*4] + ;faddp st1 + fld dword [ si+10*4] + fmul dword [ di+10*4] + ;faddp st1 + fld dword [ si+11*4] + fmul dword [ di+14*4] + ;faddp st1 + fstp dword [ bx+10*4] +;3,2 + fld dword [ si+8*4] + fmul dword [ di+3*4] + fld dword [ si+9*4] + fmul dword [ di+7*4] + ;faddp st1 + fld dword [ si+10*4] + fmul dword [ di+11*4] + ;faddp st1 + fld dword [ si+11*4] + fmul dword [ di+15*4] + ;faddp st1 + fstp dword [ bx+11*4] +;0,3 + fld dword [ si+12*4] + fmul dword [ di+0*4] + fld dword [ si+13*4] + fmul dword [ di+4*4] + ;faddp st1 + fld dword [ si+14*4] + fmul dword [ di+8*4] + ;faddp st1 + fld dword [ si+15*4] + fmul dword [ di+12*4] + ;faddp st1 + fstp dword [ bx+12*4] +;1,3 + fld dword [ si+12*4] + fmul dword [ di+1*4] + fld dword [ si+13*4] + fmul dword [ di+5*4] + ;faddp st1 + fld dword [ si+14*4] + fmul dword [ di+9*4] + ;faddp st1 + fld dword [ si+15*4] + fmul dword [ di+13*4] + ;faddp st1 + fstp dword [ bx+13*4] +;2,3 + fld dword [ si+12*4] + fmul dword [ di+2*4] + fld dword [ si+13*4] + fmul dword [ di+6*4] + ;faddp st1 + fld dword [ si+14*4] + fmul dword [ di+10*4] + ;faddp st1 + fld dword [ si+15*4] + fmul dword [ di+14*4] + ;faddp st1 + fstp dword [ bx+14*4] +;3,3 + fld dword [ si+12*4] + fmul dword [ di+3*4] + fld dword [ si+13*4] + fmul dword [ di+7*4] + ;faddp st1 + fld dword [ si+14*4] + fmul dword [ di+11*4] + ;faddp st1 + fld dword [ si+15*4] + fmul dword [ di+15*4] + ;faddp st1 + fstp dword [ bx+15*4] + retf +endp diff --git a/lib/bmp.asm b/lib/bmp.asm index 893346a..fd65db7 100644 --- a/lib/bmp.asm +++ b/lib/bmp.asm @@ -1,10 +1,3 @@ -model tiny,stdcall -p586N -locals -jumps -codeseg -option procalign:byte - include "..\include\mem.h" include "..\include\divers.h" include "..\include\bmp.h" @@ -12,7 +5,7 @@ include "..\include\bmp.h" org 0h start: -header exe <"CE",1,0,0,offset exports,offset imports,,> +header exe 1 exporting declare showbmp @@ -28,45 +21,46 @@ endi ;<- 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] +proc showbmp uses ax bx cx dx si di, pointer:word, x:word, y:word + mov si,[pointer] + virtual at si + .bmp_file bmp_file + end virtual + cmp word [.bmp_file.bmp_filetype],"MB" + jne .errorshowing + mov edi,[.bmp_file.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] + mov ecx,[.bmp_file.bmp_height] + mov edx,[.bmp_file.bmp_width] ;and dx,11111100b - cmp edx,[(bmp_file si).bmp_width] - ;jae @@noadjust + cmp edx,[.bmp_file.bmp_width] + ;jae .noadjust ;add dx,4 -@@noadjust: - sub edx,[(bmp_file si).bmp_width] -@@bouclette: +.noadjust: + sub edx,[.bmp_file.bmp_width] +.bouclette: push bx cx - add bx,[@x] - add cx,[@y] - call [cs:showpixel],bx,cx,[word ptr di] + add bx,[x] + add cx,[y] + invoke showpixel,bx,cx,word [di] pop cx bx inc bx inc di - cmp ebx,[(bmp_file si).bmp_width] - jb @@bouclette + cmp ebx,[.bmp_file.bmp_width] + jb .bouclette xor bx,bx ;add di,dx dec cx cmp cx,0 - jne @@bouclette + jne .bouclette clc ret -@@errorshowing: +.errorshowing: stc ret -ENDP showbmp +endp ;==========LOADBMPPALET========= @@ -74,14 +68,12 @@ ENDP showbmp ;-> DS:%0 BMP ;<- ;=============================== -PROC loadbmppalet FAR - ARG @pointer:word - USES ax,bx,cx,dx,si - mov si,[@pointer] +proc loadbmppalet uses ax bx cx dx si, pointer:word + mov si,[pointer] mov bx,0400h+36h-4 mov cx,100h mov dx, 3c8h -@@paletteload: +.paletteload: mov al, cl dec al out dx, al @@ -98,8 +90,8 @@ PROC loadbmppalet FAR sub bx,4 dec dx dec cl - jnz @@paletteload + jnz .paletteload ret -ENDP loadbmppalet +endp diff --git a/lib/graphic.asm b/lib/graphic.asm index 43dc68e..bef5871 100644 --- a/lib/graphic.asm +++ b/lib/graphic.asm @@ -1,230 +1,226 @@ -model tiny,stdcall -p586 -locals -jumps -codeseg -option procalign:byte - -include "..\include\mem.h" -include "..\include\graphic.h" - -org 0h - -header exe <"CE",1,0,0,offset exports,offset imports,,> - -exporting -declare hline -declare line -declare polyfill -ende - -importing -use VIDEO,showpixel -endi - -PROC hline FAR - ARG @x1:word,@x2:word,@y:word,@color:word - USES cx,dx - mov cx,[@x1] - mov dx,[@x2] - cmp cx,dx - jbe @@boucle - xchg cx,dx -@@boucle: - call [cs:showpixel],cx,[@y],[@color] - inc cx - cmp cx,dx - jbe @@boucle - ret -endp hline - -; affiche un pixel en %0 %1 couleur %2 -PROC line FAR - ARG @x1:word,@y1:word,@x2:word,@y2:word,@color:word - USES ax,bx,cx,dx,si,di - LOCAL @@deltax:word,@@deltay:word - mov ax,[@x2] - sub ax,[@x1] - call absolute - mov [@@deltax],ax - mov cx,ax - mov ax,[@y2] - sub ax,[@y1] - call absolute - mov dx,ax - mov [@@deltay],ax - mov ax,-1 - mov bx,-1 - mov si,[@x1] - mov di,[@y1] - cmp si,[@x2] - jg @@x1greater - mov ax,1 -@@x1greater: - cmp di,[@y2] - jg @@y1greater - mov bx,1 -@@y1greater: - cmp cx,dx - jl @@deltaxgreater - mov dx,[@@deltax] - sar dx,1 - xor cx,cx -@@boucle1: - add si,ax - add dx,[@@deltay] - cmp dx,[@@deltax] - jl @@above1 - sub dx,[@@deltax] - add di,bx -@@above1: - call [cs:showpixel],si,di,[@color] - inc cx - cmp cx,[@@deltax] - jl @@boucle1 - jmp @@endofline -@@deltaxgreater: - mov dx,[@@deltay] - sar dx,1 - xor cx,cx -@@boucle2: - add di,bx - add dx,[@@deltax] - cmp dx,[@@deltay] - jle @@above2 - sub dx,[@@deltay] - add si,ax -@@above2: - call [cs:showpixel],si,di,[@color] - inc cx - cmp cx,[@@deltay] - jl @@boucle2 -@@endofline: - ret -endp line - -;renvoie la valeur absolue de AX -PROC absolute NEAR - cmp ax,0 - jg @@noabs - neg ax -@@noabs: - ret -endp absolute - -ymax equ 200 - -; initialise un segment 2 -PROC polyfill FAR - ARG @pointer:word,@nbfaces:word,@color:word; - LOCAL @@startx:word:200,@@endx:word:200,@@pas:dword,@@miny:word,@@maxy:word - USES eax,ebx,ecx,edx,si,di,es - mov di,bp - sub di,2 - mov ax,16000 - mov cx,(200+200)*2 - push ss - pop es - std - rep stosw - mov si,[@pointer] - mov di,[@pointer] - add di,size vertex2d - mov [@@miny],ymax - mov [@@maxy],0 - mov cx,[@nbfaces] - dec cx -@@boucle: - push si di cx - mov ax,[(vertex2d di).py] - cmp ax,[(vertex2d si).py] - je @@noexchange - jge @@nothingtodo - xchg si,di -@@nothingtodo: - xor eax,eax - mov ax,[(vertex2d si).px] - cwde - sal eax,8 - mov ebx,eax - xor eax,eax - mov ax,[(vertex2d di).px] - sub ax,[(vertex2d si).px] - cwde - sal eax,8 - xor ecx,ecx - mov cx,[(vertex2d di).py] - sub cx,[(vertex2d si).py] - cdq - idiv ecx - mov [@@pas],eax - add ebx,eax - mov dx,[(vertex2d si).py] - inc dx - cmp dx,[@@miny] - jge @@notinf - mov [@@miny],dx -@@notinf: - mov ax,[(vertex2d di).py] - cmp ax,[@@maxy] - jle @@boucle2 - mov [@@maxy],ax -@@boucle2: - cmp dx,0 - jl @@notgood - cmp dx,ymax - jge @@notgood - mov si,dx - shl si,1 - neg si - cmp [word ptr bp+si-2],16000 - jne @@notgoodforinf - mov eax,ebx - sar eax,8 - mov [bp+si-2],ax -@@notgoodforinf: - mov eax,ebx - sar eax,8 - mov [bp+si-200*2-2],ax -@@notgood: - add ebx,[@@pas] - inc dx - cmp dx,[(vertex2d di).py] - jle @@boucle2 -@@noexchange: - pop cx di si - add si,size vertex2d - add di,size vertex2d - dec cx - js @@finished - jnz @@boucle - mov di,[@pointer] - mov cx,0FFFFh - jmp @@boucle -@@finished: - cmp [word ptr @@miny],0 - jae @@noadj - mov [@@miny],0 -@@noadj: - cmp [word ptr @@maxy],ymax - jb @@noadj2 - mov [@@maxy],ymax-1 -@@noadj2: - mov cx,[@@miny] -@@drawboucle: - mov si,cx - shl si,1 - neg si - mov ax,[bp+si-2] - mov bx,[bp+si-200*2-2] - cmp bx,16000 - jnz @@noinfatall - mov ax,bx -@@noinfatall: - call hline,ax,bx,cx,[@color] - inc cx - cmp cx,[@@maxy] - jna @@drawboucle - ret -endp polyfill - +include "..\include\mem.h" +include "..\include\graphic.h" + +org 0h + +header exe 1 + +exporting +declare hline +declare line +declare polyfill +ende + +importing +use VIDEO,showpixel +endi + +proc hline uses cx dx, x1:word,x2:word,y:word,color:word + mov cx,[x1] + mov dx,[x2] + cmp cx,dx + jbe .boucle + xchg cx,dx +.boucle: + invoke showpixel,cx,[y],[color] + inc cx + cmp cx,dx + jbe .boucle + ret +endp + +; affiche un pixel en %0 %1 couleur %2 +proc line uses ax bx cx dx si di, x1:word,y1:word,x2:word,y2:word,color:word + local deltax:WORD,deltay:WORD + mov ax,[x2] + sub ax,[x1] + call absolute + mov [deltax],ax + mov cx,ax + mov ax,[y2] + sub ax,[y1] + call absolute + mov dx,ax + mov [deltay],ax + mov ax,-1 + mov bx,-1 + mov si,[x1] + mov di,[y1] + cmp si,[x2] + jg .x1greater + mov ax,1 +.x1greater: + cmp di,[y2] + jg .y1greater + mov bx,1 +.y1greater: + cmp cx,dx + jl .deltaxgreater + mov dx,[deltax] + sar dx,1 + xor cx,cx +.boucle1: + add si,ax + add dx,[deltay] + cmp dx,[deltax] + jl .above1 + sub dx,[deltax] + add di,bx +.above1: + invoke showpixel,si,di,[color] + inc cx + cmp cx,[deltax] + jl .boucle1 + jmp .endofline +.deltaxgreater: + mov dx,[deltay] + sar dx,1 + xor cx,cx +.boucle2: + add di,bx + add dx,[deltax] + cmp dx,[deltay] + jle .above2 + sub dx,[deltay] + add si,ax +.above2: + invoke showpixel,si,di,[color] + inc cx + cmp cx,[deltay] + jl .boucle2 +.endofline: + ret +endp + +;renvoie la valeur absolue de AX +proc absolute + cmp ax,0 + jg .noabs + neg ax +.noabs: + ret +endp + +ymax equ 200 + +; initialise un segment 2 +proc polyfill uses eax ebx ecx edx si di es, pointer:word,nbfaces:word,color:word; + local startx[200]:WORD,endx[200]:WORD,pas:DWORD,miny:WORD,maxy:WORD + mov di,bp + sub di,2 + mov ax,16000 + mov cx,(200+200)*2 + push ss + pop es + std + rep stosw + mov si,[pointer] + mov di,[pointer] + virtual at 0 + .vertex2d vertex2d + end virtual + add di,.vertex2d.sizeof + mov [miny],ymax + mov [maxy],0 + mov cx,[nbfaces] + dec cx +.boucle: + push si di cx + virtual at si + .vertex2dsrc vertex2d + end virtual + virtual at di + .vertex2ddst vertex2d + end virtual + mov ax,[.vertex2ddst.py] + cmp ax,[.vertex2dsrc.py] + je .noexchange + jge .nothingtodo + xchg si,di +.nothingtodo: + xor eax,eax + mov ax,[.vertex2dsrc.px] + cwde + sal eax,8 + mov ebx,eax + xor eax,eax + mov ax,[.vertex2ddst.px] + sub ax,[.vertex2dsrc.px] + cwde + sal eax,8 + xor ecx,ecx + mov cx,[.vertex2ddst.py] + sub cx,[.vertex2dsrc.py] + cdq + idiv ecx + mov [pas],eax + add ebx,eax + mov dx,[.vertex2dsrc.py] + inc dx + cmp dx,[miny] + jge .notinf + mov [miny],dx +.notinf: + mov ax,[.vertex2ddst.py] + cmp ax,[maxy] + jle .boucle2 + mov [maxy],ax +.boucle2: + cmp dx,0 + jl .notgood + cmp dx,ymax + jge .notgood + mov si,dx + shl si,1 + neg si + cmp word [bp+si-2],16000 + jne .notgoodforinf + mov eax,ebx + sar eax,8 + mov [bp+si-2],ax +.notgoodforinf: + mov eax,ebx + sar eax,8 + mov [bp+si-200*2-2],ax +.notgood: + add ebx,[pas] + inc dx + cmp dx,[.vertex2ddst.py] + jle .boucle2 +.noexchange: + pop cx di si + add si,.vertex2d.sizeof + add di,.vertex2d.sizeof + dec cx + js .finished + jnz .boucle + mov di,[pointer] + mov cx,0FFFFh + jmp .boucle +.finished: + cmp word [miny],0 + jae .noadj + mov [miny],0 +.noadj: + cmp word [maxy],ymax + jb .noadj2 + mov [maxy],ymax-1 +.noadj2: + mov cx,[miny] +.drawboucle: + mov si,cx + shl si,1 + neg si + mov ax,[bp+si-2] + mov bx,[bp+si-200*2-2] + cmp bx,16000 + jnz .noinfatall + mov ax,bx +.noinfatall: + stdcall hline,ax,bx,cx,[color] + inc cx + cmp cx,[maxy] + jna .drawboucle + ret +endp + diff --git a/programs/exem-lib.asm b/lib/lib.asm similarity index 58% rename from programs/exem-lib.asm rename to lib/lib.asm index 0feaf4c..c6078fd 100644 --- a/programs/exem-lib.asm +++ b/lib/lib.asm @@ -1,17 +1,10 @@ -model tiny,stdcall -p586N -locals -jumps -codeseg -option procalign:byte - include "..\include\mem.h" include "..\include\divers.h" org 0h start: -header exe <"CE",1,0,0,offset exports,,,> +header exe 1 waitkey: mov ax,0 @@ -19,6 +12,5 @@ waitkey: retf exporting - declare waitkey ende diff --git a/lib/makefile b/lib/makefile index ce1facc..4587baf 100644 --- a/lib/makefile +++ b/lib/makefile @@ -1,20 +1,14 @@ -asm= lzasm /z/t -lnk= elink +ASM=fasm +CLEAN=rm -rf +OBJS= $(SRCS:.c=.o) +SRC= $(wildcard *.asm) +LIB= $(SRC:.asm=.lib) -all: detect.lib video.lib str0.lib bmp.lib graphic.lib 3d.lib math.lib +all: $(LIB) + sync -.asm.obj: - $(asm) $< - -.obj.lib: - $(lnk) $< $*.lib +%.lib: %.asm + $(ASM) $^ $@ clean: - del *.obj - del *.ce - del *.bak - del *.lib - del *.com - del *.bin - del *.sys - del *.err \ No newline at end of file + $(CLEAN) *.lib diff --git a/lib/math.asm b/lib/math.asm index 77cb89c..e69de29 100644 --- a/lib/math.asm +++ b/lib/math.asm @@ -1,38 +0,0 @@ -model tiny,stdcall -p586 -locals -jumps -codeseg -option procalign:byte - -include "..\include\mem.h" - -org 0h - -header exe <"CE",1,0,0,offset exports,,,> - -exporting -declare random -declare randomize -ende - -randseed dw 1234h - -PROC random FAR - USES dx - mov ax,[cs:randseed] - mov dx,8405h - mul dx - inc ax - mov [cs:randseed],ax - mov ax,dx - ret -endp random - -PROC randomize FAR - USES ax,cx,dx - mov ah,0 - int 1ah - mov [cs:randseed],dx - ret -endp randomize diff --git a/lib/str0.asm b/lib/str0.asm index 2e6aefa..97c9ac2 100644 --- a/lib/str0.asm +++ b/lib/str0.asm @@ -1,16 +1,9 @@ -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,,,> +header exe 1 exporting @@ -68,180 +61,169 @@ ende ; 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 +proc checksyntax uses ax bx cx dx si di ds es, src:word,dest:word,delim:word + local temp[256]:WORD push ss pop es - lea si,[@@temp] - mov di,[@dest] - call copy,[@src],si + lea si,[temp] + mov di,[dest] + stdcall copy,[src],si call xch - call compressdelimiter,si,[@delim] - call getnbitems,si,[@delim] + stdcall compressdelimiter,si,[delim] + stdcall getnbitems,si,[delim] mov bx,ax call xch - call getnbitems,di,[@delim] + stdcall getnbitems,di,[delim] cmp bx,ax - jne @@notequalatall + jne .notequalatall xor cx,cx -@@itemer: +.itemer: call xch - call whatisitem,si,cx,[@delim] + stdcall whatisitem,si,cx,[delim] mov dx,ax - call xch - call whatisitem,di,cx,[@delim] + stdcall xch + stdcall whatisitem,di,cx,[delim] cmp ax,dx - jne @@prob + jne .prob cmp al,6 - jb @@equal - call cmpitems - je @@equal -@@prob: + jb .equal + stdcall cmpitems + je .equal +.prob: cmp dl,4 - ja @@nonumber + ja .nonumber cmp dl,8 - je @@equal + je .equal ;cmp al,4 - ;jne @@notequalatall + ;jne .notequalatall cmp dh,ah - ja @@notequalatall - jmp @@equal -@@nonumber: + ja .notequalatall + jmp .equal +.nonumber: cmp al,7 - jne @@nostr + jne .nostr cmp ah,0 - jne @@notequalatall - jmp @@equal -@@nostr: + jne .notequalatall + jmp .equal +.nostr: cmp al,6 - jne @@noname + jne .noname cmp dl,6 - jne @@noname + jne .noname cmp ah,0 - jne @@notequalatall - jmp @@equal -@@noname: + jne .notequalatall + jmp .equal +.noname: cmp al,8 - je @@equal - jmp @@notequalatall -@@equal: + je .equal + jmp .notequalatall +.equal: inc cx cmp cx,bx - jne @@itemer + jne .itemer cld -@@ackno: - ret -@@notequalatall: +.ackno: + retf +.notequalatall: stc - jmp @@ackno -endp checksyntax - + jmp .ackno xch: push es push ds pop es pop ds ret +endp ;Compare les ‚l‚ments 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 +proc cmpitems uses ax cx si di es, src:word,dest:word,item:word,delim:word push ds pop es - call getpointeritem,[@src],[@item],[@delim] + stdcall getpointeritem,[src],[item],[delim] mov si,ax - call getitemsize,[@src],[@item],[@delim] - mov di,[@dest] + stdcall getitemsize,[src],[item],[delim] + mov di,[dest] mov cx,ax cld rep cmpsb clc - ret -endp cmpitems + retf +endp ;Renvoie l'‚l‚ment 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] +proc gettypeditem uses bx cx si di, src:word,item:word,delim:word + mov si,[src] + mov cx,[item] + stdcall getpointeritem,si,cx,[delim] mov di,ax inc cx - call getpointeritem,si,cx,[@delim] + stdcall getpointeritem,si,cx,[delim] mov si,ax dec si mov cl,0 xchg cl,[ds:si] - call gettyped,di + stdcall gettyped,di xchg cl,[ds:si] clc - ret -endp gettypeditem + retf +endp ;Renvoie eax si nb et dans ds:eax si str ou name -PROC gettyped FAR - ARG @src:word - USES si - mov si,[@src] +proc gettyped uses si, src:word + mov si,[src] xor eax,eax - call whatis,si + stdcall whatis,si cmp al,1 - je @@bin + je .bin cmp al,2 - je @@oct + je .oct cmp al,3 - je @@dec + je .dec cmp al,4 - je @@hex + je .hex cmp al,5 - je @@pointer + 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: + jmp .endofgettypeditem +.bin: + stdcall strtoint,si,2 + jmp .endofgettypeditem +.oct: + stdcall strtoint,si,8 + jmp .endofgettypeditem +.dec: + stdcall strtoint,si,10 + jmp .endofgettypeditem +.hex: + stdcall strtoint,si,16 + jmp .endofgettypeditem +.pointer: + stdcall strtoadress,si +.endofgettypeditem: clc - ret -endp gettyped + retf +endp ;Renvoie dans ax le type de la str0 point‚e par ds:%0 ‚l‚ment %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] +proc whatisitem uses bx cx si di, src:word,item:word,delim:word + mov si,[src] + mov cx,[item] + stdcall getpointeritem,si,cx,[delim] mov di,ax inc cx - call getpointeritem,si,cx,[@delim] + stdcall getpointeritem,si,cx,[delim] mov si,ax dec si mov cl,0 xchg cl,[ds:si] - call whatis,di + stdcall whatis,di xchg cl,[ds:si] clc - ret -endp whatisitem + retf +endp ;Renvoie dans ax le type de la str0 point‚e par ds:%0 ;High Low @@ -252,636 +234,587 @@ endp whatisitem ;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] +proc whatis uses bx cx edx si, src:word + mov si,[src] xor cx,cx mov cl,2 - call strisbase,si,cx - jnc @@finbase + stdcall strisbase,si,cx + jnc .finbase mov cl,8 - call strisbase,si,cx - jnc @@finbase + stdcall strisbase,si,cx + jnc .finbase mov cl,10 - call strisbase,si,cx - jnc @@finbase + stdcall strisbase,si,cx + jnc .finbase mov cl,16 - call strisbase,si,cx - jc @@testadress -@@finbase: + stdcall strisbase,si,cx + jc .testadress +.finbase: mov bx,cx xor ch,ch - mov al,[cs:bx+offset basenn-2] + mov al,[cs:bx+ basenn-2] push eax - call strtoint,si,cx + stdcall strtoint,si,cx mov edx,eax pop eax cmp edx,0000FFFFh - ja @@bits32 + ja .bits32 cmp dx,00FFh - ja @@bits16 + ja .bits16 mov ah,1 - jmp @@endofwhat -@@bits16: + jmp .endofwhat +.bits16: mov ah,2 - jmp @@endofwhat -@@bits32: + jmp .endofwhat +.bits32: mov ah,4 - jmp @@endofwhat -@@testadress: - call strisadress,si - jc @@testname + jmp .endofwhat +.testadress: + stdcall strisadress,si + jc .testname mov ax,0005h - jmp @@endofwhat -@@testname: - call strisname - jc @@testnumber + jmp .endofwhat +.testname: + stdcall strisname + jc .testnumber xor ah,ah - cmp [byte ptr si],'&' - je @@okname - call getlength,si + cmp byte [si],'&' + je .okname + stdcall getlength,si mov ah,al -@@okname: +.okname: mov al,06h - jmp @@endofwhat -@@testnumber: - cmp [byte ptr si],'#' - jne @@testvarstr + jmp .endofwhat +.testnumber: + cmp byte [si],'#' + jne .testvarstr xor ah,ah mov al,08h - jmp @@endofwhat -@@testvarstr: + jmp .endofwhat +.testvarstr: xor ah,ah - cmp [byte ptr si],'?' - je @@okvarstr - call getlength,si + cmp byte [si],'?' + je .okvarstr + stdcall getlength,si mov ah,al -@@okvarstr: +.okvarstr: mov al,07h -@@endofwhat: +.endofwhat: clc - ret -endp whatis + retf +endp ;Renvoie non carry si la str ds:si point‚e peut ˆtre une adresse -PROC strtoadress FAR +proc strtoadress ;push stc ;pop - ret -endp strtoadress + retf +endp ;Renvoie en es:di le pointeur str0 ds:si -PROC strisadress FAR +proc strisadress ;push stc ;pop - ret -endp strisadress + retf +endp ;Renvoie non carry si la str ds:%0 point‚e peut ˆtre un nom de fichier -PROC strisname FAR - ARG @src:word - USES ax,si,di - mov si,[@src] -@@isname: +proc strisname uses ax si di, src:word + mov si,[src] +.isname: mov al,[si] inc si cmp al,0 - je @@itsok - mov di,offset non -@@verify: + je .itsok + mov di, non +.verify: mov ah,[cs:di] inc di cmp ah,0FFh - je @@isname + je .isname cmp ah,al - jne @@verify + jne .verify stc - jmp @@itsdead -@@itsok: + jmp .itsdead +.itsok: clc -@@itsdead: - ret -endp strisname +.itsdead: + retf +endp 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 +;Renvoie non carry si le texte point‚ par %0 est de la base %1 +proc strisbase uses ax cx si di es, src:word,base:word push cs pop es - mov si,[@src] -@@gotos: - cmp [byte ptr si+1], 0 - je @@oklo + 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+ basen] + je .verifbase + xor ch,ch + inc cl + lea di,[base] + cld + repne scasb + cmp cx,0 + je .nobase inc si - jmp @@gotos -@@oklo: + jmp .isstrbase +.okbase: + clc +.endbase: + retf +.verifbase: + cmp byte [si+1],0 + je .okbase +.nobase: + stc + jmp .endbase +endp + + +;Converti un str %0 de base %1 en int dans eax +proc strtoint uses ebx ecx edx si edi es, src:word,base:word + push cs + pop es + mov si,[src] +.gotos: + cmp byte [si+1], 0 + je .oklo + inc si + jmp .gotos +.oklo: mov edi,1 xor ebx,ebx -@@baseto: - cmp [@src],si - ja @@endbaseto +.baseto: + cmp [src],si + ja .endbaseto mov al,[si] xor ecx,ecx - mov cl,[byte ptr @base] + mov cl,byte [base] inc cl push di - mov di,offset base + lea di, [base] cld repne scasb pop di - jne @@noop - sub cl,[byte ptr @base] + jne .noop + sub cl,byte [base] neg cl mov eax,edi mul ecx add ebx,eax mov eax,edi - mov cl,[byte ptr @base] + mov cl,byte [base] mul ecx mov edi,eax -@@noop: +.noop: dec si - jmp @@baseto -@@endbaseto: + jmp .baseto +.endbaseto: mov eax,ebx clc - ret -endp strtoint + retf +endp ;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 +proc left uses ax cx si di es, src:word,dest:word,nb:word push ds pop es - mov si,[@src] - mov di,[@dest] - mov cx,[@nb] + mov si,[src] + mov di,[dest] + mov cx,[nb] cld rep movsb mov al,0 stosb clc - ret -endp left + retf +endp ;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 +proc right uses ax cx si di es, src:word,dest:word,nb:word push ds pop es - mov si,[@src] - mov di,[@dest] - call getlength,si + mov si,[src] + mov di,[dest] + stdcall getlength,si add si,ax - sub si,[@nb] - mov cx,[@nb] + sub si,[nb] + mov cx,[nb] cld rep movsb mov al,0 stosb clc - ret -endp right + retf +endp ;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 +proc middle uses ax cx si di es, src:word,dest:word,item:word,nb:word push ds pop es - mov si,[@src] - mov di,[@dest] - mov cx,[@nb] - add si,[@item] + mov si,[src] + mov di,[dest] + mov cx,[nb] + add si,[item] cld rep movsb mov al,0 stosb clc - ret -endp middle + retf +endp ;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 +proc fill uses ax cx si di es, src:word,item:word,char:word,nb:word push ds pop es - mov di,[@src] - add di,[@item] - mov ax,[@char] - mov cx,[@nb] + mov di,[src] + add di,[item] + mov ax,[char] + mov cx,[nb] cld rep stosb clc - ret -endp fill + retf +endp ;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 +proc replaceallchar uses ax cx dx di es, src:word,char1:word,char2:word + mov di,[src] + stdcall getlength,di mov cx,ax - mov ax,[@char1] - mov dx,[@char2] + mov ax,[char1] + mov dx,[char2] push ds pop es -@@findandchange: +.findandchange: repne scasb cmp cx,0 - je @@endofchange + je .endofchange mov [es:di-1],dl - jmp @@findandchange -@@endofchange: + jmp .findandchange +.endofchange: clc - ret -endp replaceallchar + retf +endp ;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 +proc searchchar uses cx di es, src:word,char:word + mov di,[src] + stdcall getlength,di mov cx,ax push ds pop es - mov ax,[@char] + mov ax,[char] repne scasb mov ax,di dec ax clc - ret -endp searchchar + retf +endp ;Inverse la chaine point‚e en ds:%0 -PROC invert FAR - ARG @src:word - USES ax,cx,si,di - mov si,[@src] - call getlength,si +proc invert uses ax cx si di, src:word + mov si,[src] + stdcall getlength,si mov di,si add di,ax dec di -@@revert: +.revert: mov al,[si] xchg al,[di] mov [si],al inc si dec di cmp si,di - ja @@finishinvert + ja .finishinvert dec di cmp si,di - ja @@finishinvert + ja .finishinvert inc di - jmp @@revert -@@finishinvert: + jmp .revert +.finishinvert: clc - ret -endp invert + retf +endp ;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 +proc cmpstr uses cx dx si di, src:word,dest:word push ds pop es - mov si,[@src] - mov di,[@dest] - call getlength,di + mov si,[src] + mov di,[dest] + stdcall getlength,di mov cx,ax - call getlength,si + stdcall getlength,si cmp cx,ax - jne @@notequal + jne .notequal repe cmpsb -@@notequal: - ret -endp cmpstr +.notequal: + retf +endp ;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 +proc evalue uses cx si di es, src:word,dest:word push ds pop es - mov si,[@src] - mov di,[@dest] - call getlength ,di + mov si,[src] + mov di,[dest] + stdcall getlength ,di mov cx,ax repe cmpsb pushf - jne @@noident + jne .noident sub ax,cx popf clc - ret -@@noident: + retf +.noident: sub ax,cx dec ax popf clc - ret -endp evalue + retf +endp ;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 +proc insert uses ax cx si di es, src:word,dest:word,item:word push es pop ds - mov si,[@dest] - call getlength,si + mov si,[dest] + stdcall getlength,si mov cx,ax add si,ax mov di,si - call getlength,[@src] + stdcall getlength,[src] add di,ax - sub cx,[@item] + sub cx,[item] inc cx std rep movsb - mov si,[@src] - mov di,[@dest] - add di,[@item] + mov si,[src] + mov di,[dest] + add di,[item] mov cx,ax cld rep movsb clc - ret -endp insert + retf +endp ;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 +proc delete uses ax cx dx si di es, src:word,item:word,size:word push ds pop es - mov si,[@src] - call getlength,si + mov si,[src] + stdcall getlength,si mov cx,ax - sub cx,[@size] - sub cx,[@item] + sub cx,[size] + sub cx,[item] inc cx - add si,[@item] + add si,[item] mov di,si - add si,[@size] + add si,[size] cld rep movsb clc - ret -endp delete + retf +endp ;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 +proc copy uses ax cx si di, src:word,dest:word + mov si,[src] + mov di,[dest] + stdcall getlength,si mov cx,ax cld rep movsb mov al,0 stosb clc - ret -endp copy + retf +endp ;ConcatŠne le chaine ds:si avec ds:di -PROC concat FAR - ARG @src:word,@dest:word - USES ax,cx,si,di,es +proc concat uses ax cx si di es, src:word,dest:word push ds pop es - mov si,[@src] - call getlength,si + mov si,[src] + stdcall getlength,si mov cx,ax - mov di,[@dest] - call getlength,di + mov di,[dest] + stdcall getlength,di add di,ax cld rep movsb mov al,0 stosb clc - ret -endp concat + retf +endp ;D‚truit les d‚limiteur qui sont cons‚cutifs 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 +proc compressdelimiter uses cx dx si di es, src:word,delim:word + mov di,[src] + stdcall getlength,di mov cx,ax push ds pop es - mov ax,[@delim] + mov ax,[delim] xor dx,dx -@@compressitems: +.compressitems: repne scasb inc dx -@@againcomp: +.againcomp: cmp [di],al - jne @@nosup - call delete,di,0,1 - jmp @@againcomp -@@nosup: + jne .nosup + stdcall delete,di,0,1 + jmp .againcomp +.nosup: cmp cx,0 - jne @@compressitems + jne .compressitems mov ax,dx clc - ret -endp compressdelimiter + retf +endp ;Met le nombre d'‚l‚ments 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 +proc setnbitems uses ax cx di es, src:word,size:word,delim:word + mov di,[src] + cmp [size],0 + je .onlyzero + stdcall getnbitems,di,[delim] + cmp [size],ax + je .noadjust + jb .subsome push ds pop es - sub ax,[@size] + sub ax,[size] neg ax mov cx,ax - call getlength,di + stdcall getlength,di add di,ax - mov ax,[@delim] + mov ax,[delim] mov ah,'a' rep stosw xor al,al stosb - jmp @@noadjust -@@subsome: - call getpointeritem,[@src],[@size],[@delim] + jmp .noadjust +.subsome: + stdcall getpointeritem,[src],[size],[delim] dec ax mov di,ax -@@onlyzero: - mov [byte ptr di],0 -@@noadjust: +.onlyzero: + mov byte [di],0 +.noadjust: clc - ret -endp setnbitems + retf +endp ;Renvoie la taille ax de l'‚l‚ment %0 -PROC getitemsize FAR - ARG @src:word,@item:word,@delim:word - USES cx,dx - mov cx,[@item] - call getpointeritem,[@src],cx,[@delim] +proc getitemsize uses cx dx, src:word,item:word,delim:word + mov cx,[item] + stdcall getpointeritem,[src],cx,[delim] mov dx,ax inc cx - call getpointeritem,[@src],cx,[@delim] + stdcall getpointeritem,[src],cx,[delim] sub ax,dx dec ax clc - ret -endp getitemsize + retf +endp ;Renvoie en ds:%1 l'‚l‚ment %2 de ds:%0 -PROC getitem FAR - ARG @src:word,@dest:word,@item:word,@delim:word - USES ax,cx,si,di,es +proc getitem uses ax cx si di es, src:word,dest:word,item:word,delim:word push ds pop es - call getpointeritem,[@src],[@item],[@delim] + stdcall getpointeritem,[src],[item],[delim] mov si,ax - call getitemsize,[@src],[@item],[@delim] - mov di,[@dest] + stdcall getitemsize,[src],[item],[delim] + mov di,[dest] mov cx,ax cld rep movsb mov al,0 stosb clc - ret -endp getitem + retf +endp ;renvoi un pointeur ax sur l'‚l‚ment %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 +proc getpointeritem uses cx dx di es, src:word,item:word,delim:word + mov di,[src] + cmp [item],0 + je .finishpointer push ds pop es - call getlength,di + stdcall getlength,di mov cx,ax push ds pop es - mov ax,[@delim] + mov ax,[delim] xor dx,dx -@@countnbitems: - cmp [@item],dx - je @@finishpointer +.countnbitems: + cmp [item],dx + je .finishpointer cld repne scasb inc dx cmp cx,0 - jne @@countnbitems + jne .countnbitems inc di -@@finishpointer: +.finishpointer: mov ax,di clc - ret -endp getpointeritem + retf +endp ;Renvoie le nombre d'‚l‚ments ax de ds:%0 -PROC getnbitems FAR - ARG @src:word,@delim:word - USES cx,dx,di,es - mov di,[@src] - call getlength,di +proc getnbitems uses cx dx di es, src:word,delim:word + mov di,[src] + stdcall getlength,di mov cx,ax push ds pop es - mov ax,[@delim] + mov ax,[delim] xor dx,dx cld -@@countitems: +.countitems: repne scasb inc dx cmp cx,0 - jne @@countitems + jne .countitems mov ax,dx clc - ret -endp getnbitems + retf +endp ;renvoie la taille en octets AX de la chaine point‚e en ds:%0 -PROC getlength FAR - ARG @src:word - USES cx,di,es +proc getlength uses cx di es, src:word push ds pop es - mov di,[@src] + mov di,[src] mov al,0 mov cx,0FFFFh cld @@ -891,103 +824,93 @@ PROC getlength FAR dec cx mov ax,cx clc - ret -endp getlength + retf +endp ;Met la taille en octets de la chaine point‚e 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 +proc setlength uses si, src:word,size:word + mov si,[src] + add si,[size] + mov byte [si],0 clc - ret -endp setlength + retf +endp ;met en majuscule la chaine ds:%0 -PROC uppercase FAR - ARG @src:word - USES si,ax - mov si,[@src] -@@uppercase: +proc uppercase uses ax si, src:word + mov si,[src] +.uppercase: mov al,[ds:si] inc si cmp al,0 - je @@enduppercase + je .enduppercase cmp al,'a' - jb @@uppercase + jb .uppercase cmp al,'z' - ja @@uppercase - sub [byte ptr si-1],'a'-'A' - jmp @@uppercase -@@enduppercase: + ja .uppercase + sub byte [si-1],'a'-'A' + jmp .uppercase +.enduppercase: clc - ret -endp uppercase + retf +endp ;met en majuscule la premiŠre lettre chaine ds:%0 -PROC onecase FAR - ARG @src:word - USES ax - mov si,[@src] +proc onecase uses ax si, src:word + mov si,[src] mov al,[ds:si] cmp al,'a' - jb @@oneenduppercase + jb .oneenduppercase cmp al,'z' - ja @@oneenduppercase - sub [byte ptr si],'a'-'A' -@@oneenduppercase: + ja .oneenduppercase + sub byte [si],'a'-'A' +.oneenduppercase: clc - ret -endp onecase + retf +endp ;met en minuscule la chaine ds:%0 -PROC lowercase FAR - ARG @src:word - USES si,ax - mov si,[@src] -@@lowercase: +proc lowercase uses ax si, src:word + mov si,[src] +.lowercase: mov al,[ds:si] inc si cmp al,0 - je @@endlowercase + je .endlowercase cmp al,'A' - jb @@lowercase + jb .lowercase cmp al,'Z' - ja @@lowercase - add [byte ptr si-1],'a'-'A' - jmp @@lowercase -@@endlowercase: + ja .lowercase + add byte [si-1],'a'-'A' + jmp .lowercase +.endlowercase: clc - ret -endp lowercase + retf +endp ;Inverse la casse la chaine ds:%0 -PROC invertcase FAR - ARG @src:word - USES si,ax - mov si,[@src] -@@invertcase: +proc invertcase uses ax si, src:word + mov si,[src] +.invertcase: mov al,[ds:si] inc si cmp al,0 - je @@endinvertcase + je .endinvertcase cmp al,'A' - jb @@invertcase + jb .invertcase cmp al,'Z' - jbe @@goinvertcase + jbe .goinvertcase cmp al,'a' - jb @@invertcase + 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: + ja .invertcase + sub byte [si-1],'a'-'A' + jmp .invertcase +.goinvertcase: + add byte [si-1],'a'-'A' + jmp .invertcase +.endinvertcase: clc - ret -endp invertcase + retf +endp diff --git a/lib/video.asm b/lib/video.asm index 5881f41..baeca5e 100644 --- a/lib/video.asm +++ b/lib/video.asm @@ -110,11 +110,11 @@ proc print pointer:word add di,2 jmp .strinaize0 .showmultchar: - mov cx,[.pointer+di+2+2] + mov cx,[pointer+di+2+2] cmp cx,0 je .nextfunc .showcharsx: - invoke showchars,word [.pointer+di+2],0FFFFh + invoke showchars,word [pointer+di+2],0FFFFh dec cx jnz .showcharsx .nextfunc: @@ -123,19 +123,19 @@ proc print pointer:word jmp .strinaize0 .showint: - stdcall showint,dword [.pointer+di+2] + stdcall showint,dword [pointer+di+2] add si,2 add di,4 jmp .strinaize0 .showfixint: - stdcall showintl,word [.pointer+di+6],[dword ptr .pointer+di+2] + stdcall showintl,word [pointer+di+6],dword [pointer+di+2] add di,6 add si,2 jmp .strinaize0 .showintr: - stdcall showintr,word [.pointer+di+6],dword [.pointer+di+2] + stdcall showintr,word [pointer+di+6],dword [pointer+di+2] add di,6 add si,2 jmp .strinaize0 @@ -156,32 +156,32 @@ proc print pointer:word jmp .strinaize0 .showstring: - cmp [byte ptr si+2],'P' + cmp byte [si+2],'P' je .showstring.pointer - stdcall showstring,[word ptr .pointer+di+2] + stdcall showstring,word [pointer+di+2] add si,2 add di,2 jmp .strinaize0 .showstring.pointer: push ds - mov ds,[offset .pointer+di+2+2] - stdcall showstring,[word ptr .pointer+di+2] + mov ds,[pointer+di+2+2] + stdcall showstring,word [pointer+di+2] add si,3 add di,4 pop ds jmp .strinaize0 .showstring0: - cmp [byte ptr si+2],'P' + cmp byte [si+2],'P' je .showstring0.pointer - stdcall showstring0,[word ptr offset .pointer+di+2] + stdcall showstring0,word [pointer+di+2] add si,2 add di,2 jmp .strinaize0 .showstring0.pointer: push ds - mov ds,[offset .pointer+di+2+2] - stdcall showstring0,[word ptr offset .pointer+di+2] + mov ds,[pointer+di+2+2] + stdcall showstring0,word [pointer+di+2] add si,3 add di,4 pop ds @@ -193,44 +193,44 @@ proc print pointer:word jmp .strinaize0 .showsize: - stdcall showsize,[dword ptr offset .pointer+di+2] + stdcall showsize,dword [pointer+di+2] add si,2 add di,4 jmp .strinaize0 .showattr: - stdcall showattr,[word ptr offset .pointer+di+2] + stdcall showattr,word [pointer+di+2] add si,2 add di,2 jmp .strinaize0 .showname: - stdcall showname,[word ptr offset .pointer+di+2] + stdcall showname,word [pointer+di+2] add si,2 add di,2 jmp .strinaize0 .showtime: - stdcall showtime,[word ptr offset .pointer+di+2] + stdcall showtime,word [pointer+di+2] add si,2 add di,2 jmp .strinaize0 .showdate: - stdcall showdate,[word ptr offset .pointer+di+2] + stdcall showdate,word [pointer+di+2] add si,2 add di,2 jmp .strinaize0 .Chosesize: pop cx - push [dword ptr offset .pointer+di+2] + push dword [pointer+di+2] add di,4 - cmp [byte ptr si+2],'B' + cmp byte [si+2],'B' je .byte - cmp [byte ptr si+2],'W' + cmp byte [si+2],'W' je .word - cmp [byte ptr si+2],'D' + cmp byte [si+2],'D' je .dword dec si @@ -238,27 +238,27 @@ proc print pointer:word push 16 add si,3 push cx - retfn + ret .byte: push 8 add si,3 push cx - retfn + ret .dword: push 32 add si,3 push cx - retfn + ret .special2: - cmp [byte ptr si+1],'\' + cmp byte [si+1],'\' jne .notshowit2 inc si jmp .showit .notshowit2: - mov cl,[byte ptr si+1] + mov cl,byte [si+1] cmp cl,'l' je .showline cmp cl,'g' @@ -465,7 +465,7 @@ proc showname uses cx si, thename:word mov si,[thename] xor cx,cx .showthename: - invoke showchars,[word ptr ds:si],0FFFFh + invoke showchars,word [ds:si],0FFFFh inc si inc cx cmp cx,8 @@ -547,22 +547,22 @@ proc showsize uses edx ds, thesize:dword cmp edx,1024*9 ja .kilo stdcall showintr,4,edx - stdcall showstring0,offset unit + stdcall showstring0,unit jmp .finsize .kilo: shr edx,10 stdcall showintr,4,edx - stdcall showstring0,offset unitkilo + stdcall showstring0,unitkilo jmp .finsize .mega: shr edx,20 stdcall showintr,4,edx - stdcall showstring0,offset unitmega + stdcall showstring0,unitmega jmp .finsize .giga: shr edx,30 stdcall showintr,4,edx - stdcall showstring0,offset unitgiga + stdcall showstring0,unitgiga .finsize: retf @@ -590,11 +590,11 @@ endp ;<- ;============================ proc showint uses eax bx cx edx esi, integer:dword -local showbuffer db 50 dup (0FFh) +local showbuffer[50]:BYTE xor cx,cx mov eax,[integer] mov esi,10 - mov bx,offset showbuffer+27 + lea bx,[showbuffer+27] .decint: xor edx,edx div esi @@ -619,12 +619,13 @@ endp ;-> %0 un entier % taille en caracteres ;<- ;=============================== -proc showintl eax bx cx edx esi di, sizeofint:word,integer:dword +proc showintl uses eax bx cx edx esi di, sizeofint:word,integer:dword +local showbuffer[50]:BYTE mov di,[sizeofint] xor cx,cx mov eax,[integer] mov esi,10 - mov bx,offset showbuffer+27 + lea bx,[showbuffer+27] .decint: xor edx,edx div esi @@ -640,7 +641,7 @@ proc showintl eax bx cx edx esi di, sizeofint:word,integer:dword xchg cx,di sub cx,di .rego: - mov [byte ptr cs:bx],'0' + mov byte [cs:bx],'0' dec bx dec cx jnz .rego @@ -663,11 +664,12 @@ endp ;<- ;=============================== proc showintr uses eax bx cx edx esi di, sizeofint:word,integer:dword +local showbuffer[50]:BYTE mov di,[sizeofint] xor cx,cx mov eax,[integer] mov esi,10 - mov bx,offset showbuffer+27 + lea bx,[showbuffer+27] .decint: xor edx,edx div esi @@ -683,7 +685,7 @@ proc showintr uses eax bx cx edx esi di, sizeofint:word,integer:dword xchg cx,di sub cx,di .rego: - mov [byte ptr cs:bx],' ' + mov byte [cs:bx],' ' dec bx dec cx jnz .rego @@ -705,7 +707,7 @@ endp ;-> %0 un entier, %1 la taille ;<- ;=============================== -proc showsigned ebx cx edx, sizeofint:word,integer:dword +proc showsigned uses ebx cx edx, sizeofint:word,integer:dword mov ebx,[integer] mov cx,[sizeofint] xor edx,edx @@ -741,7 +743,7 @@ endp ;-> %0 un entier, %1 la taille ;<- ;============================ -proc showhex ax bx cx edx, sizeofint:word,integer:dword +proc showhex uses ax bx cx edx, sizeofint:word,integer:dword mov edx,[integer] mov cx,[sizeofint] mov ax,cx @@ -753,7 +755,7 @@ proc showhex ax bx cx edx, sizeofint:word,integer:dword rol edx,4 mov bx,dx and bx,0fh - mov cl,[cs:bx+offset Tab] + mov cl,[cs:bx+Tab] invoke showchars,cx,0FFFFh dec al jnz .Hexaize @@ -767,7 +769,7 @@ endp ;-> %0 un entier, %1 la taille ;<- ;============================ -proc showbin ax cx edx, sizeofint:word,integer:dword +proc showbin uses ax cx edx, sizeofint:word,integer:dword mov edx,[integer] mov cx,[sizeofint] sub cx,32 @@ -789,7 +791,7 @@ endp ;-> %0 un entier, %1 la taille ;<- ;============================ -proc showbcd ax cx edx, sizeofint:word,integer:dword +proc showbcd uses ax cx edx, sizeofint:word,integer:dword mov edx,[integer] mov ax,[sizeofint] mov cx,ax @@ -813,12 +815,12 @@ endp ;-> ds:%1 pointeur chaine type pascal ;<- ;=============================== -proc showstring bx si, pointer:word +proc showstring uses bx si, pointer:word mov si,[pointer] mov bl,[si] .strinaize: inc si - invoke showchars,[word ptr si],0FFFFh + invoke showchars,word [si],0FFFFh dec bl jnz .strinaize retf diff --git a/makefile b/makefile index d733b1b..058651b 100644 --- a/makefile +++ b/makefile @@ -1,11 +1,12 @@ -all: boot/boot12.bin lib/3d.lib noyau/systeme.sys commande.ce +all: boot/boot12.bin lib/3d.lib noyau/systeme.sys programs/commande.ce sync install: - (sudo apt-get install yasm qemu fusefat cgdb) + (sudo apt-get install fasm qemu fusefat cgdb) clean: make -C final clean + make -C boot clean make -C lib clean make -C noyau clean make -C programs clean @@ -45,3 +46,7 @@ boot/boot12.bin: lib/3d.lib: make -C lib + +programs/commande.ce: + make -C programs + diff --git a/noyau/8259a.asm b/noyau/8259a.asm index 7077b93..943abae 100644 --- a/noyau/8259a.asm +++ b/noyau/8259a.asm @@ -29,7 +29,7 @@ IRR = 0Ah ; Pas d'operation, pas de Poll, lire IRR ;Autorise une interruption electronique ;Entree : %1 - Numero de l'interruption (0-15) à autoriser 0-7 = MASTERPIC , 8-15 = SLAVEPIC -proc enableirq, irq +proc enableirq uses ax cx dx, irq:word mov ax,[irq] mov dx,MASTERPIC+IRQMASK cmp al,7 @@ -50,7 +50,7 @@ endp ;Desactive une interruption ‚lectronique ;Entr‚e : %0 - Num‚ro de l'interruption (0-15) … desactiver 0-7 = MASTERPIC , 8-15 = SLAVEPIC -proc disableirq, irq +proc disableirq uses ax cx dx, irq:word mov ax,[irq] mov dx,MASTERPIC+IRQMASK cmp al,7 @@ -71,7 +71,7 @@ endp ;Signale "End Of Interrupt" de l'interruption %0 -proc seteoi, irq +proc seteoi uses ax dx, irq:word mov ax,[irq] cmp al,7 jbe .master @@ -85,7 +85,7 @@ endp ;Lit les masques d'un contr“leur IRQ dans ax, 0 master ou slave 1 ds %1 -proc readimr, controleurx +proc readimr uses bx dx, controleur:word mov bx,[controleur] mov dx,MASTERPIC+ IRQMASK cmp bl,0 @@ -99,7 +99,7 @@ proc readimr, controleurx endp ;Lit le registre d'‚tat d'un contr“leur IRQ dans ax, 0 master ou slave 1 ds %1 -proc readisr, controleur +proc readisr uses bx dx, controleur:word mov bx,[controleur] mov dx,MASTERPIC cmp bh,0 @@ -115,7 +115,7 @@ endp ;Lit le registre d'‚tat d'un contr“leur IRQ dans al, 0 master ou slave 1 ds bh -proc readirr, controleur +proc readirr uses bx dx, controleur:word mov bx,[controleur] mov dx,MASTERPIC cmp bh,0 @@ -130,7 +130,7 @@ proc readirr, controleur endp ;carry si enable et pas carry si pas enable -proc isenableirq, irq +proc isenableirq uses ax cx dx, irq:word mov ax,[irq] mov dx,MASTERPIC+IRQMASK cmp al,7 @@ -147,7 +147,7 @@ endp ;carry si enable et pas carry si pas enable -proc isinserviceirq, irq +proc isinserviceirq uses ax cx dx, irq:word mov ax,[irq] mov dx,MASTERPIC cmp al,7 @@ -166,7 +166,7 @@ endp ;carry si enable et pas carry si pas enable -proc isrequestirq, irq +proc isrequestirq uses ax cx dx, irq:word mov ax,[irq] mov dx,MASTERPIC cmp al,7 @@ -184,62 +184,74 @@ proc isrequestirq, irq endp -proc installirqhandler +proc installirqhandler uses eax bx cx edx si di ds es push fs - stdcall mbcreate,interruptionbloc,256*ints.sizeof + virtual at 0 + .intsori ints + end virtual + stdcall mbcreate,interruptionbloc,256*.intsori.sizeof mov es,ax mov ax,0x0000 mov ds,ax xor si,si .searchdummypointer: - mov fs,[si+vector.data.seg] - mov bx,[si+vector.data.off] + virtual at si + .vector vector + end virtual + virtual at 0 + .vectorori vector + end virtual + mov fs,[.vector.data.seg] + mov bx,[.vector.data.off] cmp byte [fs:bx],0xCF ;iret je .founded - add si,vector.sizeof + add si,.vectorori.sizeof cmp si,256*4 jb .searchdummypointer xor edx,edx jmp .suite .founded: - mov edx,[si+vector.content] + mov edx,[.vector.content] .suite: xor cx,cx xor si,si xor di,di cli .copy: - mov [es:di+ints.number],cl - mov [es:di+ints.locked],0 - mov [es:di+ints.vector1.content],0 - mov [es:di+ints.vector3.content],0 - mov [es:di+ints.vector4.content],0 - mov [es:di+ints.vector5.content],0 - mov [es:di+ints.vector6.content],0 - mov [es:di+ints.vector7.content],0 - mov [es:di+ints.vector8.content],0 - mov [es:di+ints.launchedlow],0 - mov [es:di+ints.launchedhigh],0 - mov [es:di+ints.calledlow],0 - mov [es:di+ints.calledhigh],0 - mov eax,[si+vector.ints.content] + virtual at di + .ints ints + end virtual + mov [es:.ints.number],cl + mov [es:.ints.locked],0 + mov [es:.ints.vector1.content],0 + mov [es:.ints.vector3.content],0 + mov [es:.ints.vector4.content],0 + mov [es:.ints.vector5.content],0 + mov [es:.ints.vector6.content],0 + mov [es:.ints.vector7.content],0 + mov [es:.ints.vector8.content],0 + mov [es:.ints.launchedlow],0 + mov [es:.ints.launchedhigh],0 + mov [es:.ints.calledlow],0 + mov [es:.ints.calledhigh],0 + mov eax,[.vector.content] cmp eax,edx je .notarealvector - mov [es:di+ints.vector1.content],eax - mov [es:di+ints.activated],1 + mov [es:.ints.vector1.content],eax + mov [es:.ints.activated],1 jmp .copynext .notarealvector: - mov [es:di+ints.vector1.content],0 - mov [es:di+ints.activated],0 + mov [es:.ints.vector1.content],0 + mov [es:.ints.activated],0 .copynext: mov bx,cx shl bx,3 sub bx,cx add bx,coupling - mov [si+vector.data.seg],cs - mov [si+vector.data.off],bx - add si,vector.sizeof - add di,ints.sizeof + mov [.vector.data.seg],cs + mov [.vector.data.off],bx + add si,.vectorori.sizeof + add di,.intsori.sizeof inc cl cmp cl,0 jne .copy @@ -253,7 +265,7 @@ endp interruptionbloc db '/interrupts',0 -proc savecontext, pointer +proc savecontext uses eax si ds, pointer:word pushfd push eax push ebx @@ -278,39 +290,45 @@ push eax mov ax,bp add ax,4 push eax -pop [si+regs.sesp] -pop [si+regs.seip] -pop [si+regs.scs] -pop [si+regs.sebp] -pop [si+regs.sss] -pop [si+regs.sgs] -pop [si+regs.sfs] -pop [si+regs.ses] -pop [si+regs.sds] -pop [si+regs.sedi] -pop [si+regs.sesi] -pop [si+regs.sedx] -pop [si+regs.secx] -pop [si+regs.sebx] -pop [si+regs.seax] -pop [si+regs.seflags] +virtual at si +.regs regs +end virtual +pop [.regs.sesp] +pop [.regs.seip] +pop [.regs.scs] +pop [.regs.sebp] +pop [.regs.sss] +pop [.regs.sgs] +pop [.regs.sfs] +pop [.regs.ses] +pop [.regs.sds] +pop [.regs.sedi] +pop [.regs.sesi] +pop [.regs.sedx] +pop [.regs.secx] +pop [.regs.sebx] +pop [.regs.seax] +pop [.regs.seflags] retf endp -proc restorecontextg, pointer +proc restorecontextg, pointer:word mov si,[pointer] -pushd [cs:si+regs.sesi] -pushd [cs:si+regs.seflags] -mov eax,[cs:si+regs.seax] -mov ebx,[cs:si+regs.sebx] -mov ecx,[cs:si+regs.secx] -mov edx,[cs:si+regs.sedx] -mov edi,[cs:si+regs.sedi] -mov ebp,[cs:si+regs.sebp] -mov es,[cs:si+regs.ses] -mov fs,[cs:si+regs.sfs] -mov gs,[cs:si+regs.sgs] -mov ds,[cs:si+regs.sds] +virtual at si +.regs regs +end virtual +pushd [cs:.regs.sesi] +pushd [cs:.regs.seflags] +mov eax,[cs:.regs.seax] +mov ebx,[cs:.regs.sebx] +mov ecx,[cs:.regs.secx] +mov edx,[cs:.regs.sedx] +mov edi,[cs:.regs.sedi] +mov ebp,[cs:.regs.sebp] +mov es,[cs:.regs.ses] +mov fs,[cs:.regs.sfs] +mov gs,[cs:.regs.sgs] +mov ds,[cs:.regs.sds] popfd pop esi pop [cs:dummy] @@ -322,7 +340,7 @@ endp coupling: repeat 256 push %+256 -push offset irqhandlers +push irqhandlers ret end repeat @@ -334,48 +352,60 @@ function_reg regs irqhandlers: cli pop [cs:interrupt] -stdcall savecontext,offset calling_reg +stdcall savecontext,calling_reg stdcall irqhandler,[cs:interrupt] -stdcall restorecontextg,offset calling_reg +stdcall restorecontextg,calling_reg sti iret -proc irqhandler, int +proc irqhandler, int:word push cs pop ds -stdcall mbfindsb,offset interruptionbloc,cs +stdcall mbfindsb,interruptionbloc,cs jc .end mov es,ax mov ax,[int] sub ax,256 -mov cx,ints.sizeof +virtual at 0 +.intsorig ints +end virtual +mov cx,.intsorig.sizeof mul cx mov si,ax -add [es:si+ints.calledlow],1 -adc [es:si+ints.calledhigh],0 -cmp [es:si+ints.activated],1 +virtual at si +.ints ints +end virtual +add [es:.ints.calledlow],1 +adc [es:.ints.calledhigh],0 +cmp [es:.ints.activated],1 jne .end -add [es:si+ints.launchedlow],1 -adc [es:si+ints.launchedhigh],0 -lea si,[es:si+ints.vector1] +add [es:.ints.launchedlow],1 +adc [es:.ints.launchedhigh],0 +lea si,[es:.ints.vector1] mov cl,8 .launchall: -cmp [es:si+vector.content],0 +virtual at si +.vector vector +end virtual +virtual at 0 +.vectorori vector +end virtual +cmp [es:.vector.content],0 je .end push word [cs:calling_reg.seflags] push cs -push offset .back -push [es:si+vector.data.seg] -push [es:si+vector.data.off] -stdcall savecontext,offset function_reg -stdcall restorecontextg,offset calling_reg +push .back +push [es:.vector.data.seg] +push [es:.vector.data.off] +stdcall savecontext,function_reg +stdcall restorecontextg,calling_reg db 0xCB .back: cli -stdcall savecontext,offset calling_reg -stdcall restorecontextg,offset function_reg +stdcall savecontext,calling_reg +stdcall restorecontextg,function_reg .next: -add si,vector.sizeof +add si,.vectorori.sizeof dec cl jnz .launchall .end: diff --git a/noyau/makefile b/noyau/makefile index 87448dd..c74653b 100644 --- a/noyau/makefile +++ b/noyau/makefile @@ -1,16 +1,17 @@ ASM=fasm CLEAN=rm -rf -all: systeme.sys disque.sys video.sys +all: disque.sys video.sys systeme.sys + sync systeme.sys: systeme.asm - $(ASM) $^ + $(ASM) $^ $@ disque.sys: disque.asm - $(ASM) $^ + $(ASM) $^ $@ video.sys: video.asm - $(ASM) $^ + $(ASM) $^ $@ clean: $(CLEAN) *.sys diff --git a/noyau/mcb.asm b/noyau/mcb.asm index fbf4850..f2d818d 100644 --- a/noyau/mcb.asm +++ b/noyau/mcb.asm @@ -1,6 +1,6 @@ ;Affiche le nombre hexa dans %0[dword] -proc biosprinth, num:dword +proc biosprinth uses ax bx cx edx si di, num:dword mov edx,[num] mov ah,09h mov di,8 @@ -25,7 +25,7 @@ proc biosprinth, num:dword endp ;Affiche le texte ASCIIZ pointé par %0 -proc biosprint, pointer +proc biosprint uses ax bx cx si, pointer:word mov si,[pointer] mov cx,1 mov bx,7 @@ -45,7 +45,7 @@ proc biosprint, pointer retf endp -proc enablea20 +proc enablea20 uses ax mov al,0d1h out 64h,al call a20wait @@ -58,7 +58,7 @@ proc enablea20 retf endp -proc disablea20 +proc disablea20 uses ax mov al,0d1h out 64h,al call a20wait @@ -88,7 +88,7 @@ a20wait: ;and al,not 2 ;out 92h,al -proc flatmode +proc flatmode uses eax bx ds push cs pop ds ; first, calculate the linear address of GDT @@ -98,7 +98,10 @@ proc flatmode add dword [.gdt+2],eax ; store as GDT linear base addr ; now load the GDT into the GDTR lgdt fword [.gdt] ; load GDT base - mov bx,1 * descriptor.sizeof ; point to first descriptor + virtual at 0 + .descriptor descriptor + end virtual + mov bx,1 * .descriptor.sizeof ; point to first descriptor cli ; turn off interrupts mov eax,cr0 ; prepare to enter protected mode or al,1 ; flip the PE bit @@ -120,7 +123,7 @@ gdtdata descriptor 0ffffh, 0, 0, 091h, 0cfh, 0 ; 4G data segment endp ;Attend l'appuie sur une touche -proc bioswaitkey +proc bioswaitkey uses ax xor ax,ax int 16h retf @@ -130,7 +133,7 @@ firstmb dw 0 ;Charge les sections du block %0 -proc mbloadsection, blocks +proc mbloadsection uses ax bx cx si di ds es, blocks:word mov ax,[blocks] mov es,ax mov ds,ax @@ -138,7 +141,10 @@ proc mbloadsection, blocks jne .notace lea si,[.toresov] mov word [ss:si],0FFFFh - mov bx,[ds:exe.sections] + virtual at 0 + .exe exe + end virtual + mov bx,[ds:.exe.sections] cmp bx,0 je .finishloading .loading: @@ -193,7 +199,7 @@ endp ;Initialise les blocs de mémoire en prenant memorystart pour segment de base -proc mbinit +proc mbinit uses ax cx si di ds es cmp [cs:firstmb],0 jne .alreadyok push cs @@ -203,7 +209,10 @@ proc mbinit mov es,ax mov si,afree xor di,di - mov cx,mb.sizeof + virtual at 0 + .mb mb + end virtual + mov cx,.mb.sizeof rep movsb clc retf @@ -216,7 +225,7 @@ afree mb "HN",0,0,0,0A000h-memorystart,"Libre" db 0 ;Creér un bloc de nom %0 de taille %1 (octets) -> n°segment dans AX -proc mbcreate , blocks, size +proc mbcreate uses bx cx dx si di ds es, blocks:word, size:word push gs mov ax,[ss:bp+4] mov dx,ax @@ -239,20 +248,23 @@ proc mbcreate , blocks, size cmp dl,false je .notenougtmem mov es,bx - cmp word [es:mb.check],"NH" + virtual at 0 + .mb mb + end virtual + cmp word [es:.mb.check],"NH" jne .memoryerror - cmp [es:mb.isnotlast],true + cmp [es:.mb.isnotlast],true sete dl - cmp [es:mb.reference],free + cmp [es:.mb.reference],free jne .notsogood - mov ax,[es:mb.sizes] + mov ax,[es:.mb.sizes] cmp cx,ax ja .notsogood - mov word [es:mb.check],"NH" - mov [es:mb.isnotlast],true - mov [es:mb.reference],gs - mov [es:mb.isresident],false - lea di,[es:mb.names] + mov word [es:.mb.check],"NH" + mov [es:.mb.isnotlast],true + mov [es:.mb.reference],gs + mov [es:.mb.isresident],false + lea di,[es:.mb.names] push cx mov cx,24/4 mov si,[blocks] @@ -266,18 +278,18 @@ proc mbcreate , blocks, size je .nofree dec ax dec ax - mov [es:mb.sizes],cx + mov [es:.mb.sizes],cx add cx,bx mov es,cx mov si,afree xor di,di - mov cx,mb.sizeof + mov cx,.mb.sizeof push cs pop ds cld rep movsb - mov [es:mb.isnotlast],dl - mov [es:mb.sizes],ax + mov [es:.mb.isnotlast],dl + mov [es:.mb.sizes],ax .nofree: mov ax,bx pop gs @@ -286,7 +298,7 @@ proc mbcreate , blocks, size .notsogood: inc bx inc bx - add bx,[es:mb.sizes] + add bx,[es:.mb.sizes] jmp .searchfree .memoryerror: pop gs @@ -299,23 +311,26 @@ proc mbcreate , blocks, size endp ;Libère le bloc de mémoire %0 et ses sous blocs -proc mbfree, blocks +proc mbfree uses ax bx cx si di ds es, blocks:word mov bx,[blocks] mov ax,bx dec bx dec bx mov es,bx - cmp word [es:mb.check],"NH" + virtual at 0 + .mb mb + end virtual + cmp word [es:.mb.check],"NH" jne .memoryerror - cmp [es:mb.reference],free + cmp [es:.mb.reference],free je .wasfree - cmp [es:mb.isresident],true + cmp [es:.mb.isresident],true je .wasresident - mov [es:mb.reference],free + mov [es:.mb.reference],free push cs pop ds mov si,.isfree - lea di,[es:mb.names] + lea di,[es:.mb.names] mov cx,6 cld rep movsb @@ -324,24 +339,24 @@ proc mbfree, blocks dec bx .searchtofree: mov es,bx - cmp word [es:mb.check],"NH" + cmp word [es:.mb.check],"NH" jne .memoryerror inc bx inc bx - add bx,[es:mb.sizes] - cmp [es:mb.sizes],0 + add bx,[es:.mb.sizes] + cmp [es:.mb.sizes],0 je .nottofree - cmp ax,[es:mb.reference] + cmp ax,[es:.mb.reference] jne .nottofree - mov [es:mb.isresident],false - mov [es:mb.reference],free + mov [es:.mb.isresident],false + mov [es:.mb.reference],free mov si,.isfree - lea di,[es:mb.names] + lea di,[es:.mb.names] mov cx,6 cld rep movsb .nottofree: - cmp [es:mb.isnotlast],true + cmp [es:.mb.isnotlast],true je .searchtofree stdcall mbclean retf @@ -359,7 +374,7 @@ proc mbfree, blocks endp ;Mise a nivo de la mémoire (jonction de blocs libre) -proc mbclean +proc mbclean uses ax bx dx es gs mov bx,[cs:firstmb] dec bx dec bx @@ -367,20 +382,23 @@ proc mbclean xor dx,dx .searchfree: mov gs,bx - cmp word [gs:mb.check],"NH" + virtual at 0 + .mb mb + end virtual + cmp word [gs:.mb.check],"NH" jne .memoryerror inc bx inc bx - add bx,[gs:mb.sizes] - cmp word [gs:mb.sizes],0 + add bx,[gs:.mb.sizes] + cmp word [gs:.mb.sizes],0 je .notenougtmem - cmp [gs:mb.reference],free + cmp [gs:.mb.reference],free jne .notfree cmp ax,0 je .notmeetfree - add dx,[gs:mb.sizes] - mov word [gs:mb.check],0 - mov dword [gs:mb.names],0 + add dx,[gs:.mb.sizes] + mov word [gs:.mb.check],0 + mov dword [gs:.mb.names],0 inc dx inc dx jmp .nottrigered @@ -392,16 +410,16 @@ proc mbclean cmp ax,0 je .nottrigered mov es,ax - add [es:mb.sizes],dx + add [es:.mb.sizes],dx xor ax,ax .nottrigered: - cmp [gs:mb.isnotlast],true + cmp [gs:.mb.isnotlast],true je .searchfree cmp ax,0 je .reallyfinish mov es,ax - add [es:mb.sizes],dx - mov [es:mb.isnotlast],false + add [es:.mb.sizes],dx + mov [es:.mb.isnotlast],false .reallyfinish: clc retf @@ -414,14 +432,17 @@ proc mbclean endp ;Rend le segment %0 résident -proc mbresident, blocks +proc mbresident uses bx es, blocks:word mov bx,[blocks] dec bx dec bx mov es,bx - cmp word [es:mb.check],"NH" + virtual at 0 + .mb mb + end virtual + cmp word [es:.mb.check],"NH" jne .memoryerror - mov [es:mb.isresident],true + mov [es:.mb.isresident],true retf .memoryerror: stc @@ -429,14 +450,17 @@ proc mbresident, blocks endp ;Rend le segment %0 non résident -proc mbnonresident, blocks +proc mbnonresident uses bx es, blocks:word mov bx,[blocks] dec bx dec bx mov es,bx - cmp word [es:mb.check],"NH" + virtual at 0 + .mb mb + end virtual + cmp word [es:.mb.check],"NH" jne .memoryerror - mov [es:mb.isresident],false + mov [es:.mb.isresident],false retf .memoryerror: stc @@ -445,17 +469,20 @@ endp ;Change le proprietaire de %0 a %1 -proc mbchown ,blocks, owner +proc mbchown uses bx dx es,blocks:word, owner:word mov bx,[blocks] dec bx dec bx mov es,bx - cmp word [es:mb.check],"NH" + virtual at 0 + .mb mb + end virtual + cmp word [es:.mb.check],"NH" jne .memoryerror - cmp [es:mb.reference],free + cmp [es:.mb.reference],free je .wasfree mov dx,[owner] - mov [es:mb.reference],dx + mov [es:.mb.reference],dx retf .memoryerror: stc @@ -466,7 +493,7 @@ proc mbchown ,blocks, owner endp ;Alloue un bloc /data de CX caractere pour le process appelant -> ax -proc mballoc, size +proc mballoc uses si ds, size:word push cs pop ds stdcall mbcreate,.data,[size] @@ -477,25 +504,28 @@ proc mballoc, size endp ;Renvoie en AX le MB n° %0 carry quand terminé -proc mbget, num +proc mbget uses bx dx es, num:word mov bx,[cs:firstmb] dec bx dec bx xor dx,dx .searchfree: mov es,bx - cmp word [es:mb.check],"NH" + virtual at 0 + .mb mb + end virtual + cmp word [es:.mb.check],"NH" jne .memoryerror inc bx inc bx - add bx,[es:mb.sizes] - cmp [es:mb.sizes],0 + add bx,[es:.mb.sizes] + cmp [es:.mb.sizes],0 je .memoryerror cmp dx,[num] je .foundmcb ja .notfound inc dx - cmp [es:mb.isnotlast],true + cmp [es:.mb.isnotlast],true je .searchfree .memoryerror: stc @@ -512,20 +542,23 @@ proc mbget, num endp ;Renvoie en AX le MCB qui correspond a ds:%0 -proc mbfind, blocks +proc mbfind uses bx si di es, blocks:word mov bx,[cs:firstmb] dec bx dec bx mov si,[blocks] .search: mov es,bx - lea di,[es:mb.names] - cmp word [es:mb.check],"NH" + virtual at 0 + .mb mb + end virtual + lea di,[es:.mb.names] + cmp word [es:.mb.check],"NH" jne .memoryerror inc bx inc bx - add bx,[es:mb.sizes] - cmp [es:mb.sizes],0 + add bx,[es:.mb.sizes] + cmp [es:.mb.sizes],0 je .memoryerror push si di .cmpnames: @@ -540,7 +573,7 @@ proc mbfind, blocks .ok: pop di si je .foundmcb - cmp [es:mb.isnotlast],true + cmp [es:.mb.isnotlast],true je .search .notfound: stc @@ -558,21 +591,24 @@ endp ;Renvoie en AX le sous mcb qui correspond a %0 et qui appartien a %1 -proc mbfindsb, blocks, owner +proc mbfindsb uses bx dx si di es, blocks:word, owner:word mov bx,[cs:firstmb] dec bx dec bx mov si,[blocks] - lea di,[es:mb.names] + virtual at 0 + .mb mb + end virtual + lea di,[es:.mb.names] mov dx,[owner] .search: mov es,bx - cmp word [es:mb.check],"NH" + cmp word [es:.mb.check],"NH" jne .memoryerror inc bx inc bx - add bx,[es:mb.sizes] - cmp [es:mb.sizes],0 + add bx,[es:.mb.sizes] + cmp [es:.mb.sizes],0 je .memoryerror push si di .cmpnames: @@ -587,10 +623,10 @@ proc mbfindsb, blocks, owner .ok: pop di si jne .notfoundmcb - cmp [es:mb.reference],dx + cmp [es:.mb.reference],dx je .foundmcb .notfoundmcb: - cmp [es:mb.isnotlast],true + cmp [es:.mb.isnotlast],true je .search .notfound: stc @@ -607,11 +643,14 @@ proc mbfindsb, blocks, owner endp ;Resouds les dépendances du bloc de mémoire %0 -proc mbloadfuncs, blocks +proc mbloadfuncs uses ax bx cx dx si ds, blocks:word mov ds,[blocks] cmp word [0],"EC" jne .notace - mov si,[ds:exe.imports] + virtual at 0 + .exe exe + end virtual + mov si,[ds:.exe.imports] cmp si,0 je .endofloading .loadfuncs: @@ -628,7 +667,7 @@ proc mbloadfuncs, blocks cmp byte [bx], ':' jne .findend mov byte [bx],0 - stdcall [cs:projfile],si + invoke projfile,si mov byte [bx],':' jc .erroronload ;pushad @@ -664,10 +703,13 @@ endp ;Recherche une fonction pointé par DS:%0 en mémoire et renvoie son adresse en DX:AX -proc mbsearchfunc, func +proc mbsearchfunc uses bx si di es, func:word mov bx,[func] mov si,bx .findend: + virtual at 0 + .exe exe + end virtual inc bx cmp byte [bx], ':' jne .findend @@ -676,9 +718,9 @@ proc mbsearchfunc, func mov byte [bx],':' jc .notfoundattallthesb mov es,ax - cmp word [es:exe.checks],"EC" + cmp word [es:.exe.checks],"EC" jne .notfoundattallthesb - mov di,[es:exe.exports] + mov di,[es:.exe.exports] inc bx inc bx .functions: diff --git a/noyau/systeme.asm b/noyau/systeme.asm index a61b7a1..e951ec6 100644 --- a/noyau/systeme.asm +++ b/noyau/systeme.asm @@ -49,26 +49,26 @@ suite: pop gs stdcall biosprint,msg_ok stdcall biosprint,msg_video_init - stdcall [cs:setvideomode],2 + invoke setvideomode,2 jc error - stdcall [cs:clearscreen] - stdcall [cs:print],msg_memory - stdcall [cs:print],msg_ok2 - stdcall [cs:print],msg_memory_init - stdcall [cs:print],msg_ok2 - stdcall [cs:print],msg_memory_section - stdcall [cs:print],msg_ok2 - stdcall [cs:print],msg_memory_jumps - stdcall [cs:print],msg_ok2 - stdcall [cs:print],msg_video_init - stdcall [cs:print],msg_ok2 - stdcall [cs:print],msg_handler - ;stdcall installirqhandler - stdcall [cs:print],msg_ok2 - stdcall [cs:print],msg_cpu_detect - stdcall [cs:cpuinfo],thecpu - stdcall [cs:setinfo],thecpu,temporary - stdcall [cs:print],msg_ok2 + invoke clearscreen + invoke print,msg_memory + invoke print,msg_ok2 + invoke print,msg_memory_init + invoke print,msg_ok2 + invoke print,msg_memory_section + invoke print,msg_ok2 + invoke print,msg_memory_jumps + invoke print,msg_ok2 + invoke print,msg_video_init + invoke print,msg_ok2 + invoke print,msg_handler + ;invoke installirqhandler + invoke print,msg_ok2 + invoke print,msg_cpu_detect + invoke cpuinfo,thecpu + invoke setinfo,thecpu,temporary + invoke print,msg_ok2 push temporary xor eax,eax mov al,[thecpu.family] @@ -79,11 +79,11 @@ suite: push eax push thecpu.names push thecpu.vendor - stdcall [cs:print],msg_cpu_detect_inf - stdcall [cs:print],msg_pci - stdcall [cs:pciinfo],thepci + invoke print,msg_cpu_detect_inf + invoke print,msg_pci + invoke pciinfo,thepci jc nopci - stdcall [cs:print],msg_ok2 + invoke print,msg_ok2 xor eax,eax mov al,[thepci.maxbus] push eax @@ -91,25 +91,28 @@ suite: push eax mov al,[thepci.version_major] push eax - stdcall [cs:print],msg_pci_info - stdcall [cs:print],msg_pci_enum + invoke print,msg_pci_info + invoke print,msg_pci_enum xor ebx,ebx xor ecx,ecx xor si,si searchpci: - stdcall [cs:getcardinfo],bx,cx,si,temporary + invoke getcardinfo,bx,cx,si,temporary jc stopthis - mov al,[temporary+pcidata.subclass] + virtual at temporary + .pcidata pcidata + end virtual + mov al,[.pcidata.subclass] push ax - mov al,[temporary+pcidata.class] + mov al,[.pcidata.class] push ax - stdcall [cs:getpcisubclass] + invoke getpcisubclass push dx push ax - mov al,[temporary+pcidata.class] + mov al,[.pcidata.class] xor ah,ah push ax - stdcall [cs:getpciclass] + invoke getpciclass push dx push ax push 4 @@ -118,11 +121,11 @@ searchpci: push ecx push 4 push ebx - mov ax,[temporary+pcidata.device] + mov ax,[.pcidata.device] push eax - mov ax,[temporary+pcidata.vendor] + mov ax,[.pcidata.vendor] push eax - stdcall [cs:print],msg_pci_card + invoke print,msg_pci_card inc si cmp si,7 jbe searchpci @@ -137,29 +140,29 @@ stopthis: jbe searchpci jmp next nopci: - stdcall [cs:print],msg_echec2 + invoke print,msg_echec2 next: - ;stdcall [cs:detectvmware] + ;invoke detectvmware ;jne novirtual - ;stdcall [cs:print],msg_vmware + ;invoke print,msg_vmware novirtual: - ;stdcall [cs:print],msg_flat - ;stdcall enablea20 - ;stdcall flatmode + ;invoke print,msg_flat + ;invoke enablea20 + ;invoke flatmode ;xor ax,ax ;mov fs,ax ;mov esi,0100000h ;mov [dword ptr fs:esi],"OKIN" - stdcall [cs:print],msg_ok2 - stdcall [cs:print],msg_disk_init - stdcall [cs:initdrive] + invoke print,msg_ok2 + invoke print,msg_disk_init + invoke initdrive jc error2 - stdcall [cs:print],msg_ok2 - stdcall [cs:print],msg_launchcommand - stdcall [cs:execfile],shell + invoke print,msg_ok2 + invoke print,msg_launchcommand + invoke execfile,shell jc error2 error2: - stdcall [cs:print],msg_error2 + invoke print,msg_error2 stdcall bioswaitkey jmp far 0FFFFh:0000h diff --git a/programs/commande.asm b/programs/commande.asm index c9e31c0..156254c 100644 --- a/programs/commande.asm +++ b/programs/commande.asm @@ -1,10 +1,3 @@ -model tiny,stdcall -p586N -locals -jumps -codeseg -option procalign:byte - include "..\include\fat.h" include "..\include\mem.h" include "..\include\divers.h" @@ -14,31 +7,31 @@ include "..\include\cpu.h" org 0h start: -header exe <,1,0,,,offset imports,,offset realstart> +header exe 1 realstart: - call [cs:print],offset msginit + invoke print, msginit xor bp,bp replay: - call [cs:addline] + invoke addline noret: - call [cs:addline] - mov di,offset dir - call [cs:getdir],di - call [cs:print],di - call [cs:print],offset prompt - mov di,offset buffer + invoke addline + mov di,dir + invoke getdir,di + invoke print,di + invoke print,prompt + mov di, buffer waitchar: xor ax,ax int 16h - call convertfr + invoke convertfr cmp ah,59 jne norr cmp bp,0 je waitchar - call [print],[word ptr cs: bp] - call [copy],[word ptr cs: bp],di - call [getlength],di + invoke print,word [cs: bp] + invoke copy,word [cs: bp],di + invoke getlength,di add di,ax jmp waitchar norr: @@ -50,17 +43,17 @@ norr: je escape cmp al,' ' jb waitchar - cmp di,offset buffer+256 + cmp di, buffer+256 je waitchar mov [di],al inc di - call [cs:showchar],ax + invoke showchar,ax jmp waitchar escape: - cmp di,offset buffer + cmp di, buffer je waitchar - call [cs:getxy] - mov dx,offset buffer + invoke getxy + mov dx,buffer mov cx,di sub cx,dx js waitchar @@ -69,84 +62,84 @@ escape: mov cl,ah xor ah,ah xor ch,ch - call [cs:setxy],cx,ax - mov di,offset buffer - mov [byte ptr di],0 + invoke setxy,cx,ax + mov di,buffer + mov byte [di],0 jmp waitchar backspace: - cmp di,offset buffer + cmp di,buffer je waitchar - call [cs:getxy] + invoke getxy dec ah mov cl,ah xor ah,ah xor ch,ch - call [cs:setxy],cx,ax - call [cs:showchar],' ' - call [cs:setxy],cx,ax + invoke setxy,cx,ax + invoke showchar,' ' + invoke setxy,cx,ax dec di - mov [byte ptr di],0 + mov byte [di],0 jmp waitchar entere: - mov [byte ptr di],0 - cmp di,offset buffer + mov byte [di],0 + cmp di,buffer je noret - mov si,offset temp - call [cs:addline] - call [cs:getitem],offset buffer,si,0,' ' - call [cs:uppercase],si - mov bx,offset commands + mov si,temp + invoke addline + invoke getitem,buffer,si,0,' ' + invoke uppercase,si + mov bx,commands xor bp,bp xor dx,dx tre: mov di,[bx] cmp di,0 je error - call [cs:evalue],si,di + invoke evalue,si,di cmp ax,dx jb noadd mov dx,ax mov bp,bx noadd: - call [cs:cmpstr],si,di + invoke cmpstr,si,di je strisok add bx,8 jmp tre strisok: - mov di,offset temp - call [cs:copy],offset buffer,di - call [cs:uppercase],di + mov di, temp + invoke copy,buffer,di + invoke uppercase,di xor cx,cx inc cx - call [cs:getpointeritem],di,cx,' ' + invoke getpointeritem,di,cx,' ' mov di,ax - cmp [byte ptr di-1],0 + cmp byte [di-1],0 jne nopod - mov [byte ptr di],0 + mov byte [di],0 nopod: - call [cs:checksyntax],di,[word ptr bx+4],' ' + invoke checksyntax,di,word [bx+4],' ' jc errorprec mov bx,[bx+2] - call bx + invoke bx jmp replay error: - mov di,offset buffer - call [cs:searchchar],di,'.' + mov di,buffer + invoke searchchar,di,'.' je noaddext - call [cs:concat],offset extcom,di + invoke concat, extcom,di noaddext: - call [cs:execfile],di + invoke execfile,di jc reallyerror xor bp,bp jmp replay reallyerror: - push [word ptr cs: bp] - push offset error_syntax - call [cs:print] + push word [cs: bp] + push error_syntax + invoke print jmp replay errorprec: - push offset derror - call [cs:print] + push derror + invoke print jmp replay code_exit: @@ -154,13 +147,13 @@ code_exit: retf code_version: - call [cs:print],offset version_text + invoke print, version_text ret version_text db 'Cos 2000 version 1.4Fr par \c04MrNop\c07',0 code_cls: - call [cs:clearscreen] + invoke clearscreen ret code_reboot: @@ -169,15 +162,15 @@ code_reboot: retf code_command: - call [cs:print],offset def - mov bx,offset commands + invoke print, def + mov bx, commands showalls: - push [word ptr bx+4] - push [word ptr bx+6] - push [word ptr bx] - call [cs:print],offset commandes + push word [bx+4] + push word [bx+6] + push word [bx] + invoke print, commandes add bx,8 - cmp [word ptr bx],0 + cmp word [bx],0 jne showalls endoff: ret @@ -186,11 +179,11 @@ def db '\c02Liste des commandes internes\l\l\c07',0 commandes db '%0 \h10:\h12%0 \h70%0\l',0 code_detect: - call [cs:print],offset msg_cpu_detect - call [cs:cpuinfo],offset thecpu - call [cs:setinfo],offset thecpu,offset temp - call [cs:print],offset msg_ok2 - push offset temp + invoke print,msg_cpu_detect + invoke cpuinfo,thecpu + invoke setinfo,thecpu, temp + invoke print,msg_ok2 + push temp xor eax,eax mov al,[thecpu.family] push eax @@ -198,13 +191,13 @@ code_detect: push eax mov al,[thecpu.stepping] push eax - push offset thecpu.names - push offset thecpu.vendor - call [cs:print],offset msg_cpu_detect_inf - call [cs:print],offset msg_pci - call [cs:pciinfo],offset thepci + push thecpu.names + push thecpu.vendor + invoke print, msg_cpu_detect_inf + invoke print, msg_pci + invoke pciinfo, thepci jc nopci - call [cs:print],offset msg_ok2 + invoke print, msg_ok2 xor eax,eax mov al,[thepci.maxbus] push eax @@ -212,25 +205,28 @@ code_detect: push eax mov al,[thepci.version_major] push eax - call [cs:print],offset msg_pci_info - call [cs:print],offset msg_pci_enum + invoke print, msg_pci_info + invoke print, msg_pci_enum xor ebx,ebx xor ecx,ecx xor si,si searchpci: - call [cs:getcardinfo],bx,cx,si,offset temp + invoke getcardinfo,bx,cx,si, temp jc stopthis - mov al,[(pcidata offset temp).subclass] + virtual at temp + .pcidata pcidata + end virtual + mov al,[.pcidata.subclass] push ax - mov al,[(pcidata offset temp).class] + mov al,[.pcidata.class] push ax - call [cs:getpcisubclass] + invoke getpcisubclass push dx push ax - mov al,[(pcidata offset temp).class] + mov al,[.pcidata.class] xor ah,ah push ax - call [cs:getpciclass] + invoke getpciclass push dx push ax push 4 @@ -239,11 +235,11 @@ searchpci: push ecx push 4 push ebx - mov ax,[(pcidata offset temp).device] + mov ax,[.pcidata.device] push eax - mov ax,[(pcidata offset temp).vendor] + mov ax,[.pcidata.vendor] push eax - call [cs:print],offset msg_pci_card + invoke print, msg_pci_card inc si cmp si,7 jbe searchpci @@ -258,16 +254,16 @@ stopthis: jbe searchpci jmp next nopci: - call [cs:print],offset msg_echec2 + invoke print, msg_echec2 next: - call [cs:detectvmware] + invoke detectvmware jne novirtual - call [cs:print],offset msg_vmware + invoke print, msg_vmware novirtual: ret -thepci pciinf <> -thecpu cpu <> +thepci pciinf +thecpu cpu msg_ok2 db "\h70 [\c02 Ok \c07]\l",0 msg_echec2 db "\h70 [\c0CPasser\c07]\l",0 @@ -281,42 +277,45 @@ msg_pci_card db " | 0x%hW | 0x%hW |%w|%w|%w|%0P.%0P\l",0 msg_vmware db "\c04 VMWare a ete detecte !!!\c07\l",0 code_mode: - call [cs:gettypeditem],di,0,' ' + invoke gettypeditem,di,0,' ' and al,1111b - call [cs:setvideomode],ax - call [cs:clearscreen] + invoke setvideomode,ax + invoke clearscreen ret code_dir: - call [cs:getserial] + invoke getserial push eax - mov si,offset nomdisque - call [cs:getname],si + mov si, nomdisque + invoke getname,si push si - push offset present - call [cs:print] + push present + invoke print xor ecx,ecx - mov di,offset bufferentry - call [cs:findfirstfile],di + mov di, bufferentry + invoke findfirstfile,di jc nofiles go: - push [word ptr (find di).result.fileattr] - push [(find di).result.filesize] - push [(find di).result.filetime] - push [(find di).result.filedate] - push [(find di).result.filetimecrea] - push [(find di).result.filedatecrea] - lea bx,[(find di).result.filename] + virtual at di + .find find + end virtual + push word [.find.result.fileattr] + push [.find.result.filesize] + push [.find.result.filetime] + push [.find.result.filedate] + push [.find.result.filetimecrea] + push [.find.result.filedatecrea] + lea bx,[.find.result.filename] push bx - push offset line - call [cs:print] + push line + invoke print inc ecx - call [cs:findnextfile],di + invoke findnextfile,di jnc go nofiles: push ecx - push offset filess - call [cs:print] + push filess + invoke print ret nomdisque db 13 dup (0) @@ -327,14 +326,14 @@ line db '\c07%n %d %t %d %t %z %a\l',0 filess db '\l\l\c02%u Fichier(s) au total\l\c07',0 code_cd: - call [cs:gettypeditem],di,0,' ' + invoke gettypeditem,di,0,' ' push ax - push offset changing - call [cs:print] - call [cs:changedir],ax + push changing + invoke print + invoke changedir,ax jnc okchange - push offset errorchanging - call [cs:print] + push errorchanging + invoke print okchange: ret @@ -342,16 +341,16 @@ changing db 'Changement de repertoire vers %0\l',0 errorchanging db '\c04Impossible d''atteindre ce dossier\c07',0 code_kill: - call [cs:gettypeditem],di,0,' ' + invoke gettypeditem,di,0,' ' push ax - push offset killing - call [cs:print] - call [cs:mbfind],ax + push killing + invoke print + invoke mbfind,ax jc nochanged - call [cs:mbfree],ax + invoke mbfree,ax jnc okchanged nochanged: - call [cs:print],offset errorkilling + invoke print, errorkilling okchanged: ret @@ -363,26 +362,26 @@ push ebp push esp push ss push ss -call [cs:print],offset stackshow +invoke print, stackshow mov cx,12 ;12 derniers éléments xor esi,esi mov si,sp sub si,2*12 showloop: -push [dword ptr ss:si] +push dword [ss:si] push esi push ss push ss -call [cs:print],offset itemshow +invoke print, itemshow inc si inc si cmp si,sp jne notspshow -call [cs:print],offset stresp +invoke print, stresp notspshow: cmp si,bp jne nextshow -call [cs:print],offset strebp +invoke print, strebp nextshow: dec cx jnz showloop @@ -400,42 +399,42 @@ stresp db '<-- SP',0 code_setbuffer: - call [cs:gettypeditem],di,0,' ' - call [cs:setbuffer],ax + invoke gettypeditem,di,0,' ' + invoke setbuffer,ax code_getbuffer: - mov si,offset diskbuffers - call [cs:getbuffer],si + mov si, diskbuffers + invoke getbuffer,si xor ecx,ecx mov cx,[diskbuffers.current] push ecx mov cx,[diskbuffers.size] push ecx - call [cs:print],offset showbuffers - mov si,offset diskbuffers.chain + invoke print, showbuffers + mov si, diskbuffers.chain xor bx,bx showbuffer: - cmp [word ptr si],0FFFFh + cmp word [si],0FFFFh jne notnoted - push offset noted + push noted jmp islikeit notnoted: - cmp [word ptr si],0FFFEh + cmp word [si],0FFFEh jne notempty - push offset empty + push empty jmp islikeit notempty: - push [dword ptr si] - push offset occup + push dword [si] + push occup islikeit: cmp bx,[diskbuffers.current] jne notthecurrent - call [cs:showchar],'*' + invoke showchar,'*' jmp okletsgo notthecurrent: - call [cs:showchar],' ' + invoke showchar,' ' okletsgo: - call [cs:print] + invoke print inc si inc si inc bx @@ -450,89 +449,113 @@ showbuffers db '\l\c02Contenu des tampons disquette\l\l\c07' db 'Nombre de tampons alloues : %u\l' db 'Dernier element du tampon : %u\l\l',0 -diskbuffers diskbuffer <> +diskbuffers diskbuffer code_dump: - call [cs:gettypeditem],di,0,' ' - call [cs:mbfind],di + virtual at 0 + .mb mb + end virtual + invoke gettypeditem,di,0,' ' + invoke mbfind,di jc notmbfind mov fs,ax dec ax dec ax mov gs,ax - cmp [word ptr fs:0x0],'EC' + cmp word [fs:0x0],'EC' jne notace2 - push offset oui ;CE? str0 2 + push oui ;CE? str0 2 jmp suitelikeace2 notace2: - push offset non + push non suitelikeace2: - cmp [word ptr gs:mb.isnotlast],true + virtual at 0 + .mb mb + end virtual + cmp word [gs:.mb.isnotlast],true je notlast2 - push offset oui ;CE? str0 2 + push oui ;CE? str0 2 jmp suitelikelast2 notlast2: - push offset non + push non suitelikelast2: mov dx,gs push edx ;Emplacement memoire hex 2 ;parent - cmp [gs:mb.reference],0 + virtual at 0 + .mb mb + end virtual + cmp [gs:.mb.reference],0 jne nextdetect2 push cs - push offset none ;parent lstr0 2x2 - add bx,[gs:mb.sizes] + push none ;parent lstr0 2x2 + add bx,[gs:.mb.sizes] jmp suitemn2 nextdetect2: - mov dx,[gs:mb.reference] + virtual at 0 + .mb mb + end virtual + mov dx,[gs:.mb.reference] dec dx dec dx push dx ;parent lstr0 2x2 - push offset (mb).names + push .mb.names suitemn2: - cmp [gs: mb.isresident],true + virtual at 0 + .mb mb + end virtual + cmp [gs: .mb.isresident],true jne notresident2 - push offset oui ;resident str0 2 + push oui ;resident str0 2 jmp suitelistmcb2 notresident2: - push offset non ;resident str0 2 + push non ;resident str0 2 suitelistmcb2: xor edx,edx - mov dx,[gs: mb.sizes] + virtual at 0 + .mb mb + end virtual + mov dx,[gs:.mb.sizes] shl edx,4 push edx push gs ;nom lstr0 2x2 - push offset (mb).names - push offset dumpshow ;ligne - call [cs:print] - cmp [word ptr fs:0x0],'EC' + push .mb.names + push dumpshow ;ligne + invoke print + cmp word [fs:0x0],'EC' jne endofdumpformoment - push [dword ptr fs:exe.starting] + virtual at 0 + .exe exe + end virtual + push dword [fs:.exe.starting] push fs push fs - push [dword ptr fs:exe.sections] + push dword [fs:.exe.sections] push fs push fs - push [dword ptr fs:exe.imports] + push dword [fs:.exe.imports] push fs push fs - push [dword ptr fs:exe.exports] + push dword [fs:.exe.exports] push fs push fs - cmp [fs: exe.compressed],true + cmp [fs:.exe.compressed],true jne notcompressed - push offset oui + push oui jmp suiteiscompressed notcompressed: - push offset non + push non suiteiscompressed: - push [dword ptr fs:exe.checksum] - push [dword ptr fs:exe.major] - call [cs:print],offset dumpshowce + virtual at 0 + .exe exe + end virtual + push dword [fs:.exe.checksum] + push dword [fs:.exe.major] + invoke print, dumpshowce endofdumpformoment: ret notmbfind: - call [cs:print],offset errornotmbfind + invoke print, errornotmbfind ret errornotmbfind db '\c04Impossible de trouver le bloc specifie\l\l\c07',0 @@ -559,93 +582,99 @@ dumpshowce db '\c02-----------------------------\l' code_sections: - call [cs:gettypeditem],di,0,' ' - call [cs:mbfind],di + invoke gettypeditem,di,0,' ' + invoke mbfind,di jc notmbfindssections jmp haveatargetsections notmbfindssections: - call [cs:searchfile],di + invoke searchfile,di jc notmbfindall - call [cs:projfile],di + invoke projfile,di jc notmbfindall - call [cs:mbfind],di + invoke mbfind,di jc notmbfindall haveatargetsections: mov fs,ax - cmp [word ptr fs:0x0],'EC' + cmp word [fs:0x0],'EC' jne errornotace2 - mov si,[fs:exe.sections] + virtual at 0 + .exe exe + end virtual + mov si,[fs:.exe.sections] cmp si,0 je errornosections xor edx,edx - call [cs:print],offset rets + invoke print, rets showallsections: add si,4 push fs push si - call [cs:print],offset functions + invoke print, functions inc edx findnextsections: inc si - cmp [byte ptr fs:si],0 + cmp byte [fs:si],0 jne findnextsections - cmp [dword ptr fs:si],0 + cmp dword [fs:si],0 je finishsections inc si jmp showallsections finishsections: push edx - call [cs:print],offset allsections + invoke print, allsections ret errornosections: - call [cs:print],offset errornosection + invoke print, errornosection ret allsections db '\c02\lIl y avait %u sections dans le bloc ou fichier\l\c07',0 errornosection db '\c02Aucune section dans le bloc ou fichier\l\c07',0 code_exports: - call [cs:gettypeditem],di,0,' ' - call [cs:mbfind],di + invoke gettypeditem,di,0,' ' + invoke mbfind,di jc notmbfindsimports jmp haveatargetexports notmbfindsexports: - call [cs:searchfile],di + invoke searchfile,di jc notmbfindall - call [cs:projfile],di + invoke projfile,di jc notmbfindall - call [cs:mbfind],di + invoke mbfind,di jc notmbfindall haveatargetexports: mov fs,ax - cmp [word ptr fs:0x0],'EC' + cmp word [fs:0x0],'EC' jne errornotace2 - mov si,[fs:exe.exports] + virtual at 0 + .exe exe + end virtual + mov si,[fs:.exe.exports] cmp si,0 je errornoexports xor edx,edx - call [cs:print],offset rets + invoke print, rets showallexports: push fs push si - call [cs:print],offset functions + invoke print, functions inc edx findnextexports: inc si - cmp [byte ptr fs:si],0 + cmp byte [fs:si],0 jne findnextexports add si,3 - cmp [dword ptr fs:si],0 + cmp dword [fs:si],0 je finishexports jmp showallexports finishexports: push edx - call [cs:print],offset allexports + invoke print, allexports ret errornoexports: - call [cs:print],offset errornoexport + invoke print, errornoexport ret allexports db '\c02\lIl y avait %u exportations dans le bloc ou fichier\l\c07',0 @@ -653,54 +682,57 @@ errornoexport db '\c02Aucune exportation dans le bloc ou fichier\l\c07',0 code_imports: - call [cs:gettypeditem],di,0,' ' - call [cs:mbfind],di + invoke gettypeditem,di,0,' ' + invoke mbfind,di jc notmbfindsimports jmp haveatargetimports notmbfindsimports: - call [cs:searchfile],di + invoke searchfile,di jc notmbfindall - call [cs:projfile],di + invoke projfile,di jc notmbfindall - call [cs:mbfind],di + invoke mbfind,di jc notmbfindall haveatargetimports: mov fs,ax - cmp [word ptr fs:0x0],'EC' + cmp word [fs:0x0],'EC' jne errornotace2 - mov si,[fs:exe.imports] + virtual at 0 + .exe exe + end virtual + mov si,[fs:.exe.imports] cmp si,0 je errornoimports xor edx,edx - call [cs:print],offset rets + invoke print, rets showallimports: push fs push si - call [cs:print],offset functions + invoke print, functions inc edx findnextimports: inc si - cmp [byte ptr fs:si],0 + cmp byte [fs:si],0 jne findnextimports add si,5 - cmp [dword ptr fs:si],0 + cmp dword [fs:si],0 je finishimports jmp showallimports finishimports: push edx - call [cs:print],offset allimports + invoke print, allimports ret errornoimports: - call [cs:print],offset errornoimport + invoke print, errornoimport ret notmbfindall: - call [cs:print],offset errornotmborfilefind + invoke print, errornotmborfilefind ret errornotace2: - call [cs:print],offset errornotcefind + invoke print, errornotcefind ret functions db '%0P\l',0 @@ -711,63 +743,63 @@ errornotcefind db '\c04Le bloc ou le fichier sp errornotmborfilefind db '\c04Impossible de trouver le bloc ou le fichier specifie\l\c07',0 code_regs: -call [cs:savecontext],offset allregs +invoke savecontext, allregs push 6 push eax push eax -mov ax,[word ptr allregs.sss] +mov ax,word [allregs.sss] push 6 push eax push eax -mov ax,[word ptr allregs.sgs] +mov ax,word [allregs.sgs] push 6 push eax push eax -mov ax,[word ptr allregs.sfs] +mov ax,word [allregs.sfs] push 6 push eax push eax -mov ax,[word ptr allregs.ses] +mov ax,word [allregs.ses] push 6 push eax push eax -mov ax,[word ptr allregs.sds] +mov ax,word [allregs.sds] push 6 push eax push eax -mov ax,[word ptr allregs.scs] +mov ax,word [allregs.scs] xor eax,eax push 10 -pushd [dword ptr allregs.seip] -pushd [dword ptr allregs.seip] +pushd dword [allregs.seip] +pushd dword [allregs.seip] push 10 -pushd [dword ptr allregs.sesp] -pushd [dword ptr allregs.sesp] +pushd dword [allregs.sesp] +pushd dword [allregs.sesp] push 10 -pushd [dword ptr allregs.sebp] -pushd [dword ptr allregs.sebp] +pushd dword [allregs.sebp] +pushd dword [allregs.sebp] push 10 -pushd [dword ptr allregs.sedi] -pushd [dword ptr allregs.sedi] +pushd dword [allregs.sedi] +pushd dword [allregs.sedi] push 10 -pushd [dword ptr allregs.sesi] -pushd [dword ptr allregs.sesi] +pushd dword [allregs.sesi] +pushd dword [allregs.sesi] push 10 -pushd [dword ptr allregs.sedx] -pushd [dword ptr allregs.sedx] +pushd dword [allregs.sedx] +pushd dword [allregs.sedx] push 10 -pushd [dword ptr allregs.secx] -pushd [dword ptr allregs.secx] +pushd dword [allregs.secx] +pushd dword [allregs.secx] push 10 -pushd [dword ptr allregs.sebx] -pushd [dword ptr allregs.sebx] +pushd dword [allregs.sebx] +pushd dword [allregs.sebx] push 10 -pushd [dword ptr allregs.seax] -pushd [dword ptr allregs.seax] +pushd dword [allregs.seax] +pushd dword [allregs.seax] push 10 -pushd [dword ptr allregs.seflags] -pushd [dword ptr allregs.seflags] -call [cs:print],offset registershow +pushd dword [allregs.seflags] +pushd dword [allregs.seflags] +invoke print, registershow ret registershow db '\l\c02Liste des registres du Microprocesseur\l\l\c07' @@ -790,68 +822,83 @@ registershow db '\l\c02Liste des registres du Microprocesseur\l\l\c07' db 'SS : 0x%hW : %w |\h32\l',0 -allregs regs <> +allregs regs code_irqs: -call [cs:mbfind],offset interruptionbloc +invoke mbfind, interruptionbloc jc erroronint -call [cs:print],offset irqmsg1 +invoke print, irqmsg1 mov es,ax xor ebx,ebx intoirq: xor eax,eax -mov al,[bx+offset irqmap] -mov dx,size ints +mov al,[bx+ irqmap] +virtual at 0 +.intsori ints +end virtual +mov dx,.intsori.sizeof mul dx mov si,ax -pushd [dword ptr es:(ints si).vector1.data.off] -pushd [dword ptr es:(ints si).vector1.data.seg] -call [cs:isrequestirq],bx +virtual at si +.ints ints +end virtual +pushd dword [es:.ints.vector1.data.off] +pushd dword [es:.ints.vector1.data.seg] +invoke isrequestirq,bx jc requested push ' ' jmp suiterequested requested: push 'X' suiterequested: -call [cs:isinserviceirq],bx +invoke isinserviceirq,bx jc inservice push ' ' jmp suiteinservice inservice: push 'X' suiteinservice: -call [cs:isenableirq],bx +invoke isenableirq,bx jc activatemat push ' ' jmp suiteactivatemat activatemat: push 'X' suiteactivatemat: -cmp [es:(ints si).activated],1 +virtual at si +.ints ints +end virtual +cmp [es:.ints.activated],1 je activate2 push ' ' jmp suiteactivate2 activate2: push 'X' suiteactivate2: -cmp [es:(ints si).locked],1 +virtual at si +.ints ints +end virtual +cmp [es:.ints.locked],1 je verrouille2 push ' ' jmp suiteverrouille2 verrouille2: push 'X' suiteverrouille2: -pushd [dword ptr es:(ints si).calledlow] -pushd [dword ptr es:(ints si).calledhigh] -pushd [dword ptr es:(ints si).launchedlow] -pushd [dword ptr es:(ints si).launchedhigh] +virtual at si +.ints ints +end virtual +pushd dword [es:.ints.calledlow] +pushd dword [es:.ints.calledhigh] +pushd dword [es:.ints.launchedlow] +pushd dword [es:.ints.launchedhigh] push 3 xor eax,eax -mov al,[bx+offset irqmap] +mov al,[bx+ irqmap] push eax push 3 push ebx -call [cs:print],offset irqmsg2 +invoke print, irqmsg2 inc bl cmp bl,16 jb intoirq @@ -864,57 +911,66 @@ irqmsg1 db '\l\c02Listes des IRQs\c07\l\l' irqmsg2 db '%w | %w | 0x%hW%hD | 0x%hW%hD | %c | %c | %c | %c | %c | 0x%hW:0x%hW\l',0 code_int: -call [cs:mbfind],offset interruptionbloc +invoke mbfind, interruptionbloc jc erroronint mov es,ax -call [cs:gettypeditem],di,0,' ' +invoke gettypeditem,di,0,' ' xor edi,edi mov di,ax -mov cx,size ints +virtual at 0 +.intsori ints +end virtual +mov cx,.intsori.sizeof mul cx mov si,ax -pushd [dword ptr es:(ints si).vector8.data.off] -pushd [dword ptr es:(ints si).vector8.data.seg] -pushd [dword ptr es:(ints si).vector7.data.off] -pushd [dword ptr es:(ints si).vector7.data.seg] -pushd [dword ptr es:(ints si).vector6.data.off] -pushd [dword ptr es:(ints si).vector6.data.seg] -pushd [dword ptr es:(ints si).vector5.data.off] -pushd [dword ptr es:(ints si).vector5.data.seg] -pushd [dword ptr es:(ints si).vector4.data.off] -pushd [dword ptr es:(ints si).vector4.data.seg] -pushd [dword ptr es:(ints si).vector3.data.off] -pushd [dword ptr es:(ints si).vector3.data.seg] -pushd [dword ptr es:(ints si).vector2.data.off] -pushd [dword ptr es:(ints si).vector2.data.seg] -pushd [dword ptr es:(ints si).vector1.data.off] -pushd [dword ptr es:(ints si).vector1.data.seg] -pushd [dword ptr es:(ints si).calledlow] -pushd [dword ptr es:(ints si).calledhigh] -pushd [dword ptr es:(ints si).launchedlow] -pushd [dword ptr es:(ints si).launchedhigh] -cmp [es:(ints si).activated],1 +virtual at si +.ints ints +end virtual +pushd dword [es:.ints.vector8.data.off] +pushd dword [es:.ints.vector8.data.seg] +pushd dword [es:.ints.vector7.data.off] +pushd dword [es:.ints.vector7.data.seg] +pushd dword [es:.ints.vector6.data.off] +pushd dword [es:.ints.vector6.data.seg] +pushd dword [es:.ints.vector5.data.off] +pushd dword [es:.ints.vector5.data.seg] +pushd dword [es:.ints.vector4.data.off] +pushd dword [es:.ints.vector4.data.seg] +pushd dword [es:.ints.vector3.data.off] +pushd dword [es:.ints.vector3.data.seg] +pushd dword [es:.ints.vector2.data.off] +pushd dword [es:.ints.vector2.data.seg] +pushd dword [es:.ints.vector1.data.off] +pushd dword [es:.ints.vector1.data.seg] +pushd dword [es:.ints.calledlow] +pushd dword [es:.ints.calledhigh] +pushd dword [es:.ints.launchedlow] +pushd dword [es:.ints.launchedhigh] +cmp [es:.ints.activated],1 je activate -push offset oui +push oui jmp suiteactivate activate: -push offset non +push non suiteactivate: -cmp [es:(ints si).locked],1 +virtual at si +.ints ints +end virtual +cmp [es:.ints.locked],1 je verrouille -push offset oui +push oui jmp suiteverrouille verrouille: -push offset non +push non suiteverrouille: push esi push es push es push edi -call [cs:print],offset infosint +invoke print, infosint ret erroronint: - call [cs:print],offset errorint + invoke print,errorint okint: ret @@ -937,18 +993,18 @@ infosint db '\c07Le bloc d''interruption est charge en memoire et le gestionnair db 'Vecteur 8 : 0x%hW:0x%hW\l\c07',0 code_refresh: - call [cs:initdrive] + invoke initdrive jnc okrefresh - call [cs:print],offset errorrefreshing + invoke print,errorrefreshing ret okrefresh: - call [cs:getserial] + invoke getserial push eax - mov si,offset nomdisque - call [cs:getname],si + mov si,nomdisque + invoke getname,si push si - push offset present - call [cs:print] + push present + invoke print ret errorrefreshing db '\c04Impossible de lire le support',0 @@ -956,63 +1012,75 @@ extcom db '.CE',0 code_mem: - call [cs:print],offset msg + invoke print, msg xor edx,edx xor ebx,ebx xor cx,cx listmcb: - call [cs:mbget],cx + invoke mbget,cx jc fino mov fs,ax dec ax dec ax mov gs,ax inc cx - cmp [word ptr fs:0x0],'EC' + cmp word [fs:0x0],'EC' jne notace - push offset oui ;CE? str0 2 + push oui ;CE? str0 2 jmp suitelikeace notace: - push offset non + push non suitelikeace: mov dx,fs push edx ;Emplacement memoire hex 2 ;parent - cmp [gs:mb.reference],0 + virtual at 0 + .mb mb + end virtual + cmp [gs:.mb.reference],0 jne nextdetect push cs - push offset none ;parent lstr0 2x2 - add bx,[gs:mb.sizes] + push none ;parent lstr0 2x2 + add bx,[gs:.mb.sizes] jmp suitemn nextdetect: - mov dx,[gs:mb.reference] + virtual at 0 + .mb mb + end virtual + mov dx,[gs:.mb.reference] dec dx dec dx push dx ;parent lstr0 2x2 - push offset (mb).names + push .mb.names suitemn: - cmp [gs: mb.isresident],true + virtual at 0 + .mb mb + end virtual + cmp [gs: .mb.isresident],true jne notresident - push offset oui ;resident str0 2 + push oui ;resident str0 2 jmp suitelistmcb notresident: - push offset non ;resident str0 2 + push non ;resident str0 2 suitelistmcb: xor edx,edx - mov dx,[gs: mb.sizes] + virtual at 0 + .mb mb + end virtual + mov dx,[gs: .mb.sizes] shl edx,4 push 6 ;decimal 4 + type 2 push edx push gs ;nom lstr0 2x2 - push offset (mb).names - push offset line2 ;ligne - call [cs:print] + push .mb.names + push line2 ;ligne + invoke print jmp listmcb fino: shl ebx,4 push ebx - push offset fin - call [cs:print] + push fin + invoke print ret oui db "oui",0 non db "non",0 @@ -1025,7 +1093,7 @@ none db "?????",0 ;converti le jeux scancode/ascii en fr ax->ax convertfr: push dx si - mov si,offset fr + mov si, fr searchtouch: mov dx,[cs: si] cmp dx,0 diff --git a/programs/editeur.asm b/programs/editeur.asm index 89ad446..8d5b546 100644 --- a/programs/editeur.asm +++ b/programs/editeur.asm @@ -1,10 +1,3 @@ -model tiny,stdcall -p586N -locals -jumps -codeseg -option procalign:byte - include "..\include\mem.h" include "..\include\divers.h" include "..\include\graphic.h" @@ -12,20 +5,20 @@ include "..\include\graphic.h" org 0h start: -header exe <"CE",1,0,0,,offset imports,,offset realstart> +header exe 1 realstart: mov ax,0305h mov bx,0008h int 16h -call [savestate] -call [setvideomode],2 +invoke savestate +invoke setvideomode,2 xor ebp,ebp xor ax,ax mov fs,ax -call [disablescroll] +invoke disablescroll adres: -call [saveparamto],offset infos +invoke saveparamto, infos mov al,[infos.lines] dec al mov [lastline],al @@ -36,13 +29,13 @@ shr al,2 mov [sizex],al and bl,11b mov [sizex2],bl -mov al,[infos.mode] +mov al,[infos.modenum] cmp al,[oldmode] je noinit -call [clearscreen] +invoke clearscreen mov [oldmode],al noinit: -call [setxy],0,0 +invoke setxy,0,0 mov edi,ebp mov bh,[lastline] lines: @@ -53,8 +46,8 @@ mov edx,edi shr edx,4*4 shl edx,4*3 push edx -push offset spaces -call [print] +push spaces +invoke print mov dx,di mov al,[sizex] mov esi,edi @@ -63,24 +56,24 @@ mov edx,edi shr edx,4*4 shl edx,4*3 mov fs,dx -push [dword ptr fs:di] +push dword [fs:di] push 8 -call [showhex] -call [showchar],' ' +invoke showhex +invoke showchar,' ' inc edi dec al jnz doaline mov edi,esi -push offset spaces2 -call [print] +push spaces2 +invoke print mov al,[sizex] doaline2: mov edx,edi shr edx,4*4 shl edx,4*3 mov fs,dx -push [word ptr fs:di] -call [showchar] +push word [fs:di] +invoke showchar inc edi dec al jnz doaline2 @@ -88,11 +81,11 @@ dec bh je outes cmp [sizex2],0 je lines -call [addline] +invoke addline jmp lines outes: -call [setxy],0,[word ptr lastline] -call [print],offset menu +invoke setxy,0,word [lastline] +invoke print, menu waitkey: mov ax,0 int 16h @@ -128,9 +121,9 @@ jmp adres suit6: cmp ax,4100h jne suit7 -mov [dword ptr pope],'TIDE' -call [setxy],0,[word ptr lastline] -call [print],offset menu +mov dword [pope],'TIDE' +invoke setxy,0,word [lastline] +invoke print, menu mov ax,0B800h mov es,ax mov [xxyy2],3 @@ -142,7 +135,7 @@ mov ax,0 int 16h cmp ah,41h jne tre -mov [dword ptr pope],' EUV' +mov dword [pope],' EUV' push cs pop es jmp adres @@ -187,7 +180,7 @@ call calc1 call calc2 mov edi,[es:bx-1] mov dx,[es:si-1] -mov [byte ptr es:bx],0112 +mov byte [es:bx],0112 mov [es:bx-1],al writs: mov ax,0 @@ -209,12 +202,12 @@ mov cl,[gs:bx] cmp ch,cl je no push si ax -call [setxy],0,[word ptr lastline] -call [print],offset msg +invoke setxy,0,word [lastline] +invoke print, msg mov ax,0 int 16h -call [setxy],0,[word ptr lastline] -call [print],offset menu +invoke setxy,0,word [lastline] +invoke print, menu pop bx si mov [es:bx-1],edi mov [es:si-1],dx @@ -235,7 +228,7 @@ jmp waitst suit7: cmp ax,4200h jne adres -call [restorestate] +invoke restorestate retf calc1: push ax dx si @@ -251,11 +244,11 @@ shl bx,5 shl dx,7 add bx,dx add bx,ax -mov [byte ptr es:bx],112 -mov [byte ptr es:bx+2],112 +mov byte [es:bx],112 +mov byte [es:bx+2],112 mov si,[xxyy] -mov [byte ptr es:si],07 -mov [byte ptr es:si+2],07 +mov byte [es:si],07 +mov byte [es:si+2],07 mov [xxyy],bx pop si dx ax ret @@ -270,9 +263,9 @@ mov dx,[xx] shl dx,1 add si,dx add si,129 -mov [byte ptr es:si],112 +mov byte [es:si],112 mov bx,[xxyy2] -mov [byte ptr es:bx],07 +mov byte [es:bx],07 mov [xxyy2],si pop dx bx ax ret @@ -330,7 +323,7 @@ spaces2 db '\c04 | \c07',0 showbuffer db 35 dup (0FFh) oldmode db 0 -infos vgainf <> +infos vgainf importing use VIDEO,setvideomode @@ -346,10 +339,3 @@ use VIDEO.LIB,showhex use VIDEO.LIB,showchar endi - - - - - - - diff --git a/programs/exem-ce.asm b/programs/exem.asm similarity index 51% rename from programs/exem-ce.asm rename to programs/exem.asm index 867d0d7..82a5c6b 100644 --- a/programs/exem-ce.asm +++ b/programs/exem.asm @@ -1,9 +1,3 @@ -model tiny,stdcall -p586N -locals -jumps -codeseg -option procalign:byte include "..\include\mem.h" include "..\include\divers.h" @@ -11,16 +5,16 @@ include "..\include\divers.h" org 0h start: -header exe <"CE",1,0,0,,offset imports,,offset realstart> +header exe 1 realstart: - call [print],offset message - call [waitkey] + invoke print,message + invoke waitkey retf message db 'Appel de la librairie \c02video\c07 et de la librairie \c02EXEM-LIB.LIB\c07 !',0 importing use VIDEO.LIB,print -use EXEM-LIB.LIB,waitkey +use LIB.LIB,waitkey endi diff --git a/programs/gestion.asm b/programs/gestion.asm index 95de6ed..c86b942 100644 --- a/programs/gestion.asm +++ b/programs/gestion.asm @@ -1,10 +1,3 @@ -model tiny,stdcall -p586N -locals -jumps -codeseg -option procalign:byte - include "..\include\mem.h" include "..\include\fat.h" include "..\include\divers.h" @@ -13,35 +6,35 @@ include "..\include\graphic.h" org 0h start: -header exe <"CE",1,0,0,,offset imports,,offset realstart> +header exe 1 realstart: - call [saveparamto],offset infos - call [print],offset msg1 - call [initdrive] + invoke saveparamto, infos + invoke print, msg1 + invoke initdrive xor bp,bp - call [findfirstfile],offset bufferentry + invoke findfirstfile, bufferentry jc nofiles go: - push [word bufferentry.result.fileattr] + push word [bufferentry.result.fileattr] push [bufferentry.result.filesize] push [bufferentry.result.filetime] push [bufferentry.result.filedate] push [bufferentry.result.filetimecrea] push [bufferentry.result.filedatecrea] - mov bx,offset bufferentry.result.filename + mov bx,bufferentry.result.filename push bx - push offset line - call [print] + push line + invoke print - call [findnextfile],offset bufferentry + invoke findnextfile, bufferentry jc nofiles inc bp jmp go nofiles: - call [print],offset menu + invoke print, menu mov [xx],1 - call changelineattr,[xx],112 + stdcall changelineattr,[xx],112 endof: mov ax,0 int 16h @@ -49,18 +42,18 @@ endof: jne tre1 cmp [xx],bp ja endof - call changelineattr,[xx],7 + stdcall changelineattr,[xx],7 inc [xx] - call changelineattr,[xx],112 + stdcall changelineattr,[xx],112 jmp endof tre1: cmp ah,48h jne tre2 cmp [xx],1 je endof - call changelineattr,[xx],7 + stdcall changelineattr,[xx],7 dec [xx] - call changelineattr,[xx],112 + stdcall changelineattr,[xx],112 jmp endof tre2: cmp al,0Dh @@ -75,26 +68,24 @@ tre4: retf ;couleur al pour ligne %0 en %1 -PROC changelineattr near -USES ax,bx,di,es -ARG @line:word,@attr:word +proc changelineattr uses ax bx di es,line:word,attr:word mov ax,0B800h mov es,ax -mov ax,[@line] +mov ax,[line] add ax,3 mul [cs:infos.columns] mov di,ax shl di,1 mov al,[cs:infos.columns] inc di -mov bx,[@attr] -@@popep: +mov bx,[attr] +popep: mov [es:di],bl add di,2 dec al -jnz @@popep -ret -endp changelineattr +jnz popep +retf +endp xx dw 1 xxold dw 0 @@ -104,8 +95,8 @@ msg1 db '\e\g00,00\c70 Gestionnaire de fichier Version 1.5 db '\g00,02Nom Ext. Date creation Date modification Taille Attributs' db '\g00,03-------------------------------------------------------------------------------\l',0 line db '\c07%n %d %t %d %t %z %a\l',0 -bufferentry find <> -infos vgainf <> +bufferentry find +infos vgainf importing use VIDEO.LIB,print diff --git a/programs/isa.asm b/programs/isa.asm index f3e7e9c..ac8929c 100644 --- a/programs/isa.asm +++ b/programs/isa.asm @@ -1,17 +1,10 @@ -model tiny,stdcall -p586N -locals -jumps -codeseg -option procalign:byte - include "..\include\mem.h" include "..\include\divers.h" org 0h start: -header exe <"CE",1,0,0,,,,offset realstart> +header exe 1 realstart: retf diff --git a/programs/logo.asm b/programs/logo.asm index 5e5a0da..e11a447 100644 --- a/programs/logo.asm +++ b/programs/logo.asm @@ -1,69 +1,62 @@ -model tiny,stdcall -p586N -locals -jumps -codeseg -option procalign:byte - include "..\include\mem.h" include "..\include\divers.h" org 0h start: -header exe <"CE",1,0,0,,offset imports,,offset realstart> +header exe 1 realstart: - call [cs:mballoc],65535 + invoke mballoc,65535 jc problem3 push ax pop es - call [cs:projfile],offset logo + invoke projfile,logo jc problem mov ecx,eax - call [cs:mbfind],offset logo + invoke mbfind,logo jc problem - call [cs:decompressrle],ax,0,es,0,cx + invoke decompressrle,ax,0,es,0,cx jc problem2 push es pop ds - call [cs:savestate] - call [cs:setvideomode],word 8 - call [cs:clearscreen] - call [cs:loadbmppalet],word 0 - call [cs:showbmp],word 0,word 20,word 150 + invoke savestate + invoke setvideomode,word 8 + invoke clearscreen + invoke loadbmppalet,word 0 + invoke showbmp,word 0,word 20,word 150 jc problem4 push cs pop ds - call [cs:print],offset poper + invoke print,poper endofit: xor ax,ax int 16h - call [cs:restorestate] + invoke restorestate retf problem: push cs pop ds - call [cs:print],offset error + invoke print, error jmp endofit problem2: push cs pop ds - call [cs:print],offset error2 + invoke print, error2 jmp endofit problem3: push cs pop ds - call [cs:print],offset error3 + invoke print, error3 jmp endofit problem4: push cs pop ds - call [cs:print],offset error4 + invoke print, error4 jmp endofit poper db '\c0BC\c0CO\c0DS\c0E2\c0E0\c0E0\c0F0 en mode graphique',0 diff --git a/programs/lpt/com.asm b/programs/lpt/com.asm deleted file mode 100644 index 4c83399..0000000 --- a/programs/lpt/com.asm +++ /dev/null @@ -1,471 +0,0 @@ -.model tiny -.486 -smart -.code -org 0100h -start: -;call setemettor -call getfirstlpt -call initlpt -call receivecommand -ret - - - -gogo db 'Salut' -gotoz db 23 dup (0) - -;Re‡ois une commande et l'execute -Receivecommand: -push ax bx cx di es -push cs -pop es -mov di,offset command -call receivelptblock -mov bl,al -xor bh,bh -shl bx,1 -add bx,offset cmd -call [bx] -pop es di cx ax -ret -command db 25 dup (0) -cmd dw nothings - dw sendram - -nothings: -ret - -Sendram: -push ax cx si ds -mov ax,es:[di] -mov si,ax -mov ax,es:[di+2] -mov ds,ax -mov cx,es:[di+2] -call sendlptblock -pop ds si cx ax -ret - - -;---------Segment Adress----------- -Bios equ 040h -;---------Offset Adress------------ -Lptadr equ 008h -Timer equ 06Ch -;---------Constant----------------- -onesec equ 18 -tensec equ 182 -Ack equ 00 -Nack equ 0FFh -maxtry equ 10 -tokenstart equ 0 -tokennext equ 1 -tokenstop equ 2 -tokenbad equ 3 -tokenresend equ 4 - - -Initlpt: -push ax ecx -call StartTimer -cmp emettor,0 -je receptinit -mov al,10000b -call SetLptOut -waitinit1: -call EndTimer -cmp cx,cs:timeout -ja errorinit -call getlptIn -cmp al,00000b -jnz waitinit1 -jmp endinit -receptinit: -call EndTimer -cmp cx,cs:timeout -ja errorinit -call getlptIn -cmp al,00000b -jnz receptinit -mov al,10000b -call SetLptOut -endinit: -clc -pop ecx ax -ret -errorinit: -stc -pop ecx ax -ret - - -;-Envoie DL (dh) JNE si problŠme JNC error timeout -Sendlpt: -push ax bx ecx -call StartTimer -mov dh,dl -mov al,dl -and al,0Fh -call SetLptOut -waitSend: -call EndTimer -cmp cx,cs:timeout -ja errorsend -call getlptIn -bt ax,4 -jnc waitsend -and al,0Fh -mov bl,al -call StartTimer ;///// -mov al,dh -shr al,4 -or al,10000b -call SetLptOut -waitSend2: -call EndTimer -cmp cx,cs:timeout -ja errorsend -call getlptIn -bt ax,4 -jc waitsend2 -and al,0Fh -shl al,4 -add bl,al -cmp dl,bl -pop ecx bx ax -clc -ret -errorsend: -pop ecx bx ax -stc -ret - - -;-Re‡ois DL (dh) -Receivelpt: -push ax bx ecx -call StartTimer -waitreceive: -call EndTimer -cmp cx,cs:timeout -ja errorreceive -call getlptIn -bt ax,4 -jnc waitreceive -and al,0Fh -mov dl,al -call SetLptOut -call StartTimer ;///// -waitreceive2: -call EndTimer -cmp cx,cs:timeout -ja errorreceive -call getlptIn -bt ax,4 -jc waitreceive2 -and al,0Fh -mov dh,al -shl dh,4 -add dl,dh -or al,10000b -call SetlptOut -clc -pop ecx bx ax -ret -errorreceive: -stc -pop ecx bx ax -ret - -;-AX -SetTimeout: -mov cs:Timeout,ax -ret - -timeout dw tensec - -getTimeout: -mov ax,cs:Timeout -ret - -SetEmettor: -mov cs:Emettor,1 -ret - -Emettor db 0 - -SetReceptor: -mov cs:Emettor,0 -ret - -;->bx Nøport->Adresse dx -GetLpt: -push ax bx ds -mov ax,bios -mov ds,ax -dec bx -shl bx,1 -mov dx,ds:[Lptadr+bx] -mov cs:lpt,dx -pop ds bx ax -ret -lpt dw 0 - -;->bx Nøport->Adresse dx -GetFirstLpt: -push ax ds -mov ax,bios -mov ds,ax -xor bx,bx -findlpt: -mov dx,ds:[Lptadr+bx] -cmp dx,0 -jne oklpt -add bx,2 -cmp bx,4 -jbe findlpt -oklpt: -mov cs:lpt,dx -pop ds ax -ret - -;-> -StartTimer: -push ax ecx ds -mov ax,Bios -mov ds,ax -mov ecx,ds:[timer] -mov times,ecx -pop ds ecx ax -ret -times dd 0 - -;->Ecx time elapsed -EndTimer: -push ax ds -mov ax,Bios -mov ds,ax -mov ecx,ds:[timer] -sub ecx,times -mov ecx,0 -pop ds ax -ret - -;-> -GetLptOut: -push dx -mov dx,lpt -in al,dx -pop dx -ret - -GetLptIn: -push dx -mov dx,lpt -inc dx -in al,dx -shr al,3 -pop dx -ret - -GetLptInOut: -push dx -mov dx,lpt -add dx,2 -in al,dx -and al,11111b -pop dx -ret - -SetLptOut: -push dx -mov dx,lpt -out dx,al -pop dx -ret - -SetLptIn: -push dx -mov dx,lpt -inc dx -out dx,al -pop dx -ret - -SetLptInOut: -push dx -mov dx,lpt -add dx,2 -out dx,al -pop dx -ret - -;R‚alise un checksum 8 bits sur donn‚es DS:SI, nb CX r‚sultat dans dl -Checksum8: -push cx si -check: -add dl,[si] -inc si -dec cx -jnz check -pop si cx -ret - -;DS:SI pointeur sur donn‚es, CX nombres de donn‚es, AL token -SendLptBlock: -push ax bx cx edx si edi bp -mov dx,cx -shl edx,16 -mov dh,al -call checksum8 -mov edi,edx -xor dh,dh -mov bp,dx -mov ah,maxtry -retry: -mov bl,4 -xor al,al -header: -mov dx,di -call sendlpt -setne al -jc outt -rol edi,8 -dec bl -jnz header -cmp al,0 -jne notgood -mov dl,ACK -jmp allsend -notgood: -mov dl,NACK -allsend: -call sendlpt -setne al -jc outt -cmp al,0 -je okheader -dec ah -jnz retry -jmp outt -okheader: -cmp cx,0 -je endoftrans -mov di,maxtry -retry2: -mov bx,cx -xor ax,ax -body: -mov dl,[si+bx-1] -add ah,dl -call sendlpt -setne al -jc outt -dec bx -jnz body -cmp al,0 -jne notgood2 -mov dl,ACK -jmp allisend -notgood2: -mov dl,NACK -allisend: -call sendlpt -setne al -jc outt -cmp al,0 -je endoftrans -dec di -jnz retry2 -outt: -stc -endoftrans: -mov al,ah -xor ah,ah -cmp bp,ax -pop bp edi si edx cx bx ax -ret - -;Receptionne en es:di les donn‚es au nombres de CX token AL (AH) (ECX) -receiveLptBlock: -push ax bx dx si bp -mov ah,maxtry -retrye: -mov bl,4 -headere: -call receivelpt -jc outte -mov cl,dl -rol ecx,8 -dec bl -jnz headere -call receivelpt -jc outte -cmp dl,ACK -je okheadere -dec ah -jnz retrye -jmp outte -okheadere: -mov al,ch -xor ch,ch -mov bp,cx -rol ecx,16 -cmp cx,0 -je endoftranse -mov si,maxtry -retrye2: -mov bx,cx -xor ah,ah -bodye: -call receivelpt -jc outte -mov es:[di+bx-1],dl -add ah,dl -dec bx -jnz bodye -call receivelpt -jc outte -cmp dl,ACK -je endoftranse -dec si -jnz retrye2 -outte: -stc -endoftranse: -mov bl,ah -xor bh,bh -cmp bp,bx -pop bp si dx bx ax -ret - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -end start; diff --git a/programs/lpt/project1.dpr b/programs/lpt/project1.dpr deleted file mode 100644 index a771b7e..0000000 --- a/programs/lpt/project1.dpr +++ /dev/null @@ -1,12 +0,0 @@ -program Project1; - -uses - Forms, - Unit1 in 'UNIT1.PAS' {Form1}; - -{$R *.RES} - -begin - Application.CreateForm(TForm1, Form1); - Application.Run; -end. diff --git a/programs/lpt/project1.opt b/programs/lpt/project1.opt deleted file mode 100644 index 8ebc76c..0000000 --- a/programs/lpt/project1.opt +++ /dev/null @@ -1,34 +0,0 @@ -[Compiler] -A=1 -B=0 -D=1 -F=0 -I=1 -K=1 -L=1 -P=1 -Q=0 -R=0 -S=1 -T=0 -U=1 -V=1 -W=0 -X=1 -Y=1 - -[Linker] -MapFile=0 -LinkBuffer=0 -DebugInfo=0 -OptimizeExe=0 -StackSize=16384 -HeapSize=8192 - -[Directories] -OutputDir= -SearchPath= -Conditionals= - -[Parameters] -RunParams= diff --git a/programs/lpt/project1.res b/programs/lpt/project1.res deleted file mode 100644 index ab74376341da27109e2591593a13aa146d4417ea..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 794 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 diff --git a/programs/lpt/unit1.pas b/programs/lpt/unit1.pas deleted file mode 100644 index d3a6687..0000000 --- a/programs/lpt/unit1.pas +++ /dev/null @@ -1,517 +0,0 @@ -unit Unit1; - -interface - -uses - SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, - Forms, Dialogs, StdCtrls, Grids, Outline, DirOutln, FileCtrl, Buttons, - Gauges, ExtCtrls, Spin, Mask; - -type - TForm1 = class(TForm) - DriveComboBox1: TDriveComboBox; - FilterComboBox1: TFilterComboBox; - FileListBox1: TFileListBox; - DirectoryListBox1: TDirectoryListBox; - SpeedButton1: TSpeedButton; - SpeedButton2: TSpeedButton; - Memo1: TMemo; - Memo2: TMemo; - Memo3: TMemo; - SpeedButton3: TSpeedButton; - SpeedButton4: TSpeedButton; - Gauge1: TGauge; - SpeedButton5: TSpeedButton; - SpeedButton6: TSpeedButton; - SpinButton1: TSpinButton; - MaskEdit1: TMaskEdit; - SpeedButton8: TSpeedButton; - SpinButton2: TSpinButton; - okm: TCheckBox; - Label1: TLabel; - procedure FormActivate(Sender: TObject); - procedure SpinButton1DownClick(Sender: TObject); - procedure SpinButton1UpClick(Sender: TObject); - procedure showadress(Sender: TObject); - procedure SpeedButton6Click(Sender: TObject); - procedure SpeedButton8Click(Sender: TObject); - procedure MaskEdit1Change(Sender: TObject); - procedure SpinButton2DownClick(Sender: TObject); - procedure SpinButton2UpClick(Sender: TObject); - procedure SpeedButton3Click(Sender: TObject); - procedure Memo2Click(Sender: TObject); - - private - { Private-déclarations } - public - { Public-déclarations } - end; - -const UNESEC = 1000; - DIXSEC = 4000; - ACK = $00; - NAK = $FF; - MAXTRY = 5; - -type DBloc = array[ 1..15534 ] of byte; -type BHEADER = record - case boolean of - true : ( Checksum:byte; - Lenb : byte; - Lenh : byte; - Token : byte; - - ); - false : ( Champ : array[ 0..3 ] of byte ); - end; - -var - Form1: TForm1; - Inlpt : word; - Outlpt : word; - times : longint; - Block : DBLOC; - adress :longint; - errors: boolean; - reste:integer; - pop:boolean; - -implementation - -{$R *.DFM} - -function Getlpt( Number : integer ) : boolean; -begin - Outlpt := MemW[ $0040: 6 + Number * 2 ]; - if ( Outlpt <> 0 ) then - begin - Inlpt := Outlpt + 1; - Getlpt := TRUE; - end - else - Getlpt := FALSE; -end; - -function getfirstlpt:byte; -var i:integer; -begin -i:=1; - while (not(getlpt(i)) or (i>4)) do inc(i); - if (getlpt(i)=false) then i:=0; - getfirstlpt:= i; -end; - -function getb:byte; -begin - getb:=port[inlpt] and $F8 -end; - -procedure putb(what:byte); -begin - port[outlpt]:=what; -end; - -procedure starttimer; -begin - times:=GetTickCount; -end; - -function endtimer:longint; -begin - endtimer:=getTickCount-times; -end; - -function Initlpt( Emetteur : boolean ) : boolean; -begin - errors:=false; - putb($10); - putb($18); - putb($10); - starttimer; - if ( Emetteur ) then - begin - while ( ( GetB <> $00 ) and ( Endtimer <= DIXSEC ) ) do; - end - else - begin - while ( ( GetB <> $00 ) and ( Endtimer <= DIXSEC ) ) do; - PutB( $10 ); - end; - Initlpt := ( Endtimer <= DIXSEC ); -end; - -function sendlpt( Wert : byte ) : boolean; -var Retour : byte; -label fin; -begin -if errors then goto fin; - Starttimer; - PutB( Wert and $0F ); - while ( ( ( GetB and 128 ) = 0 ) and ( Endtimer <= DIXSEC )) do; - if ( Endtimer > DIXSEC ) then - begin - errors:=true; - goto fin; - end; - Retour := ( GetB shr 3 ) and $0F; - Starttimer; - PutB( ( Wert shr 4 ) or $10 ); - while ( ( ( GetB and 128 ) <> 0 ) and ( Endtimer <= DIXSEC ) ) do - if ( Endtimer > DIXSEC ) then - begin - errors:=true; - goto fin; - end; - Retour := Retour or ( ( GetB shl 1 ) and $F0 ); - fin: - sendlpt := ( Wert = Retour ); -end; - -function receivelpt : byte; -var LoNib, - HiNib : byte; -label fin; -begin - if errors then goto fin; - Starttimer; - while ( ( ( GetB and 128 ) = 0 ) and ( Endtimer <= DIXSEC )) do; - if ( Endtimer > DIXSEC ) then - begin - errors:=true; - goto fin; - end; - LoNib := ( GetB shr 3 ) and $0F; - PutB( LoNib ); - Starttimer; - while ( ( ( GetB and 128 ) <> 0 ) and ( Endtimer <= DIXSEC ) ) do; - if ( Endtimer > DIXSEC ) then - begin - errors:=true; - goto fin; - end; - HiNib := ( GetB shl 1 ) and $F0; - PutB( ( HiNib shr 4 ) or $10 ); - fin: - receivelpt := ( LoNib or HiNib ); -end; - -function checksum8(Nombre:word;Dptr : pointer):byte ; -var donnees : ^DBloc ; - i:word; - ch:byte; -begin -ch:=0; -donnees:=dptr; - for i:=1 to Nombre do ch:=ch + Donnees^[ i ]; - checksum8:=ch; - end; - -function SendlptBlock( Token : byte; - Nombre : word; - Dptr : pointer ):boolean; -var header : BHEADER; - ok : boolean; - i : word; - trys : word; - Donnees : ^DBloc; - label fin; -begin - form1.gauge1.visible:=true; - header.Token := Token; - header.Lenb := (Nombre and $FF00) shr 8; - header.Lenh := Nombre and $FF; - header.Checksum:=checksum8(nombre,Dptr); - trys := MAXTRY; - repeat - ok := TRUE; - for i := 0 to 3 do - ok := ok and sendlpt( Header.Champ[ i ] ); - if ( ok ) then - ok := ok and sendlpt( ACK ) - else - ok := ok and sendlpt( NAK ); - if ( not ok ) then - dec( trys ); - until ( ( ok ) or ( trys = 0 ) or (errors)); - if ( (trys = 0) or (errors)) then - begin - goto fin; - SendlptBlock:=false; - end; - if ( Nombre > 0 ) then - begin - Donnees := DPTR; - trys := MAXTRY; - repeat - ok := TRUE; - for i := Nombre downto 1 do - begin - ok := ok and sendlpt( Donnees^[ i ] ); - reste:=trunc(100-i/nombre*100); - form1.gauge1.progress:=reste - end; - if ( ok ) then - ok := ok and sendlpt( ACK ) - else - ok := ok and sendlpt( NAK ); - if ( not ok ) then - dec( trys ); - until ( ( ok ) or ( trys = 0 ) or (errors)); - if ( (trys = 0) or (errors)) then - begin - goto fin; - SendlptBlock:=false; - end; - end; - SendlptBlock:=true; - fin: - form1.gauge1.visible:=false; -end; - -function ReceivelptBlock( var Token : byte; - var Len : word; - Dptr : pointer ):boolean; -var header : BHEADER; - ok : boolean; - i : word; - trys : word; - EscapeStatus : boolean; - ByteBuffer : byte; - Donnees : ^DBloc; - label fin,good; -begin - form1.gauge1.visible:=true; - trys := MAXTRY; - repeat - for i:= 0 to 3 do - Header.Champ[ i ] := receivelpt; - ByteBuffer := receivelpt; - if ( ByteBuffer <> ACK ) then - dec( trys ); - until ( ( trys = 0 ) or ( ByteBuffer = ACK ) or (errors)); - if ( (trys = 0) or (errors)) then - begin - goto fin; - receivelptblock:=false; - end; - Token := Header.Token; - Len := Header.Lenh+(Header.Lenb shl 8); - if ( Len > 0 ) then - begin - Donnees := Dptr; - trys := MAXTRY; - repeat - for i := len downto 1 do - begin - Donnees^[ i ] := receivelpt; - reste:=trunc(100-i/len*100); - form1.gauge1.progress:=reste - end; - ByteBuffer := receivelpt; - if ( ByteBuffer <> ACK ) then - dec( trys ); - until ( ( trys = 0 ) or ( ByteBuffer = ACK ) ); - if ( trys = 0 ) then - begin - goto fin; - receivelptblock:=false; - end; - end; - receivelptblock:=true; - fin: - form1.gauge1.visible:=false; -end; - - -function Sendfile(name:string):boolean; -var lus:word; -Fichier:file; -begin -assign( Fichier, Name ); -reset( Fichier, 1 ); -Blockread( Fichier, Block, 15000, Lus ); -if lus>0 then -Sendfile:=SendlptBlock( 1, Lus, @Block ) -else -Sendfile:=false; -end; - -procedure TForm1.FormActivate(Sender: TObject); -begin -adress:=0; -showadress(sender); -Memo2Click(Sender); -SpeedButton8Click(Sender); -pop:=true; -end; - -procedure TForm1.SpinButton1DownClick(Sender: TObject); -begin -if (adress>0) and okm.checked then -begin -dec(adress); -SpeedButton6Click(Sender); -end; -end; - -procedure TForm1.SpinButton1UpClick(Sender: TObject); -begin -if (adress<65536*16) and okm.checked then -begin -inc(adress); -SpeedButton6Click(Sender); -end; -end; - -function hextoint(hex:string;n:word):longint; -var -resu,exp:longint; -i:word; -begin - hex :=UpperCase(hex); - resu:=0; - exp:=1; - for i:=n downto 1 do - begin - resu:=resu+(Pos(hex[i],'0123456789ABCDEF')-1)*(exp); - exp:=exp*16 - end; - hextoint:=resu; - end ; - - function adresstoint(hex:string):longint; -begin -adresstoint:=hextoint(Copy(hex, 1, 4),4)shl 4 + hextoint(Copy(hex, length(hex)-3, 4),4) -end; - -procedure TForm1.showadress(Sender: TObject); -var i,j,adh,adl:word; -adress2:longint; -old,old2:string; -begin -memo1.clear; -memo2.clear; -memo3.clear; -for i:=0 to 29 do -begin -adress2:=adress+i*16; -adl:=adress2 and $FFFF; -adh:=(adress2 and $F0000) shr 4; -memo1.lines.add(IntToHex(adh,4)+':'+IntToHex(adl,4)) ; -old:=''; -old2:=''; -for j:=1 to 16 do -begin -old:=old+inttohex(block[i*16+j],2); -if block[i*16+j]=0 then -old2:=old2+'.' -else -old2:=old2+char(block[i*16+j]) ; -if j mod 2=0 then old:=old+' '; -end; -memo2.lines.add(old) ; -memo3.lines.add(old2) ; -end -end; - -procedure TForm1.SpeedButton8Click(Sender: TObject); -begin -if getfirstlpt=0 then showmessage('Pas de port parallèle détecté'); -errors:=false; -end; - -procedure TForm1.SpeedButton6Click(Sender: TObject); -var adl,adh,good:word; -tok:byte; -ok:boolean; -begin -if (inlpt=0) then SpeedButton8Click(sender); -if ((inlpt<>0) and (initlpt(true))) then -begin - adl:=adress and $FFFF; - adh:=(adress and $F0000) shr 4; -Block[1]:=lo(adl); -Block[2]:= hi(adl); -Block[3]:= lo(adh); -Block[4]:= hi(adh); -Block[5]:= lo(512); -Block[6]:= hi(512) ; -ok:=false; -if SendlptBlock( 1,6,@Block) then ok:=receivelptBlock(tok,good ,@Block); {demande de RAM} -if not(ok) or errors then Showmessage('Erreur de transmission !!!!!!!!!!'); -showadress(sender); -end -else -Showmessage('Pas de PC distant'); -putb($08); -errors:=false; -end; - -procedure TForm1.MaskEdit1Change(Sender: TObject); -begin -if pop then -begin -adress:=adresstoint(maskedit1.text); -if okm.checked=true then SpeedButton6Click(sender); -showadress(sender); -end; -end; - -procedure TForm1.SpinButton2DownClick(Sender: TObject); -begin - if (adress+16*30<=65536*16) and okm.checked then - begin - adress:=adress+16*30; -SpeedButton6Click(Sender); -end; -end; - -procedure TForm1.SpinButton2UpClick(Sender: TObject); -begin - if (adress-16*30>=0) and okm.checked then - begin - adress:=adress-16*30; -SpeedButton6Click(Sender); -end; -end; -procedure TForm1.SpeedButton3Click(Sender: TObject); -var adl,adh,good:word; -adress2:longint; -tok:byte; -ok:boolean; -begin -if (inlpt=0) then SpeedButton8Click(sender); -if ((inlpt<>0) and (initlpt(true))) then -begin - adress2 :=adresstoint(maskedit1.text); - adl:=adress2 and $FFFF; - adh:=(adress2 and $F0000) shr 4; -Block[1]:=lo(adl); -Block[2]:= hi(adl); -Block[3]:= lo(adh); -Block[4]:= hi(adh); -ok:=SendlptBlock( 7,4,@Block); -if not(ok) or errors then Showmessage('Erreur de transmission !!!!!!!!!!'); -end -else -Showmessage('Pas de PC distant'); -putb($18); -errors:=false; -end; -procedure TForm1.Memo2Click(Sender: TObject); -var ligne,col,pos,adl,adh:word; -adress2:longint; -begin - ligne:=memo2.selstart div 42; - col:= (trunc((memo2.selstart mod 42+1) / 2.5)); - pos:=16*ligne+col; - label1.caption:=inttostr(ligne)+':'+inttostr(col)+':'+inttostr(pos); - adress2:=pos+adress; - adl:=adress2 and $FFFF; - adh:=(adress2 and $F0000) shr 4; - pop:=false; - maskedit1.text:=inttohex(adh,4)+':'+inttohex(adl,4); - pop:=true; -end; - -end. diff --git a/programs/makefile b/programs/makefile index b01d081..2853f56 100644 --- a/programs/makefile +++ b/programs/makefile @@ -1,23 +1,14 @@ -asm= lzasm /z/t -lnk= elink +ASM=fasm +CLEAN=rm -rf +OBJS= $(SRCS:.c=.o) +SRC= $(wildcard *.asm) +PROG= $(SRC:.asm=.ce) -all: exem-lib.lib exem-ce.ce pmode.ce isa.ce editeur.ce volume.ce test.ce verifier.ce gestion.ce logo.ce souris.ce test3d.ce test2d.ce +all: $(PROG) + sync -.asm.obj: - $(asm) $< - -.obj.ce: - $(lnk) $< $*.ce - -.obj.lib: - $(lnk) $< $*.lib +%.ce: %.asm + $(ASM) $^ $@ clean: - del *.obj - del *.ce - del *.bak - del *.lib - del *.com - del *.bin - del *.sys - del *.err + $(CLEAN) *.ce diff --git a/programs/pmode.asm b/programs/pmode.asm index c7c048b..c68f0d8 100644 --- a/programs/pmode.asm +++ b/programs/pmode.asm @@ -1,17 +1,10 @@ -model tiny,stdcall -p586N -locals -jumps -codeseg -option procalign:byte - include "..\include\mem.h" include "..\include\divers.h" org 0h start: -header exe <"CE",1,0,0,,,,offset realstart> +header exe 1 realstart: mov eax,cr0 diff --git a/programs/souris.asm b/programs/souris.asm index eca057b..1efb39f 100644 --- a/programs/souris.asm +++ b/programs/souris.asm @@ -1,26 +1,19 @@ -model tiny,stdcall -p586N -locals -jumps -codeseg -option procalign:byte - include "..\include\mem.h" include "..\include\divers.h" org 0h start: -header exe <"CE",1,0,0,,offset imports,,offset realstart> +header exe 1 realstart: - call [mouseon] + invoke mouseon jc errormouse - call [print],offset message + invoke print, message retf errormouse: - call [print],offset errormessage + invoke print, errormessage retf message db 'Activation de la souris\l',0 diff --git a/programs/test.asm b/programs/test.asm index eff3eb2..07e0706 100644 --- a/programs/test.asm +++ b/programs/test.asm @@ -1,27 +1,20 @@ -model tiny,stdcall -p586N -locals -jumps -codeseg -option procalign:byte - include "..\include\mem.h" include "..\include\divers.h" org 0h start: -header exe <"CE",1,0,0,,offset imports,,offset realstart> +header exe 1 realstart: - call [cs:randomize] + invoke randomize push 0FFFFh pushd 652201 pushd 1545454545 push 1523 push 2041 - push offset zero - push offset fixe + push zero + push fixe push 5 push 'i' push 'a' @@ -31,71 +24,71 @@ realstart: pushd 125645 pushd 5041 pushd 125645 - push offset message - call [print] + push message + invoke print xor ax,ax int 16h - call [clearscreen] - call [xchgpages] - call [clearscreen] + invoke clearscreen + invoke xchgpages + invoke clearscreen mov cx,200 go1: - call [xchgpages] - call [waitretrace] - call [print],offset textdemo1 - call put - call [xchgpages] - call [waitretrace] + invoke xchgpages + invoke waitretrace + invoke print, textdemo1 + invoke put + invoke xchgpages + invoke waitretrace dec cx jnz go1 mov cx,200 go2: - call [xchgpages] - call [waitretrace] - call [print],offset textdemo2 - call put - call [xchgpages] - call [waitretrace] + invoke xchgpages + invoke waitretrace + invoke print, textdemo2 + invoke put + invoke xchgpages + invoke waitretrace dec cx jnz go2 mov cx,200 go3: - call [xchgpages] - call [waitretrace] - call [print],offset textdemo3 - call put - call [xchgpages] - call [waitretrace] + invoke xchgpages + invoke waitretrace + invoke print, textdemo3 + invoke put + invoke xchgpages + invoke waitretrace dec cx jnz go3 - call [clearscreen] - call [xchgpages] - call [clearscreen] - call [print],offset texte2 + invoke clearscreen + invoke xchgpages + invoke clearscreen + invoke print, texte2 mov bp,255 xor edx,edx go4: - call [xchgpages] - call [waitretrace] + invoke xchgpages + invoke waitretrace inc edx push edx - push offset texte3 - call [print] - call [xchgpages] - call [waitretrace] + push texte3 + invoke print + invoke xchgpages + invoke waitretrace dec bp jnz go4 - push offset texte4 - call [print] + push texte4 + invoke print mov ax,0 int 16h - call [restorestate] + invoke restorestate retf put: - call [cs:random] + invoke random mov di,ax and di,4096-2 - mov si,offset fond + mov si,fond call showstring2 ret diff --git a/programs/test2d.asm b/programs/test2d.asm index c22f090..fd322d0 100644 --- a/programs/test2d.asm +++ b/programs/test2d.asm @@ -1,55 +1,48 @@ -model tiny,stdcall -p586N -locals -jumps -codeseg -option procalign:byte - -include "..\include\mem.h" -include "..\include\fat.h" -include "..\include\divers.h" -include "..\include\3d.h" - -org 0h - -start: -header exe <"CE",1,0,0,,offset imports,,offset realstart> - -realstart: - call [cs:randomize] - call [cs:savestate] - call [cs:setvideomode],10 - call [cs:clearscreen] - mov cx,65535 -show: - call [cs:random] - and ax,1111b - push ax - call [cs:random] - push ax - call [cs:random] - push ax - call [cs:random] - push ax - call [cs:random] - push ax - call [cs:line] - dec cx - jnz show - call [cs:bioswaitkey] - call [cs:restorestate] - retf - -importing -use VIDEO.LIB,print -use VIDEO,savestate -use VIDEO,clearscreen -use VIDEO,setvideomode -use VIDEO,restorestate -use VIDEO,waitretrace -use GRAPHIC,line ;@x1:word,@y1:word,@x2:word,@y2:word,@color:word -use GRAPHIC,polyfill ;@pointer:word,@nbfaces:word,@color:word; -use SYSTEME,bioswaitkey -use MATH.LIB,randomize -use MATH.LIB,random -endi +include "..\include\mem.h" +include "..\include\fat.h" +include "..\include\divers.h" +include "..\include\3d.h" + +org 0h + +start: +header exe 1 + +realstart: + invoke randomize + invoke savestate + invoke setvideomode,10 + invoke clearscreen + mov cx,65535 +show: + invoke random + and ax,1111b + push ax + invoke random + push ax + invoke random + push ax + invoke random + push ax + invoke random + push ax + invoke line + dec cx + jnz show + invoke bioswaitkey + invoke restorestate + retf + +importing +use VIDEO.LIB,print +use VIDEO,savestate +use VIDEO,clearscreen +use VIDEO,setvideomode +use VIDEO,restorestate +use VIDEO,waitretrace +use GRAPHIC,line ;@x1:word,@y1:word,@x2:word,@y2:word,@color:word +use GRAPHIC,polyfill ;@pointer:word,@nbfaces:word,@color:word; +use SYSTEME,bioswaitkey +use MATH.LIB,randomize +use MATH.LIB,random +endi diff --git a/programs/test3d.asm b/programs/test3d.asm index d57fcb7..224f7a5 100644 --- a/programs/test3d.asm +++ b/programs/test3d.asm @@ -1,245 +1,230 @@ -model tiny,stdcall -p586N -locals -jumps -codeseg -option procalign:byte - -include "..\include\mem.h" -include "..\include\fat.h" -include "..\include\divers.h" -include "..\include\3d.h" - -org 0h - -start: -header exe <"CE",1,0,0,,offset imports,,offset realstart> - -data: - -camera vertex3d <320.0,240.0,70.0> - -zoom dd 5.0 -rot1 dd 0.1 -rot2 dd -0.1 - -vertexnbp dw 15 -dd 0.0,0.0,0.0 -dd 20.0,0.0,0.0 -dd 24.0,0.0,0.0 -dd 20.0,-2.0,0.0 -dd 20.0,2.0,0.0 -dd 0.0,0.0,0.0 -dd 0.0,20.0,0.0 -dd 0.0,24.0,0.0 -dd -2.0,20.0,0.0 -dd 2.0,20.0,0.0 -dd 0.0,0.0,0.0 -dd 0.0,0.0,20.0 -dd 0.0,0.0,24.0 -dd -2.0,-2.0,20.0 -dd 2.0,2.0,20.0 - -facenbp dw 6 -dw 0,1,1 -dw 2,4,3 -dw 5,6,6 -dw 7,9,8 -dw 10,11,11 -dw 12,14,13 - -vertexnbp2 dw 15 -dd 0.0,0.0,0.0 -dd 20.0,0.0,0.0 -dd 24.0,0.0,0.0 -dd 20.0,-2.0,0.0 -dd 20.0,2.0,0.0 -dd 0.0,0.0,0.0 -dd 0.0,20.0,0.0 -dd 0.0,24.0,0.0 -dd -2.0,20.0,0.0 -dd 2.0,20.0,0.0 -dd 0.0,0.0,0.0 -dd 0.0,0.0,20.0 -dd 0.0,0.0,24.0 -dd -2.0,-2.0,20.0 -dd 2.0,2.0,20.0 - - -mat1 mat -mat2 mat -mat3 mat -matrixp mat - -mode db 0 - -objectp: -vertexp equ objectp+15 -facep equ vertexp+20000 -screen equ facep+20000 - -;typep db ? -;objectp db 15 dup (?) -;vertexp db 1000*4*3+2 dup (?) -;facep db 2000*3+2 dup (?) -;screen db 1000*2*2 dup (?) - - -realstart: - call [cs:savestate] - call [cs:setvideomode],10 - call [cs:clearscreen] - call [cs:mballoc],65535 - mov es,ax - mov si,offset data - mov di,si - mov ecx,(offset realstart-offset data) - shr ecx,2 - inc ecx - cld - rep movsd - call [cs:projfile],offset filename - jc errorloading - call [cs:mbfind],offset filename - jc errorloading - push es - pop ds - mov es,ax - call [cs:load3ds],es,0,offset objectp,offset vertexp,offset matrixp,offset facep - call [cs:transform],offset vertexnbp,offset matrixp - call [cs:identity],offset mat1 - jmp show -rool: - mov ah,1 - int 16h - jz rool - xor ax,ax - int 16h - cmp ax,011Bh - je endee - cmp ax,3B00h - jne notmode - inc [mode] - cmp [mode],3 - jb notmodify - mov [mode],0 - jmp notmodify -notmode: - cmp ax,4800h - jne notup - call [cs:rotationx],offset mat1,[rot2] - jmp show -notup: - cmp ax,5000h - jne notdown - call [cs:rotationx],offset mat1,[rot1] - jmp show -notdown: - cmp ax,4B00h - jne notleft - call [cs:rotationy],offset mat1,[rot1] - jmp show -notleft: - cmp ax,4D00h - jne notright - call [cs:rotationy],offset mat1,[rot2] - jmp show -notright: - cmp ax,4900h - jne notupup - call [cs:rotationz],offset mat1,[rot1] - jmp show -notupup: - cmp ax,5100h - jne notdowndown - call [cs:rotationz],offset mat1,[rot2] - jmp show -notdowndown: - cmp ax,4A2Dh - jne notminus - fld [camera.tz] - fsub [zoom] - fstp [camera.tz] - jmp show -notminus: - cmp ax,4E2Bh - jne notmaxus - fld [camera.tz] - fadd [zoom] - fstp [camera.tz] - jmp show -notmaxus: - call [cs:identity],offset mat1 - jmp rool -show: - call [cs:transform],offset vertexp,offset mat1 - call [cs:transform],offset vertexnbp,offset mat1 -notmodify: - call [cs:clearscreen] - call [cs:print],offset objectp - call [cs:draw3d_line],3,offset facenbp,offset vertexnbp,offset screen,offset camera,3 - call [cs:draw3d_line],3,offset facenbp,offset vertexnbp2,offset screen,offset camera,3 - cmp [mode],0 - jne line - call [cs:draw3d_point],offset vertexp,offset screen,offset camera,4 - jmp retrace -line: - cmp [mode],1 - jne hidden - call [cs:draw3d_line],3,offset facep,offset vertexp,offset screen,offset camera,4 - jmp retrace -hidden: - call [cs:draw3d_hidden],3,offset facep,offset vertexp,offset screen,offset camera,4 -retrace: - call [cs:waitretrace] - call [cs:waitretrace] - jmp rool -endee: - call [cs:restorestate] - retf - -errorloading: - push cs - pop ds - call [cs:print],offset errorload - call [cs:bioswaitkey] - jmp endee - -errorload db '\c02Erreur au chargement du fichier 3D\l\c07',0 - -filename find <"SPHERE.3DS",0,0,0,1,> - - -importing -use 3D.LIB,draw3d_point -use 3D.LIB,draw3d_line -use 3D.LIB,draw3d_hidden -use 3D.LIB,draw3d_hidden_fill -use 3D.LIB,load3ds -use 3D.LIB,translate -use 3D.LIB,translatex -use 3D.LIB,translatey -use 3D.LIB,translatez -use 3D.LIB,scale -use 3D.LIB,rescale -use 3D.LIB,copy -use 3D.LIB,fill -use 3D.LIB,identity -use 3D.LIB,rotationx -use 3D.LIB,rotationy -use 3D.LIB,rotationz -use 3D.LIB,rotation -use 3D.LIB,project -use 3D.LIB,transform -use 3D.LIB,multiply -use VIDEO,savestate -use VIDEO,clearscreen -use VIDEO,setvideomode -use VIDEO,restorestate -use VIDEO,waitretrace -use SYSTEME,bioswaitkey -use SYSTEME,mbfind -use SYSTEME,mballoc -use VIDEO.LIB,print -use DISQUE,projfile -endi +include "..\include\mem.h" +include "..\include\fat.h" +include "..\include\divers.h" +include "..\include\3d.h" + +org 0h + +start: +header exe 1 + +alldata: +camera vertex3d 320.0,240.0,70.0 + +zoom dd 5.0 +rot1 dd 0.1 +rot2 dd -0.1 + +vertexnbp dw 15 +dd 0.0,0.0,0.0 +dd 20.0,0.0,0.0 +dd 24.0,0.0,0.0 +dd 20.0,-2.0,0.0 +dd 20.0,2.0,0.0 +dd 0.0,0.0,0.0 +dd 0.0,20.0,0.0 +dd 0.0,24.0,0.0 +dd -2.0,20.0,0.0 +dd 2.0,20.0,0.0 +dd 0.0,0.0,0.0 +dd 0.0,0.0,20.0 +dd 0.0,0.0,24.0 +dd -2.0,-2.0,20.0 +dd 2.0,2.0,20.0 + +facenbp dw 6 +dw 0,1,1 +dw 2,4,3 +dw 5,6,6 +dw 7,9,8 +dw 10,11,11 +dw 12,14,13 + +vertexnbp2 dw 15 +dd 0.0,0.0,0.0 +dd 20.0,0.0,0.0 +dd 24.0,0.0,0.0 +dd 20.0,-2.0,0.0 +dd 20.0,2.0,0.0 +dd 0.0,0.0,0.0 +dd 0.0,20.0,0.0 +dd 0.0,24.0,0.0 +dd -2.0,20.0,0.0 +dd 2.0,20.0,0.0 +dd 0.0,0.0,0.0 +dd 0.0,0.0,20.0 +dd 0.0,0.0,24.0 +dd -2.0,-2.0,20.0 +dd 2.0,2.0,20.0 + + +mat1 mat +mat2 mat +mat3 mat +matrixp mat + +mode db 0 + +objectp: +vertexp equ objectp+15 +facep equ vertexp+20000 +screen equ facep+20000 + +realstart: + invoke savestate + invoke setvideomode,10 + invoke clearscreen + invoke mballoc,65535 + mov es,ax + mov si, alldata + mov di,si + mov ecx,( realstart- alldata) + shr ecx,2 + inc ecx + cld + rep movsd + invoke projfile, filename + jc errorloading + invoke mbfind, filename + jc errorloading + push es + pop ds + mov es,ax + invoke load3ds,es,0, objectp, vertexp, matrixp, facep + invoke transform, vertexnbp, matrixp + invoke identity, mat1 + jmp show +rool: + mov ah,1 + int 16h + jz rool + xor ax,ax + int 16h + cmp ax,011Bh + je endee + cmp ax,3B00h + jne notmode + inc [mode] + cmp [mode],3 + jb notmodify + mov [mode],0 + jmp notmodify +notmode: + cmp ax,4800h + jne notup + invoke rotationx, mat1,[rot2] + jmp show +notup: + cmp ax,5000h + jne notdown + invoke rotationx, mat1,[rot1] + jmp show +notdown: + cmp ax,4B00h + jne notleft + invoke rotationy, mat1,[rot1] + jmp show +notleft: + cmp ax,4D00h + jne notright + invoke rotationy, mat1,[rot2] + jmp show +notright: + cmp ax,4900h + jne notupup + invoke rotationz, mat1,[rot1] + jmp show +notupup: + cmp ax,5100h + jne notdowndown + invoke rotationz, mat1,[rot2] + jmp show +notdowndown: + cmp ax,4A2Dh + jne notminus + fld [camera.tz] + fsub [zoom] + fstp [camera.tz] + jmp show +notminus: + cmp ax,4E2Bh + jne notmaxus + fld [camera.tz] + fadd [zoom] + fstp [camera.tz] + jmp show +notmaxus: + invoke identity, mat1 + jmp rool +show: + invoke transform, vertexp, mat1 + invoke transform, vertexnbp, mat1 +notmodify: + invoke clearscreen + invoke print, objectp + invoke draw3d_line,3, facenbp, vertexnbp, screen, camera,3 + invoke draw3d_line,3, facenbp, vertexnbp2, screen, camera,3 + cmp [mode],0 + jne line + invoke draw3d_point, vertexp, screen, camera,4 + jmp retrace +line: + cmp [mode],1 + jne hidden + invoke draw3d_line,3, facep, vertexp, screen, camera,4 + jmp retrace +hidden: + invoke draw3d_hidden,3, facep, vertexp, screen, camera,4 +retrace: + invoke waitretrace + invoke waitretrace + jmp rool +endee: + invoke restorestate + retf + +errorloading: + push cs + pop ds + invoke print, errorload + invoke bioswaitkey + jmp endee + +errorload db '\c02Erreur au chargement du fichier 3D\l\c07',0 + +filename find "SPHERE.3DS" + + +importing +use 3D.LIB,draw3d_point +use 3D.LIB,draw3d_line +use 3D.LIB,draw3d_hidden +use 3D.LIB,draw3d_hidden_fill +use 3D.LIB,load3ds +use 3D.LIB,translate +use 3D.LIB,translatex +use 3D.LIB,translatey +use 3D.LIB,translatez +use 3D.LIB,scale +use 3D.LIB,rescale +use 3D.LIB,copy +use 3D.LIB,fill +use 3D.LIB,identity +use 3D.LIB,rotationx +use 3D.LIB,rotationy +use 3D.LIB,rotationz +use 3D.LIB,rotation +use 3D.LIB,project +use 3D.LIB,transform +use 3D.LIB,multiply +use VIDEO,savestate +use VIDEO,clearscreen +use VIDEO,setvideomode +use VIDEO,restorestate +use VIDEO,waitretrace +use SYSTEME,bioswaitkey +use SYSTEME,mbfind +use SYSTEME,mballoc +use VIDEO.LIB,print +use DISQUE,projfile +endi diff --git a/programs/verifier.asm b/programs/verifier.asm index 93d601e..5b15051 100644 --- a/programs/verifier.asm +++ b/programs/verifier.asm @@ -1,21 +1,14 @@ -model tiny,stdcall -p586N -locals -jumps -codeseg -option procalign:byte - include "..\include\mem.h" include "..\include\divers.h" org 0h start: -header exe <"CE",1,0,0,,offset imports,,offset realstart> +header exe 1 realstart: - call [savestate] - call [print],offset msg + invoke savestate + invoke print, msg mov bp,1000h xor di,di xor cx,cx @@ -40,9 +33,9 @@ nokey: div si mov dx,ax push edx - call [print],offset msg2 + invoke print, msg2 call gauge - call [verifysector],cx + invoke verifysector,cx jc errors je noprob inc di @@ -53,20 +46,20 @@ noprob: enend: cmp di,0 je noatall - call [print],offset error2 + invoke print, error2 jmp someof noatall: - call [print],offset noerror + invoke print, noerror someof: mov ah,0 int 16h - call [restorestate] + invoke restorestate retf errors: - call [print],offset error + invoke print, error mov ah,0 int 16h - call [restorestate] + invoke restorestate retf error db '\g10,10Erreur avec le lecteur de disquette !',0 @@ -88,10 +81,10 @@ gauge: mov dx,ax push dx push 'Û' - push offset gauges - call [print] + push gauges + invoke print pop dx ax - retn + ret max dw 2879 sizeof dw 50 diff --git a/programs/volume.asm b/programs/volume.asm index bc9703e..4853a51 100644 --- a/programs/volume.asm +++ b/programs/volume.asm @@ -1,10 +1,3 @@ -model tiny,stdcall -p586N -locals -jumps -codeseg -option procalign:byte - include "..\include\mem.h" include "..\include\divers.h" include "..\include\graphic.h" @@ -12,29 +5,29 @@ include "..\include\graphic.h" org 0h start: -header exe <"CE",1,0,0,,offset imports,,offset realstart> +header exe 1 realstart: mov ax,0305h mov bx,0008h int 16h -call [savestate] -call [setvideomode],2 +invoke savestate +invoke setvideomode,2 xor ebp,ebp xor ax,ax mov fs,ax -call [disablescroll] +invoke disablescroll adres: -call [saveparamto],offset infos -call [readsector],[sect],offset buffer +invoke saveparamto,infos +invoke readsector,[sect], buffer jnc adres2 errtr: - call [setxy],0,[word ptr lastline] - call [print],offset errordisk + invoke setxy,0,word [lastline] + invoke print, errordisk xor ax,ax int 16h adres2: -call [saveparamto],offset infos +invoke saveparamto, infos mov al,[infos.lines] dec al mov [lastline],al @@ -45,13 +38,13 @@ shr al,2 mov [sizex],al and bl,11b mov [sizex2],bl -mov al,[infos.mode] +mov al,[infos.modenum] cmp al,[oldmode] je noinit -call [clearscreen] +invoke clearscreen mov [oldmode],al noinit: -call [setxy],0,0 +invoke setxy,0,0 mov edi,ebp mov bh,[lastline] lines: @@ -61,26 +54,26 @@ push edx mov edx,edi mov dx,[sect] push edx -push offset spaces -call [print] +push spaces +invoke print mov dx,di mov al,[sizex] mov esi,edi doaline: -push [dword ptr di+offset buffer] +push dword [di+buffer] push 8 -call [showhex] -call [showchar],' ' +invoke showhex +invoke showchar,' ' inc edi dec al jnz doaline mov edi,esi -push offset spaces2 -call [print] +push spaces2 +invoke print mov al,[sizex] doaline2: -push [word ptr di+offset buffer] -call [showchar] +push word [di+buffer] +invoke showchar inc edi dec al jnz doaline2 @@ -88,11 +81,11 @@ dec bh je outes cmp [sizex2],0 je lines -call [addline] +invoke addline jmp lines outes: -call [setxy],0,[word ptr lastline] -call [print],offset menu +invoke setxy,0,word [lastline] +invoke print,menu waitkey: mov ax,0 int 16h @@ -130,30 +123,30 @@ call [print],offset menu suit5: cmp ax,4000h jne suit6 -call [writesector],[sect],offset buffer +invoke writesector,[sect],buffer jnc waitkey jmp errtr suit6: cmp ax,4100h jne suit7 -mov [dword ptr pope],'TIDE' -call [setxy],0,[word ptr lastline] -call [print],offset menu +mov dword [pope],'TIDE' +invoke setxy,0,word [lastline] +invoke print,menu mov ax,0B800h mov es,ax mov [xxyy2],3 mov [xxyy],3 -call calc1 -call calc2 +invoke calc1 +invoke calc2 waitst: mov ax,0 int 16h cmp ah,41h jne tre -mov [dword ptr pope],' EUV' +mov dword [pope],' EUV' push cs pop es -call [writesector],[sect],offset buffer +invoke writesector,[sect],buffer jnc waitkey jmp errtr tre: @@ -190,14 +183,14 @@ je waitst dec [xx] jmp cursor write: -call asciihex2dec +invoke asciihex2dec cmp cl,15 ja waitst -call calc1 -call calc2 +invoke calc1 +invoke calc2 mov edi,[es:bx-1] mov dx,[es:si-1] -mov [byte ptr es:bx],0112 +mov byte [es:bx],0112 mov [es:bx-1],al writs: mov ax,0 @@ -229,7 +222,7 @@ jmp waitst suit7: cmp ax,4200h jne adres -call [restorestate] +invoke restorestate retf calc1: push ax dx si @@ -245,11 +238,11 @@ shl bx,5 shl dx,7 add bx,dx add bx,ax -mov [byte ptr es:bx],112 -mov [byte ptr es:bx+2],112 +mov byte [es:bx],112 +mov byte [es:bx+2],112 mov si,[xxyy] -mov [byte ptr es:si],07 -mov [byte ptr es:si+2],07 +mov byte [es:si],07 +mov byte [es:si+2],07 mov [xxyy],bx pop si dx ax ret @@ -264,9 +257,9 @@ mov dx,[xx] shl dx,1 add si,dx add si,129 -mov [byte ptr es:si],112 +mov byte [es:si],112 mov bx,[xxyy2] -mov [byte ptr es:bx],07 +mov byte [es:bx],07 mov [xxyy2],si pop dx bx ax ret @@ -278,7 +271,7 @@ calc3: shl dx,4 add bx,dx add bx,bp - add bx,offset buffer + add bx,buffer pop dx ret @@ -324,7 +317,7 @@ spaces2 db '\c04 | \c07',0 showbuffer db 35 dup (0FFh) oldmode db 0 sect dw 0 -infos vgainf <> +infos vgainf importing use DISQUE,readsector @@ -342,10 +335,3 @@ use VIDEO.LIB,showhex use VIDEO.LIB,showchar endi - - - - - - -