psx emulator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

27 lines
594 B

#include "cpu.h"
#include <stdio.h>
#include "log.h"
static uint32_t translate_addr(uint32_t addr) {
if (addr >= 0xA0000000) {
addr = addr - 0xA0000000;
} else if (addr >= 0x80000000) {
addr = addr - 0x80000000;
}
return addr;
}
void cpu_write32(cpu_t *cpu, uint32_t addr, uint32_t x) {
debug("Write [%08x] = %08x", addr, x);
addr = translate_addr(addr);
cpu->main_ram[addr] = x;
}
uint32_t cpu_read32(cpu_t *cpu, uint32_t addr) {
debug("Read [%08x]", addr);
addr = translate_addr(addr);
return *(uint32_t *)&cpu->main_ram[addr];
}