WarpToScreen Collision Update Issue

JayJayHux

Active member
Im hoping someone can help me with a WarpToScreen Issue....
When I collide with warpTile i use my own code to warp to next screen (because I find it easier to understand if i write code where i can) and it works how id hoped except for one big issue i dont know how to fix. When i warp up or down 1 screen because ive hit top or bottom of screen it works perfectly but when i warp left or right everything works except the tile collisions. They seem to be for the screen before or after even though the tile graphics are correct. Also if i only use odd x screens and jump 2 screens instead of 1 everything works as it should, but then i lose 50 percent of my screens???
This is my first post so I apoligize if some things dont make sense.
I hope someone can help me isolate the issue and i can attach my code if neccesary,....thanks.
 

dale_coop

Moderator
Staff member
Im hoping someone can help me with a WarpToScreen Issue....
When I collide with warpTile i use my own code to warp to next screen (because I find it easier to understand if i write code where i can) and it works how id hoped except for one big issue i dont know how to fix. When i warp up or down 1 screen because ive hit top or bottom of screen it works perfectly but when i warp left or right everything works except the tile collisions. They seem to be for the screen before or after even though the tile graphics are correct. Also if i only use odd x screens and jump 2 screens instead of 1 everything works as it should, but then i lose 50 percent of my screens???
This is my first post so I apoligize if some things dont make sense.
I hope someone can help me isolate the issue and i can attach my code if neccesary,....thanks.
Weird issue. Are you using the scrolling module? (Do those screens with the warp tiles have scrolling?)
Could you share your tile script?
 

JayJayHux

Active member
Thankyou for replying, im very confused about why this could be. Im using arcade platformer module and scrolling is disabled everywhere in screen info and player object details edge reaction is null. I will attach my warp code in the hope it helps and im happy to send my project or a video also. Whatever it takes to isolate this issue.
Thanks again.

PLAYER SCRIPT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;WARP TO NEXT SCREEN; ;;;;this is directly after ive applied player movement (the last thing in my player script)
;add middle hitBox to playerX
LDA Object_x_hi,x
CLC
ADC #$08
STA tempx
;add middle hitBox to playerY
LDA Object_y_hi,x
CLC
ADC #$10
STA tempy
;check middle warp collision
CheckCollisionPoint tempx, tempy, #$0F, #$01 ;;;;my warpTile is #$0F
BEQ +warpCollision
JMP +notWarpCollision
+warpCollision

;set playerX and Y
LDA Object_x_hi,x
STA playerX
LDA Object_y_hi,x
STA playerY

;leftWarp
LDA tempx
CMP #008
BCS +notLeftWarp
;update playerX
LDA #232
STA playerX
;set left next screen
LDA screenXY
CLC
ADC #$FF
STA screenXY
JMP +warp
+notLeftWarp

;rightWarp
LDA tempx
CMP #248
BCC +notRightWarp
;update playerX
LDA #008
STA playerX
;set right next screen
LDA screenXY
CLC
ADC #$01
STA screenXY
JMP +warp
+notRightWarp

;upWarp
LDA tempy
CMP #048
BCS +notUpWarp
;update playerY
LDA #192
STA playerY
;set up next screen
LDA screenXY
CLC
ADC #$F0
STA screenXY
JMP +warp
+notUpWarp

;downWarp
LDA tempy
CMP #208
BCC +notDownWarp
;update playerY
LDA #040
STA playerY
;set down next screen
LDA screenXY
CLC
ADC #$10
STA screenXY
JMP +warp
+notDownWarp

JMP +notWarpCollision

;set warp next screen
+warp
LDA #$01
STA warpActive
WarpToScreen #$00, screenXY, #$01
+notWarpCollision





;NEW SCREEN UPDATE PLAYER XY; ;;;;this runs once at beginning of next frame to
LDA #$00 ;;;;place my player in the correct position for new
CMP warpActive ;;;;screen. (the first thing in my player script)
BEQ +notWarpActive
LDA #$00
STA warpActive
UpdatePosition player1_object, playerX, playerY
+notWarpActive



