From 3bc64c2438b4a20d1676e0c0b319cbfd36cda9c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timur=20=C3=87elik?= Date: Mon, 1 Dec 2025 11:08:51 +0100 Subject: [PATCH] Enable video output --- go.mod | 5 +++++ main.go | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 71730cc..b8890be 100644 --- a/go.mod +++ b/go.mod @@ -3,3 +3,8 @@ module n64tutorial go 1.24.4 require github.com/clktmr/n64 v0.1.2 + +require ( + github.com/embeddedgo/display v1.1.0 // indirect + golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect +) diff --git a/main.go b/main.go index 8561535..b833f46 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,38 @@ package main -import _ "github.com/clktmr/n64/machine" +import ( + "fmt" + "image" + "image/color" + + "github.com/clktmr/n64/drivers/display" + "github.com/clktmr/n64/drivers/draw" + "github.com/clktmr/n64/fonts/gomono12" + _ "github.com/clktmr/n64/machine" + "github.com/clktmr/n64/rcp/video" +) + +var face = gomono12.NewFace() +var background = &image.Uniform{color.RGBA{0x7f, 0x7f, 0xaf, 0x0}} func main() { - println("N⁶⁴ - Get N or Get Out ♫") + // Enable video output + video.Setup(false) + + // Allocate framebuffer + display := display.NewDisplay(image.Pt(320, 240), video.BPP16) + + for { + fb := display.Swap() // Blocks until next VBlank + + textarea := fb.Bounds().Inset(15) + pt := textarea.Min.Add(image.Pt(0, int(face.Ascent))) + + draw.Src.Draw(fb, fb.Bounds(), background, fb.Bounds().Min) + + text := fmt.Appendln(nil, "N⁶⁴ - Get N or Get Out ♫") + pt = draw.DrawText(fb, textarea, face, pt, image.Black, nil, text) + + draw.Flush() // Blocks until everything is drawn + } }