Last night I struggled implementing FDS support in my emulator.
I eventually got it working (as in it loads games successfully), but I am not happy with my implementation.*
This is my current implementation. (Sound emulation parts are omitted for brevity.) Though it works, search for instances of "WRONG" in the source.
http://pastebin.ca/2127813
Questions. (For now considering only reading operation mode.)
– Does the disk reading position advance when disk IRQ is disabled? Logically it should, because the reading position is an aspect of the disk system, not the 2C33 which produces the IRQs, but I could not get my code working without that hack.
– Can $4030 bit 1 indicate that data was transferred from/to disk even when the IRQ is disabled? I.e. could you possibly transfer data from/to disk with IRQ disabled, by just polling $4030 to see when $4024 can be updated or $4031 can be read?
– In FCEU, clearing $4025 bit 6, when it was previously set, and bit 4 is zero, decrements the reading position by two bytes. I could not get my code working unless I did that too. Does that really happen on real FDS? If not, what should I do instead?
– In general, the flowchart of my tick() is based half on experimentation (when disksys.rom stops giving error messages) and half on documentation. I would like it to be correct.
*) Not the least because it is more than third of the length of the original version of my entire NES emulator ;)
I eventually got it working (as in it loads games successfully), but I am not happy with my implementation.*
This is my current implementation. (Sound emulation parts are omitted for brevity.) Though it works, search for instances of "WRONG" in the source.
http://pastebin.ca/2127813
Questions. (For now considering only reading operation mode.)
– Does the disk reading position advance when disk IRQ is disabled? Logically it should, because the reading position is an aspect of the disk system, not the 2C33 which produces the IRQs, but I could not get my code working without that hack.
– Can $4030 bit 1 indicate that data was transferred from/to disk even when the IRQ is disabled? I.e. could you possibly transfer data from/to disk with IRQ disabled, by just polling $4030 to see when $4024 can be updated or $4031 can be read?
– In FCEU, clearing $4025 bit 6, when it was previously set, and bit 4 is zero, decrements the reading position by two bytes. I could not get my code working unless I did that too. Does that really happen on real FDS? If not, what should I do instead?
– In general, the flowchart of my tick() is based half on experimentation (when disksys.rom stops giving error messages) and half on documentation. I would like it to be correct.
*) Not the least because it is more than third of the length of the original version of my entire NES emulator ;)