Update multiple HUD elements simultaneously [4.5.9]

dale_coop

Moderator
Staff member
One of the somewhat frustrating limitations of NESmaker is that you can only update one HUD element at a time (if you're using the normal tile based HUD)
Indeed, if you have multiple UpdateHudElement calls in succession in the code, only the last one is taken into account >_<
For example, when you do:
Code:
;; refill Ammo:
LDA #$05
STA myAmmo
UpdateHudElement #$03

;; refill Health:
LDA myMaxHealth
STA myHealth
UpdateHudElement #$02


Here's a small fix that will now ensure that all UpdateHudElements are considered, allowing you to update multiple HUD elements simultaneously.

UpdateHudElements.gif

Modify the UpdateHudElement.asm script that is located in the "GameEngineData\Routines\BASE_4_5\System\Macros" folder.
Replace the content of that script with that code:
Code:
MACRO UpdateHudElement arg0;, arg1
    ;;; arg 0, which element to update.
    ;;; what variable should we update?
    
    TYA
    PHA
    LDY arg0
    ;; LDA ValToBitTable_inverse,y
    LDA hudUpdates                    ;; dale_coop: for multiple updates at once
    ORA ValToBitTable_inverse,y        ;; dale_coop: for multiple updates at once
    STA hudUpdates
    PLA
    TAY
    
    ENDM

That's it. Now it should work.
 
Top Bottom