Skip to content

Commit

Permalink
fixed Visual Studio 2019 compilation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nesbox committed Sep 29, 2020
1 parent f0fdf1c commit 5f23af3
Show file tree
Hide file tree
Showing 27 changed files with 142 additions and 143 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Expand Up @@ -134,6 +134,8 @@ endif()

if(MSVC)

add_definitions("/D\"_CRT_SECURE_NO_WARNINGS\"")

foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib )
Expand Down
22 changes: 2 additions & 20 deletions include/tic80_config.h
Expand Up @@ -52,26 +52,8 @@
#endif /* defined(__APPLE__) */

#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
# if defined(_MSC_VER) && defined(__has_include)
# define HAVE_WINAPIFAMILY_H __has_include(<winapifamily.h>)
# elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_)
# define HAVE_WINAPIFAMILY_H 1
# else
# define HAVE_WINAPIFAMILY_H 0
# endif
# if HAVE_WINAPIFAMILY_H
# include <winapifamily.h>
# define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP))
# else
# define WINAPI_FAMILY_WINRT 0
# endif /* HAVE_WINAPIFAMILY_H */
# if WINAPI_FAMILY_WINRT
# undef __TIC_WINRT__
# define __TIC_WINRT__ 1
# else
# undef __TIC_WINDOWS__
# define __TIC_WINDOWS__ 1
# endif
# undef __TIC_WINDOWS__
# define __TIC_WINDOWS__ 1
#endif

#if defined(ANDROID) || defined(__ANDROID__)
Expand Down
2 changes: 1 addition & 1 deletion src/api/js.c
Expand Up @@ -1012,7 +1012,7 @@ static const tic_outline_item* getJsOutline(const char* code, s32* size)
items = realloc(items, (*size + 1) * Size);

items[*size].pos = start;
items[*size].size = end - start;
items[*size].size = (s32)(end - start);

(*size)++;
}
Expand Down
10 changes: 5 additions & 5 deletions src/api/lua.c
Expand Up @@ -31,7 +31,7 @@
#include <lualib.h>
#include <ctype.h>

#define LUA_LOC_STACK 1E8 // 100.000.000
#define LUA_LOC_STACK 100000000

static const char TicCore[] = "_TIC80";

Expand Down Expand Up @@ -1113,7 +1113,7 @@ static s32 lua_pmem(lua_State *lua)

if(top >= 2)
{
tic_api_pmem(tic, index, lua_tointeger(lua, 2), true);
tic_api_pmem(tic, index, (u32)lua_tointeger(lua, 2), true);
}

lua_pushinteger(lua, val);
Expand Down Expand Up @@ -1481,7 +1481,7 @@ static const tic_outline_item* getLuaOutline(const char* code, s32* size)
items = realloc(items, (*size + 1) * Size);

items[*size].pos = start;
items[*size].size = end - start;
items[*size].size = (s32)(end - start);

(*size)++;
}
Expand Down Expand Up @@ -1662,7 +1662,7 @@ static const tic_outline_item* getMoonOutline(const char* code, s32* size)
items = realloc(items, (*size + 1) * Size);

items[*size].pos = start;
items[*size].size = end - start + 1;
items[*size].size = (s32)(end - start + 1);

(*size)++;
}
Expand Down Expand Up @@ -1816,7 +1816,7 @@ static const tic_outline_item* getFennelOutline(const char* code, s32* size)
items = realloc(items, (*size + 1) * Size);

items[*size].pos = start;
items[*size].size = end - start;
items[*size].size = (s32)(end - start);

(*size)++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/squirrel.c
Expand Up @@ -1239,7 +1239,7 @@ static SQInteger squirrel_tstamp(HSQUIRRELVM vm)
{
tic_mem* tic = (tic_mem*)getSquirrelCore(vm);

sq_pushinteger(vm, (SQFloat)(tic_api_tstamp(tic)));
sq_pushinteger(vm, tic_api_tstamp(tic));

return 1;
}
Expand Down
8 changes: 4 additions & 4 deletions src/api/wren.c
Expand Up @@ -374,11 +374,11 @@ static void wren_mouse(WrenVM* vm)
wrenInsertInList(vm, 0, 0, 1);
wrenSetSlotDouble(vm, 1, mouse->y);
wrenInsertInList(vm, 0, 1, 1);
wrenSetSlotBool(vm, 1, mouse->left);
wrenSetSlotBool(vm, 1, mouse->left ? true : false);
wrenInsertInList(vm, 0, 2, 1);
wrenSetSlotBool(vm, 1, mouse->middle);
wrenSetSlotBool(vm, 1, mouse->middle ? true : false);
wrenInsertInList(vm, 0, 3, 1);
wrenSetSlotBool(vm, 1, mouse->right);
wrenSetSlotBool(vm, 1, mouse->right ? true : false);
wrenInsertInList(vm, 0, 4, 1);
wrenSetSlotDouble(vm, 1, mouse->scrollx);
wrenInsertInList(vm, 0, 5, 1);
Expand Down Expand Up @@ -1505,7 +1505,7 @@ static const tic_outline_item* getWrenOutline(const char* code, s32* size)
items = realloc(items, (*size + 1) * Size);

