tigervision debugging; started verilog_bar; astrocade new header

This commit is contained in:
Steven Hugg 2018-09-14 09:10:41 -04:00
parent ccd0731b14
commit 00621bdf16
11 changed files with 76 additions and 22 deletions

View File

@ -66,6 +66,10 @@ TODO:
- debug bankswitching for funky formats
- "invalid ROM" error should show up better
- spaces in filename don't parse code listing (DASM, maybe more)
- zmac: item_lookup needs better hash function
- 'undefined' for bitmap replacer
- astrocade: run to cursor in hello world messes up emulation
- requestInterrupt needs to be disabled after breakpoint?
WEB WORKER FORMAT

View File

@ -149,6 +149,10 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
<button id="dbg_bitmap" type="submit" title="Edit Bitmap"><span class="glyphicon glyphicon-camera" aria-hidden="true"></span></button>
<button id="dbg_record" type="submit" title="Start/Stop Replay Recording" style="display:none"><span class="glyphicon glyphicon-record" aria-hidden="true"></span></button>
</span>
<span id="verilog_bar" style="display:none">
<span class="label"><span id="settle_label"></span> evals/clk</span>
</span>
<span class="dropdown" style="float:right">
<a class="btn btn-secondary dropdown-toggle" id="booksMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
GET BOOKS <span class="caret"></span>

View File

@ -1,11 +1,9 @@

; Minimal header file for use with Astrocade C programs
.area _CODE
.byte 0x55 ; ... with the code for a normal menued cartridge
.word 0x0218 ; Initialize menu
.word PrgName ; ... with string at PrgName
.word _main ; ... such that selecting the program enters PrgStart
PrgName: .ascii "8BITWORKSHOP" ; String
.byte 0 ; ... which must be followed by 0
.area _CODE
jp start ; jump to main()
start:
ld sp,#0x4fce
jp _main

View File

@ -0,0 +1,12 @@
; Minimal header file for use with Astrocade C programs
.area _CODE
.byte 0x55 ; ... with the code for a normal menued cartridge
.word 0x0218 ; Initialize menu
.word PrgName ; ... with string at PrgName
.word _main ; ... such that selecting the program enters PrgStart
PrgName:
.ascii "8BITWORKSHOP" ; String
.byte 0 ; ... which must be followed by 0

View File

