When I was playing with the new version (4.5 from the Summer Camp tutorials), I thought that the new sprite HUD for scrolling games was really cool.
No more Sprite Zero settings and really less slowdowns on your scrolling games! (the normal hud is really CPU consuming)
IMPORTANT: If you haven't seen that video explaining that new sprite Hud, you can watch it here (please watch it before going further): https://vimeo.com/432579544/67c856e297
Let's implement the same Sprite HUD system for NESmaker 4.1.5!
(myHealth and myLives are displayed as a sprite Hud)
Here's how to do:
1) First, we need to disable the normal HUD (tile based). Go to the "Hud & boxes" settings:
- uncheck the "Use Sprite Zero Detection" (you don't need that anymore)
- click on the Hud area "SET" button until it disappears (X:0 Y:0 W:0 H:0)
2) In the "Project Settings > User Constants", change the "HIDE_HUD" constant value to "1" (to disable the normal HUD):
3) In Windows Explorer, go to your "NESmaker" folder, then navigate until the "GameEngineData\Routines\Basic\System\Macros\" sub folder, make a new file named "DrawSpriteHud.asm" (or just duplicate any file from that folder and rename it):
Modify that script (in Notepad++ or Notepad...), and replace all the content with that code:
4) Still, in Windows Explorer, go to your "NESmaker" folder, then navigate until the "GameEngineData\Routines\Basic\ModuleScripts\MainScripts\" sub folder, make a new file named "PreDraw_WithSpriteHud.asm" (or just duplicate any file from that folder and rename it, like this):
Modify that script (in Notepad++ or Notepad...), and replace all the content with that code:
5) In your "Project Settings > Script Settings", select the "Handle Sprit Pre-Draw" element and assign the "PreDraw_WithSpriteHud.asm" script we just made:
Voilà, now you should have the same Sprite Hud system than the new version but on your 4.1.5 project.
No more Sprite Zero settings and really less slowdowns on your scrolling games! (the normal hud is really CPU consuming)
IMPORTANT: If you haven't seen that video explaining that new sprite Hud, you can watch it here (please watch it before going further): https://vimeo.com/432579544/67c856e297
Let's implement the same Sprite HUD system for NESmaker 4.1.5!
(myHealth and myLives are displayed as a sprite Hud)
Here's how to do:
1) First, we need to disable the normal HUD (tile based). Go to the "Hud & boxes" settings:
- uncheck the "Use Sprite Zero Detection" (you don't need that anymore)
- click on the Hud area "SET" button until it disappears (X:0 Y:0 W:0 H:0)
2) In the "Project Settings > User Constants", change the "HIDE_HUD" constant value to "1" (to disable the normal HUD):
3) In Windows Explorer, go to your "NESmaker" folder, then navigate until the "GameEngineData\Routines\Basic\System\Macros\" sub folder, make a new file named "DrawSpriteHud.asm" (or just duplicate any file from that folder and rename it):
Modify that script (in Notepad++ or Notepad...), and replace all the content with that code:
Code:
MACRO DrawSpriteHud arg0, arg1, arg2, arg3, arg4, arg5, arg6
; arg0 = starting position in pixels, x
; arg1 = starting position in pixels, y
; arg2 = sprite to draw, CONTAINER
; arg3 = MAX
; arg4 = sprite to draw, FILLED
; arg5 = variable.
; arg6 = attribute
tya
PHA
TXA
PHA
LDA arg4
STA temp ;; full
LDA arg0
STA temp2
LDA arg5
BNE +notZeroVar
;; if the variable was zero, draw empty tiles
LDA arg2
STA temp
+notZeroVar:
LDX #$00
doDrawSpriteHudElementFullLoop:
LDY spriteOffset
LDA arg1
STA SpriteRam,y
INY
LDA temp
STA SpriteRam,y
INY
LDA arg6
STA SpriteRam,y
INY
LDA temp2
STA SpriteRam,y
INY
LDA spriteOffset
CLC
ADC #$04
STA spriteOffset
LDA temp2
CLC
ADC #$08
STA temp2
INX
CPX arg3 ;; is it to the max?
BEQ doneWithSpriteDrawElement
CPX arg5 ;; has it reached the fill point?
BCS changeToContainerSprite
JMP doDrawSpriteHudElementFullLoop
changeToContainerSprite:
;; not done with sprite draw element, but now need to change to container
LDA arg2
STA temp
JMP doDrawSpriteHudElementFullLoop
doneWithSpriteDrawElement:
PLA
TAX
PLA
TAY
ENDM
4) Still, in Windows Explorer, go to your "NESmaker" folder, then navigate until the "GameEngineData\Routines\Basic\ModuleScripts\MainScripts\" sub folder, make a new file named "PreDraw_WithSpriteHud.asm" (or just duplicate any file from that folder and rename it, like this):
Modify that script (in Notepad++ or Notepad...), and replace all the content with that code:
Code:
;; sprite pre-draw
;;; this will allow a user to draw sprites before object sprites are drawn.
;;; keep in mind, there are still only 64 sprites that can be drawn on a screen, and still only 8 per scan line!
LDA gameState
CMP #GS_MainGame ;; we check if on main game screens
BEQ + ;; if it is we can continue
JMP skipDrawingSpriteHud ;; if not we skip the sprite Hud drawing
+
LDA screenFlags
AND #%00000001 ;; we check if the "hide hud" screen flag is set
BEQ + ;; if not we can continue
JMP skipDrawingSpriteHud ;; if it is we skip the sprite Hud drawing
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; TO KNOW HOW TO USE THAT SPRITE HUD, CHECK JOE'S VIDEO:
;; https://vimeo.com/432579544/67c856e297
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;DrawSpriteHud #$08, #$08, #$11, #$10, #$10, myVar, #$00
; arg0 = starting position in pixels, x
; arg1 = starting position in pixels, y
; arg2 = sprite to draw, CONTAINER
; arg3 = MAX
; arg4 = sprite to draw, FILLED
; arg5 = variable.
; arg6 = attribute
DrawSpriteHud #$10, #$10, #$0C, #$03, #$0D, myHealth, #$01
DrawSpriteHud #$D0, #$10, #$0E, #$03, #$0F, myLives, #$00
skipDrawingSpriteHud:
5) In your "Project Settings > Script Settings", select the "Handle Sprit Pre-Draw" element and assign the "PreDraw_WithSpriteHud.asm" script we just made:
Voilà, now you should have the same Sprite Hud system than the new version but on your 4.1.5 project.