| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,96 @@ |
| 1 |
+( Screen.pixel: test rom for screen pixel drawing ) |
|
| 2 |
+ |
|
| 3 |
+|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 |
|
| 4 |
+|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 |
|
| 5 |
+ |
|
| 6 |
+|0000 |
|
| 7 |
+ |
|
| 8 |
+ @center &x $2 &y $2 |
|
| 9 |
+ |
|
| 10 |
+|0100 |
|
| 11 |
+ |
|
| 12 |
+@on-reset ( -> ) |
|
| 13 |
+ ( | theme ) |
|
| 14 |
+ #f07f .System/r DEO2 |
|
| 15 |
+ #f0d6 .System/g DEO2 |
|
| 16 |
+ #f0b2 .System/b DEO2 |
|
| 17 |
+ ( | resize ) |
|
| 18 |
+ #00c8 DUP2 .Screen/width DEO2 |
|
| 19 |
+ .Screen/height DEO2 |
|
| 20 |
+ ( | find screen center ) |
|
| 21 |
+ .Screen/width DEI2 #01 SFT2 .center/x STZ2 |
|
| 22 |
+ .Screen/height DEI2 #01 SFT2 .center/y STZ2 |
|
| 23 |
+ ( | draw ) |
|
| 24 |
+ <draw-bg-fill> |
|
| 25 |
+ <draw-bg-corners> |
|
| 26 |
+ <draw-fg-corners> |
|
| 27 |
+ <draw-pixels> |
|
| 28 |
+ BRK |
|
| 29 |
+ |
|
| 30 |
+@<draw-bg-fill> ( -- ) |
|
| 31 |
+ .center/x LDZ2 .Screen/x DEO2 |
|
| 32 |
+ .center/x LDZ2 .Screen/y DEO2 |
|
| 33 |
+ ( | 4-way backgrounds ) |
|
| 34 |
+ #0400 |
|
| 35 |
+ &l ( -- ) |
|
| 36 |
+ DUP DUP #40 SFT #80 ADD ORA .Screen/pixel DEO |
|
| 37 |
+ INC GTHk ?&l |
|
| 38 |
+ POP2 JMP2r |
|
| 39 |
+ |
|
| 40 |
+@<draw-bg-corners> ( -- ) |
|
| 41 |
+ .center/x LDZ2 #01 SFT2 .Screen/x DEO2 |
|
| 42 |
+ .center/y LDZ2 #01 SFT2 .Screen/y DEO2 |
|
| 43 |
+ #b0 .Screen/pixel DEO |
|
| 44 |
+ .center/x LDZ2 #01 SFT2 #0003 MUL2 .Screen/x DEO2 |
|
| 45 |
+ .center/y LDZ2 #01 SFT2 .Screen/y DEO2 |
|
| 46 |
+ #a1 .Screen/pixel DEO |
|
| 47 |
+ .center/x LDZ2 #01 SFT2 #0003 MUL2 .Screen/x DEO2 |
|
| 48 |
+ .center/y LDZ2 #01 SFT2 #0003 MUL2 .Screen/y DEO2 |
|
| 49 |
+ #83 .Screen/pixel DEO |
|
| 50 |
+ .center/x LDZ2 #01 SFT2 .Screen/x DEO2 |
|
| 51 |
+ .center/y LDZ2 #01 SFT2 #0003 MUL2 .Screen/y DEO2 |
|
| 52 |
+ #92 .Screen/pixel DEO |
|
| 53 |
+ JMP2r |
|
| 54 |
+ |
|
| 55 |
+@<draw-fg-corners> ( -- ) |
|
| 56 |
+ .center/x LDZ2 #02 SFT2 .Screen/x DEO2 |
|
| 57 |
+ .center/y LDZ2 #02 SFT2 .Screen/y DEO2 |
|
| 58 |
+ #f1 .Screen/pixel DEO |
|
| 59 |
+ .center/x LDZ2 #02 SFT2 #0007 MUL2 .Screen/x DEO2 |
|
| 60 |
+ .center/y LDZ2 #02 SFT2 .Screen/y DEO2 |
|
| 61 |
+ #e3 .Screen/pixel DEO |
|
| 62 |
+ ( clear ) #e0 .Screen/pixel DEO |
|
| 63 |
+ .center/x LDZ2 #02 SFT2 #0007 MUL2 .Screen/x DEO2 |
|
| 64 |
+ .center/y LDZ2 #02 SFT2 #0007 MUL2 .Screen/y DEO2 |
|
| 65 |
+ #c2 .Screen/pixel DEO |
|
| 66 |
+ .center/x LDZ2 #02 SFT2 .Screen/x DEO2 |
|
| 67 |
+ .center/y LDZ2 #02 SFT2 #0007 MUL2 .Screen/y DEO2 |
|
| 68 |
+ #d0 .Screen/pixel DEO |
|
| 69 |
+ JMP2r |
|
| 70 |
+ |
|
| 71 |
+@<draw-pixels> ( -- ) |
|
| 72 |
+ ( | bottom-left, background ) |
|
| 73 |
+ .center/x LDZ2 #0010 SUB2 .Screen/x DEO2 |
|
| 74 |
+ .center/y LDZ2 .Screen/y DEO2 |
|
| 75 |
+ ( auto-x ) #01 .Screen/auto DEO |
|
| 76 |
+ #00 |
|
| 77 |
+ &bl ( -- ) |
|
| 78 |
+ #00 OVR EQU OVR #0f AND ORA ?{
|
|
| 79 |
+ .center/x LDZ2 #0010 SUB2 .Screen/x DEO2 |
|
| 80 |
+ .Screen/y DEI2k INC2 ROT DEO2 } |
|
| 81 |
+ DUP #04 SFT OVR #0f AND LTH INC .Screen/pixel DEO |
|
| 82 |
+ INC DUP ?&bl |
|
| 83 |
+ POP |
|
| 84 |
+ ( | bottom-right, foreground ) |
|
| 85 |
+ .center/x LDZ2 .Screen/x DEO2 |
|
| 86 |
+ .center/y LDZ2 #0010 SUB2 .Screen/y DEO2 |
|
| 87 |
+ ( auto-y ) #02 .Screen/auto DEO |
|
| 88 |
+ #00 |
|
| 89 |
+ &br ( -- ) |
|
| 90 |
+ #00 OVR EQU OVR #0f AND ORA ?{
|
|
| 91 |
+ .center/y LDZ2 #0010 SUB2 .Screen/y DEO2 |
|
| 92 |
+ .Screen/x DEI2k INC2 ROT DEO2 } |
|
| 93 |
+ DUP #04 SFT OVR #0f AND GTH INC #40 ORA .Screen/pixel DEO |
|
| 94 |
+ INC DUP ?&br |
|
| 95 |
+ POP JMP2r |
|
| 96 |
+ |