From b487d6fc2063009df31e80474d2847a7399108e8 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sun, 2 Sep 2018 17:35:34 +0200 Subject: [PATCH] [Reverse-engineering] [th02/th04/th05] Power overflow bonus Funded by zorg. --- th02/power_overflow[data].asm | 44 +++++++++++++ th02_main.asm | 121 +++++----------------------------- th04_main.asm | 113 ++++--------------------------- th05_main.asm | 36 ++++------ 4 files changed, 90 insertions(+), 224 deletions(-) create mode 100644 th02/power_overflow[data].asm diff --git a/th02/power_overflow[data].asm b/th02/power_overflow[data].asm new file mode 100644 index 00000000..59957c24 --- /dev/null +++ b/th02/power_overflow[data].asm @@ -0,0 +1,44 @@ +POWER_OVERFLOW_BONUS label word + dw 1 + dw 1 + dw 2 + dw 3 + dw 4 + dw 5 + dw 6 + dw 7 + dw 8 + dw 9 + dw 10 + dw 20 + dw 30 + dw 40 + dw 50 + dw 60 + dw 70 + dw 80 + dw 90 + dw 100 + dw 150 + dw 200 + dw 250 + dw 300 + dw 350 + dw 400 + dw 450 + dw 500 + dw 550 + dw 600 + dw 650 + dw 700 + dw 750 + dw 800 + dw 850 + dw 900 + dw 950 + dw 1000 + dw 1050 + dw 1100 + dw 1200 + dw 1250 + dw 1280 diff --git a/th02_main.asm b/th02_main.asm index 66ac2c3b..ffc3de53 100644 --- a/th02_main.asm +++ b/th02_main.asm @@ -3655,7 +3655,7 @@ loc_C516: idiv bx add dx, 2 mov word_1E51E, dx - mov word_1E51C, 0Ah + mov power_overflow_level, 10 mov PaletteTone, 64h ; 'd' call far ptr palette_show call sub_FBE9 @@ -6477,20 +6477,20 @@ loc_D949: jnb short loc_D964 inc power call sub_DEAD - mov word_1E51C, 0 + mov power_overflow_level, 0 inc dword_218A4 jmp short loc_D984 ; --------------------------------------------------------------------------- loc_D964: - cmp word_1E51C, 2Ah ; '*' + cmp power_overflow_level, 42 jge short loc_D96F - inc word_1E51C + inc power_overflow_level loc_D96F: - mov bx, word_1E51C + mov bx, power_overflow_level add bx, bx - movsx eax, word ptr [bx+0AC0h] + movsx eax, POWER_OVERFLOW_BONUS[bx] add dword_218A4, eax inc byte_218A8 @@ -6498,9 +6498,9 @@ loc_D984: inc byte_218A8 push si push word_2189C - mov bx, word_1E51C + mov bx, power_overflow_level add bx, bx - push word ptr [bx+0AC0h] + push POWER_OVERFLOW_BONUS[bx] call sub_C7CA jmp loc_DAB6 ; --------------------------------------------------------------------------- @@ -6586,33 +6586,33 @@ loc_DA3F: add al, 10 mov power, al inc dword_218A4 - mov word_1E51C, 0 + mov power_overflow_level, 0 jmp short loc_DA85 ; --------------------------------------------------------------------------- loc_DA5B: - cmp word_1E51C, 26h ; '&' + cmp power_overflow_level, 38 jge short loc_DA69 - add word_1E51C, 5 + add power_overflow_level, 5 jmp short loc_DA6F ; --------------------------------------------------------------------------- loc_DA69: - mov word_1E51C, 2Ah ; '*' + mov power_overflow_level, 42 loc_DA6F: mov power, 80 - mov bx, word_1E51C + mov bx, power_overflow_level add bx, bx - movsx eax, word ptr [bx+0AC0h] + movsx eax, POWER_OVERFLOW_BONUS[bx] add dword_218A4, eax loc_DA85: push si push word_2189C - mov bx, word_1E51C + mov bx, power_overflow_level add bx, bx - push word ptr [bx+0AC0h] + push POWER_OVERFLOW_BONUS[bx] call sub_C7CA call sub_DEAD jmp short loc_DAB6 @@ -34722,7 +34722,7 @@ byte_1E518 db 4 byte_1E519 db 40h byte_1E51A db 4Ch byte_1E51B db 48h -word_1E51C dw 0 +power_overflow_level dw 0 word_1E51E dw 0 db 0 db 1 @@ -34740,92 +34740,7 @@ word_1E51E dw 0 db 47h ; G db 57h ; W db 0 - db 1 - db 0 - db 1 - db 0 - db 2 - db 0 - db 3 - db 0 - db 4 - db 0 - db 5 - db 0 - db 6 - db 0 - db 7 - db 0 - db 8 - db 0 - db 9 - db 0 - db 0Ah - db 0 - db 14h - db 0 - db 1Eh - db 0 - db 28h ; ( - db 0 - db 32h ; 2 - db 0 - db 3Ch ; < - db 0 - db 46h ; F - db 0 - db 50h ; P - db 0 - db 5Ah ; Z - db 0 - db 64h ; d - db 0 - db 96h - db 0 - db 0C8h - db 0 - db 0FAh - db 0 - db 2Ch ; , - db 1 - db 5Eh ; ^ - db 1 - db 90h - db 1 - db 0C2h - db 1 - db 0F4h - db 1 - db 26h ; & - db 2 - db 58h ; X - db 2 - db 8Ah - db 2 - db 0BCh - db 2 - db 0EEh - db 2 - db 20h - db 3 - db 52h ; R - db 3 - db 84h - db 3 - db 0B6h - db 3 - db 0E8h - db 3 - db 1Ah - db 4 - db 4Ch ; L - db 4 - db 0B0h ; ° - db 4 - db 0E2h - db 4 - db 0 - db 5 +include th02/power_overflow[data].asm word_1E586 dw 0 word_1E588 dw 0BCB0h word_1E58A dw 0D4C8h diff --git a/th04_main.asm b/th04_main.asm index 10abea88..9259993c 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -12916,7 +12916,7 @@ var_1 = byte ptr -1 jnz loc_10A25 mov word_25996, 0 mov word_25998, 0 - mov word_236D6, 0 + mov power_overflow_level, 0 mov word_259BA, 0 call sub_1DACE mov al, power @@ -38217,16 +38217,16 @@ loc_1DBF5: ; --------------------------------------------------------------------------- loc_1DC04: - inc word_236D6 - cmp word_236D6, 2Ah ; '*' + inc power_overflow_level + cmp power_overflow_level, 42 jb short loc_1DC19 - mov word_236D6, 2Ah ; '*' + mov power_overflow_level, 42 mov [bp+var_1], 1 loc_1DC19: - mov bx, word_236D6 + mov bx, power_overflow_level add bx, bx - mov si, [bx+2330h] + mov si, POWER_OVERFLOW_BONUS[bx] cmp byte_21CC8, 0 jz loc_1DD93 inc byte_23660 @@ -38320,16 +38320,16 @@ loc_1DCFE: ; --------------------------------------------------------------------------- loc_1DD09: - add word_236D6, 5 - mov bx, word_236D6 + add power_overflow_level, 5 + mov bx, power_overflow_level add bx, bx - mov si, [bx+2330h] - cmp word_236D6, 2Ah ; '*' + mov si, POWER_OVERFLOW_BONUS[bx] + cmp power_overflow_level, 42 jbe short loc_1DD25 - mov word_236D6, 2Ah ; '*' + mov power_overflow_level, 42 loc_1DD25: - cmp word_236D6, 2Ah ; '*' + cmp power_overflow_level, 42 jnz short loc_1DD93 mov si, 0A00h mov [bp+var_1], 1 @@ -46131,92 +46131,7 @@ byte_23661 db 0 db 0 db 32h ; 2 db 0 - db 1 - db 0 - db 1 - db 0 - db 2 - db 0 - db 3 - db 0 - db 4 - db 0 - db 5 - db 0 - db 6 - db 0 - db 7 - db 0 - db 8 - db 0 - db 9 - db 0 - db 0Ah - db 0 - db 14h - db 0 ; jumptable 0001C46F cases 32823,35584 - db 1Eh - db 0 - db 28h ; ( - db 0 - db 32h ; 2 - db 0 - db 3Ch ; < - db 0 - db 46h ; F - db 0 - db 50h ; P - db 0 - db 5Ah ; Z - db 0 - db 64h ; d - db 0 - db 96h - db 0 - db 0C8h - db 0 - db 0FAh - db 0 - db 2Ch ; , - db 1 - db 5Eh ; ^ - db 1 - db 90h - db 1 - db 0C2h - db 1 - db 0F4h - db 1 - db 26h ; & - db 2 - db 58h ; X - db 2 - db 8Ah - db 2 - db 0BCh - db 2 - db 0EEh - db 2 - db 20h - db 3 - db 52h ; R - db 3 - db 84h - db 3 - db 0B6h - db 3 - db 0E8h - db 3 - db 1Ah - db 4 - db 4Ch ; L - db 4 - db 0B0h ; ° - db 4 - db 0E2h - db 4 - db 0 - db 5 +include th02/power_overflow[data].asm db 0 db 0 db 64h ; d @@ -46233,7 +46148,7 @@ byte_23661 db 0 db 3 db 0 db 5 -word_236D6 dw 0 +power_overflow_level dw 0 word_236D8 dw 0 word_236DA dw 0 word_236DC dw 0 diff --git a/th05_main.asm b/th05_main.asm index b92cd8eb..33e0b9f6 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -15382,7 +15382,7 @@ var_1 = byte ptr -1 jnz short loc_12092 mov word_2CEA8, 0 mov word_2CEAA, 0 - mov word_22642, 0 + mov power_overflow_level, 0 mov word_2CEC4, 0 call sub_16E29 mov al, power @@ -25527,10 +25527,10 @@ loc_16F9B: ; --------------------------------------------------------------------------- loc_16FAA: - inc word_22642 - cmp word_22642, 2Ah ; '*' + inc power_overflow_level + cmp power_overflow_level, 42 jb short loc_16FD1 - mov word_22642, 2Ah ; '*' + mov power_overflow_level, 42 mov [bp+var_3], 1 cmp byte_2264E, 0 jnz short loc_16FD1 @@ -25539,9 +25539,9 @@ loc_16FAA: inc byte_2CEC3 loc_16FD1: - mov bx, word_22642 + mov bx, power_overflow_level add bx, bx - mov si, [bx+1BFCh] + mov si, POWER_OVERFLOW_BONUS[bx] call sub_1059D jmp loc_17174 ; --------------------------------------------------------------------------- @@ -25660,16 +25660,16 @@ loc_170E7: ; --------------------------------------------------------------------------- loc_170F2: - add word_22642, 5 - mov bx, word_22642 + add power_overflow_level, 5 + mov bx, power_overflow_level add bx, bx - mov si, [bx+1BFCh] - cmp word_22642, 2Ah ; '*' + mov si, POWER_OVERFLOW_BONUS[bx] + cmp power_overflow_level, 42 jbe short loc_1710E - mov word_22642, 2Ah ; '*' + mov power_overflow_level, 42 loc_1710E: - cmp word_22642, 2Ah ; '*' + cmp power_overflow_level, 42 jnz short loc_17174 mov si, 0A00h mov [bp+var_3], 1 @@ -44434,15 +44434,7 @@ byte_225CC db 0 db 2Ah ; * db 0 - -;int powerOverflowBonus[] - dw 1,1,2,3,4,5,6,7,8,9 - dw 10,20,30,40,50,60,70,80,90,100 - dw 150,200,250,300,350,400,450,500,550,600 - dw 650,700,750,800,850,900,950,1000,1050,1100 - dw 1200,1250,1280 - - +include th02/power_overflow[data].asm db 0 db 0 db 64h ; d @@ -44459,7 +44451,7 @@ byte_225CC db 0 db 3 db 0 db 5 -word_22642 dw 0 +power_overflow_level dw 0 word_22644 dw 0 word_22646 dw 0 word_22648 dw 0