mirror of https://github.com/nmlgc/ReC98.git
[Maintenance] [th01] Compile all remaining C code as C++
And all that it needed was a few ellipses. Part of P0212, funded by GhostRiderCog, Lmocinemod, and LeyDud.
This commit is contained in:
parent
d398a949fc
commit
e97a869e90
|
@ -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);
|
|
@ -1 +0,0 @@
|
|||
#include "th01/hardware/frmdelay.c"
|
|
@ -0,0 +1 @@
|
|||
#include "th01/hardware/frmdelay.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"
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
#include "th01/hardware/grppffx.c"
|
|
@ -0,0 +1 @@
|
|||
#include "th01/hardware/grppffx.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)
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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, ...
|
|
@ -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);
|
||||
}
|
|
@ -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<dots8_t __seg *>(SEG_PLANE_B);
|
||||
VRAM_PLANE_R = reinterpret_cast<dots8_t __seg *>(SEG_PLANE_R);
|
||||
VRAM_PLANE_G = reinterpret_cast<dots8_t __seg *>(SEG_PLANE_G);
|
||||
VRAM_PLANE_E = reinterpret_cast<dots8_t __seg *>(SEG_PLANE_E);
|
||||
}
|
|
@ -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();
|
|
@ -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<uint8_t *>(MK_FP(SEG_TRAM_JIS, offset));
|
||||
}
|
||||
|
||||
inline uint16_t* tram_atrb(uint16_t offset) {
|
||||
return reinterpret_cast<uint16_t *>(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<uint8_t>(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<int16_t *>(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<int16_t *>(tram_jis(p))[0] = *reinterpret_cast<
|
||||
const uint8_t *
|
||||
>(str++);
|
||||
tram_atrb(p)[0] = hw_atrb;
|
||||
}
|
||||
p += 2;
|
||||
if(++x >= text_width()) {
|
|
@ -1 +0,0 @@
|
|||
#include "th01/core/initexit.c"
|
|
@ -0,0 +1 @@
|
|||
#include "th01/core/initexit.cpp"
|
|
@ -1 +0,0 @@
|
|||
#include "th01/hardware/vplanset.c"
|
|
@ -0,0 +1 @@
|
|||
#include "th01/hardware/vplanset.cpp"
|
|
@ -1 +0,0 @@
|
|||
#include "th01/hardware/vsync.c"
|
|
@ -0,0 +1 @@
|
|||
#include "th01/hardware/vsync.cpp"
|
|
@ -1 +0,0 @@
|
|||
#include "th01/hardware/ztext.c"
|
|
@ -0,0 +1 @@
|
|||
#include "th01/hardware/ztext.cpp"
|
|
@ -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
|
||||
|
||||
; ===========================================================================
|
||||
|
|
14
th01_op.asm
14
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
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
|
|
|
@ -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
|
||||
|
||||
; ===========================================================================
|
||||
|
|
Loading…
Reference in New Issue