18 #! Run a single 8080 instruction
\r
19 [ read-instruction ] keep ! n cpu
\r
20 over get-cycles over inc-cycles
\r
21 [ swap instructions nth call( cpu -- ) ] keep
\r
22 [ pc>> 0xFFFF bitand ] keep
\r
24 process-interrupts ;
\r
26 : test-step ( cpu -- cpu )
\r
27 [ step ] keep dup cpu. ;
\r
29 : invaders ( -- seq )
\r
31 { 0x0000 "invaders/invaders.h" }
\r
32 { 0x0800 "invaders/invaders.g" }
\r
33 { 0x1000 "invaders/invaders.f" }
\r
34 { 0x1800 "invaders/invaders.e" }
\r
37 : test-cpu ( -- cpu )
\r
38 <cpu> invaders over load-rom* dup cpu. ;
\r
41 test-cpu swap [ test-step ] times drop ;
\r
43 : run-n ( cpu n -- cpu )
\r
44 [ dup step ] times ;
\r
46 : each-8bit ( n quot -- )
\r
47 [ 8 <bits> ] dip each ; inline
\r
49 : >ppm ( cpu filename -- cpu )
\r
50 #! Dump the current screen image to a ppm image file with the given name.
\r
57 over 32 * over + 0x2400 + ! cpu h w addr
\r
58 [ pick ] dip swap ram>> nth [
\r
67 ] with-file-writer ;
\r
70 test-cpu [ 1000000 run-n drop ] time ;
\r