Countdown Timer WORKING

PewkoGames

Member
error4.JPG
 

dale_coop

Moderator
Staff member
Bucket Mouse said:
Okay, that stops the timer during the text.....but it's still going during Victory. I don't know why FF is what we're comparing player1 to...what does FF represent?

If it's checking to see if the player isn't there, shouldn't the number be 00 instead? Of course, that doesn't work either.

The player1_object is set to #$FF when he's destroyed. But looks like it's not yet there.
What's module are you using? the maze? the simple platformer?
 

Bucket Mouse

Active member
dale_coop said:
Bucket Mouse said:
Okay, that stops the timer during the text.....but it's still going during Victory. I don't know why FF is what we're comparing player1 to...what does FF represent?

If it's checking to see if the player isn't there, shouldn't the number be 00 instead? Of course, that doesn't work either.

The player1_object is set to #$FF when he's destroyed. But looks like it's not yet there.
What's module are you using? the maze? the simple platformer?

The maze. What else should I try?
 

dale_coop

Moderator
Staff member
You could modify Handle Player Win script, adding this code, just after the "DeactivateCurrentObject" line:
Code:
LDA #$FF
STA player1_object

Then the timer code I proposed some days ago, should work.


PS: sorry guys for the late reply... I was on a flight back home (Japan -> Amsterdam -> France... about 16 hours). And now jet lagged (>_<)
 

Bucket Mouse

Active member
dale_coop said:
You could modify Handle Player Win script, adding this code, just after the "DeactivateCurrentObject" line:
Code:
LDA #$FF
STA player1_object

Then the timer code I proposed some days ago, should work.


PS: sorry guys for the late reply... I was on a flight back home (Japan -> Amsterdam -> France... about 16 hours). And now jet lagged (>_<)

I have interesting news. This didn't work either, so for kicks I tried temporarily erasing the entire contents of HandlePlayerWin to see what would happen. Nothing changed. THE GAME IS NOT USING HANDLEPLAYERWIN.

So what IS the game using that activates the victory animation? I entered CreateObject temp, temp1, #$10 into the Search box....and came up with nothing. Because, as it turns out, that particular bit is actually listed as #OBJ_PLAYER_VICTORY, not #$10.

Then I had to test out all the potential places where this code I needed could be hiding. Suspects were HandleNoMorePrizeTiles.asm, CreateVictoryObject.asm, and NoMorePrize_CreateVictoryObject.asm. I experimented with them all in that order, and of course, it was the very last one I was looking for. Pasting LDA #$FF into that code made the trick work.

BUT it bugs out the timer again. Maybe monkeying with player1_object was causing it.

Alternate strategy! I made a new variable called "ifVictoryNoTimer." I put it in the same places the player1_object check was. Then I put this into the beginning of WarpToScreen, to reset the trigger:

Code:
    LDA #$00
STA ifVictoryNoTimer

Works now. Total time spent: over one hour
 

Bucket Mouse

Active member
dale_coop said:
Glad you found out :)

UPDATE: The timer displays on the Start and Win screens too, unless you use these checks:
Code:
    LDA #$00
    CMP newScreen
    BEQ dontUpdateGameTimer
    
        LDA #$01
    CMP newScreen
    BEQ dontUpdateGameTimer

Be aware that once you do, you can't use screens 0,0 or 0,1 in the grid......because for some reason, they have the same numbers as the Start and Win screens, so the timer will no longer work on them.
 

Bucket Mouse

Active member
justadude said:
where do you write this script?

In HandleGameTimer.asm, at the very beginning. Like this:

Code:
HandleGameTimer:

    ; checks to see if the text box is on   
    LDA gameHandler
    AND #%00100000
    BNE dontUpdateGameTimer
    
    LDA ifVictoryNoTimer
    CMP #$01 ; player is no more... because destroyed and been replaced by the tenth Game Object, which is the Victory animation
        BEQ dontUpdateGameTimer
        
    
    LDA #$00
    CMP newScreen ; checks to see if the Start screen is on
    BEQ dontUpdateGameTimer
    
        LDA #$01
        CMP newScreen ; checks to see if the Win screen is on
    BEQ dontUpdateGameTimer
 

rodrigotadeu

New member
Is it possible to create the inverse?
Count second of play?
And when we die stop seconds for that life I have and still count.
 

Razzie.P

Member
Thanks for the code snippets here! I've been trying to learn to do this for a bit, but my ASM is pretty weak... well... VERY weak :roll: so things like this has been invaluable to me in trying to learn how it all works.

Something I'm finding, though, that makes no sense -- when using timer code, my rooms where X is an odd number (such as X=1, Y=1; X=3, Y1; X=5, etc etc) have a very strange occurance. Tile X=11. Y=5 causes issues. Perhaps more tiles are problematic as well, but this is the only one I'm seeing where I can duplicate the issue. Using the Maze module, when I have a "power up" tile placed at 11, 5, my project goes to the Win Screen as soon as I enter the room. When I remove the "power up" tile, I can enter the room fine, BUT as soon as I stand on the tile (normal, walkable floor), the timer rapidly decreases, and sometimes I'm warped to the Win Screen as well. Any ideas on what could be going on, and/or what I could do to troubleshoot this?
 

Shaoran

New member
Razzie.P said:
Thanks for the code snippets here! I've been trying to learn to do this for a bit, but my ASM is pretty weak... well... VERY weak :roll: so things like this has been invaluable to me in trying to learn how it all works.

