2026-07-15 15:02:54 +10:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
2026-07-15 17:31:10 +10:00
|
|
|
#include <stdbool.h>
|
2026-07-15 15:02:54 +10:00
|
|
|
#include "memory.h"
|
|
|
|
|
|
2026-07-15 17:31:10 +10:00
|
|
|
#define FLAG_ZERO (1 << 0)
|
|
|
|
|
#define FLAG_NEGATIVE (1 << 1)
|
|
|
|
|
#define FLAG_OVERFLOW (1 << 2)
|
|
|
|
|
|
2026-07-15 15:02:54 +10:00
|
|
|
// -- TYPES -- //
|
|
|
|
|
typedef struct {
|
|
|
|
|
uint16_t regs[REG_MAX];
|
|
|
|
|
Memory* mem;
|
2026-07-15 15:54:51 +10:00
|
|
|
|
|
|
|
|
uint32_t pc;
|
|
|
|
|
uint32_t ihp;
|
|
|
|
|
uint32_t sp;
|
2026-07-15 17:31:10 +10:00
|
|
|
|
|
|
|
|
bool halted;
|
2026-07-15 15:02:54 +10:00
|
|
|
} Emulator;
|
|
|
|
|
|
|
|
|
|
// -- FUNCTIONS -- //
|
2026-07-15 15:54:51 +10:00
|
|
|
Emulator* initEmulator(uint32_t memorySize);
|
2026-07-15 17:31:10 +10:00
|
|
|
void freeEmulator(Emulator* emu);
|
|
|
|
|
void startEmulator(Emulator* emu);
|