Skip to content

Commit

Permalink
[Maintenance] Remove extern "C" from more areas of code
Browse files Browse the repository at this point in the history
This commit covers
• TH02's ZUNINIT errors,
• TH02's main menu,
• the init/exit functions in all 4 remaining games,
• TH03/TH04/TH05's configuration file functions, and
• TH04/TH05's tile rendering functions.

Part of P0258, funded by [Anonymous] and Blue Bolt.
  • Loading branch information
nmlgc committed Oct 31, 2023
1 parent a4fb2cf commit 757ee71
Show file tree
Hide file tree
Showing 36 changed files with 134 additions and 143 deletions.
File renamed without changes.
3 changes: 0 additions & 3 deletions th02/core/initop.cpp
Expand Up @@ -6,7 +6,6 @@
#include "th01/hardware/vplanset.h"
#include "th02/shiftjis/fns.hpp"
#include "th02/mem.h"
extern "C" {
#include "th02/core/initexit.h"
#include "th02/formats/pf.hpp"

Expand All @@ -28,5 +27,3 @@ int game_init_op(void)
game_pfopen();
return 0;
}

}
2 changes: 0 additions & 2 deletions th02/exit.c

This file was deleted.

2 changes: 2 additions & 0 deletions th02/exit.cpp
@@ -0,0 +1,2 @@
#pragma option -zCSHARED
#include "th02/core/exit.cpp"
File renamed without changes.
5 changes: 3 additions & 2 deletions th02/op_01.cpp
Expand Up @@ -20,12 +20,15 @@ extern "C" {
#include "th02/hardware/frmdelay.h"
#include "th02/hardware/grp_rect.h"
#include "th02/hardware/input.hpp"
}
#include "th02/core/globals.hpp"
#include "th02/core/zunerror.h"
#include "th02/core/initexit.h"
#include "th02/formats/cfg.h"
extern "C" {
#include "th02/formats/pi.h"
#include "th02/snd/snd.h"
}
#include "th02/gaiji/gaiji.h"
#include "th02/op/op.h"

Expand Down Expand Up @@ -702,5 +705,3 @@ int main(void)
gaiji_restore();
return ret;
}

}
3 changes: 1 addition & 2 deletions th02/op_03.cpp
Expand Up @@ -13,6 +13,7 @@ extern "C" {
#include "th02/hardware/frmdelay.h"
#include "th02/formats/pi.h"
#include "th02/snd/snd.h"
}

#include "th02/snd/data.c"
#include "th02/snd/se_data.c"
Expand Down Expand Up @@ -47,5 +48,3 @@ void title_flash(void)
pi_free(1);
pi_free(2);
}

}
5 changes: 2 additions & 3 deletions th02/op_04.cpp
Expand Up @@ -3,7 +3,6 @@
* Code segment #4 of TH02's OP.EXE
*/

extern "C" {
#include <dos.h>
#include <mbctype.h>
#include <mbstring.h>
Expand All @@ -13,8 +12,10 @@ extern "C" {
#include "shiftjis.hpp"
#include "th01/rank.h"
#include "th02/common.h"
extern "C" {
#include "th02/hardware/frmdelay.h"
#include "th02/hardware/input.hpp"
}
#include "th02/core/globals.hpp"
#include "th02/formats/scoredat.h"
#include "th02/gaiji/gaiji.h"
Expand Down Expand Up @@ -231,5 +232,3 @@ int cleardata_load(void)
}
return extra_unlocked;
}

}
3 changes: 1 addition & 2 deletions th02/op_05.cpp
Expand Up @@ -19,6 +19,7 @@ extern "C" {
#include "th02/hardware/grp_rect.h"
#include "th02/hardware/input.hpp"
#include "th02/formats/pi.h"
}

inline char sel_ring_end() {
return SHOTTYPE_COUNT - 1;
Expand Down Expand Up @@ -231,5 +232,3 @@ void pascal shottype_menu(void)
pi_free(2);
palette_black_out(1);
}

}
3 changes: 1 addition & 2 deletions th02/op_06.cpp
Expand Up @@ -20,6 +20,7 @@ extern "C" {
#include "th02/hardware/input.hpp"
#include "th02/formats/pi.h"
#include "th02/snd/snd.h"
}
#include "th02/shiftjis/fns.hpp"

