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:
Will Angenent 2018-05-08 22:18:49 +01:00
parent 5d1c25a724
commit 481ddf0ebf
3 changed files with 49 additions and 49 deletions

View File

@ -2,27 +2,60 @@ package main
import (
"flag"
"log"
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/ebitenutil"
"mos6502go/cpu"
"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() {
showInstructions := flag.Bool("show-instructions", false, "Show instructions code while running")
disableBell := flag.Bool("disable-bell", false, "Disable bell")
showInstructions = flag.Bool("show-instructions", false, "Show instructions code while running")
disableBell = flag.Bool("disable-bell", false, "Disable bell")
flag.Parse()
cpu.InitDisasm()
memory := mmu.InitRAM()
mmu.InitApple2eROM(memory)
var s cpu.State
s.Memory = memory
s.MemoryMap = &memory.MemoryMap
s.Init()
cpuState.Memory = memory
cpuState.MemoryMap = &memory.MemoryMap
cpuState.Init()
bootVector := 0xfffc
lsb := (*s.MemoryMap)[uint8(bootVector>>8)][uint8(bootVector&0xff)] // TODO move readMemory to mmu
msb := (*s.MemoryMap)[uint8((bootVector+1)>>8)][uint8((bootVector+1)&0xff)]
s.PC = uint16(lsb) + uint16(msb)<<8
cpu.Run(&s, *showInstructions, nil, *disableBell, 0)
lsb := (*cpuState.MemoryMap)[uint8(bootVector>>8)][uint8(bootVector&0xff)] // TODO move readMemory to mmu
msb := (*cpuState.MemoryMap)[uint8((bootVector+1)>>8)][uint8((bootVector+1)&0xff)]
cpuState.PC = uint16(lsb) + uint16(msb)<<8
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")
}

View File

@ -176,10 +176,6 @@ func writeMemory(s *State, address uint16, value uint8) {
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
if RunningFunctionalTests && address == 0x200 {

View File

@ -1,11 +1,11 @@
package main
package vid
import (
"image"
"log"
"mos6502go/mmu"
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/ebitenutil"
)
const (
@ -15,13 +15,11 @@ const (
)
var (
ebitenImage *ebiten.Image
memory [0x100000]byte
flashCounter int
flashOn bool
)
func drawTextScreen(screen *ebiten.Image) error {
func DrawTextScreen(memory *mmu.MemoryMap, screen *ebiten.Image, charMap *ebiten.Image) error {
flashCounter--
if flashCounter < 0 {
flashCounter = flashFrames
@ -36,7 +34,7 @@ func drawTextScreen(screen *ebiten.Image) error {
base := 128*(y%8) + 40*(y/8)
for x := 0; x < 40; x++ {
offset := textVideoMemory + base + x
value := memory[offset]
value := (*memory)[uint8(offset>>8)][uint8(offset&0xff)]
inverted := false
if (value & 0xc0) == 0 {
@ -72,7 +70,7 @@ func drawTextScreen(screen *ebiten.Image) error {
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
}
}
@ -80,30 +78,3 @@ func drawTextScreen(screen *ebiten.Image) error {
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 //")
}