News:

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

Main Menu

[SM] [ASM] Button Disable

Started by snipereighteen, February 03, 2013, 05:37:26 AM

Previous topic - Next topic

snipereighteen

Hello again, I was wondering if anyone could assist me a little. I thought of a cunning plan but there is one requirement. Would anyone happen to know who to create ASM BTS Block which disables all control buttons until you warp to another room.
Many thanks.

Scyzer

How do you get out of the block if it disables all controls?

Smiley

I'm guessing this has something to do with cutscenes of some sort.

Anyway, I checked the RAM map and found a quite a lot of addresses related to input.
http://jathys.zophar.net/supermetroid/kejardon/RAMMap.txt (I know Scyzer has a better RAM map, but Scyzer's tank is being updated, so...)
Just Ctr + F 'Control' and/or 'Input' and you'll find a lot of stuff.
Probably the most important one:
7E:0A88 - 7E:0A89    Flag for if game is using game-input instead of player input (8000+ = game input)

Qactis

$8B holds currently-pressed keys. AND with the below to get the player's customizable keys.

7E:09AA Up
7E:09AC Down
7E:09AE Left
7E:09B0 Right
7E:09B2 Shoot
7E:09B4 Jump
7E:09B6 Run
7E:09B8 Item Cancel
7E:09BA Switch Item
7E:09BC Aim Up
7E:09BE Aim Down

$4218 (Saved to $8B also): Joypad #1 status register (1=pressed)

8000: B button
4000: Y button
2000: Select
1000: Start
0800: Up
0400: Down
0200: Left
0100: Right
0080: A button
0040: X button
0020: L
0010: R


Store 0 at the above values

Scyzer

Wouldnt really work qactis. The game also reads immediate input values that dont change (such as directional input).

