-
Notifications
You must be signed in to change notification settings - Fork 1
/
lcd.h
180 lines (132 loc) · 2.69 KB
/
lcd.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#ifndef __LCD_H__
#define __LCD_H__
#include "defs.h"
struct vissprite
{
int x;
byte pal, pri, pad[6];
unsigned short pat;
byte *buf; // gbc
};
struct scan
{
int bg[64];
int wnd[64];
unsigned short *buf;
byte *cbuf;
//byte pal1[128];
//un16 pal2[64];
//un32 pal4[64];
unsigned short pal[8];
unsigned short bgpal[4];
#ifndef OLD_KERNEL
byte pri[256];
#endif
struct vissprite vs[16];
int ns, l, x, y, s, t, u, v, wx, wy, wt, wv;
};
struct obj
{
byte y;
byte x;
byte pat;
byte flags;
};
#ifdef OLD_KERNEL
byte dummy_vbank[8192];
#endif
struct lcd
{
byte vbank[8192];
#ifdef OLD_KERNEL
byte *vbank2;
#else
byte vbank2[8192];
#endif
union
{
byte mem[256];
struct obj obj[40];
} oam;
#ifdef OLD_KERNEL
byte patdirty[384]; // mono only
#else
byte patdirty[1024]; // 1024 for color
#endif
byte anydirty;
#ifndef OLD_KERNEL
byte mainpal[128];
byte needmainpal;
int palfetch[144][2];
byte pals[144][128]; // oh my god, if sram wasnt full, now it is
short pal2[64];
#endif
};
#ifdef USE_COP
struct hiramcopy
{
byte cR_BGP;
byte cR_OBP0;
byte cR_OBP1;
//byte cR_LY;
unsigned char cR_WY; // has special semantic (is not copied)
// should be [144], bad... FIXME
byte cR_WX[144];
byte cR_SCX[144];
byte cR_SCY[144];
byte cR_LCDC[144];
byte cop_stop;
};
extern struct hiramcopy *hiramcopy;
extern struct lcd *lcd;
#define LCDP lcd
#else
#define LCDP (&lcd)
extern struct lcd lcd;
#endif
#ifndef USE_COP
#define CR_LCDC (R_LCDC)
#define CR_OBP0 (R_OBP0)
#define CR_OBP1 (R_OBP1)
#define CR_BGP (R_BGP)
#define CR_WX (R_WX)
#define CR_WY (scan.wy)
#define CR_LY (R_LY)
#define CR_SCX (R_SCX)
#define CR_SCY (R_SCY)
#else
#define CR_OBP0 ((hiramcopy->cR_OBP0))
#define CR_OBP1 ((hiramcopy->cR_OBP1))
#define CR_BGP ((hiramcopy->cR_BGP))
#define CR_WY ((hiramcopy->cR_WY))
#define CR_LY curline
#define CR_WX ((hiramcopy->cR_WX[curline]))
#define CR_SCX ((hiramcopy->cR_SCX[curline]))
#define CR_SCY ((hiramcopy->cR_SCY[curline]))
#define CR_LCDC ((hiramcopy->cR_LCDC[curline]))
#endif
#define LCD_LAST_LINE 143
#define LINE_NUMBER_OF_BACKGOUND_PAL 17
#define UNUSED_WX_BYTE 0x7D /*just a guess*/
#define ANYDIRTY (LCDP->anydirty)
#define PATDIRTY (LCDP->patdirty)
extern struct scan scan;
extern short screen[145*160];
void updatepatpix();
void lcd_reset();
void lcd_begin();
void vram_write(addr a, byte b);
void update_pal0();
void update_pal1();
void lcd_refreshline();
void vram_dirty();
int lcd_set_interlace(int on);
void lcd_set_yoffset(int val);
void lcd_yflip();
#ifdef PORTABLE
void set_input_mode();
#endif
void gbc_pal_dirty();
void pal_write(int i, byte b);
void lcd_gbc_refreshline();
#endif