Something I'm finding, though, that makes no sense -- when using timer code, my rooms where X is an odd number (such as X=1, Y=1; X=3, Y1; X=5, etc etc) have a very strange occurance. Tile X=11. Y=5 causes issues. Perhaps more tiles are problematic as well, but this is the only one I'm seeing where I can duplicate the issue. Using the Maze module, when I have a "power up" tile placed at 11, 5, my project goes to the Win Screen as soon as I enter the room. When I remove the "power up" tile, I can enter the room fine, BUT as soon as I stand on the tile (normal, walkable floor), the timer rapidly decreases, and sometimes I'm warped to the Win Screen as well. Any ideas on what could be going on, and/or what I could do to troubleshoot this?


I have the same error, on screens where X is odd it broke, my solution was skipping them.
 

5kids2feed

Well-known member
Ugh...

Did step 1 & step 2... step 3 I can't find handlescreenloads.asm ... only extra screen load and post screen load

I setup the user variable myTimer and set it to 60

then run game and get a million errors in the HandleGamerTimer.asm .. lines 12, 26, 56, 57, 59, 70, 75, 76, 77, 79 ...of the first script

Anybody have any clue how to et this to run in 4.5.9?
 
Last edited:

Jonny

Well-known member
To Dale and Mugi's point, I think people like the facebook group because (as far as I'm aware), Joe and the NesMaker team reply to posts to some degree.
I'm not on facebook, im just going by what has been said on here.
Information gets quite fragmented, especially with with wiki thing too. There's actually a forum page setup on the new8bitheros page too, but its unused.

Anyway, I see this code is for 4.1.1 but it doesn't look like much, if anything would need to be changed for people who aren't still in 2019 :p
 

Arctic Blizzard

New member
Agree with Mugi, on that!!!! I hate Facebook for that, we always loose everything. I keep saying post on the forum, ask on the forum, share on the forum...
I hate FB >_<

Anyway... another version of the same script, posted on FB:

Code:
;; create a variable in your HUD called myTimer
;; set the initial value for myTimer from your HUD
;; myTimer needs to have a max value of 3
;; this script was used for NESMAKER 4.1.1 and calls the SubtractValue macro
;; make sure that SubtractValue is the *proper* version
;; This script wouldn't be possible without Kevin Skeen's Timer_Tick.asm script
;; Thank you for everything, Kevin Skeen!


HandleGameTimer:
  
    DEC gameTimer           ;decrement memory by one
  
  
    BNE dontUpdateGameTimer ;if gameTimer = 0, don't update
    LDA gameTimerLo         ;load gameTimerLo into accumulator
    CLC                     ;clear the carry flag
    ADC #$01                ;add 01 to acumulator with carry
    STA gameTimerLo         ;store to the accumlator
    LDA gameTimerHi         ;load gameTimerHi into accumulator
    ADC #$00                ;add 00 to acumulator with carry
    STA gameTimerHi         ;store to the accumlator
;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; DO WHATEVER READS OF THE GAMETIMER YOU MIGHT WANT HERE.
  
  
  
    LDX #$02                ;;Checking Hundreds
    LDA myTimer,x           ;;Load Hundreds Digit
    BNE SubtractTime        ;;If not 0, we have more than 000
    DEX                     ;;Checking Tens -- Decrease x so x is 1
    LDA myTimer,x           ;;Load Tens Digit
    BNE SubtractTime        ;;If not 0, we have more than 000
    DEX                 ;;Checking Tens
    LDA myTimer,x           ;;Load Ones Digit
    BNE SubtractTime
    JMP RESET            ;;this is what happens when the time is zero
  
 
  
;;;;;;;;;;;;;;;;;;;;;;;;;;;
    LDA #DayNightSpeed
    STA gameTimer

  
    dontUpdateGameTimer:
    RTS
  
  
SubtractTime:

SubtractValue #$03, myTimer, #$01, #$00 ;;Subtract 1 from the Ones digit
  

    ;;Update HUD
    LDA #$03                    ;; your timer can only have max 3 numbers
    STA hudElementTilesToLoad
    LDA DrawHudBytes
    ORA #HUD_myTimer
    STA DrawHudBytes
    RTS


  
DoAlarm:
  
    ;;; we're going to edge-load monsters one at a time if they are of edge type and are not active.
    LDX #$00
doLoadMonsterOnTimerLoop:

    LDA edgeLoaderInCue
    BEQ noEdgeMonstersInCue
    LDA currentBank
    STA prevBank
    LDY #$1C ;; data bank
    JSR bankswitchY
    JSR CreateTimedEdgeSpawner
    DEC edgeLoaderInCue
    LDY prevBank
    JSR bankswitchY

noEdgeMonstersInCue
    RTS
Hey Dale. I wanted to implement this into my game on NESmaker 4.5. But it doesn't seem to be working with 4.5.
Ugh...

Did step 1 & step 2... step 3 I can't find handlescreenloads.asm ... only extra screen load and post screen load

I setup the user variable myTimer and set it to 60

then run game and get a million errors in the HandleGamerTimer.asm .. lines 12, 26, 56, 57, 59, 70, 75, 76, 77, 79 ...of the first script

Anybody have any clue how to et this to run in 4.5.9?
Yeah. I was just thinking the same thing. I keep getting the same problem. Looks like it might not work with 4.5.9 šŸ˜„
 
Top Bottom