gemot encubed  

Go Back   gemot encubed > Gemot > Production & Help

Production & Help For discussions regarding production aspects, especially localisation, of visual novels and related games.

Reply
 
Thread Tools Display Modes
  #1  
Old 2012-02-15, 12:58
velocity7
Guest
 
Posts: n/a
Default White Album 2 Bytecode

Hello,

I'm looking into how to parse the bytecode for White Album 2's scripts... the script.pak extracts into *.txt and *.bnr files, where the *.bnr looks like the bytecode and *.txt looks like SJIS text that's used for the *.bnr files. The *.bnr files start with LSCR as the first four bytes before the rest of its data. Help would be appreciated!
Reply With Quote
  #2  
Old 2012-02-17, 11:45
erengy
Guest
 
Posts: n/a
Default

I'm not sure if these are correct, but a quick look at 1001.bnr reveals that:
  • Instructions are separated by 0x06 0x1E
  • 0x03 probably pushes an integer to the stack
  • Printing a string from relevant .txt file is related with opcodes of 0x83 and 0x84
  • 0x90 changes speaker tag
Reply With Quote
  #3  
Old 2012-02-17, 19:03
jonathanasdf
Guest
 
Posts: n/a
Default thanks

That's gonna be a really useful starting point for us! thanks
Reply With Quote
  #4  
Old 2012-02-17, 19:47
jonathanasdf
Guest
 
Posts: n/a
Default

(Sorry for double posting, can't edit post because I'm not registered)

You say 03 pushes an integer, but I hardly ever see 03 used by itself, it's always 05 03. Does that mean 05 03 is push?

By random trying we found that changing the 08 in address 3F4 in 1001.bnr changes the bgm played from BGM_008_A.ogg (or maybe it's B, the 2 files are identical) to whatever number we put. Thus going from this logic that 06 1E separates opcodes then the instruction starts from 3EC and is

05 03 08 05 03 [FF FF FF FE] 05 03 01 05 03 FF 04 9E

=>

push 8
push -2
push 1
push 255
and then 04 9E. Maybe 9E is the operation for playing the bgm, but either way those 2 operations need to reduce the stack by 4 somehow...
Reply With Quote
  #5  
Old 2012-02-17, 20:15
jonathanasdf
Guest
 
Posts: n/a
Default

Actually 05 03 is probably not one entity because I've seen 03 without 05 in front. 05 and 04 probably mean something.

I was thinking that if 9E calls the function "playSound" or something like that, then maybe it takes parameters like a boolean for repeat (the 1) or the type (whether it's bgm or sfx or voice, so this might be the -2) or something like that.
Reply With Quote
  #6  
Old 2012-02-17, 20:27
jonathanasdf
Guest
 
Posts: n/a
Default

yay, that 1 really did control repeat. setting it to 0 made it stop repeating. I'm think that 04 might indicate that the next thing is a function. Still not quite sure what 05 does.
Reply With Quote
  #7  
Old 2012-02-17, 20:52
jonathanasdf
Guest
 
Posts: n/a
Default

The instruction starting at 360

05 03 00 04 90

does change speaker tag:

00 = Haruki
01 = Kazusa
02 = Yukina
03+ seems to be nothing

However, the instruction at 3C8

05 03 01 06 17 04 90

doesn't seem to be for changing the speaker tag, so it seems 90 is not just for changing speaker tag?

for translation into english ideally we want to figure out how to have it take the speaker tag from the .txt file, so we don't need to modify the executable to change the hardcoded speaker tags.
Reply With Quote
  #8  
Old 2012-02-17, 21:00
jonathanasdf jonathanasdf is offline
Member
 
Join Date: Feb 2012
Posts: 12
Send a message via MSN to jonathanasdf
Default

ok I registered to make this easier.

Found out what the 4th argument to the playbgm function does (it doesn't seem to be a general playsound function). It controls the volume, and lies in the range 0-255.

so for the instruction that starts on 3EC, it is

playbgm(8, -2, 1, 255) = playbgm(track, dunno, repeat, volume).
Reply With Quote
  #9  
Old 2012-02-18, 10:11
erengy
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by jonathanasdf View Post
However, the instruction at 3C8

05 03 01 06 17 04 90

doesn't seem to be for changing the speaker tag, so it seems 90 is not just for changing speaker tag?
That example you gave above clears the tag, so its purpose is still valid.


Quote:
Originally Posted by jonathanasdf View Post
for translation into english ideally we want to figure out how to have it take the speaker tag from the .txt file, so we don't need to modify the executable to change the hardcoded speaker tags.
63rd instruction in 1001.bnr reads the tag from 1001.txt:
Code:
00000003 0000000f 00000004 00000090 00000006 0000001e
0x0F is the 15th value in 1001.txt (which is, "???") so it's possible to translate hard-coded character names by adding new values to .txt files and modifying related instructions. Not too easy, but probably easier than modifying the executable.


By the way, in case you need it, here's my interpretation of .fnc files:

LFScriptFunc.fnc:
Spoiler


LFScriptFuncEx.fnc:
Spoiler
Reply With Quote
  #10  
Old 2012-02-18, 14:49
jonathanasdf jonathanasdf is offline
Member
 
Join Date: Feb 2012
Posts: 12
Send a message via MSN to jonathanasdf
Default

Thanks again!

--------------------

So I have a theory.

05 03 xx means push the CONSTANT xx onto the stack

03 xx means push the xx'th value from the corresponding txt file onto the stack

going to test it out now :D

...and.. VERIFIED. This is going to be a big help.

Last edited by jonathanasdf; 2012-02-18 at 16:05.
Reply With Quote
  #11  
Old 2012-02-19, 09:18
erengy
Guest
 
Posts: n/a
Default

Looks like 0x06 performs mathematical and logical operations on preceding arguments. Here's a list I extracted from the executable:

Spoiler