More than one warp per screen

Bucket Mouse

Active member
In the current build of NESMaker, you can only set one warp for each screen. Recently Joe defied this with his Troll Burner Xmas release on Facebook that uses a map screen with four different warp points.

I made a comment assuming it would be possible to do this in the new version, and he told me "actually, you can do it in the old version if you're clever."

The only other way I can think of would be to make a special tile type that specifically redirects to a specific screen -- and that'd be wasteful, since you only get so many tile types. Generally you want to make tiles you can use more than once. What other way is there?

Joe Granato That’s true, but what if you could set some variables per map screen and just use a couple of tile types to direct to wherever those variable for that specific map pointed?

That’s one clever way. You could even get up to 4 by just repurposing the npc string indexes...if string 0 is selected, warp reads that and sends to screen zero.

Or you could make custom tables - on screen 00, there are these four warps...each of the four corresponding warps takes you to what is indexed in that slot for that table..

(And several other potential ways, if you’re clever ;-) )

I'm a bit confused as to what he means. The problem with using a variable is that, at some point, that variable has to be set, or loaded with a new number right before you use it for what you want to do. But the NESMaker code doesn't work that way. What does he mean?
 
Bucket Mouse said:
In the current build of NESMaker, you can only set one warp for each screen. Recently Joe defied this with his Troll Burner Xmas release on Facebook that uses a map screen with four different warp points.

I made a comment assuming it would be possible to do this in the new version, and he told me "actually, you can do it in the old version if you're clever."

The only other way I can think of would be to make a special tile type that specifically redirects to a specific screen -- and that'd be wasteful, since you only get so many tile types. Generally you want to make tiles you can use more than once. What other way is there?

Joe Granato That’s true, but what if you could set some variables per map screen and just use a couple of tile types to direct to wherever those variable for that specific map pointed?

That’s one clever way. You could even get up to 4 by just repurposing the npc string indexes...if string 0 is selected, warp reads that and sends to screen zero.

Or you could make custom tables - on screen 00, there are these four warps...each of the four corresponding warps takes you to what is indexed in that slot for that table..

(And several other potential ways, if you’re clever ;-) )

I'm a bit confused as to what he means. The problem with using a variable is that, at some point, that variable has to be set, or loaded with a new number right before you use it for what you want to do. But the NESMaker code doesn't work that way. What does he mean?

Judging by the "Map screen" in the demo they released, there will definitely be multiple warp functionality in 4.1.
 

cargo

spam bots yandex
If I were to guess (and this is just an opinion):

The quote refers to solving this problem using the NESMaker interface. Possibly the Screen Info panel. There are many ways to solve the same programming problems. Allegedly Joe points out every screen is assigned 4 text messages. He proposes that these could be used instead to store map coordinates. NESMaker stores the screen map in memory as a linked list of sorts (sequentially). For example:

Screen 0 -> Screen 1 -> Screen 2 -> Screen 3 -> .... Screen 255

So while the user thinks of it as X, Y map coordinates in NESMaker screen 0,1 is actually screen 16.

So when Joe says "You could even get up to 4 by just repurposing the npc string indexes...if string 0 is selected, warp reads that and sends to screen zero."
Means to me: "Hey lets take one or some of the unused text groups for any given screen, write the screen ID on a text entry and assign it on the Screen Info panel, then make a custom tile code look this up and pass it on as an argument to a warp macro or function". Since there are only four text messages allowed per screen then that's why he says the number 4.

It's not ideal cause you are using something that wasn't meant to hold screen IDs (and you could still need those for text), but it could work. Now if you wanted to get all proper then you could make a memory array just for your warp IDs. This is what I think Joe means when he says:

"Or you could make custom tables - on screen 00, there are these four warps...each of the four corresponding warps takes you to what is indexed in that slot for that table..". Again the number 4 could have been a reference to the current example being discussed. There are also deeper implications as to how to implement a table like this (e.g. one warp table for each screen or one table to rule them all?). Without having been in the discussion I can't say more.

