34 lines
802 B
C
34 lines
802 B
C
#pragma once
|
|
|
|
#include<stdio.h>
|
|
#include<stdlib.h>
|
|
#include<inttypes.h>
|
|
|
|
struct Cpu;
|
|
|
|
#include"ppu.h"
|
|
|
|
#define F_Z 0x80//zero flag
|
|
#define F_N 0x40//subtract
|
|
#define F_H 0x20//half-carry
|
|
#define F_C 0x10//carry
|
|
|
|
#define ror(x,n) ((x>>n)|(x<<((sizeof(x)<<3)-n)))
|
|
|
|
// Cpu state
|
|
typedef struct Cpu
|
|
{
|
|
uint8_t a,f,b,c,d,e,h,l; //regs signed, flags unsigned
|
|
uint16_t sp,pc;
|
|
uint8_t ime;
|
|
} Cpu;
|
|
|
|
char*cpu_log(void);
|
|
void cpu_log_clear(void);
|
|
void cpu_decexec(Cpu*cpu,struct Ppu*ppu,uint8_t*rom,uint8_t*op,uint8_t*ram,bool quiet);
|
|
void cpu_decexecCB(uint8_t*cpu,uint8_t*op,uint8_t*ram,bool quiet);
|
|
void cpu_fetch16(Cpu*cpu,uint8_t*rom,uint16_t*u16);
|
|
void cpu_fetch8(Cpu*cpu,uint8_t*rom,uint8_t*u8);
|
|
void cpu_romhexdump(uint8_t*rom);
|
|
void cpu_write_ram(struct Ppu*ppu,uint16_t addr,uint8_t val,uint8_t*ram);
|