Skip to content

Commit

Permalink
Added images.
Browse files Browse the repository at this point in the history
Added show border feature
  • Loading branch information
abbruzze committed Jul 23, 2024
1 parent d062f86 commit f2bc9a7
Show file tree
Hide file tree
Showing 47 changed files with 54 additions and 9 deletions.
Binary file added images/Earthworm.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/aladdin.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/anotherworld.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/atomicrunner.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/batman_robin.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/battlemania2.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/castelvania.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/comix.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/debugger.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/dragonball.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/dukenukem.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/fifa98.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/flashback.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/formula1.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ghost.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/gunstarheroes.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/lemmings.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/lighteningforce.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/megaturrican.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/mk1.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/nbajam.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/outrun.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/pop.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/roadrash.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/rocketnight.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/shinobi3.PNG
Binary file added images/skeletoncrew.PNG
Binary file added images/sonic1.PNG
Binary file added images/sonic2.PNG
Binary file added images/sonic3.PNG
Binary file added images/sonic3d.PNG
Binary file added images/ssf2.PNG
Binary file added images/streeracer.PNG
Binary file added images/streetfight2.PNG
Binary file added images/streetofrage3.PNG
Binary file added images/streetsofrage.PNG
Binary file added images/subterrania.PNG
Binary file added images/titanoverdrive.PNG
Binary file added images/titanoverdrive2.PNG
Binary file added images/vectorman.PNG
Binary file added images/virtuafighter2.PNG
Binary file added images/vr.PNG
Binary file added images/wolfstein3d.PNG
22 changes: 19 additions & 3 deletions src/ucesoft/smd/Model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,29 @@ enum VideoType(val clockFrequency:Int,
final def bottomBorderPos(v30:Boolean): Int =
topBlankingPixels + topBorderPixels + (if v30 then 240 else 224)

final def getClipArea(h40:Boolean): DisplayClipArea =
final def getClipArea(h40:Boolean,keepBorder:Boolean): DisplayClipArea =
if h40 then
// remaining hsync = 4, left black = 32, left border = 13, display = 320, right border = 14
DisplayClipArea(32 + 4,topBlankingPixels,379 + 4,topBlankingPixels + topBorderPixels + maxActiveLines + bottomBorderPixels)
inline val hsync = 4
inline val leftBlack = 32
inline val leftBorder = 13
inline val displayWidth = 320
inline val rightBorder = 14
if keepBorder then
DisplayClipArea(leftBlack + hsync,topBlankingPixels,displayWidth + leftBlack + leftBorder + rightBorder + hsync,topBlankingPixels + topBorderPixels + maxActiveLines + bottomBorderPixels)
else
DisplayClipArea(leftBlack + hsync + leftBorder,topBlankingPixels + topBorderPixels,displayWidth + leftBlack + leftBorder + hsync,topBlankingPixels + topBorderPixels + maxActiveLines)
else
// remaining hsync = 10, left black = 24, left border = 13, display = 256, right border = 14
DisplayClipArea(24 + 10,topBlankingPixels,307 + 10,topBlankingPixels + topBorderPixels + maxActiveLines + bottomBorderPixels)
inline val hsync = 10
inline val leftBlack = 24
inline val leftBorder = 13
inline val displayWidth = 256
inline val rightBorder = 14
if keepBorder then
DisplayClipArea(leftBlack + hsync,topBlankingPixels,displayWidth + leftBlack + leftBorder + rightBorder + hsync,topBlankingPixels + topBorderPixels + maxActiveLines + bottomBorderPixels)
else
DisplayClipArea(leftBlack + hsync + leftBorder, topBlankingPixels + topBorderPixels, displayWidth + leftBlack + leftBorder + hsync, topBlankingPixels + topBorderPixels + maxActiveLines)

case NTSC extends VideoType(clockFrequency = 53_693_175,
topBlankingPixels = 13,
Expand Down
17 changes: 14 additions & 3 deletions src/ucesoft/smd/VDP.scala
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,18 @@ class VDP(busArbiter:BusArbiter) extends SMDComponent with Clock.Clockable with
private var lightgunProvider : LightgunProvider = scala.compiletime.uninitialized

private var svpEnabled = false

private var showBorder = true
// =================================================================================
def setShowBorder(enabled:Boolean): Unit =
showBorder = enabled
if model != null then
val clip = model.videoType.getClipArea(h40 = !REG_H32, showBorder)
if interlaceModeEnabled then
display.setClipArea(clip.getInterlacedTuple)
else
display.setClipArea(clip.getTuple)

def setSVPEnabled(enabled:Boolean): Unit =
svpEnabled = enabled
def enableLightgun(enabled:Boolean,lightgunProvider : LightgunProvider): Unit =
Expand Down Expand Up @@ -1293,11 +1304,11 @@ class VDP(busArbiter:BusArbiter) extends SMDComponent with Clock.Clockable with
interlaceModeEnabled = true
display.setInterlaceMode(true)
videoPixels = display.displayMem
display.setClipArea(model.videoType.getClipArea(h40 = !h32).getInterlacedTuple)
display.setClipArea(model.videoType.getClipArea(h40 = !h32,showBorder).getInterlacedTuple)
sendMessage("Interlace mode on")
case _ =>
display.setInterlaceMode(false)
display.setClipArea(model.videoType.getClipArea(h40 = !h32).getTuple)
display.setClipArea(model.videoType.getClipArea(h40 = !h32,showBorder).getTuple)

videoPixels = display.displayMem
interlaceModeEnabled = false
Expand All @@ -1310,7 +1321,7 @@ class VDP(busArbiter:BusArbiter) extends SMDComponent with Clock.Clockable with
if enableInfoLogging then log.info("HMode set to %s", hmode)
sendMessage(s"HMode set to $hmode")

val clip = model.videoType.getClipArea(h40 = !h32)
val clip = model.videoType.getClipArea(h40 = !h32,showBorder)
if interlaceModeEnabled then
display.setClipArea(clip.getInterlacedTuple)
else
Expand Down
1 change: 1 addition & 0 deletions src/ucesoft/smd/misc/Preferences.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ object Preferences {
val INIT_VRAM_PREF = "init-vram"
val EXTRA_RAM_DIR_PREF = "extra-ram-path"
val LOAD_SAVE_EXTRA_RAM_PREF = "load-save-extra-ram"
val SHOW_BORDER = "vdp-show-border"

class PreferenceIllegalArgumentException(msg:String) extends Exception(msg)

Expand Down
23 changes: 20 additions & 3 deletions src/ucesoft/smd/ui/MegaDriveUI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class MegaDriveUI extends MessageBus.MessageListener with CheatManager:
"3826f26" -> (Oversea,VideoType.NTSC) // Titan 1
)

private var showBorder = true

override def onMessage(msg: MessageBus.Message): Unit =
msg match
case MessageBus.CartRemoved(_,cart) if cart != null =>
Expand Down Expand Up @@ -206,7 +208,7 @@ class MegaDriveUI extends MessageBus.MessageListener with CheatManager:
// display
val display = new Display(SCREEN_WIDTH, megaDrive.model.videoType.totalLines, frame.getTitle, frame, megaDrive.masterClock)
display.setFocusable(true)
display.setClipArea(megaDrive.model.videoType.getClipArea(h40 = false).getTuple)
display.setClipArea(megaDrive.model.videoType.getClipArea(h40 = false,showBorder).getTuple)
megaDrive.setDisplay(display)
frame.getContentPane.add("Center",display)
zoom(2)
Expand Down Expand Up @@ -552,7 +554,7 @@ class MegaDriveUI extends MessageBus.MessageListener with CheatManager:

private def applyNewModel(newModel:Model): Unit =
megaDrive.display.setNewResolution(newModel.videoType.totalLines, SCREEN_WIDTH)
megaDrive.display.setPreferredSize(newModel.videoType.getClipArea(h40 = true).getPreferredSize(if zoom4CB.isSelected then 4 else 2))
megaDrive.display.setPreferredSize(newModel.videoType.getClipArea(h40 = true,showBorder).getPreferredSize(if zoom4CB.isSelected then 4 else 2))
megaDrive.display.invalidate()
frame.pack()
MessageBus.send(MessageBus.ModelChanged(this, newModel))
Expand Down Expand Up @@ -651,6 +653,14 @@ class MegaDriveUI extends MessageBus.MessageListener with CheatManager:
debuggerCB.addActionListener(_ => debugger.showDebugger(debuggerCB.isSelected))
debuggerCB.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.ALT_DOWN_MASK))
private def buildToolsMenu(toolsMenu:JMenu): Unit =
val showBorderItem = new JCheckBoxMenuItem("VDP show border")
showBorderItem.setSelected(true)
showBorderItem.addActionListener(_ => setBorder(showBorderItem.isSelected))
toolsMenu.add(showBorderItem)
megaDrive.pref.add(Preferences.SHOW_BORDER, "show border",true) { show =>
showBorderItem.setSelected(show)
showBorder = show
}
val regionMenu = new JMenu("Region")
toolsMenu.add(regionMenu)
val group = new ButtonGroup
Expand Down Expand Up @@ -835,6 +845,12 @@ class MegaDriveUI extends MessageBus.MessageListener with CheatManager:
toolsMenu.add(fixchecksumItem)
end buildToolsMenu