WARP TILE SCRIPT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;warpTile; ;;;;and this is my warpTile code
LDA ObjectUpdateByte
ORA #%00001111
STA ObjectUpdateByte ;makes warp

RTS
 

dale_coop

Moderator
Staff member
@JayJayHux I see some errors here....
I tried to make as few modifications as I could (in order to make it work)... try this (my modifications are commented ";; dale_coop HERE"):

Code:
; PLAYER SCRIPT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;WARP TO NEXT SCREEN; ;;;;this is directly after ive applied player movement (the last thing in my player script)
;add middle hitBox to playerX
LDA Object_x_hi,x
CLC
ADC #$08
STA tempx
;add middle hitBox to playerY
LDA Object_y_hi,x
CLC
ADC #$10
STA tempy
;check middle warp collision
CheckCollisionPoint tempx, tempy, #$0F, #$01 ;;;;my warpTile is #$0F
BEQ +warpCollision
    JMP +notWarpCollision
+warpCollision

;set playerX and Y
LDA Object_x_hi,x
STA playerX
LDA Object_y_hi,x
STA playerY

;leftWarp
LDA tempx
CMP #008
BCS +notLeftWarp
    ;update playerX
    LDA #232
    STA playerX
    ;set left next screen
    LDA screenXY
    SEC         ;; dale_coop HERE
    SBC #$01    ;; dale_coop HERE
    STA screenXY
    JMP +warp
+notLeftWarp

;rightWarp
LDA tempx
CMP #248
BCC +notRightWarp
    ;update playerX
    LDA #008
    STA playerX
    ;set right next screen
    LDA screenXY
    CLC
    ADC #$01
    STA screenXY
    JMP +warp
+notRightWarp

;upWarp
LDA tempy
CMP #048
BCS +notUpWarp
    ;update playerY
    LDA #192
    STA playerY
    ;set up next screen
    LDA screenXY
    SEC         ;; dale_coop HERE
    SBC #$10    ;; dale_coop HERE
    STA screenXY
    JMP +warp
+notUpWarp

;downWarp
LDA tempy
CMP #208
BCC +notDownWarp
    ;update playerY
    LDA #040
    STA playerY
    ;set down next screen
    LDA screenXY
    CLC
    ADC #$10
    STA screenXY
    JMP +warp
+notDownWarp

JMP +notWarpCollision

;set warp next screen
+warp
    LDA #$01
    STA warpActive
    WarpToScreen #$00, screenXY, #$00  ;; dale_coop HERE: use "00" if you want to set your own player's placement
+notWarpCollision




;NEW SCREEN UPDATE PLAYER XY; ;;;;this runs once at beginning of next frame to
LDA #$00 ;;;;place my player in the correct position for new
CMP warpActive ;;;;screen. (the first thing in my player script)
BEQ +notWarpActive
    LDA #$00
    STA warpActive
    UpdatePosition player1_object, playerX, playerY
+notWarpActive



; WARP TILE SCRIPT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;warpTile; ;;;;and this is my warpTile code
LDA ObjectUpdateByte
ORA #%00001111
STA ObjectUpdateByte ;makes warp

RTS
 

JayJayHux

Active member
Thankyou for the reply @dale_coop.
I had tried to change the last warpToScreen argument to #$00 before as I wasnt quite sure what it meant but it doesnt seem to change anything either way.
Also unless im missing something ADC #$F0(#240) and SBC #$10(#16) both equal the same result? Ive been using ADC #$FF instead of SBC #$01 for all my code and have been getting the correct results so im not sure if im missing something?
Could I please send you my project so you can see the warps in action?? They do work well and zero issues warping up and down screen rows, also no issues warping left and right through odd screen columns. It just when I warp to even screen columns that the tile graphics are correct but the tile collisions are not.
Thanks again.
 

dale_coop

