From 049b5e373af6b5df2574e602409776c7c30ed865 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 22 Sep 2020 00:33:50 +0100 Subject: [PATCH 1/3] Backport the portable branch's PHILOSOPHY.md --- PHILOSOPHY.md | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/PHILOSOPHY.md b/PHILOSOPHY.md index 0434e029..eee5cf67 100644 --- a/PHILOSOPHY.md +++ b/PHILOSOPHY.md @@ -25,31 +25,36 @@ know from the [Organya source code release](https://github.com/shbow/organya/) what Pixel's code-style looked like, and I find it **extremely** hard to read. ## Language -Cave Story's developer, Pixel, primarily speaks Japanese, but his code's +Cave Story's developer (Pixel) primarily speaks Japanese, but his code's variable/function names are mostly written in English (with a few rare instances of Romanised Japanese). -The Organya source code release indicates Pixel wrote his comments in Japanese, -however, in this project, I prefer them to be written in English. +The Organya source code release indicates that Pixel wrote his comments in +Japanese, however, in this project, I prefer them to be written in English. The English employed in this project is a mix of American English, Canadian English, and British English. + + # `portable` branch This branch takes a different direction to the `accurate` branch, but they still -share some core philosophies: +share many core philosophies: ## Goal -The goal is still to accurately-reproduce Cave Story's original code, but -modified to the extent that it is easy to port to other platforms. This branch -is intended for purists that don't want to use Windows or its deprecated APIs. +While accurately-reproducing Cave Story's original code is still a priority, the +main focus of this branch is to port the game to other platforms, while also +preserving the game the way it was experienced back in 2004. -Notably, this means bugs should still be left intact. However, bugs and other -coding errors that affect portability should be fixed. +Essentially, this branch exists to provide a purist Cave Story experience +without requiring an old Windows XP computer. -For comparison, I believe this branch shares some parallels with the -Chocolate Doom project, except perhaps more strict. See the link below for their -list of philosophies which may be applicable here: +Notably, this means that bugs should still be left intact. However, bugs and +other coding errors that affect portability should be fixed. + +For comparison, I believe this branch shares many parallels with the +Chocolate Doom project. Follow the link below to see that project's list of +philosophies, which may be applicable here: https://github.com/chocolate-doom/chocolate-doom/blob/master/PHILOSOPHY.md From ab217f7f6fb84b7fed76fad366c8838c5215a1ed Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 22 Sep 2020 01:43:09 +0100 Subject: [PATCH 2/3] Document MakePixToneObject a bit more --- src/Sound.cpp | 55 ++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/src/Sound.cpp b/src/Sound.cpp index 0816ca65..9b596cc0 100644 --- a/src/Sound.cpp +++ b/src/Sound.cpp @@ -297,22 +297,19 @@ void ChangeSoundPan(int no, long pan) // 512がMAXで256がノーマル (512 is int MakePixToneObject(const PIXTONEPARAMETER *ptp, int ptp_num, int no) { // For some reason, this function creates an entire WAV file header, - // when it only needs a WAVEFORMATEX + // when it only needs a WAVEFORMATEX. + // From what I can tell, there's no struct like this in the Windows + // headers, so Pixel must have defined it manually, just like this: typedef struct WavHeader { - CHAR riff[4]; - DWORD wav_size; - CHAR wave[4]; - CHAR fmt[4]; - DWORD fmt_chunk_size; - WORD audio_format; - WORD num_channels; - DWORD sample_rate; - DWORD byte_rate; - WORD sample_alignment; - WORD bit_depth; - CHAR data[4]; - DWORD data_bytes; + FOURCC riff_id; + DWORD riff_size; + FOURCC wave_id; + FOURCC fmt_id; + DWORD fmt_size; + PCMWAVEFORMAT format; + FOURCC data_id; + DWORD data_size; } WavHeader; int sample_count; @@ -327,23 +324,23 @@ int MakePixToneObject(const PIXTONEPARAMETER *ptp, int ptp_num, int no) return 0; const char *riff = "RIFF"; - const char *fmt = "fmt "; + const char *fmt = "fmt "; const char *wave = "WAVE"; const char *data = "data"; - wav_header.bit_depth = 8; - wav_header.sample_rate = 22050; - wav_header.num_channels = 1; - wav_header.audio_format = WAVE_FORMAT_PCM; - wav_header.fmt_chunk_size = 16; - memcpy(wav_header.riff, riff, 4); - memcpy(wav_header.fmt, fmt, 4); - memcpy(wav_header.wave, wave, 4); - memcpy(wav_header.data, data, 4); - wav_header.sample_alignment = (wav_header.bit_depth / 8) * wav_header.num_channels; - wav_header.byte_rate = (wav_header.bit_depth / 8) * wav_header.num_channels * wav_header.sample_rate; - wav_header.data_bytes = wav_header.sample_alignment * ptp->size; // Note that this uses ptp->size, not sample_count. If this header were ever used, it would be incorrect. - wav_header.wav_size = wav_header.data_bytes + 36; + wav_header.format.wBitsPerSample = 8; + wav_header.format.wf.nSamplesPerSec = 22050; + wav_header.format.wf.nChannels = 1; + wav_header.format.wf.wFormatTag = WAVE_FORMAT_PCM; + wav_header.fmt_size = sizeof(wav_header.format); + memcpy(&wav_header.riff_id, riff, sizeof(FOURCC)); + memcpy(&wav_header.fmt_id, fmt, sizeof(FOURCC)); + memcpy(&wav_header.wave_id, wave, sizeof(FOURCC)); + memcpy(&wav_header.data_id, data, sizeof(FOURCC)); + wav_header.format.wf.nBlockAlign = (wav_header.format.wBitsPerSample / 8) * wav_header.format.wf.nChannels; + wav_header.format.wf.nAvgBytesPerSec = (wav_header.format.wBitsPerSample / 8) * wav_header.format.wf.nChannels * wav_header.format.wf.nSamplesPerSec; + wav_header.data_size = wav_header.format.wf.nBlockAlign * ptp->size; // Note that this uses ptp->size, not sample_count. If this header were ever used, it would be incorrect. + wav_header.riff_size = sizeof(wav_header) - 8 + wav_header.data_size; ptp_pointer = ptp; sample_count = 0; @@ -360,7 +357,7 @@ int MakePixToneObject(const PIXTONEPARAMETER *ptp, int ptp_num, int no) dsbd.dwSize = sizeof(dsbd); dsbd.dwFlags = DSBCAPS_STATIC | DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY; dsbd.dwBufferBytes = sample_count; - dsbd.lpwfxFormat = (WAVEFORMATEX*)&wav_header.audio_format; + dsbd.lpwfxFormat = (LPWAVEFORMATEX)&wav_header.format; if (lpDS->CreateSoundBuffer(&dsbd, &lpSECONDARYBUFFER[no], 0) != DS_OK) return -1; From 098aae8d73ba692f1b598ba81fff30fae13a55ca Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sat, 26 Sep 2020 23:25:02 +0100 Subject: [PATCH 3/3] Ignore Visual Studio 2019 stuff --- .gitignore | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.gitignore b/.gitignore index b494a505..89807ac3 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,29 @@ /game_japanese/CSE2_debug.rpx /game_japanese/CSE2.rpx +# Exclude MSVC debug data +/game_english/CSE2_debug.ilk +/game_english/CSE2_debug.pdb +/game_english/DoConfig_debug.ilk +/game_english/DoConfig_debug.pdb +/game_english/CSE2.ilk +/game_english/CSE2.pdb +/game_english/DoConfig.ilk +/game_english/DoConfig.pdb +/game_japanese/CSE2_debug.ilk +/game_japanese/CSE2_debug.pdb +/game_japanese/DoConfig_debug.ilk +/game_japanese/DoConfig_debug.pdb +/game_japanese/CSE2.ilk +/game_japanese/CSE2.pdb +/game_japanese/DoConfig.ilk +/game_japanese/DoConfig.pdb + +# Exclude misc. MSVC junk +/.vs +/out +/CMakeSettings.json + # Exclude save data /game_english/Config.dat /game_english/Profile.dat