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) } 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 } diff --git a/wasm/index.html b/wasm/index.html index ea1af0e..f8b9244 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 .3em; + line-height: 1; + border-radius: .25rem; + font-weight: 700; + text-decoration: none; + } #gotherworld { width: 960px; height: 600px; @@ -32,6 +42,29 @@

Gother World

+

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

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/js-canvas.go b/wasm/js-canvas.go index e5f65a3..625e88e 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,26 +19,10 @@ 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 { - interfaceSlice[i] = d + for index, pixelData := range buffer { + interfaceSlice[index] = pixelData } c.context2d.Call("blit", interfaceSlice) } diff --git a/wasm/main.go b/wasm/main.go index 325cc41..5cf7cae 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -5,13 +5,14 @@ import ( ) func init() { - logger.SetLogLevel(logger.LEVEL_INFO) logger.DisableColors() + logger.SetLogLevel(logger.LEVEL_INFO) logger.Info("WASM Gother-World initializing...") } func main() { engine := buildEngine() RegisterCallbacks(&engine) + logger.Info("Registered Callbacks") <-engine.shutdownChannel }