static void mem_config_set(unsigned int config) { mem_config = config; if (watchpoints_active) { _mem_read_tab_ptr = mem_read_tab_watch; _mem_write_tab_ptr = mem_write_tab_watch; } else { _mem_read_tab_ptr = mem_read_tab[mem_config]; _mem_write_tab_ptr = mem_write_tab[mem_config]; } _mem_read_base_tab_ptr = mem_read_base_tab[mem_config]; mem_read_limit_tab_ptr = mem_read_limit_tab[mem_config]; maincpu_resync_limits(); }
void petdww_override_std_9toa(read_func_ptr_t *mem_read_tab, store_func_ptr_t *mem_write_tab, BYTE **mem_base_tab, int *mem_limit_tab) { int i; /* Check this just in case */ if (petres.superpet) { return; } /* * Check if this was already done. * FIXME: What if something else also overrides these entries? */ if (mem_read_tab[0x90] == dww_ram9000_read) { #if DWW_DEBUG_RAM log_message(petdww_log, "petdww_override_std_9toa: override already done"); #endif return; } #if DWW_DEBUG_RAM if (!mem_at_9000) { log_message(petdww_log, "petdww_override_std_9toa: ERROR: memory not mapped here"); return; } #endif #if DWW_DEBUG_RAM log_message(petdww_log, "petdww_override_std_9toa"); #endif /* Setup my RAM at $9000 - $AFFF. */ for (i = 0x90; i < 0xb0; i++) { save_mem_read_tab[i - 0x90] = mem_read_tab[i]; save_mem_write_tab[i - 0x90] = mem_write_tab[i]; save_mem_base_tab[i - 0x90] = mem_base_tab[i]; save_mem_limit_tab[i - 0x90] = mem_limit_tab[i]; mem_read_tab[i] = dww_ram9000_read; mem_write_tab[i] = dww_ram9000_store; mem_base_tab[i] = &petdww_ram[(i - 0x90) << 8]; mem_limit_tab[i] = 0xaffd; } maincpu_resync_limits(); }
void cbm2mem_set_bank_exec(int val) { int i; val &= 0x0f; if (val != cbm2mem_bank_exec) { cbm2mem_bank_exec = val; _mem_read_tab_ptr = _mem_read_tab[cbm2mem_bank_exec]; _mem_write_tab_ptr = _mem_write_tab[cbm2mem_bank_exec]; _mem_read_base_tab_ptr = _mem_read_base_tab[cbm2mem_bank_exec]; mem_read_limit_tab_ptr = mem_read_limit_tab[(cbm2mem_bank_exec < 15) ? 0 : 1]; if (!_mem_read_base_tab_ptr[0]) { /* disable fast opcode fetch when bank_base is null, i.e. set all limits to 0 when no RAM available. This might also happen when jumping to open mem in bank 15, though. */ mem_read_limit_tab_ptr = mem_read_limit_tab[2]; } maincpu_resync_limits(); /* set all register mirror locations */ for (i = 0; i < 16; i++) { mem_ram[i << 16] = val; } mem_page_zero = _mem_read_base_tab_ptr[0]; mem_page_one = _mem_read_base_tab_ptr[1]; /* This sets the pointers to otherwise non-mapped memory, to avoid that the CPU code uses illegal memory and segfaults. */ if (!mem_page_zero) { mem_page_zero = mem_ram + 0xf0000; } if (!mem_page_one) { mem_page_one = mem_ram + 0xf0100; } } }
void petdww_restore_std_9toa(read_func_ptr_t *mem_read_tab, store_func_ptr_t *mem_write_tab, BYTE **mem_base_tab, int *mem_limit_tab) { int i; /* Check if this was already done */ if (mem_read_tab[0x90] == dww_ram9000_read) { #if DWW_DEBUG_RAM log_message(petdww_log, "petdww_restore_std_9toa"); #endif /* Restore access to memory at $9000 - $AFFF. */ for (i = 0x90; i < 0xb0; i++) { mem_read_tab[i] = save_mem_read_tab[i - 0x90]; mem_write_tab[i] = save_mem_write_tab[i - 0x90]; mem_base_tab[i] = save_mem_base_tab[i - 0x90]; mem_limit_tab[i] = save_mem_limit_tab[i - 0x90]; } maincpu_resync_limits(); } #if DWW_DEBUG_RAM else { log_message(petdww_log, "petdww_restore_std_9toa: no need to restore"); } #endif }