From ef0000b67bbd4930ccc997c45fa5e1cdc3932d25 Mon Sep 17 00:00:00 2001 From: Will Angenent Date: Wed, 9 May 2018 17:34:10 +0100 Subject: [PATCH] Renamed vid and moved some more vid stuff to it --- cmd/test-apple-iie-boot.go | 19 +++---------------- pr-latin1.png => video/pr-latin1.png | Bin vid/vid.go => video/video.go | 15 +++++++++++++-- 3 files changed, 16 insertions(+), 18 deletions(-) rename pr-latin1.png => video/pr-latin1.png (100%) rename vid/vid.go => video/video.go (86%) diff --git a/cmd/test-apple-iie-boot.go b/cmd/test-apple-iie-boot.go index 4b4329c..1351062 100644 --- a/cmd/test-apple-iie-boot.go +++ b/cmd/test-apple-iie-boot.go @@ -2,15 +2,13 @@ package main import ( "flag" - "log" "github.com/hajimehoshi/ebiten" - "github.com/hajimehoshi/ebiten/ebitenutil" "mos6502go/cpu" "mos6502go/keyboard" "mos6502go/mmu" - "mos6502go/vid" + "mos6502go/video" ) const ( @@ -19,12 +17,6 @@ const ( flashFrames = 8 // Number of frames when FLASH mode is toggled ) -var ( - charMap *ebiten.Image - flashCounter int - flashOn bool -) - var cpuState cpu.State var showInstructions *bool var disableBell *bool @@ -54,7 +46,7 @@ func update(screen *ebiten.Image) error { checkResetKeys() cpu.Run(&cpuState, *showInstructions, nil, *disableBell, 1024000/60) - return vid.DrawTextScreen(cpuState.PageTable, screen, charMap) + return video.DrawTextScreen(cpuState.PageTable, screen) } func main() { @@ -71,14 +63,9 @@ func main() { cpuState.Init() keyboard.Init() + video.Init() reset() - var err error - charMap, _, err = ebitenutil.NewImageFromFile("./pr-latin1.png", ebiten.FilterNearest) - if err != nil { - log.Fatal(err) - } - ebiten.Run(update, 280*screenSizeFactor, 192*screenSizeFactor, 2, "Apple //e") } diff --git a/pr-latin1.png b/video/pr-latin1.png similarity index 100% rename from pr-latin1.png rename to video/pr-latin1.png diff --git a/vid/vid.go b/video/video.go similarity index 86% rename from vid/vid.go rename to video/video.go index 43af6ed..f18f70e 100644 --- a/vid/vid.go +++ b/video/video.go @@ -1,4 +1,4 @@ -package vid +package video import ( "image" @@ -6,6 +6,7 @@ import ( "mos6502go/mmu" "github.com/hajimehoshi/ebiten" + "github.com/hajimehoshi/ebiten/ebitenutil" ) const ( @@ -15,11 +16,21 @@ const ( ) var ( + charMap *ebiten.Image flashCounter int flashOn bool ) -func DrawTextScreen(pageTable *mmu.PageTable, screen *ebiten.Image, charMap *ebiten.Image) error { +func Init() { + var err error + charMap, _, err = ebitenutil.NewImageFromFile("video/pr-latin1.png", ebiten.FilterNearest) + if err != nil { + panic(err) + } + +} + +func DrawTextScreen(pageTable *mmu.PageTable, screen *ebiten.Image) error { flashCounter-- if flashCounter < 0 { flashCounter = flashFrames