- Planificant els mapejadors de memòria
- Afegits supermarioland, gargoylesquest i pokemonred per a provar diferents mapejadors
This commit is contained in:
BIN
gargoylesquest.gb
Normal file
BIN
gargoylesquest.gb
Normal file
Binary file not shown.
9
main.cpp
Normal file
9
main.cpp
Normal 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
43
mem.cpp
@@ -3,20 +3,37 @@
|
||||
|
||||
namespace mem
|
||||
{
|
||||
uint8_t(*readMem)(uint16_t);
|
||||
void (*writeMem)(uint16_t, uint8_t);
|
||||
|
||||
char *title = nullptr;
|
||||
uint8_t *memory = nullptr;
|
||||
/*uint8_t *memory = nullptr;
|
||||
uint8_t *mapper_type = 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)
|
||||
{
|
||||
if (memory) free(memory);
|
||||
memory = (uint8_t*)malloc(size);
|
||||
title = (char*)&memory[0x134];
|
||||
mapper_type = &memory[0x147];
|
||||
rom_size = &memory[0x148];
|
||||
ram_size = &memory[0x149];
|
||||
//if (memory) free(memory);
|
||||
//memory = (uint8_t*)malloc(size);
|
||||
title = (char*)&rom[0x134];
|
||||
uint8_t mapper_type = rom[0x147];
|
||||
uint32_t rom_size = 32768 * (1 << rom[0x148]);
|
||||
int sizes[] = { 0, 0, 8, 32, 128, 64};
|
||||
uint32_t ram_size = sizes[rom[0x149]] * 1024;
|
||||
|
||||
readMem = r;
|
||||
writeMem = w;
|
||||
}
|
||||
|
||||
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
12
mem.h
@@ -3,10 +3,16 @@
|
||||
|
||||
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 reset();
|
||||
uint8_t readMem(uint16_t address);
|
||||
void writeMem(uint16_t address, uint8_t value);
|
||||
extern uint8_t(*readMem)(uint16_t);
|
||||
extern void (*writeMem)(uint16_t, uint8_t);
|
||||
}
|
||||
|
||||
BIN
pokemonred.gb
Normal file
BIN
pokemonred.gb
Normal file
Binary file not shown.
18
sm83.cpp
18
sm83.cpp
@@ -473,6 +473,8 @@ namespace sm83
|
||||
}
|
||||
}
|
||||
|
||||
void DI();
|
||||
|
||||
void processInterrupts()
|
||||
{
|
||||
const uint8_t IF = mem::readMem(0xff0f);
|
||||
@@ -679,6 +681,14 @@ namespace sm83
|
||||
//if (options[Z80_OPTION_STOP_ON_INVALID]) z80debug::stop();
|
||||
}
|
||||
|
||||
bool opcode_ignored = false;
|
||||
void IgnoreOpcode()
|
||||
{
|
||||
t-=3;
|
||||
rPC--;
|
||||
opcode_ignored=true;
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
mem::reset();
|
||||
@@ -700,7 +710,6 @@ namespace sm83
|
||||
|
||||
void BIT_INSTRUCTIONS();
|
||||
|
||||
bool opcode_ignored = false;
|
||||
uint32_t step()
|
||||
{
|
||||
do {
|
||||
@@ -1285,13 +1294,6 @@ namespace sm83
|
||||
}
|
||||
}
|
||||
|
||||
void IgnoreOpcode()
|
||||
{
|
||||
t-=3;
|
||||
rPC--;
|
||||
opcode_ignored=true;
|
||||
}
|
||||
|
||||
//uint8_t *getMem() { return memory; }
|
||||
uint8_t *getRegs() { return regs; }
|
||||
|
||||
|
||||
BIN
supermarioland.gb
Normal file
BIN
supermarioland.gb
Normal file
Binary file not shown.
Reference in New Issue
Block a user