From f6359484809826620ae2e4984fe3e309ef9b203c Mon Sep 17 00:00:00 2001 From: nmlgc Date: Thu, 22 Apr 2021 18:43:11 +0200 Subject: [PATCH] [Naming] .MPN: Rename mptn_* to mpn_* 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. --- Makefile.mak | 2 +- th02/formats/mpn.hpp | 20 +++++++++++++++++++ th02/formats/mpn_i.cpp | 43 +++++++++++++++++++++++++++++++++++++++++ th02/formats/mptn.hpp | 21 -------------------- th02/formats/mptn_i.cpp | 43 ----------------------------------------- th02/main02_1.cpp | 20 +++++++++---------- th02/mpn_i.cpp | 1 + th02/mptn_i.cpp | 1 - th02_main.asm | 34 ++++++++++++++++---------------- th04_main.asm | 36 +++++++++++++++++----------------- th05_main.asm | 26 ++++++++++++------------- 11 files changed, 123 insertions(+), 124 deletions(-) create mode 100644 th02/formats/mpn.hpp create mode 100644 th02/formats/mpn_i.cpp delete mode 100644 th02/formats/mptn.hpp delete mode 100644 th02/formats/mptn_i.cpp create mode 100644 th02/mpn_i.cpp delete mode 100644 th02/mptn_i.cpp diff --git a/Makefile.mak b/Makefile.mak index 3a5f7dd2..d57c9d06 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -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 @&&| $** | diff --git a/th02/formats/mpn.hpp b/th02/formats/mpn.hpp new file mode 100644 index 00000000..dfee8cf7 --- /dev/null +++ b/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); diff --git a/th02/formats/mpn_i.cpp b/th02/formats/mpn_i.cpp new file mode 100644 index 00000000..ae4dc263 --- /dev/null +++ b/th02/formats/mpn_i.cpp @@ -0,0 +1,43 @@ +#pragma option -zCSHARED -3 + +extern "C" { +#include +#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( + 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; +} + +} diff --git a/th02/formats/mptn.hpp b/th02/formats/mptn.hpp deleted file mode 100644 index 1d869789..00000000 --- a/th02/formats/mptn.hpp +++ /dev/null @@ -1,21 +0,0 @@ -typedef struct { - char magic[4]; // = "MPTN" - char count; - char unused; -} mptn_header_t; - -#define MPTN_SIZE (8 * 16) - -extern unsigned char mptn_count; -extern int *mptn_buffer; -extern Palette8 mptn_palette; - -// Reads the MPTN file with the given [fn] into the newly reallocated -// [mptn_buffer], and sets [mptn_count] and [mptn_palette] accordingly. -int pascal mptn_load(const char *fn); - -// Like mptn_load(), but sets the hardware palette to the one in [fn]'s -// header. -int pascal mptn_load_palette_show(const char *fn); - -void mptn_free(void); diff --git a/th02/formats/mptn_i.cpp b/th02/formats/mptn_i.cpp deleted file mode 100644 index 40d965cd..00000000 --- a/th02/formats/mptn_i.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#pragma option -zCSHARED -3 - -extern "C" { -#include -#include "platform.h" -#include "pc98.h" -#include "master.hpp" -#include "th02/formats/mptn.hpp" - -void mptn_palette_show(void) -{ - palette_set_all(mptn_palette); - palette_show(); -} - -int pascal mptn_load_palette_show(const char *fn) -{ - extern bool mptn_show_palette_on_load; - mptn_header_t header; - - file_ropen(fn); - file_read(&header, sizeof(header)); - mptn_count = header.count; - file_read(&mptn_palette, sizeof(mptn_palette)); - if(mptn_show_palette_on_load) { - mptn_palette_show(); - } - if(mptn_buffer) { - mptn_free(); - } - mptn_buffer = reinterpret_cast( - hmem_allocbyte((mptn_count + 1) * MPTN_SIZE) - ); - if(!mptn_buffer) { - file_close(); - return -1; - } - file_read(mptn_buffer, (mptn_count + 1) * MPTN_SIZE); - file_close(); - return 0; -} - -} diff --git a/th02/main02_1.cpp b/th02/main02_1.cpp index a8cee065..dd1ad154 100644 --- a/th02/main02_1.cpp +++ b/th02/main02_1.cpp @@ -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::free(mptn_buffer); + if(mpn_buffer) { + HMem::free(mpn_buffer); } - mptn_buffer = 0; + mpn_buffer = 0; } } diff --git a/th02/mpn_i.cpp b/th02/mpn_i.cpp new file mode 100644 index 00000000..3dfe2f11 --- /dev/null +++ b/th02/mpn_i.cpp @@ -0,0 +1 @@ +#include "th02/formats/mpn_i.cpp" diff --git a/th02/mptn_i.cpp b/th02/mptn_i.cpp deleted file mode 100644 index 395ffad7..00000000 --- a/th02/mptn_i.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "th02/formats/mptn_i.cpp" diff --git a/th02_main.asm b/th02_main.asm index 6019e73a..3f6f9766 100644 --- a/th02_main.asm +++ b/th02_main.asm @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 ? diff --git a/th04_main.asm b/th04_main.asm index e837eae3..8d1fb6ed 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -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 ; --------------------------------------------------------------------------- @@ -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 @@ -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 @@ -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 @@ -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 ======================================= @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/th05_main.asm b/th05_main.asm index 32cc5b98..4ddaf508 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -174,9 +174,9 @@ include libs/master.lib/super_put_8.asm ; =============== S U B R O U T I N E ======================================= -public MPTN_LOAD_INNER -mptn_load_inner proc far - call mptn_free +public MPN_LOAD_INNER +mpn_load_inner proc far + call mpn_free mov bx, sp push si push di @@ -226,13 +226,13 @@ mptn_load_inner proc far pop di pop si retf 4 -mptn_load_inner endp +mpn_load_inner endp ; =============== S U B R O U T I N E ======================================= -public MPTN_FREE -mptn_free proc far +public MPN_FREE +mpn_free proc far cmp word_23A5A, 0 jz short locret_4224 push word_23A5A @@ -241,7 +241,7 @@ mptn_free proc far locret_4224: retf -mptn_free endp +mpn_free endp ; --------------------------------------------------------------------------- nop @@ -1001,7 +1001,7 @@ loc_B48A: push offset aSt06_mpn ; "st06.mpn" loc_B4A6: - call mptn_load + call mpn_load loc_B4A9: call map_load @@ -1531,8 +1531,8 @@ include th05/formats/cfg_lres.asm ; =============== 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 arg_0 = dword ptr 4 @@ -1541,7 +1541,7 @@ arg_0 = dword ptr 4 push si push di pushd [bp+arg_0] - call mptn_load_inner + call mpn_load_inner mov al, 1 loc_BB08: @@ -1568,12 +1568,12 @@ loc_BB12: pop ax dec al jz short loc_BB08 - call mptn_free + call mpn_free pop di pop si pop bp retn 4 -mptn_load endp +mpn_load endp ; --------------------------------------------------------------------------- nop