different hud for different levels

strawmancomics

New member
I'm really struggling to understand basic programing logic. I want to click on a screen flag and have it change the hud for that particular level. I'm working with the doDrawSpriteHud_L2RPlatformer.asm file. After drawing my initial hud elements I want to change a background sprite to a different image. In my code example the moon sprites show up on the level. However the screen flag doesn't seem to matter if it's checked or not. To test the code I only wanted one sprite to show up on the next level. The following code doesn't work like it should but it doesn't break the game either.

For any solutions provided I would appreciate an explanation of what's happening with the code.

LDA ScreenFlags00 ; load screenflags 0-7
CMP #%00000110 ; checks the screen flag 6 bit
BEQ +Moon


+Moon:
DrawSprite #220, #30, #$2A, #%00000000
DrawSprite #228, #30, #$2B, #%00000000
DrawSprite #236, #30, #$2C, #%00000000
DrawSprite #220, #38, #$3A, #%00000000
DrawSprite #228, #38, #$3B, #%00000000
DrawSprite #236, #38, #$3C, #%00000000
DrawSprite #220, #44, #$4A, #%00000000
DrawSprite #228, #44, #$4B, #%00000000
DrawSprite #236, #44, #$4C, #%00000000

JMP +finishMoon


DrawSprite #220, #30, #$2A, #%00000000

+finishMoon
rts
 

dale_coop

Moderator
Staff member
I don't which bit of the screen flags you want to check (alors your jumps are incorrects) but... if it's 6, your code should be, somethting like
Code:
LDA ScreenFlags00 ; load screenflags 0-7
AND #%00000010 ; checks the screen flag 6 bit
BEQ +notChecked
    JMP +checked

+notChecked:
  DrawSprite #220, #30, #$2A, #%00000000
  DrawSprite #228, #30, #$2B, #%00000000
  DrawSprite #236, #30, #$2C, #%00000000
  DrawSprite #220, #38, #$3A, #%00000000
  DrawSprite #228, #38, #$3B, #%00000000
  DrawSprite #236, #38, #$3C, #%00000000
  DrawSprite #220, #44, #$4A, #%00000000
  DrawSprite #228, #44, #$4B, #%00000000
  DrawSprite #236, #44, #$4C, #%00000000

  JMP +finishMoon

+checked:
  DrawSprite #220, #30, #$2A, #%00000000

+finishMoon
 

dale_coop

Moderator
Staff member
The code is corect and should draw a bunch of sprites if the flag is NOT set and only one sprite if the flag is set (the sprite $2A).

Maybe it's not what you want to do? Can you be more specific?
Which sprite(s) do you want to draw when the flag is set and which sprites when it's not set?
(share screenshots of your tileset)
 

strawmancomics

New member
I forgot to give an update on my situation. I was able to use the screen flags to switch up my HUD. I think I had to use a different a different .ASM file to get it to work. I also had to change the logic order if checked or if not checked. I’m really fuzzy on the details. Once I got this to work I Immediately set about to implementing a pallet cycle in my game. I got that to work but it worked on every screen and I didn’t want that. Using what I learned from the screen flags code from this thread I created a screen flag that targeted a specific screen to use the effect. However it halfway worked. Where there was no hud I could stop the pallet from cycling. However when the hud was active the pallet cycling continued. I tried many variations on the code and started to understand the programing logic flow but I still couldn’t get it to work properly. Because the deadline was looming I had to cut all that custom code and try to restore everything to pre pallet swap status. So in my game Horace and Buggie shoot for the moon you’ll see that there’s a continuous sprite of the moon hanging out on level 1 and the earth hanging out on level 2. To achieve this it also came with compromise. If I gave my character 3 lives that was too much processing for the sprites and I got terrible slow down. Limiting the lives to two solved that issue. But solved it poorly.
 
Top Bottom