7 #include "os9x_asm_cpu.h"
9 //#define __debug_c_irq__
10 //#define __debug_c_nmi__
11 //#define __debug_c_hblank__
12 //#define __debug_c_io__
16 void asm_S9xSetPCBase(uint32 Address)
18 #ifdef __debug_c_setpc__
21 S9xSetPCBase(Address);
27 S9xSetWord (w, Registers.S.W - 1);\
30 S9xSetByte (b, Registers.S.W--);
33 void asm_S9xMainLoop(void)
36 //printf("asmMainLoop Enter(0x%08x).\n", CPU.Flags);
38 //printf("asmMainLoop Exit(0x%08x, %d).\n", CPU.PC - CPU.PCBase, CPU.Cycles);
42 void asm_S9xDoHBlankProcessing(void)
44 #ifdef __debug_c_hblank__
47 // S9xUnpackStatus(); // not needed
48 S9xDoHBlankProcessing();
53 uint8 asm_S9xGetByte(uint32 Address)
58 return S9xGetByte(Address);
61 uint16 asm_S9xGetWord(uint32 Address)
66 return S9xGetWord(Address);
70 void asm_S9xSetByte(uint32 Address,uint8 value)
75 S9xSetByte(value,Address);
78 void asm_S9xSetWord(uint32 Address,uint16 value)
83 S9xSetWord(value,Address);
87 void asm_S9xOpcode_NMI(void)
89 #ifdef __debug_c_nmi__
92 // S9xUnpackStatus(); // not needed
94 if (!CheckEmulation())
97 PushW (CPU.PC - CPU.PCBase);
106 if (Settings.SA1 && (Memory.FillRAM [0x2209] & 0x20))
107 S9xSetPCBase (Memory.FillRAM [0x220c] |
108 (Memory.FillRAM [0x220d] << 8));
111 S9xSetPCBase (S9xGetWord (0xFFEA));
113 CPU.Cycles += TWO_CYCLES;
120 PushW (CPU.PC - CPU.PCBase);
121 // S9xPackStatus (); // not needed
122 PushB (Registers.PL);
127 // ICPU.ShiftedPB = 0; // unused
129 if (Settings.SA1 && (Memory.FillRAM [0x2209] & 0x20))
130 S9xSetPCBase (Memory.FillRAM [0x220c] |
131 (Memory.FillRAM [0x220d] << 8));
134 S9xSetPCBase (S9xGetWord (0xFFFA));
136 CPU.Cycles += ONE_CYCLE;
142 // S9xPackStatus(); // not needed
145 void asm_S9xOpcode_IRQ(void)
147 #ifdef __debug_c_irq__
150 // S9xUnpackStatus(); // not needed
152 if (!CheckEmulation())
154 PushB (Registers.PB);
155 PushW (CPU.PC - CPU.PCBase);
156 // S9xPackStatus (); // not needed
157 PushB (Registers.PL);
162 // ICPU.ShiftedPB = 0; // unused
165 if (Settings.SA1 && (Memory.FillRAM [0x2209] & 0x40))
166 S9xSetPCBase (Memory.FillRAM [0x220e] |
167 (Memory.FillRAM [0x220f] << 8));
170 S9xSetPCBase (S9xGetWord (0xFFEE));
172 CPU.Cycles += TWO_CYCLES;
179 PushW (CPU.PC - CPU.PCBase);
180 // S9xPackStatus (); // not needed
181 PushB (Registers.PL);
186 // ICPU.ShiftedPB = 0; // unused
189 if (Settings.SA1 && (Memory.FillRAM [0x2209] & 0x40))
190 S9xSetPCBase (Memory.FillRAM [0x220e] |
191 (Memory.FillRAM [0x220f] << 8));
194 S9xSetPCBase (S9xGetWord (0xFFFE));
196 CPU.Cycles += ONE_CYCLE;
202 // S9xPackStatus(); // not needed
209 void asm_APU_EXECUTE(void)
211 #ifdef __debug_c_apuex__
214 if(CPU.APU_APUExecuting != 1) return;
216 while (CPU.APU_Cycles <= CPU.Cycles)
222 void asm_APU_EXECUTE2(void)
224 if(CPU.APU_APUExecuting != 1) return;
226 ICPU.CPUExecuting = FALSE;
230 } while (CPU.APU_Cycles < CPU.NextEvent);
231 ICPU.CPUExecuting = TRUE;