forked from abandoned-cocoon/firered
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.h
108 lines (98 loc) · 2.14 KB
/
main.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
#pragma once
#include "types.h"
enum interrupt_bits {
i_vblank = 0x1,
i_hblank = 0x2,
i_vcount = 0x4,
i_timer0 = 0x8,
i_timer1 = 0x10,
i_timer2 = 0x20,
i_timer3 = 0x40,
i_serial = 0x80,
i_dma0 = 0x100,
i_dma1 = 0x200,
i_dma2 = 0x400,
i_dma3 = 0x800,
i_keypad = 0x1000,
i_gamepak = 0x2000,
i_unused0 = 0x4000,
i_unused1 = 0x8000,
};
enum keypad {
KEYPAD_A = 0x1,
KEYPAD_B = 0x2,
KEYPAD_SELECT = 0x4,
KEYPAD_START = 0x8,
KEYPAD_RIGHT = 0x10,
KEYPAD_LEFT = 0x20,
KEYPAD_UP = 0x40,
KEYPAD_DOWN = 0x80,
KEYPAD_SHOULDER_RIGHT = 0x100,
KEYPAD_SHOULDER_LEFT = 0x200,
KEYPAD_ANYDIR = 0x3C,
// TODO: Cleanup
BUTTON_A = 0x1,
BUTTON_B = 0x2,
BUTTON_SELECT = 0x4,
BUTTON_START = 0x8,
BUTTON_RIGHT = 0x10,
BUTTON_LEFT = 0x20,
BUTTON_UP = 0x40,
BUTTON_DOWN = 0x80,
BUTTON_R = 0x100,
BUTTON_L = 0x200
};
struct sprite {
union {
struct {
u16 attr0;
u16 attr1;
u16 attr2;
u16 rotscaleinfo;
};
struct {
u8 y;
u8 flags1;
u8 x;
u8 msb_of_x_and_flags2;
};
};
};
struct superstate {
void (*callback1)(void);
void (*callback2)(void);
void (*callback2backup)(void);
void (*vblank_callback)(void);
void (*hblank_callback)(void);
u32 field_14;
u32 field_18;
u32 bits_to_wait_for;
u32 ptr_vblank_counter;
u32 local_vblank_counter;
u16 buttons_held;
u16 buttons_new;
u16 buttons_held_remapped;
u16 buttons_new_remapped;
u16 buttons_new_and_keyrepeat;
u16 keypad_countdown;
u32 unused_apparently;
struct sprite sprites[128];
u8 multi_purpose_state_tracker;
u8 gpu_sprites_upload_skip;
};
extern u16 WAITCNT;
extern u16 KEYINPUT;
// 030030E0
extern u32 keypad_initial_countdown;
// 030030E4
extern u8 byte_030030E4;
// 030030F0
extern struct superstate super;
// 0300352C
extern u32 keypad_followup_countdown;
// 03003530
extern u8 byte_03003530;
void mainloop();
void exec_c1_and_c2();
void load_keys();
void wait_for_superbit_eg_vmatch();