News:

Don't forget to visit the main site! There's lots of helpful docs, patches, and more!

Main Menu

[SM] Door Pointer Script Crash

Started by Mtgxyz, August 20, 2014, 01:42:35 PM

Previous topic - Next topic

Mtgxyz

Hello.
I wrote an ASM for a Item Stealing door (Much like the Scene in Metroid Prime).
Now i have one small (big) Problem. When i am trying to use it (via a Door Pointer) The door just disappear and the game will softlock.
Sourcecode:
lorom
org $8FEB50
LDA #0
STA $7E09A2 ;Items Got
STA $7E09A4 ;Items Equipped
STA $7E09A6 ;Beams Got
STA $7E09A8 ;Beams Equipped
; You'll get the Items back later!
; Drain Ammo
STA $7E09C6 ; Missiles
STA $7E09CA ; Super Missiles
STA $7E09CE ; Power Bombs
STA $7E09D6 ; Reserve Energy
LDA #1
STA $7E09C2 ; Samus' Energy
RTS

The door I am using is the door #0 in Level 791F8 (Room with the space ship)
the scroll pointer points to $EB50 if it matters somhow

Smiley

First of all, welcome to Metconst! :^_^:

You can start by completely getting rid of LDA #0. Instead change all the relevant lines to STZ $xxxx (Store Zero to $xxxx) . Change your LDA #1 in the end to LDA #$0001. This makes sure the code is compiled correctly and also helps making the code look nicer (you will want this if you ever make any bigger ASM). You can get rid of the 7E in all your STA's because the addresses you're storing to are lower than $7E2000. Only $7E2000 and higher require the 7E.
Last but not least, make sure your ROM is unheadered.

Here's some code that should work properly:
lorom
org $8FEB50

STZ $09A2 ;Items Got
STZ $09A4 ;Items Equipped
STZ $09A6 ;Beams Got
STZ $09A8 ;Beams Equipped
; You'll get the Items back later!
; Drain Ammo
STZ $09C6 ; Missiles
STZ $09CA ; Super Missiles
STZ $09CE ; Power Bombs
STZ $09D6 ; Reserve Energy
LDA #$0001
STA $09C2 ; Samus' Energy
RTS

Please note setting the health to #$0001 may not be a good idea... you might want to use #$0063 (99) instead.

Happy hacking!

P.JBoy

Yeah, as it turns out, both the 8-bit LDA #$00 and 16-bit LDA #$0000 exist, they assemble into different instructions, and depending on how the CPU is configured at that point in time decides (in this case, the M flag), one of the above assembly instructions is valid and the other will cause erratic behaviour. So good practice is to always specify either all four digits or all two digits in hexadecimal
...

Mtgxyz

Thank you! Its working now!
BTW it was the first time i did assembly for other architecures than x86

Mettyk25jigsaw

Hi, I would like to use this piece of ASM in this topic in my hack I am starting soon, If anyone could tell me what I would need to change in ASM File to make Missiles, S.Missile, P.Bombs, reserve energy and Samus' energy, to be lost completely while entering through the door so that Samus 'cannot' start rebuilding her missiles and stuff by simply just collecting pick-ups from killed enemies, and thenceforth have them restored very quickly, instead I want to make Samus have to refind & recollect the missiles and stuff all over again...

Thanks for any help in advance...

Jordan5

#5
This should work (I haven't tested so please make a back-up)


LoRom

org $8FF000      ;Free space in $8F - door scroll pointer
;store zero to
STZ $09C8    ;max missiles
STZ $09CA    ;max supers
STZ $09CE    ;max PBs
STZ $09D4    ;reserve energy
LDA $0063    ;load a value of 99 to...
STA $00C4    ;max energy
RTS

Mettyk25jigsaw

I am afraid Jordan it doesn't work (except for missiles)
However, you gave me an idea on how to fix it and have done successfully except for reserve tanks only--can't seem to figure out why doing the same thing doesn't work for reserves...
Here is a fix if someone else is interested...
Please Note that I've put 09D8 for reserves, I've tested it fairly well and though it doesn't stop Samus from refilling reserves, it's not showing any signs of breaking the rom in any way and I'm fairly certain that it's safe, however actually deleting it probably wouldn't hurt either (the reserves part that is, lol) and may be a better idea to too...

LoRom

org $8FF000      ;Free space in $8F - door scroll pointer
;store zero to
STZ $09C8    ;max missiles
STZ $09CC    ;max supers
STZ $09D0    ;max PBs
STZ $09D8    ;reserve energy
LDA $0063    ;load a value of 99 to...
STA $09C4    ;max energy
RTS

Jordan5

Yeah that's my bad, I wrote all the wrong addresses in the code (except missiles) because dumb. I'm not sure why the reserves still keep on filling up despite setting their max to 0, though...

Smiley

$09D8 is reserve missiles, not reserve tanks. The actual address for max reserve tanks is $09D4

Mettyk25jigsaw

Yes S.User 09D4 Does work, thankyou, I remember now I didn't test reserve tank, when I applied Jordan's ASM, I just assumed it would be done the same way as the others---by adding 2 bytes to S.User Original ASM Drain Ammo Values...All but reserve tank works that way...

Mon732

This ram map should help you find the ram addresses for stuff.

Mettyk25jigsaw

Hi there, as I'm almost finished with my first ever hack (should be ready for beta testing within a month), I have an idea for my 2nd hack thereafter, even though I have a solution for 1 part of the idea I am wondering if someone is able to assist me with an ASM (don't feel pressured if it's not simple--just say no, however I think it might be simple-not sure). Also since I won't be starting for a month or so, it doesn't matter if you decide to assist me in a months time either (if you decide to do so at all)...
   Anyway, I'd better tell you about it, what I am hoping for is a door ASM that makes it possible once transitioning through a door to reset the boss bits, so that you have to fight all the bosses again (inc mini Bosses and Torizos) for all areas.
   As I have the item/upgrade reset already available here, I would like one further improvement on it (if it's not too much of a bother) and that is if it could clear the hud icons once items are lost...
   You might want to know my idea as a matter of interest. I am hoping to have a game that once you complete the first game, you go through a door and lose everything and brings you to a 2nd game all within the one rom hack and you have to complete the first game to get to the 2nd, bosses with someone's assistance might have to be fought again. Then there is the idea with the map, to use the left half of map for the 1st game and the right half for the 2nd. Well that's the idea, hopefully people will like it...
   If anyone is able to help me, It would be greatly appreciated and thanks in advance of any help...

Smiley

LDA #$0000
STA $7ED828 : STA $7ED82A : STA $7ED82C : STA $7ED82E

That will reset all the boss bits for all areas, including Debug.

7E:D828 - 7E:D82F    Boss bits. 1 byte per area (C-B-N-W-M-T-C-D)

Scyzer


LoROM
LDX #$0012 : LDA #$0000
-   STA $09C6,X
    CPX #$0007 : BPL +
    STA $7ED828,X
+  DEX #2 : BPL -
LDX #$001C : LDA #$000E
-   STA $7EC61C,X : STA $7EC65C,X : STA $7EC69C,X
    DEX #2 : BPL -
RTS


Run this from a door. It supercedes the previous clearing code.