ReC98/th05/formats/dialog.cpp

42 lines
992 B
C++
Raw Normal View History

#pragma option -zCmain_TEXT
#include <stddef.h>
#include "platform.h"
#include "master.hpp"
#include "th04/common.h"
#include "th04/score.h"
#include "th04/main/stage/stage.hpp"
#include "th05/playchar.h"
#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) {
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
}