From f24b01fa9967873e575a56541c9dc7fd4a32eb45 Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Mon, 19 Jul 2021 14:43:22 +0100 Subject: Misc: Load roms after 0x200 --- chip8_emulator.core | Bin 0 -> 314704 bytes emulator.c | 3 ++- emulator.h | 6 +++++- main.c | 4 ++-- 4 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 chip8_emulator.core diff --git a/chip8_emulator.core b/chip8_emulator.core new file mode 100644 index 0000000..4e75aa7 Binary files /dev/null and b/chip8_emulator.core differ diff --git a/emulator.c b/emulator.c index afc78b1..699999c 100644 --- a/emulator.c +++ b/emulator.c @@ -13,7 +13,8 @@ int emulator_load_rom(Emulator* emulator, char* rom_name) struct stat st; fstat(fileno(rom), &st); - int bytes_read = fread(emulator->memory, 1, st.st_size, rom); + //rom loaded after 0x200 into memory + int bytes_read = fread(emulator->memory + 0x200, 1, st.st_size, rom); if(bytes_read != st.st_size) { perror("doesnt cuadrar\n"); diff --git a/emulator.h b/emulator.h index c8114cb..b685bea 100644 --- a/emulator.h +++ b/emulator.h @@ -23,13 +23,17 @@ typedef struct uint8_t VD; uint8_t VE; uint8_t VF; //flag register + + uint16_t I; // index register } Registers; typedef struct { uint8_t is_on; - uint16_t pc; + uint16_t pc; //program counter Registers regs; + uint8_t sp; //stack pointer + uint16_t stack[16]; uint8_t memory[4096]; } Emulator; diff --git a/main.c b/main.c index 53dd85c..48d35ee 100644 --- a/main.c +++ b/main.c @@ -21,12 +21,12 @@ int main(int argc, char** argv) printf("Hello brother!\n"); - /*for(int i = 0; i < sizeof(emulator.memory); ++i) + for(int i = 0; i < sizeof(emulator.memory); ++i) { printf("%c ", emulator.memory[i]); } - putchar('\n');*/ + putchar('\n'); while(emulator.is_on) { -- cgit 1.4.1