diff --git a/Makefile b/Makefile index 569fb0b..a076ddf 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,8 @@ ifeq ($(PLATFORM), emscripten) LDFLAGS += -s USE_SDL=2\ -s ASYNCIFY \ -s ALLOW_MEMORY_GROWTH=1 \ - --preload-file test/paint.rom@paint.rom + --preload-file test/paint.rom@paint.rom \ + --shell-file $(ARCH_DIR)/shell_minimal.html # For release: optimize, strip debug, minimize size ifeq ($(BUILD_MODE), release) diff --git a/src/arch/emscripten/main.c b/src/arch/emscripten/main.c index 4b93d85..eb80c82 100644 --- a/src/arch/emscripten/main.c +++ b/src/arch/emscripten/main.c @@ -31,94 +31,6 @@ static DeviceOps console_device_ops = { static ScreenDeviceData screen_data = {0}; static MouseDeviceData mouse_data = {0}; -const char *opcode_to_string(Opcode op) { - static const char *names[] = {[OP_HALT] = "halt", - [OP_JMP] = "jump", - [OP_JMPF] = "jump-if-flag", - [OP_CALL] = "call", - [OP_RETURN] = "return", - [OP_LOAD_IMM] = "load-immediate", - [OP_GET_8] = "get-8", - [OP_GET_16] = "get-16", - [OP_GET_32] = "get", - [OP_LOAD_8] = "load-8", - [OP_LOAD_16] = "load-16", - [OP_LOAD_32] = "load", - [OP_STORE_8] = "store-8", - [OP_STORE_16] = "store-16", - [OP_STORE_32] = "store", - [OP_PUT_8] = "put-8", - [OP_PUT_16] = "put-16", - [OP_PUT_32] = "put", - [OP_MALLOC] = "malloc", - [OP_MEMSET_8] = "memset-8", - [OP_MEMSET_16] = "memset-16", - [OP_MEMSET_32] = "memset-32", - [OP_PUSH] = "push", - [OP_POP] = "pop", - [OP_REG_MOV] = "register-move", - [OP_SYSCALL] = "syscall", - [OP_SLL] = "bit-shift-left", - [OP_SRL] = "bit-shift-right", - [OP_SRE] = "bit-shift-re", - [OP_BAND] = "bit-and", - [OP_BOR] = "bit-or", - [OP_BXOR] = "bit-xor", - [OP_ADD_INT] = "add-int", - [OP_SUB_INT] = "sub-int", - [OP_MUL_INT] = "mul-int", - [OP_DIV_INT] = "div-int", - [OP_ADD_UINT] = "add-nat", - [OP_SUB_UINT] = "sub-nat", - [OP_MUL_UINT] = "mul-nat", - [OP_DIV_UINT] = "div-nat", - [OP_ADD_REAL] = "add-real", - [OP_SUB_REAL] = "sub-real", - [OP_MUL_REAL] = "mul-real", - [OP_DIV_REAL] = "div-real", - [OP_INT_TO_REAL] = "int-to-real", - [OP_UINT_TO_REAL] = "nat-to-real", - [OP_REAL_TO_INT] = "real-to-int", - [OP_REAL_TO_UINT] = "real-to-nat", - [OP_JEQ_INT] = "jump-eq-int", - [OP_JNEQ_INT] = "jump-neq-int", - [OP_JGT_INT] = "jump-gt-int", - [OP_JLT_INT] = "jump-lt-int", - [OP_JLE_INT] = "jump-le-int", - [OP_JGE_INT] = "jump-ge-int", - [OP_JEQ_UINT] = "jump-eq-nat", - [OP_JNEQ_UINT] = "jump-neq-nat", - [OP_JGT_UINT] = "jump-gt-nat", - [OP_JLT_UINT] = "jump-lt-nat", - [OP_JLE_UINT] = "jump-le-nat", - [OP_JGE_UINT] = "jump-ge-nat", - [OP_JEQ_REAL] = "jump-eq-real", - [OP_JNEQ_REAL] = "jump-neq-real", - [OP_JGE_REAL] = "jump-ge-real", - [OP_JGT_REAL] = "jump-gt-real", - [OP_JLT_REAL] = "jump-lt-real", - [OP_JLE_REAL] = "jump-le-real", - [OP_STRLEN] = "string-length", - [OP_STREQ] = "string-eq", - [OP_STRCAT] = "string-concat", - [OP_STR_GET_CHAR] = "string-get-char", - [OP_STR_FIND_CHAR] = "string-find-char", - [OP_STR_SLICE] = "string-slice", - [OP_INT_TO_STRING] = "int-to-string", - [OP_UINT_TO_STRING] = "nat-to-string", - [OP_REAL_TO_STRING] = "real-to-string", - [OP_STRING_TO_INT] = "string-to-int", - [OP_STRING_TO_UINT] = "string-to-nat", - [OP_STRING_TO_REAL] = "string-to-real"}; - - if (op < 0 || op >= (int)(sizeof(names) / sizeof(names[0]))) { - return ""; - } - - const char *name = names[op]; - return name ? name : ""; -} - void mainloop() { SDL_Event event; SDL_PumpEvents(); @@ -181,7 +93,6 @@ void mainloop() { int cycles_this_frame = 0; int max_cycles_per_frame = 1000; // Adjust this value while (cycles_this_frame < max_cycles_per_frame) { - // printf("%s\n", opcode_to_string(vm.code[vm.pc])); // REMOVE THIS LINE if (!step_vm(&vm)) { emscripten_cancel_main_loop(); return; diff --git a/src/arch/emscripten/shell_minimal.html b/src/arch/emscripten/shell_minimal.html new file mode 100644 index 0000000..988746e --- /dev/null +++ b/src/arch/emscripten/shell_minimal.html @@ -0,0 +1,141 @@ + + + + + + Emscripten-Generated Code + + + +
+
emscripten
+
Downloading...
+
+ +
+
+ +
+
+
+ Resize canvas + Lock/hide mouse pointer +     + +
+ +
+ +
+ + {{{ SCRIPT }}} + + \ No newline at end of file