diff --git a/src/BRSRC13/CMakeLists.txt b/src/BRSRC13/CMakeLists.txt index a8895ec7..dabfd9ee 100644 --- a/src/BRSRC13/CMakeLists.txt +++ b/src/BRSRC13/CMakeLists.txt @@ -15,12 +15,15 @@ target_link_libraries(brender PRIVATE harness compile_with_werror) if(NOT MSVC) target_compile_options(brender PRIVATE -Wall + ) + add_compile_flags_if_supported(brender -Wno-return-type -Wno-unused-variable -Wno-unused-parameter -Wno-sign-compare -Wno-int-conversion #todo! -Wno-strict-aliasing + -Wstrict-prototypes ) target_link_libraries(brender PUBLIC m) diff --git a/src/DETHRACE/CMakeLists.txt b/src/DETHRACE/CMakeLists.txt index d75e78d8..db255787 100644 --- a/src/DETHRACE/CMakeLists.txt +++ b/src/DETHRACE/CMakeLists.txt @@ -32,6 +32,7 @@ else() -Wno-error=format-overflow -Wno-error=unused-but-set-variable # (SelectRaceDraw::test2), etc -Wno-format-overflow + -Wstrict-prototypes ) endif() if(DETHRACE_FIX_BUGS) diff --git a/src/DETHRACE/common/demo.c b/src/DETHRACE/common/demo.c index 2cfbc2ea..d3da987c 100644 --- a/src/DETHRACE/common/demo.c +++ b/src/DETHRACE/common/demo.c @@ -67,7 +67,7 @@ void DoDemo() { } } S3StopSound(song_tag); - S3StopAllOutletSounds(gEffects_outlet); + S3StopOutletSound(gEffects_outlet); S3StopAllOutletSounds(); fclose(f); FadePaletteDown(); diff --git a/src/DETHRACE/common/flicplay.c b/src/DETHRACE/common/flicplay.c index a7081a4e..5fcb525f 100644 --- a/src/DETHRACE/common/flicplay.c +++ b/src/DETHRACE/common/flicplay.c @@ -1440,7 +1440,7 @@ int PlayNextFlicFrame(tFlic_descriptor* pFlic_info) { } // IDA: int __usercall PlayFlic@(int pIndex@, tU32 pSize@, tS8 *pData_ptr@, br_pixelmap *pDest_pixelmap@, int pX_offset, int pY_offset, void (*DoPerFrame)(), int pInterruptable, int pFrame_rate) -int PlayFlic(int pIndex, tU32 pSize, tS8* pData_ptr, br_pixelmap* pDest_pixelmap, int pX_offset, int pY_offset, void (*DoPerFrame)(), int pInterruptable, int pFrame_rate) { +int PlayFlic(int pIndex, tU32 pSize, tS8* pData_ptr, br_pixelmap* pDest_pixelmap, int pX_offset, int pY_offset, void (*DoPerFrame)(void), int pInterruptable, int pFrame_rate) { int finished_playing; tFlic_descriptor the_flic; tU32 last_frame; diff --git a/src/DETHRACE/common/sound.c b/src/DETHRACE/common/sound.c index 19ce6d83..eb48ac91 100644 --- a/src/DETHRACE/common/sound.c +++ b/src/DETHRACE/common/sound.c @@ -13,6 +13,7 @@ #include "piping.h" #include "replay.h" #include "s3/s3.h" +#include "s3/s3_brender.h" #include "utility.h" int gSound_detail_level; diff --git a/src/DETHRACE/pc-dos/dosnet.c b/src/DETHRACE/pc-dos/dosnet.c index 6ec8654b..e33e48ae 100644 --- a/src/DETHRACE/pc-dos/dosnet.c +++ b/src/DETHRACE/pc-dos/dosnet.c @@ -36,6 +36,32 @@ unsigned short gECB_offset; tU16 gListen_selector; tU16 gSend_selector; +/*static*/ void ClearupPDNetworkStuff(void); +/*static*/ void MATTMessageCheck(char* pFunction_name, tNet_message* pMessage, int pAlleged_size); +/*static*/ int GetProfileText(char* pDest, int pDest_len, char* pFname, char* pKeyname); +/*static*/ int GetSocketNumberFromProfileFile(void); +/*static*/ tU32 EthernetAddressToU32(_IPX_LOCAL_TARGET* pAddr_ipx); +/*static*/ void NetNowIPXLocalTarget2String(char* pString, _IPX_LOCAL_TARGET* pSock_addr_ipx); +/*static*/ int GetMessageTypeFromMessage(char* pMessage_str) ; +/*static*/ int SameEthernetAddress(_IPX_LOCAL_TARGET* pAddr_ipx1, _IPX_LOCAL_TARGET* pAddr_ipx2); +/*static*/ _IPX_LOCAL_TARGET* GetIPXAddrFromPlayerID(tPlayer_ID pPlayer_id); +/*static*/ void MakeMessageToSend(int pMessage_type); +/*static*/ int ReceiveHostResponses(void); +/*static*/ int BroadcastMessage(void); +/*static*/ int hmiIPXCloseSocket(W32 wSocket); +/*static*/ void hmiIPXListenForPacket(_IPX_ECB* pECB_ptr, tU32 pOffset); +/*static*/ int hmiIPXPostListen(_IPX_ECB* pECB_ptr, tU32 pOffset); +/*static*/ int hmiIPXGetData(char* pData, tU32 wDSize); +/*static*/ void hmiIPXSendPacket(_IPX_ECB* sECB, _IPX_ECB** pPacket, char* pHeader, W32 wSize); +/*static*/ int hmiIPXSendDataDirect(char* pHeader, W32 wHSize, char* pData, W32 wDSize, _NETNOW_NODE_ADDR* sNode); +/*static*/ void hmiIPXGetInternetworkAddr(_IPX_INTERNET_ADDR* sInterworkAddr); +/*static*/ void hmiIPXGetLocalTarget(_IPX_LOCAL_TARGET* sNetworkAddr); +/*static*/ int AllocateRealMem(W32 wSize, char** pPtr, W32* pSegment, tU16* pSelector); +/*static*/ int FreeRealMem(tU16 pSelector); +/*static*/ int hmiIPXInstalled(void); +/*static*/ void GetLargestPacketSizeOoErBetterInsertLinfordChristieJokeHere(void); +/*static*/ void GetIPXToStickItsEarToTheGround(void); + // IDA: void __cdecl ClearupPDNetworkStuff() void ClearupPDNetworkStuff() { LOG_TRACE("()"); diff --git a/src/DETHRACE/pc-win95/ssdx.h b/src/DETHRACE/pc-win95/ssdx.h index fb304f24..f0e566b5 100644 --- a/src/DETHRACE/pc-win95/ssdx.h +++ b/src/DETHRACE/pc-win95/ssdx.h @@ -8,8 +8,8 @@ int SSDXStart(void* hWnd, int windowed, int flags); int SSDXInitDirectDraw(int width, int height, int* row_bytes); -void SSDXRelease(); -void SSDXLockAttachedSurface(); +void SSDXRelease(void); +void SSDXLockAttachedSurface(void); void SSDXGetWindowRect(void* hWnd); void SSDXHandleError(int error); diff --git a/src/DETHRACE/pc-win95/win95sys.c b/src/DETHRACE/pc-win95/win95sys.c index 42153d07..d57278d2 100644 --- a/src/DETHRACE/pc-win95/win95sys.c +++ b/src/DETHRACE/pc-win95/win95sys.c @@ -77,17 +77,34 @@ int gNetwork_profile_file_exists = 0; char* _unittest_last_fatal_error; -void Win32InitScreen(); -void Win32PumpMessages(); -void Win32ReleaseInputDevice(); -void Win32FatalError(char* pStr_1, char* pStr_2); -void Win32BRenderWarningFunc(char* msg); -void Win32BRenderFailureFunc(char* msg); -void Win32AllocateActionReplayBuffer(); -void Win32CreateWindow(); -void Win32InitInputDevice(); +int original_main(int pArgc, char** pArgv); -extern void QuitGame(); +/*static*/ void KeyboardHandler(void); +/*static*/ int KeyDown(tU8 pScan_code); +/*static*/ void KeyTranslation(tU8 pKey_index, tU8 pScan_code_1, tU8 pScan_code_2); +/*static*/ void KeyBegin(void); +/*static*/ void KeyEnd(void); +/*static*/ int KeyDown22(int pKey_index); +static void Win32ReleaseInputDevice(void); +static void Win32PumpMessages(void); +static HARNESS_NORETURN void Win32FatalError(char* pStr_1, char* pStr_2); +static void Win32CreateWindow(void); +static void Win32InitScreen(void); +/*static*/ void Copy8BitTo16BitPixelmap(br_pixelmap* pDst, br_pixelmap* pSrc, br_pixelmap* pPalette); +/*static*/ void SwapBackScreen(void); +/*static*/ void ReallyCopyBackScreen(int pRendering_area_only, int pClear_top_and_bottom); +/*static*/ void CopyBackScreen(int pRendering_area_only); +static void Win32SetPaletteEntries(uint8_t* entries, int pFirst_colour, int pCount); +static void Win32InitInputDevice(void); +static void Win32AllocateActionReplayBuffer(void); +static void Usage(char* pProgpath); +/*static*/ int OurGetChar(void); +/*static*/ int InitJoysticks(void); +/*static*/ tU32 ReadJoystickAxis(int pBit); +static void Win32BRenderWarningFunc(char* msg); +static void Win32BRenderFailureFunc(char* msg); + +extern void QuitGame(void); void KeyboardHandler() { tU8 scan_code; diff --git a/src/DETHRACE/pd/sys.h b/src/DETHRACE/pd/sys.h index d9ddead3..ad4f79fb 100644 --- a/src/DETHRACE/pd/sys.h +++ b/src/DETHRACE/pd/sys.h @@ -68,7 +68,7 @@ void PDSetKeyArray(int* pKeys, int pMark); int PDGetASCIIFromKey(int pKey); -void PDFatalError(char* pThe_str); +HARNESS_NORETURN void PDFatalError(char* pThe_str); void PDNonFatalError(char* pThe_str); diff --git a/src/S3/3d.h b/src/S3/3d.h index f010b710..b1225316 100644 --- a/src/S3/3d.h +++ b/src/S3/3d.h @@ -6,8 +6,8 @@ void S3Set3DSoundEnvironment(float a1, float a2, float a3); -void S3UpdateListenerVectors(); -void S3ServiceSoundSources(); +void S3UpdateListenerVectors(void); +void S3ServiceSoundSources(void); int S3UpdateSpatialSound(tS3_channel* chan); int S3BindAmbientSoundToOutlet(tS3_outlet* pOutlet, int pSound, tS3_sound_source* source, float pMax_distance, int pPeriod, int pRepeats, int pVolume, int pPitch, int pSpeed); void S3UpdateSoundSource(tS3_outlet* outlet, tS3_sound_tag tag, tS3_sound_source* src, float pMax_distance_squared, int pPeriod, tS3_repeats pAmbient_repeats, tS3_volume pVolume, int pPitch, tS3_speed pSpeed); diff --git a/src/S3/CMakeLists.txt b/src/S3/CMakeLists.txt index 46e5523a..2771378c 100644 --- a/src/S3/CMakeLists.txt +++ b/src/S3/CMakeLists.txt @@ -2,7 +2,7 @@ add_library(s3 STATIC) target_include_directories(s3 PUBLIC - include + "${CMAKE_CURRENT_SOURCE_DIR}/include" PRIVATE ${CMAKE_SOURCE_DIR} ) @@ -11,6 +11,9 @@ target_link_libraries(s3 PRIVATE brender SDL2::SDL2 harness miniaudio compile_wi if(NOT MSVC) target_link_libraries(s3 PUBLIC pthread m) + add_compile_flags_if_supported(s3 + -Wstrict-prototypes + ) else() target_compile_definitions(s3 PRIVATE -D_CRT_SECURE_NO_WARNINGS) target_compile_options(s3 PRIVATE @@ -45,5 +48,4 @@ target_sources(s3 PRIVATE s3music.h s3sound.c s3sound.h - ) diff --git a/src/S3/audio.c b/src/S3/audio.c index 7decdc06..d7696e89 100644 --- a/src/S3/audio.c +++ b/src/S3/audio.c @@ -1,6 +1,7 @@ #include "audio.h" #include "resource.h" +#include "s3/s3.h" #include "3d.h" #include "harness/config.h" #include "harness/os.h" @@ -16,7 +17,7 @@ #include #include -extern int PDGetTotalTime(); +extern int PDGetTotalTime(void); int gS3_enabled; int gS3_noutlets; diff --git a/src/S3/audio.h b/src/S3/audio.h index e875210d..a231e4f9 100644 --- a/src/S3/audio.h +++ b/src/S3/audio.h @@ -13,26 +13,26 @@ extern int gS3_inside_cockpit; int S3Init(char* path, int low_memory_mode); -void S3Enable(); -void S3Disable(); +void S3Enable(void); +void S3Disable(void); -int S3OpenOutputDevices(); -int S3OpenSampleDevice(); -int S3OpenCDADevice(); +int S3OpenOutputDevices(void); +int S3OpenSampleDevice(void); +int S3OpenCDADevice(void); -int S3OpenSampleDevice(); -void S3CloseDevices(); +int S3OpenSampleDevice(void); +void S3CloseDevices(void); tS3_outlet* S3CreateOutlet(int unk1, int pChannel_count); int S3CreateOutletChannels(tS3_outlet* outlet, int pChannel_count); void S3DisposeOutlet(tS3_outlet* outlet); int S3UnbindChannels(tS3_outlet* outlet); -void S3DisposeUnboundChannels(); +void S3DisposeUnboundChannels(void); tS3_channel* S3AllocateChannel(tS3_outlet* outlet, int priority); int S3StopChannel(tS3_channel* chan); void S3DisposeOutlet(tS3_outlet* outlet); int S3StopOutletSound(tS3_outlet* pOutlet); -void S3StopAllOutletSounds(); +void S3StopAllOutletSounds(void); int S3DisposeDescriptor(tS3_sound_id id); @@ -46,10 +46,10 @@ void S3SoundBankReaderAdvance(tS3_soundbank_read_ctx* buffer, int bytes_read); int S3SoundBankReaderReadFilename(char** filename, tS3_soundbank_read_ctx* ctx, const char* dir_name); int S3SoundBankReadEntry(tS3_soundbank_read_ctx* ctx, char* dir_name, int low_memory_mode); -tS3_descriptor* S3AllocateDescriptor(); +tS3_descriptor* S3AllocateDescriptor(void); tS3_descriptor* S3GetDescriptorByID(tS3_sound_id id); -char* S3GetCurrentDir(); +char* S3GetCurrentDir(void); void S3CalculateRandomizedFields(tS3_channel* chan, tS3_descriptor* desc); int S3IRandomBetween(int pMin, int pMax, int pDefault); @@ -62,7 +62,7 @@ int S3SetOutletVolume(tS3_outlet* pOutlet, tS3_volume pVolume); tS3_channel* S3GetChannelForTag(tS3_sound_tag tag); int S3SetTagVolume(tS3_sound_tag pTag, tS3_volume pVolume); -void S3ServiceOutlets(); +void S3ServiceOutlets(void); int S3ServiceChannel(tS3_channel* chan); void S3Service(int inside_cockpit, int unk1); diff --git a/src/S3/include/s3/s3.h b/src/S3/include/s3/s3.h index 8ad56cf8..95e649d7 100644 --- a/src/S3/include/s3/s3.h +++ b/src/S3/include/s3/s3.h @@ -4,7 +4,8 @@ // External typedefs typedef float tF32; -typedef char* tS3_sound_source_ptr; +typedef struct tS3_sound_source tS3_sound_source; +typedef tS3_sound_source *tS3_sound_source_ptr; typedef int tS3_sound_tag; typedef int tS3_sound_id; typedef int tS3_type; @@ -14,7 +15,8 @@ typedef int tS3_effect_tag; typedef long tS3_priority; typedef long tS3_pitch; typedef long tS3_speed; -typedef char* tS3_outlet_ptr; +typedef struct tS3_outlet tS3_outlet; +typedef tS3_outlet* tS3_outlet_ptr; typedef void tS3_sample_filter(tS3_effect_tag, tS3_sound_tag); @@ -25,14 +27,13 @@ typedef struct tS3_vector3 { } tS3_vector3; int S3Init(char* path, int low_memory_mode); -void S3Shutdown(); +void S3Shutdown(void); -void S3Disable(); -void S3Enable(); +void S3Disable(void); +void S3Enable(void); void S3Set3DSoundEnvironment(float a1, float a2, float a3); -tS3_sound_source_ptr S3CreateSoundSourceBR(br_vector3* pPosition, br_vector3* pVelocity, tS3_outlet_ptr pBound_outlet); -int S3BindAmbientSoundToOutlet(tS3_outlet_ptr pOutlet, int pSound, tS3_sound_source_ptr source, float pMax_distance, int pPeriod, int pRepeats, int pVolume, int pPitch, int pSpeed); +int S3BindAmbientSoundToOutlet(tS3_outlet_ptr pOutlet, int pSound, tS3_sound_source* source, float pMax_distance, int pPeriod, int pRepeats, int pVolume, int pPitch, int pSpeed); tS3_sound_tag S3StartSound3D(tS3_outlet_ptr pOutlet, tS3_sound_id pSound, tS3_vector3* pInitial_position, tS3_vector3* pInitial_velocity, tS3_repeats pRepeats, tS3_volume pVolume, tS3_pitch pPitch, tS3_speed pSpeed); @@ -48,18 +49,14 @@ void S3Service(int inside_cockpit, int unk1); int S3LoadSample(tS3_sound_id id); tS3_sound_tag S3StartSound(tS3_outlet_ptr pOutlet, tS3_sound_id pSound); tS3_sound_tag S3StartSound2(tS3_outlet_ptr pOutlet, tS3_sound_id pSound, tS3_repeats pRepeats, tS3_volume pLVolume, tS3_volume pRVolume, tS3_pitch pPitch, tS3_speed pSpeed); -void S3StopAllOutletSounds(); +void S3StopAllOutletSounds(void); int S3SoundStillPlaying(tS3_sound_tag pSound); int S3StopSound(tS3_sound_tag pSound_tag); int S3StopOutletSound(tS3_outlet_ptr pOutlet); int S3SetOutletVolume(tS3_outlet_ptr pOutlet, tS3_volume pVolume); void S3UpdateSoundSource(tS3_outlet_ptr outlet, tS3_sound_tag tag, tS3_sound_source_ptr src, float pMax_distance_squared, int pPeriod, tS3_repeats pAmbient_repeats, tS3_volume pVolume, int pPitch, tS3_speed pSpeed); -void S3BindListenerPositionBRender(br_vector3* pos); -void S3BindListenerVelocityBRender(br_vector3* vel); -void S3BindListenerLeftBRender(br_vector3* left); - -int S3IsCDAPlaying2(); +int S3IsCDAPlaying2(void); int S3SetEffects(tS3_sample_filter* filter1, tS3_sample_filter* filter2); diff --git a/src/S3/include/s3/s3_brender.h b/src/S3/include/s3/s3_brender.h new file mode 100644 index 00000000..43fa0ba3 --- /dev/null +++ b/src/S3/include/s3/s3_brender.h @@ -0,0 +1,14 @@ +#ifndef S3_S3_BRENDER_H +#define S3_S3_BRENDER_H + +#include "s3.h" + +#include "brender/brender.h" + +tS3_sound_source_ptr S3CreateSoundSourceBR(br_vector3* pPosition, br_vector3* pVelocity, tS3_outlet_ptr pBound_outlet); + +void S3BindListenerPositionBRender(br_vector3* pos); +void S3BindListenerVelocityBRender(br_vector3* vel); +void S3BindListenerLeftBRender(br_vector3* left); + +#endif /* S3_S3_BRENDER_H */ diff --git a/src/S3/s3_defs.h b/src/S3/s3_defs.h index 1ee06c2b..32d8a4a5 100644 --- a/src/S3/s3_defs.h +++ b/src/S3/s3_defs.h @@ -1,6 +1,8 @@ #ifndef S3_TYPES_H #define S3_TYPES_H +#include "s3/s3.h" + #include // extern int PDGetTotalTime(); @@ -12,7 +14,7 @@ // Internal typedefs typedef float tF32; -typedef char* tS3_sound_source_ptr; +typedef tS3_sound_source* tS3_sound_source_ptr; typedef int tS3_sound_tag; typedef int tS3_sound_id; typedef int tS3_type; @@ -22,11 +24,11 @@ typedef int tS3_effect_tag; typedef long tS3_priority; typedef long tS3_pitch; typedef long tS3_speed; -typedef char* tS3_outlet_ptr; typedef struct tS3_outlet tS3_outlet; typedef struct tS3_descriptor tS3_descriptor; typedef struct tS3_channel tS3_channel; typedef struct tS3_sound_source tS3_sound_source; +typedef tS3_outlet* tS3_outlet_ptr; typedef enum tS3_error_codes { eS3_error_none = 0, @@ -72,12 +74,6 @@ typedef enum tS3_sound_type { typedef void tS3_outlet_callback(tS3_outlet*, tS3_sound_tag, tS3_termination_reason); typedef void tS3_sample_filter(tS3_effect_tag, tS3_sound_tag); -typedef struct tS3_vector3 { - tF32 x; - tF32 y; - tF32 z; -} tS3_vector3; - typedef struct tS3_channel { int active; int termination_reason; diff --git a/src/S3/s3cda.h b/src/S3/s3cda.h index d88216c8..d780e4fa 100644 --- a/src/S3/s3cda.h +++ b/src/S3/s3cda.h @@ -3,13 +3,13 @@ #include "s3_defs.h" -void S3DisableCDA(); -void S3StopCDAOutlets(); +void S3DisableCDA(void); +void S3StopCDAOutlets(void); int S3PlayCDA(tS3_channel* chan); int S3StopCDA(tS3_channel* chan); int S3SetCDAVolume(tS3_channel* chan, int pVolume); -int S3IsCDAPlaying(); -int S3IsCDAPlaying2(); +int S3IsCDAPlaying(void); +int S3IsCDAPlaying2(void); #endif diff --git a/src/S3/s3music.h b/src/S3/s3music.h index 22a4ebd6..65e4db6c 100644 --- a/src/S3/s3music.h +++ b/src/S3/s3music.h @@ -3,8 +3,8 @@ #include "s3_defs.h" -void S3DisableMIDI(); -void S3StopMIDIOutlets(); +void S3DisableMIDI(void); +void S3StopMIDIOutlets(void); void S3DisposeMIDIChannel(tS3_sound_tag); int S3PlayMIDI(tS3_channel* chan); int S3MIDILoadSong(tS3_channel* chan); diff --git a/src/S3/s3sound.c b/src/S3/s3sound.c index 31e96670..b4ab571f 100644 --- a/src/S3/s3sound.c +++ b/src/S3/s3sound.c @@ -342,6 +342,7 @@ int S3SyncSampleRate(tS3_channel* chan) { return 1; } -void S3SetEffects(tS3_sample_filter* filter1, tS3_sample_filter* filter2) { +int S3SetEffects(tS3_sample_filter* filter1, tS3_sample_filter* filter2) { STUB_ONCE(); + return 0; } diff --git a/src/harness/CMakeLists.txt b/src/harness/CMakeLists.txt index 5b9bd93c..9cfb8784 100644 --- a/src/harness/CMakeLists.txt +++ b/src/harness/CMakeLists.txt @@ -32,6 +32,9 @@ if(NOT MSVC) -Wextra -Wno-unused-parameter ) + add_compile_flags_if_supported(harness + -Wstrict-prototypes + ) else() target_compile_definitions(harness PRIVATE -D_CRT_SECURE_NO_WARNINGS) endif() @@ -60,8 +63,9 @@ target_sources(harness PRIVATE sound/sound.c sound/sound.h win95/polyfill.c + platforms/null.c platforms/null.h - + "${CMAKE_CURRENT_BINARY_DIR}/version.h" ) diff --git a/src/harness/brender_emu/renderer_impl.h b/src/harness/brender_emu/renderer_impl.h index d80d794a..a1c13699 100644 --- a/src/harness/brender_emu/renderer_impl.h +++ b/src/harness/brender_emu/renderer_impl.h @@ -38,6 +38,6 @@ typedef struct harness_br_renderer { } harness_br_renderer; -harness_br_renderer* NewHarnessBrRenderer(); +harness_br_renderer* NewHarnessBrRenderer(void); -#endif \ No newline at end of file +#endif diff --git a/src/harness/harness.c b/src/harness/harness.c index d88ec26d..b9899921 100644 --- a/src/harness/harness.c +++ b/src/harness/harness.c @@ -22,7 +22,7 @@ br_pixelmap* last_src = NULL; unsigned int last_frame_time = 0; int force_null_platform = 0; -extern unsigned int GetTotalTime(); +extern unsigned int GetTotalTime(void); extern br_v1db_state v1db; extern uint32_t gI_am_cheating; @@ -80,11 +80,11 @@ static int splatpack_xmasdemo_ascii_shift_table[128] = { }; /* clang-format on */ -extern void Harness_Platform_Init(); +extern void Harness_Platform_Init(tHarness_platform* platform); int Harness_ProcessCommandLine(int* argc, char* argv[]); -void Harness_DetectGameMode() { +static void Harness_DetectGameMode(void) { if (access("DATA/RACES/CASTLE.TXT", F_OK) != -1) { // All splatpack edition have the castle track if (access("DATA/RACES/CASTLE2.TXT", F_OK) != -1) { @@ -320,7 +320,7 @@ void Harness_Hook_BrV1dbRendererBegin(br_v1db_state* v1db) { v1db->renderer = (br_renderer*)renderer_state; } -int Harness_CalculateFrameDelay() { +static int Harness_CalculateFrameDelay(void) { if (harness_game_config.fps == 0) { return 0; } @@ -363,7 +363,7 @@ void Harness_Hook_BrPixelmapDoubleBuffer(br_pixelmap* dst, br_pixelmap* src) { void Harness_RenderLastScreen() { if (last_dst) { Harness_RenderScreen(last_dst, last_src); - gHarness_platform.SwapWindow(0); + gHarness_platform.SwapWindow(); } } diff --git a/src/harness/harness.h b/src/harness/harness.h index 76c418da..0ea14cb1 100644 --- a/src/harness/harness.h +++ b/src/harness/harness.h @@ -4,13 +4,13 @@ #include "brender/br_types.h" #include "harness/trace.h" -void Harness_ForceNullPlatform(); +void Harness_ForceNullPlatform(void); typedef struct tCamera { - void (*update)(); - float* (*getProjection)(); - float* (*getView)(); - void (*setPosition)(); + void (*update)(void); + float* (*getProjection)(void); + float* (*getView)(void); + void (*setPosition)(void); } tCamera; #endif diff --git a/src/harness/include/harness/hooks.h b/src/harness/include/harness/hooks.h index 50a6b407..b5e57743 100644 --- a/src/harness/include/harness/hooks.h +++ b/src/harness/include/harness/hooks.h @@ -17,13 +17,13 @@ typedef struct tHarness_platform { // Called when beginning a 3D scene void (*Renderer_BeginScene)(br_actor* camera, br_pixelmap* colour_buffer, br_pixelmap* depth_buffer); // Called at the end of a 3D scene - void (*Renderer_EndScene)(); + void (*Renderer_EndScene)(void); // Render a fullscreen quad using the specified pixel data void (*Renderer_FullScreenQuad)(uint8_t* src); // Render a model void (*Renderer_Model)(br_actor* actor, br_model* model, br_material* material, br_token render_type, br_matrix34 model_matrix); // Clear frame and depth buffers - void (*Renderer_ClearBuffers)(); + void (*Renderer_ClearBuffers)(void); // Load pixelmap into video memory void (*Renderer_BufferTexture)(br_pixelmap* pm); // Load material @@ -31,7 +31,7 @@ typedef struct tHarness_platform { // Load model into video memory void (*Renderer_BufferModel)(br_model* model); // Pull contents of frame and depth buffers from video into main memory for software effects - void (*Renderer_FlushBuffers)(); + void (*Renderer_FlushBuffers)(void); // Set the 256 color palette to use (BGRA format) void (*Renderer_SetPalette)(PALETTEENTRY_* palette); // Set the viewport for 3d rendering @@ -55,9 +55,9 @@ typedef struct tHarness_platform { // Sleep void (*Sleep)(uint32_t dwMilliseconds); // Get ticks - uint32_t (*GetTicks)(); + uint32_t (*GetTicks)(void); // Swap window - void (*SwapWindow)(); + void (*SwapWindow)(void); } tHarness_platform; @@ -74,11 +74,11 @@ void Harness_Hook_renderActor(br_actor* actor, br_model* model, br_material* mat // Sound hooks void Harness_Hook_S3Service(int unk1, int unk2); -void Harness_Hook_S3StopAllOutletSounds(); +void Harness_Hook_S3StopAllOutletSounds(void); // Filesystem hooks FILE* Harness_Hook_fopen(const char* pathname, const char* mode); -void Harness_RenderLastScreen(); +void Harness_RenderLastScreen(void); #endif diff --git a/src/harness/include/harness/win95_polyfill.h b/src/harness/include/harness/win95_polyfill.h index 1a9bb626..1d08fb34 100644 --- a/src/harness/include/harness/win95_polyfill.h +++ b/src/harness/include/harness/win95_polyfill.h @@ -37,7 +37,7 @@ int GetCursorPos_(POINT_* lpPoint); int ScreenToClient_(void* hWnd, POINT_* lpPoint); -uint32_t timeGetTime_(); +uint32_t timeGetTime_(void); uint32_t GetCurrentDirectoryA_(uint32_t nBufferLength, char* lpBuffer); @@ -75,7 +75,7 @@ int GetMessageA_(MSG_* lpMsg, void* hWnd, unsigned int wMsgFilterMin, unsigned i void Sleep_(uint32_t dwMilliseconds); -void DirectDraw_CreateSurface(); +void DirectDraw_CreateSurface(int width, int height); void DirectDrawDevice_SetPaletteEntries(PALETTEENTRY_* palette, int pFirst_colour, int pCount); diff --git a/src/harness/os/linux.c b/src/harness/os/linux.c index b02e5e44..42ac59d8 100644 --- a/src/harness/os/linux.c +++ b/src/harness/os/linux.c @@ -46,7 +46,7 @@ static int dl_iterate_callback(struct dl_phdr_info* info, size_t size, void* dat return 0; } -static intptr_t get_dethrace_offset() { +static intptr_t get_dethrace_offset(void) { if (!dethrace_dl_data.initialized) { dethrace_dl_data.initialized = 1; dl_iterate_phdr(dl_iterate_callback, &dethrace_dl_data); @@ -65,7 +65,7 @@ int addr2line(char const* const program_name, void const* const addr) { return system(addr2line_cmd); } -void print_stack_trace() { +static void print_stack_trace(void) { int i, trace_size = 0; char** messages = (char**)NULL; diff --git a/src/harness/os/macos.c b/src/harness/os/macos.c index 04306c6c..dfb4ea4f 100644 --- a/src/harness/os/macos.c +++ b/src/harness/os/macos.c @@ -37,7 +37,7 @@ int addr2line(char const* const program_name, void const* const addr) { return system(addr2line_cmd); } -void print_stack_trace() { +static void print_stack_trace(void) { int i, trace_size = 0; char** messages = (char**)NULL; diff --git a/src/harness/platforms/null.c b/src/harness/platforms/null.c new file mode 100644 index 00000000..935e09ac --- /dev/null +++ b/src/harness/platforms/null.c @@ -0,0 +1,98 @@ +#include "null.h" + +// todo: shouldnt depend on sdl... +#include + +static void* null_create_window_and_renderer(char* title, int x, int y, int width, int height) { + return 0; +} + +static int null_set_window_pos(void* hWnd, int x, int y, int nWidth, int nHeight) { + return 0; +} + +static void null_destroy_window(void* hWnd) { +} + +static int null_get_and_handle_message(MSG_* msg) { + return 0; +} + +static void null_swap_window(void) { +} + +static void null_get_keyboard_state(unsigned int count, uint8_t* buffer) { +} + +static int null_get_mouse_buttons(int* pButton1, int* pButton2) { + return 0; +} + +static int null_get_mouse_position(int* pX, int* pY) { + return 0; +} + +static int null_show_cursor(int show) { + return 0; +} + +static void NullRenderer_BeginScene(br_actor* camera, br_pixelmap* colour_buffer, br_pixelmap* depth_buffer) { +} + +static void NullRenderer_EndScene(void) { +} + +static void NullRenderer_SetPalette(PALETTEENTRY_* palette) { +} + +static void NullRenderer_FullScreenQuad(uint8_t* src) { +} + +static void NullRenderer_Model(br_actor* actor, br_model* model, br_material* material, br_token render_type, br_matrix34 model_matrix) { +} + +static void NullRenderer_ClearBuffers(void) { +} + +static void NullRenderer_BufferTexture(br_pixelmap* pm) { +} + +static void NullRenderer_BufferMaterial(br_material* mat) { +} + +static void NullRenderer_BufferModel(br_model* model) { +} + +static void NullRenderer_FlushBuffers(void) { +} + +static void NullRenderer_SetViewport(int x, int y, int width, int height) { +} + +void Null_Platform_Init(tHarness_platform* platform) { + platform->ProcessWindowMessages = null_get_and_handle_message; + // todo: shouldnt depend on sdl... + platform->Sleep = SDL_Delay; + platform->GetTicks = SDL_GetTicks; + platform->CreateWindowAndRenderer = null_create_window_and_renderer; + platform->ShowCursor = null_show_cursor; + platform->SetWindowPos = null_set_window_pos; + platform->SwapWindow = null_swap_window; + platform->DestroyWindow = null_destroy_window; + platform->GetKeyboardState = null_get_keyboard_state; + platform->GetMousePosition = null_get_mouse_position; + platform->GetMouseButtons = null_get_mouse_buttons; + platform->DestroyWindow = null_destroy_window; + + platform->Renderer_BufferModel = NullRenderer_BufferModel; + platform->Renderer_BufferMaterial = NullRenderer_BufferMaterial; + platform->Renderer_BufferTexture = NullRenderer_BufferTexture; + platform->Renderer_SetPalette = NullRenderer_SetPalette; + platform->Renderer_FullScreenQuad = NullRenderer_FullScreenQuad; + platform->Renderer_Model = NullRenderer_Model; + platform->Renderer_ClearBuffers = NullRenderer_ClearBuffers; + platform->Renderer_FlushBuffers = NullRenderer_FlushBuffers; + platform->Renderer_BeginScene = NullRenderer_BeginScene; + platform->Renderer_EndScene = NullRenderer_EndScene; + platform->Renderer_SetViewport = NullRenderer_SetViewport; +} diff --git a/src/harness/platforms/null.h b/src/harness/platforms/null.h index c43aa5ac..93a5536a 100644 --- a/src/harness/platforms/null.h +++ b/src/harness/platforms/null.h @@ -2,82 +2,7 @@ #define PLATFORM_NULL #include "harness/hooks.h" -// todo: shouldnt depend on sdl... -#include -void* null_create_window_and_renderer(char* title, int x, int y, int width, int height) { - return 0; -} - -int null_set_window_pos(void* hWnd, int x, int y, int nWidth, int nHeight) { - return 0; -} - -void null_destroy_window(void* hWnd) { -} - -int null_get_and_handle_message(MSG_* msg) { - return 0; -} - -void null_swap_window() { -} - -void null_get_keyboard_state(unsigned int count, uint8_t* buffer) { -} - -int null_get_mouse_buttons(int* pButton1, int* pButton2) { - return 0; -} - -int null_get_mouse_position(int* pX, int* pY) { - return 0; -} - -int null_show_cursor(int show) { - return 0; -} - -void NullRenderer_Init() {} -void NullRenderer_BeginScene(br_actor* camera, br_pixelmap* colour_buffer, br_pixelmap* depth_buffer) {} -void NullRenderer_EndScene() {} -void NullRenderer_SetPalette(PALETTEENTRY_* palette) {} -void NullRenderer_FullScreenQuad(uint8_t* src) {} -void NullRenderer_Model(br_actor* actor, br_model* model, br_material* material, br_token render_type, br_matrix34 model_matrix) {} -void NullRenderer_RenderFrameBuffer() {} -void NullRenderer_ClearBuffers() {} -void NullRenderer_BufferTexture(br_pixelmap* pm) {} -void NullRenderer_BufferMaterial(br_material* mat) {} -void NullRenderer_BufferModel(br_model* model) {} -void NullRenderer_FlushBuffers() {} -void NullRenderer_SetViewport(int x, int y, int width, int height) {} - -void Null_Platform_Init(tHarness_platform* platform) { - platform->ProcessWindowMessages = null_get_and_handle_message; - // todo: shouldnt depend on sdl... - platform->Sleep = SDL_Delay; - platform->GetTicks = SDL_GetTicks; - platform->CreateWindowAndRenderer = null_create_window_and_renderer; - platform->ShowCursor = null_show_cursor; - platform->SetWindowPos = null_set_window_pos; - platform->SwapWindow = null_swap_window; - platform->DestroyWindow = null_destroy_window; - platform->GetKeyboardState = null_get_keyboard_state; - platform->GetMousePosition = null_get_mouse_position; - platform->GetMouseButtons = null_get_mouse_buttons; - platform->DestroyWindow = null_destroy_window; - - platform->Renderer_BufferModel = NullRenderer_BufferModel; - platform->Renderer_BufferMaterial = NullRenderer_BufferMaterial; - platform->Renderer_BufferTexture = NullRenderer_BufferTexture; - platform->Renderer_SetPalette = NullRenderer_SetPalette; - platform->Renderer_FullScreenQuad = NullRenderer_FullScreenQuad; - platform->Renderer_Model = NullRenderer_Model; - platform->Renderer_ClearBuffers = NullRenderer_ClearBuffers; - platform->Renderer_FlushBuffers = NullRenderer_FlushBuffers; - platform->Renderer_BeginScene = NullRenderer_BeginScene; - platform->Renderer_EndScene = NullRenderer_EndScene; - platform->Renderer_SetViewport = NullRenderer_SetViewport; -} +void Null_Platform_Init(tHarness_platform* platform); #endif diff --git a/src/harness/platforms/sdl_opengl.c b/src/harness/platforms/sdl_opengl.c index 5161f5a5..29eb7208 100644 --- a/src/harness/platforms/sdl_opengl.c +++ b/src/harness/platforms/sdl_opengl.c @@ -26,7 +26,7 @@ struct { float y; } sdl_window_scale; -static void update_viewport() { +static void update_viewport(void) { const float target_aspect_ratio = (float)render_width / render_height; const float aspect_ratio = (float)window_width / window_height; @@ -44,7 +44,7 @@ static void update_viewport() { GLRenderer_SetViewport(vp_x, vp_y, vp_width, vp_height); } -void* create_window_and_renderer(char* title, int x, int y, int width, int height) { +static void* create_window_and_renderer(char* title, int x, int y, int width, int height) { window_width = width; window_height = height; render_width = width; @@ -96,7 +96,7 @@ void* create_window_and_renderer(char* title, int x, int y, int width, int heigh return window; } -int set_window_pos(void* hWnd, int x, int y, int nWidth, int nHeight) { +static int set_window_pos(void* hWnd, int x, int y, int nWidth, int nHeight) { // SDL_SetWindowPosition(hWnd, x, y); if (nWidth == 320 && nHeight == 200) { nWidth = 640; @@ -106,7 +106,7 @@ int set_window_pos(void* hWnd, int x, int y, int nWidth, int nHeight) { return 0; } -void destroy_window(void* hWnd) { +static void destroy_window(void* hWnd) { SDL_GL_DeleteContext(context); SDL_DestroyWindow(window); SDL_Quit(); @@ -119,7 +119,7 @@ static int is_only_key_modifier(int modifier_flags, int flag_check) { return (modifier_flags & flag_check) && (modifier_flags & (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_GUI)) == (modifier_flags & flag_check); } -int get_and_handle_message(MSG_* msg) { +static int get_and_handle_message(MSG_* msg) { SDL_Event event; int dinput_key; @@ -171,22 +171,22 @@ int get_and_handle_message(MSG_* msg) { return 0; } -void swap_window() { +static void swap_window(void) { SDL_GL_SwapWindow(window); } -void get_keyboard_state(unsigned int count, uint8_t* buffer) { +static void get_keyboard_state(unsigned int count, uint8_t* buffer) { memcpy(buffer, directinput_key_state, count); } -int get_mouse_buttons(int* pButton1, int* pButton2) { +static int get_mouse_buttons(int* pButton1, int* pButton2) { int state = SDL_GetMouseState(NULL, NULL); *pButton1 = state & SDL_BUTTON_LMASK; *pButton2 = state & SDL_BUTTON_RMASK; return 0; } -int get_mouse_position(int* pX, int* pY) { +static int get_mouse_position(int* pX, int* pY) { SDL_GetMouseState(pX, pY); if (*pX < vp_x) { @@ -215,7 +215,7 @@ int get_mouse_position(int* pX, int* pY) { return 0; } -void set_palette(PALETTEENTRY_* pal) { +static void set_palette(PALETTEENTRY_* pal) { GLRenderer_SetPalette((uint8_t*)pal); } diff --git a/src/harness/renderers/gl/gl_renderer.c b/src/harness/renderers/gl/gl_renderer.c index ef0c066e..17877508 100644 --- a/src/harness/renderers/gl/gl_renderer.c +++ b/src/harness/renderers/gl/gl_renderer.c @@ -74,7 +74,7 @@ struct { GLuint pixels, palette; } uniforms_2d; -GLuint CreateShaderProgram(char* name, const char* vertex_shader, const int vertex_shader_len, const char* fragment_shader, const int fragment_shader_len) { +static GLuint CreateShaderProgram(char* name, const char* vertex_shader, const int vertex_shader_len, const char* fragment_shader, const int fragment_shader_len) { int success; char log_buffer[1024]; GLuint program; @@ -117,7 +117,7 @@ GLuint CreateShaderProgram(char* name, const char* vertex_shader, const int vert return program; } -GLint GetValidatedUniformLocation(GLuint program, char* uniform_name) { +static GLint GetValidatedUniformLocation(GLuint program, char* uniform_name) { GLint location; location = glGetUniformLocation(program, uniform_name); if (location == -1) { @@ -126,7 +126,7 @@ GLint GetValidatedUniformLocation(GLuint program, char* uniform_name) { return location; } -void LoadShaders() { +static void LoadShaders(void) { shader_program_2d = CreateShaderProgram("framebuffer", RESOURCES_FRAMEBUFFER_VERT_GLSL, sizeof(RESOURCES_FRAMEBUFFER_VERT_GLSL), RESOURCES_FRAMEBUFFER_FRAG_GLSL, sizeof(RESOURCES_FRAMEBUFFER_FRAG_GLSL)); glUseProgram(shader_program_2d); uniforms_2d.pixels = GetValidatedUniformLocation(shader_program_2d, "u_pixels"); @@ -172,7 +172,7 @@ void LoadShaders() { glUniform1i(uniforms_3d.colour_buffer_texture, 4); } -void SetupFullScreenRectGeometry() { +static void SetupFullScreenRectGeometry(void) { float vertices[] = { // positions // colors // texture coords 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, // top right diff --git a/src/harness/renderers/gl/gl_renderer.h b/src/harness/renderers/gl/gl_renderer.h index aa0c06c6..fd59e530 100644 --- a/src/harness/renderers/gl/gl_renderer.h +++ b/src/harness/renderers/gl/gl_renderer.h @@ -45,15 +45,15 @@ void GLRenderer_Init(int render_width, int render_height); void GLRenderer_SetPalette(uint8_t* rgba_colors); void GLRenderer_BeginScene(br_actor* camera, br_pixelmap* colour_buffer, br_pixelmap* depth_buffer); -void GLRenderer_EndScene(); +void GLRenderer_EndScene(void); void GLRenderer_FullScreenQuad(uint8_t* screen_buffer); void GLRenderer_Model(br_actor* actor, br_model* model, br_material* material, br_token render_type, br_matrix34 model_matrix); void GLRenderer_BufferTexture(br_pixelmap* pm); void GLRenderer_BufferMaterial(br_material* mat); void GLRenderer_BufferModel(br_model* model); -void GLRenderer_ClearBuffers(); +void GLRenderer_ClearBuffers(void); void GLRenderer_FlushBuffer(tRenderer_flush_type flush_type); -void GLRenderer_FlushBuffers(); +void GLRenderer_FlushBuffers(void); void GLRenderer_SetViewport(int x, int y, int width, int height); #endif diff --git a/src/harness/renderers/gl/stored_context.h b/src/harness/renderers/gl/stored_context.h index 5b7d7ba6..a4220111 100644 --- a/src/harness/renderers/gl/stored_context.h +++ b/src/harness/renderers/gl/stored_context.h @@ -24,10 +24,10 @@ typedef struct tStored_material { char identifier[200]; } tStored_material; -tStored_model_context* NewStoredModelContext(); +tStored_model_context* NewStoredModelContext(void); -tStored_material* NewStoredMaterial(); +tStored_material* NewStoredMaterial(void); -tStored_pixelmap* NewStoredPixelmap(); +tStored_pixelmap* NewStoredPixelmap(void); #endif diff --git a/src/harness/sound/sound.h b/src/harness/sound/sound.h index 1ab49c22..19919060 100644 --- a/src/harness/sound/sound.h +++ b/src/harness/sound/sound.h @@ -2,7 +2,7 @@ #ifndef HARNESS_SOUND_H #define HARNESS_SOUND_H -void Sound_Init(); -void Sound_Service(); +void Sound_Init(void); +void Sound_Service(void); -#endif \ No newline at end of file +#endif diff --git a/src/smackw32/CMakeLists.txt b/src/smackw32/CMakeLists.txt index 9fc34969..2c31c02e 100644 --- a/src/smackw32/CMakeLists.txt +++ b/src/smackw32/CMakeLists.txt @@ -10,7 +10,9 @@ target_include_directories(smackw32 target_link_libraries(smackw32 PRIVATE harness brender libsmacker compile_with_werror) if(NOT MSVC) - + add_compile_flags_if_supported(smackw32 + -Wstrict-prototypes + ) else() target_compile_definitions(smackw32 PRIVATE -D_CRT_SECURE_NO_WARNINGS) target_compile_options(smackw32 PRIVATE