diff --git a/presets/c64/climber.c b/presets/c64/climber.c index af47edb2..a5e4531e 100644 --- a/presets/c64/climber.c +++ b/presets/c64/climber.c @@ -247,9 +247,9 @@ void make_floors() { } while (ladder_in_gap(lev->ladder1, lev->gap) || ladder_in_gap(lev->ladder2, lev->gap)); if (i > 0) { - lev->objtype = rndint(1,3); + lev->objtype = rndint(0,3); do { - lev->objpos = rndint(2,COLS-7); + lev->objpos = rndint(5,COLS-7); } while (ladder_in_gap(lev->objpos, lev->gap)); } lev->ypos = y; diff --git a/src/machine/c64.ts b/src/machine/c64.ts index 7f370650..2cec82ce 100644 --- a/src/machine/c64.ts +++ b/src/machine/c64.ts @@ -572,8 +572,6 @@ import { TrapCondition } from "../common/devices"; export class C64_WASMMachine extends BaseWASMMachine implements Machine { prgstart : number; - initstring : string; - initindex : number; joymask0 = 0; reset() { @@ -584,27 +582,29 @@ export class C64_WASMMachine extends BaseWASMMachine implements Machine { this.prgstart = this.romarr[0] + (this.romarr[1]<<8); // TODO: get starting address if (this.prgstart == 0x801) this.prgstart = 0x80d; } - // set init string - if (this.prgstart) { - this.initstring = "\r\r\r\r\r\r\r\r\r\r\rSYS " + this.prgstart + "\r"; - this.initindex = 0; - } // clear keyboard for (var ch=0; ch<128; ch++) { this.setKeyInput(ch, 0, KeyFlags.KeyUp); } + if (this.prgstart) { + // advance BIOS + super.advanceFrameClock(null, 180000); + // set IRQ routine @ 0x314 + var old0x314 = this.read(0x314) + this.read(0x315) * 256; + this.write(0x314, 0x0d); + this.write(0x315, 0x08); + // wait until IRQ fires + for (var i=0; i<50000 && this.getPC() != this.prgstart; i++) { + this.exports.machine_tick(this.sys); + } + // reset 0x314 to old value + this.write(0x314, old0x314 & 0xff); + this.write(0x315, old0x314 >> 8); + } } advanceFrame(trap: TrapCondition) : number { - this.typeInitString(); // type init string into console (TODO: doesnt work during debug) return super.advanceFrameClock(trap, 19656+295); // TODO: can we sync with VSYNC? } - typeInitString() { - if (this.initstring) { - var ch = this.initstring.charCodeAt(this.initindex >> 1); - this.setKeyInput(ch, 0, (this.initindex&1) ? KeyFlags.KeyUp : KeyFlags.KeyDown); - if (++this.initindex >= this.initstring.length*2) this.initstring = null; - } - } getCPUState() { this.exports.machine_save_cpu_state(this.sys, this.cpustateptr); var s = this.cpustatearr;