1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2025-01-14 13:31:17 +00:00

refactored astrocade; added paddles, still need to simulate bus contention, bios platform

This commit is contained in:
Steven Hugg 2019-08-26 12:58:42 -04:00
parent f32009ca0b
commit 33a0e9ed57
6 changed files with 677 additions and 606 deletions

View File

@ -1038,7 +1038,7 @@ export function lookupSymbol(platform:Platform, addr:number, extra:boolean) {
/// new Machine platform adapters /// new Machine platform adapters
import { Bus, Resettable, FrameBased, VideoSource, SampledAudioSource, AcceptsROM, AcceptsKeyInput, SavesState, SavesInputState, HasCPU } from "./devices"; import { Bus, Resettable, FrameBased, VideoSource, SampledAudioSource, AcceptsROM, AcceptsKeyInput, SavesState, SavesInputState, HasCPU } from "./devices";
import { Probeable, RasterFrameBased } from "./devices"; import { Probeable, RasterFrameBased, AcceptsPaddleInput } from "./devices";
import { SampledAudio } from "./audio"; import { SampledAudio } from "./audio";
import { ProbeRecorder } from "./recorder"; import { ProbeRecorder } from "./recorder";
@ -1054,6 +1054,9 @@ function hasAudio(arg:any): arg is SampledAudioSource {
function hasKeyInput(arg:any): arg is AcceptsKeyInput { function hasKeyInput(arg:any): arg is AcceptsKeyInput {
return typeof arg.setKeyInput === 'function'; return typeof arg.setKeyInput === 'function';
} }
function hasPaddleInput(arg:any): arg is AcceptsPaddleInput {
return typeof arg.setPaddleInput === 'function';
}
function isRaster(arg:any): arg is RasterFrameBased { function isRaster(arg:any): arg is RasterFrameBased {
return typeof arg.getRasterY === 'function'; return typeof arg.getRasterY === 'function';
} }
@ -1111,6 +1114,9 @@ export abstract class BaseMachinePlatform<T extends Machine> extends BaseDebugPl
this.video.setKeyboardEvents(m.setKeyInput.bind(m)); this.video.setKeyboardEvents(m.setKeyInput.bind(m));
this.poller = new ControllerPoller(m.setKeyInput.bind(m)); this.poller = new ControllerPoller(m.setKeyInput.bind(m));
} }
if (hasPaddleInput(m)) {
this.video.setupMouseEvents();
}
if (hasProbe(m)) { if (hasProbe(m)) {
this.probeRecorder = new ProbeRecorder(m); this.probeRecorder = new ProbeRecorder(m);
this.startProbing = () => { this.startProbing = () => {
@ -1128,7 +1134,13 @@ export abstract class BaseMachinePlatform<T extends Machine> extends BaseDebugPl
this.reset(); this.reset();
} }
pollControls() { this.poller && this.poller.poll(); } pollControls() {
this.poller && this.poller.poll();
if (hasPaddleInput(this.machine)) {
this.machine.setPaddleInput(0, this.video.paddle_x);
this.machine.setPaddleInput(1, this.video.paddle_y);
}
}
advance(novideo:boolean) { advance(novideo:boolean) {
this.machine.advanceFrame(999999, this.getDebugCallback()); this.machine.advanceFrame(999999, this.getDebugCallback());

View File

@ -253,7 +253,7 @@ let run_instruction = function()
/// @param non_maskable - true if this is a non-maskable interrupt /// @param non_maskable - true if this is a non-maskable interrupt
/// @param data - the value to be placed on the data bus, if needed /// @param data - the value to be placed on the data bus, if needed
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
let interrupt = function(non_maskable, data) let interrupt = function(non_maskable:boolean, data:number) : boolean
{ {
//console.log(non_maskable, data, iff1, iff2, do_delayed_ei, do_delayed_di); //console.log(non_maskable, data, iff1, iff2, do_delayed_ei, do_delayed_di);
if (non_maskable) if (non_maskable)
@ -270,6 +270,7 @@ let interrupt = function(non_maskable, data)
push_word(pc); push_word(pc);
pc = 0x66; pc = 0x66;
cycle_counter += 11; cycle_counter += 11;
return true;
} }
else if (iff1) else if (iff1)
{ {
@ -312,6 +313,7 @@ let interrupt = function(non_maskable, data)
cycle_counter += 19; cycle_counter += 19;
} }
//console.log(imode,data,pc); //console.log(imode,data,pc);
return true;
} }
}; };
@ -3345,6 +3347,7 @@ let cycle_counts_dd = [
this.interrupt = interrupt; this.interrupt = interrupt;
this.getPC = ():number => { return pc; } this.getPC = ():number => { return pc; }
this.getSP = ():number => { return sp; } this.getSP = ():number => { return sp; }
this.getHalted = ():boolean => { return halted; }
} }
export interface Z80State { export interface Z80State {
@ -3361,6 +3364,8 @@ export class Z80 implements CPU, InstructionBased, IOBusConnected, SavesState<Z8
interruptType; interruptType;
memBus : Bus; memBus : Bus;
ioBus : Bus; ioBus : Bus;
retryInterrupts : boolean = false;
retryData : number = -1;
private buildCPU() { private buildCPU() {
if (this.memBus && this.ioBus) { if (this.memBus && this.ioBus) {
@ -3381,13 +3386,18 @@ export class Z80 implements CPU, InstructionBased, IOBusConnected, SavesState<Z8
this.buildCPU(); this.buildCPU();
} }
advanceInsn() { advanceInsn() {
if (this.retryInterrupts && this.retryData >= 0 && this.cpu.interrupt(false, this.retryData)) {
this.retryData = -1;
}
return this.cpu.advanceInsn(); return this.cpu.advanceInsn();
} }
reset() { reset() {
this.cpu.reset(); this.cpu.reset();
} }
interrupt(data:number) { interrupt(data:number) {
this.cpu.interrupt(false, data); if (!this.cpu.interrupt(false, data) && this.retryInterrupts) {
this.retryData = data;
}
} }
NMI() { NMI() {
this.cpu.interrupt(true, 0); this.cpu.interrupt(true, 0);

View File

@ -93,11 +93,15 @@ export interface SavesInputState<CS> {
saveControlsState() : CS; saveControlsState() : CS;
} }
// TODO // TODO: joystick
export interface AcceptsKeyInput { export interface AcceptsKeyInput {
setKeyInput(key:number, code:number, flags:number) : void; setKeyInput(key:number, code:number, flags:number) : void;
} }
export interface AcceptsPaddleInput {
setPaddleInput(controller:number, value:number) : void;
}
export interface Probeable { export interface Probeable {
connectProbe(probe: ProbeAll) : void; connectProbe(probe: ProbeAll) : void;
} }

632
src/machine/astrocade.ts Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,3 @@
"use strict";
import { VicDual } from "../machine/vicdual"; import { VicDual } from "../machine/vicdual";
import { BaseZ80MachinePlatform } from "../baseplatform"; import { BaseZ80MachinePlatform } from "../baseplatform";