Game url:
https://web.archive.org/web/20010810204349/http://www4.osk.3web.ne.jp/~sorl/ba2game.htm

pixel mentioned this game when he was talking about some of his piyopiyo music long ago on his old website, which i learnt of through a cstsf thread that linked to the archive. i later brought this up in the dev room pixel discord server where a blog post from room_909 was shared which said it was made by ba2. i found ba2's full name ba2deck from the shine shine galaxy credits and searched for it online, and found a shmup forums thread about shine shine galaxy that linked to ba2's website. couldn't find this game there but ba2's site linked to some of his friends' sites which i followed out of curiosity, and one of them had it uploaded (which was serendipitously archived).

text for the in-game decisions is stored in the executable, not in data.txt. Must be changed in there. Look at text from a playthrough (or play it yourself), convert to shift-jis, search for those bytes in the executable using HxD. I will have to be really careful not to use any more space than is available for fear of screwing other things up.
note: ollydbg interprets this part (text strings) as assembly instructions so it looks like gibberish if you go there and look.
Font specified at 0x310DC. The decision text strings are close beneath it.

data.txt commands:

tx# : block of text, # is any symbol
wv# : play sound effect, # is a number 0-7
qa : screen shake
/: newline
!: end of tx event
*: wait for input
+: space (there were no whitespace spaces in the jp script)

404FF0: part of the bitmap rendering code

each tx# event is hardcoded in the executable (what graphic to show, idk what else). each of these events calls the script processing code which specifically looks for the relevant tx# block in the script.

i was able to find the script processing code by searching for a command of the sort 'cmp eax, 74' where some register holds the character being parsed and is comparing it to the desired ascii value (here representing the letter 't', which events start with). this was inspired by the well-documented assembly code of cave story's tsc script parsing.

