The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
th09's code optimization certainly was better than those of earlier games, but there's still room for improvement. The original code calculates the same address twice. By optimizing this calculation and spilling the result to the stack, we save 13 bytes - enough to load both the track string and the track number into registers.
leaecx,[ecx+edi+0x1a3dc]; we'll need this address twicepushecx; spill to stackpushebxpushecxmovecx,dwordptrds:[esi+0x11b90]; yup, this is a function parametercallth09.00403e00popecx; recover our address to the register expected latermoveax,dwordptrss:[ebp-0x14]cmpbyteptrds:[ebx+eax],0jeshortth09.004274d4leaedx,[ebx-0x9f]; EDX = track numbermoveax,dwordptrss:[ebp-0x0c]; EAX = stringpusheax; insert breakpoint herepush0x302080push0x0d0effnop(*6)
Rewrite Music Room comment render calls
(music_cmt_rewrite)
Description
Because it would have been completely impossible to add music comment breakpoints to the original function with its 8 case statements, one for each comment line. Turns out that all necessary structure offsets can be easily calculated and the switch statement isn't necessary at all. This removes a total of 391 bytes from the function!
Address
Code
Error: String exceeds 1,000 character limit.
shreax,1; frame / 2jbshort+6; Only display a line on even framesdeceax; EAX = line numbercmpeax,7; maximum of 8 linesjbeshort+5jmp+0x1ee; don't print anythingimuledi,eax,0x2a4; prepare offset to somethingmovbyteptrds:[esi+edi+0x19f02],1; set something to 1leaedi,[esi+edi+0x19d04]; EDI = pointer to somethingmovebx,dwordptrds:[esi+0x11b74]; EBX = track numbercmpbyteptrds:[ebx+th09.music_unlock_table],0; Unlocked?jeshort+0x19; Noimuledx,eax,0x42; Yes; prepare line offsetimulecx,ebx,0x292; prepare track offsetaddedx,ecxleaecx,[esi+edx+0x0c9b6]; ECX = original stringnop(*5); insert breakpoint herejmpshort+7movecx,dwordptrds:[eax*4+th09.music_spoiler_table]; ECX = spoiler messagemoveax,edi; EAX = pointer to somethingpushecx; Push stringxorebx,ebx; reset EBXjmp+0x187nop(*0x187)