From http://www.jwz.org/xscreensaver/xscreensaver-5.35.tar.gz
[xscreensaver] / hacks / asm6502.c
index c3aa2a34ebe102916229f03dc6ead13c5601f0a5..2228a38e4052b93e31d28a7f3077b2a0c7bed65e 100644 (file)
@@ -20,8 +20,6 @@
       I changed the structure of the assembler in this version.
 */
 
-#define NDEBUG  /* Uncomment when done with debugging */
-
 #include <stdlib.h>
 #include <stdio.h>
 /*#include <malloc.h>*/
@@ -31,7 +29,7 @@
 #include <assert.h>
 #include <ctype.h>
 #include <math.h>
-#include <stdint.h>
+#include <inttypes.h>
 #include <unistd.h>
 
 #include "yarandom.h"
@@ -41,7 +39,7 @@
 #  define random rand
 #endif*/
 
-#ifndef USE_IPHONE
+#ifndef HAVE_MOBILE
 # define READ_FILES
 #endif
 
@@ -1373,8 +1371,10 @@ static BOOL parseDec(char **s, Bit32 *value){
     free(dec);  
     return TRUE;
   }
-  else
+  else{
+    free(dec);
     return FALSE;
+  }
 }
 
 static BOOL parseValue(char **s, Bit32 *value){
@@ -1683,7 +1683,7 @@ static char *fileToBuffer(const char *filename){
   if (!buffer) abort();
 
   ifp = fopen(filename, "rb");
-  if (!ifp) return 0;
+  if (!ifp) abort();
 
   while((c = getc(ifp)) != EOF){
     buffer[i++] = c;
@@ -1874,7 +1874,7 @@ static BOOL translate(m6502_Opcodes *op,Param *param, machine_6502 *machine){
        if (op->BRA) {
          pushByte(machine, op->BRA);
           {
-            int diff = abs(param->lbladdr - machine->defaultCodePC);
+            int diff = (param->lbladdr - machine->defaultCodePC);
             int backward = (param->lbladdr < machine->defaultCodePC);
             pushByte(machine, (backward) ? 0xff - diff : diff - 1);
           }