News: 11 March 2016 - Forum Rules

Author Topic: Editing text in Shadowrun (SNES)  (Read 9133 times)

the_E_y_Es

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
Re: Editing text in Shadowrun (SNES)
« Reply #20 on: June 25, 2021, 04:04:12 pm »
Looks like the Huffman code was only a jump away from my original breakpoint:



Out of curiosity, what is the purpose of 0x80fe3f: ora #$8000? Why perform that operation with the pointer currently in A? It didn't seem to change anything.

I stepped through the code:



So it writes the decompressed characters at 0x7e21a0, one by one, and adds a final "00" to end the string. I think that was an STZ opcode, IIRC.

There is some free space at the end of the ROM, specifically here:



From FFF3D to FFFFF. It could be enough to hold one line of decompressed dialogue. Not enough for all the changes I want to do, but right now I'm just experimenting.

I try to do as you explained, changing this code...

Code: [Select]
0x80fe57   jsl 81aec0
...into this:

Code: [Select]
0x80fe57   jml 9fff3d
I have another question: I looked at the memory viewer and that final region of ROM (with the unused space) appears several times in different areas of the RAM. Where should I jump to? I picked 0x9fff3d, but there were other addresses with that same free space. Confusing...

Anyway, so I try to write that jml at 0x80fe57. I don't know what a jml looks like in machine code so I use this as a reference:

http://problemkaputt.de/fullsnes.htm

Namely this:

Code: [Select]
Normal Jumps
  Opcode       Flags Clks  Native       Nocash        Effect
  80 dd        ------  3xx BRA disp8    JMP disp      PC=PC+/-disp8
  82 dd dd     ------  4   BRL disp16   JMP disp      PC=PC+/-disp16
  4C nn nn     ------  3   JMP nnnn     JMP nnnn      PC=nnnn
  5C nn nn nn  ------  4   JMP nnnnnn   JMP nnnnnn    PB:PC=nnnnnn
  6C nn nn     ------  5   JMP (nnnn)   JMP [nnnn]    PC=WORD[00:nnnn]
  7C nn nn     ------  6   JMP (nnnn,X) JMP [nnnn+X]  PC=WORD[PB:nnnn+X]
  DC nn nn     ------  6   JML ...      JMP FAR[nnnn] PB:PC=[00:nnnn]
  20 nn nn     ------  6   JSR nnnn     CALL nnnn     [S]=PC+2,PC=nnnn
  22 nn nn nn  ------  4   JSL nnnnnn   CALL nnnnnn   PB:PC=nnnnnn [S]=PB:PC+3
  FC nn nn     ------  6   JSR (nnnn,X) CALL [nnnn+X] PC=WORD[PB:nnnn+X] [S]=PC
  40           nzcidv  6   RTI          RETI          P=[S+1],PB:PC=[S+2],S=S+4
  6B           ------  ?   RTL          RETF          PB:PC=[S+1]+1, S=S+3
  60           ------  6   RTS          RET           PC=[S+1]+1, S=S+2

I write DC 3D FF 9F. But the game interprets that as jmp $ff9f. Or something similar. Confused again.

I'm looking up the other instructions you provided, like
Code: [Select]
rep #$20Trying to learn what they do and how to write them correctly.

Third question: what is the difference between
Code: [Select]
lda $cf and
Code: [Select]
lda [$cf]?

I'm going to try that jml again later.

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 717
  • I am the baldest romhacker
    • View Profile
Re: Editing text in Shadowrun (SNES)
« Reply #21 on: June 26, 2021, 06:51:43 am »
DC is for indirect addressing mode. Use 5C for absolute.

ORA #$8000 could be for setting some sort of flag.

[$??] means indirect addressing mode.

the_E_y_Es

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
Re: Editing text in Shadowrun (SNES)
« Reply #22 on: June 26, 2021, 12:40:24 pm »
DC is for indirect addressing mode. Use 5C for absolute.
That worked. Thanks!

I started placing the new code at the end of the ROM.



I thought I could fit at least one line of uncompressed dialogue there, but it doesn't fit. I have to expand the ROM.



According to the Datacrystal, Shadowrun (SNES) is 8MB and LoROM. I'm not sure about the RAM map, though. I picked the above option, anyway, and it seemed to work fine. Still compatible with bsnes, which is what I need. Awesome.

Now about that uncompressed line, I'm wondering what the code for writing it should look like. Maybe I'll try to replicate some of the original code. IIRC it uses the INC opcode to move forward a relative address, until the text is done. I'll have to check that.

DougRPG

  • Full Member
  • ***
  • Posts: 151
    • View Profile
Re: Editing text in Shadowrun (SNES)
« Reply #23 on: June 27, 2021, 01:04:22 pm »
Quote
I don't know what a jml looks like in machine code so I use this as a reference:

