Jump to content
ChildOfCv

This is a bug, right?

Recommended Posts

While disassembling some 6502 code, I ran across this loop.  I'm pretty sure the X indirect write is wrong for all nonzero X, but wanted to make sure I wasn't just seeing things.  What say you?

 

	STA		$E0
	LDX		#0

copy_loop:
	LDA		($31),Y
	INY
	STA		($E1,X)
	INX
	DEC		$E0
	BNE		copy_loop

 

Share this post


Link to post
Share on other sites

Do we know the value range of Y and $E0? In which ROM did you find this?

 

The code might work if X would be increased by two. But as it is now I cannot see how it would make sense. Maybe more context would help.

 

 

Share this post


Link to post
Share on other sites

Y comes from a bytecode script stream.  The top nibble (E0) is the copy command, followed by a word destination address and then the bytes to copy.  When I stopped in the debugger, the count was 2 that time.  The first byte went to the intended location (5C5), but the second was written to 405.

 

The ROM in question is Mike Tyson's Punch-Out.

Share this post


Link to post
Share on other sites

That's a NES game. You are in the Atari 2600 Programming forum. ;) 

Share this post


Link to post
Share on other sites

Yeah but it's a 6502 question and I figured there would be more Atari programmers here :)

 

Also, there's no NES programming sub-forum either

Edited by ChildOfCv

Share this post


Link to post
Share on other sites

The problem is that STA ($E1,X) looped pokes "somewhere" in the 64K range. And that "somewhere" makes no sense for an Atari 2600, since most of that area is ROM, not RAM. The NES hardware is unknown, at least to me. Maybe some of the addresses are e.g. hotspots on the NES which trigger additional stuff, maybe there is RAM, maybe ROM.

Edited by Thomas Jentzsch

Share this post


Link to post
Share on other sites

I often analyze 2600 games using Stella's integrated debugger, such as here were I figured out why BattleZone was misbehaving with a video upscaler. 

 

As such I suggest running Punch Out in an NES emulator that likewise has an integrated debugger so you can see exactly what the code is doing.  I'm not familiar with NES so don't know any of the emulators for it. I've seen many videos on @ckrtech's YouTube channel Displaced Gamers where he analyzes NES code while its running, so he may be able to recommend an emulator to use.

Share this post


Link to post
Share on other sites

I do need to find out what he's using since it seems to allow for some nice scripting.  Well, I'm currently using FCEUX, which also seems to have scripting capabilities, but is a bit clunky.  That emulator he uses looks nice.

 

But I have definitely confirmed that it writes to odd locations when count>1.  And NES RAM goes from 0-0x800 so no hot spots there.  It's likely that they never use this to copy more than a byte or 2, since the game is almost glitch-free.  The scripting handled by this function modifies the opponent's fighting strategy at specific times during the round.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...