small fixes

This commit is contained in:
Mateusz Faderewski 2024-01-15 03:59:30 +01:00
parent 7d2ebb873e
commit 980d28d94d
10 changed files with 39 additions and 33 deletions

View File

@ -8,7 +8,7 @@
.type loader, %object .type loader, %object
loader: loader:
.incbin "build/loader/loader.bin" .incbin "build/loader/loader.bin"
.org 0x1000, 0xFF
.section .text.Reset_Handler .section .text.Reset_Handler
.type Reset_Handler, %function .type Reset_Handler, %function

View File

@ -25,7 +25,7 @@ bool button_get_state (void) {
} }
bool button_set_mode (button_mode_t mode) { bool button_set_mode (button_mode_t mode) {
if (mode > BUTTON_MODE_DD_DISK_SWAP) { if (mode >= __BUTTON_MODE_COUNT) {
return true; return true;
} }
p.mode = mode; p.mode = mode;

View File

@ -6,10 +6,11 @@
typedef enum { typedef enum {
BUTTON_MODE_NONE, BUTTON_MODE_NONE = 0,
BUTTON_MODE_N64_IRQ, BUTTON_MODE_N64_IRQ = 1,
BUTTON_MODE_USB_PACKET, BUTTON_MODE_USB_PACKET = 2,
BUTTON_MODE_DD_DISK_SWAP, BUTTON_MODE_DD_DISK_SWAP = 3,
__BUTTON_MODE_COUNT
} button_mode_t; } button_mode_t;

View File

@ -18,25 +18,25 @@
typedef enum { typedef enum {
CFG_ID_BOOTLOADER_SWITCH, CFG_ID_BOOTLOADER_SWITCH = 0,
CFG_ID_ROM_WRITE_ENABLE, CFG_ID_ROM_WRITE_ENABLE = 1,
CFG_ID_ROM_SHADOW_ENABLE, CFG_ID_ROM_SHADOW_ENABLE = 2,
CFG_ID_DD_MODE, CFG_ID_DD_MODE = 3,
CFG_ID_ISV_ADDRESS, CFG_ID_ISV_ADDRESS = 4,
CFG_ID_BOOT_MODE, CFG_ID_BOOT_MODE = 5,
CFG_ID_SAVE_TYPE, CFG_ID_SAVE_TYPE = 6,
CFG_ID_CIC_SEED, CFG_ID_CIC_SEED = 7,
CFG_ID_TV_TYPE, CFG_ID_TV_TYPE = 8,
CFG_ID_DD_SD_ENABLE, CFG_ID_DD_SD_ENABLE = 9,
CFG_ID_DD_DRIVE_TYPE, CFG_ID_DD_DRIVE_TYPE = 10,
CFG_ID_DD_DISK_STATE, CFG_ID_DD_DISK_STATE = 11,
CFG_ID_BUTTON_STATE, CFG_ID_BUTTON_STATE = 12,
CFG_ID_BUTTON_MODE, CFG_ID_BUTTON_MODE = 13,
CFG_ID_ROM_EXTENDED_ENABLE, CFG_ID_ROM_EXTENDED_ENABLE = 14,
} cfg_id_t; } cfg_id_t;
typedef enum { typedef enum {
SETTING_ID_LED_ENABLE, SETTING_ID_LED_ENABLE = 0,
} setting_id_t; } setting_id_t;
typedef enum { typedef enum {
@ -179,7 +179,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_1M) { if (save_type >= __SAVE_TYPE_COUNT) {
return true; return true;
} }

View File

@ -14,6 +14,7 @@ typedef enum {
SAVE_TYPE_FLASHRAM = 4, SAVE_TYPE_FLASHRAM = 4,
SAVE_TYPE_SRAM_BANKED = 5, SAVE_TYPE_SRAM_BANKED = 5,
SAVE_TYPE_SRAM_1M = 6, SAVE_TYPE_SRAM_1M = 6,
__SAVE_TYPE_COUNT
} save_type_t; } save_type_t;

View File

@ -136,7 +136,9 @@ static bool dd_block_read_request (void) {
if (p.sd_mode) { if (p.sd_mode) {
uint32_t sector_table[DD_SD_SECTOR_TABLE_SIZE]; uint32_t sector_table[DD_SD_SECTOR_TABLE_SIZE];
uint32_t sectors = dd_fill_sd_sector_table(index, sector_table, false); uint32_t sectors = dd_fill_sd_sector_table(index, sector_table, false);
led_activity_on();
bool error = sd_optimize_sectors(buffer_address, sector_table, sectors, sd_read_sectors); bool error = sd_optimize_sectors(buffer_address, sector_table, sectors, sd_read_sectors);
led_activity_off();
dd_set_block_ready(!error); dd_set_block_ready(!error);
} else { } else {
usb_tx_info_t packet_info; usb_tx_info_t packet_info;
@ -158,7 +160,9 @@ static bool dd_block_write_request (void) {
if (p.sd_mode) { if (p.sd_mode) {
uint32_t sector_table[DD_SD_SECTOR_TABLE_SIZE]; uint32_t sector_table[DD_SD_SECTOR_TABLE_SIZE];
uint32_t sectors = dd_fill_sd_sector_table(index, sector_table, true); uint32_t sectors = dd_fill_sd_sector_table(index, sector_table, true);
led_activity_on();
bool error = sd_optimize_sectors(buffer_address, sector_table, sectors, sd_write_sectors); bool error = sd_optimize_sectors(buffer_address, sector_table, sectors, sd_write_sectors);
led_activity_off();
dd_set_block_ready(!error); dd_set_block_ready(!error);
} else { } else {
usb_tx_info_t packet_info; usb_tx_info_t packet_info;

View File

@ -169,7 +169,7 @@ static bool lcmxo2_wait_busy (void) {
uint32_t status; uint32_t status;
do { do {
status = lcmxo2_read_status(); status = lcmxo2_read_status();
} while(status & LSC_STATUS_BUSY); } while (status & LSC_STATUS_BUSY);
return (status & LSC_STATUS_FAIL); return (status & LSC_STATUS_FAIL);
} }

View File

@ -21,7 +21,7 @@ static void timer_update (void) {
} }
if (timer[id].pending) { if (timer[id].pending) {
timer[id].pending = false; timer[id].pending = false;
} else if(timer[id].value == 0) { } else if (timer[id].value == 0) {
timer[id].running = false; timer[id].running = false;
} }
} }

View File

@ -82,7 +82,7 @@ static void writeback_save_to_sd (void) {
return; return;
} }
bool error = sd_optimize_sectors(address, p.sectors, length / SD_SECTOR_SIZE, sd_write_sectors); bool error = sd_optimize_sectors(address, p.sectors, (length / SD_SECTOR_SIZE), sd_write_sectors);
if (error) { if (error) {
writeback_disable(); writeback_disable();