ref: 07792d58306205cc7cac1ad5d60b05fde42a79d7
parent: b9d9d339f831672710235330064902317a35e838
author: Jacob Moody <moody@posixcafe.org>
date: Fri Dec 8 00:40:53 EST 2023
delete the C++
--- a/src/ArmsItem.cpp
+++ b/src/ArmsItem.cpp
@@ -8,7 +8,6 @@
#include "ArmsItem.h"
#include <string.h>
-#include <string>
#include "WindowsWrapper.h"
@@ -422,7 +421,7 @@
int CampLoop(void)
{
- std::string old_script_path;
+ char *old_script_path;
RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
@@ -506,7 +505,7 @@
}
// Resume original script
- LoadTextScript_Stage(old_script_path.c_str());
+ LoadTextScript_Stage(old_script_path);
gArmsEnergyX = 32; // Displays weapon rotation animation in case the weapon was changed
return enum_ESCRETURN_continue; // Go to game
}
--- a/src/Back.cpp
+++ b/src/Back.cpp
@@ -9,7 +9,6 @@
#include <stddef.h>
#include <stdio.h>
-#include <string>
#include "WindowsWrapper.h"
@@ -25,15 +24,15 @@
// TODO - Another function that has an incorrect stack frame
BOOL InitBack(const char *fName, int type)
{
- std::string path;
+ char path[256];
FILE *fp;
color_black = GetCortBoxColor(RGB(0, 0, 0x10)); // Unused. This may have once been used by background type 4 (the solid black background)
// We're not actually loading the bitmap here - we're just reading its width/height and making sure it's really a BMP file
- path = gDataPath + '/' + fName + ".pbm";
+ snprint(path, sizeof path, "%s/%s.pbm", gDataPath, fName);
- fp = fopen(path.c_str(), "rb");
+ fp = fopen(path, "rb");
if (fp == NULL)
return FALSE;
--- a/src/Backends/Audio.h
+++ b/src/Backends/Audio.h
@@ -7,13 +7,13 @@
typedef struct AudioBackend_Sound AudioBackend_Sound;
-bool AudioBackend_Init(void);
+int AudioBackend_Init(void);
void AudioBackend_Deinit(void);
AudioBackend_Sound* AudioBackend_CreateSound(unsigned int frequency, const unsigned char *samples, size_t length);
void AudioBackend_DestroySound(AudioBackend_Sound *sound);
-void AudioBackend_PlaySound(AudioBackend_Sound *sound, bool looping);
+void AudioBackend_PlaySound(AudioBackend_Sound *sound, int looping);
void AudioBackend_StopSound(AudioBackend_Sound *sound);
void AudioBackend_RewindSound(AudioBackend_Sound *sound);
--- a/src/Backends/Controller.h
+++ b/src/Backends/Controller.h
@@ -3,6 +3,6 @@
#pragma once
-bool ControllerBackend_Init(void);
+int ControllerBackend_Init(void);
void ControllerBackend_Deinit(void);
-bool ControllerBackend_GetJoystickStatus(bool **buttons, unsigned int *button_count, short **axes, unsigned int *axis_count);
+int ControllerBackend_GetJoystickStatus(int **buttons, unsigned int *button_count, short **axes, unsigned int *axis_count);
--- a/src/Backends/Misc.h
+++ b/src/Backends/Misc.h
@@ -4,7 +4,6 @@
#pragma once
#include <stddef.h>
-#include <string>
#include "../Attributes.h"
@@ -89,16 +88,16 @@
BACKEND_KEYBOARD_TOTAL
};
-bool Backend_Init(void (*drag_and_drop_callback)(const char *path), void (*window_focus_callback)(bool focus));
+int Backend_Init(void (*drag_and_drop_callback)(const char *path), void (*window_focus_callback)(int focus));
void Backend_Deinit(void);
void Backend_PostWindowCreation(void);
-bool Backend_GetPaths(std::string *module_path, std::string *data_path);
+int Backend_GetPaths(char **module_path, char **data_path);
void Backend_HideMouse(void);
void Backend_SetWindowIcon(const unsigned char *rgb_pixels, size_t width, size_t height);
void Backend_SetCursor(const unsigned char *rgba_pixels, size_t width, size_t height);
void Backend_EnableDragAndDrop(void);
-bool Backend_SystemTask(bool active);
-void Backend_GetKeyboardState(bool *keyboard_state);
+int Backend_SystemTask(int active);
+void Backend_GetKeyboardState(int *keyboard_state);
void Backend_ShowMessageBox(const char *title, const char *message);
ATTRIBUTE_FORMAT_PRINTF(1, 2) void Backend_PrintError(const char *format, ...);
ATTRIBUTE_FORMAT_PRINTF(1, 2) void Backend_PrintInfo(const char *format, ...);
--- a/src/Backends/Rendering.h
+++ b/src/Backends/Rendering.h
@@ -16,15 +16,15 @@
long bottom;
} RenderBackend_Rect;
-RenderBackend_Surface* RenderBackend_Init(const char *window_title, size_t screen_width, size_t screen_height, bool fullscreen);
+RenderBackend_Surface* RenderBackend_Init(const char *window_title, size_t screen_width, size_t screen_height, int fullscreen);
void RenderBackend_Deinit(void);
void RenderBackend_DrawScreen(void);
-RenderBackend_Surface* RenderBackend_CreateSurface(size_t width, size_t height, bool render_target);
+RenderBackend_Surface* RenderBackend_CreateSurface(size_t width, size_t height, int render_target);
void RenderBackend_FreeSurface(RenderBackend_Surface *surface);
-bool RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface);
+int RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface);
void RenderBackend_RestoreSurface(RenderBackend_Surface *surface);
void RenderBackend_UploadSurface(RenderBackend_Surface *surface, const unsigned char *pixels, size_t width, size_t height);
-void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, bool colour_key);
+void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, int colour_key);
void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RenderBackend_Rect *rect, unsigned char red, unsigned char green, unsigned char blue);
RenderBackend_GlyphAtlas* RenderBackend_CreateGlyphAtlas(size_t width, size_t height);
void RenderBackend_DestroyGlyphAtlas(RenderBackend_GlyphAtlas *atlas);
--- a/src/Caret.cpp
+++ b/src/Caret.cpp
@@ -18,6 +18,7 @@
#define CARET_MAX 0x40
+typedef struct CARET CARET;
struct CARET
{
int cond;
@@ -36,6 +37,7 @@
RECT rect;
};
+typedef struct CARET_TABLE CARET_TABLE;
struct CARET_TABLE
{
int view_left;
--- a/src/CommonDefines.h
+++ b/src/CommonDefines.h
@@ -29,6 +29,7 @@
DIR_OTHER = 5
};
+typedef struct OTHER_RECT OTHER_RECT;
struct OTHER_RECT // The original name for this struct is unknown
{
int front;
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -8,7 +8,6 @@
#include <stddef.h>
#include <stdio.h>
#include <string.h>
-#include <string>
#include "WindowsWrapper.h"
@@ -21,14 +20,15 @@
BOOL LoadConfigData(CONFIGDATA *conf)
{
+ char path[128];
// Clear old configuration data
memset(conf, 0, sizeof(CONFIGDATA));
// Get path
- std::string path = gModulePath + '/' + gConfigName;
+ snprint(path, sizeof path, "%s/%s", gModulePath, gConfigName);
// Open file
- FILE *fp = fopen(path.c_str(), "rb");
+ FILE *fp = fopen(path, "rb");
if (fp == NULL)
return FALSE;
--- a/src/Config.h
+++ b/src/Config.h
@@ -9,6 +9,7 @@
#include "WindowsWrapper.h"
+typedef struct CONFIGDATA CONFIGDATA;
struct CONFIGDATA
{
char proof[0x20];
--- a/src/Draw.cpp
+++ b/src/Draw.cpp
@@ -11,7 +11,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <string>
#ifdef __3DS__
#include <3ds.h>
@@ -237,7 +236,7 @@
if (image_buffer == NULL)
return FALSE;
- surf[surf_no] = RenderBackend_CreateSurface(width * mag, height * mag, false);
+ surf[surf_no] = RenderBackend_CreateSurface(width * mag, height * mag, FALSE);
if (surf[surf_no] == NULL)
{
@@ -266,11 +265,13 @@
// TODO - Inaccurate stack frame
BOOL MakeSurface_File(const char *name, SurfaceID surf_no)
{
- std::string path = gDataPath + '/' + name + ".pbm";
+ char path[128];
- if (!IsEnableBitmap(path.c_str()))
+ snprint(path, sizeof path, "%s/%s.pbm", gDataPath, name);
+
+ if (!IsEnableBitmap(path))
{
- ErrorLog(path.c_str(), 0);
+ ErrorLog(path, 0);
return FALSE;
}
@@ -291,15 +292,15 @@
}
size_t width, height;
- unsigned char *image_buffer = DecodeBitmapFromFile(path.c_str(), &width, &height, 3);
+ unsigned char *image_buffer = DecodeBitmapFromFile(path, &width, &height, 3);
if (image_buffer == NULL)
{
- ErrorLog(path.c_str(), 1);
+ ErrorLog(path, 1);
return FALSE;
}
- surf[surf_no] = RenderBackend_CreateSurface(width * mag, height * mag, false);
+ surf[surf_no] = RenderBackend_CreateSurface(width * mag, height * mag, FALSE);
if (surf[surf_no] == NULL)
{
@@ -357,11 +358,13 @@
// TODO - Inaccurate stack frame
BOOL ReloadBitmap_File(const char *name, SurfaceID surf_no)
{
- std::string path = gDataPath + '/' + name + ".pbm";
+ char path[128];
- if (!IsEnableBitmap(path.c_str()))
+ snprint(path, sizeof path, "%s/%s.pbm", gDataPath, name);
+
+ if (!IsEnableBitmap(path))
{
- ErrorLog(path.c_str(), 0);
+ ErrorLog(path, 0);
return FALSE;
}
@@ -376,11 +379,11 @@
}
size_t width, height;
- unsigned char *image_buffer = DecodeBitmapFromFile(path.c_str(), &width, &height, 3);
+ unsigned char *image_buffer = DecodeBitmapFromFile(path, &width, &height, 3);
if (image_buffer == NULL)
{
- ErrorLog(path.c_str(), 1);
+ ErrorLog(path, 1);
return FALSE;
}
@@ -605,7 +608,7 @@
BOOL out(char surface_identifier)
{
// The actual name (and type) of these two variables are unknown
- std::string path;
+ char path[128];
FILE *fp;
(void)surface_identifier;
@@ -678,9 +681,10 @@
void InitTextObject(const char *name)
{
(void)name; // Unused in this branch
+ char path[128];
#ifdef FREETYPE_FONTS
- std::string path = gDataPath + "/Font/font";
+ snprint(path, sizeof path, "%s/Font/font", gDataPath);
// Get font size
size_t width, height;
@@ -723,25 +727,25 @@
break;
}
- font = LoadFreeTypeFont(path.c_str(), width, height);
+ font = LoadFreeTypeFont(path, width, height);
#else
- std::string bitmap_path;
- std::string metadata_path;
+ char bitmap_path[128];
+ char metadata_path[128];
switch (mag)
{
case 1:
- bitmap_path = gDataPath + "/Font/font_bitmap_6x12.png";
- metadata_path = gDataPath + "/Font/font_bitmap_6x12.dat";
+ snprint(bitmap_path, sizeof bitmap_path, "%s/Font/font_bitmap_6x12.png", gDataPath);
+ snprint(metadata_path, sizeof metadata_path, "%s/Font/font_bitmap_6x12.dat", gDataPath);
break;
case 2:
- bitmap_path = gDataPath + "/Font/font_bitmap_10x20.png";
- metadata_path = gDataPath + "/Font/font_bitmap_10x20.dat";
+ snprint(bitmap_path, sizeof bitmap_path, "%s/Font/font_bitmap_10x20.png", gDataPath);
+ snprint(metadata_path, sizeof metadata_path, "%s/Font/font_bitmap_10x20.dat", gDataPath);
break;
}
- font = LoadBitmapFont(bitmap_path.c_str(), metadata_path.c_str());
+ font = LoadBitmapFont(bitmap_path, metadata_path);
#endif
}
--- a/src/Ending.cpp
+++ b/src/Ending.cpp
@@ -11,7 +11,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <string>
#include "WindowsWrapper.h"
@@ -26,6 +25,7 @@
#include "Stage.h"
#include "TextScr.h"
+typedef int CREDIT_MODE;
enum CREDIT_MODE
{
CREDIT_MODE_STOP,
@@ -33,6 +33,7 @@
CREDIT_MODE_SCROLL_WAIT
};
+typedef int ILLUSTRATION_ACTION;
enum ILLUSTRATION_ACTION
{
ILLUSTRATION_ACTION_IDLE,
@@ -40,6 +41,7 @@
ILLUSTRATION_ACTION_SLIDE_OUT
};
+typedef struct CREDIT CREDIT;
struct CREDIT
{
long size;
@@ -50,6 +52,7 @@
int start_x;
};
+typedef struct STRIP STRIP;
struct STRIP
{
int flag;
@@ -59,6 +62,7 @@
char str[0x40];
};
+typedef struct ILLUSTRATION ILLUSTRATION;
struct ILLUSTRATION
{
ILLUSTRATION_ACTION act_no;
@@ -65,6 +69,7 @@
int x;
};
+typedef struct ISLAND_SPRITE ISLAND_SPRITE;
struct ISLAND_SPRITE
{
int x;
@@ -239,7 +244,7 @@
BOOL StartCreditScript(void)
{
FILE *fp;
- std::string path;
+ char path[128];
// Clear previously existing credits data
if (Credit.pData != NULL)
@@ -249,9 +254,9 @@
}
// Open file
- path = gDataPath + '/' + credit_script;
+ snprint(path, sizeof path, "%s/%s", gDataPath, credit_script);
- Credit.size = GetFileSizeLong(path.c_str());
+ Credit.size = GetFileSizeLong(path);
if (Credit.size == -1)
return FALSE;
@@ -260,7 +265,7 @@
if (Credit.pData == NULL)
return FALSE;
- fp = fopen(path.c_str(), "rb");
+ fp = fopen(path, "rb");
if (fp == NULL)
{
free(Credit.pData);
--- a/src/Fade.h
+++ b/src/Fade.h
@@ -13,6 +13,7 @@
#define FADE_WIDTH (((WINDOW_WIDTH - 1) / 16) + 1)
#define FADE_HEIGHT (((WINDOW_HEIGHT - 1) / 16) + 1)
+typedef struct FADE FADE;
struct FADE
{
int mode;
--- a/src/Flash.h
+++ b/src/Flash.h
@@ -7,6 +7,7 @@
#pragma once
+typedef int FlashMode;
enum FlashMode
{
FLASH_MODE_EXPLOSION = 1,
--- a/src/Game.cpp
+++ b/src/Game.cpp
@@ -8,7 +8,6 @@
#include "Game.h"
#include <stddef.h>
-#include <string>
#include "WindowsWrapper.h"
@@ -706,9 +705,10 @@
PlaySoundObject(7, SOUND_MODE_PLAY_LOOP);
- std::string path = gDataPath + "/npc.tbl";
+ char path[128];
+ snprint(path, sizeof path, "%s/npc.tbl", gDataPath);
- if (!LoadNpcTable(path.c_str()))
+ if (!LoadNpcTable(path))
{
#if !defined(JAPANESE) && defined(FIX_BUGS) // The Aeon Genesis translation didn't translate this
Backend_ShowMessageBox("Error", "Couldn't read the NPC table");
--- a/src/Generic.cpp
+++ b/src/Generic.cpp
@@ -10,7 +10,6 @@
#include <stddef.h>
#include <stdio.h>
#include <string.h>
-#include <string>
#include "WindowsWrapper.h"
@@ -57,19 +56,19 @@
void DeleteLog(void)
{
- std::string path;
+ char path[128];
- path = gModulePath + "/debug.txt";
- remove(path.c_str());
+ snprint(path, sizeof path, "%s/debug.txt", gModulePath);
+ remove(path);
}
BOOL WriteLog(const char *string, int value1, int value2, int value3)
{
- std::string path;
+ char path[128];
FILE *fp;
- path = gModulePath + "/debug.txt";
- fp = fopen(path.c_str(), "a+");
+ snprint(path, sizeof path, "%s/debug.txt", gModulePath);
+ fp = fopen(path, "a+");
if (fp == NULL)
return FALSE;
@@ -81,12 +80,12 @@
BOOL IsKeyFile(const char *name)
{
- std::string path;
+ char path[128];
FILE *fp;
- path = gModulePath + '/' + name;
+ snprint(path, sizeof path, "%s/%s", gModulePath, name);
- fp = fopen(path.c_str(), "rb");
+ fp = fopen(path, "rb");
if (fp == NULL)
return FALSE;
@@ -114,15 +113,15 @@
BOOL ErrorLog(const char *string, int value)
{
- std::string path;
+ char path[128];
FILE *fp;
- path = gModulePath + "/error.log";
+ snprint(path, sizeof path, "%s/error.log", gModulePath);
- if (GetFileSizeLong(path.c_str()) > 0x19000) // Purge the error log if it gets too big, I guess
- remove(path.c_str());
+ if (GetFileSizeLong(path) > 0x19000) // Purge the error log if it gets too big, I guess
+ remove(path);
- fp = fopen(path.c_str(), "a+");
+ fp = fopen(path, "a+");
if (fp == NULL)
return FALSE;
--- a/src/Input.cpp
+++ b/src/Input.cpp
@@ -26,7 +26,7 @@
BOOL GetJoystickStatus(DIRECTINPUTSTATUS *status)
{
- bool *buttons;
+ BOOL *buttons;
unsigned int button_count;
short *axes;
@@ -70,7 +70,7 @@
BOOL ResetJoystickStatus(void)
{
- bool *buttons;
+ BOOL *buttons;
unsigned int button_count;
short *axes;
--- a/src/Input.h
+++ b/src/Input.h
@@ -9,6 +9,7 @@
#include "WindowsWrapper.h"
+typedef struct DIRECTINPUTSTATUS DIRECTINPUTSTATUS;
struct DIRECTINPUTSTATUS
{
BOOL bLeft;
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -10,7 +10,6 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
-#include <string>
#include "WindowsWrapper.h"
@@ -33,8 +32,8 @@
void InactiveWindow(void);
void ActiveWindow(void);
-std::string gModulePath;
-std::string gDataPath;
+char *gModulePath;
+char *gDataPath;
BOOL bFullscreen;
BOOL gbUseJoystick = FALSE;
@@ -58,7 +57,7 @@
LoadProfile(path);
}
-static void WindowFocusCallback(bool focus)
+static void WindowFocusCallback(BOOL focus)
{
if (focus)
ActiveWindow();
@@ -116,19 +115,6 @@
// Get executable's path, and path of the data folder
if (!Backend_GetPaths(&gModulePath, &gDataPath))
{
- // Fall back on argv[0] if the backend cannot provide a path
- gModulePath = argv[0];
-
- for (size_t i = gModulePath.length();; --i)
- {
- if (i == 0 || gModulePath[i] == '\\' || gModulePath[i] == '/')
- {
- gModulePath.resize(i);
- break;
- }
- }
-
- gDataPath = gModulePath + "/data";
}
CONFIGDATA conf;
@@ -406,7 +392,7 @@
BOOL SystemTask(void)
{
- static bool previous_keyboard_state[BACKEND_KEYBOARD_TOTAL];
+ static BOOL previous_keyboard_state[BACKEND_KEYBOARD_TOTAL];
do
{
@@ -417,7 +403,7 @@
}
} while(!bActive);
- bool keyboard_state[BACKEND_KEYBOARD_TOTAL];
+ BOOL keyboard_state[BACKEND_KEYBOARD_TOTAL];
Backend_GetKeyboardState(keyboard_state);
for (unsigned int i = 0; i < BACKEND_KEYBOARD_TOTAL; ++i)
--- a/src/Main.h
+++ b/src/Main.h
@@ -7,12 +7,10 @@
#pragma once
-#include <string>
-
#include "WindowsWrapper.h"
-extern std::string gModulePath;
-extern std::string gDataPath;
+extern char *gModulePath;
+extern char *gDataPath;
extern BOOL bFullscreen;
extern BOOL gbUseJoystick;
--- a/src/Map.cpp
+++ b/src/Map.cpp
@@ -11,7 +11,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <string>
#include "WindowsWrapper.h"
@@ -37,13 +36,13 @@
{
FILE *fp;
char check[3];
- std::string path;
+ char path[128];
// Get path
- path = gDataPath + '/' + path_map;
+ snprint(path, sizeof path, "%s/%s", gDataPath, path_map);
// Open file
- fp = fopen(path.c_str(), "rb");
+ fp = fopen(path, "rb");
if (fp == NULL)
return FALSE;
@@ -77,12 +76,12 @@
BOOL LoadAttributeData(const char *path_atrb)
{
FILE *fp;
- std::string path;
+ char path[128];
// Open file
- path = gDataPath + '/' + path_atrb;
+ snprint(path, sizeof path, "%s/%s", gDataPath, path_atrb);
- fp = fopen(path.c_str(), "rb");
+ fp = fopen(path, "rb");
if (fp == NULL)
return FALSE;
--- a/src/MycParam.cpp
+++ b/src/MycParam.cpp
@@ -9,7 +9,6 @@
#include <stddef.h>
#include <stdio.h>
-#include <string>
#include "WindowsWrapper.h"
@@ -451,7 +450,7 @@
unsigned char p[4];
REC rec;
FILE *fp;
- std::string path;
+ char path[128];
// Quit if player doesn't have the Nikumaru Counter
if (!(gMC.equip & EQUIP_NIKUMARU_COUNTER))
@@ -458,9 +457,9 @@
return TRUE;
// Get last time
- path = gModulePath + "/290.rec";
+ snprint(path, sizeof path, "%s/290.rec", gModulePath);
- fp = fopen(path.c_str(), "rb");
+ fp = fopen(path, "rb");
if (fp != NULL)
{
// Read data
@@ -500,7 +499,7 @@
rec.counter[i] = p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
}
- fp = fopen(path.c_str(), "wb");
+ fp = fopen(path, "wb");
if (fp == NULL)
return FALSE;
@@ -523,12 +522,12 @@
unsigned char p[4];
REC rec;
FILE *fp;
- std::string path;
+ char path[128];
// Open file
- path = gModulePath + "/290.rec";
+ snprint(path, sizeof path, "%s/290.rec", gModulePath);
- fp = fopen(path.c_str(), "rb");
+ fp = fopen(path, "rb");
if (fp == NULL)
return 0;
--- a/src/NpChar.cpp
+++ b/src/NpChar.cpp
@@ -10,7 +10,6 @@
#include <stddef.h>
#include <stdio.h>
#include <string.h>
-#include <string>
#include "WindowsWrapper.h"
@@ -68,9 +67,10 @@
char code[4];
EVENT eve;
- std::string path = gDataPath + '/' + path_event;
+ char path[128];
+ snprint(path, sizeof path, "%s/%s", gDataPath, path_event);
- fp = fopen(path.c_str(), "rb");
+ fp = fopen(path, "rb");
if (fp == NULL)
return FALSE;
--- a/src/NpChar.h
+++ b/src/NpChar.h
@@ -97,6 +97,7 @@
struct NPCHAR *pNpc;
} NPCHAR;
+typedef struct EVENT EVENT;
struct EVENT
{
short x;
--- a/src/NpcAct060.cpp
+++ b/src/NpcAct060.cpp
@@ -827,6 +827,7 @@
// Misery bubble
void ActNpc066(NPCHAR *npc)
{
+ int a;
RECT rect[4] = {
{32, 192, 56, 216},
{56, 192, 80, 216},
@@ -837,7 +838,6 @@
switch (npc->act_no)
{
case 0:
- int a;
for (a = 0; a < NPC_MAX; ++a)
if (gNPC[a].code_event == 1000)
break;
--- a/src/NpcTbl.h
+++ b/src/NpcTbl.h
@@ -11,6 +11,7 @@
#include "NpChar.h"
+typedef struct NPC_TBL_RECT NPC_TBL_RECT;
struct NPC_TBL_RECT
{
unsigned char front;
@@ -19,6 +20,7 @@
unsigned char bottom;
};
+typedef struct NPC_TABLE NPC_TABLE;
struct NPC_TABLE
{
unsigned short bits;
--- a/src/Organya.cpp
+++ b/src/Organya.cpp
@@ -43,8 +43,9 @@
#define SETWAVE 0x00000020
#define SETPIPI 0x00000040
+typedef struct NOTELIST NOTELIST;
// Below are Organya song data structures
-typedef struct NOTELIST
+struct NOTELIST
{
NOTELIST *from; // Previous address
NOTELIST *to; // Next address
@@ -54,7 +55,7 @@
unsigned char y; // Sound height
unsigned char volume; // Volume
unsigned char pan;
-} NOTELIST;
+};
// Track data * 8
typedef struct TRACKDATA
@@ -82,7 +83,7 @@
// メインクラス。このアプリケーションの中心。(クラスってやつを初めて使う) (Main class. The heart of this application. (Class is used for the first time))
typedef struct OrgData
{
- OrgData(); // コンストラクタ (Constructor)
+// OrgData(); // コンストラクタ (Constructor)
// ~OrgData(); // デストラクタ (Destructor)
MUSICINFO info;
char track;
@@ -89,19 +90,23 @@
char mute[MAXTRACK];
unsigned char def_pan;
unsigned char def_volume;
- void InitOrgData(void);
- void GetMusicInfo(MUSICINFO *mi); // 曲情報を取得 (Get song information)
+
// 曲情報を設定。flagは設定アイテムを指定 (Set song information. flag specifies the setting item)
- BOOL SetMusicInfo(MUSICINFO *mi,unsigned long flag);
- BOOL NoteAlloc(unsigned short note_num); // 指定の数だけNoteDataの領域を確保 (Allocate the specified number of NoteData areas.)
- void ReleaseNote(void); // NoteDataを開放 (Release NoteData)
+
// 以下は再生 (The following is playback)
- void PlayData(void);
- void SetPlayPointer(long x); // 再生ポインターを指定の位置に設定 (Set playback pointer to specified position)
// 以下はファイル関係 (The following are related to files)
- BOOL InitMusicData(const char *path);
} ORGDATA;
+void OrgDataOrgData();
+void OrgDataInitOrgData(void);
+void OrgDataGetMusicInfo(MUSICINFO *mi); // 曲情報を取得 (Get song information)
+BOOL OrgDataSetMusicInfo(MUSICINFO *mi,unsigned long flag);
+BOOL OrgDataNoteAlloc(unsigned short note_num); // 指定の数だけNoteDataの領域を確保 (Allocate the specified number of NoteData areas.)
+void OrgDataReleaseNote(void); // NoteDataを開放 (Release NoteData)
+BOOL OrgDataInitMusicData(const char *path);
+void OrgDataPlayData(void);
+void OrgDataSetPlayPointer(long x); // 再生ポインターを指定の位置に設定 (Set playback pointer to specified position)
+
AudioBackend_Sound *lpORGANBUFFER[8][8][2] = {NULL};
/////////////////////////////////////////////
@@ -407,44 +412,44 @@
static void OrganyaCallback(void)
{
- org_data.PlayData();
+ OrgDataPlayData();
}
-OrgData::OrgData(void)
+void OrgDataOrgData(void)
{
for (int i = 0; i < MAXTRACK; i++)
{
- info.tdata[i].note_list = NULL;
- info.tdata[i].note_p = NULL;
+ org_data.info.tdata[i].note_list = NULL;
+ org_data.info.tdata[i].note_p = NULL;
}
}
-void OrgData::InitOrgData(void)
+void OrgDataInitOrgData(void)
{
- track = 0;
- info.alloc_note = ALLOCNOTE; // とりあえず10000個確保 (For the time being, secure 10,000 pieces)
- info.dot = 4;
- info.line = 4;
- info.wait = 128;
- info.repeat_x = info.dot * info.line * 0;
- info.end_x = info.dot * info.line * 255;
+ org_data.track = 0;
+ org_data.info.alloc_note = ALLOCNOTE; // とりあえず10000個確保 (For the time being, secure 10,000 pieces)
+ org_data.info.dot = 4;
+ org_data.info.line = 4;
+ org_data.info.wait = 128;
+ org_data.info.repeat_x = org_data.info.dot * org_data.info.line * 0;
+ org_data.info.end_x = org_data.info.dot * org_data.info.line * 255;
for (int i = 0; i < MAXTRACK; i++)
{
- info.tdata[i].freq = 1000;
- info.tdata[i].wave_no = 0;
- info.tdata[i].pipi = 0;
+ org_data.info.tdata[i].freq = 1000;
+ org_data.info.tdata[i].wave_no = 0;
+ org_data.info.tdata[i].pipi = 0;
}
- NoteAlloc(info.alloc_note);
- SetMusicInfo(&info, SETALL);
+ OrgDataNoteAlloc(org_data.info.alloc_note);
+ OrgDataSetMusicInfo(&org_data.info, SETALL);
- def_pan = DEFPAN;
- def_volume = DEFVOLUME;
+ org_data.def_pan = DEFPAN;
+ org_data.def_volume = DEFVOLUME;
}
// 曲情報を設定。flagはアイテムを指定 (Set song information. flag specifies an item)
-BOOL OrgData::SetMusicInfo(MUSICINFO *mi, unsigned long flag)
+BOOL OrgDataSetMusicInfo(MUSICINFO *mi, unsigned long flag)
{
//char str[32]; // Leftover debug junk
int i;
@@ -451,20 +456,20 @@
if (flag & SETGRID) // グリッドを有効に (Enable grid)
{
- info.dot = mi->dot;
- info.line = mi->line;
+ org_data.info.dot = mi->dot;
+ org_data.info.line = mi->line;
}
if (flag & SETWAIT)
{
- info.wait = mi->wait;
+ org_data.info.wait = mi->wait;
//itoa(mi->wait, str, 10); // Leftover debug junk
}
if (flag & SETREPEAT)
{
- info.repeat_x = mi->repeat_x;
- info.end_x = mi->end_x;
+ org_data.info.repeat_x = mi->repeat_x;
+ org_data.info.end_x = mi->end_x;
}
if (flag & SETFREQ)
@@ -471,44 +476,44 @@
{
for (i = 0; i < MAXMELODY; i++)
{
- info.tdata[i].freq = mi->tdata[i].freq;
- info.tdata[i].pipi = info.tdata[i].pipi; // Just sets info.tdata[i].pipi to itself (SETPIPI already sets pipi, so maybe this line shouldn't be here in the first place)
+ org_data.info.tdata[i].freq = mi->tdata[i].freq;
+ org_data.info.tdata[i].pipi = org_data.info.tdata[i].pipi; // Just sets info.tdata[i].pipi to itself (SETPIPI already sets pipi, so maybe this line shouldn't be here in the first place)
}
}
if (flag & SETWAVE)
for (i = 0; i < MAXTRACK; i++)
- info.tdata[i].wave_no = mi->tdata[i].wave_no;
+ org_data.info.tdata[i].wave_no = mi->tdata[i].wave_no;
if (flag & SETPIPI)
for (i = 0; i < MAXTRACK; i++)
- info.tdata[i].pipi = mi->tdata[i].pipi;
+ org_data.info.tdata[i].pipi = mi->tdata[i].pipi;
return TRUE;
}
// 指定の数だけNoteDataの領域を確保(初期化) (Allocate the specified number of NoteData areas (initialization))
-BOOL OrgData::NoteAlloc(unsigned short alloc)
+BOOL OrgDataNoteAlloc(unsigned short alloc)
{
int i,j;
for (j = 0; j < MAXTRACK; j++)
{
- info.tdata[j].wave_no = 0;
- info.tdata[j].note_list = NULL; // コンストラクタにやらせたい (I want the constructor to do it)
- info.tdata[j].note_p = (NOTELIST*)malloc(sizeof(NOTELIST) * alloc);
+ org_data.info.tdata[j].wave_no = 0;
+ org_data.info.tdata[j].note_list = NULL; // コンストラクタにやらせたい (I want the constructor to do it)
+ org_data.info.tdata[j].note_p = (NOTELIST*)malloc(sizeof(NOTELIST) * alloc);
- if (info.tdata[j].note_p == NULL)
+ if (org_data.info.tdata[j].note_p == NULL)
{
for (i = 0; i < MAXTRACK; i++)
{
- if (info.tdata[i].note_p != NULL)
+ if (org_data.info.tdata[i].note_p != NULL)
{
- free(info.tdata[i].note_p);
+ free(org_data.info.tdata[i].note_p);
#ifdef FIX_BUGS
- info.tdata[i].note_p = NULL;
+ org_data.info.tdata[i].note_p = NULL;
#else
- info.tdata[j].note_p = NULL; // Uses j instead of i
+ org_data.info.tdata[j].note_p = NULL; // Uses j instead of i
#endif
}
}
@@ -518,32 +523,32 @@
for (i = 0; i < alloc; i++)
{
- (info.tdata[j].note_p + i)->from = NULL;
- (info.tdata[j].note_p + i)->to = NULL;
- (info.tdata[j].note_p + i)->length = 0;
- (info.tdata[j].note_p + i)->pan = PANDUMMY;
- (info.tdata[j].note_p + i)->volume = VOLDUMMY;
- (info.tdata[j].note_p + i)->y = KEYDUMMY;
+ (org_data.info.tdata[j].note_p + i)->from = NULL;
+ (org_data.info.tdata[j].note_p + i)->to = NULL;
+ (org_data.info.tdata[j].note_p + i)->length = 0;
+ (org_data.info.tdata[j].note_p + i)->pan = PANDUMMY;
+ (org_data.info.tdata[j].note_p + i)->volume = VOLDUMMY;
+ (org_data.info.tdata[j].note_p + i)->y = KEYDUMMY;
}
}
for (j = 0; j < MAXMELODY; j++)
- MakeOrganyaWave(j, info.tdata[j].wave_no, info.tdata[j].pipi);
+ MakeOrganyaWave(j, org_data.info.tdata[j].wave_no, org_data.info.tdata[j].pipi);
- track = 0; // 今はここに書いておく (Write here now)
+ org_data.track = 0; // 今はここに書いておく (Write here now)
return TRUE;
}
// NoteDataを開放 (Release NoteData)
-void OrgData::ReleaseNote(void)
+void OrgDataReleaseNote(void)
{
for (int i = 0; i < MAXTRACK; i++)
{
- if (info.tdata[i].note_p != NULL)
+ if (org_data.info.tdata[i].note_p != NULL)
{
- free(info.tdata[i].note_p);
- info.tdata[i].note_p = NULL;
+ free(org_data.info.tdata[i].note_p);
+ org_data.info.tdata[i].note_p = NULL;
}
}
}
@@ -551,7 +556,7 @@
char pass[7] = "Org-01";
char pass2[7] = "Org-02"; // Pipi
-BOOL OrgData::InitMusicData(const char *path)
+BOOL OrgDataInitMusicData(const char *path)
{
#define READ_LE16(p) ((p[1] << 8) | p[0]); p += 2
#define READ_LE32(p) ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]); p += 4
@@ -578,22 +583,22 @@
return FALSE;
// 曲の情報を設定 (Set song information)
- info.wait = READ_LE16(p);
- info.line = *p++;
- info.dot = *p++;
- info.repeat_x = READ_LE32(p);
- info.end_x = READ_LE32(p);
+ org_data.info.wait = READ_LE16(p);
+ org_data.info.line = *p++;
+ org_data.info.dot = *p++;
+ org_data.info.repeat_x = READ_LE32(p);
+ org_data.info.end_x = READ_LE32(p);
for (i = 0; i < MAXTRACK; i++)
{
- info.tdata[i].freq = READ_LE16(p);
+ org_data.info.tdata[i].freq = READ_LE16(p);
- info.tdata[i].wave_no = *p++;
+ org_data.info.tdata[i].wave_no = *p++;
if (ver == 1)
- info.tdata[i].pipi = 0;
+ org_data.info.tdata[i].pipi = 0;
else
- info.tdata[i].pipi = *p;
+ org_data.info.tdata[i].pipi = *p;
++p;
@@ -606,13 +611,13 @@
// 最初の音符はfromがNULLとなる (The first note has from as NULL)
if (note_num[j] == 0)
{
- info.tdata[j].note_list = NULL;
+ org_data.info.tdata[j].note_list = NULL;
continue;
}
// リストを作る (Make a list)
- np = info.tdata[j].note_p;
- info.tdata[j].note_list = info.tdata[j].note_p;
+ np = org_data.info.tdata[j].note_p;
+ org_data.info.tdata[j].note_list = org_data.info.tdata[j].note_p;
np->from = NULL;
np->to = (np + 1);
np++;
@@ -629,7 +634,7 @@
np->to = NULL;
// 内容を代入 (Assign content)
- np = info.tdata[j].note_p; // X座標 (X coordinate)
+ np = org_data.info.tdata[j].note_p; // X座標 (X coordinate)
for (i = 0; i < note_num[j]; i++)
{
np->x = READ_LE32(p);
@@ -636,7 +641,7 @@
np++;
}
- np = info.tdata[j].note_p; // Y座標 (Y coordinate)
+ np = org_data.info.tdata[j].note_p; // Y座標 (Y coordinate)
for (i = 0; i < note_num[j]; i++)
{
np->y = *p++;
@@ -643,7 +648,7 @@
np++;
}
- np = info.tdata[j].note_p; // 長さ (Length)
+ np = org_data.info.tdata[j].note_p; // 長さ (Length)
for (i = 0; i < note_num[j]; i++)
{
np->length = *p++;
@@ -650,7 +655,7 @@
np++;
}
- np = info.tdata[j].note_p; // ボリューム (Volume)
+ np = org_data.info.tdata[j].note_p; // ボリューム (Volume)
for (i = 0; i < note_num[j]; i++)
{
np->volume = *p++;
@@ -657,7 +662,7 @@
np++;
}
- np = info.tdata[j].note_p; // パン (Pan)
+ np = org_data.info.tdata[j].note_p; // パン (Pan)
for (i = 0; i < note_num[j]; i++)
{
np->pan = *p++;
@@ -667,12 +672,12 @@
// データを有効に (Enable data)
for (j = 0; j < MAXMELODY; j++)
- MakeOrganyaWave(j,info.tdata[j].wave_no, info.tdata[j].pipi);
+ MakeOrganyaWave(j,org_data.info.tdata[j].wave_no, org_data.info.tdata[j].pipi);
// Pixel ripped out some code so he could use PixTone sounds as drums, but he left this dead code
for (j = MAXMELODY; j < MAXTRACK; j++)
{
- i = info.tdata[j].wave_no;
+ i = org_data.info.tdata[j].wave_no;
//InitDramObject(dram_name[i], j - MAXMELODY);
}
@@ -682,20 +687,20 @@
}
// 曲情報を取得 (Get song information)
-void OrgData::GetMusicInfo(MUSICINFO *mi)
+void OrgDataGetMusicInfo(MUSICINFO *mi)
{
- mi->dot = info.dot;
- mi->line = info.line;
- mi->alloc_note = info.alloc_note;
- mi->wait = info.wait;
- mi->repeat_x = info.repeat_x;
- mi->end_x = info.end_x;
+ mi->dot = org_data.info.dot;
+ mi->line = org_data.info.line;
+ mi->alloc_note = org_data.info.alloc_note;
+ mi->wait = org_data.info.wait;
+ mi->repeat_x = org_data.info.repeat_x;
+ mi->end_x = org_data.info.end_x;
for (int i = 0; i < MAXTRACK; i++)
{
- mi->tdata[i].freq = info.tdata[i].freq;
- mi->tdata[i].wave_no = info.tdata[i].wave_no;
- mi->tdata[i].pipi = info.tdata[i].pipi;
+ mi->tdata[i].freq = org_data.info.tdata[i].freq;
+ mi->tdata[i].wave_no = org_data.info.tdata[i].wave_no;
+ mi->tdata[i].pipi = org_data.info.tdata[i].pipi;
}
}
@@ -708,7 +713,7 @@
int TrackVol[MAXTRACK];
BOOL bFadeout = FALSE;
-void OrgData::PlayData(void)
+void OrgDataPlayData(void)
{
int i;
@@ -725,7 +730,7 @@
{
if (!g_mute[i] && np[i]->y != KEYDUMMY) // 音が来た。 (The sound has come.)
{
- PlayOrganObject(np[i]->y, -1, i, info.tdata[i].freq);
+ PlayOrganObject(np[i]->y, -1, i, org_data.info.tdata[i].freq);
now_leng[i] = np[i]->length;
}
@@ -738,7 +743,7 @@
}
if (now_leng[i] == 0)
- PlayOrganObject(0, 2, i, info.tdata[i].freq);
+ PlayOrganObject(0, 2, i, org_data.info.tdata[i].freq);
if (now_leng[i] > 0)
now_leng[i]--;
@@ -769,18 +774,18 @@
// Looping
PlayPos++;
- if (PlayPos >= info.end_x)
+ if (PlayPos >= org_data.info.end_x)
{
- PlayPos = info.repeat_x;
+ PlayPos = org_data.info.repeat_x;
SetPlayPointer(PlayPos);
}
}
-void OrgData::SetPlayPointer(long x)
+void OrgDataSetPlayPointer(long x)
{
for (int i = 0; i < MAXTRACK; i++)
{
- np[i] = info.tdata[i].note_list;
+ np[i] = org_data.info.tdata[i].note_list;
while (np[i] != NULL && np[i]->x < x)
np[i] = np[i]->to; // 見るべき音符を設定 (Set note to watch)
}
@@ -797,7 +802,7 @@
if (!InitWaveData100())
return FALSE;
- org_data.InitOrgData();
+ OrgDataInitOrgData();
AudioBackend_SetOrganyaCallback(OrganyaCallback);
@@ -810,7 +815,7 @@
if (!audio_backend_initialised)
return FALSE;
- if (!org_data.InitMusicData(name))
+ if (!OrgDataInitMusicData(name))
return FALSE;
Volume = 100;
@@ -828,7 +833,7 @@
if (!audio_backend_initialised)
return;
- org_data.SetPlayPointer(x);
+ OrgDataSetPlayPointer(x);
Volume = 100;
bFadeout = FALSE;
}
@@ -897,7 +902,7 @@
AudioBackend_SetOrganyaTimer(0);
// Release everything related to org
- org_data.ReleaseNote();
+ OrgDataReleaseNote();
for (int i = 0; i < MAXMELODY; i++)
{
--- a/src/Profile.cpp
+++ b/src/Profile.cpp
@@ -10,7 +10,6 @@
#include <stddef.h>
#include <stdio.h>
#include <string.h>
-#include <string>
#include "WindowsWrapper.h"
@@ -36,9 +35,10 @@
BOOL IsProfile(void)
{
- std::string path = gModulePath + '/' + gDefaultName;
+ char path[128];
+ snprint(path, sizeof path, "%s/%s", gModulePath, gDefaultName);
- FILE *file = fopen(path.c_str(), "rb");
+ FILE *file = fopen(path, "rb");
if (file == NULL)
return FALSE;
@@ -52,16 +52,16 @@
PROFILEDATA profile;
const char *FLAG = "FLAG";
- std::string path;
+ char path[128];
// Get path
if (name != NULL)
- path = gModulePath + '/' + name;
+ snprint(path, sizeof path, "%s/%s", gModulePath, name);
else
- path = gModulePath + '/' + gDefaultName;
+ snprint(path, sizeof path, "%s/%s", gModulePath, gDefaultName);
// Open file
- fp = fopen(path.c_str(), "wb");
+ fp = fopen(path, "wb");
if (fp == NULL)
return FALSE;
@@ -131,16 +131,16 @@
{
FILE *fp;
PROFILEDATA profile;
- std::string path;
+ char path[128];
// Get path
if (name != NULL)
- path = name;
+ snprint(path, sizeof path, "%s", name);
else
- path = gModulePath + '/' + gDefaultName;
+ snprint(path, sizeof path, "%s/%s", gModulePath, gDefaultName);
// Open file
- fp = fopen(path.c_str(), "rb");
+ fp = fopen(path, "rb");
if (fp == NULL)
return FALSE;
--- a/src/SelStage.cpp
+++ b/src/SelStage.cpp
@@ -8,7 +8,6 @@
#include "SelStage.h"
#include <string.h>
-#include <string>
#include "WindowsWrapper.h"
@@ -167,7 +166,7 @@
int StageSelectLoop(int *p_event)
{
- std::string old_script_path;
+ char *old_script_path;
RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
@@ -223,7 +222,7 @@
if (gKeyTrg & gKeyCancel)
{
StopTextScript();
- LoadTextScript_Stage(old_script_path.c_str());
+ LoadTextScript_Stage(old_script_path);
*p_event = 0;
return enum_ESCRETURN_continue;
}
@@ -234,7 +233,7 @@
return enum_ESCRETURN_exit;
}
- LoadTextScript_Stage(old_script_path.c_str());
+ LoadTextScript_Stage(old_script_path);
*p_event = gPermitStage[gSelectedStage].event;
return enum_ESCRETURN_continue;
}
--- a/src/Sound.cpp
+++ b/src/Sound.cpp
@@ -23,7 +23,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <string>
#include "WindowsWrapper.h"
@@ -125,18 +124,18 @@
BOOL LoadSoundObject(const char *file_name, int no)
{
- std::string path;
+ char path[128];
//unsigned long i;
unsigned long file_size = 0;
char check_box[58];
FILE *fp;
- path = gModulePath + '/' + file_name;
+ snprint(path, sizeof path, "%s/%s", gModulePath, file_name);
if (!audio_backend_initialised)
return TRUE;
- if ((fp = fopen(path.c_str(), "rb")) == NULL)
+ if ((fp = fopen(path, "rb")) == NULL)
return FALSE;
fseek(fp, 0, SEEK_END);
--- a/src/Sound.h
+++ b/src/Sound.h
@@ -33,6 +33,7 @@
// To be continued
};
+typedef int SoundMode;
enum SoundMode
{
SOUND_MODE_PLAY_LOOP = -1,
--- a/src/Stage.cpp
+++ b/src/Stage.cpp
@@ -5,10 +5,9 @@
// Modifications and custom code are under the MIT licence.
// See LICENCE.txt for details.
+#include <stdio.h>
#include "Stage.h"
-#include <string>
-
#include "WindowsWrapper.h"
#include "Back.h"
@@ -137,8 +136,8 @@
BOOL TransferStage(int no, int w, int x, int y)
{
- std::string path;
- std::string path_dir;
+ char path[128];
+ char path_dir[128];
BOOL bError;
// Move character
@@ -147,47 +146,47 @@
bError = FALSE;
// Get path
- path_dir = "Stage";
+ snprint(path_dir, sizeof path_dir, "Stage");
// Load tileset
- path = path_dir + "/Prt" + gTMT[no].parts;
- if (!ReloadBitmap_File(path.c_str(), SURFACE_ID_LEVEL_TILESET))
+ snprint(path, sizeof path, "%s/Prt%s", path_dir, gTMT[no].parts);
+ if (!ReloadBitmap_File(path, SURFACE_ID_LEVEL_TILESET))
bError = TRUE;
- path = path_dir + '/' + gTMT[no].parts + ".pxa";
- if (!LoadAttributeData(path.c_str()))
+ snprint(path, sizeof path, "%s/%s.pxa", path_dir, gTMT[no].map);
+ if (!LoadAttributeData(path))
bError = TRUE;
// Load tilemap
- path = path_dir + '/' + gTMT[no].map + ".pxm";
- if (!LoadMapData2(path.c_str()))
+ snprint(path, sizeof path, "%s/%s.pxm", path_dir, gTMT[no].map);
+ if (!LoadMapData2(path))
bError = TRUE;
// Load NPCs
- path = path_dir + '/' + gTMT[no].map + ".pxe";
- if (!LoadEvent(path.c_str()))
+ snprint(path, sizeof path, "%s/%s.pxe", path_dir, gTMT[no].map);
+ if (!LoadEvent(path))
bError = TRUE;
// Load script
- path = path_dir + '/' + gTMT[no].map + ".tsc";
- if (!LoadTextScript_Stage(path.c_str()))
+ snprint(path, sizeof path, "%s/%s.tsc", path_dir, gTMT[no].map);
+ if (!LoadTextScript_Stage(path))
bError = TRUE;
// Load background
- path = gTMT[no].back;
- if (!InitBack(path.c_str(), gTMT[no].bkType))
+ snprint(path, sizeof path, "%s", gTMT[no].back);
+ if (!InitBack(path, gTMT[no].bkType))
bError = TRUE;
// Get path
- path_dir = "Npc";
+ snprint(path_dir, sizeof path_dir, "Npc");
// Load NPC sprite sheets
- path = path_dir + "/Npc" + gTMT[no].npc;
- if (!ReloadBitmap_File(path.c_str(), SURFACE_ID_LEVEL_SPRITESET_1))
+ snprint(path, sizeof path, "%s/Npc%s", path_dir, gTMT[no].npc);
+ if (!ReloadBitmap_File(path, SURFACE_ID_LEVEL_SPRITESET_1))
bError = TRUE;
- path = path_dir + "/Npc" + gTMT[no].boss;
- if (!ReloadBitmap_File(path.c_str(), SURFACE_ID_LEVEL_SPRITESET_2))
+ snprint(path, sizeof path, "%s/Npc%s", path_dir, gTMT[no].boss);
+ if (!ReloadBitmap_File(path, SURFACE_ID_LEVEL_SPRITESET_2))
bError = TRUE;
if (bError)
--- a/src/TextScr.cpp
+++ b/src/TextScr.cpp
@@ -11,7 +11,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <string>
#include "WindowsWrapper.h"
@@ -133,17 +132,17 @@
BOOL LoadTextScript2(const char *name)
{
FILE *fp;
- std::string path;
+ char path[128];
// Get path
- path = gDataPath + '/' + name;
+ snprint(path, sizeof path, "%s/%s", gDataPath, name);
- gTS.size = GetFileSizeLong(path.c_str());
+ gTS.size = GetFileSizeLong(path);
if (gTS.size == -1)
return FALSE;
// Open file
- fp = fopen(path.c_str(), "rb");
+ fp = fopen(path, "rb");
if (fp == NULL)
return FALSE;
@@ -165,14 +164,14 @@
BOOL LoadTextScript_Stage(const char *name)
{
FILE *fp;
- std::string path;
+ char path[128];
long head_size;
long body_size;
// Open Head.tsc
- path = gDataPath + "/Head.tsc";
+ snprint(path, sizeof path, "%s/Head.tsc", gDataPath);
- head_size = GetFileSizeLong(path.c_str());
+ head_size = GetFileSizeLong(path);
if (head_size == -1)
return FALSE;
@@ -183,7 +182,7 @@
return FALSE;
#endif
- fp = fopen(path.c_str(), "rb");
+ fp = fopen(path, "rb");
if (fp == NULL)
return FALSE;
@@ -194,9 +193,9 @@
fclose(fp);
// Open stage's .tsc
- path = gDataPath + '/' + name;
+ snprint(path, sizeof path, "%s/%s", name);
- body_size = GetFileSizeLong(path.c_str());
+ body_size = GetFileSizeLong(path);
if (body_size == -1)
return FALSE;
@@ -206,7 +205,7 @@
return FALSE;
#endif
- fp = fopen(path.c_str(), "rb");
+ fp = fopen(path, "rb");
if (fp == NULL)
return FALSE;
@@ -224,7 +223,7 @@
}
// Get current path
-std::string GetTextScriptPath(void)
+char *GetTextScriptPath(void)
{
return gTS.path;
}
--- a/src/TextScr.h
+++ b/src/TextScr.h
@@ -7,14 +7,12 @@
#pragma once
-#include <string>
-
#include "WindowsWrapper.h"
typedef struct TEXT_SCRIPT
{
// Path (reload when exit teleporter menu/inventory)
- std::string path;
+ char *path;
// Script buffer
long size;
@@ -71,7 +69,7 @@
void EncryptionBinaryData2(unsigned char *pData, long size);
BOOL LoadTextScript2(const char *name);
BOOL LoadTextScript_Stage(const char *name);
-std::string GetTextScriptPath(void);
+char* GetTextScriptPath(void);
BOOL StartTextScript(int no);
void StopTextScript(void);
void PutTextScript(void);
--- a/src/WindowsWrapper.h
+++ b/src/WindowsWrapper.h
@@ -9,11 +9,12 @@
#define RGB(r,g,b) ((r) | ((g) << 8) | ((b) << 16))
-typedef bool BOOL;
+typedef int BOOL;
-#define FALSE false
-#define TRUE true
+#define FALSE 0
+#define TRUE 1
+typedef struct RECT RECT;
struct RECT
{
long left;
--- /dev/null
+++ b/src/mkfile
@@ -1,0 +1,85 @@
+</$objtype/mkfile
+
+CFLAGS=-Fpw -I/sys/include/npe -I/sys/include/npe/SDL2 -D__plan9__ -D__${objtype}__ -I../assets
+BIN=/$objtype/bin/games
+TARG=cstory
+
+OFILES=\
+ ArmsItem.$O\
+ Back.$O\
+ Bitmap.$O\
+ Boss.$O\
+ BossAlmo1.$O\
+ BossAlmo2.$O\
+ BossBallos.$O\
+ BossFrog.$O\
+ BossIronH.$O\
+ BossLife.$O\
+ BossOhm.$O\
+ BossPress.$O\
+ BossTwinD.$O\
+ BossX.$O\
+ BulHit.$O\
+ Bullet.$O\
+ Caret.$O\
+ Config.$O\
+ Draw.$O\
+ Ending.$O\
+ Escape.$O\
+ Fade.$O\
+ File.$O\
+ Flags.$O\
+ Flash.$O\
+ Font.$O\
+ Frame.$O\
+ Game.$O\
+ Generic.$O\
+ GenericLoad.$O\
+ Input.$O\
+ KeyControl.$O\
+ Main.$O\
+ Map.$O\
+ MapName.$O\
+ MiniMap.$O\
+ MyChar.$O\
+ MycHit.$O\
+ MycParam.$O\
+ NpcAct000.$O\
+ NpcAct020.$O\
+ NpcAct040.$O\
+ NpcAct060.$O\
+ NpcAct080.$O\
+ NpcAct100.$O\
+ NpcAct120.$O\
+ NpcAct140.$O\
+ NpcAct160.$O\
+ NpcAct180.$O\
+ NpcAct200.$O\
+ NpcAct220.$O\
+ NpcAct240.$O\
+ NpcAct260.$O\
+ NpcAct280.$O\
+ NpcAct300.$O\
+ NpcAct320.$O\
+ NpcAct340.$O\
+ NpChar.$O\
+ NpcHit.$O\
+ NpcTbl.$O\
+ Organya.$O\
+ PixTone.$O\
+ Profile.$O\
+ Random.$O\
+# Resource.$O\
+ SelStage.$O\
+ Shoot.$O\
+ Sound.$O\
+ Stage.$O\
+ Star.$O\
+ TextScr.$O\
+ Triangle.$O\
+ ValueView.$O\
+
+</sys/src/cmd/mkone
+
+%.$O: %.cpp
+ $CC $CFLAGS -o $stem.$O $stem.cpp