save bug fixes

This commit is contained in:
Mateusz Faderewski 2023-06-25 23:56:55 +02:00
parent 3fdad1ef61
commit 885015ba75
5 changed files with 38 additions and 24 deletions

View File

@ -5,7 +5,7 @@
## N64 commands ## N64 commands
| id | name | arg0 | arg1 | rsp0 | rsp1 | description | | id | name | arg0 | arg1 | rsp0 | rsp1 | description |
| --- | --------------------- | ---------- | ------------ | ---------------- | -------------- | -------------------------------------------------- | | --- | --------------------- | -------------- | ------------ | ---------------- | -------------- | ---------------------------------------------------------- |
| `v` | **IDENTIFIER_GET** | --- | --- | identifier | --- | Get flashcart identifier `SCv2` | | `v` | **IDENTIFIER_GET** | --- | --- | identifier | --- | Get flashcart identifier `SCv2` |
| `V` | **VERSION_GET** | --- | --- | version | --- | Get flashcart firmware version | | `V` | **VERSION_GET** | --- | --- | version | --- | Get flashcart firmware version |
| `c` | **CONFIG_GET** | config_id | --- | --- | current_value | Get config option | | `c` | **CONFIG_GET** | config_id | --- | --- | current_value | Get config option |
@ -23,6 +23,7 @@
| `s` | **SD_READ** | pi_address | sector_count | --- | --- | Read sectors from SD card to flashcart | | `s` | **SD_READ** | pi_address | sector_count | --- | --- | Read sectors from SD card to flashcart |
| `S` | **SD_WRITE** | pi_address | sector_count | --- | --- | Write sectors from flashcart to SD card | | `S` | **SD_WRITE** | pi_address | sector_count | --- | --- | Write sectors from flashcart to SD card |
| `D` | **DD_SD_INFO** | pi_address | table_size | --- | --- | Set 64DD disk SD sector info | | `D` | **DD_SD_INFO** | pi_address | table_size | --- | --- | Set 64DD disk SD sector info |
| `w` | **WRITEBACK_PENDING** | pending_status | --- | --- | --- | Get save writeback status (is write queued to the SD card) |
| `W` | **WRITEBACK_SD_INFO** | pi_address | --- | --- | --- | Load writeback SD sector table and enable it | | `W` | **WRITEBACK_SD_INFO** | pi_address | --- | --- | --- | Load writeback SD sector table and enable it |
| `K` | **FLASH_PROGRAM** | pi_address | length | --- | --- | Program flash with bytes loaded into data buffer | | `K` | **FLASH_PROGRAM** | pi_address | length | --- | --- | Program flash with bytes loaded into data buffer |
| `p` | **FLASH_WAIT_BUSY** | wait | --- | erase_block_size | --- | Wait until flash ready / get block erase size | | `p` | **FLASH_WAIT_BUSY** | wait | --- | erase_block_size | --- | Wait until flash ready / get block erase size |

View File

@ -178,7 +178,7 @@ static void cfg_change_scr_bits (uint32_t mask, bool value) {
} }
static bool cfg_set_save_type (save_type_t save_type) { static bool cfg_set_save_type (save_type_t save_type) {
if (save_type > SAVE_TYPE_SRAM_BANKED) { if (save_type > SAVE_TYPE_SRAM_1M) {
return true; return true;
} }
@ -639,6 +639,10 @@ void cfg_process (void) {
dd_set_sd_info(args[0], args[1]); dd_set_sd_info(args[0], args[1]);
break; break;
case 'w':
args[0] = writeback_pending();
break;
case 'W': case 'W':
if (cfg_translate_address(&args[0], WRITEBACK_SECTOR_TABLE_SIZE, (SDRAM | BRAM))) { if (cfg_translate_address(&args[0], WRITEBACK_SECTOR_TABLE_SIZE, (SDRAM | BRAM))) {
cfg_set_error(CFG_ERROR_BAD_ADDRESS); cfg_set_error(CFG_ERROR_BAD_ADDRESS);

View File

@ -424,6 +424,10 @@ bool sd_read_sectors (uint32_t address, uint32_t sector, uint32_t count) {
return true; return true;
} }
if (p.byte_swap && ((address % 2) != 0)) {
return true;
}
if (!p.card_type_block) { if (!p.card_type_block) {
sector *= SD_SECTOR_SIZE; sector *= SD_SECTOR_SIZE;
} }

View File

@ -124,6 +124,10 @@ void writeback_disable (void) {
timer_set(TIMER_ID_WRITEBACK, 0); timer_set(TIMER_ID_WRITEBACK, 0);
} }
bool writeback_pending (void) {
return p.enabled && p.pending;
}
void writeback_init (void) { void writeback_init (void) {
p.enabled = false; p.enabled = false;
p.pending = false; p.pending = false;

View File

@ -18,6 +18,7 @@ typedef enum {
void writeback_load_sector_table (uint32_t address); void writeback_load_sector_table (uint32_t address);
void writeback_enable (writeback_mode_t mode); void writeback_enable (writeback_mode_t mode);
void writeback_disable (void); void writeback_disable (void);
bool writeback_pending (void);
void writeback_init (void); void writeback_init (void);
void writeback_process (void); void writeback_process (void);