1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
|
diff -U 3 -b -B -r -N -- a/Joystick.cpp b/Joystick.cpp
--- a/Joystick.cpp 2013-02-15 21:03:34.651799381 +0100
+++ b/Joystick.cpp 2013-02-15 21:02:58.125330595 +0100
@@ -33,6 +33,8 @@
*/
#include "Joystick.h"
+#include <sys/types.h>
+#include <unistd.h>
/**
* Constructor. Throw an exception in case of failure.
@@ -41,10 +43,8 @@
* Param2 : The JoystickListener that will be notified with jostick events
*
*/
-Joystick::Joystick(char *dev_name, JoystickListener *lstnr)
+Joystick::Joystick(const char *dev_name, JoystickListener *lstnr)
{
- mutex = PTHREAD_MUTEX_INITIALIZER;
-
// Try to open the device.
joystickFD = ::open(dev_name, O_RDONLY | O_NONBLOCK);
if (joystickFD < 0)
@@ -118,7 +118,7 @@
{
int bytes_read;
- bytes_read = read(joystickFD, jse, sizeof(*jse));
+ bytes_read = ::read(joystickFD, jse, sizeof(*jse));
// Handle errors !!!
if (bytes_read == -1)
diff -U 3 -b -B -r -N -- a/Joystick.h b/Joystick.h
--- a/Joystick.h 2013-02-15 21:03:34.648466066 +0100
+++ b/Joystick.h 2013-02-15 21:02:58.121997280 +0100
@@ -68,7 +68,7 @@
{
public:
- Joystick(char *dev_name, JoystickListener *l);
+ Joystick(const char *dev_name, JoystickListener *l);
const char * getStrID() { return joystickID; }
const char * getDeviceName() { return deviceName; }
void setListener(JoystickListener *lstnr) { listener = lstnr; }
@@ -95,7 +95,6 @@
JoystickListener *listener;
int pollingPeriod;
bool done;
- pthread_mutex_t mutex;
bool readDevice(struct js_event *jse);
diff -U 3 -b -B -r -N -- a/Osmose-0-9-96-QT.pro b/Osmose-0-9-96-QT.pro
--- a/Osmose-0-9-96-QT.pro 2013-02-15 21:03:34.651799381 +0100
+++ b/Osmose-0-9-96-QT.pro 2013-02-15 21:02:58.125330595 +0100
@@ -1,13 +1,16 @@
-######################################################################
-# Automatically generated by qmake (2.01a) sam. avr. 30 07:19:19 2011
-######################################################################
+QT += core gui opengl
+TARGET = osmose
TEMPLATE = app
-TARGET =
+
DEPENDPATH += . cpu osmose unzip
INCLUDEPATH += . cpu osmose unzip
+
LIBS += -lz -lasound
-QT+=opengl
+
+FLAGS = -Wall -Wextra -Wunused -Wcast-qual
+QMAKE_CXXFLAGS += -std=c++11 $$FLAGS
+QMAKE_CFLAGS += -Wmissing-prototypes -Wshadow $$FLAGS
# Input
HEADERS += EmulationThread.h \
@@ -48,7 +51,7 @@
unzip/crypt.h \
unzip/ioapi.h \
unzip/unzip.h
-FORMS += Configuration.ui LogWindow.ui
+
SOURCES += EmulationThread.cpp \
Joystick.cpp \
KeyMapper.cpp \
@@ -86,3 +89,5 @@
osmose/WaveWriter.cpp \
unzip/ioapi.c \
unzip/unzip.c
+
+FORMS += Configuration.ui LogWindow.ui
diff -U 3 -b -B -r -N -- a/OsmoseGUI.cpp b/OsmoseGUI.cpp
--- a/OsmoseGUI.cpp 2013-02-15 21:03:34.651799381 +0100
+++ b/OsmoseGUI.cpp 2013-02-15 21:02:58.125330595 +0100
@@ -350,7 +350,7 @@
js0 = NULL;
try
{
- js0 = new Joystick((char *)configuration->getJoystickDevice().c_str(), this);
+ js0 = new Joystick(configuration->getJoystickDevice().c_str(), this);
string msg = "Found Joystick :";
msg = msg + js0->getStrID();
QLogWindow::getInstance()->appendLog(msg);
@@ -683,7 +683,7 @@
void OsmoseGUI::saveState()
{
if (osmoseCore == NULL) return;
- bool success = osmoseCore->saveSaveState(saveStateSlot);
+ osmoseCore->saveSaveState(saveStateSlot);
}
/**
@@ -691,7 +691,7 @@
void OsmoseGUI::loadState()
{
if (osmoseCore == NULL) return;
- bool success = osmoseCore->loadSaveState(saveStateSlot);
+ osmoseCore->loadSaveState(saveStateSlot);
}
/**
@@ -719,7 +719,7 @@
void OsmoseGUI::saveVDPGFX()
{
if (osmoseCore == NULL) return;
- bool success = osmoseCore->captureTiles();
+ osmoseCore->captureTiles();
}
/**
diff -U 3 -b -B -r -N -- a/Pthreadcpp.cpp b/Pthreadcpp.cpp
--- a/Pthreadcpp.cpp 2013-02-15 21:03:34.651799381 +0100
+++ b/Pthreadcpp.cpp 2013-02-15 21:02:58.125330595 +0100
@@ -95,7 +95,7 @@
void *Thread::entryPoint(void *instance)
{
Thread *myself = (Thread *)instance;
- myself->run( myself->getArg());
+ return myself->run( myself->getArg());
}
/**
diff -U 3 -b -B -r -N -- a/QLogWindow.cpp b/QLogWindow.cpp
--- a/QLogWindow.cpp 2013-02-15 21:03:34.651799381 +0100
+++ b/QLogWindow.cpp 2013-02-15 21:02:58.125330595 +0100
@@ -43,7 +43,7 @@
return self;
}
-void QLogWindow::appendLog(char *str)
+void QLogWindow::appendLog(const char *str)
{
QString msg(str);
QString time = getTimePrefix();
diff -U 3 -b -B -r -N -- a/QLogWindow.h b/QLogWindow.h
--- a/QLogWindow.h 2013-02-15 21:03:34.651799381 +0100
+++ b/QLogWindow.h 2013-02-15 21:02:58.125330595 +0100
@@ -46,7 +46,7 @@
~QLogWindow();
static QLogWindow *getInstance(QWidget *parent = 0);
void appendLog(string &);
- void appendLog(char *);
+ void appendLog(const char *);
void addSeparator();
protected slots:
diff -U 3 -b -B -r -N -- a/QOsmoseConfiguration.cpp b/QOsmoseConfiguration.cpp
--- a/QOsmoseConfiguration.cpp 2013-02-15 21:03:34.651799381 +0100
+++ b/QOsmoseConfiguration.cpp 2013-02-15 21:02:58.125330595 +0100
@@ -689,8 +689,6 @@
/* JoystickListener interface */
void QOsmoseConfiguration::buttonChanged(unsigned int button, bool pressed)
{
- QLabel *label;
-
switch(button)
{
case 0:
@@ -722,10 +720,12 @@
void QOsmoseConfiguration::xAxisChanged(int value)
{
+ Q_UNUSED(value)
}
void QOsmoseConfiguration::yAxisChanged(int value)
{
+ Q_UNUSED(value)
}
void QOsmoseConfiguration::joystickError()
diff -U 3 -b -B -r -N -- a/TGAWriter.cpp b/TGAWriter.cpp
--- a/TGAWriter.cpp 2013-02-15 21:03:34.758465470 +0100
+++ b/TGAWriter.cpp 2013-02-15 21:02:58.128663911 +0100
@@ -32,7 +32,7 @@
#include "TGAWriter.h"
-TGAWriter::TGAWriter(char *filename, int width, int height)
+TGAWriter::TGAWriter(const char *filename, int width, int height)
{
/* Initialise TGA Header with the given informations.*/
header.identsize = 0;
diff -U 3 -b -B -r -N -- a/TGAWriter.h b/TGAWriter.h
--- a/TGAWriter.h 2013-02-15 21:03:34.651799381 +0100
+++ b/TGAWriter.h 2013-02-15 21:02:58.125330595 +0100
@@ -60,7 +60,7 @@
{
public:
- TGAWriter(char *fn, int width, int height);
+ TGAWriter(const char *fn, int width, int height);
~TGAWriter();
bool isOk() {return isOk_;}
void writePixel(unsigned char r, unsigned char g,unsigned char b);
diff -U 3 -b -B -r -N -- a/osmose/MemoryMapper.cpp b/osmose/MemoryMapper.cpp
--- a/osmose/MemoryMapper.cpp 2013-02-15 21:03:34.758465470 +0100
+++ b/osmose/MemoryMapper.cpp 2013-02-15 21:02:58.125330595 +0100
@@ -764,7 +764,7 @@
ostringstream oss;
oss << "Cartdrige contains " << (int)bank16Ko_nbr << " 16Ko banks.";
- QLogWindow::getInstance()->appendLog((char *)oss.str().c_str());
+ QLogWindow::getInstance()->appendLog(oss.str().c_str());
// Allocate RAM for the whole cartridge.
if (rom_size < 65536)
{
@@ -833,7 +833,7 @@
ostringstream oss;
oss << "Cartdrige contains " << (int)bank16Ko_nbr << " 16Ko banks.";
- QLogWindow::getInstance()->appendLog((char *)oss.str().c_str());
+ QLogWindow::getInstance()->appendLog(oss.str().c_str());
// Allocate RAM for the whole cartridge.
if (rom_size < 65536)
@@ -877,7 +877,7 @@
{
oss << "ROM size is " << rom_size << " bytes (" << ((rom_size * 8)/1024)<< " kbits).";
}
- QLogWindow::getInstance()->appendLog((char *)oss.str().c_str());
+ QLogWindow::getInstance()->appendLog(oss.str().c_str());
}
/*------------------------------------------------------------*/
diff -U 3 -b -B -r -N -- a/osmose/OsmoseCore.cpp b/osmose/OsmoseCore.cpp
--- a/osmose/OsmoseCore.cpp 2013-02-15 21:03:34.758465470 +0100
+++ b/osmose/OsmoseCore.cpp 2013-02-15 21:02:58.125330595 +0100
@@ -251,7 +251,6 @@
// Draw tiles there.
for (int o=0; o<28;o++)
{
- int tile = 0;
for (int i=0; i<16;i++)
{
int tile = map_p;
@@ -261,7 +260,7 @@
}
/* Save the buffer. */
- TGAWriter tgaFile((char *)oss.str().c_str(), 128, 224);
+ TGAWriter tgaFile(oss.str().c_str(), 128, 224);
if (tgaFile.isOk() == true)
{
for (int y=223; y>=0; y--)
@@ -350,7 +349,7 @@
oss << configuration->getScreenshotPath() << "/" << game_name << "-" << screenshotNbr << ".tga";
screenshotNbr++;
- TGAWriter tgaFile((char *)oss.str().c_str(), 256, 192);
+ TGAWriter tgaFile(oss.str().c_str(), 256, 192);
if (tgaFile.isOk() == true)
{
for (int y=191; y>=0; y--)
@@ -431,7 +430,7 @@
save_state_name << configuration->getSaveStatePath() << "/" << mem->getROMName() << "_slot_" << slot <<".sta";
- ofstream output_file((char *)save_state_name.str().c_str(), ios::out | ios::binary );
+ ofstream output_file(save_state_name.str().c_str(), ios::out | ios::binary );
if (output_file.is_open() == false )
{
string msg = "Cannot create save state file:" + save_state_name.str();
@@ -487,7 +486,7 @@
ostringstream load_state_name;
load_state_name << configuration->getSaveStatePath() << "/" << mem->getROMName() << "_slot_" << slot <<".sta";
- ifstream input_file((char *)load_state_name.str().c_str(), ios::in | ios::binary);
+ ifstream input_file(load_state_name.str().c_str(), ios::in | ios::binary);
if (input_file.is_open() == false )
{
string msg = "Fail to load state from file : " + load_state_name.str();
diff -U 3 -b -B -r -N -- a/osmose/SoundThread.cpp b/osmose/SoundThread.cpp
--- a/osmose/SoundThread.cpp 2013-02-15 21:03:34.758465470 +0100
+++ b/osmose/SoundThread.cpp 2013-02-15 21:02:58.125330595 +0100
@@ -61,6 +61,8 @@
*/
void* SoundThread::run(void *p)
{
+ (void)p;
+
SoundThreadState local_state_copy;
{
diff -U 3 -b -B -r -N -- a/unzip/crypt.h b/unzip/crypt.h
--- a/unzip/crypt.h 2013-02-15 21:03:34.755132155 +0100
+++ b/unzip/crypt.h 2013-02-15 21:02:58.125330595 +0100
@@ -38,6 +38,8 @@
* unpredictable manner on 16-bit systems; not a problem
* with any known compiler so far, though */
+ (void)pcrc_32_tab;
+
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
}
diff -U 3 -b -B -r -N -- a/unzip/ioapi.c b/unzip/ioapi.c
--- a/unzip/ioapi.c 2013-02-15 21:03:34.755132155 +0100
+++ b/unzip/ioapi.c 2013-02-15 21:02:58.125330595 +0100
@@ -70,6 +70,8 @@
const char* filename;
int mode;
{
+ (void)opaque;
+
FILE* file = NULL;
const char* mode_fopen = NULL;
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
@@ -93,6 +95,8 @@
void* buf;
uLong size;
{
+ (void)opaque;
+
uLong ret;
ret = fread(buf, 1, (size_t)size, (FILE *)stream);
return ret;
@@ -105,6 +109,8 @@
const void* buf;
uLong size;
{
+ (void)opaque;
+
uLong ret;
ret = fwrite(buf, 1, (size_t)size, (FILE *)stream);
return ret;
@@ -114,6 +120,8 @@
voidpf opaque;
voidpf stream;
{
+ (void)opaque;
+
long ret;
ret = ftell((FILE *)stream);
return ret;
@@ -125,6 +133,8 @@
uLong offset;
int origin;
{
+ (void)opaque;
+
int fseek_origin=0;
long ret;
switch (origin)
@@ -149,6 +159,8 @@
voidpf opaque;
voidpf stream;
{
+ (void)opaque;
+
int ret;
ret = fclose((FILE *)stream);
return ret;
@@ -158,6 +170,8 @@
voidpf opaque;
voidpf stream;
{
+ (void)opaque;
+
int ret;
ret = ferror((FILE *)stream);
return ret;
diff -U 3 -b -B -r -N -- a/unzip/unzip.c b/unzip/unzip.c
--- a/unzip/unzip.c 2013-02-15 21:03:34.755132155 +0100
+++ b/unzip/unzip.c 2013-02-15 21:02:58.125330595 +0100
@@ -607,12 +607,12 @@
/* we check the magic */
- if (err==UNZ_OK)
+ if (err==UNZ_OK) {
if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
err=UNZ_ERRNO;
else if (uMagic!=0x02014b50)
err=UNZ_BADZIPFILE;
-
+ }
if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK)
err=UNZ_ERRNO;
@@ -687,14 +687,16 @@
else
uSizeRead = extraFieldBufferSize;
- if (lSeek!=0)
+ if (lSeek!=0) {
if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
lSeek=0;
else
err=UNZ_ERRNO;
- if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
+ }
+ if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) {
if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead)
err=UNZ_ERRNO;
+ }
lSeek += file_info.size_file_extra - uSizeRead;
}
else
@@ -712,14 +714,16 @@
else
uSizeRead = commentBufferSize;
- if (lSeek!=0)
+ if (lSeek!=0) {
if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
lSeek=0;
else
err=UNZ_ERRNO;
- if ((file_info.size_file_comment>0) && (commentBufferSize>0))
+ }
+ if ((file_info.size_file_comment>0) && (commentBufferSize>0)) {
if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
err=UNZ_ERRNO;
+ }
lSeek+=file_info.size_file_comment - uSizeRead;
}
else
@@ -975,12 +979,12 @@
return UNZ_ERRNO;
- if (err==UNZ_OK)
+ if (err==UNZ_OK) {
if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
err=UNZ_ERRNO;
else if (uMagic!=0x04034b50)
err=UNZ_BADZIPFILE;
-
+ }
if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
err=UNZ_ERRNO;
/*
@@ -1163,7 +1167,7 @@
if (password != NULL)
{
int i;
- s->pcrc_32_tab = get_crc_table();
+ s->pcrc_32_tab = (const unsigned long *)get_crc_table();
init_keys(password,s->keys,s->pcrc_32_tab);
if (ZSEEK(s->z_filefunc, s->filestream,
s->pfile_in_zip_read->pos_in_zipfile +
@@ -1519,7 +1523,6 @@
char *szComment;
uLong uSizeBuf;
{
- int err=UNZ_OK;
unz_s* s;
uLong uReadThis ;
if (file==NULL)
|