Code( macros ) %RTN { JMP2r } %/2 { #01 SFT2 } %RECT-W { .Screen/width DEI2 #00a0 SUB2 } %RECT-H { .Screen/height DEI2 #00c0 SUB2 } %RECT-MARGIN { #0050 } %MOUSE { .mouse/x LDZ2 .mouse/y LDZ2 } %-- { #0001 SUB2 } %++ { #0001 ADD2 } ( devices ) |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ] |90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ] |80 @Controller [ &vector $2 &button $1 &key $1 ] ( zero page ) |0000 @canvas [ &x $2 &y $2 &w $2 &h $2 ] ( program ) |0100 ;text1 .canvas/x LDZ2 #0035 ;draw-text JSR2 BRK @draw-letters ( letters length* x* y* color -- ) ( assign parameters to local variables ) ,&color STR ( ws: letters length x y ) .Screen/y DEO2 ( ws letters length x ) ,&x STR2 ( ws: letters length ) ,&length STR2 ( ws: letters ) ( reverse loop over each letter to draw them ) &loop ( ws: letters ) ,&length LDR2 ( ws: letters length ) #0001 SUB2 ( ws: letters length ) #0008 MUL2 ( ws: letters xoffset ) ,&x LDR2 ADD2 .Screen/x DEO2 ( ws: letters ) ;draw-letter JSR2 ( decrease length, loop if > 0 ) ,&length LDR2 #0001 SUB2 DUP2 ,&length STR2 #0000 GTH2 ,&loop JCN RTN BRK BRK ( local ) &color $1 &x $2 &y $2 &length $2 @draw-letter ( letter -- ) ( the letter 'a' starts at offset #61 of the ascii table. ) #61 SUB ( ws: char ) ( to get the offset, multiply char by 8. first, pad with 00 to get a short. ) #00 SWP #0008 MUL2 ( add the font addr to offset and draw letter. ) ;font ADD2 .Screen/addr DEO2 #05 .Screen/sprite DEO &draw-space RTN BRK ( push all letters into the ws. ) @draw-text ( addr* x* y* -- a... ) ( load length, add length and count to rs ) STH2 STH2 LDAk ( ws: addr* len / rs: ) #00 ( ws: addr* len 00 / rs: ) &loop STH2 ( ws: addr* / rs: len counter ) DUP2 ( ws: addr* addr* / rs: len counter ) INC2 #00 ( ws: addr* addr* 00 / rs: len counter ) STHrk ( ws: addr* addr* 00 counter / rs: len counter ) ADD2 LDA ROT ROT ( ws: c addr* / rs: len counter ) STH2r ( ws: c addr* len counter / rs: ) INC DUP2 NEQ ,&loop JCN POP2 LDA #00 SWP STH2r STH2r #01 ;draw-letters JSR2 RTN BRK &addr @text1 20 "hello 20 "world @font 007e 0202 7e42 427e 0040 4040 7e42 427e 007e 4040 4040 407e 0070 4844 4444 4870 007c 4040 7040 407c 007c 4040 7040 4040 007c 4040 4e42 427e 0042 4242 7e42 4242 0000 1010 1010 1010 003c 0808 0808 0870 0044 4850 6050 4844 0040 4040 4040 407c 006c 5242 4242 4242 0078 4444 4444 4444 0038 4444 4444 4438 007c 4444 7c40 4040 0038 4444 4454 4834 007c 4444 7c50 4844 003c 4040 3804 0478 007c 1010 1010 1010 0044 4444 4444 4438 0044 4444 4444 2810 0044 4444 4444 5428 0042 4224 1824 4242 0044 4444 3c04 047c 007c 0408 1020 407c 0000 0000 0000 0000
Good lord. I don't think anyone's going to top this. Is this Assembly?










Posts: 102/24hrs







