p*********************************                              ** sTEPHEN jUDD                 ** gEORGE tAYLOR                ** sTARTED: 7/11/94             ** fINISHED: 7/19/94            **                              ** wELL, IF ALL GOES WELL THIS  ** PROGRAM WILL ROTATE A CUBE.  **                              ** tHIS PROGRAM IS INTENDED TO  ** ACCOMPANY THE ARTICLE IN     ** c=hACKING, jULY 94 ISSUE.    ** fOR DETAILS ON THIS PROGRAM, ** READ THE ARTICLE!            **                              ** wRITE TO US!                 **                              ** UN(BEE)MO                    **                              ** VI                           ** N(IN)G                       ** ARE(TH                       ** E)YOU(O                      ** NLY)                         **                              ** ASL(ROSE)EEP                 **              E.E.CUMMINGS    **                              ** p.s. tHIS WAS WRITTEN USING  **      mERLIN 128.  wITH A     **      LITTLE MODIFICATION IT  **      WILL WORK FINE WITH     **      mERLIN 64.  iF YOU      **      DON'T HAVE EITHER...    **      WELL, WE ALL HAVE OUR   **      LITTLE FAULTS.          ********************************* org $1000* cONSTANTSbuff1 equ $3000 ;fIRST CHARACTER SETbuff2 equ $3800 ;sECOND CHARACTER SETbuffer equ $a3 ;pRESUMABLY THE TAPE WON'T BE RUNNINGx1 equ $fb ;pOINTS FOR DRAWING A LINEy1 equ $fc ;tHESE ZERO PAGE ADDRESSESx2 equ $fd ;DON'T CONFLICT WITH basicy2 equ $fedx equ $f9dy equ $fatemp1 equ $fb ;oF COURSE, COULD CONFLICT WITH X1temp2 equ $fc ;tEMPORARY VARIABLESacc equ $fb ;tHESE FOUR VARIABLES ARE USEDaux equ $fc ;BY THE MULTIPLICATION ROUTINEext equ $fdrem equ $feztemp equ $02 ;uSED FOR BUFFER SWAP.  dON'T TOUCH.angmax equ 120 ;tHERE ARE 2*PI/ANGMAX ANGLESoffset equ 6 ;fLOAT OFFSET: X=XACTUAL*2^OFFSET* vicvmcsb equ $d018bkgnd equ $d020border equ $d021sstart equ 1344 ;ROW 9 IN SCREEN MEMORY AT 1024* kERNALchrout equ $ffd2getin equ $ffe4*** mACROSmove mac lda ]1 sta ]2 <<<getkey mac  ;wAIT FOR A KEYPRESSwait jsr getin cmp #00 beq wait <<<debug mac  ;pRINT A CHARACTER  do 0  ;dON'T ASSEMBLE lda #]1 jsr chrout >>> getkey ;aND WAIT TO CONTINUE cmp #'S' ;mY SECRECT SWITCH KEY bne l1 jsr cleanup jmp donel1 cmp #'X' ;mY SECRET ABORT KEY bne done jmp cleanup findone <<<debuga mac do 0 lda ]1 sta 1024 findonea <<<setbuf mac  ;pUT BUFFERS WHERE THEY CAN BE HURT lda #00 sta buffer lda ztemp ;ZTEMP CONTAINS THE HIGH BYTE HERE sta buffer+1 <<<*------------------------------- lda #$00 sta bkgnd sta border lda vmcsb and #%00001111 ;sCREEN MEMORY TO 1024 ora #%00010000 sta vmcsb ldy #00 lda #<ttext sta temp1 lda #>ttext sta temp2 jmp titlettext hex 9305111111 ;CLEAR SCREEN, WHITE, CRSR DN txt '               CUBE3D',0D,0D txt '                 BY',0D hex 9f ;CYAN txt '    STEPHEN JUDD' hex 99 txt '    GEORGE TAYLOR',0D,0D hex 9b txt '  CHECK OUT THE JULY 94 ISSUE OF',0D hex 96 txt '  C=HACKING' hex 9b txt ' FOR MORE DETAILS!',0D hex 0d1d1d9e12 txt 'F1/F2',92 txt ' - INC/DEC X-ROTATION',0D hex 1d1d12 txt 'F3/F4',92 txt ' - INC/DEC Y-ROTATION',0D hex 1d1d12 txt 'F5/F6',92 txt ' - INC/DEC Z-ROTATION',0D hex 1d1d12 txt 'F7',92 txt ' RESETS',0D txt '  PRESS Q TO QUIT',0D hex 0d05 txt '      PRESS ANY KEY TO BEGIN',0D hex 00title lda (temp1),y beq :cont jsr chrout iny bne title inc temp2 jmp title:cont >>> getkey**** sET UP TABLES(?)* tABLES ARE CURRENTLY SET UP IN basic* AND BY THE ASSEMBLER.tables**** cLEAR SCREEN AND SET UP "BITMAP"setup lda #147 jsr chrout lda #<sstart adc #12 ;tHE GOAL IS TO CENTER THE GRAPHICS sta temp1 ;cOLUMN 12 lda #>sstart ;rOW 9 sta temp1+1 ;sstart POINTS TO ROW 9 lda #00 ldy #00 ldx #00 ;X WILL COUNT 16 ROWS FOR US clc:loop sta (temp1),y iny adc #16 bcc :loop clc lda temp1 adc #40 ;nEED TO ADD 40 TO THE BASE POINTER sta temp1 ;tO JUMP TO THE NEXT ROW lda temp1+1 adc #00 ;tAKE CARE OF CARRIES sta temp1+1 ldy #00 inx txa  ;x IS ALSO AN INDEX INTO THE CHARACTER NUMBER cpx #16 bne :loop ;nEED TO DO IT 16 TIMES >>> debug,'2'**** sET UP BUFFERS lda #<buff1 sta buffer lda #>buff1 sta buffer+1 sta ztemp ;ZTEMP WILL MAKE LIFE SIMPLE FOR US lda vmcsb and #%11110001 ;sTART HERE SO THAT SWAP BUFFERS WILL WORK RIGHT ora #%00001110 sta vmcsb**** sET UP INITIAL VALUESinit lda #00 sta dsx sta dsy sta dsz sta sx sta sy sta sz >>> debug,'4'*-------------------------------* mAIN LOOP**** gET KEYPRESSmainkpress jsr getin cmp #133 ;f1? bne :f2 lda dsx cmp #angmax/2 ;nO MORE THAN PI beq :cont inc dsx ;OTHERWISE INCREASE X-ROTATION jmp :cont:f2 cmp #137 ;f2? bne :f3 lda dsx beq :cont dec dsx jmp :cont:f3 cmp #134 bne :f4 lda dsy cmp #angmax/2 beq :cont inc dsy ;iNCREASE Y-ROTATION jmp :cont:f4 cmp #138 bne :f5 lda dsy beq :cont dec dsy jmp :cont:f5 cmp #135 bne :f6 lda dsz cmp #angmax/2 beq :cont inc dsz ;Z-ROTATION jmp :cont:f6 cmp #139 bne :f7 lda dsz beq :cont dec dsz jmp :cont:f7 cmp #136 bne :q jmp init:q cmp #'Q' ;Q QUITS bne :cont jmp cleanup:cont* >>> debug,'5'**** uPDATE ANGLESupdate clc lda sx adc dsx cmp #angmax ;aRE WE >= MAXIMUM ANGLE? bcc :cont1 sbc #angmax :iF SO, RESET:cont1 sta sx clc lda sy adc dsy cmp #angmax bcc :cont2 sbc #angmax ;sAME DEAL:cont2 sta sy clc lda sz adc dsz cmp #angmax bcc :cont3 sbc #angmax:cont3 sta sz**** rOTATE COORDINATESrotate*** fIRST, CALCULATE T1,T2,...,T10** tWO MACROS TO SIMPLIFY OUR LIFEadda mac  ;aDD TWO ANGLES TOGETHER clc lda ]1 adc ]2 cmp #angmax ;iS THE SUM > 2*PI? bcc done sbc #angmax ;iF SO, SUBTRACT 2*PIdone <<<suba mac  ;sUBTRACT TWO ANGLES sec lda ]1 sbc ]2 bcs done adc #angmax ;oOPS, WE NEED TO ADD 2*PIdone <<<** nOW CALCULATE T1,T2,ETC. >>> suba,sy;sz sta t1 ;T1=SY-SZ >>> adda,sy;sz sta t2 ;T2=SY+SZ >>> adda,sx;sz sta t3 ;T3=SX+SZ >>> suba,sx;sz sta t4 ;T4=SX-SZ >>> adda,sx;t2 sta t5 ;T5=SX+T2 >>> suba,sx;t1 sta t6 ;T6=SX-T1 >>> adda,sx;t1 sta t7 ;T7=SX+T1 >>> suba,t2;sx sta t8 ;T8=T2-SX >>> suba,sy;sx sta t9 ;T9=SY-SX >>> adda,sx;sy sta t10 ;T10=SX+SY* eT VOILA!*** nEXT, CALCULATE a,b,c,...,i** aNOTHER USEFUL LITTLE MACROdiv2 mac  ;dIVIDE A SIGNED NUMBER BY 2;iT IS ASSUMED THAT THE NUMBER bpl pos ;IS IN THE ACCUMULATOR clc eor #$ff ;wE NEED TO UN-NEGATIVE THE NUMBER adc #01 ;BY TAKING IT'S COMPLEMENT lsr  ;DIVIDE BY TWO clc eor #$ff adc #01 ;mAKE IT NEGATIVE AGAIN jmp donedivpos lsr  ;nUMBER IS POSITIVEdonediv <<<mul2 mac  ;mULTIPLY A SIGNED NUMBER BY 2 bpl posm clc eor #$ff adc #$01 asl clc eor #$ff adc #$01 jmp donemulposm asldonemul <<<** nOTE THAT WE ARE CURRENTLY MAKING A MINOR LEAP** OF FAITH THAT NO OVERFLOWS WILL OCCUR.:calca clc ldx t1 lda cos,x ldx t2 adc cos,x sta a11 ;a=(COS(T1)+COS(T2))/2:calcb ldx t1 lda sin,x sec ldx t2 sbc sin,x sta b12 ;b=(SIN(T1)-SIN(T2))/2:calcc ldx sy lda sin,x >>> mul2 sta c13 ;c=SIN(SY):calcd sec ldx t8 lda cos,x ldx t7 sbc cos,x sec ldx t5 sbc cos,x clc ldx t6 adc cos,x ;dI=(COS(T8)-COS(T7)+COS(T6)-COS(T5))/2 >>> div2 clc ldx t3 adc sin,x sec ldx t4 sbc sin,x sta d21 ;d=(SIN(T3)-SIN(T4)+dI)/2:calce sec ldx t5 lda sin,x ldx t6 sbc sin,x sec ldx t7 sbc sin,x sec ldx t8 sbc sin,x ;eI=(SIN(T5)-SIN(T6)-SIN(T7)-SIN(T8))/2 >>> div2 clc ldx t3 adc cos,x clc ldx t4 adc cos,x sta e22 ;e=(COS(T3)+COS(T4)+eI)/2:calcf ldx t9 lda sin,x sec ldx t10 sbc sin,x sta f23 ;f=(SIN(T9)-SIN(T10))/2:calcg ldx t6 lda sin,x sec ldx t8 sbc sin,x sec ldx t7 sbc sin,x sec ldx t5 sbc sin,x ;gI=(SIN(T6)-SIN(T8)-SIN(T7)-SIN(T5))/2 >>> div2 clc ldx t4 adc cos,x sec ldx t3 sbc cos,x sta g31 ;g=(COS(T4)-COS(T3)+gI)/2 >>> debuga,g31 >>> debug,'G':calch clc ldx t6 lda cos,x ldx t7 adc cos,x sec ldx t5 sbc cos,x sec ldx t8 sbc cos,x ;hI=(COS(T6)+COS(T7)-COS(T5)-COS(T8))/2 >>> div2 clc ldx t3 adc sin,x clc ldx t4 adc sin,x sta h32 ;h=(SIN(T3)+SIN(T4)+hI)/2:whew clc ldx t9 lda cos,x ldx t10 adc cos,x sta i33 ;i=(COS(T9)+COS(T10))/2** iT'S ALL DOWNHILL FROM HERE.** rOTATE, PROJECT, AND STORE THE POINTSdownhill lda a11 ;tHIS IS GETTING TO BE A REAL MESS sta ta lda b12 ;tHE REASON THIS IS DONE sta tb ;IS TO MAKE THE CODE A LITTLE lda c13 ;EASIER TO READ (AND DEBUG!) sta tc lda d21 ;tHESE ARE ALL TEMPORARY LOCATIONS sta td ;uSED BY THE PROJECTION SUBROUTINE. lda e22 sta te ;oTHERWISE, THERE WOULD BE EIGHT lda f23 ;LONG ROUTINES HERE. sta tf lda g31 ;bUT IT WOULD BE SIGNIFICANTLY FASTER sta tg lda h32 sta th lda i33 sta ti* a NEAT MACROneg mac  ;cHANGE THE SIGN OF A TWO'S COMPLEMENT clc lda ]1 ;NUMBER. eor #$ff adc #$01 <<<* p1=[1 1 1] jsr project ;uNROLL THIS WHOLE THING ldx tx1 ;(SORRY ABOUT THESE TWO LINES) ldy ty1 ;(SEE project FOR REASON WHY) stx p1x ;fOR A PRETTY BIG SPEED INCREASE! sty p1y* p2=[1 -1 1] >>> neg,b12 ;cHANGE THESE ELEMENTS sta tb >>> neg,e22 ;sINCE Y IS NOW -1 sta te >>> neg,h32 sta th jsr project ldx tx1 ldy ty1 stx p2x sty p2y* p3=[-1 -1 1] >>> neg,a11 sta ta >>> neg,d21 sta td >>> neg,g31 sta tg jsr project ldx tx1 ldy ty1 stx p3x sty p3y* p4=[-1 1 1] lda b12 sta tb lda e22 sta te lda h32 sta th jsr project ldx tx1 ldy ty1 stx p4x sty p4y* p8=[-1 1 -1] >>> neg,c13 sta tc >>> neg,f23 sta tf >>> neg,i33 sta ti jsr project ldx tx1 ldy ty1 stx p8x sty p8y* p7=[-1 -1 -1] >>> neg,b12 sta tb >>> neg,e22 sta te >>> neg,h32 sta th jsr project ldx tx1 ldy ty1 stx p7x sty p7y* p6=[1 -1 -1] lda a11 sta ta lda d21 sta td lda g31 sta tg jsr project ldx tx1 ldy ty1 stx p6x sty p6y* p5=[1 1 -1] lda b12 sta tb lda e22 sta te lda h32 sta th jsr project ldx tx1 ldy ty1 stx p5x sty p5y**** cLEAR BUFFER >>> setbufclrbuf lda #$00 ;pRETTY STRAIGHTFORWARD, ldx #$08 ;i THINK ldy #$00:loop sta (buffer),y iny bne :loop inc buffer+1 dex bne :loop lda buffer+1**** fINALLY, DRAW THE LINES. lda p1x ;[1 1 1] sta tx1 lda p1y sta ty1 lda p2x ;[1 -1 1] sta tx2 lda p2y sta ty2 jsr draw ;fIRST LINE lda p3x ;[-1 -1 1] sta tx1 lda p3y sta ty1 jsr draw ;sECOND LINE lda p4x ;[-1 1 1] sta tx2 lda p4y sta ty2 jsr draw ;tHIRD LINE lda p1x ;[1 1 1] sta tx1 lda p1y sta ty1 jsr draw ;fOURTH LINE.  oNE FACE DONE. lda p5x ;[1 1 -1] sta tx2 lda p5y sta ty2 jsr draw ;fIVE lda p6x ;[1 -1 -1] sta tx1 lda p6y sta ty1 jsr draw ;sIX lda p2x ;[1 -1 1] sta tx2 lda p2y sta ty2 jsr draw ;sEVEN lda p7x ;[-1 -1 -1] sta tx2 lda p7y sta ty2 jsr draw ;eIGHT lda p3x ;[-1 -1 1] sta tx1 lda p3y sta ty1 jsr draw ;nINE lda p8x ;[-1 1 -1] sta tx1 lda p8y sta ty1 jsr draw ;tEN lda p4x ;[-1 1 1] sta tx2 lda p4y sta ty2 jsr draw ;eLEVEN lda p5x ;[1 1 -1] sta tx2 lda p5y sta ty2 jsr draw ;tWELVE!**** sWAP BUFFERSswapbuf lda vmcsb eor #$02 ;pRETTY TRICKY, EH? sta vmcsb lda #$08 eor ztemp ;ZTEMP=HIGH BYTE JUST FLIPS sta ztemp ;BETWEEN $30 AND $38 jmp main ;aROUND AND AROUND WE GO...*-------------------------------* tHIS SUBROUTINE CALCULATES THE PROJECTION OF x AND yproject clc lda tg adc th clc adc ti ;tHIS IS ROTATED z clc adc #128 ;wE ARE GOING TO TAKE 128+Z* >>> debuga,aux* >>> debug,'A' tax  ;nOW IT IS READY FOR INDEXING lda zdiv,x ;tABLE OF -D/Z sta aux ;tHIS IS FOR THE PROJECTION sta rem ;mULTIPLY CAN CLOBBER aux clc lda ta adc tb clc adc tc sta acc ;tHIS IS ROTATED X jsr smult ;sIGNED MULTIPLY acc*aux/2^offset clc lda acc:cont1 adc #64 ;oFFSET THE COORDINATE* sEE BELOW FOR THE REASON WHY THIS* NEXT INSTRUCTION IS COMMENTED OUT* tax  ;nOW x IS X! sta tx1 clc  ;dO THE WHOLE THING AGAIN FOR y lda rem sta aux lda td adc te clc adc tf sta acc ;tHIS IS ROTATED Y jsr smult ;sIGNED MULTIPLY acc*aux/2^offset clc lda acc:cont2 adc #64 ;oFFSET THE COORDINATE* fOR SOME COMPLETELY UNKNOWN REASON TO ME* THE INSTRUCTION BELOW DOESN'T WORK.  sOMEHOW* THE rts IS MODIFYING x AND y???* tay  ;sTORE IN y sta ty1 rts  ;i HOPE TO HECK THIS WORKS.*-------------------------------* smult: 8-BIT SIGNED (SORT-OF) MULTIPLY** acc*aux/2^offset -> [acc, ext]  16-BIT RESULT  LO,HI** nOTE THAT THIS ROUTINE DIVIDES THE END RESULT BY 2^offset* yUP, ANOTHER MACRO.divoff mac  ;dIVIDE BY THE FLOAT OFFSET lup offset ;rEPEAT OFFSET TIMES lsr  ;a CONTAINS HIGH BYTE ror acc ;acc IS LOW BYTE --^ <<<smult clc lda acc ;fIRST, IS THE RESULT POSITIVE OR NEGATIVE? eor aux bmi :neg lda acc ;tHEY ARE EITHER BOTH NEGATIVE OR bpl :cont1 ;BOTH POSITIVE eor #$ff ;iN THIS CASE, MAKE THEM adc #$01 ;BOTH POSITIVE! sta acc >>> neg,aux ;lITTLE MACRO USED EARLIER.:cont1 lda #00 ;mULTIPLY THE TWO NUMBERS ldy #$09]loop lsr  ;rEAD THE ARTICLE FOR DETAILS. ror acc bcc :mult1 ;oR FIGURE IT OUT YOURSELF! clc adc aux:mult1 dey bne ]loop >>> divoff ;rEMOVE THIS LINE FOR A GENERAL MULTIPLY sta ext rts:neg lda acc ;oNE OF THE TWO IS NEGATIVE bmi :cont2 >>> neg,aux ;oTHERWISE IT'S aux jmp :cont3:cont2 eor #$ff ;tAKE TWO'S COMPLEMENT adc #$01 sta acc:cont3 lda #00 ;mULTIPLY ldy #$09]loop2 lsr ror acc bcc :mult2 clc adc aux:mult2 dey bne ]loop2 >>> divoff ;aGAIN, DIVIDE BY THE OFFSET sta ext lda acc bpl :ok ;sOMETHING IS REALLY WRONG IF THIS IS NEGATIVE. jsr choke:ok eor #$ff ;oTHERISE, EVERYTHING RELEVANT SHOULD adc #$01 ;BE COMPLETELY IN THE LOW BYTE. sta acc rts  ;i HOPE...*-------------------------------* gENERAL QUESTIONABLE-VALUE ERROR PROCEDUREchoke ldx #00:loop lda :ctext,x beq :done jsr chrout inx jmp :loop:done rts:ctext hex 0d ;cr txt 'SOMETHING CHOKED :(' hex 0d00*-------------------------------* dRAWIN' A LINE.  a FAHN LAHN.*** sOME USEFUL MACROSplotpx mac  ;PLOT A POINT IN X pha  ;uSE THIS ONE EVERY TIME lda bitp,x ;x IS INCREASED bpl c1 eor buffer sta buffer bmi c2 inc buffer+1c2 lda #%10000000c1 ora (buffer),y sta (buffer),y pla  ;nEED TO SAVE a! <<<plotpy mac  ;pLOT A POINT IN Y: SIMPLER AND NECESSARY! pha  ;uSE THIS ONE WHEN YOU JUST INCREASE y lda bitp,x ;BUT x DOESN'T CHANGE ora (buffer),y sta (buffer),y pla <<<cinit mac  ;mACRO TO INITIALIZE THE COUNTER lda ]1 ;DX OR DY lsr eor #$ff ;(nOT TWO'S COMPLEMENT) adc #$01 ;a = 256-DX/2 OR 256-DY/2 <<<  ;tHE DX/2 MAKES A NICER LOOKING LINExstep mac  ;mACRO TO TAKE A STEP IN xxloop inx adc dy bcc l1* dO WE USE iny OR dey HERE? if i,]1 ;iF THE FIRST CHARACTER IS AN 'i' iny else dey fin sbc dxl1 >>> plotpx ;aLWAYS TAKE A STEP IN x cpx x2 bne xloop <<<ystep mac  ;sAME THING, BUT FOR yyloop if i,]1 iny else dey clc  ;vERY IMPORTANT! fin adc dx bcc l2 inx  ;aLWAYS INCREASE x sbc dy >>> plotpx jmp l3l2 >>> plotpy ;wE ONLY INCREASED yl3 cpy y2 bne yloop <<<**** iNITIAL LINE SETUPdraw >>> move,tx1;x1  ;mOVE STUFF INTO ZERO PAGE >>> move,tx2;x2  ;wHERE IT CAN BE MODIFIED >>> move,ty1;y1 >>> move,ty2;y2 >>> setbuf ;nOW WE CAN CLOBBER THE BUFFER sec  ;mAKE SURE X1<X2 lda x2 sbc x1 bcs :cont lda y2 ;iF NOT, SWAP p1 AND p2 ldy y1 sta y1 sty y2 lda x1 ldy x2 sty x1 sta x2 sbc x1 ;nOW a=DX:cont sta dx ldx x1 ;pUT X1 INTO x, NOW WE CAN TRASH x1column lda x1 ;fIND THE FIRST COLUMN FOR x lsr  ;(tHIS CAN BE MADE MUCH FASTER!) lsr  ;tHERE ARE X1/8 128 BYTE BLOCKS lsr  ;wHICH MEANS X1/16 256 BYTE BLOCKS lsr bcc :even ;wITH A POSSIBLE EXTRA 128 BYTE BLOCK ldy #$80 ;IF SO, SET THE HIGH BIT sty buffer clc:even adc buffer+1 ;aDD IN THE NUMBER OF 256 BYTE BLOCKS sta buffer+1 ;aND STORE IT! sec lda y2 ;cALCULATE DY sbc y1 bcs :cont2 ;iS Y2>Y1? lda y1 ;oTHERWISE DY=Y1-Y2 sbc y2:cont2 sta dy cmp dx ;wHO'S BIGGER: DY OR DX? bcs stepiny ;iF DY, WE NEED TO TAKE BIG STEPS IN Ystepinx ldy y1 ;x IS ALREADY SET TO X1 lda bitp,x ;pLOT THE FIRST POINT ora (buffer),y sta (buffer),y >>> cinit,dx ;iNITIALIZE THE COUNTER cpy y2 bcs xdecy ;dO WE STEP FORWARDS OR BACKWARDS IN y?xincy >>> xstep,iny rtsxdecy >>> xstep,dey rtsstepiny ldy y1 ;wELL, A LITTLE REPETITION NEVER HURT ANYONE lda bitp,x ora (buffer),y sta (buffer),y >>> cinit,dy cpy y2 bcs ydecyyincy >>> ystep,iny rtsydecy >>> ystep,dey rts*-------------------------------* cLEAN UPcleanup lda vmcsb ;sWITCH CHAR ROM BACK IN and #%11110101 ;DEFAULT sta vmcsb rts  ;BYE!*-------------------------------* sOME VARIABLEStx1 ds 1ty1 ds 1tx2 ds 1ty2 ds 1p1x ds 1 ;tHESE ARE TEMPORARY STORAGEp1y ds 1 ;uSED IN PLOTTING THE PROJECTIONp2x ds 1p2y ds 1 ;tHEY ARE HERE SO THAT WEp3x ds 1 ;DON'T HAVE TO RECALCULATE THEM.p3y ds 1p4x ds 1 ;tHEY MAKE LIFE EASY.p4y ds 1p5x ds 1 ;wHY ARE YOU LOOKING AT ME LIKE THAT?p5y ds 1 ;dON'T YOU TRUST ME?p6x ds 1p6y ds 1 ;hAVING ANOTHER CHILD WASN'T MY IDEA.p7x ds 1p7y ds 1p8x ds 1p8y ds 1dsx ds 1 ;dsx IS THE INCREMENT FOR ROTATING AROUND Xdsy ds 1 ;sIMILAR FOR dsy, dszdsz ds 1sx ds 1 ;tHESE ARE THE ACTUAL ANGLES IN X Y AND Zsy ds 1sz ds 1t1 ds 1 ;tHESE ARE USED IN THE ROTATIONt2 ds 1t3 ds 1 ;sEE THE ARTICLE FOR MORE DETAILSt4 ds 1t5 ds 1t6 ds 1t7 ds 1t8 ds 1t9 ds 1t10 ds 1a11 ds 1 ;tHESE ARE THE ELEMENTS OF THE ROTATION MATRIXb12 ds 1 ;xyzc13 ds 1d21 ds 1 ;tHE NUMBER DENOTES (ROW,COLUMN)e22 ds 1f23 ds 1g31 ds 1h32 ds 1i33 ds 1ta ds 1 ;tHESE ARE TEMPORARY LOCATIONStb ds 1 ;FOR USE BY THE PROJECTION ROUTINEtc ds 1td ds 1te ds 1tf ds 1tg ds 1th ds 1ti ds 1*-------------------------------* sET UP BIT TABLE ds ^ ;cLEAR TO END OF PAGE   ;sO THAT TABLES START ON A PAGE BOUNDARYbitp lup 16 ;128 eNTRIES FOR x dfb %10000000 dfb %01000000 dfb %00100000 dfb %00010000 dfb %00001000 dfb %00000100 dfb %00000010 dfb %00000001 --^sin   ;tABLE OF SINES, 120 BYTEScos equ sin+128 ;tABLE OF COSINES   ;bOTH OF THESE TRIG TABLES ARE   ;CURRENTLY SET UP FROM basiczdiv equ cos+128 ;dIVISION TABLE