Add blinking "PRESS START" on the start screen [4.1.X Basic module]

crazygrouptrio

Active member
voltopt said:
I tested this on the arcade platform tutorial, and also on my adventure game and one-way scroll platformer, all in 4.5.6, and it locks up on each! I have the user variable created, set to 0, and the code crazygrouptrio posted. Frustrating!

Are you assigning the script to HandleGameTimer under the Game section in scripts? It doesn't go in Timer under Subroutines (I almost made that mistake). Its the only thing I can think of, unless something else is causing the lock up. :?
 

voltopt

Member
I am. I am copying the script you shared into a new HandleGameTimer_palcycle.asm, assigning it to HandleGameTimer under the Game section, and adding the "palettesCycleTimer" under user variables. It locks up immediately after it compiles successfully.

I have the most recent core, as well. hmm... maybe it's Mesen? Lol. I did set the first screen in the arcadeplat tutorial to Medium as a test, and it starts to cycle (one color changes) and then it crashes.
 

AllDarnDavey

Active member
Yeah, trying it out tonight. I'm not able to get this to work on any of the cores, usually compiles fine, but just freezes or crashes...
I wonder if one of the recent core updates broke it.
 

voltopt

Member
OMG, the only thing broken was the shared code was missing the ++ at the end from the jump. The jump had nowhere to go, so it locked up... ha. This works for me in Adventure Module.


Code:
;;; handle game timer.
JSR handlePaletteCycleTimer
	LDA gameTimerTicks
	CLC
	ADC #$01 ;; 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
	JMP ++
	
handlePaletteCycleTimer:
	;WE DONT USE SPECIAL SCREENS ANYMORE
	
	;; Pal cycling on "Medium"-speed screens :
	LDA screenSpeed
	CMP #$01
	BEQ doPaletteCycleTimer

	;; another example, Pal cycling on screen type 255 screens :
	;LDA screenType
	;CMP #255
	;BEQ doPaletteCycleTimer

	
	JMP endPaletteCycleTimer
doPaletteCycleTimer: 
	;; from here, DO the palette cycle:
	LDA palettesCycleTimer
	BNE dontUpdatePaletteCycleTimer
	JSR pickPaletteToCycle
	LDA #$10  			;; HERE !!! the SPEED of the cycling
	STA palettesCycleTimer
dontUpdatePaletteCycleTimer:
	DEC palettesCycleTimer
endPaletteCycleTimer:
	RTS    
pickPaletteToCycle:
	LDA #$02    		;; HERE !!! the "Sub 3" palette
	ASL
	ASL 				;; these multiply your literal or variable with 4 so we can get the right offset for each palette in increments of 4.
	TAX
	LDY bckPal+1,x		;; pocket colour 1 in reg y
	LDA bckPal+2,x 
	STA bckPal+1,x		;; move colour 2 to 1
	LDA bckPal+3,x 
	STA bckPal+2,x		;; move colour 3 to 2
	TYA
	STA bckPal+3,x	;; move pocket (y) to 3
	
	LDA #$01
	STA updateScreenData	;; loading anything but zero into this value tells NESmaker it needs to update palettes.
	RTS
++

**Minor edit to fix tabs in code (purely cosmetic)
 

AllDarnDavey

Active member
Oh man... I just spent half the night writing my own reworked version of this. I got it all working and everything, I was just about to post it here too.
Oh well... mine wasn't all that different, just jumps around a little differently, and changes some of the processes up a bit. This one is probably slightly faster. Oh well, it was a good 6502 assembly exercise.
 

voltopt

Member
Trust me, I was hunting all over the place for the answer. I think it helped me figure out a little bit more on assembly, maybe. Instead of my knowledge being in total darkness there's a flickering light lol.
 

crazygrouptrio

Active member
voltopt said:
OMG, the only thing broken was the shared code was missing the ++ at the end from the jump. The jump had nowhere to go, so it locked up... ha. This works for me in Adventure Module.

Oooops that's my fault sorry! :oops: This is why I don't share code often :lol:
 

AllDarnDavey

Active member
crazygrouptrio said:
Oooops that's my fault sorry! :oops: This is why I don't share code often :lol:

That's okay... I saw the JMP to nowhere right away and just brushed it off as legacy code from the old version, instead of realizing it was a glaring red flag that the last line was missing.
 

vanderblade

Active member
I implemented the palette swapping into 4.1.5 using the shooter mod.

On the Star Screen, it naturally works without question.

During the single-screen or scrolling sections in-game, though, sometimes it works flawlessly and other times the background tiles go wonky. There doesn't seem to be a reason for why it works sometimes and why it doesn't.
 

PasseGaming

Active member
I know I am very late to this party but I tried adding this code and it doesn't seem to want to agree with me. Below is my handle timer script? The error appears to be line 7 (LDA update_screen_details), 9 (LDA currentScreen), & 50 (STA updatePalettes).

Code:
    LDA bulletTimer
    BEQ +skip
        DEC bulletTimer
        ;;;;;;;;;;;;;;;;;;; PALETTES CYCLE  ;;;;;;;;;;;;;;;;;;;
handlePaletteCycleTimer:
    ;; Pal cycling on START SCREEN :
    LDA update_screen_details    ;; special screen (start/win screens)?
    BNE +                        ;; if not skip the pal cycle code
    LDA currentScreen        ;; screen 0 (the start one)?
    BEQ doPaletteCycleTimer    
    ;; if not skip the pal cycle code
    +  
   
    ;; Pal cycling on "Medium"-speed screens :
    ;;LDA screenSpeed
    ;;CMP #$01
    ;;BEQ doPaletteCycleTimer

    ;; another example, Pal cycling on screen type 255 screens :
    ;LDA screenType
    ;CMP #255
    ;BEQ doPaletteCycleTimer

   
    JMP endPaletteCycleTimer
