4.5.6 User Screen Byte 0 to Warp Tile Script

TolerantX

Active member
4.5.6 User Screen Byte 0 to Warp Tile Script
FIRST MAKE SURE YOU HAVE DONE THIS TUTORIAL:
http://nesmakers.com/viewtopic.php?f=35&t=5842

script:
Code:
		CPX player1_object
	BEQ +doWarpPlayer
		JMP +notWarpPlayer

	+doWarpPlayer:
		LDA userScreenByte0			
		CMP #$00
		BNE doNextWarp
				WarpToScreen warpToMap, warpToScreen, #$01
					;; arg0 = warp to map.  0= map1.  1= map2.
					;; arg1 = screen to warp to.
					;; arg2 = screen transition type - most likely use 1 here.
						;; 1 = warp, where it observes the warp in position for the player.						
	doNextWarp:						
		LDA userScreenByte0			
		CMP #$01
		BNE doNextWarp
					WarpToScreen #$00, #$02, #$01  ;;test numbers to try to warp to screen 2 or 3 i dont care as long as it warps;;

	doNextWarp:						
		LDA userScreenByte0			
		CMP #$02
		BNE doNextWarp
					WarpToScreen #$00, #$03, #$01  ;;test numbers to try to warp to screen 2 or 3 i dont care as long as it warps;;

	doNextWarp:						
;		LDA userScreenByte0			
;		CMP #$03
;		BNE doNextWarp
;					WarpToScreen #$00, #$04, #$01  ;;any screen you want etc.. keep going as long as you want;;
;	doNextWarp:

+notWarpPlayer:

Explanation: The userScreenByte0 user variable will now be used to control where you warp to. Zero number or null will now always result in normal warp tile function AKA it warps to designated screen from the actual screen settings. 1-255 (use hex as always) will be for screens you choose. you'll note this script has limited default warps. You need to set up your warps. the end of the script is commented to be used for copy > pasting and continuing with more map coordinates.
I HOPE ALL THIS MAKES SENSE.
If anyone needs future clarity I can make a video or something. For now it's just a script you need to edit your own coordinates to.
This is so you can warp to two different locations. For example, what if you set on the screen that you want to warp to 0,0 as default yes this on 0 will warp there.... but that's what a normal warp does. so this is al ALTERNATIVE so you can have another... you wont have to use a different tile every time you want two warps per screen. I use 0 as a default in case you mess up. its a safety feature thats all.
Thank you. have a nice weekend!
 

IMBrendan

Member
I'm really interested in what you are doing here - in my version of the code I replaced your doNextWarp sequence with a single instance that checks the userScreenByte and simply warps to that address.

; Check USB0 - if 0 do default warp
+doWarpPlayer:
LDA userScreenByte0
CMP #$00
BNE doNextWarp
WarpToScreen warpToMap, warpToScreen, #$01
;; arg0 = warp to map. 0= map1. 1= map2.
;; arg1 = screen to warp to.
;; arg2 = screen transition type - most likely use 1 here.
;; 1 = warp, where it observes the warp in position for the player.

;ELSE - Do warp to?
doNextWarp:
LDA userScreenByte0
STA tempA

WarpToScreen warpToMap, tempA, #$01

I also added code so that the warp tile only activates on the button press of UP.

LDA gamepad
AND #%00010000 ; checking for UP button
The only thing to note about BOTH our scripts is the USB data is only activated on warp in - so it has to be set on the main screen for each level - I will be digging deeper today to see if there is an effective way to solve that problem.
 

tbizzle

Well-known member
If you add screenType into the mix that could potentially give you three different warp options per screen.

Code:
CPX player1_object
    BEQ +doWarpPlayer
        JMP +notWarpPlayer

    +doWarpPlayer:
        LDA screenType           
        CMP #$00
        BNE doNextWarp
                WarpToScreen warpToMap, warpToScreen, #$01
                    ;; arg0 = warp to map.  0= map1.  1= map2.
                    ;; arg1 = screen to warp to.
                    ;; arg2 = screen transition type - most likely use 1 here.
                        ;; 1 = warp, where it observes the warp in position for the player.
 

tbizzle

Well-known member
Code:
CPX player1_object
    BEQ +doWarpPlayer
        JMP +notWarpPlayer

    +doWarpPlayer:
    ;LDA userScreenByte0
        LDA screenType 
        CMP #$00
        BNE doNextWarp
                   WarpToScreen #$00, #$00, #$01
                    ;; arg0 = warp to map.  0= map1.  1= map2.
                    ;; arg1 = screen to warp to.
                    ;; arg2 = screen transition type - most likely use 1 here.
                        ;; 1 = warp, where it observes the warp in position for the player.                   
    doNextWarp:                   
    ;LDA userScreenByte0
        LDA screenType 
        CMP #$00
        BNE doNextWarp1
                   WarpToScreen #$00, #$00, #$01

    doNextWarp1:                     
        LDA screenType       
        CMP #$00
        BNE doNextWarp2
                    WarpToScreen #$00, #$00, #$01

    doNextWarp2:                     
        LDA screenType       
        CMP #$00
        BNE doNextWarp3
                    WarpToScreen #$00, #$00, #$01
    doNextWarp3:
        LDA screenType       
        CMP #$00
        BNE doNextWarp4
                    WarpToScreen #$00, #$00, #$01
 
        doNextWarp4:
        LDA screenType     
        CMP #$00
        BNE doNextWarp5
                    WarpToScreen #$00, #$00, #$01

        doNextWarp5:
        LDA screenType       
        CMP #$00
        BNE doNextWarp6
                    WarpToScreen #$00, #$00, #$01

        doNextWarp6:
        LDA screenType
        CMP #$00
        BNE doNextWarp7
                                         WarpToScreen #$00, #$00, #$01
        doNextWarp7:

+notWarpPlayer:
 
Top Bottom