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
loader:
.incbin "build/loader/loader.bin"
.org 0x1000, 0xFF
.section .text.Reset_Handler
.type Reset_Handler, %function

View File

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

View File

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

View File

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

View File

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

View File

@ -136,7 +136,9 @@ static bool dd_block_read_request (void) {
if (p.sd_mode) {
uint32_t sector_table[DD_SD_SECTOR_TABLE_SIZE];
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);
led_activity_off();
dd_set_block_ready(!error);
} else {
usb_tx_info_t packet_info;
@ -158,7 +160,9 @@ static bool dd_block_write_request (void) {
if (p.sd_mode) {
uint32_t sector_table[DD_SD_SECTOR_TABLE_SIZE];
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);
led_activity_off();
dd_set_block_ready(!error);
} else {
usb_tx_info_t packet_info;

View File

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

View File

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

View File

@ -7,13 +7,13 @@
typedef enum packet_cmd {
PACKET_CMD_BUTTON_TRIGGER = 'B',
PACKET_CMD_DATA_FLUSHED = 'G',
PACKET_CMD_DEBUG_OUTPUT = 'U',
PACKET_CMD_DD_REQUEST = 'D',
PACKET_CMD_ISV_OUTPUT = 'I',
PACKET_CMD_SAVE_WRITEBACK = 'S',
PACKET_CMD_UPDATE_STATUS = 'F',
PACKET_CMD_BUTTON_TRIGGER = 'B',
PACKET_CMD_DATA_FLUSHED = 'G',
PACKET_CMD_DEBUG_OUTPUT = 'U',
PACKET_CMD_DD_REQUEST = 'D',
PACKET_CMD_ISV_OUTPUT = 'I',
PACKET_CMD_SAVE_WRITEBACK = 'S',
PACKET_CMD_UPDATE_STATUS = 'F',
} usb_packet_cmd_e;

View File

@ -82,7 +82,7 @@ static void writeback_save_to_sd (void) {
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) {
writeback_disable();