Am I reading this right. (cracking away at marble madness)

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
gukingofheart
Posts: 44
Joined: Tue Dec 04, 2018 2:28 pm

Am I reading this right. (cracking away at marble madness)

Post by gukingofheart »

01:E23E:9D D0 03 STA $03D0,X @ $03D0 = #$00
01:E241:BD D8 03 LDA $03D8,X @ $03D8 = #$00
01:E244:E9 00 SBC #$00
01:E246:10 05 BPL $E24D
01:E248:A9 00 LDA #$00
01:E24A:9D D0 03 STA $03D0,X @ $03D0 = #$00
01:E24D:9D D8 03 STA $03D8,X @ $03D8 = #$00

01:E250:60 RTS -----------------------------------------

E246.. if the value is above 0, ignore E248 & E24A, and run E24D (correct? #1)
OR is it this...
E246.. if the value is above 0, run E248, E24A, & E24D (correct #2?)


These addresses has to do with the \ direction speed.. However, unless if there's something I'm overlooking this will not help with turbo only speed.. as at the moment when I mess with an of the addresses within E23E to E24D the ball usually moves on it's own.. and I'm only wanting it to do this when I hold the A button. (A button makes the ball go faster normally)

PS. Marble madness has two direction speeds \ & / (45% & 225% basically)
User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2033
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: Am I reading this right. (cracking away at marble madnes

Post by FrankenGraphics »

the branch will go to the specified address ($E24D) if the value is between 0 and 127.

128-255 is considered the negative range for our purposes since the most significant bit is a negative sign in signed math operations, and any such value would set the S flag, which BPL and BMI checks for.

Article on signed binary numbers.
http://www.frankengraphics.com - personal NES blog
gukingofheart
Posts: 44
Joined: Tue Dec 04, 2018 2:28 pm

Re: Am I reading this right. (cracking away at marble madnes

Post by gukingofheart »

E246.. if the value is above 0, ignore E248 & E24A, and run E24D (correct? #1)

^ so these lines won't run then?
User avatar
rainwarrior
Posts: 8062
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Am I reading this right. (cracking away at marble madnes

Post by rainwarrior »

Expanding the context just a couple of lines, this seems to be a subroutine at $E236:

Code: Select all

STA $14
LDA $03D0,X
SEC
SBC $14
STA $03D0,X
LDA $03D8,X
SBC #$00
BPL :+ ; $E24D
LDA #$00
STA $03D0,X
: ; $E24D
STA $03D8,X
RTS
This code takes a parameter A (value to subtract), and X (index of value). The two arrays appear to be $3D0, X for the low byte, and $3D8, X for the high byte of a combined array of 16 bit values.

$14 is used as a temporary value, but the parameter A (unsigned byte) is subtracted from a signed 16-bit value (at index X), and if there is a negative result it is replaced with 0, otherwise the result remains.

Note that first STA to $3D0, X is storing the low byte of the result, but after calculating the high byte it might get overwritten with 0. The high byte of the result is temporarily in A, which is why that STA $3D8, X can be shared by both branches here.
Oziphantom
Posts: 1163
Joined: Tue Feb 07, 2017 2:03 am

Re: Am I reading this right. (cracking away at marble madnes

Post by Oziphantom »

to surmise what rainwarrior said its a 16bit signed - 8bit unsinged number that clamps to 0.
Post Reply