Possible HUD Garbage bug -- help please

Razzie.P

Member
One more bug to squish (that I know of), and I think I'm home free! But I'm not sure where to begin with troubleshooting and fixing this. Much appreciated it you happen to know what's causing it and what I can do to fix it.


The hud will randomly seem to glitch, causing something what you see at the beginning of the video. The lives counter (the L - ) is blank, and a random number will appear on the left top and left, nearly half way down. In the video example here, you can see that the numbers are 0, but that's not always the case. I've not been able to determine a pattern for which number is showing up.

When the player dies (as shown about 15 seconds in) the issue corrects itself. But If I reload the save state (about 20 seconds in) you can see that the issue is still there.

I reloaded a different save state (23 seconds in) to return to the previous screen to see if the issue could be duplicated. I finished the level and you'll notice that the issue did not return, so I'm not able to duplicate it and, as I mentioned, it seems completely random.

Finally, if I continue and finish the level, the issue goes away when the next level loads, much like when the player dies that I mentioned above.

Any help for fixing this would be greatly appreaciated.

Thanks!




https://youtu.be/-2CM4wxAthQ
 

dale_coop

Moderator
Staff member
Yhe video show nothing we can analyse... the HUD already glitched when you show it. It would be better if we could see when it glitches... the cause.
If it's when you collect a item, or when you warp to another screen or when you got hurt or when the timer goes below 200 or another number,...? or when you press an input button?

I think it's a small bug, maybe just a script that modify one of your hud variable and the script is not correctly written ;)
 

Razzie.P

Member
Here's a video that shows the levels leading to the glitch. I hope to capture more examples, but I since I can't duplicate it, I have to wait until it "randomly" happens, which makes it a bit difficult to capture. At about 49 seconds, I collect the final item in the level which loads the next level, and you can see the glitch as soon as the level loads.

https://youtu.be/3QOhhKbf_Ck
 

dale_coop

Moderator
Staff member
It could be because it updates the timer at the same time than the level HUD? or the score?
If it's difficult to reproduce, it might be difficult to fix it for good.

I know there is an issue when the code tries to 2 HUD updates at the same time. There is a fix for that, but I don't know for sure if it's your issue.
Anyway, here how to fix that issue (just in case it would be that)...

Modify the script assigned to your Handle HUD data (in project settings > script settings), at line 18, just after the line:
Code:
	STA updateCHR_offset
Add, this line:
Code:
	STA hudElementTilesMax	;; dale_coop fix for the hud updating issue (when 2 updates called at the same time)

And modify the UpdateHud.asm macro (in the System\Macros folder), comment out the line 11 and 12, like this:
Code:
	; LDA #$00
	; STA hudElementTilesMax

Tell me, if you still have the issue...
 

Razzie.P

Member
Took a while for it to come back, but it still happened, sadly. Always seems to put a number at 0,0 and 0,4. This time, it added a 0 beside the "lives" counter, under the "A" in remaining. I didn't get a video of this one, though, as I was simply playing through.


Oof_Error001.jpg
 

dale_coop

Moderator
Staff member
But it looks like it's related to your timer or your victory/ warp to new screen/ update the level HUD element... coud you tell me where is your code that update your screen/level hud ?
Could you also share the code (of your timer script) where it decreases and updates the timer hud ?
 

Razzie.P

Member
Apologies if I'm misunderstanding, but it seems the code that updates the screen/level hud is in the "HandleScreenLoads.asm" script. This script has been modified using code by FrankeGraphics for cleaner warping and loading, but I didn't see any changes to the parts concerning the hud. I'll post it here in case it contains something problematic that I'm not seeing.

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 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.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;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


And here's the code from my "HandleGameTimer" script.

