-
Notifications
You must be signed in to change notification settings - Fork 3
/
ppu.h
91 lines (67 loc) · 1.55 KB
/
ppu.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#pragma once
#include "types.h"
#define PPU_N_OBJS 10
struct ppu_state_t
{
pixel_t* __restrict * __restrict framebuffer;
void* _dummy1;
void* _dummy2;
void* _dummy3;
var scanX;
var scanY;
var subclk;
var interlace;
var posX;
var _dummy5;
var latchY;
var latchX;
hilow16_t latches[PPU_N_OBJS];
};
struct ppu_t
{
const r8* __restrict VRAM;
const r8* __restrict OAM;
var next_update_ticks;
var next_update_n;
var is_cgb;
var _redrawed;
var rOBPI;
var rBGPI;
var rOBP0;
var rOBP1;
var rBGP;
var rLYC;
var rLCDC;
var rSTAT;
var rSCX;
var rSCY;
var rWX;
var rWY;
var IF_SCHED;
var _internal_WY;
r16 OBP[4*8];
r16 BGP[4*8];
struct ppu_state_t state;
};
typedef struct ppu_t ppu_t;
void ppu_reset(ppu_t* __restrict pp);
void ppu_initialize(ppu_t* __restrict pp);
void ppu_turn_off(ppu_t* __restrict pp);
void ppu_turn_on(ppu_t* __restrict pp);
void ppu_on_write_LYC(ppu_t* __restrict pp);
void ppu_tick_internal(ppu_t* __restrict pp, word ncycles, word rem);
PGB_FUNC static inline word ppu_tick(ppu_t* __restrict pp, word ncycles)
{
var rem = pp->next_update_ticks;
if(ncycles < rem) // Less cycles than to cause an event
{
// Just subtract and return
pp->next_update_ticks = rem - ncycles;
return 0;
}
ppu_tick_internal(pp, ncycles, rem);
var ret = pp->IF_SCHED;
if(ret)
pp->IF_SCHED = 0;
return ret;
}