added cartridge jpgs and gui elements
After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 75 KiB |
After Width: | Height: | Size: 106 KiB |
After Width: | Height: | Size: 69 KiB |
After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 81 KiB |
After Width: | Height: | Size: 73 KiB |
After Width: | Height: | Size: 144 KiB |
After Width: | Height: | Size: 58 KiB |
After Width: | Height: | Size: 79 KiB |
After Width: | Height: | Size: 134 KiB |
Before Width: | Height: | Size: 222 KiB |
|
@ -1,24 +1,35 @@
|
|||
--TODO: Fix color pallet issue... the color pallet should be set to a known (maybe default) value for the GUI every time so it does not change depending on the previously
|
||||
--loaded game. i.e. fix the cream not white issue observed with loz2/smb setup!!
|
||||
|
||||
local gd = require("gd")
|
||||
|
||||
emu.print("Go Gators!")
|
||||
MAX_SCREEN_WIDTH = 256
|
||||
MAX_SCREEN_HEIGHT = 240
|
||||
MAX_PER_PAGE = 6
|
||||
CART_WIDTH = 30
|
||||
CART_HEIGHT = 30
|
||||
DRAWER_OFFSET_X = 10
|
||||
DRAWER_OFFSET_Y = 10
|
||||
DRAWER_OFFSET_X = 20
|
||||
DRAWER_OFFSET_Y = 75
|
||||
DRAWER_BUFFER_X = 10
|
||||
DRAWER_BUFFER_Y = 10
|
||||
DRAWER_WIDTH = 3*DRAWER_BUFFER_X + 2*CART_WIDTH
|
||||
DRAWER_HEIGHT = 4*DRAWER_BUFFER_Y + 3*CART_HEIGHT
|
||||
PAGE_LEFT = {x = DRAWER_OFFSET_X + CART_WIDTH + DRAWER_BUFFER_X - 10, y = DRAWER_OFFSET_Y + DRAWER_HEIGHT - 4}
|
||||
PAGE_RIGHT = {x = DRAWER_OFFSET_X + CART_WIDTH + DRAWER_BUFFER_X + 16, y = DRAWER_OFFSET_Y + DRAWER_HEIGHT - 4}
|
||||
|
||||
local currPage = 1
|
||||
local cart = {x1=50, y1=50, x2=100, y2=100}
|
||||
local console = {x1=150, y1=50, x2=200, y2=100}
|
||||
local console = {x1=150, y1=75, x2=200, y2=125}
|
||||
local unloadButton = {x1 = 220, y1 = 220, x2 = 250, y2 = 230}
|
||||
local ejectInsertButton = {x1 = 5, y1 = 220, x2 = 64, y2 = 230}
|
||||
local switchButton = {x1 = 180, y1 = 220, x2 = 210, y2 = 230}
|
||||
local selectedRom = nil
|
||||
local wasClicked = false
|
||||
local lmbWasPressed = false
|
||||
|
||||
local FAMICOM_Roms = {}
|
||||
FAMICOM_Roms[1] = {}
|
||||
local romDir = [[../../../emugator/ROMs/]]
|
||||
local romCartDir = [[../../../emugator/ROM_Carts/]]
|
||||
|
||||
|
@ -28,7 +39,13 @@ local pageNumber = 1
|
|||
local pageSlot = 1
|
||||
|
||||
for rom in io.popen([[dir "]] ..romDir.. [[" /b]]):lines() do
|
||||
local dot = string.find(rom, "%.")
|
||||
local dot = nil
|
||||
local dotPos = 0
|
||||
while(true) do
|
||||
dotPos = string.find(rom, "%.", dotPos + 1)
|
||||
if(dotPos == nil) then break end
|
||||
dot = dotPos
|
||||
end
|
||||
ext = nil
|
||||
if(dot ~= nil) then
|
||||
ext = string.sub(rom, dot, -1)
|
||||
|
@ -55,7 +72,7 @@ for rom in io.popen([[dir "]] ..romDir.. [[" /b]]):lines() do
|
|||
end
|
||||
|
||||
if(srcImg == nil) then
|
||||
dstImg:filledRectangle(0, 0, CART_WIDTH-1, CART_HEIGHT-1)
|
||||
dstImg:filledRectangle(0, 0, CART_WIDTH-1, CART_HEIGHT-1, 255)
|
||||
else
|
||||
dstImg:copyResized(srcImg, 0, 0, 0, 0, CART_WIDTH, CART_HEIGHT, srcImg:sizeX(), srcImg:sizeY())
|
||||
end
|
||||
|
@ -70,6 +87,10 @@ for rom in io.popen([[dir "]] ..romDir.. [[" /b]]):lines() do
|
|||
end
|
||||
end
|
||||
|
||||
if(pageSlot == 1) then
|
||||
pageNumber = pageNumber - 1
|
||||
end
|
||||
|
||||
--Main Loop
|
||||
while(true) do
|
||||
local inpt = input.read()
|
||||
|
@ -77,17 +98,39 @@ while(true) do
|
|||
if(emu.emulating() == false) then --should be changed to allow gui to be swaped to while emulating. maybe check if paused?
|
||||
wasClicked = false
|
||||
|
||||
--draw gui background
|
||||
gui.rect(0, 0, MAX_SCREEN_WIDTH-1, MAX_SCREEN_HEIGHT-1,"grey")
|
||||
local srcImg = gd.createFromPng("gui/DrjMicroMusuem.png"):gdStr()
|
||||
gui.gdoverlay(20, 20, srcImg)
|
||||
|
||||
gui.rect(DRAWER_OFFSET_X, DRAWER_OFFSET_Y, DRAWER_OFFSET_X + DRAWER_WIDTH, DRAWER_OFFSET_Y + DRAWER_HEIGHT + 5,"blue", "white")
|
||||
gui.text(DRAWER_OFFSET_X + CART_WIDTH + DRAWER_BUFFER_X - 3, DRAWER_OFFSET_Y + DRAWER_HEIGHT - 5, currPage.. "/" ..pageNumber, "white", "blue")
|
||||
|
||||
local leftArrow = gd.createFromPng("gui/arrow.png")
|
||||
local rightArrow = gd.create(leftArrow:sizeX(), leftArrow:sizeY())
|
||||
|
||||
rightArrow:copyRotated(leftArrow, rightArrow:sizeX()/2, rightArrow:sizeY()/2, 0, 0, leftArrow:sizeX(), leftArrow:sizeY(), 180)
|
||||
gui.gdoverlay(PAGE_RIGHT.x, PAGE_RIGHT.y, rightArrow:gdStr())
|
||||
gui.gdoverlay(PAGE_LEFT.x, PAGE_LEFT.y, leftArrow:gdStr())
|
||||
|
||||
--Load Cartridge if dropped on Console
|
||||
if (inpt.leftclick == nil) then
|
||||
if((inpt.xmouse > console.x1) and (inpt.xmouse < console.x2) and (inpt.ymouse > console.y1) and (inpt.ymouse < console.y2) and selectedRom ~= nil) then
|
||||
emu.loadrom(romDir ..FAMICOM_Roms[currPage][selectedRom].rom)
|
||||
elseif((inpt.xmouse > PAGE_LEFT.x) and (inpt.xmouse < PAGE_LEFT.x + leftArrow:sizeX()) and (inpt.ymouse > PAGE_LEFT.y) and (inpt.ymouse < PAGE_LEFT.y + leftArrow:sizeY()) and selectedRom == nil and lmbWasPressed) then
|
||||
if(currPage > 1) then
|
||||
currPage = currPage - 1
|
||||
end
|
||||
elseif((inpt.xmouse > PAGE_RIGHT.x) and (inpt.xmouse < PAGE_RIGHT.x + rightArrow:sizeX()) and (inpt.ymouse > PAGE_RIGHT.y) and (inpt.ymouse < PAGE_RIGHT.y + rightArrow:sizeY()) and selectedRom == nil and lmbWasPressed) then
|
||||
if(currPage < pageNumber) then
|
||||
currPage = currPage + 1
|
||||
end
|
||||
end
|
||||
|
||||
if(selectedRom ~= nil) then
|
||||
FAMICOM_Roms[currPage][selectedRom].isSelected = false
|
||||
selectedRom = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--Draw Cartridges
|
||||
|
@ -118,6 +161,8 @@ while(true) do
|
|||
gui.rect(console.x1, console.y1, console.x2, console.y2, "blue", "white")
|
||||
gui.text(console.x1 + 9, console.y1 + 16, "Famicom\n/NES")
|
||||
|
||||
lmbWasPressed = inpt.leftclick ~= nil
|
||||
|
||||
emugator.yieldwithflag() -- call this if you want the script to run without emulation (game running)
|
||||
else
|
||||
gui.rect(unloadButton.x1, unloadButton.y1, unloadButton.x2, unloadButton.y2, "blue", "white")
|
||||
|
|
Before Width: | Height: | Size: 70 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 94 B |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 256 B |
|
@ -2,8 +2,8 @@ local gd = require("gd")
|
|||
|
||||
while(true) do
|
||||
|
||||
local im = gd.createFromJpeg("superMarioBros.jpg"):gdStr()
|
||||
gui.gdoverlay(im)
|
||||
|
||||
local im = gd.createFromJpeg("gui/famicom.jpg")
|
||||
--gui.gdoverlay(0, 3, im:gdStr())
|
||||
gui.rect(20, 20, 256-20, 60 , "white")
|
||||
emugator.yieldwithflag()
|
||||
end
|
Before Width: | Height: | Size: 125 KiB |