ishe / plus4

FPGATED based plus4 implementation using Papilio Pro platform
GNU General Public License v3.0
15 stars 1 forks source link

Open bus reads #3

Open gyurco opened 6 months ago

gyurco commented 6 months ago

Hi!

I wonder about reads of unselected areas. There's a new released game (Giana Sisters) which reads from $fdf1, and it doesn't continue to load with $ff.

I added the following, which made it work:

wire       free_sel = cpu_addr[15:5] == {8'hFD, 3'b111};
wire [7:0] free_data = free_sel ? 8'h0 : 8'hff;

assign c16_data=(mux)?.....&free_data;  // C16 data bus

But probably it's not just 0 in real HW, but something left on the bus. Maybe what TED reads for the display?

iszell commented 4 months ago

Hi,

the loader in Giana Sisters is made by me. There was a first version which could go to infinite loop upon reading $fdf1 but that's already fixed, grab the current version from plus/4 world.

As for the real question: when reading unmapped I/O area the read will always return the last value from the data bus. That's usually the high byte of the address read but when TED interrupts the processor between the address read and the memory read to fetch display data it will be the last read byte by TED. So it's "floating" on the real hardware.

ishe commented 4 months ago

Hi, Yes iszell is right. When you read the non used I/O area then you read back the last data byte what was on the data bus. In my C16 wrapper there is a data latch however that is active only when mux is high. When mux is low and I/O space is selected then nothing drives the bus so in real hardware you read back what was on the data bus before, however in my code the line

assign c16_data=(mux)?c16_datalatch:cpu_data&ted_data&ram_data&kernal_data&basic_data&keyport_data;

will provide 0xff on the data bus. This is not exactly what happens in real hardware so what gyurco you recommend is not bad but instead of assigning 8'h0 to it, you should assign the datalatch value to free_data.

Normally however this should not have any impact on software unless as iszell says there was a bug in his code and that freeze the real HW too in some cases.

I might implement this code in C16 and Plus4 wrapper code.

gyurco commented 4 months ago

Thanks for the comments. My final fix was actually this: https://github.com/mist-devel/c16/commit/257b70d6992766da10453338bacbde1a511b1750 (using c16_datalatch for this open area.)

gyurco commented 4 months ago

The openbus_sel condition probably could be improved to 'if nothing else is selected', but it's tricky, as many modules decides internally if it's selected or not.