Code:
;; create a variable in your HUD called myTimer 
;; set the initial value for myTimer from your HUD 
;; myTimer needs to have a max value of 3
;; this script was used for NESMAKER 4.1.1 and calls the SubtractValue macro
;; make sure that SubtractValue is the *proper* version
;; This script wouldn't be possible without Kevin Skeen's Timer_Tick.asm script
;; Thank you for everything, Kevin Skeen!




HandleGameTimer:


DEC gameTimer ;decrement memory by one


BNE dontUpdateGameTimer ;if gameTimer = 0, don't update
LDA gameTimerLo ;load gameTimerLo into accumulator
CLC ;clear the carry flag
ADC #$01 ;add 01 to acumulator with carry
STA gameTimerLo ;store to the accumlator
LDA gameTimerHi ;load gameTimerHi into accumulator
ADC #$00 ;add 00 to acumulator with carry
STA gameTimerHi ;store to the accumlator

;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;; DO WHATEVER READS OF THE GAMETIMER YOU MIGHT WANT HERE.
LDA #DayNightSpeed
STA gameTimer


LDX #$02 ;;Checking Hundreds
LDA myTimer,x ;;Load Hundreds Digit
BNE SubtractTime ;;If not 0, we have more than 000
DEX ;;Checking Tens -- Decrease x so x is 1
LDA myTimer,x ;;Load Tens Digit
BNE SubtractTime ;;If not 0, we have more than 000
DEX ;;Checking Tens 
LDA myTimer,x ;;Load Ones Digit
BNE SubtractTime
;;JMP RESET


;;;;;;;;;;;;;;;;;;;;;;;;;;;



dontUpdateGameTimer:
RTS


SubtractTime:

SubtractValue #$03, myTimer, #$01, #$00 ;;Subtract 1 from the Ones digit


;;Update HUD
LDA #$03 ;; your timer can only have max 3 numbers
STA hudElementTilesToLoad
LDA DrawHudBytes
ORA #HUD_myTimer
STA DrawHudBytes
RTS



DoAlarm:

;;; we're going to edge-load monsters one at a time if they are of edge type and are not active.
LDX #$00
doLoadMonsterOnTimerLoop:

LDA edgeLoaderInCue
BEQ noEdgeMonstersInCue
LDA currentBank
STA prevBank
LDY #$1C ;; data bank
JSR bankswitchY
JSR CreateTimedEdgeSpawner
DEC edgeLoaderInCue
LDY prevBank
JSR bankswitchY

noEdgeMonstersInCue
RTS


As always, thanks for your help with this!
 

dale_coop

Moderator
Staff member
In your HandleGameTimer, I see that you are using a old code for updating your timer hud, you should fix that...
around line 58, you will see:

Code:
;;Update HUD
LDA #$03 ;; your timer can only have max 3 numbers
STA hudElementTilesToLoad
LDA DrawHudBytes
ORA #HUD_myTimer
STA DrawHudBytes
RTS

Replace those 7 lines, with that 3 lines code:

Code:
;;Update HUD
UpdateHud HUD_myTimer
RTS


Now, you might have another hud somewhere, the one that updates your level number hud... Maybe you put it, in your Victory script?
Could you share the script that is assigned to the "Handle No More Prize Tiles" element in your "Project Settings > Script Settings"?
 

Razzie.P

Member
A couple of new developments here, that I hope may prove useful --

1) I changed to those 3 lines, but the error still happens.

2) When I comment out that entire section, the timer does not count down in real time (it seems frozen - which I'm sure is normal since it's commented out), but it does load the new, decreased time during each screen load, which certainly seems to be in line with your theory that it's perhaps working in duplicate scripts.



Code:
HandleHudData:

	LDA textboxHandler
	BEQ +
	RTS
+
	;; we may have to test to see if any other tiles are updating this frame.
	;; and skip if there are tiles updating.
	;; NOW let's find which element might be updating.
	LDA ActivateHudUpdate
	BEQ + ;; hud is not currently being updated
	;; HUD IS being currently activated
	JMP UpdateHudTiles
