IECHost bug fixed!

Fixing my IEChost receive routine was as simple as changing:

if (CLK_VAL) break;

to:

if (!CLK_VAL) break;

That’s a subtle bug to spot once again, which could not have been easily fixed by looking at the traces alone, even if the latter were quite useful to point me in the right direction.

Here’s the code I am running with filename being “$” (in order to get the directory listing):

st = 0;
open(filename, device_number, secondary_address, &st);
if (st) return IOERR_DEVICE_NOT_PRESENT;

iec_send_talk(device_number, &st);
iec_send_secondary_address_after_talk(CTRL_CODE_DATA | 0x00, &st);

iec_read(2, Buff, &br, &st); /* Load address, e.g. $0801 */
if (st) return IOERR_FILE_NOT_FOUND;

iec_read((sizeof Buff) - 2, &Buff[2], &br, &st); /* File contents */

iec_send_untalk(&st);

close(device_number, secondary_address, &st);

return st;

And here’s the data I have in my read buffer:

0000: 01 04 01 00 00 12 22 55 54 49 4C 49 54 49 45 53 ......"UTILITIES
0010: 20 20 20 20 20 20 20 22 20 30 31 20 32 41 00 01        " 01 2A..
0020: 01 3E 00 20 20 22 45 41 53 59 50 52 4F 47 2D 31 .>.  "EASYPROG-1
0030: 2E 36 2E 33 22 20 20 20 50 52 47 20 20 20 00 01 .6.3"   PRG   ..
0040: 01 07 00 20 20 20 22 55 53 42 2D 42 41 53 49 43 ...   "USB-BASIC
0050: 20 31 2E 31 50 22 20 20 20 50 52 47 20 20 00 01  1.1P"   PRG  ..
0060: 01 07 00 20 20 20 22 55 53 42 2D 42 41 53 49 43 ...   "USB-BASIC
0070: 20 31 2E 31 53 22 20 20 20 50 52 47 20 20 00 01  1.1S"   PRG  ..
0080: 01 21 00 20 20 22 55 53 42 42 41 53 49 43 2E 43 .!.  "USBBASIC.C
0090: 52 54 22 20 20 20 20 20 50 52 47 20 20 20 00 01 RT"     PRG   ..
00A0: 01 21 00 20 20 22 55 53 42 42 41 53 49 43 2D 31 .!.  "USBBASIC-1
00B0: 2E 32 2E 43 52 54 22 20 50 52 47 20 20 20 00 01 .2.CRT" PRG   ..
00C0: 01 10 00 20 20 22 44 36 34 44 55 4D 50 45 52 22 ...  "D64DUMPER"
00D0: 20 20 20 20 20 20 20 20 50 52 47 20 20 20 00 01         PRG   ..
00E0: 01 21 00 20 20 22 55 53 42 42 41 53 49 43 2D 32 .!.  "USBBASIC-2
00F0: 2E 30 2E 43 52 54 22 20 50 52 47 20 20 20 00 01 .0.CRT" PRG   ..
0100: 01 D9 01 42 4C 4F 43 4B 53 20 46 52 45 45 2E 20 ...BLOCKS FREE.
0110: 20 20 20 20 20 20 20 20 20 20 20 20 00 00 00 00             ....
...
01F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

What makes me proud is not just that I fixed the code without looking at my previous implementation, but that I wrote such a beautiful new implementation with a very rich API that mimics what C64 programmers are used to 🙂

This entry was posted in Retrocomputing, Technical and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s