It is currently Tue Oct 17, 2017 10:12 am

All times are UTC - 7 hours



Forum rules


Related:



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: OAM reverse engineering
PostPosted: Tue Jun 14, 2016 12:38 pm 
Offline

Joined: Mon Jul 02, 2012 7:46 am
Posts: 759
I'm working on a ROM hack of A Link to the Past, and one of the sprites is using the wrong palette, so I'm currently trying to backtrace the sprite loading routine in order to find where the palette is being loaded from and fix it. Unfortunately, I'm a bit lost. First of all, what I know.

Here is the NO$SNS OAM view of the sprite in question

Image

It is currently using palette OBP2, the correct palette is OBP4.

I've managed to trace the exact DMA transfer that loads this particular sprite into VRAM

Code:
808bb0 stz $2102     [802102] A:0000 X:0000 Y:0080 S:01f0 D:0000 DB:80 nvmXdIZC V:252 H:  96 F: 2
808bb3 lda #$0400             A:0000 X:0000 Y:0080 S:01f0 D:0000 DB:80 nvmXdIZC V:252 H: 126 F: 2
808bb6 sta $4300     [804300] A:0400 X:0000 Y:0080 S:01f0 D:0000 DB:80 nvmXdIzC V:252 H: 144 F: 2
808bb9 lda #$0800             A:0400 X:0000 Y:0080 S:01f0 D:0000 DB:80 nvmXdIzC V:252 H: 174 F: 2
808bbc sta $4302     [804302] A:0800 X:0000 Y:0080 S:01f0 D:0000 DB:80 nvmXdIzC V:252 H: 192 F: 2
808bbf stz $4304     [804304] A:0800 X:0000 Y:0080 S:01f0 D:0000 DB:80 nvmXdIzC V:252 H: 222 F: 2
808bc2 lda #$0220             A:0800 X:0000 Y:0080 S:01f0 D:0000 DB:80 nvmXdIzC V:252 H: 252 F: 2
808bc5 sta $4305     [804305] A:0220 X:0000 Y:0080 S:01f0 D:0000 DB:80 nvmXdIzC V:252 H: 270 F: 2
808bc8 ldy #$01               A:0220 X:0000 Y:0080 S:01f0 D:0000 DB:80 nvmXdIzC V:252 H: 300 F: 2
808bca sty $420b     [80420b] A:0220 X:0000 Y:0001 S:01f0 D:0000 DB:80 nvmXdIzC V:252 H: 312 F: 2


If I understand this correctly, the OAM buffer is at $000800 (aka $7E0800), and is $220 bytes long, which sounds exactly right for OAM. I don't really understand the OAM Address field in the NO$SNS viewer. It seems to be displaying sprite_index * 2, but aren't OAM entries 4 bytes? So, the shield sprite is at index 0x0F, which would put its data at 0x3C-0x3F in the buffer, right? And the palette should be in the last byte, so I'm looking for the last write to $7E083F before this DMA? Is that correct?


Top
 Profile  
 
PostPosted: Tue Jun 14, 2016 12:56 pm 
Offline

Joined: Mon Jul 02, 2012 7:46 am
Posts: 759
Looks like I got it right, chalk one up for rubber duck debugging...

Image


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

All times are UTC - 7 hours


Who is online

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