static const int MUSIC_CMT_LINE_LEN = 42;
Expand Down Expand Up @@ -370,5 +371,3 @@ void pascal musicroom(void)
graph_copy_page(0);
graph_accesspage(0);
}

}
File renamed without changes.
8 changes: 4 additions & 4 deletions th02_main.asm
Expand Up @@ -971,7 +971,7 @@ _envp = dword ptr 0Ch
call _game_init_main
or ax, ax
jz short @@game_init_main_is_0
call zun_error pascal, 3
call @zun_error$q11zun_error_t pascal, 3

@@cfg_load_is_1:
mov ax, 1
Expand Down Expand Up @@ -2644,7 +2644,7 @@ public @GameExecl$qnxc
call graph_clear
call text_clear
call @gaiji_free$qv
call _game_exit
call @game_exit$qv
call _execl c, large [bp+@@binary_fn], large [bp+@@binary_fn], large 0
pop bp
retf
Expand Down Expand Up @@ -6428,7 +6428,7 @@ main_01____TEXT ends
; ===========================================================================

SHARED segment word public 'CODE' use16
extern ZUN_ERROR:proc
extern @ZUN_ERROR$Q11ZUN_ERROR_T:proc
extern _key_delay:proc
extern MPN_LOAD:proc
extern _mpn_free:proc
Expand All @@ -6437,7 +6437,7 @@ SHARED segment word public 'CODE' use16
extern @VECTOR2_BETWEEN_PLUS$QIIIIUCMIT6I:proc
extern FRAME_DELAY:proc
extern _input_sense:proc
extern _game_exit:proc
extern @game_exit$qv:proc
extern _snd_mmd_resident:proc
extern _snd_determine_mode:proc
extern _snd_pmd_resident:proc
Expand Down
4 changes: 2 additions & 2 deletions th02_maine.asm
Expand Up @@ -2905,7 +2905,7 @@ loc_B1C6:
mov PaletteTone, 0
call far ptr palette_show
call gaiji_restore
call _game_exit
call @game_exit$qv
pushd 0
push ds
push offset path ; "op"
Expand All @@ -2929,7 +2929,7 @@ SHARED segment word public 'CODE' use16
extern _pi_load:proc
extern FRAME_DELAY:proc
extern _input_sense:proc
extern _game_exit:proc
extern @game_exit$qv:proc
extern _snd_mmd_resident:proc
extern _snd_determine_mode:proc
extern _snd_pmd_resident:proc
Expand Down
2 changes: 0 additions & 2 deletions th03/core/exitmain.cpp
Expand Up @@ -4,9 +4,7 @@
#include "platform.h"
#include "x86real.h"
#include "master.hpp"
extern "C" {
#include "th03/core/initexit.h"
}