@ -15,7 +15,10 @@ export interface OpcodeMetadata {
}
export interface CpuState {
PC:number, T?:number, o?:number,/*opcode*/
PC:number;
EPC?:number; // effective PC (for bankswitching)
T?:number;
o?:number;/*opcode*/
SP?:number
/*
A:number, X:number, Y:number, SP:number, R:boolean,
@ -425,7 +428,6 @@ export abstract class BaseZ80Platform extends BaseDebugPlatform {
var targetTstates = cpu.getTstates() + cycles;
if (debugCond) { // || trace) {
while (cpu.getTstates() < targetTstates) {
//_trace(); // TODO
if (debugCond && debugCond()) {
debugCond = null;
break;
@ -437,6 +439,10 @@ export abstract class BaseZ80Platform extends BaseDebugPlatform {
}
return cpu.getTstates() - targetTstates;
}
requestInterrupt(cpu, data) {
if (!this.wasBreakpointHit())
cpu.requestInterrupt(data);
}
postFrame() {
if (this.debugCondition && !this.debugBreakState) {
this.debugSavedState = this.saveState();

View File

@ -86,6 +86,10 @@ const _BallyAstrocadePlatform = function(mainElement, arcade) {
function ramwrite(a:number, v:number) {
ram.mem[a] = v;
ramupdate(a, v);
}
function ramupdate(a:number, v:number) {
var ofs = a*4+3; // 4 pixels per byte
for (var i=0; i<4; i++) {
var lr = ((a % swbytes) >= (horcb & 0x3f)) ? 0 : 4;
@ -97,7 +101,7 @@ const _BallyAstrocadePlatform = function(mainElement, arcade) {
function refreshline(y:number) {
var ofs = y*swidth/4;
for (var i=0; i<swidth/4; i++)
ramwrite(ofs+i, ram.mem[ofs+i]);
ramupdate(ofs+i, ram.mem[ofs+i]);
}
function magicwrite(a:number, v:number) {
@ -295,9 +299,10 @@ const _BallyAstrocadePlatform = function(mainElement, arcade) {
advance(novideo : boolean) {
for (var sl=0; sl<sheight; sl++) {
//console.log(sl, hex(cpu.getPC(),4), cpu.saveState());
this.runCPU(cpu, cpuCyclesPerLine);
if (sl == inlin && (inmod & 0x8)) {
cpu.requestInterrupt(infbk);
this.requestInterrupt(cpu, infbk);
}
if (refreshlines>0) {
refreshline(sl);
@ -326,7 +331,7 @@ const _BallyAstrocadePlatform = function(mainElement, arcade) {
}
loadState(state) {
cpu.loadState(state.c);
cpu.loadState(state.c); // TODO: this causes problems on reset+debug
ram.mem.set(state.b);
palette.set(state.palette);
magicop = state.magicop;
@ -339,6 +344,7 @@ const _BallyAstrocadePlatform = function(mainElement, arcade) {
infbk = state.infbk;
verbl = state.verbl;
this.loadControlsState(state);
refreshall();
}
saveState() {
return {
@ -408,7 +414,6 @@ class AstrocadeAudio extends AY38910_Audio {
var j = val*2+1;
this.psg.writeRegisterAY(i, j&0xff); // freq lo
this.psg.writeRegisterAY(i+1, (j>>8)&0xff); // freq hi
console.log(i,j);
break;
case 5:
this.psg.writeRegisterAY(10, val & 0xf); // tone c vol

View File

@ -156,7 +156,10 @@ class VCSPlatform extends BasePlatform {
return state;
}
fixState(state) {
state.c.EPC = state.c.PC + (state.ca.bo || 0); // effective PC for ROM
var ofs = state.ca.bo || 0;
if (state.ca.fo && (state.c.PC & 0xfff) >= 2048)
ofs = state.ca.fo; // 3E/3F fixed-slice formats
state.c.EPC = state.c.PC + ofs; // ofs = effective PC for ROM
}
loadState(state) {
return Javatari.room.console.loadState(state);
@ -216,12 +219,15 @@ class VCSPlatform extends BasePlatform {
}
getDebugInfo(category, state) {
switch (category) {
case 'CPU': return (state.ca.bo ? ("BankOffset "+hex(state.ca.bo)+"\n"):"") + this.cpuStateToLongString(state.c);
case 'CPU': return this.cpuStateToLongString(state.c) + this.bankSwitchStateToString(state);
case 'Stack': return dumpStackToString(this, this.getRAMForState(state), 0x100, 0x1ff, 0x100+state.c.SP, 0x20);
case 'PIA': return this.ramStateToLongString(state) + "\n" + this.piaStateToLongString(state.p);
case 'TIA': return this.tiaStateToLongString(state.t);
}
}
bankSwitchStateToString(state) {
return (state.ca.bo !== undefined ? ("BankOffset "+hex(state.ca.bo,4)+"\n"):"");
}
piaStateToLongString(p) {
return "Timer " + p.t + "/" + p.c + "\nINTIM $" + hex(p.IT,2) + " (" + p.IT + ")\nINSTAT $" + hex(p.IS,2) + "\n";
}

View File

@ -124,7 +124,7 @@ export function VL_RANDOM_I(bits) { return 0 | Math.floor(Math.random() * (1<<bi
abstract class VerilatorBase {
totalTicks = 0;
maxVclockLoop = 1;
maxVclockLoop = 0;
clk = 0;
reset = 0;
@ -182,7 +182,11 @@ abstract class VerilatorBase {
}
if (__VclockLoop > this.maxVclockLoop) {
this.maxVclockLoop = __VclockLoop;
console.log("Graph took " + this.maxVclockLoop + " iterations to stabilize");
if (this.maxVclockLoop > 1) {
console.log("Graph took " + this.maxVclockLoop + " iterations to stabilize");
$("#verilog_bar").show();
$("#settle_label").text(this.maxVclockLoop+"");
}
}
this.totalTicks++;
}
@ -666,6 +670,7 @@ var VerilogPlatform = function(mainElement, options) {
trace_index = 0;
if (trace_buffer) trace_buffer.fill(0);
if (video) video.setRotate(gen.rotate ? -90 : 0);
$("#verilog_bar").hide();
}
tick() {
gen.tick2();

View File

@ -224,8 +224,12 @@ function getSkeletonFile(fileid:string, callback) {
function _createNewFile(e) {
// TODO: support spaces
var filename = prompt("Create New File (no spaces)", "newfile" + platform.getDefaultExtension());
var filename = prompt("Create New File", "newfile" + platform.getDefaultExtension());
if (filename && filename.length) {
if (filename.indexOf(" ") >= 0) {
alert("No spaces, please.");
return;
}
if (filename.indexOf(".") < 0) {
filename += platform.getDefaultExtension();
}
@ -828,8 +832,9 @@ function setupDebugControls(){
$("#dbg_reset").click(resetAndDebug);
$("#dbg_pause").click(pause);
$("#dbg_go").click(resume);
Mousetrap.bindGlobal('ctrl+alt+p', togglePause);
Mousetrap.bindGlobal('ctrl+alt+r', resetAndDebug);
Mousetrap.bindGlobal('ctrl+alt+p', pause);
Mousetrap.bindGlobal('ctrl+alt+r', resume);
Mousetrap.bindGlobal('ctrl+alt+.', resetAndDebug);
if (platform.step) {
$("#dbg_step").click(singleStep).show();

View File

@ -39,6 +39,7 @@ var _galaxian = require('gen/platform/galaxian.js');
var _vector = require('gen/platform/vector.js');
var _williams = require('gen/platform/williams.js');
var _sound_williams = require('gen/platform/sound_williams.js');
var _astrocade = require('gen/platform/astrocade.js');
//
@ -211,6 +212,14 @@ describe('Platform Replay', () => {
});
});
*/
it('Should run astrocade', () => {
var platform = testPlatform('astrocade', 'cosmic.c.rom', 92, (platform, frameno) => {
if (frameno == 62) {
keycallback(Keys.VK_SPACE.c, Keys.VK_SPACE.c, 1);
}
});
});
});

Binary file not shown.