Language…
3 users online: Anas, Firstnamebutt, tOaO - Guests: 179 - Bots: 330
Users: 64,795 (2,380 active)
Latest user: mathew

Multiple Midway Points Tool - I have a small problem

Hello, I downloaded the Multiple Midway Points Tool (by kaijyuu, MarioFanGamer & lx5) and with imamelia's very nice ObjecTool-Tutorial, I could learn how to create and insert custom Objects.
I used these lines of code from the tutorial:

CustExObj98:
LDY $57
LDX $13BF
LDA $1EA2,x
BPL .Blank
LDA #$25
STA [$6B],y
LDA #$00
STA [$6E],y
RTS
.Blank
LDA #$F0
STA [$6B],y
LDA #$0C
STA [$6E],y
RTS

This code works perfectly fine and creates a midway point object, that stays after it gets collected and you respawn, but dissappears after the level is beaten. I can't find out how to change the code to make the midway dissappear forever, after it's collected the first time. I tried to find a solution in imamelia's ObjecTool-Tutorial, but couldn't (maybe it's in there and I'm just a great dumbo). I know that we're checking bit 7 here and I somehow need bit 6 but I can't grasp the concept of scary hex numbers... I tried searching in the Forums but couldn't find anything, sorry if someone already posted about this.

Thank you for reading!
-Goobie Doobie


So if I'm understanding you correctly, you want the midway point flag to disappear both when respawning after dying in the level, and after returning to the level once it has been beaten?

The bit of code you want to look at is this code here:
Code
LDX $13BF
LDA $1EA2,x
BPL .Blank

If you look up the two RAM addresses here in the RAM map, you'll see that $13BF is a value used to indicate the level, and $1EA2 is a table of values for each level that contains various flags regarding it (including the "level is beaten" flag, in bit 7). So the code takes the current level, finds the flags for that level, and if bit 7 of those flags (i.e. the level is beaten) is not set, then it branches.

Now, $1EA2 also includes a flag for just indicating "midway point has been passed", in bit 6. So if you want to only branch if both the level-beaten and midway-collected flags are not set, then you could check for that like this:
Code
LDX $13BF
LDA $1EA2,x
AND #%11000000		; filter down the value to just bit 6 and bit 7
BEQ .Blank		; if the result is 00 (neither bit was set) then branch


Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
Yes, it worked! Thank you so much!
I see your name in many threads, and you always explain everything so perfectly (thats how I learned many other things like changing Bowser's palette for example).
So I just wanted to say thank you for your help again! Definitly deserves credit-mention#smw{:peace:}
Wait! Is someone still here? Everything works fine, but I just found out that, if I collect the first midway, every other midway in the level dissappears.
CustExObj98:

LDY $57
LDX $13BF
LDA $1EA2,x
AND #%01000000 ; I changed this because I changed my mind about the 'not spawning if returning to the level' -thing
BEQ .Blank
LDA #$25
STA [$6B],y
LDA #$00
STA [$6E],y
RTS
.Blank
LDA #$F0
STA [$6B],y
LDA #$0C
STA [$6E],y
RTS

The checkpoints despawn successfully after I collect them and I spawn at the correct screens, but the problem is that every other checkpoint in the same level despawns too.
What do I need to do, if I want the other checkpoints to stay, after I collected the first one?
Do I need to change something in this particular code?
I also have various multimidwaypoint-blocks inserted with gopher. And I changed the Midway Point Number of every block to their appropriate value. Maybe they might have something to do with this?

Thank you for reading! (again)
-Goobie Doobie


For what it's worth, the multiple midway points patch already comes with a custom object for what you want then (the "multi_midway_object.txt" file included with it). If you don't want to use that object specifically, you can use the conditions it checks for writing your object. Specifically this bit:

Code
	LDX $13BF|!addr		; Load translevel
	LDA !RAM_Midway,x	; If the current midway point index
	CMP $58				; smaller than midway point object number
	BCS .return			; ... return


Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
Ah yes, I had difficulties getting the already existing multy midway object to work, so I tried to do it from scratch. And at the same time, I could kinda learn what the different codes do.

Sadly I have to say, I still couldn't get it to work (I am so sorry#smw{-_-2}).
The problem still remains, if I collect the checkpoint, then die, every other checkpoint disappears too.
But if I play through the level deathless, everything is working correctly (every checkpoint appears/disappears correctly).
It seems that a certain flag or value doesn't reset when I die. (Maybe? I don't know thats just a guess)

Here are the codes for checkpoint 1 & 2 that I applied.

CustExObj98:
LDX $13BF|!addr ; Load translevel
LDA !RAM_Midway,x ; If the current midway point index
CMP $01 ; smaller than midway point object number
BCS .return ; ... return
LDY $57
LDX $13BF
LDA $1EA2,x
AND #%01000000
BEQ .Blank
LDA #$25
STA [$6B],y
LDA #$00
STA [$6E],y
RTS
.Blank
LDA #$F0
STA [$6B],y
LDA #$0C
STA [$6E],y
.return
RTS

Here is the 2nd checkpoint

CustExObj99:
LDX $13BF|!addr ; Load translevel
LDA !RAM_Midway,x ; If the current midway point index
CMP $02 ; smaller than midway point object number
BCC .return ; ... return
LDY $57
LDX $13BF
LDA $1EA2,x
AND #%01000000
BEQ .Blank
LDA #$25
STA [$6B],y
LDA #$00
STA [$6E],y
RTS
.Blank
LDA #$F1
STA [$6B],y
LDA #$0C
STA [$6E],y
.return
RTS

Did I screw something in those codes? (probably) Or is it something different like bwRAM or the Blocks?

Anyway, hope you have a nice day!#smw{:TUP:}
-Goobie Doobie


Code
CMP $01 ; smaller than midway point object number

It's this line (and the $02 one in the other object). First, the value here is a RAM address rather than a constant (which would be written like CMP #$01). Since $01 is scratch RAM and isn't being initialized anywhere, the actual value you're comparing against will essentially be random. So for these codes, you'd want to change that to a constant value like #$01 instead.

Now, the object included with the multi-midway patch does use CMP $58. As mentioned, this is actually a RAM address rather than a constant, and specifically $58 is specifically used by ObjecTool to old the settings byte for object 2D. Object 2D is a special 5-byte object added by Lunar Magic for custom objects, which are handled by the "CustObjXX" objects in ObjecTool (as opposed to the CustExtObj ones, which do not get a settings byte). When inserting one, you enter its data like so:



So by using $58 to hold the midway number rather than a constant, you can require only a single custom object slot to handle as many midpoints as you want.

Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
Oh so thats why I had difficulties with the already existing Midway-Patch!
I always inserted it as custom-extended-object and not as custom-obbject.#smw{._.}
But now I finally get what CMP $58 does! I aborted the previous codes and used the existing one again.

This time I inserted everything correctly and successfully... and it worked!
Every checkpoint acts how it should, no matter if I arrive deathless, or with death.

I double-checked everything twice and arrived at the checkpoints on every crazy way possible to be sure that nothing goes wrong. Now all checkpoint-problems have truly been solved, for real this time.

Thank you for your patience and time, I really appreciate it! And I wish you a good day!
-Goobie Doobie