[4.5.9] UnTriggerScreen macro

dale_coop

Moderator
Staff member
A macro that could be useful to some of you... here's the UnTriggerScript I use for my projects.
Save it as "UnTriggerScreen.asm", in your "GameEngineData\Routines\BASE_4_5\System\Macros" folder:
Code:
MACRO UnTriggerScreen arg0
    ;; arg0 = screen to change, usually held in variable screenType
    TXA
    STA tempx
    TYA
    STA tempy
    
    lda arg0 ;; this is the value of the screen to change.
        AND #%00000111 ;; look at last bits to know what bit to check, 0-7
        TAX
        LDA ValToBitTable_inverse,x
        STA temp2
    lda arg0 ;; this is the value of the screen to change
    
    LSR
    LSR
    LSR
    ;;; now we have the right *byte* out of the 32 needed for 256 screen bytes
    TAY
    LDA screenTriggers,y ;; now the rigth bit is loaded into the accum
    AND temp2
    BEQ +
        LDA screenTriggers,y ;; now the rigth bit is loaded into the accum
        EOR temp2
        STA screenTriggers,y
    +

    LDX tempx
    LDY tempy
    ENDM

Then to untrigger a screen type, just use in your scripts:
Code:
UnTriggerScreen <YourScreenType>

For example, to untrigger the current screen type:
Code:
UnTriggerScreen screenType

For example, to untrigger the screen type 3:
Code:
UnTriggerScreen #$03
 

Retrofaija

Member
Thank you again here as well! This is a diamond script, and was just struggling with this idea of mine. Now it all works and my day and night in the game has real purpose! :)
 
Top Bottom