void game_exit_from_mainl_to_main()
{
Expand Down
2 changes: 0 additions & 2 deletions th03/exit.c

This file was deleted.

2 changes: 2 additions & 0 deletions th03/exit.cpp
@@ -0,0 +1,2 @@
#pragma option -zCSHARED
#include "th02/core/exit.cpp"
6 changes: 3 additions & 3 deletions th03/formats/cfg.hpp
Expand Up @@ -13,7 +13,7 @@
// Loads the [resident] pointer from the .CFG file, initializes the rest of
// the structure (in TH03 and TH04), and clamps the life, bomb, and BGM/SE
// mode fields to their respective ranges (in TH04 and TH05).
void near pascal cfg_load(void);
void near cfg_load(void);

// Loads just the [resident] pointer from the .CFG file, and returns its new
// value.
Expand All @@ -32,7 +32,7 @@ static inline resident_t __seg* cfg_load_and_set_resident(
}

// Saves the .CFG file, without changing its resident segment pointer.
void near pascal cfg_save(void);
void near cfg_save(void);

// Like cfg_save(), but resets the resident segment pointer to zero.
void near pascal cfg_save_exit(void);
void near cfg_save_exit(void);
10 changes: 5 additions & 5 deletions th03/op_01.cpp
Expand Up @@ -3,7 +3,6 @@
* Code segment #1 of TH03's OP.EXE
*/

extern "C" {
#include <stddef.h>
#include "platform.h"
#include "master.hpp"
Expand All @@ -12,7 +11,9 @@ extern "C" {
#include "th03/score.h"
#include "th03/resident.hpp"
#include "th03/formats/cfg.hpp"
extern "C" {
#include "th03/snd/snd.h"
}

bool snd_sel_disabled = false; // Yes, it's just (!snd_fm_possible).

Expand All @@ -26,7 +27,7 @@ bool snd_sel_disabled = false; // Yes, it's just (!snd_fm_possible).
#undef CFG_FN
extern const char CFG_FN[];

void near pascal cfg_load(void)
void near cfg_load(void)
{
cfg_t cfg;

Expand Down Expand Up @@ -58,18 +59,17 @@ inline void cfg_save_bytes(cfg_t &cfg, size_t bytes) {
file_close();
}

void near pascal cfg_save(void)
void near cfg_save(void)
{
cfg_t cfg;
cfg_save_bytes(cfg, 4); // MODDERS: Should be `sizeof(cfg.opts)`
}

void near pascal cfg_save_exit(void)
void near cfg_save_exit(void)
{
cfg_t cfg = { 0 };
cfg_save_bytes(cfg, sizeof(cfg));
}
/// ---------------------------

void pascal near start_demo();
}
4 changes: 2 additions & 2 deletions th03/start.asm
Expand Up @@ -55,10 +55,10 @@ start_demo proc near
cmp si, (PLAYER_COUNT * SCORE_DIGITS)
jl short @@score_loop
call palette_black_out pascal, 1
call cfg_save
call @cfg_save$qv
call gaiji_restore
kajacall KAJA_SONG_STOP
call _game_exit
call @game_exit$qv
call _execl c, offset path, ds, offset path, ds, large 0
pop si
pop bp
Expand Down
6 changes: 3 additions & 3 deletions th03_main.asm
Expand Up @@ -2385,7 +2385,7 @@ public @GameExecl$qnxc
call gaiji_restore
call @mrs_free$qi pascal, 0
call @mrs_free$qi pascal, 1
call _game_exit
call @game_exit$qv
call _execl c, large [bp+@@binary_fn], large [bp+@@binary_fn], large 0
pop bp
retf 4
Expand Down Expand Up @@ -8727,7 +8727,7 @@ SHARED segment word public 'CODE' use16
extern _snd_determine_mode:proc
extern VECTOR2:proc
extern VECTOR2_BETWEEN_PLUS:proc
extern _game_exit:proc
extern @game_exit$qv:proc
extern @polar$qiii:proc
extern FRAME_DELAY:proc
extern _input_reset_sense_key_held:proc
Expand Down Expand Up @@ -18911,7 +18911,7 @@ loc_14C36:
mov byte ptr [bx], 2
cmp di, 2
jge short loc_14C4E
mov byte ptr [bx+1Eh], 0B0h ; ''
mov byte ptr [bx+1Eh], 0B0h ; '°'
jmp short loc_14C56
; ---------------------------------------------------------------------------

Expand Down
12 changes: 6 additions & 6 deletions th03_mainl.asm
Expand Up @@ -897,7 +897,7 @@ loc_9DAD:
call sub_B7D2
call text_clear
call gaiji_restore
call _game_exit
call @game_exit$qv
pushd 0
push ds
push offset path ; "op"
Expand Down Expand Up @@ -1002,7 +1002,7 @@ loc_9EF1:
call gaiji_restore

loc_9F1E:
call _game_exit_from_mainl_to_main
call @game_exit_from_mainl_to_main$qv
pushd 0
push ds
push offset aMain ; "main"
Expand Down Expand Up @@ -1034,7 +1034,7 @@ loc_9F58:
loc_9F69:
call text_clear
call gaiji_restore
call _game_exit
call @game_exit$qv
pushd 0
push ds
push offset path ; "op"
Expand Down Expand Up @@ -1503,7 +1503,7 @@ loc_B9DD:
loc_BA66:
call text_clear
call gaiji_restore
call _game_exit
call @game_exit$qv
pushd 0
push ds
push offset aOp_0 ; "op"
Expand Down Expand Up @@ -2796,7 +2796,7 @@ SHARED segment word public 'CODE' use16
extern _snd_delay_until_volume:proc
extern _snd_load:proc
extern VECTOR2:proc
extern _game_exit:proc
extern @game_exit$qv:proc
extern CDG_PUT_8:proc
extern CDG_PUT_HFLIP_8:proc
extern FRAME_DELAY:proc
Expand All @@ -2811,7 +2811,7 @@ SHARED segment word public 'CODE' use16
extern CDG_LOAD_ALL_NOALPHA:proc
extern CDG_LOAD_ALL:proc
extern CDG_FREE:proc
extern _game_exit_from_mainl_to_main:proc
extern @game_exit_from_mainl_to_main$qv:proc
extern GRAPH_PUTSA_FX:proc
extern SND_DELAY_UNTIL_MEASURE:proc
extern PI_LOAD:proc
Expand Down

0 comments on commit 757ee71

Please sign in to comment.