Moderator
Staff member
Thankyou for the reply @dale_coop.
I had tried to change the last warpToScreen argument to #$00 before as I wasnt quite sure what it meant but it doesnt seem to change anything either way.
Also unless im missing something ADC #$F0(#240) and SBC #$10(#16) both equal the same result? Ive been using ADC #$FF instead of SBC #$01 for all my code and have been getting the correct results so im not sure if im missing something?
Could I please send you my project so you can see the warps in action?? They do work well and zero issues warping up and down screen rows, also no issues warping left and right through odd screen columns. It just when I warp to even screen columns that the tile graphics are correct but the tile collisions are not.
Thanks again.

What do you mean by "but the tile collisions are not." ?
The screen your player is warped doesn't have the correct collisiton data at all? When you move the player, he doesn't collide with solid tiles, etc..?

Or you mean that if you tried to play again your script, that script doesn't work correctly?
And that it's because the last parameter of the CheckCollisionPoint macro is the collision data table and you used a hardcoded value #01"!
So, your script will not work on even screens, instead of doing:
Code:
LDA Object_x_hi,x
CLC
ADC #$08
STA tempx
;add middle hitBox to playerY
LDA Object_y_hi,x
CLC
ADC #$10
STA tempy
;check middle warp collision
CheckCollisionPoint tempx, tempy, #$0F, #$01  ;;;;my warpTile is #$0F
You should use:

Code:
LDA Object_y_hi,x
CLC
ADC #$10
STA tempy

LDA Object_x_hi,x
CLC
ADC #$08
STA tempx

JSR getPointColTable  ;; this subroutine calculate the corect nametable based on X coord and set it to tempA
CheckCollisionPoint tempx, tempy, #$0F, tempA
 

JayJayHux

Active member
@dale_coop I hope these pictures help explain the issue but it seems that you understand what im trying to say. Yes, I mean the screen my player is warping to (only if it is an even screen) does not load the correct collisions. It looks like the correct room but the collisions as far as I can tell are the same as the room I warped from. I interprete what you said in the last reply as every second screen uses the opposite collision table? If thats the case it makes sense to me why this is happening. I tried your code suggestion and felt like it was going to work but sadly it hasnt yet? I do feel like its close to a solution now though. Maybe there is a way I can manual change the collision table if im about to warp to an even screen? Just a thought....
Thanks again.
 

Attachments

  • game_001.png
    game_001.png
    1.9 KB · Views: 11
  • game_000.png
    game_000.png
    1.9 KB · Views: 11
  • Skärmbild (1).png
    Skärmbild (1).png
    451.6 KB · Views: 11

dale_coop

Moderator
Staff member
To help you write a working script, you should first explain what the code is supposed to do. What are you trying to achieve, game-wise? Can you show us a use case?
It looks like you just want the player to exit one side of the screen and appear on the other… but if that’s the goal, why not simply use the player’s edge collision ("Go to next screen") for that? (like in the adventure module tutorial?)
 

JayJayHux

Active member
I apoligize if im not making as much sense as im intending to. I did attempt to do just that in my first post but ive never posted anything before so I was aware it might come off abit confusing. My goal is to have my own script to warp anywhere i wish as I find it easier to adjust where needed. I had noticed things in the default warp at edge like the player doesnt get as close to the left edge as it does the right edge before warping etc and I decided it would be easier to write my own script rather than adjust and potentielly break other scripts. My script works just as id hoped except for this even screen issue that I dont understand. If this cant be solved thats unfortunate but worst case scenario with my current script i can still warp around seemlessly if I only use odd screens. I really appreciate your help so far either way and again apoligize if im coming off as difficult.
 
In this thread, James Nes explain how to do a custom warp tile that use userscreenbytes to determine destination screen and player position. My custom warp tile is based on his concept and work perfectly in both scrolling games and non scrolling games.

 

dale_coop

Moderator
Staff member
I apoligize if im not making as much sense as im intending to. I did attempt to do just that in my first post but ive never posted anything before so I was aware it might come off abit confusing. My goal is to have my own script to warp anywhere i wish as I find it easier to adjust where needed. I had noticed things in the default warp at edge like the player doesnt get as close to the left edge as it does the right edge before warping etc and I decided it would be easier to write my own script rather than adjust and potentielly break other scripts. My script works just as id hoped except for this even screen issue that I dont understand. If this cant be solved thats unfortunate but worst case scenario with my current script i can still warp around seemlessly if I only use odd screens. I really appreciate your help so far either way and again apoligize if im coming off as difficult.
I think the problem in your script isn’t the warp tile itself, but everything else you’ve added that might interfere.
Keep it simple: just ONE custom warp tile script that you assign to you 0F tile . Don’t add code in screen load, action scripts, or elsewhere.


