Skip to content

Commit a252ea6

Browse files
committed
vic20: default tiny bios
1 parent 1c0b3e2 commit a252ea6

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

presets/vic20/cartheader.dasm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
org $a000-2 ; so we can write the ...
2+
.word $a000 ; cartridge 2-byte header
3+
.word Start ; start vector
4+
.word Start ; RESTORE vector
5+
.byte $41, $30, $c3, $c2, $cd ; "A0CBM"

src/common/wasmplatform.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,16 @@ export abstract class BaseWASMMachine {
6666
this.exports = wasmResult.exports;
6767
} else throw new Error('could not load WASM file');
6868
}
69+
allocateBIOS(biosBinary: Uint8Array) {
70+
this.biosptr = this.exports.malloc(biosBinary.byteLength);
71+
this.biosarr = new Uint8Array(this.exports.memory.buffer, this.biosptr, biosBinary.byteLength);
72+
}
6973
async fetchBIOS() {
7074
var biosResponse = await fetch('res/'+this.prefix+'.bios');
7175
if (biosResponse.status == 200 || (biosResponse as any as Blob).size) {
72-
var biosBinary = await biosResponse.arrayBuffer();
73-
this.biosptr = this.exports.malloc(biosBinary.byteLength);
74-
this.biosarr = new Uint8Array(this.exports.memory.buffer, this.biosptr, biosBinary.byteLength);
75-
this.loadBIOS(new Uint8Array(biosBinary));
76+
var biosBinary = new Uint8Array(await biosResponse.arrayBuffer());
77+
this.allocateBIOS(biosBinary);
78+
this.loadBIOS(biosBinary);
7679
} else throw new Error('could not load BIOS file');
7780
}
7881
async initWASM() {

src/machine/vic20.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ export class VIC20_WASMMachine extends BaseWASMMachine implements Machine, Probe
2626
loadBIOS(srcArray: Uint8Array) {
2727
super.loadBIOS(srcArray);
2828
}
29+
async fetchBIOS() {
30+
let bios = new Uint8Array(20480);
31+
bios.set(DEFAULT_BIOS, bios.length - DEFAULT_BIOS.length);
32+
this.allocateBIOS(bios);
33+
this.loadBIOS(new Uint8Array(bios));
34+
}
2935
reset() {
3036
super.reset();
3137
// clear keyboard
@@ -170,3 +176,19 @@ export class VIC20_WASMMachine extends BaseWASMMachine implements Machine, Probe
170176
}
171177

172178
}
179+
180+
// pretty much just runs autostart ROM and not much else...
181+
const DEFAULT_BIOS = [
182+
0xA2, 0x10, 0xA0, 0x91, 0x60, 0x71, 0xFF, 0x71, 0xFF, 0x5C, 0xFF, 0xA2, 0xFF, 0x78, 0x9A, 0xD8,
183+
0x6C, 0x00, 0xA0, 0xA2, 0x45, 0xA0, 0xFF, 0x18, 0x78, 0x6C, 0x18, 0x03, 0x48, 0x8A, 0x48, 0x98,
184+
0x48, 0xAD, 0x1D, 0x91, 0x10, 0x03, 0x6C, 0x02, 0xA0, 0x4C, 0x6C, 0xFF, 0x68, 0xA8, 0x68, 0xAA,
185+
0x68, 0x40, 0x48, 0x8A, 0x48, 0x98, 0x48, 0xBA, 0xBD, 0x04, 0x01, 0x29, 0x10, 0xF0, 0x03, 0x6C,
186+
0x16, 0x03, 0x6C, 0x14, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x4C, 0x53, 0xFF, 0x4C, 0x44, 0xFF,
187+
0x4C, 0x44, 0xFF, 0x4C, 0x44, 0xFF, 0x4C, 0x44, 0xFF, 0x4C, 0x44, 0xFF, 0x4C, 0x44, 0xFF, 0x4C,
188+
0x44, 0xFF, 0x4C, 0x44, 0xFF, 0x4C, 0x44, 0xFF, 0x4C, 0x44, 0xFF, 0x4C, 0x44, 0xFF, 0x4C, 0x44,
189+
0xFF, 0x4C, 0x44, 0xFF, 0x4C, 0x44, 0xFF, 0x4C, 0x44, 0xFF, 0x4C, 0x44, 0xFF, 0x4C, 0x44, 0xFF,
190+
0x6C, 0x1A, 0x03, 0x6C, 0x1C, 0x03, 0x6C, 0x1E, 0x03, 0x6C, 0x20, 0x03, 0x6C, 0x22, 0x03, 0x6C,
191+
0x24, 0x03, 0x6C, 0x26, 0x03, 0x4C, 0x44, 0xFF, 0x4C, 0x44, 0xFF, 0x4C, 0x44, 0xFF, 0x4C, 0x44,
192+
0xFF, 0x6C, 0x28, 0x03, 0x6C, 0x2A, 0x03, 0x6C, 0x2C, 0x03, 0x4C, 0x44, 0xFF, 0x4C, 0x44, 0xFF,
193+
0x4C, 0x44, 0xFF, 0x4C, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x58, 0xFF, 0x4B, 0xFF, 0x72, 0xFF
194+
];

src/platform/vic20.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { PLATFORMS } from "../common/emu";
55
import { BaseMAME6502Platform } from "../common/mameplatform";
66

77
const VIC20_PRESETS = [
8-
{id:'hello.dasm', name:'Hello World (ASM)'},
8+
// {id:'hello.dasm', name:'Hello World (ASM)'},
99
{id:'hellocart.dasm', name:'Hello Cartridge (ASM)'},
10-
{id:'siegegame.c', name:'Siege Game (C)'},
10+
// {id:'siegegame.c', name:'Siege Game (C)'},
1111
];
1212

1313
const VIC20_MEMORY_MAP = { main:[

0 commit comments

Comments
 (0)