+ 
	;;;;;;;;;;;;;;;;;; FIRST, reset values:
	LDA #$00
	STA updateCHR_counter
	STA updateCHR_offset
	STA hudElementTilesMax	;; dale_coop fix for the hud updating issue (when 2 updates called at the same time)

	
;;; CHECK FIRST ELEMENT
	LDA DrawHudBytes
	AND #%10000000 
	BEQ +
	;; do first element
	LDY #$00
	JSR LoadHudElementInfo
	LDA #BOX_0_ASSET_0_STRING
	STA updateHUD_STRING
	LDA #BOX_0_ASSET_0_IMAGE
	STA updateHUD_IMAGE
	HudUpdateForNumericDisplay #BOX_0_ASSET_0_STRING
	JMP UpdateHudTiles
+
;;; CHECK SECOND ELEMENT
	LDA DrawHudBytes
	AND #%01000000 
	BEQ +
	;; do second element
	LDY #$01
	JSR LoadHudElementInfo
	LDA #BOX_0_ASSET_1_STRING
	STA updateHUD_STRING
	LDA #BOX_0_ASSET_1_IMAGE
	STA updateHUD_IMAGE
	HudUpdateForNumericDisplay #BOX_0_ASSET_1_STRING
	JMP UpdateHudTiles
+
+++++
;;; CHECK THIRD ELEMENT
	LDA DrawHudBytes
	AND #%00100000 
	BEQ +
	;; do third element
	LDY #$02
	JSR LoadHudElementInfo
	LDA #BOX_0_ASSET_2_STRING
	STA updateHUD_STRING
	LDA #BOX_0_ASSET_2_IMAGE
	STA updateHUD_IMAGE
	HudUpdateForNumericDisplay #BOX_0_ASSET_2_STRING
	JMP UpdateHudTiles
+
;;; CHECK FOURTH ELEMENT
	LDA DrawHudBytes
	AND #%00010000
	BEQ +
	;; do fourth element
	LDY #$03
	JSR LoadHudElementInfo
	LDA #BOX_0_ASSET_3_STRING
	STA updateHUD_STRING
	LDA #BOX_0_ASSET_3_STRING
		LDA #BOX_0_ASSET_3_IMAGE
	STA updateHUD_IMAGE
	HudUpdateForNumericDisplay #BOX_0_ASSET_3_STRING
	JMP UpdateHudTiles
+
;;; CHECK FIFTH ELEMENT
	;LDA DrawHudBytes
	;AND #%00001000 
	;BEQ +
	;;; do fifth element
	;LDY #$04
	;JSR LoadHudElementInfo
	;LDA #BOX_0_ASSET_4_STRING
	;STA updateHUD_STRING
	;	LDA #BOX_0_ASSET_4_IMAGE
	;STA updateHUD_IMAGE
	;HudUpdateForNumericDisplay #BOX_0_ASSET_4_STRING
	;JMP UpdateHudTiles
+
;;; CHECK SIXTH ELEMENT
	LDA DrawHudBytes
	AND #%00000100 
	BEQ +
	;; do sixth element
	LDY #$05
	JSR LoadHudElementInfo
	LDA #BOX_0_ASSET_5_STRING
	STA updateHUD_STRING	
	LDA #BOX_0_ASSET_5_IMAGE
	STA updateHUD_IMAGE
	HudUpdateForNumericDisplay #BOX_0_ASSET_5_STRING
	JMP UpdateHudTiles
	
+
;;; CHECK SEVENTH ELEMENT
	LDA DrawHudBytes
	AND #%00000010
	BEQ +
	;; do seventh element
	LDY #$06
	JSR LoadHudElementInfo
	LDA #BOX_0_ASSET_6_STRING
	STA updateHUD_STRING
		LDA #BOX_0_ASSET_6_IMAGE
	STA updateHUD_IMAGE
	HudUpdateForNumericDisplay #BOX_0_ASSET_6_STRING
	JMP UpdateHudTiles
