Skip to content

Instantly share code, notes, and snippets.

@karikas
Last active October 5, 2021 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karikas/2cf911fce98e59fb3a3cde9280f44368 to your computer and use it in GitHub Desktop.
Save karikas/2cf911fce98e59fb3a3cde9280f44368 to your computer and use it in GitHub Desktop.
NESMaker 4.5.9 Custom HUD text code reference

This code corresponds with the video how-to on adding custom HUD text per screen found at https://youtu.be/iEKdwuDYT_A

These reference files under the NESMaker 4.5.9 scripts in the \GameEngineData\Routines\BASE_4_5\Game\ folder (a little different from the video):

  • \LoadAllSubroutinesMaile2.asm
  • \MOD_AdventureBase\Game\PostScreenLoad_AdventureBase.asm
  • \MyCustomCode\varHudLocationText.asm
; Added this around line 31 above the HUD file includes, but I don't think it has to specifically go there
; Change the "MyCustomCode" part of the path to wherever you're putting this file
.include ROOT\Game\MyCustomCode\varHudLocationText.asm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Custom HUD "Location" text update - MK
;; You can probably skip the commented lines,
;; but in case things look weird they're here
;; for reference.
; LDA gameHandler ; Do a thing to check the HUD
; AND #%00100000 ; Still doing a thing to check the HUD
; BNE doDrawHudUpdatesCustom ; If the HUD isn't hidden then...
JSR updateHudLocationText ; Run our custom HUD text updater for the Location value
; doDrawHudUpdatesCustom ; If the HUD was hidden we have landed here
;;;;;;;;;;;;;;;;;;;;;;;;;;
;; MIKE CODE -----
;; Set variable location text values for HUD
;; Generate these with NESMaker's HUD -> HUD Assets tool,
;; reference them in the HUD Elements, and then take note
;; of the output in \GameEngineData\GameData\HUD_DEFINES.dat
;;
;; It also appears that you can use the values found in
;; HUD_CONSTANTS.dat instead of the hex numbers below - such
;; as #_T, #_H, #_I, #_S
;;
;; Follow the patterns below for additional flags and text
HUD__0_LOC_STRING: ; "INSIDE HOUSE" text
.db #$22, #$27, #$2c, #$22, #$1d, #$1e, #$35, #$21, #$28, #$2e, #$2c, #$1e, #$35, #$35, #$35, #$FF
HUD__1_LOC_STRING: ; "OUTSIDE" text
.db #$28, #$2e, #$2d, #$2c, #$22, #$1d, #$1e, #$35, #$35, #$35, #$35, #$35, #$35, #$35, #$35, #$FF
HUD__2_LOC_STRING: ; "TRADER JOE'S" text
.db #$2d, #$2b, #$1a, #$1d, #$1e, #$2b, #$35, #$23, #$28, #$1e, #$00, #$2c, #$35, #$35, #$35, #$FF
; Check each user flag for location text to draw
updateHudLocationText:
LDA ScreenFlags01 ; check "ScreenFlags2"
AND #%10000000 ; check User Flag 8
BEQ + ; if not set, jump to the next check
DrawTilesDirect #HUD_BANK, HUD__0_LOC_STRING, #2, #2, #HUD_OFFSET
RTS ; if set, update location text and return
+
LDA ScreenFlags01 ; check "ScreenFlags2"
AND #%01000000 ; check User Flag 9
BEQ + ; if not set, jump to the next check
DrawTilesDirect #HUD_BANK, HUD__1_LOC_STRING, #2, #2, #HUD_OFFSET
RTS ; if set, update location text and return
+
LDA ScreenFlags01 ; check "ScreenFlags2"
AND #%00100000 ; check User Flag 10
BEQ + ; if not set, jump to the next check
DrawTilesDirect #HUD_BANK, HUD__2_LOC_STRING, #2, #2, #HUD_OFFSET
RTS ; if set, update location text and return
+
RTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment