-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpu.h
102 lines (76 loc) · 2.38 KB
/
cpu.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
#ifndef CPU_H
#define CPU_H
/*must be called before running the emulator and after resetmemory()*/
extern void resetcpu(void);
/*must be called before running the emulator*/
extern void resetscheduler(void);
/*start the emulator execution. */
extern void run(void);
/*use it to activate an Horizontal IRQ at the correct point in a scanline*/
extern void setHIRQ (void);
extern void check_for_IRQ(void);
extern struct cpu{
boolean irq;
boolean WaitingForInterrupt;
boolean branch_skip;//used for sound skip
byte skip_method;
} CPU;
extern struct scheduler{
int cycles;//remaining cpu cycles before the end of the current scanline
int screen_scanline; //the current scanline
int next_event;//the cpu execution is stopped when cycles reach the next_event value. Then the hardware emulation is
int which_event;//performed (i.e. HDMA, NMI, etc. etc.). What exactly will be performed depend on which_event value
int slowrom_cycles_per_scanline;//number of cpu cycles per scanline in case of slow rom speed
int fastrom_cycles_per_scanline;//number of cpu cycles per scanline in case of fast rom speed
int cycles_per_scanline;//the cycles per scanline currently used(equal to slowrom_cycles_per_scanline or fastrom_cycles_per_scanline)
int fastrom_cycles;///the cycles per scanline currently setted for bank 80-FF(depends on 0x420D)
/*h-blanking start*/
int fastromHBlankStart;
int slowromHBlankStart;
} SCHEDULER;
//events definition
#define END_SCANLINE 0
#define IRQ_REQUIRED 1
extern dword getPC(void);
#ifdef SOUND_SKIP
#define BranchCheck2()\
if( CPU.branch_skip)\
{\
if(CPU.skip_method == 0)\
{\
CPU.branch_skip = FALSE;\
}\
else if(CPU.skip_method == 1)\
{\
CPU.branch_skip = FALSE;\
if( ((sbyte) opdata) > 0)\
{\
PC += ((sbyte) opdata);\
cycles -= 3; DOBREAK;\
}\
}\
else if(CPU.skip_method == 2)\
{\
CPU.branch_skip = FALSE;\
if( ((sbyte) opdata) < 0)\
{\
cycles -= 2; DOBREAK;\
}\
}\
else if(CPU.skip_method == 3)\
{\
CPU.branch_skip = FALSE;\
if( ((sbyte) opdata) < 0)\
{\
cycles -= 2; DOBREAK;\
}else\
{\
PC += ((sbyte) opdata);\
cycles -= 3; DOBREAK;\
}\
}\
}
#else
#define BranchCheck2()
#endif
#endif