1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-05-28 23:41:32 +00:00

new cc65 version; move to WASM

This commit is contained in:
Steven Hugg 2019-03-14 11:20:50 -04:00
parent 98ccf2b26a
commit 7f6f5cdce4
16 changed files with 109 additions and 165 deletions

View File

@ -16,8 +16,7 @@ TODO:
- break on BRK/illegal opcode? - break on BRK/illegal opcode?
- multiple breakpoints, expression breakpoints - multiple breakpoints, expression breakpoints
- watchpoints - watchpoints
- breakpoints - debug inspector for variables
- debug inspector
- MAME single step (?) - MAME single step (?)
- step over (line, instruction) - step over (line, instruction)
- slowdown beam for all platforms? - slowdown beam for all platforms?
@ -39,13 +38,12 @@ TODO:
- online tools for music etc - online tools for music etc
- text log debugging script - text log debugging script
- NES crt should mark raster pos when debugging - NES crt should mark raster pos when debugging
- intro/help text for each platform (+ memory map) - intro/help text for each platform
- vscode/atom extension? - vscode/atom extension?
- navigator.getGamepads - navigator.getGamepads
- VCS library - VCS asm library
- better VCS single stepping, maybe also listings - better VCS single stepping, maybe also listings
- VCS skips step on lsr/lsr after run to line - VCS skips step on lsr/lsr after run to line
- bring back the profiler!
- links to external tools in ide - links to external tools in ide
- error msg when #link doesn't work - error msg when #link doesn't work
- figure out folders for projects for real - figure out folders for projects for real
@ -55,7 +53,6 @@ TODO:
- quantify verilog "graph iterations" - quantify verilog "graph iterations"
- debug bankswitching for funky formats - debug bankswitching for funky formats
- spaces in filename don't parse code listing (DASM, maybe more) - spaces in filename don't parse code listing (DASM, maybe more)
- zmac: item_lookup needs better hash function
- 'undefined' for bitmap replacer - 'undefined' for bitmap replacer
- astrocade: run to cursor in hello world messes up emulation - astrocade: run to cursor in hello world messes up emulation
- requestInterrupt needs to be disabled after breakpoint? - requestInterrupt needs to be disabled after breakpoint?
@ -73,13 +70,11 @@ TODO:
- compiler flags for final ROM build - compiler flags for final ROM build
- workermain: split build functions, better msg types - workermain: split build functions, better msg types
- vcs: INPTx needs to be added to control state - vcs: INPTx needs to be added to control state
- rename, delete, save as
- sdcc: can't link asm files before c files (e.g. acheader.s must be last) - 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 >1 file with same name? (local/nonlocal/directory)
- what if .c and .s names collide? - what if .c and .s names collide?
- live coding URL - live coding URL
- memory viewer: ROM/RAM/VRAM/etc - resize memory browser when vertical div resize
- resize memory browser when split resize (any div resize)
- preroll the emulator so optimizer does its thing before loading rom - preroll the emulator so optimizer does its thing before loading rom
- wasm dynamic linking of emulators (https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md) - wasm dynamic linking of emulators (https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md)
- use alternate confirm/prompt dialogs - use alternate confirm/prompt dialogs
@ -94,8 +89,6 @@ TODO:
- https://makecode.com/language? - https://makecode.com/language?
- show .map file in listings? memory map view? - show .map file in listings? memory map view?
- open ROM from URL? - open ROM from URL?
- NES: disassembly not aligned on PC
- NES: vrambuf.c for Solarian
- game starts even if switched away before first load - game starts even if switched away before first load
- vcs: break on # of lines changed (maybe using getRasterPosition?) - vcs: break on # of lines changed (maybe using getRasterPosition?)
- profiler restarts when paused - profiler restarts when paused

View File

@ -1,9 +1,10 @@
# Emscripten target (see https://github.com/apiaryio/emscripten-docker)
DOCKEREMCC=docker run --rm -v $(shell pwd):/src -e USERID=$(shell id -u) -t apiaryio/emcc CC=emcc
%.js: bin/%.bc all: js/cc65.js js/ca65.js js/ld65.js
$(DOCKEREMCC) emcc -O2 --memory-init-file 0 \
js/%.js: bin/%.bc
emcc -O2 --memory-init-file 0 \
-s ASM_JS=1 \ -s ASM_JS=1 \
-s MODULARIZE=1 \ -s MODULARIZE=1 \
-s EXPORT_NAME=\"'$*'\" \ -s EXPORT_NAME=\"'$*'\" \
@ -13,13 +14,32 @@ DOCKEREMCC=docker run --rm -v $(shell pwd):/src -e USERID=$(shell id -u) -t apia
bin/%.bc: bin/%.bc:
mkdir -p bin js mkdir -p bin js
$(DOCKEREMCC) emmake make $* emmake make $* CC=emcc
cp bin/$*.exe bin/$*.bc cp bin/$*.exe bin/$*.bc
emscripten: include asminc cfg lib/apple2.lib target/apple2 FILE_PACKAGER=python $(EMSCRIPTEN)/tools/file_packager.py
cp -rp src Makefile js
make -C js cc65.js ca65.js co65.js ld65.js fs65-all.js:
$(DOCKEREMCC) \ python $(EMSCRIPTEN)/tools/file_packager.py fs65.data \
python /emscripten/tools/file_packager.py fs65.data \ --preload include asminc cfg lib target \
--preload include asminc cfg lib/apple2.lib target/apple2 \ neslib/nes.cfg@cfg/neslib.cfg \
--separate-metadata --js-output=fs65.js neslib/neslib.lib@lib/neslib.lib \
neslib/neslib.h@include/neslib.h \
--separate-metadata --js-output=fs65.js
fs65-nes.js:
$(FILE_PACKAGER) fs65-nes.data --separate-metadata --js-output=$@ \
--preload include asminc cfg/nes* lib/nes* target/nes* \
neslib/nes.cfg@cfg/neslib.cfg \
neslib/neslib.lib@lib/neslib.lib \
neslib/neslib.h@include/neslib.h \
fs65-atari8.js:
$(FILE_PACKAGER) fs65-atari8.data --separate-metadata --js-output=$@ \
--preload include asminc cfg/atari* lib/atari* target/atari*
fs65-%.js:
$(FILE_PACKAGER) fs65-$*.data --separate-metadata --js-output=$@ \
--preload include asminc cfg/$** lib/$** target/$**
filesystems: fs65-nes.js fs65-apple2.js fs65-c64.js fs65-atari8.js

