mirror of
https://github.com/JetSetIlly/Gopher2600.git
synced 2024-06-23 15:03:14 -04:00
cartridge RAM window now appears under cartridge specific menu along
with any registers and static areas
This commit is contained in:
parent
744050c1ef
commit
4422f195e8
|
@ -105,6 +105,10 @@ func (lz *LazyCart) update() {
|
|||
lz.RAMbus, lz.HasRAMbus = lz.atomicRAMbus.Load().(bus.CartRAMbus)
|
||||
if lz.HasRAMbus {
|
||||
lz.RAM, _ = lz.atomicRAM.Load().([]bus.CartRAM)
|
||||
|
||||
// as explained in the commentary for the CartRAMbus interface, a
|
||||
// cartridge my implement the interface but not actually have any RAM.
|
||||
// we check for this here and correct the HasRAMbus boolean accordingly
|
||||
if lz.RAM == nil {
|
||||
lz.HasRAMbus = false
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ func (win *winDPCregisters) draw() {
|
|||
return
|
||||
}
|
||||
|
||||
imgui.SetNextWindowPosV(imgui.Vec2{659, 35}, imgui.ConditionFirstUseEver, imgui.Vec2{0, 0})
|
||||
imgui.SetNextWindowPosV(imgui.Vec2{633, 451}, imgui.ConditionFirstUseEver, imgui.Vec2{0, 0})
|
||||
imgui.BeginV(winDPCregistersTitle, &win.open, imgui.WindowFlagsAlwaysAutoResize)
|
||||
|
||||
// random number generator value
|
||||
|
|
|
@ -65,7 +65,7 @@ func (win *winDPCplusRegisters) draw() {
|
|||
return
|
||||
}
|
||||
|
||||
imgui.SetNextWindowPosV(imgui.Vec2{659, 35}, imgui.ConditionFirstUseEver, imgui.Vec2{0, 0})
|
||||
imgui.SetNextWindowPosV(imgui.Vec2{610, 303}, imgui.ConditionFirstUseEver, imgui.Vec2{0, 0})
|
||||
imgui.BeginV(winDPCplusRegistersTitle, &win.open, imgui.WindowFlagsAlwaysAutoResize)
|
||||
|
||||
// random number generator value
|
||||
|
|
|
@ -68,8 +68,8 @@ func (win *winCartRAM) draw() {
|
|||
return
|
||||
}
|
||||
|
||||
imgui.SetNextWindowPosV(imgui.Vec2{890, 29}, imgui.ConditionFirstUseEver, imgui.Vec2{0, 0})
|
||||
imgui.SetNextWindowSizeV(imgui.Vec2{X: 558, Y: 201}, imgui.ConditionFirstUseEver)
|
||||
imgui.SetNextWindowPosV(imgui.Vec2{616, 524}, imgui.ConditionFirstUseEver, imgui.Vec2{0, 0})
|
||||
imgui.SetNextWindowSizeV(imgui.Vec2{X: 402, Y: 232}, imgui.ConditionFirstUseEver)
|
||||
imgui.BeginV(winCartRAMTitle, &win.open, 0)
|
||||
|
||||
// no spacing between any of the drawEditByte() objects
|
||||
|
|
|
@ -118,9 +118,6 @@ func newWindowManager(img *SdlImgui) (*windowManager, error) {
|
|||
if err := addWindow(newWinRAM, true, windowMenuMain); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := addWindow(newWinCartRAM, false, windowMenuMain); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := addWindow(newWinTIA, true, windowMenuMain); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -159,9 +156,18 @@ func newWindowManager(img *SdlImgui) (*windowManager, error) {
|
|||
if err := addWindow(newWinDPCplusStatic, false, windowMenuCart); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := addWindow(newWinCartRAM, false, windowMenuCart); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// associate cartridge types with cartridge specific menus. using cartridge
|
||||
// ID as the key in the windowMenu map
|
||||
//
|
||||
// note that the name of the window menu's we use here must match the ID
|
||||
// used by the cartridge mapper.
|
||||
//
|
||||
// also note that we don't need to add the cartridge RAM window to these
|
||||
// lists. we can detect when to add that automatically
|
||||
wm.windowMenu["DPC"] = append(wm.windowMenu["DPC"], winDPCstaticTitle)
|
||||
wm.windowMenu["DPC"] = append(wm.windowMenu["DPC"], winDPCregistersTitle)
|
||||
wm.windowMenu["DPC+"] = append(wm.windowMenu["DPC+"], winDPCplusStaticTitle)
|
||||
|
@ -243,54 +249,52 @@ func (wm *windowManager) drawMenu() {
|
|||
// window menu
|
||||
if imgui.BeginMenu(windowMenuMain) {
|
||||
for _, id := range wm.windowMenu[windowMenuMain] {
|
||||
// add decorator indicating if window is currently open
|
||||
w := wm.windows[id]
|
||||
if w.isOpen() {
|
||||
// checkmark is unicode middle dot - code 00b7
|
||||
id = fmt.Sprintf("· %s", id)
|
||||
} else {
|
||||
id = fmt.Sprintf(" %s", id)
|
||||
}
|
||||
|
||||
if imgui.Selectable(id) {
|
||||
// windows in this menu are toggleable
|
||||
if w.isOpen() {
|
||||
w.setOpen(false)
|
||||
} else {
|
||||
w.setOpen(true)
|
||||
}
|
||||
}
|
||||
wm.drawMenuWindowEntry(wm.windows[id], id)
|
||||
}
|
||||
|
||||
imgui.EndMenu()
|
||||
}
|
||||
|
||||
// add cartridge specific menu
|
||||
if l, ok := wm.windowMenu[wm.img.lz.Cart.ID]; ok {
|
||||
// add cartridge specific menu if cartridge has a RAM bus or a debug bus.
|
||||
// note that debug bus windows need to have been added to the window menu
|
||||
// for the specific cartridge ID. see newWindowManager() function above
|
||||
cartSpecificMenu := wm.img.lz.Cart.HasRAMbus
|
||||
if _, ok := wm.windowMenu[wm.img.lz.Cart.ID]; ok && wm.img.lz.Cart.HasDebugBus {
|
||||
cartSpecificMenu = true
|
||||
}
|
||||
if cartSpecificMenu {
|
||||
if imgui.BeginMenu(wm.img.lz.Cart.ID) {
|
||||
for _, id := range l {
|
||||
w := wm.windows[id]
|
||||
|
||||
// decorate the menu entry with an "window open" indicator
|
||||
if w.isOpen() {
|
||||
// checkmark is unicode middle dot - code 00b7
|
||||
id = fmt.Sprintf("· %s", id)
|
||||
} else {
|
||||
id = fmt.Sprintf(" %s", id)
|
||||
}
|
||||
|
||||
if imgui.Selectable(id) {
|
||||
// windows in this menu are toggleable
|
||||
if w.isOpen() {
|
||||
w.setOpen(false)
|
||||
} else {
|
||||
w.setOpen(true)
|
||||
}
|
||||
}
|
||||
cartSpecificMenu = true
|
||||
for _, id := range wm.windowMenu[wm.img.lz.Cart.ID] {
|
||||
wm.drawMenuWindowEntry(wm.windows[id], id)
|
||||
}
|
||||
|
||||
if wm.img.lz.Cart.HasRAMbus {
|
||||
wm.drawMenuWindowEntry(wm.windows[winCartRAMTitle], winCartRAMTitle)
|
||||
}
|
||||
|
||||
imgui.EndMenu()
|
||||
}
|
||||
}
|
||||
|
||||
imgui.EndMainMenuBar()
|
||||
}
|
||||
|
||||
func (wm *windowManager) drawMenuWindowEntry(w managedWindow, id string) {
|
||||
// decorate the menu entry with an "window open" indicator
|
||||
if w.isOpen() {
|
||||
// checkmark is unicode middle dot - code 00b7
|
||||
id = fmt.Sprintf("· %s", id)
|
||||
} else {
|
||||
id = fmt.Sprintf(" %s", id)
|
||||
}
|
||||
|
||||
// window menu entries are toggleable
|
||||
if imgui.Selectable(id) {
|
||||
if w.isOpen() {
|
||||
w.setOpen(false)
|
||||
} else {
|
||||
w.setOpen(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,8 +93,12 @@ type CartStatic interface {
|
|||
// CartRAMbus is implemented for catridge mappers that have an addressable RAM
|
||||
// area. This differs from a Static area which is not addressable by the VCS.
|
||||
//
|
||||
// Note that some mappers will implement this interface but have no RAM for the
|
||||
// specific cartridge. In these case GetRAM() will return nil.
|
||||
// Note that for convenience, some mappers will implement this interface but
|
||||
// have no RAM for the specific cartridge. In these case GetRAM() will return
|
||||
// nil.
|
||||
//
|
||||
// The test for whether a specific cartridge has additional RAM should include
|
||||
// a interface type asserstion as well as checking GetRAM() == nil
|
||||
type CartRAMbus interface {
|
||||
GetRAM() []CartRAM
|
||||
PutRAM(bank int, idx int, data uint8)
|
||||
|
|
Loading…
Reference in a new issue