Skip to content

Commit

Permalink
[Decompilation] [th01] .BOS: Unused and broken plane pointer reset fu…
Browse files Browse the repository at this point in the history
…nction

Because that's not how you free dynamically allocated memory?

Part of P0106, funded by Yanga.
  • Loading branch information
nmlgc committed Aug 12, 2020
1 parent 1a595cf commit 5f5eb8a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 73 deletions.
2 changes: 1 addition & 1 deletion Makefile.mak
Expand Up @@ -59,7 +59,7 @@ bin\th01\op.exe: bin\piloadc.obj bin\th01\op.obj th01\op_01.cpp th01\op_02.c th0
$**
|

bin\th01\reiiden.exe: bin\piloadc.obj bin\th01\reiiden.obj th01\main_01.cpp th01\main_01_.cpp th01\main_02.c th01\main_03.c th01\main_04.c th01\main_05.c th01\main_06.cpp th01\main_07.cpp th01\main_08.cpp th01\main_09.cpp th01\main_12.c th01\main_13.cpp th01\main_13_.cpp th01\main_14.cpp th01\main_16.c th01\main_19.cpp th01\main_23.cpp th01\main_25.cpp th01\main_27.cpp th01\main_30.cpp th01\main_38.cpp
bin\th01\reiiden.exe: bin\piloadc.obj bin\th01\reiiden.obj th01\main_01.cpp th01\main_01_.cpp th01\main_02.c th01\main_03.c th01\main_04.c th01\main_05.c th01\main_06.cpp th01\main_07.cpp th01\main_08.cpp th01\main_09.cpp th01\main_12.c th01\main_13.cpp th01\main_13_.cpp th01\main_14.cpp th01\main_16.c th01\main_19.cpp th01\main_21.cpp th01\main_23.cpp th01\main_25.cpp th01\main_27.cpp th01\main_30.cpp th01\main_38.cpp
$(CC) $(CFLAGS) -ml -3 -DGAME=1 -DBINARY='M' -nbin\th01\ -eREIIDEN.EXE @&&|
$**
|
Expand Down
18 changes: 18 additions & 0 deletions th01/main/boss/entity.cpp
@@ -0,0 +1,18 @@
#include <stddef.h>
#include "platform.h"
#include "pc98.h"
#include "planar.h"
#include "th01/formats/bos.hpp"

void bos_reset_all_broken(void)
{
for(int slot = 0; slot < 10; slot++) { // should be BOS_SLOT_COUNT
for(int image = 0; image < BOS_IMAGES_PER_SLOT; image++) {
bos_images[slot].image[image].alpha = NULL;
bos_images[slot].image[image].planes.B = NULL;
bos_images[slot].image[image].planes.R = NULL;
bos_images[slot].image[image].planes.G = NULL;
bos_images[slot].image[image].planes.E = NULL;
}
}
}
10 changes: 10 additions & 0 deletions th01/main_21.cpp
@@ -0,0 +1,10 @@
/* ReC98
* -----
* Code segment #21 of TH01's REIIDEN.EXE
*/

#pragma option -Z

extern "C" {
#include "th01/main/boss/entity.cpp"
}
81 changes: 9 additions & 72 deletions th01_reiiden.asm
Expand Up @@ -74,6 +74,7 @@ BOMBS_MAX = 5
main_01 group main_01_TEXT, main_01__TEXT, main_01___TEXT
main_13 group main_13_TEXT, main_13__TEXT
main_19 group main_19_TEXT, main_19__TEXT
main_21 group main_21_TEXT, main_21__TEXT
main_23 group main_23_TEXT, main_23__TEXT
main_25 group main_25_TEXT, main_25__TEXT
main_27 group main_27_TEXT, main_27__TEXT
Expand Down Expand Up @@ -8874,77 +8875,13 @@ main_20_TEXT ends

; Segment type: Pure code
main_21_TEXT segment byte public 'CODE' use16
assume cs:main_21_TEXT
main_21_TEXT ends

main_21__TEXT segment byte public 'CODE' use16
assume cs:main_21
;org 4
assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing

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

; Attributes: bp-based frame

sub_155F4 proc far
push bp
mov bp, sp
xor dx, dx
jmp loc_15686
; ---------------------------------------------------------------------------

loc_155FC:
xor cx, cx
jmp short loc_1567E
; ---------------------------------------------------------------------------

loc_15600:
mov bx, dx
imul bx, size bos_t
mov ax, cx
imul ax, size bos_image_t
add bx, ax
mov word ptr (_bos_images[bx].BOS_alpha+2), 0
mov word ptr (_bos_images[bx].BOS_alpha+0), 0
mov bx, dx
imul bx, size bos_t
mov ax, cx
imul ax, size bos_image_t
add bx, ax
mov word ptr (_bos_images[bx].BOS_B+2), 0
mov word ptr (_bos_images[bx].BOS_B+0), 0
mov bx, dx
imul bx, size bos_t
mov ax, cx
imul ax, size bos_image_t
add bx, ax
mov word ptr (_bos_images[bx].BOS_R+2), 0
mov word ptr (_bos_images[bx].BOS_R+0), 0
mov bx, dx
imul bx, size bos_t
mov ax, cx
imul ax, size bos_image_t
add bx, ax
mov word ptr (_bos_images[bx].BOS_G+2), 0
mov word ptr (_bos_images[bx].BOS_G+0), 0
mov bx, dx
imul bx, size bos_t
mov ax, cx
imul ax, size bos_image_t
add bx, ax
mov word ptr (_bos_images[bx].BOS_E+2), 0
mov word ptr (_bos_images[bx].BOS_E+0), 0
inc cx

loc_1567E:
cmp cx, 8
jl loc_15600
inc dx

loc_15686:
cmp dx, 0Ah
jl loc_155FC
pop bp
retf
sub_155F4 endp


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

; Attributes: bp-based frame
Expand Down Expand Up @@ -11945,7 +11882,7 @@ sub_17041 proc far
CBossEntity__ctor boss_entity_2
CBossEntity__ctor boss_entity_3
CBossEntity__ctor boss_entity_4
push seg main_21_TEXT
push seg main_21
push offset sub_17096
push 5
pushd 5
Expand Down Expand Up @@ -11993,7 +11930,7 @@ loc_170C3:
retf
sub_17096 endp

main_21_TEXT ends
main_21__TEXT ends

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

Expand Down Expand Up @@ -33492,15 +33429,15 @@ sub_24722 endp
sub_24DFF proc far
push bp
mov bp, sp
push seg main_21_TEXT
push seg main_21
push offset sub_17096
push 5
pushd 5
push size CBossEntity
push ds
push offset _kikuri_souls
call @_vector_new_$qnvuiuluie ; _vector_new_(void *,uint,ulong,uint,...)
push seg main_21_TEXT
push seg main_21
push offset sub_17096
push 5
pushd KIKURI_TEAR_COUNT
Expand Down

0 comments on commit 5f5eb8a

Please sign in to comment.