Possible Space Saver: Disabling the HUD

User avatar
jorotroid
Posts: 151
Joined: Wed Aug 08, 2018 7:48 pm
Location: California
Contact:

Possible Space Saver: Disabling the HUD

Post by jorotroid » Sun Sep 09, 2018 10:00 pm

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: Select all

	; 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.
User avatar
Jacotomo
Posts: 22
Joined: Tue Sep 04, 2018 3:46 pm

Re: Possible Space Saver: Disabling the HUD

Post by Jacotomo » Fri Sep 14, 2018 2:26 pm

Thanks, great for the simple game I am making.
User avatar
stevenshepherd
Posts: 191
Joined: Sun Feb 18, 2018 5:25 pm

Re: Possible Space Saver: Disabling the HUD

Post by stevenshepherd » Fri Sep 14, 2018 7:02 pm

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)?
User avatar
chronosv2
Posts: 217
Joined: Wed Aug 08, 2018 9:30 pm
Location: KY, USA
Contact:

Re: Possible Space Saver: Disabling the HUD

Post by chronosv2 » Fri Sep 14, 2018 7:26 pm

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.
ASM/C# Coder -- Computer + Coffee = Code
ASM Tutorial Series
User avatar
jorotroid
Posts: 151
Joined: Wed Aug 08, 2018 7:48 pm
Location: California
Contact:

Re: Possible Space Saver: Disabling the HUD

Post by jorotroid » Fri Sep 21, 2018 7:24 pm

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.

Image
User avatar
jorotroid
Posts: 151
Joined: Wed Aug 08, 2018 7:48 pm
Location: California
Contact:

Re: Possible Space Saver: Disabling the HUD

Post by jorotroid » Tue Oct 09, 2018 1:18 am

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.
User avatar
DanielT1985
Posts: 61
Joined: Sat Sep 01, 2018 7:44 pm

Re: Possible Space Saver: Disabling the HUD

Post by DanielT1985 » Tue Oct 09, 2018 5:03 pm

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?
User avatar
CutterCross
Posts: 271
Joined: Sat Apr 28, 2018 9:42 pm

Re: Possible Space Saver: Disabling the HUD

Post by CutterCross » Wed Oct 10, 2018 1:00 am

DanielT1985 wrote:
Tue Oct 09, 2018 5:03 pm
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.
The Tower of Turmoil: viewtopic.php?f=12&t=1348
User avatar
DanielT1985
Posts: 61
Joined: Sat Sep 01, 2018 7:44 pm

Re: Possible Space Saver: Disabling the HUD

Post by DanielT1985 » Wed Oct 10, 2018 1:13 am

CutterCross wrote:
Wed Oct 10, 2018 1:00 am
DanielT1985 wrote:
Tue Oct 09, 2018 5:03 pm
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
User avatar
CutterCross
Posts: 271
Joined: Sat Apr 28, 2018 9:42 pm

Re: Possible Space Saver: Disabling the HUD

Post by CutterCross » Wed Oct 10, 2018 1:19 am

DanielT1985 wrote:
Wed Oct 10, 2018 1:13 am
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!
The Tower of Turmoil: viewtopic.php?f=12&t=1348
Post Reply