From 91de152e35c78992a213f197fd59a700e4621a39 Mon Sep 17 00:00:00 2001 From: Martin Thierer Date: Sat, 17 Sep 2022 19:22:55 +0200 Subject: [PATCH] Revert "Default to 0 for first two M-R result bytes" This reverts commit 26dd93eb3a69ba03f808253b5984603389eba525. Turns out that: 1. The content in error_buffer[] isn't really random during M-R command handling, but always "00, OK,00,00", because the error buffer is reset just before parsing the command. 2. "GEOS MegaPatch 3" relies on this behavior for sd2iec detection. As after all the result for M-R to unhandled memory locations already seems to be predictable with the original implementation, revert the commit in the interest of the least intrusive change in respect to the official firmware. This also requires minor changes to the "Krill's loader" handler, as it depends on the returned value during the loader's drive probing. --- README | 5 ++--- src/doscmd.c | 13 ++++--------- src/fl-krill.c | 11 ++++++----- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/README b/README index c89fa999..87fe013d 100644 --- a/README +++ b/README @@ -441,9 +441,8 @@ Supported commands: table of common drive-detection addresses and return data that forces most of the supported fast loaders into a compatible mode (e.g. 1541 mode for Dreamload and ULoad Model 3, disabled fastloader - for Action Replay 6). If the address is not recognized, zero will - be returned for the first two bytes and more-or-less random data - beyond. + for Action Replay 6). If the address is not recognized, more-or-less + random data will be returned. This includes basic support for identifying the drive type based on the type of D64 image mounted (1541 for D41, 1571 for D71 and 1581 diff --git a/src/doscmd.c b/src/doscmd.c index ad6c30a4..35cbb5a5 100644 --- a/src/doscmd.c +++ b/src/doscmd.c @@ -203,7 +203,7 @@ static const PROGMEM struct fastloader_crc_s fl_crc_table[] = { #endif #ifdef CONFIG_LOADER_KRILL /* CRCs of the first respective M-W chunk except where noted */ - { 0x8227, FL_KRILL_R58, RXTX_NONE }, // r58/r146 drvchkme + { 0x8667, FL_KRILL_R146, RXTX_NONE }, // r146 drvchkme { 0xe300, FL_KRILL_R186, RXTX_KRILL_CLOCK }, // second chunk { 0x19a4, FL_KRILL_R184, RXTX_KRILL_CLOCK }, // second chunk { 0x741d, FL_KRILL_R184, RXTX_KRILL_CLOCK }, @@ -334,7 +334,7 @@ static const PROGMEM struct fastloader_handler_s fl_handler_table[] = { { 0x020b, FL_NONE, bus_sleep_krill, 1 }, // >= r192 ATN responder #endif #ifdef CONFIG_LOADER_KRILL - { 0x0300, FL_KRILL_R58, drvchkme_krill, 0 }, // <= r146 drvchkme + { 0x0300, FL_KRILL_R146, drvchkme_krill, 0 }, // r146 drvchkme { 0x0209, FL_NONE, load_krill, 0 }, // >= r192 load { 0x0770, FL_KRILL_R186, load_krill, 0 }, { 0x0758, FL_KRILL_R184, load_krill, 0 }, @@ -400,8 +400,8 @@ static const PROGMEM magic_value_t drive_magics[] = { { 0xfea0, { 0x0d, 0xed }, DRIVE_1541|DRIVE_1571 }, /* used by DreamLoad, ULoad Model 3 and Krill's loader */ { 0xe5c6, { 0x34, 0xb1 }, DRIVE_1541 }, - /* Disable AR6 fastloader; entry no longer needed, as 0 is the default now */ - // { 0xfffe, { 0x00, 0x00 }, 0xff }, + /* Disable AR6 fastloader */ + { 0xfffe, { 0x00, 0x00 }, 0xff }, /* used by Krill's loader */ { 0xeaa3, { 0xff, 0x4c }, DRIVE_1541 }, { 0xe5c6, { 0x37, 0xb1 }, DRIVE_1571 }, @@ -1375,11 +1375,6 @@ static void handle_memread(void) { } p++; } - if (check == 0) { - /* use 0 as default */ - error_buffer[0] = 0; - error_buffer[1] = 0; - } } /* This might not work for all scenarios, but for now better be strict */ diff --git a/src/fl-krill.c b/src/fl-krill.c index b0f99878..f9412cb7 100644 --- a/src/fl-krill.c +++ b/src/fl-krill.c @@ -155,15 +155,15 @@ static bool magic_string_matches(void) { } /* Universal handler for possible drvchkme memexecs */ -/* f == 0: drvchkme of <= r146; detected by M-W, no further checks necessary */ -/* f == 1: possible drvchkme of <= r186; check command crc */ -/* f == 2: possible drvchkme of >= r192; check command for magic string */ +/* f == 0: drvchkme of r146; detected by M-W, no further checks necessary */ +/* f == 1: possible drvchkme of <= r186; check command crc */ +/* f == 2: possible drvchkme of >= r192; check command for magic string */ bool drvchkme_krill(uint8_t f) { uint8_t i; uint16_t crc; switch (f) { - case 0: /* <= r146: M-W drvchkme crc matched */ + case 0: /* r146: M-W drvchkme crc matched */ break; case 1: /* check command length and crc for drvchkme */ @@ -191,7 +191,8 @@ bool drvchkme_krill(uint8_t f) { } custom_magic.address = 0x300; - custom_magic.val[0] = ~0; /* the first read will have returned 0 */ + /* the first read will have returned '0' ("00, OK, .." in error_buffer[]) */ + custom_magic.val[0] = ~'0'; custom_magic.val[1] = 0; custom_magic.drives = 0xff; /* applicable for all drive types */