Skip to content

Commit

Permalink
Code cleanup addressing warnings to gcc8
Browse files Browse the repository at this point in the history
  - Added 64bit Lua 'os.clock' timing work-a-round
  • Loading branch information
DirtBagXon committed Jan 12, 2020
1 parent 0b7d664 commit b5b16a5
Show file tree
Hide file tree
Showing 30 changed files with 111 additions and 118 deletions.
3 changes: 0 additions & 3 deletions src/cpu/x86/instr86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1180,9 +1180,6 @@ static void PREFIX86(_ds)(void) /* Opcode 0x3e */

static void PREFIX86(_aas)(void) /* Opcode 0x3f */
{
UINT8 ALcarry=1;
if (I.regs.b[AL]>0xf9) ALcarry=2;

if (I86_AF || ((I.regs.b[AL] & 0xf) > 9))
{
I.regs.b[AL] -= 6;
Expand Down
2 changes: 1 addition & 1 deletion src/game/astron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ Uint8 astron::port_read(Uint16 port)
// writes a byte to the cpu's port
void astron::port_write(Uint16 port, Uint8 value)
{
char s[81] = { 0 };
char s[82] = { 0 };

port &= 0xFF;

Expand Down
2 changes: 1 addition & 1 deletion src/game/boardinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void print_board_info(unsigned char index, // which board
{

char sequence_type[160] = { 0 };
char s1[160] = { 0 };
char s1[340] = { 0 };
char board_name[160] = { 0 };

// if we know that we are playing Dragon's Lair
Expand Down
2 changes: 1 addition & 1 deletion src/game/cliff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ void outcommand(char *s) //dangit Matt, stop ripping out my useful routines =]
static int row=1,commandnum=0;

int slength,x;
char strtoprint[25],string2[25];
char strtoprint[25],string2[40];
//gotoxy(43,row++);
if (row==21) row=1;
slength=strlen(s);
Expand Down
2 changes: 1 addition & 1 deletion src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ Uint8 game::port_read(Uint16 port)
// writes a byte to the cpu's port
void game::port_write(Uint16 port, Uint8 value)
{
char s[81] = { 0 };
char s[82] = { 0 };

port &= 0xFF;
sprintf(s, "ERROR: CPU port %x write requested (value %x) but this function is unimplemented!", port, value);
Expand Down
2 changes: 1 addition & 1 deletion src/game/gpworld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ Uint8 gpworld::port_read(Uint16 port)
// writes a byte to the cpu's port
void gpworld::port_write(Uint16 port, Uint8 value)
{
char s[81] = { 0 };
char s[82] = { 0 };

port &= 0xFF;

Expand Down
2 changes: 1 addition & 1 deletion src/game/lair2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ lair2::lair2() :
{
m_shortgamename = "lair2";
memset(m_cpumem, 0, CPU_MEM_SIZE);
memset(EEPROM_9536, 0, 0x80);
memset(EEPROM_9536, 0, sizeof(EEPROM_9536));
m_uCoinCount[0] = m_uCoinCount[1] = 0;
banks[0] = 0xff; // bank 0 is active low
banks[1] = 0x01; // bank 1 is active high - bit 0 is set for EEP
Expand Down
8 changes: 6 additions & 2 deletions src/game/laireuro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,12 @@ void laireuro::do_nmi()
// Redraws the screen (if needed) on interrupt
video_blit();

// intermediate variable to avoid: promoted ~unsigned is always non-zero [-Wsign-compare]
uint8_t check1 = ~(m_banks[1] & 0x04);
uint8_t check2 = ~(m_banks[1] & 0x08);

// Italian DL doesn't like it if coins held too long
if (~(m_banks[1] & 0x04))
if (check1)
{
static int coinCount = 0;
if (coinCount >= 6)
Expand All @@ -160,7 +164,7 @@ void laireuro::do_nmi()
}
coinCount++;
}
if (~(m_banks[1] & 0x08))
if (check2)
{
static int coinCount = 0;
if (coinCount >= 6)
Expand Down
4 changes: 4 additions & 0 deletions src/game/singe/loslib.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ static int os_getenv (lua_State *L) {


static int os_clock (lua_State *L) {
#ifdef __x86_64__
lua_pushnumber(L, (((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC)*6);
#else
lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC);
#endif
return 1;
}

Expand Down
7 changes: 4 additions & 3 deletions src/game/timetrav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ Uint8 timetrav::cpu_mem_read(Uint32 addr)
Uint8 result = m_cpumem[addr];

// Scratch ram
if (addr < 0x10000)
if (addr < 0x10000)
{
(void)0;
}
// ROM
else if (addr >= 0xc0000)
else if (addr >= 0xc0000)
{
(void)0;
}
else
{
Expand Down
3 changes: 2 additions & 1 deletion src/io/mpo_fileio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ void mpo_test()
{
int i = 0;
int b;


b = b + 0;
b = 5 / i; // force crash
}
}
Expand Down
15 changes: 7 additions & 8 deletions src/io/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ struct net_packet g_packet; // what we're gonna send

void net_set_gamename(char *gamename)
{
strncpy(g_packet.gamename, gamename, sizeof(g_packet.gamename));
strncpy(g_packet.gamename, gamename, sizeof(g_packet.gamename)-1);
}

void net_set_ldpname(char *ldpname)
{
strncpy(g_packet.ldpname, ldpname, sizeof(g_packet.ldpname));
strncpy(g_packet.ldpname, ldpname, sizeof(g_packet.ldpname)-1);
}

#ifdef WIN32
Expand Down Expand Up @@ -236,12 +236,11 @@ unsigned int get_sys_mem()
unsigned int mem = 0;
#ifdef LINUX
FILE *F;
int iRes = 0;
const char *s = "ls -l /proc/kcore | awk '{print $5}'";
F = popen(s, "r");
if (F)
{
iRes = fscanf(F, "%u", &mem); // this breaks if they have over 2 gigs of ram :)
fscanf(F, "%u", &mem); // this breaks if they have over 2 gigs of ram :)
pclose(F);
}

Expand Down Expand Up @@ -603,13 +602,13 @@ void net_send_data_to_server()
printerror("your OS is unknown in network.cpp, please fix this");
}

strncpy(g_packet.os_desc, get_os_description(), sizeof(g_packet.os_desc));
strncpy(g_packet.os_desc, get_os_description(), sizeof(g_packet.os_desc)-1);
g_packet.protocol = PROTOCOL_VERSION;
g_packet.mhz = get_cpu_mhz();
g_packet.mem = get_sys_mem();
strncpy(g_packet.video_desc, get_video_description(), sizeof(g_packet.video_desc));
strncpy(g_packet.cpu_name, get_cpu_name(), sizeof(g_packet.cpu_name));
strncpy(g_packet.daphne_version, get_daphne_version(), sizeof(g_packet.daphne_version));
strncpy(g_packet.video_desc, get_video_description(), sizeof(g_packet.video_desc)-1);
strncpy(g_packet.cpu_name, get_cpu_name(), sizeof(g_packet.cpu_name)-1);
strncpy(g_packet.daphne_version, get_daphne_version(), sizeof(g_packet.daphne_version)-1);

// now compute CRC32 of the rest of the packet
g_packet.crc32 = crc32(0L, Z_NULL, 0);
Expand Down
19 changes: 7 additions & 12 deletions src/io/unzip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,8 @@ extern int ZEXPORT unzLocateFile (
if (file==NULL)
return UNZ_PARAMERROR;

if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
return UNZ_PARAMERROR;
if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
return UNZ_PARAMERROR;

s=(unz_s*)file;
if (!s->current_file_ok)
Expand Down Expand Up @@ -854,11 +854,7 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (
*poffset_local_extrafield = 0;
*psize_local_extrafield = 0;

// if (fseek(s->file,s->cur_file_info_internal.offset_curfile +
// s->byte_before_the_zipfile,SEEK_SET)!=0)
if (!mpo_seek(s->cur_file_info_internal.offset_curfile +
s->byte_before_the_zipfile,
MPO_SEEK_SET, s->file)) // MPO
if (!mpo_seek(s->cur_file_info_internal.offset_curfile + s->byte_before_the_zipfile, MPO_SEEK_SET, s->file)) // MPO
return UNZ_ERRNO;


Expand All @@ -884,9 +880,8 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (
else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
err=UNZ_BADZIPFILE;

if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
(s->cur_file_info.compression_method!=Z_DEFLATED))
err=UNZ_BADZIPFILE;
if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && (s->cur_file_info.compression_method!=Z_DEFLATED))
err=UNZ_BADZIPFILE;

if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */ // MPO
err=UNZ_ERRNO;
Expand Down Expand Up @@ -949,8 +944,8 @@ extern int ZEXPORT unzOpenCurrentFile (
if (!s->current_file_ok)
return UNZ_PARAMERROR;

if (s->pfile_in_zip_read != NULL)
unzCloseCurrentFile(file);
if (s->pfile_in_zip_read != NULL)
unzCloseCurrentFile(file);

if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar,
&offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
Expand Down
2 changes: 0 additions & 2 deletions src/ldp-in/vp380.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ void write_vp380 (unsigned char value)
char yc[4];
int x;
int y;
int Line = 0;

// get x,y
strncpy (xc, &CommandBuffer[5],2);
Expand All @@ -218,7 +217,6 @@ void write_vp380 (unsigned char value)
if (g_LDP1450_Strings[j].y == (36 * y) - 20)
{
g_LDP1450_TextControl.TextLine = j;
Line = 1;
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ldp-out/ld-v6000.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ bool v6000::wait_for_finished()
{

const int time_to_finish = 3; // wait this long to timeout
char s[81] = { 0 };
char s[48] = { 0 };
char debug_string[81] = { 0 };
// int status_timer = 0;
int finish_timer = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/sound/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
#ifndef SOUND_H
#define SOUND_H

#ifdef WIN32
#include <SDL.h>
#else
#include <SDL/SDL.h>
#endif

// header file for sound.c

Expand Down
3 changes: 1 addition & 2 deletions src/sound/ssi263.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,15 +472,14 @@ bool g_bSamplePlaying = false;
void ssi263_say_phones(char *phonemes, int len)
{
sample_s the_sample;
unsigned int channel;

the_sample.pu8Buf = NULL;
the_sample.uLength = 0;

if (tqsynth_phones_to_wave(phonemes, len, &the_sample))
{
g_bSamplePlaying = true; // so that we don't overlap samples (only happens at the very beginning of boot-up)
channel = samples_play_sample(the_sample.pu8Buf, the_sample.uLength, AUDIO_CHANNELS, -1, ssi263_finished_callback);
samples_play_sample(the_sample.pu8Buf, the_sample.uLength, AUDIO_CHANNELS, -1, ssi263_finished_callback);

// Wait for sample to stop playing
// NOTE : This is a hack and isn't proper emulation.
Expand Down
11 changes: 0 additions & 11 deletions src/sound/tms9919-sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ void cSdlTMS9919::AudioCallback ( Uint8 *stream, int length )

// int volume = ( m_MasterVolume * AUDIO_MAX_VOLUME ) / 100;

bool mix = false;
memset ( stream, m_AudioSpec.silence, length );

for ( int i = 0; i < 4; i++ ) {
Expand All @@ -141,9 +140,6 @@ void cSdlTMS9919::AudioCallback ( Uint8 *stream, int length )
// make sure that attenuation (volume) isn't 15 = off and we have a frequency
if (( m_Attenuation [i] != 15 ) && ( info->period >= 1.0 ))
{
// new data so we'll need to mix
mix = true;

// set left = length (number of samples we need to process)
int left = length/4, j = 1;

Expand Down Expand Up @@ -198,13 +194,6 @@ void cSdlTMS9919::AudioCallback ( Uint8 *stream, int length )
}
}

// if ( m_pSpeechSynthesizer != NULL ) {
// mix |= m_pSpeechSynthesizer->AudioCallback ( m_MixBuffer, length );
// }

//if ( mix == true ) {
// SDL_MixAudio ( stream, m_MixBuffer, length, volume );
// }
}

int cSdlTMS9919::SetSpeechSynthesizer ( cTMS5220 *speech )
Expand Down
2 changes: 1 addition & 1 deletion src/video/SDL_Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void UpdateConsole()
void DrawConsole()
{
int loop;
SDL_Rect DestRect = {0, 0, ConsoleSurface->w, ConsoleSurface->h};
SDL_Rect DestRect = {0, 0, (short unsigned int)ConsoleSurface->w, (short unsigned int)ConsoleSurface->h};


SDL_BlitSurface(ConsoleSurface, NULL, OutputScreen, &DestRect);
Expand Down
2 changes: 1 addition & 1 deletion src/video/SDL_Console.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "SDL_ConsoleCommands.h"


#define CHARS_PER_LINE 128
#define CHARS_PER_LINE 256

#ifdef __cplusplus
extern "C" {
Expand Down
6 changes: 3 additions & 3 deletions src/vldp2/libmpeg2/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const mpeg2_info_t * mpeg2_info (mpeg2dec_t * mpeg2dec)
return &(mpeg2dec->info);
}

static inline int skip_chunk (mpeg2dec_t * mpeg2dec, int bytes)
static int skip_chunk (mpeg2dec_t * mpeg2dec, int bytes)
{
uint8_t * current;
uint32_t shift;
Expand Down Expand Up @@ -74,7 +74,7 @@ static inline int skip_chunk (mpeg2dec_t * mpeg2dec, int bytes)
return 0;
}

static inline int copy_chunk (mpeg2dec_t * mpeg2dec, int bytes)
static int copy_chunk (mpeg2dec_t * mpeg2dec, int bytes)
{
uint8_t * current;
uint32_t shift;
Expand Down Expand Up @@ -116,7 +116,7 @@ void mpeg2_buffer (mpeg2dec_t * mpeg2dec, uint8_t * start, uint8_t * end)
mpeg2dec->buf_end = end;
}

static inline int seek_chunk (mpeg2dec_t * mpeg2dec)
static int seek_chunk (mpeg2dec_t * mpeg2dec)
{
int size, skipped;

Expand Down
2 changes: 1 addition & 1 deletion src/vldp2/libmpeg2/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ static int sequence_display_ext (mpeg2dec_t * mpeg2dec)
return 0;
}

static inline void finalize_sequence (sequence_t * sequence)
static void finalize_sequence (sequence_t * sequence)
{
int width;
int height;
Expand Down
4 changes: 2 additions & 2 deletions src/vldp2/libmpeg2/idct.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ do { \
} while (0)
#endif

static void inline idct_row (int16_t * const block)
static void idct_row (int16_t * const block)
{
int d0, d1, d2, d3;
int a0, a1, a2, a3, b0, b1, b2, b3;
Expand Down Expand Up @@ -113,7 +113,7 @@ static void inline idct_row (int16_t * const block)
block[7] = (a0 - b0) >> 8;
}

static void inline idct_col (int16_t * const block)
static void idct_col (int16_t * const block)
{
int d0, d1, d2, d3;
int a0, a1, a2, a3, b0, b1, b2, b3;
Expand Down
Loading

0 comments on commit b5b16a5

Please sign in to comment.