News: 11 March 2016 - Forum Rules

Author Topic: Expanding Fixed Length Text?  (Read 3473 times)

Almagest

  • Sr. Member
  • ****
  • Posts: 302
  • ファーストエイド
    • View Profile
    • Almagest's ROM Hacking Blog
Expanding Fixed Length Text?
« on: February 26, 2014, 12:32:03 pm »
Hi guys, I have some doubts about expanding fixed length text. I read Anusp's tutorial, but it doesn't say much about this. I also did some searches in the forum, but I couldn't find any similar thread. I've already learned how to hack absolute pointers (for variable length texts), it was easy; but fixed length is different. How do I expand this type of text? Do I have to move it to another bank inside the rom? Does it require assembly? I'd like to expand texts that are 7 characters long to 9.

Edit: More details. The rom I'm using is the NA version of FF6 (SNES), v1.1. I'm trying to expand the spell names, which are limited to 7 characters (the first one being the spell icon). There are other fixed length texts I want to expand too, like the item names or the esper attacks. Angelo did this already, but his patch is for version 1.0, so it won't work with my GBA Script hack (I tried to apply it, but the game crashed in a random battle).
« Last Edit: February 26, 2014, 04:30:43 pm by Thisguyaresick2 »

Bregalad

  • Hero Member
  • *****
  • Posts: 2763
    • View Profile
Re: Expanding Fixed Length Text?
« Reply #1 on: February 26, 2014, 02:54:13 pm »
Quote
Do I have to move it to another bank inside the rom? Does it require assembly?
Yes and yes. At least you'll have to hack the thing so that the fixed length is different (it's a very simple hack don't worry). Now the problem is that if there isn't free space in your bank you're going to run out of space.

FAST6191

  • Hero Member
  • *****
  • Posts: 3237
    • View Profile
Re: Expanding Fixed Length Text?
« Reply #2 on: February 26, 2014, 03:02:04 pm »
We could go in depth and discuss the various techniques seen and theoretical but for the time being I am here to mention the pseudo variable width font/MTE technique. If you only have a few things (it is annoying to do it for an in game encyclopaedia, 6 lines of menu text less so) and enough of a font to edit some things then you could try combining a few letters so two or more tiles make up more letters.

If you are already up at 7 characters then even better as you have some room to play with, doing this on a 3 character fixed width affair is no fun at all.

If you do not have room in the font/memory then yeah you are back to assembly, hopefully if it is just a simple bit of pointer maths like add 7 to the previous pointer you can change to read add 9 instead.

Almagest

  • Sr. Member
  • ****
  • Posts: 302
  • ファーストエイド
    • View Profile
    • Almagest's ROM Hacking Blog
Re: Expanding Fixed Length Text?
« Reply #3 on: February 26, 2014, 04:49:53 pm »
We could go in depth and discuss the various techniques seen and theoretical but for the time being I am here to mention the pseudo variable width font/MTE technique. If you only have a few things (it is annoying to do it for an in game encyclopaedia, 6 lines of menu text less so) and enough of a font to edit some things then you could try combining a few letters so two or more tiles make up more letters.
I already knew that trick.

Quote
If you are already up at 7 characters then even better as you have some room to play with, doing this on a 3 character fixed width affair is no fun at all.

If you do not have room in the font/memory then yeah you are back to assembly, hopefully if it is just a simple bit of pointer maths like add 7 to the previous pointer you can change to read add 9 instead.
Then I give up. I know nothing of assembly. I don't even know which tool I should use (DisAsm, xkas, asar, spcas, spcdas...).

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 7183
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: Expanding Fixed Length Text?
« Reply #4 on: February 26, 2014, 07:31:16 pm »
The simplest way to do pointer math is like

Code: [Select]
asl StringIndex   ;string *= 2
lda StringIndex
asl a        ;a = String * 4
clc
adc StringIndex  ; Now a = (String * 4) + (String * 2) = (String*6)

Could probably find the routine easily with SNES9X Tracer, just trace while opening the menu then looking for the SNES address of the text in the trace file.
It's probably going to read the address of the start of the text block, then do math to get the address of the string.
"My watch says 30 chickens" Google, 2018

Lenophis

  • Discord Staff
  • Hero Member
  • *****
  • Posts: 971
  • The return of the sombrero!
    • View Profile
    • Slick Productions
Re: Expanding Fixed Length Text?
« Reply #5 on: February 27, 2014, 02:41:18 am »
Oh, if I had a nickel for every time I've had to grab these routines...
Code: [Select]
Display spell name

C1/6019: EB      XBA (from only C1/5FBF)
C1/601A: A907    LDA #$07 (7 = spell name length)
C1/601C: 8510    STA $10
C1/601E: 8D6D61  STA $616D
C1/6021: 20CA18  JSR $18CA (half multiplier)
C1/6024: C220    REP #$20
C1/6026: AF164200 LDA $004216
C1/602A: AA      TAX
C1/602B: 7B      TDC
C1/602C: E220    SEP #$20
C1/602E: CE6D61  DEC $616D
C1/6031: BF68F5E6 LDA $E6F568,X (Load Spell name X)
C1/6035: C9FF    CMP #$FF
C1/6037: F009    BEQ $6042
C1/6039: 201161  JSR $6111
C1/603C: E8      INX
C1/603D: CE6D61  DEC $616D
C1/6040: D0EF    BNE $6031
C1/6042: 60      RTS
 
