Having a little trouble with the Prize tile code in Arcade Plat (4.5.9)

So my goal is to make a prize tile similar to the coin in Mario, where you collect 100 and get an extra life. While I am able to get the Prize counter (HUD element 0) to count up currently, the Lives counter (HUD element 1) does not update when I collect 100 prizes. Can anyone see what I'm doing wrong here?
Thanks.

Code:
;;; prize tile

    LDA updateScreenData
    AND #%00000100
    BEQ +doScript
        RTS
    +doScript
    LDA scrollOffsetCounter
    BEQ +doIt
        RTS
    +doIt   
CPX player1_object
BEQ +isPlayer
    JMP +notPlayer
    +isPlayer
    


    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BELOW WILL CHANGE TILE AT COLLISION.
    
    ChangeTileAtCollision #$E7, #$00
    
    ;MACRO AddValue arg0, arg1, arg2, arg3
    ;arg0 = how many places this value has.
    ;arg1 = home variable
    ;arg2 = amount to add
    ;arg3 = what place value is receiving the addition?
        ;;; 0 = ones place, 1 = tens place, 2 = hundreds place, etc.
UpdateHudElement #$00


        INC myPrizes
AddValue #$01, myPrizes, #$0, #$00
        LDA myPrizes
        CMP #100 ;; one more than the max
        BEQ +addLives
JMP +notHundredYet

+addLives
        UpdateHudElement #$01
            INC myLives
            LDA myLives
    AddValue #$01, myLives, #$00, #$00
        ;    LDA #$00 ;; normalize the value to 00 if it got bigger than 100
        ;    STA myPrizes
        ;+dontNormalizeValue

        
AddValue #$07, myScore, #$1, #$02
    UpdateHudElement #$06

+notHundredYet
+notPlayer
 

tbizzle

Well-known member
You should put the UpdateHudElement 1 and 2 after where you placed your INC's. Also this isn't doing anything, it is just adding a zero?

Code:
AddValue #$01, myPrizes, #$0, #$00
and this one
AddValue #$01, myLives, #$0, #$00

I guess I'd do it like this:

Code:
;;; prize tile

    LDA updateScreenData
    AND #%00000100
    BEQ +doScript
        RTS
    +doScript
    LDA scrollOffsetCounter
    BEQ +doIt
        RTS
    +doIt  
CPX player1_object
BEQ +isPlayer
    JMP +notPlayer
    +isPlayer
   


    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BELOW WILL CHANGE TILE AT COLLISION.
   
    ChangeTileAtCollision #$E7, #$00
   
    ;MACRO AddValue arg0, arg1, arg2, arg3
    ;arg0 = how many places this value has.
    ;arg1 = home variable
    ;arg2 = amount to add
    ;arg3 = what place value is receiving the addition?
        ;;; 0 = ones place, 1 = tens place, 2 = hundreds place, etc.



        INC myPrizes
        UpdateHudElement #$00
        LDA myPrizes
        CMP #100 ;; one more than the max
        BEQ +addLives
JMP +notHundredYet

+addLives
       
            INC myLives
            UpdateHudElement #$01
        ;    LDA #$00 ;; normalize the value to 00 if it got bigger than 100
        ;    STA myPrizes
        ;+dontNormalizeValue

       
AddValue #$07, myScore, #$1, #$02
    UpdateHudElement #$06

+notHundredYet
+notPlayer

Then also if you plan on having myPrizes reach a denomination of 100, you'd need two more variables for myPrizes:
myPrizes
myPrizes01
myPrizes001
 
You should put the UpdateHudElement 1 and 2 after where you placed your INC's. Also this isn't doing anything, it is just adding a zero?

Code:
AddValue #$01, myPrizes, #$0, #$00
and this one
AddValue #$01, myLives, #$0, #$00

I guess I'd do it like this:

Code:
;;; prize tile

    LDA updateScreenData
    AND #%00000100
    BEQ +doScript
        RTS
    +doScript
    LDA scrollOffsetCounter
    BEQ +doIt
        RTS
    +doIt 
CPX player1_object
BEQ +isPlayer
    JMP +notPlayer
    +isPlayer
  


    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BELOW WILL CHANGE TILE AT COLLISION.
  
    ChangeTileAtCollision #$E7, #$00
  
    ;MACRO AddValue arg0, arg1, arg2, arg3
    ;arg0 = how many places this value has.
    ;arg1 = home variable
    ;arg2 = amount to add
    ;arg3 = what place value is receiving the addition?
        ;;; 0 = ones place, 1 = tens place, 2 = hundreds place, etc.



        INC myPrizes
        UpdateHudElement #$00
        LDA myPrizes
        CMP #100 ;; one more than the max
        BEQ +addLives
JMP +notHundredYet

+addLives
      
            INC myLives
            UpdateHudElement #$01
        ;    LDA #$00 ;; normalize the value to 00 if it got bigger than 100
        ;    STA myPrizes
        ;+dontNormalizeValue

      
AddValue #$07, myScore, #$1, #$02
    UpdateHudElement #$06

+notHundredYet
+notPlayer

Then also if you plan on having myPrizes reach a denomination of 100, you'd need two more variables for myPrizes:
myPrizes
myPrizes01
myPrizes001
Hello!

I'm not entirely sure what you mean about the addvalue macros as they function fine in my script. If you mean arg2, I have it as #$00 instead of #$01, because writing #$01 (or #1) adds 2 prizes to my Prize counter.

This script you have sent I believe I've used before, and unfortunately it does not work properly in my game. Both prize and life counters update, however, after the counter reaches 09, Instead of going to 10, it goes to 0A, 0B, 0C and goes through all the tiles in the HUD and other screen tiles. The tenths digit never updates.

I forgot to mention I did have a myPrizes01 variable, but my counter goes from 99 to 00 and never displays 100, would I still need a myPrizes001 variable?
 
Top Bottom