Changing player object upon warp-into flagged screen

dale_coop

Moderator
Staff member
I think the scripts you are using and the ones for the maze are similar, so you won't need to modify yours.
...I think (I'd have to check).
 

Raftronaut

Member
The character currently does not change to idle animation when movement is stopped.
The shooter module certainly does not change to Idle animation at all.

Maybe I will dig into the StopPlayerMovement scripts of Maze game and compare to the shooter when I get home tonight.

I currently have the cardinal movement scripts ready to go. Maybe I could use your branching arguments from the movement scripts to change player state to Idle..

I'm so excited to see this working!
 

dale_coop

Moderator
Staff member
Looks like the shooter StopMovingPlayerLeft is just a:
Code:
	StopMoving player1_object, STOP_LEFT
Yep, you need to modify them like you did for the StartMovingXXX ones...

Something like that (for the stop MovingPlayerLeft):
Code:
;;;;; STOP MOVING PLAYER LEFT:
;;; ON SINGLE SCREEN :
LDA screenFlags
AND #%10000000
BNE +
jmp +++
+

    StopMoving player1_object, STOP_LEFT
	GetCurrentActionType player1_object
    CMP #$02 ;; if the state is invincible
    BCS + 
    LDX player1_object

	;;; and we will change the object state to idle.
    ChangeObjectState #$00, #$04  
	+ 
	RTS
	
+++


    StopMoving player1_object, STOP_LEFT
    
    RTS

For other scripts, just replace the "_LEFT" with other directions.
 

Raftronaut

Member
dale_coop said:
Looks like the shooter StopMovingPlayerLeft is just a:
Code:
	StopMoving player1_object, STOP_LEFT
Yep, you need to modify them like you did for the StartMovingXXX ones...

Something like that (for the stop MovingPlayerLeft):
Code:
;;;;; STOP MOVING PLAYER LEFT:
;;; ON SINGLE SCREEN :
LDA screenFlags
AND #%10000000
BNE +
jmp +++
+

    StopMoving player1_object, STOP_LEFT
	GetCurrentActionType player1_object
    CMP #$02 ;; if the state is invincible
    BCS + 
    LDX player1_object

	;;; and we will change the object state to idle.
    ChangeObjectState #$00, #$04  
	+ 
	RTS
	
+++


    StopMoving player1_object, STOP_LEFT
    
    RTS

For other scripts, just replace the "_LEFT" with other directions.

Awesome! I will get these scripts written out and assigned. I did some testing last night and did not get the results that I was looking for.
First I added to the movement scripts for each cardinal direction hoping to get my movement animations working. I assigned them to my controller inputs. They Did not work, the only animation I was able to trigger was walk_down. (as seen in my last video)
Is it possible that the other animations will not work until I set up my StopMovement scripts?

Also. I was not able to get Collectable victory working either. ( I followed along with the instructions to fix the bug). I realized that I had already changed HandleScreenLoads.asm script with the changes that Frankenpgraphics suggested for smoother screen loads.
I inserted the bug fix:
Code:
LDA #$00
	STA screenPrizeCounter  ; reset to 0 the screenPrizeCounter collectables

But with the Frankengraphics fix in place it doesn't seem to work (I inserted at around line 25).
Did I not insert the code into the right place?
Here is my entire script for HandleScreenLoads:
Code:
HandleScreenLoads:
	LDA update_screen
	AND #%10000000 ;; are we cued to update screen?
	BNE screenIsCued 
	JMP noNewScreen
screenIsCued:
;;;;;;;;;;;;;;;;;;;
;;;; handle how NMI updates will be observed.
;==========================================================
;this block modified by FrankenGraphics 2019-03-29
;==========================================================
	LDA #$00
	STA $2001 
	STA soft2001 ;we actually still need soft2001 for mainASM.asm to evaluate 3 different situations.  
	;JSR WaitFrame ;;all these calls are commented out since they actually doesn't do anything for us at this point.
	LDA #$01
	STA canUpdateScreen
;==========================================================
;end of mod - except for the redundant jsr:s cpmmented out 
;==========================================================
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;; SET SCREENS RELATIVE TO THE SCREEN TO BE LOADED

	LDA #$00
	STA screenPrizeCounter  ; reset to 0 the screenPrizeCounter collectables


	LDA newGameState
	STA gameSubState
	
	LDA loadObjectFlag
	BEQ +
	LDA #$00
	STA loadObjectFlag
	LDA playerToSpawn
	CreateObject newX, newY, playerToSpawn, #$00, currentNametable
	TXA
	STA player1_object
+



	
	LDA newScreen
	STA currentScreen
	STA currentNametable
	STA nt_hold
	CLC
	ADC #$01
	STA rightNametable
	SEC
	SBC #$02
	STA leftNametable
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	LDA update_screen
	AND #%00001111
	STA gameState
	;;; the high four bits for update screen activate screen updates.
	;;; the low four bits give 16 potential gameStates
	;;; This is loaded in whatever screen the player is moving from,
	;;; whether by a warp or screen edge or whatever.
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; GET THE SCREEN BANK FOR THE SCREEN TO BE LOADED.
	LDA #$00
	STA update_screen_hud_offset

	LDA update_screen_details
	BEQ + ; is special screen
	JMP notSpecialScreenLoad
+
	LDA #$00
	STA showingNametable
	STA columnTracker
	STA xScroll_hi
	STA xScroll
	
	;;;;; THIS SCREEN IS A SPECIAL SCREEN
	;;;;; Special screens are stored in bank #$1E
	LDA #$1E
	STA screenBank
	LDA newScreen
	ASL
	STA temp
	
	LoadNametableFull screenBank, temp, #$10, #$0f, #$20, #$00
	LoadAttributeData screenBank, temp, #$0, #$00
	
	; arg0 - screen bank
	; arg1 - special screen number
	; arg2 - columns to load
	; arg3 - rows to load
	; arg4 - start position hi
	; arg5 - start position lo
	
	;; Need to load background graphics.
	;LDA #$00
	LDA newScreen
	STA backgroundTilesToLoad
;;;;;;;;;;;;;; GET INDEX FOR CHR DATA	
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	LDY backgroundTilesToLoad
	
	LDA #CHRAddressLo,y
	STA temp16
	LDA #CHRAddressHi,y
	STA temp16+1
	
	;LDA #<startScreenTiles
	;STA temp16
	;LDA #>startScreenTiles
	;STA temp16+1
	
	LoadChrData #BANK_STARTSCREEN_CHR, #$10, #$0, #$0
;	LoadNametableData #$1E, NT_StartScreen, #$00, #$00, #$00
	LDY prevBank
	JSR bankswitchY

	
	;;;;;;;;;;;;;; GET INDEX FOR PAL data
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	LDY newScreen
	
	LDA #SpecialBackPalLo,y
	STA temp16
	LDA #SpecialBackPalHi,y
	STA temp16+1
	
	LDY prevBank
	JSR bankswitchY
	
	LoadBackgroundPalette ;BckPal00 ;; we need to get this from screen info
	
;	LoadNametableData #$1E, NT_StartScreen, #$00, #$00, #$00
	LDY prevBank
	JSR bankswitchY
	;;;; any other special screen considerations go here.
	JMP EndLoadScreen
notSpecialScreenLoad:
	GetScreenBank newScreen
	;;; The above gets the screen bank of the screen loaded in newScreen.
gotScreenBank:
	
	;;; CHECK IF EVEN OR ODD SCREEN
	LDA newScreen
	AND #%00000001
	BNE notEvenScreen
	LDA #$00
	STA columnTracker
	STA showingNametable
	JMP gotColumnTrackerValue
notEvenScreen:
	LDA #%00010000
	STA columnTracker
	STA columnToUpdate
	LDA #$01
	STA showingNametable
gotColumnTrackerValue
	LDA #$01
	STA skipNMI
	
	LdA update_screen_details
	CMP #$01
	;;; if it is zero, it is a special screen.
	;;; one is map 1
	;;; two is map 2	
	BNE +
	LDA #$00
	STA currentMap
	JMP ++
+
	LDA #$01
	STA currentMap
++
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; LOAD SCREEN DATA:	
	
	LoadScreen screenBank, currentMap, newScreen, #SCREEN_DATA_OFFSET
	;;;; if newScreen, the screen that is being loaded
	;;;; is an odd screen, it should load the right nametable, collision and attribute table.
	;;;; otherwise it should load the left.
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; LOAD COLLISION TABLES:	
	LDA newScreen
	AND #%00000001
	STA temp
	;;; now, either 1 or 0 is in temp.
	LoadCollisionTable screenBank, currentMap, newScreen, #$10, #$0f, temp, #$00, #$00
	;;; now, we will load the right collision table.
	LDA rightNametable
	AND #%00000001
	STA temp ;; is it an even or odd screen?
	LDA rightNametable
	LSR
	LSR
	LSR
	LSR
	LSR
	STA temp1 ;; the bank for this screen
	LDA currentMap
	ASL
	ASL
	ASL
	CLC
	ADC temp1
	STA temp1
	LoadCollisionTable temp1, currentMap, rightNametable, #$08, #$0f, temp, #$00, #$00
	;;;;;;;;; now we will load the left collision table
	LDA leftNametable
	AND #%00000001
	STA temp ;; is it an even or odd screen?
	LDA leftNametable
	LSR
	LSR
	LSR
	LSR
	LSR
	STA temp1 ;; the bank for this screen
	LDA currentMap
	ASL
	ASL
	ASL
	CLC
	ADC temp1
	STA temp1
	LoadCollisionTable temp1, currentMap, leftNametable, #$08, #$0f, temp, #$04, #$08
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; COLLISION TABLES ARE LOADED
	;JSR WaitFrame
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; LOAD NAMETABLES:	
	LDA newScreen
	AND #%00000001
	BNE + ;; jump to starting on odd screen
	;;; starting on even screen.
	LDA #$20
	STA temp ;;; use for main nametable load addresses
	LDA #$24
	STA temp1 ;;; use for secondary nametable load addresses
	LDA #$23
	STA tempx ;; for attribute high byte
	LDA #$27
	STA tempy ;; for attribute high byte
	JMP ++
+	;; started on odd screen
	
	LDA #$24
	STA temp ;; use for main nametable load addresses
	LDA #$20
	STA temp1 ;; use for secondary nametable load addresses
	LDA #$27
	STA tempx ;; for attribute high byte
	LDA #$23
	STA tempy ;; for attribute high byte
++
	;;; have high byte of nametable load addresses
	;;;; LOAD MAIN NAMETABLE to primary addresses.
	LoadNametableMeta screenBank, currentMap, newScreen, #$10, #$0f, temp, #$00, #$00
	JSR WaitFrame
	;;; LOAD RIGHT NAMETABLE to secondary addresses
	LDA rightNametable
	LSR
	LSR
	LSR
	LSR
	LSR
	STA temp2  ;; screen bank for this screen
	LDA currentMap
	ASL
	ASL
	ASL
	CLC
	ADC temp2
	STA temp2
	LoadNametableMeta temp2, currentMap, rightNametable, #$08, #$0f, temp1, #$00, #$00 ;; right
	JSR WaitFrame
;;; LOAD LEFT NAMETABLE to secondary addresses
	LDA leftNametable
	LSR
	LSR
	LSR
	LSR
	LSR
	STA temp3  ;; screen bank for this screen
	LDA currentMap
	ASL
	ASL
	ASL
	CLC
	ADC temp3
	STA temp3
	LoadNametableMeta temp3, currentMap, leftNametable, #$08, #$0f, temp1, #$10, #$08 ;; left
	JSR WaitFrame
	;;; NAMETABLE LOADS ARE DONE
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; LOAD ATTRIBUTES:	
	;;;temp2 is still the bank for the right nametable, and temp3 for the left
	
	LoadAttributes screenBank, currentMap, newScreen, #$08, #$08, tempx, #$c0, #$00
	;;; Load attributes for the right screen
	LoadAttributes temp2, currentMap, rightNametable, #$04, #$08, tempy, #$c0, #$00
		;;; Load attributes for the left screen
	LoadAttributes temp3, currentMap, leftNametable, #$04, #$08, tempy, #$c4, #$04

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;END LOADING SCREENS.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	LDA screenFlags
	AND #%10000000
	BEQ +
    LDX player1_object
    DeactivateCurrentObject
    LDA #OBJ_PLAYER_2
    STA playerToSpawn    
    CreateObject newX, newY, playerToSpawn, #$00, currentNametable
    STX player1_object
    +

;;;;;;;;;;;;HANDLE SPECIAL TILE GRAPHICS.
	
;;;;;;;;;;;;;HANDLE MAIN GAMEPLAY TILE GRAPHICS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	LDX newPal
	LDA GameBckPalLo,x
	STA temp16
	LDA GameBckPalHi,x
	STA temp16+1
	LDY prevBank
	JSR bankswitchY
	
	LoadBackgroundPalette ;BckPal00 ;; we need to get this from screen info

	LDA graphicsBank
	STA update_screen_bck_graphics_bank
	;JSR WaitFrame
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	LDX backgroundTilesToLoad   ;; we get background tiles to load from screen info. 
	LDA #BckCHRAddLo,x
	STA temp16
	LDA #BckCHRAddHi,x
	STA temp16+1
	LDY prevBank
	JSR bankswitchY	
	;;; load graphics for new screen

	LoadChrData update_screen_bck_graphics_bank, #$10, #$00, #$60
	
	;JSR WaitFrame
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	
	LDX screenSpecificTilesToLoad   ;; we get background tiles to load from screen info. 
	;LDX #$00
	LDA #BckSSChrAddLo,x
	STA temp16
	LDA #BckSSChrAddHi,x
	STA temp16+1
	LDY prevBank
	JSR bankswitchY
	
	;;; load graphics for new screen

	LoadChrData update_screen_bck_graphics_bank, #$16, #$00, #$20
	
	
	;;=====================NOW LOAD THE PATHS
	; path 0 gets loaded into row 18
	; path 1 gets laoded into row 19
	; path 2 gets loaded into row 1a
	; path 3 gets loaded into row 1b
	
	;JSR WaitFrame
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	
	LDX pathTile00   ;; we get background tiles to load from screen info. 
	;LDX #$00
	LDA #PathCHRAddLo,x
	STA temp16
	LDA #PathCHRAddHi,x
	STA temp16+1
	LDY prevBank
	JSR bankswitchY
	
	;;; load graphics for new screen

	LoadChrData update_screen_bck_graphics_bank, #$18, #$00, #$10
	
	
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	
	LDX pathTile01   ;; we get background tiles to load from screen info. 
	;LDX #$00
	LDA #PathCHRAddLo,x
	STA temp16
	LDA #PathCHRAddHi,x
	STA temp16+1
	LDY prevBank
	JSR bankswitchY
	
	;;; load graphics for new screen

	LoadChrData update_screen_bck_graphics_bank, #$19, #$00, #$10
	
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	
	LDX pathTile02   ;; we get background tiles to load from screen info. 
	;LDX #$00
	LDA #PathCHRAddLo,x
	STA temp16
	LDA #PathCHRAddHi,x
	STA temp16+1
	LDY prevBank
	JSR bankswitchY
	
	;;; load graphics for new screen

	LoadChrData update_screen_bck_graphics_bank, #$1A, #$00, #$10
	
		LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	
	LDX pathTile03   ;; we get background tiles to load from screen info. 
	;LDX #$00
	LDA #PathCHRAddLo,x
	STA temp16
	LDA #PathCHRAddHi,x
	STA temp16+1
	LDY prevBank
	JSR bankswitchY
	
	;;; load graphics for new screen

	LoadChrData update_screen_bck_graphics_bank, #$1b, #$00, #$10
	
	;;=====================END LOAD PATHS 
	
	;JSR WaitFrame
;;===============LOAD OBJECT GRAPHICS
;;=========================================
	LDA objGraphicsBank
	STA update_screen_bck_graphics_bank
;
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	LDX objectTilesToLoad   ;; we get background tiles to load from screen info. 
	LDA #MonsterAddressLo,x
	STA temp16
	LDA #MonsterAddressHi,x
	STA temp16+1
	LDY prevBank
	JSR bankswitchY
;	
;;; load graphics for new screen
	

	LoadChrData update_screen_bck_graphics_bank, #$08, #$00, #$80

;;==================================================================
;;=================================================================
	
	;;; load palette for new screen
	;JSR WaitFrame
	LoadSpritePalette newGO1Pal, newGO2Pal, newObj1Pal, newObj2Pal

	;;; load hud tiles?
	LDA #$02 
	STA backgroundTilesToLoad ;; yikes, we probably want to do something different here.
	
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	LDX backgroundTilesToLoad
	LDA #CHRAddressLo,x
	STA temp16
	LDA #CHRAddressHi,x
	STA temp16+1
	LDY prevBank
	JSR bankswitchY
	
	LoadChrData #$1d, #$1c, #$00, #$40
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;; ALL GRAPHICS ARE LOADED.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; GET FLAGS FOR OBJECTS SO WE CAN COUNT UPON LOAD.
	LDA currentBank
	STA prevBank
	LDY #BANK_ANIMATIONS
	JSR bankswitchY
	LDX #$00
DoSetMonsterFlagsLoop:
	LDA Object_status,x
	AND #%01000000 ;; is it about ready to load, but not loaded yet?
	BEQ + ;skip setting flag.
	LDY Object_type,x
	LDA ObjectFlags,y
	STA Object_flags,x
+
	INX
	CPX #TOTAL_MAX_OBJECTS
	BNE DoSetMonsterFlagsLoop
	LDY prevBank
	JSR bankswitchY

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;; HANDLE LOADING HUD, IF ENABLED
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	LDA #HIDE_HUD
	BEQ dontHideHud
	JMP skipDrawingHud_GameHandler
dontHideHud
	LDA HudHandler
	AND #%10000000
	BNE drawHud_GameHandler
	JMP skipDrawingHud_GameHandler
drawHud_GameHandler:
	LDA screenFlags
	AND #%00000001
	BEQ screenDrawsHud
	JMP skipDrawingHud_GameHandler
screenDrawsHud:
;; check to see if hud is shown.
	;; if hud is hidden, skip
	;; otherwise...
	;;; prep hud area load
	;JSR WaitFrame
	LDA #BOX_0_WIDTH 
	STA updateNT_columns
	LDA #BOX_0_HEIGHT
	STA updateNT_rows
	LDA #BOX_0_ORIGIN_X
	STA tileX
	LDA #BOX_0_ORIGIN_Y
	STA tileY
	JSR FillBoxArea
	;JSR WaitFrame
	;;;;;;;;;;;;;;;;
	;; set up attribute routine needs
	LDA #BOX_0_ORIGIN_X
	STA tileX
	LDA #BOX_0_ORIGIN_Y
	STA tileY 
	LDA #BOX_0_ATT_WIDTH
	STA updateNT_attWidth
	LDA #BOX_0_ATT_HEIGHT
	STA updateNT_attHeight
	;;;;;;;;;;;;;;;
	JSR UpdateAttributeTable
	;; first turn off drawing sprites.
	;JSR WaitFrame
	LDA #$00
	STA textboxHandler
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	LDA currentBank
	STA prevBank
	LDY #$14
	JSR bankswitchY

	;JSR HandleLoadHud
	LDA #HUD_LOAD

	STA DrawHudBytes
	JSR HandleHudData
	LDA #$00
	STA ActivateHudUpdate

	JSR CheckForTriggers
	JSR CheckForMonsters
	
	LDY prevBank
	JSR bankswitchY

	
;	.include ROOT\System\HandleScreenLoadHudDraw.asm
skipDrawingHud_GameHandler:
	;;====================================
	LDA navFlag
	AND #%00000010
	BEQ dontForceSong
	LDA navFlag
	AND #%11111101
	STA navFlag
	JMP +
dontForceSong:
	LDA songToPlay
	STA temp
	
	CMP currentSong ;; the song for this screen is same as last
	BEQ DoneWithThisScreenLoad
	; the song is different
+	
	PlaySong songToPlay
	LDA temp
	STA currentSong

DoneWithThisScreenLoad:	
	;LDA #$00
	;STA update_screen
	;;;
	;; if we are starting game
	;; we use the player position
	;; in the constants as the starting position.

	LDA screen_transition_type
	BNE notStartingGameTransitionType

	;; set newX and newY to the game start positions
	LDA #START_POSITION_PIX_X 
	STA newX
	LDA #START_POSITION_PIX_Y
	STA newY
	JMP doneWithScreenTransition
notStartingGameTransitionType:
	CMP #$01
	BNE notNormalScreenToScreenUpdate

	LDA screenFlags
	AND #%00100000 ;; does it use gravity?
	BNE keepVspeed
	LDX player1_object
	LDA #$00
	STA Object_v_speed_lo,x
	STA Object_v_speed_hi,x
keepVspeed:
	
	;; normal screen to screen update. 
	;; this just skips observing newX and newY load
	JMP doneWithScreenTransition
notNormalScreenToScreenUpdate:
	CMP #$02
	BNE notWarpTypeTransition
	LDX player1_object
	LDA newX
	STA xHold_hi
	STA Object_x_hi,x
	LDA newY
	STA yHold_hi
	STA Object_y_hi,x
	LDA #$00
	STA Object_x_lo,x
	STA Object_y_lo,x
	STA xHold_lo
	STA yHold_lo
		JMP doneWithScreenTransition
notWarpTypeTransition:
	CMP #$03
	BNE notMapReturnTransition
	LDX player1_object
	LDA mapPosX
	STA xHold_hi
	STA Object_x_hi,x
	LDA mapPosY
	STA yHold_hi
	STA Object_y_hi,x
	LDA #$00
	STA Object_x_lo,x
	STA Object_y_lo,x
	STA xHold_lo
	STA yHold_lo
		JMP doneWithScreenTransition
	
	
notMapReturnTransition:
	CMP #$04
	BNE notContinueScreen
	LDX player1_object
	LDA continuePositionX
	STA xHold_hi
	STA Object_x_hi,x
	LDA continuePositionY
	STA yHold_hi
	STA Object_y_hi,x
	LDA #$00
	STA Object_x_lo,x
	STA Object_y_lo,x
	STA xHold_lo
	STA yHold_lo
	;;; any other thing that needs to happen on continuePositionX
	JMP doneWithScreenTransition
notContinueScreen:

doneWithScreenTransition:


	LDA screenFlags
	AND #%10000000
	BNE EndLoadScreen
	LDA #$01
	STA forceScroll
	LDA #$00
	STA prevent_scroll_flag
	STA updateNametable

EndLoadScreen:



	LDA #$00
	STA updateNT_fire_Att
	STA updateNT_fire_Att+1
	STA updateNT_fire_Att+2
	STA updateNT_fire_Att+3
	STA updateNT_fire_Att+4
	STA updateNT_fire_Att+5
	STA updateNT_fire_Att+6
	STA updateNT_fire_Att+7
	
	STA updateNT_att_fire_Address_lo
	STA updateNT_att_fire_Address_lo+1
	STA updateNT_att_fire_Address_lo+2
	STA updateNT_att_fire_Address_lo+3
	STA updateNT_att_fire_Address_lo+4
	STA updateNT_att_fire_Address_lo+5
	STA updateNT_att_fire_Address_lo+6
	STA updateNT_att_fire_Address_lo+7
	

	
	
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	LDA gameHandler
	ORA #%10000000
	STA gameHandler
	LDA #$00 
	STA update_screen
	STA canUpdateScreen
	LDA #%00011110
	STA soft2001
	
	

	
noNewScreen:	
	RTS
if I did not insert correctly, could you please clarify?

Also, I am a little confused which collectible script I should be using.. My current collectable is just for score (which i've appropriately named Sandwich) , I made a new tile using the normal collectible script imported from the maze game. Will the victory object be created when either collectible are all gone? I am still a little confused on that. Though I did set up a victory object last night in my player objects..(wishing I could use character animation for this, as I will have to switch CHR files back to the van) At least I have a victory object to use int he mean time..

Thanks as always dale!
 

dale_coop

Moderator
Staff member
About your animations... For your character, have you made thew walking left / right animations and assigned them to your Walk animation type in the "Object Details" (for each directions)?

About the collectables... yep you need a Collectable.asm script (from the maze folder, for example..), it increases the myScore variable and creates a Victory Object (you need one, to have a End of animation to "Warp to Screen"... here, to your next screen/level)
 

Raftronaut

Member
dale_coop said:
About your animations... For your character, have you made thew walking left / right animations and assigned them to your Walk animation type in the "Object Details" (for each directions)?

About the collectables... yep you need a Collectable.asm script (from the maze folder, for example..), it increases the myScore variable and creates a Victory Object (you need one, to have a End of animation to "Warp to Screen"... here, to your next screen/level)

Hey Dale, I still cannot get it working. I replaced all the StartMovement Scripts and the StopMovement scripts with your corrections. However, implementing the StopMovement scripts means that my character does not change into walking animation at all. Previously my character would only change to WalkDown animation and not return to idle.

I've compared my character to how the player is set up in the maze game and do not see any differences what-so-ever.
I am very confused.

Here is a short video
https://youtu.be/G9YSU6P1D50

All of my animations seem to be set up correctly, along with being assigned to the correct animation direction in monster animation info:
idle.PNG


walk.PNG

Idle is action step 0:
idle 1.PNG

Walk is action step 1:
walk 1.PNG

Animation info is set correctly:
animation info.PNG


as far as creating the victory object, I am using this collectable script from the maze game:
Code:
;; COLLECTABLE - this tile requires 
;; HUD to be active and for myScore variable to be drawn.
;; To use this without this feature, comment out lines marked below.
	CPX player1_object
	BEQ isPlayerForCollectable
	JMP ++
isPlayerForCollectable:
	;LDA tileCollisionFlag
	;BEQ +
	;JMP ++
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; TO USE WITHOUT HUD, COMMENT OUT THIS BLOCK
;;; It may result in anomalies if two tiles
;;; register collision simultaneously without
;;; this block.
	;;LDA #$01
	;STA tileCollisionFlag
	ChangeTileAtCollision #$00, #$00
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	TXA
	STA tempx	
	AddValue #$08, myScore, #$01, #$00
	;;; we also need to set up the routine to update the HUD
		; LDA DrawHudBytes
		; ora #HUD_myScore
		; STA DrawHudBytes
	UpdateHud HUD_myScore
	
	
	PlaySound #SND_GET
	LDA #$00
	STA value
	STA value+1
	STA value+2
	STA value+3
	STA value+4
	STA value+5
	STA value+6
	STA value+7
	
	LDX tempx
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	DEC screenPrizeCounter
	BNE ++
	
	;;; do whatever should happen if you collect all of the prizes on this screen.
	JSR HandleNoMorePrizeTiles

++

Here is my script for NoMorePrizeTiles_CreateVictoryObject.asm:
Code:
	TXA
	STA tempx
	LDX player1_object
	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	STA temp1
	CreateObject temp, temp1, #OBJ_PLAYER_VICTORY, #$00, currentNametable
	LDX player1_object
	DeactivateCurrentObject
	LDA #$01
	STA loadObjectFlag
	StopSound
	LDA #$ff
	
	PlaySound #SND_VICTORY
	LDX tempx

Is it possible there is something incorrect on the scripting side? Maybe upon warp into single screen game script? Or in the movement scripts?
The directional movement works just fine, but changing animation states does not...I am completely stumped...

So close!
 

Raftronaut

Member
dale_coop said:
Could you share your stop moving player scripts? the issue might come from them.

Sure thing!

StopMovingPlayerDown:
Code:
;;;;; STOP MOVING PLAYER DOWN:
;;; ON SINGLE SCREEN :
LDA screenFlags
AND #%10000000
BNE +
jmp +++
+

    StopMoving player1_object, STOP_DOWN
	GetCurrentActionType player1_object
    CMP #$02 ;; if the state is invincible
    BCS + 
    LDX player1_object

	;;; and we will change the object state to idle.
    ChangeObjectState #$00, #$04  
	+ 
	RTS
	
+++


    StopMoving player1_object, STOP_DOWN
    
    RTS

StopMovingPlayerUp:
Code:
;;;;; STOP MOVING PLAYER UP:
;;; ON SINGLE SCREEN :
LDA screenFlags
AND #%10000000
BNE +
jmp +++
+

    StopMoving player1_object, STOP_UP
	GetCurrentActionType player1_object
    CMP #$02 ;; if the state is invincible
    BCS + 
    LDX player1_object

	;;; and we will change the object state to idle.
    ChangeObjectState #$00, #$04  
	+ 
	RTS
	
+++


    StopMoving player1_object, STOP_UP 
    
    RTS

StopPlayerMovingLeft:
Code:
;;;;; STOP MOVING PLAYER LEFT:
;;; ON SINGLE SCREEN :
LDA screenFlags
AND #%10000000
BNE +
jmp +++
+

    StopMoving player1_object, STOP_LEFT
	GetCurrentActionType player1_object
    CMP #$02 ;; if the state is invincible
    BCS + 
    LDX player1_object

	;;; and we will change the object state to idle.
    ChangeObjectState #$00, #$04  
	+ 
	RTS
	
+++


    StopMoving player1_object, STOP_LEFT
    
    RTS

StopPlayerMovingRight:
Code:
;;;;; STOP MOVING PLAYER RIGHT:
;;; ON SINGLE SCREEN :
LDA screenFlags
AND #%10000000
BNE +
jmp +++
+

    StopMoving player1_object, STOP_RIGHT
	GetCurrentActionType player1_object
    CMP #$02 ;; if the state is invincible
    BCS + 
    LDX player1_object

	;;; and we will change the object state to idle.
    ChangeObjectState #$00, #$04  
	+ 
	RTS
	
+++


    StopMoving player1_object, STOP_RIGHT
    
    RTS
 

dale_coop

Moderator
Staff member
Everything looks correct. Don't see what is causing the issue, here.

If you could share your NESmaker project, I would check everything...? (I'd need the project .MST file, the GraphicAssets and the GameEngineData folders).
 

Raftronaut

Member
dale_coop said:
Everything looks correct. Don't see what is causing the issue, here.

If you could share your NESmaker project, I would check everything...? (I'd need the project .MST file, the GraphicAssets and the GameEngineData folders).

I would be totally willing to do that, is it best to DM you the zip file?
 

dale_coop

Moderator
Staff member
Hey Raft...
I checked your project, the issue come from your startMovingPlayerXXX script. As I wrote, the code I gave you needs to be place before the current code. You added it after. So basically the modifications were ignored.

Here the full script, for StartMovingDown.asm:

Code:
;;;;; START MOVING PLAYER DOWN:
;;; ON SINGLE SCREEN :
LDA screenFlags
AND #%10000000
BNE +
jmp +++
+
 ;;;;; We will use this when the down button is pressed.
 ;;;;; If we are already showing the walking animation, which is for this module
 ;;;;; action step 1, we will skip changing to the walking state.
    LDX player1_object
    GetCurrentActionType player1_object
    CMP #$02 ;; if the state is invincible
    BcS + 
    CMP #$01
    BEQ + ;; if the action type already equals 1, jump forward
    ChangeObjectState #$01, #$04
+
;;;;;; Then, we will begin moving.
    StartMoving player1_object, MOVE_DOWN
;;;;;; Lastly, we will change the facing direction.
    FaceDirection player1_object, FACE_DOWN
    RTS
+++
;;; ELSE :


    StartMoving player1_object, MOVE_DOWN
    RTS


Do the same for ALL your start moving player scripts (maybe, you'll have to do for your diagonals scripts, too).
 

Raftronaut

Member
dale_coop said:
Hey Raft...
I checked your project, the issue come from your startMovingPlayerXXX script. As I wrote, the code I gave you needs to be place before the current code. You added it after. So basically the modifications were ignored.

Here the full script, for StartMovingDown.asm:

Code:
;;;;; START MOVING PLAYER DOWN:
;;; ON SINGLE SCREEN :
LDA screenFlags
AND #%10000000
BNE +
jmp +++
+
 ;;;;; We will use this when the down button is pressed.
 ;;;;; If we are already showing the walking animation, which is for this module
 ;;;;; action step 1, we will skip changing to the walking state.
    LDX player1_object
    GetCurrentActionType player1_object
    CMP #$02 ;; if the state is invincible
    BcS + 
    CMP #$01
    BEQ + ;; if the action type already equals 1, jump forward
    ChangeObjectState #$01, #$04
+
;;;;;; Then, we will begin moving.
    StartMoving player1_object, MOVE_DOWN
;;;;;; Lastly, we will change the facing direction.
    FaceDirection player1_object, FACE_DOWN
    RTS
+++
;;; ELSE :


    StartMoving player1_object, MOVE_DOWN
    RTS


Do the same for ALL your start moving player scripts (maybe, you'll have to do for your diagonals scripts, too).

Now, my next question is why isn't my victory object creating when I clear the collectables?

Any thoughts?
 

Raftronaut

Member
Ok!

Now that movement animation is working I have two immediate concerns. First, how to activate victory object, And Second how to branch to a separate death animation when in Maze game.
In the video here, you will see the collectables cleared and nothing happening, followed by player running into the monster and creating the original player's death object. (also note, apparently I have not done the check on player projectile yet for Single screen, i will put this on my list)
https://www.youtube.com/watch?v=Pl9iDKOjKB4&feature=youtu.be

So in order to create Victory object, I assume I would first need to create a user constant, which I have done:
user contants victory object.PNG

I linked it to object number 6, which I have created here:
victory object.PNG

I set up the animation to play and warp after a timer, but it is not seeming to work yet.

NEXT, I set up my player death animations, The second two steps here are the sequence I would like to play upon the player dying in single screen mode:
maze death.PNG

I set up action step one to feed into action step two, which concludes in a reset:
Action step one:
maze death action one.PNG
Action step two:
Maze death action 2.PNG

How would I edit my handle player death script to branch to this separate animation when single screen flag is checked?
Here is my current HandlePlayerDeath:
Code:
    TXA
    STA tempx
    TYA 
    STA tempy

    ;;;;;;;;;;;;;;;;;;;
    LDX player1_object
    LDA Object_x_hi,x
    STA temp
    LDA Object_y_hi,x
    STA temp1

    DeactivateCurrentObject
    
    CreateObject temp, temp1, #OBJ_PLAYER_DEATH, #$00, currentNametable
    ;;;;;;;;;;;;;;;;;;;
    StopSound
    ;PlaySound #$00, #$00
    LDA #$FF
    STA player1_object
    
    LDX tempx
    LDY tempy



And Finally, Is it possible to play a character animation before switching to player Death or Player Victory?
Perhaps The NOMorePrizeTiles script could be edited to play victory animation in the current character CHR file, THEN have an AI action create the actual PLAYER Victory object which could be a little "Poof" followed by warp. Do you think this would be possible?
The same could be done for Maze PLayer Death, When dead player character animation and when done create PLayer Death object..
I set up both victory and Death animations within my Maze Player so I could still use that CHR File:

death and victory animations.PNG

Does this make any sense? Looking for ways to conserve CHR space and still have full animations...
 

dale_coop

Moderator
Staff member
If you check your user constants (at the begining of the list), you will see that you have already the "OBJ_PLAYER_VICTORY", that is actually used by the "NoMorePrize_CreateVictoryObject.asm" script (assgined to the "Handle No More Prize Tiles" element).
Just set the correct value to THAT constant (you don't need to add a new constant).

And for your Handle Player Death... could be somehting like:
Code:
	TXA
	STA tempx
	TYA 
	STA tempy

	;;;;;;;;;;;;;;;;;;;
	LDX player1_object
	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	STA temp1

	DeactivateCurrentObject
	
	
	
	
	LDA screenFlags
	AND #%10000000
	BEQ +
	;;; ON Single Screen:
	CreateObject temp, temp1, #OBJ_PLAYER_DEATH, #$02, currentNametable
	JMP ++
	+	
	;;; NOT on Single Screen:
	CreateObject temp, temp1, #OBJ_PLAYER_DEATH, #$00, currentNametable
	++
	
	
	
	;;;;;;;;;;;;;;;;;;;
	StopSound
	;PlaySound #$00, #$00
	LDA #$FF
	STA player1_object
	
	LDX tempx
	LDY tempy
 

Raftronaut

Member
dale_coop said:
If you check your user constants (at the begining of the list), you will see that you have already the "OBJ_PLAYER_VICTORY", that is actually used by the "NoMorePrize_CreateVictoryObject.asm" script (assgined to the "Handle No More Prize Tiles" element).
Just set the correct value to THAT constant (you don't need to add a new constant).

And for your Handle Player Death... could be somehting like:
Code:
	TXA
	STA tempx
	TYA 
	STA tempy

	;;;;;;;;;;;;;;;;;;;
	LDX player1_object
	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	STA temp1

	DeactivateCurrentObject
	
	
	
	
	LDA screenFlags
	AND #%10000000
	BEQ +
	;;; ON Single Screen:
	CreateObject temp, temp1, #OBJ_PLAYER_DEATH, #$02, currentNametable
	JMP ++
	+	
	;;; NOT on Single Screen:
	CreateObject temp, temp1, #OBJ_PLAYER_DEATH, #$00, currentNametable
	++
	
	
	
	;;;;;;;;;;;;;;;;;;;
	StopSound
	;PlaySound #$00, #$00
	LDA #$FF
	STA player1_object
	
	LDX tempx
	LDY tempy

Ok Great! Death object is created correctly upon player death now.

I still have had no luck getting create victory object to work. Yesterday I did notice that OBJ_PLAYER_VICTORY was already in my user constants as you said. I redefined the constant to #6 Shown here:
object victory.PNG
This should line up with my Victory Object:
victory object.PNG


I am very confused currently. I am trying both the Maze game collectable script and Collectable just-for-score and neither seems to do anything . I am trying to think of other reasons it may not work, or perhaps something I have overlooked but nothing comes to mind... The only thing I keep thinking is maybe I edited my HandleScreenLoads.asm to fix the bug in the wrong place in the code.

I followed the instructions to fix the bug from here: http://nesmakers.com/viewtopic.php?p=13494#p13494

I added the lines To my HandleScreenLoads.asm:
Code:
LDA #$00
	STA screenPrizeCounter  ; reset to 0 the screenPrizeCounter collectables

This is my complete HandleScreenLoads.asm script, you can see that changes I made roughly at line#25 Here:

Code:
HandleScreenLoads:
	LDA update_screen
	AND #%10000000 ;; are we cued to update screen?
	BNE screenIsCued 
	JMP noNewScreen
screenIsCued:
;;;;;;;;;;;;;;;;;;;
;;;; handle how NMI updates will be observed.
;==========================================================
;this block modified by FrankenGraphics 2019-03-29
;==========================================================
	LDA #$00
	STA $2001 
	STA soft2001 ;we actually still need soft2001 for mainASM.asm to evaluate 3 different situations.  
	;JSR WaitFrame ;;all these calls are commented out since they actually doesn't do anything for us at this point.
	LDA #$01
	STA canUpdateScreen
;==========================================================
;end of mod - except for the redundant jsr:s cpmmented out 
;==========================================================
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;; SET SCREENS RELATIVE TO THE SCREEN TO BE LOADED

	LDA #$00
	STA screenPrizeCounter  ; reset to 0 the screenPrizeCounter collectables


	LDA newGameState
	STA gameSubState
	
	LDA loadObjectFlag
	BEQ +
	LDA #$00
	STA loadObjectFlag
	LDA playerToSpawn
	CreateObject newX, newY, playerToSpawn, #$00, currentNametable
	TXA
	STA player1_object
+



	
	LDA newScreen
	STA currentScreen
	STA currentNametable
	STA nt_hold
	CLC
	ADC #$01
	STA rightNametable
	SEC
	SBC #$02
	STA leftNametable
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	LDA update_screen
	AND #%00001111
	STA gameState
	;;; the high four bits for update screen activate screen updates.
	;;; the low four bits give 16 potential gameStates
	;;; This is loaded in whatever screen the player is moving from,
	;;; whether by a warp or screen edge or whatever.
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; GET THE SCREEN BANK FOR THE SCREEN TO BE LOADED.
	LDA #$00
	STA update_screen_hud_offset

	LDA update_screen_details
	BEQ + ; is special screen
	JMP notSpecialScreenLoad
+
	LDA #$00
	STA showingNametable
	STA columnTracker
	STA xScroll_hi
	STA xScroll
	
	;;;;; THIS SCREEN IS A SPECIAL SCREEN
	;;;;; Special screens are stored in bank #$1E
	LDA #$1E
	STA screenBank
	LDA newScreen
	ASL
	STA temp
	
	LoadNametableFull screenBank, temp, #$10, #$0f, #$20, #$00
	LoadAttributeData screenBank, temp, #$0, #$00
	
	; arg0 - screen bank
	; arg1 - special screen number
	; arg2 - columns to load
	; arg3 - rows to load
	; arg4 - start position hi
	; arg5 - start position lo
	
	;; Need to load background graphics.
	;LDA #$00
	LDA newScreen
	STA backgroundTilesToLoad
;;;;;;;;;;;;;; GET INDEX FOR CHR DATA	
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	LDY backgroundTilesToLoad
	
	LDA #CHRAddressLo,y
	STA temp16
	LDA #CHRAddressHi,y
	STA temp16+1
	
	;LDA #<startScreenTiles
	;STA temp16
	;LDA #>startScreenTiles
	;STA temp16+1
	
	LoadChrData #BANK_STARTSCREEN_CHR, #$10, #$0, #$0
;	LoadNametableData #$1E, NT_StartScreen, #$00, #$00, #$00
	LDY prevBank
	JSR bankswitchY

	
	;;;;;;;;;;;;;; GET INDEX FOR PAL data
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	LDY newScreen
	
	LDA #SpecialBackPalLo,y
	STA temp16
	LDA #SpecialBackPalHi,y
	STA temp16+1
	
	LDY prevBank
	JSR bankswitchY
	
	LoadBackgroundPalette ;BckPal00 ;; we need to get this from screen info
	
;	LoadNametableData #$1E, NT_StartScreen, #$00, #$00, #$00
	LDY prevBank
	JSR bankswitchY
	;;;; any other special screen considerations go here.
	JMP EndLoadScreen
notSpecialScreenLoad:
	GetScreenBank newScreen
	;;; The above gets the screen bank of the screen loaded in newScreen.
gotScreenBank:
	
	;;; CHECK IF EVEN OR ODD SCREEN
	LDA newScreen
	AND #%00000001
	BNE notEvenScreen
	LDA #$00
	STA columnTracker
	STA showingNametable
	JMP gotColumnTrackerValue
notEvenScreen:
	LDA #%00010000
	STA columnTracker
	STA columnToUpdate
	LDA #$01
	STA showingNametable
gotColumnTrackerValue
	LDA #$01
	STA skipNMI
	
	LdA update_screen_details
	CMP #$01
	;;; if it is zero, it is a special screen.
	;;; one is map 1
	;;; two is map 2	
	BNE +
	LDA #$00
	STA currentMap
	JMP ++
+
	LDA #$01
	STA currentMap
++
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; LOAD SCREEN DATA:	
	
	LoadScreen screenBank, currentMap, newScreen, #SCREEN_DATA_OFFSET
	;;;; if newScreen, the screen that is being loaded
	;;;; is an odd screen, it should load the right nametable, collision and attribute table.
	;;;; otherwise it should load the left.
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; LOAD COLLISION TABLES:	
	LDA newScreen
	AND #%00000001
	STA temp
	;;; now, either 1 or 0 is in temp.
	LoadCollisionTable screenBank, currentMap, newScreen, #$10, #$0f, temp, #$00, #$00
	;;; now, we will load the right collision table.
	LDA rightNametable
	AND #%00000001
	STA temp ;; is it an even or odd screen?
	LDA rightNametable
	LSR
	LSR
	LSR
	LSR
	LSR
	STA temp1 ;; the bank for this screen
	LDA currentMap
	ASL
	ASL
	ASL
	CLC
	ADC temp1
	STA temp1
	LoadCollisionTable temp1, currentMap, rightNametable, #$08, #$0f, temp, #$00, #$00
	;;;;;;;;; now we will load the left collision table
	LDA leftNametable
	AND #%00000001
	STA temp ;; is it an even or odd screen?
	LDA leftNametable
	LSR
	LSR
	LSR
	LSR
	LSR
	STA temp1 ;; the bank for this screen
	LDA currentMap
	ASL
	ASL
	ASL
	CLC
	ADC temp1
	STA temp1
	LoadCollisionTable temp1, currentMap, leftNametable, #$08, #$0f, temp, #$04, #$08
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; COLLISION TABLES ARE LOADED
	;JSR WaitFrame
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; LOAD NAMETABLES:	
	LDA newScreen
	AND #%00000001
	BNE + ;; jump to starting on odd screen
	;;; starting on even screen.
	LDA #$20
	STA temp ;;; use for main nametable load addresses
	LDA #$24
	STA temp1 ;;; use for secondary nametable load addresses
	LDA #$23
	STA tempx ;; for attribute high byte
	LDA #$27
	STA tempy ;; for attribute high byte
	JMP ++
+	;; started on odd screen
	
	LDA #$24
	STA temp ;; use for main nametable load addresses
	LDA #$20
	STA temp1 ;; use for secondary nametable load addresses
	LDA #$27
	STA tempx ;; for attribute high byte
	LDA #$23
	STA tempy ;; for attribute high byte
++
	;;; have high byte of nametable load addresses
	;;;; LOAD MAIN NAMETABLE to primary addresses.
	LoadNametableMeta screenBank, currentMap, newScreen, #$10, #$0f, temp, #$00, #$00
	JSR WaitFrame
	;;; LOAD RIGHT NAMETABLE to secondary addresses
	LDA rightNametable
	LSR
	LSR
	LSR
	LSR
	LSR
	STA temp2  ;; screen bank for this screen
	LDA currentMap
	ASL
	ASL
	ASL
	CLC
	ADC temp2
	STA temp2
	LoadNametableMeta temp2, currentMap, rightNametable, #$08, #$0f, temp1, #$00, #$00 ;; right
	JSR WaitFrame
;;; LOAD LEFT NAMETABLE to secondary addresses
	LDA leftNametable
	LSR
	LSR
	LSR
	LSR
	LSR
	STA temp3  ;; screen bank for this screen
	LDA currentMap
	ASL
	ASL
	ASL
	CLC
	ADC temp3
	STA temp3
	LoadNametableMeta temp3, currentMap, leftNametable, #$08, #$0f, temp1, #$10, #$08 ;; left
	JSR WaitFrame
	;;; NAMETABLE LOADS ARE DONE
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; LOAD ATTRIBUTES:	
	;;;temp2 is still the bank for the right nametable, and temp3 for the left
	
	LoadAttributes screenBank, currentMap, newScreen, #$08, #$08, tempx, #$c0, #$00
	;;; Load attributes for the right screen
	LoadAttributes temp2, currentMap, rightNametable, #$04, #$08, tempy, #$c0, #$00
		;;; Load attributes for the left screen
	LoadAttributes temp3, currentMap, leftNametable, #$04, #$08, tempy, #$c4, #$04

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;END LOADING SCREENS.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	LDA screenFlags
	AND #%10000000
	BEQ +
    LDX player1_object
    DeactivateCurrentObject
    LDA #OBJ_PLAYER_2
    STA playerToSpawn    
    CreateObject newX, newY, playerToSpawn, #$00, currentNametable
    STX player1_object
    +

;;;;;;;;;;;;HANDLE SPECIAL TILE GRAPHICS.
	
;;;;;;;;;;;;;HANDLE MAIN GAMEPLAY TILE GRAPHICS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	LDX newPal
	LDA GameBckPalLo,x
	STA temp16
	LDA GameBckPalHi,x
	STA temp16+1
	LDY prevBank
	JSR bankswitchY
	
	LoadBackgroundPalette ;BckPal00 ;; we need to get this from screen info

	LDA graphicsBank
	STA update_screen_bck_graphics_bank
	;JSR WaitFrame
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	LDX backgroundTilesToLoad   ;; we get background tiles to load from screen info. 
	LDA #BckCHRAddLo,x
	STA temp16
	LDA #BckCHRAddHi,x
	STA temp16+1
	LDY prevBank
	JSR bankswitchY	
	;;; load graphics for new screen

	LoadChrData update_screen_bck_graphics_bank, #$10, #$00, #$60
	
	;JSR WaitFrame
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	
	LDX screenSpecificTilesToLoad   ;; we get background tiles to load from screen info. 
	;LDX #$00
	LDA #BckSSChrAddLo,x
	STA temp16
	LDA #BckSSChrAddHi,x
	STA temp16+1
	LDY prevBank
	JSR bankswitchY
	
	;;; load graphics for new screen

	LoadChrData update_screen_bck_graphics_bank, #$16, #$00, #$20
	
	
	;;=====================NOW LOAD THE PATHS
	; path 0 gets loaded into row 18
	; path 1 gets laoded into row 19
	; path 2 gets loaded into row 1a
	; path 3 gets loaded into row 1b
	
	;JSR WaitFrame
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	
	LDX pathTile00   ;; we get background tiles to load from screen info. 
	;LDX #$00
	LDA #PathCHRAddLo,x
	STA temp16
	LDA #PathCHRAddHi,x
	STA temp16+1
	LDY prevBank
	JSR bankswitchY
	
	;;; load graphics for new screen

	LoadChrData update_screen_bck_graphics_bank, #$18, #$00, #$10
	
	
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	
	LDX pathTile01   ;; we get background tiles to load from screen info. 
	;LDX #$00
	LDA #PathCHRAddLo,x
	STA temp16
	LDA #PathCHRAddHi,x
	STA temp16+1
	LDY prevBank
	JSR bankswitchY
	
	;;; load graphics for new screen

	LoadChrData update_screen_bck_graphics_bank, #$19, #$00, #$10
	
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	
	LDX pathTile02   ;; we get background tiles to load from screen info. 
	;LDX #$00
	LDA #PathCHRAddLo,x
	STA temp16
	LDA #PathCHRAddHi,x
	STA temp16+1
	LDY prevBank
	JSR bankswitchY
	
	;;; load graphics for new screen

	LoadChrData update_screen_bck_graphics_bank, #$1A, #$00, #$10
	
		LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	
	LDX pathTile03   ;; we get background tiles to load from screen info. 
	;LDX #$00
	LDA #PathCHRAddLo,x
	STA temp16
	LDA #PathCHRAddHi,x
	STA temp16+1
	LDY prevBank
	JSR bankswitchY
	
	;;; load graphics for new screen

	LoadChrData update_screen_bck_graphics_bank, #$1b, #$00, #$10
	
	;;=====================END LOAD PATHS 
	
	;JSR WaitFrame
;;===============LOAD OBJECT GRAPHICS
;;=========================================
	LDA objGraphicsBank
	STA update_screen_bck_graphics_bank
;
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	LDX objectTilesToLoad   ;; we get background tiles to load from screen info. 
	LDA #MonsterAddressLo,x
	STA temp16
	LDA #MonsterAddressHi,x
	STA temp16+1
	LDY prevBank
	JSR bankswitchY
;	
;;; load graphics for new screen
	

	LoadChrData update_screen_bck_graphics_bank, #$08, #$00, #$80

;;==================================================================
;;=================================================================
	
	;;; load palette for new screen
	;JSR WaitFrame
	LoadSpritePalette newGO1Pal, newGO2Pal, newObj1Pal, newObj2Pal

	;;; load hud tiles?
	LDA #$02 
	STA backgroundTilesToLoad ;; yikes, we probably want to do something different here.
	
	LDA currentBank
	STA prevBank
	LDY #$16
	JSR bankswitchY
	LDX backgroundTilesToLoad
	LDA #CHRAddressLo,x
	STA temp16
	LDA #CHRAddressHi,x
	STA temp16+1
	LDY prevBank
	JSR bankswitchY
	
	LoadChrData #$1d, #$1c, #$00, #$40
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;; ALL GRAPHICS ARE LOADED.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; GET FLAGS FOR OBJECTS SO WE CAN COUNT UPON LOAD.
	LDA currentBank
	STA prevBank
	LDY #BANK_ANIMATIONS
	JSR bankswitchY
	LDX #$00
DoSetMonsterFlagsLoop:
	LDA Object_status,x
	AND #%01000000 ;; is it about ready to load, but not loaded yet?
	BEQ + ;skip setting flag.
	LDY Object_type,x
	LDA ObjectFlags,y
	STA Object_flags,x
+
	INX
	CPX #TOTAL_MAX_OBJECTS
	BNE DoSetMonsterFlagsLoop
	LDY prevBank
	JSR bankswitchY

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;; HANDLE LOADING HUD, IF ENABLED
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	LDA #HIDE_HUD
	BEQ dontHideHud
	JMP skipDrawingHud_GameHandler
dontHideHud
	LDA HudHandler
	AND #%10000000
	BNE drawHud_GameHandler
	JMP skipDrawingHud_GameHandler
drawHud_GameHandler:
	LDA screenFlags
	AND #%00000001
	BEQ screenDrawsHud
	JMP skipDrawingHud_GameHandler
screenDrawsHud:
;; check to see if hud is shown.
	;; if hud is hidden, skip
	;; otherwise...
	;;; prep hud area load
	;JSR WaitFrame
	LDA #BOX_0_WIDTH 
	STA updateNT_columns
	LDA #BOX_0_HEIGHT
	STA updateNT_rows
	LDA #BOX_0_ORIGIN_X
	STA tileX
	LDA #BOX_0_ORIGIN_Y
	STA tileY
	JSR FillBoxArea
	;JSR WaitFrame
	;;;;;;;;;;;;;;;;
	;; set up attribute routine needs
	LDA #BOX_0_ORIGIN_X
	STA tileX
	LDA #BOX_0_ORIGIN_Y
	STA tileY 
	LDA #BOX_0_ATT_WIDTH
	STA updateNT_attWidth
	LDA #BOX_0_ATT_HEIGHT
	STA updateNT_attHeight
	;;;;;;;;;;;;;;;
	JSR UpdateAttributeTable
	;; first turn off drawing sprites.
	;JSR WaitFrame
	LDA #$00
	STA textboxHandler
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	LDA currentBank
	STA prevBank
	LDY #$14
	JSR bankswitchY

	;JSR HandleLoadHud
	LDA #HUD_LOAD

	STA DrawHudBytes
	JSR HandleHudData
	LDA #$00
	STA ActivateHudUpdate

	JSR CheckForTriggers
	JSR CheckForMonsters
	
	LDY prevBank
	JSR bankswitchY

	
;	.include ROOT\System\HandleScreenLoadHudDraw.asm
skipDrawingHud_GameHandler:
	;;====================================
	LDA navFlag
	AND #%00000010
	BEQ dontForceSong
	LDA navFlag
	AND #%11111101
	STA navFlag
	JMP +
dontForceSong:
	LDA songToPlay
	STA temp
	
	CMP currentSong ;; the song for this screen is same as last
	BEQ DoneWithThisScreenLoad
	; the song is different
+	
	PlaySong songToPlay
	LDA temp
	STA currentSong

DoneWithThisScreenLoad:	
	;LDA #$00
	;STA update_screen
	;;;
	;; if we are starting game
	;; we use the player position
	;; in the constants as the starting position.

	LDA screen_transition_type
	BNE notStartingGameTransitionType

	;; set newX and newY to the game start positions
	LDA #START_POSITION_PIX_X 
	STA newX
	LDA #START_POSITION_PIX_Y
	STA newY
	JMP doneWithScreenTransition
notStartingGameTransitionType:
	CMP #$01
	BNE notNormalScreenToScreenUpdate

	LDA screenFlags
	AND #%00100000 ;; does it use gravity?
	BNE keepVspeed
	LDX player1_object
	LDA #$00
	STA Object_v_speed_lo,x
	STA Object_v_speed_hi,x
keepVspeed:
	
	;; normal screen to screen update. 
	;; this just skips observing newX and newY load
	JMP doneWithScreenTransition
notNormalScreenToScreenUpdate:
	CMP #$02
	BNE notWarpTypeTransition
	LDX player1_object
	LDA newX
	STA xHold_hi
	STA Object_x_hi,x
	LDA newY
	STA yHold_hi
	STA Object_y_hi,x
	LDA #$00
	STA Object_x_lo,x
	STA Object_y_lo,x
	STA xHold_lo
	STA yHold_lo
		JMP doneWithScreenTransition
notWarpTypeTransition:
	CMP #$03
	BNE notMapReturnTransition
	LDX player1_object
	LDA mapPosX
	STA xHold_hi
	STA Object_x_hi,x
	LDA mapPosY
	STA yHold_hi
	STA Object_y_hi,x
	LDA #$00
	STA Object_x_lo,x
	STA Object_y_lo,x
	STA xHold_lo
	STA yHold_lo
		JMP doneWithScreenTransition
	
	
notMapReturnTransition:
	CMP #$04
	BNE notContinueScreen
	LDX player1_object
	LDA continuePositionX
	STA xHold_hi
	STA Object_x_hi,x
	LDA continuePositionY
	STA yHold_hi
	STA Object_y_hi,x
	LDA #$00
	STA Object_x_lo,x
	STA Object_y_lo,x
	STA xHold_lo
	STA yHold_lo
	;;; any other thing that needs to happen on continuePositionX
	JMP doneWithScreenTransition
notContinueScreen:

doneWithScreenTransition:


	LDA screenFlags
	AND #%10000000
	BNE EndLoadScreen
	LDA #$01
	STA forceScroll
	LDA #$00
	STA prevent_scroll_flag
	STA updateNametable

EndLoadScreen:



	LDA #$00
	STA updateNT_fire_Att
	STA updateNT_fire_Att+1
	STA updateNT_fire_Att+2
	STA updateNT_fire_Att+3
	STA updateNT_fire_Att+4
	STA updateNT_fire_Att+5
	STA updateNT_fire_Att+6
	STA updateNT_fire_Att+7
	
	STA updateNT_att_fire_Address_lo
	STA updateNT_att_fire_Address_lo+1
	STA updateNT_att_fire_Address_lo+2
	STA updateNT_att_fire_Address_lo+3
	STA updateNT_att_fire_Address_lo+4
	STA updateNT_att_fire_Address_lo+5
	STA updateNT_att_fire_Address_lo+6
	STA updateNT_att_fire_Address_lo+7
	

	
	
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	LDA gameHandler
	ORA #%10000000
	STA gameHandler
	LDA #$00 
	STA update_screen
	STA canUpdateScreen
	LDA #%00011110
	STA soft2001
	
	

	
noNewScreen:	
	RTS

Is this in the correct spot? My last issue was due to my not understanding exactly where to insert code into my script. Maybe I am making a similar mistake here?
Since my HandleLoadScreen is already heavily edited with Frankengraphics transitions code, I may not be doing this correctly at all

Any thoughts?
 

dale_coop

Moderator
Staff member
All those scripts are correct.
Again, use the Collectable script (NOT the "ForScore" one)...

Now maybe your mistake is your collectable tile type itself? Which collision type numer is it?
For example, it's a "06" (a "06 - Collectable" tile)... make sure that your "COL_INDEX_PRIZE" constant (in "Project Settings > User constants") is set to the same value (in my example, "06").
 

Raftronaut

Member
dale_coop said:
All those scripts are correct.
Again, use the Collectable script (NOT the "ForScore" one)...

Now maybe your mistake is your collectable tile type itself? Which collision type numer is it?
For example, it's a "06" (a "06 - Collectable" tile)... make sure that your "COL_INDEX_PRIZE" constant (in "Project Settings > User constants") is set to the same value (in my example, "06").

Hey Dale! It's working! I was completely ignorant of the need to set up COL_INDEX_PRIZE constant. Once I defined that constant it works exactly as needed.

In the example video You can see the player warping into a checkpoint on the single screen example, the player then approaches the monster to successfully create death object animation warping back to the checkpoint. The player then collects the items and creates victory object. (player then warps to wrong screen, I was in a rush to make the video and did not yet set up warp to screen in maze game)
https://youtu.be/2WrcAiRTVGE

Everything is working!

My big concern right now is not having enough CHR space in my original player object file to create a satisfactory looking VICTORY object..
Could you help me understand if it is possible to have my CreateVictoryObject script play a victory animation from the current player object BEFORE switching to the ACTUAL victory object in Game Objects?

It seems entirely possible, but am unsure of the steps needed to take to make it work. I have my maze player victory animation set up to animation state #4.

Any advice on how to achieve this? SO CLOSE NOW!!!!
 
Top Bottom