/* * SD2SNES menu loop. * monitors menu selection. return when selection was made. */ uint8_t menu_main_loop() { uint8_t cmd = 0; sram_writebyte(0, SRAM_CMD_ADDR); while(!cmd) { if(!get_snes_reset()) { while(!sram_reliable())printf("hurr\n"); cmd = sram_readbyte(SRAM_CMD_ADDR); } if(get_snes_reset()) { cmd = 0; } sleep_ms(20); cli_entrycheck(); } return cmd; }
void prepare_reset() { snes_reset(1); delay_ms(1); if(romprops.ramsize_bytes && fpga_test() == FPGA_TEST_TOKEN) { writeled(1); save_sram(file_lfn, romprops.ramsize_bytes, SRAM_SAVE_ADDR); writeled(0); } rdyled(1); readled(1); writeled(1); snes_reset(0); while(get_snes_reset()); snes_reset(1); fpga_dspx_reset(1); delay_ms(200); }
/* Systick interrupt handler */ void SysTick_Handler(void) { ticks++; static int warmup = 0; static uint16_t sdch_state = 0; static uint16_t reset_state = 0; sdch_state = (sdch_state << 1) | SDCARD_DETECT | 0xe000; if(warmup > WARMUP_TICKS && ((sdch_state == 0xf000) || (sdch_state == 0xefff))) { sd_changed = 1; } reset_state = (reset_state << 1) | get_snes_reset() | 0xe000; if((reset_state == 0xf000) || (reset_state == 0xefff)) { reset_pressed = (reset_state == 0xf000); reset_changed = 1; } led_error(); sdn_changed(); SysTick_Hook(); if(warmup <= WARMUP_TICKS) warmup++; }
uint32_t calc_sram_crc(uint32_t base_addr, uint32_t size) { uint8_t data; uint32_t count; uint32_t crc; crc=0; crc_valid=1; set_mcu_addr(base_addr); FPGA_SELECT(); FPGA_TX_BYTE(0x88); for(count=0; count<size; count++) { FPGA_WAIT_RDY(); data = FPGA_RX_BYTE(); if(get_snes_reset()) { crc_valid = 0; break; } crc += crc32_update(crc, data); } FPGA_DESELECT(); return crc; }
int msu1_check_reset(void) { static tick_t rising_ticks; static uint8_t resbutton=0, resbutton_prev=0; int result = MSU_RESET_NONE; resbutton = get_snes_reset(); if(resbutton && !resbutton_prev) { /* push */ rising_ticks = getticks(); } else if(resbutton && resbutton_prev) { /* hold */ if(getticks() > rising_ticks + 99) { result = MSU_RESET_LONG; } } else if(!resbutton && resbutton_prev) { /* release */ if(getticks() < rising_ticks + 99) { result = MSU_RESET_SHORT; } } else { result = MSU_RESET_NONE; } resbutton_prev = resbutton; return result; }