diff --git a/8253.asm b/8253.asm new file mode 100755 index 0000000..7189103 --- /dev/null +++ b/8253.asm @@ -0,0 +1,53 @@ +.model tiny +.486 +smart +.code +org 0100h +start: +jmp tsr +db '8253' +Tsr: +cli +cmp ax,1234h +jne nomore +mov ax,4321h +jmp itsok +nomore: +push bx +mov bl,ah +xor bh,bh +shl bx,1 +mov bx,cs:[bx].tables +mov cs:current,bx +pop bx +call cs:current +itsok: +jnc noerror +push bp +mov bp,sp +or byte ptr [bp+6],1b +pop bp +mov ax,cs +shl eax,16 +mov ax,cs:current +jmp endofint +noerror: +push bp +mov bp,sp +and byte ptr [bp+6],0FEh +pop bp +endofint: +sti +iret +current dw 0 +tables dw enableirq + dw disableirq + dw readmaskirq + dw readirr + dw readisr + dw installhandler + dw replacehandler + dw getint + dw setint + dw seteoi + diff --git a/asm.bat b/asm.bat index 8223189..daef462 100755 --- a/asm.bat +++ b/asm.bat @@ -11,6 +11,8 @@ echo Copying file %1... if "%1"=="video" goto video if "%1"=="lpt" goto system if "%1"=="keyboard" goto system +if "%1"=="mouse" goto system +if "%1"=="pic8259a" goto system if "%1"=="timer" goto system if "%1"=="drive" goto system if "%1"=="system" goto system diff --git a/asmsys.bat b/asmsys.bat new file mode 100755 index 0000000..e18c01e --- /dev/null +++ b/asmsys.bat @@ -0,0 +1,9 @@ +@echo off +call asm video +call asm system +call asm lpt +call asm keyboard +call asm pic8259a +call asm timer +call asm drive +call asm mouse diff --git a/boot.asm b/boot.asm index 347a19d..438a180 100755 --- a/boot.asm +++ b/boot.asm @@ -8,17 +8,17 @@ start: jmp boot -bootdb db 'COS2000A' ;ID Formatage +bootdb db 'COS2000A' ;Fabricant + n°série Formatage sizec dw 512 ;octet/secteur db 1 ;secteur/cluster reserv dw 1 ;secteur reserv‚ -nbfat db 1 ;nb de FAT -nbfit dw 25 ;nb secteur rep racine -allclu dw 2880 ;nb secteur du volume - db 0F0h ;ID support -fatsize dw 12 ;secteur/FAT +nbfat db 1 ;nb de copie de la FAT +nbfit dw 25 ;taille rep racine +allclu dw 2880 ;nb secteur du volume si < 32 még + db 0F0h ;Descripteur de média +fatsize dw 12 ;secteur/FAT nbtrack dw 18 ;secteur/piste -head dw 2 ;nb de tˆte +head dw 2 ;nb de tˆteb de lecture/écriture hidden dd 0 ;nombre de secteur cach‚s dd 0 ;si nbsecteur = 0 nbsect ; the number of sectors bootdrv db 0 ;Lecteur de d‚marrage @@ -119,7 +119,7 @@ oksystem: mov si,offset syst call showstr mov cx,[di+BX+26] -mov bx,1000h +mov bx,200h mov es,bx push bx mov bx,0100h diff --git a/clean.bat b/clean.bat new file mode 100755 index 0000000..200b0c1 --- /dev/null +++ b/clean.bat @@ -0,0 +1 @@ +del ..\data\*.exe diff --git a/drive.asm b/drive.asm index e2766a4..39204df 100755 --- a/drive.asm +++ b/drive.asm @@ -5,6 +5,7 @@ smart org 0100h + start: jmp tsr db 'DRIVE' @@ -47,10 +48,12 @@ tables dw readsector dw verifysector2 dw loadfatway dw loadfile + dw compressrle + dw decompressrle ;cx entr‚e -> fatway chemin getfatway: -push bx cx es +push bx cx mov bx,offset fatway fatagain: mov cs:[bx],cx @@ -60,48 +63,50 @@ jae finishload call getfat jnc fatagain finishload: -pop es cx bx +pop cx bx ret -;Charge le fichier de chemin cx +;Charge le fichier de chemin cx -> taille dx loadfatway: -push ax bx cx di +push ax bx cx di call getfatway jc endload mov di,offset fatway +xor dx,dx loadagain: mov cx,cs:[di] cmp cx,0FFF0h jae endload add di,2 -xor al,al +mov al,1 call readsector jc endload add bx,cs:sizec +add dx,cs:sizec jmp loadagain endload: pop di cx bx ax ret -sizec dw 512 -reserv dw 1 ;<-cx nøsecteur ->cx code FAT getfat: push es ax bx dx -mov ax,cx -xor dx,dx -div cs:sizec -mov cx,ax -add cx,cs:reserv -mov bx,offset buffer +push cs +pop ds push cs pop es +mov ax,cx +xor dx,dx +div sizec +mov cx,ax +add cx,reserv +mov bx,offset buffer call readsector jc errorgetfat shl dx,1 add bx,dx -mov cx,cs:[bx] +mov cx,[bx] errorgetfat: pop dx bx ax es ret @@ -140,7 +145,7 @@ TryAgain: jnc Done dec SI jnz TryAgain -mov word ptr cs:lastread,0ffffh + mov word ptr cs:lastread,0ffffh Done: pop si dx cx ax ret @@ -176,7 +181,7 @@ TryAgain2: int 13h jnc Done2 dec SI - jnz TryAgain2 + jnz TryAgain2 Done2: pop si dx cx ax ret @@ -229,27 +234,32 @@ or byte ptr [bp+6],10b nook: ret -;Charge le fichier Ds:si en es:di +;Charge le fichier Ds:si en es:di taille-> cx loadfile: -push bx cx +push bx call searchfile +jc errorloadfile mov bx,di call loadfatway -pop cx bx -ret +mov cx,dx +errorloadfile: +pop bx +ret ;Recherche le fichier et retourne sont path et en cx sont debut Searchfile: push bx dx si di ds es push cs pop es +xor dx,dx mov di,offset temp call asciiztofit -mov bx,offset buffer push cs pop ds mov cx,13 check: +mov al,1 +mov bx,offset buffer call readsector jc errorboot xor di,di @@ -261,6 +271,7 @@ mov si,di add si,bx mov di,offset temp mov cx,12+4 +cld rep cmpsb pop cx di si je oksystem @@ -274,7 +285,11 @@ inc cx jmp Check oksystem: mov cx,[di+BX+26] +cld +jmp goodboot errorboot: +stc +goodboot: pop es ds di si dx bx ret @@ -345,15 +360,15 @@ isSystchar: push di mov di,offset exeptchar isexcept: -cmp al,[di] +cmp al,cs:[di] je nogood inc di -cmp byte ptr [di],0 +cmp byte ptr cs:[di],0 jne isexcept endanal: -pop di +clc +pop di ret -exeptchar db '/\<>:|.',01,0,0 nogood: stc jmp endanal @@ -380,19 +395,110 @@ clc pop ax cx di si ret -nbfit equ 255 +;decompress ds:si en es:di taille bp d‚compress‚ cx compress‚ +DecompressRle: +push cx dx si di +mov dx,cx +mov bp,di +decompression: +mov eax,[si] +cmp al,'/' +jne nocomp +cmp si,07FFFh-6 +jae thenen +mov ecx,eax +ror ecx,16 +cmp cl,'*' +jne nocomp +cmp byte ptr [si+4],'/' +jne nocomp +mov al,ch +mov cl,ah +xor ah,ah +xor ch,ch +rep stosb +add si,5 +sub dx,5 +jnz decompression +jmp thenen +nocomp: +mov es:[di],al +inc si +inc di +dec dx +jnz decompression +thenen: +mov ax,dx +sub bp,di +neg bp +pop di si dx cx +ret + +;compress ds:si en es:di taille cx d‚compress‚ BP compress‚ +CompressRle: +push ax bx cx dx si di ds es +mov bp,di +xchg si,di +push es +push ds +pop es +pop ds +mov dx,cx +;mov bp,cx +againcomp: +mov bx,di +mov al,es:[di] +mov cx,dx +cmp ch,0 +je poo +mov cl,0ffh +;mov cx,bp +;sub cx,di +;mov ah,cl +poo: +mov ah,cl +inc di +xor ch,ch +repe scasb +sub cl,ah +neg cl +cmp cl,6 +jbe nocomp2 +mov dword ptr [si],' * /' +mov byte ptr [si+4],'/' +mov [si+1],cl +mov [si+3],al +add si,5 +dec di +xor ch,ch +sub dx,cx +jnz againcomp +jmp fini +nocomp2: +mov [si],al +inc si +inc bx +mov di,bx +dec dx +jnz againcomp +fini: +sub bp,si +neg bp +pop es ds di si dx cx bx ax +ret + +nbfit equ 255 namesize equ 12 extsize equ 5 - - -temp db 12+5+1 dup (0) - +exeptchar db '/\<>:|.',01,0,0 +temp db 12+5+1+90 dup (0) DiskSectorsPerTrack dw 18 DiskTracksPerHead dw 80 DiskHeads dw 2 - -fatway equ $ - -buffer equ $+3000 +sizec dw 512 +reserv dw 1 +buffer equ $ buffer2 equ $+512 +fatway equ $+512 + end start diff --git a/editor.asm b/editor.asm index aac1b83..9760787 100755 --- a/editor.asm +++ b/editor.asm @@ -367,83 +367,6 @@ pope db 'VUE ',0 spaces db ' ³ ',0 showbuffer db 35 dup (0FFh) -Lastread dw 0FFFFh - -ReadSector: -push ax cx dx si - cmp cx,cs:lastread - je done - mov cs:LastRead,cx - mov AX, CX - xor DX, DX - div cs:DiskSectorsPerTrack - mov CL, DL ;{ Set the sector } - and CL, 63 ;{ Top two bits are bits 8&9 of the cylinder } - xor DX, DX - div cs:DiskTracksPerHead - mov CH, DL ;{ Set the track bits 0-7 } - mov AL, DH - ror AL, 1 - ror AL, 1 - and AL, 11000000b - or CL, AL ;{ Set bits 8&9 of track } - xor dX, DX - div cs:DiskHeads - mov DH, DL ;{ Set the head } - inc CL - mov SI, 4 -TryAgain: - mov AL, 1 - mov DL, 0 - mov AH, 2 - int 13h - jnc Done - dec SI - jnz TryAgain -mov word ptr cs:lastread,0ffffh -Done: - pop si dx cx ax -ret - -WriteSector: -push ax cx dx si - cmp cs:Lastread,cx - jne nodestruct - mov cs:Lastread,0ffffh - nodestruct: - mov AX, CX - xor DX, DX - div cs:DiskSectorsPerTrack - mov CL, DL ;{ Set the sector } - and CL, 63 ;{ Top two bits are bits 8&9 of the cylinder } - xor DX, DX - div cs:DiskTracksPerHead - mov CH, DL ;{ Set the track bits 0-7 } - mov AL, DH - ror AL, 1 - ror AL, 1 - and AL, 11000000b - or CL, AL ;{ Set bits 8&9 of track } - xor DX, DX - div cs:DiskHeads - mov DH, DL ;{ Set the head } - inc CL - mov SI, 4 -TryAgain2: - mov AL, 1 - mov DL, 0 - mov AH, 3 - int 13h - jnc Done2 - dec SI - jnz TryAgain2 -Done2: - pop si dx cx ax -ret - -DiskSectorsPerTrack dw 18 -DiskTracksPerHead dw 80 -DiskHeads dw 2 oldmode db 0 infos db 10 dup (0) end start diff --git a/keyboard.asm b/keyboard.asm index ee09c17..2c959d5 100755 --- a/keyboard.asm +++ b/keyboard.asm @@ -15,63 +15,71 @@ tsr: db 2eh,0ffh,1eh dw offsets cli - pusha + mov cs:feax,eax in al,60h cmp cs:isstate,1 jne nostate cmp al,57 - jne nof12 + jne endof mov cs:isstate,0 - jmp noF12 + jmp endof nostate: cmp al,87 - jne NoF11 - push es - push cs - pop es - mov di,offset infos - mov ah,34 - int 47h - mov al,cs:infos+7 - inc al - and ax,111b - int 47h - pop es - nof11: + je F11 cmp al,88 - jne NoF12 - mov ah,26 - int 47h - call showstate - mov cs:isstate,1 - sti - waitt: - cmp cs:isstate,0 - jne waitt - mov ah,27 - int 47h - noF12: - popa + je F12 + endof: + mov eax,cs:feax sti iret isstate db 0 infos db 10 dup (0) - showstate: - push ds es - push ss +F11: + push ax di es + push cs + pop es + mov di,offset infos + mov ah,34 + int 47h + mov al,cs:infos+7 + inc al + and ax,111b + int 47h + pop es di ax + jmp endof + + +f12: + mov cs:isstate,1 + pop word ptr cs:fip + pop word ptr cs:fcs + pop dword ptr cs:ffl + mov cs:fesp,esp + push ds es + pusha + push word ptr cs:fip push gs push fs + push ss push es push ds - push cs - pushad - pushfd - + push word ptr cs:fcs + push dword ptr cs:fesp + push ebp + push edi + push esi + push edx + push ecx + push ebx + push eax + push dword ptr cs:ffl push cs push cs pop es pop ds + mov ah,26 + int 47h mov ah,2 int 47h mov ah,21 @@ -97,16 +105,17 @@ tsr: mov ah,10 int 47h mov si,offset regs - mov bx,8+6 + mov bx,8+7 mov ah,21 mov cl,6 int 47h showallREG: mov ah,6 int 47h - cmp bx,7 + cmp bx,8 jb nodr pop edx + mov cx,32 jmp popo nodr: mov ah,21 @@ -114,11 +123,11 @@ showallREG: int 47h xor edx,edx pop dx + mov cx,16 popo: mov ah,13 int 47h mov ah,10 - mov cx,32 int 47h mov ah,5 int 47h @@ -153,27 +162,43 @@ showallREG: dec di mov cl,116 int 47h + pop es ds + sti + waitt: + cmp cs:isstate,0 + jne waitt + mov ah,27 + int 47h + popa pop es ds - ret + push dword ptr cs:ffl + push word ptr cs:fcs + push word ptr cs:fip + jmp endof -reg db 'State of registers',0 -fla db 'Flags:',0 -regs db 'EDI:',0 +reg db ' State of registers',0 +fla db 'Eflags:',0 +regs db 'EAX:',0 + db 'EBX:',0 + db 'ECX:',0 + db 'EDX:',0 db 'ESI:',0 + db 'EDI:',0 db 'EBP:',0 db 'ESP:',0 - db 'EBX:',0 - db 'EDX:',0 - db 'ECX:',0 - db 'EAX:',0 db ' CS:',0 db ' DS:',0 db ' ES:',0 db ' FS:',0 db ' GS:',0 db ' SS:',0 + db ' IP:',0 gr db '(',0 dr db ')',0 app db 'Press space to quit...',0 - +ffl dd 0 +fcs dw 0 +fip dw 0 +fesp dd 0 +feax dd 0 end start diff --git a/logo.asm b/logo.asm index 842e04e..f20ec8f 100755 --- a/logo.asm +++ b/logo.asm @@ -17,146 +17,28 @@ mov bx,5000h mov es,bx xor si,si xor di,di -xor bx,bx -call DecompressRle +mov ah,6 +int 48h push es pop ds -call loadbmp -xor ax,ax +mov ax,0006h +int 47h +mov ah,38 +int 47h +mov ah,35 +int 47h +mov ah,37 +int 47h +xor cx,cx xor bx,bx -call showbmp +mov ah,36 +int 47h mov ax,0 int 16h -db 0CBH - -loadbmp: -push ax bx cx dx bp ds -mov ax,6 -int 47h -mov ax,ds:[18] -mov si,ax -shr ax,2 -and si,11b -cmp si,0 -je is4x -add ax,1 -is4x: -mov cs:sizeh,ax -mov ax,ds:[22] -mov cs:sizev,ax -mov di,0FFFFh-1024 -mov si,54 -mov cl, 0ffh -paletteload: -lodsb -shr al, 2 -mov [di+2], al -lodsb -shr al, 2 -mov [di+1], al -lodsb -shr al, 2 -mov [di+0], al -inc si -add di, 3 -dec cl -jnz paletteload -mov si,0FFFFh-1024 -mov dx, 3c8h -cld -mov cl, 0ffh -xor bx, bx -palettemake: -mov al, bl -out dx, al -inc dx -lodsb -out dx, al -lodsb -out dx, al -lodsb -out dx, al -dec dx -inc bl -dec cl -jnz palettemake -pop ds bp dx cx bx ax -ret -sizeh dw 0 -sizev dw 0 - -showbmp: -push ax bx cx dx si di ds es -mov cx,cs:sizeh -mov dx,cs:sizev -add bx,dx -mov di,ax -mov ax,bx -shl ax,6 -shl bx,8 -add di,bx -add di,ax -mov bx,di -mov ax,0A000H -mov es,ax -mov si,1024+54 -mov ax,cx -bouclebmp: -cmp di,64000 -jae nopp -cld -rep movsd -no: -mov cx,ax -sub bx,320 -mov di,bx -dec dx -jnz bouclebmp -fin: -pop es ds di si dx cx bx ax -ret -nopp: -shl cx,2 -add si,cx -jmp no - -DecompressRle: -push cx dx si di -mov dx,cx -mov bp,di -decompression: -mov eax,[si] -cmp al,'/' -jne nocomp -cmp si,07FFFh-6 -jae thenen -mov ecx,eax -ror ecx,16 -cmp cl,'*' -jne nocomp -cmp byte ptr [si+4],'/' -jne nocomp -mov al,ch -mov cl,ah -xor ah,ah -xor ch,ch -rep stosb -add si,5 -sub dx,5 -jnz decompression -jmp thenen -nocomp: -mov es:[di],al -inc si -inc di -dec dx -jnz decompression -thenen: -mov ax,dx -sub bp,di -neg bp -pop di si dx cx -ret - +mov ah,39 +int 47h +mov ax,0004 +int 47h +db 0CBH logo db 'cos.rip',0 end start diff --git a/lpt.asm b/lpt.asm index 9f07dda..3ab87ec 100755 --- a/lpt.asm +++ b/lpt.asm @@ -5,7 +5,7 @@ smart org 0100h start: jmp tsr -db 'LPT' +drv db 'LPT ',0 Tsr: cli cmp ax,1234h @@ -13,7 +13,17 @@ jne nomore mov ax,4321h jmp itsok nomore: -push bx +push bx ax +mov ah,4 +mov bh,1 +int 50h +mov bl,al +pop ax +cmp byte ptr cs:isact,1 +je nottest +mov cs:isact,1 +cmp bl,80h +jae react mov bl,ah xor bh,bh shl bx,1 @@ -37,8 +47,12 @@ mov bp,sp and byte ptr [bp+6],0FEh pop bp endofint: +mov cs:isact,0 sti iret +nottest: +pop bx +jmp endofint current dw 0 tables dw getlptin dw getlptout @@ -59,6 +73,127 @@ tables dw getlptin dw receivecommand dw sendcommand +react: +push ds es +mov cs:isact,1 +pushad +push cs +pop ds +push cs +pop es +cmp byte ptr never,1 +je oknever +mov bl,[drv+3] +sub bl,'0' +xor bh,bh +call getlpt +dec bl +shl bl,1 +mov al,7 +sub al,bl +mov ah,40 +mov di,offset video +int 47h +push ax +mov ah,01h +int 50h +mov ah,21 +mov cl,4 +int 47h +sti +mov al,0111b +call setlptout +call setreceptor +call initlpt +jc errorie +mov cx,0 +mov ah,20 +mov bx,1012h +mov si,offset initok +int 47h +cmp byte ptr always,1 +je yes +mov ah,20 +mov bx,1010h +mov si,offset mdd +int 47h +mov ah,13 +mov si,offset drv +int 47h +mov ah,6 +int 47h +mov ah,20 +mov bx,1011h +mov si,offset msg +int 47h +waitkey: +mov ax,0 +int 16h +cmp al,'n' +je no +cmp al,'N' +je no +cmp al,'Y' +je yes +cmp al,'y' +je yes +cmp al,'e' +je nev +cmp al,'E' +je nev +cmp al,'a' +je alw +cmp al,'A' +je alw +jmp waitkey +yes: +call receivecommand +jc errortimeout +no: +mov al,0111b +call setlptout +cli +mov ah,41 +mov si,offset video +int 47h +pop ax +mov ah,00h +int 50h +mov ah,09h +int 50h +oknever: +popad +pop es ds +mov cs:isact,0 +pop bx +jmp endofint +errorie: +mov si,offset inits +jmp show +errortimeout: +mov si,offset timeouts +show: +mov ah,20 +mov bx,1012h +int 47h +mov ax,0 +int 16h +jmp no +nev: +mov byte ptr never,1 +jmp no +alw: +mov byte ptr always,1 +jmp yes +initok db 'Initialisation is realised !',0 +inits db 'Error on initialisation',0 +timeouts db 'Connection lost or timeout complete !!',0 +mdd db 'Connection demand on ',0 +msg db 'Accept connection ? (Y)es (N)o n(E)ver (A)lways',0 +isact db 0 +always db 0 +never db 0 + ;envois une commande al sendcommand: push ax bx cx di @@ -84,31 +219,63 @@ pop ds mov si,bx mov cx,6 call sendlptblock +jc endofget call receivelptblock +endofget: pop ds cx bx ax ret ;Re‡ois une commande et l'execute Receivecommand: -push ax bx cx di es +push ax bx cx di ds es push cs pop es +push cs +pop ds mov di,offset command call receivelptblock +jc endofno mov bl,al xor bh,bh shl bx,1 add bx,offset cmd call cs:[bx] -pop es di cx bx ax +clc +endofno: +pop es ds di cx bx ax ret + command db 25 dup (0) cmd dw nothings dw sendram - + dw receiveram + dw sendreg + dw receivereg + dw sendport + dw receiveport + dw letexecute nothings: ret +letexecute: +push ds es fs gs +pushad +push cs +push offset suite +mov ax,es:[di+2] +mov ds,ax +mov es,ax +mov fs,ax +mov gs,ax +push ax +mov ax,es:[di] +push ax +DB 0CBh +suite: +popad +pop gs fs es ds +ret + Sendram: push ax cx si ds mov si,es:[di] @@ -119,6 +286,30 @@ call sendlptblock pop ds si cx ax ret +receiveram: +sendreg: +receivereg: + +sendport: +push ax cx dx si +mov dx,es:[di] +in ax,dx +mov cx,2 +mov si,offset tempblock +mov ds:[si],ax +call sendlptblock +pop si dx cx ax +ret + +receiveport: +push ax dx +mov dx,es:[di] +mov ax,es:[di+2] +out dx,ax +pop dx ax +ret + +tempblock db 25 dup (0) ;---------Segment Adress----------- Bios equ 040h @@ -130,18 +321,12 @@ 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 - +maxtry equ 10 Initlpt: push ax ecx call StartTimer -cmp emettor,0 +cmp cs:emettor,0 je receptinit mov al,10000b call SetLptOut @@ -269,7 +454,7 @@ Emettor db 0 SetReceptor: mov cs:Emettor,0 -ret +ret ;->bx Nøport->Adresse dx GetLpt: @@ -320,7 +505,6 @@ mov ax,Bios mov ds,ax mov ecx,ds:[timer] sub ecx,cs:times -mov ecx,0 pop ds ax ret @@ -510,5 +694,6 @@ mov bl,ah xor bh,bh cmp bp,bx pop bp si dx bx -ret +ret +video db 0 end start diff --git a/mm.asm b/mm.asm new file mode 100755 index 0000000..885d078 --- /dev/null +++ b/mm.asm @@ -0,0 +1,52 @@ +.model tiny +.486 +smart +.code + +org 0100h + +start: +mov ah,2 +int 74h +jc error +mov si,offset dnoerror +jmp noerror +error: +mov si,offset derror +noerror: +mov ah,20 +mov bx,1010h +int 47h +mov ax,0 +int 16h +xor edx,edx +popr: +mov ah,3 +int 74h +mov ah,6 +int 47h +mov si,bx +mov di,cx +mov ah,11 +mov cx,8 +int 47H +mov ah,5 +int 47H +mov dx,si +mov ah,10 +mov cx,16 +int 47H +mov ah,5 +int 47h +mov dx,di +mov ah,10 +mov cx,16 +int 47H +jmp popr +db 0CBh + +dnoerror db 'Souris d‚tect‚e en PS/2',0 +derror db 'Souris non d‚tect‚e',0 + + +end start diff --git a/mouse.asm b/mouse.asm new file mode 100755 index 0000000..acee17d --- /dev/null +++ b/mouse.asm @@ -0,0 +1,257 @@ +.model tiny +.486 +smart +.code +org 0100h +start: +jmp tsr +drv db 'MOUSE',0 +Tsr: +cli +cmp ax,1234h +jne nomore +mov ax,4321h +jmp itsok +nomore: +push bx ax +mov ah,4 +mov bh,0 +int 50h +mov bl,al +pop ax +cmp byte ptr cs:isact,1 +je nottest +mov cs:isact,1 +and bl,10000b +cmp bl,16 +jae react +mov bl,ah +xor bh,bh +shl bx,1 +mov bx,cs:[bx].tables +mov cs:current,bx +pop bx +call cs:current +itsok: +jnc noerror +push bp +mov bp,sp +or byte ptr [bp+6],1b +pop bp +mov ax,cs +shl eax,16 +mov ax,cs:current +jmp endofint +noerror: +push bp +mov bp,sp +and byte ptr [bp+6],0FEh +pop bp +endofint: +mov cs:isact,0 +sti +iret +nottest: +pop bx +jmp endofint +current dw 0 +tables dw cmdmouse + dw cmdmouse2 + dw detectmouse + dw getmouse + +isact db 0 + +;Envoie une commande AL … la souris via controleur clavier +cmdmouse: + push ax +videbuff1: + in al, 64h + and al, 10b + jne videbuff1 + mov al, 00d4h + out 64h, al +videbuff2: + in al, 64h + and al, 10b + jne videbuff2 + pop ax + out 60h, al + in al, 60h + ret + +;Envoie une commande2 AL … la souris via controleur clavier carry=nomouse +cmdmouse2: + push ax +videbuff21: + in al, 64h + and al, 10b + jne videbuff21 + mov al, 0060h + out 64h, al +videbuff22: + in al, 64h + and al, 10b + jne videbuff22 + pop ax + out 60h, al + in al, 60h + ret + +Detectmouse: + push ax cx + mov al, 0a8h ;AUX enable + out 64h, al + mov al, 0f3h ;Set sample + call cmdmouse + mov al, 100 ;Set sample + call cmdmouse + mov al, 0e8h ;Set resolution + call cmdmouse + mov al, 01 ;Set resolution + call cmdmouse + mov al, 0e7h ;Set scale 2:1 + call cmdmouse + mov al, 0f4h ;Enable device + call cmdmouse + mov al, 47h ;Interruption ON + call cmdmouse2 + mov cx, 1024 +testmouse: + in al, 60h ;Lecture du port de donn‚es + cmp al, 250 ;Test si il y a une souris + je okmouse + dec cx + jnz testmouse + stc + jmp endoftest +okmouse: + clc +endoftest: + pop cx ax + ret + +;envoie en bx,cx les coordonn‚es et en dl les boutons +getmouse: +mov bl,cs:vx +xor bh,bh +mov cl,cs:vy +xor ch,ch +mov dl,cs:button +;sub dl,8 +;and dl,0Fh +clc +ret + +Button db 0 +rx dw 0 +ry dw 0 +VX db 0 +VY db 0 +X dw 0 +Y dw 0 +count db 0 +error db 0 +xy dw 0 +old dw 0 +;Gestionnaire de souris PS/2 +react: + push ax bx cx dx di ds es + push cs + pop ds + in al, 60h + cmp error, 1 + je gest1 + cmp count, 1 + je gest1 + cmp count, 2 + je gest2 + cmp count, 3 + je gest3 + +gest1: + mov count, 2 + mov Button, al + and al, 00001000b + cmp al, 8 + je gest1end + mov error, 1 + jmp gest1end2 +gest1end: + mov error, 0 +gest1end2: + mov count, 2 + jmp endgest +gest2: + mov count, 3 + mov VX, al + jmp endgest +gest3: + mov count, 1 + mov VY, al + jmp endgest +endgest: + mov bl,VY + xor bh,bh + mov al,button + shr al,5 + and al,1 + cmp al,0 + je addy + add y,bx + jmp hadsuby + addy: + sub y,bx + hadsuby: + mov bl,VX + xor bh,bh + mov al,button + shr al,8 + and al,1 + cmp al,0 + je addx + sub x,bx + jmp hadsubx + addx: + add x,bx + hadsubx: + push cs + pop es + mov di,offset infos + mov ah,34 + int 47h + mov ax,x + mov bx,0FFFFh + xor ch,ch + mov cl,[di+1] + mul cx + div bx + mov rx,ax + mov ax,y + mov cl,[di] + mul cx + div bx + mov ry,ax + mul byte ptr [di+1] + add ax,rx + shl ax,1 + mov di,ax + mov ax,0B800h + mov es,ax + mov bx,xy + mov ax,old + mov word ptr es:[bx],ax + mov xy,di + mov ax,es:[di] + mov old,ax + mov word ptr es:[di],0FF70h + mov al, 20h + out 0a0h, al + out 20h, al + pop es ds di dx cx bx ax + mov cs:isact,0 + pop bx + iret + infos db 10 dup (0) + +end start diff --git a/pic8259a.asm b/pic8259a.asm new file mode 100755 index 0000000..a8e5474 --- /dev/null +++ b/pic8259a.asm @@ -0,0 +1,237 @@ +.model tiny +.486 +smart +.code +org 0100h +start: +jmp tsr +db 'PIC8259A' +Tsr: +cli +cmp ax,1234h +jne nomore +mov ax,4321h +jmp itsok +nomore: +push bx +mov bl,ah +xor bh,bh +shl bx,1 +mov bx,cs:[bx].tables +mov cs:current,bx +pop bx +call cs:current +itsok: +jnc noerror +push bp +mov bp,sp +or byte ptr [bp+6],1b +pop bp +mov ax,cs +shl eax,16 +mov ax,cs:current +jmp endofint +noerror: +push bp +mov bp,sp +and byte ptr [bp+6],0FEh +pop bp +endofint: +sti +iret +current dw 0 +tables dw enableirq + dw disableirq + dw readmaskirq + dw readirr + dw readisr + dw installhandler + dw replacehandler + dw getint + dw setint + dw seteoi + +;Adresses de port du contr“leur IRQ + MASTERPIC = 020h ;Adresse de base du PIC maŒtre + SLAVEPIC = 0A0h ;Adresse de base du PIC esclave + IRQMASK = 001h ;Offset sur port de masquage + +;Commandes IRQ OCW2 + DISABLEROTATION = 000h ;Desactiver la rotation de priorités en mode EOI automatique + EOI = 020h ;End of Interrupt non sp‚cifi‚ + COMMANDEOI = 060h ;Commande EOI particulière + ENABLEROTATION = 080h ;Activer la rotation de priorités en mode EOI automatique + ROTATIONNOSPEC = 0A0h ;Rotation des priorités en mode EOI automatique + SETPRIORITY = 0C0h ;Definir la priorité + ROTATIONSPEC = 0E0h ;Rotation des priorités en mode EOI spécifié + +;Position des vecteurs d'interruptions + MASTERFIRSTVECTOR = 008h ;Vecteurs logiciels des interruptions + SLAVEFIRSTVECTOR = 070h ;‚lectroniques + +;OCW3 codes registres + IRR = 002h ;Interrupt Request Register + ISR = 003h ;In Service Register +;OCW3 et modes + OCW3 = 008h ;OCW3 + POLLING = 004h ;Polling bit + + +ISR = 0Bh ; Pas d'op‚ration, pas de Poll, lire ISR OCW3 +IRR = 0Ah ; Pas d'op‚ration, pas de Poll, lire IRR + + +;Autorise une interruption ‚lectronique +;Entr‚e : AL - Num‚ro de l'interruption (0-15) … autoriser 0-7 = MASTERPIC , 8-15 = SLAVEPIC +EnableIRQ: +push ax cx dx +mov dx,MASTERPIC+IRQMASK +cmp al,7 +jbe master +mov dx,SLAVEPIC+IRQMASK +master: +mov cl,al +and cl,7 +mov al,1 +shl al,cl +not al +mov ah,al +in al,dx +and al,ah +out dx,al +pop dx cx ax +ret + +;Desactive une interruption ‚lectronique +;Entr‚e : AL - Num‚ro de l'interruption (0-15) … desactiver 0-7 = MASTERPIC , 8-15 = SLAVEPIC +DisableIRQ: +push ax cx dx +mov dx,MASTERPIC+IRQMASK +cmp al,7 +jbe master2 +mov dx,SLAVEPIC+IRQMASK +master2: +mov cl,al +and cl,7 +mov al,1 +shl al,cl +mov ah,al +in al,dx +or al,ah +out dx,al +pop dx cx ax +ret + +;Signale "End Of Interrupt" de l'interruption al +SetEOI: +push ax dx +cmp al,7 +jbe master3 +mov al,EOI +out SLAVEPIC,al +master3: +mov al,EOI +out MASTERPIC,al +pop dx ax +ret + +;Lit les masques d'un contr“leur IRQ dans al, 0 master ou slave 1 ds bh +ReadmaskIrq: +push dx +mov dx,MASTERPIC+ IRQMASK +cmp bh,0 +jne Master5 +mov dx,SLAVEPIC+ IRQMASK +master5: +in al,dx +pop dx +ret + +;Lit le registre d'‚tat d'un contr“leur IRQ dans al, 0 master ou slave 1 ds bh +ReadISR: +push dx +mov dx,MASTERPIC +cmp bh,0 +jne Master6 +mov dx,SLAVEPIC +master6: +mov al,isr +out dx,al +in al,dx +pop dx +ret + +;Lit le registre d'‚tat d'un contr“leur IRQ dans al, 0 master ou slave 1 ds bh +ReadIRR: +push dx +mov dx,MASTERPIC +cmp bh,0 +jne Master7 +mov dx,SLAVEPIC +master7: +mov al,irr +out dx,al +in al,dx +pop dx +ret + +;remplace le handler pointer par ds:si en bx:100h interruption ax +replacehandler: +push ax bx si di ds es +mov es,bx +mov di,0100h +mov ah,4 +int 48h +mov bx,ax +call getint +mov es:[102h],si +mov es:[104h],ds +call setint +pop es ds di si bx ax +ret + +;install le handler pointer par ds:si en bx:100h interruption ax +installhandler: +push bx di es +mov es,bx +mov di,100h +mov ah,4 +int 48h +mov bx,ax +call setint +pop es di bx +ret + +;met es:di le handle de l'int al +setint: +push ax bx ds +call disableirq +cli +xor ah,ah +mov bx,ax +shl bx,2 +xor ax,ax +mov ds,ax +mov ds:[bx],di +mov ds:[bx+2],es +pop ds bx ax +sti +call enableirq +ret + +;met ds:si le handle de l'int al +getint: +push ax bx es +xor ah,ah +mov bx,ax +shl bx,2 +xor ax,ax +mov es,ax +mov si,es:[bx] +mov ds,es:[bx+2] +pop es bx ax +ret + + +end start + diff --git a/prompt.asm b/prompt.asm new file mode 100755 index 0000000..70abaf6 --- /dev/null +++ b/prompt.asm @@ -0,0 +1,233 @@ +.model tiny +.486 +smart +.code + +org 0100h + +start: +mov ah,2 +int 47h +mov ah,6 +int 47h +mov ah,6 +int 47h +mov ah,13 +mov si,offset msg +int 47h +replay: +mov ah,6 +int 47h +mov ah,6 +int 47h +mov ah,13 +mov si,offset prompt +int 47h +mov di,offset buffer +waitchar: +mov ax,0 +int 16h +mov dl,al +mov [di],al +cmp al,0Dh +je entere +inc di +mov ah,7 +int 47h +jmp waitchar +entere: +mov ah,6 +int 47h +mov ah,6 +int 47h +mov byte ptr [di],0 +mov si,offset buffer +call uppercasestr0 +mov bx,offset commands +tre: +mov di,[bx] +add bx,4 +cmp di,0 +je error +push cs +pop es +call cmpstr0 +jne tre +mov bx,[bx-2] +call bx +jmp replay +error: +push cs +pop es +mov dl,'.' +call searchcharstr0 +je noaddext +mov di,offset buffer +mov si,offset extcom +call concatstr0 +noaddext: +mov si,offset buffer +push cs +mov ax,offset arrive +push ax +mov di,offset vga +mov ah,40 +int 47h +mov ax,6000h +mov es,ax +push ax +mov di,0100h +push di +mov ah,4 +int 48h +jc reallyerror + push es + push es + push es + pop ds + pop fs + pop gs + push 7202h + popf +db 0CBh +arrive: +push cs +push cs +push cs +push cs +pop ds +pop es +pop fs +pop gs +mov si,offset vga +mov ah,41 +int 47h +jmp replay +reallyerror: +pop ax +pop ax +pop ax +pop ax +mov ah,13 +mov si,offset Error_Syntax +int 47h +jmp replay + +;met en majuscule la string ds:si +uppercasestr0: +push si ax +uppercaser: +mov al,ds:[si] +inc si +cmp al,0 +je enduppercase +cmp al,'a' +jb uppercaser +cmp al,'z' +ja uppercaser +sub byte ptr [si-1],'a'-'A' +jmp uppercaser +enduppercase: +clc +pop ax si +ret + +;Cherche dl dans la str ds:si -> di +SearchCharStr0: +push ax cx si di es +mov di,si +push ds +pop es +mov cx,0FFh +mov al,0 +cld +repne scasb +neg cx +dec cx +xor ch,ch +mov di,si +mov al,dl +repne scasb +pop es di si cx ax +ret + +;concatŠne la chaine str ds:si avec es:di +concatstr0: +push ax cx dx si di +push es di +mov di,si +push ds +pop es +mov al,0 +mov cx,255 +cld +repne scasb +neg cx +dec cx +xor ch,ch +mov dx,cx +pop di es +mov cx,0FFh +repne scasb +dec di +mov cx,dx +rep movsb +pop di si dx cx ax +ret + +;compare la chaine es:di avec ds:si +cmpstr0: +push cx dx si di +push di +mov al,0 +mov cx,255 +cld +repne scasb +neg cx +mov dx,cx +pop di +push es di +mov di,si +push ds +pop es +mov cx,255 +repne scasb +neg cx +cmp dx,cx +pop di es +jne notequal +dec cx +xor ch,ch +rep cmpsb +notequal: +pop di si dx cx +ret + +Code_Exit: +pop ax +db 0CBh + +Code_Version: +mov ah,13 +mov si,offset Version_Text +int 47h +ret + +Version_Text db 'Cos 2000 version 1.1.1B by Nico',0 +extcom db '.EXE',0 + +commands dw Str_Exit ,Code_Exit + dw Str_Version,Code_Version + dw 0 + + +Str_Exit db 'EXIT',0 +Str_Version db 'VERSION',0 + +Error_Syntax db 'The command doesn''t exit !',0 +prompt db 'COS>',0 +msg db 'Cos command interpretor V1.0',0 +buffer db 255 dup (0) + +vga db 0 +end start diff --git a/system.asm b/system.asm index 4d26b56..dbb0152 100755 --- a/system.asm +++ b/system.asm @@ -7,25 +7,81 @@ org 0100h start: mov si,offset video -mov bx,8400h +mov bx,400h mov ax,47h call installhandler -mov si,offset lpt -mov bx,7400h -mov ax,49h -call installhandler -mov si,offset keyboard -mov bx,7000h -mov ax,9h -call replacehandler mov si,offset timer -mov bx,7800h +mov bx,900h mov ax,8h call replacehandler +mov si,offset pic +mov bx,950h +mov ax,50h +call installhandler mov si,offset drive -mov bx,9000h +mov bx,1020h mov ax,48h call installhandler +mov si,offset keyboard +mov bx,1400h +mov ax,9h +call replacehandler +mov ax,40h +mov es,ax +mov dx,es:[8] +cmp dx,0 +je nolpt1 +mov al,0FFh +add dx,2 +out dx,al +mov si,offset lpt +mov bx,1500h +mov ax,0Fh +call installhandler +mov es,bx +sub al,8 +xor ah,ah +int 50h +mov byte ptr es:[105h],'1' +nolpt1: +push es +mov ax,40h +mov es,ax +mov dx,es:[10] +pop es +cmp dx,0 +je nolpt2 +mov al,0FFh +add dx,2 +out dx,al +mov si,offset lpt +mov bx,1700h +mov ax,0Dh +call installhandler +sub al,8 +xor ah,ah +int 50h +mov es,bx +mov byte ptr es:[105h],'2' +nolpt2: +mov si,offset mouse +mov bx,1900h +mov ax,74h +call installhandler +mov ax,0012 +int 50h +;mov ah, 00010000b +;not ah +;in al, 0a1h +;and al, ah +;out 0a1h, al +mov ah,2 +int 74h + + + + + start2: push cs push cs @@ -398,6 +454,7 @@ ret ;Recherchele fichier et retourne sont path et en cx sont debut Searchfile: push bx dx si di ds es +xor dx,dx push cs pop es mov di,offset temp @@ -540,6 +597,8 @@ extsize equ 5 nbfit equ 255 +mouse db 'mouse.sys',0 +pic db 'pic8259a.sys',0 drive db 'drive.sys',0 timer db 'timer.sys',0 lpt db 'lpt.sys',0 diff --git a/test.asm b/test.asm new file mode 100755 index 0000000..db759cc --- /dev/null +++ b/test.asm @@ -0,0 +1,330 @@ +.model tiny +.486 +smart +.code +org 0100h + + +start: +mov ah,26 +int 47h +mov ax,0001 +int 47h +mov ah,2 +int 47h + +mov si,offset text1 ;titre +mov ah,13 +int 47h +mov ah,6 +int 47h +int 47h + +mov ah,21 +mov cl,3 +int 47h +mov ah,13 +mov si,offset text2 +int 47h +mov ah,6 +int 47h +mov edx,2612182686 +mov ah,8 +int 47h +mov ah,6 +int 47h +mov edx,7576534 +mov ah,8 +int 47h +mov ah,6 +int 47h + +mov ah,21 +mov cl,4 +int 47h +mov si,offset text3 +mov ah,13 +int 47h +mov ah,6 +int 47h +mov edx,-6876253 +mov ah,9 +int 47h +mov ah,6 +int 47h +mov edx,-311212323 +mov ah,9 +int 47h +mov ah,6 +int 47h + +mov ah,21 +mov cl,5 +int 47h +mov ah,13 +mov si,offset text4 +int 47h +mov ah,6 +int 47h +mov edx,0892325457 +mov cx,16 +mov ah,10 +int 47h +mov ah,6 +int 47h +mov edx,0236514 +mov ah,10 +mov cx,32 +int 47h +mov ah,6 +int 47h + +mov ah,21 +mov cl,6 +int 47h +mov ah,13 +mov si,offset text5 +int 47h +mov ah,6 +int 47h +mov edx,3762182686 +mov ah,11 +mov cx,32 +int 47h +mov ah,6 +int 47h +mov edx,2182686 +mov ah,11 +mov cx,16 +int 47h +mov ah,6 +int 47h + +mov ah,21 +mov cl,7 +int 47h +mov ah,13 +mov si,offset text6 +int 47h +mov ah,6 +int 47h +mov dl,'h' +mov ah,7 +int 47h +mov ah,6 +int 47h +mov dl,'@' +mov ah,7 +int 47h +mov ah,6 +int 47h + +mov ah,21 +mov cl,8 +int 47h +mov ah,13 +mov si,offset text7 +int 47h +mov ah,6 +int 47h +mov si,offset textt +mov ah,13 +int 47h +mov ah,6 +int 47h +mov si,offset texttt +mov ah,13 +int 47h + +mov ax,0 +int 16h + +mov ah,2 +int 47h +mov ah,30 +int 47h +mov ah,2 +int 47h + +mov ah,21 +mov cl,5 +int 47h +mov cx,200 +go1: +mov ah,30 +int 47h +mov ah,33 +int 47 +mov ah,20 +xor bh,bh +inc bl +mov si,offset text8 +int 47h +call put +mov ah,30 +int 47h +mov ah,33 +int 47h +dec cx +jnz go1 + +mov ah,21 +mov cl,7 +int 47h +mov cx,200 +go2: +mov si,offset text9 +mov ah,30 +int 47h +mov ah,33 +int 47h +mov ah,6 +int 47h +mov ah,13 +int 47h +call put +mov ah,30 +int 47h +mov ah,33 +int 47h +dec cx +jnz go2 + +mov ah,21 +mov cl,9 +int 47h +mov cx,200 +go3: +mov si,offset text10 +mov ah,30 +int 47h +mov ah,33 +int 47h +xor bh,bh +inc bl +mov ah,20 +int 47h +call put +mov ah,30 +int 47h +mov ah,33 +int 47h +dec cx +jnz go3 + +mov ah,30 +int 47h +mov ah,2 +int 47h +mov bx,040Dh +mov si,offset texte1 +mov ah,20 +int 47h +mov si,offset texte2 +inc bl +mov ah,20 +int 47h +mov ah,30 +int 47h +mov ah,2 +int 47h +mov ah,30 +int 47h + +mov cl,12 +mov ah,21 +int 47h +mov bp,255 +xor edx,edx +go4: +mov ah,30 +int 47h +mov ah,33 +int 47h +inc edx +mov ah,11 +mov cx,16 +int 47h +mov ah,6 +int 47h +mov ah,30 +int 47h +mov ah,33 +int 47h +dec bp +jnz go4 +mov ah,27 +int 47h +xor bx,bx +mov si,offset texte3 +mov ah,20 +int 47h +mov ax,0 +int 16h +db 0CBh + +put: +call random +mov di,dx +and di,4096-2 +mov si,offset text11 +call showstring2 +ret + +Random: +push ax +MOV AX,cs:[RandSeed] +MOV DX,8405h +MUL DX +INC AX +MOV cs:[RandSeed],AX +pop ax +ret + +randseed dw 1234h + +Randomize: +push ax cx dx +mov ah,0 +int 1ah +mov cs:randseed,dx +pop dx cx ax +ret + +texttt db 'Texte',0 +textt db 'Divers',0 +text1 db ' D‚monstration de l''utilisation de la bibliothŠque VIDEO',0 +text2 db 'Nombre entier :',0 +text3 db 'Nombre sign‚ :',0 +text4 db 'Nombre h‚xad‚cimal :',0 +text5 db 'Nombre binaire :',0 +text6 db 'CaractŠres :',0 +text7 db 'Texte :',0 +text8 db 'Scrolling Scrolling Scrolling Scrolling Scrolling Scrolling Scrolling Scrolling',0 +text9 db 'Vertical Vertical Vertical Vertical Vertical Vertical Vertical Vertical',0 +text10 db 'Rapide Rapide Rapide Rapide Rapide Rapide Rapide Rapide',0 +text11 db 'Echange rapide de pages Vid‚o',0 +texte1 db 'Routine d''affichage Ultra Rapide Agissant sur le Mat‚riel',0 +texte2 db 'Possibilit‚ de r‚aliser des effets de superposition',0 +texte3 db 'Sauvegarde et restauration de l''ecran',0 + +showstring2: + push es bx cx si di + add di,4000 + mov bx,0B800h + mov es,bx + mov bl,[si] + mov ch,3 +strinaize4: + inc si + mov cl,[si] + mov es:[di],cx + add di,2 + dec bl + jnz strinaize4 + pop di si cx bx es + ret + + + +end start diff --git a/timer.asm b/timer.asm index a7c11e4..ce6c0b0 100755 --- a/timer.asm +++ b/timer.asm @@ -24,6 +24,65 @@ tsr: mov ax,0B800h mov es,ax mov es:[0],bl +push ds es +pusha +mov ax,40h +mov es,ax +mov ax,0B800h +mov ds,ax +mov word ptr dx,es:[8] + +in al,dx +mov di,158 +decompose: +mov cl,al +and cl,1 +cmp cl,1 +je un +mov byte ptr ds:[di],'0' +jmp errr +un: +mov byte ptr ds:[di],'1' +errr: +shr al,1 +dec di +dec di +cmp di,142 +jne decompose + +inc dx +in al,dx +mov di,318 +decompose2: +mov cl,al +and cl,1 +cmp cl,1 +je un2 +mov byte ptr ds:[di],'0' +jmp errr2 +un2: +mov byte ptr ds:[di],'1' +errr2: +cmp di,314 +jb errrr +mov byte ptr ds:[di],'X' +errrr: +shr al,1 +dec di +dec di +cmp di,302 +jne decompose2 +popa +pop es ds + + + + + + + + + pop es bx ax sti iret diff --git a/video.asm b/video.asm index 775ddc0..52f849b 100755 --- a/video.asm +++ b/video.asm @@ -77,6 +77,58 @@ tables dw setvideomode dw changelineattr dw waitretrace dw getinfos + dw loadbmp + dw showbmp + dw clearscr + dw savedac + dw restoredac + dw savestate + dw restorestate + +;sauve le DAC +savedac: +push ax cx dx di +mov dx,3C7h +xor ax,ax +out dx,al +mov cx,256*3 +inc dx +inc dx +mov di,offset dac +save: +in al,dx +mov cs:[di],al +inc di +dec cx +jne save +pop di dx cx ax +ret + +;restore le DAC +restoredac: +push ax cx dx si +xor ax,ax +cli +mov dx,3DAh +in al,dx +mov dx,0 +out dx,al +mov dx,3C8h +out dx,al +mov cx,256*3 +mov si,offset dac +save2: +mov al,cs:[si] +inc si +out dx,al +dec cx +jne save2 +mov dx,3DAh +in al,dx +mov dx,32 +out dx,al +pop si dx cx ax +ret ;Change la police a CL changefont: @@ -186,7 +238,7 @@ mode1 DB 67H,00H, 03H,00H,03H,00H,02H db 80,25 ;80*50 16 couleurs -mode1b DB 63H, 00H, 03H,01H,03H,01H,02H +mode2 DB 63H, 00H, 03H,01H,03H,01H,02H DB 5FH,4FH,50H,82H,55H,81H,0BFH,1FH,00H,47H,06H,07H,00H,00H,00H DB 00H,9CH,8EH,8FH,28H,1FH,96H,0B9H,0A3H,0FFH DB 00H,00H,00H,00H,00H,10H,0EH,00H,0FFH @@ -204,7 +256,7 @@ mode3 DB 067H,00H,03H,01H,03H,01H,02H db 100,50 ;100*60 16 couleurs -mode4b DB 067H,00H,03H,01H,03H,01H,02H +mode4 DB 0A7H,00H,03H,01H,03H,01H,02H DB 70H,63H,64H,85H,68H,84H,0FFH,1FH,00H,47H,06H,07H,00H,00H,00H DB 00H,0E7H,8EH,0DFH,32H,1FH,0DFH,0E5H,0A3H,0FFH DB 00H,00H,00H,00H,00H,10H,0EH,00H,0FFH @@ -212,9 +264,8 @@ mode4b DB 067H,00H,03H,01H,03H,01H,02H DB 0CH,00H,0FH,00H,00H db 100,60 - ;320*200 16 couleurs -mode4 DB 63H,00H, 03H,09H,0FH,00H,06H +mode5 DB 63H,00H, 03H,09H,0FH,00H,06H DB 2DH,27H,28H,90H,2BH,080H,0BFH,01FH,00H,0C0H,00H,00H,00H,00H,00H,00H DB 9CH,8EH,8FH,14H,00H,96H,0B9H,0E3H,0FFH DB 00H,00H,00H,00H,00H,00H,05H,0FH,0FFH @@ -222,8 +273,8 @@ mode4 DB 63H,00H, 03H,09H,0FH,00H,06H DB 41H,00H,0FH,00H,00H db 40,25 -;320*200 256 couleurs -mode5 DB 63H, 00H, 03H,01H,0FH,00H,0EH +;320*200 256 couleurs +mode6 DB 63H, 00H, 03H,01H,0FH,00H,0EH DB 5FH,4FH,50H,82H,54H,80H,0BFH,1FH,00H,41H,00H,00H,00H,00H,00H,00H DB 9CH,0EH,8FH,28H,40H,96H,0B9H,0A3H,0FFH DB 00H,00H,00H,00H,00H,40H,05H,0FH,0FFH @@ -231,8 +282,17 @@ mode5 DB 63H, 00H, 03H,01H,0FH,00H,0EH DB 41H,00H,0FH,00H,00H db 00,00 +;320*400 256 couleurs chain4 +mode7 DB 63H, 00H, 03H,01H,0FH,00H,06H + DB 5FH,4FH,50H,82H,54H,80H,0BFH,1FH,00H,40H,00H,00H,00H,00H,00H,00H + DB 9CH,8EH,8FH,28H,00H,96H,0B9H,0E3H,0FFH + DB 00H,00H,00H,00H,00H,40H,05H,0FH,0FFH + DB 00H,01H,02H,03H,04H,05H,06H,07H,08H,09H,0AH,0BH,0CH,0DH,0EH,0FH + DB 41H,00H,0FH,00H,00H + db 00,00 + ;640*400 16 couleurs -mode6 DB 63H, 00H, 03H,01H,0FH,00H,0EH +mode8 DB 63H, 00H, 03H,01H,0FH,00H,0EH DB 5FH,4FH,50H,82H,54H,80H,0BFH,1FH,00H,41H,00H,00H,00H,00H,00H,00H DB 9CH,0EH,8FH,28H,40H,96H,0B9H,0A3H,0FFH DB 00H,00H,00H,00H,00H,10H,05H,0FH,0FFH @@ -241,7 +301,7 @@ mode6 DB 63H, 00H, 03H,01H,0FH,00H,0EH db 00,00 ;640*400 256 couleurs -mode7 DB 63H, 00H, 03H,01H,0FH,00H,0EH +mode9 DB 63H, 00H, 03H,01H,0FH,00H,0EH DB 2DH,27H,27H,91H,2AH,9FH,0BFH,1FH,00H,0C0H,00H,00H,00H,00H,00H,00H DB 9CH,0EH,8FH,50H,00H,8FH,0C0H,0E3H,0FFH DB 00H,00H,00H,00H,00H,40H,05H,0FH,0FFH @@ -368,7 +428,7 @@ out dx,ax inc al inc di cmp al,9 -jb initgraphic +jb initgraphic mov dx,statut in al,dx mov dx,attribs @@ -453,6 +513,7 @@ mov bl,cs:y xor bh,bh mov cl,cs:lines dec cl +dec cl cmp bl,cl jne scro dec bl @@ -572,6 +633,19 @@ SaveScreen: pop es ds di si cx ret +;===================================sauve l'ecran rapidement en es:di================ +SaveScreento: + push cx si di ds + mov cx,0B800H + mov ds,cx + mov cx,cs:pagesize + shr cx,2 + xor si,si + cld + rep movsd + pop ds di si cx + ret + ;===================================sauve l'ecran rapidement================ Savepage1: push cx si di ds es @@ -604,6 +678,19 @@ RestoreScreen: pop es ds di si cx ret +;===================================restore l'ecran rapidement de ds:si================ +RestoreScreenfrom: + push cx si di ds es + mov cx,0B800H + mov es,cx + mov cx,cs:pagesize + shr cx,2 + xor di,di + cld + rep movsd + pop es ds di si cx + ret + ;===============================Page2to1============================ Page2to1: push cx si di ds es @@ -912,6 +999,392 @@ rep movsb pop ds di si cx ret + +clearscr: +push eax cx +mov cx,320*200/4 +mov eax,0 +rep movsd +pop cx eax + +loadbmp: +push ax bx cx dx bp ds +mov ax,ds:[18] +mov si,ax +shr ax,2 +and si,11b +cmp si,0 +je is4x +add ax,1 +is4x: +mov cs:sizeh,ax +mov ax,ds:[22] +mov cs:sizev,ax +mov di,0FFFFh-1024 +mov si,54 +mov cl, 0ffh +paletteload: +lodsb +shr al, 2 +mov [di+2], al +lodsb +shr al, 2 +mov [di+1], al +lodsb +shr al, 2 +mov [di+0], al +inc si +add di, 3 +dec cl +jnz paletteload +mov si,0FFFFh-1024 +mov dx, 3c8h +cld +mov cl, 0ffh +xor bx, bx +palettemake: +mov al, bl +out dx, al +inc dx +lodsb +out dx, al +lodsb +out dx, al +lodsb +out dx, al +dec dx +inc bl +dec cl +jnz palettemake +pop ds bp dx cx bx ax +ret +sizeh dw 0 +sizev dw 0 + +showbmp: +push ax bx cx dx si di ds es +mov dx,cs:sizev +add bx,dx +mov di,cx +mov ax,bx +shl ax,6 +shl bx,8 +add di,bx +add di,ax +mov bx,di +mov ax,0A000H +mov es,ax +mov si,1024+54 +mov ax,cs:sizeh +bouclebmp: +cmp di,64000 +jae nopp +cld +rep movsd +no: +mov cx,ax +sub bx,320 +mov di,bx +dec dx +jnz bouclebmp +fin: +pop es ds di si dx cx bx ax +ret +nopp: +shl cx,2 +add si,cx +jmp no + +fire: +push ax cx dx si di +xor si,si +xor di,di +mov cx,64000 +makefire: +xor ax,ax +mov al,[si] +add al,[si+321] +adc ah,0 +add al,[si-321] +adc ah,0 +add al,[si+320] +adc ah,0 +shr ax,2 +cmp al,191 +jb pp +mov al,191 +pp: +cmp al,0 +je p +dec ax +p: +mov es:[di],al +inc si +inc di +dec cx +jnz makefire +pop di si dx cx ax +ret + +fireflamme: +push ax cx dx si di +xor si,si +xor di,di +mov cx,64000 +makefire2: +xor ax,ax +mov al,[si] +add al,[si+1] +adc ah,0 +add al,[si-1] +adc ah,0 +add al,[si+320] +adc ah,0 +shr ax,2 +cmp al,191 +jb ppp +mov al,191 +ppp: +cmp al,0 +je pppp +dec ax +pppp: +mov es:[di],al +inc si +inc di +dec cx +jnz makefire2 +pop di si dx cx ax +ret + +gauss: +push ax cx dx si di +xor si,si +xor di,di +mov cx,64000 +makegauss: +xor ax,ax +mov al,[si+1] +add al,[si-1] +adc ah,0 +add al,[si+321] +adc ah,0 +add al,[si+320] +adc ah,0 +add al,[si+319] +adc ah,0 +add al,[si-321] +adc ah,0 +add al,[si-320] +adc ah,0 +add al,[si-319] +adc ah,0 +shr ax,3 +mov es:[di],al +inc si +inc di +dec cx +jnz makegauss +pop di si dx cx ax +ret + +lowgauss: +push ax cx dx si di +xor si,si +xor di,di +mov cx,64000 +makegausss: +xor ax,ax +mov al,[si+1] +add al,[si-1] +adc ah,0 +add al,[si+320] +adc ah,0 +add al,[si-320] +adc ah,0 +shr ax,2 +mov es:[di],al +inc si +inc di +dec cx +jnz makegausss +pop di si dx cx ax +ret + +firepalett: +push ax cx dx +mov dx,03C8h +xor ax,ax +out dx,al +inc dx +mov cx,64 +rouge1: +out dx,al +push ax +xor al,al +out dx,al +out dx,al +pop ax +inc ax +loop rouge1 +mov cx,64 +jaune1: +push ax +mov al,63 +out dx,al +pop ax +out dx,al +push ax +xor al,al +out dx,al +pop ax +inc ax +loop jaune1 +mov cx,63 +blanc1: +push ax +mov al,63 +out dx,al +out dx,al +pop ax +out dx,al +loop blanc1 +pop dx cx ax +ret + +allfirepalett: +push ax cx dx +mov dx,03C8h +xor ax,ax +out dx,al +inc dx +mov cx,64 +rouge: +push ax +shr ax,1 +out dx,al +xor al,al +out dx,al +out dx,al +pop ax +inc ax +loop rouge +mov cx,64 +rouge2: +push ax +shr ax,1 +out dx,al +xor al,al +out dx,al +out dx,al +pop ax +inc ax +loop rouge2 +mov cx,64 +Jaune: +push ax +mov al,63 +out dx,al +pop ax +out dx,al +push ax +xor al,al +out dx,al +pop ax +inc ax +loop jaune +mov cx,64 +blanc: +push ax +mov al,63 +out dx,al +out dx,al +pop ax +out dx,al +loop blanc +pop dx cx ax +ret + +gaussscreen: +push ax ds es +mov ax,0A000h +mov ds,ax +push fs +pop es +call gauss +push ds +pop es +push fs +pop ds +call Copyscreen +pop es ds ax +ret + +lowgaussscreen: +push ax ds es +mov ax,0A000h +mov ds,ax +push fs +pop es +call lowgauss +push ds +pop es +push fs +pop ds +call Copyscreen +pop es ds ax +ret + +firescreen: +push ax ds es +mov ax,0A000h +mov ds,ax +push fs +pop es +call fire +push ds +pop es +push fs +pop ds +call Copyscreen +pop es ds ax +ret + +copyscreen: +push si di cx +xor si,si +xor di,di +mov cx,64000/4 +rep movsd +pop cx di si +ret + +;Sauve l'‚tat de la carte en es:di +savestate: +push cx si di ds +push cs +pop ds +mov cx,10 +mov si,offset lines +cld +rep movsb +call savescreento +pop ds di si cx +ret + +;R‚cupŠre l'‚tat de la carte en ds:si +restorestate: +push cx si di es +push cs +pop es +mov cx,10 +mov di,offset lines +cld +rep movsb +call restorescreenfrom +pop es di si cx +ret + lines db 0 columns db 0 x db 0 @@ -923,7 +1396,7 @@ pagesize dw 0 font equ $ copy equ $+4000 copy2 equ $+8000 - -endofme equ $ +12000 +dac equ $+12000 +endofme equ $ +12768 end start