mirror of
https://github.com/freewilll/apple2-go.git
synced 2024-09-27 17:55:56 +00:00
Integrated test-vid with test-apple-iie-boot ...
... we have the apple booting up with a well working screen and hanging on not yet implemented disk I/O.
This commit is contained in:
parent
5d1c25a724
commit
481ddf0ebf
@ -2,27 +2,60 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/hajimehoshi/ebiten"
|
||||||
|
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||||
|
|
||||||
"mos6502go/cpu"
|
"mos6502go/cpu"
|
||||||
"mos6502go/mmu"
|
"mos6502go/mmu"
|
||||||
|
"mos6502go/vid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
screenSizeFactor = 1 // Factor by which the whole screen is resized
|
||||||
|
textVideoMemory = 0x400 // Base location of page 1 text video memory
|
||||||
|
flashFrames = 8 // Number of frames when FLASH mode is toggled
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
charMap *ebiten.Image
|
||||||
|
flashCounter int
|
||||||
|
flashOn bool
|
||||||
|
)
|
||||||
|
|
||||||
|
var cpuState cpu.State
|
||||||
|
var showInstructions *bool
|
||||||
|
var disableBell *bool
|
||||||
|
|
||||||
|
func update(screen *ebiten.Image) error {
|
||||||
|
cpu.Run(&cpuState, *showInstructions, nil, *disableBell, 1024000/60)
|
||||||
|
return vid.DrawTextScreen(cpuState.MemoryMap, screen, charMap)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
showInstructions := flag.Bool("show-instructions", false, "Show instructions code while running")
|
showInstructions = flag.Bool("show-instructions", false, "Show instructions code while running")
|
||||||
disableBell := flag.Bool("disable-bell", false, "Disable bell")
|
disableBell = flag.Bool("disable-bell", false, "Disable bell")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
cpu.InitDisasm()
|
cpu.InitDisasm()
|
||||||
memory := mmu.InitRAM()
|
memory := mmu.InitRAM()
|
||||||
mmu.InitApple2eROM(memory)
|
mmu.InitApple2eROM(memory)
|
||||||
|
|
||||||
var s cpu.State
|
cpuState.Memory = memory
|
||||||
s.Memory = memory
|
cpuState.MemoryMap = &memory.MemoryMap
|
||||||
s.MemoryMap = &memory.MemoryMap
|
cpuState.Init()
|
||||||
s.Init()
|
|
||||||
|
|
||||||
bootVector := 0xfffc
|
bootVector := 0xfffc
|
||||||
lsb := (*s.MemoryMap)[uint8(bootVector>>8)][uint8(bootVector&0xff)] // TODO move readMemory to mmu
|
lsb := (*cpuState.MemoryMap)[uint8(bootVector>>8)][uint8(bootVector&0xff)] // TODO move readMemory to mmu
|
||||||
msb := (*s.MemoryMap)[uint8((bootVector+1)>>8)][uint8((bootVector+1)&0xff)]
|
msb := (*cpuState.MemoryMap)[uint8((bootVector+1)>>8)][uint8((bootVector+1)&0xff)]
|
||||||
s.PC = uint16(lsb) + uint16(msb)<<8
|
cpuState.PC = uint16(lsb) + uint16(msb)<<8
|
||||||
cpu.Run(&s, *showInstructions, nil, *disableBell, 0)
|
|
||||||
|
var err error
|
||||||
|
charMap, _, err = ebitenutil.NewImageFromFile("./pr-latin1.png", ebiten.FilterNearest)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ebiten.Run(update, 280*screenSizeFactor, 192*screenSizeFactor, 2, "Apple //e")
|
||||||
}
|
}
|
||||||
|
@ -176,10 +176,6 @@ func writeMemory(s *State, address uint16, value uint8) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if address >= 0x400 && address < 0x800 {
|
|
||||||
fmt.Printf("Text page write %04x: %02x\n", address, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
(*s.MemoryMap)[uint8(address>>8)][uint8(address&0xff)] = value
|
(*s.MemoryMap)[uint8(address>>8)][uint8(address&0xff)] = value
|
||||||
|
|
||||||
if RunningFunctionalTests && address == 0x200 {
|
if RunningFunctionalTests && address == 0x200 {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package main
|
package vid
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"image"
|
"image"
|
||||||
"log"
|
|
||||||
|
"mos6502go/mmu"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten"
|
"github.com/hajimehoshi/ebiten"
|
||||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -15,13 +15,11 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ebitenImage *ebiten.Image
|
|
||||||
memory [0x100000]byte
|
|
||||||
flashCounter int
|
flashCounter int
|
||||||
flashOn bool
|
flashOn bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func drawTextScreen(screen *ebiten.Image) error {
|
func DrawTextScreen(memory *mmu.MemoryMap, screen *ebiten.Image, charMap *ebiten.Image) error {
|
||||||
flashCounter--
|
flashCounter--
|
||||||
if flashCounter < 0 {
|
if flashCounter < 0 {
|
||||||
flashCounter = flashFrames
|
flashCounter = flashFrames
|
||||||
@ -36,7 +34,7 @@ func drawTextScreen(screen *ebiten.Image) error {
|
|||||||
base := 128*(y%8) + 40*(y/8)
|
base := 128*(y%8) + 40*(y/8)
|
||||||
for x := 0; x < 40; x++ {
|
for x := 0; x < 40; x++ {
|
||||||
offset := textVideoMemory + base + x
|
offset := textVideoMemory + base + x
|
||||||
value := memory[offset]
|
value := (*memory)[uint8(offset>>8)][uint8(offset&0xff)]
|
||||||
inverted := false
|
inverted := false
|
||||||
|
|
||||||
if (value & 0xc0) == 0 {
|
if (value & 0xc0) == 0 {
|
||||||
@ -72,7 +70,7 @@ func drawTextScreen(screen *ebiten.Image) error {
|
|||||||
|
|
||||||
op.ColorM.Scale(0.20, 0.75, 0.20, 1)
|
op.ColorM.Scale(0.20, 0.75, 0.20, 1)
|
||||||
|
|
||||||
if err := screen.DrawImage(ebitenImage, op); err != nil {
|
if err := screen.DrawImage(charMap, op); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,30 +78,3 @@ func drawTextScreen(screen *ebiten.Image) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func update(screen *ebiten.Image) error {
|
|
||||||
return drawTextScreen(screen)
|
|
||||||
}
|
|
||||||
|
|
||||||
func addTestTextScreenData() {
|
|
||||||
// Clear screen
|
|
||||||
for i := 0; i < 0x400; i++ {
|
|
||||||
memory[textVideoMemory+i] = 160
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := 0; i < 255; i++ {
|
|
||||||
memory[textVideoMemory+i] = byte(i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
addTestTextScreenData()
|
|
||||||
|
|
||||||
var err error
|
|
||||||
ebitenImage, _, err = ebitenutil.NewImageFromFile("./pr-latin1.png", ebiten.FilterNearest)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
ebiten.Run(update, 280*screenSizeFactor, 192*screenSizeFactor, 2, "Apple //")
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user