Kanbei85
Member
It's a flag. It's either 0 or 1.
So if I set nightbyte to 1, and screenState to 04, then will I be in a triggered night screen?
It's a flag. It's either 0 or 1.
No, screenState would have to be 03, since it's from 00 to 03.So if I set nightbyte to 1, and screenState to 04, then will I be in a triggered night screen?
LDA screenState
CMP #$00 ; not night
BEQ +
CMP #$02 ; not night either
BEQ +
LDY #$20 ; to load the night palettes, Y must be shifted forward by 32 (20 in hex)
JMP +night
+
Okay, looking back, here's what I really did: I flipped on the nightbyte flag, not the screenState flag, because screenState is taken care of in the other script. For example this one's for a tile:
Code:CMP #$B2 ; entrance to dark cave BNE + LDA #$01 STA nightbyte JMP warphere +
There is one instance of screenState being changed, but nightbyte is changed at the same time.
Code:LDA #$01 STA nightbyte STA screenState
LDA #$01
STA nightbyte
STA screenState
As of now I haven't changed the background tiles, but I changed the monster spawns.I have to ask....do you have the colors wrong? Like, are your day colors the same as your night colors? If you followed the directions, setting nightbyte to 1 should put everything in screenState 01 which is night. The code can't be more clear on that. 01 is night!
Okay, looking back, here's what I really did: I flipped on the nightbyte flag, not the screenState flag, because screenState is taken care of in the other script. For example this one's for a tile:
Code:CMP #$B2 ; entrance to dark cave BNE + LDA #$01 STA nightbyte JMP warphere +
There is one instance of screenState being changed, but nightbyte is changed at the same time.
Code:LDA #$01 STA nightbyte STA screenState
in the adventure module for me looks like the same code effect, no effect on monster spawning and the change is gone if you reload the screen; but in the scrolingPlataform module the monster spawning works well and the night and day colors circle work ok too, whitout fade transitions but work, all whith the macro "LoadBackgroundPalettes" on in the timer. you got to make the fade transitions works in that stuff??? I trying something using the parameters of "fade out" and fade out whith the color white(#$20) too, but got nothing concrete yet.. problems whith the second screenFlags now ^^, my ScreenFlag01 do not want to work for some reason...If I set nightbyte to #$00, THEN the screenState variable works TEMPORARILY, but the command to update the background palette has to be run manually:
LoadBackgroundPalettes newPal
>>>>>>>>It has no effect on monster spawning locations, however, and the change is gone if you reload the screen.<<<<<<<<<<<<<
This tells me that modifying the screenState variable manually is not enough. In some way, we must figure out what's going on with the TriggerScreen macro to see what it's doing that allows a persistent global change to occur.
;;; handle game timer.
LDA gameTimerTicks
CLC
ADC #$04 ;; change this to how fast you want the timer to run.
STA gameTimerTicks
LDA gameTimerLo
ADC #$00
STA gameTimerLo
LDA gameTimerHi
ADC #$00
STA gameTimerHi
LDA gameTimerHi
BEQ +resethi
CMP #05 ; this should be exactly half of your total time
BEQ +hihalfway
LDA gameTimerLo
BEQ +resetlo ; if lo number reaches zero, this decreases hi number
DEC gameTimerLo ; otherwise, it decreases the lo digit then cycles again
JMP +
+resetlo:
DEC gameTimerHi
LDA #100 ; the low mumber counts this number of frames, then decreases the high number by 1
STA gameTimerLo
JMP +
+resethi
LDA #10 ; enter the amount of time you want between night and day here
STA gameTimerHi
LDA #$00
STA nightbyte
STA screenState
LoadBackgroundPalettes newPal
LDA #$01
STA updateScreenData
JMP +
+hihalfway
DEC gameTimerHi
LDA #$01
STA nightbyte
STA screenState
LoadBackgroundPalettes newPal
LDA #$01
STA updateScreenData
+
LDA nightbyte
STA screenState
LDX screenState ;; activates night text group
JSR LoadMonster_1
GetScreenTriggerInfo:
JSR doClearAllMonsters
;;;;; MONSTERS
;;; constants for banks
GetTrigger
;; result of screenType trigger stored in temp3 and also in accum
;; x and y restored.
BEQ thisScreenIsNotTriggered
;; this screen IS triggered
LDA nightbyte
CMP #$01
BNE isTriggeredDay
;; triggered and night
LDA #$03
STA screenState
JMP triggeredStateInfoIsLoaded
isTriggeredDay
; triggered and day
LDA #$02
STA screenState
JMP triggeredStateInfoIsLoaded
;;=================================
thisScreenIsNotTriggered
LDA nightbyte
CMP #$01
BNE isNormalDay
;; normal and night
LDA #$01
STA screenState
JMP triggeredStateInfoIsLoaded
isNormalDay:
; normal and day
LDA #$00
STA screenState
triggeredStateInfoIsLoaded:
LDX screenState ;; activates night text group
LDA gameTimerHi
BEQ +resethi
CMP #05 ; this should be exactly half of your total time
BEQ +hihalfway
LDA gameTimerLo
BEQ +resetlo ; if lo number reaches zero, this decreases hi number
DEC gameTimerLo ; otherwise, it decreases the lo digit then cycles again
JMP +
+resetlo:
DEC gameTimerHi
LDA #100 ; the low mumber counts this number of frames, then decreases the high number by 1
STA gameTimerLo
JMP +
+resethi
LDA #10 ; enter the amount of time you want between night and day here
STA gameTimerHi
LDA #$00
STA nightbyte
LoadBackgroundPalettes newPal
LDA #$01
STA updateScreenData
JMP +
+hihalfway
DEC gameTimerHi
LDA #$01
STA nightbyte
LoadBackgroundPalettes newPal
LDA #$01
STA updateScreenData
+
doLoadBackgroundPalettes:
;; This is tied to the macro LoadBackgroundPalettes.
;; It uses bank and 16 bit label.
TXA
PHA
TYA
PHA
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Get Palette Label based on INDEX
SwitchBank #$16
LDY arg0_hold
LDA GameBckPalLo,y
STA temp16
LDA GameBckPalHi,y
STA temp16+1
LDA nightbyte
CMP #$00 ; not night
BEQ +
CMP #$02 ; not night either
BEQ +
LDY #$20 ; to load the night palettes, Y must be shifted forward by 32 (20 in hex)
JMP +night
+
LDY #$00
+night
LDX #$00
loop_LoadBackgroundPalette:
LDA (temp16),y
STA bckPal,x
INY
INX
CPX #$10
BNE loop_LoadBackgroundPalette
;;;; end of loop.
LDA updateScreenData
ORA #%00000001 ;; palette
STA updateScreenData
ReturnBank
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PLA
TAY
PLA
TAX
RTS
GetScreenTriggerInfo:
JSR doClearAllMonsters
;;;;; MONSTERS
;;; constants for banks
GetTrigger
;; result of screenType trigger stored in temp3 and also in accum
;; x and y restored.
BEQ thisScreenIsNotTriggered
;; this screen IS triggered
LDA gameHandler
AND #%00000001 ;; one = night
BEQ isTriggeredDay
;; triggered and night
LDA #$03
LDA nightbyte
STA screenState
TAX
LDY #152
LDA (collisionPointer),y
LSR
LSR
LSR
LSR
; LDA #$03
STA monsterTableOffset
JMP triggeredStateInfoIsLoaded
isTriggeredDay
;; triggered and day
LDA #$02
LDA nightbyte
STA screenState
TAX
LDY #153
LDA (collisionPointer),y
AND #%00001111
; LDA #$02
STA monsterTableOffset
JMP triggeredStateInfoIsLoaded
;;=================================
thisScreenIsNotTriggered
JMP isNormalDay
LDA gameHandler
AND #%00000001 ;; one = night
BEQ isNormalDay
;; normal and night
LDA #$01
LDA nightbyte
STA screenState
TAX
LDY #152
LDA (collisionPointer),y
LSR
LSR
LSR
LSR
; LDA #$01
STA monsterTableOffset
JMP triggeredStateInfoIsLoaded
isNormalDay:
;; normal and day
LDA #$00
LDA nightbyte
STA screenState
TAX
;;;;;;;;;;;
;Load correspnding monster tileset.
LDY #152
LDA (collisionPointer),y
AND #%00001111
; LDA #$00
STA monsterTableOffset
triggeredStateInfoIsLoaded:
;;=================================
;Now, here, load all of the state specific stuff.
;This will use X as an offset for small tables in ZeroOutAssets file.
; We'll have to use the stack for any part of these routines that might need X.
; ;;;;; considerations for the states.
; ;1: Get Object Graphics Bank
; ;2: String Data
; ;3: Monster Spawn positions
; ;4: Monster group (this is more complicated than a single digit)
; ;5: Object palettes (also more complicated than a single digit)
; ;6: Object tiles to load.
; ;7: Object IDs
; ;8: Song to play
;;=============================================================
;;=============================================================
LDA StringDataChoice,x
TAY ;; now y holds the byte offset value for the text string group.
LDA (collisionPointer),y
STA stringGroupPointer
TXA
PHA
; LDX monsterTableOffset
;;; Handle monster 1
LDX screenState ;; activates night text group
JSR LoadMonster_1