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.

32 lines
591 B

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