From 975313b4aa1869a72ad8f89d897d12f6e8507ac2 Mon Sep 17 00:00:00 2001 From: michuNEEO Date: Mon, 11 May 2020 21:01:46 +0200 Subject: [PATCH 01/10] pause game as long as P is pressed --- wasm/engine.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wasm/engine.go b/wasm/engine.go index 1df3c27..e954122 100644 --- a/wasm/engine.go +++ b/wasm/engine.go @@ -38,6 +38,10 @@ func (engine *Engine) initGame(memlist []byte, bankFilesMap map[int][]byte) { } func (engine *Engine) mainLoop() { + if engine.keyMap[anotherworld.KeyPause] == true { + logger.Debug("PAUSED") + return + } engine.app.MainLoop(engine.counter) engine.counter += 1 } From f9a856194a5ce49858a13950b2d383e26d412e07 Mon Sep 17 00:00:00 2001 From: michuNEEO Date: Mon, 11 May 2020 21:49:13 +0200 Subject: [PATCH 02/10] add option to load specific game part --- wasm/index.html | 21 +++++++++++++++++++++ wasm/js-api.go | 3 +-- wasm/main.go | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/wasm/index.html b/wasm/index.html index ea1af0e..d304d27 100644 --- a/wasm/index.html +++ b/wasm/index.html @@ -17,6 +17,16 @@ text-align: center; font-family: "Monaco", "Andale Mono", "Lucida Console", "FreeMono", monospace; } + #badge { + color: #fff; + background-color: #000; + display: inline-block; + padding: .25em .4em; + line-height: 1; + border-radius: .25rem; + font-weight: 700; + text-decoration: none; + } #gotherworld { width: 960px; height: 600px; @@ -32,6 +42,17 @@

Gother World

+

+ Load Game part + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 +

diff --git a/wasm/js-api.go b/wasm/js-api.go index 04ccf8c..2c41d45 100644 --- a/wasm/js-api.go +++ b/wasm/js-api.go @@ -74,7 +74,6 @@ func startGameFromPartWrapper(engine *Engine, inputs []js.Value) { js.Global().Call("requestAnimationFrame", renderFrame) } -//TODO move to hal-wasm func handleKeyEventWrapper(engine *Engine, inputs []js.Value) { if len(inputs) != 3 { logger.Error("Ignoring incomplete key event", inputs) @@ -109,7 +108,7 @@ func parseGamePartOffset(gamePartOffset js.Value) int { } parsedOffset := gamePartOffset.Int() if parsedOffset >= minStartPartOffset && parsedOffset <= maxStartPartOffset { - logger.Info("Parsed gamePartOffset %v", gamePartOffset) + logger.Info("Parsed gamePartOffset %d", parsedOffset) return parsedOffset } logger.Error("Out of range gamePart offset %v, using default.", parsedOffset) diff --git a/wasm/main.go b/wasm/main.go index 325cc41..b74f7f5 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -13,5 +13,6 @@ func init() { func main() { engine := buildEngine() RegisterCallbacks(&engine) + logger.Info("Registered Callbacks") <-engine.shutdownChannel } From f2a5c447466ab50950c2a86e3752ac57d05935db Mon Sep 17 00:00:00 2001 From: michuNEEO Date: Mon, 11 May 2020 22:17:37 +0200 Subject: [PATCH 03/10] less spam --- anotherworld/assets.go | 2 +- anotherworld/video.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/anotherworld/assets.go b/anotherworld/assets.go index 27fda69..308de17 100644 --- a/anotherworld/assets.go +++ b/anotherworld/assets.go @@ -33,7 +33,7 @@ func (assets StaticGameAssets) LoadEntryFromBank(index int) []uint8 { //LoadResource return a resource func (assets *StaticGameAssets) LoadResource(id int) { if len(assets.LoadedResources[id]) > 0 { - logger.Info("resource [%d] already loaded", id) + logger.Debug("resource [%d] already loaded", id) return } assets.LoadedResources[id] = assets.LoadEntryFromBank(id) diff --git a/anotherworld/video.go b/anotherworld/video.go index 8d9e74b..983fa8f 100644 --- a/anotherworld/video.go +++ b/anotherworld/video.go @@ -273,7 +273,7 @@ func (video *Video) PlaySound(resNum, freq, vol, channel int) { return } - logger.Info("playSound resNum %d", resNum) + logger.Debug("playSound resNum %d", resNum) video.Hal.PlaySound(resNum, freq, vol, channel) } From d07861f5ced8a1bb233ab7e373b1f242c9052989 Mon Sep 17 00:00:00 2001 From: michuNEEO Date: Mon, 11 May 2020 22:25:35 +0200 Subject: [PATCH 04/10] add exit app link --- wasm/index.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wasm/index.html b/wasm/index.html index d304d27..2530f73 100644 --- a/wasm/index.html +++ b/wasm/index.html @@ -43,7 +43,7 @@

Gother World

- Load Game part + Load Game Part 0 1 2 @@ -52,6 +52,10 @@

5 6 7 + + // + EXIT +

