Retro Fantasy Console like thingy

The place to share and discuss your Ultibo projects.
msx80
Posts: 32
Joined: Thu Aug 02, 2018 8:38 am

Retro Fantasy Console like thingy

Postby msx80 » Fri Oct 05, 2018 9:27 pm

Well finally i have something to show. I'm working on a retro console for RPi, heavily inspired by current fantasy consoles like TIC80 or Pico8. Basically it's an environment with some drawing and input primitive (the API) that's able to run "game cartridge". Game cartridges are made of a lua program and some graphics and maps (sounds and musics too but i've not started that yet). The Lua program calls the api and works like a super simple game console.
Well it's harder to explain than to understand, but if you ever gave TIC80 a try, it's exacly like that.

The "system" has a screen resolution of 256 x 144 and 32 colors.

Here's an intro screen:

Image

This is the Lua code for the intro, just to give a taste:

Code: Select all

t = 0

function frame()
  cls(20)
  draw(0, 20,2,0,0,128,64,3)
  print("Very Early Alpha System 0.0.1", 21,61,0)
  print("Very Early Alpha System 0.0.1", 20,60,1)
 
  -- blink the string
  if (t // 30) % 2 == 0 then
    print("Press FIRE to start", 21,69,0)
    print("Press FIRE to start", 20,68,1)
  end
 
  -- move sprite across screen
  draw(0, (t // 2) % (256-16),120,0,128-16,16,16,3)
 
  t = t + 1 
end



I was able to port one of my TIC80 games and it works almost perfectly, here's a shot (with the wrong palette, but hey):

Image

Initially i was going to target RPi Zero but it looks like Lua is a little too much to get a stable 60 fps on that board. Works great on RPi2 tho.
I want to add integrated (simple) code and graphics editors just like the other fantasy consoles.
If anyone wants to give it a try just let me know and i'll create a small package.
pik33
Posts: 840
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: Retro Fantasy Console like thingy

Postby pik33 » Sun Oct 07, 2018 5:03 am

Good job :)
pjde
Posts: 426
Joined: Tue Feb 09, 2016 6:21 am
Location: Sydney, Australia

Re: Retro Fantasy Console like thingy

Postby pjde » Sun Oct 07, 2018 7:54 pm

Lua has a compile function so that the code can be precompiled before running.

Would that speeds things up?

Just a thought.

Paul
msx80
Posts: 32
Joined: Thu Aug 02, 2018 8:38 am

Re: Retro Fantasy Console like thingy

Postby msx80 » Mon Oct 08, 2018 7:28 am

I don't think so, i think Lua still compiles the code to its bytecode before executing so you'd only speed up code loading which is already pretty fast
msx80
Posts: 32
Joined: Thu Aug 02, 2018 8:38 am

Re: Retro Fantasy Console like thingy

Postby msx80 » Fri Dec 07, 2018 9:17 pm

ok, i was finally able to develop enought to show something working.

You can download the current "alpha" here

So basically, when you boot up, you get to the console main screen which is currently this one:

Image

Here you can choose some Cartridge (which are Lua programs with embedded graphics and such) to run.

There are two games included, both developed by me and ported from TIC80, one is Secret Agents which is a fairly completed game:

Image

Image

The other game is Oseo, a simple game where you have to pop baloon with your beak:

Image

Also included is the editor:

Image

The editor is a big part of the system, you can load cartridges into it, edit them live and run them. Currently is limited to only the code, but it will eventually include sprite and map editor like TIC80 or other fantasy consoles.
Currently is very crude (writing a text editor from scratch is a project in itself), it support basic editing, cursor movements and not much more. No selections, no undo, no CTRL keys except nano-style CTRL-K and CTRL-U (cut/uncut). Also scrolling is limited to vertical. But it's still somehow usable, i spent some time using it to adapt my ported games. Probably the biggest missing feature is a search function.

Cartridges interact with the system with a bunch of "system call" that handle inputs and screen drawing. The current set of API is the following (these are the freepascal signatures, in lua there are equivalents):

Code: Select all

type TApiSystem = class
  procedure draw(sheetNum,x,y,srcx,srcy,width,height,rotmir,colorKey:integer);virtual;abstract;
  function print(text:String; x,y,color:integer):integer;virtual;abstract;
  procedure rect(x,y,width,height,color:integer; fill:boolean);virtual;abstract;
  procedure cls(color:integer);virtual;abstract;
  function btn(id:integer):boolean;virtual;abstract;
  function btnp(id:integer):boolean;virtual;abstract;
  procedure key(out KeyCode:Word; out down:boolean; out modifiers:integer);virtual;abstract;
  function time():integer;virtual;abstract;
  procedure map(mapNum, sheetNum, x, y, mx, my, w, h, colorKey:integer); virtual; abstract;
  function mem(resourceType:integer; resourceNum, pos, val:integer):integer; virtual; abstract;
  procedure quit(res:string);virtual;abstract;
  function params(num:integer):string;virtual;abstract;
  function hardware(module:string; command:string; param:array of string):string; virtual; abstract;
end;
   


Programs also have the ability to start other programs, pass parameters to them and receive results, thus making a simple system (for example, there's an "input.lua" program which is actually an input dialog, it returns any input the user enters). The editor is made this way too (it's a cartridge like the others)

Well this is it mainly, big missing features are sound and music, and gamepad support, then i can have my working console :P

Let me know if you like it.

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 0 guests