# TOWER OF HANOI # K. Semrad, DREAMER 17 (Jan 1982), magazine page 10 (PDF page 19) # CHIP-8, load 0200-0400, run C000 (FN 3) # Transfer the seven discs from peg 1 to peg 2 or 3, one at a time, never a larger disc on a smaller one. # First key pressed = FROM peg, second key = TO peg (keys 1, 2, 3; others ignored). # At the end of the game press any key to restart. # Behaviour (from the code): an illegal move (larger disc on smaller, empty FROM peg) shows "ERROR f ON t" and # the next key restarts the whole game; the win screen shows the move count (3 digits) and "MOVE E". # Doubt, left as printed: 03DE-03DF = 00 01 gives "MOVE E"; the font's char 7 (S, C546 at 03FC) is never # used, so "MOVES" (07 at 03DE) was probably meant. Text font: 3x5 packed, 2 bytes/char from 03EE via CHIPOS C198. # Correction: 0372 printed 0A35 (machine-code call to non-existent RAM); fixed to 6A35 = VA:=35, x of the third # peg disc, by symmetry with 6A09 (peg 1, 0356) and 6A1F (peg 2, 036E); pegs are drawn at x 0A, 20, 36. # Correction: 037E printed 00E0 (erase); fixed to 00EE (return): the disc-drawing subroutine 0376 must return # when V0 (disc width) is 0 - empty slots; with 00E0 it clears the screen and loops forever. # Machine code: 02F4-02FD (LDAA #20 / STAA 21 / LDAB #40 / JSR C2E5 / RTS), 038C-0393 (LDAA 30 / LDX #03EC / JMP C198). 0200 13CA 6100 6200 A080 F21E F155 4228 1218 0210 7001 7101 7202 1206 6200 6000 A08E F21E 0220 F055 421A 122A 7202 121C 6D00 6A00 6B1F 0230 A279 DAB1 7A08 3A40 1230 6A0A 6B1E A207 0240 DAB1 7BFF 3B0C 1240 7A16 3A4C 123C 6200 0250 A080 F21E F165 2354 2376 4228 1262 7202 0260 1250 6407 13C4 3E01 128C 6200 A080 F21E 0270 F065 3000 1280 7202 74FF 3400 126C 1298 0280 8300 6000 A080 F21E F055 12A0 3E02 1294 0290 620E 126C 4E03 129C 02F4 1262 621C 126C 02A0 6407 1348 3E01 12E4 620C A080 F21E F065 02B0 4000 12C0 72FE 74FF 3400 12AA 02F4 12A0 02C0 8030 A080 F21E F055 420C 12E2 421A 12E2 02D0 4228 12E2 7202 A080 F21E F065 8305 3F00 02E0 132E 12FE 3E02 12EC 621A 12AA 3E03 12BC 02F0 6228 12AA 8620 9721 C640 BDC2 E539 7D01 0300 6700 661C A08C F61E F065 8704 76F2 36F2 0310 1304 3000 7701 00E0 122C F000 6A00 6200 0320 2394 3A40 1320 23A6 F00A 00E0 1200 6A00 0330 6210 2394 3A40 1332 6A28 6B00 F829 DAB5 0340 6A3C F929 DAB5 1328 FE0A 89E0 12A4 FE0A 0350 88E0 1266 6507 6A09 6B11 8155 3F00 1368 0360 8154 8B14 8B14 00EE 8155 3F00 1372 6A1F 0370 1360 6A35 1362 A207 8CA0 7C02 4000 00EE 0380 DAB1 DCB1 7AFF 7C01 70FF 137C 9630 CE03 0390 EC7E C198 6B00 A3D0 F21E F065 038C DAB5 03A0 7A04 7201 00EE A0FC FD33 F265 6A00 6B00 03B0 F029 23BE F129 23BE F229 23BE 00EE DAB5 03C0 7A04 00EE 3707 134E 131C 6700 6001 1202 03D0 0000 0000 0000 0000 0000 0503 0601 0001 03E0 0102 0203 0200 0000 0000 0000 0304 0000 03F0 F3CE BBDE F6DE B6DE B7FA 56DA C546 0000