From: sparky4 Date: Wed, 9 Dec 2015 16:31:09 +0000 (-0600) Subject: wwww X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=a2c9fecb49f628620e6e11450864ded097cc3f96;p=16.git wwww --- diff --git a/16/mxbb.asm b/16/mxbb.asm new file mode 100755 index 00000000..a403c631 --- /dev/null +++ b/16/mxbb.asm @@ -0,0 +1,208 @@ +.387 + PUBLIC MXBITBLT + EXTRN SUBHORIZONTALLINEINFO:BYTE + EXTRN MX_VIDEOSEGMENT:BYTE + EXTRN MX_BYTESPERLINE:BYTE +MX_TEXT SEGMENT PARA PUBLIC USE16 'CODE' + ASSUME CS:MX_TEXT, DS:DGROUP, SS:DGROUP +MXBITBLT: + push bp + mov bp,sp + sub sp,16H + push ds + push si + push es + push di + cmp word ptr 0cH[bp],0 + je L$2 + mov ax,word ptr 10H[bp] + and al,3 + mov dx,word ptr 8[bp] + and dl,3 + mov bx,offset L$10 + cmp al,dl + jne L$1 + mov bx,offset L$3 +L$1: + call bx +L$2: + xor ax,ax + pop di + pop es + pop si + pop ds + mov sp,bp + pop bp + retf 0cH +L$3: + mov bx,word ptr 8[bp] + mov ax,word ptr 6[bp] + mov cx,word ptr 0cH[bp] + call near ptr MX_TEXT:SUBHORIZONTALLINEINFO + mov byte ptr -14H[bp],al + mov byte ptr -16H[bp],ah + mov word ptr 0cH[bp],cx + mov ax,word ptr cs:MX_VIDEOSEGMENT + mov ds,ax + mov es,ax + mov ax,word ptr 0eH[bp] + mul word ptr cs:MX_BYTESPERLINE + mov si,word ptr 10H[bp] + shr si,1 + shr si,1 + add si,ax + mov dx,3ceH + mov ax,4105H + out dx,ax + cld + mov ah,byte ptr -14H[bp] + or ah,ah + je L$5 + mov dx,3c4H + mov al,2 + out dx,ax + mov ax,word ptr cs:MX_BYTESPERLINE + dec ax + mov cx,word ptr 0aH[bp] + push si + push di +L$4: + movsb + add si,ax + add di,ax + dec cx + jne L$4 + pop di + pop si + inc si + inc di +L$5: + mov bx,word ptr 0cH[bp] + test bx,bx + je L$7 + mov dx,3c4H + mov ax,0f02H + out dx,ax + mov ax,word ptr cs:MX_BYTESPERLINE + sub ax,bx + mov dx,word ptr 0aH[bp] + push si + push di +L$6: + mov cx,bx + rep movsb + add si,ax + add di,ax + dec dx + jne L$6 + pop di + pop si + add si,bx + add di,bx +L$7: + mov ah,byte ptr -16H[bp] + or ah,ah + je L$9 + mov dx,3c4H + mov al,2 + out dx,ax + mov ax,word ptr cs:MX_BYTESPERLINE + dec ax + mov cx,word ptr 0aH[bp] +L$8: + movsb + add si,ax + add di,ax + dec cx + jne L$8 +L$9: + mov dx,3ceH + mov ax,4005H + out dx,ax + ret +L$10: + mov cx,word ptr 0cH[bp] + mov bx,cx + shr bx,1 + shr bx,1 + and cl,3 + mov al,8 + shr al,cl + mov si,6 +L$11: + mov word ptr -8[bp+si],bx + shr al,1 + adc bx,0 + dec si + dec si + jge L$11 + mov ax,word ptr cs:MX_VIDEOSEGMENT + mov ds,ax + mov es,ax + mov ax,word ptr 0eH[bp] + mul word ptr cs:MX_BYTESPERLINE + mov si,word ptr 10H[bp] + shr si,1 + shr si,1 + add si,ax + mov word ptr -0aH[bp],si + mov ax,word ptr 6[bp] + mul word ptr cs:MX_BYTESPERLINE + mov di,word ptr 8[bp] + shr di,1 + shr di,1 + add di,ax + mov word ptr -0cH[bp],di + mov ax,word ptr 10H[bp] + and al,3 + mov byte ptr -10H[bp],al + mov cx,word ptr 8[bp] + and cl,3 + mov al,11H + shl al,cl + mov byte ptr -12H[bp],al + cld + mov byte ptr -0eH[bp],4 + lea bx,-8[bp] +L$12: + cmp word ptr ss:[bx],0 + je L$15 + mov ah,byte ptr -12H[bp] + and ah,0fH + mov al,2 + mov dx,3c4H + out dx,ax + mov ah,byte ptr -10H[bp] + mov al,4 + mov dx,3ceH + out dx,ax + mov dx,word ptr 0aH[bp] + mov ax,word ptr cs:MX_BYTESPERLINE + sub ax,word ptr ss:[bx] +L$13: + mov cx,word ptr ss:[bx] + shr cx,1 + rep movsw + rcl cx,1 + rep movsb + add si,ax + add di,ax + dec dx + jne L$13 + inc bx + inc bx + inc byte ptr -10H[bp] + and byte ptr -10H[bp],3 + jne L$14 + inc word ptr -0aH[bp] +L$14: + rol byte ptr -12H[bp],1 + adc word ptr -0cH[bp],0 + mov si,word ptr -0aH[bp] + mov di,word ptr -0cH[bp] + dec byte ptr -0eH[bp] + jne L$12 +L$15: + ret +MX_TEXT ENDS + END diff --git a/16/x/MODEX.BAK b/16/x/MODEX.BAK deleted file mode 100755 index 560a1c68..00000000 Binary files a/16/x/MODEX.BAK and /dev/null differ diff --git a/16/x/MODEX.LBR b/16/x/MODEX.LBR index 93fc7801..b1ec26b6 100755 --- a/16/x/MODEX.LBR +++ b/16/x/MODEX.LBR @@ -21,7 +21,6 @@ +-MXPI.OBJ & +-MXPN.OBJ & +-MXPP.OBJ & -+-MXPT.OBJ & +-MXRA.OBJ & +-MXRP.OBJ & +-MXSA.OBJ & diff --git a/16/x/makefile.wat b/16/x/makefile.wat new file mode 100755 index 00000000..7d76eadb --- /dev/null +++ b/16/x/makefile.wat @@ -0,0 +1,59 @@ +!ifdef __LINUX__ +REMOVECOMMAND=rm -f +COPYCOMMAND=cp -f +DIRSEP=/ +OBJ=o +!else +REMOVECOMMAND=del +COPYCOMMAND=copy /y +DIRSEP=\ +OBJ=obj +!endif + +TARGET_OS = dos + +DISS=wdis -a +REDR=">" ..$(DIRSEP)xw_$(DIRSEP) + +all: + @beep + +pee: .symbolic +$(DISS) MXBB.OBJ $(REDR)mxbb.asm +$(DISS) MXCC.OBJ $(REDR)mxcc.asm +$(DISS) MXCG.OBJ $(REDR)mxcg.asm +$(DISS) MXCL.OBJ $(REDR)mxcl.asm +$(DISS) MXCR.OBJ $(REDR)mxcl.asm +$(DISS) MXFB.OBJ $(REDR)mxfb.asm +$(DISS) MXFP.OBJ $(REDR)mxfp.asm +$(DISS) MXGC.OBJ $(REDR)mxgc.asm +$(DISS) MXGI.OBJ $(REDR)mxgi.asm +$(DISS) MXGM.OBJ $(REDR)mxgm.asm +$(DISS) MXGP.OBJ $(REDR)mxgp.asm +$(DISS) MXGV.OBJ $(REDR)mxgv.asm +$(DISS) MXHL.OBJ $(REDR)mxhl.asm +$(DISS) MXIT.OBJ $(REDR)mxit.asm +$(DISS) MXLL.OBJ $(REDR)mxll.asm +$(DISS) MXLN.OBJ $(REDR)mxln.asm +$(DISS) MXOT.OBJ $(REDR)mxot.asm +$(DISS) MXPB.OBJ $(REDR)mxpb.asm +$(DISS) MXPF.OBJ $(REDR)mxpf.asm +$(DISS) MXPG.OBJ $(REDR)mxpg.asm +$(DISS) MXPI.OBJ $(REDR)mxpi.asm +$(DISS) MXPN.OBJ $(REDR)mxpn.asm +$(DISS) MXPP.OBJ $(REDR)mxpp.asm +$(DISS) MXRA.OBJ $(REDR)mxra.asm +$(DISS) MXRP.OBJ $(REDR)mxrp.asm +$(DISS) MXSA.OBJ $(REDR)mxsa.asm +$(DISS) MXSC.OBJ $(REDR)mxsc.asm +$(DISS) MXSI.OBJ $(REDR)mxsi.asm +$(DISS) MXSL.OBJ $(REDR)mxsl.asm +$(DISS) MXSM.OBJ $(REDR)mxsm.asm +$(DISS) MXSP.OBJ $(REDR)mxsp.asm +$(DISS) MXSS.OBJ $(REDR)mxss.asm +$(DISS) MXTL.OBJ $(REDR)mxtl.asm +$(DISS) MXVS.OBJ $(REDR)mxvs.asm +$(DISS) MXWD.OBJ $(REDR)mxwd.asm +$(DISS) MXWM.OBJ $(REDR)mxwm.asm +$(DISS) MXWP.OBJ $(REDR)mxwp.asm +$(DISS) MXWR.OBJ $(REDR)mxwr.asm diff --git a/16/x/modex.lbr b/16/x/modex.lbr index 93fc7801..b1ec26b6 100755 --- a/16/x/modex.lbr +++ b/16/x/modex.lbr @@ -21,7 +21,6 @@ +-MXPI.OBJ & +-MXPN.OBJ & +-MXPP.OBJ & -+-MXPT.OBJ & +-MXRA.OBJ & +-MXRP.OBJ & +-MXSA.OBJ & diff --git a/16/xw/modex/demo01.c b/16/xw/modex/demo01.c new file mode 100755 index 00000000..0908fdf4 --- /dev/null +++ b/16/xw/modex/demo01.c @@ -0,0 +1,125 @@ +/* + DEMO01 - Sprites, page flipping and palette rotation + Copyright (c) 1994 Alessandro Scotti +*/ +uses Crt, Modex; + +#DEFINE MAX_SPRITE 100 +type + (* Sprite structure *) + TSprite = record + X, Y : integer; (* Sprite coordinates *) + DX,DY: integer; (* Deltas for sprite movement *) + W, H : integer; (* Sprite width and height *) + Image: array[ 1..16, 1..16 ] of byte; (* Sprite image data *) + end; + (* RGB color structure *) + TRgb = record + R, G, B: byte; + end; +var + S : array[ 1..MAX_SPRITE ] of TSprite; (* An array of sprites *) + Palette: array[ byte ] of TRgb; (* Palette *) + Page : word; (* Page offset *) + I : word; + +(* Initializes a sprite structure *) +procedure sxInit( var S: TSprite ); +var + I: word; +begin + S.X := Random( 320 ); (* Initialize position with random values *) + S.Y := Random( 240 ); + S.DX := Random( 7 )-3; (* Initialize speed with random values *) + S.DY := Random( 7 )-3; + S.W := 16; (* Size is fixed in this program *) + S.H := 16; + (* The image is a square with a hole inside *) + FillChar( S.Image, SizeOf(S.Image), Random(15)+1 ); + for I:=5 to 12 do FillChar( S.Image[ I, 5 ], 8, 0 ); +end; + +(* Moves a sprite *) +procedure sxMove( var S: TSprite ); +begin + Inc( S.X, S.DX ); (* Get new position *) + Inc( S.Y, S.DY ); + (* Check sprite position, change delta if needed *) + if( S.X > 320 ) then begin + S.X := 320; + S.DX := -S.DX; + end; + if( S.X < -16 ) then begin + S.X := -16; + S.DX := -S.DX; + end; + if( S.Y > 240 ) then begin + S.Y := 240; + S.DY := -S.DY; + end; + if( S.Y < -16 ) then begin + S.Y := -16; + S.DY := -S.DY; + end; + (* Draw the sprite, note the Page offset added to the *) + (* Y coordinate of the image *) + mxPutImage( @S.Image, S.X, Page+S.Y, S.W, S.H, OP_TRANS ); +end; + +begin + (* Initialize library *) + mxInit; + + (* Enter graphics mode *) + mxSetMode( MX_320x240 ); + + (* Print initialization message *) + mxSetTextColor( 15, OP_TRANS ); + mxOutStr( 4, 4, 'Initializing...' ); + + (* Initialize sprites *) + for I:=1 to MAX_SPRITE do sxInit( S[I] ); + + (* Draw background *) + for I:=1 to 192 do begin + mxCircle( 160, 480+120, I, I+63 ); + mxCircle( 161, 480+120, I, I+63 ); + end; + + (* Compute and set palette *) + for I:=1 to 192 do with Palette[I+63] do begin + R := 0; + G := 0; + B := 0; + if( I < 64 ) then + R := I shr 1+31 + else if( I < 128 ) then + G := (I-64) shr 1+31 + else + B := (I-128) shr 1+31; + end; + mxSetPalette( @Palette[64], 64, 192 ); + + (* Main loop *) + Page := 240; + while( not KeyPressed ) do begin + (* Set clip region to current page *) + mxSetClipRegion( 0, Page, 320, 240 ); + mxSetClip( TRUE ); + (* Restore background *) + mxBitBlt( 0, 480, 320, 240, 0, Page ); + (* Draw sprites *) + for I:=1 to MAX_SPRITE do sxMove( S[I] ); + (* Print message *) + mxOutStr( 4, Page+4, 'Some sprites moving...' ); + (* Flip page *) + mxStartLine( Page ); + Page := 240-Page; + (* Animate palette *) + mxSetPalette( @Palette[64], 64, 192 ); + mxRotatePalette( @Palette[64], 192, 3 ); + end; + + mxSetMode( MX_TEXT ); + mxTerm; +end. diff --git a/16/xw/mxbb.asm b/16/xw/mxbb.asm index 190fa7b2..ed24a27c 100755 --- a/16/xw/mxbb.asm +++ b/16/xw/mxbb.asm @@ -47,7 +47,7 @@ mxBitBlt PROC FAR WritePlane:BYTE, \ LeftMask:BYTE, \ RightMask:BYTE = AUTO_SIZE - .enter AUTO_SIZE + .enter AUTO_SIZE .push ds, si, es, di ; Exit now if null width diff --git a/16/xw_/default.fnt b/16/xw_/default.fnt new file mode 100755 index 00000000..12eb22cb --- /dev/null +++ b/16/xw_/default.fnt @@ -0,0 +1,260 @@ +; +; MODEX library default font +; Copyright (c) 1993-1994 by Alessandro Scotti +; + DB 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; #0 + DB 07Eh, 081h, 0A5h, 081h, 0A5h, 099h, 081h, 07Eh ; #1 + DB 07Eh, 0FFh, 0DBh, 0FFh, 0DBh, 0E7h, 0FFh, 07Eh ; #2 + DB 06Ch, 0FEh, 0FEh, 0FEh, 07Ch, 038h, 010h, 000h ; #3 + DB 010h, 038h, 07Ch, 0FEh, 07Ch, 038h, 010h, 000h ; #4 + DB 010h, 038h, 010h, 054h, 0FEh, 054h, 010h, 0FEh ; #5 + DB 010h, 038h, 07Ch, 0FEh, 0FEh, 07Ch, 010h, 0FEh ; #6 + DB 000h, 018h, 03Ch, 07Eh, 07Eh, 03Ch, 018h, 000h ; #7 + DB 0FFh, 0E7h, 0C3h, 081h, 081h, 0C3h, 0E7h, 0FFh ; #8 + DB 000h, 03Ch, 066h, 042h, 042h, 066h, 03Ch, 000h ; #9 + DB 0FFh, 0C3h, 099h, 0BDh, 0BDh, 099h, 0C3h, 0FFh ; #10 + DB 007h, 003h, 005h, 078h, 084h, 084h, 084h, 078h ; #11 + DB 07Ch, 082h, 082h, 082h, 07Ch, 010h, 038h, 010h ; #12 + DB 01Ch, 010h, 01Ch, 010h, 010h, 010h, 030h, 030h ; #13 + DB 03Eh, 022h, 03Eh, 022h, 022h, 026h, 066h, 060h ; #14 + DB 099h, 05Ah, 03Ch, 0E7h, 0E7h, 03Ch, 05Ah, 099h ; #15 + DB 000h, 010h, 030h, 070h, 0F0h, 070h, 030h, 010h ; #16 + DB 000h, 080h, 0C0h, 0E0h, 0F0h, 0E0h, 0C0h, 080h ; #17 + DB 010h, 038h, 054h, 010h, 010h, 054h, 038h, 010h ; #18 + DB 048h, 048h, 048h, 048h, 048h, 000h, 048h, 000h ; #19 + DB 07Eh, 092h, 092h, 072h, 012h, 012h, 012h, 000h ; #20 + DB 03Ch, 022h, 018h, 024h, 024h, 018h, 044h, 03Ch ; #21 + DB 000h, 000h, 000h, 000h, 000h, 03Eh, 03Eh, 000h ; #22 + DB 038h, 054h, 010h, 010h, 010h, 054h, 038h, 0FEh ; #23 + DB 000h, 010h, 038h, 054h, 010h, 010h, 010h, 000h ; #24 + DB 000h, 010h, 010h, 010h, 054h, 038h, 010h, 000h ; #25 + DB 000h, 008h, 004h, 0FEh, 004h, 008h, 000h, 000h ; #26 + DB 000h, 020h, 040h, 0FEh, 040h, 020h, 000h, 000h ; #27 + DB 000h, 000h, 080h, 080h, 080h, 0FCh, 000h, 000h ; #28 + DB 000h, 024h, 042h, 0FFh, 042h, 024h, 000h, 000h ; #29 + DB 000h, 000h, 010h, 038h, 07Ch, 0FEh, 000h, 000h ; #30 + DB 000h, 000h, 0FEh, 07Ch, 038h, 010h, 000h, 000h ; #31 + DB 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; + DB 010h, 010h, 010h, 010h, 010h, 000h, 010h, 000h ; ! + DB 000h, 024h, 024h, 000h, 000h, 000h, 000h, 000h ; " + DB 024h, 024h, 07Eh, 024h, 07Eh, 024h, 024h, 000h ; # + DB 038h, 054h, 050h, 038h, 014h, 054h, 038h, 010h ; $ + DB 000h, 002h, 044h, 008h, 010h, 020h, 042h, 000h ; % + DB 038h, 044h, 038h, 060h, 094h, 088h, 074h, 000h ; & + DB 020h, 020h, 040h, 000h, 000h, 000h, 000h, 000h ; ' + DB 010h, 020h, 040h, 040h, 040h, 020h, 010h, 000h ; ( + DB 040h, 020h, 010h, 010h, 010h, 020h, 040h, 000h ; ) + DB 000h, 024h, 018h, 07Eh, 018h, 024h, 000h, 000h ; * + DB 000h, 010h, 010h, 07Ch, 010h, 010h, 000h, 000h ; + + DB 000h, 000h, 000h, 000h, 000h, 010h, 010h, 020h ; , + DB 000h, 000h, 000h, 0FCh, 000h, 000h, 000h, 000h ; - + DB 000h, 000h, 000h, 000h, 000h, 000h, 010h, 000h ; . + DB 000h, 004h, 008h, 010h, 020h, 040h, 080h, 000h ; / + DB 07Ch, 0C6h, 08Ah, 092h, 0A2h, 0C6h, 07Ch, 000h ; 0 + DB 010h, 030h, 010h, 010h, 010h, 010h, 038h, 000h ; 1 + DB 078h, 084h, 004h, 018h, 060h, 080h, 0FCh, 000h ; 2 + DB 078h, 084h, 004h, 038h, 004h, 084h, 078h, 000h ; 3 + DB 01Ch, 024h, 044h, 084h, 0FEh, 004h, 00Eh, 000h ; 4 + DB 0FCh, 080h, 0F8h, 004h, 004h, 084h, 078h, 000h ; 5 + DB 078h, 084h, 080h, 0F8h, 084h, 084h, 078h, 000h ; 6 + DB 0FCh, 004h, 004h, 008h, 010h, 020h, 020h, 000h ; 7 + DB 078h, 084h, 084h, 078h, 084h, 084h, 078h, 000h ; 8 + DB 078h, 084h, 084h, 07Ch, 004h, 084h, 078h, 000h ; 9 + DB 000h, 000h, 010h, 000h, 000h, 000h, 010h, 000h ; : + DB 000h, 000h, 010h, 000h, 000h, 010h, 010h, 020h ; ; + DB 008h, 010h, 020h, 040h, 020h, 010h, 008h, 000h ; < + DB 000h, 000h, 0FCh, 000h, 000h, 0FCh, 000h, 000h ; = + DB 040h, 020h, 010h, 008h, 010h, 020h, 040h, 000h ; > + DB 078h, 084h, 004h, 008h, 010h, 000h, 010h, 000h ; ? + DB 07Ch, 082h, 0BAh, 0A6h, 0BEh, 080h, 07Ch, 000h ; @ + DB 078h, 084h, 084h, 0FCh, 084h, 084h, 084h, 000h ; A + DB 0F8h, 084h, 084h, 0F8h, 084h, 084h, 0F8h, 000h ; B + DB 078h, 084h, 080h, 080h, 080h, 084h, 078h, 000h ; C + DB 0F0h, 088h, 084h, 084h, 084h, 088h, 0F0h, 000h ; D + DB 0FCh, 080h, 080h, 0F0h, 080h, 080h, 0FCh, 000h ; E + DB 0FCh, 080h, 080h, 0F0h, 080h, 080h, 080h, 000h ; F + DB 078h, 084h, 080h, 09Ch, 084h, 084h, 078h, 000h ; G + DB 084h, 084h, 084h, 0FCh, 084h, 084h, 084h, 000h ; H + DB 038h, 010h, 010h, 010h, 010h, 010h, 038h, 000h ; I + DB 01Ch, 008h, 008h, 008h, 088h, 088h, 070h, 000h ; J + DB 084h, 088h, 090h, 0E0h, 090h, 088h, 084h, 000h ; K + DB 080h, 080h, 080h, 080h, 080h, 080h, 0FCh, 000h ; L + DB 0C6h, 0AAh, 092h, 082h, 082h, 082h, 082h, 000h ; M + DB 082h, 0C2h, 0A2h, 092h, 08Ah, 086h, 082h, 000h ; N + DB 078h, 084h, 084h, 084h, 084h, 084h, 078h, 000h ; O + DB 0F8h, 084h, 084h, 0F8h, 080h, 080h, 080h, 000h ; P + DB 078h, 084h, 084h, 084h, 094h, 088h, 076h, 000h ; Q + DB 0F8h, 084h, 084h, 0F8h, 090h, 088h, 084h, 000h ; R + DB 078h, 084h, 080h, 078h, 004h, 084h, 078h, 000h ; S + DB 0FEh, 010h, 010h, 010h, 010h, 010h, 010h, 000h ; T + DB 084h, 084h, 084h, 084h, 084h, 084h, 078h, 000h ; U + DB 084h, 084h, 084h, 084h, 084h, 048h, 030h, 000h ; V + DB 082h, 082h, 082h, 082h, 092h, 0AAh, 0C6h, 000h ; W + DB 082h, 044h, 028h, 010h, 028h, 044h, 082h, 000h ; X + DB 044h, 044h, 044h, 038h, 010h, 010h, 010h, 000h ; Y + DB 0FEh, 004h, 008h, 010h, 020h, 040h, 0FEh, 000h ; Z + DB 078h, 040h, 040h, 040h, 040h, 040h, 078h, 000h ; [ + DB 000h, 080h, 040h, 020h, 010h, 008h, 004h, 000h ; \ + DB 078h, 008h, 008h, 008h, 008h, 008h, 078h, 000h ; ] + DB 010h, 028h, 044h, 082h, 000h, 000h, 000h, 000h ; ^ + DB 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0FFh ; _ + DB 020h, 020h, 010h, 000h, 000h, 000h, 000h, 000h ; ` + DB 000h, 000h, 038h, 004h, 03Ch, 044h, 07Ch, 000h ; a + DB 000h, 040h, 040h, 078h, 044h, 044h, 078h, 000h ; b + DB 000h, 000h, 03Ch, 040h, 040h, 040h, 03Ch, 000h ; c + DB 000h, 004h, 004h, 03Ch, 044h, 044h, 03Ch, 000h ; d + DB 000h, 000h, 038h, 044h, 07Ch, 040h, 03Ch, 000h ; e + DB 000h, 00Ch, 010h, 03Ch, 010h, 010h, 010h, 000h ; f + DB 000h, 000h, 03Ch, 044h, 044h, 03Ch, 004h, 038h ; g + DB 000h, 040h, 040h, 078h, 044h, 044h, 044h, 000h ; h + DB 000h, 010h, 000h, 010h, 010h, 010h, 010h, 000h ; i + DB 000h, 004h, 000h, 004h, 004h, 004h, 044h, 038h ; j + DB 000h, 040h, 040h, 050h, 060h, 050h, 048h, 000h ; k + DB 000h, 030h, 010h, 010h, 010h, 010h, 010h, 000h ; l + DB 000h, 000h, 068h, 054h, 054h, 044h, 044h, 000h ; m + DB 000h, 000h, 078h, 044h, 044h, 044h, 044h, 000h ; n + DB 000h, 000h, 038h, 044h, 044h, 044h, 038h, 000h ; o + DB 000h, 000h, 078h, 044h, 044h, 078h, 040h, 040h ; p + DB 000h, 000h, 03Ch, 044h, 044h, 03Ch, 004h, 004h ; q + DB 000h, 000h, 05Ch, 060h, 040h, 040h, 040h, 000h ; r + DB 000h, 000h, 038h, 040h, 07Ch, 004h, 07Ch, 000h ; s + DB 000h, 010h, 038h, 010h, 010h, 010h, 018h, 000h ; t + DB 000h, 000h, 044h, 044h, 044h, 044h, 038h, 000h ; u + DB 000h, 000h, 044h, 044h, 044h, 028h, 010h, 000h ; v + DB 000h, 000h, 044h, 044h, 054h, 054h, 06Ch, 000h ; w + DB 000h, 000h, 044h, 028h, 010h, 028h, 044h, 000h ; x + DB 000h, 000h, 044h, 044h, 044h, 03Ch, 004h, 07Ch ; y + DB 000h, 000h, 07Ch, 004h, 038h, 040h, 07Ch, 000h ; z + DB 000h, 008h, 010h, 010h, 030h, 010h, 010h, 008h ; { + DB 000h, 010h, 010h, 010h, 000h, 010h, 010h, 010h ; | + DB 000h, 020h, 010h, 010h, 018h, 010h, 010h, 020h ; } + DB 064h, 098h, 000h, 000h, 000h, 000h, 000h, 000h ; ~ + DB 000h, 010h, 028h, 044h, 082h, 082h, 0FEh, 000h ;  + DB 07Ch, 080h, 080h, 080h, 080h, 07Ch, 004h, 07Ch ; #128 + DB 000h, 028h, 000h, 044h, 044h, 044h, 038h, 000h ; #129 + DB 03Ch, 000h, 07Ch, 044h, 07Ch, 040h, 07Ch, 000h ; #130 + DB 07Eh, 081h, 038h, 004h, 03Ch, 044h, 07Ch, 000h ; #131 + DB 024h, 000h, 038h, 004h, 03Ch, 044h, 07Ch, 000h ; #132 + DB 078h, 000h, 038h, 004h, 03Ch, 044h, 07Ch, 000h ; #133 + DB 018h, 018h, 038h, 004h, 03Ch, 044h, 07Ch, 000h ; #134 + DB 000h, 000h, 078h, 080h, 080h, 078h, 008h, 038h ; #135 + DB 07Ch, 082h, 038h, 044h, 07Ch, 040h, 03Ch, 000h ; #136 + DB 048h, 000h, 038h, 044h, 07Ch, 040h, 03Ch, 000h ; #137 + DB 078h, 000h, 038h, 044h, 07Ch, 040h, 03Ch, 000h ; #138 + DB 000h, 028h, 000h, 010h, 010h, 010h, 010h, 000h ; #139 + DB 010h, 028h, 000h, 010h, 010h, 010h, 010h, 000h ; #140 + DB 000h, 030h, 000h, 010h, 010h, 010h, 010h, 000h ; #141 + DB 048h, 000h, 078h, 084h, 0FCh, 084h, 084h, 000h ; #142 + DB 030h, 030h, 078h, 084h, 0FCh, 084h, 084h, 000h ; #143 + DB 038h, 000h, 0FCh, 080h, 0F0h, 080h, 0FCh, 000h ; #144 + DB 000h, 000h, 07Eh, 008h, 07Eh, 048h, 07Eh, 000h ; #145 + DB 07Eh, 090h, 090h, 0FCh, 090h, 090h, 09Eh, 000h ; #146 + DB 07Ch, 082h, 038h, 044h, 044h, 044h, 038h, 000h ; #147 + DB 028h, 000h, 038h, 044h, 044h, 044h, 038h, 000h ; #148 + DB 070h, 000h, 038h, 044h, 044h, 044h, 038h, 000h ; #149 + DB 038h, 044h, 000h, 044h, 044h, 044h, 038h, 000h ; #150 + DB 070h, 000h, 044h, 044h, 044h, 044h, 038h, 000h ; #151 + DB 028h, 000h, 044h, 044h, 044h, 03Ch, 004h, 07Ch ; #152 + DB 048h, 000h, 078h, 084h, 084h, 084h, 078h, 000h ; #153 + DB 048h, 000h, 084h, 084h, 084h, 084h, 078h, 000h ; #154 + DB 000h, 010h, 038h, 040h, 040h, 040h, 038h, 010h ; #155 + DB 038h, 044h, 040h, 0E0h, 040h, 040h, 082h, 0FCh ; #156 + DB 044h, 07Ch, 010h, 07Ch, 010h, 07Ch, 010h, 000h ; #157 + DB 0F0h, 088h, 08Ah, 0F7h, 082h, 082h, 082h, 000h ; #158 + DB 00Ch, 012h, 010h, 018h, 030h, 010h, 090h, 060h ; #159 + DB 03Ch, 000h, 038h, 004h, 03Ch, 044h, 07Ch, 000h ; #160 + DB 000h, 018h, 000h, 010h, 010h, 010h, 010h, 000h ; #161 + DB 01Ch, 000h, 038h, 044h, 044h, 044h, 038h, 000h ; #162 + DB 01Ch, 000h, 044h, 044h, 044h, 044h, 038h, 000h ; #163 + DB 07Ch, 000h, 078h, 044h, 044h, 044h, 044h, 000h ; #164 + DB 07Ch, 000h, 044h, 064h, 054h, 04Ch, 044h, 000h ; #165 + DB 018h, 024h, 024h, 01Eh, 000h, 03Eh, 000h, 000h ; #166 + DB 01Ch, 022h, 022h, 01Ch, 000h, 03Eh, 000h, 000h ; #167 + DB 010h, 000h, 010h, 020h, 040h, 042h, 03Ch, 000h ; #168 + DB 000h, 000h, 000h, 0FCh, 080h, 080h, 000h, 000h ; #169 + DB 000h, 000h, 000h, 0FCh, 004h, 004h, 000h, 000h ; #170 + DB 040h, 044h, 048h, 057h, 021h, 047h, 004h, 007h ; #171 + DB 040h, 044h, 048h, 052h, 026h, 04Ah, 01Fh, 002h ; #172 + DB 010h, 000h, 010h, 010h, 010h, 010h, 010h, 000h ; #173 + DB 000h, 024h, 048h, 090h, 048h, 024h, 000h, 000h ; #174 + DB 000h, 048h, 024h, 012h, 024h, 048h, 000h, 000h ; #175 + DB 022h, 088h, 022h, 088h, 022h, 088h, 022h, 088h ; #176 + DB 055h, 0AAh, 055h, 0AAh, 055h, 0AAh, 055h, 0AAh ; #177 + DB 0DBh, 077h, 0DBh, 0EEh, 0DBh, 077h, 0DBh, 0EEh ; #178 + DB 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h ; #179 + DB 018h, 018h, 018h, 018h, 0F8h, 018h, 018h, 018h ; #180 + DB 018h, 018h, 0F8h, 018h, 0F8h, 018h, 018h, 018h ; #181 + DB 036h, 036h, 036h, 036h, 0F6h, 036h, 036h, 036h ; #182 + DB 000h, 000h, 000h, 000h, 0FEh, 036h, 036h, 036h ; #183 + DB 000h, 000h, 0F8h, 018h, 0F8h, 018h, 018h, 018h ; #184 + DB 036h, 036h, 0F6h, 006h, 0F6h, 036h, 036h, 036h ; #185 + DB 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h ; #186 + DB 000h, 000h, 0FEh, 006h, 0F6h, 036h, 036h, 036h ; #187 + DB 036h, 036h, 0F6h, 006h, 0FEh, 000h, 000h, 000h ; #188 + DB 036h, 036h, 036h, 036h, 0FEh, 000h, 000h, 000h ; #189 + DB 018h, 018h, 0F8h, 018h, 0F8h, 000h, 000h, 000h ; #190 + DB 000h, 000h, 000h, 000h, 0F8h, 018h, 018h, 018h ; #191 + DB 018h, 018h, 018h, 018h, 01Fh, 000h, 000h, 000h ; #192 + DB 018h, 018h, 018h, 018h, 0FFh, 000h, 000h, 000h ; #193 + DB 000h, 000h, 000h, 000h, 0FFh, 018h, 018h, 018h ; #194 + DB 018h, 018h, 018h, 018h, 01Fh, 018h, 018h, 018h ; #195 + DB 000h, 000h, 000h, 000h, 0FFh, 000h, 000h, 000h ; #196 + DB 018h, 018h, 018h, 018h, 0FFh, 018h, 018h, 018h ; #197 + DB 018h, 018h, 01Fh, 018h, 01Fh, 018h, 018h, 018h ; #198 + DB 036h, 036h, 036h, 036h, 037h, 036h, 036h, 036h ; #199 + DB 036h, 036h, 037h, 030h, 03Fh, 000h, 000h, 000h ; #200 + DB 000h, 000h, 03Fh, 030h, 037h, 036h, 036h, 036h ; #201 + DB 036h, 036h, 0F7h, 000h, 0FFh, 000h, 000h, 000h ; #202 + DB 000h, 000h, 0FFh, 000h, 0F7h, 036h, 036h, 036h ; #203 + DB 036h, 036h, 037h, 030h, 037h, 036h, 036h, 036h ; #204 + DB 000h, 000h, 0FFh, 000h, 0FFh, 000h, 000h, 000h ; #205 + DB 036h, 036h, 0F7h, 000h, 0F7h, 036h, 036h, 036h ; #206 + DB 018h, 018h, 0FFh, 000h, 0FFh, 000h, 000h, 000h ; #207 + DB 036h, 036h, 036h, 036h, 0FFh, 000h, 000h, 000h ; #208 + DB 000h, 000h, 0FFh, 000h, 0FFh, 018h, 018h, 018h ; #209 + DB 000h, 000h, 000h, 000h, 0FFh, 036h, 036h, 036h ; #210 + DB 036h, 036h, 036h, 036h, 03Fh, 000h, 000h, 000h ; #211 + DB 018h, 018h, 01Fh, 018h, 01Fh, 000h, 000h, 000h ; #212 + DB 000h, 000h, 01Fh, 018h, 01Fh, 018h, 018h, 018h ; #213 + DB 000h, 000h, 000h, 000h, 03Fh, 036h, 036h, 036h ; #214 + DB 036h, 036h, 036h, 036h, 0FFh, 036h, 036h, 036h ; #215 + DB 018h, 018h, 0FFh, 018h, 0FFh, 018h, 018h, 018h ; #216 + DB 018h, 018h, 018h, 018h, 0F8h, 000h, 000h, 000h ; #217 + DB 000h, 000h, 000h, 000h, 01Fh, 018h, 018h, 018h ; #218 + DB 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh, 0FFh ; #219 + DB 000h, 000h, 000h, 000h, 0FFh, 0FFh, 0FFh, 0FFh ; #220 + DB 0F0h, 0F0h, 0F0h, 0F0h, 0F0h, 0F0h, 0F0h, 0F0h ; #221 + DB 00Fh, 00Fh, 00Fh, 00Fh, 00Fh, 00Fh, 00Fh, 00Fh ; #222 + DB 0FFh, 0FFh, 0FFh, 0FFh, 000h, 000h, 000h, 000h ; #223 + DB 000h, 000h, 062h, 094h, 088h, 094h, 062h, 000h ; #224 + DB 000h, 0F0h, 088h, 0F0h, 088h, 088h, 0F0h, 080h ; #225 + DB 000h, 0F8h, 088h, 080h, 080h, 080h, 080h, 000h ; #226 + DB 000h, 0FCh, 048h, 048h, 048h, 048h, 048h, 000h ; #227 + DB 0FCh, 084h, 040h, 020h, 040h, 084h, 0FCh, 000h ; #228 + DB 03Ch, 040h, 038h, 044h, 044h, 044h, 038h, 000h ; #229 + DB 000h, 000h, 044h, 044h, 044h, 078h, 040h, 040h ; #230 + DB 000h, 036h, 048h, 008h, 008h, 008h, 008h, 000h ; #231 + DB 038h, 010h, 038h, 044h, 044h, 038h, 010h, 038h ; #232 + DB 078h, 084h, 084h, 0FCh, 084h, 084h, 078h, 000h ; #233 + DB 078h, 084h, 084h, 084h, 048h, 048h, 0CCh, 000h ; #234 + DB 078h, 004h, 038h, 044h, 044h, 044h, 038h, 000h ; #235 + DB 000h, 000h, 06Ch, 092h, 092h, 06Ch, 000h, 000h ; #236 + DB 000h, 000h, 03Ah, 044h, 05Ah, 022h, 05Ch, 000h ; #237 + DB 018h, 020h, 040h, 078h, 040h, 020h, 018h, 000h ; #238 + DB 078h, 084h, 084h, 084h, 084h, 084h, 084h, 000h ; #239 + DB 000h, 0FCh, 000h, 0FCh, 000h, 0FCh, 000h, 000h ; #240 + DB 020h, 020h, 0F8h, 020h, 020h, 000h, 0F8h, 000h ; #241 + DB 020h, 010h, 008h, 010h, 020h, 000h, 07Ch, 000h ; #242 + DB 008h, 010h, 020h, 010h, 008h, 000h, 07Ch, 000h ; #243 + DB 00Ch, 012h, 010h, 010h, 010h, 010h, 010h, 010h ; #244 + DB 010h, 010h, 010h, 010h, 010h, 010h, 090h, 060h ; #245 + DB 000h, 010h, 000h, 07Ch, 000h, 010h, 000h, 000h ; #246 + DB 000h, 032h, 04Ch, 000h, 032h, 04Ch, 000h, 000h ; #247 + DB 038h, 044h, 044h, 038h, 000h, 000h, 000h, 000h ; #248 + DB 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h ; #249 + DB 000h, 000h, 000h, 000h, 018h, 000h, 000h, 000h ; #250 + DB 00Eh, 008h, 008h, 008h, 048h, 028h, 018h, 008h ; #251 + DB 038h, 024h, 024h, 024h, 024h, 000h, 000h, 000h ; #252 + DB 03Ch, 004h, 03Ch, 020h, 03Ch, 000h, 000h, 000h ; #253 + DB 000h, 000h, 03Ch, 03Ch, 03Ch, 03Ch, 000h, 000h ; #254 + DB 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; #255 diff --git a/16/xw_/makefile b/16/xw_/makefile new file mode 100755 index 00000000..298ec301 --- /dev/null +++ b/16/xw_/makefile @@ -0,0 +1,134 @@ +# +# MODEX library makefile (for Borland MAKE) +# Copyright (c) 1993,1994 by Alessandro Scotti +# +!ifdef __LINUX__ +REMOVECOMMAND=rm -f +COPYCOMMAND=cp -f +DIRSEP=/ +OBJ=o +!else +REMOVECOMMAND=del +COPYCOMMAND=copy /y +DIRSEP=\ +OBJ=obj +!endif +LIBINCS = modex.def + +LIBOBJS = mxbb.$(OBJ) mxcc.$(OBJ) mxcg.$(OBJ) mxcl.$(OBJ) mxcr.$(OBJ) mxel.$(OBJ) mxfb.$(OBJ) mxfp.$(OBJ) mxgc.$(OBJ) mxgi.$(OBJ) mxgm.$(OBJ) mxgp.$(OBJ) mxgv.$(OBJ) mxhl.$(OBJ) mxit.$(OBJ) mxll.$(OBJ) mxln.$(OBJ) mxot.$(OBJ) mxpb.$(OBJ) mxpf.$(OBJ) mxpg.$(OBJ) mxpi.$(OBJ) mxpn.$(OBJ) mxpp.$(OBJ) mxra.$(OBJ) mxrp.$(OBJ) mxsa.$(OBJ) mxsc.$(OBJ) mxsi.$(OBJ) mxsl.$(OBJ) mxsm.$(OBJ) mxsp.$(OBJ) mxss.$(OBJ) mxtl.$(OBJ) mxvs.$(OBJ) mxwd.$(OBJ) mxwm.$(OBJ) mxwp.$(OBJ) mxwr.$(OBJ) + +# +# ASM compiler +# +ASMC =wasm +ASMO =-mh -0 + +# +# PAS compiler +# +#PASC = tpc +#PASO = /m -$D- -$L- -$S- + +# +# LIB maker, uses response file +# +LIBC = wlib + +# .asm.obj: +# $(ASMC) $(ASMO) $< + +mxbb.$(OBJ): mxbb.asm + $(ASMC) $(ASMO) mxbb.asm +mxcc.$(OBJ): mxcc.asm + $(ASMC) $(ASMO) mxcc.asm +mxcg.$(OBJ): mxcg.asm + $(ASMC) $(ASMO) mxcg.asm +mxcl.$(OBJ): mxcl.asm + $(ASMC) $(ASMO) mxcl.asm +mxcr.$(OBJ): mxcr.asm + $(ASMC) $(ASMO) mxcr.asm +mxel.$(OBJ): mxel.asm + $(ASMC) $(ASMO) mxel.asm +mxfb.$(OBJ): mxfb.asm + $(ASMC) $(ASMO) mxfb.asm +mxfp.$(OBJ): mxfp.asm + $(ASMC) $(ASMO) mxfp.asm +mxgc.$(OBJ): mxgc.asm + $(ASMC) $(ASMO) mxgc.asm +mxgi.$(OBJ): mxgi.asm + $(ASMC) $(ASMO) mxgi.asm +mxgm.$(OBJ): mxgm.asm + $(ASMC) $(ASMO) mxgm.asm +mxgp.$(OBJ): mxgp.asm + $(ASMC) $(ASMO) mxgp.asm +mxgv.$(OBJ): mxgv.asm + $(ASMC) $(ASMO) mxgv.asm +mxhl.$(OBJ): mxhl.asm + $(ASMC) $(ASMO) mxhl.asm +mxit.$(OBJ): mxit.asm + $(ASMC) $(ASMO) mxit.asm +mxll.$(OBJ): mxll.asm + $(ASMC) $(ASMO) mxll.asm +mxln.$(OBJ): mxln.asm + $(ASMC) $(ASMO) mxln.asm +mxot.$(OBJ): mxot.asm + $(ASMC) $(ASMO) mxot.asm +mxpb.$(OBJ): mxpb.asm + $(ASMC) $(ASMO) mxpb.asm +mxpf.$(OBJ): mxpf.asm + $(ASMC) $(ASMO) mxpf.asm +mxpg.$(OBJ): mxpg.asm + $(ASMC) $(ASMO) mxpg.asm +mxpi.$(OBJ): mxpi.asm + $(ASMC) $(ASMO) mxpi.asm +mxpn.$(OBJ): mxpn.asm + $(ASMC) $(ASMO) mxpn.asm +mxpp.$(OBJ): mxpp.asm + $(ASMC) $(ASMO) mxpp.asm +mxra.$(OBJ): mxra.asm + $(ASMC) $(ASMO) mxra.asm +mxrp.$(OBJ): mxrp.asm + $(ASMC) $(ASMO) mxrp.asm +mxsa.$(OBJ): mxsa.asm + $(ASMC) $(ASMO) mxsa.asm +mxsc.$(OBJ): mxsc.asm + $(ASMC) $(ASMO) mxsc.asm +mxsi.$(OBJ): mxsi.asm + $(ASMC) $(ASMO) mxsi.asm +mxsl.$(OBJ): mxsl.asm + $(ASMC) $(ASMO) mxsl.asm +mxsm.$(OBJ): mxsm.asm + $(ASMC) $(ASMO) mxsm.asm +mxsp.$(OBJ): mxsp.asm + $(ASMC) $(ASMO) mxsp.asm +mxss.$(OBJ): mxss.asm + $(ASMC) $(ASMO) mxss.asm +mxtl.$(OBJ): mxtl.asm + $(ASMC) $(ASMO) mxtl.asm +mxvs.$(OBJ): mxvs.asm + $(ASMC) $(ASMO) mxvs.asm +mxwd.$(OBJ): mxwd.asm + $(ASMC) $(ASMO) mxwd.asm +mxwm.$(OBJ): mxwm.asm + $(ASMC) $(ASMO) mxwm.asm +mxwp.$(OBJ): mxwp.asm + $(ASMC) $(ASMO) mxwp.asm +mxwr.$(OBJ): mxwr.asm + $(ASMC) $(ASMO) mxwr.asm + +all: $(LIBOBJS) modex.lib +# modex.tpu modex.tpp + +#modex.tpu: $(LIBOBJS) modex.pas +# $(PASC) $(PASO) modex +# copy modex.tpu .. +# copy modex.pas .. + +#modex.tpp: $(LIBOBJS) modex.pas +# $(PASC) /cp $(PASO) modex +# copy modex.tpp .. + +modex.lib: modex.lbr $(LIBOBJS) + $(LIBC) modex.lib @modex.lbr + +$(LIBOBJS): modex.def diff --git a/16/xw_/makefile.bcc b/16/xw_/makefile.bcc new file mode 100755 index 00000000..d3ad8b71 --- /dev/null +++ b/16/xw_/makefile.bcc @@ -0,0 +1,81 @@ +# +# MODEX library makefile (for Borland MAKE) +# Copyright (c) 1993,1994 by Alessandro Scotti +# +LIBINCS = MODEX.DEF + +LIBOBJS = MXBB.OBJ \ + MXCC.OBJ \ + MXCG.OBJ \ + MXCL.OBJ \ + MXCR.OBJ \ + MXFB.OBJ \ + MXFP.OBJ \ + MXGC.OBJ \ + MXGI.OBJ \ + MXGM.OBJ \ + MXGP.OBJ \ + MXGV.OBJ \ + MXHL.OBJ \ + MXIT.OBJ \ + MXLL.OBJ \ + MXLN.OBJ \ + MXOT.OBJ \ + MXPB.OBJ \ + MXPF.OBJ \ + MXPG.OBJ \ + MXPI.OBJ \ + MXPN.OBJ \ + MXPP.OBJ \ + MXRA.OBJ \ + MXRP.OBJ \ + MXSA.OBJ \ + MXSC.OBJ \ + MXSI.OBJ \ + MXSL.OBJ \ + MXSM.OBJ \ + MXSP.OBJ \ + MXSS.OBJ \ + MXTL.OBJ \ + MXVS.OBJ \ + MXWD.OBJ \ + MXWM.OBJ \ + MXWP.OBJ \ + MXWR.OBJ + +# +# ASM compiler +# +ASMC = tasm +ASMO = /m5 /p + +# +# PAS compiler +# +PASC = tpc +PASO = /m -$D- -$L- -$S- + +# +# LIB maker, uses response file +# +LIBC = tlib + +.asm.obj: + $(ASMC) $(ASMO) $< + +target: modex.lib +# modex.tpu modex.tpp + +#modex.tpu: $(LIBOBJS) modex.pas +# $(PASC) $(PASO) modex +# copy modex.tpu .. +# copy modex.pas .. + +#modex.tpp: $(LIBOBJS) modex.pas +# $(PASC) /cp $(PASO) modex +# copy modex.tpp .. + +modex.lib: modex.lbr $(LIBOBJS) + $(LIBC) modex.lib @modex.lbr + +$(LIBOBJS): modex.def diff --git a/16/x/modex.bak b/16/xw_/modex.bak similarity index 100% rename from 16/x/modex.bak rename to 16/xw_/modex.bak diff --git a/16/xw_/modex.def b/16/xw_/modex.def new file mode 100755 index 00000000..7977a4a0 --- /dev/null +++ b/16/xw_/modex.def @@ -0,0 +1,163 @@ +;------------------------------------------------------------ +; +; MODEX.DEF - Include file +; Copyright (c) 1993-1994 by Alessandro Scotti +; +;JUMPS +;LOCALS + +TRUE EQU 1 ; Boolean constants +FALSE EQU 0 + +USE286 = FALSE ; TRUE enables 80286 instructions +USE386 = FALSE ; TRUE enables 80386 (and 80286) instructions + +IF USE286 EQ TRUE + P286 +ENDIF + +IF USE386 EQ TRUE + P386 + USE286 = TRUE +ENDIF + +MXVERSION EQU 0128h ; Library version (1.40) + +;------------------------------------------------------------ +; +; VGA definitions +; +MISC EQU 3C2h ; Miscellaneous output +TS EQU 3C4h ; Timing Sequencer index register +GDC EQU 3CEh ; Graphics Data Controller index register +CRTC EQU 3D4h ; CRTC index register +STATUS EQU 3DAh ; Input Status register one + +;------------------------------------------------------------ +; +; Raster operators +; +OP_SET EQU 0 +OP_MOVE EQU 0 ; Same as OP_SET +OP_AND EQU 1 +OP_OR EQU 2 +OP_XOR EQU 3 +OP_TRANS EQU 4 +OP_ADD EQU 5 ; Must be last op + +;------------------------------------------------------------ +; +; Polygon fill functions +; +POLYSCANBUFSIZE EQU 4*1024 + +;------------------------------------------------------------ +; Macro to push registers, variables or flags onto the stack +; Usage: .push "loc16"[,"loc16"...] +; where "loc16" is a 16-bit register, a word-sized variable or the +; keyword "FLAGS". +; Exmpl: .push ax, flags, var1 +; .pop ax, flags, var1 +; +.push MACRO r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10 + IFNB + .ERROR <.PUSH has more than 10 arguments> + ENDIF + IRP $reg, + IFB <$reg> ;; Is argument blank? + EXITM ;; Yes, exit + ELSEIFIDNI <$reg>, ;; Is argument the keyword "FLAGS"? + pushf ;; Yes, push flags + ELSE + push $reg ;; Push argument + ENDIF + ENDM +ENDM + +;------------------------------------------------------------ +; Macro to pop registers, variables or flags from the stack +; Usage: .pop "loc16"[,"loc16"...] +; where "loc16" is a 16-bit register, a word-sized variable or the +; keyword "FLAGS". +; Exmpl: .push ax, flags, var1 +; .pop ax, flags, var1 +; +.pop MACRO r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10 + IFNB + .ERROR <.POP has more than 10 arguments> + ENDIF + IRP $reg, + IFNB <$reg> ;; Is argument non-blank? + IFIDNI <$reg>, ;; Yes, is it the keyword "FLAGS"? + popf ;; Yes, pop flags + ELSE + pop $reg ;; Pop argument + ENDIF + ENDIF + ENDM +ENDM + +;------------------------------------------------------------ +; +.enter MACRO localsize + IF USE286 EQ TRUE + enter localsize, 0 + ELSE + push bp + mov bp, sp + sub sp, localsize + ENDIF +ENDM + +;------------------------------------------------------------ +; +;.leave MACRO argsize +; IF USE286 EQ TRUE +; leave +; ELSE +; mov sp, bp +; pop bp +; ENDIF +; IFNB +; ret argsize +; ELSE +; ret +; ENDIF +;ENDM + +;------------------------------------------------------------ +; +;.shr MACRO arg, count +; IF USE286 EQ TRUE +; shr arg, count +; ELSE +; $temp = count +; WHILE $temp GT 0 +; shr arg, 1 +; $temp = $temp-1 +; ENDM +; ENDIF +;ENDM + +;------------------------------------------------------------ +; +;.shl MACRO arg, count +; IF USE286 EQ TRUE +; shl arg, count +; ELSE +; $temp = count +; WHILE $temp GT 0 +; shl arg, 1 +; $temp = $temp-1 +; ENDM +; ENDIF +;ENDM + +;------------------------------------------------------------ +; +;.chk386 MACRO name, jump +; IF USE386 EQ FALSE +; .OUT "Warning: ", , " needs a 386 or better to run!" +; jmp @@jump +; ENDIF +;ENDM diff --git a/16/xw_/modex.h b/16/xw_/modex.h new file mode 100755 index 00000000..2c1f1ebe --- /dev/null +++ b/16/xw_/modex.h @@ -0,0 +1,153 @@ +/* + MODEX.H - C/C++ include file for the MODEX library + Copyright (c) 1994 Alessandro Scotti +*/ + +#ifndef _MODEX_H_ // Avoid nested inclusions +#define _MODEX_H_ + +// +// Video modes +// +#define MX_TEXT 0 // 80x25 text +#define MX_320x175 1 // 320x175x256 +#define MX_320x200 2 // 320x200x256, 4 pages, aspect 6:5 +#define MX_320x240 3 // 320x240x256, 3 pages, aspect 1:1 +#define MX_320x350 4 // 320x350x256 +#define MX_320x400 5 // 320x400x256, 2 pages +#define MX_320x480 6 // 320x480x256, 1 page +#define MX_360x175 7 // 360x175x256 +#define MX_360x200 8 // 360x200x256, 3 pages +#define MX_360x240 9 // 360x240x256, 2 pages +#define MX_360x350 10 // 360x350x256 +#define MX_360x400 11 // 360x400x256, 1 page +#define MX_360x480 12 // 360x480x256, 1 page +#define MX_400x600 13 // 400x600x256, 1 page + +// +// Fade effects +// +#define MX_FADEIN 0 +#define MX_FADEOUT 1 + +// +// Raster ops +// +#define OP_SET 0 // No operator +#define OP_AND 1 // And +#define OP_OR 2 // Or +#define OP_XOR 3 // Xor +#define OP_TRANS 4 // Transparent +#define OP_ADD 5 // Additive +#define OP_MOVE 0 // Alias for OP_SET + +// +// Temporary definitions +// +#define MXBYTE unsigned char +#define MXBOOL short int +#define MXSINT short int +#define MXUINT unsigned short int +#define MXAPI far pascal +#define MXPTR void far * + +// Functions + +#ifdef __cplusplus // Avoid C++ name mangling +extern "C" { +#endif + +// +// Initialization +// +MXSINT MXAPI mxInit( void ); // Returns 0 if successful +void MXAPI mxTerm( void ); +MXUINT MXAPI mxGetVersion( void ); +// +// Mode setting +// +void MXAPI mxChangeMode( MXUINT mode ); +void MXAPI mxSetMode( MXUINT mode ); +void MXAPI mxGetAspect( MXUINT far *aspectx, MXUINT far *aspecty ); +void MXAPI mxGetScreenSize( MXUINT far *width, MXUINT far *height ); +// +// Hardware support +// +void MXAPI mxWriteMode( MXBYTE wm ); +void MXAPI mxSplitScreen( MXUINT line ); +void MXAPI mxStartAddress( MXUINT sa ); +void MXAPI mxStartLine( MXUINT sl ); +void MXAPI mxWaitDisplay( void ); +void MXAPI mxWaitRetrace( void ); +void MXAPI mxWritePlane( MXBYTE wp ); +void MXAPI mxReadPlane( MXBYTE rp ); +void MXAPI mxRowAddress( MXBYTE ra ); +// +// Virtual screen +// +void MXAPI mxGetVirtualScreen( MXUINT far *width, MXUINT far *height ); +void MXAPI mxSetVirtualScreen( MXUINT width, MXUINT height ); +void MXAPI mxPan( MXUINT x, MXUINT y ); +// +// Clipping +// +MXBOOL MXAPI mxGetClip( void ); +MXBOOL MXAPI mxGetClipRegion( MXSINT far *x, MXSINT far *y, MXSINT far *w, MXSINT far *h ); +MXBOOL MXAPI mxSetClip( MXBOOL ); +void MXAPI mxSetClipRegion( MXUINT x, MXUINT y, MXUINT width, MXUINT height ); +// +// Graphics +// +void MXAPI mxBitBlt( MXSINT sx, MXSINT sy, MXUINT width, MXUINT height, MXSINT dx, MXSINT dy ); +void MXAPI mxFillBox( MXSINT x, MXSINT y, MXUINT width, MXUINT height, MXUINT color, MXUINT op ); +MXBYTE MXAPI mxGetPixel( MXSINT x, MXSINT y ); +void MXAPI mxPutPixel( MXSINT x, MXSINT y, MXBYTE color ); +void MXAPI mxLine( MXSINT x1, MXSINT y1, MXSINT x2, MXSINT y2, MXUINT color, MXUINT op ); +void MXAPI mxGetImage( MXPTR img, MXSINT x, MXSINT y, MXUINT width, MXUINT height ); +void MXAPI mxPutImage( MXPTR img, MXSINT x, MXSINT y, MXUINT w, MXUINT h, MXUINT op ); +void MXAPI mxPutTile( MXPTR tile, MXSINT x, MXSINT y, MXUINT width, MXUINT height ); +void MXAPI mxTransPutTile( MXPTR tile, MXSINT x, MXSINT y, MXUINT w, MXUINT h ); +void MXAPI mxCircle( MXSINT x, MXSINT y, MXUINT radius, MXBYTE color ); +void MXAPI mxStretchImage( MXPTR img, MXSINT x, MXSINT y, MXUINT w, MXUINT h, MXUINT neww, MXUINT newh, MXUINT op ); +// +// Palette +// +void MXAPI mxColorToGray( MXPTR source, MXPTR dest, MXUINT count ); +void MXAPI mxGammaCorrect( MXPTR source, MXPTR dest, MXUINT count ); +void MXAPI mxGetColor( MXUINT index, MXSINT far *r, MXSINT far *g, MXSINT far *b ); +void MXAPI mxSetColor( MXUINT index, MXSINT red, MXSINT green, MXSINT blue ); +void MXAPI mxGetPalette( MXPTR palette, MXUINT index, MXUINT count ); +void MXAPI mxSetPalette( MXPTR palette, MXUINT index, MXUINT count ); +void MXAPI mxFadePalette( MXPTR, MXUINT, MXUINT, MXUINT, MXUINT, MXUINT, MXUINT ); +void MXAPI mxRotatePalette( MXPTR palette, MXUINT count, MXSINT step ); +// +// Text +// +MXSINT MXAPI mxSetFont( MXPTR font, MXUINT charwidth, MXUINT charheight ); +void MXAPI mxSetTextColor( MXUINT color, MXUINT op ); +void MXAPI mxGetTextStep( MXSINT far *deltax, MXSINT far *deltay ); +void MXAPI mxSetTextStep( MXSINT deltax, MXSINT deltay ); +void MXAPI mxOutChar( MXSINT x, MXSINT y, char c ); +void MXAPI mxOutText( MXSINT x, MXSINT y, char far *sz ); +// +// Convex polygons +// +void MXAPI mxFillPoly( MXUINT, MXPTR, MXPTR, MXUINT, MXUINT ); +void MXAPI mxGouraudPoly( MXUINT, MXPTR, MXPTR, MXPTR, MXUINT, MXUINT ); +void MXAPI mxTexturePoly( MXUINT, MXPTR, MXPTR, MXPTR, MXPTR, MXUINT, MXUINT ); + +#ifdef __cplusplus +} +#endif + +// +// Remove temporary defines +// +#undef MXBYTE +#undef MXBOOL +#undef MXSINT +#undef MXUINT +#undef MXPTR +#undef MXAPI + +#endif // _MODEX_H_ diff --git a/16/xw_/modex.lbr b/16/xw_/modex.lbr new file mode 100755 index 00000000..93fc7801 --- /dev/null +++ b/16/xw_/modex.lbr @@ -0,0 +1,39 @@ ++-MXBB.OBJ & ++-MXCC.OBJ & ++-MXCG.OBJ & ++-MXCL.OBJ & ++-MXCR.OBJ & ++-MXFB.OBJ & ++-MXFP.OBJ & ++-MXGC.OBJ & ++-MXGI.OBJ & ++-MXGM.OBJ & ++-MXGP.OBJ & ++-MXGV.OBJ & ++-MXHL.OBJ & ++-MXIT.OBJ & ++-MXLL.OBJ & ++-MXLN.OBJ & ++-MXOT.OBJ & ++-MXPB.OBJ & ++-MXPF.OBJ & ++-MXPG.OBJ & ++-MXPI.OBJ & ++-MXPN.OBJ & ++-MXPP.OBJ & ++-MXPT.OBJ & ++-MXRA.OBJ & ++-MXRP.OBJ & ++-MXSA.OBJ & ++-MXSC.OBJ & ++-MXSI.OBJ & ++-MXSL.OBJ & ++-MXSM.OBJ & ++-MXSP.OBJ & ++-MXSS.OBJ & ++-MXTL.OBJ & ++-MXVS.OBJ & ++-MXWD.OBJ & ++-MXWM.OBJ & ++-MXWP.OBJ & ++-MXWR.OBJ diff --git a/16/xw_/modex.pas b/16/xw_/modex.pas new file mode 100755 index 00000000..7d9d26ed --- /dev/null +++ b/16/xw_/modex.pas @@ -0,0 +1,194 @@ +(* + Turbo Pascal interface to the MODEX library + Copyright (c) 1993,1994 by Alessandro Scotti +*) +unit ModeX; +interface + +const + (* Video modes *) + MX_TEXT = 0; + MX_320x175 = 1; + MX_320x200 = 2; + MX_320x240 = 3; + MX_320x350 = 4; + MX_320x400 = 5; + MX_320x480 = 6; + MX_360x175 = 7; + MX_360x200 = 8; + MX_360x240 = 9; + MX_360x350 = 10; + MX_360x400 = 11; + MX_360x480 = 12; + MX_400x600 = 13; + + (* Fade effects *) + MX_FADEIN = 0; + MX_FADEOUT = 1; + + (* Raster ops *) + OP_SET = 0; + OP_AND = 1; + OP_OR = 2; + OP_XOR = 3; + OP_TRANS = 4; + OP_ADD = 5; + OP_MOVE = 0; (* Alias for OP_SET *) + +procedure mxBitBlt( SX, SY: integer; Width, Height: word; DX, DY: integer ); +procedure mxCircle( CX, CY: integer; Radius: word; Color: byte ); +procedure mxChangeMode( Mode: word ); +procedure mxColorToGray( ColorPalette, GrayPalette: pointer; Count: word ); +procedure mxFadePalette( Palette: pointer; Cmd, Start, Count, R, G, B: word ); +procedure mxFillBox( X, Y: integer; Width, Height: word; Color: byte; Op: word ); +procedure mxGammaCorrect( ColorPalette, GammaPalette: pointer; Count: word ); +procedure mxGetAspect( var AspectX, AspectY: word ); +function mxGetClipRegion( var X1, Y1, Width, Height: word ): boolean; +function mxGetClip: boolean; +procedure mxGetImage( Image: pointer; X, Y: integer; Width, Height: word ); +procedure mxGetPalette( Palette: pointer; Start, Count: word ); +function mxGetPixel( X, Y: word ): byte; +procedure mxGetScreenSize( var Width, Height: word ); +procedure mxGetTextStep( var DeltaX, DeltaY: integer ); +function mxGetVersion: word; +procedure mxGetVirtualScreen( var Width, Height: word ); +procedure mxInit; +procedure mxLine( X1, Y1, X2, Y2: integer; Color, Op: word ); +procedure mxOutChar( X, Y: integer; C: char ); +procedure mxOutText( X, Y: integer; S: pointer ); +procedure mxPan( X, Y: word ); +procedure mxPutImage( Image: pointer; X, Y: integer; Width, Height, Op: word ); +procedure mxPutPixel( X, Y: word; C: byte ); +procedure mxPutTile( Tile: pointer; X, Y: integer; Width, Height: word ); +procedure mxReadPlane( Plane: byte ); +procedure mxRotatePalette( Palette: pointer; Count: word; Step: integer ); +procedure mxRowAddress( RowAddress: byte ); +function mxSetClip( Clip: boolean ): boolean; +procedure mxSetClipRegion( X1, Y1, Width, Height: word ); +procedure mxSetColor( Index, R, G, B: word ); +procedure mxSetFont( Font: pointer; Width, Height: word ); +procedure mxSetMode( Mode: word ); +procedure mxSetPalette( Palette: pointer; Start, Count: word ); +procedure mxSetTextColor( Color, Op: word ); +procedure mxSetTextStep( DeltaX, DeltaY: integer ); +procedure mxSetVirtualScreen( Width, Height: word ); +procedure mxStretchImage( Image: pointer; X, Y: integer; Width, Height, NewWidth, NewHeight, Op: word ); +procedure mxSplitScreen( Line: word ); +procedure mxStartAddress( StartAddress: word ); +procedure mxStartLine( Line: word ); +procedure mxTerm; +procedure mxTransPutTile( Tile: pointer; X, Y: integer; Width, Height: word ); +procedure mxWaitDisplay; +procedure mxWaitRetrace; +procedure mxWriteMode( Mode: byte ); +procedure mxWritePlane( Plane: byte ); + +procedure mxFillPoly( Count: word; var Map, Points; Color: word ); +procedure mxGouraudPoly( Count: word; var Map, Points, Colors; BaseColor: word ); +procedure mxTexturePoly( Count: word; var Map, Points, ImgPoints, Texture; Width: word ); + +procedure mxOutStr( X, Y: integer; S: string ); + +implementation + +procedure mxBitBlt; external; +procedure mxChangeMode( Mode: word ); external; +procedure mxCircle; external; +procedure mxColorToGray; external; +procedure mxFadePalette; external; +procedure mxFillBox; external; +procedure mxGammaCorrect; external; +procedure mxGetAspect( var AspectX, AspectY: word ); external; +function mxGetClipRegion; external; +function mxGetClip: boolean; external; +procedure mxGetImage; external; +procedure mxGetPalette( Palette: pointer; Start, Count: word ); external; +function mxGetPixel( X, Y: word ): byte; external; +procedure mxGetScreenSize( var Width, Height: word ); external; +procedure mxGetTextStep( var DeltaX, DeltaY: integer ); external; +function mxGetVersion: word; external; +procedure mxGetVirtualScreen( var Width, Height: word ); external; +procedure mxInit; external; +procedure mxLine( X1, Y1, X2, Y2: integer; Color, Op: word ); external; +procedure mxOutChar( X, Y: integer; C: char ); external; +procedure mxOutText( X, Y: integer; S: pointer ); external; +procedure mxPan( X, Y: word ); external; +procedure mxPutImage; external; +procedure mxPutPixel( X, Y: word; C: byte ); external; +procedure mxPutTile; external; +procedure mxReadPlane( Plane: byte ); external; +procedure mxRotatePalette; external; +procedure mxRowAddress( RowAddress: byte ); external; +function mxSetClip( Clip: boolean ): boolean; external; +procedure mxSetClipRegion( X1, Y1, Width, Height: word ); external; +procedure mxSetColor( Index, R, G, B: word ); external; +procedure mxSetFont( Font: pointer; Width, Height: word ); external; +procedure mxSetMode( Mode: word ); external; +procedure mxSetPalette( Palette: pointer; Start, Count: word ); external; +procedure mxSetTextColor( Color, Op: word ); external; +procedure mxSetTextStep( DeltaX, DeltaY: integer ); external; +procedure mxSetVirtualScreen( Width, Height: word ); external; +procedure mxSplitScreen( Line: word ); external; +procedure mxStartAddress( StartAddress: word ); external; +procedure mxStartLine; external; +procedure mxStretchImage; external; +procedure mxTerm; external; +procedure mxTransPutTile; external; +procedure mxWaitDisplay; external; +procedure mxWaitRetrace; external; +procedure mxWriteMode( Mode: byte ); external; +procedure mxWritePlane( Plane: byte ); external; + +procedure mxFillPoly; external; +procedure mxGouraudPoly; external; +procedure mxTexturePoly; external; +{$L MXPB} +{$L MXPF} +{$L MXPG} +{$L MXPT} + +{$L MXBB} +{$L MXCC} +{$L MXCG} +{$L MXCL} +{$L MXCR} +{$L MXFB} +{$L MXFP} +{$L MXGI} +{$L MXGM} +{$L MXGP} +{$L MXGV} +{$L MXHL} +{$L MXIT} +{$L MXLN} +{$L MXOT} +{$L MXPI} +{$L MXPN} +{$L MXPP} +{$L MXRA} +{$L MXRP} +{$L MXSA} +{$L MXSC} +{$L MXSI} +{$L MXSL} +{$L MXSM} +{$L MXSP} +{$L MXSS} +{$L MXTL} +{$L MXVS} +{$L MXWD} +{$L MXWM} +{$L MXWP} +{$L MXWR} + +(* + Prints a Turbo Pascal string. + Note: BP 7.0 supports ASCIIZ strings (PChar type). +*) +procedure mxOutStr; +begin + S := S + #0; + mxOutText( X, Y, @S[1] ); +end; + +end. diff --git a/16/xw_/modex/DEMO01.EXE b/16/xw_/modex/DEMO01.EXE new file mode 100755 index 00000000..28caff88 Binary files /dev/null and b/16/xw_/modex/DEMO01.EXE differ diff --git a/16/xw_/modex/DEMO01.PAS b/16/xw_/modex/DEMO01.PAS new file mode 100755 index 00000000..c684acdd --- /dev/null +++ b/16/xw_/modex/DEMO01.PAS @@ -0,0 +1,126 @@ +(* + DEMO01 - Sprites, page flipping and palette rotation + Copyright (c) 1994 Alessandro Scotti +*) +uses Crt, Modex; + +const + MAX_SPRITE = 100; +type + (* Sprite structure *) + TSprite = record + X, Y : integer; (* Sprite coordinates *) + DX,DY: integer; (* Deltas for sprite movement *) + W, H : integer; (* Sprite width and height *) + Image: array[ 1..16, 1..16 ] of byte; (* Sprite image data *) + end; + (* RGB color structure *) + TRgb = record + R, G, B: byte; + end; +var + S : array[ 1..MAX_SPRITE ] of TSprite; (* An array of sprites *) + Palette: array[ byte ] of TRgb; (* Palette *) + Page : word; (* Page offset *) + I : word; + +(* Initializes a sprite structure *) +procedure sxInit( var S: TSprite ); +var + I: word; +begin + S.X := Random( 320 ); (* Initialize position with random values *) + S.Y := Random( 240 ); + S.DX := Random( 7 )-3; (* Initialize speed with random values *) + S.DY := Random( 7 )-3; + S.W := 16; (* Size is fixed in this program *) + S.H := 16; + (* The image is a square with a hole inside *) + FillChar( S.Image, SizeOf(S.Image), Random(15)+1 ); + for I:=5 to 12 do FillChar( S.Image[ I, 5 ], 8, 0 ); +end; + +(* Moves a sprite *) +procedure sxMove( var S: TSprite ); +begin + Inc( S.X, S.DX ); (* Get new position *) + Inc( S.Y, S.DY ); + (* Check sprite position, change delta if needed *) + if( S.X > 320 ) then begin + S.X := 320; + S.DX := -S.DX; + end; + if( S.X < -16 ) then begin + S.X := -16; + S.DX := -S.DX; + end; + if( S.Y > 240 ) then begin + S.Y := 240; + S.DY := -S.DY; + end; + if( S.Y < -16 ) then begin + S.Y := -16; + S.DY := -S.DY; + end; + (* Draw the sprite, note the Page offset added to the *) + (* Y coordinate of the image *) + mxPutImage( @S.Image, S.X, Page+S.Y, S.W, S.H, OP_TRANS ); +end; + +begin + (* Initialize library *) + mxInit; + + (* Enter graphics mode *) + mxSetMode( MX_320x240 ); + + (* Print initialization message *) + mxSetTextColor( 15, OP_TRANS ); + mxOutStr( 4, 4, 'Initializing...' ); + + (* Initialize sprites *) + for I:=1 to MAX_SPRITE do sxInit( S[I] ); + + (* Draw background *) + for I:=1 to 192 do begin + mxCircle( 160, 480+120, I, I+63 ); + mxCircle( 161, 480+120, I, I+63 ); + end; + + (* Compute and set palette *) + for I:=1 to 192 do with Palette[I+63] do begin + R := 0; + G := 0; + B := 0; + if( I < 64 ) then + R := I shr 1+31 + else if( I < 128 ) then + G := (I-64) shr 1+31 + else + B := (I-128) shr 1+31; + end; + mxSetPalette( @Palette[64], 64, 192 ); + + (* Main loop *) + Page := 240; + while( not KeyPressed ) do begin + (* Set clip region to current page *) + mxSetClipRegion( 0, Page, 320, 240 ); + mxSetClip( TRUE ); + (* Restore background *) + mxBitBlt( 0, 480, 320, 240, 0, Page ); + (* Draw sprites *) + for I:=1 to MAX_SPRITE do sxMove( S[I] ); + (* Print message *) + mxOutStr( 4, Page+4, 'Some sprites moving...' ); + (* Flip page *) + mxStartLine( Page ); + Page := 240-Page; + (* Animate palette *) + mxSetPalette( @Palette[64], 64, 192 ); + mxRotatePalette( @Palette[64], 192, 3 ); + end; + + mxSetMode( MX_TEXT ); + mxTerm; +end. diff --git a/16/xw_/modex/DEMO02.EXE b/16/xw_/modex/DEMO02.EXE new file mode 100755 index 00000000..14e7dc72 Binary files /dev/null and b/16/xw_/modex/DEMO02.EXE differ diff --git a/16/xw_/modex/DEMO02.PAS b/16/xw_/modex/DEMO02.PAS new file mode 100755 index 00000000..6b4fb6f9 --- /dev/null +++ b/16/xw_/modex/DEMO02.PAS @@ -0,0 +1,125 @@ +(* + DEMO02 - Texture mapping and palette rotation + (c) 1994 by Alessandro Scotti +*) +uses Crt, Modex, Plasma, Threed; + +const + LSIZE = 85; + Trans : TPoint = ( X:0; Y:0; Z:0 ); +type + T2DPoint = record + X, Y: integer; + end; + TTexture = record + Desc : array[ 0..3 ] of T2DPoint; + Width : word; + Data : array[ 1..64*64 ] of byte; + end; + TQuad = record + VtxCnt : word; + Vtx : array[ 0..3 ] of word; + Texture: word; + end; +var + Vtx : array[ 0..7 ] of TPoint; + XVtx : array[ 0..7 ] of TPoint; + VVtx : array[ 0..7 ] of T2DPoint; + Face : array[ 0..5 ] of TQuad; + Txts : array[ 0..5 ] of TTexture; + Nrm : array[ 0..5 ] of TPoint; + XNrm : array[ 0..5 ] of TPoint; + Page : word; + Palette: array[ byte ] of record R, G, B: byte; end; + +(* Make a 64x64 plasma to be used as texture *) +procedure MakeTexture( Idx: word ); +var + I: word; +begin + mxFillBox( 0, 0, 64, 64, 0, OP_SET ); + MakePlasma( 0, 0, 64, 64, 96, Random(192)+1, Random(192)+1, Random(192)+1 ); + mxGetImage( @Txts[Idx].Data, 0, 0, 64, 64 ); + (* Texture vertexes are 8:8 fixed, add $80 (0.5) for best results *) + with Txts[Idx] do begin + Desc[0].X := $80; Desc[0].Y := $80; + Desc[1].X := $80; Desc[1].Y := $3F80; + Desc[2].X := $3F80; Desc[2].Y := $3F80; + Desc[3].X := $3F80; Desc[3].Y := $80; + Width := 64; + end; +end; + +procedure Init; +var + I: integer; +begin + (* Build vertexes for a cube *) + with Vtx[0] do begin X:=-LSIZE; Y:=-LSIZE; Z:=-LSIZE; end; + with Vtx[1] do begin X:=+LSIZE; Y:=-LSIZE; Z:=-LSIZE; end; + with Vtx[2] do begin X:=-LSIZE; Y:=+LSIZE; Z:=-LSIZE; end; + with Vtx[3] do begin X:=+LSIZE; Y:=+LSIZE; Z:=-LSIZE; end; + with Vtx[4] do begin X:=-LSIZE; Y:=-LSIZE; Z:=+LSIZE; end; + with Vtx[5] do begin X:=+LSIZE; Y:=-LSIZE; Z:=+LSIZE; end; + with Vtx[6] do begin X:=-LSIZE; Y:=+LSIZE; Z:=+LSIZE; end; + with Vtx[7] do begin X:=+LSIZE; Y:=+LSIZE; Z:=+LSIZE; end; + for I:=0 to 7 do begin (* Make points 16:16 fixed *) + Vtx[I].X := Vtx[I].X*$10000; + Vtx[I].Y := Vtx[I].Y*$10000; + Vtx[I].Z := Vtx[I].Z*$10000; + end; + (* Build faces *) + with Face[0] do begin Vtx[0]:=0; Vtx[1]:=2; Vtx[2]:=3; Vtx[3]:=1; end; + with Face[1] do begin Vtx[0]:=4; Vtx[1]:=5; Vtx[2]:=7; Vtx[3]:=6; end; + with Face[2] do begin Vtx[0]:=0; Vtx[1]:=1; Vtx[2]:=5; Vtx[3]:=4; end; + with Face[3] do begin Vtx[0]:=1; Vtx[1]:=3; Vtx[2]:=7; Vtx[3]:=5; end; + with Face[4] do begin Vtx[0]:=2; Vtx[1]:=0; Vtx[2]:=4; Vtx[3]:=6; end; + with Face[5] do begin Vtx[0]:=7; Vtx[1]:=3; Vtx[2]:=2; Vtx[3]:=6; end; + for I:=0 to 5 do Face[I].Texture := I; + (* Build textures and palette *) + Randomize; + FillChar( Palette, SizeOf(Palette), 0 ); + MakePlasmaPalette( Palette, PAL_RGB ); + mxSetPalette( @Palette, 0, 193 ); + for I:=0 to 5 do MakeTexture( I ); +end; + +var + AX, AY, AZ: byte; + I: word; +begin + mxInit; + mxSetMode( MX_320x240 ); + Init; + Page := 240; (* Start with hidden page *) + + AX := 0; + AY := 0; + AZ := 0; + (* Init 3D transforms, perspective is intentionally exaggerated *) + tdSetTranslation( Trans ); + tdSetPerspective( 400*$10000, $10000, $10000 ); + (* Main loop, all magic here! *) + while( not KeyPressed ) do begin + tdSetRotation( AX, AY, AZ ); (* Set new angles *) + tdTransform( Vtx, XVtx, 8 ); (* 3D transform points *) + tdTransformToImage( XVtx, VVtx, 8, 160, 120+Page ); + Inc( AX, 1 ); (* Bump angles *) + Inc( AY, 1 ); + Inc( AZ, 2 ); + mxSetClipRegion( 0, Page, 320, 240 ); (* Set clip to new page *) + mxSetClip( TRUE ); + mxFillBox( 0, Page, 320, 240, 0, OP_MOVE ); (* Clear screen *) + mxRotatePalette( @Palette[1], 192, 3 ); (* Rotate palette *) + (* Draw cube: backface culling is straighforward in this case, so *) + (* it can be handled by the polygon filling procedure *) + for I:=0 to 5 do + mxTexturePoly( 4, Face[I].Vtx, VVtx, Txts[I].Desc, Txts[I].Data, Txts[I].Width ); + mxStartLine( Page ); (* Flip pages *) + mxSetPalette( @Palette[1], 1, 192 ); (* Set new palette *) + Page := 240-Page; + end; + + mxSetMode( MX_TEXT ); + mxTerm; +end. diff --git a/16/xw_/modex/DEMO03.EXE b/16/xw_/modex/DEMO03.EXE new file mode 100755 index 00000000..c646c4b0 Binary files /dev/null and b/16/xw_/modex/DEMO03.EXE differ diff --git a/16/xw_/modex/DEMO03.PAS b/16/xw_/modex/DEMO03.PAS new file mode 100755 index 00000000..01d10f49 --- /dev/null +++ b/16/xw_/modex/DEMO03.PAS @@ -0,0 +1,152 @@ +(* + DEMO03 - Simple star animation, morphs between a cube and a sphere + (c) 1994 by Alessandro Scotti +*) +uses Crt, Modex, Threed; + +const + MAXVTX = 1000; (* Number of points *) + EDGE = 70; (* Length of cube edge *) + RADIUS = 90; (* Radius of sphere *) + WAITCOUNT = 192; (* Frames to wait for non-morphing shapes *) + MS = 32; (* Number of steps for morphing *) + Trans : TPoint = ( X:0; Y:0; Z:0 ); + InitMorph1: array[ 0..3 ] of integer = ( 0, MS, 0, 0 ); + InitMorph2: array[ 0..3 ] of integer = ( 0, 0, 0, MS ); + InitDelta1: array[ 0..3 ] of integer = ( 0, -1, 0, +1 ); + InitDelta2: array[ 0..3 ] of integer = ( 0, +1, 0, -1 ); +type + T2DPoint = record + X, Y: integer; + end; + T3DPointArray = array[ 0..MAXVTX-1 ] of TPoint; + P3DPointArray = ^T3DPointArray; +var + CubeVtx, SphereVtx, Vtx, XVtx: P3DPointArray; + VVtx : array[ 0..MAXVTX-1 ] of T2DPoint; + Page : word; + Status, Count, Delta1, Delta2, Morph1, Morph2: integer; + +procedure Swap( var A, B: longint ); +var + L: longint; +begin + L := A; A := B; B := L; +end; + +function Toggle( A: longint ): longint; +begin + Toggle := A; + if( Random(2) = 0 ) then Toggle := -A; +end; + +procedure Init; +label Retry; +var + I: integer; +begin + New( CubeVtx ); + New( SphereVtx ); + New( Vtx ); + New( XVtx ); + (* Build vertexes (yes, I know this piece of code is terrible) *) + Randomize; + for I:=0 to MAXVTX-1 do begin + with CubeVtx^[I] do begin + (* Build cube *) + X := (longint(Random(2*EDGE))-EDGE)*$10000; + Y := (longint(Random(2*EDGE))-EDGE)*$10000; + Z := Toggle( EDGE*$10000 ); + case Random(3) of + 0: Swap( X, Z ); + 1: Swap( Y, Z ); + end; + end; + with SphereVtx^[I] do begin + (* Build sphere *) +Retry: + X := (longint(Random(2*RADIUS))-RADIUS); + Y := (longint(Random(2*RADIUS))-RADIUS); + if( X*X+Y*Y > RADIUS*RADIUS ) then goto Retry; + Z := Toggle( Round( Sqrt( Abs( RADIUS*RADIUS-X*X-Y*Y ) ) ) ); + case Random(3) of + 0: Swap( X, Z ); + 1: Swap( Y, Z ); + end; + X := X * $10000; Y := Y * $10000; Z := Z * $10000; + end; + end; + (* Initialize morphing *) + Move( CubeVtx^, Vtx^, SizeOf(Vtx^) ); + Status := 0; + Count := WAITCOUNT; +end; + +procedure Morph; +var + I: integer; +begin + (* Fully unoptimized, slowest loop I could think of! *) + for I:=0 to MAXVTX-1 do begin + Vtx^[I].X := ((CubeVtx^[I].X * Morph1)+(SphereVtx^[I].X * Morph2)) div MS; + Vtx^[I].Y := ((CubeVtx^[I].Y * Morph1)+(SphereVtx^[I].Y * Morph2)) div MS; + Vtx^[I].Z := ((CubeVtx^[I].Z * Morph1)+(SphereVtx^[I].Z * Morph2)) div MS; + end; +end; + +var + AX, AY, AZ: byte; + I: word; + C: char; +begin + mxInit; + mxSetMode( MX_320x240 ); + Init; + Page := 240; (* Start with hidden page *) + + AX := 0; + AY := 0; + AZ := 0; + (* Init 3D transforms, perspective is intentionally exaggerated *) + tdSetTranslation( Trans ); + tdSetPerspective( 400*$10000, $10000, $10000 ); + C := #0; + repeat + tdSetRotation( AX, AY, AZ ); (* Set new angles *) + tdTransform( Vtx^, XVtx^, MAXVTX ); (* 3D transform points *) + tdTransformToImage( XVtx^, VVtx, MAXVTX, 160, 120+Page ); + Inc( AX, 1 ); (* Bump angles *) + Inc( AY, 1 ); + Inc( AZ, 2 ); + mxSetClipRegion( 0, Page, 320, 240 ); (* Set clip to new page *) + mxSetClip( TRUE ); + mxFillBox( 0, Page, 320, 240, 0, OP_MOVE ); (* Clear screen *) + (* Draw points *) + for I:=0 to MAXVTX-1 do + mxPutPixel( VVtx[I].X, VVtx[I].Y, 128 + XVtx^[I].Z shr 18 ); + mxStartLine( Page ); (* Flip pages *) + Page := 240-Page; + (* Morph *) + if( Odd(Status) ) then begin + Morph; + Inc( Morph1, Delta1 ); + Inc( Morph2, Delta2 ); + if( Morph1 < 0 )or( Morph2 < 0 ) then Inc( Status ); + if( Status = 4 ) then Status := 0; + end + else begin + Dec( Count ); + if( Count < 0 ) then begin + Inc( Status ); + Count := WAITCOUNT; + Morph1 := InitMorph1[Status]; + Morph2 := InitMorph2[Status]; + Delta1 := InitDelta1[Status]; + Delta2 := InitDelta2[Status]; + end; + end; + until( KeyPressed ); + + mxSetMode( MX_TEXT ); + mxTerm; +end. diff --git a/16/xw_/modex/DEMO04.DAT b/16/xw_/modex/DEMO04.DAT new file mode 100755 index 00000000..72aaad08 Binary files /dev/null and b/16/xw_/modex/DEMO04.DAT differ diff --git a/16/xw_/modex/DEMO04.EXE b/16/xw_/modex/DEMO04.EXE new file mode 100755 index 00000000..1fec5e8a Binary files /dev/null and b/16/xw_/modex/DEMO04.EXE differ diff --git a/16/xw_/modex/DEMO04.PAS b/16/xw_/modex/DEMO04.PAS new file mode 100755 index 00000000..1a946315 --- /dev/null +++ b/16/xw_/modex/DEMO04.PAS @@ -0,0 +1,198 @@ +(* + DEMO04 - Multiple textures and triple buffering (3 pages) + (c) 1994 by Alessandro Scotti +*) +uses Crt, Modex, Threed; + +const + MAXVTX = 256; + MAXCUB = 2; + MAXTXT = 2; + Trans : TPoint = ( X:0; Y:0; Z:0 ); + TxtSunDial: array[ 0..7 ] of word = ( + $7F80,$0080, $0080,$0080, $0080,$7E80, $7F80,$7E80 ); + TxtSapphire : array[ 0..7 ] of word = ( + $0080,$0080, $0080,$1F80, $1F80,$1F80, $1F80,$0080 ); + TxtMarble: array[ 0..7 ] of word = ( + $0080,$8080, $0080,$FD80, $7F80,$FD80, $7F80,$8080 ); +type + T2DPoint = record + X, Y: integer; + end; + TTexture = record + Desc : array[ 0..3 ] of record X, Y: word end; + Width : word; + Data : pointer; + end; + TQuad = record + Vtx : array[ 0..3 ] of word; + Texture: word; + end; + TCube = record + Face : array[ 0..5 ] of TQuad; + Base : integer; + end; +var + Vtx, XVtx: array[ 0..MAXVTX ] of TPoint; + VVtx : array[ 0..MAXVTX ] of T2DPoint; + Cube : array[ 0..MAXCUB ] of TCube; + ZList : array[ 0..MAXCUB ] of integer; + VtxCnt : word; + Txts : array[ 0..MAXTXT ] of TTexture; + Page : word; + Palette : array[ byte ] of record R, G, B: byte; end; + TxtDat1, TxtDat2: pointer; + +(* Add a new entry to the vertex array *) +procedure AddVtx( PX, PY, PZ: longint ); +begin + with Vtx[VtxCnt] do begin X:=PX*$10000; Y:=PY*$10000; Z:=PZ*$10000; end; + Inc( VtxCnt ); +end; + +procedure MakeCube( var C: TCube; X1,Y1,Z1, X2,Y2,Z2, TX,TY,TZ, Texture: integer ); +const + FaceIdx: array[ 0..23 ] of integer = ( + 0,1,2,3, 0,4,5,1, 1,5,6,2, 2,6,7,3, 3,7,4,0, 6,5,4,7 ); +var + I, VC: integer; +begin + VC := VtxCnt; + C.Base := VC; + AddVtx( X1+TX, Y1+TY, Z1+TZ ); + AddVtx( X2+TX, Y1+TY, Z1+TZ ); + AddVtx( X2+TX, Y2+TY, Z1+TZ ); + AddVtx( X1+TX, Y2+TY, Z1+TZ ); + AddVtx( X1+TX, Y1+TY, Z2+TZ ); + AddVtx( X2+TX, Y1+TY, Z2+TZ ); + AddVtx( X2+TX, Y2+TY, Z2+TZ ); + AddVtx( X1+TX, Y2+TY, Z2+TZ ); + for I:=0 to 23 do C.Face[I shr 2].Vtx[I and 3] := VC+FaceIdx[I]; + for I:=0 to 5 do C.Face[I].Texture := Texture; +end; + +procedure MakeTexture( Idx: integer; var VtxData ); +var + P: ^word; + I: integer; +begin + P := @VtxData; + with Txts[Idx] do begin + for I:=0 to 3 do begin + Desc[I].X := P^; Inc( P ); + Desc[I].Y := P^; Inc( P ); + end; + Width := 129; + Data := TxtDat1; + end; +end; + +procedure Init; +var + I: integer; + V: integer; + F: file; + P: array[ 1..768 ] of byte; +begin + (* Initialize objects *) + VtxCnt := 0; + MakeCube( Cube[0], -64,-64,8, 64,64,-8, 0,0,0, 1 ); (* Sundial *) + Cube[0].Face[0].Texture := 0; + V := VtxCnt; + MakeCube( Cube[1], -16,-16,16, 16,16,-16, 0,0,0, 2 ); (* Sapphire *) + tdSetTranslation( Trans ); + tdSetRotation( 32, 32, 00 ); + tdRotate( Vtx[V], XVtx[V], 8 ); (* Got to rotate this cube *) + for I:=V to V+7 do begin + Vtx[I].X := XVtx[I].X; + Vtx[I].Y := XVtx[I].Y; + Vtx[I].Z := XVtx[I].Z + 100*$10000; + end; + MakeCube( Cube[2], -64,-4,48, 64,4,-48, 0,68,56, 1 ); (* Marble *) + (* Load texture and palette *) + Assign( F, 'DEMO04.DAT' ); + Reset( F, 1 ); + BlockRead( F, P, SizeOf(P) ); + mxSetPalette( @P, 0, 256 ); + GetMem( TxtDat1, 63*1024 ); + BlockRead( F, TxtDat1^, 129*286 ); + Close( F ); + TxtDat2 := Ptr( Seg(TxtDat1^), Ofs(TxtDat1^)+129*254 ); + (* Init textures *) + MakeTexture( 0, TxtSundial ); + MakeTexture( 1, TxtMarble ); + MakeTexture( 2, TxtSapphire ); + Txts[2].Data := TxtDat2; +end; + +(* Sort procedure, not worth optimizing with only a few objects *) +procedure SortObjects; +var + I, J, K: integer; + ZMax: array[ 0..MAXCUB ] of longint; + ZI: integer; + L: longint; +begin + for I:=0 to MAXCUB do begin + L := XVtx[Cube[I].Base].Z; + for J:=1 to 7 do + if( L > XVtx[Cube[I].Base+J].Z ) then L := XVtx[Cube[I].Base+J].Z; + ZMax[I] := L; + ZList[I] := I; + end; + for I:=0 to MAXCUB-1 do begin + ZI := I; + for J:=I+1 to MAXCUB do + if( ZMax[ZList[J]] > ZMax[ZList[ZI]] ) then ZI := J; + if( ZI <> I ) then begin + K := ZList[I]; + ZList[I] := ZList[ZI]; + ZList[ZI] := K; + end; + end; +end; + +var + AX, AY, AZ: byte; + I, J, K: word; +begin + mxInit; + mxSetMode( MX_320x240 ); + Init; + Page := 240; (* Start with hidden page *) + + (* Init 3D transforms, perspective is intentionally exaggerated *) + AX := 0; AY := 0; AZ := 0; + tdSetTranslation( Trans ); + tdSetPerspective( 600*$10000, $10000, $10000 ); + (* Main loop, all magic here! *) + while( not KeyPressed ) do begin + tdSetRotation( AX, AY, AZ ); (* Set new angles *) + tdTransform( Vtx, XVtx, VtxCnt ); (* 3D transform points *) + tdTransformToImage( XVtx, VVtx, VtxCnt, 160, 120+Page ); + Inc( AX, 1 ); (* Bump angles *) + Inc( AY, 2 ); + Inc( AZ, 1 ); + mxSetClipRegion( 0, Page, 320, 240 ); (* Set clip to new page *) + mxSetClip( TRUE ); + mxFillBox( 0, Page, 320, 240, 0, OP_MOVE ); (* Clear screen *) + (* Draw objects *) + SortObjects; + for I:=0 to MAXCUB do with Cube[ZList[I]] do begin + for J:=0 to 5 do begin + K := Face[J].Texture; + mxTexturePoly( 4, Face[J].Vtx, VVtx, Txts[K].Desc, Txts[K].Data^, Txts[K].Width ); + end; + end; + (* Flip page: at 320x240 the Start Address Register Low is always zero *) + case Page of + 0 : begin PortW[$3D4] := $000C; Page := 240; end; + 240: begin PortW[$3D4] := $4B0C; Page := 480; end; + 480: begin PortW[$3D4] := $960C; Page := 0; end; + end; + mxWaitRetrace; (* If the frame rate seems low, try to remove this line *) + end; + + mxSetMode( MX_TEXT ); + mxTerm; +end. diff --git a/16/xw_/modex/DEMO05.EXE b/16/xw_/modex/DEMO05.EXE new file mode 100755 index 00000000..21a7c207 Binary files /dev/null and b/16/xw_/modex/DEMO05.EXE differ diff --git a/16/xw_/modex/DEMO05.PAS b/16/xw_/modex/DEMO05.PAS new file mode 100755 index 00000000..819c5cf3 --- /dev/null +++ b/16/xw_/modex/DEMO05.PAS @@ -0,0 +1,131 @@ +(* + DEMO05 - A Gouraud-shaded rotating torus + (c) 1994 Alessandro Scotti +*) +uses Crt, Modex, Threed; + +(* Define ALTPAL for alternate palette *) +{$define ALTPAL} + +const + MAXVTX1 = 15; RADIUS1 = 70; (* MAXVTX1+1 must be multiple of 4 *) + MAXVTX2 = 15; RADIUS2 = 30; + MAXVTX = (MAXVTX1+1)*(MAXVTX2+1)-1; + MAXFACE = MAXVTX; + Trans : TPoint = ( X:0; Y:0; Z:0 ); (* Object translation *) + Light : TPoint = ( X:0; Y:0; Z:-63*$10000 ); (* Light direction *) +type + TQuad = record + QVtx : array[ 0..3 ] of integer; + end; +var + Vtx, XVtx : array[ 0..MAXVTX ] of TPoint; (* Points *) + VVtx : array[ 0..MAXVTX ] of record X, Y: integer end; + Face : array[ 0..MAXFACE ] of TQuad; (* Polys *) + Culled : array[ 0..MAXFACE ] of integer; + GNrm,XGNrm: array[ 0..MAXVTX ] of TVector; (* Gouraud normals *) + VtxLight : array[ 0..MAXVTX ] of integer; (* Points brightness *) + Page : word; + +function GetVtx( I1, I2: integer ): integer; +begin + GetVtx := (I1 mod (MAXVTX1+1))*(MAXVTX2+1) + I2 mod (MAXVTX2+1); +end; + +procedure Init; +var + R, N, X, Y, Z: real; + I, J, K, V: integer; +begin + (* Build vertexes *) + for I:=0 to MAXVTX1 do begin + K := (I + (MAXVTX1+1) shr 2) mod (MAXVTX1+1); + R := RADIUS1 + RADIUS2*Cos( 2*K*Pi / (MAXVTX1+1) ); + for J:=0 to MAXVTX2 do begin + V := I*(MAXVTX2+1)+J; (* Index of current vertex *) + (* Compute coordinates of current vertex *) + X := R*Cos(2*J*Pi / (MAXVTX2+1)); (* Get coordinates *) + Y := R*Sin(2*J*Pi / (MAXVTX2+1)); + Z := RADIUS2*Sin(2*K*Pi / (MAXVTX1+1)); + Vtx[V].X := Round( X )*$10000; (* Save coordinates *) + Vtx[V].Y := Round( Y )*$10000; + Vtx[V].Z := Round( Z )*$10000; + (* Compute direction of Gouraud normal thru current vertex *) + X := X - RADIUS1*Cos(2*J*Pi / (MAXVTX2+1)); + Y := Y - RADIUS1*Sin(2*J*Pi / (MAXVTX2+1)); + N := Sqrt( X*X + Y*Y + Z*Z ); (* Get vector length *) + GNrm[V].X := Trunc( X*$10000/N ); (* Save normal vector *) + GNrm[V].Y := Trunc( Y*$10000/N ); + GNrm[V].Z := Trunc( Z*$10000/N ); + end; + end; + (* Generate faces so that depth-sorting is not needed: there are still *) + (* some *very* little errors, but this is the best I could devise *) + J := 0; + K := 0; + for I:=0 to MAXFACE do with Face[I] do begin + QVtx[0] := GetVtx( J, K ); + QVtx[1] := GetVtx( J, K+1 ); + QVtx[2] := GetVtx( J+1, K+1 ); + QVtx[3] := GetVtx( J+1, K ); + Inc( K ); + if( K > MAXVTX2 ) then begin + K := 0; + Inc( J ); + end; + end; +{$ifndef ALTPAL} + for I:=0 to 63 do mxSetColor( I+64, 0, 0, I ); (* Blue palette *) +{$else} + for I:=0 to 31 do mxSetColor(I+64, 0, I shl 1, 0); (* Green neon palette *) + for I:=32 to 63 do mxSetColor ( I+64, (I-32) shl 1, 63, (I-32) shl 1 ); +{$endif} +end; + +var + AX, AY, AZ: byte; + I: word; +begin + mxInit; + mxSetMode( MX_320x240 ); + Init; + Page := 240; (* Start with hidden page *) + + AX := 0; + AY := 0; + AZ := 0; + (* Init 3D transforms, perspective is intentionally exaggerated *) + tdSetTranslation( Trans ); + tdSetLight( Light ); + tdSetPerspective( 400*$10000, $10000, $10000 ); + (* Main loop, all magic here! *) + while( not KeyPressed ) do begin + tdSetRotation( AX, AY, AZ ); (* Set new angles *) + tdTransform( Vtx, XVtx, MAXVTX+1 ); (* 3D transform points *) + tdTransformToImage( XVtx, VVtx, MAXVTX+1, 160, 120+Page ); + tdRotate( GNrm, XGNrm, MAXVTX+1 ); (* Rotate Gouraud normals *) + tdTransformLight( XGNrm, VtxLight, MAXVTX+1 ); + (* Backplane culling is not really needed here! *) + FillChar( Culled, SizeOf(Culled), 0 ); + tdBackPlaneCull( Face, XVtx, Culled, MAXFACE+1, SizeOf(TQuad) ); + Inc( AX, 1 ); (* Bump angles *) + Inc( AY, 2 ); + Inc( AZ, 3 ); + mxSetClipRegion( 0, Page, 320, 240 ); (* Set clip to new page *) + mxSetClip( TRUE ); + mxFillBox( 0, Page, 320, 240, 0, OP_MOVE ); (* Clear screen *) + (* Draw polygons *) + for I:=0 to MAXFACE do with Face[I] do + if( Culled[I] >= 0 ) then mxGouraudPoly( 4, QVtx, VVtx, VtxLight, 64 ); + (* Flip page: at 320x240 the Start Address Register Low is always zero *) + case Page of + 0 : begin PortW[$3D4] := $000C; Page := 240; end; + 240: begin PortW[$3D4] := $4B0C; Page := 480; end; + 480: begin PortW[$3D4] := $960C; Page := 0; end; + end; + mxWaitRetrace; (* Uncomment this instruction if screen flickers *) + end; + + mxSetMode( MX_TEXT ); + mxTerm; +end. diff --git a/16/xw_/modex/DEMO06.DAT b/16/xw_/modex/DEMO06.DAT new file mode 100755 index 00000000..1ac2c2bb Binary files /dev/null and b/16/xw_/modex/DEMO06.DAT differ diff --git a/16/xw_/modex/DEMO06.EXE b/16/xw_/modex/DEMO06.EXE new file mode 100755 index 00000000..f1308e8a Binary files /dev/null and b/16/xw_/modex/DEMO06.EXE differ diff --git a/16/xw_/modex/DEMO06.PAS b/16/xw_/modex/DEMO06.PAS new file mode 100755 index 00000000..f26af067 --- /dev/null +++ b/16/xw_/modex/DEMO06.PAS @@ -0,0 +1,135 @@ +(* + DEMO06 - Magnifying glass + (c) 1994 Alessandro Scotti +*) +uses Crt, Modex; + +const + R = 40; (* Lens radius *) + K : real = 1.8; (* Magnifying factor, less makes a stronger lens *) +type + TLine = array[ 0..319 ] of byte; + PLine = ^TLine; + TScreen = array[ 0..239 ] of PLine; +var + VScreen: TScreen; (* Virtual screen *) + BallX : array[ 0..R, 0..R ] of integer; + BallY : array[ 0..R, 0..R ] of integer; + Sprite : array[ -R..R, -R..R ] of byte; + Page : word; + +(* Returns "lens-view" coordinates of X,Y *) +procedure GetCoords( var X, Y: integer ); +var + LR, Z, SinA, SinB, TgB, Q: real; +begin + LR := Sqrt( X*X + Y*Y ); + if( LR = 0 ) then Exit; + if( LR < R ) then begin + Z := Sqrt( R*R - LR*LR ); + SinA := LR / R; + SinB := SinA / K; + TgB := SinB / Sqrt( 1-SinB*SinB ); + Q := LR - TgB*Z; + X := Round( X * ( Q/LR ) ); + Y := Round( Y * ( Q/LR ) ); + end; +end; + +procedure Init; +var + F : file; + Palette: array[ 0..767 ] of record R, G, B: byte; end; + X, Y, + X2, Y2 : integer; +begin + (* Load background image *) + Assign( F, 'demo06.dat' ); + Reset( F, 1 ); + BlockRead( F, Palette, 768 ); + mxSetPalette( @Palette, 0, 256 ); + for Y:=0 to 239 do begin + New( VScreen[Y] ); + BlockRead( F, VScreen[Y]^, 320 ); + mxPutImage( VScreen[Y], 0, 480+Y, 320, 1, OP_MOVE ); + end; + Close( F ); + (* Build lens *) + for X:=0 to R do begin + for Y:=0 to R do begin + X2 := X; + Y2 := Y; + GetCoords( X2, Y2 ); + BallX[X, Y] := X2; + BallY[X, Y] := Y2; + end; + end; +end; + +procedure PutLens( OX, OY: integer ); +var + X, Y: integer; +begin + for X:=0 to R do begin + for Y:=0 to R do begin + Sprite[Y][X] := VScreen[ OY+BallY[X,Y] ]^[ OX+BallX[X,Y] ]; + Sprite[Y][-X] := VScreen[ OY+BallY[X,Y] ]^[ OX-BallX[X,Y] ]; + Sprite[-Y][X] := VScreen[ OY-BallY[X,Y] ]^[ OX+BallX[X,Y] ]; + Sprite[-Y][-X] := VScreen[ OY-BallY[X,Y] ]^[ OX-BallX[X,Y] ]; + end; + end; + (* Draw the sprite *) + mxPutImage( @Sprite, OX-R, OY-R+Page, 2*R+1, 2*R+1, OP_MOVE ); +end; + +function Delta: integer; +begin + Delta := Random(3)+2; +end; + +procedure Check( Cond: boolean; var Coord, DeltaC: integer; NewCoord, Sign: integer ); +begin + if( Cond ) then begin + Coord := NewCoord; + DeltaC := Sign*Delta; + end; +end; + +var + X, Y, DX, DY: integer; + C: char; +begin + mxInit; + mxSetMode( MX_320x240 ); + Init; + Page := 240; + X := R; + Y := R; + Randomize; + DX := Delta; + DY := Delta; + + (* Main loop *) + repeat + (* Update video *) + mxBitBlt( 0, 480, 320, 240, 0, Page ); + PutLens( X, Y ); + mxCircle( X, Page+Y, R, 0 ); + (* Update lens coordinates *) + Inc( X, DX ); + Check( X+R >= 319, X, DX, 319-R, -1 ); + Check( X <= R, X, DX, R, +1 ); + Inc( Y, DY ); + Check( Y+R >= 239, Y, DY, 239-R, -1 ); + Check( Y <= R, Y, DY, R, +1 ); + (* Flip pages: double buffering, avoid wait for display *) + case Page of + 0 : begin PortW[$3D4] := $000C; Page := 240; end; + 240: begin PortW[$3D4] := $4B0C; Page := 0; end; + end; + mxWaitRetrace; (* Wait for hidden page to show *) + until( KeyPressed ); + + mxSetMode( MX_TEXT ); + mxTerm; +end. diff --git a/16/xw_/modex/DEMO07.EXE b/16/xw_/modex/DEMO07.EXE new file mode 100755 index 00000000..8a401169 Binary files /dev/null and b/16/xw_/modex/DEMO07.EXE differ diff --git a/16/xw_/modex/DEMO07.PAS b/16/xw_/modex/DEMO07.PAS new file mode 100755 index 00000000..04fff790 --- /dev/null +++ b/16/xw_/modex/DEMO07.PAS @@ -0,0 +1,68 @@ +(* + DEMO07 - Hardware scrolling + Copyright (c) 1994 Alessandro Scotti +*) +uses Crt, Modex; + +const + (* Change this if scrolling seems jerky (this simple program does *) + (* not handle vertical retrace/display very well) *) + STEPS = 5; + +procedure Check( Cond: boolean; var Coord, DeltaC: integer; NewCoord, Sign: integer ); +begin + if( Cond ) then begin + Coord := NewCoord; + DeltaC := Sign*(Random(3)+2); + end; +end; + +var + I, X, Y, DX, DY: integer; +begin + (* Initialize library and graphics mode *) + mxInit; + mxSetMode( MX_320x200 ); + (* Set a 640x400 virtual screen *) + mxSetVirtualScreen( 640, 400 ); + mxSetClip( TRUE ); + + X := 0; + Y := 0; + DX := 1; + DY := 1; + + (* Main loop: draw lines, circles, points and rectangles in separate *) + (* 320x200 windows, while smoothly panning virtual screen *) + while( not KeyPressed ) do begin + (* Points *) + mxSetClipRegion( 0, 0, 320, 200 ); + for I:=1 to STEPS do + mxPutPixel( Random(320), Random(200), Random(16) ); + (* Lines *) + mxSetClipRegion( 0, 200, 320, 200 ); + for I:=1 to STEPS do + mxLine( Random(320), Random(200)+200, Random(320), Random(200)+200, Random(16), OP_SET ); + (* Circles *) + mxSetClipRegion( 320, 0, 320, 200 ); + for I:=1 to STEPS do + mxCircle( Random(320)+320, Random(200), Random(100), Random(16) ); + (* Boxes *) + mxSetClipRegion( 320, 200, 320, 200 ); + for I:=1 to STEPS do + mxFillBox( Random(320)+320, Random(200)+200, Random(100)+1, Random(100)+1, Random(16), OP_SET ); + (* Pan *) + Inc( X, DX ); + Check( X+320 >= 639, X, DX, 319, -1 ); + Check( X < 0, X, DX, 0, +1 ); + Inc( Y, DY ); + Check( Y+200 >= 399, Y, DY, 199, -1 ); + Check( Y < 0, Y, DY, 0, +1 ); + mxPan( X, Y ); + mxWaitRetrace; + end; + + (* Shutdown *) + mxSetMode( MX_TEXT ); + mxTerm; +end. diff --git a/16/xw_/modex/MATH.INC b/16/xw_/modex/MATH.INC new file mode 100755 index 00000000..742af410 --- /dev/null +++ b/16/xw_/modex/MATH.INC @@ -0,0 +1,34 @@ +; +; MATH.INC - Include file for THREED.ASM +; + +; 3-dimensional point, coordinates in fixed format (16:16) +; +TPOINT STRUC + X DD ? + Y DD ? + Z DD ? +TPOINT ENDS + +; 2-dimensional point, coordinates in integer format +; +TIMAGEPOINT STRUC + IX DW ? + IY DW ? +TIMAGEPOINT ENDS + +; Fixed-point divide: EAX = EAX / arg +; +.xdiv MACRO arg + xor edx, edx + shld edx, eax, 16 + shl eax, 16 + idiv arg +ENDM + +; Fixed-point multiply: EAX = EAX * arg +; +.xmul MACRO arg + imul arg + shrd eax, edx, 16 +ENDM diff --git a/16/xw_/modex/PLASMA.PAS b/16/xw_/modex/PLASMA.PAS new file mode 100755 index 00000000..237e292a --- /dev/null +++ b/16/xw_/modex/PLASMA.PAS @@ -0,0 +1,103 @@ +unit Plasma; +interface + +const + PAL_RGB = 0; + PAL_CLOUDS = 1; + PAL_LANDSCAPE = 2; + +procedure MakePlasma( X, Y: integer; W, H: word; C1, C2, C3, C4: byte ); +procedure MakePlasmaPalette( var Palette; What: word ); + +implementation uses Modex; + +procedure NewColor( XA, YA, X, Y, XB, YB: integer ); +var + Color: longint; +begin + Color := Abs( XA-XB )+Abs( YA-YB ); + Color := Random( Color shl 1 )-Color; + Color := (Color+mxGetPixel( XA, YA )+mxGetPixel( XB, YB )+1) shr 1; + if( Color < 1 ) then Color := 1; + if( Color > 192 ) then Color := 192; + if( mxGetPixel( X, Y ) = 0 ) then + mxPutPixel( X, Y, Lo(Color) ); +end; + +procedure Divide( X1, Y1, X2, Y2: integer ); +var + X, Y, Color: integer; +begin + if not( (X2-X1<2)and(Y2-Y1<2) ) then begin + X := (X1+X2) shr 1; + Y := (Y1+Y2) shr 1; + NewColor( X1, Y1, X, Y1, X2, Y1 ); + NewColor( X2, Y1, X2, Y, X2, Y2 ); + NewColor( X1, Y2, X, Y2, X2, Y2 ); + NewColor( X1, Y1, X1, Y, X1, Y2 ); + Color := (mxGetPixel( X1, Y1 )+mxGetPixel( X2, Y1 )+ + mxGetPixel( X2, Y2 )+mxGetPixel( X1, Y2 )) shr 2; + mxPutPixel( X, Y, Color ); + Divide( X1, Y1, X, Y ); + Divide( X, Y1, X2, Y ); + Divide( X, Y, X2, Y2 ); + Divide( X1, Y, X, Y2 ); + end; +end; + +procedure MakePlasma; +begin + Dec( W ); + Dec( H ); + mxPutPixel( X, Y, C1 ); + mxPutPixel( X, Y+H, C2 ); + mxPutPixel( X+W, Y+H, C3 ); + mxPutPixel( X+W, Y, C4 ); + Divide( X, Y, X+W, Y+H ); +end; + +procedure MakePlasmaPalette; +type + TPal = array[ byte ] of record R, G, B: byte end; +var + I: word; +begin + FillChar( TPal(Palette)[1], 192*3, 0 ); + case What of + PAL_CLOUDS: + for I:=1 to 192 do begin + TPal(Palette)[I].R := Abs( I-96 )*63 div 96; + TPal(Palette)[I].G := Abs( I-96 )*63 div 96; + TPal(Palette)[I].B := 63; + end; + PAL_LANDSCAPE: + begin + for I:=0 to 31 do begin + TPal(Palette)[I+1].R := I; + TPal(Palette)[I+1].G := I; + TPal(Palette)[I+1].B := I + I shr 1+15; + end; + for I:=32 to 63 do begin + TPal(Palette)[I+1].R := 0; + TPal(Palette)[I+1].G := I; + TPal(Palette)[I+1].B := 0; + end; + for I:=64 to 191 do begin + TPal(Palette)[I+1].R := (I-64) div 3 + 15; + TPal(Palette)[I+1].G := (I-64) div 3 + 15; + TPal(Palette)[I+1].B := (I-64) div 3 + 15; + end; + end; + else + for I:=1 to 64 do begin + TPal(Palette)[I].G := I-1; + TPal(Palette)[I].B := 64-I; + TPal(Palette)[I+64].R := I-1; + TPal(Palette)[I+64].G := 64-I; + TPal(Palette)[I+128].B := I-1; + TPal(Palette)[I+128].R := 64-I; + end; + end; +end; + +end. \ No newline at end of file diff --git a/16/xw_/modex/QIX2.EXE b/16/xw_/modex/QIX2.EXE new file mode 100755 index 00000000..a10d7db5 Binary files /dev/null and b/16/xw_/modex/QIX2.EXE differ diff --git a/16/xw_/modex/QIX2.PAS b/16/xw_/modex/QIX2.PAS new file mode 100755 index 00000000..d1b59791 --- /dev/null +++ b/16/xw_/modex/QIX2.PAS @@ -0,0 +1,210 @@ +{$E-,N+} +uses Crt, Modex; + +const + DEFVERT = 12; (* Vertex count *) + DEFREPL = 3; (* Repetition count *) + DEFQIXS = 2; (* Qixs *) + FADESPEED = 48; +type + TPoint = record + X, Y : integer; + end; + TRGB = record + R, G, B: byte; + end; + TQix = record + Color: integer; + Vert : array[ 0..DEFVERT-1, 0..DEFREPL-1 ] of TPoint; + Delta: array[ 0..DEFVERT-1 ] of TPoint; + end; +var + Page : integer; + MaxX, + MaxY : word; + Qix : array[ 0..DEFQIXS-1 ] of TQix; + Pal : array[ byte ] of TRGB; + +type + TReal = double; + TRPoint = record + X, Y: TReal; + end; + TMatrix = array[ 0..3, 0..3 ] of TReal; +var + M: TMatrix; + G: array[ 0..DEFVERT-1 ] of TRPoint; + C: array[ 0..DEFVERT-1 ] of TRPoint; + +procedure BumpPal( Idx, DR, DG, DB, Steps: integer ); +var + I: integer; +begin + for I:=1 to Steps do begin + Pal[Idx+1].R := Pal[Idx].R + DR; + Pal[Idx+1].G := Pal[Idx].G + DG; + Pal[Idx+1].B := Pal[Idx].B + DB; + Inc( Idx ); + end; +end; + +procedure InitPalette; +begin + with Pal[0] do begin R:=0; G:=0; B:=0; end; + with Pal[1] do begin R:=0; G:=0; B:=62; end; + BumpPal( 1, 0, 2, -2, 31 ); + BumpPal( 32, 2, -2, 0, 31 ); + BumpPal( 63, -2, 2, 2, 31 ); + BumpPal( 94, 2, 0, -2, 31 ); + BumpPal( 125, -2, -2, 2, 31 ); +end; + +procedure Init( var Qix: TQix; Color: integer ); +var + I: integer; +begin + FillChar( Qix.Vert, SizeOf(Qix.Vert), 0 ); + for I:=0 to DEFVERT-1 do begin + Qix.Vert[I, DEFREPL-1].X := Random( MaxX ); + Qix.Vert[I, DEFREPL-1].Y := Random( MaxY ); + Qix.Delta[I].X := Random(5)+1; + Qix.Delta[I].Y := Random(5)+1; + end; + Qix.Color := Color; + + (* Initialize matrix (Catmull-Rom) *) + M[0,0] := -1/2; M[0,1] := 3/2; M[0,2] := -3/2; M[0,3] := 1/2; + M[1,0] := 1; M[1,1] := -5/2; M[1,2] := 2; M[1,3] := -1/2; + M[2,0] := -1/2; M[2,1] := 0; M[2,2] := 1/2; M[2,3] := 0; + M[3,0] := 0; M[3,1] := 1; M[3,2] := 0; M[3,3] := 0; +end; + +procedure mxBezier( var Qix: TQix; I0, Idx, N: integer ); +var + I, J: integer; + T, T2, T3: TReal; + X0, Y0, X, Y: TReal; + Delta: TReal; +begin + (* Compute coefficients *) + for I:=0 to 3 do begin + C[I].X := 0; + for J:=0 to 3 do C[I].X := C[I].X + M[I,J]*Qix.Vert[(I0+J) mod DEFVERT,Idx].X; + C[I].Y := 0; + for J:=0 to 3 do C[I].Y := C[I].Y + M[I,J]*Qix.Vert[(I0+J) mod DEFVERT,Idx].Y; + end; + X0 := C[3].X; + Y0 := C[3].Y; + Delta := 1 / N; + T := 0; + for I:=1 to N do begin + T := T + Delta; + T2 := T*T; + T3 := T*T2; + X := C[0].X*T3 + C[1].X*T2 + C[2].X*T + C[3].X; + Y := C[0].Y*T3 + C[1].Y*T2 + C[2].Y*T + C[3].Y; + mxLine( Round(X0), Page+Round(Y0), Round(X), Page+Round(Y), Qix.Color, OP_SET ); + X0 := X; + Y0 := Y; + end; +end; + +procedure Plot( var Qix: TQix; Idx: integer ); +var + I, J: integer; +begin + for I:=0 to DEFVERT-1 do begin + mxBezier( Qix, I, Idx, 12 ); + end; +end; + +procedure Update( var Qix: TQix; Idx: integer ); +var + I: integer; +begin + for I:=0 to DEFVERT-1 do with Qix do begin + Inc( Vert[I,Idx].X, Delta[I].X ); + if( Vert[I,Idx].X < 0 ) then begin + Vert[I,Idx].X := 0; + Delta[I].X := Random( 5 )+1; + end; + if( Vert[I,Idx].X > MaxX ) then begin + Vert[I,Idx].X := MaxX; + Delta[I].X := -Random( 5 )-1; + end; + Inc( Vert[I,Idx].Y, Delta[I].Y ); + if( Vert[I,Idx].Y < 0 ) then begin + Vert[I,Idx].Y := 0; + Delta[I].Y := Random( 5 )+1; + end; + if( Vert[I,Idx].Y > MaxY ) then begin + Vert[I,Idx].Y := MaxY; + Delta[I].Y := -Random( 5 )-1; + end; + end; +end; + +procedure Copy( var Qix: TQix; Dest, Src: integer ); +var + I: integer; +begin + for I:=0 to DEFVERT-1 do with Qix do begin + Vert[I,Dest].X := Vert[I,Src].X; + Vert[I,Dest].Y := Vert[I,Src].Y; + end; +end; + +procedure AnimateQix; +var + Q, Idx, I, J, P, Count: integer; +begin + Count := 0; + P := DEFREPL-1; + I := 0; + J := 1; + repeat + mxSetClipRegion( 0, Page, MaxX+1, MaxY+1 ); + mxSetClip( TRUE ); + mxFillBox( 0, Page, MaxX+1, MaxY+1, 0, OP_SET ); + for Q:=0 to DEFQIXS-1 do begin + Copy( Qix[Q], I, P ); + Update( Qix[Q], I ); + for Idx:=0 to DEFREPL-1 do begin + Plot( Qix[Q], Idx ); + end; + end; + I := (I+1) mod DEFREPL; + J := (J+1) mod DEFREPL; + P := (P+1) mod DEFREPL; + Inc( Count ); + mxStartLine( Page ); + if( Count >= FADESPEED ) then begin + for Q:=0 to DEFQIXS-1 do begin + Inc( Qix[Q].Color ); + if( Qix[Q].Color > 156 ) then + Qix[Q].Color := 1; + end; + Count := 0; + end; + Page := 240-Page; + until( KeyPressed ); +end; + +var + I: integer; +begin + Randomize; + mxInit; + mxSetMode( MX_320x240 ); + mxGetScreenSize( MaxX, MaxY ); + for I:=0 to DEFQIXS-1 do + Init( Qix[I], (I*(155 div DEFQIXS)) mod 155 + 1 ); + InitPalette; + mxSetPalette( @Pal, 0, 157 ); + Page := 240; + Dec( MaxX ); + Dec( MaxY ); + AnimateQix; + mxSetMode( MX_TEXT ); + mxTerm; +end. diff --git a/16/xw_/modex/README.TXT b/16/xw_/modex/README.TXT new file mode 100755 index 00000000..306e8b9a --- /dev/null +++ b/16/xw_/modex/README.TXT @@ -0,0 +1,8 @@ +ModeX - A graphical library for DOS programs +Copyright (c) 1993-1994 Alessandro Scotti +http://www.ascotti.org/ + +Please look at the above site in the "Art of..." and +then in the "Old programs" section for more information. + + diff --git a/16/xw_/modex/SINCOS.INC b/16/xw_/modex/SINCOS.INC new file mode 100755 index 00000000..6986eeeb --- /dev/null +++ b/16/xw_/modex/SINCOS.INC @@ -0,0 +1,518 @@ +; +; SINCOS.INC - Sin/cos tables for THREED.ASM +; + +tblSin LABEL DWORD + DD 0 + DD 411733 + DD 823219 + DD 1234209 + DD 1644455 + DD 2053710 + DD 2461729 + DD 2868265 + DD 3273072 + DD 3675909 + DD 4076531 + DD 4474698 + DD 4870169 + DD 5262706 + DD 5652074 + DD 6038037 + DD 6420363 + DD 6798821 + DD 7173184 + DD 7543226 + DD 7908725 + DD 8269459 + DD 8625213 + DD 8975771 + DD 9320922 + DD 9660458 + DD 9994176 + DD 10321873 + DD 10643353 + DD 10958422 + DD 11266890 + DD 11568571 + DD 11863283 + DD 12150850 + DD 12431097 + DD 12703856 + DD 12968963 + DD 13226258 + DD 13475586 + DD 13716797 + DD 13949745 + DD 14174291 + DD 14390298 + DD 14597637 + DD 14796184 + DD 14985817 + DD 15166424 + DD 15337895 + DD 15500126 + DD 15653022 + DD 15796488 + DD 15930439 + DD 16054795 + DD 16169479 + DD 16274424 + DD 16369565 + DD 16454846 + DD 16530216 + DD 16595628 + DD 16651044 + DD 16696429 + DD 16731757 + DD 16757007 + DD 16772163 + DD 16777216 + DD 16772163 + DD 16757007 + DD 16731757 + DD 16696429 + DD 16651044 + DD 16595628 + DD 16530216 + DD 16454846 + DD 16369565 + DD 16274424 + DD 16169479 + DD 16054795 + DD 15930439 + DD 15796488 + DD 15653022 + DD 15500126 + DD 15337895 + DD 15166424 + DD 14985817 + DD 14796184 + DD 14597637 + DD 14390298 + DD 14174291 + DD 13949745 + DD 13716797 + DD 13475586 + DD 13226258 + DD 12968963 + DD 12703856 + DD 12431097 + DD 12150850 + DD 11863283 + DD 11568571 + DD 11266890 + DD 10958422 + DD 10643353 + DD 10321873 + DD 9994176 + DD 9660458 + DD 9320922 + DD 8975771 + DD 8625213 + DD 8269459 + DD 7908725 + DD 7543226 + DD 7173184 + DD 6798821 + DD 6420363 + DD 6038037 + DD 5652074 + DD 5262706 + DD 4870169 + DD 4474698 + DD 4076531 + DD 3675909 + DD 3273072 + DD 2868265 + DD 2461729 + DD 2053710 + DD 1644455 + DD 1234209 + DD 823219 + DD 411733 + DD 0 + DD -411733 + DD -823219 + DD -1234209 + DD -1644455 + DD -2053710 + DD -2461729 + DD -2868265 + DD -3273072 + DD -3675909 + DD -4076531 + DD -4474698 + DD -4870169 + DD -5262706 + DD -5652074 + DD -6038037 + DD -6420363 + DD -6798821 + DD -7173184 + DD -7543226 + DD -7908725 + DD -8269459 + DD -8625213 + DD -8975771 + DD -9320922 + DD -9660458 + DD -9994176 + DD -10321873 + DD -10643353 + DD -10958422 + DD -11266890 + DD -11568571 + DD -11863283 + DD -12150850 + DD -12431097 + DD -12703856 + DD -12968963 + DD -13226258 + DD -13475586 + DD -13716797 + DD -13949745 + DD -14174291 + DD -14390298 + DD -14597637 + DD -14796184 + DD -14985817 + DD -15166424 + DD -15337895 + DD -15500126 + DD -15653022 + DD -15796488 + DD -15930439 + DD -16054795 + DD -16169479 + DD -16274424 + DD -16369565 + DD -16454846 + DD -16530216 + DD -16595628 + DD -16651044 + DD -16696429 + DD -16731757 + DD -16757007 + DD -16772163 + DD -16777216 + DD -16772163 + DD -16757007 + DD -16731757 + DD -16696429 + DD -16651044 + DD -16595628 + DD -16530216 + DD -16454846 + DD -16369565 + DD -16274424 + DD -16169479 + DD -16054795 + DD -15930439 + DD -15796488 + DD -15653022 + DD -15500126 + DD -15337895 + DD -15166424 + DD -14985817 + DD -14796184 + DD -14597637 + DD -14390298 + DD -14174291 + DD -13949745 + DD -13716797 + DD -13475586 + DD -13226258 + DD -12968963 + DD -12703856 + DD -12431097 + DD -12150850 + DD -11863283 + DD -11568571 + DD -11266890 + DD -10958422 + DD -10643353 + DD -10321873 + DD -9994176 + DD -9660458 + DD -9320922 + DD -8975771 + DD -8625213 + DD -8269459 + DD -7908725 + DD -7543226 + DD -7173184 + DD -6798821 + DD -6420363 + DD -6038037 + DD -5652074 + DD -5262706 + DD -4870169 + DD -4474698 + DD -4076531 + DD -3675909 + DD -3273072 + DD -2868265 + DD -2461729 + DD -2053710 + DD -1644455 + DD -1234209 + DD -823219 + DD -411733 +tblCos LABEL DWORD + DD 16777216 + DD 16772163 + DD 16757007 + DD 16731757 + DD 16696429 + DD 16651044 + DD 16595628 + DD 16530216 + DD 16454846 + DD 16369565 + DD 16274424 + DD 16169479 + DD 16054795 + DD 15930439 + DD 15796488 + DD 15653022 + DD 15500126 + DD 15337895 + DD 15166424 + DD 14985817 + DD 14796184 + DD 14597637 + DD 14390298 + DD 14174291 + DD 13949745 + DD 13716797 + DD 13475586 + DD 13226258 + DD 12968963 + DD 12703856 + DD 12431097 + DD 12150850 + DD 11863283 + DD 11568571 + DD 11266890 + DD 10958422 + DD 10643353 + DD 10321873 + DD 9994176 + DD 9660458 + DD 9320922 + DD 8975771 + DD 8625213 + DD 8269459 + DD 7908725 + DD 7543226 + DD 7173184 + DD 6798821 + DD 6420363 + DD 6038037 + DD 5652074 + DD 5262706 + DD 4870169 + DD 4474698 + DD 4076531 + DD 3675909 + DD 3273072 + DD 2868265 + DD 2461729 + DD 2053710 + DD 1644455 + DD 1234209 + DD 823219 + DD 411733 + DD 0 + DD -411733 + DD -823219 + DD -1234209 + DD -1644455 + DD -2053710 + DD -2461729 + DD -2868265 + DD -3273072 + DD -3675909 + DD -4076531 + DD -4474698 + DD -4870169 + DD -5262706 + DD -5652074 + DD -6038037 + DD -6420363 + DD -6798821 + DD -7173184 + DD -7543226 + DD -7908725 + DD -8269459 + DD -8625213 + DD -8975771 + DD -9320922 + DD -9660458 + DD -9994176 + DD -10321873 + DD -10643353 + DD -10958422 + DD -11266890 + DD -11568571 + DD -11863283 + DD -12150850 + DD -12431097 + DD -12703856 + DD -12968963 + DD -13226258 + DD -13475586 + DD -13716797 + DD -13949745 + DD -14174291 + DD -14390298 + DD -14597637 + DD -14796184 + DD -14985817 + DD -15166424 + DD -15337895 + DD -15500126 + DD -15653022 + DD -15796488 + DD -15930439 + DD -16054795 + DD -16169479 + DD -16274424 + DD -16369565 + DD -16454846 + DD -16530216 + DD -16595628 + DD -16651044 + DD -16696429 + DD -16731757 + DD -16757007 + DD -16772163 + DD -16777216 + DD -16772163 + DD -16757007 + DD -16731757 + DD -16696429 + DD -16651044 + DD -16595628 + DD -16530216 + DD -16454846 + DD -16369565 + DD -16274424 + DD -16169479 + DD -16054795 + DD -15930439 + DD -15796488 + DD -15653022 + DD -15500126 + DD -15337895 + DD -15166424 + DD -14985817 + DD -14796184 + DD -14597637 + DD -14390298 + DD -14174291 + DD -13949745 + DD -13716797 + DD -13475586 + DD -13226258 + DD -12968963 + DD -12703856 + DD -12431097 + DD -12150850 + DD -11863283 + DD -11568571 + DD -11266890 + DD -10958422 + DD -10643353 + DD -10321873 + DD -9994176 + DD -9660458 + DD -9320922 + DD -8975771 + DD -8625213 + DD -8269459 + DD -7908725 + DD -7543226 + DD -7173184 + DD -6798821 + DD -6420363 + DD -6038037 + DD -5652074 + DD -5262706 + DD -4870169 + DD -4474698 + DD -4076531 + DD -3675909 + DD -3273072 + DD -2868265 + DD -2461729 + DD -2053710 + DD -1644455 + DD -1234209 + DD -823219 + DD -411733 + DD 0 + DD 411733 + DD 823219 + DD 1234209 + DD 1644455 + DD 2053710 + DD 2461729 + DD 2868265 + DD 3273072 + DD 3675909 + DD 4076531 + DD 4474698 + DD 4870169 + DD 5262706 + DD 5652074 + DD 6038037 + DD 6420363 + DD 6798821 + DD 7173184 + DD 7543226 + DD 7908725 + DD 8269459 + DD 8625213 + DD 8975771 + DD 9320922 + DD 9660458 + DD 9994176 + DD 10321873 + DD 10643353 + DD 10958422 + DD 11266890 + DD 11568571 + DD 11863283 + DD 12150850 + DD 12431097 + DD 12703856 + DD 12968963 + DD 13226258 + DD 13475586 + DD 13716797 + DD 13949745 + DD 14174291 + DD 14390298 + DD 14597637 + DD 14796184 + DD 14985817 + DD 15166424 + DD 15337895 + DD 15500126 + DD 15653022 + DD 15796488 + DD 15930439 + DD 16054795 + DD 16169479 + DD 16274424 + DD 16369565 + DD 16454846 + DD 16530216 + DD 16595628 + DD 16651044 + DD 16696429 + DD 16731757 + DD 16757007 + DD 16772163 diff --git a/16/xw_/modex/THREED.ASM b/16/xw_/modex/THREED.ASM new file mode 100755 index 00000000..5ecd3ba3 --- /dev/null +++ b/16/xw_/modex/THREED.ASM @@ -0,0 +1,872 @@ +COMMENT / + Fixed-point math functions and 3D transforms + Copyright (c) 1993,94 by Alessandro Scotti +/ +WARN PRO +P386 +JUMPS +LOCALS + +INCLUDE MATH.INC + +PUBLIC tdFixedMul +PUBLIC tdGetNormal +PUBLIC tdRotate +PUBLIC tdGetSurfaceLight +PUBLIC tdSetLight +PUBLIC tdSetRotation +PUBLIC tdSetTranslation +PUBLIC tdTransform +PUBLIC tdTransformToImage +PUBLIC tdTransformLight +PUBLIC tdBackPlaneCull +PUBLIC tdSetPerspective + +;----------------------------------------------------------- +; +; Data segment +; +MATH_DATA SEGMENT USE16 PARA PUBLIC 'DATA' + ASSUME ds:MATH_DATA + +INCLUDE SINCOS.INC ; Fixed 8:24 sin/cos table + +XRotation TPOINT <> ; 3x3 rotation matrix +YRotation TPOINT <> +ZRotation TPOINT <> + +Translation TPOINT <> ; Translation vector + +Light TPOINT <> ; Light vector +AmbientLight DW 00 ; Ambient light + +XScale DD 10000h ; Scaling factor for X coordinate +YScale DD 10000h ; Scaling factor for Y coordinate +PerspectiveDistance DD 20000000h + +MATH_DATA ENDS + +;----------------------------------------------------------- +; +; Code segment +; +MATH_TEXT SEGMENT USE16 PARA PUBLIC 'CODE' + ASSUME cs:MATH_TEXT, es:NOTHING, fs:NOTHING + +tdSetPerspective PROC PASCAL FAR + ARG Perspective:DWORD, \ + ScaleX:DWORD, \ + ScaleY:DWORD + USES ds + + mov ax, SEG MATH_DATA + mov ds, ax + ASSUME ds:MATH_DATA + + mov eax, [Perspective] + mov [PerspectiveDistance], eax + mov eax, [ScaleX] + mov [XScale], eax + mov eax, [ScaleY] + mov [YScale], eax + + ret +tdSetPerspective ENDP + + +;----------------------------------------------------------- +; +; Sets the rotation matrix. +; +; Input: +; RX = X-axis rotation angle +; RY = X-axis rotation angle +; RZ = X-axis rotation angle +; Output: +; none +; +tdSetRotation PROC PASCAL FAR + ARG RX:WORD, \ + RY:WORD, \ + RZ:WORD + USES ds, si, di + + mov ax, SEG MATH_DATA + mov ds, ax + ASSUME ds:MATH_DATA + + mov bx, [RZ] + mov si, [RY] + mov di, [RX] + shl bx, 2 + shl si, 2 + shl di, 2 + + push ebp ; We use EBP as a scratch register + +; Set X rotation + mov eax, tblCos[bx] + imul tblCos[si] + mov [XRotation.X], edx + + mov eax, tblSin[bx] + imul tblCos[si] + mov [XRotation.Y], edx + + mov eax, tblSin[si] + sar eax, 8 ; Convert fixed 8:24 to fixed 16:16 + mov [XRotation.Z], eax + +; Set Y rotation + mov eax, tblCos[bx] + imul tblSin[si] ; EDX:EAX = fixed 16:48 + shrd eax, edx, 24 ; EAX = fixed 8:24 + imul tblSin[di] ; EDX:EAX = fixed 16:48 + mov ebp, eax + mov ecx, edx + mov eax, tblSin[bx] + imul tblCos[di] + add eax, ebp + adc edx, ecx ; EDX:EAX = fixed 16:48 + neg edx + mov [YRotation.X], edx + + mov eax, tblSin[bx] + imul tblSin[si] + shrd eax, edx, 24 + imul tblSin[di] + mov ebp, eax + mov ecx, edx + mov eax, tblCos[bx] + imul tblCos[di] + sub eax, ebp + sbb edx, ecx + mov [YRotation.Y], edx + + mov eax, tblCos[si] + imul tblSin[di] + mov [YRotation.Z], edx + +; Set Z rotation + mov eax, tblCos[bx] + imul tblSin[si] + shrd eax, edx, 24 + imul tblCos[di] + mov ebp, eax + mov ecx, edx + mov eax, tblSin[bx] + imul tblSin[di] + sub eax, ebp + sbb edx, ecx + mov [ZRotation.X], edx + + mov eax, tblSin[bx] + imul tblSin[si] + shrd eax, edx, 24 + imul tblCos[di] + mov ebp, eax + mov ecx, edx + mov eax, tblCos[bx] + imul tblSin[di] + add eax, ebp + add edx, ecx + neg edx + mov [ZRotation.Y], edx + + mov eax, tblCos[si] + imul tblCos[di] + mov [ZRotation.Z], edx + + pop ebp ; Restore EBP + + ret +tdSetRotation ENDP + +;----------------------------------------------------------- +; +; Sets the translation vector. +; +; Input: +; TV = pointer to translation vector +; Output: +; none +; +tdSetTranslation PROC PASCAL FAR + ARG TV:DWORD + USES ds, es, di + + mov ax, SEG MATH_DATA + mov ds, ax + ASSUME ds:MATH_DATA + + les di, [TV] + mov eax, es:[di].X + mov [Translation.X], eax + mov eax, es:[di].Y + mov [Translation.Y], eax + mov eax, es:[di].Z + mov [Translation.Z], eax + + ret +tdSetTranslation ENDP + +;----------------------------------------------------------- +; +; Transforms an array of TPOINT. +; +; Input: +; Source = pointer to source array of TPOINT +; Dest = pointer to destination array of TPOINT +; Count = number of entries to transform +; Output: +; none +; +tdTransform PROC PASCAL FAR + ARG Source:DWORD, \ + Dest:DWORD, \ + Count:WORD + LOCAL Adjust:DWORD + USES ds, si, es, di, fs + + mov ax, SEG MATH_DATA + mov ds, ax + ASSUME ds:MATH_DATA + + lfs si, [Source] + les di, [Dest] + + ALIGN DWORD +@@Loop: +; Transform Z coordinate + mov eax, fs:[si].X + imul [ZRotation.X] + mov ecx, eax + mov ebx, edx + mov eax, fs:[si].Y + imul [ZRotation.Y] + add ecx, eax + adc ebx, edx + mov eax, fs:[si].Z + imul [ZRotation.Z] + add eax, ecx + adc edx, ebx + mov ebx, eax + shrd eax, edx, 16 + add eax, [Translation.Z] ; EAX = new Z coord (fixed 16:16) + mov es:[di].Z, eax +; Get perspective factor + mov ebx, [PerspectiveDistance] + sub eax, ebx + neg eax ; EAX = PD - Z + xor edx, edx + shld edx, eax, 16 + shl eax, 16 + idiv ebx ; EAX = fixed 16:16 result + mov [Adjust], eax + +; Transform X coordinate + mov eax, fs:[si].X + imul [XRotation.X] + mov ecx, eax + mov ebx, edx + mov eax, fs:[si].Y + imul [XRotation.Y] + add ecx, eax + adc ebx, edx + mov eax, fs:[si].Z + imul [XRotation.Z] + add eax, ecx + adc edx, ebx + shrd eax, edx, 16 + add eax, [Translation.X] + imul [Adjust] + shrd eax, edx, 16 + mov es:[di].X, eax + +; Transform Y coordinate + mov eax, fs:[si].X + imul [YRotation.X] + mov ecx, eax + mov ebx, edx + mov eax, fs:[si].Y + imul [YRotation.Y] + add ecx, eax + adc ebx, edx + mov eax, fs:[si].Z + imul [YRotation.Z] + add eax, ecx + adc edx, ebx + shrd eax, edx, 16 + add eax, [Translation.Y] + imul [Adjust] + shrd eax, edx, 16 + mov es:[di].Y, eax + + add si, SIZE TPOINT + add di, SIZE TPOINT + dec [Count] + jnz @@Loop + + ret +tdTransform ENDP + +;----------------------------------------------------------- +; +; Transforms an array of TPOINT into an array of TIMAGEPOINT. +; +; Input: +; Source = pointer to source array of TPOINT +; Dest = pointer to destination array of TIMAGEPOINT +; Count = number of entries to transform +; DeltaX = translation distance for the X coordinate +; DeltaY = translation distance for the Y coordinate +; Output: +; the maximum Z value +; +tdTransformToImage PROC PASCAL FAR + ARG Source:DWORD, \ + Dest:DWORD, \ + Count:WORD, \ + DeltaX:WORD, \ + DeltaY:WORD + LOCAL Adjust:DWORD, \ + Max:DWORD + USES ds, si, es, di, fs + + mov ax, SEG MATH_DATA + mov ds, ax + ASSUME ds:MATH_DATA + + lfs si, [Source] + les di, [Dest] + mov [Max], 80000000h + +@@Loop: +; Check max Z + mov eax, fs:[si].Z + cmp eax, [Max] + jle @@1 + mov [Max], eax +@@1: + +; Transform X coordinate + mov ax, WORD PTR fs:[si].X[2] + add ax, [DeltaX] + mov es:[di].IX, ax + +; Transform Y coordinate + mov ax, WORD PTR fs:[si].Y[2] + add ax, [DeltaY] + mov es:[di].IY, ax + + add si, SIZE TPOINT + add di, SIZE TIMAGEPOINT + dec [Count] + jnz @@Loop + + mov eax, [Max] + shld edx, eax, 16 + ret +tdTransformToImage ENDP + +;----------------------------------------------------------- +; +; Sets the light source. +; +; Input: +; Light = pointer to light vector +; Output: +; none +; +tdSetLight PROC PASCAL FAR + ARG L:DWORD + USES ds, es, di + + mov ax, SEG MATH_DATA + mov ds, ax + ASSUME ds:MATH_DATA + + les di, [L] + mov eax, es:[di].X + mov [Light.X], eax + mov eax, es:[di].Y + mov [Light.Y], eax + mov eax, es:[di].Z + mov [Light.Z], eax + + ret +tdSetLight ENDP + +;----------------------------------------------------------- +; +; Computes light intensity for an array of surfaces. +; +; Input: +; Normals = pointer to an array of surface normals +; Lights = pointer to an array of integer to be filled with +; light intensity +; Count = number of elements to transform +; Output: +; none +; +tdTransformLight PROC PASCAL FAR + ARG Normals:DWORD, \ + Lights:DWORD, \ + Count:WORD + USES ds, si, es, di, fs + + mov ax, SEG MATH_DATA + mov fs, ax + ASSUME fs:MATH_DATA + + lds si, [Normals] + les di, [Lights] + ASSUME ds:NOTHING + +; Intensity is given by the dot product between the Light vector and +; the surface normal +@@Loop: + mov eax, ds:[si].Z + imul [Light.Z] + mov ebx, eax + mov ecx, edx + mov eax, ds:[si].Y + imul [Light.Y] + add ebx, eax + adc ecx, edx + mov eax, ds:[si].X + imul [Light.X] + add eax, ebx + adc edx, ecx ; EDX:EAX = fixed 32:32 intensity + add dx, [AmbientLight] + test dx, dx + jg @@1 + xor dx, dx ; Return 0 for no light +@@1: + mov es:[di], dx + inc di + inc di + add si, SIZE TPOINT + dec [Count] + jnz @@Loop + + ASSUME fs:NOTHING + ret +tdTransformLight ENDP + +;----------------------------------------------------------- +; +; Returns the light value given the normal to a surface. +; +; Input: +; Normal = pointer to TPOINT surface normal vector +; Output: +; AX = light intensity (>=0) +; Notes: +; the normal is rotated according to the current setting. +; +tdGetSurfaceLight PROC PASCAL FAR + ARG Normal:DWORD + USES ds, esi, es, di + + mov ax, SEG MATH_DATA + mov ds, ax + ASSUME ds:MATH_DATA + + les di, [Normal] + +; Transform Z coordinate + mov eax, es:[di].X + imul [ZRotation.X] + mov ecx, eax + mov ebx, edx + mov eax, es:[di].Y + imul [ZRotation.Y] + add ecx, eax + adc ebx, edx + mov eax, es:[di].Z + imul [ZRotation.Z] + add eax, ecx + adc edx, ebx + shrd eax, edx, 16 + imul [Light.Z] + shrd eax, edx, 16 + mov esi, eax + +; Transform X coordinate + mov eax, es:[di].X + imul [XRotation.X] + mov ecx, eax + mov ebx, edx + mov eax, es:[di].Y + imul [XRotation.Y] + add ecx, eax + adc ebx, edx + mov eax, es:[di].Z + imul [XRotation.Z] + add eax, ecx + adc edx, ebx + shrd eax, edx, 16 + imul [Light.X] + shrd eax, edx, 16 + add esi, eax + +; Transform Y coordinate + mov eax, es:[di].X + imul [YRotation.X] + mov ecx, eax + mov ebx, edx + mov eax, es:[di].Y + imul [YRotation.Y] + add ecx, eax + adc ebx, edx + mov eax, es:[di].Z + imul [YRotation.Z] + add eax, ecx + adc edx, ebx + shrd eax, edx, 16 + imul [Light.X] + shrd eax, edx, 16 + add eax, esi + shr eax, 16 + +; Add ambient light + add ax, [AmbientLight] + test ax, ax + jge @@Exit + xor ax, ax + +@@Exit: + ret +tdGetSurfaceLight ENDP + +;----------------------------------------------------------- +; +; Rotates an array of TPOINT. +; +; Input: +; Source = pointer to source array of TPOINT +; Dest = pointer to destination array of TPOINT +; Count = number of entries to transform +; Output: +; none +; +tdRotate PROC PASCAL FAR + ARG Source:DWORD, \ + Dest:DWORD, \ + Count:WORD + USES ds, si, es, di, fs + + mov ax, SEG MATH_DATA + mov ds, ax + ASSUME ds:MATH_DATA + + lfs si, [Source] + les di, [Dest] + +@@Loop: +; Transform Z coordinate + mov eax, fs:[si].X + imul [ZRotation.X] + mov ecx, eax + mov ebx, edx + mov eax, fs:[si].Y + imul [ZRotation.Y] + add ecx, eax + adc ebx, edx + mov eax, fs:[si].Z + imul [ZRotation.Z] + add eax, ecx + adc edx, ebx + shrd eax, edx, 16 + mov es:[di].Z, eax + +; Transform X coordinate + mov eax, fs:[si].X + imul [XRotation.X] + mov ecx, eax + mov ebx, edx + mov eax, fs:[si].Y + imul [XRotation.Y] + add ecx, eax + adc ebx, edx + mov eax, fs:[si].Z + imul [XRotation.Z] + add eax, ecx + adc edx, ebx + shrd eax, edx, 16 + mov es:[di].X, eax + +; Transform Y coordinate + mov eax, fs:[si].X + imul [YRotation.X] + mov ecx, eax + mov ebx, edx + mov eax, fs:[si].Y + imul [YRotation.Y] + add ecx, eax + adc ebx, edx + mov eax, fs:[si].Z + imul [YRotation.Z] + add eax, ecx + adc edx, ebx + shrd eax, edx, 16 + mov es:[di].Y, eax + + add si, SIZE TPOINT + add di, SIZE TPOINT + dec [Count] + jnz @@Loop + + ret +tdRotate ENDP + +tdFixedMul PROC PASCAL FAR + ARG F1:DWORD, \ + F2:DWORD + + mov eax, [F1] + imul [F2] + shr eax, 16 + + ret +tdFixedMul ENDP + +;----------------------------------------------------------- +; +; Returns in EAX the square root of EDX:EAX. +; +subSqrt PROC NEAR + push esi + push edi + + add eax, eax + adc edx, 0 + mov eax, edx ; Just discard the low bits + + mov esi, eax + xor edi, edi + shld edi, esi, 16 + shl esi, 16 +@@Loop: + mov ebx, eax + mul eax + add eax, esi + adc edx, edi + shrd eax, edx, 1 + shr edx, 1 + div ebx + cmp eax, ebx + jne @@Loop + +; Adjust EAX + shl eax, 8 + + pop edi + pop esi + ret +subSqrt ENDP + +;----------------------------------------------------------- +; +; Finds the unitary normal to a given surface. +; +; Input: +; Dest = pointer to TPOINT (vector) result +; P1, P2, P3 = pointer to TPOINT points on surface +; Output: +; none +; Notes: +; the normal is given by the cross-product between (P3-P1) and +; (P2-P1), so its orientation depends on the parameters order. +; +tdGetNormal PROC PASCAL FAR + ARG Dest:DWORD, \ + P1:DWORD, \ + P2:DWORD, \ + P3:DWORD + LOCAL V1:TPOINT, \ + V2:TPOINT, \ + N:TPOINT + USES ds, si, es, di + +; Get vector V1 + lds si, [P1] + les di, [P3] + mov eax, es:[di].X + sub eax, ds:[si].X + mov [V1.X], eax + mov eax, es:[di].Y + sub eax, ds:[si].Y + mov [V1.Y], eax + mov eax, es:[di].Z + sub eax, ds:[si].Z + mov [V1.Z], eax + +; Get vector V2 + les di, [P2] + mov eax, es:[di].X + sub eax, ds:[si].X + mov [V2.X], eax + mov eax, es:[di].Y + sub eax, ds:[si].Y + mov [V2.Y], eax + mov eax, es:[di].Z + sub eax, ds:[si].Z + mov [V2.Z], eax + +; Get normal vector (V1 x V2) + mov eax, [V1.Z] + imul [V2.Y] + mov ebx, eax + mov ecx, edx + mov eax, [V1.Y] + imul [V2.Z] + sub eax, ebx + sbb edx, ecx + shrd eax, edx, 16 + mov [N.X], eax + + mov eax, [V1.X] + imul [V2.Z] + mov ebx, eax + mov ecx, edx + mov eax, [V1.Z] + imul [V2.X] + sub eax, ebx + sbb edx, ecx + shrd eax, edx, 16 + mov [N.Y], eax + + mov eax, [V1.Y] + imul [V2.X] + mov ebx, eax + mov ecx, edx + mov eax, [V1.X] + imul [V2.Y] + sub eax, ebx + sbb edx, ecx + shrd eax, edx, 16 + mov [N.Z], eax + +; Get normal length + mov eax, [N.X] + imul eax + mov ebx, eax + mov ecx, edx + mov eax, [N.Y] + imul eax + add ebx, eax + adc ecx, edx + mov eax, [N.Z] + imul eax + add eax, ebx + adc edx, ecx ; EDX:EAX = N.X*N.X + N.Y*N.Y + N.Z*N.Z + call subSqrt ; EAX = normal length + mov ebx, eax + +; Adjust vector and save it + les di, [Dest] + mov eax, [N.X] + cdq + shld edx, eax, 16 + shl eax, 16 + idiv ebx + mov es:[di].X, eax + mov eax, [N.Y] + cdq + shld edx, eax, 16 + shl eax, 16 + idiv ebx + mov es:[di].Y, eax + mov eax, [N.Z] + cdq + shld edx, eax, 16 + shl eax, 16 + idiv ebx + mov es:[di].Z, eax + + ret +tdGetNormal ENDP + +TPOLY STRUC + Vtx DW 4 DUP(?) +TPOLY ENDS + +;----------------------------------------------------------- +; +; Performs surface removal on an array of polygons. +; +; Input: +; Poly = pointer to an array of TPOLY +; Vertex = pointer to an array of TPOINT +; Dest = pointer to an array of integer +; Count = number of polygons to check +; Step = size of TPOLY structure +; Output: +; if the n-th polygon is invisible the n-th entry of the +; Dest array is set to -1, other entries are not modified +; (so it's possible to use the Light array for Dest, because +; the light intensity is always >= 0) +; +tdBackPlaneCull PROC PASCAL FAR + ARG Step:WORD, \ + Poly:DWORD, \ + Vertex:DWORD, \ + Dest:DWORD, \ + Count:WORD + USES ds, si, es, di, fs + ASSUME ds:NOTHING + + mov ds, WORD PTR Vertex[2] + les di, [Poly] + mov fs, WORD PTR Dest[2] + +@@Loop: + mov ax, es:[di].Vtx[2] ; Index of 2nd vertex + shl ax, 2 + mov bx, ax + shl ax, 1 + add bx, ax ; BX = index*SIZE TPOINT + add bx, WORD PTR [Vertex] ; BX = offset of 2nd vertex + mov ax, es:[di].Vtx[4] ; Index of 3rd vertex + shl ax, 2 + mov si, ax + shl ax, 1 + add si, ax + add si, WORD PTR [Vertex] ; SI = offset of 3rd vertex + mov ecx, ds:[si].X + sub ecx, ds:[bx].X ; ECX = V3.X-V2.X + mov edx, ds:[si].Y + sub edx, ds:[bx].Y ; EDX = V3.Y-V2.Y + mov ax, es:[di].Vtx[0] ; Index of 1st vertex + shl ax, 2 + mov si, ax + shl ax, 1 + add si, ax + add si, WORD PTR [Vertex] ; SI = offset of 1st vertex + mov eax, ds:[si].X + sub eax, ds:[bx].X ; EAX = V1.X-V2.X + mov esi, ds:[si].Y + sub esi, ds:[bx].Y ; ESI = V1.Y-V2.Y + imul edx + mov ebx, eax + xchg ecx, edx ; ECX:EBX = (V1.X-V2.X)*(V3.Y-V2.Y) + mov eax, esi + imul edx ; EDX:EAX = (V1.Y-V2.Y)*(V3.X-V2.X) + sub eax, ebx + sbb edx, ecx + jl @@Next ; Polygon is visible + mov bx, WORD PTR [Dest] ; FS:BX -> current Dest entry + mov WORD PTR fs:[bx], -1 ; Remove polygon +@@Next: + add WORD PTR [Dest], 2 ; Next entry for dest + add di, [Step] ; Next polygon + dec [Count] + jnz @@Loop + + ret +tdBackPlaneCull ENDP + +MATH_TEXT ENDS +END diff --git a/16/xw_/modex/THREED.H b/16/xw_/modex/THREED.H new file mode 100755 index 00000000..b993ef86 --- /dev/null +++ b/16/xw_/modex/THREED.H @@ -0,0 +1,32 @@ +typedef struct { + long x, y, z; +} TVECTOR; + +#define PVECTOR TVECTOR far * + +#define TPOINT TVECTOR +#define PPOINT PVECTOR + +#define VPTR void far * + +#ifdef __cplusplus +extern "C" { +#endif + +long far pascal tdFixedMul( long, long ); +int far pascal tdGetSurfaceLight( PPOINT ); +long far pascal tdTransformToImage( VPTR, VPTR, short, short, short ); + +void far pascal tdBackPlaneCull( VPTR, VPTR, VPTR, short, short ); +void far pascal tdGetNormal( VPTR, PPOINT, PPOINT, PPOINT ); +void far pascal tdRotate( VPTR, VPTR, short ); +void far pascal tdSetLight( PVECTOR ); +void far pascal tdSetRotation( short, short, short ); +void far pascal tdSetTranslation( PVECTOR ); +void far pascal tdSetPerspective( long, long, long ); +void far pascal tdTransform( VPTR, VPTR, short ); +void far pascal tdTransformLight( VPTR, VPTR, short ); + +#ifdef __cplusplus +} +#endif diff --git a/16/xw_/modex/THREED.PAS b/16/xw_/modex/THREED.PAS new file mode 100755 index 00000000..8b712c9d --- /dev/null +++ b/16/xw_/modex/THREED.PAS @@ -0,0 +1,40 @@ +unit ThreeD; +interface + +type + TVector = record + X, Y, Z : longint; + end; + TPoint = TVector; + +function tdFixedMul( F1, F2: longint ): longint; +function tdGetSurfaceLight( var Normal: TPoint ): integer; +function tdTransformToImage( var Source, Dest; Count, DeltaX, DeltaY: integer ): longint; + +procedure tdBackPlaneCull( var Poly, Vertex, Dest; Count, Step: word ); +procedure tdGetNormal( var Dest, P1, P2, P3: TVector ); +procedure tdRotate( var Source, Dest; Count: word ); +procedure tdSetLight( var Light: TVector ); +procedure tdSetRotation( RX, RY, RZ: word ); +procedure tdSetTranslation( var TV: TVector ); +procedure tdSetPerspective( PD, XF, YF: longint ); +procedure tdTransform( var Source, Dest; Count: word ); +procedure tdTransformLight( var Source, Dest; Count: word ); + +implementation + +function tdGetSurfaceLight; external; +procedure tdSetRotation( RX, RY, RZ: word ); external; +procedure tdGetNormal; external; +procedure tdSetTranslation( var TV: TVector ); external; +procedure tdTransform( var Source, Dest; Count: word ); external; +procedure tdRotate; external; +function tdTransformToImage; external; +procedure tdSetLight( var Light: TVector ); external; +procedure tdSetPerspective; external; +procedure tdTransformLight; external; +function tdFixedMul( F1, F2: longint ): longint; external; +procedure tdBackPlaneCull; external; +{$L THREED} + +end. diff --git a/16/xw_/modex/demo01.c b/16/xw_/modex/demo01.c new file mode 100755 index 00000000..0908fdf4 --- /dev/null +++ b/16/xw_/modex/demo01.c @@ -0,0 +1,125 @@ +/* + DEMO01 - Sprites, page flipping and palette rotation + Copyright (c) 1994 Alessandro Scotti +*/ +uses Crt, Modex; + +#DEFINE MAX_SPRITE 100 +type + (* Sprite structure *) + TSprite = record + X, Y : integer; (* Sprite coordinates *) + DX,DY: integer; (* Deltas for sprite movement *) + W, H : integer; (* Sprite width and height *) + Image: array[ 1..16, 1..16 ] of byte; (* Sprite image data *) + end; + (* RGB color structure *) + TRgb = record + R, G, B: byte; + end; +var + S : array[ 1..MAX_SPRITE ] of TSprite; (* An array of sprites *) + Palette: array[ byte ] of TRgb; (* Palette *) + Page : word; (* Page offset *) + I : word; + +(* Initializes a sprite structure *) +procedure sxInit( var S: TSprite ); +var + I: word; +begin + S.X := Random( 320 ); (* Initialize position with random values *) + S.Y := Random( 240 ); + S.DX := Random( 7 )-3; (* Initialize speed with random values *) + S.DY := Random( 7 )-3; + S.W := 16; (* Size is fixed in this program *) + S.H := 16; + (* The image is a square with a hole inside *) + FillChar( S.Image, SizeOf(S.Image), Random(15)+1 ); + for I:=5 to 12 do FillChar( S.Image[ I, 5 ], 8, 0 ); +end; + +(* Moves a sprite *) +procedure sxMove( var S: TSprite ); +begin + Inc( S.X, S.DX ); (* Get new position *) + Inc( S.Y, S.DY ); + (* Check sprite position, change delta if needed *) + if( S.X > 320 ) then begin + S.X := 320; + S.DX := -S.DX; + end; + if( S.X < -16 ) then begin + S.X := -16; + S.DX := -S.DX; + end; + if( S.Y > 240 ) then begin + S.Y := 240; + S.DY := -S.DY; + end; + if( S.Y < -16 ) then begin + S.Y := -16; + S.DY := -S.DY; + end; + (* Draw the sprite, note the Page offset added to the *) + (* Y coordinate of the image *) + mxPutImage( @S.Image, S.X, Page+S.Y, S.W, S.H, OP_TRANS ); +end; + +begin + (* Initialize library *) + mxInit; + + (* Enter graphics mode *) + mxSetMode( MX_320x240 ); + + (* Print initialization message *) + mxSetTextColor( 15, OP_TRANS ); + mxOutStr( 4, 4, 'Initializing...' ); + + (* Initialize sprites *) + for I:=1 to MAX_SPRITE do sxInit( S[I] ); + + (* Draw background *) + for I:=1 to 192 do begin + mxCircle( 160, 480+120, I, I+63 ); + mxCircle( 161, 480+120, I, I+63 ); + end; + + (* Compute and set palette *) + for I:=1 to 192 do with Palette[I+63] do begin + R := 0; + G := 0; + B := 0; + if( I < 64 ) then + R := I shr 1+31 + else if( I < 128 ) then + G := (I-64) shr 1+31 + else + B := (I-128) shr 1+31; + end; + mxSetPalette( @Palette[64], 64, 192 ); + + (* Main loop *) + Page := 240; + while( not KeyPressed ) do begin + (* Set clip region to current page *) + mxSetClipRegion( 0, Page, 320, 240 ); + mxSetClip( TRUE ); + (* Restore background *) + mxBitBlt( 0, 480, 320, 240, 0, Page ); + (* Draw sprites *) + for I:=1 to MAX_SPRITE do sxMove( S[I] ); + (* Print message *) + mxOutStr( 4, Page+4, 'Some sprites moving...' ); + (* Flip page *) + mxStartLine( Page ); + Page := 240-Page; + (* Animate palette *) + mxSetPalette( @Palette[64], 64, 192 ); + mxRotatePalette( @Palette[64], 192, 3 ); + end; + + mxSetMode( MX_TEXT ); + mxTerm; +end. diff --git a/16/xw_/readme.txt b/16/xw_/readme.txt new file mode 100755 index 00000000..306e8b9a --- /dev/null +++ b/16/xw_/readme.txt @@ -0,0 +1,8 @@ +ModeX - A graphical library for DOS programs +Copyright (c) 1993-1994 Alessandro Scotti +http://www.ascotti.org/ + +Please look at the above site in the "Art of..." and +then in the "Old programs" section for more information. + + diff --git a/makefile b/makefile index c0f971a1..7e02f9ba 100755 --- a/makefile +++ b/makefile @@ -426,18 +426,25 @@ comp: .symbolic @upx -9 -qqq x-demo.exe updatelibs: .symbolic - cd $(JSMNLIB) - git pull - cd ../../../ + @cd $(JSMNLIB) + @git pull + @cd ../../../ xlib: .symbolic @cd 16/xlib @wmake clean @wmake all - cd ../../ + @cd ../../ mx: .symbolic @cd 16/xw # @wmake clean @wmake all - cd ../../ + @cd ../../ + +x: .symbolic + @cd 16/x + @wmake -f makefile.wat pee + @cd ../xw_/ + @wmake all + @cd ../../