doPaletteCycleTimer:
    ;; from here, DO the palette cycle:
    LDA palettesCycleTimer
    BNE dontUpdatePaletteCycleTimer
    JSR pickPaletteToCycle
    LDA #$10              ;; HERE !!! the SPEED of the cycling
    STA palettesCycleTimer
dontUpdatePaletteCycleTimer:
    DEC palettesCycleTimer
endPaletteCycleTimer:
    RTS  
pickPaletteToCycle:
    LDA #$02            ;; HERE !!! the "Sub 3" palette
    ASL
    ASL                 ;; these multiply your literal or variable with 4 so we can get the right offset for each palette in increments of 4.
    TAX
    LDY bckPal+1,x        ;; pocket colour 1 in reg y
    LDA bckPal+2,x
    STA bckPal+1,x        ;; move colour 2 to 1
    LDA bckPal+3,x
    STA bckPal+2,x        ;; move colour 3 to 2
    TYA
    STA bckPal+3,x        ;; move pocket (y) to 3
    LDA #$01
    STA updatePalettes    ;; loading anything but zero into this value tells NESmaker it needs to update palettes.
    RTS  
    +skip
 

Jonny

Well-known member
I know I am very late to this party but I tried adding this code and it doesn't seem to want to agree with me. Below is my handle timer script? The error appears to be line 7 (LDA update_screen_details), 9 (LDA currentScreen), & 50 (STA updatePalettes).

Is the error "not defined" ? and are you still using 4.5.6 ?

There's another post with 4.5.6 palette cycling script, I can't remember who by sorry. It's very similar to this one for 4.1.

I belive updateScreenData now updates palettes.
 

Logana

Well-known member
I actually used this code for monster slayer, did you make sure to add the variable called PalletCycleTimer, also this code is sorta constant so I’m not sure it would be good for bosses, also it glitches out text, turn it on by setting the screen speed to medium :3
 

PasseGaming

Active member
I got it working, used the wrong code and had it in the wrong place. Adds a nice touch to the start screen. I am really looking forward to using it for my next games.
 
Last edited:

davev

New member
I want to have the tiles fade in and out, like a bounce effect (i.e. colors do 3212321232123 etc). I ALSO have been using this as my first real foray into 6502 ASM. I got something to work, but I know there HAS to be a better way to do it. I'd love to learn if anyone wants to take a look and advise on how this can be optimized. If not - here's the code if anyone else wants a "bounce" animation:
JSR handlePaletteCycleTimer
LDA gameTimerTicks
CLC
ADC #$01 ;; 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
JMP ++

handlePaletteCycleTimer:
;WE DONT USE SPECIAL SCREENS ANYMORE

;; Pal cycling on "Medium"-speed screens :
LDA screenSpeed
CMP #$01
BEQ doPaletteCycleTimer

;; another example, Pal cycling on screen type 255 screens :
;LDA screenType
;CMP #255
;BEQ doPaletteCycleTimer


JMP endPaletteCycleTimer
doPaletteCycleTimer:
;; from here, DO the palette cycle:
LDA palettesCycleTimer
BNE dontUpdatePaletteCycleTimer
LDA #$A0 ;; HERE !!! the SPEED of the cycling
STA palettesCycleTimer

LDA cycleDir
BNE pickPaletteToCycle
LDA cycleDir
BEQ pickPaletteToCycle2


decreaseCycle:
DEC cycleStage

dontUpdatePaletteCycleTimer:
DEC palettesCycleTimer
endPaletteCycleTimer:
RTS
pickPaletteToCycle:
LDA #$02 ;; HERE !!! the "Sub 3" palette
ASL
ASL ;; these multiply your literal or variable with 4 so we can get the right offset for each palette in increments of 4.
TAX
LDY bckPal+1,x ;; pocket colour 1 in reg y
LDA bckPal+2,x
STA bckPal+1,x ;; move colour 2 to 1
LDA bckPal+3,x
STA bckPal+2,x ;; move colour 3 to 2
TYA
STA bckPal+3,x ;; move pocket (y) to 3

LDA #$01
STA updateScreenData ;; loading anything but zero into this value tells NESmaker it needs to update palettes.

LDA cycleStage
BNE decreaseCycle
LDA #$01
STA cycleStage
LDA cycleDir
EOR #$01
STA cycleDir

RTS

pickPaletteToCycle2:
LDA #$02 ;; HERE !!! the "Sub 3" palette
ASL
ASL ;; these multiply your literal or variable with 4 so we can get the right offset for each palette in increments of 4.
TAX
LDY bckPal+2,x ;; pocket colour 1 in reg y
LDA bckPal+1,x
STA bckPal+2,x ;; move colour 2 to 1
LDA bckPal+3,x
STA bckPal+1,x ;; move colour 3 to 2
TYA
STA bckPal+3,x ;; move pocket (y) to 3

LDA #$01
STA updateScreenData ;; loading anything but zero into this value tells NESmaker it needs to update palettes.

LDA cycleStage
BNE decreaseCycle
LDA #$01
STA cycleStage
LDA cycleDir
EOR #$01
STA cycleDir

RTS
++
 
Top Bottom