- Planificant els mapejadors de memòria

- Afegits supermarioland, gargoylesquest i pokemonred per a provar diferents mapejadors
This commit is contained in:
2025-01-14 17:02:07 +01:00
parent f766c40cc7
commit add6562575
7 changed files with 53 additions and 29 deletions

BIN
gargoylesquest.gb Normal file

Binary file not shown.

9
main.cpp Normal file
View File

@@ -0,0 +1,9 @@
#include "sm83.h"
#include "mem.h"
int main(int argc, char *argv[])
{
mem::init(nullptr, 0);
return 0;
}

43
mem.cpp
View File

@@ -3,20 +3,37 @@
namespace mem namespace mem
{ {
uint8_t(*readMem)(uint16_t);
void (*writeMem)(uint16_t, uint8_t);
char *title = nullptr; char *title = nullptr;
uint8_t *memory = nullptr; /*uint8_t *memory = nullptr;
uint8_t *mapper_type = nullptr; uint8_t *mapper_type = nullptr;
uint8_t *rom_size = nullptr; uint8_t *rom_size = nullptr;
uint8_t *ram_size = nullptr; uint8_t *ram_size = nullptr;*/
uint8_t r(uint16_t address)
{
return 0;
}
void w(uint16_t address, uint8_t value)
{
}
void init(const uint8_t* rom, const int size) void init(const uint8_t* rom, const int size)
{ {
if (memory) free(memory); //if (memory) free(memory);
memory = (uint8_t*)malloc(size); //memory = (uint8_t*)malloc(size);
title = (char*)&memory[0x134]; title = (char*)&rom[0x134];
mapper_type = &memory[0x147]; uint8_t mapper_type = rom[0x147];
rom_size = &memory[0x148]; uint32_t rom_size = 32768 * (1 << rom[0x148]);
ram_size = &memory[0x149]; int sizes[] = { 0, 0, 8, 32, 128, 64};
uint32_t ram_size = sizes[rom[0x149]] * 1024;
readMem = r;
writeMem = w;
} }
void reset() void reset()
@@ -24,14 +41,4 @@ namespace mem
} }
uint8_t readMem(uint16_t address)
{
}
void writeMem(uint16_t address, uint8_t value)
{
}
} }

12
mem.h
View File

@@ -3,10 +3,16 @@
namespace mem namespace mem
{ {
#define MAPPER_NONE 0 #define MBC_NONE 0
#define MBC1 1
#define MBC2 2
#define MBC3 3
#define MBC5 5
#define MBC6 6
#define MBC7 7
void init(const uint8_t* rom, const int size); void init(const uint8_t* rom, const int size);
void reset(); void reset();
uint8_t readMem(uint16_t address); extern uint8_t(*readMem)(uint16_t);
void writeMem(uint16_t address, uint8_t value); extern void (*writeMem)(uint16_t, uint8_t);
} }

BIN
pokemonred.gb Normal file

Binary file not shown.

View File

@@ -473,6 +473,8 @@ namespace sm83
} }
} }
void DI();
void processInterrupts() void processInterrupts()
{ {
const uint8_t IF = mem::readMem(0xff0f); const uint8_t IF = mem::readMem(0xff0f);
@@ -679,6 +681,14 @@ namespace sm83
//if (options[Z80_OPTION_STOP_ON_INVALID]) z80debug::stop(); //if (options[Z80_OPTION_STOP_ON_INVALID]) z80debug::stop();
} }
bool opcode_ignored = false;
void IgnoreOpcode()
{
t-=3;
rPC--;
opcode_ignored=true;
}
void reset() void reset()
{ {
mem::reset(); mem::reset();
@@ -700,7 +710,6 @@ namespace sm83
void BIT_INSTRUCTIONS(); void BIT_INSTRUCTIONS();
bool opcode_ignored = false;
uint32_t step() uint32_t step()
{ {
do { do {
@@ -1285,13 +1294,6 @@ namespace sm83
} }
} }
void IgnoreOpcode()
{
t-=3;
rPC--;
opcode_ignored=true;
}
//uint8_t *getMem() { return memory; } //uint8_t *getMem() { return memory; }
uint8_t *getRegs() { return regs; } uint8_t *getRegs() { return regs; }

BIN
supermarioland.gb Normal file

Binary file not shown.