Making good progress tidying up the firmware. The debugger is sorted, USB disk handling is now more robust, and directory listings now pause when the screen is full. I added a HEX$() function to convert 16 bit integers to hexadecimal strings.
I tried to implement subdirectories, but it was harder than I thought. The CH376 changes to the subdirectory when it is opened, but forgets about it after opening a file. So I will have to cache the directory names and traverse the full path every time. I am thinking one directory level will be enough, then I only have to find 8 bytes to store its name (note: long names will not be supported!).
The debugger steals a bit over 2k of RAM for internal use. There's still almost 32k free so this hasn't been a problem for me. However I will provide an option to disable the debugger for those who want the maximum possible RAM available in BASIC. The micro-expander takes a 64k EPROM but only uses 16K of it, so you could have 4 different firmware versions selectable via the jumpers on the board. One pair might be needed to select between NTSC and PAL, then the other two would be debugger on/off. Alternatively the debugger could be disabled from the splash screen or via a BASIC command.
There is still ~1.8k of free space in the 16K ROM, so If anyone has any ideas for improvements or additions, now is the time to speak up!
Attached is a current snapshot of the source code (it totals just under 10,000 lines of Z80 assembly language), and a ROM image which can be run in Virtual Aquarius (note: anything that tries to access USB won't work in the simulator!). Since Virtual Aquarius doesn't have a built-in debugger, this ROM could be quite useful for software development.
Edited by Bruce Abbott, Thu Apr 13, 2017 7:16 PM.