Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d4a422e61 | ||
|
|
483714c0d6 | ||
|
|
ecbd103917 | ||
|
|
b2412d9487 | ||
|
|
dd1045553b |
+1
-1
@@ -495,7 +495,7 @@ static int cpuException(VB *sim) {
|
||||
sim->cpu.eipc = sim->cpu.pc;
|
||||
sim->cpu.psw.ep = 1;
|
||||
sim->cpu.nextPC = 0xFFFF0000 |
|
||||
((cause & 0xFFF0) == 0xFF60 ? 0xFF60 : cause & 0xFFF0);
|
||||
((cause & 0xFFF0) == 0xFF70 ? 0xFF60 : cause & 0xFFF0);
|
||||
}
|
||||
|
||||
/* All exceptions */
|
||||
|
||||
@@ -361,6 +361,7 @@ struct VB {
|
||||
|
||||
/* Other state */
|
||||
uint32_t clocks; /* Clocks until modification */
|
||||
uint8_t freqmask; /* Frequency mask */
|
||||
uint8_t modmask; /* Modifications masked */
|
||||
uint16_t next; /* Next frequency value */
|
||||
int sample; /* Current sample index */
|
||||
|
||||
@@ -436,6 +436,9 @@ static void vipWriteIO(
|
||||
|
||||
case 0x5F802>>1: /* INTENB */
|
||||
sim->vip.intenb = (sim->vip.intenb & mask) | (value & 0xE01F);
|
||||
if (sim->vip.intenb & sim->vip.intpnd)
|
||||
sim->cpu.irq |= 0x0010;
|
||||
else sim->cpu.irq &= ~0x0010;
|
||||
break;
|
||||
case 0x5F804>>1: /* INTCLR */
|
||||
sim->vip.intpnd &= ~value;
|
||||
|
||||
+18
-10
@@ -82,12 +82,12 @@ static void vsuNextFreqMod(VB *sim, Channel *chan) {
|
||||
|
||||
/* Modulation */
|
||||
else {
|
||||
next = (int32_t) chan->freq.written +
|
||||
sim->vsu.modulation[sim->vsu.freqmod.sample];
|
||||
if (next < 0)
|
||||
next = 0;
|
||||
if (next > 2047)
|
||||
next = 2047;
|
||||
next = ((int32_t) chan->freq.written +
|
||||
sim->vsu.modulation[sim->vsu.freqmod.sample]) & 0x7FF;
|
||||
if (sim->vsu.freqmod.freqmask == 1)
|
||||
next = (next & 0x700) | (chan->freq.written & 0x0FF);
|
||||
else if (sim->vsu.freqmod.freqmask == 2)
|
||||
next = (next & 0x0FF) | (chan->freq.written & 0x700);
|
||||
}
|
||||
|
||||
/* Configure state */
|
||||
@@ -257,7 +257,9 @@ static void vsuWriteFQH(VB *sim, int index, uint16_t value) {
|
||||
value = value << 8 & 0x0700;
|
||||
chan->freq.current = (chan->freq.current & 0x00FF) | value;
|
||||
chan->freq.written = (chan->freq.written & 0x00FF) | value;
|
||||
if (index == 4)
|
||||
if (index != 4)
|
||||
return;
|
||||
sim->vsu.freqmod.freqmask = 2;
|
||||
vsuNextFreqMod(sim, chan);
|
||||
}
|
||||
|
||||
@@ -266,7 +268,9 @@ static void vsuWriteFQL(VB *sim, int index, uint8_t value) {
|
||||
Channel *chan = &sim->vsu.channels[index];
|
||||
chan->freq.current = (chan->freq.current & 0x0700) | value;
|
||||
chan->freq.written = (chan->freq.written & 0x0700) | value;
|
||||
if (index == 4)
|
||||
if (index != 4)
|
||||
return;
|
||||
sim->vsu.freqmod.freqmask = 1;
|
||||
vsuNextFreqMod(sim, chan);
|
||||
}
|
||||
|
||||
@@ -507,6 +511,7 @@ static void vsuReset(VB *sim) {
|
||||
sim->vsu.freqmod.clocks = 0;
|
||||
sim->vsu.freqmod.dir = 0;
|
||||
sim->vsu.freqmod.enb = 0;
|
||||
sim->vsu.freqmod.freqmask = 0;
|
||||
sim->vsu.freqmod.func = 0;
|
||||
sim->vsu.freqmod.interval = 0;
|
||||
sim->vsu.freqmod.modmask = 0;
|
||||
@@ -536,11 +541,14 @@ static void vsuWrite(VB*sim,uint32_t address,int type,int32_t value,int debug){
|
||||
}
|
||||
|
||||
/* Unmapped */
|
||||
if (address & 3)
|
||||
if (address & 1)
|
||||
return;
|
||||
|
||||
/* Working variables */
|
||||
address &= 0x7FF;
|
||||
address &= 0x7FC;
|
||||
|
||||
/* Clear frequency mask */
|
||||
sim->vsu.freqmod.freqmask = 0;
|
||||
|
||||
/* Wave memory */
|
||||
if (address < 0x280) {
|
||||
|
||||
@@ -293,6 +293,12 @@ new class Core {
|
||||
}, [ output.buffer ]);
|
||||
}
|
||||
|
||||
// Reset simulation state
|
||||
reset(message) {
|
||||
this.vbReset(message.sim);
|
||||
this.dom.postMessage({ promised: true });
|
||||
}
|
||||
|
||||
// Specify anaglyph colors
|
||||
setAnaglyph(message) {
|
||||
this.SetAnaglyph(message.sim, message.left, message.right);
|
||||
|
||||
@@ -436,8 +436,17 @@ class Sim extends HTMLElement {
|
||||
response.lines.map(l=>new DasmLine(GUARD, l));
|
||||
}
|
||||
|
||||
// Reset simulation state
|
||||
reset() {
|
||||
return this.#core.toCore({
|
||||
command : "reset",
|
||||
promised: true,
|
||||
sim : this.#pointer
|
||||
});
|
||||
}
|
||||
|
||||
// Specify anaglyph colors
|
||||
async setAnaglyph(left, right) {
|
||||
setAnaglyph(left, right) {
|
||||
|
||||
// Error checking
|
||||
if (!Number.isSafeInteger(left ) || left < 0 || left > 0xFFFFFF)
|
||||
@@ -455,7 +464,7 @@ class Sim extends HTMLElement {
|
||||
this.#anaglyph[1] = right;
|
||||
|
||||
// Send the colors to the core
|
||||
await this.#core.toCore({
|
||||
return this.#core.toCore({
|
||||
command : "setAnaglyph",
|
||||
promised: true,
|
||||
sim : this.#pointer,
|
||||
@@ -475,7 +484,7 @@ class Sim extends HTMLElement {
|
||||
}
|
||||
|
||||
// Specify new game pad keys
|
||||
async setKeys(keys) {
|
||||
setKeys(keys) {
|
||||
|
||||
// Error checking
|
||||
if (!Number.isSafeInteger(keys) || keys < 0 || keys > 0xFFFF)
|
||||
@@ -487,7 +496,7 @@ class Sim extends HTMLElement {
|
||||
this.#keys = keys;
|
||||
|
||||
// Send the keys to the core
|
||||
await this.#core.toCore({
|
||||
return this.#core.toCore({
|
||||
command : "setKeys",
|
||||
promised: true,
|
||||
sim : this.#pointer,
|
||||
@@ -496,7 +505,7 @@ class Sim extends HTMLElement {
|
||||
}
|
||||
|
||||
// Specify audio panning
|
||||
async setPanning(panning) {
|
||||
setPanning(panning) {
|
||||
|
||||
// Error checking
|
||||
if (!Number.isFinite(panning) ||panning < -1 || panning > +1) {
|
||||
@@ -508,7 +517,7 @@ class Sim extends HTMLElement {
|
||||
this.#panning = panning;
|
||||
|
||||
// Send the panning to the core
|
||||
await this.#core.toCore({
|
||||
return this.#core.toCore({
|
||||
command : "setPanning",
|
||||
promised: true,
|
||||
sim : this.#pointer,
|
||||
@@ -529,7 +538,7 @@ class Sim extends HTMLElement {
|
||||
}
|
||||
|
||||
// Specify audio volume
|
||||
async setVolume(volume) {
|
||||
setVolume(volume) {
|
||||
|
||||
// Error checking
|
||||
if (!Number.isFinite(volume) ||volume < 0 || volume > 10) {
|
||||
@@ -541,7 +550,7 @@ class Sim extends HTMLElement {
|
||||
this.#volume = volume;
|
||||
|
||||
// Send the volume to the core
|
||||
await this.#core.toCore({
|
||||
return this.#core.toCore({
|
||||
command : "setVolume",
|
||||
promised: true,
|
||||
sim : this.#pointer,
|
||||
@@ -596,7 +605,7 @@ class VB {
|
||||
#commands; // Computed method table
|
||||
#core; // Core worker
|
||||
#proxy; // Self proxy for sim access
|
||||
#sims; // All sims
|
||||
#sims; // Mapping of Sim|pointer -> proxy
|
||||
#state; // Operations state
|
||||
|
||||
|
||||
@@ -683,8 +692,8 @@ class VB {
|
||||
///////////////////////////// Static Methods //////////////////////////////
|
||||
|
||||
// Create a core instance
|
||||
static async create(options) {
|
||||
return await new VB(GUARD).#construct(options);
|
||||
static create(options) {
|
||||
return new VB(GUARD).#construct(options);
|
||||
}
|
||||
|
||||
|
||||
@@ -769,6 +778,16 @@ class VB {
|
||||
|
||||
|
||||
|
||||
/////////////////////////////// Properties ////////////////////////////////
|
||||
|
||||
// Number of managed simulations
|
||||
get size() { return this.#sims.size / 2; }
|
||||
|
||||
// Managed simulations
|
||||
get sims() { return [... this.#sims.keys()].filter(s=>s instanceof Sim); }
|
||||
|
||||
|
||||
|
||||
///////////////////////////// Public Methods //////////////////////////////
|
||||
|
||||
// Create one or more sims
|
||||
@@ -809,7 +828,7 @@ class VB {
|
||||
if (
|
||||
!Array.isArray(sims) ||
|
||||
sims.length == 0 ||
|
||||
sims.find(s=>!this.#sims.has(s))
|
||||
sims.some(s=>!this.#sims.has(s))
|
||||
) {
|
||||
throw new TypeError("Must specify a Sim or array of Sims " +
|
||||
"that belong to this core.");
|
||||
|
||||
Reference in New Issue
Block a user