src/gba/gba.c (view raw)
1/* Copyright (c) 2013-2014 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#include "gba.h"
7
8#include "gba-bios.h"
9#include "gba-io.h"
10#include "gba-rr.h"
11#include "gba-sio.h"
12#include "gba-thread.h"
13
14#include "isa-inlines.h"
15
16#include "util/crc32.h"
17#include "util/memory.h"
18#include "util/patch.h"
19#include "util/vfs.h"
20
21const uint32_t GBA_ARM7TDMI_FREQUENCY = 0x1000000;
22const uint32_t GBA_COMPONENT_MAGIC = 0x1000000;
23
24static const size_t GBA_ROM_MAGIC_OFFSET = 3;
25static const uint8_t GBA_ROM_MAGIC[] = { 0xEA };
26
27static void GBAInit(struct ARMCore* cpu, struct ARMComponent* component);
28static void GBAInterruptHandlerInit(struct ARMInterruptHandler* irqh);
29static void GBAProcessEvents(struct ARMCore* cpu);
30static int32_t GBATimersProcessEvents(struct GBA* gba, int32_t cycles);
31static void GBAHitStub(struct ARMCore* cpu, uint32_t opcode);
32static void GBAIllegal(struct ARMCore* cpu, uint32_t opcode);
33
34void GBACreate(struct GBA* gba) {
35 gba->d.id = GBA_COMPONENT_MAGIC;
36 gba->d.init = GBAInit;
37 gba->d.deinit = 0;
38}
39
40static void GBAInit(struct ARMCore* cpu, struct ARMComponent* component) {
41 struct GBA* gba = (struct GBA*) component;
42 gba->cpu = cpu;
43 gba->debugger = 0;
44
45 GBAInterruptHandlerInit(&cpu->irqh);
46 GBAMemoryInit(gba);
47 GBASavedataInit(&gba->memory.savedata, 0);
48
49 gba->video.p = gba;
50 GBAVideoInit(&gba->video);
51
52 gba->audio.p = gba;
53 GBAAudioInit(&gba->audio, GBA_AUDIO_SAMPLES);
54
55 GBAIOInit(gba);
56
57 gba->sio.p = gba;
58 GBASIOInit(&gba->sio);
59
60 gba->timersEnabled = 0;
61 memset(gba->timers, 0, sizeof(gba->timers));
62
63 gba->springIRQ = 0;
64 gba->keySource = 0;
65 gba->rotationSource = 0;
66 gba->luminanceSource = 0;
67 gba->rtcSource = 0;
68 gba->rumble = 0;
69 gba->rr = 0;
70
71 gba->romVf = 0;
72 gba->biosVf = 0;
73
74 gba->logLevel = GBA_LOG_INFO | GBA_LOG_WARN | GBA_LOG_ERROR | GBA_LOG_FATAL;
75
76 gba->biosChecksum = GBAChecksum(gba->memory.bios, SIZE_BIOS);
77
78 gba->busyLoop = -1;
79}
80
81void GBADestroy(struct GBA* gba) {
82 if (gba->pristineRom == gba->memory.rom) {
83 gba->memory.rom = 0;
84 }
85
86 if (gba->romVf) {
87 gba->romVf->unmap(gba->romVf, gba->pristineRom, gba->pristineRomSize);
88 }
89
90 if (gba->biosVf) {
91 gba->biosVf->unmap(gba->biosVf, gba->memory.bios, SIZE_BIOS);
92 }
93
94 GBAMemoryDeinit(gba);
95 GBAVideoDeinit(&gba->video);
96 GBAAudioDeinit(&gba->audio);
97 GBARRContextDestroy(gba);
98}
99
100void GBAInterruptHandlerInit(struct ARMInterruptHandler* irqh) {
101 irqh->reset = GBAReset;
102 irqh->processEvents = GBAProcessEvents;
103 irqh->swi16 = GBASwi16;
104 irqh->swi32 = GBASwi32;
105 irqh->hitIllegal = GBAIllegal;
106 irqh->readCPSR = GBATestIRQ;
107 irqh->hitStub = GBAHitStub;
108}
109
110void GBAReset(struct ARMCore* cpu) {
111 ARMSetPrivilegeMode(cpu, MODE_IRQ);
112 cpu->gprs[ARM_SP] = SP_BASE_IRQ;
113 ARMSetPrivilegeMode(cpu, MODE_SUPERVISOR);
114 cpu->gprs[ARM_SP] = SP_BASE_SUPERVISOR;
115 ARMSetPrivilegeMode(cpu, MODE_SYSTEM);
116 cpu->gprs[ARM_SP] = SP_BASE_SYSTEM;
117
118 struct GBA* gba = (struct GBA*) cpu->master;
119 if (!GBARRIsPlaying(gba->rr) && !GBARRIsRecording(gba->rr)) {
120 GBASavedataUnmask(&gba->memory.savedata);
121 }
122 GBAMemoryReset(gba);
123 GBAVideoReset(&gba->video);
124 GBAAudioReset(&gba->audio);
125 GBAIOInit(gba);
126
127 GBASIODeinit(&gba->sio);
128 GBASIOInit(&gba->sio);
129
130 gba->timersEnabled = 0;
131 memset(gba->timers, 0, sizeof(gba->timers));
132}
133
134void GBASkipBIOS(struct ARMCore* cpu) {
135 if (cpu->gprs[ARM_PC] == BASE_RESET + WORD_SIZE_ARM) {
136 cpu->gprs[ARM_PC] = BASE_CART0;
137 int currentCycles = 0;
138 ARM_WRITE_PC;
139 }
140}
141
142static void GBAProcessEvents(struct ARMCore* cpu) {
143 do {
144 struct GBA* gba = (struct GBA*) cpu->master;
145 int32_t cycles = cpu->nextEvent;
146 int32_t nextEvent = INT_MAX;
147 int32_t testEvent;
148
149 gba->bus = cpu->prefetch[1];
150 if (cpu->executionMode == MODE_THUMB) {
151 gba->bus |= cpu->prefetch[1] << 16;
152 }
153
154 if (gba->springIRQ) {
155 ARMRaiseIRQ(cpu);
156 gba->springIRQ = 0;
157 }
158
159 testEvent = GBAVideoProcessEvents(&gba->video, cycles);
160 if (testEvent < nextEvent) {
161 nextEvent = testEvent;
162 }
163
164 testEvent = GBAAudioProcessEvents(&gba->audio, cycles);
165 if (testEvent < nextEvent) {
166 nextEvent = testEvent;
167 }
168
169 testEvent = GBATimersProcessEvents(gba, cycles);
170 if (testEvent < nextEvent) {
171 nextEvent = testEvent;
172 }
173
174 testEvent = GBAMemoryRunDMAs(gba, cycles);
175 if (testEvent < nextEvent) {
176 nextEvent = testEvent;
177 }
178
179 testEvent = GBASIOProcessEvents(&gba->sio, cycles);
180 if (testEvent < nextEvent) {
181 nextEvent = testEvent;
182 }
183
184 cpu->cycles -= cycles;
185 cpu->nextEvent = nextEvent;
186
187 if (cpu->halted) {
188 cpu->cycles = cpu->nextEvent;
189 }
190 } while (cpu->cycles >= cpu->nextEvent);
191}
192
193static int32_t GBATimersProcessEvents(struct GBA* gba, int32_t cycles) {
194 int32_t nextEvent = INT_MAX;
195 if (gba->timersEnabled) {
196 struct GBATimer* timer;
197 struct GBATimer* nextTimer;
198
199 timer = &gba->timers[0];
200 if (timer->enable) {
201 timer->nextEvent -= cycles;
202 timer->lastEvent -= cycles;
203 if (timer->nextEvent <= 0) {
204 timer->lastEvent = timer->nextEvent;
205 timer->nextEvent += timer->overflowInterval;
206 gba->memory.io[REG_TM0CNT_LO >> 1] = timer->reload;
207 timer->oldReload = timer->reload;
208
209 if (timer->doIrq) {
210 GBARaiseIRQ(gba, IRQ_TIMER0);
211 }
212
213 if (gba->audio.enable) {
214 if ((gba->audio.chALeft || gba->audio.chARight) && gba->audio.chATimer == 0) {
215 GBAAudioSampleFIFO(&gba->audio, 0, timer->lastEvent);
216 }
217
218 if ((gba->audio.chBLeft || gba->audio.chBRight) && gba->audio.chBTimer == 0) {
219 GBAAudioSampleFIFO(&gba->audio, 1, timer->lastEvent);
220 }
221 }
222
223 nextTimer = &gba->timers[1];
224 if (nextTimer->countUp) {
225 ++gba->memory.io[REG_TM1CNT_LO >> 1];
226 if (!gba->memory.io[REG_TM1CNT_LO >> 1]) {
227 nextTimer->nextEvent = 0;
228 }
229 }
230 }
231 nextEvent = timer->nextEvent;
232 }
233
234 timer = &gba->timers[1];
235 if (timer->enable) {
236 timer->nextEvent -= cycles;
237 timer->lastEvent -= cycles;
238 if (timer->nextEvent <= 0) {
239 timer->lastEvent = timer->nextEvent;
240 timer->nextEvent += timer->overflowInterval;
241 gba->memory.io[REG_TM1CNT_LO >> 1] = timer->reload;
242 timer->oldReload = timer->reload;
243
244 if (timer->doIrq) {
245 GBARaiseIRQ(gba, IRQ_TIMER1);
246 }
247
248 if (gba->audio.enable) {
249 if ((gba->audio.chALeft || gba->audio.chARight) && gba->audio.chATimer == 1) {
250 GBAAudioSampleFIFO(&gba->audio, 0, timer->lastEvent);
251 }
252
253 if ((gba->audio.chBLeft || gba->audio.chBRight) && gba->audio.chBTimer == 1) {
254 GBAAudioSampleFIFO(&gba->audio, 1, timer->lastEvent);
255 }
256 }
257
258 if (timer->countUp) {
259 timer->nextEvent = INT_MAX;
260 }
261
262 nextTimer = &gba->timers[2];
263 if (nextTimer->countUp) {
264 ++gba->memory.io[REG_TM2CNT_LO >> 1];
265 if (!gba->memory.io[REG_TM2CNT_LO >> 1]) {
266 nextTimer->nextEvent = 0;
267 }
268 }
269 }
270 if (timer->nextEvent < nextEvent) {
271 nextEvent = timer->nextEvent;
272 }
273 }
274
275 timer = &gba->timers[2];
276 if (timer->enable) {
277 timer->nextEvent -= cycles;
278 timer->lastEvent -= cycles;
279 if (timer->nextEvent <= 0) {
280 timer->lastEvent = timer->nextEvent;
281 timer->nextEvent += timer->overflowInterval;
282 gba->memory.io[REG_TM2CNT_LO >> 1] = timer->reload;
283 timer->oldReload = timer->reload;
284
285 if (timer->doIrq) {
286 GBARaiseIRQ(gba, IRQ_TIMER2);
287 }
288
289 if (timer->countUp) {
290 timer->nextEvent = INT_MAX;
291 }
292
293 nextTimer = &gba->timers[3];
294 if (nextTimer->countUp) {
295 ++gba->memory.io[REG_TM3CNT_LO >> 1];
296 if (!gba->memory.io[REG_TM3CNT_LO >> 1]) {
297 nextTimer->nextEvent = 0;
298 }
299 }
300 }
301 if (timer->nextEvent < nextEvent) {
302 nextEvent = timer->nextEvent;
303 }
304 }
305
306 timer = &gba->timers[3];
307 if (timer->enable) {
308 timer->nextEvent -= cycles;
309 timer->lastEvent -= cycles;
310 if (timer->nextEvent <= 0) {
311 timer->lastEvent = timer->nextEvent;
312 timer->nextEvent += timer->overflowInterval;
313 gba->memory.io[REG_TM3CNT_LO >> 1] = timer->reload;
314 timer->oldReload = timer->reload;
315
316 if (timer->doIrq) {
317 GBARaiseIRQ(gba, IRQ_TIMER3);
318 }
319
320 if (timer->countUp) {
321 timer->nextEvent = INT_MAX;
322 }
323 }
324 if (timer->nextEvent < nextEvent) {
325 nextEvent = timer->nextEvent;
326 }
327 }
328 }
329 return nextEvent;
330}
331
332void GBAAttachDebugger(struct GBA* gba, struct ARMDebugger* debugger) {
333 gba->debugger = debugger;
334 gba->cpu->components[GBA_COMPONENT_DEBUGGER] = &debugger->d;
335 ARMHotplugAttach(gba->cpu, GBA_COMPONENT_DEBUGGER);
336}
337
338void GBADetachDebugger(struct GBA* gba) {
339 gba->debugger = 0;
340 ARMHotplugDetach(gba->cpu, GBA_COMPONENT_DEBUGGER);
341 gba->cpu->components[GBA_COMPONENT_DEBUGGER] = 0;
342}
343
344void GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char* fname) {
345 gba->romVf = vf;
346 gba->pristineRomSize = vf->size(vf);
347 vf->seek(vf, 0, SEEK_SET);
348 if (gba->pristineRomSize > SIZE_CART0) {
349 gba->pristineRomSize = SIZE_CART0;
350 }
351 gba->pristineRom = vf->map(vf, gba->pristineRomSize, MAP_READ);
352 if (!gba->pristineRom) {
353 GBALog(gba, GBA_LOG_WARN, "Couldn't map ROM");
354 return;
355 }
356 gba->memory.rom = gba->pristineRom;
357 gba->activeFile = fname;
358 gba->memory.romSize = gba->pristineRomSize;
359 gba->romCrc32 = doCrc32(gba->memory.rom, gba->memory.romSize);
360 GBASavedataInit(&gba->memory.savedata, sav);
361 GBAGPIOInit(&gba->memory.gpio, &((uint16_t*) gba->memory.rom)[GPIO_REG_DATA >> 1]);
362 // TODO: error check
363}
364
365void GBALoadBIOS(struct GBA* gba, struct VFile* vf) {
366 gba->biosVf = vf;
367 uint32_t* bios = vf->map(vf, SIZE_BIOS, MAP_READ);
368 if (!bios) {
369 GBALog(gba, GBA_LOG_WARN, "Couldn't map BIOS");
370 return;
371 }
372 gba->memory.bios = bios;
373 gba->memory.fullBios = 1;
374 uint32_t checksum = GBAChecksum(gba->memory.bios, SIZE_BIOS);
375 GBALog(gba, GBA_LOG_DEBUG, "BIOS Checksum: 0x%X", checksum);
376 if (checksum == GBA_BIOS_CHECKSUM) {
377 GBALog(gba, GBA_LOG_INFO, "Official GBA BIOS detected");
378 } else if (checksum == GBA_DS_BIOS_CHECKSUM) {
379 GBALog(gba, GBA_LOG_INFO, "Official GBA (DS) BIOS detected");
380 } else {
381 GBALog(gba, GBA_LOG_WARN, "BIOS checksum incorrect");
382 }
383 gba->biosChecksum = checksum;
384 if (gba->memory.activeRegion == REGION_BIOS) {
385 gba->cpu->memory.activeRegion = gba->memory.bios;
386 }
387 // TODO: error check
388}
389
390void GBAApplyPatch(struct GBA* gba, struct Patch* patch) {
391 size_t patchedSize = patch->outputSize(patch, gba->memory.romSize);
392 if (!patchedSize) {
393 return;
394 }
395 gba->memory.rom = anonymousMemoryMap(patchedSize);
396 if (!patch->applyPatch(patch, gba->pristineRom, gba->pristineRomSize, gba->memory.rom, patchedSize)) {
397 mappedMemoryFree(gba->memory.rom, patchedSize);
398 gba->memory.rom = gba->pristineRom;
399 return;
400 }
401 gba->memory.romSize = patchedSize;
402 gba->romCrc32 = doCrc32(gba->memory.rom, gba->memory.romSize);
403}
404
405void GBATimerUpdateRegister(struct GBA* gba, int timer) {
406 struct GBATimer* currentTimer = &gba->timers[timer];
407 if (currentTimer->enable && !currentTimer->countUp) {
408 gba->memory.io[(REG_TM0CNT_LO + (timer << 2)) >> 1] = currentTimer->oldReload + ((gba->cpu->cycles - currentTimer->lastEvent) >> currentTimer->prescaleBits);
409 }
410}
411
412void GBATimerWriteTMCNT_LO(struct GBA* gba, int timer, uint16_t reload) {
413 gba->timers[timer].reload = reload;
414}
415
416void GBATimerWriteTMCNT_HI(struct GBA* gba, int timer, uint16_t control) {
417 struct GBATimer* currentTimer = &gba->timers[timer];
418 GBATimerUpdateRegister(gba, timer);
419
420 int oldPrescale = currentTimer->prescaleBits;
421 switch (control & 0x0003) {
422 case 0x0000:
423 currentTimer->prescaleBits = 0;
424 break;
425 case 0x0001:
426 currentTimer->prescaleBits = 6;
427 break;
428 case 0x0002:
429 currentTimer->prescaleBits = 8;
430 break;
431 case 0x0003:
432 currentTimer->prescaleBits = 10;
433 break;
434 }
435 currentTimer->countUp = !!(control & 0x0004);
436 currentTimer->doIrq = !!(control & 0x0040);
437 currentTimer->overflowInterval = (0x10000 - currentTimer->reload) << currentTimer->prescaleBits;
438 int wasEnabled = currentTimer->enable;
439 currentTimer->enable = !!(control & 0x0080);
440 if (!wasEnabled && currentTimer->enable) {
441 if (!currentTimer->countUp) {
442 currentTimer->nextEvent = gba->cpu->cycles + currentTimer->overflowInterval;
443 } else {
444 currentTimer->nextEvent = INT_MAX;
445 }
446 gba->memory.io[(REG_TM0CNT_LO + (timer << 2)) >> 1] = currentTimer->reload;
447 currentTimer->oldReload = currentTimer->reload;
448 currentTimer->lastEvent = 0;
449 gba->timersEnabled |= 1 << timer;
450 } else if (wasEnabled && !currentTimer->enable) {
451 if (!currentTimer->countUp) {
452 gba->memory.io[(REG_TM0CNT_LO + (timer << 2)) >> 1] = currentTimer->oldReload + ((gba->cpu->cycles - currentTimer->lastEvent) >> oldPrescale);
453 }
454 gba->timersEnabled &= ~(1 << timer);
455 } else if (currentTimer->prescaleBits != oldPrescale && !currentTimer->countUp) {
456 // FIXME: this might be before present
457 currentTimer->nextEvent = currentTimer->lastEvent + currentTimer->overflowInterval;
458 }
459
460 if (currentTimer->nextEvent < gba->cpu->nextEvent) {
461 gba->cpu->nextEvent = currentTimer->nextEvent;
462 }
463};
464
465void GBAWriteIE(struct GBA* gba, uint16_t value) {
466 if (value & (1 << IRQ_KEYPAD)) {
467 GBALog(gba, GBA_LOG_STUB, "Keypad interrupts not implemented");
468 }
469
470 if (value & (1 << IRQ_GAMEPAK)) {
471 GBALog(gba, GBA_LOG_STUB, "Gamepak interrupts not implemented");
472 }
473
474 if (gba->memory.io[REG_IME >> 1] && value & gba->memory.io[REG_IF >> 1]) {
475 ARMRaiseIRQ(gba->cpu);
476 }
477}
478
479void GBAWriteIME(struct GBA* gba, uint16_t value) {
480 if (value && gba->memory.io[REG_IE >> 1] & gba->memory.io[REG_IF >> 1]) {
481 ARMRaiseIRQ(gba->cpu);
482 }
483}
484
485void GBARaiseIRQ(struct GBA* gba, enum GBAIRQ irq) {
486 gba->memory.io[REG_IF >> 1] |= 1 << irq;
487 gba->cpu->halted = 0;
488
489 if (gba->memory.io[REG_IME >> 1] && (gba->memory.io[REG_IE >> 1] & 1 << irq)) {
490 ARMRaiseIRQ(gba->cpu);
491 }
492}
493
494void GBATestIRQ(struct ARMCore* cpu) {
495 struct GBA* gba = (struct GBA*) cpu->master;
496 if (gba->memory.io[REG_IME >> 1] && gba->memory.io[REG_IE >> 1] & gba->memory.io[REG_IF >> 1]) {
497 gba->springIRQ = 1;
498 gba->cpu->nextEvent = 0;
499 }
500}
501
502void GBAHalt(struct GBA* gba) {
503 gba->cpu->nextEvent = 0;
504 gba->cpu->halted = 1;
505}
506
507static void _GBAVLog(struct GBA* gba, enum GBALogLevel level, const char* format, va_list args) {
508 struct GBAThread* threadContext = GBAThreadGetContext();
509 enum GBALogLevel logLevel = -1;
510
511 if (gba) {
512 logLevel = gba->logLevel;
513 }
514
515 if (threadContext) {
516 logLevel = threadContext->logLevel;
517 gba = threadContext->gba;
518 }
519
520 if (!(level & logLevel) && level != GBA_LOG_FATAL) {
521 return;
522 }
523
524 if (level == GBA_LOG_FATAL && gba) {
525 gba->cpu->nextEvent = 0;
526 }
527
528 if (threadContext) {
529 if (level == GBA_LOG_FATAL) {
530 MutexLock(&threadContext->stateMutex);
531 threadContext->state = THREAD_CRASHED;
532 MutexUnlock(&threadContext->stateMutex);
533 }
534 if (threadContext->logHandler) {
535 threadContext->logHandler(threadContext, level, format, args);
536 return;
537 }
538 }
539
540 vprintf(format, args);
541 printf("\n");
542
543 if (level == GBA_LOG_FATAL && !threadContext) {
544 abort();
545 }
546}
547
548void GBALog(struct GBA* gba, enum GBALogLevel level, const char* format, ...) {
549 va_list args;
550 va_start(args, format);
551 _GBAVLog(gba, level, format, args);
552 va_end(args);
553}
554
555void GBADebuggerLogShim(struct ARMDebugger* debugger, enum DebuggerLogLevel level, const char* format, ...) {
556 struct GBA* gba = 0;
557 if (debugger->cpu) {
558 gba = (struct GBA*) debugger->cpu->master;
559 }
560
561 enum GBALogLevel gbaLevel;
562 switch (level) {
563 default: // Avoids compiler warning
564 case DEBUGGER_LOG_DEBUG:
565 gbaLevel = GBA_LOG_DEBUG;
566 break;
567 case DEBUGGER_LOG_INFO:
568 gbaLevel = GBA_LOG_INFO;
569 break;
570 case DEBUGGER_LOG_WARN:
571 gbaLevel = GBA_LOG_WARN;
572 break;
573 case DEBUGGER_LOG_ERROR:
574 gbaLevel = GBA_LOG_ERROR;
575 break;
576 }
577 va_list args;
578 va_start(args, format);
579 _GBAVLog(gba, gbaLevel, format, args);
580 va_end(args);
581}
582
583bool GBAIsROM(struct VFile* vf) {
584 if (vf->seek(vf, GBA_ROM_MAGIC_OFFSET, SEEK_SET) < 0) {
585 return false;
586 }
587 uint8_t signature[sizeof(GBA_ROM_MAGIC)];
588 if (vf->read(vf, &signature, sizeof(signature)) != sizeof(signature)) {
589 return false;
590 }
591 return memcmp(signature, GBA_ROM_MAGIC, sizeof(signature)) == 0;
592}
593
594bool GBAIsBIOS(struct VFile* vf) {
595 if (vf->seek(vf, 0, SEEK_SET) < 0) {
596 return false;
597 }
598 uint32_t interruptTable[7];
599 if (vf->read(vf, &interruptTable, sizeof(interruptTable)) != sizeof(interruptTable)) {
600 return false;
601 }
602 int i;
603 for (i = 0; i < 7; ++i) {
604 if ((interruptTable[i] & 0xFFFF0000) != 0xEA000000) {
605 return false;
606 }
607 }
608 return true;
609}
610
611void GBAGetGameCode(struct GBA* gba, char* out) {
612 memcpy(out, &((struct GBACartridge*) gba->memory.rom)->id, 4);
613}
614
615void GBAGetGameTitle(struct GBA* gba, char* out) {
616 memcpy(out, &((struct GBACartridge*) gba->memory.rom)->title, 12);
617}
618
619void GBAHitStub(struct ARMCore* cpu, uint32_t opcode) {
620 struct GBA* gba = (struct GBA*) cpu->master;
621 enum GBALogLevel level = GBA_LOG_FATAL;
622 if (gba->debugger) {
623 level = GBA_LOG_STUB;
624 ARMDebuggerEnter(gba->debugger, DEBUGGER_ENTER_ILLEGAL_OP);
625 }
626 GBALog(gba, level, "Stub opcode: %08x", opcode);
627}
628
629void GBAIllegal(struct ARMCore* cpu, uint32_t opcode) {
630 struct GBA* gba = (struct GBA*) cpu->master;
631 GBALog(gba, GBA_LOG_WARN, "Illegal opcode: %08x", opcode);
632 if (gba->debugger) {
633 ARMDebuggerEnter(gba->debugger, DEBUGGER_ENTER_ILLEGAL_OP);
634 }
635}