From 3acd06348b9fb8b161b601425d12401d810bbbfc Mon Sep 17 00:00:00 2001 From: michuNEEO Date: Mon, 11 May 2020 22:33:48 +0200 Subject: [PATCH 05/10] wire log output functions to ui --- wasm/index.html | 11 +++++++++-- wasm/main.go | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/wasm/index.html b/wasm/index.html index 2530f73..655b221 100644 --- a/wasm/index.html +++ b/wasm/index.html @@ -21,7 +21,7 @@ color: #fff; background-color: #000; display: inline-block; - padding: .25em .4em; + padding: .25em .3em; line-height: 1; border-radius: .25rem; font-weight: 700; @@ -54,7 +54,14 @@

7 // - EXIT + STOP + + // LOG + DEBUG + INFO + WARN + ERROR + FATAL

diff --git a/wasm/main.go b/wasm/main.go index b74f7f5..5cf7cae 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -5,8 +5,8 @@ import ( ) func init() { - logger.SetLogLevel(logger.LEVEL_INFO) logger.DisableColors() + logger.SetLogLevel(logger.LEVEL_INFO) logger.Info("WASM Gother-World initializing...") } From 5434c037ca88da8669f414bc5b0e5ba0e6e9c587 Mon Sep 17 00:00:00 2001 From: michuNEEO Date: Mon, 11 May 2020 22:46:01 +0200 Subject: [PATCH 06/10] clean it! --- wasm/js-canvas.go | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/wasm/js-canvas.go b/wasm/js-canvas.go index e5f65a3..c8f66d5 100644 --- a/wasm/js-canvas.go +++ b/wasm/js-canvas.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "syscall/js" "github.com/neophob/ganother-world/anotherworld" @@ -20,22 +19,6 @@ func GetCanvas(domElementId string) Canvas { } } -func (c Canvas) SetColor(color anotherworld.Color) { - c.context2d.Set("fillStyle", fmt.Sprintf("rgb(%d, %d, %d)", color.R, color.G, color.B)) -} - -func (c Canvas) DrawPoint(x, y int) { - c.context2d.Call("fillRect", x, y, 1, 1) -} - -func (c Canvas) fillStyle(style string) { - c.context2d.Set("fillStyle", style) -} - -func (c Canvas) fillRect(x, y, width, height int) { - c.context2d.Call("fillRect", x, y, width, height) -} - func (c Canvas) blitIt(buffer [anotherworld.WIDTH * anotherworld.HEIGHT]int) { var interfaceSlice []interface{} = make([]interface{}, len(buffer)) for i, d := range buffer { From 85510c018755d12fa8d605d0ec65290d4bcff7ce Mon Sep 17 00:00:00 2001 From: michuNEEO Date: Mon, 11 May 2020 22:51:03 +0200 Subject: [PATCH 07/10] moar readable --- wasm/js-canvas.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wasm/js-canvas.go b/wasm/js-canvas.go index c8f66d5..625e88e 100644 --- a/wasm/js-canvas.go +++ b/wasm/js-canvas.go @@ -21,8 +21,8 @@ func GetCanvas(domElementId string) Canvas { func (c Canvas) blitIt(buffer [anotherworld.WIDTH * anotherworld.HEIGHT]int) { var interfaceSlice []interface{} = make([]interface{}, len(buffer)) - for i, d := range buffer { - interfaceSlice[i] = d + for index, pixelData := range buffer { + interfaceSlice[index] = pixelData } c.context2d.Call("blit", interfaceSlice) } From 638929441efd8873896dae64f9e45aa888ff9a1c Mon Sep 17 00:00:00 2001 From: michuNEEO Date: Mon, 11 May 2020 23:03:29 +0200 Subject: [PATCH 08/10] wire load and save to the ui --- wasm/index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wasm/index.html b/wasm/index.html index 655b221..0ec7cb6 100644 --- a/wasm/index.html +++ b/wasm/index.html @@ -55,6 +55,8 @@

// STOP + LOAD + SAVE // LOG DEBUG From cc4c885d51e86a26de80b11efbdbe88f51ee2771 Mon Sep 17 00:00:00 2001 From: michuNEEO Date: Mon, 11 May 2020 23:22:37 +0200 Subject: [PATCH 09/10] rearrange ui --- wasm/index.html | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/wasm/index.html b/wasm/index.html index 0ec7cb6..ea3605a 100644 --- a/wasm/index.html +++ b/wasm/index.html @@ -43,7 +43,11 @@

Gother World

- Load Game Part + STOP + LOAD + SAVE + + // Game Part 0 1 2 @@ -53,11 +57,6 @@

6 7 - // - STOP - LOAD - SAVE - // LOG DEBUG INFO From 6a868f5cc9d727a51aa0e62047557d8f4500e58d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 12 May 2020 15:41:28 +0200 Subject: [PATCH 10/10] a css noob commit --- wasm/index.html | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/wasm/index.html b/wasm/index.html index ea3605a..f8b9244 100644 --- a/wasm/index.html +++ b/wasm/index.html @@ -17,7 +17,7 @@ text-align: center; font-family: "Monaco", "Andale Mono", "Lucida Console", "FreeMono", monospace; } - #badge { + .badge { color: #fff; background-color: #000; display: inline-block; @@ -43,26 +43,26 @@

Gother World

- STOP - LOAD - SAVE + STOP + LOAD + SAVE // Game Part - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 // LOG - DEBUG - INFO - WARN - ERROR - FATAL + DEBUG + INFO + WARN + ERROR + FATAL