C1/6043: 20EC66  JSR $66EC (from C1/5E51, X = E)
C1/6046: A748    LDA [$48]
C1/6048: C9FF    CMP #$FF
C1/604A: D005    BNE $6051
C1/604C: A90D    LDA #$0D
C1/604E: 4CA85F  JMP $5FA8
Code: [Select]
C1/65E8: A907    LDA #$07 (from C1/65AA)(7 = spell name length)
C1/65EA: 852E    STA $2E
C1/65EC: 8540    STA $40
C1/65EE: 20B018  JSR $18B0
C1/65F1: A630    LDX $30
C1/65F3: BF67F5E6 LDA $E6F567,X (Load Spell name X)
C1/65F7: 20FE63  JSR $63FE
C1/65FA: E8      INX
C1/65FB: C640    DEC $40
C1/65FD: D0F4    BNE $65F3
C1/65FF: 60      RTS
Code: [Select]
C1/6B1C: EB      XBA (from C1/6AD2)
C1/6B1D: A907    LDA #$07
C1/6B1F: 8510    STA $10
C1/6B21: 20CA18  JSR $18CA (half multiplier)
C1/6B24: C220    REP #$20
C1/6B26: AF164200 LDA $004216 (load product)
C1/6B2A: AA      TAX
C1/6B2B: 7B      TDC
C1/6B2C: E220    SEP #$20
C1/6B2E: BF67F5E6 LDA $E6F567,X (Load spell name X)
C1/6B32: 20F366  JSR $66F3
C1/6B35: E8      INX
C1/6B36: C610    DEC $10
C1/6B38: D0F4    BNE $6B2E
C1/6B3A: 60      RTS

That's just for battle. This next one is for the menu.
Code: [Select]
C3/4FB5: A00700  LDY #$0007    (spell letter length)
C3/4FB8: 84EB    STY $EB
C3/4FBA: A067F5  LDY #$F567    (spell name address)
C3/4FBD: 84EF    STY $EF
C3/4FBF: A9E6    LDA #$E6      (spell name bank)
C3/4FC1: 85F1    STA $F1
C3/4FC3: 60      RTS
 
Draw a column of spells
C3/4FC4: A5E6    LDA $E6
C3/4FC6: 1A      INC A
C3/4FC7: 209F80  JSR $809F
C3/4FCA: C220    REP #$20      (16 bit memory/accum.)
C3/4FCC: 8A      TXA
C3/4FCD: 8F899E7E STA $7E9E89
C3/4FD1: E220    SEP #$20      (8 bit memory/accum.)
C3/4FD3: A59E    LDA $9E
C3/4FD5: F067    BEQ $503E
C3/4FD7: 20EC50  JSR $50EC      (get the current spell to check)
C3/4FDA: 204D51  JSR $514D      (determine if spells are useable?)
C3/4FDD: 20EC50  JSR $50EC      (get the current spell to check)
C3/4FE0: C9FF    CMP #$FF
C3/4FE2: F036    BEQ $501A      (branch if no spell to draw)
C3/4FE4: 20A250  JSR $50A2      (get spells learned amount)
C3/4FE7: C9FF    CMP #$FF
C3/4FE9: D02F    BNE $501A      (branch if spell is already learned?)
C3/4FEB: 20EC50  JSR $50EC      (get the current spell to check)
C3/4FEE: 206784  JSR $8467      (draw the current spell name)
C3/4FF1: A2929E  LDX #$9E92     (position of MP cost)
C3/4FF4: 8E8121  STX $2181
C3/4FF7: A9FF    LDA #$FF
C3/4FF9: 8D8021  STA $2180      (insert a space)
C3/4FFC: 20EC50  JSR $50EC      (get the current spell to check)
C3/4FFF: 200D51  JSR $510D      (get spell's MP cost)
C3/5002: 20E004  JSR $04E0      (turn MP cost into digits)
C3/5005: A5F8    LDA $F8
C3/5007: 8D8021  STA $2180      (draw tens digit of MP cost)
C3/500A: A5F9    LDA $F9
C3/500C: 8D8021  STA $2180      (draw ones digit of MP cost)
C3/500F: A9FF    LDA #$FF
C3/5011: 8D8021  STA $2180      (insert a space)
C3/5014: 9C8021  STZ $2180      (end this string)
C3/5017: 4CD97F  JMP $7FD9      (draw MP cost)

Blank out the current spell (MP cost and spell learn rate too)
C3/501A: 7B      TDC
C3/501B: A5E5    LDA $E5
C3/501D: AA      TAX
C3/501E: A9FF    LDA #$FF
C3/5020: 9F899D7E STA $7E9D89,X
C3/5024: 20B951  JSR $51B9      (set's the text color to gray among other things)
C3/5027: A00B00  LDY #$000B
C3/502A: A28B9E  LDX #$9E8B     (position of where it is to be blanked)
C3/502D: 8E8121  STX $2181
C3/5030: A9FF    LDA #$FF
C3/5032: 8D8021  STA $2180      (insert a space)
C3/5035: 88      DEY
C3/5036: D0FA    BNE $5032      (do 11 times?)
C3/5038: 9C8021  STZ $2180      (end this string)
C3/503B: 4CD97F  JMP $7FD9      (display the blanked name)


https://ff6randomizer.codeplex.com/ - Randomize your FF6 experience!