Skip to content

Commit

Permalink
[Naming] .MPN: Rename mptn_* to mpn_*
Browse files Browse the repository at this point in the history
We've been using the three-letter extension names for everything else
that isn't .DAT, so it's more consistent to do the same for .MPN,
however particularly nice and readable its FOURCC may be. 8.3 filenames
also really appreciate that they'll have to accommodate one fewer
letter.

Part of P0138, funded by [Anonymous] and Blue Bolt.
  • Loading branch information
nmlgc committed Apr 22, 2021
1 parent 9739f69 commit f635948
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 124 deletions.
2 changes: 1 addition & 1 deletion Makefile.mak
Expand Up @@ -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\mptn_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_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 @&&|
$**
|
Expand Down
20 changes: 20 additions & 0 deletions th02/formats/mpn.hpp
@@ -0,0 +1,20 @@
typedef struct {
char magic[4]; // = "MPTN"
char count;
char unused;
} mpn_header_t;

#define MPN_SIZE (8 * 16)

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_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);

void mpn_free(void);
43 changes: 43 additions & 0 deletions th02/formats/mpn_i.cpp
@@ -0,0 +1,43 @@
#pragma option -zCSHARED -3

extern "C" {
#include <mem.h>
#include "platform.h"
#include "pc98.h"
#include "master.hpp"
#include "th02/formats/mpn.hpp"

void mpn_palette_show(void)
{
palette_set_all(mpn_palette);
palette_show();
}

int pascal mpn_load_palette_show(const char *fn)
{
extern bool mpn_show_palette_on_load;
mpn_header_t header;

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) {
mpn_free();
}
mpn_buffer = reinterpret_cast<int __seg*>(
hmem_allocbyte((mpn_count + 1) * MPN_SIZE)
);
if(!mpn_buffer) {
file_close();
return -1;
}
file_read(mpn_buffer, (mpn_count + 1) * MPN_SIZE);
file_close();
return 0;
}

}
21 changes: 0 additions & 21 deletions th02/formats/mptn.hpp

This file was deleted.

43 changes: 0 additions & 43 deletions th02/formats/mptn_i.cpp

This file was deleted.

