30 #include "EventCallback.h"
31 #include "EventScheduler.h"
39 namespace libsidplayfp
45 namespace MOS6510Debug
47 void DumpState(event_clock_t time, MOS6510 &cpu);
58 # define CORRECT_SH_INSTRUCTIONS
74 friend void MOS6510Debug::DumpState(event_clock_t time,
MOS6510 &cpu);
86 static const int MAX = 65536;
89 static const uint8_t SP_PAGE = 0x01;
116 bool irqAssertedOnPin;
132 #ifdef CORRECT_SH_INSTRUCTIONS
133 bool rdyOnThrowAwayRead;
141 uint_least16_t Register_ProgramCounter;
142 uint_least16_t Cycle_EffectiveAddress;
143 uint_least16_t Cycle_Pointer;
146 uint8_t Register_StackPointer;
147 uint8_t Register_Accumulator;
153 int_least32_t instrStartPC;
154 uint_least16_t instrOperand;
162 struct ProcessorCycle instrTable[0x101 << 3];
171 void eventWithoutSteals();
172 void eventWithSteals();
174 inline void Initialise();
177 inline void IRQLoRequest();
178 inline void IRQHiRequest();
179 inline void interruptsAndNextOpcode();
180 inline void calculateInterruptTriggerCycle();
183 inline void fetchNextOpcode();
184 inline void throwAwayFetch();
185 inline void throwAwayRead();
186 inline void FetchDataByte();
187 inline void FetchLowAddr();
188 inline void FetchLowAddrX();
189 inline void FetchLowAddrY();
190 inline void FetchHighAddr();
191 inline void FetchHighAddrX();
192 inline void FetchHighAddrX2();
193 inline void FetchHighAddrY();
194 inline void FetchHighAddrY2();
195 inline void FetchLowEffAddr();
196 inline void FetchHighEffAddr();
197 inline void FetchHighEffAddrY();
198 inline void FetchHighEffAddrY2();
199 inline void FetchLowPointer();
200 inline void FetchLowPointerX();
201 inline void FetchHighPointer();
202 inline void FetchEffAddrDataByte();
203 inline void PutEffAddrDataByte();
204 inline void PushLowPC();
205 inline void PushHighPC();
206 inline void PushSR();
207 inline void PopLowPC();
208 inline void PopHighPC();
210 inline void brkPushLowPC();
211 inline void WasteCycle();
213 inline void Push(uint8_t data);
214 inline uint8_t Pop();
215 inline void compare(uint8_t data);
218 inline void adc_instr();
219 inline void alr_instr();
220 inline void anc_instr();
221 inline void and_instr();
222 inline void ane_instr();
223 inline void arr_instr();
224 inline void asl_instr();
225 inline void asla_instr();
226 inline void aso_instr();
227 inline void axa_instr();
228 inline void axs_instr();
229 inline void bcc_instr();
230 inline void bcs_instr();
231 inline void beq_instr();
232 inline void bit_instr();
233 inline void bmi_instr();
234 inline void bne_instr();
235 inline void branch_instr(
bool condition);
236 inline void fix_branch();
237 inline void bpl_instr();
238 inline void bvc_instr();
239 inline void bvs_instr();
240 inline void clc_instr();
241 inline void cld_instr();
242 inline void cli_instr();
243 inline void clv_instr();
244 inline void cmp_instr();
245 inline void cpx_instr();
246 inline void cpy_instr();
247 inline void dcm_instr();
248 inline void dec_instr();
249 inline void dex_instr();
250 inline void dey_instr();
251 inline void eor_instr();
252 inline void inc_instr();
253 inline void ins_instr();
254 inline void inx_instr();
255 inline void iny_instr();
256 inline void jmp_instr();
257 inline void las_instr();
258 inline void lax_instr();
259 inline void lda_instr();
260 inline void ldx_instr();
261 inline void ldy_instr();
262 inline void lse_instr();
263 inline void lsr_instr();
264 inline void lsra_instr();
265 inline void oal_instr();
266 inline void ora_instr();
267 inline void pha_instr();
268 inline void pla_instr();
269 inline void rla_instr();
270 inline void rol_instr();
271 inline void rola_instr();
272 inline void ror_instr();
273 inline void rora_instr();
274 inline void rra_instr();
275 inline void rti_instr();
276 inline void rts_instr();
277 inline void sbx_instr();
278 inline void say_instr();
279 inline void sbc_instr();
280 inline void sec_instr();
281 inline void sed_instr();
282 inline void sei_instr();
283 inline void shs_instr();
284 inline void sta_instr();
285 inline void stx_instr();
286 inline void sty_instr();
287 inline void tax_instr();
288 inline void tay_instr();
289 inline void tsx_instr();
290 inline void txa_instr();
291 inline void txs_instr();
292 inline void tya_instr();
293 inline void xas_instr();
294 inline void sh_instr(uint8_t offset);
299 void invalidOpcode();
305 inline bool checkInterrupts()
const {
return rstFlag || nmiFlag || (irqAssertedOnPin && !flags.getI()); }
307 inline void buildInstructionTable();
310 MOS6510(EventScheduler &scheduler);
319 virtual uint8_t
cpuRead(uint_least16_t addr) =0;
327 virtual void cpuWrite(uint_least16_t addr, uint8_t data) =0;
334 void debug(
bool enable, FILE *out);