tridoraemu: enable debug display via F12
This commit is contained in:
parent
d2cae9480c
commit
b2c2e8dc0c
3 changed files with 29 additions and 6 deletions
|
|
@ -125,7 +125,7 @@ func (c *CPU) step() error {
|
||||||
|
|
||||||
Y := c.estack[c.ESP]
|
Y := c.estack[c.ESP]
|
||||||
|
|
||||||
insWord, err := c.mem.read(c.PC)
|
insWord, err := c.mem.readIns(c.PC)
|
||||||
if err != nil { return err }
|
if err != nil { return err }
|
||||||
if c.PC % 4 == 0 {
|
if c.PC % 4 == 0 {
|
||||||
insWord = insWord >> 16
|
insWord = insWord >> 16
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,12 @@ const IOSlotSize = 128
|
||||||
|
|
||||||
const IOSlotCount = 16
|
const IOSlotCount = 16
|
||||||
|
|
||||||
|
const DRAMStart = 65536
|
||||||
|
|
||||||
|
const CacheAddrShift = 8
|
||||||
|
|
||||||
|
const CacheWriteThrough = true
|
||||||
|
|
||||||
type Mem struct {
|
type Mem struct {
|
||||||
ram [] word
|
ram [] word
|
||||||
iohandler [IOSlotCount] IOHandler
|
iohandler [IOSlotCount] IOHandler
|
||||||
|
|
@ -79,7 +85,7 @@ func (m *Mem) attachIO(h IOHandler, slot int) {
|
||||||
m.iohandler[slot] = h
|
m.iohandler[slot] = h
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Mem) read(byteaddr word) (word, error) {
|
func (m *Mem) readRaw(byteaddr word) (word, error) {
|
||||||
if byteaddr >= IOStartAddr && byteaddr < RAMStartAddr {
|
if byteaddr >= IOStartAddr && byteaddr < RAMStartAddr {
|
||||||
ioslot := (byteaddr - IOStartAddr) / IOSlotSize
|
ioslot := (byteaddr - IOStartAddr) / IOSlotSize
|
||||||
if m.iohandler[ioslot] != nil {
|
if m.iohandler[ioslot] != nil {
|
||||||
|
|
@ -96,6 +102,14 @@ func (m *Mem) read(byteaddr word) (word, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Mem) read(byteaddr word) (word, error) {
|
||||||
|
return m.readRaw(byteaddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Mem) readIns(byteaddr word) (word, error) {
|
||||||
|
return m.readRaw(byteaddr);
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Mem) write(value word, byteaddr word) error {
|
func (m *Mem) write(value word, byteaddr word) error {
|
||||||
if byteaddr < IOStartAddr {
|
if byteaddr < IOStartAddr {
|
||||||
return fmt.Errorf("Write to ROM area at %08X value %08X", byteaddr, value)
|
return fmt.Errorf("Write to ROM area at %08X value %08X", byteaddr, value)
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"time"
|
"time"
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
"github.com/hajimehoshi/ebiten/v2"
|
||||||
// "github.com/hajimehoshi/ebiten/v2/ebitenutil"
|
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
|
||||||
|
"github.com/hajimehoshi/ebiten/v2/inpututil"
|
||||||
// "image/color"
|
// "image/color"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -35,6 +36,7 @@ func idle(canGoIdle bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Game struct{
|
type Game struct{
|
||||||
|
debug bool
|
||||||
x,y int
|
x,y int
|
||||||
stepsPerFrame int
|
stepsPerFrame int
|
||||||
lastFrameDuration time.Duration
|
lastFrameDuration time.Duration
|
||||||
|
|
@ -58,16 +60,23 @@ func (g *Game) Update() error {
|
||||||
}
|
}
|
||||||
g.lastFrameDuration = time.Since(startTime)
|
g.lastFrameDuration = time.Since(startTime)
|
||||||
|
|
||||||
|
if inpututil.IsKeyJustReleased(ebiten.KeyF12) {
|
||||||
|
g.debug = !g.debug
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) Draw(screen *ebiten.Image) {
|
func (g *Game) Draw(screen *ebiten.Image) {
|
||||||
screen.DrawImage(framebuffer.framebuffer, nil)
|
screen.DrawImage(framebuffer.framebuffer, nil)
|
||||||
|
|
||||||
/*
|
if g.debug {
|
||||||
buf := fmt.Sprintf("PC: %08X FP: %08X RP: %08X ESP: %2X\n%v", cpu.PC, cpu.FP, cpu.RP, cpu.ESP, g.lastFrameDuration)
|
buf := fmt.Sprintf("PC: %08X FP: %08X RP: %08X ESP: %2X %v",
|
||||||
ebitenutil.DebugPrint(screen, buf)
|
cpu.PC, cpu.FP, cpu.RP, cpu.ESP, g.lastFrameDuration)
|
||||||
|
ebitenutil.DebugPrint(screen, buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
screen.Set(g.x, g.y, color.RGBA{255,0,0,0})
|
screen.Set(g.x, g.y, color.RGBA{255,0,0,0})
|
||||||
screen.Set(g.x, g.y+1, color.RGBA{0,255,0,0})
|
screen.Set(g.x, g.y+1, color.RGBA{0,255,0,0})
|
||||||
screen.Set(g.x, g.y+2, color.RGBA{0,255,255,0})
|
screen.Set(g.x, g.y+2, color.RGBA{0,255,255,0})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue