Possible Space Saver: Disabling the HUD

jorotroid

Member
Updated: I realized there were more lines I could comment out.

Obviously this isn't for everyone, but I think right now it looks like it will be useful for my game. By disabling the HUD you save about 1k of memory! Eventually, I'm going to try to make a Mega Man style sprite HUD, so I'll "lose" some of that space again, but for now this seems promising. If you want to disable the HUD, go to HandleScreenLoads.asm to about line 308and comment out things out like this:

Code:
	; LDA #$02 
	; STA backgroundTilesToLoad ;; yikes, we probably want to do something different here.
	
	; LDA currentBank
	; STA prevBank
	; LDY #$16
	; JSR bankswitchY
	; LDX backgroundTilesToLoad
	; LDA #CHRAddressLo,x
	; STA temp16
	; LDA #CHRAddressHi,x
	; STA temp16+1
	; LDY prevBank
	; JSR bankswitchY
	
	; LoadChrData #$1d, #$1c, #$00, #$40
	;;; black out hud space?
;	BlackOutArea #$20, #$00, #$80		;JOROTROID: This one was already commented out
;
	; LDA HudHandler
	; AND #%10000000
	; BNE drawHud_GameHandler
	; JMP skipDrawingHud_GameHandler
;drawHud_GameHandler:
;; check to see if hud is shown.
	;; if hud is hidden, skip
	;; otherwise...
	;;; prep hud area load
	
	; JSR WaitFrame
	
	; LDA #BOX_0_WIDTH 
	; STA updateNT_columns
	; LDA #BOX_0_HEIGHT
	; STA updateNT_rows
	; LDA #BOX_0_ORIGIN_X
	; STA tileX
	; LDA #BOX_0_ORIGIN_Y
	; STA tileY
	; JSR FillBoxArea
	; JSR WaitFrame
	
	;;;;;;;;;;;;;;;;
	;; set up attribute routine needs
	; LDA #BOX_0_ORIGIN_X
	; STA tileX
	; LDA #BOX_0_ORIGIN_Y
	; STA tileY 
	; LDA #BOX_0_ATT_WIDTH
	; STA updateNT_attWidth
	; LDA #BOX_0_ATT_HEIGHT
	; STA updateNT_attHeight
	;;;;;;;;;;;;;;;
	;JSR UpdateAttributeTable
	;; first turn off drawing sprites.
	;JSR WaitFrame 		;JOROTROID: This one was already commented out
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;.include "Routines\System\HandleLoadHud.asm"
	;.include "Routines\System\HandleScreenLoadHudDraw.asm"
;skipDrawingHud_GameHandler:

I make no guarantees there there aren't some negative repercussions to doing this.
 

stevenshepherd

New member
When you say it will save memory, you mean compared to having more screen available, or just having a black bar with no info in it/no info that needs to be constantly updated (like health)?
 

chronosv2

New member
I believe it's code in the Static Bank that gets disabled, so program space.
Screens are stored in their own bank so you can easily have all 512 without any adverse effects, as far as I'm aware.
Turning off the code also means you should get the entire screen as gameplay space. I've got more plans for HUD-using code, though, so it's a feature trade-off.
 

jorotroid

Member
I really need to remember to click subscribe when I make a new topic.

Yes, what chronosv2 said. I'm adding a lot of code, so the Static Bank got filled up. You can see this happen in the video Joe put out on facebook the day they released NESmaker. You can use a tool called NES Space Checker to see how much of the Static Bank (bank $1F) is getting used. After disabling the HUD, I went from 0kb free to 1kb free. Unfortunately the tool only displays the value of free space in increments of 1kb plus a visual representation, so it's hard to see how much I have left now, but looks like I have a little less than 500 bytes free at the moment.

oVY4tXG.png
 

jorotroid

Member
A bit of a warning, when I did this I was desperate for more space to make other stuff and didn't yet understand what sort of downsides there might be to gutting out the HUD system. I now know a bit more and also came to a point in my game where I wanted to draw some text boxes, but found out that text boxes also rely on the HUD code. So text boxes won't work if you do this. I'm trying to see if I can figure out a way to have textboxes, without bringing all of the HUD system back. So far I have been able to get a box to show up, but I can't figure out how to actually get the text two write on screen.
 

DanielT1985

Member
I was wondering if there was a way to make certain screens not show the hud and others show it. I would like to be able to make screens and cutscenes without having to constantly see the hud. Any ideas?
 

CutterCross

Active member
DanielT1985 said:
I was wondering if there was a way to make certain screens not show the hud and others show it. I would like to be able to make screens and cutscenes without having to constantly see the hud. Any ideas?

You can make another palette for those specific screens and have all the colors in your HUD subpalette be black (or whatever your "sky color" is). That's what I did for my animated splash screens.

Video: https://www.youtube.com/watch?v=QrV7TEDBu4k

The HUD is still there, but all the colors in its subpalette are black to match the background, so you can't see the text.
 

DanielT1985

Member
CutterCross said:
DanielT1985 said:
I was wondering if there was a way to make certain screens not show the hud and others show it. I would like to be able to make screens and cutscenes without having to constantly see the hud. Any ideas?

You can make another palette for those specific screens and have all the colors in your HUD subpalette be black (or whatever your "sky color" is). That's what I did for my animated splash screens.

Video: https://www.youtube.com/watch?v=QrV7TEDBu4k

The HUD is still there, but all the colors in its subpalette are black to match the background, so you can't see the text.

1. Thank you for that.
2. OH MY GOD THAT LOOKS AWESOME
 

DanielT1985

Member
CutterCross said:
DanielT1985 said:
1. Thank you for that.
2. OH MY GOD THAT LOOKS AWESOME

Haha, thanks a lot! Once NESmaker starts supporting fades again I'm sure I can make it look even better!

Looking at your Tower of Turmoil videos, I saw that You managed to get enemies to stay on platforms, which is something I tried doing but failing miserably.
 

CutterCross

Active member
DanielT1985 said:
Looking at your Tower of Turmoil videos, I saw that You managed to get enemies to stay on platforms, which is something I tried doing but failing miserably.

I just used the MonsterBlock asm file and made a new tile type in the Project Settings tab. Then I just place those tiles on each side of a platform with a monster on it.

I know it wasn't really included in the Platformer tutorial, so I'll just provide it here if you don't have it.
Code:
;; MONSTER BLOCK	
	;;; skip monster block if player
	LDA Object_flags,x
	AND #%00001000 ;; is it a monster?  
	BEQ skipMonsterBlock;; skip monster block if not a monster
	;; do any other checks here.  Is there a bit you want to use to determine
	;;; whether or not specific monsters ignore monster blocks?  like flying monsters, etc?
	LDA #TILE_SOLID
	STA tile_solidity
skipMonsterBlock:
  RTS
 

jorotroid

Member
DanielT1985 said:
I was wondering if there was a way to make certain screens not show the hud and others show it. I would like to be able to make screens and cutscenes without having to constantly see the hud. Any ideas?

I think what your are looking for is dale_coop's thread on cutscenes.
http://nesmakers.com/viewtopic.php?f=3&t=597&hilit=hide+hud
He temporarily disables the hud in that code. The what I am going for here is to not only disable it, but to also remove it entirely to make room for different stuff.
 
Top Bottom