+
;;; CHECK EIGHTH ELEMENT
	LDA DrawHudBytes
	AND #%00000001 
	BEQ +
	;; do eigthth element.
	LDY #$07
	JSR LoadHudElementInfo
	LDA #BOX_0_ASSET_7_STRING
	STA updateHUD_STRING
		LDA #BOX_0_ASSET_7_IMAGE
	STA updateHUD_IMAGE
	HudUpdateForNumericDisplay #BOX_0_ASSET_7_STRING
	JMP UpdateHudTiles
+
	
	;; end of checking element bits.
	RTS
	
	
	
UpdateHudTiles:
	
	;;; one of the hud bits was flipped.
	;;; now we have all the necessary data to do the update
	;;; FIRST check the type of asset.
	LDA updateHUD_ASSET_TYPE
	BEQ + ;; is not zero asset type
	JMP notHudElement0
+
	;;;; generally, this is for the Var Image type.
	.include SCR_HUD_ELEMENT_0
	;;; rts is in the script
notHudElement0:
	CMP #$01
	BEQ +
	JMP notHudElement1
+

	.include SCR_HUD_ELEMENT_1
	;; rts is in the script
notHudElement1:
	CMP #$02
	BEQ +
	JMP notHudElement2
+
	.include SCR_HUD_ELEMENT_2
	;; rts is in the script
notHudElement2:
	;;; elements 1 and 2 have no mid-frame updates.
	CMP #$03
	BEQ +
	JMP notHudElelement3
+
	.include SCR_HUD_ELEMENT_3 
	;;; rts is in the script
	
notHudElelement3:

HandleHudData_direct:


SkipHandleHudData:

	RTS
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
LoadHudElementInfo:
	;;; hud element loaded into y.
	LDA HudActive,y
	STA updateHUD_active
	LDA HudInverse,y
	STA updateHUD_inverse
	LDA HudAssetTypes,y
	STA updateHUD_ASSET_TYPE
	LDA HudAssetX,y
	STA updateHUD_ASSET_X
	LDA HudAssetY,y
	STA updateHUD_ASSET_Y
	;LDA HudImage,y
	;STA updateHUD_IMAGE
	LDA HudBlank,y
	STA updateHUD_BLANK
	LDA HudRow,y
	STA updateHUD_ROW
	LDA HudColumn,y
	STA updateHUD_COLUMN
	LDA HudMaxValue,y
	STA hudElementTilesFull
	RTS
	
	
	
	
	
GetHudDrawPositionAndOffset:
	;; keep in mind, a HUD will always be in the first nametable.
	LDA #BOX_0_ORIGIN_X
	STA tileX
	LDA #BOX_0_ORIGIN_Y
	STA tileY 
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	JSR coordinatesToMetaNametableValue
	;; establishes updateNT_pos and updateNT_pos+1
	;;; FIRST, IF this has been tripped, blank all of the values
	LDA updateHUD_ASSET_Y
	ASL
	ASL
	ASL
	ASL
	ASL
	STA temp
	ORA updateHUD_ASSET_X
	STA temp
	
	LDA updateHUD_ASSET_Y
	LSR 
	LSR
	
	STA temp1
	
	LDA updateNT_pos 
	CLC
	ADC temp
	CLC
	ADC updateHUD_offset
	STA updateHUD_fire_Address_Lo
	LDA updateNT_pos+1
	ADC temp1
	STA updateHUD_fire_Address_Hi
	RTS

4) Doesn't seem to be anything in the Victory script, but maybe I'm missing it.

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
 

Razzie.P

Member
Edit:

Oops... meant to send a PM but posted here instead :lol:


But, I'm still struggling with this issue, so if anyone has any idea how I can solve it, I'd greatly appreciate it and you'd sure be my favorite person for the day!
 
Top Bottom