There was a related thread here but it only focused on having one warp per screen. Some code workaround was offered, but it doesn't work correctly (v4.0.11).
 
cargo said:
If I were to guess (and this is just an opinion):

The quote refers to solving this problem using the NESMaker interface. Possibly the Screen Info panel. There are many ways to solve the same programming problems. Allegedly Joe points out every screen is assigned 4 text messages. He proposes that these could be used instead to store map coordinates. NESMaker stores the screen map in memory as a linked list of sorts (sequentially). For example:

Screen 0 -> Screen 1 -> Screen 2 -> Screen 3 -> .... Screen 255

So while the user thinks of it as X, Y map coordinates in NESMaker screen 0,1 is actually screen 16.

So when Joe says "You could even get up to 4 by just repurposing the npc string indexes...if string 0 is selected, warp reads that and sends to screen zero."
Means to me: "Hey lets take one or some of the unused text groups for any given screen, write the screen ID on a text entry and assign it on the Screen Info panel, then make a custom tile code look this up and pass it on as an argument to a warp macro or function". Since there are only four text messages allowed per screen then that's why he says the number 4.

It's not ideal cause you are using something that wasn't meant to hold screen IDs (and you could still need those for text), but it could work. Now if you wanted to get all proper then you could make a memory array just for your warp IDs. This is what I think Joe means when he says:

"Or you could make custom tables - on screen 00, there are these four warps...each of the four corresponding warps takes you to what is indexed in that slot for that table..". Again the number 4 could have been a reference to the current example being discussed. There are also deeper implications as to how to implement a table like this (e.g. one warp table for each screen or one table to rule them all?). Without having been in the discussion I can't say more.

There was a related thread here but it only focused on having one warp per screen. Some code workaround was offered, but it doesn't work correctly (v4.0.11).

Or that. :D
I'm not afraid to admit when I'm out done. :lol:
 

dale_coop

Moderator
Staff member
Agree with Cargo. I think Joe could say you could use text strings, text groups... (a hack) to implement a multi warps system per screen.

