Retro Fantasy Console like thingy

The place to share and discuss your Ultibo projects.
Posts: 33
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:


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

Code: Select all

t = 0

function frame()
  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)
  -- move sprite across screen
  draw(0, (t // 2) % (256-16),120,0,128-16,16,16,3)
  t = t + 1 

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):


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.
Posts: 858
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland

Re: Retro Fantasy Console like thingy

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

Good job :)
Posts: 443
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.

Posts: 33
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
Posts: 33
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:


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:



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


Also included is the editor:


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;

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.
Posts: 1
Joined: Tue Mar 21, 2017 8:09 pm

Re: Retro Fantasy Console like thingy

Postby Dafix » Sun Mar 24, 2019 9:36 pm

Congratulations on the release of TIC 80 on Raspberry Pi :D
Posts: 33
Joined: Thu Aug 02, 2018 8:38 am

Re: Retro Fantasy Console like thingy

Postby msx80 » Mon Mar 25, 2019 8:55 am

Dafix wrote:Congratulations on the release of TIC 80 on Raspberry Pi :D

Ahah thank you :) Obviously it stem from the same "research area" as this project. Actually this was my take on TIC-80, removing things i didn't like and doing things my way. Naturally the port of original TIC-80 is bound to raise more interest as the fantasy console is already pretty well known.
It's been interesting to explore both options.

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 1 guest