Flash Screen Macro [4.5.9]

crazygrouptrio

Active member
Here is a very basic macro for flashing the background. First argument will choose speed of the flash (0 does a quick flash, 1 for slower. All other numbers will be a quick flash), and the second argument lets you choose the color (you'll probably want white which is #$30, but hey options are neat). I intended on making the macro more versatile so you could choose the number/more speed of flashes but that caused too many issues, but this is helpful too.

ZsQmv3T.gif

(the flashes don't capture well, but this is close to what you'll get)

Just copy the code below into a new file and save it as an ASM in your macros folder. Enjoy!

Code:
MACRO FlashScreen arg0, arg1
;arg0 = fast or slow flash? (0 for fast or 1 for slow)
;arg1 = what color of flashes? (#$30 is white)

LDA arg0
STA arg0_hold
LDA arg1
STA arg1_hold

flashScreen:
LDA bckPal+0
STA tempA
LDA bckPal+1
STA tempB
LDA bckPal+2
STA tempC
LDA bckPal+3
STA tempD

JSR doWaitFrame
JSR doWaitFrame
JSR doWaitFrame

LDA arg1_hold
STA bckPal+0
LDA arg1_hold
STA bckPal+1
LDA arg1_hold
STA bckPal+2
LDA arg1_hold
STA bckPal+3

LDA #$01
STA updateScreenData

JSR doWaitFrame

LDA tempA
STA bckPal+0
LDA tempB
STA bckPal+1
LDA tempC
STA bckPal+2
LDA tempD
STA bckPal+3

LDA #$01
STA updateScreenData

JSR doWaitFrame
JSR doWaitFrame
JSR doWaitFrame

DEC arg0_hold

LDA arg0_hold
BEQ flashScreen

ENDM
 

Jonny

Well-known member
I've been thinking about doing a lights off / on script so this is quite helpful. Is it better to do things like this as a macro? I've not made my own macro yet. Seems fairly easy to do.
 

CutterCross

Active member
I've been thinking about doing a lights off / on script so this is quite helpful. Is it better to do things like this as a macro? I've not made my own macro yet. Seems fairly easy to do.
Fairly lengthy macros like this are better used as a subroutine if you're using it in many areas. Put in the subroutine once [that contains the actual palette flash code], and simply JSR to its corresponding label when you want to use it. That way you aren't flooding the ROM with duplicate code every time you use the macro.
 

Jonny

Well-known member
Fairly lengthy macros like this are better used as a subroutine if you're using it in many areas. Put in the subroutine once [that contains the actual palette flash code], and simply JSR to its corresponding label when you want to use it. That way you aren't flooding the ROM with duplicate code every time you use the macro.
Cheers for tip. I hope to start trying my own subroutines but I need to read up on it as I'm not sure how to define them for nesmaker or weather I need to be putting new scripts into certain banks for them to work. Totally clueless on that front.

Going back to the flash effect. I'm not really a Castlevania fan but doesn't that game do somthing like this effect too? Or ghosts n goblins or something.. maybe I dreamt it :unsure:
 

CutterCross

Active member
Cheers for tip. I hope to start trying my own subroutines but I need to read up on it as I'm not sure how to define them for nesmaker or weather I need to be putting new scripts into certain banks for them to work. Totally clueless on that front.

Going back to the flash effect. I'm not really a Castlevania fan but doesn't that game do somthing like this effect too? Or ghosts n goblins or something.. maybe I dreamt it :unsure:
All a subroutine does is jump to a label, then returns back to the original location it jumped from once the program counter reaches an RTS instruction [assuming you didn't accidently pull the return address off the stack or push something to the stack and left it there during that subroutine code]. If that label is viewable from CPU memory window, you're good.

Code:
someSubroutine:        ;; Don't put this directly in your game loop
    ;;;; subroutine code
    RTS
   
;; ... somewhere else in the program

    JSR someSubroutine
    ;; ... rest of program continues after subroutine finishes
 

Bucket Mouse

Active member
It's a misnomer that ALL flashing triggers seizures in epileptic people; it's when it flashes in a certain way or for a certain length of time. I don't believe flashing the screen once for one or two frames is going to trigger epilepsy.

Anyway, great code and thanks for sharing!
 
Top Bottom