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.

29 lines
559 B

  1. #include "cpu.h"
  2. static uint32_t translate_addr(uint32_t addr)
  3. {
  4. if (addr >= 0xA0000000)
  5. {
  6. addr = addr - 0xA0000000;
  7. }
  8. else if (addr >= 0x80000000)
  9. {
  10. addr = addr - 0x80000000;
  11. }
  12. return addr;
  13. }
  14. void cpu_write32(cpu_t *cpu, uint32_t addr, uint32_t x)
  15. {
  16. printf("WRITE: %08x to %08x\n", x, addr);
  17. addr = translate_addr(addr);
  18. cpu->main_ram[addr] = x;
  19. }
  20. uint32_t cpu_read32(cpu_t *cpu, uint32_t addr)
  21. {
  22. printf("READ: %08x\n", addr);
  23. addr = translate_addr(addr);
  24. return cpu->main_ram[addr];
  25. }