feat: added cpu.h, memory.h and zboy.h

This commit is contained in:
Zoëy Noort 2025-05-11 19:54:10 +02:00
parent 16b355f92b
commit 32a2eab015
3 changed files with 54 additions and 0 deletions

27
hdrs/cpu.h Normal file
View file

@ -0,0 +1,27 @@
#ifndef CPU_H
#define CPU_H
#include <stdint.h>
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

16
hdrs/memory.h Normal file
View file

@ -0,0 +1,16 @@
#ifndef MEMORY_H
#define MEMORY_H
#include <stdint.h>
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

11
hdrs/zboy.h Normal file
View file

@ -0,0 +1,11 @@
#include "cpu.h"
#include "memory.h"
typedef struct zboy
{
t_cpu cpu;
t_memory memory;
};
void zboy_init();