Let's give this thing a name

This commit is contained in:
Ivan Izaguirre 2020-10-03 23:38:26 +02:00
parent e07754d1d0
commit 66e94574a0
56 changed files with 115 additions and 115 deletions

View File

@ -1,8 +1,8 @@
# Apple ][+, //e emulator # izapple2 - Apple ][+, //e emulator
Portable emulator of an Apple II+ or //e. Written in Go. Portable emulator of an Apple II+ or //e. Written in Go.
[![CircleCI](https://circleci.com/gh/ivanizag/apple2/tree/master.svg?style=svg)](https://circleci.com/gh/ivanizag/apple2/tree/master) [![CircleCI](https://circleci.com/gh/ivanizag/izapple2/tree/master.svg?style=svg)](https://circleci.com/gh/ivanizag/izapple2/tree/master)
## Features ## Features
@ -72,14 +72,14 @@ By default the following configuration is launched:
## Running the emulator ## Running the emulator
No installation required. [Download](https://github.com/ivanizag/apple2/releases) the single file executable `apple2xxx_xxx` for linux or Mac, SDL2 graphics or console. Build from source to get the latest features. No installation required. [Download](https://github.com/ivanizag/izapple2/releases) the single file executable `izapple2xxx_xxx` for linux or Mac, SDL2 graphics or console. Build from source to get the latest features.
### Default mode ### Default mode
Execute without parameters to have an emulated Apple //e Enhanced with 128kb booting DOS 3.3 ready to run Applesoft: Execute without parameters to have an emulated Apple //e Enhanced with 128kb booting DOS 3.3 ready to run Applesoft:
``` terminal ``` terminal
casa@servidor:~$ ./apple2sdl casa@servidor:~$ ./izapple2sdl
``` ```
![DOS 3.3 started](doc/dos33.png) ![DOS 3.3 started](doc/dos33.png)
@ -89,7 +89,7 @@ casa@servidor:~$ ./apple2sdl
Download a DSK or WOZ file or use an URL ([Asimov](https://www.apple.asimov.net/images/) is an excellent source) with the `-disk` parameter: Download a DSK or WOZ file or use an URL ([Asimov](https://www.apple.asimov.net/images/) is an excellent source) with the `-disk` parameter:
``` terminal ``` terminal
casa@servidor:~$ ./apple2sdl -disk "https://www.apple.asimov.net/images/games/action/karateka/karateka (includes intro).dsk" casa@servidor:~$ ./izapple2sdl -disk "https://www.apple.asimov.net/images/games/action/karateka/karateka (includes intro).dsk"
``` ```
![Karateka](doc/karateka.png) ![Karateka](doc/karateka.png)
@ -100,7 +100,7 @@ Download the excellent [Total Replay](https://archive.org/details/TotalReplay) c
[a2-4am](https://github.com/a2-4am/4cade). Run it with the `-hd` parameter: [a2-4am](https://github.com/a2-4am/4cade). Run it with the `-hd` parameter:
``` terminal ``` terminal
casa@servidor:~$ ./apple2sdl -hd "Total Replay v3.0.2mg" casa@servidor:~$ ./izapple2sdl -hd "Total Replay v3.0.2mg"
``` ```
Displays super hi-res box art as seen with the VidHD card. Displays super hi-res box art as seen with the VidHD card.
@ -109,10 +109,10 @@ Displays super hi-res box art as seen with the VidHD card.
### Terminal mode ### Terminal mode
To run text mode right on the terminal without the SDL2 dependency, use `apple2console`. It runs on the console using ANSI escape codes. Input is sent to the emulated Apple II one line at a time: To run text mode right on the terminal without the SDL2 dependency, use `izapple2console`. It runs on the console using ANSI escape codes. Input is sent to the emulated Apple II one line at a time:
``` terminal ``` terminal
casa@servidor:~$ ./apple2console -model 2plus casa@servidor:~$ ./izapple2console -model 2plus
############################################ ############################################
# # # #
@ -229,26 +229,26 @@ Only valid on SDL mode
## Building from source ## Building from source
### apple2console ### izapple2console
The only dependency is having a working Go installation on any platform. The only dependency is having a working Go installation on any platform.
Run: Run:
``` terminal ``` terminal
go get github.com/ivanizag/apple2/apple2console go get github.com/ivanizag/izapple2/izapple2console
go build github.com/ivanizag/apple2/apple2console go build github.com/ivanizag/izapple2/izapple2console
``` ```
### apple2sdl ### izapple2sdl
Besides having a working Go installation, install the SDL2 developer files. Valid for any platform Besides having a working Go installation, install the SDL2 developer files. Valid for any platform
Run: Run:
``` terminal ``` terminal
go get github.com/ivanizag/apple2/apple2sdl go get github.com/ivanizag/izapple2/izapple2sdl
go build github.com/ivanizag/apple2/apple2sdl go build github.com/ivanizag/izapple2/izapple2sdl
``` ```
### Use docker to cross compile for Linux and Windows ### Use docker to cross compile for Linux and Windows
@ -260,4 +260,4 @@ cd docker
./build.sh ./build.sh
``` ```
To run in Windows, copy the file `SDL2.dll` on the same folder as `apple2sdl.exe`. The latest `SDL2.dll` can be found in the [Runtime binary for Windows 64-bit](https://www.libsdl.org/download-2.0.php). To run in Windows, copy the file `SDL2.dll` on the same folder as `izapple2sdl.exe`. The latest `SDL2.dll` can be found in the [Runtime binary for Windows 64-bit](https://www.libsdl.org/download-2.0.php).

View File

@ -1,10 +1,10 @@
package apple2 package izapple2
import ( import (
"fmt" "fmt"
"time" "time"
"github.com/ivanizag/apple2/core6502" "github.com/ivanizag/izapple2/core6502"
) )
// Apple2 represents all the components and state of the emulated machine // Apple2 represents all the components and state of the emulated machine

View File

@ -1,9 +1,9 @@
package apple2 package izapple2
import ( import (
"errors" "errors"
"github.com/ivanizag/apple2/core6502" "github.com/ivanizag/izapple2/core6502"
) )
func newApple2() *Apple2 { func newApple2() *Apple2 {

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"flag" "flag"

View File

@ -1,9 +1,9 @@
package apple2 package izapple2
import ( import (
"fmt" "fmt"
"github.com/ivanizag/apple2/core6502" "github.com/ivanizag/izapple2/core6502"
) )
/* /*

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"errors" "errors"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
type card interface { type card interface {
loadRom(data []uint8) loadRom(data []uint8)

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
/* /*
Simulates just what is needed to make Total Replay use fast mode. Can change Simulates just what is needed to make Total Replay use fast mode. Can change

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import "fmt" import "fmt"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
/* /*
Language card with 16 extra kb for the Apple ][ and ][+ Language card with 16 extra kb for the Apple ][ and ][+

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
/* /*
Apple II Memory Expansion Card Apple II Memory Expansion Card

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
/* /*
Extended 80-Column Text AppleColor Card or Video7 RGB-SL7 card Extended 80-Column Text AppleColor Card or Video7 RGB-SL7 card

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
/* /*
RAMWorks style card on the Apple IIe aus slot. RAMWorks style card on the Apple IIe aus slot.

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
/* /*
RAM card with 128Kb. It's like 8 language cards. RAM card with 128Kb. It's like 8 language cards.

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
/* /*
ThunderClock`, real time clock card. ThunderClock`, real time clock card.

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
/* /*
Simulates just what is needed to make Total Replay use the GS modes if the VidHD card is found Simulates just what is needed to make Total Replay use the GS modes if the VidHD card is found

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"errors" "errors"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"errors" "errors"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
/* /*
See: See:

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
type diskette16sectorTimed struct { type diskette16sectorTimed struct {
nib *fileNib nib *fileNib

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
/* /*
See: See:

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"errors" "errors"

View File

@ -1,27 +1,27 @@
#!/bin/bash #!/bin/bash
cd /tmp cd /tmp
git clone https://github.com/ivanizag/apple2 git clone https://github.com/ivanizag/izapple2
# Build apple2console for Linux # Build izapple2console for Linux
cd /tmp/apple2/apple2console cd /tmp/apple2/izapple2console
go build . go build .
chown --reference /build apple2console chown --reference /build izapple2console
cp apple2console /build cp izapple2console /build
# Build apple2console.exe for Windows # Build izapple2console.exe for Windows
cd /tmp/apple2/apple2console cd /tmp/apple2/izapple2console
env CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows CGO_LDFLAGS="-L/usr/x86_64-w64-mingw32/lib" CGO_FLAGS="-I/usr/x86_64-w64-mingw32/include -D_REENTRANT" go build -o apple2console.exe . env CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows CGO_LDFLAGS="-L/usr/x86_64-w64-mingw32/lib" CGO_FLAGS="-I/usr/x86_64-w64-mingw32/include -D_REENTRANT" go build -o izapple2console.exe .
chown --reference /build apple2console.exe chown --reference /build izapple2console.exe
cp apple2console.exe /build cp izapple2console.exe /build
# Build apple2sdl for Linux # Build izapple2sdl for Linux
cd /tmp/apple2/apple2sdl cd /tmp/apple2/izapple2sdl
go build . go build .
chown --reference /build apple2sdl chown --reference /build izapple2sdl
cp apple2sdl /build cp izapple2sdl /build
# Build apple2sdl.exe for Windows # Build izapple2sdl.exe for Windows
cd /tmp/apple2/apple2sdl cd /tmp/apple2/izapple2sdl
env CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows CGO_LDFLAGS="-L/usr/x86_64-w64-mingw32/lib -lSDL2" CGO_FLAGS="-I/usr/x86_64-w64-mingw32/include -D_REENTRANT" go build -o apple2sdl.exe . env CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows CGO_LDFLAGS="-L/usr/x86_64-w64-mingw32/lib -lSDL2" CGO_FLAGS="-I/usr/x86_64-w64-mingw32/include -D_REENTRANT" go build -o izapple2sdl.exe .
chown --reference /build apple2sdl.exe chown --reference /build izapple2sdl.exe
cp apple2sdl.exe /build cp izapple2sdl.exe /build

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"encoding/binary" "encoding/binary"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"errors" "errors"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"testing" "testing"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"bytes" "bytes"

3
go.mod
View File

@ -1,4 +1,4 @@
module github.com/ivanizag/apple2 module github.com/ivanizag/izapple2
go 1.12 go 1.12
@ -7,5 +7,4 @@ require (
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect
github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd
github.com/veandco/go-sdl2 v0.4.0-rc.1 github.com/veandco/go-sdl2 v0.4.0-rc.1
golang.org/x/tools v0.0.0-20191220234730-f13409bbebaf // indirect
) )

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"fmt" "fmt"

View File

@ -7,7 +7,7 @@ import (
"strings" "strings"
"time" "time"
apple2 "github.com/ivanizag/apple2" apple2 "github.com/ivanizag/izapple2"
) )
func main() { func main() {

View File

@ -5,17 +5,18 @@ import (
"image" "image"
"unsafe" "unsafe"
"github.com/ivanizag/apple2" "github.com/ivanizag/izapple2"
"github.com/pkg/profile" "github.com/pkg/profile"
"github.com/veandco/go-sdl2/sdl" "github.com/veandco/go-sdl2/sdl"
) )
func main() { func main() {
a := apple2.MainApple() a := izapple2.MainApple()
if a != nil { if a != nil {
if a.IsProfiling() { if a.IsProfiling() {
// See the log with: // See the log with:
// go tool pprof --pdf ~/go/bin/apple2sdl /tmp/profile329536248/cpu.pprof > profile.pdf // go tool pprof --pdf ~/go/bin/izapple2sdl /tmp/profile329536248/cpu.pprof > profile.pdf
defer profile.Start().Stop() defer profile.Start().Stop()
} }
@ -24,7 +25,7 @@ func main() {
} }
// SDLRun starts the Apple2 emulator on SDL // SDLRun starts the Apple2 emulator on SDL
func SDLRun(a *apple2.Apple2) { func SDLRun(a *izapple2.Apple2) {
window, renderer, err := sdl.CreateWindowAndRenderer(4*40*7, 4*24*8, window, renderer, err := sdl.CreateWindowAndRenderer(4*40*7, 4*24*8,
sdl.WINDOW_SHOWN) sdl.WINDOW_SHOWN)
@ -35,7 +36,7 @@ func SDLRun(a *apple2.Apple2) {
defer window.Destroy() defer window.Destroy()
defer renderer.Destroy() defer renderer.Destroy()
window.SetTitle(a.Name) window.SetTitle("iz-" + a.Name)
kp := newSDLKeyBoard(a) kp := newSDLKeyBoard(a)
a.SetKeyboardProvider(kp) a.SetKeyboardProvider(kp)
@ -55,7 +56,7 @@ func SDLRun(a *apple2.Apple2) {
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() { for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
switch t := event.(type) { switch t := event.(type) {
case *sdl.QuitEvent: case *sdl.QuitEvent:
a.SendCommand(apple2.CommandKill) a.SendCommand(izapple2.CommandKill)
running = false running = false
case *sdl.KeyboardEvent: case *sdl.KeyboardEvent:
kp.putKey(t) kp.putKey(t)
@ -76,9 +77,9 @@ func SDLRun(a *apple2.Apple2) {
if paused != a.IsPaused() { if paused != a.IsPaused() {
if a.IsPaused() { if a.IsPaused() {
window.SetTitle(a.Name + " - PAUSED!") window.SetTitle("iz-" + a.Name + " - PAUSED!")
} else { } else {
window.SetTitle(a.Name) window.SetTitle("iz-" + a.Name)
} }
paused = a.IsPaused() paused = a.IsPaused()
} }

View File

@ -4,18 +4,18 @@ import (
"fmt" "fmt"
"unicode/utf8" "unicode/utf8"
"github.com/ivanizag/apple2" "github.com/ivanizag/izapple2"
"github.com/veandco/go-sdl2/sdl" "github.com/veandco/go-sdl2/sdl"
) )
type sdlKeyboard struct { type sdlKeyboard struct {
keyChannel chan uint8 keyChannel chan uint8
a *apple2.Apple2 a *izapple2.Apple2
showPages bool showPages bool
} }
func newSDLKeyBoard(a *apple2.Apple2) *sdlKeyboard { func newSDLKeyBoard(a *izapple2.Apple2) *sdlKeyboard {
var k sdlKeyboard var k sdlKeyboard
k.keyChannel = make(chan uint8, 100) k.keyChannel = make(chan uint8, 100)
k.a = a k.a = a
@ -98,33 +98,33 @@ func (k *sdlKeyboard) putKey(keyEvent *sdl.KeyboardEvent) {
// Control of the emulator // Control of the emulator
case sdl.K_F1: case sdl.K_F1:
if ctrl { if ctrl {
k.a.SendCommand(apple2.CommandReset) k.a.SendCommand(izapple2.CommandReset)
} }
case sdl.K_F5: case sdl.K_F5:
if ctrl { if ctrl {
k.a.SendCommand(apple2.CommandShowSpeed) k.a.SendCommand(izapple2.CommandShowSpeed)
} else { } else {
k.a.SendCommand(apple2.CommandToggleSpeed) k.a.SendCommand(izapple2.CommandToggleSpeed)
} }
case sdl.K_F6: case sdl.K_F6:
k.a.SendCommand(apple2.CommandToggleColor) k.a.SendCommand(izapple2.CommandToggleColor)
case sdl.K_F7: case sdl.K_F7:
k.showPages = !k.showPages k.showPages = !k.showPages
case sdl.K_F9: case sdl.K_F9:
k.a.SendCommand(apple2.CommandDumpDebugInfo) k.a.SendCommand(izapple2.CommandDumpDebugInfo)
case sdl.K_F10: case sdl.K_F10:
k.a.SendCommand(apple2.CommandNextCharGenPage) k.a.SendCommand(izapple2.CommandNextCharGenPage)
case sdl.K_F11: case sdl.K_F11:
k.a.SendCommand(apple2.CommandToggleCPUTrace) k.a.SendCommand(izapple2.CommandToggleCPUTrace)
case sdl.K_F12: case sdl.K_F12:
err := apple2.SaveSnapshot(k.a, "snapshot.png") err := izapple2.SaveSnapshot(k.a, "snapshot.png")
if err != nil { if err != nil {
fmt.Printf("Error saving snapshoot: %v.\n.", err) fmt.Printf("Error saving snapshoot: %v.\n.", err)
} else { } else {
fmt.Println("Saving snapshot") fmt.Println("Saving snapshot")
} }
case sdl.K_PAUSE: case sdl.K_PAUSE:
k.a.SendCommand(apple2.CommandPauseUnpauseEmulator) k.a.SendCommand(izapple2.CommandPauseUnpauseEmulator)
} }
// Missing values 91 to 95. Usually control for [\]^_ // Missing values 91 to 95. Usually control for [\]^_

View File

@ -10,7 +10,7 @@ import (
"reflect" "reflect"
"unsafe" "unsafe"
"github.com/ivanizag/apple2" "github.com/ivanizag/izapple2"
"github.com/veandco/go-sdl2/sdl" "github.com/veandco/go-sdl2/sdl"
) )
@ -18,7 +18,7 @@ const (
samplingHz = 48000 samplingHz = 48000
bufferSize = 1000 bufferSize = 1000
// bufferSize/samplingHz will be the max delay of the sound // bufferSize/samplingHz will be the max delay of the sound
sampleDurationCycles = 1000000 * apple2.CPUClockMhz / samplingHz sampleDurationCycles = 1000000 * izapple2.CPUClockMhz / samplingHz
// each sample on the sound stream is 21.31 cpu cycles approx // each sample on the sound stream is 21.31 cpu cycles approx
maxOutOfSyncMs = 2000 maxOutOfSyncMs = 2000
decayLevel = 128 decayLevel = 128
@ -49,10 +49,10 @@ func newSDLSpeaker() *sdlSpeaker {
// Click receives a speaker click. The argument is the CPU cycle when it is generated // Click receives a speaker click. The argument is the CPU cycle when it is generated
func (s *sdlSpeaker) Click(cycle uint64) { func (s *sdlSpeaker) Click(cycle uint64) {
select { select {
case s.clickChannel <- cycle: case s.clickChannel <- cycle:
// Sent // Sent
default: default:
// The channel is full, the click is lost. // The channel is full, the click is lost.
} }
} }
@ -88,7 +88,7 @@ func SpeakerCallback(userdata unsafe.Pointer, stream *C.Uint8, length C.int) {
} }
// Verify that we are not too long behind // Verify that we are not too long behind
var maxOutOfSyncCyclesFloat = 1000 * apple2.CPUClockMhz * maxOutOfSyncMs var maxOutOfSyncCyclesFloat = 1000 * izapple2.CPUClockMhz * maxOutOfSyncMs
var maxOutOfSyncCycles = uint64(maxOutOfSyncCyclesFloat) var maxOutOfSyncCycles = uint64(maxOutOfSyncCyclesFloat)
for _, pc := range s.pendingClicks { for _, pc := range s.pendingClicks {
if pc-s.lastCycle > maxOutOfSyncCycles { if pc-s.lastCycle > maxOutOfSyncCycles {

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import "fmt" import "fmt"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"time" "time"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"time" "time"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"io" "io"
@ -7,7 +7,7 @@ import (
"os" "os"
"strings" "strings"
"github.com/ivanizag/apple2/romdumps" "github.com/ivanizag/izapple2/romdumps"
) )
const ( const (

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"image" "image"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"image" "image"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"image" "image"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"testing" "testing"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"image" "image"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"image" "image"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"image" "image"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import ( import (
"testing" "testing"

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
const ( const (
ioDataKeyboard uint8 = 0x10 ioDataKeyboard uint8 = 0x10

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
/* /*
See: See:

View File

@ -1,4 +1,4 @@
package apple2 package izapple2
import "fmt" import "fmt"