2023-10-15 00:26:32 +00:00
|
|
|
|
#pragma option -zCmain_TEXT -zPmain_01
|
2022-03-13 18:29:08 +00:00
|
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2024-05-20 18:02:24 +00:00
|
|
|
|
#include "libs/master.lib/master.hpp"
|
2022-03-13 18:29:08 +00:00
|
|
|
|
#include "th04/main/stage/stage.hpp"
|
|
|
|
|
#include "th05/resident.hpp"
|
|
|
|
|
#include "th05/formats/dialog.hpp"
|
|
|
|
|
|
|
|
|
|
void pascal dialog_load(const char *fn)
|
|
|
|
|
{
|
|
|
|
|
size_t size;
|
|
|
|
|
tx2_header_t header;
|
|
|
|
|
|
|
|
|
|
if(dialog_p) {
|
2022-03-13 19:47:32 +00:00
|
|
|
|
// PORTERS: See the note in dialog_free() – and maybe just call that
|
|
|
|
|
// function instead, then.
|
2022-03-13 18:29:08 +00:00
|
|
|
|
hmem_free(reinterpret_cast<void __seg *>(dialog_p));
|
|
|
|
|
}
|
|
|
|
|
file_ropen(fn);
|
|
|
|
|
file_read(&header, sizeof(header));
|
|
|
|
|
|
|
|
|
|
// A sanity check here would have been particularly helpful for
|
|
|
|
|
// translators, who tend to start out by just blindly editing a .TX2 file.
|
|
|
|
|
size = (header.offset_for[playchar + 1] - header.offset_for[playchar]);
|
|
|
|
|
|
|
|
|
|
dialog_p = reinterpret_cast<unsigned char far *>(hmem_allocbyte(size));
|
|
|
|
|
file_seek(header.offset_for[playchar], SEEK_SET);
|
|
|
|
|
file_read(dialog_p, size);
|
|
|
|
|
file_close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void near dialog_load(void)
|
|
|
|
|
{
|
|
|
|
|
#define fn dialog_fn
|
|
|
|
|
extern char *fn;
|
|
|
|
|
fn[4] = ('0' + stage_id);
|
|
|
|
|
dialog_load(fn);
|
|
|
|
|
#undef fn
|
|
|
|
|
}
|
2022-03-13 19:47:32 +00:00
|
|
|
|
|
|
|
|
|
void near dialog_free(void)
|
|
|
|
|
{
|
|
|
|
|
if(dialog_p) {
|
|
|
|
|
// PORTERS: Relies on `far` pointer semantics, specifically on the
|
|
|
|
|
// segment part still being identical to what hmem_allocbyte()
|
|
|
|
|
// returned. You'll need to introduce a separate "dialog buffer base
|
|
|
|
|
// pointer" when porting to flat memory models.
|
|
|
|
|
hmem_free(reinterpret_cast<void __seg *>(dialog_p));
|
2022-06-26 09:32:25 +00:00
|
|
|
|
dialog_p = nullptr;
|
2022-03-13 19:47:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|