fx9860-emulator-playground/fx9860-emulator/headers/memory.h

45 lines
1.0 KiB
C

#pragma once
#include "main.h"
#define ROM_START 0x00300000
#define RAM_START_MMU_ALIAS 0x08100000
#define RAM_START 0x8801c000 // 0x88048000 on 35+E II
#define XRAM_START 0xe5007000
#define YRAM_START 0xe5017000
#define ILRAM_START 0xe5200000
#define ROM_SIZE (2048 * 1024)
#define RAM_SIZE (512 * 1024)
#define XRAM_SIZE (8 * 1024)
#define YRAM_SIZE (8 * 1024)
#define ILRAM_SIZE (4 * 1024)
typedef struct{
uint32_t size;
uint32_t addr;
} malloc_info_t;
// MEMORY
struct memory_t {
uint8_t* rom; // Read-only memory
uint32_t rom_size;
uint8_t ram[RAM_SIZE]; // Random-access memory
// uint8_t xram[XRAM_SIZE];
// uint8_t yram[YRAM_SIZE];
// uint8_t ilram[ILRAM_SIZE];
// Malloc
int mallocCount;
malloc_info_t* mallocs;
};
uint8_t* get_memory_for_address(cpu_t* cpu, uint32_t address);
uint32_t mem_read(cpu_t* cpu, uint32_t address, uint8_t bytes);
void mem_write(cpu_t* cpu, uint32_t address, uint32_t data, uint8_t bytes);