Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
155a3aa678 | ||
|
|
04e79c9151 | ||
|
|
57dcd8370a | ||
|
|
06849b54ba | ||
|
|
eef255b507 | ||
|
|
db966c8cb8 | ||
|
|
b4feff41f0 | ||
|
|
4449acada0 | ||
|
|
799ac9f51a | ||
|
|
b83b49221d | ||
|
|
27e926bd58 |
@@ -159,6 +159,8 @@ static void busRead(VB *sim, uint32_t address, int type, int32_t *value) {
|
|||||||
|
|
||||||
case 2: /* Misc. I/O */
|
case 2: /* Misc. I/O */
|
||||||
*value = busReadMisc(sim, address, type);
|
*value = busReadMisc(sim, address, type);
|
||||||
|
if (type == VB_S8)
|
||||||
|
*value = (int8_t) *value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: break; /* Unmapped */
|
case 3: break; /* Unmapped */
|
||||||
|
|||||||
@@ -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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+39
-12
@@ -5,6 +5,15 @@
|
|||||||
|
|
||||||
/***************************** Module Functions ******************************/
|
/***************************** Module Functions ******************************/
|
||||||
|
|
||||||
|
/* Compute clocks until the next decrement to zero */
|
||||||
|
static uint32_t tmrGetUntil(VB *sim) {
|
||||||
|
uint32_t fullTick = sim->tmr.t_clk_sel ? 400 : 2000;
|
||||||
|
uint32_t thisTick = sim->tmr.clocks +
|
||||||
|
(sim->tmr.t_clk_sel ? 0 : 400 * (4 - sim->tmr.tick20));
|
||||||
|
return thisTick + fullTick *
|
||||||
|
(sim->tmr.counter == 0 ? sim->tmr.reload : sim->tmr.counter - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* Update the counter to a new value */
|
/* Update the counter to a new value */
|
||||||
static void tmrUpdate(VB *sim, uint16_t value) {
|
static void tmrUpdate(VB *sim, uint16_t value) {
|
||||||
if (value == 0 && sim->tmr.counter != 0) {
|
if (value == 0 && sim->tmr.counter != 0) {
|
||||||
@@ -23,10 +32,6 @@ static void tmrUpdate(VB *sim, uint16_t value) {
|
|||||||
/* Process component */
|
/* Process component */
|
||||||
static void tmrEmulate(VB *sim, uint32_t clocks) {
|
static void tmrEmulate(VB *sim, uint32_t clocks) {
|
||||||
|
|
||||||
/* Timer is disabled */
|
|
||||||
if (!sim->tmr.t_enb)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Process all clocks */
|
/* Process all clocks */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
@@ -40,13 +45,20 @@ static void tmrEmulate(VB *sim, uint32_t clocks) {
|
|||||||
/* Advance forward the component's number of clocks */
|
/* Advance forward the component's number of clocks */
|
||||||
clocks -= sim->tmr.clocks;
|
clocks -= sim->tmr.clocks;
|
||||||
sim->tmr.until -= sim->tmr.clocks;
|
sim->tmr.until -= sim->tmr.clocks;
|
||||||
sim->tmr.clocks = sim->tmr.t_clk_sel ? 400 : 2000;
|
sim->tmr.clocks = 400;
|
||||||
|
sim->tmr.tick20 += sim->tmr.tick20 == 4 ? -4 : 1;
|
||||||
|
|
||||||
|
/* Do not decrement counter */
|
||||||
|
if (
|
||||||
|
!sim->tmr.t_enb ||
|
||||||
|
(!sim->tmr.t_clk_sel && sim->tmr.tick20 != 0)
|
||||||
|
) continue;
|
||||||
|
|
||||||
/* Advance to the next counter value */
|
/* Advance to the next counter value */
|
||||||
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);
|
||||||
if (sim->tmr.counter == 0)
|
if (sim->tmr.counter == 0)
|
||||||
sim->tmr.until = sim->tmr.clocks * ((uint32_t)sim->tmr.reload + 1);
|
sim->tmr.until = tmrGetUntil(sim);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -71,8 +83,10 @@ static void tmrReset(VB *sim) {
|
|||||||
sim->tmr.z_stat = 0;
|
sim->tmr.z_stat = 0;
|
||||||
|
|
||||||
/* Other */
|
/* Other */
|
||||||
|
sim->tmr.clocks = 400;
|
||||||
sim->tmr.counter = 0xFFFF;
|
sim->tmr.counter = 0xFFFF;
|
||||||
sim->tmr.reload = 0x0000;
|
sim->tmr.reload = 0x0000;
|
||||||
|
sim->tmr.tick20 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Determine how many clocks are guaranteed to process */
|
/* Determine how many clocks are guaranteed to process */
|
||||||
@@ -88,14 +102,27 @@ static void tmrWriteControl(VB *sim, uint8_t value) {
|
|||||||
if (
|
if (
|
||||||
(value & 0x04) && /* Z-Stat-Clr */
|
(value & 0x04) && /* Z-Stat-Clr */
|
||||||
(
|
(
|
||||||
sim->tmr.counter != 0 ||
|
!sim->tmr.t_enb ||
|
||||||
!sim->tmr.t_enb
|
(
|
||||||
|
sim->tmr.counter != 0 &&
|
||||||
|
!(value & 0x01) /* T-Enb */
|
||||||
|
)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
sim->tmr.z_stat = sim->tmr.counter != 0;
|
sim->tmr.z_stat = sim->tmr.counter != 0;
|
||||||
sim->cpu.irq &= ~0x0002;
|
sim->cpu.irq &= ~0x0002;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Hardware bug: decrement on switch to 20us mode */
|
||||||
|
if (
|
||||||
|
!sim->tmr.t_clk_sel &&
|
||||||
|
(value & 0x10) && /* T-Clk-Sel */
|
||||||
|
sim->tmr.tick20 != 0
|
||||||
|
) {
|
||||||
|
tmrUpdate(sim, sim->tmr.counter == 0 ?
|
||||||
|
sim->tmr.reload : sim->tmr.counter - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* Parse fields */
|
/* Parse fields */
|
||||||
sim->tmr.t_clk_sel = value >> 4 & 1;
|
sim->tmr.t_clk_sel = value >> 4 & 1;
|
||||||
sim->tmr.tim_z_int = value >> 3 & 1;
|
sim->tmr.tim_z_int = value >> 3 & 1;
|
||||||
@@ -105,10 +132,8 @@ static void tmrWriteControl(VB *sim, uint8_t value) {
|
|||||||
if (!sim->tmr.tim_z_int)
|
if (!sim->tmr.tim_z_int)
|
||||||
sim->cpu.irq &= ~0x0002;
|
sim->cpu.irq &= ~0x0002;
|
||||||
|
|
||||||
/* Configure countdowns */
|
/* Configure state */
|
||||||
sim->tmr.clocks = sim->tmr.t_clk_sel ? 400 : 2000;
|
sim->tmr.until = tmrGetUntil(sim);
|
||||||
sim->tmr.until = sim->tmr.clocks * (sim->tmr.counter == 0 ?
|
|
||||||
(uint32_t) sim->tmr.reload + 1 : sim->tmr.counter);
|
|
||||||
|
|
||||||
/* TODO: Will Z-Stat raise an interrupt when Tim-Z-Int is set? */
|
/* TODO: Will Z-Stat raise an interrupt when Tim-Z-Int is set? */
|
||||||
}
|
}
|
||||||
@@ -117,12 +142,14 @@ static void tmrWriteControl(VB *sim, uint8_t value) {
|
|||||||
static void tmrWriteHigh(VB *sim, uint8_t value) {
|
static void tmrWriteHigh(VB *sim, uint8_t value) {
|
||||||
sim->tmr.reload = (uint16_t) value << 8 | (sim->tmr.reload & 0x00FF);
|
sim->tmr.reload = (uint16_t) value << 8 | (sim->tmr.reload & 0x00FF);
|
||||||
tmrUpdate(sim, sim->tmr.reload);
|
tmrUpdate(sim, sim->tmr.reload);
|
||||||
|
sim->tmr.until = tmrGetUntil(sim);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write to the low data register */
|
/* Write to the low data register */
|
||||||
static void tmrWriteLow(VB *sim, uint8_t value) {
|
static void tmrWriteLow(VB *sim, uint8_t value) {
|
||||||
sim->tmr.reload = (sim->tmr.reload & 0xFF00) | value;
|
sim->tmr.reload = (sim->tmr.reload & 0xFF00) | value;
|
||||||
tmrUpdate(sim, sim->tmr.reload);
|
tmrUpdate(sim, sim->tmr.reload);
|
||||||
|
sim->tmr.until = tmrGetUntil(sim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -251,6 +251,7 @@ struct VB {
|
|||||||
uint32_t clocks; /* Master clocks to wait */
|
uint32_t clocks; /* Master clocks to wait */
|
||||||
uint16_t counter; /* Current counter value */
|
uint16_t counter; /* Current counter value */
|
||||||
uint16_t reload; /* Reload counter value */
|
uint16_t reload; /* Reload counter value */
|
||||||
|
uint8_t tick20; /* Current 20-microsecond tick */
|
||||||
uint32_t until; /* Clocks until interrupt condition */
|
uint32_t until; /* Clocks until interrupt condition */
|
||||||
} tmr;
|
} tmr;
|
||||||
|
|
||||||
@@ -311,6 +312,7 @@ struct VB {
|
|||||||
int frame; /* FRMCYC counter */
|
int frame; /* FRMCYC counter */
|
||||||
int32_t halfword; /* Current output halfword offset */
|
int32_t halfword; /* Current output halfword offset */
|
||||||
int step; /* Processing phase */
|
int step; /* Processing phase */
|
||||||
|
uint8_t toggle; /* Switch frame buffers next frame */
|
||||||
uint32_t until; /* Clocks until interrupt condition */
|
uint32_t until; /* Clocks until interrupt condition */
|
||||||
} xp;
|
} xp;
|
||||||
|
|
||||||
@@ -325,6 +327,7 @@ struct VB {
|
|||||||
uint16_t spt[4]; /* Object control */
|
uint16_t spt[4]; /* Object control */
|
||||||
|
|
||||||
/* Rendering shadow memory */
|
/* Rendering shadow memory */
|
||||||
|
uint8_t buffer; /* Output buffer */
|
||||||
uint16_t halfwords[384*28]; /* Output timing by 1x8 halfword */
|
uint16_t halfwords[384*28]; /* Output timing by 1x8 halfword */
|
||||||
Pixels output[2]; /* Output images, row-major */
|
Pixels output[2]; /* Output images, row-major */
|
||||||
Pixels shadow; /* Drawing shadow image, column-major */
|
Pixels shadow; /* Drawing shadow image, column-major */
|
||||||
@@ -631,7 +634,7 @@ VBAPI void vbGetPixels(VB *sim, void *left, int leftStrideX, int leftStrideY,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Transfer pixels to the destination */
|
/* 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 (y = 0; y < 224; y++, dest += yStride)
|
||||||
for (x = offset = 0; x < 384; x++, offset += xStride)
|
for (x = offset = 0; x < 384; x++, offset += xStride)
|
||||||
dest[offset] = *src++;
|
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 vbEmulate (VB *sim, uint32_t *clocks);
|
||||||
VBAPI int vbEmulateEx (VB **sims, unsigned count, 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* vbGetCartRAM (VB *sim, uint32_t *size);
|
||||||
VBAPI void* vbGetCartROM (VB *sim, uint32_t *size);
|
VBAPI void* vbGetCartROM (VB *sim, uint32_t *size);
|
||||||
VBAPI vbOnException vbGetExceptionCallback(VB *sim);
|
VBAPI vbOnException vbGetExceptionCallback(VB *sim);
|
||||||
|
|||||||
+34
-18
@@ -234,7 +234,7 @@ static void vipWriteCell(VB *sim, uint32_t offset, int type, int32_t value) {
|
|||||||
case VB_S8:
|
case VB_S8:
|
||||||
case VB_U8:
|
case VB_U8:
|
||||||
value = offset & 1 ?
|
value = offset & 1 ?
|
||||||
value << 8 | sim->vip.ram[0x20000 | offset] :
|
value << 8 | sim->vip.ram[0x20001 ^ offset] :
|
||||||
value | (int32_t) sim->vip.ram[0x20001 | offset] << 8
|
value | (int32_t) sim->vip.ram[0x20001 | offset] << 8
|
||||||
;
|
;
|
||||||
break;
|
break;
|
||||||
@@ -284,7 +284,7 @@ static void vipWriteObject(VB *sim, uint32_t offset, int type, int32_t value) {
|
|||||||
case VB_S8:
|
case VB_S8:
|
||||||
case VB_U8:
|
case VB_U8:
|
||||||
value = offset & 1 ?
|
value = offset & 1 ?
|
||||||
value << 8 | sim->vip.ram[0x3E000 | offset] :
|
value << 8 | sim->vip.ram[0x3E001 ^ offset] :
|
||||||
value | (int32_t) sim->vip.ram[0x3E001 | offset] << 8
|
value | (int32_t) sim->vip.ram[0x3E001 | offset] << 8
|
||||||
;
|
;
|
||||||
break;
|
break;
|
||||||
@@ -326,7 +326,7 @@ static void vipWriteWorld(VB *sim, uint32_t offset, int type, int32_t value) {
|
|||||||
case VB_S8:
|
case VB_S8:
|
||||||
case VB_U8:
|
case VB_U8:
|
||||||
value = offset & 1 ?
|
value = offset & 1 ?
|
||||||
value << 8 | sim->vip.ram[0x3D800 | offset] :
|
value << 8 | sim->vip.ram[0x3D801 ^ offset] :
|
||||||
value | (int32_t) sim->vip.ram[0x3D801 | offset] << 8
|
value | (int32_t) sim->vip.ram[0x3D801 | offset] << 8
|
||||||
;
|
;
|
||||||
break;
|
break;
|
||||||
@@ -598,7 +598,7 @@ static void vipTransferColumn(VB *sim, int32_t eye) {
|
|||||||
|
|
||||||
/* Select destination address in host memory */
|
/* Select destination address in host memory */
|
||||||
dest = &sim->vip.output
|
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 */
|
/* Output is disabled */
|
||||||
if (!sim->vip.dp.enabled) {
|
if (!sim->vip.dp.enabled) {
|
||||||
@@ -654,28 +654,29 @@ static int vipEmulateDisplay(VB *sim, uint32_t clocks) {
|
|||||||
vipThrow(sim, 0x0010); /* FRAMESTART */
|
vipThrow(sim, 0x0010); /* FRAMESTART */
|
||||||
|
|
||||||
/* Game frame */
|
/* Game frame */
|
||||||
if (sim->vip.xp.xpen) {
|
|
||||||
if (sim->vip.xp.frame >= sim->vip.frmcyc) {
|
if (sim->vip.xp.frame >= sim->vip.frmcyc) {
|
||||||
sim->vip.xp.frame = 0;
|
sim->vip.xp.frame = 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;
|
|
||||||
vipThrow(sim, 0x0008); /* GAMESTART */
|
vipThrow(sim, 0x0008); /* GAMESTART */
|
||||||
}
|
if (sim->vip.xp.step != 0) {
|
||||||
|
|
||||||
/* Drawing procedure has run into overtime */
|
|
||||||
else {
|
|
||||||
sim->vip.xp.overtime = 1;
|
sim->vip.xp.overtime = 1;
|
||||||
vipThrow(sim, 0x8000); /* TIMEERR */
|
vipThrow(sim, 0x8000); /* TIMEERR */
|
||||||
}
|
}
|
||||||
|
|
||||||
} else sim->vip.xp.frame++;
|
/* Initiate drawing procedure */
|
||||||
|
else if (sim->vip.xp.xpen) {
|
||||||
|
sim->vip.dp.buffer ^= sim->vip.xp.toggle;
|
||||||
|
sim->vip.xp.enabled = 1;
|
||||||
|
sim->vip.xp.overtime = 0;
|
||||||
|
sim->vip.xp.step = 1;
|
||||||
|
sim->vip.xp.toggle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Not a game frame */
|
||||||
|
else sim->vip.xp.frame++;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* 0ms-3ms - Idle */
|
/* 0ms-3ms - Idle */
|
||||||
@@ -767,6 +768,7 @@ static int vipEmulateDisplay(VB *sim, uint32_t clocks) {
|
|||||||
/* 18ms-20ms - Idle */
|
/* 18ms-20ms - Idle */
|
||||||
|
|
||||||
case 8: /* 20ms - Display interval complete */
|
case 8: /* 20ms - Display interval complete */
|
||||||
|
sim->vip.buffer ^= 1;
|
||||||
sim->vip.dp.step = 0;
|
sim->vip.dp.step = 0;
|
||||||
if (vipOnFrame(sim))
|
if (vipOnFrame(sim))
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1264,6 +1266,7 @@ static void vipEmulateDrawing(VB *sim, uint32_t clocks) {
|
|||||||
case 4: /* Drawing complete */
|
case 4: /* Drawing complete */
|
||||||
sim->vip.xp.enabled = 0;
|
sim->vip.xp.enabled = 0;
|
||||||
sim->vip.xp.step = 0;
|
sim->vip.xp.step = 0;
|
||||||
|
sim->vip.xp.toggle = 1;
|
||||||
if (sim->vip.dp.buffer == 0)
|
if (sim->vip.dp.buffer == 0)
|
||||||
sim->vip.xp.f1bsy = 0;
|
sim->vip.xp.f1bsy = 0;
|
||||||
else sim->vip.xp.f0bsy = 0;
|
else sim->vip.xp.f0bsy = 0;
|
||||||
@@ -1313,8 +1316,13 @@ static void vipRead(VB *sim, uint32_t address, int type, int32_t *value) {
|
|||||||
*value = 0;
|
*value = 0;
|
||||||
|
|
||||||
/* I/O register */
|
/* I/O register */
|
||||||
else if (address < 0x60000)
|
else if (address < 0x60000) {
|
||||||
*value = vipReadIO(sim, address, type);
|
*value = vipReadIO(sim, address, type);
|
||||||
|
switch (type) {
|
||||||
|
case VB_S8 : *value = (int8_t ) *value; break;
|
||||||
|
case VB_S16: *value = (int16_t) *value; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Unmapped */
|
/* Unmapped */
|
||||||
else if (address < 0x78000)
|
else if (address < 0x78000)
|
||||||
@@ -1334,7 +1342,7 @@ static void vipReset(VB *sim) {
|
|||||||
Character *chr; /* Character state */
|
Character *chr; /* Character state */
|
||||||
Object *obj; /* Object state */
|
Object *obj; /* Object state */
|
||||||
World *world; /* World state */
|
World *world; /* World state */
|
||||||
int x, y; /* Iterators */
|
int x, y, z; /* Iterators */
|
||||||
|
|
||||||
/* Normal */
|
/* Normal */
|
||||||
sim->vip.intenb = 0x0000;
|
sim->vip.intenb = 0x0000;
|
||||||
@@ -1424,6 +1432,13 @@ static void vipReset(VB *sim) {
|
|||||||
sim->vip.xp.sbcount = 0;
|
sim->vip.xp.sbcount = 0;
|
||||||
sim->vip.xp.sbout = 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 */
|
/* Display processor other */
|
||||||
sim->vip.dp.brt[0] = 0;
|
sim->vip.dp.brt[0] = 0;
|
||||||
sim->vip.dp.buffer = 0; /* TODO: Hardware might actually do this */
|
sim->vip.dp.buffer = 0; /* TODO: Hardware might actually do this */
|
||||||
@@ -1434,6 +1449,7 @@ static void vipReset(VB *sim) {
|
|||||||
/* Pixel processor other */
|
/* Pixel processor other */
|
||||||
sim->vip.xp.clocks = 0;
|
sim->vip.xp.clocks = 0;
|
||||||
sim->vip.xp.step = 0;
|
sim->vip.xp.step = 0;
|
||||||
|
sim->vip.xp.toggle = 0;
|
||||||
sim->vip.xp.until = 0;
|
sim->vip.xp.until = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-5
@@ -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(
|
||||||
|
|||||||
Reference in New Issue
Block a user