It is currently Sun Nov 19, 2017 12:07 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Sat Nov 04, 2017 5:35 am 
Offline

Joined: Mon Apr 04, 2016 3:19 am
Posts: 21
Next issue, for the line:

Code:
AND #~SPR_VFLIP


Asm6 is giving me the error "Value out of range".

My best guess is that the ~ operator returns a word instead of a byte, so I have to specifically state that I want the low byte?

Code:
AND #<~SPR_VFLIP


It does assemble without complaint but I have no idea if this actually gives me the value I want lol.


Top
 Profile  
 
PostPosted: Sat Nov 04, 2017 9:19 am 
Offline

Joined: Mon Apr 04, 2016 3:19 am
Posts: 21
Alright, I'm getting somewhere now. The game boots up when assembled by asm6.

https://github.com/Drakim/smb3

Image

So, not everything is as it should be :wink: Unfortunately I'm a bit stuck, the project is huge and I have no idea where to start looking for these errors.

The sound and music is perfect, which at first lead me to believe that all that was messed up was the graphics. I double checked the CHR data, even going so far as to use NES Screen Tool to rip the CHR data from the actual binaries once they were assembled. But it turns out, the CHR data is just fine.

I also used FXEUX PPU viewer and made sure that everything was identical between the nesasm and asm6 version once the game was running and I was on the overworld, which it was.

So it's clear that the graphical glitches are not merely coming from the graphical data being misplaced or anything like that. It's a code issue.

Testing the game a bit more, I noticed some more things that are broken:

1. During the intro, Luigi walks up to Mario but doesn't jump on top of him.
2. During the World map any attempts to move fails with that DUUuuM! sound.
3. During the world map the hammer bros isn't doing his idle walk offset, but his animation is fine.

But surprisingly, a lot of things are not broken, like the intro background and sound. They work flawlessly.

