Improve game boot compatibility

This commit is contained in:
Mateusz Faderewski 2023-09-06 00:49:06 +02:00
parent 5ef09def69
commit b15be6467b
4 changed files with 27 additions and 13 deletions

View File

@ -87,7 +87,23 @@ void boot (boot_params_t *params) {
while (!(cpu_io_read(&SP->SR) & SP_SR_HALT));
cpu_io_write(&SP->SR, SP_SR_CLR_INTR | SP_SR_SET_HALT);
cpu_io_write(&SP->SR,
SP_SR_CLR_SIG7 |
SP_SR_CLR_SIG6 |
SP_SR_CLR_SIG5 |
SP_SR_CLR_SIG4 |
SP_SR_CLR_SIG3 |
SP_SR_CLR_SIG2 |
SP_SR_CLR_SIG1 |
SP_SR_CLR_SIG0 |
SP_SR_CLR_INTR_BREAK |
SP_SR_CLR_SSTEP |
SP_SR_CLR_INTR |
SP_SR_CLR_BROKE |
SP_SR_SET_HALT
);
cpu_io_write(&SP->SEMAPHORE, 0);
cpu_io_write(&SP->PC, 0);
while (cpu_io_read(&SP->DMA_BUSY));

View File

@ -37,6 +37,8 @@ typedef struct {
io32_t DMA_FULL;
io32_t DMA_BUSY;
io32_t SEMAPHORE;
io32_t __reserved[0xFFF8];
io32_t PC;
} sp_regs_t;
#define SP_BASE (0x04040000UL)

View File

@ -68,8 +68,6 @@ reset_rdram:
1:
addiu $t2, (-1)
bnez $t2, 1b
mtc0 $zero, $9
reset_rdram_skip:
prepare_registers:
@ -110,7 +108,7 @@ ra_values:
.set ra_table, REBOOT_ADDRESS + (. - reboot_start)
.word 0xA4001554
.word 0xA4001550
.word 0xA4001550 # TODO: Figure out address for MPAL console
.word 0xA4001554
.set reboot_size, (. - reboot_start)
.global reboot_size

View File

@ -29,7 +29,6 @@
static menu_t *menu;
static bool boot_pending;
static tv_type_t tv_type;
static volatile int frame_counter = 0;
@ -62,8 +61,6 @@ static void menu_init (boot_params_t *boot_params) {
fonts_init();
sound_init_default();
boot_pending = false;
menu = calloc(1, sizeof(menu_t));
assert(menu != NULL);
@ -148,7 +145,7 @@ static struct views_s {
void menu_run (boot_params_t *boot_params) {
menu_init(boot_params);
while (!boot_pending && (exception_reset_time() < RESET_TIME_LENGTH)) {
while (exception_reset_time() < RESET_TIME_LENGTH) {
surface_t *display = (frame_counter >= FRAMERATE_DIVIDER) ? display_try_get() : NULL;
if (display != NULL) {
@ -160,7 +157,12 @@ void menu_run (boot_params_t *boot_params) {
views[menu->mode].show(menu, display);
} else {
rdpq_attach_clear(display, NULL);
rdpq_detach_show();
rdpq_detach_wait();
display_show(display);
}
if (menu->mode == MENU_MODE_BOOT) {
break;
}
while (menu->mode != menu->next_mode) {
@ -169,10 +171,6 @@ void menu_run (boot_params_t *boot_params) {
if (views[menu->mode].init) {
views[menu->mode].init(menu);
}
if (menu->mode == MENU_MODE_BOOT) {
boot_pending = true;
}
}
time(&menu->current_time);