RomCombiner - fix offered bank/sector ranges for flash erase in slot 0

Merged
#6 · Created  · Last updated

Merged pull request

Merged in romcombiner-slot0-fixes (pull request #6)

428cc5f·Author: ·Closed by: ·2023-03-08

Description

  • Flash cards in slots 1-3 have either RAM or flash memory in their lower half (banks $00 to $1F), but will always have flash memory in their upper half (banks $20 to $3F)

  • Slot 0 (internal) is addressed the other way around. It has ROM or flash memory in its lower half ($00 to $1F), and RAM in its upper half ($20 to $3F).

I recently modified RomCombiner to probe the flash memory to determine whether it supports the classic 64KB sector erase, or individual 16KB bank erase (to add SST flash memory support). I also decided to enhance the screen prompt to suggest only valid sector and bank ranges when erasing, since this can be very confusing to non-expert users.

The way I achieved this without major changes was to extend the assembly eraseflash function to probe the flash hardware when sent an input value of 254, using the FlashEprCardID and FlashEprPollSectorSize functions from the standard library. The BBC BASIC PROCFlashErase procedure does this, catches any errors, and it uses the following variables:

  • C% = target slot number (0 to 3)

  • B% = number of 16KB flash memory banks (32 for 512KB, 64 for 1MB)

  • S% = sector size (64 or 16)

I have fixed the range-finding logic to account for the slot 0 differences via this pair of BASIC one-liners in romutil.cli.

4680 IF S%=16 THEN PRINT "Flash EPROM 16K bank to erase ("+STR$((64-B%)*-(C%>0))+"-"+STR$(63+(C%=0)*32)+",255=all,-1=end)";:INPUT E% 4685 IF S%<>16 THEN PRINT "Flash EPROM 64KB sector to erase ("+STR$(1+(16-(B%/4))*-(C%>0))+"-"+STR$(16+(C%=0)*8)+",256=all,0=end)";:INPUT E%:E%=E%-1

Of course, it should be noted that it is very dangerous to erase sectors in slot 0 flash memory. A mistake here could result in a non-booting Z88, requiring the flash chip to reprogrammed externally. However, at least the correct ranges are offered now. Note also that the BASIC program is not enforcing these ranges, merely suggesting them. I did not want to substantially re-write RomCombiner.

0 attachments

0 comments

Loading commits...