[Decompilation] [th03/th04/th05] Music Room: Comment loading

Part of P0264, funded by [Anonymous] and Blue Bolt.
This commit is contained in:
nmlgc 2024-01-09 05:27:42 +01:00
parent ee5c7c56d1
commit cbcb540c54
13 changed files with 46 additions and 110 deletions

View File

@ -6,8 +6,8 @@
// The first line contains the track title and is rendered to a different
// position than the other 19 lines.
static const shiftjis_ank_amount_t CMT_LINE_LENGTH = 40;
static const shiftjis_ank_amount_t CMT_LINE_LENGTH = ((GAME >= 4) ? 38 : 40);
static const shiftjis_ank_amount_t CMT_LINE_SIZE = (CMT_LINE_LENGTH + 2);
static const int CMT_TITLE_LINE = 0;
static const int CMT_COMMENT_LINES = 19;
static const int CMT_COMMENT_LINES = ((GAME == 5) ? 9 : 19);
static const int CMT_LINES = (1 + CMT_COMMENT_LINES);

View File

@ -1,17 +0,0 @@
#define MUSIC_CMT_LEN MUSIC_CMT_LINE_COUNT * MUSIC_CMT_LINE_LEN
char music_cmt[MUSIC_CMT_LINE_COUNT][MUSIC_CMT_LINE_LEN];
#undef MUSIC_CMT_FN
#define MUSIC_CMT_FN (const char *)(MK_FP(_DS, 0x0C13))
void pascal near music_cmt_load(int track)
{
int i;
file_ropen(MUSIC_CMT_FN);
file_seek(track * MUSIC_CMT_LEN, SEEK_SET);
file_read(music_cmt, MUSIC_CMT_LEN);
file_close();
for(i = 0; i < MUSIC_CMT_LINE_COUNT; i++) {
music_cmt[i][MUSIC_CMT_LINE_LEN - 2] = 0;
}
}

View File

@ -153,6 +153,12 @@ page_t music_page;
extern Planar<dots8_t far *> cmt_bg;
// -----------
#define cmt music_cmt
struct cmt_line_t {
shiftjis_t c[CMT_LINE_SIZE];
};
extern cmt_line_t cmt[CMT_LINES];
#if (GAME == 5)
// TH05 selection state
// --------------------
@ -439,3 +445,25 @@ void near music_flip(void)
cmt_bg_blit_planar(cmt_bg_p, vo, x, cmt_bg, cmt_bg_p, VRAM_PLANE, vo);
}
#endif
void pascal near cmt_load(int track)
{
#if (GAME == 5)
char* FN = "_MUSIC0.TXT";
FN[6] = ('0' + game_sel);
file_ropen(FN);
#elif (GAME == 4)
file_ropen("_MUSIC.TXT\0music.pi");
#elif (GAME == 3)
file_ropen(reinterpret_cast<const char *>(MK_FP(_DS, 0x09D1)));
#elif (GAME == 2)
file_ropen(reinterpret_cast<const char *>(MK_FP(_DS, 0x0C13)));
#endif
file_seek((track * int(sizeof(cmt))), SEEK_SET);
file_read(cmt, sizeof(cmt));
file_close();
for(int i = 0; i < CMT_LINES; i++) {
cmt[i].c[CMT_LINE_LENGTH] = '\0';
}
}

View File

@ -1,35 +0,0 @@
; int __pascal __near music_cmt_load(int track)
music_cmt_load proc pascal near
@@track = word ptr [bp+4]
push bp
mov bp, sp
push si
call file_ropen pascal, ds, offset _aMUSIC_TXT
mov ax, @@track
imul ax, MUSIC_CMT_LEN
if GAME ge 3
cwde
call file_seek pascal, eax, 0
else
cwd
call file_seek pascal, dx, ax, 0
endif
call file_read pascal, ds, offset _music_cmt, MUSIC_CMT_LEN
call file_close
xor si, si
jmp short @@check
@@terminate_line:
mov bx, si
imul bx, MUSIC_CMT_LINE_LEN
mov (_music_cmt + MUSIC_CMT_LINE_LEN - 2)[bx], 0
inc si
@@check:
cmp si, MUSIC_CMT_LINE_COUNT
jl short @@terminate_line
pop si
pop bp
ret 2
music_cmt_load endp

View File

