News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Zelda 1 level text  (Read 4212 times)

gzip

  • RHDN Patreon Supporter!
  • Jr. Member
  • *****
  • Posts: 49
    • View Profile
Zelda 1 level text
« 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.


ultimaweapon

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
Re: Zelda 1 level text
« Reply #1 on: September 19, 2020, 10:40:38 pm »
The3Dude changes his from Level to Map, so he would be the person to ask.
Trust in the Heart of the Cards

The3Dude

  • Full Member
  • ***
  • Posts: 224
    • View Profile
Re: Zelda 1 level text
« Reply #2 on: September 19, 2020, 10:57:59 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

  • Hero Member
  • *****
  • Posts: 1540
    • View Profile
Re: Zelda 1 level text
« Reply #3 on: September 19, 2020, 11:00:05 pm »
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

  • RHDN Patreon Supporter!
  • Jr. Member
  • *****
  • Posts: 49
    • View Profile
Re: Zelda 1 level text
« Reply #4 on: September 19, 2020, 11:25:31 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.

Code: [Select]
> 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.
« Last Edit: September 19, 2020, 11:38:27 pm by gzip »

The3Dude

  • Full Member
  • ***
  • Posts: 224
    • View Profile
Re: Zelda 1 level text
« Reply #5 on: September 19, 2020, 11:39:54 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

  • RHDN Patreon Supporter!
  • Jr. Member
  • *****
  • Posts: 49
    • View Profile
Re: Zelda 1 level text
« Reply #6 on: September 19, 2020, 11:44:50 pm »
Good idea! I don't have the graphics space though. :-\

The3Dude

  • Full Member
  • ***
  • Posts: 224
    • View Profile
Re: Zelda 1 level text
« Reply #7 on: September 19, 2020, 11:53:10 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

  • RHDN Patreon Supporter!
  • Jr. Member
  • *****
  • Posts: 49
    • View Profile
Re: Zelda 1 level text
« Reply #8 on: September 20, 2020, 12:15:01 am »
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

  • Full Member
  • ***
  • Posts: 224
    • View Profile
Re: Zelda 1 level text
« Reply #9 on: September 20, 2020, 12:25:07 am »
Would you like me to modernize the Zelda title screen font too?
~The3Dude~

gzip

  • RHDN Patreon Supporter!
  • Jr. Member
  • *****
  • Posts: 49
    • View Profile
Re: Zelda 1 level text
« Reply #10 on: September 20, 2020, 12:28:23 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

  • Full Member
  • ***
  • Posts: 224
    • View Profile
Re: Zelda 1 level text
« Reply #11 on: September 20, 2020, 12:29:47 am »
Hmm, not sure what that means. Maybe in a separate patch. Do you have an example?

This

to this

~The3Dude~

gzip

  • RHDN Patreon Supporter!
  • Jr. Member
  • *****
  • Posts: 49
    • View Profile
Re: Zelda 1 level text
« Reply #12 on: September 20, 2020, 12:33:48 am »
Tempting but I think I'll stick with the classic title screen for now. :thumbsup:

The3Dude

  • Full Member
  • ***
  • Posts: 224
    • View Profile
Re: Zelda 1 level text
« Reply #13 on: September 20, 2020, 01:05:20 am »
Check PM's ;D
~The3Dude~

ShadowOne333

  • Hero Member
  • *****
  • Posts: 1540
    • View Profile
Re: Zelda 1 level text
« Reply #14 on: September 20, 2020, 10:15:26 am »
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:
Code: [Select]
// 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:
Code: [Select]
// 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.

Code: [Select]
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
« Last Edit: September 20, 2020, 12:19:16 pm by ShadowOne333 »

abw

  • Hero Member
  • *****
  • Posts: 556
    • View Profile
Re: Zelda 1 level text
« Reply #15 on: September 20, 2020, 12:45:36 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

  • Hero Member
  • *****
  • Posts: 1540
    • View Profile
Re: Zelda 1 level text
« Reply #16 on: September 20, 2020, 12:57:23 pm »
The code @abw pointed out for the number is correct.
Changing it to the following:
Code: [Select]
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

  • Hero Member
  • *****
  • Posts: 556
    • View Profile
Re: Zelda 1 level text
« Reply #17 on: September 20, 2020, 03:49:27 pm »
Ah, sorry, I didn't see your previous edit before posting.

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

  • RHDN Patreon Supporter!
  • Jr. Member
  • *****
  • Posts: 49
    • View Profile
Re: Zelda 1 level text
« Reply #18 on: September 20, 2020, 07:15:48 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.)
The code @abw pointed out for the number is correct.
Changing it to the following:
Code: [Select]
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

  • Hero Member
  • *****
  • Posts: 1540
    • View Profile
Re: Zelda 1 level text
« Reply #19 on: September 20, 2020, 07:23:48 pm »
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.