Build dethrace with -Wstrict-prototypes (#314)

* Add HOOK_NORETURN to certain function declarations

This fixes the following warning:
warning: ‘noreturn’ function does return

* Fix -Wstrict-prototypes warnings

* Fix -Wstrict-prototypes warnings in S3

* harness: split null.h in null.h and null.c

* Move GLRenderer_ClearBuffers to previous location

* Whitespace fixes
This commit is contained in:
Anonymous Maarten 2023-05-02 01:21:02 +02:00 committed by GitHub
parent 34a22f2516
commit 597de52fd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 273 additions and 185 deletions

View File

@ -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)

View File

@ -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)

View File

@ -67,7 +67,7 @@ void DoDemo() {
}
}
S3StopSound(song_tag);
S3StopAllOutletSounds(gEffects_outlet);
S3StopOutletSound(gEffects_outlet);
S3StopAllOutletSounds();
fclose(f);
FadePaletteDown();

View File

@ -1440,7 +1440,7 @@ int PlayNextFlicFrame(tFlic_descriptor* pFlic_info) {
}
// IDA: int __usercall PlayFlic@<EAX>(int pIndex@<EAX>, tU32 pSize@<EDX>, tS8 *pData_ptr@<EBX>, br_pixelmap *pDest_pixelmap@<ECX>, 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;

View File

@ -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;

View File

@ -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("()");

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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
)

View File

@ -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 <stdlib.h>
#include <string.h>
extern int PDGetTotalTime();
extern int PDGetTotalTime(void);
int gS3_enabled;
int gS3_noutlets;

View File

@ -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);

View File

@ -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);

View File

@ -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 */

View File

@ -1,6 +1,8 @@
#ifndef S3_TYPES_H
#define S3_TYPES_H
#include "s3/s3.h"
#include <stdint.h>
// 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;

View File

@ -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

View File

@ -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);

View File

@ -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;
}

View File

@ -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"
)

View File

@ -38,6 +38,6 @@ typedef struct harness_br_renderer {
} harness_br_renderer;
harness_br_renderer* NewHarnessBrRenderer();
harness_br_renderer* NewHarnessBrRenderer(void);
#endif
#endif

View File

@ -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();
}
}

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -0,0 +1,98 @@
#include "null.h"
// todo: shouldnt depend on sdl...
#include <SDL.h>
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;
}

View File

@ -2,82 +2,7 @@
#define PLATFORM_NULL
#include "harness/hooks.h"
// todo: shouldnt depend on sdl...
#include <SDL.h>
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

View File

@ -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);
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
#endif

View File

@ -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