Hi, are you trying to write machine code by hand? You need an assembler like Bass, xkas, wla, etc. I used Bass in this project.

You are in the right direction, but now you need to study the cpu assembly and addressing modes to understand the difference between "lda $cf" and "lda [$cf]".

You can do everything with the assembler, including inserting the new strings.

About the expansion, the game is Lorom with 1MB using the region 80-9f:8000-ffff, so just expand the rom to 2MB (filling with 0) and use the new megabyte at a0-bf:8000:ffff.
I think you can use Lunar Expand to do this expansion, otherwise just create a python script to append a bytearray of zeroes to the rom.

So the next step is to read some articles about assembly and learning how to use the assembler. Regarding the assembler, I always have a original rom and I have a script to copy the original rom to a new file and apply the changes on this new file.

the_E_y_Es

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
Re: Editing text in Shadowrun (SNES)
« Reply #24 on: June 29, 2021, 05:39:47 pm »
Yes, I'm reading mostly this https://ersanio.gitbook.io/assembly-for-the-snes/ and this https://wiki.superfamicom.org/65816-reference. Good stuff.

I downloaded both Bass and Asar. Don't know how to use them, yet. I think I'll watch a tutotial video for that.

About the expansion, the game is Lorom with 1MB using the region 80-9f:8000-ffff, so just expand the rom to 2MB (filling with 0) and use the new megabyte at a0-bf:8000:ffff.
I see. I'm pretty sure I expanded the rom incorrectly the first time. The game still runs on bsnes, but it refuses to read anything beyond the 0x9FFFFF RAM address. So all that extra space is useless. I'll try as you said and expand it to 2MB. In Lunar Expand, would that be the "2 Mbit (256 KB)" option or the "16 Mbit (2MB)" one?

DougRPG

  • Full Member
  • ***
  • Posts: 151
    • View Profile
Re: Editing text in Shadowrun (SNES)
« Reply #25 on: June 29, 2021, 06:42:53 pm »
The size of the original game is 1MB (8Mbit), so you need to expand to 2MB (16Mbit).
About the expansion, I think you don't need to do anything to run in Bsnes+, but in some cases you'll need a custom manifest file to inform the game's memory map.I don't think it's the case for a simple expansion to 2MB.

the_E_y_Es

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
Re: Editing text in Shadowrun (SNES)
« Reply #26 on: June 29, 2021, 06:49:16 pm »
Meanwhile, in the Japanese version:





It's working. :crazy:

Ultimately, I want to be able to edit both versions, the American and the Japanese. I only got it to work first on the (J) ROM because it has a lot of free space by default, no need to expand it.

I want to ask: how do you change the size of a message box? Not the text itself, but the horizontal box that contains it. I want to expand this box to fit my text in it:



I've always wanted to fix that. I got the game to read my own "Wastelands Club" text, but it doesn't print the "Club" word because there's not enough space in there.

Edit: uncensoring the Japanese version:

« Last Edit: June 30, 2021, 06:28:37 pm by the_E_y_Es »

phonymike

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: Editing text in Shadowrun (SNES)
« Reply #27 on: July 01, 2021, 07:14:39 am »
Wow the_E_y_Es you're making some great progress. It's also good to see advice from DougRPG.

Looking back at the progress I made before, I think I was able to intercept the decompression code to get the pointer to the script (the "lines", not the "conversations"). So the game would say where the compressed script is, and I would take that and substitute the uncompressed script. I was having a hard time finding where to inject the code though. I copied the uncompressed lines to wram, but the game didn't draw the text to VRAM, I had the wrong injection point.

The code below would set the carry flag for the 612 "lines" that were uncompressed, while letting "conversations" be decompressed normally.

Code: [Select]
org $80FEA2
JSL tag_uncompressed_text
NOP ;padding for 5 bytes

org $A08xxx ;expanded ROM space
tag_uncompressed_text:
LDA $D980,x ;original code
STA $02 ;original code
SEC ;set carry to indicate uncompressed
RTL

While the code below would detect the carry flag and copy the script byte by byte, or continue on and decompress the script if the carry flag was clear. The code is incomplete but I think it worked pretty good.
Code: [Select]
org $80FE34
JSL filter_text_types
NOP ;padding for 5 byte

org $A08xxx ;expanded ROM space
filter_text_types:
BCC compressed

uncompressed:
CLC
PLA ;pull the JSL off stack, any more and game freezes
~~~~~~
~copy the uncompressed script to WRAM~

compressed:
LDA #$9DFF ;original code
STA $D0 ;original code

continue_to_text_draw:
RTL



But like DougRPG said, the window boxes seem to be hard coded into the game code, so there's no pointer table or easy way to change the sizes of them. It looks like they have to each be changed by hand.

One idea that could help with this, are snes emulators that support LUA (like snes9x-rr). You could write a LUA script that detects the window drawing routine and maybe output the location to a text file. Using scripting like this you could really dig into the game and make things easy for yourself.

