Removed the WINDOWS and NONPORTABLE stuff

Now that all the ASM-accurate stuff is in its own branch, we don't
need these anymore.
This commit is contained in:
Clownacy 2019-09-04 00:54:11 +01:00
parent 5ea356a3bd
commit 73e18b4610
12 changed files with 8 additions and 144 deletions

View file

@ -44,7 +44,7 @@ ifeq ($(DEBUG_SAVE), 1)
CXXFLAGS += -DDEBUG_SAVE
endif
CXXFLAGS += -std=c++98 -MMD -MP -MF $@.d -DWINDOWS `pkg-config sdl2 --cflags`
CXXFLAGS += -std=c++98 -MMD -MP -MF $@.d `pkg-config sdl2 --cflags`
LIBS += -lkernel32 -lgdi32 -lddraw -ldinput -ldsound -lversion -lshlwapi -limm32 -lwinmm -ldxguid
ifeq ($(STATIC), 1)

View file

@ -32,30 +32,6 @@ BOOL InitBack(const char *fName, int type)
if (fp == NULL)
return FALSE;
#ifdef NONPORTABLE
// This is ridiculously platform-dependant:
// It should break on big-endian CPUs, and platforms where short isn't 16-bit and long isn't 32-bit.
unsigned short bmp_header_buffer[7]; // These names aren't the original. This ruins the stack frame layout.
unsigned long bmp_header_buffer2[10];
fread(bmp_header_buffer, 14, 1, fp);
// Check if this is a valid bitmap file
if (bmp_header_buffer[0] != 0x4D42) // 'MB' (we use hex to prevent a compiler warning)
{
#ifdef FIX_BUGS
// The original game forgets to close fp
fclose(fp);
#endif
return FALSE;
}
fread(bmp_header_buffer2, 40, 1, fp);
fclose(fp);
gBack.partsW = bmp_header_buffer2[1];
gBack.partsH = bmp_header_buffer2[2];
#else
if (fgetc(fp) != 'B' || fgetc(fp) != 'M')
{
fclose(fp);
@ -67,7 +43,6 @@ BOOL InitBack(const char *fName, int type)
gBack.partsW = File_ReadLE32(fp);
gBack.partsH = File_ReadLE32(fp);
fclose(fp);
#endif
// Set background stuff and load texture
gBack.flag = 1;

View file

@ -25,10 +25,6 @@ BOOL LoadConfigData(CONFIG *conf)
if (fp == NULL)
return FALSE;
// Read data
#ifdef NONPORTABLE
size_t fread_result = fread(conf, sizeof(CONFIG), 1, fp); // Not the original name
#else
// Read the version id and font name
fread(conf->proof, sizeof(conf->proof), 1, fp);
fread(conf->font_name, sizeof(conf->font_name), 1, fp);
@ -45,17 +41,12 @@ BOOL LoadConfigData(CONFIG *conf)
conf->bJoystick = File_ReadLE32(fp);
for (int button = 0; button < 8; button++)
conf->joystick_button[button] = File_ReadLE32(fp);
#endif
// Close file
fclose(fp);
// Check if version is not correct, and return if it failed
#ifdef NONPORTABLE
if (fread_result != 1 || strcmp(conf->proof, config_magic))
#else
if (strcmp(conf->proof, config_magic))
#endif
{
memset(conf, 0, sizeof(CONFIG));
return FALSE;

View file

@ -51,14 +51,8 @@ BOOL LoadMapData2(const char *path_map)
{
fread(&dum, 1, 1, fp);
// Get width and height
#ifdef NONPORTABLE
// This fails on big-endian hardware, and platforms where short is not two bytes long.
fread(&gMap.width, 2, 1, fp);
fread(&gMap.length, 2, 1, fp);
#else
gMap.width = File_ReadLE16(fp);
gMap.length = File_ReadLE16(fp);
#endif
if (gMap.data == NULL)
{

View file

@ -2,6 +2,8 @@
#include <stdio.h>
#include "SDL.h"
#include "WindowsWrapper.h"
#include "ArmsItem.h"
@ -450,9 +452,6 @@ BOOL SaveTimeCounter()
if (fp)
{
// Read data
#ifdef NONPORTABLE
fread(&rec, sizeof(REC), 1, fp);
#else
rec.counter[0] = File_ReadLE32(fp);
rec.counter[1] = File_ReadLE32(fp);
rec.counter[2] = File_ReadLE32(fp);
@ -461,21 +460,13 @@ BOOL SaveTimeCounter()
rec.random[1] = fgetc(fp);
rec.random[2] = fgetc(fp);
rec.random[3] = fgetc(fp);
#endif
fclose(fp);
p = (unsigned char*)&rec.counter[0];
#ifdef NONPORTABLE
p[0] -= rec.random[0];
p[1] -= rec.random[0];
p[2] -= rec.random[0];
p[3] -= rec.random[0] / 2;
#else
p[0] -= (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[0]) : (rec.random[0] / 2);
p[1] -= rec.random[0];
p[2] -= rec.random[0];
p[3] -= (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[0] / 2) : (rec.random[0]);
#endif
// If this is faster than our new time, quit
if (rec.counter[0] < time_count)
return TRUE;
@ -488,26 +479,16 @@ BOOL SaveTimeCounter()
rec.random[i] = Random(0, 250) + i;
p = (unsigned char*)&rec.counter[i];
#ifdef NONPORTABLE
p[0] += rec.random[i];
p[1] += rec.random[i];
p[2] += rec.random[i];
p[3] += rec.random[i] / 2;
#else
p[0] += (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[i]) : (rec.random[i] / 2);
p[1] += rec.random[i];
p[2] += rec.random[i];
p[3] += (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[i] / 2) : (rec.random[i]);
#endif
}
fp = fopen(path, "wb");
if (fp == NULL)
return FALSE;
#ifdef NONPORTABLE
fwrite(&rec, sizeof(REC), 1, fp);
#else
File_WriteLE32(rec.counter[0], fp);
File_WriteLE32(rec.counter[1], fp);
File_WriteLE32(rec.counter[2], fp);
@ -516,7 +497,6 @@ BOOL SaveTimeCounter()
fputc(rec.random[1], fp);
fputc(rec.random[2], fp);
fputc(rec.random[3], fp);
#endif
fclose(fp);
return TRUE;
@ -538,9 +518,6 @@ int LoadTimeCounter()
REC rec;
// Read data
#ifdef NONPORTABLE
fread(&rec, sizeof(REC), 1, fp);
#else
rec.counter[0] = File_ReadLE32(fp);
rec.counter[1] = File_ReadLE32(fp);
rec.counter[2] = File_ReadLE32(fp);
@ -549,24 +526,16 @@ int LoadTimeCounter()
rec.random[1] = fgetc(fp);
rec.random[2] = fgetc(fp);
rec.random[3] = fgetc(fp);
#endif
fclose(fp);
// Decode from checksum
for (i = 0; i < 4; i++)
{
p = (unsigned char*)&rec.counter[i];
#ifdef NONPORTABLE
p[0] -= rec.random[i];
p[1] -= rec.random[i];
p[2] -= rec.random[i];
p[3] -= rec.random[i] / 2;
#else
p[0] -= (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[i]) : (rec.random[i] / 2);
p[1] -= rec.random[i];
p[2] -= rec.random[i];
p[3] -= (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[i] / 2) : (rec.random[i]);
#endif
}
// Verify checksum's result

View file

@ -79,11 +79,7 @@ BOOL LoadEvent(const char *path_event)
}
// Get amount of NPCs
#ifdef NONPORTABLE
fread(&count, 4, 1, fp);
#else
count = File_ReadLE32(fp);
#endif
// Load NPCs
memset(gNPC, 0, sizeof(gNPC));
@ -92,16 +88,12 @@ BOOL LoadEvent(const char *path_event)
for (i = 0; i < count; i++)
{
// Get data from file
#ifdef NONPORTABLE
fread(&eve, sizeof(EVENT), 1, fp);
#else
eve.x = File_ReadLE16(fp);
eve.y = File_ReadLE16(fp);
eve.code_flag = File_ReadLE16(fp);
eve.code_event = File_ReadLE16(fp);
eve.code_char = File_ReadLE16(fp);
eve.bits = File_ReadLE16(fp);
#endif
// Set NPC parameters
gNPC[n].direct = (eve.bits & NPC_SPAWN_IN_OTHER_DIRECTION) ? 2 : 0;

View file

@ -37,28 +37,6 @@ BOOL LoadNpcTable(const char *path)
return FALSE;
}
#ifdef NONPORTABLE
for (n = 0; n < num; n++) // bits
fread(&gNpcTable[n].bits, 2, 1, fp);
for (n = 0; n < num; n++) // life
fread(&gNpcTable[n].life, 2, 1, fp);
for (n = 0; n < num; n++) // surf
fread(&gNpcTable[n].surf, 1, 1, fp);
for (n = 0; n < num; n++) // destroy_voice
fread(&gNpcTable[n].destroy_voice, 1, 1, fp);
for (n = 0; n < num; n++) // hit_voice
fread(&gNpcTable[n].hit_voice, 1, 1, fp);
for (n = 0; n < num; n++) // size
fread(&gNpcTable[n].size, 1, 1, fp);
for (n = 0; n < num; n++) // exp
fread(&gNpcTable[n].exp, 4, 1, fp);
for (n = 0; n < num; n++) // damage
fread(&gNpcTable[n].damage, 4, 1, fp);
for (n = 0; n < num; n++) // hit
fread(&gNpcTable[n].hit, 4, 1, fp);
for (n = 0; n < num; n++) // view
fread(&gNpcTable[n].view, 4, 1, fp);
#else
for (n = 0; n < num; n++) // bits
gNpcTable[n].bits = File_ReadLE16(fp);
for (n = 0; n < num; n++) // life
@ -79,7 +57,6 @@ BOOL LoadNpcTable(const char *path)
fread(&gNpcTable[n].hit, 4, 1, fp);
for (n = 0; n < num; n++) // view
fread(&gNpcTable[n].view, 4, 1, fp);
#endif
fclose(fp);
return TRUE;

View file

@ -80,9 +80,6 @@ BOOL SaveProfile(const char *name)
memcpy(profile.flags, gFlagNPC, sizeof(profile.flags));
// Write to file
#ifdef NONPORTABLE
fwrite(&profile, sizeof(PROFILE), 1, fp);
#else
fwrite(profile.code, 8, 1, fp);
File_WriteLE32(profile.stage, fp);
File_WriteLE32(profile.music, fp);
@ -116,7 +113,6 @@ BOOL SaveProfile(const char *name)
fwrite(profile.permit_mapping, 0x80, 1, fp);
fwrite(FLAG, 4, 1, fp);
fwrite(profile.flags, 1000, 1, fp);
#endif
fclose(fp);
return TRUE;
@ -152,9 +148,6 @@ BOOL LoadProfile(const char *name)
// Read data
fseek(fp, 0, SEEK_SET);
memset(&profile, 0, sizeof(PROFILE));
#ifdef NONPORTABLE
fread(&profile, sizeof(PROFILE), 1, fp);
#else
fread(profile.code, 8, 1, fp);
profile.stage = File_ReadLE32(fp);
profile.music = (MusicID)File_ReadLE32(fp);
@ -188,7 +181,6 @@ BOOL LoadProfile(const char *name)
fread(profile.permit_mapping, 0x80, 1, fp);
fread(profile.FLAG, 4, 1, fp);
fread(profile.flags, 1000, 1, fp);
#endif
fclose(fp);
// Set things

View file

@ -82,11 +82,7 @@ static const struct
{"ORG", "BALLOS", rBallos, sizeof(rBallos)},
{"ORG", "BDOWN", rBreakDown, sizeof(rBreakDown)},
{"ORG", "CEMETERY", rCemetery, sizeof(rCemetery)},
#ifdef NONPORTABLE
{"ORG", "Curly", rCurly, sizeof(rCurly)},
#else
{"ORG", "CURLY", rCurly, sizeof(rCurly)},
#endif
{"ORG", "DR", rDr, sizeof(rDr)},
{"ORG", "ENDING", rEnding, sizeof(rEnding)},
{"ORG", "ESCAPE", rEscape, sizeof(rEscape)},

View file

@ -224,11 +224,7 @@ const char *gMusicTable[42] =
"ACCESS",
"IRONH",
"GRAND",
#ifdef NONPORTABLE
"Curly", // The vanilla game used the original filename instead of the internal 8.3 one
#else
"CURLY",
#endif
"OSIDE",
"REQUIEM",
"WANPAK2",

View file

@ -1263,20 +1263,11 @@ int TextScriptProc()
{
char str_0[0x40];
#ifdef JAPANESE
#if defined(NONPORTABLE) && defined(WINDOWS)
sprintf(str_0, "\x95\x73\x96\xBE\x82\xCC\x83\x52\x81\x5B\x83\x68:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]);
MessageBoxA(NULL, str_0, "\x83\x47\x83\x89\x81\x5B", MB_OK);
#else
sprintf(str_0, "不明のコード:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "エラー", str_0, NULL);
#endif
sprintf(str_0, "不明のコード:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "エラー", str_0, NULL);
#else
sprintf(str_0, "Unknown code:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]);
#if defined(NONPORTABLE) && defined(WINDOWS)
MessageBoxA(NULL, str_0, "Error", MB_OK);
#else
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", str_0, NULL);
#endif
sprintf(str_0, "Unknown code:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", str_0, NULL);
#endif
return 0;

View file

@ -1,13 +1,5 @@
#pragma once
/*
#ifdef WINDOWS
#include <windows.h>
// Avoid name collisions
#undef DrawText
#undef FindResource
#undef CreateWindow
#else
*/
#include <stdio.h>
typedef int HWND;
@ -32,7 +24,6 @@ struct RECT
long right;
long bottom;
};
//#endif
#define SET_RECT(rect, l, t, r, b) \
rect.left = l; \