mirror of
https://github.com/JetSetIlly/Gopher2600.git
synced 2025-04-02 11:02:17 -04:00
47 lines
950 B
Go
47 lines
950 B
Go
package debugger
|
|
|
|
import (
|
|
"gopher2600/errors"
|
|
"gopher2600/hardware"
|
|
"gopher2600/television"
|
|
)
|
|
|
|
// defines which types are valid targets
|
|
type target interface {
|
|
Label() string
|
|
ShortLabel() string
|
|
ToInt() int
|
|
}
|
|
|
|
// parseTarget uses a keyword to decide which part of the vcs to target
|
|
func parseTarget(vcs *hardware.VCS, keyword string) (target, error) {
|
|
var trg target
|
|
var err error
|
|
|
|
switch keyword {
|
|
case "PC":
|
|
trg = vcs.MC.PC
|
|
case "A":
|
|
trg = vcs.MC.A
|
|
case "X":
|
|
trg = vcs.MC.X
|
|
case "Y":
|
|
trg = vcs.MC.Y
|
|
case "SP":
|
|
trg = vcs.MC.SP
|
|
case "FRAMENUM", "FRAME", "FR":
|
|
trg, err = vcs.TV.RequestTVState(television.ReqFramenum)
|
|
case "SCANLINE", "SL":
|
|
trg, err = vcs.TV.RequestTVState(television.ReqScanline)
|
|
case "HORIZPOS", "HP":
|
|
trg, err = vcs.TV.RequestTVState(television.ReqHorizPos)
|
|
default:
|
|
return nil, errors.NewGopherError(errors.InvalidTarget, keyword)
|
|
}
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return trg, nil
|
|
}
|