View File

@ -1,3 +1,14 @@
CC65LIB=../../src/worker/lib/nes/
NESLIB=$(HOME)/compilers/cc65/neslib/
shoot2: shoot2.c neslib.h
cl65 -tnes -O -o $@ -l $@.lst vrambuf.c bcd.c apu.c shoot2.c -lnes -lneslib $(CC65LIB)/crt0.o -L$(CC65LIB) -C$(NESLIB)/nes.cfg\
-Wl -DNES_MIRRORING=1 -Wl -DNES_PRG_BANKS=2 -Wl -DNES_CHR_BANKS=0 -Wl -DNES_MAPPER=2
conio: conio.c
cl65 -l conio.lst -tnes -O $<
test.rom: ex2.asm nesdefs.asm nesppu.asm test.rom: ex2.asm nesdefs.asm nesppu.asm
dasm ex2.asm dasm ex2.asm

View File

@ -429,15 +429,9 @@ void return_attacker(register AttackingEnemy* a) {
} }
} }
#pragma bss-name (push,"ZEROPAGE")
#pragma data-name (push,"ZEROPAGE")
int sincos;
#pragma data-name(pop)
#pragma bss-name (pop)
void fly_attacker(register AttackingEnemy* a) { void fly_attacker(register AttackingEnemy* a) {
#if 1 #ifdef USE_FASTLUT
//register int sincos; static int sincos;
sincos = FASTLUT16(sincos, SINTBL2, a->dir&31); sincos = FASTLUT16(sincos, SINTBL2, a->dir&31);
a->x += sincos; a->x += sincos;
sincos = FASTLUT16(sincos, SINTBL2, (a->dir+8)&31); sincos = FASTLUT16(sincos, SINTBL2, (a->dir+8)&31);
@ -766,6 +760,10 @@ void play_round() {
} }
} }
// turn off aggressive inlining to save a few bytes
// functions after this point aren't called often
#pragma codesize(100)
void set_shifted_pattern(const byte* src, word dest, byte shift) { void set_shifted_pattern(const byte* src, word dest, byte shift) {
static byte buf[16*3]; static byte buf[16*3];
byte y; byte y;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -474,7 +474,7 @@ function loadWASM(modulename:string, debug?:boolean) {
xhr.send(null); xhr.send(null);
if (xhr.response) { if (xhr.response) {
wasmBlob[modulename] = new Uint8Array(xhr.response); wasmBlob[modulename] = new Uint8Array(xhr.response);
console.log("Loaded " + modulename + ".wasm"); console.log("Loaded " + modulename + ".wasm (" + wasmBlob[modulename].length + " bytes)");
loaded[modulename] = 1; loaded[modulename] = 1;
} else { } else {
throw Error("Could not load WASM file " + modulename + ".wasm"); throw Error("Could not load WASM file " + modulename + ".wasm");
@ -1022,7 +1022,7 @@ function fixParamsWithDefines(path:string, params){
} }
function compileCC65(step:BuildStep) { function compileCC65(step:BuildStep) {
load("cc65"); loadNative("cc65");
var params = step.params; var params = step.params;
// stderr // stderr
var re_err1 = /.*?[(](\d+)[)].*?: (.+)/; var re_err1 = /.*?[(](\d+)[)].*?: (.+)/;
@ -1043,6 +1043,7 @@ function compileCC65(step:BuildStep) {
var destpath = step.prefix + '.s'; var destpath = step.prefix + '.s';
if (staleFiles(step, [destpath])) { if (staleFiles(step, [destpath])) {
var CC65 = emglobal.cc65({ var CC65 = emglobal.cc65({
instantiateWasm: moduleInstFn('cc65'),
noInitialRun:true, noInitialRun:true,
//logReadFiles:true, //logReadFiles:true,
print:print_fn, print:print_fn,
@ -1053,7 +1054,7 @@ function compileCC65(step:BuildStep) {
populateFiles(step, FS); populateFiles(step, FS);
fixParamsWithDefines(step.path, params); fixParamsWithDefines(step.path, params);
execMain(step, CC65, ['-T', '-g', execMain(step, CC65, ['-T', '-g',
'-Oirs', '-Oirs', // don't inline CodeSizeFactor 200? (no -Oi)
'-Cl', // static locals '-Cl', // static locals
'-I', '/share/include', '-I', '/share/include',
'-D' + params.define, '-D' + params.define,

2
tss

@ -1 +1 @@
Subproject commit d630ddcb29d74a178cde043d74188fac35d6a21f Subproject commit 61a1691a1de05dca3b694bf603db49ffbaf572cf