private def setBorder(show: Boolean): Unit =
showBorder = show
megaDrive.vdp.setShowBorder(showBorder)
zoom(if zoom4CB.isSelected then 4 else 2)
megaDrive.pref.updateWithoutNotify(Preferences.SHOW_BORDER,show)

private def buildCartMenu(cartMenu:JMenu): Unit =
val cartInfoItem = new JMenuItem("Cart info ...")
cartMenu.add(cartInfoItem)
Expand Down Expand Up @@ -887,7 +903,7 @@ class MegaDriveUI extends MessageBus.MessageListener with CheatManager:
private def zoom(factor:Int): Unit =
if factor == 4 then
zoom4CB.setSelected(true)
megaDrive.display.setPreferredSize(megaDrive.model.videoType.getClipArea(h40 = true).getPreferredSize(factor))
megaDrive.display.setPreferredSize(megaDrive.model.videoType.getClipArea(h40 = true,showBorder).getPreferredSize(factor))
megaDrive.display.invalidate()
frame.pack()
private def enableMouseCapture(enabled:Boolean): Unit =
Expand Down Expand Up @@ -1013,6 +1029,7 @@ class MegaDriveUI extends MessageBus.MessageListener with CheatManager:
fullScreenMode.setEnabled(true)
cartMenu.setEnabled(true)
MouseHider.hideMouseOn(megaDrive.display)
megaDrive.vdp.setShowBorder(showBorder)

if cheatList.nonEmpty then
JOptionPane.showConfirmDialog(frame,s"Apply ${cheatList.size} configured cheats on this cartridge ?","Cheats confirm",JOptionPane.YES_NO_OPTION) match
Expand Down

0 comments on commit f2bc9a7

Please sign in to comment.