summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2011-05-01 13:48:28 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2011-05-01 13:48:28 +0000
commitf7c45941344ecfbcdd5d9b311b61573d37c6ef58 (patch)
tree4c2fa595d7209694dd30b0e0b349a0a44116d712
parent08fb3f65745a237e2c1eae55d856ff27702246e5 (diff)
downloadrockbox-f7c45941344ecfbcdd5d9b311b61573d37c6ef58.tar.gz
rockbox-f7c45941344ecfbcdd5d9b311b61573d37c6ef58.zip
Fix further 'variable set but not used' warnings reported from GCC 4.6.0.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29809 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/raac.c3
-rw-r--r--apps/gui/option_select.c13
-rw-r--r--apps/metadata/rm.c2
-rw-r--r--apps/plugins/bubbles.c3
-rw-r--r--apps/plugins/chessbox/chessbox.c3
-rw-r--r--apps/plugins/chopper.c7
-rw-r--r--apps/plugins/frotz/fastmem.c618
-rw-r--r--apps/plugins/imageviewer/png/png_decoder.c3
-rw-r--r--apps/plugins/keybox.c3
-rw-r--r--apps/plugins/lrcplayer.c2
-rw-r--r--apps/plugins/mp3_encoder.c6
-rw-r--r--apps/plugins/pitch_detector.c4
-rw-r--r--apps/plugins/plasma.c5
-rw-r--r--apps/plugins/sokoban.c4
-rw-r--r--apps/plugins/star.c4
-rw-r--r--apps/plugins/zxbox/zxbox_keyb.c22
-rw-r--r--lib/skin_parser/skin_parser.c3
17 files changed, 347 insertions, 358 deletions
diff --git a/apps/codecs/raac.c b/apps/codecs/raac.c
index 48a0b60ce1..3f6dc01970 100644
--- a/apps/codecs/raac.c
+++ b/apps/codecs/raac.c
@@ -54,7 +54,6 @@ enum codec_status codec_run(void)
54 static NeAACDecFrameInfo frame_info; 54 static NeAACDecFrameInfo frame_info;
55 NeAACDecHandle decoder; 55 NeAACDecHandle decoder;
56 size_t n; 56 size_t n;
57 void *ret;
58 unsigned int i; 57 unsigned int i;
59 unsigned char* buffer; 58 unsigned char* buffer;
60 int err, consumed, pkt_offset, skipped = 0; 59 int err, consumed, pkt_offset, skipped = 0;
@@ -192,7 +191,7 @@ enum codec_status codec_run(void)
192 191
193 /* Decode one block - returned samples will be host-endian */ 192 /* Decode one block - returned samples will be host-endian */
194 for(i = 0; i < rmctx.sub_packet_cnt; i++) { 193 for(i = 0; i < rmctx.sub_packet_cnt; i++) {
195 ret = NeAACDecDecode(decoder, &frame_info, buffer, rmctx.sub_packet_lengths[i]); 194 NeAACDecDecode(decoder, &frame_info, buffer, rmctx.sub_packet_lengths[i]);
196 buffer += rmctx.sub_packet_lengths[i]; 195 buffer += rmctx.sub_packet_lengths[i];
197 if (frame_info.error > 0) { 196 if (frame_info.error > 0) {
198 DEBUGF("FAAD: decode error '%s'\n", NeAACDecGetErrorMessage(frame_info.error)); 197 DEBUGF("FAAD: decode error '%s'\n", NeAACDecGetErrorMessage(frame_info.error));
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c
index 5d1e3d778e..f954268c18 100644
--- a/apps/gui/option_select.c
+++ b/apps/gui/option_select.c
@@ -315,7 +315,10 @@ void option_select_next_val(const struct settings_list *setting,
315 315
316static int selection_to_val(const struct settings_list *setting, int selection) 316static int selection_to_val(const struct settings_list *setting, int selection)
317{ 317{
318 int min = 0, max = 0, step = 1; 318 /* rockbox: comment 'set but unused' variables
319 int min = 0;
320 */
321 int max = 0, step = 1;
319 if (((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) || 322 if (((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) ||
320 ((setting->flags & F_CHOICE_SETTING) == F_CHOICE_SETTING)) 323 ((setting->flags & F_CHOICE_SETTING) == F_CHOICE_SETTING))
321 return selection; 324 return selection;
@@ -339,10 +342,10 @@ static int selection_to_val(const struct settings_list *setting, int selection)
339#ifndef ASCENDING_INT_SETTINGS 342#ifndef ASCENDING_INT_SETTINGS
340 step = sound_steps(setting_id); 343 step = sound_steps(setting_id);
341 max = sound_max(setting_id); 344 max = sound_max(setting_id);
342 min = sound_min(setting_id); 345 /* min = sound_min(setting_id); */
343#else 346#else
344 step = -sound_steps(setting_id); 347 step = -sound_steps(setting_id);
345 min = sound_max(setting_id); 348 /* min = sound_max(setting_id); */
346 max = sound_min(setting_id); 349 max = sound_min(setting_id);
347#endif 350#endif
348 } 351 }
@@ -350,12 +353,12 @@ static int selection_to_val(const struct settings_list *setting, int selection)
350 { 353 {
351 const struct int_setting *info = setting->int_setting; 354 const struct int_setting *info = setting->int_setting;
352#ifndef ASCENDING_INT_SETTINGS 355#ifndef ASCENDING_INT_SETTINGS
353 min = info->min; 356 /* min = info->min; */
354 max = info->max; 357 max = info->max;
355 step = info->step; 358 step = info->step;
356#else 359#else
357 max = info->min; 360 max = info->min;
358 min = info->max; 361 /* min = info->max; */
359 step = -info->step; 362 step = -info->step;
360#endif 363#endif
361 } 364 }
diff --git a/apps/metadata/rm.c b/apps/metadata/rm.c
index 8dc4fbe8db..27f541cb25 100644
--- a/apps/metadata/rm.c
+++ b/apps/metadata/rm.c
@@ -223,7 +223,7 @@ static int rm_parse_header(int fd, RMContext *rmctx, struct mp3entry *id3)
223 struct real_object_t obj; 223 struct real_object_t obj;
224 int res; 224 int res;
225 int skipped; 225 int skipped;
226 off_t curpos; 226 off_t curpos __attribute__((unused));
227 uint8_t len; /* Holds a string_length, which is then passed to read_string() */ 227 uint8_t len; /* Holds a string_length, which is then passed to read_string() */
228 228
229#ifdef SIMULATOR 229#ifdef SIMULATOR
diff --git a/apps/plugins/bubbles.c b/apps/plugins/bubbles.c
index 1a2f96ddfa..d9f76f7f72 100644
--- a/apps/plugins/bubbles.c
+++ b/apps/plugins/bubbles.c
@@ -1953,7 +1953,7 @@ static int bubbles_remove(struct game_context* bb) {
1953******************************************************************************/ 1953******************************************************************************/
1954static void bubbles_anchored(struct game_context* bb, int row, int col) { 1954static void bubbles_anchored(struct game_context* bb, int row, int col) {
1955 int i, adj; 1955 int i, adj;
1956 int myrow, mycol, mytype; 1956 int myrow, mycol;
1957 int count = 0; 1957 int count = 0;
1958 1958
1959 struct coord { 1959 struct coord {
@@ -1971,7 +1971,6 @@ static void bubbles_anchored(struct game_context* bb, int row, int col) {
1971 for(i=0; i<count; i++) { 1971 for(i=0; i<count; i++) {
1972 myrow = search[i].row; 1972 myrow = search[i].row;
1973 mycol = search[i].col; 1973 mycol = search[i].col;
1974 mytype = bb->playboard[myrow][mycol].type;
1975 adj = myrow%2; 1974 adj = myrow%2;
1976 1975
1977 if(mycol-1 >= 0) { 1976 if(mycol-1 >= 0) {
diff --git a/apps/plugins/chessbox/chessbox.c b/apps/plugins/chessbox/chessbox.c
index 4876231207..6e77b62718 100644
--- a/apps/plugins/chessbox/chessbox.c
+++ b/apps/plugins/chessbox/chessbox.c
@@ -321,7 +321,6 @@ void cb_saveposition ( void ) {
321/* ---- Restore saved position ---- */ 321/* ---- Restore saved position ---- */
322void cb_restoreposition ( void ) { 322void cb_restoreposition ( void ) {
323 int fd; 323 int fd;
324 int c;
325 short sq; 324 short sq;
326 unsigned short m; 325 unsigned short m;
327 326
@@ -357,7 +356,7 @@ void cb_restoreposition ( void ) {
357 else 356 else
358 --color[sq]; 357 --color[sq];
359 } 358 }
360 GameCnt = -1; c = '?'; 359 GameCnt = -1;
361 while (rb->read(fd, &(GameList[++GameCnt].gmove), 360 while (rb->read(fd, &(GameList[++GameCnt].gmove),
362 sizeof(GameList[GameCnt].gmove)) > 0) { 361 sizeof(GameList[GameCnt].gmove)) > 0) {
363 rb->read(fd, &(GameList[GameCnt].score), 362 rb->read(fd, &(GameList[GameCnt].score),
diff --git a/apps/plugins/chopper.c b/apps/plugins/chopper.c
index 5f9fadf205..bb36294238 100644
--- a/apps/plugins/chopper.c
+++ b/apps/plugins/chopper.c
@@ -392,7 +392,6 @@ static void chopTerrainNodeDeleteAndShift(struct CTerrain *ter,int nodeIndex)
392int chopUpdateTerrainRecycling(struct CTerrain *ter) 392int chopUpdateTerrainRecycling(struct CTerrain *ter)
393{ 393{
394 int i=1; 394 int i=1;
395 int ret = 0;
396 int iNewNodePos,g,v; 395 int iNewNodePos,g,v;
397 while(i < ter->iNodesCount) 396 while(i < ter->iNodesCount)
398 { 397 {
@@ -412,8 +411,6 @@ int chopUpdateTerrainRecycling(struct CTerrain *ter)
412 v*=5; 411 v*=5;
413 412
414 chopAddTerrainNode(ter,iNewNodePos,g - iR(-v,v)); 413 chopAddTerrainNode(ter,iNewNodePos,g - iR(-v,v));
415 ret=1;
416
417 } 414 }
418 415
419 i++; 416 i++;
@@ -426,7 +423,7 @@ int chopUpdateTerrainRecycling(struct CTerrain *ter)
426int chopTerrainHeightAtPoint(struct CTerrain *ter, int pX) 423int chopTerrainHeightAtPoint(struct CTerrain *ter, int pX)
427{ 424{
428 425
429 int iNodeIndexOne=0,iNodeIndexTwo=0, h, terY1, terY2, terX1, terX2, a, b; 426 int iNodeIndexOne=0,iNodeIndexTwo=0, h, terY1, terY2, terX2, a, b;
430 float c,d; 427 float c,d;
431 428
432 int i=0; 429 int i=0;
@@ -444,7 +441,7 @@ int chopTerrainHeightAtPoint(struct CTerrain *ter, int pX)
444 terY1 = ter->mNodes[iNodeIndexOne].y; 441 terY1 = ter->mNodes[iNodeIndexOne].y;
445 terY2 = ter->mNodes[iNodeIndexTwo].y; 442 terY2 = ter->mNodes[iNodeIndexTwo].y;
446 443
447 terX1 = 0; 444 /* terX1 = 0; */
448 terX2 = ter->mNodes[iNodeIndexTwo].x - ter->mNodes[iNodeIndexOne].x; 445 terX2 = ter->mNodes[iNodeIndexTwo].x - ter->mNodes[iNodeIndexOne].x;
449 446
450 pX-= ter->mNodes[iNodeIndexOne].x; 447 pX-= ter->mNodes[iNodeIndexOne].x;
diff --git a/apps/plugins/frotz/fastmem.c b/apps/plugins/frotz/fastmem.c
index ce424af1f2..39ad5510ed 100644
--- a/apps/plugins/frotz/fastmem.c
+++ b/apps/plugins/frotz/fastmem.c
@@ -1,5 +1,5 @@
1/* fastmem.c - Memory related functions (fast version without virtual memory) 1/* fastmem.c - Memory related functions (fast version without virtual memory)
2 * Copyright (c) 1995-1997 Stefan Jokisch 2 * Copyright (c) 1995-1997 Stefan Jokisch
3 * 3 *
4 * Changes for Rockbox copyright 2009 Torne Wuff 4 * Changes for Rockbox copyright 2009 Torne Wuff
5 * 5 *
@@ -93,7 +93,7 @@ zword get_header_extension (int entry)
93 zword val; 93 zword val;
94 94
95 if (h_extension_table == 0 || entry > hx_table_size) 95 if (h_extension_table == 0 || entry > hx_table_size)
96 return 0; 96 return 0;
97 97
98 addr = h_extension_table + 2 * entry; 98 addr = h_extension_table + 2 * entry;
99 LOW_WORD (addr, val) 99 LOW_WORD (addr, val)
@@ -114,7 +114,7 @@ void set_header_extension (int entry, zword val)
114 zword addr; 114 zword addr;
115 115
116 if (h_extension_table == 0 || entry > hx_table_size) 116 if (h_extension_table == 0 || entry > hx_table_size)
117 return; 117 return;
118 118
119 addr = h_extension_table + 2 * entry; 119 addr = h_extension_table + 2 * entry;
120 SET_WORD (addr, val) 120 SET_WORD (addr, val)
@@ -141,39 +141,39 @@ void restart_header (void)
141 SET_WORD (H_FLAGS, h_flags) 141 SET_WORD (H_FLAGS, h_flags)
142 142
143 if (h_version >= V4) { 143 if (h_version >= V4) {
144 SET_BYTE (H_INTERPRETER_NUMBER, h_interpreter_number) 144 SET_BYTE (H_INTERPRETER_NUMBER, h_interpreter_number)
145 SET_BYTE (H_INTERPRETER_VERSION, h_interpreter_version) 145 SET_BYTE (H_INTERPRETER_VERSION, h_interpreter_version)
146 SET_BYTE (H_SCREEN_ROWS, h_screen_rows) 146 SET_BYTE (H_SCREEN_ROWS, h_screen_rows)
147 SET_BYTE (H_SCREEN_COLS, h_screen_cols) 147 SET_BYTE (H_SCREEN_COLS, h_screen_cols)
148 } 148 }
149 149
150 /* It's less trouble to use font size 1x1 for V5 games, especially 150 /* It's less trouble to use font size 1x1 for V5 games, especially
151 because of a bug in the unreleased German version of "Zork 1" */ 151 because of a bug in the unreleased German version of "Zork 1" */
152 152
153 if (h_version != V6) { 153 if (h_version != V6) {
154 screen_x_size = (zword) h_screen_cols; 154 screen_x_size = (zword) h_screen_cols;
155 screen_y_size = (zword) h_screen_rows; 155 screen_y_size = (zword) h_screen_rows;
156 font_x_size = 1; 156 font_x_size = 1;
157 font_y_size = 1; 157 font_y_size = 1;
158 } else { 158 } else {
159 screen_x_size = h_screen_width; 159 screen_x_size = h_screen_width;
160 screen_y_size = h_screen_height; 160 screen_y_size = h_screen_height;
161 font_x_size = h_font_width; 161 font_x_size = h_font_width;
162 font_y_size = h_font_height; 162 font_y_size = h_font_height;
163 } 163 }
164 164
165 if (h_version >= V5) { 165 if (h_version >= V5) {
166 SET_WORD (H_SCREEN_WIDTH, screen_x_size) 166 SET_WORD (H_SCREEN_WIDTH, screen_x_size)
167 SET_WORD (H_SCREEN_HEIGHT, screen_y_size) 167 SET_WORD (H_SCREEN_HEIGHT, screen_y_size)
168 SET_BYTE (H_FONT_HEIGHT, font_y_size) 168 SET_BYTE (H_FONT_HEIGHT, font_y_size)
169 SET_BYTE (H_FONT_WIDTH, font_x_size) 169 SET_BYTE (H_FONT_WIDTH, font_x_size)
170 SET_BYTE (H_DEFAULT_BACKGROUND, h_default_background) 170 SET_BYTE (H_DEFAULT_BACKGROUND, h_default_background)
171 SET_BYTE (H_DEFAULT_FOREGROUND, h_default_foreground) 171 SET_BYTE (H_DEFAULT_FOREGROUND, h_default_foreground)
172 } 172 }
173 173
174 if (h_version == V6) 174 if (h_version == V6)
175 for (i = 0; i < 8; i++) 175 for (i = 0; i < 8; i++)
176 storeb ((zword) (H_USER_NAME + i), h_user_name[i]); 176 storeb ((zword) (H_USER_NAME + i), h_user_name[i]);
177 177
178 SET_BYTE (H_STANDARD_HIGH, h_standard_high) 178 SET_BYTE (H_STANDARD_HIGH, h_standard_high)
179 SET_BYTE (H_STANDARD_LOW, h_standard_low) 179 SET_BYTE (H_STANDARD_LOW, h_standard_low)
@@ -197,41 +197,41 @@ void init_memory (void)
197 size_t buf_size; 197 size_t buf_size;
198 198
199 static struct { 199 static struct {
200 enum story story_id; 200 enum story story_id;
201 zword release; 201 zword release;
202 zbyte serial[6]; 202 zbyte serial[6];
203 } records[] = { 203 } records[] = {
204 { SHERLOCK, 21, "871214" }, 204 { SHERLOCK, 21, "871214" },
205 { SHERLOCK, 26, "880127" }, 205 { SHERLOCK, 26, "880127" },
206 { BEYOND_ZORK, 47, "870915" }, 206 { BEYOND_ZORK, 47, "870915" },
207 { BEYOND_ZORK, 49, "870917" }, 207 { BEYOND_ZORK, 49, "870917" },
208 { BEYOND_ZORK, 51, "870923" }, 208 { BEYOND_ZORK, 51, "870923" },
209 { BEYOND_ZORK, 57, "871221" }, 209 { BEYOND_ZORK, 57, "871221" },
210 { ZORK_ZERO, 296, "881019" }, 210 { ZORK_ZERO, 296, "881019" },
211 { ZORK_ZERO, 366, "890323" }, 211 { ZORK_ZERO, 366, "890323" },
212 { ZORK_ZERO, 383, "890602" }, 212 { ZORK_ZERO, 383, "890602" },
213 { ZORK_ZERO, 393, "890714" }, 213 { ZORK_ZERO, 393, "890714" },
214 { SHOGUN, 292, "890314" }, 214 { SHOGUN, 292, "890314" },
215 { SHOGUN, 295, "890321" }, 215 { SHOGUN, 295, "890321" },
216 { SHOGUN, 311, "890510" }, 216 { SHOGUN, 311, "890510" },
217 { SHOGUN, 322, "890706" }, 217 { SHOGUN, 322, "890706" },
218 { ARTHUR, 54, "890606" }, 218 { ARTHUR, 54, "890606" },
219 { ARTHUR, 63, "890622" }, 219 { ARTHUR, 63, "890622" },
220 { ARTHUR, 74, "890714" }, 220 { ARTHUR, 74, "890714" },
221 { JOURNEY, 26, "890316" }, 221 { JOURNEY, 26, "890316" },
222 { JOURNEY, 30, "890322" }, 222 { JOURNEY, 30, "890322" },
223 { JOURNEY, 77, "890616" }, 223 { JOURNEY, 77, "890616" },
224 { JOURNEY, 83, "890706" }, 224 { JOURNEY, 83, "890706" },
225 { LURKING_HORROR, 203, "870506" }, 225 { LURKING_HORROR, 203, "870506" },
226 { LURKING_HORROR, 219, "870912" }, 226 { LURKING_HORROR, 219, "870912" },
227 { LURKING_HORROR, 221, "870918" }, 227 { LURKING_HORROR, 221, "870918" },
228 { UNKNOWN, 0, "------" } 228 { UNKNOWN, 0, "------" }
229 }; 229 };
230 230
231 /* Open story file */ 231 /* Open story file */
232 232
233 if ((story_fp = rb->open(story_name, O_RDONLY)) < 0) 233 if ((story_fp = rb->open(story_name, O_RDONLY)) < 0)
234 os_fatal ("Cannot open story file"); 234 os_fatal ("Cannot open story file");
235 235
236 /* Allocate memory for story header */ 236 /* Allocate memory for story header */
237 237
@@ -240,19 +240,19 @@ void init_memory (void)
240 /* Load header into memory */ 240 /* Load header into memory */
241 241
242 if (fread (zmp, 1, 64, story_fp) != 64) 242 if (fread (zmp, 1, 64, story_fp) != 64)
243 os_fatal ("Story file read error"); 243 os_fatal ("Story file read error");
244 244
245 /* Copy header fields to global variables */ 245 /* Copy header fields to global variables */
246 246
247 LOW_BYTE (H_VERSION, h_version) 247 LOW_BYTE (H_VERSION, h_version)
248 248
249 if (h_version < V1 || h_version > V8) 249 if (h_version < V1 || h_version > V8)
250 os_fatal ("Unknown Z-code version"); 250 os_fatal ("Unknown Z-code version");
251 251
252 LOW_BYTE (H_CONFIG, h_config) 252 LOW_BYTE (H_CONFIG, h_config)
253 253
254 if (h_version == V3 && (h_config & CONFIG_BYTE_SWAPPED)) 254 if (h_version == V3 && (h_config & CONFIG_BYTE_SWAPPED))
255 os_fatal ("Byte swapped story file"); 255 os_fatal ("Byte swapped story file");
256 256
257 LOW_WORD (H_RELEASE, h_release) 257 LOW_WORD (H_RELEASE, h_release)
258 LOW_WORD (H_RESIDENT_SIZE, h_resident_size) 258 LOW_WORD (H_RESIDENT_SIZE, h_resident_size)
@@ -264,7 +264,7 @@ void init_memory (void)
264 LOW_WORD (H_FLAGS, h_flags) 264 LOW_WORD (H_FLAGS, h_flags)
265 265
266 for (i = 0, addr = H_SERIAL; i < 6; i++, addr++) 266 for (i = 0, addr = H_SERIAL; i < 6; i++, addr++)
267 LOW_BYTE (addr, h_serial[i]) 267 LOW_BYTE (addr, h_serial[i])
268 268
269 /* Auto-detect buggy story files that need special fixes */ 269 /* Auto-detect buggy story files that need special fixes */
270 270
@@ -272,15 +272,15 @@ void init_memory (void)
272 272
273 for (i = 0; records[i].story_id != UNKNOWN; i++) { 273 for (i = 0; records[i].story_id != UNKNOWN; i++) {
274 274
275 if (h_release == records[i].release) { 275 if (h_release == records[i].release) {
276 276
277 for (j = 0; j < 6; j++) 277 for (j = 0; j < 6; j++)
278 if (h_serial[j] != records[i].serial[j]) 278 if (h_serial[j] != records[i].serial[j])
279 goto no_match; 279 goto no_match;
280 280
281 story_id = records[i].story_id; 281 story_id = records[i].story_id;
282 282
283 } 283 }
284 284
285 no_match: ; /* null statement */ 285 no_match: ; /* null statement */
286 286
@@ -293,18 +293,18 @@ void init_memory (void)
293 293
294 if (h_file_size != 0) { 294 if (h_file_size != 0) {
295 295
296 story_size = (long) 2 * h_file_size; 296 story_size = (long) 2 * h_file_size;
297 297
298 if (h_version >= V4) 298 if (h_version >= V4)
299 story_size *= 2; 299 story_size *= 2;
300 if (h_version >= V6) 300 if (h_version >= V6)
301 story_size *= 2; 301 story_size *= 2;
302 302
303 } else { /* some old games lack the file size entry */ 303 } else { /* some old games lack the file size entry */
304 304
305 fseek (story_fp, 0, SEEK_END); 305 fseek (story_fp, 0, SEEK_END);
306 story_size = ftell (story_fp); 306 story_size = ftell (story_fp);
307 fseek (story_fp, 64, SEEK_SET); 307 fseek (story_fp, 64, SEEK_SET);
308 308
309 } 309 }
310 310
@@ -318,27 +318,27 @@ void init_memory (void)
318 /* Zork Zero Macintosh doesn't have the graphics flag set */ 318 /* Zork Zero Macintosh doesn't have the graphics flag set */
319 319
320 if (story_id == ZORK_ZERO && h_release == 296) 320 if (story_id == ZORK_ZERO && h_release == 296)
321 h_flags |= GRAPHICS_FLAG; 321 h_flags |= GRAPHICS_FLAG;
322 322
323 /* Adjust opcode tables */ 323 /* Adjust opcode tables */
324 324
325 if (h_version <= V4) { 325 if (h_version <= V4) {
326 op0_opcodes[0x09] = z_pop; 326 op0_opcodes[0x09] = z_pop;
327 op1_opcodes[0x0f] = z_not; 327 op1_opcodes[0x0f] = z_not;
328 } else { 328 } else {
329 op0_opcodes[0x09] = z_catch; 329 op0_opcodes[0x09] = z_catch;
330 op1_opcodes[0x0f] = z_call_n; 330 op1_opcodes[0x0f] = z_call_n;
331 } 331 }
332 332
333 /* Allocate memory for story data */ 333 /* Allocate memory for story data */
334 334
335 if ((size_t)story_size > buf_size) 335 if ((size_t)story_size > buf_size)
336 { 336 {
337 audiobuf = rb->plugin_get_audio_buffer(&buf_size); 337 audiobuf = rb->plugin_get_audio_buffer(&buf_size);
338 if ((size_t)story_size > buf_size) 338 if ((size_t)story_size > buf_size)
339 os_fatal ("Out of memory"); 339 os_fatal ("Out of memory");
340 rb->memcpy(audiobuf, zmp, 64); 340 rb->memcpy(audiobuf, zmp, 64);
341 zmp = audiobuf; 341 zmp = audiobuf;
342 } 342 }
343 343
344 /* Assign left over memory as the arena for undo alloc */ 344 /* Assign left over memory as the arena for undo alloc */
@@ -351,13 +351,13 @@ void init_memory (void)
351 351
352 for (size = 64; size < story_size; size += n) { 352 for (size = 64; size < story_size; size += n) {
353 353
354 if (story_size - size < 0x8000) 354 if (story_size - size < 0x8000)
355 n = (unsigned) (story_size - size); 355 n = (unsigned) (story_size - size);
356 356
357 SET_PC (size) 357 SET_PC (size)
358 358
359 if (fread (pcp, 1, n, story_fp) != (signed)n) 359 if (fread (pcp, 1, n, story_fp) != (signed)n)
360 os_fatal ("Story file read error"); 360 os_fatal ("Story file read error");
361 361
362 } 362 }
363 363
@@ -383,13 +383,13 @@ void init_undo (void)
383 + 1.5 h_dynamic_size for Quetzal diff + 2. */ 383 + 1.5 h_dynamic_size for Quetzal diff + 2. */
384 int size = (h_dynamic_size * 5) / 2 + 2; 384 int size = (h_dynamic_size * 5) / 2 + 2;
385 if ((arena_end - arena_start) >= size) { 385 if ((arena_end - arena_start) >= size) {
386 prev_zmp = arena_start; 386 prev_zmp = arena_start;
387 undo_diff = arena_start + h_dynamic_size; 387 undo_diff = arena_start + h_dynamic_size;
388 arena_start = (void*)((intptr_t)(arena_start + size + 3) & ~3); 388 arena_start = (void*)((intptr_t)(arena_start + size + 3) & ~3);
389 arena_next = arena_start; 389 arena_next = arena_start;
390 memcpy (prev_zmp, zmp, h_dynamic_size); 390 memcpy (prev_zmp, zmp, h_dynamic_size);
391 } else 391 } else
392 f_setup.undo_slots = 0; 392 f_setup.undo_slots = 0;
393 393
394}/* init_undo */ 394}/* init_undo */
395 395
@@ -402,21 +402,19 @@ void init_undo (void)
402 402
403static void free_undo (int count) 403static void free_undo (int count)
404{ 404{
405 undo_t *p;
406
407 if (count > undo_count) 405 if (count > undo_count)
408 count = undo_count; 406 count = undo_count;
409 while (count--) { 407 while (count--) {
410 p = first_undo; 408
411 if (curr_undo == first_undo) 409 if (curr_undo == first_undo)
412 curr_undo = curr_undo->next; 410 curr_undo = curr_undo->next;
413 first_undo = first_undo->next; 411 first_undo = first_undo->next;
414 undo_count--; 412 undo_count--;
415 } 413 }
416 if (first_undo) 414 if (first_undo)
417 first_undo->prev = NULL; 415 first_undo->prev = NULL;
418 else 416 else
419 last_undo = NULL; 417 last_undo = NULL;
420}/* free_undo */ 418}/* free_undo */
421 419
422/* 420/*
@@ -429,7 +427,7 @@ static void free_undo (int count)
429void reset_memory (void) 427void reset_memory (void)
430{ 428{
431 if (story_fp != -1) 429 if (story_fp != -1)
432 fclose (story_fp); 430 fclose (story_fp);
433 story_fp = -1; 431 story_fp = -1;
434 432
435 free_undo (undo_count); 433 free_undo (undo_count);
@@ -452,22 +450,22 @@ void storeb (zword addr, zbyte value)
452{ 450{
453 451
454 if (addr >= h_dynamic_size) 452 if (addr >= h_dynamic_size)
455 runtime_error (ERR_STORE_RANGE); 453 runtime_error (ERR_STORE_RANGE);
456 454
457 if (addr == H_FLAGS + 1) { /* flags register is modified */ 455 if (addr == H_FLAGS + 1) { /* flags register is modified */
458 456
459 h_flags &= ~(SCRIPTING_FLAG | FIXED_FONT_FLAG); 457 h_flags &= ~(SCRIPTING_FLAG | FIXED_FONT_FLAG);
460 h_flags |= value & (SCRIPTING_FLAG | FIXED_FONT_FLAG); 458 h_flags |= value & (SCRIPTING_FLAG | FIXED_FONT_FLAG);
461 459
462 if (value & SCRIPTING_FLAG) { 460 if (value & SCRIPTING_FLAG) {
463 if (!ostream_script) 461 if (!ostream_script)
464 script_open (); 462 script_open ();
465 } else { 463 } else {
466 if (ostream_script) 464 if (ostream_script)
467 script_close (); 465 script_close ();
468 } 466 }
469 467
470 refresh_text_style (); 468 refresh_text_style ();
471 469
472 } 470 }
473 471
@@ -493,7 +491,7 @@ void storew (zword addr, zword value)
493/* 491/*
494 * z_restart, re-load dynamic area, clear the stack and set the PC. 492 * z_restart, re-load dynamic area, clear the stack and set the PC.
495 * 493 *
496 * no zargs used 494 * no zargs used
497 * 495 *
498 */ 496 */
499 497
@@ -509,10 +507,10 @@ void z_restart (void)
509 507
510 if (!first_restart) { 508 if (!first_restart) {
511 509
512 fseek (story_fp, 0, SEEK_SET); 510 fseek (story_fp, 0, SEEK_SET);
513 511
514 if (fread (zmp, 1, h_dynamic_size, story_fp) != h_dynamic_size) 512 if (fread (zmp, 1, h_dynamic_size, story_fp) != h_dynamic_size)
515 os_fatal ("Story file read error"); 513 os_fatal ("Story file read error");
516 514
517 } else first_restart = FALSE; 515 } else first_restart = FALSE;
518 516
@@ -524,8 +522,8 @@ void z_restart (void)
524 522
525 if (h_version != V6) { 523 if (h_version != V6) {
526 524
527 long pc = (long) h_start_pc; 525 long pc = (long) h_start_pc;
528 SET_PC (pc) 526 SET_PC (pc)
529 527
530 } else call (h_start_pc, 0, NULL, 0); 528 } else call (h_start_pc, 0, NULL, 0);
531 529
@@ -546,30 +544,30 @@ static void get_default_name (char *default_name, zword addr)
546 544
547 if (addr != 0) { 545 if (addr != 0) {
548 546
549 zbyte len; 547 zbyte len;
550 int i; 548 int i;
551 549
552 LOW_BYTE (addr, len) 550 LOW_BYTE (addr, len)
553 addr++; 551 addr++;
554 552
555 for (i = 0; i < len; i++) { 553 for (i = 0; i < len; i++) {
556 554
557 zbyte c; 555 zbyte c;
558 556
559 LOW_BYTE (addr, c) 557 LOW_BYTE (addr, c)
560 addr++; 558 addr++;
561 559
562 if (c >= 'A' && c <= 'Z') 560 if (c >= 'A' && c <= 'Z')
563 c += 'a' - 'A'; 561 c += 'a' - 'A';
564 562
565 default_name[i] = c; 563 default_name[i] = c;
566 564
567 } 565 }
568 566
569 default_name[i] = 0; 567 default_name[i] = 0;
570 568
571 if (strchr (default_name, '.') == NULL) 569 if (strchr (default_name, '.') == NULL)
572 strcpy (default_name + i, ".AUX"); 570 strcpy (default_name + i, ".AUX");
573 571
574 } else strcpy (default_name, auxilary_name); 572 } else strcpy (default_name, auxilary_name);
575 573
@@ -578,9 +576,9 @@ static void get_default_name (char *default_name, zword addr)
578/* 576/*
579 * z_restore, restore [a part of] a Z-machine state from disk 577 * z_restore, restore [a part of] a Z-machine state from disk
580 * 578 *
581 * zargs[0] = address of area to restore (optional) 579 * zargs[0] = address of area to restore (optional)
582 * zargs[1] = number of bytes to restore 580 * zargs[1] = number of bytes to restore
583 * zargs[2] = address of suggested file name 581 * zargs[2] = address of suggested file name
584 * 582 *
585 */ 583 */
586 584
@@ -594,84 +592,84 @@ void z_restore (void)
594 592
595 if (zargc != 0) { 593 if (zargc != 0) {
596 594
597 /* Get the file name */ 595 /* Get the file name */
598 596
599 get_default_name (default_name, (zargc >= 3) ? zargs[2] : 0); 597 get_default_name (default_name, (zargc >= 3) ? zargs[2] : 0);
600 598
601 if (os_read_file_name (new_name, default_name, FILE_LOAD_AUX) == 0) 599 if (os_read_file_name (new_name, default_name, FILE_LOAD_AUX) == 0)
602 goto finished; 600 goto finished;
603 601
604 strcpy (auxilary_name, default_name); 602 strcpy (auxilary_name, default_name);
605 603
606 /* Open auxilary file */ 604 /* Open auxilary file */
607 605
608 if ((gfp = rb->open (new_name, O_RDONLY)) < 0) 606 if ((gfp = rb->open (new_name, O_RDONLY)) < 0)
609 goto finished; 607 goto finished;
610 608
611 /* Load auxilary file */ 609 /* Load auxilary file */
612 610
613 success = fread (zmp + zargs[0], 1, zargs[1], gfp); 611 success = fread (zmp + zargs[0], 1, zargs[1], gfp);
614 612
615 /* Close auxilary file */ 613 /* Close auxilary file */
616 614
617 fclose (gfp); 615 fclose (gfp);
618 616
619 } else { 617 } else {
620 618
621 /* Get the file name */ 619 /* Get the file name */
622 620
623 if (os_read_file_name (new_name, save_name, FILE_RESTORE) == 0) 621 if (os_read_file_name (new_name, save_name, FILE_RESTORE) == 0)
624 goto finished; 622 goto finished;
625 623
626 strcpy (save_name, new_name); 624 strcpy (save_name, new_name);
627 625
628 /* Open game file */ 626 /* Open game file */
629 627
630 if ((gfp = rb->open (new_name, O_RDONLY)) < 0) 628 if ((gfp = rb->open (new_name, O_RDONLY)) < 0)
631 goto finished; 629 goto finished;
632 630
633 success = restore_quetzal (gfp, story_fp); 631 success = restore_quetzal (gfp, story_fp);
634 632
635 /* Close game file */ 633 /* Close game file */
636 634
637 fclose (gfp); 635 fclose (gfp);
638 636
639 if ((short) success >= 0) { 637 if ((short) success >= 0) {
640 638
641 if ((short) success > 0) { 639 if ((short) success > 0) {
642 zbyte old_screen_rows; 640 zbyte old_screen_rows;
643 zbyte old_screen_cols; 641 zbyte old_screen_cols;
644 642
645 /* In V3, reset the upper window. */ 643 /* In V3, reset the upper window. */
646 if (h_version == V3) 644 if (h_version == V3)
647 split_window (0); 645 split_window (0);
648 646
649 LOW_BYTE (H_SCREEN_ROWS, old_screen_rows); 647 LOW_BYTE (H_SCREEN_ROWS, old_screen_rows);
650 LOW_BYTE (H_SCREEN_COLS, old_screen_cols); 648 LOW_BYTE (H_SCREEN_COLS, old_screen_cols);
651 649
652 /* Reload cached header fields. */ 650 /* Reload cached header fields. */
653 restart_header (); 651 restart_header ();
654 652
655 /* 653 /*
656 * Since QUETZAL files may be saved on many different machines, 654 * Since QUETZAL files may be saved on many different machines,
657 * the screen sizes may vary a lot. Erasing the status window 655 * the screen sizes may vary a lot. Erasing the status window
658 * seems to cover up most of the resulting badness. 656 * seems to cover up most of the resulting badness.
659 */ 657 */
660 if (h_version > V3 && h_version != V6 658 if (h_version > V3 && h_version != V6
661 && (h_screen_rows != old_screen_rows 659 && (h_screen_rows != old_screen_rows
662 || h_screen_cols != old_screen_cols)) 660 || h_screen_cols != old_screen_cols))
663 erase_window (1); 661 erase_window (1);
664 } 662 }
665 } else 663 } else
666 os_fatal ("Error reading save file"); 664 os_fatal ("Error reading save file");
667 } 665 }
668 666
669finished: 667finished:
670 668
671 if (h_version <= V3) 669 if (h_version <= V3)
672 branch (success); 670 branch (success);
673 else 671 else
674 store (success); 672 store (success);
675 673
676}/* z_restore */ 674}/* z_restore */
677 675
@@ -694,28 +692,28 @@ static long mem_diff (zbyte *a, zbyte *b, zword mem_size, zbyte *diff)
694 zbyte c = 0; 692 zbyte c = 0;
695 693
696 for (;;) { 694 for (;;) {
697 for (j = 0; size > 0 && (c = *a++ ^ *b++) == 0; j++) 695 for (j = 0; size > 0 && (c = *a++ ^ *b++) == 0; j++)
698 size--; 696 size--;
699 if (size == 0) break; 697 if (size == 0) break;
700 size--; 698 size--;
701 if (j > 0x8000) { 699 if (j > 0x8000) {
702 *p++ = 0; 700 *p++ = 0;
703 *p++ = 0xff; 701 *p++ = 0xff;
704 *p++ = 0xff; 702 *p++ = 0xff;
705 j -= 0x8000; 703 j -= 0x8000;
706 } 704 }
707 if (j > 0) { 705 if (j > 0) {
708 *p++ = 0; 706 *p++ = 0;
709 j--; 707 j--;
710 if (j <= 0x7f) { 708 if (j <= 0x7f) {
711 *p++ = j; 709 *p++ = j;
712 } else { 710 } else {
713 *p++ = (j & 0x7f) | 0x80; 711 *p++ = (j & 0x7f) | 0x80;
714 *p++ = (j & 0x7f80) >> 7; 712 *p++ = (j & 0x7f80) >> 7;
715 } 713 }
716 } 714 }
717 *p++ = c; 715 *p++ = c;
718 *(b - 1) ^= c; 716 *(b - 1) ^= c;
719 } 717 }
720 return p - diff; 718 return p - diff;
721}/* mem_diff */ 719}/* mem_diff */
@@ -732,27 +730,27 @@ static void mem_undiff (zbyte *diff, long diff_length, zbyte *dest)
732 zbyte c; 730 zbyte c;
733 731
734 while (diff_length) { 732 while (diff_length) {
735 c = *diff++; 733 c = *diff++;
736 diff_length--; 734 diff_length--;
737 if (c == 0) { 735 if (c == 0) {
738 unsigned runlen; 736 unsigned runlen;
739 737
740 if (!diff_length) 738 if (!diff_length)
741 return; /* Incomplete run */ 739 return; /* Incomplete run */
742 runlen = *diff++; 740 runlen = *diff++;
743 diff_length--; 741 diff_length--;
744 if (runlen & 0x80) { 742 if (runlen & 0x80) {
745 if (!diff_length) 743 if (!diff_length)
746 return; /* Incomplete extended run */ 744 return; /* Incomplete extended run */
747 c = *diff++; 745 c = *diff++;
748 diff_length--; 746 diff_length--;
749 runlen = (runlen & 0x7f) | (((unsigned) c) << 7); 747 runlen = (runlen & 0x7f) | (((unsigned) c) << 7);
750 } 748 }
751 749
752 dest += runlen + 1; 750 dest += runlen + 1;
753 } else { 751 } else {
754 *dest++ ^= c; 752 *dest++ ^= c;
755 } 753 }
756 } 754 }
757}/* mem_undiff */ 755}/* mem_undiff */
758 756
@@ -766,13 +764,13 @@ static void mem_undiff (zbyte *diff, long diff_length, zbyte *dest)
766int restore_undo (void) 764int restore_undo (void)
767{ 765{
768 766
769 if (f_setup.undo_slots == 0) /* undo feature unavailable */ 767 if (f_setup.undo_slots == 0) /* undo feature unavailable */
770 768
771 return -1; 769 return -1;
772 770
773 if (curr_undo == NULL) /* no saved game state */ 771 if (curr_undo == NULL) /* no saved game state */
774 772
775 return 0; 773 return 0;
776 774
777 /* undo possible */ 775 /* undo possible */
778 776
@@ -783,7 +781,7 @@ int restore_undo (void)
783 frame_count = curr_undo->frame_count; 781 frame_count = curr_undo->frame_count;
784 mem_undiff ((zbyte *) (curr_undo + 1), curr_undo->diff_size, prev_zmp); 782 mem_undiff ((zbyte *) (curr_undo + 1), curr_undo->diff_size, prev_zmp);
785 memcpy (sp, (zbyte *)(curr_undo + 1) + curr_undo->diff_size, 783 memcpy (sp, (zbyte *)(curr_undo + 1) + curr_undo->diff_size,
786 curr_undo->stack_size * sizeof (*sp)); 784 curr_undo->stack_size * sizeof (*sp));
787 785
788 curr_undo = curr_undo->prev; 786 curr_undo = curr_undo->prev;
789 787
@@ -796,7 +794,7 @@ int restore_undo (void)
796/* 794/*
797 * z_restore_undo, restore a Z-machine state from memory. 795 * z_restore_undo, restore a Z-machine state from memory.
798 * 796 *
799 * no zargs used 797 * no zargs used
800 * 798 *
801 */ 799 */
802 800
@@ -810,9 +808,9 @@ void z_restore_undo (void)
810/* 808/*
811 * z_save, save [a part of] the Z-machine state to disk. 809 * z_save, save [a part of] the Z-machine state to disk.
812 * 810 *
813 * zargs[0] = address of memory area to save (optional) 811 * zargs[0] = address of memory area to save (optional)
814 * zargs[1] = number of bytes to save 812 * zargs[1] = number of bytes to save
815 * zargs[2] = address of suggested file name 813 * zargs[2] = address of suggested file name
816 * 814 *
817 */ 815 */
818 816
@@ -826,63 +824,63 @@ void z_save (void)
826 824
827 if (zargc != 0) { 825 if (zargc != 0) {
828 826
829 /* Get the file name */ 827 /* Get the file name */
830 828
831 get_default_name (default_name, (zargc >= 3) ? zargs[2] : 0); 829 get_default_name (default_name, (zargc >= 3) ? zargs[2] : 0);
832 830
833 if (os_read_file_name (new_name, default_name, FILE_SAVE_AUX) == 0) 831 if (os_read_file_name (new_name, default_name, FILE_SAVE_AUX) == 0)
834 goto finished; 832 goto finished;
835 833
836 strcpy (auxilary_name, default_name); 834 strcpy (auxilary_name, default_name);
837 835
838 /* Open auxilary file */ 836 /* Open auxilary file */
839 837
840 if ((gfp = rb->open (new_name, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) 838 if ((gfp = rb->open (new_name, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0)
841 goto finished; 839 goto finished;
842 840
843 /* Write auxilary file */ 841 /* Write auxilary file */
844 842
845 success = fwrite (zmp + zargs[0], zargs[1], 1, gfp); 843 success = fwrite (zmp + zargs[0], zargs[1], 1, gfp);
846 844
847 /* Close auxilary file */ 845 /* Close auxilary file */
848 846
849 fclose (gfp); 847 fclose (gfp);
850 848
851 } else { 849 } else {
852 850
853 /* Get the file name */ 851 /* Get the file name */
854 852
855 if (os_read_file_name (new_name, save_name, FILE_SAVE) == 0) 853 if (os_read_file_name (new_name, save_name, FILE_SAVE) == 0)
856 goto finished; 854 goto finished;
857 855
858 strcpy (save_name, new_name); 856 strcpy (save_name, new_name);
859 857
860 /* Open game file */ 858 /* Open game file */
861 859
862 if ((gfp = rb->open (new_name, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) 860 if ((gfp = rb->open (new_name, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0)
863 goto finished; 861 goto finished;
864 862
865 success = save_quetzal (gfp, story_fp); 863 success = save_quetzal (gfp, story_fp);
866 864
867 /* Close game file and check for errors */ 865 /* Close game file and check for errors */
868 866
869 if (fclose (gfp) != 0 || ferror (story_fp)) { 867 if (fclose (gfp) != 0 || ferror (story_fp)) {
870 print_string ("Error writing save file\n"); 868 print_string ("Error writing save file\n");
871 goto finished; 869 goto finished;
872 } 870 }
873 871
874 /* Success */ 872 /* Success */
875 873
876 success = 1; 874 success = 1;
877 875
878 } 876 }
879 877
880finished: 878finished:
881 879
882 if (h_version <= V3) 880 if (h_version <= V3)
883 branch (success); 881 branch (success);
884 else 882 else
885 store (success); 883 store (success);
886 884
887}/* z_save */ 885}/* z_save */
888 886
@@ -900,57 +898,57 @@ int save_undo (void)
900 int size; 898 int size;
901 undo_t *p; 899 undo_t *p;
902 900
903 if (f_setup.undo_slots == 0) /* undo feature unavailable */ 901 if (f_setup.undo_slots == 0) /* undo feature unavailable */
904 return -1; 902 return -1;
905 903
906 /* save undo possible */ 904 /* save undo possible */
907 905
908 while (last_undo != curr_undo) { 906 while (last_undo != curr_undo) {
909 p = last_undo; 907 p = last_undo;
910 last_undo = last_undo->prev; 908 last_undo = last_undo->prev;
911 arena_next = p; 909 arena_next = p;
912 undo_count--; 910 undo_count--;
913 } 911 }
914 if (last_undo) 912 if (last_undo)
915 last_undo->next = NULL; 913 last_undo->next = NULL;
916 else 914 else
917 first_undo = NULL; 915 first_undo = NULL;
918 916
919 if (undo_count == f_setup.undo_slots) 917 if (undo_count == f_setup.undo_slots)
920 free_undo (1); 918 free_undo (1);
921 919
922 diff_size = mem_diff (zmp, prev_zmp, h_dynamic_size, undo_diff); 920 diff_size = mem_diff (zmp, prev_zmp, h_dynamic_size, undo_diff);
923 stack_size = stack + STACK_SIZE - sp; 921 stack_size = stack + STACK_SIZE - sp;
924 do { 922 do {
925 size = sizeof (undo_t) + diff_size + stack_size * sizeof (*sp); 923 size = sizeof (undo_t) + diff_size + stack_size * sizeof (*sp);
926 if (arena_next > (void*)first_undo) { 924 if (arena_next > (void*)first_undo) {
927 /* Free space is all at the end */ 925 /* Free space is all at the end */
928 if ((arena_end - arena_next) >= size) { 926 if ((arena_end - arena_next) >= size) {
929 /* Trivial: enough room at the end */ 927 /* Trivial: enough room at the end */
930 p = arena_next; 928 p = arena_next;
931 arena_next = (void*)((intptr_t)(arena_next + size + 3) & ~3); 929 arena_next = (void*)((intptr_t)(arena_next + size + 3) & ~3);
932 } else { 930 } else {
933 /* Need to wrap */ 931 /* Need to wrap */
934 arena_next = arena_start; 932 arena_next = arena_start;
935 p = NULL; 933 p = NULL;
936 } 934 }
937 } else { 935 } else {
938 /* Free space is somewhere else */ 936 /* Free space is somewhere else */
939 if (((void*)first_undo - arena_next) >= size) { 937 if (((void*)first_undo - arena_next) >= size) {
940 /* There is room before the "first" undo */ 938 /* There is room before the "first" undo */
941 p = arena_next; 939 p = arena_next;
942 arena_next = (void*)((intptr_t)(arena_next + size + 3) & ~3); 940 arena_next = (void*)((intptr_t)(arena_next + size + 3) & ~3);
943 } else { 941 } else {
944 /* Not enough room, just need to free some */ 942 /* Not enough room, just need to free some */
945 p = NULL; 943 p = NULL;
946 } 944 }
947 } 945 }
948 946
949 if (p == NULL) 947 if (p == NULL)
950 free_undo (1); 948 free_undo (1);
951 } while (!p && undo_count); 949 } while (!p && undo_count);
952 if (p == NULL) 950 if (p == NULL)
953 return -1; 951 return -1;
954 GET_PC (p->pc) 952 GET_PC (p->pc)
955 p->frame_count = frame_count; 953 p->frame_count = frame_count;
956 p->diff_size = diff_size; 954 p->diff_size = diff_size;
@@ -960,11 +958,11 @@ int save_undo (void)
960 memcpy ((zbyte *)(p + 1) + diff_size, sp, stack_size * sizeof (*sp)); 958 memcpy ((zbyte *)(p + 1) + diff_size, sp, stack_size * sizeof (*sp));
961 959
962 if (!first_undo) { 960 if (!first_undo) {
963 p->prev = NULL; 961 p->prev = NULL;
964 first_undo = p; 962 first_undo = p;
965 } else { 963 } else {
966 last_undo->next = p; 964 last_undo->next = p;
967 p->prev = last_undo; 965 p->prev = last_undo;
968 } 966 }
969 p->next = NULL; 967 p->next = NULL;
970 curr_undo = last_undo = p; 968 curr_undo = last_undo = p;
@@ -976,7 +974,7 @@ int save_undo (void)
976/* 974/*
977 * z_save_undo, save the current Z-machine state for a future undo. 975 * z_save_undo, save the current Z-machine state for a future undo.
978 * 976 *
979 * no zargs used 977 * no zargs used
980 * 978 *
981 */ 979 */
982 980
@@ -990,7 +988,7 @@ void z_save_undo (void)
990/* 988/*
991 * z_verify, check the story file integrity. 989 * z_verify, check the story file integrity.
992 * 990 *
993 * no zargs used 991 * no zargs used
994 * 992 *
995 */ 993 */
996 994
@@ -1004,7 +1002,7 @@ void z_verify (void)
1004 fseek (story_fp, 64, SEEK_SET); 1002 fseek (story_fp, 64, SEEK_SET);
1005 1003
1006 for (i = 64; i < story_size; i++) 1004 for (i = 64; i < story_size; i++)
1007 checksum += fgetc (story_fp); 1005 checksum += fgetc (story_fp);
1008 1006
1009 /* Branch if the checksums are equal */ 1007 /* Branch if the checksums are equal */
1010 1008
diff --git a/apps/plugins/imageviewer/png/png_decoder.c b/apps/plugins/imageviewer/png/png_decoder.c
index 1349d75db6..bae1fe3321 100644
--- a/apps/plugins/imageviewer/png/png_decoder.c
+++ b/apps/plugins/imageviewer/png/png_decoder.c
@@ -1675,7 +1675,6 @@ static void decodeGeneric(LodePNG_Decoder* decoder)
1675 1675
1676 /* for unknown chunk order */ 1676 /* for unknown chunk order */
1677 bool unknown = false; 1677 bool unknown = false;
1678 uint8_t critical_pos = 1; /*1 = after IHDR, 2 = after PLTE, 3 = after IDAT*/
1679 1678
1680 if (decoder->file_size == 0 || in == NULL) 1679 if (decoder->file_size == 0 || in == NULL)
1681 { 1680 {
@@ -1739,7 +1738,6 @@ static void decodeGeneric(LodePNG_Decoder* decoder)
1739 /* copy compressed data */ 1738 /* copy compressed data */
1740 memcpy(idat+idat_size, data, chunkLength * sizeof(uint8_t)); 1739 memcpy(idat+idat_size, data, chunkLength * sizeof(uint8_t));
1741 idat_size += chunkLength; 1740 idat_size += chunkLength;
1742 critical_pos = 3;
1743 } 1741 }
1744 /*IEND chunk*/ 1742 /*IEND chunk*/
1745 else if (LodePNG_chunk_type_equals(chunk, PNG_CHUNK_IEND)) 1743 else if (LodePNG_chunk_type_equals(chunk, PNG_CHUNK_IEND))
@@ -1765,7 +1763,6 @@ static void decodeGeneric(LodePNG_Decoder* decoder)
1765 decoder->infoPng.color.palette[(i<<2) | 2] = data[pos++]; /*B*/ 1763 decoder->infoPng.color.palette[(i<<2) | 2] = data[pos++]; /*B*/
1766 decoder->infoPng.color.palette[(i<<2) | 3] = 255; /*alpha*/ 1764 decoder->infoPng.color.palette[(i<<2) | 3] = 255; /*alpha*/
1767 } 1765 }
1768 critical_pos = 2;
1769 } 1766 }
1770 /*palette transparency chunk (tRNS)*/ 1767 /*palette transparency chunk (tRNS)*/
1771 else if (LodePNG_chunk_type_equals(chunk, PNG_CHUNK_tRNS)) 1768 else if (LodePNG_chunk_type_equals(chunk, PNG_CHUNK_tRNS))
diff --git a/apps/plugins/keybox.c b/apps/plugins/keybox.c
index 932fc5fd47..570f4e6c76 100644
--- a/apps/plugins/keybox.c
+++ b/apps/plugins/keybox.c
@@ -465,7 +465,6 @@ static int parse_buffer(void)
465 465
466static void write_output(int fd) 466static void write_output(int fd)
467{ 467{
468 size_t bytes_written;
469 int i; 468 int i;
470 size_t len, size; 469 size_t len, size;
471 char *p = &buffer[HEADER_LEN]; /* reserve space for salt + hash */ 470 char *p = &buffer[HEADER_LEN]; /* reserve space for salt + hash */
@@ -498,7 +497,7 @@ static void write_output(int fd)
498 encrypt_buffer(&buffer[8], size, &key.words[0]); 497 encrypt_buffer(&buffer[8], size, &key.words[0]);
499 rb->memcpy(&buffer[0], &salt, sizeof(salt)); 498 rb->memcpy(&buffer[0], &salt, sizeof(salt));
500 499
501 bytes_written = rb->write(fd, &buffer, size); 500 rb->write(fd, &buffer, size);
502} 501}
503 502
504static int enter_pw(char *pw_buf, size_t buflen, bool new_pw) 503static int enter_pw(char *pw_buf, size_t buflen, bool new_pw)
diff --git a/apps/plugins/lrcplayer.c b/apps/plugins/lrcplayer.c
index 8e9878f78b..a124863cc3 100644
--- a/apps/plugins/lrcplayer.c
+++ b/apps/plugins/lrcplayer.c
@@ -1193,7 +1193,6 @@ static void parse_id3v2(int fd)
1193 int bytesread = 0; 1193 int bytesread = 0;
1194 unsigned char global_flags; 1194 unsigned char global_flags;
1195 int flags; 1195 int flags;
1196 int skip;
1197 bool global_unsynch = false; 1196 bool global_unsynch = false;
1198 bool global_ff_found = false; 1197 bool global_ff_found = false;
1199 bool unsynch = false; 1198 bool unsynch = false;
@@ -1235,7 +1234,6 @@ static void parse_id3v2(int fd)
1235 1234
1236 /* Skip the extended header if it is present */ 1235 /* Skip the extended header if it is present */
1237 if(global_flags & 0x40) { 1236 if(global_flags & 0x40) {
1238 skip = 0;
1239 1237
1240 if(version == ID3_VER_2_3) { 1238 if(version == ID3_VER_2_3) {
1241 if(10 != rb->read(fd, header, 10)) 1239 if(10 != rb->read(fd, header, 10))
diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c
index 4094b4c34f..11d001cd6a 100644
--- a/apps/plugins/mp3_encoder.c
+++ b/apps/plugins/mp3_encoder.c
@@ -871,8 +871,10 @@ int Read32BitsLowHigh(int fd)
871int wave_open(void) 871int wave_open(void)
872{ 872{
873 unsigned short wFormatTag; 873 unsigned short wFormatTag;
874 /* rockbox: comment 'set but unused" variable
874 unsigned long dAvgBytesPerSec; 875 unsigned long dAvgBytesPerSec;
875 unsigned short wBlockAlign; 876 unsigned short wBlockAlign;
877 */
876 unsigned short bits_per_samp; 878 unsigned short bits_per_samp;
877 long header_size; 879 long header_size;
878 880
@@ -889,8 +891,8 @@ int wave_open(void)
889 891
890 cfg.channels = Read16BitsLowHigh(wavfile); 892 cfg.channels = Read16BitsLowHigh(wavfile);
891 cfg.samplerate = Read32BitsLowHigh(wavfile); 893 cfg.samplerate = Read32BitsLowHigh(wavfile);
892 dAvgBytesPerSec = Read32BitsLowHigh(wavfile); 894 /*dAvgBytesPerSec*/ Read32BitsLowHigh(wavfile);
893 wBlockAlign = Read16BitsLowHigh(wavfile); 895 /*wBlockAlign */ Read16BitsLowHigh(wavfile);
894 bits_per_samp = Read16BitsLowHigh(wavfile); 896 bits_per_samp = Read16BitsLowHigh(wavfile);
895 897
896 if(wFormatTag != 0x0001) return -5; /* linear PCM required */ 898 if(wFormatTag != 0x0001) return -5; /* linear PCM required */
diff --git a/apps/plugins/pitch_detector.c b/apps/plugins/pitch_detector.c
index 5e68822735..ec208268ab 100644
--- a/apps/plugins/pitch_detector.c
+++ b/apps/plugins/pitch_detector.c
@@ -982,7 +982,9 @@ static void record_data(void)
982static void record_and_get_pitch(void) 982static void record_and_get_pitch(void)
983{ 983{
984 int quit=0, button; 984 int quit=0, button;
985#ifndef SIMULATOR
985 bool redraw = true; 986 bool redraw = true;
987#endif
986 /* For tracking the latency */ 988 /* For tracking the latency */
987 /* 989 /*
988 long timer; 990 long timer;
@@ -1016,7 +1018,9 @@ static void record_and_get_pitch(void)
1016 quit = main_menu(); 1018 quit = main_menu();
1017 if(!quit) 1019 if(!quit)
1018 { 1020 {
1021#ifndef SIMULATOR
1019 redraw = true; 1022 redraw = true;
1023#endif
1020 record_data(); 1024 record_data();
1021 } 1025 }
1022 break; 1026 break;
diff --git a/apps/plugins/plasma.c b/apps/plugins/plasma.c
index 52f4204a17..4359e6e8b6 100644
--- a/apps/plugins/plasma.c
+++ b/apps/plugins/plasma.c
@@ -153,10 +153,11 @@ void cleanup(void)
153int main(void) 153int main(void)
154{ 154{
155 plasma_frequency = 1; 155 plasma_frequency = 1;
156 int action, delay, x, y; 156 int action, x, y;
157 unsigned char p1,p2,p3,p4,t1,t2,t3,t4, z,z0; 157 unsigned char p1,p2,p3,p4,t1,t2,t3,t4, z,z0;
158 long last_tick = *rb->current_tick; 158 long last_tick = *rb->current_tick;
159#ifdef HAVE_ADJUSTABLE_CPU_FREQ 159#ifdef HAVE_ADJUSTABLE_CPU_FREQ
160 int delay;
160 int cumulated_lag = 0; 161 int cumulated_lag = 0;
161#endif 162#endif
162#ifdef HAVE_LCD_COLOR 163#ifdef HAVE_LCD_COLOR
@@ -243,8 +244,8 @@ int main(void)
243 grey_ub_gray_bitmap(greybuffer, 0, 0, LCD_WIDTH, LCD_HEIGHT); 244 grey_ub_gray_bitmap(greybuffer, 0, 0, LCD_WIDTH, LCD_HEIGHT);
244#endif 245#endif
245 246
246 delay = last_tick - *rb->current_tick + HZ/33;
247#ifdef HAVE_ADJUSTABLE_CPU_FREQ 247#ifdef HAVE_ADJUSTABLE_CPU_FREQ
248 delay = last_tick - *rb->current_tick + HZ/33;
248 if (!boosted && delay < 0) 249 if (!boosted && delay < 0)
249 { 250 {
250 cumulated_lag -= delay; /* proportional increase */ 251 cumulated_lag -= delay; /* proportional increase */
diff --git a/apps/plugins/sokoban.c b/apps/plugins/sokoban.c
index 40288330bf..29bdbbbba5 100644
--- a/apps/plugins/sokoban.c
+++ b/apps/plugins/sokoban.c
@@ -1528,16 +1528,12 @@ static bool sokoban_loop(void)
1528{ 1528{
1529 bool moved; 1529 bool moved;
1530 int i = 0, button = 0, lastbutton = 0; 1530 int i = 0, button = 0, lastbutton = 0;
1531 short r = 0, c = 0;
1532 int w, h; 1531 int w, h;
1533 char *loc; 1532 char *loc;
1534 1533
1535 while (true) { 1534 while (true) {
1536 moved = false; 1535 moved = false;
1537 1536
1538 r = current_info.player.row;
1539 c = current_info.player.col;
1540
1541 button = rb->button_get(true); 1537 button = rb->button_get(true);
1542 1538
1543 switch(button) 1539 switch(button)
diff --git a/apps/plugins/star.c b/apps/plugins/star.c
index 0268ceb947..3506f4b09e 100644
--- a/apps/plugins/star.c
+++ b/apps/plugins/star.c
@@ -947,10 +947,6 @@ static int star_run_game(int current_level)
947 int key; 947 int key;
948 int lastkey = BUTTON_NONE; 948 int lastkey = BUTTON_NONE;
949 949
950 int label_offset_y;
951
952 label_offset_y = LCD_HEIGHT - char_height;
953
954 if (!star_load_level(current_level)) 950 if (!star_load_level(current_level))
955 return 0; 951 return 0;
956 952
diff --git a/apps/plugins/zxbox/zxbox_keyb.c b/apps/plugins/zxbox/zxbox_keyb.c
index 9a55475d3f..5680a8e327 100644
--- a/apps/plugins/zxbox/zxbox_keyb.c
+++ b/apps/plugins/zxbox/zxbox_keyb.c
@@ -1,5 +1,7 @@
1#include "zxconfig.h" 1#include "zxconfig.h"
2 2
3//#define ZX_WRITE_OUT_TEXT
4
3#ifndef O_BINARY 5#ifndef O_BINARY
4#define O_BINARY 0 6#define O_BINARY 0
5#endif 7#endif
@@ -274,8 +276,9 @@ int zx_kbd_input(char* text/*, int buflen*/)
274 bool done = false; 276 bool done = false;
275 int i, j, k, w, l; 277 int i, j, k, w, l;
276 int text_w = 0; 278 int text_w = 0;
277 int len_utf8/*, c = 0*/; 279#ifdef ZX_WRITE_OUT_TEXT
278 int editpos; 280 int editpos, len_utf8;
281#endif
279/* int statusbar_size = global_settings.statusbar ? STATUSBAR_HEIGHT : 0;*/ 282/* int statusbar_size = global_settings.statusbar ? STATUSBAR_HEIGHT : 0;*/
280 unsigned short ch/*, tmp, hlead = 0, hvowel = 0, htail = 0*/; 283 unsigned short ch/*, tmp, hlead = 0, hvowel = 0, htail = 0*/;
281 /*bool hangul = false;*/ 284 /*bool hangul = false;*/
@@ -298,7 +301,7 @@ int zx_kbd_input(char* text/*, int buflen*/)
298 } 301 }
299 302
300 char outline[256]; 303 char outline[256];
301 int button, lastbutton = 0; 304 int button;
302 FOR_NB_SCREENS(l) 305 FOR_NB_SCREENS(l)
303 { 306 {
304 /* Copy default keyboard to buffer */ 307 /* Copy default keyboard to buffer */
@@ -419,13 +422,15 @@ int zx_kbd_input(char* text/*, int buflen*/)
419 param[l].keyboard_margin -= param[l].keyboard_margin/2; 422 param[l].keyboard_margin -= param[l].keyboard_margin/2;
420 423
421 } 424 }
425#ifdef ZX_WRITE_OUT_TEXT
422 editpos = rb->utf8length(text); 426 editpos = rb->utf8length(text);
423 427#endif
424
425 428
426 while(!done) 429 while(!done)
427 { 430 {
431#ifdef ZX_WRITE_OUT_TEXT
428 len_utf8 = rb->utf8length(text); 432 len_utf8 = rb->utf8length(text);
433#endif
429 FOR_NB_SCREENS(l) 434 FOR_NB_SCREENS(l)
430 rb->screens[l]->clear_display(); 435 rb->screens[l]->clear_display();
431 436
@@ -456,8 +461,8 @@ int zx_kbd_input(char* text/*, int buflen*/)
456 param[l].main_y - param[l].keyboard_margin); 461 param[l].main_y - param[l].keyboard_margin);
457 462
458 /* write out the text */ 463 /* write out the text */
459#if 0 464#ifdef ZX_WRITE_OUT_TEXT
460 rb->screens[l]->setfont(param[l].curfont); 465 rb->screens[l]->setfont(param[l].curfont);
461 466
462 i=j=0; 467 i=j=0;
463 param[l].curpos = MIN(editpos, param[l].max_chars_text 468 param[l].curpos = MIN(editpos, param[l].max_chars_text
@@ -493,7 +498,7 @@ int zx_kbd_input(char* text/*, int buflen*/)
493 rb->screens[l]->hline(param[l].curpos*text_w, (param[l].curpos+1)*text_w, 498 rb->screens[l]->hline(param[l].curpos*text_w, (param[l].curpos+1)*text_w,
494 param[l].main_y+param[l].font_h-1); 499 param[l].main_y+param[l].font_h-1);
495#endif 500#endif
496 } 501 }
497 cur_blink = !cur_blink; 502 cur_blink = !cur_blink;
498 503
499 504
@@ -626,7 +631,6 @@ int zx_kbd_input(char* text/*, int buflen*/)
626 } 631 }
627 if (button != BUTTON_NONE) 632 if (button != BUTTON_NONE)
628 { 633 {
629 lastbutton = button;
630 cur_blink = true; 634 cur_blink = true;
631 } 635 }
632 } 636 }
diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c
index 1916111e09..c4bd78c8ee 100644
--- a/lib/skin_parser/skin_parser.c
+++ b/lib/skin_parser/skin_parser.c
@@ -474,7 +474,6 @@ static int skin_parse_tag(struct skin_element* element, const char** document)
474 int num_args = 1; 474 int num_args = 1;
475 int i; 475 int i;
476 int star = 0; /* Flag for the all-or-none option */ 476 int star = 0; /* Flag for the all-or-none option */
477 int req_args; /* To mark when we enter optional arguments */
478 477
479 int optional = 0; 478 int optional = 0;
480 tag_recursion_level++; 479 tag_recursion_level++;
@@ -597,7 +596,6 @@ static int skin_parse_tag(struct skin_element* element, const char** document)
597 if(*tag_args == '|') 596 if(*tag_args == '|')
598 { 597 {
599 optional = 1; 598 optional = 1;
600 req_args = i;
601 tag_args++; 599 tag_args++;
602 } 600 }
603 601
@@ -775,7 +773,6 @@ static int skin_parse_tag(struct skin_element* element, const char** document)
775 if(*tag_args == '|') 773 if(*tag_args == '|')
776 { 774 {
777 optional = 1; 775 optional = 1;
778 req_args = i + 1;
779 tag_args++; 776 tag_args++;
780 } 777 }
781 } 778 }