It is currently Mon Dec 18, 2017 3:46 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Mon Oct 17, 2016 3:15 pm 
Offline

Joined: Sat Jun 27, 2015 1:09 pm
Posts: 70
Hi !

I started for fun, a SI emulator, and got stuck at probably one stupid cpu, or flags bug.

I have working inputs, the game boots perfectly, shift registers are emulated, but when all the aliens are shown, the game makes a jump HL() instruction to what was on the stack, which is 0000, and resets itself obviously.

Here's the complete disassembled code:
http://www.computerarcheology.com/Arcad ... /Code.html

The problem happens at PC: 0550
HL is set to 0x2073, then the copy block function is called, which copies 2073 and 2074 with 00, and those 00 are later feeding the HL register from stack, and making that invalid jump.

Any idea of what is going on ? I know is hard to find the problem, but I've seen it in other forums (with no replies).

Thanks,


Top
 Profile  
 
PostPosted: Mon Oct 17, 2016 11:24 pm 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
Where is the JP (HL)?

Quote:
copies 2073 and 2074 with 00, and those 00 are later feeding the HL register from stack

That doesn't sound right. According to that page, the stack is located at $2300-$23FF.


Top
 Profile  
 
PostPosted: Tue Oct 18, 2016 5:28 am 
Offline

Joined: Sat Jun 27, 2015 1:09 pm
Posts: 70
026E: E9 JP (HL) ; Run object's code (will return to next line)

That's the line .. they were doing some sort of smart code there calling different functions while injecting manually the return vector to the stack.


Top
 Profile  
 
PostPosted: Tue Oct 18, 2016 6:44 am 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
Well, based on that page, SP should never be in the $20xx range, so "copies 2073 and 2074 with 00, and those 00 are later feeding the HL register from stack" should not be possible. Have you perhaps implemented EX (SP),HL as EX SP,HL by mistake?


Top
 Profile  
 
PostPosted: Tue Oct 18, 2016 7:25 am 
Offline

Joined: Sat Jun 27, 2015 1:09 pm
Posts: 70
I have those instructions correct, what is happening is this:

0262: 23 INC HL ; xx03
0263: 5E LD E,(HL) ; Get handler address LSB
0264: 23 INC HL ; xx04
0265: 56 LD D,(HL) ; Get handler address MSB

When PC is 0x262, HL = 0x2072, gets incremented to 0x2073, which previously was loaded with memory value held at 0x2055 (which is 0), same with 0x2074 (read value from 0x2056). Then DE is exchanged to HL, so now HL = 0000 .. then eventually HL gets loaded with value from stack, and Jump (HL) is jump to 0000, which resets the game.

This happens exactly when the last alien is drawn (either on demo mode, or playing).


Top
 Profile  
 
PostPosted: Tue Oct 18, 2016 8:36 am 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
Based on the comments it seems like HL shouldn't be 0x2072 at that point. Perhaps you can work backwards from there to see how L got the value 0x72 rather than 0x02 (which the comments imply is the correct value).


Top
 Profile  
 
PostPosted: Tue Oct 18, 2016 11:32 am 
Offline

Joined: Sat Jun 27, 2015 1:09 pm
Posts: 70
I think those comments are not quite right, since the first line of that function sets HL = 0x2010

I think every 0x10 bytes, theres a different object and the code is looping all of them, jumping to their respective handlers to handle logic, and then returning.

For some reason, Im getting handler 0000 for a game object, still cant fix this stupid bug =(


Top
 Profile  
 
PostPosted: Tue Oct 18, 2016 12:21 pm 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
The "RAM use" page lists 5 game objects, located at 0x201x-0x205x.

0x2073 and 0x2074 are supposedly used for:

Code:
aShotStatus   Bit 0 set if shot is blowing up, bit 7 set if active
aShotStepCnt   Count of steps made by shot (used for fire reload rate)


Top
 Profile  
 
PostPosted: Tue Oct 18, 2016 1:04 pm 
Offline

Joined: Sat Jun 27, 2015 1:09 pm
Posts: 70
Ok fair enough.

I will keep checking .. it's getting very difficult to debug and find an issue.

I'm 80% certain that there's an issue with the flags.

In some documents I read that the sign flag is set if there's a substract operation and clear if it's a sum. Others say that sign flag is set to the most significant bit of the result (bit 7).

Not sure what to make of that


Top
 Profile  
 
PostPosted: Tue Oct 18, 2016 1:19 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6540
Location: Seattle
Should be easy enough to use MAME's debugger to figure out which, right?


Top
 Profile  
 
PostPosted: Tue Oct 18, 2016 1:41 pm 
Offline

Joined: Sat Jun 27, 2015 1:09 pm
Posts: 70
Ive used MAME for 17 years, and never used the debugger, shame on me.

I will check it out on the official site, thanks !


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: 93143 and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group