blob: e7026706cd4ee66ebc080d817db406ffd1bf9f4f (
plain)
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
|
#include "../copyright"
#include "snes9x.h"
#include "memmap.h"
#include "ppu.h"
#include "dsp1.h"
#include "cpuexec.h"
#include "apu.h"
#include "dma.h"
#include "sa1.h"
#include "cheats.h"
#include "srtc.h"
#include "sdd1.h"
#include "spc7110.h"
#include "obc1.h"
#include "fxemu.h"
extern struct FxInit_s SuperFX;
void S9xResetSuperFX()
{
SuperFX.vFlags = 0;
FxReset(&SuperFX);
}
void S9xResetCPU()
{
ICPU.Registers.PB = 0;
ICPU.Registers.PC = S9xGetWord(0xFFFC);
ICPU.Registers.D.W = 0;
ICPU.Registers.DB = 0;
ICPU.Registers.SH = 1;
ICPU.Registers.SL = 0xFF;
ICPU.Registers.XH = 0;
ICPU.Registers.YH = 0;
ICPU.Registers.P.W = 0;
ICPU.ShiftedPB = 0;
ICPU.ShiftedDB = 0;
SetFlags(MemoryFlag | IndexFlag | IRQ | Emulation);
ClearFlags(Decimal);
CPU.Flags = CPU.Flags & (DEBUG_MODE_FLAG | TRACE_FLAG);
CPU.BranchSkip = false;
CPU.NMIActive = false;
CPU.IRQActive = false;
CPU.WaitingForInterrupt = false;
CPU.InDMA = false;
CPU.WhichEvent = HBLANK_START_EVENT;
CPU.PC = NULL;
CPU.PCBase = NULL;
CPU.PCAtOpcodeStart = NULL;
CPU.WaitAddress = NULL;
CPU.WaitCounter = 0;
CPU.Cycles = 0;
CPU.NextEvent = Settings.HBlankStart;
CPU.V_Counter = 0;
CPU.MemSpeed = SLOW_ONE_CYCLE;
CPU.MemSpeedx2 = SLOW_ONE_CYCLE * 2;
CPU.FastROMSpeed = SLOW_ONE_CYCLE;
CPU.AutoSaveTimer = 0;
CPU.SRAMModified = false;
CPU.BRKTriggered = false;
CPU.NMICycleCount = 0;
CPU.IRQCycleCount = 0;
S9xSetPCBase(ICPU.Registers.PC);
ICPU.S9xOpcodes = S9xOpcodesE1;
ICPU.CPUExecuting = true;
S9xUnpackStatus();
}
static void CommonS9xReset(void)
{
if (Settings.SuperFX)
S9xResetSuperFX();
memset(Memory.FillRAM, 0, 0x8000);
memset(Memory.VRAM, 0x00, 0x10000);
if (Settings.SPC7110)
S9xSpc7110Reset();
S9xResetCPU();
S9xResetSRTC();
if (Settings.SDD1)
S9xResetSDD1();
S9xResetDMA();
S9xResetAPU();
S9xResetDSP1();
if (Settings.OBC1)
ResetOBC1();
S9xSA1Init();
if (Settings.C4)
S9xInitC4();
#ifdef WANT_CHEATS
S9xInitCheatData();
#endif
}
void S9xReset(void)
{
CommonS9xReset();
S9xResetPPU();
memset(Memory.RAM, 0x55, 0x20000);
}
void S9xSoftReset(void)
{
CommonS9xReset();
S9xSoftResetPPU();
}
|