The easiest way to disable input altogether is to just hijack the button input update routine (cant remember off the top of my head, but it's called from the main NMI loop in bank $82).

Crashtour99

Alternatively while browsing through one of Kej's docs I came across this info.

;255E6 Instruction D5E6 (0) : Disable Samus's controls
IDisableSamus:
   LDA #$0000
   JSL $90F084  ;  $87084 IN ROM
   RTS

;255EE Instruction D5EE (0) : Enable Samus's controls
IEnableSamus:
   LDA #$0001
   JSL $90F084  ;  $87084 IN ROM
   RTS

These are from PLMs, and I thought I remembered some stuff about a routine in $90 that had the ability to disable controller input.  So yeah, if you're going to use these, just remember that the player can't do anything until you enable controls again.


snipereighteen

#7
Quote from: SMILEuser96 on February 04, 2013, 03:34:02 AM
I'm guessing this has something to do with cutscenes of some sort.

Yes indeed. But you see, if it works, lets say I place 2 tiles vertically then all horizontal, I could also have 'TREADMILL' blocks lining under the button disablers.

Quote from: Crashtour99 on February 09, 2013, 09:22:32 PM
Alternatively while browsing through one of Kej's docs I came across this info.

;255E6 Instruction D5E6 (0) : Disable Samus's controls
IDisableSamus:
   LDA #$0000
   JSL $90F084  ;  $87084 IN ROM
   RTS

;255EE Instruction D5EE (0) : Enable Samus's controls
IEnableSamus:
   LDA #$0001
   JSL $90F084  ;  $87084 IN ROM
   RTS

These are from PLMs, and I thought I remembered some stuff about a routine in $90 that had the ability to disable controller input.  So yeah, if you're going to use these, just remember that the player can't do anything until you enable controls again.

Yes I could use this with the 'AIR-FOOL X-RAY' BTS code.
I'll just merge the two and boom!  :lol:

Cheers anyways!  :^_^:

snipereighteen

lorom

org $9498B2

DW $B300

org $94B300

LDA #$0001
JSL $90F084

RTS


This is the code I have used so far. It disables the keys succesfully, however nothing can interact with Samus.
In this context, "TREADMILL" tiles don't allow Samus to move.

Is there anyway to counter this?

JAM

Use self-destructive FX2.


lorom

org $9498B2

DW $B300

org $94B300

LDA #$0001
JSL $90F084
LDA !FX2Code
STA $07DF
LDA !NumberOfFrames
STA !Counter
RTS

org YourFX2Code (Bank $8F)
LDA !Counter
BEQ Stop
DEC !Counter
INC $0AF6 ;Move Samus to the right, use DEC to move to the left.
RTS

Stop:
LDA #$0000
JSL $90F084
STZ $07DF

RTS

Counter is an intermediate RAM value

Black Falcon

#10
Hm, that wouldn't work too well, as Samus would simply pass through solid walls and ignore any slopes.
Good routines to move Samus properly are here:

90:9350 (JSR) moves Samus left $12.$14 pixels with all the checks; this --> A0:A8F0, 94:971E, E5CE, 9842, 94:87F4
90:93B1 (JSR) moves Samus right $12.$14 pixels with all the checks; this --> A0:A8F0, 94:971E, E5CE, 9826, 94:87F4
90:93EC (JSR) moves Samus up $12.$14 pixels with all the checks; this --> A0:A8F0, 94:9763, E606, 988D
90:9440 (JSR) moves Samus down $12.$14 pixels with all the checks; this --> A0:A8F0, 94:9763, E61B, 9871

However the code needs to be in bank $90, so the code could get messy with all the jumps you'd have to do.

Also, the button disable Routine from Kej's docs doesn't simply disable buttons, but any interaction with Samus to enemies and environment, it also stops her animation (That's why Samus doesn't even breathe anymore or rotates in morphball form)
It's used by the Torizo statues hand to freeze morphball and by the mapstation.

However I'd manually override the routine found at 80:95E1, which is JSL $809459 (controller input), without the need to create extra blocks to make Samus move:

[spoiler]
lorom

org $8095E1 ;original offset for JSL $809459, the controller input routine
JSL CHECKDISABLE ;replace it with our hijack routine (I recommend using a long jump here)

org $9498B2

DW AIRFOOLBTS03
; DW AIRFOOLBTS04
; DW AIRFOOLBTS05 ;just showing that you don't have to use multiple org commands for each new fool-X-ray block, as this is a simple table

org $94B300

CHECKDISABLE:

LDA $1760 ;this value is an unused Stack address, I'm using the first stack addresses a lot in my asm, as they are never really accessed.
;I'm using this as a flag here.
;you could also use the last few RAM addresses reserved for enemies, however these are set to 0 everytime you touch a door and remember not to use 0x32 enemies in the room :P
CMP #$1111 ;this can be any value here, except #$5555 (stack is initialized with this iirc)
BEQ NOBUTTONINPUT
JSL $809459 ;Get controller input, and also a debug branch
NOBUTTONINPUT:
STZ $1760 ;this immediately enables the controls again, so they're only disabled while touching the Fool-Xray block with BTS 03
RTL ;remember it's a long jump

AIRFOOLBTS03:
LDA #$1111 ;for the Block, simply write this
STA $1760 ;it sets the flag every frame. This could be used in many ways, not only to disable controls.
RTS
[/spoiler]


This way it allows you to move Samus with treadmill blocks and interact with enemies, get damage etc, but the player can't control Samus as long as she's touching the block.
Be careful when standing in the block, you might not be able to get out again without the use of treadmills!
Remember that this is only the raw unoptimized code to make it work.
If you want to use a timer like JAM did above, you'll have pull that off for yourself (which I'm pretty sure you can :wink:)

That should work (haven't had time to test it, sorry)

EDIT: Okay it works. It has an interesting side effect, too: when running through a line of Air-fool-Xray blocks you lose control over Samus, but she keeps running until the line ends. Pretty neat IMO. If you pressed any buttons (charge beam, for example) while touching these blocks, they will be hold (Samus keeps charging her beam) until she has no contact with the block anymore.
Now if I just need to find out how to disable certain buttons only...
[spoiler]Quicktime events, anyone?  :grin:[/spoiler]





snipereighteen

Sweet! I'll try this code and see. Cheers everyone!  :^_^:

QuoteQuicktime events, anyone?  :grin:

This? I think this could work actually. However, I'd probably make it a mini-hack though.  :^_^: