mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-12-25 15:30:03 +00:00
verilog: added keycode/keystrobe
This commit is contained in:
parent
211386e7bf
commit
70862f2146
@ -121,7 +121,6 @@ TODO:
|
||||
- can't add control instructions b/c of split
|
||||
- bad error msg if >2 moduels and top module doesn't match filename
|
||||
- separate Scope View
|
||||
- keyboard interface
|
||||
- single-stepping vector games makes screen fade
|
||||
- break on stack overflow, illegal op, bad access, BRK, etc
|
||||
- nes
|
||||
|
@ -470,7 +470,7 @@ function _metakeyflags(e) {
|
||||
|
||||
type KeyMapFunction = (o:KeyMapEntry, key:number, code:number, flags:number) => void;
|
||||
|
||||
export function newKeyboardHandler(switches:number[]|Uint8Array, map:KeyCodeMap, func?:KeyMapFunction) {
|
||||
export function newKeyboardHandler(switches:number[]|Uint8Array, map:KeyCodeMap, func?:KeyMapFunction, alwaysfunc?:boolean) {
|
||||
return (key:number,code:number,flags:number) => {
|
||||
if (!map) {
|
||||
func(null, key, code, flags);
|
||||
@ -478,7 +478,7 @@ export function newKeyboardHandler(switches:number[]|Uint8Array, map:KeyCodeMap,
|
||||
}
|
||||
var o : KeyMapEntry = map[key];
|
||||
if (!o) o = map[0];
|
||||
if (o && func) {
|
||||
if (func && (o || alwaysfunc)) {
|
||||
func(o, key, code, flags);
|
||||
}
|
||||
if (o) {
|
||||
@ -498,8 +498,8 @@ export function newKeyboardHandler(switches:number[]|Uint8Array, map:KeyCodeMap,
|
||||
};
|
||||
}
|
||||
|
||||
export function setKeyboardFromMap(video:RasterVideo, switches:number[]|Uint8Array, map:KeyCodeMap, func?:KeyMapFunction) {
|
||||
var handler = newKeyboardHandler(switches, map, func);
|
||||
export function setKeyboardFromMap(video:RasterVideo, switches:number[]|Uint8Array, map:KeyCodeMap, func?:KeyMapFunction, alwaysfunc?:boolean) {
|
||||
var handler = newKeyboardHandler(switches, map, func, alwaysfunc);
|
||||
video.setKeyboardEvents(handler);
|
||||
return new ControllerPoller(handler);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
import { Platform, BasePlatform } from "../baseplatform";
|
||||
import { PLATFORMS, setKeyboardFromMap, AnimationTimer, RasterVideo, Keys, makeKeycodeMap, getMousePos } from "../emu";
|
||||
import { PLATFORMS, setKeyboardFromMap, AnimationTimer, RasterVideo, Keys, makeKeycodeMap, getMousePos, KeyFlags } from "../emu";
|
||||
import { SampleAudio } from "../audio";
|
||||
import { safe_extend, clamp } from "../util";
|
||||
import { WaveformView, WaveformProvider, WaveformMeta } from "../waveform";
|
||||
@ -235,6 +235,7 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
|
||||
// control inputs
|
||||
var switches = [0,0,0];
|
||||
var keycode = 0;
|
||||
|
||||
// inspect feature
|
||||
var inspect_obj, inspect_sym;
|
||||
@ -280,6 +281,8 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
gen.tick2();
|
||||
if (useAudio)
|
||||
audio.feedSample(gen.spkr*(1.0/255.0), 1);
|
||||
if (keycode && keycode >= 128 && gen.keystrobe) // keystrobe = clear hi bit of key buffer
|
||||
keycode = gen.keycode = keycode & 0x7f;
|
||||
if (debugCond && debugCond())
|
||||
debugCond = null;
|
||||
}
|
||||
@ -328,7 +331,11 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
ctx.font = "8px TinyFont";
|
||||
ctx.fillStyle = "white";
|
||||
ctx.textAlign = "left";
|
||||
poller = setKeyboardFromMap(video, switches, VERILOG_KEYCODE_MAP);
|
||||
poller = setKeyboardFromMap(video, switches, VERILOG_KEYCODE_MAP, (o,key,code,flags) => {
|
||||
if (flags & KeyFlags.KeyPress) {
|
||||
keycode = code | 0x80;
|
||||
}
|
||||
}, true); // true = always send function
|
||||
var vcanvas = $(video.canvas);
|
||||
idata = video.getFrameData();
|
||||
timerCallback = () => {
|
||||
@ -389,6 +396,7 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
gen.switches_p1 = switches[0];
|
||||
gen.switches_p2 = switches[1];
|
||||
gen.switches_gen = switches[2];
|
||||
gen.keycode = keycode;
|
||||
}
|
||||
|
||||
updateVideoFrame() {
|
||||
@ -768,6 +776,7 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
sw0: switches[0],
|
||||
sw1: switches[1],
|
||||
sw2: switches[2],
|
||||
keycode: keycode
|
||||
};
|
||||
}
|
||||
loadControlsState(state) {
|
||||
@ -776,6 +785,7 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
switches[0] = state.sw0;
|
||||
switches[1] = state.sw1;
|
||||
switches[2] = state.sw2;
|
||||
keycode = state.keycode;
|
||||
}
|
||||
|
||||
} // end of inner class
|
||||
|
Loading…
Reference in New Issue
Block a user