x86: fixed yasm listing, font size resize, resize for zmachine too

This commit is contained in:
Steven Hugg 2020-07-10 13:25:34 -05:00
parent caabcb8196
commit c76d240a87
4 changed files with 38 additions and 9 deletions

View File

@ -92,9 +92,9 @@ export class CodeProject {
this.pushAllFiles(files, m[1]);
}
} else {
// for .asm -- [.]include "file"
// for .asm -- [.%]include "file"
// for .c -- #include "file"
let re2 = /^\s*[.#]?(include|incbin)\s+"(.+?)"/gmi;
let re2 = /^\s*[.#%]?(include|incbin)\s+"(.+?)"/gmi;
while (m = re2.exec(text)) {
this.pushAllFiles(files, m[2]);
}

View File

@ -52,8 +52,9 @@ class FATFSArrayBufferDriver {
class X86PCPlatform implements Platform {
mainElement;
video;
mainElement : HTMLElement;
video : RasterVideo;
console_div : HTMLElement;
emulator;
v86;
@ -99,10 +100,13 @@ class X86PCPlatform implements Platform {
this.video = new RasterVideo(this.mainElement,640,480,{overscan:false});
this.video.create();
var div = document.createElement('div');
div.classList.add('pc-console');
div.classList.add('emuvideo');
this.mainElement.appendChild(div);
this.console_div = div;
this.resize(); // set font size
this.emulator = new V86Starter({
memory_size: 2 * 1024 * 1024,
@ -133,6 +137,12 @@ class X86PCPlatform implements Platform {
});
}
resize() {
// set font size proportional to window width
var charwidth = $(this.console_div).width() * 1.7 / 80;
$(this.console_div).css('font-size', charwidth+'px');
}
getDebugTree() {
return this.v86;
}

View File

@ -46,7 +46,7 @@ interface IFZVM {
class GlkWindow {
page: HTMLElement;
stream: number;
curline: HTMLElement;
curstyle: number;
reverse: boolean;
@ -102,8 +102,8 @@ class GlkWindow {
move_cursor(col, row) {
// TODO
if (row == this.row && col > this.col) {
for (var i=this.col; i<col; i++)
this.addtext(' ', this.curstyle);
for (var i = this.col; i < col; i++)
this.addtext(' ', this.curstyle);
}
this.col = col;
this.row = row;
@ -337,7 +337,7 @@ class GlkImpl {
glk_window_get_size(win, widthref: RefBox, heightref: RefBox) {
console.log('glk_window_get_size', arguments);
// TODO: made up sizes, only status line supported
if (widthref) widthref.set_value(40);
if (widthref) widthref.set_value(STATUS_NUM_COLS);
if (heightref) heightref.set_value(win == 1 ? 25 : 1);
}
garglk_set_reversevideo(val) {
@ -681,6 +681,8 @@ const Const = {
//
const STATUS_NUM_COLS = 80;
class ZmachinePlatform implements Platform {
mainElement: HTMLElement;
zfile: Uint8Array;
@ -715,8 +717,16 @@ class ZmachinePlatform implements Platform {
windowport.on('click', (e) => {
inputline.focus();
});
this.resize = () => {
// set font size proportional to window width
var charwidth = $(gameport).width() * 1.6 / STATUS_NUM_COLS;
$(upperwnd).css('font-size', charwidth + 'px');
}
this.resize();
}
resize : () => void;
loadROM(title, data) {
this.zfile = data;
this.reset();

View File

@ -614,9 +614,12 @@ function extractErrors(regex, strings:string[], path:string, iline, imsg, ifilen
// TODO: "of" doesn't work in MSIE
var re_crlf = /\r?\n/;
// 1 %line 16+1 hello.asm
var re_lineoffset = /\s*(\d+)\s+[%]line\s+(\d+)\+(\d+)\s+(.+)/;
function parseListing(code:string, lineMatch, iline:number, ioffset:number, iinsns:number, icycles?:number) : SourceLine[] {
var lines : SourceLine[] = [];
var lineofs = 0;
code.split(re_crlf).forEach((line, lineindex) => {
var linem = lineMatch.exec(line);
if (linem && linem[1]) {
@ -627,13 +630,19 @@ function parseListing(code:string, lineMatch, iline:number, ioffset:number, iins
var iscode = cycles > 0;
if (insns) {
lines.push({
line:linenum,
line:linenum + lineofs,
offset:offset,
insns:insns,
cycles:cycles,
iscode:iscode
});
}
} else {
let m = re_lineoffset.exec(line);
// TODO: check filename too
if (m) {
lineofs = parseInt(m[2]) - parseInt(m[1]) - parseInt(m[3]);
}
}
});
return lines;