From a74c82503e71e16aba2b05497c0bb5ac80801000 Mon Sep 17 00:00:00 2001 From: Stefan Koelle <50440224+skoelle@users.noreply.github.com> Date: Fri, 3 Jan 2025 19:41:51 +0100 Subject: [PATCH] Add files via upload Initial commit --- xlibunit.pas | 576 +++++++++++++++++++++++++++++++++++++++++++++++++++ xlibunit.tpu | Bin 0 -> 7728 bytes 2 files changed, 576 insertions(+) create mode 100644 xlibunit.pas create mode 100644 xlibunit.tpu diff --git a/xlibunit.pas b/xlibunit.pas new file mode 100644 index 0000000..c920271 --- /dev/null +++ b/xlibunit.pas @@ -0,0 +1,576 @@ +{ >>> *The X-LIB UNiT V0.3á* <<< - first beta release } + +(* + Hi Everybody! + this is the XLIB-UNIT + made by Stefan KOelle + You can use this LIB freely, but you have to + credit me in you program and you have to send me a fido messy to: + Stefan Koelle 2:2480/330 + + New in this version: Virtual Horizontal 640 Pixel + + If you have any questions then also write a message to me + Comming soon: Double wide + Panning + Lines, Circle, Ellipse -Draw + Demosource using the LIB + and even more... +*) + +unit xlibunit; + +interface +type paltype=array[0..767] of byte; +var textpal:array[1..3,0..15] of byte; +procedure initxlib; {init vgamode 13} +procedure initxmode; {init xmode} +procedure clearxmode; {quick clearscreen for xmode} +procedure cleartext; {quick clearscreen for txtmode} +procedure exitxlib; {exit lib and init vgamode 3} +procedure point(x,y,c:word); {point in xmode} +procedure blackpal; {all colors in black} +procedure vert_retr; {wait for vert-retr} +procedure fadeup(scol:paltype;speed:integer); {fadeup-palette} +procedure fadedown(scol:paltype;speed:integer); {fadedown-palette} +procedure copypic13(s,o,b,c:word); {copy pic from segment o + and offset o + to vga from begin b + c times + in mode 13} +procedure copypicx(s,o,b,c:word); {same as copypic13 but in xmode} +procedure copypicxd(s,o,b,c:word); {same as copypic13 but in xmode + but in virtual horizontal 640} +procedure copypal(s,o,b,c,ps,po:word); {copy pal from segment o + and offset o + at begin b + c times + to pal at segment s + and offset o} +procedure startingarea(s:word); {Linear Staring Area} +procedure vert400; {Switch to 320*400} +procedure vert200; {Switch to 320*200} +procedure vert100; {Switch to 320*100 not testet!} +procedure hor640; {Switch to virual horizontal 640} +procedure hor320; {Switch to normal horizontal 320} +procedure vpan(b:byte); +procedure hpan(b:byte); +procedure hbegin(b:byte); +Procedure CRTC_UnProtect; +Procedure CRTC_Protect; +procedure unprotect; +procedure protect; +procedure hor_retr; +procedure moveblock(s,d,b,h,p:word); +procedure setdac(c,r,g,b:byte); +procedure print(x,y:byte;s:string;c:byte); +procedure locate(x,y:word); +function key:boolean; + +implementation +procedure initxlib; assembler; +asm + mov ax,13h + int 10h +end; +procedure clearxmode; assembler; +asm + mov dx,3c4h + mov al,02h + out dx,al + inc dx + mov al,00001111b + out dx,al + mov ax,0a000h + mov es,ax + mov cx,0ffffh + xor di,di + xor ax,ax + cld + rep stosw +end; +procedure initxmode; assembler; +asm + mov dx,3c4h + mov al,4 + out dx,al + inc dx + in al,dx + and al,11110111b {Enable Chain4} + or al,00000100b {Odd/Even} + out dx,al + + mov dx,3d4h + mov al,14h + out dx,al + inc dx + in al,dx + and al,10111111b {Disable Doubleword addressing} + out dx,al + + mov dx,3d4h + mov al,17h + out dx,al + inc dx + in al,dx + or al,01000000b {Byte Mode} + out dx,al +end; +procedure cleartext; assembler; +asm + mov ax,0b800h + mov es,ax + mov cx,01fffh + xor di,di + mov ax,$0720 + cld + rep stosw +end; +procedure exitxlib; assembler; +asm + mov ax,3h + int 10h + jmp cleartext +end; +procedure point(x,y,c:word); assembler; +asm + mov ax,0a000h + mov es,ax + + mov cx,x + and cx,3 + mov ax,1 + shl ax,cl + mov ah,al + mov dx,3c4h + mov al,2 + out dx,ax + + mov ax,80 + mul y + mov di,ax + mov ax,x + shr ax,2 + add di,ax + mov al,byte ptr c + mov es:[di],al +end; +procedure blackpal; assembler; +asm + mov cx,255 + @delloop: + mov dx,3c8h + mov ax,cx + out dx,ax + mov dx,3c9h + mov ax,0 + out dx,ax + out dx,ax + out dx,ax + loop @delloop +end; +procedure vert_retr; assembler; +asm + mov dx,$3da + @wait1: + in al,dx + test al,$8 + jnz @wait1 + @wait2: + in al,dx + test al,$8 + jz @wait2 +end; +procedure fadeup(scol:paltype;speed:integer); +var i,j:integer; +begin + for i:=1 to speed do begin + vert_retr; + for j:=0 to 255 do begin + port[$3c8]:=j; + port[$3c9]:=(scol[j*3]*i) div speed; + port[$3c9]:=(scol[j*3+1]*i) div speed; + port[$3c9]:=(scol[j*3+2]*i) div speed; + end; + end; +end; +procedure fadedown(scol:paltype;speed:integer); +var i,j:integer; +begin + for i:=speed downto 1 do begin + vert_retr; + for j:=0 to 255 do begin + port[$3c8]:=j; + port[$3c9]:=(scol[j*3]*i) div speed; + port[$3c9]:=(scol[j*3+1]*i) div speed; + port[$3c9]:=(scol[j*3+2]*i) div speed; + end; + end; +end; +procedure copypic13(s,o,b,c:word); assembler; +asm + push es + push ds + push di + push si + mov ds,s + mov si,o + mov ax,0a000h + mov es,ax + mov di,b + mov cx,c + rep movsw + pop si + pop di + pop ds + pop es +end; +procedure copypicx(s,o,b,c:word); assembler; +asm + push es + push ds + push di + push si + + mov dl,00000001b {Init} + mov ds,s {Segs. laden} + mov ax,0a000h + mov es,ax + mov si,o + + @planeloop: + mov cl,dl {Plane setzten} + mov dx,3c4h + mov al,02h + out dx,al + inc dx + mov al,cl + out dx,al + mov dl,al + + mov di,b + mov cx,c + + @copy1plane: + movsb + add si,3 + loop @copy1plane + + sub si,c + sub si,c + sub si,c + sub si,c + add si,1 + shl dl,1 + cmp dl,10h + jne @planeloop + + pop si + pop di + pop ds + pop es +end; +procedure copypicxd(s,o,b,c:word); assembler; +asm + push es + push ds + push di + push si + + mov dl,00000001b {Init} + mov ds,s {Segs. laden} + mov ax,0a000h + mov es,ax + mov si,o + + @planeloop: + mov cl,dl {Plane setzten} + mov dx,3c4h + mov al,02h + out dx,al + inc dx + mov al,cl + out dx,al + mov dl,al + + mov di,b + mov cx,c + + mov al,80 + + @copy1plane: + movsb + add si,3 + dec al + cmp al,0 + jnz @weitercopy + mov al,80 + add di,80 + @weitercopy: + loop @copy1plane + + sub si,c + sub si,c + sub si,c + sub si,c + add si,1 + shl dl,1 + cmp dl,10h + jne @planeloop + + pop si + pop di + pop ds + pop es +end; +procedure copypal(s,o,b,c,ps,po:word); assembler; +asm + push es + push ds + push di + push si + mov ds,s + mov si,o + mov es,ps + mov ax,po + add ax,b + mov di,ax + mov cx,c + rep movsb + pop si + pop di + pop ds + pop es +end; +procedure startingarea(s:word); assembler; +asm + mov dx,3d4h + mov al,0ch + mov ah,byte ptr s + 1 + out dx,ax + mov al,0dh + mov ah,byte ptr s + out dx,ax +end; +procedure vert400; assembler; +asm + mov dx,3d4h + mov al,9 + out dx,al + inc dx + in al,dx + and al,01110000b + out dx,al +end; +procedure vert200; assembler; +asm + mov dx,3d4h + mov al,9 + out dx,al + inc dx + in al,dx + or al,00000001b + out dx,al +end; +procedure vert100; assembler; +asm + mov dx,3d4h + mov al,9 + out dx,al + inc dx + in al,dx + or al,00000010b + out dx,al +end; +procedure hor640; assembler; +asm + mov dx,3d4h + mov ax,5013h + out dx,ax +end; +procedure hor320; assembler; +asm + mov dx,3d4h + mov ax,2813h + out dx,ax +end; +procedure vpan(b:byte); assembler; +asm + mov dx,3d4h + mov al,8 + mov ah,b + out dx,ax +end; +procedure hpan(b:byte); assembler; +asm + mov dx,3dah + in al,dx + + mov dx,3c0h + mov al,13h or 32d + out dx,al + mov al,b + or al,32d + out dx,al +end; +procedure hbegin(b:byte); assembler; +asm + mov dx,3d4h + mov al,4 + mov ah,b + out dx,ax +end; +Procedure CRTC_UnProtect; +Begin + Port[$3d4]:=$11; {Register 11h des CRTC (Vertical Sync End)} + Port[$3d5]:=Port[$3d5] and not $80 {Bit 7 (Protection Bit) l”schen} +End; +Procedure CRTC_Protect; +Begin + Port[$3d4]:=$11; {Register 11h des CRTC (Vertical Sync End)} + Port[$3d5]:=Port[$3d5] or $80 {Bit 7 (Protection Bit) setzen} +End; +procedure unprotect; assembler; +asm + mov dx,3d4h + mov al,11h + out dx,al + inc dx + in al,dx + and al,10111111b + out dx,al +end; +procedure protect; assembler; +asm + mov dx,3d4h + mov al,11h + out dx,al + inc dx + in al,dx + or al,01000000b + out dx,al +end; +procedure hor_retr; assembler; +asm + mov dx,3dah + @in_display: + in al,dx + test al,1 + je @in_display + @in_retrace: + in al,dx + test al,1 + jne @in_retrace +end; +procedure moveblock(s,d,b,h,p:word); assembler; +asm + push ds + push es + push si + push di + + mov dx,3ceh {Select all planes} + mov ax,4105h + out dx,ax + mov dx,3c4h + mov ax,0f02h + out dx,ax + + mov ax,0a000h + mov es,ax + mov ds,ax + mov si,s + mov di,d + mov dx,h + +@line_lp: + mov cx,b + rep movsb + add si,p + add di,p + + dec dx + jne @line_lp + + pop di + pop si + pop es + pop ds +end; +procedure setdac(c,r,g,b:byte); assembler; +asm + mov dx,3c8h + mov al,c + out dx,al + inc dx + mov al,r + out dx,al + mov al,g + out dx,al + mov al,b + out dx,al +end; +procedure print(x,y:byte;s:string;c:byte); +var i:byte; +begin + for i:=1 to length(s) do begin + mem[$b800:(i-1+x)*2+y*160]:=ord(s[i]); + mem[$b800:(i-1+x)*2+y*160+1]:=c; + end; +end; +procedure locate(x,y:word); assembler; +asm + mov ah,02h + xor bh,bh + mov dh,byte ptr x + mov dl,byte ptr y + int 10h +end; +procedure splitscreen(b:byte); assembler; +asm + mov bl,b + xor bh,bh + shl bx,1 + mov cx,bx + + mov dx,3d4h + mov al,07h + out dx,al + inc dx + in al,dx + and al,11101111b + shr cx,4 + and cl,16 + or al,cl + out dx,al + + dec dx + mov al,09h + out dx,al + inc dx + in al,dx + and al,10111111b + shr bl,3 + and bl,64 + or al,bl + out dx,al + + dec dx + mov al,18h + mov ah,b + shl ah,1 + out dx,ax +end; +function key:boolean; +begin + if port[$60] and 128=128 then key:=false else key:=true; +end; +var i:byte; +begin + for i:=0 to 15 do begin + port[$3c7]:=i; + textpal[1,i]:=port[$3c9]; + textpal[2,i]:=port[$3c9]; + textpal[3,i]:=port[$3c9]; + end; +end. \ No newline at end of file diff --git a/xlibunit.tpu b/xlibunit.tpu new file mode 100644 index 0000000000000000000000000000000000000000..f859de4767a9aedc1f76f59d4f86229d4f68b2d0 GIT binary patch literal 7728 zcmc&(4Nz3q6~6brw{PFRT@f@fhWbO%(r7e6gVZ0ihzT(nV*#Tvtx*uxNJQ9y1#!|^ zHl&D)QjOTC+6w4vhyd*s<=b?77(vG?-^3i@i<505;`d^yus+C2B%gc)k-HaVPcO5?QEKnA# zEpt0pGp4;qJiKOEU3o?BwJzsG-oqTS5fAEuDCTfHj7b_^!%(~vI*eso-Ofrk%*X|v zIZ~+lx(hnKfpjdc zlEPxQN2LxOiBgc*EDVU~dtrpsRwjrbeDQqIs^(v zgYpts=f6{#( zburX;N2$xv-O@YQiDnGLN{^ZgyTC2kQGZRl0*|^9hMBhh{T;YL7+Q5hjHT*=+2$xS zWxzQ5&4#1Qomc8EEPgVt)S2f|D=F$IFFfRhTBB)6Nlx~#D(DT<`UeS-p)#3NYQZLa ztI8x&*$kEO1F0x0OG;Bypz$&^Qf|`Fcn)dYHyIiY(3o|T1|pFwTzSPFbvx?kM%8nD z9STk4$SZZFMkp;GSZSGrww61eEQBu~)P6az8XAn5lk@1DWebb5N=w|%d^cB{p}r+b z9U_+F&^5z)Es!+~q-QHHc7>dISO=7L+@#dSbF5*N^HAAylM32XF<8cGx(J4&$f4n;omBL_5SPVOimijI zH(*rs9Y#&ev`oTmAjUkm)1%U+dpycYL_~=Oq*czfT%{8&)zKGIDFR`PPOGahrzdn; zr9-Fx^S?c<`VO*NFI~WP*==pdJDXP~YI@|fpow3bsP^OY6O}MOa0|25Y&F#5Y`HAI zq$rVnLx(JFop5L=b2*&_a6&TLNhhk=yioK8Og_V@Ir?w%?Wm{zn>=|+vZZ2cBTe$O z%hje7U0 z?kOhBhdepL{0`ld7Ur95*}_$Z?wbxiBtZ$HHU-ocRsa@tsQ(J1n-jGas?lrdr9a;< z%h5fB;!b==jQx*#A~V_>&6y)b zy3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