@ -17,7 +17,6 @@ extern "C" {
#include "th02/formats/pi.h"
#include "th02/snd/snd.h"
}
#include "th02/shiftjis/fns.hpp"
extern const char* MUSIC_FILES[15];
extern uint8_t track_playing;
@ -33,6 +32,7 @@ extern unsigned char music_sel;
extern page_t music_page;
dots8_t *nopoly_B;
Planar<dots8_t far *> cmt_back;
shiftjis_t music_cmt[MUSIC_CMT_LINE_COUNT][MUSIC_CMT_LINE_LEN];
void pascal near track_put(uint8_t sel, vc_t col);
void pascal near tracklist_put(uint8_t sel);
@ -41,6 +41,7 @@ void near nopoly_B_free(void);
void near nopoly_B_put(void);
void near music_flip(void);
void near cmt_bg_snap(void);
void pascal near cmt_load(int track);
#define cmt_bg_put_planar(cmt_bg_p, vo, x, dst, dst_p, src, src_p) \
size_t cmt_bg_p = 0; \
@ -66,8 +67,6 @@ void near cmt_bg_snap(void);
} \
}
#include "th02/op/cmt_load.c"
void pascal near cmt_back_free(void)
{
HMem<dots8_t>::free(cmt_back.B);
@ -86,7 +85,7 @@ void pascal near cmt_back_put(void)
void pascal near draw_cmt(int track)
{
int line;
music_cmt_load(track);
cmt_load(track);
nopoly_B_put();
cmt_back_put();

View File

@ -1,5 +1,4 @@
#define PF_FN "“Œ•û••–‚.˜^"
#define MUSIC_CMT_FN "MUSIC.TXT"
#define SHIFTJIS_FN "MIKOFT.bft"
#define BGM_MENU_MAIN_FN "op.m"

View File

@ -1,6 +1,9 @@
; (identical to the already decompiled TH02 version, except for the first X
; coordinate)
@CMT_LOAD$QI procdesc pascal near \
track:word
public DRAW_CMT
draw_cmt proc near
@ -10,7 +13,7 @@ draw_cmt proc near
mov bp, sp
push si
push di
call music_cmt_load pascal, [bp+@@track]
call @cmt_load$qi pascal, [bp+@@track]
call @nopoly_B_put$qv
call cmt_back_put
push 1300040h

View File

@ -34,10 +34,6 @@ _TEXT segment word public 'CODE' use16
extern PALETTE_BLACK_OUT:proc
extern DOS_PUTS2:proc
extern EGC_SHIFT_LEFT_ALL:proc
extern FILE_CLOSE:proc
extern FILE_READ:proc
extern FILE_ROPEN:proc
extern FILE_SEEK:proc
extern GRCG_BOXFILL:proc
extern GRCG_BYTEBOXFILL_X:proc
extern GRCG_PSET:proc
@ -1329,7 +1325,6 @@ OP_MUSIC_TEXT segment byte public 'CODE' use16
@cmt_bg_snap$qv procdesc near
include th02/op/music.asm
include th02/op/music_cmt_load.asm
include th03/op/cmt_back_free_put.asm
include th03/op/draw_cmt.asm

View File

@ -1 +0,0 @@
_aMUSIC_TXT db '_MUSIC.TXT',0

View File

@ -70,9 +70,10 @@ op_01_TEXT segment byte public 'CODE' use16
sel:byte, col:byte
@TRACKLIST_PUT$QUC procdesc pascal near \
sel:byte
@CMT_LOAD$QI procdesc pascal near \
track:word
include th02/op/music.asm
include th02/op/music_cmt_load.asm
; =============== S U B R O U T I N E =======================================
@ -180,7 +181,7 @@ draw_cmt proc near
call sub_C33F
loc_C37C:
call music_cmt_load pascal, [bp+@@track]
call @cmt_load$qi pascal, [bp+@@track]
call @nopoly_B_put$qv
call bgimage_put_rect_16 pascal, (320 shl 16) or 64, (320 shl 16) or 320
cmp byte_12DBE, 0
@ -1089,10 +1090,9 @@ include th04/zunsoft[data].asm
extern _MUSIC_FILES:dword
extern _track_playing:byte
aOp_2 = ($ - 118)
aOp_2 = ($ - 138)
aMusic_pi = ($ - 9)
include th04/op/music_cmt_load[data].asm
aMusic_pi db 'music.pi',0
aGensou_scr db 'GENSOU.SCR',0
aName db 'name',0
aHi01_pi db 'hi01.pi',0

View File

@ -1,34 +0,0 @@
; int __pascal __near music_cmt_load(int track)
music_cmt_load proc pascal near
arg @@track:word
local @@fn:dword
push si
mov word ptr @@fn+2, ds
mov word ptr @@fn, offset _a_Music0_txt
les bx, @@fn
mov al, byte ptr _game_sel
add al, '0'
mov es:[bx+6], al
call file_ropen pascal, word ptr @@fn+2, bx
mov ax, @@track
imul ax, MUSIC_CMT_LEN
cwde
call file_seek pascal, eax, 0
call file_read pascal, ds, offset _music_cmt, MUSIC_CMT_LEN
call file_close
xor si, si
jmp short @@check
@@terminate_line:
mov bx, si
imul bx, MUSIC_CMT_LINE_LEN
mov (_music_cmt + MUSIC_CMT_LINE_LEN - 2)[bx], 0
inc si
@@check:
cmp si, MUSIC_CMT_LINE_COUNT
jl short @@terminate_line
pop si
ret
music_cmt_load endp

View File

@ -1 +0,0 @@
_a_Music0_txt db '_MUSIC0.TXT',0

View File

@ -71,9 +71,10 @@ op_01_TEXT segment byte public 'CODE' use16
track_sel:byte, boot:word
@TRACKLIST_PUT$QUC procdesc pascal near \
sel:byte
@CMT_LOAD$QI procdesc pascal near \
track:word
include th02/op/music.asm
include th05/op/music_cmt_load.asm
; =============== S U B R O U T I N E =======================================
@ -176,7 +177,7 @@ draw_cmt proc near
call sub_C3A7
loc_C406:
call music_cmt_load pascal, [bp+@@track]
call @cmt_load$qi pascal, [bp+@@track]
call @nopoly_B_put$qv
call bgimage_put_rect_16 pascal, (320 shl 16) or 64, (320 shl 16) or 256
cmp byte_13E96, 0
@ -887,9 +888,8 @@ include th04/zunsoft[data].asm
extern _MUSIC_FILES:dword
extern _game_sel:word
extern _TRACK_COUNT:word:5
aH_op = ($ - 530)
aH_op = ($ - 542)
include th05/op/music_cmt_load[data].asm
aMusic_pi db 'music.pi',0
aMusic_dat db 'music.dat',0
aKaikidan1_dat1 db '‰öãYk1.dat',0