Open nihirash opened 7 months ago
I'd also like to add to this that ffs_api_fread
and ffs_api_fwrite
unnecessarily destroy a shadow register which isn't really noted in the API (and no other APIs, or anything in MOS in general, seem to do this).
This code sequence:
EXX
LD HL, _scratchpad
PUSH HL
EXX
Could be replaced with this sequence, which is also smaller:
PUSH HL
LD HL, _scratchpad
EX (SP), HL
as I'm currently digging around in the MOS API implementation code I've taken a look at this. I can confirm that it looks like mos_fread and mos_fwrite both weren't adjusting the pointer argument in HL to be 24-bit compatible. I've looked around a bit further than I think they may be the only APIs that had that oversight - everywhere else I've looked so far is ensuring that registers with pointers are made 24-bit compatible. doh!
also the fatfs versions of fread and write were also both the only places in the code that were using EXX
I just added a commit to #91 that addresses these issues
I might end up back-porting these to 2.3, as MOS 3 is probably still quite a while away from release
I can open file by 16 bit pointer in legacy cpu mode but when I'll try read or write to buffer from non-ADL mode I'm getting failure - cause API works only with full ADL pointers.
As current workaround I'm using prefixed LD command(LD.LIL) but best solution will be making API consistent and allow use fread and fwrite with non-ADL pointers(when MB isn't equal zero).