The CoCo SDC contains 128K of Flash memory which is divided into
eight banks of 16K. The active Flash bank appears in the CoCo
memory map from $C000 to $FEFF. Flash is SST 39SF010A

Each bank is divided into four sectors of 4K:

    0 $C000 - $CFFF
    1 $D000 - $DFFF
    2 $E000 - $EFFF
    3 $F000 - $FEFF

The SDC-DOS WRITE MEM command is used to change one or more bytes:

    WRITE MEM @bank, source, destination, count

Destination is $C000-$FEFF.

To actually write a byte to a bank a sequence of four writes is
used. The first three are unlock writes used to prepare the 39SF010A
flash. The last actually writes the data:

    1 write bank 1 $D555 $AA
    2 write bank 0 $EAAA $55
    3 write bank 1 $D555 $A0
    4 write data to target bank

To do each write:

	1 Store value to write in the Flash Data register
	2 Write bank number ORed with $80 to Flash Control register
	3 Read from the target address

-------------------------------------

Test write using SDC-DOS "DISK" still at $400

WRITE MEM @4, &H400, &HC000, 4

Result:

LoadRom load flash bank 4

WriteFlashBank 0 1 1555 AA  state, bank, address, data
WriteFlashBank 1 0 2AAA 55
WriteFlashBank 2 1 1555 A0
WriteFlashBank 3 4 0000 44  "D" written to flash

WriteFlashBank 0 1 1555 AA
WriteFlashBank 1 0 2AAA 55
WriteFlashBank 2 1 1555 A0
WriteFlashBank 3 4 0001 49  "I" written to flash

WriteFlashBank 0 1 1555 AA
WriteFlashBank 1 0 2AAA 55
WriteFlashBank 2 1 1555 A0
WriteFlashBank 3 4 0002 53  "S" written to flash

WriteFlashBank 0 1 1555 AA
WriteFlashBank 1 0 2AAA 55
WriteFlashBank 2 1 1555 A0
WriteFlashBank 3 4 0003 4B  "K" written to flash

LoadRom switching out dirty bank 4
LoadRom load flash bank 0

--------------------------------------
KILL MEM uses the sector erase sequence.

    1 write bank 1 $D555 $AA
    2 write bank 0 $EAAA $55
    3 write bank 1 $D555 $80
    4 write bank 1 $D555 $AA
    5 write bank 0 $EAAA $55
    6 write bank # #Sect $30 // Sector $0000,$1000,$2000,$3000

Test kill mem. Note LoadRom occurs after the first sequence

KILL MEM @4

WriteFlashBank 0 1 1555 AA  state, bank, address, data
WriteFlashBank 1 0 2AAA 55
WriteFlashBank 2 1 1555 80
WriteFlashBank 4 1 1555 AA
WriteFlashBank 5 0 2AAA 55
WriteFlashBank 6 4 0000 30  0

LoadRom load flash bank 4

WriteFlashBank 0 1 1555 AA
WriteFlashBank 1 0 2AAA 55
WriteFlashBank 2 1 1555 80
WriteFlashBank 4 1 1555 AA
WriteFlashBank 5 0 2AAA 55
WriteFlashBank 6 4 1000 30  1

WriteFlashBank 0 1 1555 AA
WriteFlashBank 1 0 2AAA 55
WriteFlashBank 2 1 1555 80
WriteFlashBank 4 1 1555 AA
WriteFlashBank 5 0 2AAA 55
WriteFlashBank 6 4 2000 30  2

WriteFlashBank 0 1 1555 AA
WriteFlashBank 1 0 2AAA 55
WriteFlashBank 2 1 1555 80
WriteFlashBank 4 1 1555 AA
WriteFlashBank 5 0 2AAA 55
WriteFlashBank 6 4 3000 30  3

LoadRom load flash bank 0

