From 46b66ec7c342a52f7446573698af0139e99d6580 Mon Sep 17 00:00:00 2001 From: Zellyn Hunter Date: Wed, 13 Jul 2016 22:00:26 -0600 Subject: [PATCH] Flesh out readme, reorder shiny code --- README.md | 44 ++++++++++++++++++++++++++++++++++--- data/roms/apple2-chars.rom | Bin 0 -> 512 bytes data/roms/getroms.sh | 36 ++++++++++++++++++++++++++++++ shiny/shiny.go | 17 +++++++------- util/util.go | 9 +++++--- 5 files changed, 92 insertions(+), 14 deletions(-) create mode 100644 data/roms/apple2-chars.rom create mode 100755 data/roms/getroms.sh diff --git a/README.md b/README.md index a2b8497..4a6c16f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,42 @@ -goapple2 -======== +# goapple2 -Apple ][+ emulator written in Go. \ No newline at end of file +Apple ][+ emulator written in Go. + +## Status + +Basic functionality (keyboard input, text, low and hires graphics) +works. + +Very basic (and fake) *read-only* disk access works, for `.dsk` images +where no trickery is involved. + +This was one of my early Go-learning projects: the code organization +is pretty horrible. + +## Shiny + +This is the main "supported" interface, hacked together during hack +day at GopherCon2016. It's almost certainly doing things wrong +Shiny-wise: pull requests welcome. Press backquote/tilde to exit. + +## Texty + +`texty/` contains a hackish version of the emulator that runs in a +terminal. It interprets all videoscan outputs as text, regardless of +any other settings. Press `~` to exit. + +## Where to find ROMs + +cd data/roms +./getroms.sh + +## Contributing + +Pull requests welcome. If you have any questions, feel free to get in +touch with me: username "zellyn" on gmail, twitter, facebook, github, +golang slack. + +### Contributors + +- [zellyn](https://github.com/zellyn) +- [frumious](https://github.com/frumious) diff --git a/data/roms/apple2-chars.rom b/data/roms/apple2-chars.rom new file mode 100644 index 0000000000000000000000000000000000000000..785e7ee21d38ec013af23d052a2223f69152e57c GIT binary patch literal 512 zcmYLG!D_`Y3=<|iOerIj93CT-;zJo>htb1hhm!yQtV!mP0>u!UU{%J%ITmOuZBT;QbpZ14nBu zPgO{d9MrWwiNl4mOwG11SoP)8a}%B!8>AQ|FyFZV MO@n8wue9g*0~ZJ-l>h($ literal 0 HcmV?d00001 diff --git a/data/roms/getroms.sh b/data/roms/getroms.sh new file mode 100755 index 0000000..cd14ae7 --- /dev/null +++ b/data/roms/getroms.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +DIR1='http://mirrors.apple2.org.za/Apple%20II%20Documentation%20Project/Computers/Apple%20II/Apple%20II/ROM%20Images' +DIR2='http://mirrors.apple2.org.za/Apple%20II%20Documentation%20Project/Computers/Apple%20II/Apple%20II%20plus/ROM%20Images' + +rm -f apple2.rom apple2+.rom + +D0_2="Apple%20Programmer's%20Aid%20%231%20ROM%20(D000)%20-%20341-0016%20-%202716.bin" +E0_2='Apple%20II%20ROM%20Pages%20E0-E7%20-%20341-0001%20-%20Integer%20BASIC.bin' +E8_2='Apple%20II%20ROM%20Pages%20E8-EF%20-%20341-0002%20-%20Integer%20BASIC.bin' +F0_2='Apple%20II%20ROM%20Pages%20F0-F7%20-%20341-0003%20-%20Integer%20BASIC.bin' +F8_2='Apple%20II%20ROM%20Pages%20F8-FF%20-%20341-0004%20-%20Original%20Monitor.bin' + + +D0_2P='Apple%20II%20plus%20ROM%20Pages%20D0-D7%20-%20341-0011%20-%20Applesoft%20BASIC.bin' +D8_2P='Apple%20II%20plus%20ROM%20Pages%20D8-DF%20-%20341-0012%20-%20Applesoft%20BASIC.bin' +E0_2P='Apple%20II%20plus%20ROM%20Pages%20E0-E7%20-%20341-0013%20-%20Applesoft%20BASIC.bin' +E8_2P='Apple%20II%20plus%20ROM%20Pages%20E8-EF%20-%20341-0014%20-%20Applesoft%20BASIC.bin' +F0_2P='Apple%20II%20plus%20ROM%20Pages%20F0-F7%20-%20341-0015%20-%20Applesoft%20BASIC.bin' +F8_2P='Apple%20II%20plus%20ROM%20Pages%20F8-FF%20-%20341-0020%20-%20Autostart%20Monitor.bin' + +curl $DIR2/$D0_2P > apple2+.rom +curl $DIR2/$D8_2P >> apple2+.rom +curl $DIR2/$E0_2P >> apple2+.rom +curl $DIR2/$E8_2P >> apple2+.rom +curl $DIR2/$F0_2P >> apple2+.rom +curl $DIR2/$F8_2P >> apple2+.rom + +curl $DIR1/$D0_2 > apple2.rom +curl $DIR2/$D8_2P >> apple2.rom +curl $DIR1/$E0_2 >> apple2.rom +curl $DIR1/$E8_2 >> apple2.rom +curl $DIR1/$F0_2 >> apple2.rom +curl $DIR1/$F8_2 >> apple2.rom + +curl http://mirrors.apple2.org.za/Apple%20II%20Documentation%20Project/Interface%20Cards/Disk%20Drive%20Controllers/Apple%20Disk%20II%20Interface%20Card/ROM%20Images/Apple%20Disk%20II%2016%20Sector%20Interface%20Card%20ROM%20P5%20-%20341-0027.bin >> 'Apple Disk II 16 Sector Interface Card ROM P5 - 341-0027.bin' diff --git a/shiny/shiny.go b/shiny/shiny.go index 04d6610..22c319c 100644 --- a/shiny/shiny.go +++ b/shiny/shiny.go @@ -16,7 +16,6 @@ import ( "golang.org/x/mobile/event/key" "golang.org/x/mobile/event/lifecycle" - "github.com/zellyn/go6502/cpu" "github.com/zellyn/goapple2" "github.com/zellyn/goapple2/cards" "github.com/zellyn/goapple2/util" @@ -38,10 +37,10 @@ const ( // Run the emulator func RunEmulator(s screen.Screen) { - rom := util.ReadRomOrDie("../data/roms/apple2+.rom") - // charRom = util.ReadFullCharacterRomOrDie("../data/roms/apple2char.rom") + rom := util.ReadRomOrDie("../data/roms/apple2+.rom", 12288) charRom := util.ReadSmallCharacterRomOrDie("../data/roms/apple2-chars.rom") - intBasicRom := util.ReadRomOrDie("../data/roms/apple2.rom") + intBasicRom := util.ReadRomOrDie("../data/roms/apple2.rom", 12288) + util.ReadRomOrDie("../data/roms/Apple Disk II 16 Sector Interface Card ROM P5 - 341-0027.bin", 256) eventChan := make(chan (interface{})) w, err := s.NewWindow(&screen.NewWindowOptions{Width: SCREEN_WIDTH, Height: SCREEN_HEIGHT}) @@ -129,9 +128,8 @@ func RunEmulator(s screen.Screen) { a2.AddPCAction( 0xBDAF, goapple2.PCAction{Type: goapple2.ActionDumpMem, String: "0xBDAF-goa2.bin", Delay: 68}) */ - _ = cpu.FLAG_Z - // go typeProgram(a2) + go typeProgram(a2) go func() { for { @@ -307,6 +305,8 @@ var KeyToApple = map[Key]byte{ func shinyToAppleKeyboard(e key.Event) (byte, error) { if b, ok := KeyToApple[Key{e.Code, e.Modifiers}]; ok { return b, nil + } else { + fmt.Printf("Key for %v not found\n", e) } /* switch k.Mod { @@ -346,8 +346,10 @@ func ProcessEvents(a2 *goapple2.Apple2, w screen.Window, eventChan chan interfac return true } if e.Direction == key.DirPress || e.Direction == key.DirNone { - if b, err := shinyToAppleKeyboard(e); err != nil { + if b, err := shinyToAppleKeyboard(e); err == nil { a2.Keypress(b) + } else { + fmt.Printf("Unable to convert event %v (%d, %d): %v\n", e, int(e.Code), int(e.Modifiers), err) } } } @@ -410,7 +412,6 @@ func (s ShinyPlotter) OncePerFrame() { } func typeProgram(a2 *goapple2.Apple2) { - return lines := []string{ "10 GR", "20 POKE -16302,0", diff --git a/util/util.go b/util/util.go index 7bfcabb..29a6a54 100644 --- a/util/util.go +++ b/util/util.go @@ -5,16 +5,19 @@ import ( "io/ioutil" ) -func ReadRomOrDie(filename string) []byte { +func ReadRomOrDie(filename string, size int) []byte { bytes, err := ioutil.ReadFile(filename) if err != nil { panic("Cannot read ROM file: " + filename) } + if len(bytes) != size { + panic(fmt.Sprintf("Want length of %d for ROM %q; want %d", size, filename, len(bytes))) + } return bytes } func ReadSmallCharacterRomOrDie(filename string) [2048]byte { - bytes := ReadRomOrDie(filename) + bytes := ReadRomOrDie(filename, 512) if len(bytes) != 512 { panic(fmt.Sprintf("Got %d bytes (not 512) from file '%s'", len(bytes), filename)) } @@ -29,7 +32,7 @@ func ReadSmallCharacterRomOrDie(filename string) [2048]byte { } func ReadFullCharacterRomOrDie(filename string) [2048]byte { - bytes := ReadRomOrDie(filename) + bytes := ReadRomOrDie(filename, 2048) if len(bytes) != 2048 { panic(fmt.Sprintf("Got %d bytes (not 2048) from file '%s'", len(bytes), filename)) }