items[*size].pos = start;
items[*size].size = end - start;
items[*size].size = (s32)(end - start);

(*size)++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/cart.c
Expand Up @@ -206,7 +206,7 @@ s32 tic_cart_save(const tic_cartridge* cart, u8* buffer)
buffer = SAVE_CHUNK(CHUNK_FLAGS, cart->banks[i].flags, i);
}

s32 codeLen = strlen(cart->code.data);
s32 codeLen = (s32)strlen(cart->code.data);
if(codeLen < TIC_CODE_BANK_SIZE)
buffer = saveFixedChunk(buffer, CHUNK_CODE, cart->code.data, codeLen, 0);
else
Expand Down
16 changes: 8 additions & 8 deletions src/core/draw.c
Expand Up @@ -465,8 +465,8 @@ static void setSideTexPixel(s32 x, s32 y, float u, float v)
if (x < SidesBuffer.Left[yy])
{
SidesBuffer.Left[yy] = x;
SidesBuffer.ULeft[yy] = u * 65536.0f;
SidesBuffer.VLeft[yy] = v * 65536.0f;
SidesBuffer.ULeft[yy] = (s32)(u * 65536.0f);
SidesBuffer.VLeft[yy] = (s32)(v * 65536.0f);
}
if (x > SidesBuffer.Right[yy])
{
Expand Down Expand Up @@ -617,13 +617,13 @@ static void ticTexLine(tic_mem* memory, TexVert* v0, TexVert* v1)
y = .0f;
}

s32 botY = bot->y;
s32 botY = (s32)bot->y;
if (botY > TIC80_HEIGHT)
botY = TIC80_HEIGHT;

