diff --git a/hdrs/cpu.h b/hdrs/cpu.h new file mode 100644 index 0000000..e9f2bfc --- /dev/null +++ b/hdrs/cpu.h @@ -0,0 +1,27 @@ +#ifndef CPU_H +#define CPU_H + +#include + +typedef struct s_cpu +{ + uint8_t a; // Accumulator register + uint8_t f; // Flags register (Z, N, H, C) + uint8_t b; // General-purpose register B + uint8_t c; // General-purpose register C + uint8_t d; // General-purpose register D + uint8_t e; // General-purpose register E + uint8_t h; // General-purpose register H + uint8_t l; // General-purpose register L + + uint16_t sp; // Stack pointer + uint16_t pc; // Program counter + + uint8_t ime; // Interrupt Master Enable flag + uint8_t halted; // Halted state flag + uint8_t stopped; // Stopped state flag +} t_cpu; + +void cpu_init(t_cpu *cpu); + +#endif CPU_H \ No newline at end of file diff --git a/hdrs/memory.h b/hdrs/memory.h new file mode 100644 index 0000000..b017f71 --- /dev/null +++ b/hdrs/memory.h @@ -0,0 +1,16 @@ +#ifndef MEMORY_H +#define MEMORY_H + +#include + +typedef struct s_memory +{ + uint8_t wram[0x2000]; // Working RAM (0xC000 - 0xDFFF), 8KB + uint8_t vram[0x2000]; // Video RAM (0x8000 - 0x9FFF), 8KB +} t_memory; + +void memory_init(t_memory *memory); +uint8_t memory_read(t_memory *memory, uint16_t address); +void memory_write(t_memory *memory, uint16_t address, uint8_t value); + +#endif \ No newline at end of file diff --git a/hdrs/zboy.h b/hdrs/zboy.h new file mode 100644 index 0000000..5970a7c --- /dev/null +++ b/hdrs/zboy.h @@ -0,0 +1,11 @@ +#include "cpu.h" +#include "memory.h" + + +typedef struct zboy +{ + t_cpu cpu; + t_memory memory; +}; + +void zboy_init(); \ No newline at end of file