Compare commits

...
3 Commits
Author SHA1 Message Date
GuyPerfect 06849b54ba Fix TRAP restore PC, but better 2024-12-29 09:52:07 -06:00
GuyPerfect eef255b507 Fix TRAP restore PC 2024-12-29 09:22:14 -06:00
GuyPerfect db966c8cb8 Fix memory growth handling 2024-12-26 14:13:13 -06:00
3 changed files with 16 additions and 8 deletions
+1
View File
@@ -1637,6 +1637,7 @@ static void cpuSUBF_S(VB *sim) {
/* TRAP */ /* TRAP */
static void cpuTRAP(VB *sim) { static void cpuTRAP(VB *sim) {
sim->cpu.clocks += cpuClocks(15); sim->cpu.clocks += cpuClocks(15);
sim->cpu.pc += 2;
cpuThrow(sim, 0xFFA0 + cpuGetImm5U(sim)); cpuThrow(sim, 0xFFA0 + cpuGetImm5U(sim));
} }
+1 -1
View File
@@ -117,7 +117,7 @@ static void tmrWriteControl(VB *sim, uint8_t value) {
if ( if (
!sim->tmr.t_clk_sel && !sim->tmr.t_clk_sel &&
(value & 0x10) && /* T-Clk-Sel */ (value & 0x10) && /* T-Clk-Sel */
sim->tmr.tick20 != 4 sim->tmr.tick20 != 0
) { ) {
tmrUpdate(sim, sim->tmr.counter == 0 ? tmrUpdate(sim, sim->tmr.counter == 0 ?
sim->tmr.reload : sim->tmr.counter - 1); sim->tmr.reload : sim->tmr.counter - 1);
+12 -5
View File
@@ -87,10 +87,7 @@ new class Core {
this.sims.set(sim.pointer, sim); this.sims.set(sim.pointer, sim);
// Video // Video
sim.pixels = this.#noalloc( sim.pixels = this.#getPixels(sim);
this.GetExtPixels(sim.pointer),
384*224*4, sim, "pixels", Uint8ClampedArray
);
sim.image = new ImageData(sim.pixels, 384, 224); sim.image = new ImageData(sim.pixels, 384, 224);
// Audio // Audio
@@ -364,9 +361,11 @@ new class Core {
this.mallocs.set(buffer.pointer, buffer); this.mallocs.set(buffer.pointer, buffer);
this.#updateTarget(buffer); this.#updateTarget(buffer);
} }
for (let sim of this.sims) for (let sim of this.sims.values()) {
sim.pixels = this.#getPixels(sim);
sim.image = new ImageData(sim.pixels, 384, 224); sim.image = new ImageData(sim.pixels, 384, 224);
} }
}
@@ -436,6 +435,14 @@ new class Core {
this.Realloc(buffer.pointer, 0); this.Realloc(buffer.pointer, 0);
} }
// Register a sim's pixel buffer
#getPixels(sim) {
return this.#noalloc(
this.GetExtPixels(sim.pointer),
384*224*4, sim, "pixels", Uint8ClampedArray
);
}
// Allocate memory in WebAssembly and register the buffer // Allocate memory in WebAssembly and register the buffer
#malloc(count, target = null, assign = null, type = Uint8ClampedArray) { #malloc(count, target = null, assign = null, type = Uint8ClampedArray) {
return this.#noalloc( return this.#noalloc(