Here's how I would code it (no need the use of any extra variables than the default nesmaker ones):
1) "Tile 15" tile script:
Code:
; PLAYER SCRIPT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CPX player1_object
BEQ +continue
    ;; if not player object:
    JMP +notPlayer
+continue:

;WARP TO NEXT SCREEN; ;;;;this is directly after ive applied player movement (the last thing in my player script)
;add middle hitBox to playerX
LDA Object_x_hi,x
CLC
ADC #$08
STA tempx
;add middle hitBox to playerY
LDA Object_y_hi,x
CLC
ADC #$10
STA tempy


;leftWarp
LDA tempx
CMP #008
BCS +notLeftWarp
    ;update playerX
    LDA #232
    STA newX
    ;set left next screen
    LDA currentNametable
    SEC      
    SBC #$01  
    STA warpToScreen
    JMP +warp
+notLeftWarp

;rightWarp
LDA tempx
CMP #248
BCC +notRightWarp
    ;update playerX
    LDA #008
    STA newX
    ;set right next screen
    LDA currentNametable
    CLC
    ADC #$01
    STA warpToScreen
    JMP +warp
+notRightWarp

;upWarp
LDA tempy
CMP #048
BCS +notUpWarp
    ;update playerY
    LDA #192
    STA newY
    ;set up next screen
    LDA currentNametable
    SEC        
    SBC #$10  
    STA warpToScreen
    JMP +warp
+notUpWarp

;downWarp
LDA tempy
CMP #208
BCC +notDownWarp
    ;update playerY
    LDA #040
    STA newY
    ;set down next screen
    LDA currentNametable
    CLC
    ADC #$10
    STA warpToScreen
    JMP +warp
+notDownWarp

JMP +notWarpCollision

;set warp next screen
+warp:
    WarpToScreen warpMap, warpToScreen, #$00  ;; dale_coop HERE: use "00" if you want to set your own player's placement

    RTS

+notPlayer:

    LDA ObjectUpdateByte
    ORA #%00000001
    STA ObjectUpdateByte ;; makes solid

+notWarpCollision:

RTS

And that's it!
Nothing more. The warp to screen should send your player to the correct screen, with the correct collision (unless you changed something elsewhere).
Since that script is assigned to tile 15, it will be executed only when the player collides with that tile type (and a piece of code to excluse any other objects).
 

JayJayHux

Active member
In this thread, James Nes explain how to do a custom warp tile that use userscreenbytes to determine destination screen and player position. My custom warp tile is based on his concept and work perfectly in both scrolling games and non scrolling games.

Thanks @Francois Brodeur. I will definitely read through the thread and hopefully it will help.
 

JayJayHux

Active member
I think the problem in your script isn’t the warp tile itself, but everything else you’ve added that might interfere.
Keep it simple: just ONE custom warp tile script that you assign to you 0F tile . Don’t add code in screen load, action scripts, or elsewhere.


Here's how I would code it (no need the use of any extra variables than the default nesmaker ones):
1) "Tile 15" tile script:
Code:
; PLAYER SCRIPT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CPX player1_object
BEQ +continue
    ;; if not player object:
    JMP +notPlayer
+continue:

;WARP TO NEXT SCREEN; ;;;;this is directly after ive applied player movement (the last thing in my player script)
;add middle hitBox to playerX
LDA Object_x_hi,x
CLC
ADC #$08
STA tempx
;add middle hitBox to playerY
LDA Object_y_hi,x
CLC
ADC #$10
STA tempy


;leftWarp
LDA tempx
CMP #008
BCS +notLeftWarp
    ;update playerX
    LDA #232
    STA newX
    ;set left next screen
    LDA currentNametable
    SEC     
    SBC #$01 
    STA warpToScreen
    JMP +warp
