DaveTCode / GBADotnet

A C#/net core GBA emulator
MIT License
20 stars 1 forks source link

Alien Hominids crashes after logo screens #37

Closed DaveTCode closed 2 years ago

DaveTCode commented 2 years ago

Hits an undefined instruction in bios:

 r0:00000000   r1:00000001   r2:00000000   r3:00000000
 r4:00000001   r5:03000100   r6:00000000   r7:00000000
 r8:00000000   r9:00000000  r10:00000000  r11:0000001F 
r12:04000000  r13:03007FD0  r14:087D6B82  r15:0000034E
cpsr: 400000B3 -Z---I- Thm Supervisor
Cycle: 146431577
0000034A: EB00   Invalid thumb instruction

Not sure what it's doing in BIOS at this point, maybe can track this one down by what SWIs/Interrupts are called to get closer to working out what's happening

DaveTCode commented 2 years ago

Note that this also happens to Atari collection at only 759001 cycles in so that will be much easier to track down. Maybe a regression on recent thumb code changes?

DaveTCode commented 2 years ago
SWI (Thumb)
 r0:00000000   r1:020101AC   r2:00000000   r3:020101AC
 r4:00000001   r5:00000000   r6:00000000   r7:020101AC
 r8:00000000   r9:00000000  r10:00000000  r11:0000001F
r12:02000148  r13:03007F64  r14:08002EFF  r15:08060690
cpsr: 600000B2 -ZC--I- Thm Irq
Cycle: 758853
0806068C: DF1C   SWI #1C = SoundDriverMain

Looks like a call into SoundDriverMain is causing the bad execution. I wonder if that requires some register stuff in the APU I haven't implemented properly yet.

DaveTCode commented 2 years ago
 r0:00000000   r1:00000001   r2:00000000   r3:00000000
 r4:00000001   r5:00002001   r6:00000000   r7:00000000
 r8:00000000   r9:00000000  r10:00000000  r11:0000001F
r12:04000000  r13:03007FA0  r14:0000034C  r15:00000144
cpsr: 20000092 --C--I- Arm Irq
Cycle: 758997
0000013C: E25EF004       SUBS PC, LR, #4

 r0:00000000   r1:00000001   r2:00000000   r3:00000000
 r4:00000001   r5:00002001   r6:00000000   r7:00000000
 r8:00000000   r9:00000000  r10:00000000  r11:0000001F
r12:04000000  r13:03007FD0  r14:0806068E  r15:0000034C
cpsr: 600000B3 -ZC--I- Thm Supervisor
Cycle: 759000
00000348: 0002   MOV Shifted reg

is the smoking gun.

> n
 r0: 00000000   r1: 00000001   r2: 00000000   r3: 00000000
 r4: 00000001   r5: 00002001   r6: 00000000   r7: 00000000
 r8: 00000000   r9: 00000000  r10: 00000000  r11: 0000001F
r12: 04000000  r13: 03007FA0  r14: 0000034C  r15: 00000140
cpsr: 20000092 [--C-I--]
Cycle: 605641
0000013C:  E25EF004 subs pc, lr, #4
> n
 r0: 00000000   r1: 00000001   r2: 00000000   r3: 00000000
 r4: 00000001   r5: 00002001   r6: 00000000   r7: 00000000
 r8: 00000000   r9: 00000000  r10: 00000000  r11: 0000001F
r12: 04000000  r13: 03007EA4  r14: 00000344  r15: 0000034C
cpsr: 6000001F [-ZC----]
Cycle: 605644
00000348:  EB000002 bl 0x00000358

is mgba in the same piece. Note the different cpsr. Since this is a SUBS with destination PC it's right that SPSR overwrites CPSR. What's presumably wrong is the value of SPSR at that point. Haven't tracked that down yet