405B70 script processing code starts?
[4373DC] position of parser in the script?
EBP+C is the offset in the script for a block of code/event? no, more likely the address where the whole script is stored in the code.
EBP+30 is the symbol that comes after the 'tx' that starts a dialogue?
code block at 405B88 looks for a tx event. 
if [4372E8] is 1, a tx# command has been found.
405BA7 tests if the character in the parser is ascii (while it's searching for the 'tx' string).
the dialogue rendering is probably handled by the block at 405C2C.

405CDF tests characters within tx blocks if they are ascii (jp script uses ascii characters exclusively as commands). this has been changed to look for a '<' as a prefix for commands.


Okay.
change 405CD9 to look for '<'. if found, increment parser and look for the next character command as usual. 
if a command is not found, jmp to 405CE7.
if a command is found, jmp to 405D9F.

405CE7 handles the regular text rendering, it increments the parser by 2 bytes. changing that to 1 (and also changing 'stringsize' to 1 in a called function) fixes the text rendering problem, and ascii characters can be used just fine for dialogue now.

how it looks like right now:
00405CCD  |> 8B4D 0C        MOV ECX,DWORD PTR SS:[EBP+C]
00405CD0  |. 030D DC734300  ADD ECX,DWORD PTR DS:[4373DC]
00405CD6  |. 0FBE11         MOVSX EDX,BYTE PTR DS:[ECX]
00405CD9  |. 81E2 80000000  AND EDX,80
00405CDF     85D2           TEST EDX,EDX
00405CE1     0F84 B8000000  JE gekiai_-.00405D9F
~~~
00405CE7  |. 8B45 20        MOV EAX,DWORD PTR SS:[EBP+20]



how to increment parser (using edx to help)
00405BCD  |. 8B15 DC734300  |MOV EDX,DWORD PTR DS:[4373DC]
00405BD3  |. 83C2 01        |ADD EDX,1
00405BD6  |. 8915 DC734300  |MOV DWORD PTR DS:[4373DC],EDX

how to look at the current character
00405BDC  |. 8B45 0C        |MOV EAX,DWORD PTR SS:[EBP+C]
00405BDF  |. 0305 DC734300  |ADD EAX,DWORD PTR DS:[4373DC]
00405BE5  |. 0FBE08         |MOVSX ECX,BYTE PTR DS:[EAX]

compare to a known character, jump if not equal, continue on if equal
00405BE8  |. 83F9 78        |CMP ECX,78
00405BEB  |. 75 2D          |JNZ SHORT gekiai_-.00405C1A



jump table used in parsing code used at 00405DCC:

004060AD   . D35D4000       DD gekiai_-.00405DD3 
004060B1   . BD5E4000       DD gekiai_-.00405EBD
004060B5   . 125F4000       DD gekiai_-.00405F12
004060B9   . 375E4000       DD gekiai_-.00405E37
004060BD   . 5D604000       DD gekiai_-.0040605D
004060C1   . 335F4000       DD gekiai_-.00405F33
004060C5   . 8B604000       DD gekiai_-.0040608B

004060C9   . 00             DB 00                                    ;  Index table to switch 004060AD

in the command checking code, a character table is used:
! 00
* 01
+ 02
/ 03
q 04
w 05
everything else 06
this is the id then used in the jump table

any ascii character other than these (id 06) will just increment the parser and end the code. (the code calls 40dac0 as it ends, this seems to be a debugging helper?)


The code for + just adds 0A to [4373E0] (before incrementing the parser and going to the end of the script processing block). Is that the horizontal position of the text? But the space added is 12 pixels. Maybe the distance is in points, at 10pt foint size.

[4373E4] is the vertical position of text on screen, and [4373E0] is horizontal.

/: If [4373E4] != 3C, then increment it by 14 (=one new line), set [4373E0] to 0 (=carriage return), and you're done. 
If it is 3C (i.e. you're on the third and last line of the message box), then... ???
[4372EC] and possibly [434C66] i'm guessing has something to do with clearing the message box.

"set [4372EC] to 1, check if half of [434C66] is 0, end code if it is, otherwise call fx401181 with argument [EBP+8]" is a block used in !, *, and /. In / it is used only if we're on the third line. Probably clearing the message box.
yes, fx401181 definitely clears the message box.
[4372EC] is 0 when the text is rolling but turns 1 when paused on a line (*). [434CF0] seems to just be a copy of this.
[434C66] something to do with pressing spacebar?
This is the only thing that still doesn't work.

oh figured it out. it wasn't working because once it moves to the * and doesn't see keyboard input it ends the parser code and moves on. then when the parser reloads it sees we're still stuck on the *, which it doesn't recognise as anything special. so i made the code for * jump to 406160, where i decremented the parser by 1 so it goes back to <, so it still recognises it as a command.
will modify ! code the same way. and / too.
okay so now it works but then the * still appears each time after the message box is cleared, so i had to increment the parser additionally to take care of that.

q: increments parser, checks for 'a', if found it calls a screen shake (QuAke) function. i should probably change it from 'qa' to '<qa' to simply '<q' because these two-letter commands are causingi problems with the angle bracket notation. (done)
note that if 'a' is not found, the code ends without incrementing the parser because maybe the next letter, while not 'a', is something that needs to be rendered. fix this jmp if singlifying the quake command. (done)
[436C70] denotes frame# for quake animation.
[4373C8,CC,D0,D4] are probably offsets/displacements for drawing the image to the screen, like an origin.

w looks for v, then a number, then calls fx401069. (changed to require < prefix but otherwise unchanged.)


using tx0 as an example:
406D83: # of tx# event the function is looking for (each event is coded separately in the executable)
406D85, 406D8A, 406D8F: text colour (BGR)
406D9B: text size/zoom
406DC2: The <! code sets EAX to 1. This address checks for that and executes the event-ending code if it is.

There's text in the executable that says the font is MS Gothic, but it doesn't look like it. Anyways, the default letter spacing is terrible, so I added a manual spacing table for the letters. the code for this is at 4061C4.





i dont remember what this is or why i copied it:
00405C43  |. 6A 04          PUSH 4
00405C45  |. 68 903A4300    PUSH gekiai_-.00433A90
00405C4A  |. 68 3C3A4300    PUSH gekiai_-.00433A3C
00405C4F  |. 6A 07          PUSH 7
00405C51  |. 6A 20          PUSH 20
00405C53  |. 6A 20          PUSH 20
00405C55  |. 68 3C3A4300    PUSH gekiai_-.00433A3C
00405C5A  |. 8B4D 08        MOV ECX,DWORD PTR SS:[EBP+8]
00405C5D  |. 51             PUSH ECX
00405C5E  |. E8 00B5FFFF    CALL gekiai_-.00401163

fonts used in system2.bmp:
Monotype Corsiva, Goudy Old Style, Modern No. 20, Bookman Antique
18pt, bold, italic
The original used more calligraphic styles, but it says 1954, so I went with fonts that kinda evoke that era in an English context.

why am i even writing all of this down? am i going to need it later? is anyone even going to read it? i don't think so. it's mostly to feel good about myself, that i'm doing a thorough job. i guess. i dunno.