diff --git a/apple2/characterGenerator.go b/apple2/characterGenerator.go new file mode 100644 index 0000000..a1318f5 --- /dev/null +++ b/apple2/characterGenerator.go @@ -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)) + } +} diff --git a/apple2/ioC0Page.go b/apple2/ioC0Page.go index b38e07a..e1bcf89 100644 --- a/apple2/ioC0Page.go +++ b/apple2/ioC0Page.go @@ -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) } diff --git a/apple2/romdumps/Apple II+ - Lowercase Character Generator - 2716.bin b/apple2/romdumps/Apple II+ - Lowercase Character Generator - 2716.bin new file mode 100644 index 0000000..0cc83d3 Binary files /dev/null and b/apple2/romdumps/Apple II+ - Lowercase Character Generator - 2716.bin differ diff --git a/apple2/romdumps/Apple II+ - Pig Font Character Generator - 2716.bin b/apple2/romdumps/Apple II+ - Pig Font Character Generator - 2716.bin new file mode 100644 index 0000000..fb199b7 Binary files /dev/null and b/apple2/romdumps/Apple II+ - Pig Font Character Generator - 2716.bin differ diff --git a/apple2/romdumps/Apple2rev7CharGen.rom b/apple2/romdumps/Apple2rev7CharGen.rom new file mode 100644 index 0000000..094bebf Binary files /dev/null and b/apple2/romdumps/Apple2rev7CharGen.rom differ diff --git a/apple2/softSwitches2.go b/apple2/softSwitches2.go index 0a66df9..0198e83 100644 --- a/apple2/softSwitches2.go +++ b/apple2/softSwitches2.go @@ -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 diff --git a/main.go b/main.go index bd3d70e..77c4d1f 100644 --- a/main.go +++ b/main.go @@ -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)