Skip to content

Commit

Permalink
Revert "Default to 0 for first two M-R result bytes"
Browse files Browse the repository at this point in the history
This reverts commit 26dd93e.

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.
  • Loading branch information
thierer committed Sep 17, 2022
1 parent 3c2406e commit 91de152
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
5 changes: 2 additions & 3 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 4 additions & 9 deletions src/doscmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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 */
Expand Down
11 changes: 6 additions & 5 deletions src/fl-krill.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */

Expand Down

0 comments on commit 91de152

Please sign in to comment.