mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-12-22 12:30:01 +00:00
"Save As"; command-line assembler; 32-bit limit (so far) in opcodes
This commit is contained in:
parent
f24213aa1d
commit
5b92659b97
4
Makefile
4
Makefile
@ -21,3 +21,7 @@ archive:
|
||||
git archive --prefix 8bitworkshop- -o release/8bitworkshop-tools.zip HEAD tools
|
||||
|
||||
|
||||
web:
|
||||
ifconfig | grep inet
|
||||
python2 -m SimpleHTTPServer 2>> http.out
|
||||
|
||||
|
@ -98,6 +98,9 @@ div.mem_info {
|
||||
margin-left:8px;
|
||||
background-color: #666;
|
||||
}
|
||||
.btn_label {
|
||||
color: #ccc;
|
||||
}
|
||||
.btn_group.debug_group {
|
||||
}
|
||||
.btn_group.view_group {
|
||||
|
15
index.html
15
index.html
@ -39,10 +39,11 @@ ga('send', 'pageview');
|
||||
☰ <span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<li><a class="dropdown-item" href="#" id="item_new_file">New File...</a></li>
|
||||
<li><a class="dropdown-item" href="#" id="item_new_file">New File...</a></li>
|
||||
<li><a class="dropdown-item" href="#" id="item_share_file">Share File as GitHub Gist...</a></li>
|
||||
<li><a class="dropdown-item" href="#" id="item_reset_file">Revert to Original...</a></li>
|
||||
<li><a class="dropdown-item" href="#" id="item_download_rom">Download ROM Image...</a></li>
|
||||
<li><a class="dropdown-item" href="#" id="item_download_file">Download File</a></li>
|
||||
<li><a class="dropdown-item" href="#" id="item_download_rom">Download ROM Image</a></li>
|
||||
<li><a class="dropdown-item" href="#" id="item_record_video">Record Video...</a></li>
|
||||
<li class="dropdown dropdown-submenu">
|
||||
<a tabindex="-1" href="#">Debug</a>
|
||||
@ -50,6 +51,12 @@ ga('send', 'pageview');
|
||||
<li><a class="dropdown-item" href="#" id="item_debug_expr">Break Expression...</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown dropdown-submenu">
|
||||
<a tabindex="-1" href="#">Options</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><i id="item_low_power_check" style="display:hidden" class="fa fa-check"></i><a class="dropdown-item" href="#" id="item_low_power">Low Power Mode</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<hr>
|
||||
<li class="dropdown dropdown-submenu">
|
||||
<a tabindex="-1" href="#">Platform</a>
|
||||
@ -82,7 +89,7 @@ ga('send', 'pageview');
|
||||
<span class="btn_group view_group" id="speed_bar" style="display:none">
|
||||
<button id="dbg_slowest" type="submit" title="Slowest"><span class="glyphicon glyphicon-fast-backward" aria-hidden="true"></span></button>
|
||||
<button id="dbg_slower" type="submit" title="Slower"><span class="glyphicon glyphicon-backward" aria-hidden="true"></span></button>
|
||||
<span id="fps_label">60.00</span> fps
|
||||
<span class="label"><span id="fps_label">60.00</span> fps</span>
|
||||
<button id="dbg_faster" type="submit" title="Faster"><span class="glyphicon glyphicon-forward" aria-hidden="true"></span></button>
|
||||
<button id="dbg_fastest" type="submit" title="Faster"><span class="glyphicon glyphicon-fast-forward" aria-hidden="true"></span></button>
|
||||
</span>
|
||||
@ -224,8 +231,10 @@ ga('send', 'pageview');
|
||||
</script>
|
||||
|
||||
<script>
|
||||
/*
|
||||
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
||||
if (!isFirefox && platform_id != 'vcs') { $("#best_in_firefox").show(); }
|
||||
*/
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
@ -25,6 +25,7 @@
|
||||
{"fmt":"pop ~reg", "bits":["01001",0,"00001","110"]},
|
||||
{"fmt":"rts", "bits":["01001","111","00001","110"]},
|
||||
{"fmt":"jsr ~reg", "bits":["01110","111","00",0,"110"]},
|
||||
{"fmt":"jsr ~imm16", "bits":["0001110001011000",0,"0111011100100110"]},
|
||||
|
||||
{"fmt":"bcc ~rel8", "bits":["10000001",0]},
|
||||
{"fmt":"bcs ~rel8", "bits":["10001001",0]},
|
||||
|
@ -19,8 +19,8 @@
|
||||
mov ax,@$4ffe
|
||||
mov dx,@ClearTiles
|
||||
jsr dx
|
||||
mov dx,@ClearSprites
|
||||
jsr dx
|
||||
mov ex,@ClearSprites
|
||||
jsr ex
|
||||
reset
|
||||
InitPageTable:
|
||||
mov ax,@$6000 ; screen buffer
|
||||
|
@ -372,6 +372,11 @@ function _downloadROMImage(e) {
|
||||
saveAs(blob, getCurrentFilename()+".rom");
|
||||
}
|
||||
|
||||
function _downloadSourceFile(e) {
|
||||
var blob = new Blob([editor.getValue()], {type: "text/plain;charset=utf-8"});
|
||||
saveAs(blob, getCurrentFilename());
|
||||
}
|
||||
|
||||
function populateExamples(sel) {
|
||||
sel.append($("<option />").text("--------- Examples ---------").attr('disabled',true));
|
||||
for (var i=0; i<PRESETS.length; i++) {
|
||||
@ -1312,6 +1317,7 @@ function setupDebugControls(){
|
||||
else
|
||||
$("#item_debug_expr").hide();
|
||||
$("#item_download_rom").click(_downloadROMImage);
|
||||
$("#item_download_file").click(_downloadSourceFile);
|
||||
$("#item_record_video").click(_recordVideo);
|
||||
if (platform.setFrameRate && platform.getFrameRate) {
|
||||
$("#speed_bar").show();
|
||||
|
@ -124,24 +124,30 @@ var Assembler = function(spec) {
|
||||
self.buildInstruction = function(rule, m) {
|
||||
var opcode = 0;
|
||||
var oplen = 0;
|
||||
// iterate over each component of the rule output ("bits")
|
||||
for (var i=0; i<rule.bits.length; i++) {
|
||||
var b = rule.bits[i];
|
||||
var n,x;
|
||||
// is a string? then it's a bit constant
|
||||
// TODO
|
||||
if (b.length) {
|
||||
n = b.length;
|
||||
x = parseInt(b,2);
|
||||
} else {
|
||||
// it's an indexed variable, look up its variable
|
||||
var id = m[b+1];
|
||||
var v = spec.vars[rule.varlist[b]];
|
||||
if (!v) {
|
||||
return {error:"Could not find matching identifier for '" + m[0] + "'"};
|
||||
}
|
||||
n = v.bits;
|
||||
// is it an enumerated type? look up the index of its keyword
|
||||
if (v.toks) {
|
||||
x = v.toks.indexOf(id);
|
||||
if (x < 0)
|
||||
return null;
|
||||
} else {
|
||||
// otherwise, parse it as a constant
|
||||
x = parseConst(id, n);
|
||||
// is it a label? add fixup
|
||||
if (isNaN(x)) {
|
||||
@ -158,14 +164,16 @@ var Assembler = function(spec) {
|
||||
}
|
||||
if (oplen == 0)
|
||||
warning("Opcode had zero length");
|
||||
else if (oplen > 32)
|
||||
warning("Opcodes > 32 bits not supported");
|
||||
else if ((oplen % width) != 0)
|
||||
warning("Opcode was not word-aligned (" + oplen + " bits)");
|
||||
return {opcode:opcode, nbits:oplen};
|
||||
}
|
||||
|
||||
self.loadArch = function(arch) {
|
||||
if (self.loadFile) {
|
||||
var json = self.loadFile(arch + ".json");
|
||||
if (self.loadJSON) {
|
||||
var json = self.loadJSON(arch + ".json");
|
||||
if (json && json.vars && json.rules) {
|
||||
spec = json;
|
||||
preprocessRules();
|
||||
@ -292,13 +300,16 @@ if (typeof module !== 'undefined' && require.main === module) {
|
||||
var stdinBuffer = fs.readFileSync(0);
|
||||
var code = stdinBuffer.toString();
|
||||
var asm = new Assembler();
|
||||
asm.loadFile = function(filename) {
|
||||
return fs.readFileSync(filename, 'utf8');
|
||||
asm.loadJSON = function(filename) {
|
||||
return JSON.parse(fs.readFileSync(filename, 'utf8'));
|
||||
};
|
||||
asm.loadInclude = function(filename) {
|
||||
filename = filename.substr(1, filename.length-2); // remove quotes
|
||||
//return fs.readFileSync(filename, 'utf8');
|
||||
};
|
||||
asm.loadModule = function(top_module) {
|
||||
//TODO
|
||||
};
|
||||
var out = asm.assembleFile(code);
|
||||
if (out.errors) {
|
||||
console.log(out.errors);
|
||||
} else {
|
||||
console.log(out.outwords);
|
||||
}
|
||||
console.log(out);
|
||||
}
|
||||
|
@ -1126,7 +1126,7 @@ function compileJSASM(asmcode, platform, options, is_inline) {
|
||||
load("assembler");
|
||||
var asm = new Assembler();
|
||||
var includes = [];
|
||||
asm.loadFile = function(filename) {
|
||||
asm.loadJSON = function(filename) {
|
||||
// TODO: what if it comes from dependencies?
|
||||
var path = '../../presets/' + platform + '/' + filename;
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
Loading…
Reference in New Issue
Block a user