diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 00000000..26d33521
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/fceux.iml b/.idea/fceux.iml
new file mode 100644
index 00000000..d0876a78
--- /dev/null
+++ b/.idea/fceux.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 00000000..105ce2da
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..d56657ad
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 00000000..5cfee3ab
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..94a25f7f
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/emugator/ROM_Carts/LegendOfZelda2_JP.jpg b/emugator/ROM_Carts/LegendOfZelda2_JP.jpg
new file mode 100644
index 00000000..90439851
Binary files /dev/null and b/emugator/ROM_Carts/LegendOfZelda2_JP.jpg differ
diff --git a/emugator/ROM_Carts/superMarioBros.jpg b/emugator/ROM_Carts/superMarioBros.jpg
new file mode 100644
index 00000000..64786fd8
Binary files /dev/null and b/emugator/ROM_Carts/superMarioBros.jpg differ
diff --git a/emugator/ROMs/LegendOfZelda2_JP.fds b/emugator/ROMs/LegendOfZelda2_JP.fds
new file mode 100644
index 00000000..744e8124
Binary files /dev/null and b/emugator/ROMs/LegendOfZelda2_JP.fds differ
diff --git a/emugator/ROMs/superMarioBros.nes b/emugator/ROMs/superMarioBros.nes
new file mode 100644
index 00000000..878ef21b
Binary files /dev/null and b/emugator/ROMs/superMarioBros.nes differ
diff --git a/output/luaScripts/emugator/PNG_transparency_demonstration_1.png b/output/luaScripts/emugator/PNG_transparency_demonstration_1.png
new file mode 100644
index 00000000..80fb9729
Binary files /dev/null and b/output/luaScripts/emugator/PNG_transparency_demonstration_1.png differ
diff --git a/output/luaScripts/emugator/cartridgeFormatter.py b/output/luaScripts/emugator/cartridgeFormatter.py
new file mode 100644
index 00000000..e69de29b
diff --git a/output/luaScripts/emugator/emugators_demo.lua b/output/luaScripts/emugator/emugators_demo.lua
index ff1ffd55..5617babb 100644
--- a/output/luaScripts/emugator/emugators_demo.lua
+++ b/output/luaScripts/emugator/emugators_demo.lua
@@ -1,38 +1,120 @@
- emu.print("Go Gators!")
- local cart = {x1=50, y1=50, x2=100, y2=100}
- local console = {x1=150, y1=50, x2=200, y2=100}
- 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 isDrag = false
- local wasClicked = false
- --local gd = require("gd")
+local gd = require("gd")
-while(true) do
- --need gd for this
- --local gdstr = gd.createFromPng("C:\Users\Super\Emugators\fceux\output\luaScripts\emugator\nesRomGeneric.png"):gdStr()
- --gui.gdoverlay(gdstr)
+emu.print("Go Gators!")
+MAX_PER_PAGE = 6
+CART_WIDTH = 30
+CART_HEIGHT = 30
+DRAWER_OFFSET_X = 10
+DRAWER_OFFSET_Y = 10
+DRAWER_BUFFER_X = 10
+DRAWER_BUFFER_Y = 10
+
+local currPage = 1
+local cart = {x1=50, y1=50, x2=100, y2=100}
+local console = {x1=150, y1=50, x2=200, y2=100}
+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 FAMICOM_Roms = {}
+local romDir = [[../../../emugator/ROMs/]]
+local romCartDir = [[../../../emugator/ROM_Carts/]]
+
+--Find ROMS
+local totalRoms = 0
+local pageNumber = 1
+local pageSlot = 1
+
+for rom in io.popen([[dir "]] ..romDir.. [[" /b]]):lines() do
+ local dot = string.find(rom, "%.")
+ ext = nil
+ if(dot ~= nil) then
+ ext = string.sub(rom, dot, -1)
+ end
+
+ if(ext == ".nes" or ext == ".fds") then
+ print("found: " ..rom)
+ if(FAMICOM_Roms[pageNumber] == nil) then
+ FAMICOM_Roms[pageNumber] = {}
+ end
+
+ local xpos = DRAWER_OFFSET_X + DRAWER_BUFFER_X*(math.floor(((pageSlot-1)%2)) + 1) + math.floor(((pageSlot-1)%2))*CART_WIDTH
+ local ypos = DRAWER_OFFSET_Y + DRAWER_BUFFER_Y*(math.floor(((pageSlot-1)/2)) + 1) + math.floor(((pageSlot-1)/2))*CART_HEIGHT
+ local name = string.sub(rom, 1, dot-1)
+ local dstImg = gd.create(CART_WIDTH, CART_HEIGHT)
+ local srcImg = gd.createFromJpeg(romCartDir ..name.. [[.jpg]])
+
+ if(srcImg == nil) then
+ srcImg = gd.createFromJpeg(romCartDir ..name.. [[.jpeg]])
+ end
+
+ if(srcImg == nil) then
+ srcImg = gd.createFromPng(romCartDir ..name.. [[.png]])
+ end
+
+ if(srcImg == nil) then
+ dstImg:filledRectangle(0, 0, CART_WIDTH-1, CART_HEIGHT-1)
+ else
+ dstImg:copyResized(srcImg, 0, 0, 0, 0, CART_WIDTH, CART_HEIGHT, srcImg:sizeX(), srcImg:sizeY())
+ end
+
+ FAMICOM_Roms[pageNumber][pageSlot] = {rom = rom, image = dstImg, name = name, x = xpos, y = ypos, slot = pageSlot, isSelected = false}
+ pageSlot = pageSlot + 1
+ if(pageSlot > MAX_PER_PAGE) then
+ pageSlot = 1
+ pageNumber = pageNumber + 1
+ end
+ totalRoms = totalRoms + 1
+ end
+end
+
+--Main Loop
+while(true) do
local inpt = input.read()
- if(emu.emulating() == false) then
+ if(emu.emulating() == false) then --should be changed to allow gui to be swaped to while emulating. maybe check if paused?
wasClicked = false
+
+ --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 isDrag) then
- emu.loadrom("LegendOfZelda2_JP.fds")
+ 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)
end
- isDrag = false
+
+ if(selectedRom ~= nil) then
+ FAMICOM_Roms[currPage][selectedRom].isSelected = false
+ selectedRom = nil
+ end
+
end
- if isDrag then
- gui.rect(inpt.xmouse, inpt.ymouse, inpt.xmouse+50, inpt.ymouse+50, "red", "white")
- gui.text(inpt.xmouse + 12, inpt.ymouse+12, "Legend\nOf\nZelda")
- elseif ((inpt.xmouse > cart.x1) and (inpt.xmouse < cart.x2) and (inpt.ymouse > cart.y1) and (inpt.ymouse < cart.y2) and inpt.leftclick) then
- isDrag = true
+ --Draw Cartridges
+ for _, rom in pairs(FAMICOM_Roms[currPage]) do
+ if(rom.isSelected == false) then
+ local gdstr = rom.image:gdStr()
+ gui.gdoverlay(rom.x, rom.y, gdstr)
+ end
+ end
+
+ if (selectedRom == nil) then
+ local index = 0
+ for _, rom in pairs(FAMICOM_Roms[currPage]) do
+ if ((inpt.xmouse > rom.x) and (inpt.xmouse < (rom.x+CART_WIDTH)) and (inpt.ymouse > rom.y) and (inpt.ymouse < (rom.y+CART_HEIGHT)) and inpt.leftclick) then
+ selectedRom = rom.slot
+ rom.isSelected = true
+ break
+ end
+ end
else
- gui.rect(cart.x1, cart.y1, cart.x2, cart.y2, "gray", "white")
- gui.text(cart.x1 + 12, cart.y1 + 12, "Legend\nof\nZelda\n2")
+ --gui.rect(inpt.xmouse, inpt.ymouse, inpt.xmouse+50, inpt.ymouse+50, "red", "white")
+ --gui.text(inpt.xmouse + 12, inpt.ymouse+12, "Legend\nOf\nZelda\nII")
+ local gdstr = FAMICOM_Roms[currPage][selectedRom].image:gdStr()
+ gui.gdoverlay(inpt.xmouse, inpt.ymouse, gdstr)
end
+ --Draw console
gui.rect(console.x1, console.y1, console.x2, console.y2, "blue", "white")
gui.text(console.x1 + 9, console.y1 + 16, "Famicom\n/NES")
diff --git a/output/luaScripts/emugator/geometry2Dshapes.png b/output/luaScripts/emugator/geometry2Dshapes.png
new file mode 100644
index 00000000..836e6914
Binary files /dev/null and b/output/luaScripts/emugator/geometry2Dshapes.png differ
diff --git a/output/luaScripts/emugator/nesRomGeneric.png b/output/luaScripts/emugator/nesRomGeneric.png
index d31c400d..04076efd 100644
Binary files a/output/luaScripts/emugator/nesRomGeneric.png and b/output/luaScripts/emugator/nesRomGeneric.png differ
diff --git a/output/luaScripts/emugator/scratch.lua b/output/luaScripts/emugator/scratch.lua
new file mode 100644
index 00000000..e29cbbe5
--- /dev/null
+++ b/output/luaScripts/emugator/scratch.lua
@@ -0,0 +1,9 @@
+local gd = require("gd")
+
+while(true) do
+
+ local im = gd.createFromJpeg("superMarioBros.jpg"):gdStr()
+ gui.gdoverlay(im)
+
+ emugator.yieldwithflag()
+end
\ No newline at end of file
diff --git a/output/luaScripts/emugator/superMarioBros.jpg b/output/luaScripts/emugator/superMarioBros.jpg
new file mode 100644
index 00000000..64786fd8
Binary files /dev/null and b/output/luaScripts/emugator/superMarioBros.jpg differ
diff --git a/vc/vc14_fceux.sln b/vc/vc14_fceux.sln
index 87a0b3db..4c12f59f 100644
--- a/vc/vc14_fceux.sln
+++ b/vc/vc14_fceux.sln
@@ -1,6 +1,8 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
+# Visual Studio Version 17
+VisualStudioVersion = 17.3.32825.248
+MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fceux", "vc14_fceux.vcxproj", "{6893EF44-FEA3-46DF-B236-C4C200F54294}"
EndProject
Global
@@ -15,8 +17,8 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6893EF44-FEA3-46DF-B236-C4C200F54294}.Debug|Win32.ActiveCfg = Debug|Win32
{6893EF44-FEA3-46DF-B236-C4C200F54294}.Debug|Win32.Build.0 = Debug|Win32
- {6893EF44-FEA3-46DF-B236-C4C200F54294}.Debug|x64.ActiveCfg = Debug|x64
- {6893EF44-FEA3-46DF-B236-C4C200F54294}.Debug|x64.Build.0 = Debug|x64
+ {6893EF44-FEA3-46DF-B236-C4C200F54294}.Debug|x64.ActiveCfg = Debug|Win32
+ {6893EF44-FEA3-46DF-B236-C4C200F54294}.Debug|x64.Build.0 = Debug|Win32
{6893EF44-FEA3-46DF-B236-C4C200F54294}.PublicRelease|Win32.ActiveCfg = PublicRelease|Win32
{6893EF44-FEA3-46DF-B236-C4C200F54294}.PublicRelease|Win32.Build.0 = PublicRelease|Win32
{6893EF44-FEA3-46DF-B236-C4C200F54294}.PublicRelease|x64.ActiveCfg = PublicRelease|x64
@@ -29,4 +31,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {88B51FA7-225E-47B0-AE28-52E983BCFC27}
+ EndGlobalSection
EndGlobal