-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow save games in nestang core #78
Comments
It's already enabled. You need r0.10 and to allow it from the options. I tested it on Edit: after a power cycle, saves are gone ⚠ |
It creates the snestang.ini (even on the nestang core it is named snestang.ini) and when i load the snestang core it saves everything perfectly fine in the saves directory, but the functionality is not there on the nestang core (to survive the power cycle). |
RAM backups are not implemented yet. It requires some changes to sdram_nes.v to allow RV to access CPU/PPU memory. |
What exactly are the necessary changes? I was trying to work on this one and then I realised exactly that, RV doesn't have access to NES RAM. I thought about backing up 0x6000-0x8000 in a local bram block inside My idea was that, when RV was reading from 0x6000-0x8000, then sdram module would output the info saved in the BRAM block. If RV is writing into that range (load from sd card) then add some logic for the NES part of sdram controller to allow it |
BSRAM backup in snestang is easy because both RV and BSRAM uses the same memory bank (bank 1), with BSRAM access from CPU taking precedence: if (bsram_req ^ bsram_req_ack) begin
next_port[0] = PORT_BSRAM;
next_addr[0] = { 5'b01_111, bsram_addr }; // BSRAM at start of 7MB bank 1
next_din[0] = { bsram_din, bsram_din };
next_ds[0] = {bsram_addr[0], ~bsram_addr[0]};
next_we[0] = bsram_we;
next_oe[0] = ~bsram_we;
end else if (rv_req ^ rv_req_ack) begin // RV uses bank 1 and has lowest priority
next_port[0] = PORT_RV;
next_addr[0] = { 2'b01, rv_addr, 1'b0 };
next_we[0] = rv_we;
next_oe[0] = ~rv_we;
next_din[0] = rv_din;
next_ds[0] = rv_ds;
end So BSRAM automatically maps to
The nice thing about this design is that as RV already has lower-priority than CPU, its access never conflicts with the CPU. So backup/restore is done silently in the background. Nestang's sdram_nes.v currently puts CPU and PPU memory in a single large 4MB space, using bank 0 and 1. BSRAM is some where in it, depending on the mapper (I haven't really looked at the details yet). RV is using bank 2. So RV does not have access to BSRAM now, without stopping the CPU first. There are multiple ways we can do this. But one would be to separate out BSRAM from the 4MB block, and put it in the RV bank (bank 2). Then adds logic to make RV access lower priority, similar to snestang's memory controller. Then we can probably reuse the firmware logic to save and restore the bsram. |
Another way (probably easier if performance turns out ok), is to let the memory layout stay the same, then simply make RV access lower priority than CPU (thus making the memory controller single-channel). This way, whenever RV is accessing memory, the CPU is not. Then we are free to change the address lines for RV to directly access the BSRAM content. |
So I actually tried to have CPU/PPU and RISC-V in the same bank: Bank0/1. I did the changes in fjpolo/WRAM branch but I wasn't able to boot RV yet, there's no menu booting up, so I might be missing something in the logic, or in the Fw (I didn't change anything in the Fw). Would you mind taking a look? There's no actual rush, so only if you've got some spare time :) |
This works in the snestang core, can it be ported to the nestang core to allow for saves to be enabled.
The text was updated successfully, but these errors were encountered: