| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,158 @@ |
| 1 |
+( isometric cube ) |
|
| 2 |
+ |
|
| 3 |
+%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
|
|
| 4 |
+%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
|
|
| 5 |
+%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
|
|
| 6 |
+%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
|
|
| 7 |
+ |
|
| 8 |
+%2* { #10 SFT } %2/ { #01 SFT } %2** { #10 SFT2 } %2// { #01 SFT2 }
|
|
| 9 |
+%4* { #20 SFT } %4/ { #02 SFT } %4** { #20 SFT2 } %4// { #02 SFT2 }
|
|
| 10 |
+%8* { #30 SFT } %8/ { #03 SFT } %8** { #30 SFT2 } %8// { #03 SFT2 }
|
|
| 11 |
+%10* { #40 SFT } %10/ { #04 SFT } %10** { #40 SFT2 } %10// { #04 SFT2 }
|
|
| 12 |
+%20* { #50 SFT } %20/ { #05 SFT } %20** { #50 SFT2 } %20// { #05 SFT2 }
|
|
| 13 |
+ |
|
| 14 |
+%ABS2 { DUP2 #0f SFT2 EQU #05 JCN #0000 SWP2 SUB2 }
|
|
| 15 |
+%LTS2 { #8000 ADD2 SWP2 #8000 ADD2 GTH2 }
|
|
| 16 |
+%GTS2 { #8000 ADD2 SWP2 #8000 ADD2 LTH2 }
|
|
| 17 |
+ |
|
| 18 |
+%DEBUG { ;print-hex/byte JSR2 #0a18 DEO }
|
|
| 19 |
+%DEBUG2 { ;print-hex JSR2 #0a18 DEO }
|
|
| 20 |
+%RTN { JMP2r }
|
|
| 21 |
+ |
|
| 22 |
+( devices ) |
|
| 23 |
+ |
|
| 24 |
+|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1 |
|
| 25 |
+|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 |
|
| 26 |
+ |
|
| 27 |
+( variables ) |
|
| 28 |
+ |
|
| 29 |
+|0000 |
|
| 30 |
+ |
|
| 31 |
+@cube |
|
| 32 |
+ &v0 $8 |
|
| 33 |
+ &v4 $8 |
|
| 34 |
+@timer $1 |
|
| 35 |
+@color $1 |
|
| 36 |
+@line |
|
| 37 |
+ &x0 $2 &y0 $2 |
|
| 38 |
+ &x $2 &y $2 |
|
| 39 |
+ &sx $2 &sy $2 |
|
| 40 |
+ &dx $2 &dy $2 |
|
| 41 |
+ &e1 $2 &e2 $2 |
|
| 42 |
+@center |
|
| 43 |
+ &x $2 &y $2 |
|
| 44 |
+ |
|
| 45 |
+( program ) |
|
| 46 |
+ |
|
| 47 |
+|0100 ( -> ) |
|
| 48 |
+ |
|
| 49 |
+ ( theme ) |
|
| 50 |
+ #0fe5 .System/r DEO2 |
|
| 51 |
+ #0fc5 .System/g DEO2 |
|
| 52 |
+ #0f25 .System/b DEO2 |
|
| 53 |
+ |
|
| 54 |
+ .Screen/width DEI2 2// #0040 -- .center/x STZ2 |
|
| 55 |
+ .Screen/height DEI2 2// #0040 -- .center/y STZ2 |
|
| 56 |
+ |
|
| 57 |
+ ;on-frame .Screen/vector DEO2 |
|
| 58 |
+ |
|
| 59 |
+@on-frame ( -> ) |
|
| 60 |
+ |
|
| 61 |
+ #00 ;draw-cube JSR2 |
|
| 62 |
+ .timer LDZk INC SWP STZ |
|
| 63 |
+ #05 ;draw-cube JSR2 |
|
| 64 |
+ |
|
| 65 |
+BRK |
|
| 66 |
+ |
|
| 67 |
+@draw-cube ( frame color -- ) |
|
| 68 |
+ |
|
| 69 |
+ .color STZ |
|
| 70 |
+ ( create box ) |
|
| 71 |
+ #0800 |
|
| 72 |
+ &loop |
|
| 73 |
+ STHk |
|
| 74 |
+ #00 .timer LDZ [ #00 STHkr INC #07 AND #60 SFT ++ ] #00ff AND2 ;table ++ LDA 2/ |
|
| 75 |
+ #00 .timer LDZ [ #00 STHkr #60 SFT ++ ] #00ff AND2 ;table ++ LDA 4/ [ #00 STHkr #62 SFT2 ++ ] |
|
| 76 |
+ .cube/v0 STHr 2* + STZ2 |
|
| 77 |
+ INC GTHk ,&loop JCN |
|
| 78 |
+ POP2 |
|
| 79 |
+ ( vertices ) |
|
| 80 |
+ #0800 |
|
| 81 |
+ &ver-loop |
|
| 82 |
+ DUP 2* .cube + LDZ2 ;draw-vertex JSR2 |
|
| 83 |
+ INC GTHk ,&ver-loop JCN |
|
| 84 |
+ POP2 |
|
| 85 |
+ ( lines ) |
|
| 86 |
+ #0400 |
|
| 87 |
+ &line-loop |
|
| 88 |
+ STHk |
|
| 89 |
+ .cube/v0 STHkr 2* + .cube/v0 STHkr INC #03 AND 2* + ;draw-line JSR2 |
|
| 90 |
+ .cube/v0 STHkr 2* + .cube/v4 STHkr 2* + ;draw-line JSR2 |
|
| 91 |
+ .cube/v4 STHkr 2* + .cube/v4 STHr INC #03 AND 2* + ;draw-line JSR2 |
|
| 92 |
+ INC GTHk ,&line-loop JCN |
|
| 93 |
+ POP2 |
|
| 94 |
+ |
|
| 95 |
+RTN |
|
| 96 |
+ |
|
| 97 |
+@draw-line ( a b -- ) |
|
| 98 |
+ |
|
| 99 |
+ STH STH |
|
| 100 |
+ #00 STHkr LDZ .center/x LDZ2 ++ #00 STHr INC LDZ .center/y LDZ2 ++ |
|
| 101 |
+ #00 STHkr LDZ .center/x LDZ2 ++ #00 STHr INC LDZ .center/y LDZ2 ++ |
|
| 102 |
+ .color LDZ ;line-slow JSR2 |
|
| 103 |
+ |
|
| 104 |
+RTN |
|
| 105 |
+ |
|
| 106 |
+@draw-vertex ( x y -- ) |
|
| 107 |
+ |
|
| 108 |
+ #00 SWP #0004 -- .center/y LDZ2 ++ .Screen/y DEO2 |
|
| 109 |
+ #00 SWP #0003 -- .center/x LDZ2 ++ .Screen/x DEO2 |
|
| 110 |
+ ;&icn .Screen/addr DEO2 |
|
| 111 |
+ .color LDZ 2* .Screen/sprite DEO |
|
| 112 |
+ |
|
| 113 |
+RTN |
|
| 114 |
+ &icn 0000 387c 7c7c 3800 |
|
| 115 |
+ |
|
| 116 |
+@line-slow ( x1 y1 x2 y2 color -- ) |
|
| 117 |
+ |
|
| 118 |
+ ( load ) .color STZ #0001 SUB2 .line/y0 STZ2 #0001 SUB2 .line/x0 STZ2 .line/y STZ2 .line/x STZ2 |
|
| 119 |
+ .line/x0 LDZ2 .line/x LDZ2 SUB2 ABS2 .line/dx STZ2 |
|
| 120 |
+ .line/y0 LDZ2 .line/y LDZ2 SUB2 ABS2 #0000 SWP2 SUB2 .line/dy STZ2 |
|
| 121 |
+ #ffff #00 .line/x LDZ2 .line/x0 LDZ2 LTS2 2** ADD2 .line/sx STZ2 |
|
| 122 |
+ #ffff #00 .line/y LDZ2 .line/y0 LDZ2 LTS2 2** ADD2 .line/sy STZ2 |
|
| 123 |
+ .line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2 |
|
| 124 |
+ &loop |
|
| 125 |
+ .line/x LDZ2 .Screen/x DEO2 .line/y LDZ2 .Screen/y DEO2 .color LDZ .Screen/pixel DEO |
|
| 126 |
+ .line/x LDZ2 .line/x0 LDZ2 EQU2 .line/y LDZ2 .line/y0 LDZ2 EQU2 #0101 EQU2 ,&end JCN |
|
| 127 |
+ .line/e1 LDZ2 2** .line/e2 STZ2 |
|
| 128 |
+ .line/e2 LDZ2 .line/dy LDZ2 LTS2 ,&skipy JCN |
|
| 129 |
+ .line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2 |
|
| 130 |
+ .line/x LDZ2 .line/sx LDZ2 ADD2 .line/x STZ2 |
|
| 131 |
+ &skipy |
|
| 132 |
+ .line/e2 LDZ2 .line/dx LDZ2 GTS2 ,&skipx JCN |
|
| 133 |
+ .line/e1 LDZ2 .line/dx LDZ2 ADD2 .line/e1 STZ2 |
|
| 134 |
+ .line/y LDZ2 .line/sy LDZ2 ADD2 .line/y STZ2 |
|
| 135 |
+ &skipx |
|
| 136 |
+ ;&loop JMP2 |
|
| 137 |
+ |
|
| 138 |
+ &end |
|
| 139 |
+ |
|
| 140 |
+RTN |
|
| 141 |
+ |
|
| 142 |
+@table ( 256 xy ) |
|
| 143 |
+ f7f8 f9fa fbfc fcfd fefe ffff ffff ffff |
|
| 144 |
+ ffff ffff fffe fefd fcfc fbfa f9f8 f7f6 |
|
| 145 |
+ f5f3 f2f0 efed ecea e8e6 e4e2 e0de dcda |
|
| 146 |
+ d8d5 d3d1 cecc c9c7 c4c1 bfbc b9b6 b3b0 |
|
| 147 |
+ aeab a8a5 a29f 9c98 9592 8f8c 8986 8380 |
|
| 148 |
+ 7c79 7673 706d 6a67 6360 5d5a 5754 514f |
|
| 149 |
+ 4c49 4643 403e 3b38 3633 312e 2c2a 2725 |
|
| 150 |
+ 2321 1f1d 1b19 1715 1312 100f 0d0c 0a09 |
|
| 151 |
+ 0807 0605 0403 0302 0101 0000 0000 0000 |
|
| 152 |
+ 0000 0000 0001 0102 0303 0405 0607 0809 |
|
| 153 |
+ 0a0c 0d0f 1012 1315 1719 1b1d 1f21 2325 |
|
| 154 |
+ 272a 2c2e 3133 3638 3b3e 4043 4649 4c4f |
|
| 155 |
+ 5154 575a 5d60 6367 6a6d 7073 7679 7c7f |
|
| 156 |
+ 8386 898c 8f92 9598 9c9f a2a5 a8ab aeb0 |
|
| 157 |
+ b3b6 b9bc bfc1 c4c7 c9cc ced1 d3d5 d8da |
|
| 158 |
+ dcde e0e2 e4e6 e8ea eced eff0 f2f3 f5f6 |