for (; y < botY; ++y)
{
setSideTexPixel(x, y, u, v);
setSideTexPixel((s32)x, (s32)y, u, v);
x += step_x;
u += step_u;
v += step_v;
Expand All @@ -645,19 +645,19 @@ static void drawTexturedTriangle(tic_core* core, float x1, float y1, float x2, f

// calculate the slope of the surface
// use floats here
double denom = (V0.x - V2.x) * (V1.y - V2.y) - (V1.x - V2.x) * (V0.y - V2.y);
float denom = (V0.x - V2.x) * (V1.y - V2.y) - (V1.x - V2.x) * (V0.y - V2.y);
if (denom == 0.0)
{
return;
}
double id = 1.0 / denom;
float id = 1.0f / denom;
float dudx, dvdx;
// this is the UV slope across the surface
dudx = ((V0.u - V2.u) * (V1.y - V2.y) - (V1.u - V2.u) * (V0.y - V2.y)) * id;
dvdx = ((V0.v - V2.v) * (V1.y - V2.y) - (V1.v - V2.v) * (V0.y - V2.y)) * id;
// convert to fixed
s32 dudxs = dudx * 65536.0f;
s32 dvdxs = dvdx * 65536.0f;
s32 dudxs = (s32)(dudx * 65536.0f);
s32 dvdxs = (s32)(dvdx * 65536.0f);
// fill the buffer
initSidesBuffer();
// parse each line and decide where in the buffer to store them ( left or right )
Expand Down
4 changes: 2 additions & 2 deletions src/core/io.c
Expand Up @@ -49,7 +49,7 @@ u32 tic_api_btnp(tic_mem* tic, s32 index, s32 hold, s32 period)

tic80_gamepads previous;

previous.data = core->state.gamepads.holds[index] >= hold
previous.data = core->state.gamepads.holds[index] >= (u32)hold
? period && core->state.gamepads.holds[index] % period ? core->state.gamepads.previous.data : 0
: core->state.gamepads.previous.data;

Expand Down Expand Up @@ -83,7 +83,7 @@ bool tic_api_keyp(tic_mem* tic, tic_key key, s32 hold, s32 period)

if (key > tic_key_unknown)
{
bool prevDown = hold >= 0 && period >= 0 && core->state.keyboard.holds[key] >= hold
bool prevDown = hold >= 0 && period >= 0 && core->state.keyboard.holds[key] >= (u32)hold
? period && core->state.keyboard.holds[key] % period
? isKeyPressed(&core->state.keyboard.previous, key)
: false
Expand Down
8 changes: 4 additions & 4 deletions src/ext/net.c
Expand Up @@ -58,7 +58,7 @@ static size_t writeCallbackSync(void *contents, size_t size, size_t nmemb, void
}
data->buffer = newBuffer;
memcpy(data->buffer + data->size, contents, total);
data->size += total;
data->size += (s32)total;

return total;
}
Expand All @@ -76,20 +76,20 @@ static size_t writeCallback(char *ptr, size_t size, size_t nmemb, void *userdata
}
data->buffer = newBuffer;
memcpy(data->buffer + data->size, ptr, total);
data->size += total;
data->size += (s32)total;

double cl;
curl_easy_getinfo(data->async, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl);

if(cl > 0)
if(cl > 0.0)
{
HttpGetData getData =
{
.type = HttpGetProgress,
.progress =
{
.size = data->size,
.total = cl,
.total = (s32)cl,
},
.calldata = data->calldata,
.url = data->url,
Expand Down
18 changes: 9 additions & 9 deletions src/player/sdl.c
Expand Up @@ -39,15 +39,15 @@ static void onExit()
state.quit = true;
}

int main(int argc, char **argv)
s32 main(s32 argc, char **argv)
{
char* cart = (argc > 1) ? argv[1] : "cart.tic";
FILE* file = fopen(cart, "rb");

if(file)
{
fseek(file, 0, SEEK_END);
int size = ftell(file);
s32 size = ftell(file);
fseek(file, 0, SEEK_SET);

void* cart = SDL_malloc(size);
Expand Down Expand Up @@ -133,7 +133,7 @@ int main(int argc, char **argv)
SDL_SCANCODE_S,
};

for (int i = 0; i < SDL_arraysize(Keys); i++)
for (s32 i = 0; i < SDL_arraysize(Keys); i++)
{
if (keyboard[Keys[i]])
{
Expand Down Expand Up @@ -169,21 +169,21 @@ int main(int argc, char **argv)

{
void* pixels = NULL;
int pitch = 0;
s32 pitch = 0;
SDL_Rect destination;
SDL_LockTexture(texture, NULL, &pixels, &pitch);
SDL_memcpy(pixels, tic->screen, pitch * TIC80_FULLHEIGHT);
SDL_UnlockTexture(texture);

// Render the image in the proper aspect ratio.
{
int windowWidth, windowHeight;
s32 windowWidth, windowHeight;
SDL_GetWindowSize(window, &windowWidth, &windowHeight);
float widthRatio = (float)windowWidth / (float)TIC80_FULLWIDTH;
float heightRatio = (float)windowHeight / (float)TIC80_FULLHEIGHT;
float widthRatio = (float)windowWidth / TIC80_FULLWIDTH;
float heightRatio = (float)windowHeight / TIC80_FULLHEIGHT;
float optimalSize = widthRatio < heightRatio ? widthRatio : heightRatio;
destination.w = TIC80_FULLWIDTH * optimalSize;
destination.h = TIC80_FULLHEIGHT * optimalSize;
destination.w = (s32)(TIC80_FULLWIDTH * optimalSize);
destination.h = (s32)(TIC80_FULLHEIGHT * optimalSize);
destination.x = windowWidth / 2 - destination.w / 2;
destination.y = windowHeight / 2 - destination.h / 2;
}
Expand Down
4 changes: 2 additions & 2 deletions src/studio/config.c
Expand Up @@ -93,7 +93,7 @@ static void readConfigUiScale(Config* config, lua_State* lua)
lua_getglobal(lua, "UI_SCALE");

if(lua_isinteger(lua, -1))
config->data.uiScale = lua_tointeger(lua, -1);
config->data.uiScale = (s32)lua_tointeger(lua, -1);

lua_pop(lua, 1);
}
Expand Down Expand Up @@ -287,7 +287,7 @@ static void readConfig(Config* config)
}
}

static void update(Config* config, const u8* buffer, size_t size)
static void update(Config* config, const u8* buffer, s32 size)
{
tic_cart_load(&config->cart, buffer, size);

Expand Down

0 comments on commit 5f23af3

Please sign in to comment.