Character map roms initial support

This commit is contained in:
Ivan Izaguirre 2019-04-21 18:18:43 +02:00
parent 05355749f3
commit 016e1ea875
7 changed files with 90 additions and 1 deletions

View File

@ -0,0 +1,73 @@
package apple2
import (
"bufio"
"fmt"
"os"
)
/*
See:
hhttps://mirrors.apple2.org.za/Apple%20II%20Documentation%20Project/Companies/Apple/Documentation/Apple%20Technical%20Information%20Library/a2til041.txt
*/
// CharacterGenerator represents the ROM wth the characters bitmaps
type CharacterGenerator struct {
data []uint8
}
const (
rev7CharGenSize = 2048
)
// NewCharacterGenerator instantiates a new Character Generator with the rom on the file given
func NewCharacterGenerator(filename string) *CharacterGenerator {
var cg CharacterGenerator
cg.load(filename)
return &cg
}
func (cg *CharacterGenerator) load(filename string) {
f, err := os.Open(filename)
if err != nil {
panic(err)
}
defer f.Close()
stats, statsErr := f.Stat()
if statsErr != nil {
panic(err)
}
size := stats.Size()
if size != rev7CharGenSize {
panic("Character ROM size not supported")
}
cg.data = make([]uint8, size)
buf := bufio.NewReader(f)
buf.Read(cg.data)
}
func (cg *CharacterGenerator) dumpChar(char uint8) {
base := int(char) * 8
fmt.Printf("Char: %v\n---------\n", char)
for i := 0; i < 8; i++ {
fmt.Print("|")
b := cg.data[base+i]
for j := 6; j >= 0; j-- {
if (b>>uint(j))&1 == 1 {
fmt.Print("#")
} else {
fmt.Print(" ")
}
}
fmt.Println("|")
}
fmt.Println("---------")
}
func (cg *CharacterGenerator) Dump() {
for i := 0; i < 256; i++ {
cg.dumpChar(uint8(i))
}
}

View File

@ -15,6 +15,7 @@ type ioC0Page struct {
type softSwitchR func(io *ioC0Page) uint8
type softSwitchW func(io *ioC0Page, value uint8)
// KeyboardProvider declares the keyboard implementation requitements
type KeyboardProvider interface {
GetKey(strobe bool) (key uint8, ok bool)
}

Binary file not shown.

View File

@ -7,7 +7,7 @@ const (
ioFlagMixed uint8 = 0x52
ioFlagSecondPage uint8 = 0x54
ioFlagHiRes uint8 = 0x56
ioFlagAnnunciator0 uint8 = 0x58
ioFlagAnnunciator0 uint8 = 0x58 // On Copam Electronics Base-64A this is used to bank swith the ROM
ioFlagAnnunciator1 uint8 = 0x5a
ioFlagAnnunciator2 uint8 = 0x5c
ioFlagAnnunciator3 uint8 = 0x5e

15
main.go
View File

@ -19,6 +19,10 @@ func main() {
"disk",
"../dos33.dsk",
"file to load on the first disk drive")
charRomFile := flag.String(
"charRom",
"apple2/romdumps/Apple2rev7CharGen.rom",
"rom file for the disk drive controller")
useSdl := flag.Bool(
"sdl",
true,
@ -27,6 +31,11 @@ func main() {
"panicss",
false,
"panic if a not implemented softwtich is used")
dumpChars := flag.Bool(
"dumpChars",
false,
"shows the character map",
)
flag.Parse()
//romFile := "apple2/romdumps/Apple2.rom"
@ -37,6 +46,12 @@ func main() {
//diskImage := "../Apex II - Apple II Diagnostic (v4.7-1986).DSK"
//diskImage := "../A2Diag.v4.1.SDK"
if *dumpChars {
cg := apple2.NewCharacterGenerator(*charRomFile)
cg.Dump()
return
}
log := false
a := apple2.NewApple2(*romFile, *panicSS)
a.AddDisk2(*disk2RomFile, *diskImage)