c64, zx: added probe buffer support, need to log scanlines
This commit is contained in:
parent
95e1ef8a0d
commit
93aff314c8
BIN
res/c64.wasm
BIN
res/c64.wasm
Binary file not shown.
BIN
res/zx.wasm
BIN
res/zx.wasm
Binary file not shown.
|
@ -965,7 +965,7 @@ export function lookupSymbol(platform:Platform, addr:number, extra:boolean) {
|
|||
/// new Machine platform adapters
|
||||
|
||||
import { Bus, Resettable, FrameBased, VideoSource, SampledAudioSource, AcceptsROM, AcceptsKeyInput, SavesState, SavesInputState, HasCPU, TrapCondition, CPU } from "./devices";
|
||||
import { Probeable, RasterFrameBased, AcceptsPaddleInput, SampledAudioSink } from "./devices";
|
||||
import { Probeable, RasterFrameBased, AcceptsPaddleInput, SampledAudioSink, ProbeAll, NullProbe } from "./devices";
|
||||
import { SampledAudio } from "./audio";
|
||||
import { ProbeRecorder } from "./recorder";
|
||||
|
||||
|
@ -1205,6 +1205,7 @@ export abstract class BaseWASMMachine {
|
|||
romarr : Uint8Array;
|
||||
audio : SampledAudioSink;
|
||||
audioarr : Float32Array;
|
||||
probe : ProbeAll;
|
||||
|
||||
abstract getCPUState() : CpuState;
|
||||
|
||||
|
@ -1235,7 +1236,7 @@ export abstract class BaseWASMMachine {
|
|||
var wasmResult = await WebAssembly.instantiate(wasmCompiled);
|
||||
this.instance = wasmResult;
|
||||
this.exports = wasmResult.exports;
|
||||
this.exports.memory.grow(32);
|
||||
this.exports.memory.grow(64); // TODO: need more when probing?
|
||||
// fetch BIOS
|
||||
var biosResponse = await fetch('res/'+this.prefix+'.bios');
|
||||
var biosBinary = await biosResponse.arrayBuffer();
|
||||
|
@ -1347,5 +1348,19 @@ export abstract class BaseWASMMachine {
|
|||
this.syncAudio();
|
||||
return i;
|
||||
}
|
||||
copyProbeData() {
|
||||
if (this.probe && !(this.probe instanceof NullProbe)) {
|
||||
var datalen = this.exports.machine_get_probe_buffer_size();
|
||||
var dataaddr = this.exports.machine_get_probe_buffer_address();
|
||||
// TODO: more efficient way to put into probe
|
||||
var databuf = new Uint32Array(this.exports.memory.buffer, dataaddr, datalen);
|
||||
this.probe.logNewFrame(); // TODO: machine should do this
|
||||
for (var i=0; i<datalen; i++)
|
||||
this.probe.logData(databuf[i]);
|
||||
}
|
||||
}
|
||||
connectProbe(probe: ProbeAll): void {
|
||||
this.probe = probe;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -144,6 +144,7 @@ export interface ProbeVRAM {
|
|||
}
|
||||
|
||||
export interface ProbeAll extends ProbeTime, ProbeCPU, ProbeBus, ProbeIO, ProbeVRAM {
|
||||
logData(data:number); // entire 32 bits
|
||||
}
|
||||
|
||||
export class NullProbe implements ProbeAll {
|
||||
|
@ -159,6 +160,7 @@ export class NullProbe implements ProbeAll {
|
|||
logVRAMRead() {}
|
||||
logVRAMWrite() {}
|
||||
logIllegal() {}
|
||||
logData() {}
|
||||
}
|
||||
|
||||
/// CONVENIENCE
|
||||
|
|
|
@ -203,6 +203,9 @@ export class ProbeRecorder implements ProbeAll {
|
|||
clear() {
|
||||
this.idx = 0;
|
||||
}
|
||||
logData(a:number) {
|
||||
this.log(a);
|
||||
}
|
||||
log(a:number) {
|
||||
// TODO: coalesce READ and EXECUTE and PUSH/POP
|
||||
if (this.idx >= this.buf.length) return;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -11,6 +11,9 @@ import { TrapCondition } from "../common/devices";
|
|||
|
||||
export class ZX_WASMMachine extends BaseWASMMachine implements Machine {
|
||||
|
||||
numTotalScanlines = 312;
|
||||
cpuCyclesPerLine = 224;
|
||||
|
||||
joymask0 = 0;
|
||||
|
||||
reset() {
|
||||
|
@ -34,7 +37,12 @@ export class ZX_WASMMachine extends BaseWASMMachine implements Machine {
|
|||
}
|
||||
}
|
||||
advanceFrame(trap: TrapCondition) : number {
|
||||
return super.advanceFrameClock(trap, Math.floor(1000000 / 50)); // TODO: use ticks, not msec
|
||||
//var scanline = this.exports.machine_get_raster_line(this.sys);
|
||||
var probing = this.probe != null;
|
||||
if (probing) this.exports.machine_reset_probe_buffer();
|
||||
var clocks = super.advanceFrameClock(trap, Math.floor(1000000 / 50)); // TODO: use ticks, not msec
|
||||
if (probing) this.copyProbeData();
|
||||
return clocks;
|
||||
}
|
||||
/*
|
||||
z80_tick_t tick_cb; // 0
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
import { C64, C64_WASMMachine } from "../machine/c64";
|
||||
import { C64_WASMMachine } from "../machine/c64";
|
||||
import { Platform, Base6502MachinePlatform, getToolForFilename_6502, getOpcodeMetadata_6502 } from "../common/baseplatform";
|
||||
import { PLATFORMS } from "../common/emu";
|
||||
|
||||
|
@ -37,17 +37,6 @@ const C64_MEMORY_MAP = { main:[
|
|||
{name:'KERNAL ROM', start:0xe000,size:0x2000,type:'rom'},
|
||||
] }
|
||||
|
||||
// native C64 platform (NOT USED)
|
||||
class C64Platform extends Base6502MachinePlatform<C64> implements Platform {
|
||||
|
||||
newMachine() { return new C64(); }
|
||||
getPresets() { return C64_PRESETS; }
|
||||
getDefaultExtension() { return ".c"; };
|
||||
readAddress(a) { return this.machine.readConst(a); }
|
||||
loadBIOS(bios) { this.machine.loadBIOS(bios); }
|
||||
getMemoryMap() { return C64_MEMORY_MAP; }
|
||||
}
|
||||
|
||||
// WASM C64 platform
|
||||
class C64WASMPlatform extends Base6502MachinePlatform<C64_WASMMachine> implements Platform {
|
||||
|
||||
|
@ -76,4 +65,3 @@ class C64WASMPlatform extends Base6502MachinePlatform<C64_WASMMachine> implement
|
|||
|
||||
PLATFORMS['c64'] = C64WASMPlatform;
|
||||
PLATFORMS['c64.wasm'] = C64WASMPlatform;
|
||||
PLATFORMS['c64.js'] = C64Platform;
|
||||
|
|
Loading…
Reference in New Issue