Win Screen crashes the game

Bucket Mouse

Active member
To win my game you have to find and collect a certain number of items. I put the trigger for these items in the text box.....if you select the "Give Item" option in the menu, I threw out the code for it and made this instead:

Code:
AddValue #$01, myKeys, #$01, #$00

UpdateHud HUD_myKeys

LDX #$01

LDA Object_ID,x

DeactivateCurrentObject
JMP wingamestuff

This code also vanishes the sprite for the item, and triggers the screen so it doesn't appear again. "Wingamestuff" reads like this...

Code:
wingamestuff:

TriggerScreen screenType

LDA #$06

CMP myKeys

BEQ winactivated

JMP enditempart2

winactivated:

JMP winGame

"winGame" jumps to the Win Game Tile code. As intended, it's supposed to go to the Win screen. Instead, it crashes the game with a glitch screen.

Keep in mind I can't go back on the "text box gives item" mechanic; not at this stage if I want to make PRGE. It has to work THIS way. What is going wrong?

One potential cause: the game is not undrawing the text box before attempting to warp. I don't know why; when it's adding to the HUD, it always waits until the text box finishes drawing before it performs that function.
 

Bucket Mouse

Active member
Tried putting this code at the top of "HandleScreenLoads" instead, but that doesn't seem to work at all.....

Code:
HandleScreenLoads:
LDA #$06
CMP myKeys
BNE ignorethis

LDA #STATE_WIN_GAME
STA change_state
LDA #$01
STA newScreen
ignorethis:
 

Bucket Mouse

Active member
Thought of something clever, but apparently the game ignores anything you put in NullTile_Walkable no matter what it is.

Putting it halfway in the middle of HandleHudData, right before the first RTS, resulted in a half-victory....the win screen appears but it is strobing constantly.
 

dale_coop

Moderator
Staff member
Have you tried to put the:
Code:
	LDA #STATE_WIN_GAME
	STA change_state
	LDA #$01
	STA newScreen
directly in your HandleTextBox, instead of the "JMP winGame"?


Else, here's how I fixed the "Win Game" text action in my game:
- I added a txtWinGame user variable (value "0").
- Modified my "HandleTextBox.asm", round line 319, just after the
Code:
notEndItem:
I added :
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; END WIN GAME:
	CMP #_ENDWIN
	BNE notEndWin
	;; is an end trigger
	INC textboxOffsetHold ;; get the very next value.
	LDY textboxOffsetHold
	LDA (temp16),y
	STA temp
	;; is an end "WIN GAME"
	LDA #$01
	STA txtWinGame
	;;;; this now has the trigger to change.
	TriggerScreen temp
	
	JMP EndText
notEndWin:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Then, around the line 665(or around that), just after the line
Code:
;;;; THIS WOULD WARP YOU TO A SCREEN AFTER TEXTBOX.
I added:
Code:
	LDA txtWinGame
	BEQ +
	LDA #$00
	STA txtWinGame
	LDA #STATE_WIN_GAME
	STA change_state
	LDA #$01
	STA newScreen
	+
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
Top Bottom