diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..d29a83af --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,4 @@ +# These are supported funding model platforms + +#github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: 8bitworkshop diff --git a/.gitignore b/.gitignore index 41850320..12d7c394 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ local release gen test/output +.DS_Store diff --git a/.gitmodules b/.gitmodules index 946ca202..97e0d7cb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,15 +16,12 @@ [submodule "localForage"] path = localForage url = https://github.com/localForage/localForage -[submodule "bitmap-fonts"] - path = bitmap-fonts - url = https://github.com/Tecate/bitmap-fonts -[submodule "ibmfonts"] - path = ibmfonts - url = https://github.com/farsil/ibmfonts [submodule "jsnes"] path = jsnes url = https://github.com/sehugg/jsnes [submodule "bootstrap-tourist"] path = bootstrap-tourist url = https://github.com/IGreatlyDislikeJavascript/bootstrap-tourist +[submodule "nanoasm"] + path = nanoasm + url = https://github.com/sehugg/nanoasm diff --git a/Makefile b/Makefile index b10995d1..016d7630 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ TSC=./node_modules/typescript/bin/tsc all: + cp nanoasm/src/assembler.ts src/worker/ $(TSC) cd jsnes && npm i @@ -28,3 +29,6 @@ tsweb: ifconfig | grep inet $(TSC) -w & python3 scripts/serveit.py 2>> http.out + +astrolibre.b64.txt: astrolibre.rom + lzg -9 $< | base64 -w 0 > $@ diff --git a/README.md b/README.md index fd5d52b0..7963d03f 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ make tsweb ## Run tests ```sh -make test +npm test ``` ## Author @@ -66,5 +66,11 @@ Give a ⭐️ if this project helped you! Copyright © 2019 [Steven Hugg](https://github.com/sehugg).
This project is [GPL-3.0](https://github.com/sehugg/8bitworkshop/blob/master/LICENSE) licensed. +Dependencies retain their original licenses. + +All included code samples (all files under the presets/ directory) are licensed under +[CC0](https://creativecommons.org/publicdomain/zero/1.0/) +unless otherwise licensed. + *** _This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_ diff --git a/bitmap-fonts b/bitmap-fonts deleted file mode 160000 index 6f52a7ca..00000000 --- a/bitmap-fonts +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6f52a7ca0838967cc57e9a44d76c6e1f60e62842 diff --git a/bootstrap/js/bootbox.all.min.js b/bootstrap/js/bootbox.all.min.js new file mode 100644 index 00000000..feecd0a8 --- /dev/null +++ b/bootstrap/js/bootbox.all.min.js @@ -0,0 +1,6 @@ +/** + * bootbox.js 5.1.3 + * + * http://bootboxjs.com/license.txt + */ +!function(t,e){'use strict';'function'==typeof define&&define.amd?define(['jquery'],e):'object'==typeof exports?module.exports=e(require('jquery')):t.bootbox=e(t.jQuery)}(this,function e(p,u){'use strict';var r,n,i,l;Object.keys||(Object.keys=(r=Object.prototype.hasOwnProperty,n=!{toString:null}.propertyIsEnumerable('toString'),l=(i=['toString','toLocaleString','valueOf','hasOwnProperty','isPrototypeOf','propertyIsEnumerable','constructor']).length,function(t){if('function'!=typeof t&&('object'!=typeof t||null===t))throw new TypeError('Object.keys called on non-object');var e,o,a=[];for(e in t)r.call(t,e)&&a.push(e);if(n)for(o=0;o
",header:"
",footer:'',closeButton:'',form:'
',button:'',option:'',promptMessage:'
',inputs:{text:'',textarea:'',email:'',select:'',checkbox:'
',radio:'
',date:'',time:'',number:'',password:'',range:''}},m={locale:'en',backdrop:'static',animate:!0,className:null,closeButton:!0,show:!0,container:'body',value:'',inputType:'text',swapButtonOrder:!1,centerVertical:!1,multiple:!1,scrollable:!1};function c(t,e,o){return p.extend(!0,{},t,function(t,e){var o=t.length,a={};if(o<1||2').attr('label',e.group)),o=i[e.group]);var a=p(f.option);a.attr('value',e.value).text(e.text),o.append(a)}),O(i,function(t,e){n.append(e)}),n.val(r.value);break;case'checkbox':var l=p.isArray(r.value)?r.value:[r.value];if(!(a=r.inputOptions||[]).length)throw new Error('prompt with "inputType" set to "checkbox" requires at least one option');n=p('
'),O(a,function(t,o){if(o.value===u||o.text===u)throw new Error('each option needs a "value" property and a "text" property');var a=p(f.inputs[r.inputType]);a.find('input').attr('value',o.value),a.find('label').append('\n'+o.text),O(l,function(t,e){e===o.value&&a.find('input').prop('checked',!0)}),n.append(a)});break;case'radio':if(r.value!==u&&p.isArray(r.value))throw new Error('prompt with "inputType" set to "radio" requires a single, non-array value for "value"');if(!(a=r.inputOptions||[]).length)throw new Error('prompt with "inputType" set to "radio" requires at least one option');n=p('
');var s=!0;O(a,function(t,e){if(e.value===u||e.text===u)throw new Error('each option needs a "value" property and a "text" property');var o=p(f.inputs[r.inputType]);o.find('input').attr('value',e.value),o.find('label').append('\n'+e.text),r.value!==u&&e.value===r.value&&(o.find('input').prop('checked',!0),s=!1),n.append(o)}),s&&n.find('input[type="radio"]').first().prop('checked',!0)}if(t.append(n),t.on('submit',function(t){t.preventDefault(),t.stopPropagation(),e.find('.bootbox-accept').trigger('click')}),''!==p.trim(r.message)){var c=p(f.promptMessage).html(r.message);t.prepend(c),r.message=t}else r.message=t;return(e=d.dialog(r)).off('shown.bs.modal'),e.on('shown.bs.modal',function(){n.focus()}),!0===o&&e.modal('show'),e},d.addLocale('en',{OK:'OK',CANCEL:'Cancel',CONFIRM:'OK'}),d}); \ No newline at end of file diff --git a/cc65/.gitignore b/cc65/.gitignore deleted file mode 100644 index 6754d4ff..00000000 --- a/cc65/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.nes -*.o -*.s -*.lzg diff --git a/cc65/Makefile b/cc65/Makefile deleted file mode 100644 index 98639c63..00000000 --- a/cc65/Makefile +++ /dev/null @@ -1,25 +0,0 @@ - -CC65FLAGS=-I/home/hugg/compilers/cc65/include -I/home/hugg/compilers/cc65/include/nes -L/home/hugg/compilers/cc65/lib --cfg-path /home/hugg/compilers/cc65/cfg/ -v - -all: \ - default_neslib.neslib.nes default_conio.conio.nes \ - default_neslib.neslib.lzg default_conio.conio.lzg - -clean: - rm -f *.s *.o *.nes *.lzg - -#%.s: %.c -# cc65 $*.c -# ca65 $*.s - -%.neslib.nes: %.c - cl65 $(CC65FLAGS) -o $@ -t nes -C neslib.cfg $*.c neslib.lib nes.lib - -%.conio.nes: %.c - cl65 $(CC65FLAGS) -o $@ -t nes $*.c nes.lib - -%.rom: %.s - time ld65 -o $@ -C atarivec.cfg $*.o atari2600.lib - -%.lzg: %.nes - lzg $< | hexdump -v -e '"\n" 32/1 "%u,"' > $@ diff --git a/cc65/default_conio.c b/cc65/default_conio.c deleted file mode 100644 index 7b2721ff..00000000 --- a/cc65/default_conio.c +++ /dev/null @@ -1,43 +0,0 @@ - -#include "nes.h" - -unsigned char index; - -const unsigned char TEXT[]={"No cart loaded"}; - -const unsigned char PALETTE[]={0x1, 0x00, 0x10, 0x20}; //blue, gray, lt gray, white - -void main (void) { - - // turn off the screen - PPU.control = 0; - PPU.mask = 0; - - // load the palette - PPU.vram.address = 0x3f; - PPU.vram.address = 0x0; - for(index = 0; index < sizeof(PALETTE); ++index){ - PPU.vram.data = PALETTE[index]; - } - - // load the text - PPU.vram.address = 0x21; // set an address in the PPU of 0x21ca - PPU.vram.address = 0xc9; // about the middle of the screen - for( index = 0; index < sizeof(TEXT); ++index ){ - PPU.vram.data = TEXT[index]; - } - - // reset the scroll position - PPU.vram.address = 0x20; - PPU.vram.address = 0x0; - PPU.scroll = 0; - PPU.scroll = 0; - - // turn on screen - PPU.control = 0x80; // NMI on - PPU.mask = 0x1e; // screen on - - // infinite loop - while (1) { - } -} diff --git a/cc65/default_neslib.c b/cc65/default_neslib.c deleted file mode 100644 index d86f7ce0..00000000 --- a/cc65/default_neslib.c +++ /dev/null @@ -1,53 +0,0 @@ - -//this example code shows how to put some text in nametable - -#include "neslib.h" - -// tileset data - -const unsigned char TILESET[8*128] = {/*{w:8,h:8,bpp:1,count:128,brev:1}*/ -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x7c,0x7c,0x7c,0x38,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6c,0x6c,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6c,0xfe,0x6c,0xfe,0x6c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0xfe,0xd0,0xfe,0x16,0xfe,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xce,0xdc,0x38,0x76,0xe6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x6c,0x7c,0xec,0xee,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x70,0x70,0x70,0x70,0x70,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x38,0x38,0x38,0x38,0x38,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6c,0x38,0x6c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0xfe,0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x1e,0x3c,0x78,0xf0,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x7c,0xee,0xee,0xee,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x78,0x38,0x38,0x38,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x0e,0x7c,0xe0,0xee,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x0e,0x3c,0x0e,0x0e,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x7e,0xee,0xee,0xfe,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xe0,0xfc,0x0e,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xe0,0xfc,0xee,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xee,0x1c,0x1c,0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0x7c,0xee,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0xee,0x7e,0x0e,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x60,0x60,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x38,0x70,0x70,0x38,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x00,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x38,0x1c,0x1c,0x38,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0x1c,0x38,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x7c,0xee,0xee,0xee,0xe0,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0xee,0xee,0xfe,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xee,0xfc,0xee,0xee,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0xe0,0xe0,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xec,0xee,0xee,0xee,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xe0,0xf0,0xe0,0xe0,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xe0,0xf8,0xe0,0xe0,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xe0,0xee,0xee,0xee,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0xee,0xfe,0xee,0xee,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x38,0x38,0x38,0x38,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x0e,0x0e,0x0e,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0xfc,0xf8,0xec,0xee,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xe0,0xe0,0xe0,0xee,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc6,0xee,0xfe,0xfe,0xee,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xce,0xee,0xfe,0xfe,0xee,0xe6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0xee,0xee,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0xfc,0xee,0xee,0xee,0xfc,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xee,0xee,0xee,0xec,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xee,0xee,0xee,0xfc,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0xe0,0x7c,0x0e,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x38,0x38,0x38,0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0xee,0xee,0xee,0xee,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0xee,0xee,0x6c,0x38,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0xee,0xfe,0xfe,0xee,0xc6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0x7c,0x38,0x7c,0xee,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0xee,0xee,0x7c,0x38,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x1c,0x38,0x70,0xe0,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -}; - -//this macro is used remove need of calculation of the nametable address in runtime - -#define NTADR(x,y) ((0x2000|((y)<<5)|x)) - -//put a string into the nametable - -void put_str(unsigned int adr,const char *str) -{ - vram_adr(adr); - - while(1) - { - if(!*str) break; - vram_put((*str++)-0x20);//-0x20 because ASCII code 0x20 is placed in tile 0 of the CHR - } -} - -void main(void) -{ - //copy tileset to RAM - vram_write((unsigned char*)TILESET, 0x0, sizeof(TILESET)); - - //rendering is disabled at the startup, and palette is all black - pal_col(0,0x1); - pal_col(1,0x30);//set while color - - //you can't put data into vram through vram_put while rendering is enabled - //so you have to disable rendering to put things like text or a level map - //into the nametable - - //there is a way to update small number of nametable tiles while rendering - //is enabled, using set_vram_update and an update list - - put_str(NTADR(9,15),"NO CART LOADED"); - - ppu_on_all();//enable rendering - - while(1);//do nothing, infinite loop -} diff --git a/cc65/longbranch.mac b/cc65/longbranch.mac deleted file mode 100644 index d6f6cde8..00000000 --- a/cc65/longbranch.mac +++ /dev/null @@ -1,88 +0,0 @@ -.macro jeq Target - .if .match(Target, 0) - bne *+5 - jmp Target - .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127) - beq Target - .else - bne *+5 - jmp Target - .endif -.endmacro -.macro jne Target - .if .match(Target, 0) - beq *+5 - jmp Target - .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127) - bne Target - .else - beq *+5 - jmp Target - .endif -.endmacro -.macro jmi Target - .if .match(Target, 0) - bpl *+5 - jmp Target - .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127) - bmi Target - .else - bpl *+5 - jmp Target - .endif -.endmacro -.macro jpl Target - .if .match(Target, 0) - bmi *+5 - jmp Target - .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127) - bpl Target - .else - bmi *+5 - jmp Target - .endif -.endmacro -.macro jcs Target - .if .match(Target, 0) - bcc *+5 - jmp Target - .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127) - bcs Target - .else - bcc *+5 - jmp Target - .endif -.endmacro -.macro jcc Target - .if .match(Target, 0) - bcs *+5 - jmp Target - .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127) - bcc Target - .else - bcs *+5 - jmp Target - .endif -.endmacro -.macro jvs Target - .if .match(Target, 0) - bvc *+5 - jmp Target - .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127) - bvs Target - .else - bvc *+5 - jmp Target - .endif -.endmacro -.macro jvc Target - .if .match(Target, 0) - bvs *+5 - jmp Target - .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127) - bvc Target - .else - bvs *+5 - jmp Target - .endif -.endmacro diff --git a/cc65/neslib.h b/cc65/neslib.h deleted file mode 100644 index 5ba0493a..00000000 --- a/cc65/neslib.h +++ /dev/null @@ -1,226 +0,0 @@ -//NES hardware-dependent functions by Shiru (shiru@mail.ru) -//Feel free to do anything you want with this code, consider it Public Domain - - -//set bg and spr palettes, data is 32 bytes array - -void __fastcall__ pal_all(const char *data); - -//set bg palette only, data is 16 bytes array - -void __fastcall__ pal_bg(const char *data); - -//set spr palette only, data is 16 bytes array - -void __fastcall__ pal_spr(const char *data); - -//set a palette entry, index is 0..31 - -void __fastcall__ pal_col(unsigned char index,unsigned char color); - -//reset palette to $0f - -void __fastcall__ pal_clear(void); - -//set virtual bright, 0 is black, 4 is normal, 8 is white - -void __fastcall__ pal_bright(unsigned char bright); - - -//turn off rendering and nmi - -void __fastcall__ ppu_off(void); - -//turn on bg, spr, and nmi - -void __fastcall__ ppu_on_all(void); - -//turn on bg only and nmi - -void __fastcall__ ppu_on_bg(void); - -//turn on spr only and nmi - -void __fastcall__ ppu_on_spr(void); - -//set PPU_MASK directly - -;void __fastcall__ ppu_mask(unsigned char mask); - - - -//clear OAM buffer, all the sprites are hidden - -void __fastcall__ oam_clear(void); - -//set sprites size, 0 for 8x8, 1 for 8x16 - -void __fastcall__ oam_size(unsigned char size); - -//set sprite in OAM buffer, chrnum is tile, attr is attribute, sprid is offset in OAM in bytes -//returns sprid+4, which is offset for a next sprite - -unsigned char __fastcall__ oam_spr(unsigned char x,unsigned char y,unsigned char chrnum,unsigned char attr,unsigned char sprid); - -//set metasprite in OAM buffer -//meta sprite is a const unsigned char array, it contains four bytes per sprite -//in order x offset, y offset, tile, attribute -//x=128 is end of a meta sprite -//returns sprid+4, which is offset for a next sprite - -unsigned char __fastcall__ oam_meta_spr(unsigned char x,unsigned char y,unsigned char sprid,const unsigned char *data); - -//hide all the sprites starting from given offset - -void __fastcall__ oam_hide_rest(unsigned char sprid); - - - -//wait NMI and sync to 50hz (with frameskip for NTSC) - -void __fastcall__ ppu_waitnmi(void); - - - -//play a music in FamiTone format - -void __fastcall__ music_play(const unsigned char *data); - -//stop music - -void __fastcall__ music_stop(void); - -//pause and unpause music - -void __fastcall__ music_pause(unsigned char pause); - -//play FamiTone sound effect on channel 0..3 - -void __fastcall__ sfx_play(unsigned char sound,unsigned char channel); - - - -//poll controller and return flags like PAD_LEFT etc, input is pad number (0 or 1) - -unsigned char __fastcall__ pad_poll(unsigned char pad); - -//poll controller in trigger mode, a flag is set only on button down, not hold -//if you need to poll the pad in both normal and trigger mode, poll it in the -//trigger mode for first, then use pad_state - -unsigned char __fastcall__ pad_trigger(unsigned char pad); - -//get previous pad state without polling ports - -unsigned char __fastcall__ pad_state(unsigned char pad); - - -//set scroll, including top bits - -void __fastcall__ scroll(unsigned int x,unsigned int y); - - - -//select current chr bank for sprites, 0..1 - -void __fastcall__ bank_spr(unsigned char n); - -//select current chr bank for background, 0..1 - -void __fastcall__ bank_bg(unsigned char n); - - - -//returns random number 0..255 or 0..65535 - -unsigned char __fastcall__ rand8(void); -unsigned int __fastcall__ rand16(void); - -//set random seed - -void __fastcall__ set_rand(unsigned int seed); - - - -//set a pointer to update buffer, contents of the buffer is transferred to vram every frame -//buffer structure is MSB, LSB, byte to write, len is number of entries (not bytes) -//could be set during rendering, but only takes effect on a new frame -//number of transferred bytes is limited by vblank time - -void __fastcall__ set_vram_update(unsigned char len,unsigned char *buf); - -//set vram pointer to write operations if you need to write some data to vram -//works only when rendering is turned off - -void __fastcall__ vram_adr(unsigned int adr); - -//put a byte at current vram address, works only when rendering is turned off - -void __fastcall__ vram_put(unsigned char n); - -//fill a block with a byte at current vram address, works only when rendering is turned off - -void __fastcall__ vram_fill(unsigned char n,unsigned int len); - -//set vram autoincrement, 0 for +1 and not 0 for +32 - -void __fastcall__ vram_inc(unsigned char n); - -//read a block from vram, works only when rendering is turned off - -void __fastcall__ vram_read(unsigned char *dst,unsigned int adr,unsigned int size); - -//write a block to vram, works only when rendering is turned off - -void __fastcall__ vram_write(unsigned char *src,unsigned int adr,unsigned int size); - - -//unpack a nametable into vram - -void __fastcall__ unrle_vram(const unsigned char *data,unsigned int vram); - - - -//like a normal memcpy, but does not return anything - -void __fastcall__ memcpy(void *dst,void *src,unsigned int len); - -//like memset, but does not return anything - -void __fastcall__ memfill(void *dst,unsigned char value,unsigned int len); - -//delay for N frames - -void __fastcall__ delay(unsigned char frames); - -//initialize sound effects - -void __fastcall__ FamiToneSfxInit(void* src); - -void __fastcall__ FamiToneSfxInit(void* src); - - -#define PAD_A 0x01 -#define PAD_B 0x02 -#define PAD_SELECT 0x04 -#define PAD_START 0x08 -#define PAD_UP 0x10 -#define PAD_DOWN 0x20 -#define PAD_LEFT 0x40 -#define PAD_RIGHT 0x80 - -#define OAM_FLIP_V 0x80 -#define OAM_FLIP_H 0x40 -#define OAM_BEHIND 0x20 - -#define MAX(x1,x2) (x1 - -typedef unsigned char byte; -typedef signed char sbyte; -typedef unsigned short word; - -#define inline - -#define dvgram ((word*)0x1000) -#define _dvgstart (*((byte*)0x8840)) - -#define mathbox_sum (*((int*)0x8100)) -#define mathbox_arg1 (*((sbyte*)0x8102)) -#define mathbox_arg2 (*((sbyte*)0x8103)) -#define mathbox_go_mul (*((byte*)0x810f)) - -void start() { -/* -__asm - LD SP,#0x0 - DI -__endasm; -*/ -} - -int dvgwrofs; // write offset for DVG buffer - -inline word ___swapw(word j) { - return ((j << 8) | (j >> 8)); -} - -inline void dvgreset() { - dvgwrofs = 0; -} - -inline void dvgstart() { - _dvgstart = 0; -} - -void dvgwrite(word w) { - dvgram[dvgwrofs++] = w; -} - -inline void VCTR(int dx, int dy, byte bright) { - dvgwrite((dy & 0x1fff)); - dvgwrite(((bright & 7) << 13) | (dx & 0x1fff)); -} - -inline void SVEC(sbyte dx, sbyte dy, byte bright) { - dvgwrite(0x4000 | (dx & 0x1f) | ((bright&7)<<5) | ((dy & 0x1f)<<8)); -} - -inline void JSRL(word offset) { - dvgwrite(0xa000 | offset); -} - -inline void JMPL(word offset) { - dvgwrite(0xe000 | offset); -} - -inline void RTSL() { - dvgwrite(0xc000); -} - -inline void CNTR() { - dvgwrite(0x8000); -} - -inline void HALT() { - dvgwrite(0x2000); -} - -inline void STAT(byte rgb, byte intens) { - dvgwrite(0x6000 | ((intens & 0xf)<<4) | (rgb & 7)); -} - -inline void STAT_sparkle(byte intens) { - dvgwrite(0x6800 | ((intens & 0xf)<<4)); -} - -inline void SCAL(word scale) { - dvgwrite(0x7000 | scale); -} - -enum { - BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, YELLOW, WHITE -} Color; - -/// - -typedef struct { - sbyte m[3][3]; -} Matrix; - -typedef struct { - sbyte x,y,z; -} Vector8; - -typedef struct { - int x,y,z; -} Vector16; - -typedef struct { - byte numverts; - const Vector8* verts; // array of vertices - const sbyte* edges; // array of vertex indices (edges) -} Wireframe; - -void mat_identity(Matrix* m) { - memset(m, 0, sizeof(*m)); - m->m[0][0] = 127; - m->m[1][1] = 127; - m->m[2][2] = 127; -} - -inline void mul16(sbyte a, sbyte b) { - mathbox_arg1 = a; - mathbox_arg2 = b; - mathbox_go_mul=0; -} - -void vec_mat_transform(Vector16* dest, const Vector8* v, const Matrix* m) { - byte i; - int* result = &dest->x; - const sbyte* mval = &m->m[0][0]; - for (i=0; i<3; i++) { - mathbox_sum = 0; - mul16(*mval++, v->x); - mul16(*mval++, v->y); - mul16(*mval++, v->z); - *result++ = mathbox_sum; - } -} - -/* -void vec_mat_transform2(Vector16* dest, const Vector8* v, const Matrix* m) { - dest->x = v->x*m->m[0][0] + v->y*m->m[0][1] + v->z*m->m[0][2]; - dest->y = v->x*m->m[1][0] + v->y*m->m[1][1] + v->z*m->m[1][2]; - dest->z = v->x*m->m[2][0] + v->y*m->m[2][1] + v->z*m->m[2][2]; -} -*/ - -const sbyte sintbl[64] = { -0, 3, 6, 9, 12, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, -49, 51, 54, 57, 60, 63, 65, 68, 71, 73, 76, 78, 81, 83, 85, 88, -90, 92, 94, 96, 98, 100, 102, 104, 106, 107, 109, 111, 112, 113, 115, 116, -117, 118, 120, 121, 122, 122, 123, 124, 125, 125, 126, 126, 126, 127, 127, 127, -}; - -sbyte isin(byte x0) { - byte x = x0; - if (x0 & 0x40) x = 127-x; - if (x0 & 0x80) { - return -sintbl[x+128]; - } else { - return sintbl[x]; - } -} - -sbyte icos(byte x) { - return isin(x+64); -} - -void mat_rotate(Matrix* m, byte axis, byte angle) { - sbyte sin = isin(angle); - sbyte cos = icos(angle); - mat_identity(m); - switch (axis) { - case 0: - m->m[1][1] = cos; - m->m[2][1] = sin; - m->m[1][2] = -sin; - m->m[2][2] = cos; - break; - case 1: - m->m[2][2] = cos; - m->m[0][2] = sin; - m->m[2][0] = -sin; - m->m[0][0] = cos; - break; - case 2: - m->m[0][0] = cos; - m->m[1][0] = sin; - m->m[0][1] = -sin; - m->m[1][1] = cos; - break; - } -} - -const Vector8 tetra_v[] = { {0,-86,86},{86,86,86},{-86,86,86},{0,0,-86} }; -const signed char tetra_e[] = { 0, 1, 2, 0, 3, 1, -1, 3, 2, -2 }; -const Wireframe tetra = { 4, tetra_v, tetra_e }; - -void xform_vertices(Vector16* dest, const Vector8* src, const Matrix* m, byte nv) { - byte i; - for (i=0; iedges; - byte bright = 0; - int x1 = 0; - int y1 = 0; - Vector16 scrnverts[16]; - xform_vertices(scrnverts, wf->verts, m, wf->numverts); - do { - sbyte i = *e++; - if (i == -1) - bright = 0; - else if (i == -2) - break; - else { - int x2 = scrnverts[i].x>>8; - int y2 = scrnverts[i].y>>8; - VCTR(x2-x1, y2-y1, bright); - x1 = x2; - y1 = y2; - } - bright = 2; - } while (1); -} - -/// - -word frame; - -void main() { - int x,y; - Matrix m; - mat_identity(&m); - while (1) { - dvgreset(); - CNTR(); - SCAL(0x1f); - STAT(RED, 5); - x = isin(frame/8); - y = icos(frame/8); - VCTR(x, y, 2); - STAT(GREEN, 15); - mat_rotate(&m, (frame>>8)&3, frame); - draw_wireframe_ortho(&tetra, &m); - HALT(); - dvgstart(); - frame++; - } -} diff --git a/css/codemirror.css b/css/codemirror.css index b93fb015..55fde9f0 100644 --- a/css/codemirror.css +++ b/css/codemirror.css @@ -2,10 +2,9 @@ .CodeMirror { /* Set height, width, borders, and global font properties here */ - border: 1px solid #eee; font-family: "Andale Mono", "Menlo", "Lucida Console", monospace; font-size: 0.8em; - height: 96vh; + height: 94vh; } /* PADDING */ diff --git a/css/ui.css b/css/ui.css index 69b4588c..efaee3f5 100644 --- a/css/ui.css +++ b/css/ui.css @@ -49,8 +49,8 @@ background-color:#000066; } #controls_top { - position: absolute; - padding: 0.5em; + position:absolute; + padding:0.5em; height:3em; width:100%; background-color:#999; @@ -111,7 +111,7 @@ div.mem_info a.selected { text-align:right; } .btn_group { - border-radius:6px; + border-radius:8px; padding:8px; margin-left:8px; background-color: #666; @@ -223,6 +223,8 @@ a.dropdown-toggle { div.emulator { background-color: #666; margin-top: 20px auto 0; + display:flex; + flex-direction:column; } div.emuoverlay { display:flex; @@ -249,6 +251,10 @@ div.emuspacer { width:90%; pointer-events:auto; } +.emuvideo:focus { + outline:none; + border-color:#888; +} canvas.pixelated { image-rendering: optimizeSpeed; /* Older versions of FF */ image-rendering: -moz-crisp-edges; /* FF 6.0+ */ @@ -277,14 +283,15 @@ canvas.pixelated { font-family: TinyFont; src: url(04B_03__.TTF); } -#booksMenuButton { - border-width:3px; - border-color:#99ff99; - background-color:#006600; +.toolbarMenuButton { + background-color:#666; border-style:solid; - font-family: "Andale Mono", "Menlo", "Lucida Console", monospace; position:relative; - top:-0.25em; + margin-left:0.5em; + margin-right:0.5em; +} +a.toolbarMenuButton { + padding:0.3em; } a.dropdown-toggle { } @@ -516,3 +523,23 @@ div.asset_toolbar { padding:8px; margin:8px; } +.control-insns { + margin-top: auto; + margin-bottom: 2em; +} +.control-key { + border: 2px solid rgba(0,0,0,0.2); + border-radius: 0.6em; + padding: 0.2em; + padding-left: 0.5em; + padding-right: 0.5em; + background-color: #eee; + margin-left: 1em; + color: #666; +} +.control-def { + color: #ccc; +} +.book-title { + font-size:12pt; +} diff --git a/doc/notes.txt b/doc/notes.txt index 9f90de7c..7fdfde0d 100644 --- a/doc/notes.txt +++ b/doc/notes.txt @@ -6,14 +6,8 @@ TODO: - confuse code/data in listing - show memory locations hovering over lines - don't check against ROM signatures -- support 6502 test cases - DASM: macro forward refs - asm: support macro expansion -- support narrow screens -- case sensisitvity looking for mismatch variables -- remove pulldown when no preset? -- can't step after reset (or when funky frame; TIA frame is out of sync) -- break on BRK/illegal opcode? - multiple breakpoints, expression breakpoints - watchpoints - debug inspector for variables @@ -21,95 +15,96 @@ TODO: - step over (line, instruction) - slowdown beam for all platforms? - PC x86 support + - https://bellard.org/tcc/ - show errors in list (maybe window list?) -- can't see 1st line in editor sometimes (when scrolling cursor past bottom of screen) + - click to go to error + - what if error in include file you can't edit b/c it never appears? - online help - show self-modifying code insns left of editor -- facade/kbd shortcuts for emulators, focus - update Javatari version? (and others?) -- unify versioning -- disassembler for uploaded ROMs -- compile stuck when errors unchanged - sound mute? - $error updates source editor -- go to error in include files - online tools for music etc - text log debugging script -- NES crt should mark raster pos when debugging - intro/help text for each platform - vscode/atom extension? -- VCS asm library -- better VCS single stepping, maybe also listings -- VCS skips step on lsr/lsr after run to line -- error msg when #link doesn't work -- figure out folders for projects for real - click to break on raster position - restructure src/ folders - debug bankswitching for funky formats - spaces in filename don't parse code listing (DASM, maybe more) - 'undefined' for bitmap replacer -- astrocade: run to cursor in hello world messes up emulation - requestInterrupt needs to be disabled after breakpoint? -- C/asm formatter +- C/asm source formatter - fix WebAudio (https://news.ycombinator.com/item?id=18066474) - allow download of JSASM output - update bootstrap to 4.0 - batariBasic: proper line numbers, debugging - granular control over time scrubbing, show CPU state -- error showing replay div before rom starts -- compiler flags for final ROM build -- workermain: split build functions, better msg types -- vcs: INPTx needs to be added to control state -- sdcc: can't link asm files before c files (e.g. acheader.s must be last) -- what if >1 file with same name? (local/nonlocal/directory) -- what if .c and .s names collide? +- builds: + - compiler flags for final ROM build + - workermain: split build functions, better msg types + - what if >1 file with same name? (local/nonlocal/directory) + - what if .c and .s names collide? + - maybe put stuff in examples/ dir? + - error msg when #link doesn't work + - warning when ROM too big + - detect "libcv.h" and include library automagically? +- sdcc: + - can't link asm files before c files (e.g. acheader.s must be last) + - figure out area names ordering + - debug inline asm - live coding URL -- resize memory browser when vertical div resize -- preroll the emulator so optimizer does its thing before loading rom +- resize memory browser, other windows when vertical div resize +- preroll the Z80 emulator so optimizer does its thing before loading rom - wasm dynamic linking of emulators (https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md) -- use alternate confirm/prompt dialogs - https://github.com/jvilk/BrowserFS -- what if error in include file you can't edit b/c it never appears? - markdown, verilog: can't share - https://www.crowdsupply.com/tinyfpga/tinyfpga-bx -- HTTPS warning - stego shareable images (http://pico-8.wikia.com/wiki/P8PNGFileFormat) - https://makecode.com/language? - open ROM from URL? - game starts even if switched away before first load -- vcs: break on # of lines changed (maybe using getRasterPosition?) -- profiler restarts when paused - it's pretty easy to add a new file named like a library file (bcd.c) - or have neslib.h in a subdirectory... - put globals into view/controller objects - upload binary files doesn't do what's expected, changing pulldown and whatnot -- chrome autostart audio: https://github.com/processing/p5.js-sound/issues/249 -- firefox autostart audio: https://support.mozilla.org/en-US/kb/block-autoplay -- show player controls for each platform, allow touch support, navigator.getGamepads +- autostart audio + - chrome: https://github.com/processing/p5.js-sound/issues/249 + - firefox: https://support.mozilla.org/en-US/kb/block-autoplay +- touch support - better undo/diff for mistakes? - ide bug/feature visualizer for sponsors -- optimization flags for sdcc (oldralloc) - global undo/redo at checkpoints (when rom changes) -- pulldown shows wrong file if preset not present - landscape mode for arcade ports +- symmetric load/save state types - pixel editor - persist palette/tilemap selections - more tools for editing - map editor + - arbitrary nametable editing - metasprites - throw errors when bad/no refs - per-View keyboard shortcuts - parse labels - parse .incbin directives? - can't replace in hex directives + - should maybe use same single-canvas editor for map + char editor + - undo doesn't refresh editor + - editing sometimes messes up cursor movement (CURBS) - crt0.s compiled each time? - debug highlight doesn't go away when debugging -> running - show breakpoint of PC or highest address on stack - can we highlight line instead of select? -- replay doesn't work for nes (force background tile redraw) -- running profiler while replaying? grand unified replay? -- click on profiler to step to position - - breakpoints stop profiler from running +- profiler + - profiler restarts emulator when paused + - running profiler while replaying? grand unified replay? + - click on profiler to step to position + - breakpoints stop profiler from running + - single-screen profiler + - hide labels that aren't available, like BIOS addrs + - show interrupts, other events + - sometimes interleaves two different PCs? like two profilers running simultaneously? + - ah, symbols persist across builds - https://remotestoragejs.readthedocs.io/en/latest/getting-started/how-to-add.html ? - Verilog - larger scope range, better scrolling @@ -123,29 +118,66 @@ TODO: - toolbar overlaps scope - CPU debugging - use $readmem for inline asm programs? + - can't add control instructions b/c of split - single-stepping vector games makes screen fade -- break on stack overflow, bad op, bad access, etc -- PPU/TIA register write visualization -- nes debug view toolbar -- vcs sound continues when paused +- break on stack overflow, illegal op, bad access, BRK, etc +- nes + - replay doesn't work for nes (force background tile redraw) + - nes debug view toolbar + - support NES_HEADER_16K? + - PPU/TIA register write visualization + - show cur/tmp vram addresses + - NES crt should mark raster pos when debugging + - OAMDMA in profiler? (haltCycles) + - ca65 skeleton + - neslib.cfg nesbanked.cfg ZP segment is C64-ish, should use $00-$FF +- JSNES + - doesn't support hiding >8 sprites + - doesn't do sprite zero test right + - doesn't do clip right + - doesn't do b/w tint +- vcs + - vcs sound continues when paused + - vcs: INPTx needs to be added to control state + - vcs: break on # of lines changed (maybe using getRasterPosition?) + - chrome looks blurry on vcs + - VCS asm game library + - VCS skips step on lsr/lsr after run to line + - better VCS single stepping, maybe also listings - upload multiple files/zip file to subdirectory - allow "include graphics.asm" instead of "include project/graphics.asm" -- chrome looks blurry on vcs - convert more stuff to Promises +- target ES6 - don't have to include bootstrap-tourist each time? - don't have to include firebase always? + - squelch error msgs? + - test offline? (if window.firebase) - Github + - platform_id/repo.platform mismatch (can't leave repository) - gh-pages branch with embedded - handle overwrite logic - - test edge/failure cases - what to do about included files? - - what if files already open in editor - - un-bind from repo? - can published files retain path? - what if import interrupted and partial files? - CORS for some blobs? - - confusing when examples load if file not found - don't import useless files + - support projects with subdirectories, file list? + - emulator needs reset shortcut for nes + - switching platform of a repo? + - make sure to flatten subdirs +- astrocade +- keyboard shortcuts + - ctrl+alt+l on ubuntu locks screen + - alt-D doesn't work anymore + - facade/kbd shortcuts for emulators, focus +- cookie + - list of stuff for policy + - popup +- convert binary to hex stmts +- "suggestions" (vblank overrun, variable # scanlines, etc) +- SMS + - can't step back twice? + - compiler bug in chase WEB WORKER FORMAT @@ -281,3 +313,43 @@ Pull Push Git metadata kept in local storage + +Converting from NESASM to DASM +- asl a -> asl +- subroutine keyword on labels +- [zp],y to (zp),y +- LOW(x) and HIGH(x) to <() and >() +- .db to .byte, .dw to .word +- use NES_HEADER macros +- no .bank + +Cross platform NES/SMS/GG library +- use CHR RAM + - create flipped tiles/sprites + - create alternate palette tiles +- metatiles +- cross platform music/sound +- scrolling + - row/column mask + - no nametable mirroring in SMS + - 256x240 vs 256x192 + +Emulator Lib +- move getPresets() (into presets/ dir?) +- CPU interface + - execCycle(), execInsn() + - fix/unfix PC + - interrupt +- generic raster scanline platform +- PlatformRunner + - handles rewind, intra-frame breakpoint, debugging + - profiling log, exec/read/write/intr (for each bus?) +- expose video, audio, controller interfaces +- new debugging info +- memory map interface +- "About" metadata +- auto load/save state? +- handle legacy + - VCS + - NES + - MAME diff --git a/doc/platforms.md b/doc/platforms.md new file mode 100644 index 00000000..5e8bd709 --- /dev/null +++ b/doc/platforms.md @@ -0,0 +1,265 @@ + +class Platform +-------------- + +Mandatory functions: +~~~ + start() : void; + reset() : void; + isRunning() : boolean; + pause() : void; + resume() : void; + loadROM(title:string, rom:any); +~~~ + +These are for the compiler/editor: +~~~ + getToolForFilename(s:string) : string; + getDefaultExtension() : string; + getPresets() : Preset[]; +~~~ + +Most platforms have these: +~~~ + loadState?(state : EmuState) : void; + saveState?() : EmuState; +~~~ + +... etc + + +6502 +---- + +`advance()` advances one frame. +The basic idea: iterate through all the scanlines, run a bunch of CPU cycles per scanline. +If we hit a breakpoint, exit the loop. + +~~~ + var debugCond = this.getDebugCallback(); + for (var sl=0; sl<262; sl++) { + for (var i=0; i { + }, + onAudioSample: (left:number, right:number) => { + }, + onStatusUpdate: function(s) { + }, + }); +~~~ + +We monkey-patch the code to add a debugging hook: + +~~~ + // insert debug hook + this.nes.cpu._emulate = this.nes.cpu.emulate; + this.nes.cpu.emulate = () => { + var cycles = this.nes.cpu._emulate(); + this.evalDebugCondition(); + return cycles; + } +~~~ + +NES was the first platform with an "illegal opcode" hard stop, so we added a special `EmuHalt` exception which causes a breakpoint: + +~~~ + this.nes.stop = () => { + console.log(this.nes.cpu.toJSON()); + throw new EmuHalt("CPU STOPPED @ PC $" + hex(this.nes.cpu.REG_PC)); + }; +~~~ + + +MAME +---- + +The `BaseMAMEPlatform` class implements a MAME platform. +You just have to pass it various parameters when starting, and tell it how to load the ROM file: + +~~~ +class ColecoVisionMAMEPlatform extends BaseMAMEPlatform implements Platform { + + start() { + this.startModule(this.mainElement, { + jsfile: 'mamecoleco.js', + cfgfile: 'coleco.cfg', + biosfile: 'coleco/313 10031-4005 73108a.u2', + driver: 'coleco', + width: 280 * 2, + height: 216 * 2, + romfn: '/emulator/cart.rom', + romsize: 0x8000, + preInit: function(_self) { + }, + }); + } + + loadROM(title, data) { + this.loadROMFile(data); + this.loadRegion(":coleco_cart:rom", data); + } + + getPresets() { return ColecoVision_PRESETS; } + getToolForFilename = getToolForFilename_z80; + getDefaultExtension() { return ".c"; }; +} +~~~ + +A lot of things are done via Lua scripting -- for example, loading a ROM requires we loop over the memory region and issue `rgn:write_u32` calls. +It kinda-sorta works, except debugging isn't reliable because MAME [doesn't return from the event loop](https://github.com/mamedev/mame/issues/3649) at breakpoints. + +MAME platforms don't have state load/save either. + + +Verilog +-------- + +The Verilog platform is the odd one out, since it has no fixed CPU as such. +The `loadROM` function instead loads a JavaScript function. +Some platforms do have a ROM if using assembly, so we load that into a Verilog array. +It's quite the hack, and it could be better. + +Verilog has its own debugger, logging signals in a fixed-size buffer. + + + +Profiling +---------- + +`EmuProfilerImpl` runs the profiler. +When started, it calls `setBreakpoint` to add a profiler-specific breakpoint that never hits, just records the CPU state at each clock. +It uses `getRasterScanline` to associate IPs with scanlines. +Platforms can also log their own reads, writes, interrupts, etc. + + +Future Ideas +------------ + +There should be a standard CPU interface, buses, memory map. +More like MAME configuration. + +Platforms might have different ideas of "clock" (CPU clock, pixel clock, 1 clock per instruction, etc) + +The goal is to rewind and advance to any clock cycle within a frame, and get complete introspection of events, without hurting performance. + +Unify raster platforms, they should all allow the same debugging and CPU interfaces. + +Separate UI/sim parts of platform? +A lot of platforms write into a uint32 buffer. +We might want to buffer audio the same way. +Also some way to log events, and handle input. + +Figure out how to make platform-specific type for load/save state. +(generics?) + +Separate emulators from 8bitworkshop IDE. + +Can we use WASM emulators without JS interop penalty? +Maybe using [AssemblyScript](https://docs.assemblyscript.org/)? +Startup would be faster, probably runtime too. +Drawback is that dynamic stuff (custom breakpoint functions, profiling) might be slow, slower dev too maybe. +Need proof-of-concept. diff --git a/embed.html b/embed.html index acacb1f9..e2036c3a 100644 --- a/embed.html +++ b/embed.html @@ -13,8 +13,11 @@ align-items: center; justify-content: center; } +#emuscreen { + flex-grow: 1; +} .emuvideo { - height:80%; + width:90%; border-radius:20px; border: 4px solid #222; outline-color: #666; @@ -35,6 +38,9 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
+ +
+
+
+
-
+
+ +
+
+ + + + + + + + +
@@ -244,7 +331,7 @@ if (window.location.host.endsWith('8bitworkshop.com')) {