mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-02-05 20:33:14 +00:00
c64: removed wait_vblank macro
This commit is contained in:
parent
bd63ef1268
commit
312cb3d025
@ -61,8 +61,6 @@ typedef enum { false, true } bool; // boolean
|
||||
// default screen base address on startup
|
||||
#define DEFAULT_SCREEN ((void*)0x400)
|
||||
|
||||
// wait until next frame, same as waitvsync()
|
||||
#define wait_vblank waitvsync
|
||||
// is raster line > 255?
|
||||
#define RASTER_HIBIT (VIC.ctrl1 & 0x80)
|
||||
|
||||
|
54
src/common/wasi/libretro.ts
Normal file
54
src/common/wasi/libretro.ts
Normal file
@ -0,0 +1,54 @@
|
||||
import { WASIRunner } from "./wasishim";
|
||||
|
||||
export class LibRetroRunner extends WASIRunner {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
getEnv() {
|
||||
return {
|
||||
...super.getEnv(),
|
||||
retro_environment_callback: (cmd: number, data: number) => {
|
||||
console.log(`retro_environment_callback: ${cmd}, ${data}`);
|
||||
return 0;
|
||||
},
|
||||
retro_video_refresh_callback: (data: number, width: number, height: number, pitch: number) => {
|
||||
console.log(`retro_video_refresh_callback: ${data}, ${width}, ${height}, ${pitch}`);
|
||||
},
|
||||
retro_audio_sample_batch_callback: (data: number, frames: number) => {
|
||||
console.log(`retro_audio_sample_batch_callback: ${data}, ${frames}`);
|
||||
},
|
||||
retro_audio_sample_callback: (left: number, right: number) => {
|
||||
console.log(`retro_audio_sample_callback: ${left}, ${right}`);
|
||||
return 0;
|
||||
},
|
||||
retro_input_poll_callback: () => {
|
||||
console.log(`retro_input_poll_callback`);
|
||||
},
|
||||
retro_input_state_callback: (port: number, device: number, index: number, id: number) => {
|
||||
console.log(`retro_input_state_callback: ${port}, ${device}, ${index}, ${id}`);
|
||||
return 0;
|
||||
},
|
||||
}
|
||||
}
|
||||
retro_init() {
|
||||
let errno = this.initialize();
|
||||
// TODO: if (errno) throw new Error(`retro_init failed: ${errno}`);
|
||||
this.exports().retro_init_callbacks();
|
||||
this.exports().retro_init();
|
||||
this.exports().retro_set_controller_port_device(0,1);
|
||||
this.exports().retro_set_controller_port_device(1,1);
|
||||
}
|
||||
retro_api_version() {
|
||||
return this.exports().retro_api_version();
|
||||
}
|
||||
load_rom(path: string, data: Uint8Array) {
|
||||
const meta = '';
|
||||
this.exports().retro_load_rom(path, data, data.length, meta);
|
||||
}
|
||||
reset() {
|
||||
this.exports().retro_reset();
|
||||
}
|
||||
advance() {
|
||||
this.exports().retro_run();
|
||||
}
|
||||
}
|
@ -264,7 +264,7 @@ export class WASIMemoryFilesystem implements WASIFilesystem {
|
||||
}
|
||||
|
||||
export class WASIRunner {
|
||||
#instance; // TODO
|
||||
#instance : any; // TODO
|
||||
#memarr8: Uint8Array;
|
||||
#memarr32: Int32Array;
|
||||
#args: Uint8Array[] = [];
|
||||
@ -282,6 +282,9 @@ export class WASIRunner {
|
||||
constructor() {
|
||||
this.createStdioBrowser();
|
||||
}
|
||||
exports() {
|
||||
return this.#instance.exports;
|
||||
}
|
||||
createStdioNode() {
|
||||
this.stdin = new WASIStreamingFileDescriptor(0, '<stdin>', FDType.CHARACTER_DEVICE, FDRights.FD_READ, process.stdin);
|
||||
this.stdout = new WASIStreamingFileDescriptor(1, '<stdout>', FDType.CHARACTER_DEVICE, FDRights.FD_WRITE, process.stdout);
|
||||
@ -373,6 +376,10 @@ export class WASIRunner {
|
||||
}
|
||||
return this.getErrno();
|
||||
}
|
||||
initialize() {
|
||||
this.#instance.exports._initialize();
|
||||
return this.getErrno();
|
||||
}
|
||||
getImportObject() {
|
||||
return {
|
||||
"wasi_snapshot_preview1": this.getWASISnapshotPreview1(),
|
||||
@ -604,11 +611,12 @@ export class WASIRunner {
|
||||
fd_readdir() { warning("TODO: fd_readdir"); return WASIErrors.NOTSUP; },
|
||||
path_unlink_file() { warning("TODO: path_unlink_file"); return WASIErrors.NOTSUP; },
|
||||
clock_time_get() { warning("TODO: clock_time_get"); return WASIErrors.NOTSUP; },
|
||||
fd_tell() { warning("TODO: fd_tell"); return WASIErrors.NOTSUP; },
|
||||
}
|
||||
}
|
||||
getEnv() {
|
||||
return {
|
||||
__syscall_unlinkat() { warning('TODO: unlink'); return 0; },
|
||||
__syscall_unlinkat() { warning('TODO: unlink'); return WASIErrors.NOTSUP; },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
24
src/test/testlibretro.ts
Normal file
24
src/test/testlibretro.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import assert from "assert";
|
||||
import * as fs from "fs";
|
||||
import { LibRetroRunner } from "../common/wasi/libretro";
|
||||
|
||||
async function loadLibretro() {
|
||||
const wasmdata = fs.readFileSync(`./wasi/stella2014_libretro_2.wasm`);
|
||||
let shim = new LibRetroRunner();
|
||||
await shim.loadAsync(wasmdata);
|
||||
return shim;
|
||||
}
|
||||
|
||||
/*
|
||||
describe('test WASI libretro', function () {
|
||||
it('libretro init', async function () {
|
||||
let shim = await loadLibretro();
|
||||
assert.strictEqual(1, shim.retro_api_version());
|
||||
shim.retro_init();
|
||||
let romdata = fs.readFileSync(`./test/roms/vcs/brickgame.rom`);
|
||||
shim.load_rom('brickgame.rom', romdata);
|
||||
shim.reset();
|
||||
shim.advance();
|
||||
});
|
||||
});
|
||||
*/
|
@ -77,3 +77,4 @@ describe('test WASI cc7800', function () {
|
||||
assert.ok(stdout.indexOf('Usage: cc7800') >= 0);
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user