tridoraemu: enable debug display via F12

This commit is contained in:
slederer 2025-09-13 22:59:21 +02:00
parent d2cae9480c
commit b2c2e8dc0c
3 changed files with 29 additions and 6 deletions

View file

@ -125,7 +125,7 @@ func (c *CPU) step() error {
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 c.PC % 4 == 0 {
insWord = insWord >> 16

View file

@ -17,6 +17,12 @@ const IOSlotSize = 128
const IOSlotCount = 16
const DRAMStart = 65536
const CacheAddrShift = 8
const CacheWriteThrough = true
type Mem struct {
ram [] word
iohandler [IOSlotCount] IOHandler
@ -79,7 +85,7 @@ func (m *Mem) attachIO(h IOHandler, slot int) {
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 {
ioslot := (byteaddr - IOStartAddr) / IOSlotSize
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 {
if byteaddr < IOStartAddr {
return fmt.Errorf("Write to ROM area at %08X value %08X", byteaddr, value)

View file

@ -8,7 +8,8 @@ import (
"flag"
"time"
"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"
)
@ -35,6 +36,7 @@ func idle(canGoIdle bool) {
}
type Game struct{
debug bool
x,y int
stepsPerFrame int
lastFrameDuration time.Duration
@ -58,16 +60,23 @@ func (g *Game) Update() error {
}
g.lastFrameDuration = time.Since(startTime)
if inpututil.IsKeyJustReleased(ebiten.KeyF12) {
g.debug = !g.debug
}
return nil
}
func (g *Game) Draw(screen *ebiten.Image) {
screen.DrawImage(framebuffer.framebuffer, nil)
/*
buf := fmt.Sprintf("PC: %08X FP: %08X RP: %08X ESP: %2X\n%v", cpu.PC, cpu.FP, cpu.RP, cpu.ESP, g.lastFrameDuration)
if g.debug {
buf := fmt.Sprintf("PC: %08X FP: %08X RP: %08X ESP: %2X %v",
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+1, color.RGBA{0,255,0,0})
screen.Set(g.x, g.y+2, color.RGBA{0,255,255,0})