diff --git a/gargoylesquest.gb b/gargoylesquest.gb new file mode 100644 index 0000000..9616f7e Binary files /dev/null and b/gargoylesquest.gb differ diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..17d80f5 --- /dev/null +++ b/main.cpp @@ -0,0 +1,9 @@ +#include "sm83.h" +#include "mem.h" + +int main(int argc, char *argv[]) +{ + mem::init(nullptr, 0); + + return 0; +} \ No newline at end of file diff --git a/mem.cpp b/mem.cpp index a45c48f..1096581 100644 --- a/mem.cpp +++ b/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) - { - - } - } diff --git a/mem.h b/mem.h index afc2000..06553a0 100644 --- a/mem.h +++ b/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); } diff --git a/pokemonred.gb b/pokemonred.gb new file mode 100644 index 0000000..c602e6c Binary files /dev/null and b/pokemonred.gb differ diff --git a/sm83.cpp b/sm83.cpp index 57d8fbc..8cfcf5b 100644 --- a/sm83.cpp +++ b/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; } diff --git a/supermarioland.gb b/supermarioland.gb new file mode 100644 index 0000000..4b7dca3 Binary files /dev/null and b/supermarioland.gb differ