Skip to content

Commit

Permalink
[Separate translation units] [th02/th03/th05] game_init_op()
Browse files Browse the repository at this point in the history
Completes P0133, funded by [Anonymous].
  • Loading branch information
nmlgc committed Jan 31, 2021
1 parent e8588b1 commit 1d5db71
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 23 deletions.
6 changes: 3 additions & 3 deletions Makefile.mak
Expand Up @@ -78,7 +78,7 @@ bin\th02\zun_res.com: th02\zun_res1.c th02\zun_res2.c th02\zun_res3.c
$**
| masters.lib

bin\th02\op.exe: th02\op_01.cpp bin\exit_dos.obj bin\th02\zunerror.obj bin\th02\grppsafx.obj bin\th02\op.obj th02\op_02_1.cpp bin\th02\pi_load.obj bin\th02\grp_rect.obj bin\frmdely2.obj th02\op_02_2.cpp bin\th02\exit.obj bin\th02\snd_mmdr.obj bin\th02\snd_mode.obj bin\th02\snd_pmdr.obj bin\th02\snd_load.obj bin\th02\pi_put.obj bin\th02\snd_kaja.obj th02\op_02_3.cpp bin\th02\snd_se.obj bin\frmdely1.obj th02\op_03.cpp th02\op_04.cpp th02\op_05.cpp th02\op_06.cpp
bin\th02\op.exe: th02\op_01.cpp bin\exit_dos.obj bin\th02\zunerror.obj bin\th02\grppsafx.obj bin\th02\op.obj th02\op_02_1.cpp bin\th02\pi_load.obj bin\th02\grp_rect.obj bin\frmdely2.obj th02\op_02_2.cpp bin\th02\initop.obj bin\th02\exit.obj bin\th02\snd_mmdr.obj bin\th02\snd_mode.obj bin\th02\snd_pmdr.obj bin\th02\snd_load.obj bin\th02\pi_put.obj bin\th02\snd_kaja.obj th02\op_02_3.cpp bin\th02\snd_se.obj bin\frmdely1.obj th02\op_03.cpp th02\op_04.cpp th02\op_05.cpp th02\op_06.cpp
$(CC) $(CFLAGS) -ml -Z -DGAME=2 -nbin\th02\ -eOP.EXE @&&|
$**
|
Expand All @@ -101,7 +101,7 @@ bin\th03\res_yume.com: th03\res_yume.cpp
$**
| masters.lib

bin\th03\op.exe: th03\op_01.cpp bin\th03\op.obj bin\th03\cdg_load.obj bin\th03\grppsafx.obj bin\th03\pi_load.obj bin\th03\inp_m_w.obj bin\th03\cdg_p_na.obj bin\hfliplut.obj bin\frmdely2.obj
bin\th03\op.exe: th03\op_01.cpp bin\th03\op.obj bin\th03\initop.obj bin\th03\cdg_load.obj bin\th03\grppsafx.obj bin\th03\pi_load.obj bin\th03\inp_m_w.obj bin\th03\cdg_p_na.obj bin\hfliplut.obj bin\frmdely2.obj
$(CC) $(CFLAGS) -ml -3 -Z -DGAME=3 -nbin\th03\ -eOP.EXE @&&|
$**
|
Expand Down Expand Up @@ -150,7 +150,7 @@ bin\th05\res_kso.com: th05\res_kso.cpp
$**
| masters.lib

bin\th05\op.exe: th05\op010.cpp bin\th05\op.obj th05\op011.cpp th05\m_char.cpp bin\th05\input_s.obj bin\th05\inp_h_w.obj bin\th05\snd_dlym.obj th05\cdg_p_nc.cpp bin\th05\frmdelay.obj bin\th04\cdg_load.obj bin\th05\egcrect.obj bin\hfliplut.obj
bin\th05\op.exe: th05\op010.cpp bin\th05\op.obj th05\op011.cpp th05\m_char.cpp bin\th05\initop.obj bin\th05\input_s.obj bin\th05\inp_h_w.obj bin\th05\snd_dlym.obj th05\cdg_p_nc.cpp bin\th05\frmdelay.obj bin\th04\cdg_load.obj bin\th05\egcrect.obj bin\hfliplut.obj
$(CC) $(CFLAGS) -ml -DGAME=5 -DBINARY='O' -3 -Z -nbin\th05\ -eOP.EXE @&&|
$**
|
Expand Down
20 changes: 12 additions & 8 deletions th02/core/initop.cpp
@@ -1,18 +1,20 @@
#pragma codeseg SHARED

