mirror of
https://github.com/freewilll/apple2-go.git
synced 2025-01-10 07:29:47 +00:00
Replaced charmap sheet png loading with hardcoded characters ...
... the main reason for this was so that the character map is a static asset.
This commit is contained in:
parent
ca7f2d2e04
commit
c49a14d9ca
2861
video/charmap.go
Normal file
2861
video/charmap.go
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 21 KiB |
@ -23,7 +23,6 @@ const (
|
|||||||
type drawTextLoresByte func(*ebiten.Image, int, int, uint8) error
|
type drawTextLoresByte func(*ebiten.Image, int, int, uint8) error
|
||||||
|
|
||||||
var (
|
var (
|
||||||
charMap *ebiten.Image // Character map for text screen
|
|
||||||
flashCounter int // Counter used for flashing characters on the text screen
|
flashCounter int // Counter used for flashing characters on the text screen
|
||||||
flashOn bool // Are we currently flashing?
|
flashOn bool // Are we currently flashing?
|
||||||
loresSquares [16]*ebiten.Image // Colored blocks for lores rendering
|
loresSquares [16]*ebiten.Image // Colored blocks for lores rendering
|
||||||
@ -32,18 +31,6 @@ var (
|
|||||||
ShowFPS bool
|
ShowFPS bool
|
||||||
)
|
)
|
||||||
|
|
||||||
// initTextCharMap initializes the text character map
|
|
||||||
func initTextCharMap() {
|
|
||||||
// The character map pr-latin1.png was downloaded from
|
|
||||||
// http://www.kreativekorp.com/software/fonts/apple2.shtml
|
|
||||||
|
|
||||||
var err error
|
|
||||||
charMap, _, err = ebitenutil.NewImageFromFile("video/pr-latin1.png", ebiten.FilterNearest)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// initLoresSquares creates 16 colored squares for the lores renderer
|
// initLoresSquares creates 16 colored squares for the lores renderer
|
||||||
func initLoresSquares() {
|
func initLoresSquares() {
|
||||||
var err error
|
var err error
|
||||||
@ -111,16 +98,11 @@ func drawText(screen *ebiten.Image, x int, y int, value uint8) error {
|
|||||||
op.GeoM.Scale(ScreenSizeFactor, ScreenSizeFactor)
|
op.GeoM.Scale(ScreenSizeFactor, ScreenSizeFactor)
|
||||||
op.GeoM.Translate(ScreenSizeFactor*7*float64(x), ScreenSizeFactor*8*float64(y))
|
op.GeoM.Translate(ScreenSizeFactor*7*float64(x), ScreenSizeFactor*8*float64(y))
|
||||||
|
|
||||||
// Grab the image from the font image
|
r := image.Rect(0, 0, 7, 8)
|
||||||
fontRow := value % 16
|
|
||||||
fontCol := value / 16
|
|
||||||
var fontX = (int)(15 + fontCol*12)
|
|
||||||
var fontY = (int)(32 + fontRow*11)
|
|
||||||
r := image.Rect(fontX, fontY, fontX+7, fontY+8)
|
|
||||||
op.SourceRect = &r
|
op.SourceRect = &r
|
||||||
|
|
||||||
// The charMap is already inverted. Invert it back if we ourselves aren't inverted.
|
// The charMap is already inverted. Invert it back if we ourselves aren't inverted.
|
||||||
if !inverted {
|
if inverted {
|
||||||
op.ColorM.Scale(-1, -1, -1, 1)
|
op.ColorM.Scale(-1, -1, -1, 1)
|
||||||
op.ColorM.Translate(1, 1, 1, 0)
|
op.ColorM.Translate(1, 1, 1, 0)
|
||||||
}
|
}
|
||||||
@ -128,7 +110,7 @@ func drawText(screen *ebiten.Image, x int, y int, value uint8) error {
|
|||||||
// Make it look greenish
|
// Make it look greenish
|
||||||
op.ColorM.Scale(0.20, 0.75, 0.20, 1)
|
op.ColorM.Scale(0.20, 0.75, 0.20, 1)
|
||||||
|
|
||||||
return screen.DrawImage(charMap, op)
|
return screen.DrawImage(charMap[value], op)
|
||||||
}
|
}
|
||||||
|
|
||||||
// drawLores draws two colored lores squares at the equivalent text location x,y.
|
// drawLores draws two colored lores squares at the equivalent text location x,y.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user