Joe used an NPC to warp the player to different screen, I think this is a hint... he uses a different screen assigned for each NPC.
For example, let's say you place 4 times the same NPC object on your main screen.
A NPC to warp you to Screen 16 (X=0,Y=1), another ont to the Screen 25 (X=9,Y=1, another one to Screen 30 (X=14,Y=1) and the last NPC would warp you to Screen 50 ((X=2,Y=3)...
You could just use "Text 16", "Text 25", "Text 30" and "Text 50"... set with any texts you want, assign them to a Text Group... and assign the Text Group to your screen (NPC group index).

Then when your NPC activate one NPC, you could know what screen (text ID) you would like to warp.
Would required some modifications in the script for NPC (maybe hacking the unused "open shop" action) and some custom warp screen with the text ID var.

i will do tests...
 

cargo

spam bots yandex
Hey RadJunk we need a [youtube] tag!

Nice! I thought about this as well (i.e. use the text entry index as opposed to write the screen index value on a text entry). I guess as long as your warp screen stays within the range of available text index values this approach would work just fine. Hope I understood you correctly.

Can you post your example code? Would love to see what variable names you are manipulating.
 

chronosv2

New member
Now I just feel silly. I was so busy thinking of all the technical ways this could be done that I overlooked the simplest method. Could even have a flag that, combined with the NPC flag, skipped the text box. And all it'd cost are some text groups.
Could have a second flag that sets the warp destination to the underworld.
 

dale_coop

Moderator
Staff member
Exactly that, cargo (sorry I wrote quickly and it’s late here >_<).
The text indexes go from 0 to 255... as screens so it’s ok.

Yeah, of course, I wanted to post the code modifications... but tomorrow, it’s too late here (I go to bed now, it’s 01:45AM)
 

Bucket Mouse

Active member
In the new demo, though, text is still functional -- you get a text box describing the level, and THEN you warp.

I want text functional anyway. Odds are good if you're using multiple warps on one screen, you need to explain something to the player as well.
 

cargo

spam bots yandex
Well not every screen may necessarily uses all its message slots. That's what Joe points out in your alleged quotes and certainly what I've seen in my experience. To me both approaches have their pros and cons. One of the pros for matching index values is that you still get to use text (as you explained). However it will complicate your text index management proportionally as you use more warps because you'll have to marry text indexes with screen IDs arbitrarily. If you use text entries instead of text indexes then you lose a few text messages but it's a lot easier to manage.
 

dale_coop

Moderator
Staff member
Using an NPC to warp the player to different screens (a different screen for each NPC).


How it works :
For example, let's say you place 4 times the same NPC object on your main screen.
A NPC to warp you to Screen 16 (X=0,Y=1), another ont to the Screen 25 (X=9,Y=1, another one to Screen 30 (X=14,Y=1) and the last NPC would warp you to Screen 50 ((X=2,Y=3)...
You could just use "Text 16", "Text 25", "Text 30" and "Text 50"... set with any texts you want, assign them to a Text Group... and assign the Text Group to your screen (NPC group index).

Then when your NPC activate one NPC, you could know what screen (text ID) you would like to warp.
Would required some modifications in the script for NPC (maybe hacking the unused "open shop" action) and some custom warp screen with the text ID var.


Here how I did:


See more in the video


1) Declare a new user variable (in "Project Settings > User Variables") : name it "TextIDScreen" with an initial value "0".
2018-12-26-11-02-56-Project-Settings.png


2) Now coding the "open shop" action (that currently does nothing). Modify the "System\HandleHUDData.asm" script (around lines 333), from :
Code:
notDOneWithText3:
	CMP #_ENDTRIGGER
	BNE notEndTrigger
	;; is an end trigger
	INC updateHUD_offset ;; get the very next value.
	LDY updateHUD_offset
	LDA (temp16),y
	STA temp
	;;;; this now has the trigger to change.
	TriggerScreen temp
	JMP DoneWithText
notEndTrigger:
to:
Code:
notDOneWithText3:
	CMP #_ENDTRIGGER
	BNE notDOneWithText4  ;; <<--- check for custom warps
	;; is an end trigger
	INC updateHUD_offset ;; get the very next value.
	LDY updateHUD_offset
	LDA (temp16),y
	STA temp
	;;;; this now has the trigger to change.
	TriggerScreen temp
	JMP DoneWithText
	
;; begin check for custom warps -->> : 
notDOneWithText4:
	CMP #_ENDSHOP
	BNE notEndTrigger
	;; is an end "Open SHOP"
	INC updateHUD_offset ;; get the very next value.
	LDY updateHUD_offset
	LDA (temp16),y
	STA temp
	;;;; this now has the trigger to change.
	LDY stringTemp
	LDA screenText,y
	STA TextIDScreen
	JMP DoneWithText
;; <<-- end check for custom warps

notEndTrigger:

3) Modify the "UserScripts\UserSubroutines.asm", adding this subroutine (at the end of the script):
Code:
WarpToTextIDScreen:
	LDA #%11000000
		;7 = active
		;6 = 8 or 16 px tiles
	ORA #GS_MainGame
	ORA #%01000000
	STA update_screen
	LDA #%00000001
	STA update_screen_details ;; load from map 1
	;;LDA #$13
	LDA TextIDScreen
	STA newScreen
	STA currentScreen
	LSR
	LSR
	LSR
	LSR
	LSR
	STA screenBank
	LDA #$02
	STA screen_transition_type
	LDA #$00 
	STA TextIDScreen
	RTS

4) Modify the "System\DrawNPCText.asm" script (at line 95), from this:
Code:
dontLoadANewTextString:
	
	HideBox #BOX_1_ORIGIN_X,#BOX_1_ORIGIN_Y,#BOX_1_WIDTH, #BOX_1_HEIGHT, #BOX_1_ATT_WIDTH, #BOX_1_ATT_HEIGHT
	LDA gameHandler
	AND #%11011111
	STA gameHandler
	ShowSprites
	LDA #$00
	STA textBoxFlag
	STA updateHUD_offset
