News:

11 March 2016 - Forum Rules

Main Menu

Zelda 1 level text

Started by gzip, September 19, 2020, 06:41:40 PM

Previous topic - Next topic

gzip

I'd like to change the text in the dungeons from "Level-1" to "Dungeon-1". In addition to the text change, the text also has to move over to the left one space so it fits well. This is probably an easy change for someone that knows what they're doing. I'm not having much luck.


ultimaweapon

The3Dude changes his from Level to Map, so he would be the person to ask.
Trust in the Heart of the Cards

The3Dude

Quote from: gzip on September 19, 2020, 06:41:40 PM
I'd like to change the text in the dungeons from "Level-1" to "Dungeon-1". In addition to the text change, the text also has to move over to the left one space so it fits well. This is probably an easy change for someone that knows what they're doing. I'm not having much luck.


First things first, if you are hacking an NES game, the EASIEST way to hex edit is by using the FCEUX emulator. Here is a step by step to getting to the line of text you want to find.

1. Open Zelda 1 in FCEUX.
2. Click the debug tab.
3. After clicking the debug tab, click the "Hex editor..." tab.
4. Once the hex editor appears, click "View".
5. Change from "NES MEMORY" view to "ROM FILE" view.
6. After above steps, click "File"... You should now see a selection called "Load *.TBL File"
7. Click Load Table file, download this table file https://drive.google.com/file/d/1sRZBYPIOS42uWmxNC1qUGAUHwPyPm9uv/view?usp=sharing and then load the downloaded table file.

8. After loading the .TBL file, finding your text string is super easy. All you must do is click the "Edit" tab, then the "Find..." tab, search for the text you are looking for, which in this case is LEVEL-, Just search "level" all lowercase and you should find what you're looking for.
9. MAKE SURE YOU CHANGE  THE VIEW TYPE FROM HEX VIEW TO TEXT VIEW OR YOU WON'T FIND THE TEXT STRING!
~The3Dude~

ShadowOne333

I think I tried to do something similar for Redux, but I ended up not going for it, can't truly remember why.

I believe because I was having issues with either the character length, the dash being handled through code or the number, which is also handled through code.
I might give this a go again later this week.

gzip

#4
Quote from: The3Dude on September 19, 2020, 10:57:59 PM
First things first, if you are hacking an NES game, the EASIEST way to hex edit is by using the FCEUX emulator.

Thanks, I've done all this already but the text doesn't really allow me to go beyond the current length without causing corruption. I also need to move the text to the left one space. I imagine that I'll have to relocate the text, read from there, and then tweak the start column and number replacement. Can you point me to the relevant code?

I added a read breakpoint for the RAM location (0x681F) and I can see the text being written to the PPU but I'm not sure where the column location and text length are stored.

> 01A0DE:B0 01     BCS $A0D1
  01A0E0:C8        INY
  01A0E1:B1 00     LDA ($00),Y @ $6823 = #$0E
  01A0E3:8D 07 20  STA PPU_DATA = #$F6
  01A0E6:CA        DEX
  01A0E7:D0 F5     BNE $A0CE


It would be really useful to know how to use the stack to see where this was called from.

The3Dude

Quote from: gzip on September 19, 2020, 11:25:31 PM
Thanks, I've done all this already but the text doesn't really allow me to go beyond the current length without causing corruption. I also need to move the text to the left one space. I imagine that I'll have to relocate the text, read from there, and then tweak the start column and number replacement. Can you point me to the code where the text gets written to the screen?

I honestly same as you have no idea on how to move the text offset. But I did find a "Smarter not Harder"  ;) workaround for it. If you have graphics space "Which you most likely do" Just do this.



That way, it will still say dungeon, and you won't have to find the pointers.
~The3Dude~

gzip

Good idea! I don't have the graphics space though. :-\

The3Dude

Quote from: gzip on September 19, 2020, 11:44:50 PM
Good idea! I don't have the graphics space though. :-\

You very sure? I can make some space if you send me the current build.

As long as it doesn't look like this :laugh: :-\ And If you have title screen graphics in the section of space seen on that image above, I could move it to the top of the game near where the "PLEASE READ THE MANUAL FOR DETAILS" sign is located.




