- Treballant en el mbc_none

This commit is contained in:
2025-01-15 07:34:12 +01:00
parent add6562575
commit 0c97143b22
2 changed files with 62 additions and 0 deletions

56
mbc_none.cpp Normal file
View File

@@ -0,0 +1,56 @@
#include "mbc_none.h"
#include "mem.h"
namespace mbc_none
{
uint8_t bootrom[256];
uint8_t *rom;
uint8_t vram[8192];
uint8_t exram[8192];
uint8_t wram[8192];
uint8_t hram[512];
uint8_t readMem(uint16_t address)
{
if (address < 0x8000) {
if ( (address < 0x0100) && ((hram[0x150]&0x01)==0) ) return bootrom[address];
return rom[address];
} else if (address < 0xA000) {
return vram[address - 0x8000];
} else if (address < 0xC000) {
return exram[address - 0xA000];
} else if (address < 0xE000) {
return wram[address - 0xC000];
} else if (address < 0xFE00) {
return wram[address - 0xE000];
} else {
return hram[address - 0XFE00];
}
}
void writeMem(uint16_t address, uint8_t value)
{
if (address < 0x8000) {
// Read Only Memory, you know...
//rom[address] = value;
} else if (address < 0xA000) {
vram[address - 0x8000] = value;
} else if (address < 0xC000) {
exram[address - 0xA000] = value;
} else if (address < 0xE000) {
wram[address - 0xC000] = value;
} else if (address < 0xFE00) {
wram[address - 0xE000] = value;
} else {
if ( (address==0xFF50) && ((value&0x01) != 1) ) return; //Only allow disabling boot room
hram[address - 0xFE00] = value;
}
}
void init(uint8_t *rom)
{
mem::readMem = mbc_none::readMem;
mem::writeMem = mbc_none::writeMem;
mbc_none::rom = rom;
}
}

6
mbc_none.h Normal file
View File

@@ -0,0 +1,6 @@
#pragma once
namespace mbc_none
{
void init();
}