Initial Project Setup

This commit is contained in:
2025-01-30 14:30:19 -07:00
parent a47ca7dcbf
commit 7e0b305d17
50 changed files with 3227 additions and 0 deletions

6
include/bus.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <common.h>
u8 bus_read(u16 address);
void bus_write(u16 address, u8 value);

22
include/cart.h Normal file
View File

@ -0,0 +1,22 @@
#pragma once
#include <common.h>
typedef struct {
u8 entry[4];
u8 logo[0x30];
char title[16];
u16 new_lic_code;
u8 sgb_flag;
u8 type;
u8 rom_size;
u8 ram_size;
u8 dest_code;
u8 lic_code;
u8 version;
u8 checksum;
u16 global_checksum;
} rom_header;
bool cart_load(char *cart);

17
include/common.h Normal file
View File

@ -0,0 +1,17 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
#define BIT(a, n) ((a & (1 << n)) ? 1 : 0)
#define BIT_SET(a, n, on) (on ? (a) |= (1 << n) : (a) &= !(1 << n))
#define BETWEEN(a, b, c) ((a >= b) && (a <= c))
void delay(u32 ms);

6
include/cpu.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <common.h>
void cpu_init();
bool cpu_step();

12
include/emu.h Normal file
View File

@ -0,0 +1,12 @@
#pragma once
#include <common.h>
typedef struct {
bool paused;
bool running;
u64 ticks;
} emu_context;
int emu_run(int, char**);
emu_context *emu_get_context();

6
include/ppu.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <common.h>
void ppu_init();
void ppu_tick();

6
include/timer.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <common.h>
void timer_init();
void timer_tick();