[Maintenance] [th02] .MPN: Update existing decompilations to current standards

Part of P0138, funded by [Anonymous] and Blue Bolt.
This commit is contained in:
nmlgc 2021-04-18 18:36:29 +02:00
parent f635948480
commit b1cf7ee021
6 changed files with 51 additions and 35 deletions

View File

@ -85,7 +85,7 @@ bin\th02\op.exe: th02\op_01.cpp bin\exit_dos.obj bin\th02\zunerror.obj bin\th02\
$**
|
bin\th02\main.exe: bin\th02\main.obj bin\th02\zunerror.obj bin\th02\keydelay.obj th02\main02_1.cpp bin\th01\vplanset.obj bin\th02\pi_load.obj bin\th02\vector2.obj bin\frmdely1.obj bin\th02\input_s.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_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
bin\th02\main.exe: bin\th02\main.obj bin\th02\zunerror.obj bin\th02\keydelay.obj th02\main02_1.cpp bin\th01\vplanset.obj bin\th02\pi_load.obj bin\th02\vector2.obj bin\frmdely1.obj bin\th02\input_s.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
$(CC) $(CFLAGS) $(LARGE_LFLAGS) -Z -DGAME=2 -nbin\th02\ -eMAIN.EXE @&&|
$**
|

View File

@ -1,20 +1,30 @@
/// Uncompressed 16-color 16×16 image format with palette, used for map tiles
/// -------------------------------------------------------------------------
typedef dot_rect_t(TILE_W, TILE_H) mpn_plane_t;
typedef Planar<mpn_plane_t> mpn_image_t;
typedef struct {
char magic[4]; // = "MPTN"
char count;
char unused;
uint8_t count;
int8_t unused;
} mpn_header_t;
#define MPN_SIZE (8 * 16)
#if (GAME == 2)
extern uint8_t mpn_count;
extern mpn_image_t *mpn_images;
extern Palette8 mpn_palette;
extern unsigned char mpn_count;
extern int *mpn_buffer;
extern Palette8 mpn_palette;
// Reads the .MPN file with the given [fn] into the newly reallocated
// [mpn_images], and sets [mpn_count] and [mpn_palette] accordingly.
// Returns 0 if allocation succeeded and the tiles were read into
// [mpn_images], -1 otherwise.
int pascal mpn_load(const char *fn);
// Reads the .MPN file with the given [fn] into the newly reallocated
// [mpn_buffer], and sets [mpn_count] and [mpn_palette] accordingly.
int pascal mpn_load(const char *fn);
// Like mpn_load(), but sets the hardware palette to the one in [fn]'s
// header.
int pascal mpn_load_palette_show(const char *fn);
// Like mpn_load(), but sets the hardware palette to the one in [fn]'s header.
int pascal mpn_load_palette_show(const char *fn);
void mpn_free(void);
void mpn_free(void);
#endif
/// -------------------------------------------------------------------------

View File

@ -4,7 +4,10 @@ extern "C" {
#include <mem.h>
#include "platform.h"
#include "pc98.h"
#include "planar.h"
#include "master.hpp"
#include "th02/main/playfld.h"
#include "th02/main/tile.hpp"
#include "th02/formats/mpn.hpp"
void mpn_palette_show(void)
@ -21,21 +24,24 @@ int pascal mpn_load_palette_show(const char *fn)
file_ropen(fn);
file_read(&header, sizeof(header));
mpn_count = header.count;
file_read(&mpn_palette, sizeof(mpn_palette));
if(mpn_show_palette_on_load) {
mpn_palette_show();
}
if(mpn_buffer) {
if(mpn_images) {
mpn_free();
}
mpn_buffer = reinterpret_cast<int __seg*>(
hmem_allocbyte((mpn_count + 1) * MPN_SIZE)
);
if(!mpn_buffer) {
mpn_images = reinterpret_cast<mpn_image_t __seg* >(hmem_allocbyte(
(mpn_count + 1) * sizeof(mpn_image_t)
));
if(!mpn_images) {
file_close();
return -1;
}
file_read(mpn_buffer, (mpn_count + 1) * MPN_SIZE);
file_read(mpn_images, (mpn_count + 1) * sizeof(mpn_image_t));
file_close();
return 0;
}

View File

@ -9,7 +9,10 @@ extern "C" {
#include <stddef.h>
#include "platform.h"
#include "pc98.h"
#include "planar.h"
#include "master.hpp"
#include "th02/main/playfld.h"
#include "th02/main/tile.hpp"
#include "th02/formats/mpn.hpp"
int pascal mpn_load(const char *fn)
@ -25,10 +28,10 @@ int pascal mpn_load(const char *fn)
void mpn_free(void)
{
if(mpn_buffer) {
HMem<int>::free(mpn_buffer);
if(mpn_images) {
HMem<mpn_image_t>::free(mpn_images);
}
mpn_buffer = 0;
mpn_images = NULL;
}
}

1
th02/mpn_l_i.cpp Normal file
View File

@ -0,0 +1 @@
#include "th02/formats/mpn_l_i.cpp"

View File

@ -162,8 +162,8 @@ arg_4 = word ptr 0Ah
mov di, ax
mov ax, [bp+arg_0]
shl ax, 7
mov dx, word ptr _mpn_buffer+2
mov bx, word ptr _mpn_buffer
mov dx, word ptr _mpn_images+2
mov bx, word ptr _mpn_images
add bx, ax
mov ds, dx
mov si, bx
@ -2249,7 +2249,7 @@ loc_B4D7:
lea ax, [bp+var_C]
push ax
call mpn_load
push 30h ; '0' ; n
push size palette_t ; n
push ds
push offset _mpn_palette ; src
push ds
@ -2398,9 +2398,7 @@ loc_B8B5:
graph_accesspage 0
call sub_4782
call _mpn_free
push ds
push offset aMiko_k_mpn ; "miko_k.mpn"
call mpn_load
call mpn_load pascal, ds, offset aMiko_k_mpn ; "miko_k.mpn"
les bx, _resident
cmp es:[bx+mikoconfig_t.demo_num], 0
jnz short loc_B922
@ -33652,9 +33650,8 @@ include th02/formats/pfopen[data].asm
public _snd_active
_snd_active db 0
db 0
public _mpn_show_palette_on_load
public _mpn_show_palette_on_load, _mpn_count
_mpn_show_palette_on_load db 1
public _mpn_count
_mpn_count db 0
public _pf_fn
_pf_fn db '“Œ•û••–‚.˜^',0
@ -34651,10 +34648,9 @@ include libs/master.lib/pfint21[bss].asm
include th02/hardware/input_sense[bss].asm
include th02/snd/snd[bss].asm
include th02/snd/load[bss].asm
public _mpn_buffer
_mpn_buffer dd ?
public _mpn_palette
_mpn_palette db 16 * 3 dup(?)
public _mpn_images, _mpn_palette
_mpn_images dd ?
_mpn_palette palette_t <?>
word_1FFF0 dw ?
word_1FFF2 dw ?
word_1FFF4 dw ?