20 changes: 10 additions & 10 deletions th02/main02_1.cpp
Expand Up @@ -10,25 +10,25 @@ extern "C" {
#include "platform.h"
#include "pc98.h"
#include "master.hpp"
#include "th02/formats/mptn.hpp"
#include "th02/formats/mpn.hpp"

int pascal mptn_load(const char *fn)
int pascal mpn_load(const char *fn)
{
extern bool mptn_show_palette_on_load;
extern bool mpn_show_palette_on_load;

int ret;
mptn_show_palette_on_load = false;
ret = mptn_load_palette_show(fn);
mptn_show_palette_on_load = true;
mpn_show_palette_on_load = false;
ret = mpn_load_palette_show(fn);
mpn_show_palette_on_load = true;
return ret;
}

void mptn_free(void)
void mpn_free(void)
{
if(mptn_buffer) {
HMem<int>::free(mptn_buffer);
if(mpn_buffer) {
HMem<int>::free(mpn_buffer);
}
mptn_buffer = 0;
mpn_buffer = 0;
}

}
1 change: 1 addition & 0 deletions th02/mpn_i.cpp
@@ -0,0 +1 @@
#include "th02/formats/mpn_i.cpp"
1 change: 0 additions & 1 deletion th02/mptn_i.cpp

This file was deleted.

34 changes: 17 additions & 17 deletions th02_main.asm
Expand Up @@ -162,8 +162,8 @@ arg_4 = word ptr 0Ah
mov di, ax
mov ax, [bp+arg_0]
shl ax, 7
mov dx, word ptr _mptn_buffer+2
mov bx, word ptr _mptn_buffer
mov dx, word ptr _mpn_buffer+2
mov bx, word ptr _mpn_buffer
add bx, ax
mov ds, dx
mov si, bx
Expand Down Expand Up @@ -2248,10 +2248,10 @@ loc_B4D7:
push ss
lea ax, [bp+var_C]
push ax
call mptn_load
call mpn_load
push 30h ; '0' ; n
push ds
push offset _mptn_palette ; src
push offset _mpn_palette ; src
push ds
push offset unk_1F4AD ; dest
call _memcpy
Expand Down Expand Up @@ -2397,10 +2397,10 @@ loc_B8B5:
call sub_4596
graph_accesspage 0
call sub_4782
call _mptn_free
call _mpn_free
push ds
push offset aMiko_k_mpn ; "miko_k.mpn"
call mptn_load
call mpn_load
les bx, _resident
cmp es:[bx+mikoconfig_t.demo_num], 0
jnz short loc_B922
Expand Down Expand Up @@ -3510,7 +3510,7 @@ _arg0 = dword ptr 6
mov bp, sp
freePISlotLarge 0
call sub_E24A
call _mptn_free
call _mpn_free
call sub_1C608
call super_free
call graph_clear
Expand Down Expand Up @@ -9286,8 +9286,8 @@ main_01_TEXT ends
SHARED segment word public 'CODE' use16
extern ZUN_ERROR:proc
extern _key_delay:proc
extern MPTN_LOAD:proc
extern _mptn_free:proc
extern MPN_LOAD:proc
extern _mpn_free:proc
extern _vram_planes_set:proc
extern _pi_load:proc
extern VECTOR2:proc
Expand Down Expand Up @@ -33652,10 +33652,10 @@ include th02/formats/pfopen[data].asm
public _snd_active
_snd_active db 0
db 0
public _mptn_show_palette_on_load
_mptn_show_palette_on_load db 1
public _mptn_count
_mptn_count db 0
public _mpn_show_palette_on_load
_mpn_show_palette_on_load db 1
public _mpn_count
_mpn_count db 0
public _pf_fn
_pf_fn db '��������.�^',0
include th02/snd/se[data].asm
Expand Down Expand Up @@ -34651,10 +34651,10 @@ 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 _mptn_buffer
_mptn_buffer dd ?
public _mptn_palette
_mptn_palette db 16 * 3 dup(?)
public _mpn_buffer
_mpn_buffer dd ?
public _mpn_palette
_mpn_palette db 16 * 3 dup(?)
word_1FFF0 dw ?
word_1FFF2 dw ?
word_1FFF4 dw ?
Expand Down
36 changes: 18 additions & 18 deletions th04_main.asm
Expand Up @@ -838,7 +838,7 @@ loc_B0B2:
call stage4_setup
push ds
push offset aSt03_mpn ; "st03.mpn"
call main_01:mptn_load
call main_01:mpn_load
mov _stage_render, offset stage4_render
jmp short loc_B144
; ---------------------------------------------------------------------------
Expand Down Expand Up @@ -872,7 +872,7 @@ loc_B11E:
push offset aSt06_mpn ; "st06.mpn"

loc_B141:
call main_01:mptn_load
call main_01:mpn_load

loc_B144:
call main_01:map_load
Expand Down Expand Up @@ -1467,8 +1467,8 @@ sub_B835 endp
; =============== S U B R O U T I N E =======================================

; Attributes: bp-based frame
public MPTN_LOAD
mptn_load proc near
public MPN_LOAD
mpn_load proc near

var_6 = word ptr -6
@@tile_y = word ptr -4
Expand All @@ -1480,7 +1480,7 @@ arg_0 = dword ptr 4
push di
push 0
pushd [bp+arg_0]
call mptn_load_inner
call mpn_load_inner
mov [bp+var_6], 0
mov [bp+@@tile_x], 0
mov si, 576
Expand Down Expand Up @@ -1520,12 +1520,12 @@ loc_B95E:
cmp [bp+@@tile_x], 4
jl short loc_B91C
push 0
call mptn_free
call mpn_free
pop di
pop si
leave
retn 4
mptn_load endp
mpn_load endp


; =============== S U B R O U T I N E =======================================
Expand Down Expand Up @@ -12984,8 +12984,8 @@ SHARED_ segment word public 'CODE' use16
; =============== S U B R O U T I N E =======================================

; Attributes: bp-based frame
public MPTN_FREE
mptn_free proc far
public MPN_FREE
mpn_free proc far

arg_0 = word ptr 6

Expand All @@ -13006,15 +13006,15 @@ loc_1320E:
pop si
pop bp
retf 2
mptn_free endp
mpn_free endp

include th04/hardware/input_wait.asm

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

; Attributes: bp-based frame
public MPTN_PALETTE_SHOW
mptn_palette_show proc far
public MPN_PALETTE_SHOW
mpn_palette_show proc far

arg_0 = word ptr 6

Expand All @@ -13033,14 +13033,14 @@ arg_0 = word ptr 6
call far ptr palette_show
pop bp
retf 2
mptn_palette_show endp
mpn_palette_show endp


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

; Attributes: bp-based frame
public MPTN_LOAD_INNER
mptn_load_inner proc far
public MPN_LOAD_INNER
mpn_load_inner proc far

var_8 = word ptr -8
var_6 = byte ptr -6
Expand Down Expand Up @@ -13079,11 +13079,11 @@ arg_4 = word ptr 0Ah
cmp byte_21AF2, 0
jz short loc_132E3
push di
call mptn_palette_show
call mpn_palette_show

loc_132E3:
push di
nopcall mptn_free
nopcall mpn_free
push [bp+var_8]
call hmem_allocbyte
mov [si+2], ax
Expand All @@ -13107,7 +13107,7 @@ loc_1331A:
pop si
leave
retf 6
mptn_load_inner endp
mpn_load_inner endp

include th04/math/vector1_at.asm
include th04/math/vector2_at.asm
Expand Down

0 comments on commit f635948

Please sign in to comment.