diff --git a/core/bus.c b/core/bus.c index 4dd9fd3..1017613 100644 --- a/core/bus.c +++ b/core/bus.c @@ -89,7 +89,7 @@ static int32_t busReadMisc(VB *sim, uint8_t address, int type) { /* Unmapped */ switch (type) { case VB_S8 : case VB_U8 : if (address & 3) return 0; break; - case VB_S16: case VB_U16: if (address & 1) return 0; + case VB_S16: case VB_U16: if (address & 2) return 0; } /* Access by register */ @@ -117,7 +117,7 @@ static void busWriteMisc(VB *sim, uint8_t address, int type, int32_t value) { /* Unmapped */ switch (type) { case VB_S8 : case VB_U8 : if (address & 3) return; break; - case VB_S16: case VB_U16: if (address & 1) return; + case VB_S16: case VB_U16: if (address & 2) return; } /* Access by register */ diff --git a/core/cpu.c b/core/cpu.c index b453536..fcdb3c0 100644 --- a/core/cpu.c +++ b/core/cpu.c @@ -1831,7 +1831,7 @@ static uint32_t cpuUntil(VB *sim, uint32_t clocks) { return sim->cpu.operation == CPU_HALTING && !(sim->cpu.psw.id | sim->cpu.psw.ep | sim->cpu.psw.np) && - IRQ_LEVELS[sim->cpu.irq] < sim->cpu.psw.i + IRQ_LEVELS[sim->cpu.irq] >= sim->cpu.psw.i ? 0 : clocks; } diff --git a/core/vb.c b/core/vb.c index 19c6e9f..1a0221a 100644 --- a/core/vb.c +++ b/core/vb.c @@ -103,8 +103,8 @@ struct VB { uint8_t soft_ck; /* Controller communication signal */ /* Simulation state */ - uint8_t keys; /* Next input bits */ - int step; /* Software read processing phase */ + uint16_t keys; /* Next input bits */ + int step; /* Software read processing phase */ } pad; /* Timer */ diff --git a/core/vip.c b/core/vip.c index d8aa347..962a1a6 100644 --- a/core/vip.c +++ b/core/vip.c @@ -606,7 +606,7 @@ static void vipDrawObjects(VB *sim, int group) { start = group == 0 ? 0 : (sim->vip.spt[group - 1] + 1) & 1023; stop = sim->vip.spt[group]; top = (int32_t) sim->vip.xp.sbcount << 3; - for (o = stop;; o = (o - 1) & 1023) { + for (o = stop; o != -1; o = o == start ? -1 : (o - 1) & 1023) { obj = &sim->vip.ram[0x3E000 | o << 3]; /* Validate object is enabled */ @@ -655,15 +655,12 @@ static void vipDrawObjects(VB *sim, int group) { pixel = src[sy << 1 | sx >> 2] >> ((sx & 3) << 1) & 3; if (pixel != 0) dest[y] = plt[pixel]; /* TODO: Research clocks */ - } /* x */ + } /* y */ - } /* y */ + } /* x */ } /* i */ - /* All objects have been drawn */ - if (o == start) - break; } } @@ -792,13 +789,12 @@ static void vipDrawWorld(VB *sim, uint8_t *world, uint16_t attr) { param += 4; break; case 2: /* Affine */ - dx = (int32_t) (int16_t) vipParam(param | 6) << 7; - dy = (int32_t) (int16_t) vipParam(param | 8) << 7; - mp = (int32_t) (int16_t) vipParam(param | 2); - mx = ((int32_t) (int16_t) vipParam(param ) << 13) + - dx * (left - ((mp < 0) ^ i ? mp : 0)); - my = ((int32_t) (int16_t) vipParam(param | 4) << 13) + - dy * (left - ((mp < 0) ^ i ? mp : 0)); + dx = (int32_t) (int16_t) vipParam(param|6) << 7; + dy = (int32_t) (int16_t) vipParam(param|8) << 7; + mp = (int32_t) (int16_t) vipParam(param|2); + mp = left - wx - ((mp < 0) ^ i ? mp : 0); + mx = ((int32_t) (int16_t) vipParam(param ) << 13) + dx*mp; + my = ((int32_t) (int16_t) vipParam(param|4) << 13) + dy*mp; param += 16; } @@ -882,7 +878,7 @@ static void vipRender(VB *sim) { attr = busReadBuffer(world, VB_U16); /* Non-graphical world */ - if (attr & 0x0020) /* END */ + if (attr & 0x0040) /* END */ break; /* Control world */ if ((attr & 0xC000) == 0) /* LON, RON */ continue; /* Dummy world */