+notLeftWarp

;rightWarp
LDA tempx
CMP #248
BCC +notRightWarp
    ;update playerX
    LDA #008
    STA newX
    ;set right next screen
    LDA currentNametable
    CLC
    ADC #$01
    STA warpToScreen
    JMP +warp
+notRightWarp

;upWarp
LDA tempy
CMP #048
BCS +notUpWarp
    ;update playerY
    LDA #192
    STA newY
    ;set up next screen
    LDA currentNametable
    SEC       
    SBC #$10 
    STA warpToScreen
    JMP +warp
+notUpWarp

;downWarp
LDA tempy
CMP #208
BCC +notDownWarp
    ;update playerY
    LDA #040
    STA newY
    ;set down next screen
    LDA currentNametable
    CLC
    ADC #$10
    STA warpToScreen
    JMP +warp
+notDownWarp

JMP +notWarpCollision

;set warp next screen
+warp:
    WarpToScreen warpMap, warpToScreen, #$00  ;; dale_coop HERE: use "00" if you want to set your own player's placement

    RTS

+notPlayer:

    LDA ObjectUpdateByte
    ORA #%00000001
    STA ObjectUpdateByte ;; makes solid

+notWarpCollision:

RTS

And that's it!
Nothing more. The warp to screen should send your player to the correct screen, with the correct collision (unless you changed something elsewhere).
Since that script is assigned to tile 15, it will be executed only when the player collides with that tile type (and a piece of code to excluse any other objects).
Thanks @dale_coop. That all makes sense to me and I will try it ASAP.
 

JayJayHux

Active member
@dale_coop I have tried the new code and it still has the same problem. I commented out all of my warp code running from my player script and copy and pasted your code into tile script 15. It unfortunately gave me the same result(the even screens loading incorrect collisions but correct tile graphics).
Also I have not added or changed any default code anywhere except for my own player script and tile scripts. Ill mention just incase it matters that im using arcade platformer module. Ive noticed that the incorrect collisions being loaded are from both the screen to the left and the right? So half the screen has the collisions from the room i warped in from(room to the right) and the other half are from the following room after(room to the left).
I have at least updated my warp code with the default variables(nameTable,newX,newY etc) instead of my user variables since i now understand thanks to you how and when to use them.
Thanks.
 

dale_coop

Moderator
Staff member
If you want more help fixing the issue, I can take a look at your whole project. If that works for you, we can continue the conversation in private. Just let me know.
 

JayJayHux

Active member
@dale_coop I would very much appreciate you having a look at my project. I doubt I will find the solution without help unfortunately.
Please let me know the best way to send you my project. Thankyou.
 

JayJayHux

Active member
@dale_coop I'm very happy to say that after following your advice and updating all my CheckCollisionPoints the issue is fixed!


CheckCollisionPoint tempx, tempy, #$01, #$01

NESmaker stores collision data in two tables, collisionTable and collisionTable2 , for odd/even screens, used for scrolling... even if you don't use scrolling. The last parameter you set 01, means you will always check only collisionTable2, which will be correct only on odd screens.

So, instead you need to use:
Code:
LDA currentNametable
AND #%00000001
STA tempD
CheckCollisionPoint tempx, tempy, #$01, tempD


Thankyou again for taking the time to look at my code and easily find the issue.
 

dale_coop

Moderator
Staff member
@dale_coop I'm very happy to say that after following your advice and updating all my CheckCollisionPoints the issue is fixed!


CheckCollisionPoint tempx, tempy, #$01, #$01

NESmaker stores collision data in two tables, collisionTable and collisionTable2 , for odd/even screens, used for scrolling... even if you don't use scrolling. The last parameter you set 01, means you will always check only collisionTable2, which will be correct only on odd screens.

So, instead you need to use:
Code:
LDA currentNametable
AND #%00000001
STA tempD
CheckCollisionPoint tempx, tempy, #$01, tempD


Thankyou again for taking the time to look at my code and easily find the issue.
Glad it helped.
 
Top Bottom