the_E_y_Es

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
Re: Editing text in Shadowrun (SNES)
« Reply #28 on: July 01, 2021, 10:32:58 am »
Hey there phonymike. Yes I'm pretty excited now that my goal is near. I'm trying to understand how to use Bass atm. I watched a youtube video on it and man that gave me a headache. :o But hey, whatever it takes!

The LUA scripting sounds like a good idea, I've heard of that but don't really know what it's all about. Got any good resource on that?

EDIT: More progress!



So changing the message box dimensions is not very practical, but it can be done.

Next step: changing the Japanese text so it matches the new, corrected English one. That'll be a challenge!
« Last Edit: July 10, 2021, 12:55:06 pm by the_E_y_Es »

the_E_y_Es

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
Re: Editing text in Shadowrun (SNES)
« Reply #29 on: July 12, 2021, 04:04:46 pm »
Yet more progress! I can edit the Japanese text now. So any changes I make to the English text can be matched by corresponding changes to the Japanese one.



^I thought it would look better simply as "Wastelands", without the "Club". Notice I removed those annoying extra dots from the JP text.



^The new 1,500 price now also appears in the JP text, as it should. I can do as I want now with the shadowrunner prices.  :)

Noctropolitan

  • Jr. Member
  • **
  • Posts: 2
    • View Profile
Re: Editing text in Shadowrun (SNES)
« Reply #30 on: September 14, 2021, 08:09:00 am »
Hi, the_E_y_Es, I've sent you a private message about this topic, in case you are still working on this.

the_E_y_Es

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
Re: Editing text in Shadowrun (SNES)
« Reply #31 on: September 14, 2021, 07:49:02 pm »
Hi, the_E_y_Es, I've sent you a private message about this topic, in case you are still working on this.
Hey there. I don't think I've received your message. You might want to re-send it.

Edit: oh, it's an email. Nevermind, I got it.
« Last Edit: September 14, 2021, 08:03:25 pm by the_E_y_Es »

Noctropolitan

  • Jr. Member
  • **
  • Posts: 2
    • View Profile
Re: Editing text in Shadowrun (SNES)
« Reply #32 on: September 16, 2021, 11:02:02 am »
Hey there. I don't think I've received your message. You might want to re-send it.

Edit: oh, it's an email. Nevermind, I got it.
MMmh, no, it's a direct message here in the forums. Was asking for your help to re-introduce text strings into the game since I made a complete translation into Castillian Spanish and didn't know how to insert the texts back in the game.

the_E_y_Es

  • Jr. Member
  • **
  • Posts: 83
    • View Profile
Re: Editing text in Shadowrun (SNES)
« Reply #33 on: September 16, 2021, 07:53:45 pm »
Funny, my inbox shows no new messages. Instead, I got an email.

I took a quick look at your work in the link you provided. I want to elaborate a bit on what I can and cannot do, so I'll PM you as soon as I have some free time.

EDIT: I sent you a PM but it's not showing in my Sent items. I guess the system is acting up. I'll just paste here what I wrote:

Hey there. I have three ongoing projects right now, and that greatly limits my available free time. On principle, though, I'm not against working on your translation. The main draw for me is that I'd learn some Spanish in the process; my first language is Portuguese, so it's quite similar. Just reading bits of the text you provided me was already a fun ride. So, in short, I'm interested.

Here's what I'm currently able to change: dialogue, character/equipment/item names, and the size of the message boxes. DougRPG was right: the message boxes are very difficult to resize. The ones displayed during combat are particularly hard. This one took me a whole day to find in the code:

https://i.imgur.com/HOfQ6Hm.png

My edit: https://i.imgur.com/R3BWqGJ.png

What I don't know how to change: the introduction text (The year is 2050, etc) and the font (we'll need new characters like the inverted question mark). I'm sure there's other stuff I can't recall at the moment.

I'll need to investigate on how to change these things. As you know, sometimes it requires the help and guidance of others; my own topic being an example of this. And sometimes it takes a while for any help to appear.... you can see what I'm getting at. I can't say how long it will take to finish the project. I've never helped with a translation before, y'know. It's also the first time I've dabbled with SNES hacking. This is all new to me. Real life gets in the way and... did I mention those three other projects? Yeah.

So my idea is: let me experiment with this for a while, see what I can do to place your text into the game, and we'll see how that goes. I didn't check everything you sent me, but I'm assuming the translation itself is 100% complete. That means your share of the work is done. So sit back, wait a while and I'll contact you when I have something. Although I don't really know when that'll be. Sorry I can't offer anything more solid. Gotta be realistic.

In the worst case scenario, you'll end up with an incomplete translation that will require a third party to help finish. Hopefully not, but I'm just saying. So if you're cool with that, I can give it a go.
« Last Edit: September 19, 2021, 08:42:54 am by the_E_y_Es »