It would look like this in game btw.

~The3Dude~

gzip

Here's how my space currently looks (a lot of it gets eaten up by automap). There are title graphics in there, the "A NEW LIGHT" part, so if you have some magic to move them, then by all means. The extra space would be welcome either way (if I can make the text change without additional graphics then all the better).

The current build is on the hack page.


The3Dude

Would you like me to modernize the Zelda title screen font too?
~The3Dude~

gzip

Quote from: The3Dude on September 20, 2020, 12:25:07 AM
Would you like me to modernize the Zelda title screen font too?

Hmm, not sure what that means. Maybe in a separate patch. Do you have an example?

The3Dude

Quote from: gzip on September 20, 2020, 12:28:23 AM
Hmm, not sure what that means. Maybe in a separate patch. Do you have an example?

This

to this

~The3Dude~

gzip

Tempting but I think I'll stick with the classic title screen for now. :thumbsup:

The3Dude

~The3Dude~

ShadowOne333

#14
Give me some hours, maybe I can come up with something for the LEVEL text.

September 20, 2020, 12:19:16 PM - (Auto Merged - Double Posts are not allowed before 7 days.)

Okay this is what I found so far.

The PPU transfer for the "LEVEL-0" string is located at 0x19D14 in the ROM, or $19D04 in NES address.
Here's what's in there:
// LEVEL-X text
org $9D04 // $19D14
db $20,$42,$07
db "LEVEL-0"
db $FF


The first 3 bytes specify the PPU address where to start printing it, and then comes the actual letters, then the end command "FF" for PPU transfers. Changing this to say DUNGEON-0 would be like this:
// LEVEL-X text
org $9D04 // $19D14
db $20,$42,$09
db "DUNGEON-0"
db $FF


However, trouble arises when we try to make the room for the 2 additional bytes we require.
The LEVEL text and its PPU transfer don't seem to have any direct pointer that I can track down. I tried debugging it a little bit, and I came to the same routine you guys hit, with no direct reference to $9D04 that I could tell.
The whole routine for this I will post next, however I am unfamiliar with most of the opcodes here, so I'm at a bit of a loss here.

Once the PPU transfer is dealt with, there's still the numeral that gets placed depending on the Dungeon number, which always gets sent to PPU $205C, so we would also need to locate the code that handles that.

1A0A2: 48 PHA
1A0A3: 8D 0620 STA $2006
1A0A6: C8 INY
1A0A7: B1 00 LDA ($00),Y
1A0A9: 8D 0620 STA $2006
1A0AC: C8 INY
1A0AD: B1 00 LDA ($00),Y
1A0AF: 0A ASL
1A0B0: 48 PHA
1A0B1: A5 FF LDA $FF
1A0B3: 09 04 ORA #$04 ; set  bits .... .x..
1A0B5: B0 02 BCS $1A0B9

1A0B7: 29 FB AND #$FB ; keep bits xxxx x.xx

1A0B9: 8D 0020 STA $2000
1A0BC: 85 FF STA $FF
1A0BE: 68 PLA
1A0BF: 0A ASL
1A0C0: 08 PHP
1A0C1: 90 03 BCC $1A0C6

1A0C3: 09 02 ORA #$02 ; set  bits .... ..x.
1A0C5: C8 INY

1A0C6: 28 PLP
1A0C7: 18 CLC
1A0C8: D0 01 BNE $1A0CB

1A0CA: 38 SEC

1A0CB: 6A ROR
1A0CC: 4A LSR
1A0CD: AA TAX

1A0CE: B0 01 BCS $1A0D1

1A0D0: C8 INY

1A0D1: B1 00 LDA ($00),Y
1A0D3: 8D 0720 STA $2007
1A0D6: CA DEX
1A0D7: D0 F5 BNE $1A0CE

1A0D9: 68 PLA
1A0DA: C9 3F CMP #$3F
1A0DC: D0 0C BNE $1A0EA

1A0DE: 8D 0620 STA $2006
1A0E1: 8E 0620 STX $2006
1A0E4: 8E 0620 STX $2006
1A0E7: 8E 0620 STX $2006