dontTurnOffTextBox:
    rts
to:
Code:
dontLoadANewTextString:
	
	HideBox #BOX_1_ORIGIN_X,#BOX_1_ORIGIN_Y,#BOX_1_WIDTH, #BOX_1_HEIGHT, #BOX_1_ATT_WIDTH, #BOX_1_ATT_HEIGHT
	LDA gameHandler
	AND #%11011111
	STA gameHandler
	ShowSprites
	LDA #$00
	STA textBoxFlag
	STA updateHUD_offset
	
	;; begin check for custom warps:
	LDA TextIDScreen
	BEQ dontTurnOffTextBox  
	JMP WarpToTextIDScreen
	;; end check for custom warps
	
dontTurnOffTextBox:
    rts


5) Make some NPC monster/objects and put them on the screen

6) Set your Texts, for the screen warps. If you want a warp to Screen 16 (X=0, Y=1) then set your "Text 16"... and a warp to Screen 25, set your "Text 25" (X=9,Y=1)... using the text index corresponding the screen index you want.
2018-12-26-10-53-22.png

And for each Text you set, chose the "Open Shop" action (currently not used so we will use it for the warp to the textindex screen).

6) Add all those warp Text to a Text Group:
2018-12-26-10-56-14.png

And assign the Text Group to your main screen:
2018-12-26-10-56-29-Screen-Details.png


Now, the multi warps should work.
 
I was depending on this code for my game. Or specifically, I need a warp that changes location if the screen has been triggered.

It seems that Dale's code doesn't work with the latest nesmaker, as the asm files look completely different than how he's describing.

Is it possible to update the code, Dale? Or is there another way to accomplish this task?

Thanks for the help.
 

dale_coop

Moderator
Staff member
You really need that? multiples warps using NPCs?
I can try to find some time tomorrow to update it...
 
Specifically I need to have a warp that changes location when the screen is triggered. Using an NPC seems like a good way to accomplish that, if I can get it to work.

Actually, there seems to be some optional warp code in the System/HandleTextBox.asm, around line 670ish, but I don't understand how I'd target the screens that I want to warp to.

;;;; THIS WOULD WARP YOU TO A SCREEN AFTER TEXTBOX.
; LDA #$01
; STA activateWarpFlag
; PlaySound #SND_ENTER
; LDX player1_object
; LDA Object_x_hi,x
; STA mapPosX
; LDA Object_y_hi,x
; STA mapPosY
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Actually, Dale, I've almost gotten your code to work. The code to be modified in HandleHUDData.asm and DrawNPCText.asm can both be found HandleTextBox.asm, around lines 300 and 660 respectively. My problem is that I still can't seem to control where the player warps too. Regardless of the text entry I use as a warp, I always end up one screen to left and one screen up.

Sorry for being a pain. I know you've got your own stuff to work on. I appreciate the help, but I completely understand if you don't have time to help me. I'm sure I can come up with an alternative somehow.
 

dale_coop

Moderator
Staff member
Oh on, so take a look at this post:
http://nesmakers.com/viewtopic.php?f=40&t=2009

Exactly what you need...?
 
This is just uses the screen info warp coordinates, right?

I need my warp location to change if the screen is triggered. Unless I've misunderstood, I don't think that script lets me do that.

Update:
I've almost got your multiple-warp script working. It does work, but for some reason it warps me more than once. I talk to the NPC and when the warp happens, I see the screen I want to go to flicker, but then I'm warped again to the screen that's one to the left and one screen up from the NPC that warped me.

So it's warping multiple times for some reason. Hopefully I can figure out why.
 

dale_coop

Moderator
Staff member
Here's a the tutorial to implement that for the Two Players module NESmaker 4.1.5:
http://nesmakers.com/viewtopic.php?p=16594#p16594
 
Top Bottom