Repositioning player back to warp-in location? [4.1.5]

omniretro

New member
Note: I'd originally marked this as "resolved" because I'd found the variables for a screen's warp-in coordinates, but I'm still unable to get the rest to work...

Some background: I'm using the two-player co-op module 4.1.5.

I'm trying to create a tile that will warp the player back to the warp-in location (along with doing damage). The purpose of this is to act as a "pit" tile for a single-screen platformer. This is the script I have so far:

Code:
LDA Object_flags,x
    AND #%10010000
    BNE ++
    +   
cpx player1_object
bne +

LDA newY
STA Object_y_hi,x

LDA newX  
STA Object_x_hi,x  ;

lda Object_timer_0,x
bne +

jsr playerGetsHurt
+
    LDA #TILE_SOLID
    STA tile_solidity
    
    cpx player2_object
bne +
LDA newY
STA Object_y_hi,x

LDA newX        
STA Object_x_hi,x  

lda Object_timer_0,x
bne +
jsr playerGetsHurt
+
    LDA #TILE_SOLID
    STA tile_solidity
    
++

This works to reset the player's Y coordinate, but for some reason it doesn't do anything to the X coordinate. In other words, this:

Code:
LDA newX        
STA Object_x_hi,x

seems to be the issue, even though the corresponding Y-coordinate code is working just fine. Any ideas what I might be doing wrong?
 
Last edited:

dale_coop

Moderator
Staff member
maybe the playerGetsHurt subroutine modifies the Object_x_hi, too (like a recoil or something)?
 

omniretro

New member
maybe the playerGetsHurt subroutine modifies the Object_x_hi, too (like a recoil or something)?
Thanks for the reply! I tried commenting out the jump to that subroutine, but it still doesn't seem to update the player's X-coordinate. I also tried removing everything except the

Code:
LDA newY
STA Object_y_hi,x

LDA newX  
STA Object_x_hi,x

code and it still won't reposition. I've ruled out it being an issue with newX since using that variable elsewhere returns what you would expect (e.g., setting the Y-coordinate to newX places the player at a Y-position equivalent to what newX would be), and replacing newX with a fixed number doesn't change anything.

I was even starting to think that maybe Object_x_hi,x isn't what I should be updating to adjust the player's X-coordinate, but there really isn't anything else I can think of that would do that.
 

dale_coop

Moderator
Staff member
Ok... maybe...

Try that:
Code:
LDA newY
STA Object_y_hi,x
STA yHold_hi

LDA newX 
STA Object_x_hi,x
STA xHold_hi
 
Top Bottom