diff --git a/th01/core/initexit.c b/th01/core/initexit.cpp similarity index 78% rename from th01/core/initexit.c rename to th01/core/initexit.cpp index b3b8a654..517581ef 100644 --- a/th01/core/initexit.c +++ b/th01/core/initexit.cpp @@ -6,19 +6,22 @@ #include "pc98.h" #include "planar.h" #include "master.hpp" +extern "C" { #include "th01/hardware/graph.h" #include "th01/hardware/palette.h" #include "th01/hardware/vplanset.h" -#include "th01/hardware/vsync.h" -#include "th01/hardware/ztext.h" +} +#include "th01/hardware/vsync.hpp" +#include "th01/hardware/ztext.hpp" +#include "th01/core/initexit.hpp" extern bool game_initialized; -extern void interrupt(* int06_old)(); +extern void interrupt (* int06_old)(...); -void interrupt int06_game_exit(); +void interrupt int06_game_exit(...); void game_exit_inner(void); -void interrupt int06_nop() +void interrupt int06_nop(...) { } @@ -44,7 +47,7 @@ void game_exit(void) if(game_initialized != true) { return; } - game_initialized = 0; + game_initialized = false; game_exit_inner(); respal_free(); } @@ -59,12 +62,12 @@ void game_switch_binary(void) z_text_setcursor(CURSOR_HIDE); z_text_clear(); z_text_show(); - game_initialized = 0; + game_initialized = false; } void game_exit_inner(void) { - game_initialized = 0; + game_initialized = false; setvect(6, int06_nop); vsync_exit(); z_text_clear(); @@ -74,7 +77,7 @@ void game_exit_inner(void) setvect(6, int06_old); } -void interrupt int06_game_exit() +void interrupt int06_game_exit(...) { game_exit(); exit(0); diff --git a/th01/core/initexit.h b/th01/core/initexit.hpp similarity index 100% rename from th01/core/initexit.h rename to th01/core/initexit.hpp diff --git a/th01/frmdelay.c b/th01/frmdelay.c deleted file mode 100644 index 2d471485..00000000 --- a/th01/frmdelay.c +++ /dev/null @@ -1 +0,0 @@ -#include "th01/hardware/frmdelay.c" diff --git a/th01/frmdelay.cpp b/th01/frmdelay.cpp new file mode 100644 index 00000000..49dc40ac --- /dev/null +++ b/th01/frmdelay.cpp @@ -0,0 +1 @@ +#include "th01/hardware/frmdelay.cpp" diff --git a/th01/fuuin_04.cpp b/th01/fuuin_04.cpp index 332f67bc..3109dbb1 100644 --- a/th01/fuuin_04.cpp +++ b/th01/fuuin_04.cpp @@ -12,8 +12,8 @@ extern "C" { #include "th01/hardware/graph.h" #include "th01/hardware/palette.h" -#include "th01/hardware/vsync.h" } +#include "th01/hardware/vsync.hpp" #include "th01/formats/grp.h" #include "th01/end/type.hpp" diff --git a/th01/grppffx.c b/th01/grppffx.c deleted file mode 100644 index c9753f1b..00000000 --- a/th01/grppffx.c +++ /dev/null @@ -1 +0,0 @@ -#include "th01/hardware/grppffx.c" diff --git a/th01/grppffx.cpp b/th01/grppffx.cpp new file mode 100644 index 00000000..08f68df9 --- /dev/null +++ b/th01/grppffx.cpp @@ -0,0 +1 @@ +#include "th01/hardware/grppffx.cpp" diff --git a/th01/hardware/frmdelay.c b/th01/hardware/frmdelay.cpp similarity index 81% rename from th01/hardware/frmdelay.c rename to th01/hardware/frmdelay.cpp index 3c76440d..4fada9cc 100644 --- a/th01/hardware/frmdelay.c +++ b/th01/hardware/frmdelay.cpp @@ -1,5 +1,7 @@ -#include "th01/hardware/vsync.h" +#include "th01/hardware/vsync.hpp" +extern "C" { #include "th01/hardware/frmdelay.h" +} #define z_vsync_reset1() (vsync_frame = 0) // #define z_vsync_reset2() (vsync_unused = 0) diff --git a/th01/hardware/graph.cpp b/th01/hardware/graph.cpp index 1ae51d78..ac6c2e61 100644 --- a/th01/hardware/graph.cpp +++ b/th01/hardware/graph.cpp @@ -9,8 +9,8 @@ #include "th01/v_colors.hpp" #include "th01/math/clamp.hpp" #include "th01/hardware/egc.h" +#include "th01/hardware/vsync.hpp" extern "C" { -#include "th01/hardware/vsync.h" #include "th01/hardware/graph.h" #include "th01/hardware/palette.h" diff --git a/th01/hardware/grppffx.c b/th01/hardware/grppffx.cpp similarity index 86% rename from th01/hardware/grppffx.c rename to th01/hardware/grppffx.cpp index d852519f..6fd5e161 100644 --- a/th01/hardware/grppffx.c +++ b/th01/hardware/grppffx.cpp @@ -3,7 +3,9 @@ #include "platform.h" #include "pc98.h" #include "planar.h" -#include "th01/hardware/graph.h" +extern "C" { +#include "th01/hardware/grppsafx.h" +} void graph_printf_fx( screen_x_t left, vram_y_t top, int16_t col_and_fx, const char *fmt, ... diff --git a/th01/hardware/vplanset.c b/th01/hardware/vplanset.c deleted file mode 100644 index 4be2d7f9..00000000 --- a/th01/hardware/vplanset.c +++ /dev/null @@ -1,14 +0,0 @@ -#pragma option -zCSHARED - -#include "platform.h" -#include "pc98.h" -#include "planar.h" -#include "th01/hardware/vplanset.h" - -void vram_planes_set(void) -{ - VRAM_PLANE_B = (dots8_t __seg *)(SEG_PLANE_B); - VRAM_PLANE_R = (dots8_t __seg *)(SEG_PLANE_R); - VRAM_PLANE_G = (dots8_t __seg *)(SEG_PLANE_G); - VRAM_PLANE_E = (dots8_t __seg *)(SEG_PLANE_E); -} diff --git a/th01/hardware/vplanset.cpp b/th01/hardware/vplanset.cpp new file mode 100644 index 00000000..2c93d2c3 --- /dev/null +++ b/th01/hardware/vplanset.cpp @@ -0,0 +1,16 @@ +#pragma option -zCSHARED + +#include "platform.h" +#include "pc98.h" +#include "planar.h" +extern "C" { +#include "th01/hardware/vplanset.h" +} + +void vram_planes_set(void) +{ + VRAM_PLANE_B = reinterpret_cast(SEG_PLANE_B); + VRAM_PLANE_R = reinterpret_cast(SEG_PLANE_R); + VRAM_PLANE_G = reinterpret_cast(SEG_PLANE_G); + VRAM_PLANE_E = reinterpret_cast(SEG_PLANE_E); +} diff --git a/th01/hardware/vsync.c b/th01/hardware/vsync.cpp similarity index 78% rename from th01/hardware/vsync.c rename to th01/hardware/vsync.cpp index 1be73b53..3ea89f00 100644 --- a/th01/hardware/vsync.c +++ b/th01/hardware/vsync.cpp @@ -9,19 +9,19 @@ #include "platform.h" #include "x86real.h" #include "pc98.h" -#include "th01/hardware/vsync.h" +#include "th01/hardware/vsync.hpp" -extern char vsync_initialized; +extern bool vsync_initialized; extern int vsync_callback_is_set; extern pixel_t RES_X_HALF; extern pixel_t RES_Y_HALF; extern int vsync_unused; -extern void interrupt (*vsync_callback_old)(void); +extern void interrupt (*vsync_callback_old)(...); extern void (*vsync_callback)(void); -static void interrupt vsync_intfunc(void) +static void interrupt vsync_intfunc(...) { pixel_t res_x_half = RES_X_HALF; pixel_t res_y_half = RES_Y_HALF; @@ -36,14 +36,14 @@ static void interrupt vsync_intfunc(void) void vsync_init(void) { - if(vsync_initialized == 0) { - vsync_initialized = 1; + if(vsync_initialized == false) { + vsync_initialized = true; disable(); vsync_callback_old = getvect(0x0A); setvect(0x0A, vsync_intfunc); // Disable all interrupts from 0x08 to 0x0F except for 0x0A - outportb(0x02, inportb(0x02) & 0xFB); + outportb(0x02, (inportb(0x02) & 0xFB)); outportb(0x64, 0); // VSync interrupt trigger enable(); @@ -52,12 +52,12 @@ void vsync_init(void) void vsync_exit(void) { - if(vsync_initialized == 1) { - vsync_initialized = 0; + if(vsync_initialized == true) { + vsync_initialized = false; disable(); // Reenable all interrupts from 0x08 to 0x0F except for 0x0A - outportb(0x02, inportb(0x02) | 0x04); + outportb(0x02, (inportb(0x02) | 0x04)); setvect(0x0a, vsync_callback_old); enable(); diff --git a/th01/hardware/vsync.h b/th01/hardware/vsync.hpp similarity index 100% rename from th01/hardware/vsync.h rename to th01/hardware/vsync.hpp diff --git a/th01/hardware/ztext.c b/th01/hardware/ztext.cpp similarity index 71% rename from th01/hardware/ztext.c rename to th01/hardware/ztext.cpp index 61b26a24..7fc5ccf7 100644 --- a/th01/hardware/ztext.c +++ b/th01/hardware/ztext.cpp @@ -14,7 +14,7 @@ #include "x86real.h" #include "pc98.h" #include "master.hpp" -#include "th01/hardware/ztext.h" +#include "th01/hardware/ztext.hpp" extern char txesc_25line[]; extern char txesc_20line[]; @@ -87,7 +87,7 @@ void z_text_setcursor(z_text_cursor_t type) { _BX = peekb2(0, 0x53B); // Text mode line height outportb(0x62, 0x4B); // CSRFORM - outportb(0x60, _BL | 0x80); + outportb(0x60, (_BL | 0x80)); switch(type) { case CURSOR_HIDE: outportb(0x60, 0x9F); @@ -96,10 +96,10 @@ void z_text_setcursor(z_text_cursor_t type) outportb(0x60, 0x80); break; case CURSOR_UNDERLINE: - outportb(0x60, _BL + 0x7D); + outportb(0x60, (_BL + 0x7D)); break; } - outportb(0x60, (_BL << 3) + 2); + outportb(0x60, ((_BL << 3) + 2)); } void z_text_locate(char x, char y) @@ -112,15 +112,20 @@ void z_text_locate(char x, char y) int86(0xDC, ®s, ®s); } +inline uint8_t* tram_jis(uint16_t offset) { + return reinterpret_cast(MK_FP(SEG_TRAM_JIS, offset)); +} + +inline uint16_t* tram_atrb(uint16_t offset) { + return reinterpret_cast(MK_FP(SEG_TRAM_ATRB, offset)); +} + void z_text_putsa(tram_x_t x, tram_y_t y, int z_atrb, const char *str) { uint16_t codepoint; - int p = ((y * text_width()) + x) * 2; + int p = (((y * text_width()) + x) * 2); int hw_atrb = 1; - #define tx_chars(byte) ((char*)MK_FP(0xA000, p + byte)) - #define tx_atrbs(byte) ((int16_t*)MK_FP(0xA200, p + byte)) - if(z_atrb & Z_ATRB_BLUE) { hw_atrb += 0x20; } @@ -142,34 +147,36 @@ void z_text_putsa(tram_x_t x, tram_y_t y, int z_atrb, const char *str) if(z_atrb & Z_ATRB_BLINK) { hw_atrb += TX_BLINK; } - hw_atrb += hw_atrb << 8; + hw_atrb += (hw_atrb << 8); while(str[0]) { if(_ismbblead(str[0])) { codepoint = _mbcjmstojis( - (str[0] << 8) + (unsigned char)str[1] + (str[0] << 8) + static_cast(str[1]) ); str += 2; - if(codepoint >= 0x2921 && codepoint <= 0x2B7E) { - *tx_chars(0) = ((codepoint >> 8) + 0xE0) | 0x80; - *tx_chars(1) = codepoint; - *tx_atrbs(0) = hw_atrb; - } else if(x == text_width() - 1) { - *(int16_t*)tx_chars(0) = ' '; - *tx_atrbs(0) = hw_atrb; + if((codepoint >= 0x2921) && (codepoint <= 0x2B7E)) { + tram_jis(p)[0] = (((codepoint >> 8) + 0xE0) | 0x80); + tram_jis(p)[1] = codepoint; + tram_atrb(p)[0] = hw_atrb; + } else if(x == (text_width() - 1)) { + reinterpret_cast(tram_jis(p))[0] = ' '; + tram_atrb(p)[0] = hw_atrb; } else { - *tx_chars(0) = (codepoint >> 8) + 0xE0; - *tx_chars(1) = codepoint; - *tx_chars(2) = ((codepoint >> 8) + 0xE0) | 0x80; - *tx_chars(3) = codepoint; + tram_jis(p)[0] = ((codepoint >> 8) + 0xE0); + tram_jis(p)[1] = codepoint; + tram_jis(p)[2] = (((codepoint >> 8) + 0xE0) | 0x80); + tram_jis(p)[3] = codepoint; - *tx_atrbs(0) = hw_atrb; - *tx_atrbs(2) = hw_atrb; + tram_atrb(p)[0] = hw_atrb; + tram_atrb(p)[1] = hw_atrb; p += 2; x++; } } else { - *(int16_t*)tx_chars(0) = *(unsigned char*)(str++); - *tx_atrbs(0) = hw_atrb; + reinterpret_cast(tram_jis(p))[0] = *reinterpret_cast< + const uint8_t * + >(str++); + tram_atrb(p)[0] = hw_atrb; } p += 2; if(++x >= text_width()) { diff --git a/th01/hardware/ztext.h b/th01/hardware/ztext.hpp similarity index 100% rename from th01/hardware/ztext.h rename to th01/hardware/ztext.hpp diff --git a/th01/initexit.c b/th01/initexit.c deleted file mode 100644 index 0cd3cdf5..00000000 --- a/th01/initexit.c +++ /dev/null @@ -1 +0,0 @@ -#include "th01/core/initexit.c" diff --git a/th01/initexit.cpp b/th01/initexit.cpp new file mode 100644 index 00000000..5404f3b2 --- /dev/null +++ b/th01/initexit.cpp @@ -0,0 +1 @@ +#include "th01/core/initexit.cpp" diff --git a/th01/vplanset.c b/th01/vplanset.c deleted file mode 100644 index 5416832d..00000000 --- a/th01/vplanset.c +++ /dev/null @@ -1 +0,0 @@ -#include "th01/hardware/vplanset.c" diff --git a/th01/vplanset.cpp b/th01/vplanset.cpp new file mode 100644 index 00000000..c7208ca0 --- /dev/null +++ b/th01/vplanset.cpp @@ -0,0 +1 @@ +#include "th01/hardware/vplanset.cpp" diff --git a/th01/vsync.c b/th01/vsync.c deleted file mode 100644 index d0693f25..00000000 --- a/th01/vsync.c +++ /dev/null @@ -1 +0,0 @@ -#include "th01/hardware/vsync.c" diff --git a/th01/vsync.cpp b/th01/vsync.cpp new file mode 100644 index 00000000..d2c6fed6 --- /dev/null +++ b/th01/vsync.cpp @@ -0,0 +1 @@ +#include "th01/hardware/vsync.cpp" diff --git a/th01/ztext.c b/th01/ztext.c deleted file mode 100644 index 1e5c96ca..00000000 --- a/th01/ztext.c +++ /dev/null @@ -1 +0,0 @@ -#include "th01/hardware/ztext.c" diff --git a/th01/ztext.cpp b/th01/ztext.cpp new file mode 100644 index 00000000..6fe8401c --- /dev/null +++ b/th01/ztext.cpp @@ -0,0 +1 @@ +#include "th01/hardware/ztext.cpp" diff --git a/th01_fuuin.asm b/th01_fuuin.asm index 215b04d5..ad9e0e37 100644 --- a/th01_fuuin.asm +++ b/th01_fuuin.asm @@ -123,9 +123,9 @@ loc_A139: loc_A13E: call _mdrv2_check_board - call _game_init + call @game_init$qv call @end_and_verdict_and_regist_anima$qv - call _game_switch_binary + call @game_switch_binary$qv push 0 push 0 push ds @@ -173,8 +173,8 @@ ztext_TEXT ends ; Segment type: Pure code initexit_TEXT segment byte public 'CODE' use16 - extern _game_init:proc - extern _game_switch_binary:proc + extern @game_init$qv:proc + extern @game_switch_binary$qv:proc initexit_TEXT ends ; =========================================================================== diff --git a/th01_op.asm b/th01_op.asm index 18306dda..0741c8e2 100644 --- a/th01_op.asm +++ b/th01_op.asm @@ -165,7 +165,7 @@ sub_A7B5 proc far call _resident_stuff_set c, word ptr _opts.O_rank, word ptr _opts.O_bgm_mode, word ptr _opts.O_bombs, word ptr _opts.O_lives_extra, large [_rand] call sub_A79D call _mdrv2_bgm_fade_out_nonblock - call _game_switch_binary + call @game_switch_binary$qv mov al, _mode cbw cmp ax, 2 @@ -258,7 +258,7 @@ sub_A8AD proc far loc_A8E1: call sub_A79D call _mdrv2_bgm_fade_out_nonblock - call _game_switch_binary + call @game_switch_binary$qv les bx, _resident assume es:nothing mov es:[bx+reiidenconfig_t.debug_mode], DM_OFF @@ -1163,7 +1163,7 @@ loc_B06F: loc_B0D6: call _mdrv2_check_board - call _game_init + call @game_init$qv call _cfg_load mov al, _opts.O_bgm_mode cbw @@ -1320,7 +1320,7 @@ loc_B21A: call _graph_accesspage_func pop cx call _z_graph_clear - call _game_exit + call @game_exit$qv call _mdrv2_bgm_stop push ds push offset format ; "おつかれさまでした!!\n" @@ -1357,9 +1357,9 @@ ztext_TEXT ends ; Segment type: Pure code initexit_TEXT segment byte public 'CODE' use16 - extern _game_init:proc - extern _game_exit:proc - extern _game_switch_binary:proc + extern @game_init$qv:proc + extern @game_exit$qv:proc + extern @game_switch_binary$qv:proc initexit_TEXT ends ; --------------------------------------------------------------------------- diff --git a/th01_reiiden.asm b/th01_reiiden.asm index 8d1c2062..9c6d7be0 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -547,7 +547,7 @@ loc_CD70: jnz short loc_CDA2 les bx, _resident mov es:[bx+reiidenconfig_t.snd_need_init], 0 - call _game_switch_binary + call @game_switch_binary$qv les bx, _resident mov es:[bx+reiidenconfig_t.p_value], 0 pushd 0 @@ -1530,7 +1530,7 @@ loc_D583: mov word_34A8A, ax mov eax, _frame_rand mov random_seed, eax - call _game_init + call @game_init$qv call key_start push 3F003Fh call __control87 @@ -2324,7 +2324,7 @@ loc_DE47: push 78h ; 'x' call _frame_delay pop cx - call _game_switch_binary + call @game_switch_binary$qv pushd 0 push ds push offset aFuuin ; "fuuin" @@ -2425,7 +2425,7 @@ loc_DF52: les bx, _resident mov al, _bombs mov es:[bx+reiidenconfig_t.bombs], al - call _game_switch_binary + call @game_switch_binary$qv pushd 0 push ds push offset aReiiden ; "reiiden" @@ -2644,7 +2644,7 @@ loc_E2A8: loc_E2CB: call sub_D487 call sub_D4DD - call _game_switch_binary + call @game_switch_binary$qv call key_end call arc_free pushd 0 @@ -2724,8 +2724,8 @@ ztext_TEXT ends ; Segment type: Pure code initexit_TEXT segment byte public 'CODE' use16 - extern _game_init:proc - extern _game_switch_binary:proc + extern @game_init$qv:proc + extern @game_switch_binary$qv:proc initexit_TEXT ends ; ===========================================================================