So, my conclusion is that something related to fetching data (data for the sprites in the intro, data for the worldmap pathing, data for luigi's movement during the intro, etc) is broken. My initial guess was indirect access [] vs () being the cause, but looking around I could only find a single instance of () misuse in an LDA, which wasn't related to these glitches.

So, does anybody have any ideas, advice, tricks, tools or pointers that could help me figure this out?

I'm so close! :beer:


Top
 Profile  
 
PostPosted: Sat Nov 04, 2017 11:05 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2981
Location: Tampere, Finland
Compare your ROM to the original SMB3 ROM. There are many ways to do this depending on your operating system. In Windows you can use fc /b on the command line. HxD hex editor can also do file comparisons (Analysis -> File-compare).

Once you find where the difference is, you just need to locate the same code in the assembly code and see what's going wrong. FCEUX debugger might come handy when doing this.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Sat Nov 04, 2017 12:18 pm 
Offline

Joined: Mon Apr 04, 2016 3:19 am
Posts: 21
Thanks, that's finally a lead to follow. Gonna set up FCEUX's debugger with labels and see if I can figure out what's so different.


Top
 Profile  
 
PostPosted: Sat Nov 04, 2017 12:46 pm 
Offline
User avatar

Joined: Tue Jan 24, 2017 1:23 am
Posts: 7
ADD and SUB macro is not working.
SUB Address,X
assembled as:
SEC
SBC Address


Top
 Profile  
 
PostPosted: Sat Nov 04, 2017 12:55 pm 
Offline

Joined: Mon Apr 04, 2016 3:19 am
Posts: 21
Oh, you are right!

In NESASM macros behave a bit differently, so that ",X" part would have tagged along in the first parameter.

Thanks for the heads up, I'll fix this one right away and go over the other macros too. :beer:


Top
 Profile  
 
PostPosted: Sat Nov 04, 2017 1:12 pm 
Offline

Joined: Mon Apr 04, 2016 3:19 am
Posts: 21
Actually, I'm struggling a bit. ASM6's macro system seems a lot weaker than NESASM's macro system.

I've been been going over the documentation, and it doesn't seem like there is any way of supporting an "optional" argument in ASM6, which means I'd either have to split it into two separate ADD and ADD2,X macros or just unroll all the macro calls entirely for ADD and SUB.

Unless somebody else knows any tricks that I'm not aware of?

Edit:

I used a regex to remove the macro from the project, and behold, the title screen is now correct!

Image

I also found a lead on the next issue for the glitchy overworld, NESASM and ASM6 treats negative numbers differently (NESASM makes a negative byte, while ASM6 makes a negative word)


Top
 Profile  
 
PostPosted: Sat Nov 04, 2017 2:57 pm 
Offline

Joined: Mon Apr 04, 2016 3:19 am
Posts: 21
thefox wrote:
Compare your ROM to the original SMB3 ROM. There are many ways to do this depending on your operating system. In Windows you can use fc /b on the command line. HxD hex editor can also do file comparisons (Analysis -> File-compare).

Once you find where the difference is, you just need to locate the same code in the assembly code and see what's going wrong. FCEUX debugger might come handy when doing this.



Ouch, I've run into a big problem with comparing the roms.

in ASM6, all zero page references automatically uses the zero page accessing mode, while in NESASM you have to manually specify if you want to use zero page or absolute access. This mean, a bunch of lines that used to be absolute access in NESASM have been made into zero page access in ASM6.

And, a zero page access LDA is 2 bytes in size, while an absolute access LDA is 3 bytes in size. This means ALL bytes afterwards is gonna be offset. This makes comparing byte for byte between the two roms is nearly impossible.


Top
 Profile  
 
PostPosted: Sat Nov 04, 2017 5:51 pm 
Offline
User avatar

Joined: Tue Jan 24, 2017 1:23 am
Posts: 7
Lot of typos in levels dir.
Exsample:
\levels\Hills\1-2.asm
NESASM: .byte LEVEL4_BGBANK_INDEX(19) | LEVEL4_INITACT_NOTHING
assemble to $13
ASM6: .byte 9 & %00011111 | LEVEL4_INITACT_NOTHING
assemble to $09

Edit:
In many places "# & %00011111 | LEVEL4_INITACT_NOTHING" is missing the first digit. Fixing these will fix at least the level background.


Top
 Profile  
 
PostPosted: Sun Nov 05, 2017 2:45 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2981
Location: Tampere, Finland
Drakim wrote:
And, a zero page access LDA is 2 bytes in size, while an absolute access LDA is 3 bytes in size. This means ALL bytes afterwards is gonna be offset. This makes comparing byte for byte between the two roms is nearly impossible.

I think it would be a good idea to fix those places so you get a byte-per-byte equivalent output. Unfortunately IIRC ASM6 doesn't have a way to override zeropage addressing, so you might have to resort to creating some special macros (maybe something like LDA_ABS).

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Sun Nov 05, 2017 2:46 am 
Offline

Joined: Mon Apr 04, 2016 3:19 am
Posts: 21
Thanks nin-kuuku, it was one of my regexp gone wrong

Also thanks thefox, I was thinking the same thing. As long as I get most of the binaries identical, finding any leftover errors should be a breeze.


Top
 Profile  
 
PostPosted: Sun Nov 05, 2017 6:53 am 
Offline

Joined: Mon Apr 04, 2016 3:19 am
Posts: 21
Alright, all the non-zero page opcodes are now restored!

The next (and hopefully last!) issue is that the orginal NESASM wrapped a lot of it's expressions in parenthesis for clarity, which unfortunately often triggers the indirect access mode in ASM6.

I'm writing a regexp to remove this from the entire project, however, I came across this case:

Code:
LDA #((KingToad_Sprites_End - KingToad_Sprites - 1) & ~3)


Here the parenthesis is used for to ensure the correct precedence of operators. How can I do the same without triggering the indirect addressing mode in ASM6?

EDIT:
I figured it out by random testing. ASM6 detects it automatically, so that LDA ($50+1) is indirect and LDA ($50)+1 is not indirect.


Top
 Profile  
 
PostPosted: Sun Nov 05, 2017 8:47 am 
Offline

Joined: Mon Apr 04, 2016 3:19 am
Posts: 21
Image

Success!

The two rom outputs are now 100% identical.

The only downside is that I had to rely pretty heavily on some macros for the absolute addressing. If you don't care about having a 100% identical starting point (for binary patches or whatever) then you can remove them without any visible changes to the game.

https://github.com/Drakim/smb3

If you make something cool with this, give me a hoot! And major credits for Captain Southbird for actually doing all the hard work.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 3 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