Graphics.init() -- Init GPU
Sound.init() -- init Sound
white = Color.new(255,255,255)
black = Color.new(0,0,0)
red = Color.new(255,0,0)
blue = Color.new(0,0,255)
green = Color.new(0,255,0)
c00 = Color.new(226,90,90) --red
c15 = Color.new(30,38,15)
c30 = Color.new(61,76,30)
c45 = Color.new(92,114,45)
c60 = Color.new(123,153,61)
c75 = Color.new(154,191,76)
c90 = Color.new(183,229,91)
oldpad = Controls.read()
--LOAD RESOURCES /////////////////////////////////////////
img_cli_background = Screen.loadImage(System.currentDirectory().."/images/cli_background.png")
img_cli_header = Screen.loadImage(System.currentDirectory().."/images/cli_header.png")
img_menu_background = Screen.loadImage(System.currentDirectory().."/images/menu_background.png")
img_menu_main = Screen.loadImage(System.currentDirectory().."/images/menu_main.png")
img_arc_logingui = Screen.loadImage(System.currentDirectory().."/images/arc_logingui.png")
img_arc_uploader = Screen.loadImage(System.currentDirectory().."/images/arc_uploader.png")
img_arc_uploader_pip = Screen.loadImage(System.currentDirectory().."/images/arc_uploader_pip.png")
img_blank = Screen.createImage(20,20,white)
wav_boot = Sound.openWav(System.currentDirectory().."/sounds/boot.wav")
fnt_small = Font.load(System.currentDirectory().."/fonts/3by5.ttf")
Font.setPixelSizes(fnt_small,5)
dofile(System.currentDirectory().."/gamedata/ds_queue_init.lua")
q_commands = {}
--q_commands.value = {}
q_commands.fontcol = {}
ds_queue_create(q_commands)
--ds_queue_create(q_commands.value)
ds_queue_create(q_commands.fontcol)
dofile(System.currentDirectory().."/gamedata/text_init.lua")
ds_queue_stack(q_commands,txt.startup)
ds_queue_stack(q_commands.fontcol,txt.startup.fontcol)
dofile(System.currentDirectory().."/gamedata/fps_init.lua")
redraw = 2
--redraw = {}
--redraw[TOP_SCREEN] = 2
--redraw[BOTTOM_SCREEN] = 2
dofile(System.currentDirectory().."/gamedata/commands_init.lua")
--////////////////////////////////////////////////////////
--Programs and Gui
--////////////////////////////////////////////////////////
topscreen_enabled = false
logingui_arc = false
mainmenu_arc = false
filebrowser_arc = false
bbs_arc = false
rvemail_arc = false
keyboard_arc = false
uploader_arc = false
biosbusy = false
local i = 1
cli_text = {}
repeat
cli_text[i] = ''
--cli_text[i].value = {} --the value table is used for customizable data per line... not needed yet
cli_text[i+50] = c30 --plus 50 is the magic number for "font"
i = i+1
until i==35
cli_text.index = 0
--BOOT SECT--
boot = false
debugstr = ''
while true do
pad = Controls.read()
tx,ty = Controls.readTouch()
if boot == false then --PRE BOOT STAGE/////////////////////////////////////////
Screen.waitVblankStart()
Screen.refresh()
Screen.clear(TOP_SCREEN)
Screen.clear(BOTTOM_SCREEN)
Screen.debugPrint(6,6,"Press X to launch RomanVault", white, TOP_SCREEN)
if (Controls.check(pad,KEY_X)) then
boot = true
Screen.clear(TOP_SCREEN)
Screen.clear(BOTTOM_SCREEN)
--Sound.play(wav_boot,NO_LOOP,0x09)
end
if (Controls.check(pad,KEY_SELECT)) and not (Controls.check(oldpad,KEY_SELECT)) then
local user = System.getUsername()
--System.addNotification("Welcome",user..", RomanVault awaits you.")
end
else --/////////////////////////////////////////////////////////////////////////
--if (Controls.check(pad,KEY_B)) and not (Controls.check(oldpad,KEY_B)) then
-- Screen.saveBitmap(bitmap2,"/bitmap.bmp")
-- System.takeScreenshot("/screenshot.bmp",false)
--end
--SHIFTING QUEUED COMMANDS TO THE COMMAND LINE INTERFACE
if q_commands.size > 0 and biosbusy == false then
if cli_text.index == 24 then --we shift all the lines down, and then add the new line to 35
--redraw=2
local i = 1
repeat
cli_text[i] = cli_text[i+1]
cli_text[i+50] = cli_text[i+1+50]
--cli_text[i].value = cli_text[i+1].value
i = i+1
until i==24
local str = ds_queue_dequeue(q_commands)
str = read_command(str)
cli_text[i] = str
--cli_text[i] = ds_queue_dequeue(q_commands)
cli_text[i+50] = ds_queue_dequeue(q_commands.fontcol)
--cli_text[i].value = ds_queue_dequeue(q_commands.value)
else --we add the value to the index and add one to index
--redraw=1
cli_text.index = cli_text.index + 1
local str = ds_queue_dequeue(q_commands)
str = read_command(str)
cli_text[cli_text.index] = str
--cli_text[cli_text.index] = ds_queue_dequeue(q_commands)
cli_text[cli_text.index +50] = ds_queue_dequeue(q_commands.fontcol)
end
end
if biosbusy == true then
--bios queued commands here
process_command()
end
--START OF DRAW FUNCTIONS/////////////////////////////
Screen.waitVblankStart()
Screen.refresh()
--Screen.clear(TOP_SCREEN)
--Screen.clear(BOTTOM_SCREEN)
--if redraw == 2 then
Screen.clear(TOP_SCREEN)
Screen.clear(BOTTOM_SCREEN)
--end
--if redraw[TOP_SCREEN] ==2 then Screen.clear(TOP_SCREEN) end
--if redraw[BOTTOM_SCREEN]==2 then Screen.clear(BOTTOM_SCREEN) end
Screen.debugPrint(6,20,"q_commands.size = "..q_commands.size, white, TOP_SCREEN)
Screen.debugPrint(6,34,"debugstr = "..debugstr, white, TOP_SCREEN)
--TOP SCREEN//////////////////////////////////////////
if topscreen_enabled then
--if redraw==2 then
Screen.drawImage(0,0,img_menu_background,TOP_SCREEN)
Screen.drawImage(0,0,img_menu_main,TOP_SCREEN)
--end
end
fps_draw()
--BOTTOM SCREEN///////////////////////////////////////
--if redraw==2 then
Screen.drawImage(0,0,img_cli_background,BOTTOM_SCREEN)
Screen.drawImage(0,0,img_cli_header,BOTTOM_SCREEN)
--end
--if redraw>1 then
local i=1
while i < cli_text.index + 1 do
if cli_text[i] ~= nil then --as long as the line actually has text in it? Otherwise it errors
Font.print(fnt_small, 1, 6*i +15, cli_text[i],cli_text[i+50],BOTTOM_SCREEN)
end
i=i+1
end
if logingui_arc then
Screen.drawImage(0,0,img_arc_logingui,BOTTOM_SCREEN)
end
if uploader_arc then
Screen.drawImage(87,105,img_arc_uploader,BOTTOM_SCREEN)
local i = 0
while i < uploader_arc_progress do
Screen.drawImage(97+(i*3),117,img_arc_uploader_pip,BOTTOM_SCREEN)
i = i+1
end
end
--end
--END OF DRAW FUNCTION/////////////////////////////////
--redraw[TOP_SCREEN] = 0
--redraw[BOTTOM_SCREEN] = 0
--redraw=0
--/////
end
--THESE FUNCTIONS ALWAYS RUN///////////////////////////////
if (Controls.check(pad,KEY_START)) then --shutdown sequence
Graphics.term()
Sound.close(wav_boot)
Sound.term()
System.exit()
end
Screen.flip()
oldpad = pad
end