1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2025-02-26 22:29:56 +00:00

clearBreakpoint before loadRom() to refresh memory; refresh listing view

This commit is contained in:
Steven Hugg 2018-08-19 19:25:42 -04:00
parent c43ecf046c
commit e964bd26be
7 changed files with 77 additions and 12 deletions

View File

@ -50,6 +50,10 @@ TODO:
- BOM in upload/download? - BOM in upload/download?
- stack view for Z80 platforms using memory map - stack view for Z80 platforms using memory map
- online tools for music etc - online tools for music etc
- tools (memory, disasm) use debugging state
- loadROM needs to stop debugging before loading
- text log debugging script
- update listing when recompiling
FYI: Image links for the books on http://8bitworkshop.com/ are broken FYI: Image links for the books on http://8bitworkshop.com/ are broken
On the website the additional grey spacing next to the program line numbers is not dynamically resized when the web browser window size is changed. Intentional? On the website the additional grey spacing next to the program line numbers is not dynamically resized when the web browser window size is changed. Intentional?

View File

@ -404,6 +404,14 @@ const byte SINTBL[32] = {
-127, -125, -117, -106, -90, -71, -49, -25, -127, -125, -117, -106, -90, -71, -49, -25,
}; };
// pre-multiplied by 2
const int SINTBL2[32] = {
0, 25*2, 49*2, 71*2, 90*2, 106*2, 117*2, 125*2,
127*2, 125*2, 117*2, 106*2, 90*2, 71*2, 49*2, 25*2,
0*2, -25*2, -49*2, -71*2, -90*2, -106*2, -117*2, -125*2,
-127*2, -125*2, -117*2, -106*2, -90*2, -71*2, -49*2, -25*2,
};
signed char isin(byte dir) { signed char isin(byte dir) {
return SINTBL[dir & 31]; return SINTBL[dir & 31];
} }
@ -412,6 +420,29 @@ signed char icos(byte dir) {
return isin(dir+8); return isin(dir+8);
} }
// Fast 8-bit table lookup macro
// dest: destination
// ident: table identifier
// index: 8-bit index
#define FASTLUT8(dest,ident,index) \
__AX__ = (index); \
asm ("tax"); \
asm ("lda %v,x", ident); \
(dest) = __AX__;
// Fast 16-bit table lookup (single table of 2-byte words, 128 entries max)
// dest: destination (16 bits)
// ident: table identifier
// index: 8-bit index
#define FASTLUT16(dest,ident,index) \
__AX__ = (index); \
asm ("asl"); \
asm ("tay"); \
asm ("lda %v+1,y", ident); \
asm ("tax"); \
asm ("lda %v,y", ident); \
(dest) = __AX__;
#define FORMATION_X0 0 #define FORMATION_X0 0
#define FORMATION_Y0 19 #define FORMATION_Y0 19
#define FORMATION_XSPACE 24 #define FORMATION_XSPACE 24
@ -467,8 +498,11 @@ void return_attacker(register AttackingEnemy* a) {
void fly_attacker(register AttackingEnemy* a) { void fly_attacker(register AttackingEnemy* a) {
byte dir = a->dir; byte dir = a->dir;
#if 1 #if 1
a->x += SINTBL[dir & 31] * 2; int sincos;
a->y += SINTBL[(dir+8) & 31] * 2; sincos = FASTLUT16(sincos, SINTBL2, dir&31);
a->x += sincos;
sincos = FASTLUT16(sincos, SINTBL2, (dir+8)&31);
a->y += sincos;
#else #else
a->x += isin(dir) * 2; a->x += isin(dir) * 2;
a->y += icos(dir) * 2; a->y += icos(dir) * 2;
@ -660,7 +694,7 @@ void does_missile_hit_player() {
return; return;
for (i=0; i<MAX_ATTACKERS; i++) { for (i=0; i<MAX_ATTACKERS; i++) {
if (missiles[i].ypos != YOFFSCREEN && if (missiles[i].ypos != YOFFSCREEN &&
in_rect(missiles[i].xpos + 8, missiles[i].ypos + 16, in_rect(missiles[i].xpos, missiles[i].ypos + 16,
player_x, player_y, 16, 16)) { player_x, player_y, 16, 16)) {
player_exploding = 1; player_exploding = 1;
break; break;

View File

@ -202,6 +202,8 @@ export function getToolForFilename_6502(fn:string) : string {
if (fn.endsWith(".pla")) return "plasm"; if (fn.endsWith(".pla")) return "plasm";
if (fn.endsWith(".c")) return "cc65"; if (fn.endsWith(".c")) return "cc65";
if (fn.endsWith(".s")) return "ca65"; if (fn.endsWith(".s")) return "ca65";
if (fn.endsWith(".ca65")) return "ca65";
if (fn.endsWith(".dasm")) return "dasm";
if (fn.endsWith(".acme")) return "acme"; if (fn.endsWith(".acme")) return "acme";
return "dasm"; // .a return "dasm"; // .a
} }

View File

@ -490,7 +490,7 @@ var DVGBWStateMachine = function(bus, video, bofs) {
if (!running) return; if (!running) return;
var w = readWord(pc); var w = readWord(pc);
var op = w >> 12; var op = w >> 12;
//console.log(hex(pc*2+bofs), hex(w), hex(x>>2), hex(y>>2)); //console.log(hex(pc*2+bofs), hex(w), hex(x>>2), hex(y>>2), hex(32-pcstack.length*2));
pc++; pc++;
switch (op) { switch (op) {
// VEC // VEC

View File

@ -148,13 +148,14 @@ function refreshWindowList() {
}); });
// add listings // add listings
// TODO: update listing when recompiling
var listings = current_project.getListings(); var listings = current_project.getListings();
if (listings) { if (listings) {
for (var lstfn in listings) { for (var lstfn in listings) {
var lst = listings[lstfn]; var lst = listings[lstfn];
if (lst.assemblyfile) { if (lst.assemblyfile) {
addWindowItem(lstfn, getFilenameForPath(lstfn), function(path) { addWindowItem(lstfn, getFilenameForPath(lstfn), function(path) {
return new Views.ListingView(lst.assemblyfile); return new Views.ListingView(lstfn);
}); });
} }
} }
@ -309,6 +310,7 @@ function _shareFile(e) {
return true; return true;
} }
// TODO: reset file, not project
function _resetPreset(e) { function _resetPreset(e) {
if (!current_preset_entry) { if (!current_preset_entry) {
alert("Can only reset built-in file examples.") alert("Can only reset built-in file examples.")
@ -399,8 +401,9 @@ function setCompileOutput(data: WorkerResult) {
var rom = data.output; var rom = data.output;
if (rom) { // TODO instanceof Uint8Array) { if (rom) { // TODO instanceof Uint8Array) {
try { try {
clearBreakpoint(); // so we can replace memory (TODO: change toolbar btn)
platform.loadROM(getCurrentPresetTitle(), rom); platform.loadROM(getCurrentPresetTitle(), rom);
if (!userPaused) resume(); if (!userPaused) _resume();
current_output = rom; current_output = rom;
// TODO: reset profiler etc? (Tell views?) // TODO: reset profiler etc? (Tell views?)
} catch (e) { } catch (e) {

View File

@ -279,7 +279,7 @@ export class SourceEditor implements ProjectView {
refreshListing() { refreshListing() {
// lookup corresponding sourcefile for this file, using listing // lookup corresponding sourcefile for this file, using listing
var lst = current_project.getListingForFile(this.path); var lst = current_project.getListingForFile(this.path);
if (lst && lst.sourcefile && lst.sourcefile != this.sourcefile) { if (lst && lst.sourcefile && lst.sourcefile !== this.sourcefile) {
this.sourcefile = lst.sourcefile; this.sourcefile = lst.sourcefile;
this.dirtylisting = true; this.dirtylisting = true;
} }
@ -484,13 +484,24 @@ export class DisassemblerView implements ProjectView {
export class ListingView extends DisassemblerView implements ProjectView { export class ListingView extends DisassemblerView implements ProjectView {
assemblyfile : SourceFile; assemblyfile : SourceFile;
path : string;
constructor(assemblyfile : SourceFile) { constructor(lstfn : string) {
super(); super();
this.assemblyfile = assemblyfile; this.path = lstfn;
}
refreshListing() {
// lookup corresponding assemblyfile for this file, using listing
var lst = current_project.getListingForFile(this.path);
if (lst && lst.assemblyfile && lst.assemblyfile !== this.assemblyfile) {
this.assemblyfile = lst.assemblyfile;
}
} }
refresh(moveCursor: boolean) { refresh(moveCursor: boolean) {
this.refreshListing();
if (!this.assemblyfile) return; // TODO?
var state = lastDebugState || platform.saveState(); var state = lastDebugState || platform.saveState();
var pc = state.c ? state.c.PC : 0; var pc = state.c ? state.c.PC : 0;
var asmtext = this.assemblyfile.text; var asmtext = this.assemblyfile.text;
@ -515,11 +526,21 @@ export class ListingView extends DisassemblerView implements ProjectView {
/// ///
// TODO: make it use debug state
export class MemoryView implements ProjectView { export class MemoryView implements ProjectView {
memorylist; memorylist;
dumplines; dumplines;
maindiv : HTMLElement; maindiv : HTMLElement;
static IGNORE_SYMS = {s__INITIALIZER:true, /* s__GSINIT:true, */ _color_prom:true}; static IGNORE_SYMS = {s__INITIALIZER:true, /* s__GSINIT:true, */ _color_prom:true};
/*
read(addr:number) {
// TODO: b offset ?
if (lastDebugState && lastDebugState.b && addr < lastDebugState.b.length)
return lastDebugState.b[addr];
else
return this.platform.readMemory(addr);
}
*/
createDiv(parent : HTMLElement) { createDiv(parent : HTMLElement) {
var div = document.createElement('div'); var div = document.createElement('div');

View File

@ -146,9 +146,10 @@ describe('Store', function() {
assert.deepEqual([false], msgs); assert.deepEqual([false], msgs);
var lst = buildresult.listings.test; var lst = buildresult.listings.test;
console.log(lst); console.log(lst);
assert.equal(3, lst.sourcefile.findLineForOffset(61440+15)); assert.equal(3, lst.sourcefile.findLineForOffset(61440+15, 15));
assert.equal(null, lst.sourcefile.findLineForOffset(61440+16)); assert.equal(null, lst.sourcefile.findLineForOffset(61440+16, 15));
assert.equal(null, lst.sourcefile.findLineForOffset(61440-1)); assert.equal(null, lst.sourcefile.findLineForOffset(61440+1, 0));
assert.equal(null, lst.sourcefile.findLineForOffset(61440-1, 16));
assert.equal(1, lst.sourcefile.lineCount()); assert.equal(1, lst.sourcefile.lineCount());
done(); done();
}); });