[4.5.6] Hide Sprite Hud on certain Game States

TheStrahl

New member
So I'm using a sprite based HUD and I want it to only show on the Main Game Game-state. I'm still learning 6502 and I want to give it an honest try.

I know this is the section I want to do it in most likely.
Code:
;;; Here is an example of how to do a sprite hud.
;;; Arg5, the one that has the value of myVar, must correspond to a user variable you have in your game.
;;; Don't forget, you can only draw 8 sprites per scanline, so a sprite hud can only be 8 sprites wide max.


;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 #16, #16, #$7f, myLives, #$32, myLives, #%00000000  ;;;; this draws health

;;; Here, we are going to draw a sprite, followed by a little x, followed by numbers representing a quasi-score value.
;;; We are doing this all with sprites so that it can follow our hud more easily. 
;;; To do this, our game object tileset has numbers, 0-9, located at 40-49, and 4A represents the X.
;;; The identifier for the type of thing we're drawing is at 22.

    DrawSprite #16, #26, #$22, #%00000001 ;; draws the "carrot"
    DrawSprite #24, #26, #$4a, #$00 ;; draws the x 8 pixels to the right of it.
    
    LDA myPrizes
    CLC
    ADC #$40
    ;; now we have the number 40 + how many prizes we have.
    ;; so the resulting graphic will be 0-9.
    STA temp
    DrawSprite #32, #26, temp, #$00

I'm thinking I need to do something like


Code:
LDA (The current Game state) <- What would go here?
BEQ (The Game state I want the HUD to be visible) <what would go here?

The Hud Code here

Am I on the right track or is it something more complicated?
 

CutterCross

Active member
You're on the right track.

gameState holds the current game state, from #$00 to #$07.

So you'd want to:
Code:
LDA gameState
BNE skipDrawingSpriteHud    ;;main gs is #$00, so no need to CMP.

;;;; sprite HUD code here

skipDrawingSpriteHud:
 

CutterCross

Active member
Also if you run into a Branch out of Range error just flip the branch statement and use a JMP like this:

Code:
LDA gameState
BEQ +
JMP skipDrawingSpriteHud
+

;;;; sprite HUD code here

skipDrawingSpriteHud:
 

drexegar

Member
I use a screen flag instead. There a weird problem with Game states in nesmaker, for whatever reason, the bits get moved over 4 times, and only the first 4 are available on the 5 6 7 and 8 bits.

This does not effect the controller code.
 
Top Bottom