Nitro Entertainment System for Raspberry Pi

Monkey Archive Forums/Monkey Projects/Nitro Entertainment System for Raspberry Pi

skid(Posted 2015) [#1]



skid(Posted 2015) [#2]
As I am only days away from first (raspbian exclusive!) release of my nitro system I thought i would publish current design spec for anyone that may be interested.

The core nitro runtime is a proprietary binary featuring

* multi rom cartridge based console
* Print(message$) and Input
* SDL2 based display, messaging, joystick and audio
* persistent global metaverse renderer with user mesh and shaders
* mojo2 integration planned but not included

The plan is to be exclusive on raspbian until Christmas and then release MacOS as first commercial offering at around the $20 mark featuring a collection of playable demos and some dev tools to seal the deal.

So to summarise first release will allow building of roms on pi with rom banks being sharable. Future roms may need to be built and signed server side so that they can be trusted on consumer accounts.

I hope to provide publishing services in the long run but for now I just need some help testing the various API features as they are completed.

Besides managed environment like monkey, raw C++ and monkey2 rom builds will also be possible in future releases.

The monkey API is designed ala AmiBlitz / Blitz3D with raw bank indexes (minimal memory fragmentation) being the obvious choice for entity handles and friends.

I need to write an installation guide and upload some binaries but for me the countdown is now on....

http://nitrologic.blogspot.co.nz/2015/10/piraspberrypi-testing.html


DruggedBunny(Posted 2015) [#3]
Interesting! Have I understood correctly that it's a 2D/3D game engine that loads virtual "ROMs" as .so libraries (written in Monkey?), on a Pi-based console, something along those lines?


MikeHart(Posted 2015) [#4]
wow. Love it


skid(Posted 2015) [#5]
Yes James, if by Pi Console you mean any Pi with display and controller plugged into it.

Here is the current bin folder, monkeycc is transcc but only translates no build abilities, buildrom packags monkeycc output, and nitro is the host, which in theory can be always on.

pi@raspberrypi ~/nitro/bin $ ls -l
total 4200
-rwxr-xr-x 1 pi pi   69180 Oct 22 17:33 buildrom
-rwxr-xr-x 1 pi pi  831032 Oct 22 17:33 monkeycc
-rwxr-xr-x 1 pi pi 3383660 Oct 22 17:24 nitro
-rwxr-xr-x 1 pi pi     116 Oct 21 09:04 run
-rwxr-xr-x 1 pi pi     191 Oct 21 10:44 run.save
-rw-r--r-- 1 pi pi      67 Oct 16 13:13 vcbuild.bat
pi@raspberrypi ~/nitro/bin $ cat run
monkeycc -target=Rom $1

if [[ "$OSTYPE" == "darwin"* ]]; then
   nitro run ./$1.dylib
else
   nitro run ./$1.so
fi
pi@raspberrypi ~/nitro/bin $ 


and this is a typical rom

pi@raspberrypi ~/nitro/tests/meshtest $ cd ..
pi@raspberrypi ~/nitro/tests $ ls
codectest  cubetest  curltest  dynamictest  fonttest  globalstest  helloworld  inputtest  mathtest  meshtest  myfirstapp  texturetest  vectortest  wavtest
pi@raspberrypi ~/nitro/tests $ ls codectest -l
total 500
-rw-r--r-- 1 pi pi    789 Oct 21 09:42 codectest.monkey
-rw-r--r-- 1 pi pi  48000 Oct 21 09:42 codectest.monkey.cpp
-rw-r--r-- 1 pi pi 252276 Oct 21 09:42 codectest.monkey.o
-rwxr-xr-x 1 pi pi 180160 Oct 21 09:42 codectest.monkey.so
-rw-r--r-- 1 pi pi   5764 Oct 18 15:11 testimg.jpg
-rw-r--r-- 1 pi pi  12901 Oct 18 15:11 toucan.png
pi@raspberrypi ~/nitro/tests $ 


The 180K minimum size is same for windows and macos so still unsure why it's quite so fat at this time...


DruggedBunny(Posted 2015) [#6]
Ah, nice, so you [can, at least] write in Monkey code but you're not actually using Monkey (ie. it's not a Monkey target), just a stripped transcc, and the build system then spits out the .so and [.]so on?

Will have to dig out the Pi2!

What does "rom banks being sharable" mean in practice in this system?


skid(Posted 2015) [#7]
Yes it is effectively monkey-x with bunch of hacks to C++_Tool including separation of translate and build steps. Re-building trans is a 12 minute coffee break on Pi1 and a good 6 I would guess on Pi2...

By dropping mojo I can keep the fork clear of licensing issues and without mojo the BBGame architecture has been dropped also as too complex and it has since been feeling more and more like home.

Most of brl and monkey lang modules have survived intact.

The meta nature of the ROMS is that it is intended that ROMS can load ROMS.

The pi dashboard will be a rom itself that updates and runs pi roms from my server. For now however it is strictly one rom per nitro run command and a boatload of API calls still to go.


DruggedBunny(Posted 2015) [#8]
Look forward to giving it a whirl!


skid(Posted 2015) [#9]
Woot, port midi now alive on MacOS and PI.


pi@raspberrypi ~/nitro3d $ nitro test
[NITRO] FT_Init_FreeType returned 0

MIDI input devices = 4:
1: ALSA, Midi Through Port-0
3: ALSA, SynthStation25 MIDI 1
[NITRO] midiInCount=4

[NITRO] nitroTime 1445556207.496183872
[NITRO] nitroControllerCount 0
[NITRO] nitroDisplayCount 1
[NITRO] nitroDisplay[0] is 1920x1200 @ 0,0
pi@raspberrypi ~/nitro3d $





degac(Posted 2015) [#10]
it seems an interesting project.
You called it 'virtual console' so I presume there are some 'games' (ROM) ready for the launch?


skid(Posted 2015) [#11]
For initial release the roms available will be mostly diagnostic in nature,

I have some pretty grand experiments planned but am much looking forward to when API feels final.

[edit]

Latest interface including recent additions:

Function NitroLog(text$)

Function NitroVersion%()
Function NitroInit%()
Function NitroUpdate()
Function NitroTerminate()

Function NitroTime#()
Function NitroSleep(delay#)

Function NitroBeep(volume#,rate#,duration#)

Function NitroControllerCount()
Function NitroOpenController(index)
Function NitroCloseController(index)
Function NitroControllerName$(index)
Function NitroControllerSpec$(index)
Function NitroControllerButtons(index)
Function NitroControllerAxis(index,sixaxis[])

Function NitroDisplayCount()
Function NitroDisplaySize(index,widthheight[])
Function NitroDisplayPosition(index,xposypos[])

Function NitroCreateWindow%(x,y,width,height,flags)
Function NitroWindowFullscreen(id,display)
Function NitroWindowState(id,state[])
Function NitroWindowHandle(id,sdlhandle[])
Function NitroWindowDraw(id,commandBuffer[],index,count)
Function NitroWindowPresent(id)
Function NitroWindowClose(id)
	
Function NitroEvent()
Function NitroEventType()
Function NitroEventTime()
Function NitroEventString$()

Function NitroWindowEventType()
	
Function NitroMouseWindow()
Function NitroMouseButton()
Function NitroMouseX()
Function NitroMouseY()
Function NitroMouseXSpeed()
Function NitroMouseYSpeed()
	
Function NitroKeyboardKey()
Function NitroKeyboardModifiers()
	
Function NitroMouseDown(button)
Function NitroKeyDown(keycode)
Function NitroJoyDown(index,button)

Function NitroInitGlew()

Function NitroCreateCamera%()
Function NitroSetRange(camera%,near#,far#)
Function NitroSetFOV(camera%,radians#)

Function NitroCreateLight%(type)
Function NitroCreateSprite%(mat)
Function NitroCreateScene%()

Function NitroSetParent(id,parent)
Function NitroSetColor(id,argb)
Function NitroSetPosition(id,x#,y#,z#)
Function NitroRevolve(id,x#,y#,z#,w#)

Function NitroCreateBox(width#,height#,depth#,mat)

' renderer

Function NitroCreateRenderer%()
Function NitroRendererSetScene(rendera,scene)
Function NitroRendererSetCamera(rendera,camera)
Function NitroRendererSetViewport(rendera,x,y,w,h)
Function NitroRendererRender(rendera)

' mesh

Function NitroCreateMesh%(material%)
Function NitroAddVertices(id,xyz#[],nxnynz#[],uv#[])
Function NitroAddPoint(id,v0)
Function NitroAddLine(id,v0,v1)
Function NitroAddTriangle(id,v0,v1,v2)
Function NitroAddQuad(id,v0,v1,v2,v3)
Function NitroUpdateMesh(id)

' model

Function NitroCreateModel%()
Function NitroAddMesh(model,mesh)

' codec

Function NitroReadJPEGImage%(path$)
Function NitroWriteJPEGImage%(path$,width,height,channels,quality)

Function NitroReadPNGImage%(path$)
Function NitroWritePNGImage%(path$,width,height,depth,type)

Function NitroImageClose(imageHandle%)

Function NitroImageWidth%(imageHandle%)
Function NitroImageHeight%(imageHandle%)

Function NitroImageChannels%(imageHandle%)
Function NitroImageFlags%(imageHandle%)
Function NitroImageType%(imageHandle%)

Function NitroImageReadLine%(imageHandle%,data%[],offset%)
Function NitroImageWriteLine%(imageHandle%,data%[],offset%)

' sampler

Function NitroLoadWAV%(path$)
Function NitroLoadOGG%(path$)
Function NitroSampleLength%(sampleHandle%)
Function NitroSampleHertz%(sampleHandle%)
Function NitroSampleBits%(sampleHandle%)
Function NitroSampleChannels%(sampleHandle%)
Function NitroSamplePlay%(sampleHandle%,volume#,rate#,duration#)

' freetype

Function NitroLoadTTF%(path$,size%,metrics8[])
Function NitroGlyphMetrics%(fontHandle%,charcode%,metrics6[])
Function NitroGlyphPixels%(fontHandle%,span%,height%,pixels[])

' texture

Function NitroCreateTexture%(width%,height%,flags%,pixels[])

' material

Function NitroCreateShader%(source$)

Function NitroCreateMaterial%(shaderHandle)
Function NitroColorMaterial%(key$,argb%,materialHandle%)
Function NitroTextureMaterial%(key$,textureHandle%,materialHandle%)

Function NitroSwapInterval(count)

' midi

Function NitroMidiDeviceCount%()
Function NitroMidiDeviceHandle%(index)
Function NitroMidiDeviceName$(handle%)

Function NitroMidiEventData%()
Function NitroMidiEventTimestamp%()

Function NitroMidiInCount%(handle%)
Function NitroMidiInOpen%(handle%)
Function NitroMidiInPoll%(handle%)
Function NitroMidiInClose(handle%)

Function NitroMidiOutCount%(handle%)
Function NitroMidiOutOpen%(handle%)
Function NitroMidiOutSend%(handle%,b0,b1,b2)
Function NitroMidiOutClose(handle%)

' db

Function NitroOpenDatabase%(path$)
Function NitroDBExecute$(dbhandle%,query$) 
Function NitroDBClose(dbhandle%)

' socket

Function NitroListen%(port%)
Function NitroConnect%(host$,port%)

Function NitroSocketRead$(handle%)
Function NitroSocketWrite(handle%,content$)
Function NitroSocketClose(handle%)



The project is experimental in nature hence the Pi target. Most ROM code in release will be diagnostic in nature.

Having my nano kontrol, synthstation and dx7 with sustain pedal and breath controller hooked up to the Pi has been on the cards for yonks, finally done.

I'm just tidying up the main binary now, next is long overdue remote automation which is intended to save me what has been an increased amount of fafffing around with ssh and git command line control.

I would like a basic mesh network running on release so connectivity code is going in next.

Usage: nitro [command [argument]]

Commands
run <rom> - load rom and run
connect <url> - connect to host
listen <port> - listen for external connection
version - display nitro version of this build
about - display acknowledgements and licenses
interface - display nitro interface



DruggedBunny(Posted 2015) [#12]
I like that the command set can be grasped in a single reading, yet seems to cover all bases for a console-type system.

I'd assume more 'ROMs' would come from dabblers of the early beta releases, anyway.

Any chance of posting your 3d-cube source, Simon, just to get an idea of a real graphical program?


skid(Posted 2015) [#13]
The 3d side of things is still very much a work in progress,

https://github.com/nitrologic/nitro/blob/master/tests/cubetest/cubetest.monkey

The monkey interface lives here:

https://github.com/nitrologic/nitro/tree/master/monkey/modules/nitro


DruggedBunny(Posted 2015) [#14]
Cool, looks nice and simple... will be nice to have an easy Pi option.

I'll certainly cough up $20 or so for Pi/Windows targets! (Reckon Pi would cover general Linux? As in feasible to skip the Pi-specific Linux initialisation?)


skid(Posted 2015) [#15]
After success with AWS today I will include elf64 binaries with first release as building and running stuff on the cloud is too useful.

I do want to focus on pi exclusive for immediate future, It seems like a particular corner of the industry that sits well with education and do it yourself maker communities.

There is also a street fighter machine at the local fish and chip shop I am hoping to modify..

The $20 could be due when you are ready to publish.

I hope to build and sign roms on the server - the build system looks like it can provide zero friction distribution for authors similar to the model Josh provides Leadwerks users but in a more experimental / modular manner.


degac(Posted 2015) [#16]
Hi
just read the source about the '3d cube'... very Blitz3d :D!

Just two thing.
1. there's a reason about the creation of Light/Camera and THEN assign it to the scene?
        Local light:=NitroCreateLight(DIRECTIONALLIGHT)
	NitroSetParent light,scene

        Local light:=NitroCreateLight(DIRECTIONALLIGHT,scene)


2, the event system, I would put an 'EVENT_' or 'NEVENT_' as prefix.. because a constant like 'KEYDOWN' seems to be so common

I know, nothing really important,
I must admit that it's one of the most interesting thing I saw in monkey...

ps: I hope in a Windows release maybe !


Sammy(Posted 2015) [#17]
Nice work, esp. the midi commands, it's so rare to see these in an engine at all.


skid(Posted 2015) [#18]
Things just got interesting.

Stargate
1981 Williams

CPU:
M6809 1.000000 MHz
M6808 894.750 kHz

Sound:
DAC

Video:
292 × 240 (H) 60.096154 Hz



MikeHart(Posted 2015) [#19]
I am off to by a Pi2 myself.


skid(Posted 2015) [#20]
And after a visit to turbosquid, 3d feature development continues...

fbxtool (C)2015 Simon Armstrong
Autodesk FBX SDK version 2015.1 Release (228957)
FBX file format version for this FBX SDK is 7.4.0
FBX file format version for file 'stargatemachine.fbx' is 6.0.0
DumpMesh nump=36843 numv=110529 numuv=41587 numuvn=1 numc=18929



Nobuyuki(Posted 2015) [#21]
I too am buying a couple pi2's, as Christmas presents for my brothers. The system you have going here is pretty neat, I think it could do well as a retroarch core (so out can run on retropie and recalos as well as raspbian). Would definitely reach more pi owners who mainly use it for retrogaming...


skid(Posted 2015) [#22]
I will be getting back to the Pi this week and expect first release by end of week.

I got a little sidetracked with my first native rom, a mame "adapter" project. The new defender build is to die for with shoulder buttons of game pad thrust and reverse and fire on B. For proof at how crap I am as player am backing up the non volatile on github -

https://github.com/nitrologic/nitro/blob/master/native/emulator/nvram/defenderg.nv

The robotron roms I have seem to have been modified, they fail checksum and the coin drop lets out a different sound effect for each credit.


skid(Posted 2015) [#23]
Part 2 of my rambling blog is here:

http://nitrologic.blogspot.co.nz/2015/11/piraspberrypi-testing-2.html

I was going to say I am also waiting for RASPBIAN JESSIE, and yes it's finally out. No more faffing about installing C++11 which is a primary dependency.

https://www.raspberrypi.org/downloads/raspbian/


skid(Posted 2015) [#24]
And more ramblings.

http://nitrologic.blogspot.co.nz/search/label/NitroSDK

I completely lost track of priorities yesterday and began another adapter cartridge based on a V8 / D8 javascript environment.

It is nice to be interfacing to a C++ project for a change. The google code standards are high and the opportunities for interesting research projects seems as rich as another incomplete diversion.


skid(Posted 2015) [#25]
And even more ramblings

http://nitrologic.blogspot.co.nz/2015/11/work-in-progress.html

After buying an astro hat for my Raspberry PI (don't ask) it became evident most development on PI is being done in Python.

So I have a new bait and switch marketing plan that involves inclusion of Python support in the Nitro SDK as well as a bundled nitro version of transcc for more serious monkey development.


Fred(Posted 2016) [#26]
Hi skid,
I'm building a rPI small box with LCD/sound/joysticks/... I was looking for a way to make a graphical interface in order to launch some old games I did (they work with Retropie) and I discover NitroSDK (I come here often but missed it), very good news (I use Monkey everyday).
I have also some serial devices to control but I should not need Python.
So, I installed everything and I tried this:

and get this:

I spent the last hour searching for a solution, and google is not my friend today.
Any idea ?


skid(Posted 2016) [#27]
Hi fred, r u on raspian Jessie?


Fred(Posted 2016) [#28]
I'm on Wheezy. I'm not a Linux expert and just discovered the differences...
Trying some forums solution, I did put a mess in all versions of libstdc++...
I'll give a try to convert my Wheezy to Jessie to try to keep all I already installed... (I'm sure it's a bad idea)
Now to test your SDK, I'm installing a fresh Jessie.

I tried the window version too, and I also have an issue...
exe files are not executable files from the git download. I rebuilt them. (not mandatory but it was fun to compile monk.exe with Blitzmax, I had to update my old 1.42 version. I like Blitzmax, I did a lot of game and toy prototypes with it)
Everything looks fine (helloworld.monkey.dll) except I can't find how to make wnitro.exe ?


skid(Posted 2016) [#29]
The binary issue with wnitro is possible due to git large file storage system.

Or it is not static link and needs VisualC++ runtime libraries.

I can share source on github if you have an account but have not yet decided to open-source the nitro engine itself.

Or...

Running plain monkey with mojo2 should be fine on Pi. Clone the gitub brl monkey repos to your pi and run the src rebuildall.sh script.


Fred(Posted 2016) [#30]
Fresh Jessy install :)
Couldn't resist to set back all my stuff, everything's perfect.
NitroSdk:

(same result right after Jessy install and now with more dev stuff installed)

Monkey install:
rebuildall.sh from scratch: Transcc ok
sudo apt-get install libxinerama-dev
sudo apt-get install libxrandr-dev
Makedocs ok
sudo apt-get install libalut0 libalut-dev
sudo apt-get install libxi-dev
Mserver ok
Launcher ok

Issues with Ted:
building ted
qmake: could not exec '/usr/lib/arm-linux-gnueabihf/qt4/bin/qmake': No such file or directory
I googled it... :(
sudo apt-get install qtcreator (244Mo)
Qtcreator works in X
apt-get install qtbase5-dev qtdeclarative5-dev
still have the qmake error.
Should I install qt4 ? how ? a lot have the same issues with several Qt.
I gave up on Ted,
let's build some project with transcc:
mojo/mojotest.monkey OK, runs slowly in an X window without GL acceleration
mojo2/mojotest.monkey OK, same as mojo1, runs but no acceleration.

Anyway thanks a lot for the help, I didn't try to install Monkey before because of the issues I saw in the forum here.

Now I need to set it up to get hardware acceleration and to be able to run a prog without X...
I compiled with success some accelerated glfw (not monkey) progs on my previous Wheezy.
So let's start again from there. I'll tell my progress.
And I still want to test your SDK (pi and win).


Fred(Posted 2016) [#31]
By the way: Enabling the experimental GL Driver (raspi-config) makes both mojo and mojo2 samples GPU accelerated.
Mojo2 bump map shader sample (with the rotating light) is working nicely.
I had issues to boot (black screen) with my 7" 1024x600 LCD. Adding video=1024x600 in /boot/cmdline.txt did the trick.
SDL progs don't work which prevents retropie to run.