jscrane / UK101

Compukit UK101 hardware emulator on Stellarpad, ESP8266 and ESP32
GNU General Public License v2.0
7 stars 4 forks source link

Superinvaders #22

Closed jscrane closed 4 months ago

jscrane commented 4 months ago

Hangs on load:

aa xx yy sp nv_bdizc pc op ff 05 08 f2 11110001 fb12 aa ff ff 08 f2 11110001 fb13 ad 0c ff 08 f2 01110001 fb16 60 0c ff 08 f4 01110001 fe7c 6c 0c ff 08 f4 01110001 0075 00 0c ff 08 f1 01110101 0225 4c 0c ff 08 f1 01110101 01c0 00 0c ff 08 f1 01110101 01c1 00 0c ff 08 f1 01110101 01c2 00 0c ff 08 f1 01110101 01c3 00 0c ff 08 f1 01110101 01c4 00 0c ff 08 f1 01110101 01c5 00 0c ff 08 f1 01110101 01c6 00 0c ff 08 f1 01110101 01c7 ad 24 ff 08 f1 01110101 01ca 19 6f ff 08 f1 01110101 01cd b8 6f ff 08 f1 00110101 01ce dd 6f ff 08 f1 00110101 01d1 04 6f ff 08 f1 00110101 01d3 80 6f ff 08 f1 00110101 01d5 00 6f ff 08 f1 00110101 01d6 00 6f ff 08 f1 00110101 01d7 a9 ac ff 08 f1 10110101 01d9 1f

Note the PC transfers to $0075 instead of $0705. It finally stops with an Illegal Instruction.

jscrane commented 4 months ago

The fix was to edit the input file from:

^M54^M41^M52^M54^M00^MFF^M.0705G0^ to ^M54^M41^M52^M54^M00^MFF^M.07005G^

I don't understand why this is!

jscrane commented 4 months ago

more 9 read 46 more 8 read 48 more 7 read 55 read 48 more 5 read 53 more 4 read 71

It is clear that two consecutive reads are issued, without an intervening call to more. (more is called from a read of the ACIA status register, read is called from a read of the data register.)

The first read is obviously being lost, resulting in a transfer of control to 0075, instead of 0705.

jscrane commented 4 months ago

This behaviour only happens with the monuk02 load routine, not cegmon's.

jscrane commented 4 months ago

It looks as if this read is a spurious one:

03 02 00 f4 00110011 fe30 b1 read 0 30 02 00 f4 00110001 fe32 85

Instruction b1 is LDA (ind), Y. The location indirected though is 0xfe. This instruction is processed twice more in this trace, without reading the ACIA.

I expect that this would have happened "in real life" too, but a character wouldn't have been available to have been read from the slow tape at this time, so it was a benign bug.

jscrane commented 4 months ago

Turns out that this spurious read was reading from $f007 which would not have addressed the ACIA on a real UK101. Tightening up the ACIA read handler fixed this.

Nice bug!