Skip to content

Commit

Permalink
[Decompilation] [th02] Score: Skill value calculation
Browse files Browse the repository at this point in the history
This will end up at the end of Mima's translation unit. Might as well
start a separate temporary one then, which will simplify the diff once
we eventually merge it into that future Mima TU which is very likely to
grow from top to bottom.

Part of P0279, funded by Yanga and Blue Bolt.
  • Loading branch information
nmlgc committed Apr 11, 2024
1 parent 4a7d4db commit 40010a6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 57 deletions.
2 changes: 1 addition & 1 deletion Makefile.mak
Expand Up @@ -99,7 +99,7 @@ bin\th02\op.exe: th02\op_01.cpp bin\th02\exit_dos.obj bin\th02\zunerror.obj bin\
$**
|

bin\th02\main.exe: bin\th02\main.obj bin\th02\tile.obj th02\pointnum.cpp th02\item.cpp th02\hud.cpp th02\player_b.cpp bin\th02\zunerror.obj bin\th02\keydelay.obj th02\main02_1.cpp bin\th01\vplanset.obj bin\th02\pi_load.obj bin\th02\vector.obj bin\th02\frmdely1.obj bin\th02\input_rs.obj bin\th02\exit.obj bin\th02\snd_mmdr.obj bin\th02\snd_mode.obj bin\th02\snd_pmdr.obj bin\th02\snd_dlyv.obj bin\th02\snd_load.obj th02\mpn_l_i.cpp bin\th02\initmain.obj bin\th02\pi_put.obj bin\th02\snd_kaja.obj bin\th02\snd_dlym.obj bin\th02\snd_se_r.obj bin\th02\snd_se.obj th02\main_03.cpp th02\hud_ovrl.cpp th02\dialog.cpp
bin\th02\main.exe: bin\th02\main.obj bin\th02\tile.obj th02\pointnum.cpp th02\item.cpp th02\hud.cpp th02\player_b.cpp bin\th02\zunerror.obj bin\th02\keydelay.obj th02\main02_1.cpp bin\th01\vplanset.obj bin\th02\pi_load.obj bin\th02\vector.obj bin\th02\frmdely1.obj bin\th02\input_rs.obj bin\th02\exit.obj bin\th02\snd_mmdr.obj bin\th02\snd_mode.obj bin\th02\snd_pmdr.obj bin\th02\snd_dlyv.obj bin\th02\snd_load.obj th02\mpn_l_i.cpp bin\th02\initmain.obj bin\th02\pi_put.obj bin\th02\snd_kaja.obj bin\th02\snd_dlym.obj bin\th02\snd_se_r.obj bin\th02\snd_se.obj th02\main_03.cpp th02\hud_ovrl.cpp th02\dialog.cpp th02\boss_5.cpp
$(CC) $(CFLAGS) $(LARGE_LFLAGS) -3 -Z -DGAME=2 -nbin\th02\ -eMAIN.EXE @&&|
$**
|
Expand Down
1 change: 1 addition & 0 deletions th02/boss_5.cpp
@@ -0,0 +1 @@
#include "th02/main/boss/b5_.cpp"
24 changes: 24 additions & 0 deletions th02/main/boss/b5_.cpp
@@ -0,0 +1,24 @@
#include "platform.h"
#include "th02/resident.hpp"
#include "th02/core/globals.hpp"
#include "th02/main/playperf.hpp"

void near skill_calculate(void)
{
int skill = (rank * 20);
skill += (10 - (resident->continues_used * 3));

int skill_miss_and_bombs = (50 - (total_miss_count * 3) - total_bombs_used);
if(skill_miss_and_bombs < 0) {
skill_miss_and_bombs = 0;
}
skill += skill_miss_and_bombs;

if(item_skill > 25) {
item_skill = 25;
} else if(item_skill < 0) {
item_skill = 0;
}
skill += item_skill;
resident->skill = skill;
}
62 changes: 6 additions & 56 deletions th02_main.asm
Expand Up @@ -74,7 +74,7 @@ FACE_EXRIKA_FROWN = 156
FACE_COL_0 = 255

main_01 group main_01_TEXT, POINTNUM_TEXT, main_01__TEXT, ITEM_TEXT, HUD_TEXT, main_01___TEXT, PLAYER_B_TEXT, main_01____TEXT
main_03 group main_03_TEXT, DIALOG_TEXT, main_03__TEXT
main_03 group main_03_TEXT, DIALOG_TEXT, BOSS_5_TEXT, main_03__TEXT

; ===========================================================================

Expand Down Expand Up @@ -12416,7 +12416,7 @@ DS_POSTBOSS = 1
@dialog_script_extra_pre_intro_an$qv procdesc near
DIALOG_TEXT ends

main_03__TEXT segment byte public 'CODE' use16
BOSS_5_TEXT segment byte public 'CODE' use16

; =============== S U B R O U T I N E =======================================

Expand Down Expand Up @@ -23650,60 +23650,10 @@ off_19937 dw offset loc_19821
dw offset loc_19844
dw offset loc_19849

; =============== S U B R O U T I N E =======================================

; Attributes: bp-based frame

sub_19949 proc near
push bp
mov bp, sp
push si
mov al, _rank
cbw
imul ax, 14h
mov cx, ax
les bx, _resident
mov ax, es:[bx+mikoconfig_t.continues_used]
imul ax, 3
mov dx, 0Ah
sub dx, ax
add dx, cx
mov cx, dx
mov al, _total_miss_count
mov ah, 0
imul ax, 3
mov dx, 32h ; '2'
sub dx, ax
mov al, _total_bombs_used
mov ah, 0
sub dx, ax
mov si, dx
or si, si
jge short loc_19986
xor si, si

loc_19986:
add cx, si
cmp _item_skill, 25
jle short loc_19997
mov _item_skill, 25
jmp short loc_199A4
; ---------------------------------------------------------------------------

loc_19997:
cmp _item_skill, 0
jge short loc_199A4
mov _item_skill, 0

loc_199A4:
add cx, _item_skill
les bx, _resident
mov es:[bx+mikoconfig_t.skill], cx
pop si
pop bp
retn
sub_19949 endp
@skill_calculate$qv procdesc pascal near
BOSS_5_TEXT ends

main_03__TEXT segment byte public 'CODE' use16

; =============== S U B R O U T I N E =======================================

Expand Down Expand Up @@ -23903,7 +23853,7 @@ loc_19C4A:
mov es:[bx+mikoconfig_t.rem_lives], al
mov al, _bombs
mov es:[bx+mikoconfig_t.rem_bombs], al
call sub_19949
call @skill_calculate$qv
call @GameExecl$qnxc c, offset aMaine_0, ds ; "maine"
pop bp
retn
Expand Down

0 comments on commit 40010a6

Please sign in to comment.