This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

[CLOSED]Trying to understand the Address for speed

[CLOSED]Trying to understand the Address for speed
by on (#230464)
For educational purposes to help me figure out how to maybe modify the speed for other nes games, I'm trying to figure out why the gamegenie modifies the bike speed and how.

Mega turbo speed on 'A' button - EVUKGEAP + TESGPALA
https://datacrystal.romhacking.net/wiki ... ke:RAM_map

----------------------------
EVUKGEAP
----------------------------
C0BC cmp: 18 v: E0 (GG converted)
----------------------------
00:C0BC:E0 3F CPX #$3F (with GG activated)
00:C0BC:18 CLC (Without GG activated)
----------------------------
0x00F3 speed starting at 0, maxes at 46/47. pressing B gets you there faster (increments by 2, where A adds just one), but 47/49 seems the max speed. seems to be a cap somewhere, poking it higher doesnt give you more speed. (datacrystal info)
---------------------------

I did some searching and found the ram map (I believe) to be 00F3.. and this part of the code affects speed.
Why doesn't he move with 00F3 Val: 0E
?


TESGPALA What's the purpose of this part of the code?
----------------------------
C0D1 cmp: 03 v: 06
----------------------------
00:C0D1:06 03 ASL $0003 = #$22 (With GG activated)
00:C0D1:03 UNDEFINED (without GG activated)
----------------------------
Re: Trying to understand the Address for speed, ExciteBike
by on (#230465)
I'm pretty certain that isn't code. It might instead be changing the first entry in a table that holds accelerations...

Clever-disasm finds that that's a 5 byte data table containing the values $18, $3F, $28, $20, $28; and is followed by another table.
Re: Trying to understand the Address for speed, ExciteBike
by on (#230466)
Not code? You referring to the debug info? (I could of took a screenshot)
How is it changing it?, and what does "TESGPALA" even do?
Re: Trying to understand the Address for speed, ExciteBike
by on (#230467)
The CPU can access memory and treat it as something for the CPU to do: "code"; or can instead work with it as numbers: "data".

I'm about 90% certain that every single byte in the range of $C000 through $C183 is data.

I find that the best way to figure out how changing these constants affects things is to play in a debugging emulator and see what happens with the value.
Re: Trying to understand the Address for speed, ExciteBike
by on (#230468)
access memory?
Is there a bunch of CLC & CPX examples around? I don't get how to use these exactly.
Re: Trying to understand the Address for speed, ExciteBike
by on (#230469)
My point is that that's not CLC, it's just the number $18 = 24. Similarly it's not CPX, it's just the number $E0 = 224.
Re: Trying to understand the Address for speed, ExciteBike
by on (#230472)
Not sure how to play around though. Let's switch games then to my goal. "Marble madness"
Trying to give the marble increased speed. From what I can tell, there's an X speed and Y speed.. will start just with the X for now.

In this case, I have to work with SBC? Sec? and maybe LDA.
Which value do I even try to mess with? and do I change the SBC to something else, or the Sec to something else?
Re: Trying to understand the Address for speed, ExciteBike
by on (#230478)
My next idea, is to look up a bunch of different speed codes from different NES games.. because even though I believe your trying, I'm not understanding your advice.. I think it's made for people who created a bunch of gamegenie codes already.
Re: Trying to understand the Address for speed, ExciteBike
by on (#230479)
Do you want higher maximum velocities or higher acceleration? Either way, it'll basically involve tracing through execution. If there isn't already a complete memory map, it probably will require finding what holds position, from that figuring out what holds velocity, (possibly from that figuring out what holds acceleration,) and then stepping and/or using breakpoints to figure out how what code affects things.

It's a lot of little steps, and while a good debugger will make it a lot quicker, it still requires being able to generate a mental model of how they built things.
Re: Trying to understand the Address for speed, ExciteBike
by on (#230480)
Right now, I'm trying to "Hold A" to make the marble move much faster.
(Using fceux btw)

If for some reason I get this, I'd try to find a way to "Hold A" to make the marble jump.. but I figure, one step at a time.

I have no clue what I should do with CPX, CLC, SBC? SEC?
In excitebike a CPX was changed to a CLC.. but why.
Do things like this always need to be swapped to another function.. and how does one figure out what to even swap something to.
There's a lot of option.. doing a complete guessing game for every single possibility would take months if you don't have a general idea on what to even try.
Re: Trying to understand the Address for speed, ExciteBike
by on (#230483)
gukingofheart wrote:
In excitebike a CPX was changed to a CLC.. but why.

Don't call it an instruction unless it's actually executed as one. These aren't instructions, they're just numbers stored in RAM.

Don't use the disassembler to inspect RAM variables like this. Use the hex memory view, or RAM watch, etc. The disassembly view is for tracing out the code parts, not looking at variables in RAM.
Re: Trying to understand the Address for speed, ExciteBike
by on (#230485)
Hex or disassembly, it still converts to the same thing.
CLC (CLear Carry) $18
Immediate CPX #$44 $E0 2 2

Calling it CLC/CPX $18/$E0 shouldn't make a difference.
So let me rephrase. Why was it changed from $18 to $E0?
Re: Trying to understand the Address for speed, ExciteBike
by on (#230487)
Er, sorry, I misunderstood. I thought you were looking at the speed variable in RAM, didn't realize you were referring to a game genie code that affects a change in ROM.

Still, this is not code, so there is no meaningful way to answer "why CPX instead of CLC", because it is not used as either of those instructions. You do have to rephrase your question to just be about the numbers before it can even be approached.

If you want to see how that value is used, create a new breakpoint for CPU memory read of $C0BC and you will find the code that uses that value. Then you can look at the code where that breakpoint hits and see how it affects things.
Re: Trying to understand the Address for speed, ExciteBike
by on (#230488)
Telling me to use "read breakpoint" is at least new info.. but what this new info tell me/us? Is it, just always use a hex higher then $18? If so, that's a good answer.. if not, then hmmmm.

00:CE2D:B9 BC C0 LDA $C0BC,Y @ $C0BC = #$18 (Without GG) | 4C D0 18 B9 BC C0
00:CE2D:B9 BC C0 LDA $C0BC,Y @ $C0BC = #$E0 (With GG) | 4C D0 18 B9 BC C0

Ok.. now we have a matching data and the hex is unchanged for CE2A to CE2F
Re: Trying to understand the Address for speed, ExciteBike
by on (#230489)
So you hit that breakpoint. Your value is loaded into A with a LDA. Use the step button to continue a few instructions from there until something happens with the value in A. Maybe it will immediately get stored somewhere (STA) or maybe it will go through some arithmetic/logic first.
Re: Trying to understand the Address for speed, ExciteBike
by on (#230490)
Step Into, Step Out, Step Over

Which does what?

There's also "run line" & "128 lines" as well.
Re: Trying to understand the Address for speed, ExciteBike
by on (#230491)
This might help:
http://www.fceux.com/web/help/fceux.html?Debugger.html

All of those terms are defined there, but if you need clarification though you can ask.
Re: Trying to understand the Address for speed, ExciteBike
by on (#230492)
now I understand, but which one do you want me to use?


(thanks for the info so far.. working on a simple guide to help me remember this info for the future)
Re: Trying to understand the Address for speed, ExciteBike
by on (#230494)
Game Genie or not returns these same results
---------------------
00:CE30:18 CLC (Step Into)
00:CE31:75 90 ADC $90,X @ $0090 = #$00 (Step Into Twice)
00:CE33:95 90 STA $90,X @ $0090 = #$00 (Step Into 3 times)
00:CDAF:4C BD CD JMP $CDBD (Step Out)
00:CE30:18 CLC (Step Over)
Re: Trying to understand the Address for speed, ExciteBike
by on (#230495)
There isn't a cookbook for this type of work. It doesn't boil down to following someone else's directions. You need to do analysis and trial-and-error.

Step into/out/over are just for navigating the code. You don't have to use them -- you can use the scrollbar instead and track the program counter in your head. What you're trying to determine is what the code does.

In particular, you're trying to determine what part of the code is capping the speed, so look around for some sort of comparison like CMP #48. But who knows what it could be! You have to figure it out.

Also, play with the game genie code. Try halving numbers. Does halving a number halve the bike's speed? If so, that's the data!
Re: Trying to understand the Address for speed, ExciteBike
by on (#230496)
First I have to know what to play around with.. what to experiment with... what values to try to change, and what values are pointless.
Puppy, not sure if you're trying to even help.. and "rainwarrior" is helping me a lot more atm.

(I'm also writing all this info down.. and will be asking questions for different games in the future... and will try to find a pattern of what to try, and what would be a total waste of time).

Haven't even figured out yet why this cheat needs a second line of code yet.
Re: Trying to understand the Address for speed, ExciteBike
by on (#230512)
My question is do you need to use game genie codes? Why? What is your goal? You can make modifications to games yourself by understanding what the code does and I think that putting game genie code in the middle of this is only going to make your learning more complicated. If you want to change the bike's top speed forget GG, learn assembly and learn how to use fceux's debugger.

http://www.6502.org/tutorials/6502opcodes.html
http://www.fceux.com/web/help/fceux.html?Debugger.html
Re: Trying to understand the Address for speed, ExciteBike
by on (#230526)
address codes easily convert to GG.

For some games & codes, it probably won't become a GG.. but for others, it will be.
I'm not making GG codes for myself (other then a learning experience), making it for others.

Basically creating a new hobby in life.


Anyways, until I learn something new... I guess this might be all the info I can understand at this time.... so thanks again

(Mods can close this thread, as I need to organize info, and this thread would just get messier)
Re: [CLOSED]Trying to understand the Address for speed
by on (#230530)
Here are some points I hope you might find helpful if they weren't clear before:


Game Genie codes can't directly affect RAM

On the NES, the RAM is at CPU addresses 0000 to 07FF. However, a Game Genie can only modify the values at CPU addresses 8000 to FFFF. So to make a Game Genie code affect a RAM address, you have to find something in addresses 8000 to FFFF that affects that RAM address, then change that.


Code vs. data

The CPU is always executing instructions. It has an internal counter called the program counter (PC) that is the address of the instruction it is executing.

When you are looking at the contents of CPU addresses in the hex editor or the debugger, be aware that the contents will be interpreted as instructions only if the CPU's program counter ever gets to that address.

Alternatively, the contents of addresses might be used as data. That is, there are various load and store instructions that can get the value from an address or put a value into a RAM address. If that happens, the value in that address could represent something like, for example, the hit points for a bad guy, and not an instruction.