X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fasm6502.c;h=27d2824f45e1c050fdb077c72c9d57cd72691e9b;hb=39809ded547bdbb08207d3e514950425215b4410;hp=2228a38e4052b93e31d28a7f3077b2a0c7bed65e;hpb=aa75c7476aeaa84cf3abc192b376a8b03c325213;p=xscreensaver diff --git a/hacks/asm6502.c b/hacks/asm6502.c index 2228a38e..27d2824f 100644 --- a/hacks/asm6502.c +++ b/hacks/asm6502.c @@ -29,7 +29,14 @@ #include #include #include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#if defined(HAVE_STDINT_H) +# include +#elif defined(HAVE_INTTYPES_H) +# include +#endif #include #include "yarandom.h" @@ -542,7 +549,7 @@ static void jmpBIT(machine_6502 *machine, m6502_AddrMode adm){ Pointer ptr; BOOL isValue = getValue(machine, adm, &ptr); warnValue(isValue); - machine->regP = setBit(machine->regP, ZERO_FL, (ptr.value & machine->regA)); + machine->regP = setBit(machine->regP, ZERO_FL, !(ptr.value & machine->regA)); machine->regP = setBit(machine->regP, OVERFLOW_FL, bitOn(ptr.value, OVERFLOW_FL)); machine->regP = setBit(machine->regP, NEGATIVE_FL, bitOn(ptr.value, NEGATIVE_FL)); @@ -1874,7 +1881,7 @@ static BOOL translate(m6502_Opcodes *op,Param *param, machine_6502 *machine){ if (op->BRA) { pushByte(machine, op->BRA); { - int diff = (param->lbladdr - machine->defaultCodePC); + int diff = abs((int)param->lbladdr - (int)machine->defaultCodePC); int backward = (param->lbladdr < machine->defaultCodePC); pushByte(machine, (backward) ? 0xff - diff : diff - 1); } @@ -2035,7 +2042,7 @@ static BOOL compileCode(machine_6502 *machine, const char *code){ AsmLine *p; if(asmlist != NULL){ for (p = asmlist; p != NULL; p = p->next) - fprintf(stderr,"%s lbl: %s addr: %d ParamLbl: %s ParamAddr: %d\n", + fprintf(stderr,"%s lbl: %s addr: %x ParamLbl: %s ParamAddr: %x\n", p->command, p->label->label, p->label->addr, p->param->label, p->param->lbladdr); } @@ -2192,7 +2199,7 @@ void m6502_eval_file(machine_6502 *machine, const char *filename, m6502_Plotter do{ sleep(0); /* XXX */ #if 0 - trace(machine); + m6502_trace(machine, stdout); #endif execute(machine); }while(machine->codeRunning);