Compare commits
5
Commits
b4feff41f0
...
04e79c9151
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04e79c9151 | ||
|
|
57dcd8370a | ||
|
|
06849b54ba | ||
|
|
eef255b507 | ||
|
|
db966c8cb8 |
@@ -153,12 +153,18 @@ static void busRead(VB *sim, uint32_t address, int type, int32_t *value) {
|
||||
|
||||
case 0: /* VIP */
|
||||
vipRead(sim, address, type, value);
|
||||
switch (type) {
|
||||
case VB_S8 : *value = (int8_t ) *value; break;
|
||||
case VB_S16: *value = (int16_t) *value; break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: break; /* VSU */
|
||||
|
||||
case 2: /* Misc. I/O */
|
||||
*value = busReadMisc(sim, address, type);
|
||||
if (type == VB_S8)
|
||||
*value = (int8_t) *value;
|
||||
break;
|
||||
|
||||
case 3: break; /* Unmapped */
|
||||
|
||||
@@ -1637,6 +1637,7 @@ static void cpuSUBF_S(VB *sim) {
|
||||
/* TRAP */
|
||||
static void cpuTRAP(VB *sim) {
|
||||
sim->cpu.clocks += cpuClocks(15);
|
||||
sim->cpu.pc += 2;
|
||||
cpuThrow(sim, 0xFFA0 + cpuGetImm5U(sim));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ static void tmrWriteControl(VB *sim, uint8_t value) {
|
||||
if (
|
||||
!sim->tmr.t_clk_sel &&
|
||||
(value & 0x10) && /* T-Clk-Sel */
|
||||
sim->tmr.tick20 != 4
|
||||
sim->tmr.tick20 != 0
|
||||
) {
|
||||
tmrUpdate(sim, sim->tmr.counter == 0 ?
|
||||
sim->tmr.reload : sim->tmr.counter - 1);
|
||||
|
||||
@@ -312,6 +312,7 @@ struct VB {
|
||||
int frame; /* FRMCYC counter */
|
||||
int32_t halfword; /* Current output halfword offset */
|
||||
int step; /* Processing phase */
|
||||
uint8_t toggle; /* Switch frame buffers next frame */
|
||||
uint32_t until; /* Clocks until interrupt condition */
|
||||
} xp;
|
||||
|
||||
@@ -326,6 +327,7 @@ struct VB {
|
||||
uint16_t spt[4]; /* Object control */
|
||||
|
||||
/* Rendering shadow memory */
|
||||
uint8_t buffer; /* Output buffer */
|
||||
uint16_t halfwords[384*28]; /* Output timing by 1x8 halfword */
|
||||
Pixels output[2]; /* Output images, row-major */
|
||||
Pixels shadow; /* Drawing shadow image, column-major */
|
||||
@@ -632,7 +634,7 @@ VBAPI void vbGetPixels(VB *sim, void *left, int leftStrideX, int leftStrideY,
|
||||
continue;
|
||||
|
||||
/* Transfer pixels to the destination */
|
||||
src = sim->vip.output[sim->vip.dp.buffer ^ 1][i];
|
||||
src = sim->vip.output[sim->vip.buffer][i];
|
||||
for (y = 0; y < 224; y++, dest += yStride)
|
||||
for (x = offset = 0; x < 384; x++, offset += xStride)
|
||||
dest[offset] = *src++;
|
||||
|
||||
@@ -126,7 +126,6 @@ typedef int (*vbOnWrite )(VB *sim, uint32_t address, int type, int32_t *valu
|
||||
|
||||
VBAPI int vbEmulate (VB *sim, uint32_t *clocks);
|
||||
VBAPI int vbEmulateEx (VB **sims, unsigned count, uint32_t *clocks);
|
||||
VBAPI void* vbGetCallback (VB *sim, int id);
|
||||
VBAPI void* vbGetCartRAM (VB *sim, uint32_t *size);
|
||||
VBAPI void* vbGetCartROM (VB *sim, uint32_t *size);
|
||||
VBAPI vbOnException vbGetExceptionCallback(VB *sim);
|
||||
|
||||
+19
-8
@@ -598,7 +598,7 @@ static void vipTransferColumn(VB *sim, int32_t eye) {
|
||||
|
||||
/* Select destination address in host memory */
|
||||
dest = &sim->vip.output
|
||||
[sim->vip.dp.buffer][eye][sim->vip.dp.column];
|
||||
[sim->vip.buffer ^ 1][eye][sim->vip.dp.column];
|
||||
|
||||
/* Output is disabled */
|
||||
if (!sim->vip.dp.enabled) {
|
||||
@@ -656,11 +656,12 @@ static int vipEmulateDisplay(VB *sim, uint32_t clocks) {
|
||||
/* Game frame */
|
||||
if (sim->vip.xp.xpen) {
|
||||
if (sim->vip.xp.frame >= sim->vip.frmcyc) {
|
||||
sim->vip.xp.frame = 0;
|
||||
sim->vip.dp.buffer ^= sim->vip.xp.toggle;
|
||||
sim->vip.xp.frame = 0;
|
||||
sim->vip.xp.toggle = 0;
|
||||
|
||||
/* Initiate drawing procedure */
|
||||
if (sim->vip.xp.step == 0) {
|
||||
sim->vip.dp.buffer ^= 1;
|
||||
sim->vip.xp.enabled = 1;
|
||||
sim->vip.xp.overtime = 0;
|
||||
sim->vip.xp.step = 1;
|
||||
@@ -767,6 +768,7 @@ static int vipEmulateDisplay(VB *sim, uint32_t clocks) {
|
||||
/* 18ms-20ms - Idle */
|
||||
|
||||
case 8: /* 20ms - Display interval complete */
|
||||
sim->vip.buffer ^= 1;
|
||||
sim->vip.dp.step = 0;
|
||||
if (vipOnFrame(sim))
|
||||
return 1;
|
||||
@@ -1264,6 +1266,7 @@ static void vipEmulateDrawing(VB *sim, uint32_t clocks) {
|
||||
case 4: /* Drawing complete */
|
||||
sim->vip.xp.enabled = 0;
|
||||
sim->vip.xp.step = 0;
|
||||
sim->vip.xp.toggle = 1;
|
||||
if (sim->vip.dp.buffer == 0)
|
||||
sim->vip.xp.f1bsy = 0;
|
||||
else sim->vip.xp.f0bsy = 0;
|
||||
@@ -1330,11 +1333,11 @@ static void vipRead(VB *sim, uint32_t address, int type, int32_t *value) {
|
||||
|
||||
/* Simulate a hardware reset */
|
||||
static void vipReset(VB *sim) {
|
||||
Cell *cell; /* BG map cell state */
|
||||
Character *chr; /* Character state */
|
||||
Object *obj; /* Object state */
|
||||
World *world; /* World state */
|
||||
int x, y; /* Iterators */
|
||||
Cell *cell; /* BG map cell state */
|
||||
Character *chr; /* Character state */
|
||||
Object *obj; /* Object state */
|
||||
World *world; /* World state */
|
||||
int x, y, z; /* Iterators */
|
||||
|
||||
/* Normal */
|
||||
sim->vip.intenb = 0x0000;
|
||||
@@ -1424,6 +1427,13 @@ static void vipReset(VB *sim) {
|
||||
sim->vip.xp.sbcount = 0;
|
||||
sim->vip.xp.sbout = 0;
|
||||
|
||||
/* Other */
|
||||
sim->vip.buffer = 0;
|
||||
for (x = 0; x < 2; x++)
|
||||
for (y = 0; y < 2; y++)
|
||||
for (z = 0; z < 384*224; z++)
|
||||
sim->vip.output[x][y][z] = 0;
|
||||
|
||||
/* Display processor other */
|
||||
sim->vip.dp.brt[0] = 0;
|
||||
sim->vip.dp.buffer = 0; /* TODO: Hardware might actually do this */
|
||||
@@ -1434,6 +1444,7 @@ static void vipReset(VB *sim) {
|
||||
/* Pixel processor other */
|
||||
sim->vip.xp.clocks = 0;
|
||||
sim->vip.xp.step = 0;
|
||||
sim->vip.xp.toggle = 0;
|
||||
sim->vip.xp.until = 0;
|
||||
}
|
||||
|
||||
|
||||
+14
-7
@@ -87,11 +87,8 @@ new class Core {
|
||||
this.sims.set(sim.pointer, sim);
|
||||
|
||||
// Video
|
||||
sim.pixels = this.#noalloc(
|
||||
this.GetExtPixels(sim.pointer),
|
||||
384*224*4, sim, "pixels", Uint8ClampedArray
|
||||
);
|
||||
sim.image = new ImageData(sim.pixels, 384, 224);
|
||||
sim.pixels = this.#getPixels(sim);
|
||||
sim.image = new ImageData(sim.pixels, 384, 224);
|
||||
|
||||
// Audio
|
||||
sim.samples = this.#noalloc(
|
||||
@@ -364,8 +361,10 @@ new class Core {
|
||||
this.mallocs.set(buffer.pointer, buffer);
|
||||
this.#updateTarget(buffer);
|
||||
}
|
||||
for (let sim of this.sims)
|
||||
sim.image = new ImageData(sim.pixels, 384, 224);
|
||||
for (let sim of this.sims.values()) {
|
||||
sim.pixels = this.#getPixels(sim);
|
||||
sim.image = new ImageData(sim.pixels, 384, 224);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -436,6 +435,14 @@ new class Core {
|
||||
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
|
||||
#malloc(count, target = null, assign = null, type = Uint8ClampedArray) {
|
||||
return this.#noalloc(
|
||||
|
||||
Reference in New Issue
Block a user