tile codes only run when you collide with them.
to make a tile that allows only the player do something, you start off the tile code by comparing X to the player (whatever collides with the tile, is loaded into X when the tile code runs.)
so you do
Code:
CPX player1_object
BEQ +
JMP endtilefunction
+
<put whatever you want the tile to do here>
endtilefunction:
after this, since you want to be able to hide at a button press, you propably want to do something along the lines of reading the gamepad to see if a certain button is pressed;
(this stuff would go into the "code space" on the above code.)
Code:
LDA gamepad
AND #%xxxxxxxx ; read whatever input you want here
BNE dotilestuff ; mind you when doing an AND read, the function of BEQ / BNE (branch if equal / branch not equal) is inverted.
JMP endtilefunction
dotilestuff:
something along the lines. it's not very complicated, just take it one step at the time. what you want to do ? what you need to do to get there? (read a gamepad for example.)
for an example of a similar function, here's how my wall grabbing tile looks like.
Code:
; 03_WallGrabTile
CPX player1_object
BNE dontMessWithGravity
LDA gamepad
AND #%00010000 ; is up pressed ?
BEQ dontMessWithGravity
LDA Object_v_speed_hi,x
BEQ dontMessWithGravity ; v_speed 0 won't allow wallgrab
BMI dontMessWithGravity ; are we falling downwards ?
LDX player1_object ; fetch facing direction of player
LDA Object_movement,x
AND #%00001111
CMP #%00000110
BEQ doLeftCollisionCheck
LDA collisionPoint1 ; compare top right collision point
CMP #$03 ; compare against "wallgrab tile"
BNE dontMessWithGravity
JMP doGrab
doLeftCollisionCheck:
LDA collisionPoint0 ; compare top left collision point
CMP #$03 ; compare against "wallgrab tile"
BNE dontMessWithGravity
doGrab: ; enable grabbing the wall
ChangeObjectState #$07, #$03
dontMessWithGravity:
it starts off by checking if the player collides with the tile, if not, end the code
then it reads gamepad to check if up is pressed, if not, end the code.
then it reads the vertical speed of the object loaded in X, if 0 or negative, end the code.
then it reads which direction the object is facing, and depending on the result, it either does a left or a right collision check.
finally, all the conditions are met, and the tile enables the function (changes player action state to 7)