1A0EA: 38 SEC
1A0EB: 98 TYA
1A0EC: 65 00 ADC $00
1A0EE: 85 00 STA $00
1A0F0: A9 00 LDA #$00 ; A = 00
1A0F2: 65 01 ADC $01
1A0F4: 85 01 STA $01

1A0F6: AE 0220 LDX $2002
1A0F9: A0 00 LDY #$00 ; Y = 00
1A0FB: B1 00 LDA ($00),Y
1A0FD: 10 A3 BPL $1A0A2

1A0FF: 60 RTS

abw

Quote from: The3Dude on September 19, 2020, 11:39:54 PM
I honestly same as you have no idea on how to move the text offset.
This is the easy part. As with many of the other strings in this game, the format is [2-byte PPU address (big endian)] + [1-byte string length] + [string], so changing its screen position is trivial; if you want to move it 1 tile to the left, simply subtract 1 from the PPU address, i.e. $2042 -> $2041.

The hard part is that the "LEVEL-0" text gets copied from ROM into cartridge RAM (ending up at $681C) on power/reset and is tightly packed in cartridge RAM with a bunch of other data, so instead of just updating some ROM pointer to target somewhere in the giant chunk of nearby free space in ROM, you also need to change the game's RAM usage, which is more annoying.

Changing the position of the dynamic level number, however, is also easy: that's controlled by the STA $6825 at $05:$B02F, so once you've got the RAM usage sorted out, just replace $6825 with the new RAM address of the level number placeholder.

ShadowOne333

The code @abw pointed out for the number is correct.
Changing it to the following:
bank 5;
org $B02F // 0x1703F
    sta $6827   // Originally STA $6825


Makes it so the number is now printed two positions to the right from the original one, so once the "DUNGEON-0" pointer has been figured out, having that for the number printing would move the numeral accordingly for the DUNGEON text.

abw

Ah, sorry, I didn't see your previous edit before posting.

Quote from: ShadowOne333 on September 20, 2020, 10:15:26 AM
The LEVEL text and its PPU transfer don't seem to have any direct pointer that I can track down.
The pointer to the LEVEL text lives at $06:$A00C.

The various sections of RAM loading code populate $67F0-$6C7D, and it looks like $67CE-$6C8F might be unused, in which case you could probably insert your extra 2 bytes in ROM and (find and) update everything that references $681D-$6C7D accordingly. Or add new code to load the LEVEL text into $67CE-$6C8F and update just $06:$A00C and $05:$B02F. The squishy tiles also look okay, if that ends up being easier.

gzip

Quote from: abw on September 20, 2020, 12:45:36 PM
This is the easy part. As with many of the other strings in this game, the format is [2-byte PPU address (big endian)] + [1-byte string length] + [string], so changing its screen position is trivial; if you want to move it 1 tile to the left, simply subtract 1 from the PPU address, i.e. $2042 -> $2041.

I had no idea that strings were formatted like this. Very useful, thanks!

September 20, 2020, 07:19:18 PM - (Auto Merged - Double Posts are not allowed before 7 days.)

Quote from: ShadowOne333 on September 20, 2020, 12:57:23 PM
The code @abw pointed out for the number is correct.
Changing it to the following:
bank 5;
org $B02F // 0x1703F
    sta $6827   // Originally STA $6825


Makes it so the number is now printed two positions to the right from the original one, so once the "DUNGEON-0" pointer has been figured out, having that for the number printing would move the numeral accordingly for the DUNGEON text.

Hmm, I don't get any number printed when I make this change, not sure why. Maybe it's being redrawn after the fact? Maybe the initial string has to be longer?

Here's my latest thinking:

1) Change "LEVEL-0" to "DUNGEON", same number of bytes, sacrifice the dash, no big loss (verified)
2) Move the text to the left one space by changing 2042 to 2041 (verified)
3) Move the number right two positions as outlined above (not working)

That way all the RAM and ROM shuffling is eliminated (depending on 3).

ShadowOne333

The reason why the moved number doesn't show up is because you need a sprite there that the number can replace. Try putting $09 in the PPU Transfer for LEVEL and then make the number change, you'll see the number in red now moved two tiles to the right.