(SOLVED) (4.5.9) - Arcade Platformer - How to uncheck a Screenflag with script

Subotai

Active member
Hi,

Is it possible to uncheck a Screenflag with a script ?

2.png

When the flags is "CHECKED", the dark cave is all black.
When the player will get a lamp, when he will go back to this dark cave, the area will be visible.

Here the section for that in my "Post Screen Load" :
Code:
    LDA ScreenFlags00
    AND #%00001000
    BEQ doNotTurnOnTheLight
    LDX #$00
    doFadeCurrentBckPal:
    LDA bckPal,x ;; loads joes pallete for background (0-3) (4-7) (8-11) (12-15) 4,8,and 12 is not needed since its the same bgcolor as 0
    CMP #$10 ;; compares 10
    BCC + ;; if less than 10 skip to p1, if not continue below
    SEC ;; needs for subtraction
    SBC #$10 ;; subtract #$10
    STA bckPal,x ;; store it back into pallete
    JMP goNextBckPal;; jump to the next pal2
    +
    LDA #$0F ;; set accumalator to 0F which is (black)
    STA bckPal,x ;; store it into pallete
    goNextBckPal:
    INX   
    CPX #4
    BEQ goNextBckPal
    CPX #8
    BEQ goNextBckPal
    CPX #12
    BEQ goNextBckPal
    CPX #16
    BCC doFadeCurrentBckPal
    LDA #$01
    STA updateScreenData   

    JMP doneWithExtraScreenCheckForLight
    doNotTurnOnTheLight:
    doneWithExtraScreenCheckForLight:


Here's the section in the pickup script :

Code:
    CMP #$07 ;;lamp
    BNE +notThisPickup
            LDA ScreenFlags00
            AND #%11110111
            STA ScreenFlags00
        JMP +endPickups

    ; CMP #$07 ;;candle
    ; BNE +notThisPickup
            ; LDA #$01
            ; STA light
        ; JMP +endPickups


+notThisPickup:

+endPickups

At this time, when the player pickup the lamp, it doesn't do anything on theses 13 screens.
Am I missing something ?

P.S : - The dark cave has 13 screens.
- The lamp will be found somewhere else of these screens.
- Sorry for my bad english

Thanks
 

Subotai

Active member
Here is the final result for the script :

pickup script :

Code:
    CMP #$07 ;;candle
    BNE +notThisPickup
            LDA #$01
            STA light
        JMP +endPickups

Post Screen Load :

Code:
    LDA ScreenFlags00
    AND #%00001000
    BNE darkVador
        JMP doneWithExtraScreenCheckForLight
    darkVador:
    LDA light
    AND #$01
    BEQ fearOfTheDark
        JMP doneWithExtraScreenCheckForLight
    fearOfTheDark:
    LDX #$00
    doFadeCurrentBckPal:
    LDA bckPal,x ;; loads joes pallete for background (0-3) (4-7) (8-11) (12-15) 4,8,and 12 is not needed since its the same bgcolor as 0
    CMP #$10 ;; compares 10
    BCC + ;; if less than 10 skip to p1, if not continue below
    SEC ;; needs for subtraction
    SBC #$10 ;; subtract #$10
    STA bckPal,x ;; store it back into pallete
    JMP goNextBckPal;; jump to the next pal2
    +
    LDA #$0F ;; set accumalator to 0F which is (black)
    STA bckPal,x ;; store it into pallete
    goNextBckPal:
    INX   
    CPX #4
    BEQ goNextBckPal
    CPX #8
    BEQ goNextBckPal
    CPX #12
    BEQ goNextBckPal
    CPX #16
    BCC doFadeCurrentBckPal
    LDA #$01
    STA updateScreenData   

    doneWithExtraScreenCheckForLight:

Thanks Dale for your answer.
 

Pep31

New member
Hi, I'm dealing with the same problem, looking for checking/unchecking a ScreenFlag with a script. But I don't understand your solution. It seems you chose a workaround.

Did you find how to uncheck a Screenflag with a script ? Can you explain ?

I want to do the trick in the pickup.asm script to check the ScreenFlag when I pick up a game object. I tried to add the following code but with no success :

Code:
LDA ScreenFlags00
ORA #%00001000
STA ScreenFlags00

I have also tried this with no more luck :

Code:
LDA ScreenFlags00
ORA #%00001000
LDY #124
STA (collisionPointer),y

In both cases, when the screen is reloaded (when my hero gets hurt), my ScreenFlag remains unchecked.

Any help would be appreciated.
 
Last edited:

dale_coop

Moderator
Staff member
To set a screen flag (for example, the 3rd bit):
Code:
LDA ScreenFlags00
ORA #%00001000
STA ScreenFlags00

To UNset a screen flag (for example, the 3rd bit):
Code:
LDA ScreenFlags00
AND #%11110111
STA ScreenFlags00

2021-03-02 15_33_48-Screen Details.png
On this setup, to set the "Hide Hud", for example:
Code:
LDA ScreenFlags00
ORA #%01000000
STA ScreenFlags00
 

Pep31

New member
Yes, this is what I tried. But, ScreenFlags00 seems to be a temporary variable and it is overwritten when the screen reloads.

Actually, when my hero gets hurt, the screen restarts (Arcade Platformer module) and the ScreenFlag remains unchecked.
 

dale_coop

Moderator
Staff member
Of course, ScreenFlags00 is loaded with the screen (it's a data/property of the screen data). It's the reason, I suggested you to trigger the screen instead.
It's what everyone do here... for pickups, keys... when collected, we trigger the screen. And on triggered screen, they will not be here anymore.
(triggers are initialized when the game load / RESET... and you can use 256 unique triggers). Check the video ;)
 
Top Bottom