extern "C" {
#include <dos.h>
#include "master.hpp"
#include "th01/hardware/vplanset.h"
#include "th02/mem.h"
#include "th02/core/initexit.h"
#include "th02/formats/pf.hpp"

const char pf_fn[] = PF_FN;

int game_init_op(void)
{
#if GAME >= 4
# define PARAS (mem_assign_paras)
#else
# define PARAS (MEM_ASSIGN_PARAS_OP)
#endif
if(mem_assign_dos(PARAS)) {
if(mem_assign_dos(MEM_ASSIGN_PARAS_OP)) {
return 1;
}
#undef PARAS

vram_planes_set();
graph_start();
graph_clear_both();
Expand All @@ -24,3 +26,5 @@ int game_init_op(void)
game_pfopen();
return 0;
}

}
1 change: 1 addition & 0 deletions th02/initop.cpp
@@ -0,0 +1 @@
#include "th02/core/initop.cpp"
10 changes: 0 additions & 10 deletions th02/op_02_2.cpp
Expand Up @@ -8,17 +8,7 @@

extern "C" {
#include "platform.h"
#include "master.hpp"
#include "th02/mem.h"
#include "th02/core/initexit.h"
#include "th02/formats/pf.hpp"
#include "th02/hardware/frmdelay.h"
#include "th02/hardware/input.hpp"

const char pf_fn[] = PF_FN;
#include "th02/snd/data.c"
#include "th02/snd/se_data.c"

#include "th02/hardware/input.c"
#include "th02/core/initop.cpp"
}
4 changes: 4 additions & 0 deletions th02/op_02_3.cpp
Expand Up @@ -7,5 +7,9 @@
// common set of library functions *and* obviously copy-pasted and separately
// compiled versions of some of these functions?

#include "platform.h"
#include "th02/snd/data.c"
#include "th02/snd/se_data.c"

#define frame_delay frame_delay_2
#include "th02/snd_dlym.cpp"
46 changes: 46 additions & 0 deletions th03/core/initop.cpp
@@ -0,0 +1,46 @@
#pragma option -3

extern "C" {
#include <stddef.h>
#include <dos.h>
#include "master.hpp"
#include "th01/hardware/vplanset.h"
#include "th03/core/initexit.h"

#if (GAME <= 3)
#include "th03/mem.h"
#define mem_assign_paras MEM_ASSIGN_PARAS_OP
#endif

int game_init_op(const unsigned char *pf_fn)
{
if(mem_assign_dos(mem_assign_paras)) {
return 1;
}
#if (GAME <= 4)
vram_planes_set();
#endif
graph_start();
graph_clear_both();
#if (GAME >= 4)
pfsetbufsiz(8192);
#endif
vsync_start();
key_beep_off();
text_systemline_hide();
text_cursor_hide();
egc_start();
js_start();

#if (GAME >= 4)
if(pf_fn[0]) {
pfstart(pf_fn);
}
bgm_init(1024);
#else
pfstart(pf_fn);
#endif
return 0;
}

}
2 changes: 2 additions & 0 deletions th03/initop.cpp
@@ -0,0 +1,2 @@
#pragma codeseg SHARED
#include "th03/core/initop.cpp"
2 changes: 1 addition & 1 deletion th03_op.asm
Expand Up @@ -3627,7 +3627,7 @@ include th03/hardware/input_sense.asm
include th02/formats/pi_palette_apply.asm
include th02/formats/pi_put.asm
include th02/snd/kajaint.asm
include th02/initop.asm
extern _game_init_op:proc
extern CDG_LOAD_SINGLE:proc
extern CDG_LOAD_SINGLE_NOALPHA:proc
extern CDG_LOAD_ALL_NOALPHA:proc
Expand Down
2 changes: 2 additions & 0 deletions th05/initop.cpp
@@ -0,0 +1,2 @@
#pragma codeseg SHARED_
#include "th03/core/initop.cpp"
2 changes: 1 addition & 1 deletion th05_op.asm
Expand Up @@ -2548,7 +2548,7 @@ include th05/formats/pi_load.asm
include th05/formats/pi_put.asm
include th05/formats/pi_palette_apply.asm
include th05/formats/pi_free.asm
include th02/initop.asm
extern _game_init_op:proc
extern _input_reset_sense_held:proc
extern INPUT_WAIT_FOR_CHANGE:proc
extern SND_DELAY_UNTIL_MEASURE:proc
Expand Down

0 comments on commit 1d5db71

Please sign in to comment.