View Full Version : Programming experiment

July 25th, 2017, 12:32
(Video at bottom of text).

Hello. This is probably wayyy, wayyy too early and crappy looking to post about, but in case anyone is interested I would like to show a video of a system I am working on, and mention some of the ideas I have for it. Basically I wanted to play around with C++ some more after many years of mostly avoiding it and using other things like C# and Node.js. This gives me a chance to learn new C++ features and integrate easily with lots of stuff. Including libretro.

I have been watching youtube channels like Lazy Game Reviews etc. and was jealous of the vintage computer collections. I made a few visits to eBay and local thrift shops and realized it was not going to be easy to run out and start grabbing a bunch of inexpensive vintage computers that actually worked. So instead of waiting for eBay stuff I decided to try to build a _virtual_ vintage computer collection.

I have been building my own 3D Libretro front-end starting with Irrlicht Engine. The great thing about Irrlicht is that even though it is very old and not flashy, it has built in support to load several 3d model file formats. I figured out how to get MAME Libretro to load up with multiple cores running at the same time. This involves copying DLLs (lol) and some C++ templates, plus a few places that just need to be long lists of case options. Anyway I think its pretty cool being able to load up multiple MAME or other libretro cores at the same time. Obviously this has performance consequences so maybe is a bit of a gimmick in some circumstances, but it is cool. MAME is designed as a command line application and so as a libretro DLL is quite crashy. I hacked a bit on it so that I could just pass in normal MAME command lines. And after a lot of debugging to figure out where the files had to go, have been successful in loading up Coco2 and its cartridges as well as other MESS computers I tried (through my hacked MAME-libretro core).

In order to make this a truly customizable system, I found an open source BASIC interpreter called My-Basic by Wang Renxin and modified it. To make it more retro, I added line numbers, enabled GOTO line number (still have to work on that). I also added a number of commands, like REZ to load a 3D model, LINE3D for 3D lines, and EMULATE to start emulating a libretro (including MAME) system.

The demo looks like crap right now, I know. I have a lot of plans for features to add that will enable me to create a much, much more awesome demo. MAME has lua support built in. I plan to hack into my MAME-libretro core a hook into that lua script code, to run arbitrary lua script. With lua you can also read and write memory from MAME cores. So I will add a BASIC command that wraps around luascript to read and write mem, probably call it PEEK and POKE (like POKE SOME_EMULATOR, MEMADDR, BYTE or something). With this capability, it should be possible to do a number of things, such as having one MAME 80s computer controlling another one, or having a Spectrum assembly program outputting BASIC commands to draw and rotate 3D lines in my environment.

I also plan to add in the PDFium library which is Chromium's PDF renderer, and set up a 3D book page flip thing so that I can import old computer manuals and display them. I also plan to add OpenVR support.


July 25th, 2017, 13:08
for me very interesting bright idea you will use low system language asm or leve it as is

July 25th, 2017, 13:39
Well like I re-iterated in my reply to your PM, it is programmed in C++, which is fairly low-level. The customization language built in is Vintage BASIC, which I feel is quite retro and easy to use, and since its based on My-Basic, has some nice modern features like lambdas and object-oriented programming for people that want that. Then, as I mentioned in my post, I plan to add POKE and PEEK commands to Vintage BASIC, that can read memory from an emulated computer which could in turn output BASIC commands to be interpreted, which will make it possible to create a sort of operating system for the 3D environment that runs on a MAME or other Libretro vintage computer. This way it will be possible to control the system, like loading up new computers or arcade cabinet models, via Z80 or 6502 assembly language running on one of the MAME libretro cores.

July 26th, 2017, 14:33
Irrlicht Engine. LOL cool. I made a metroid game with that. Here was the video.


July 26th, 2017, 14:51
really nice :happy:

July 27th, 2017, 00:00
Very cool. Were you able to use getMesh with an animated mesh for that transition into a ball thing? I have not actually used any animated meshes, but I am guessing there is are methods to play animations and specify certain keyframes or something? Or did you need to do something more complicated? I am planning on adding a command like ANIMATE to my Vintage BASIC to trigger animations on models. This type of thing is why I like Irrlicht even though it is pretty old -- it has features like easily loading animated models that simplify things for me trying to make a dynamic programmable environment.
Also how did you create that animation? In Blender or Maya or something?

August 2nd, 2017, 14:33
Yes It took some doing but using the irreditor I was able to get all transformations. I actually had to modify the animator code to get reversals. Not sure they push my code change or not. I only used frame animations. I knew what frames had what and the animations where all on one time line. 0-10 stand 11-20 run, etc...

Yes I did everything in maya. I used IK's and constrains for my rag doll I rigged up. I found the best tools to irr engine were irrwizard and irredit. They just made life easy for me

August 12th, 2017, 13:29
Well, the BASIC interpreter was too slow. So I changed to Lua. I still support line numbers though heh.

July 26th, 2019, 19:27
Any progress?

August 27th, 2019, 11:32
I actually didn't have thread notifications on and so just randomly happened to come back here and see the question about progress. So I have been through a lot of different mini-projects and stages with this. There is a website https://vintagesimulator.com with an old version up. Unfortunately the documentation on github is for the new version rather than that really old one you can download.

If you look on the home page you can see some of the experiments I have done. One of them was running hundreds of ZX Spectrum libretro instances on one screen:


There has been one major change which involved rewriting a lot of the code. Several libretro cores just would not work with the single process multiple thread thing I had set up before. Something to do with the fact that they used libco.

So I had to split it up into multiple processes. One process for the frontend, and each emulator running in its own process. This required a bunch of IPC work included Windows named pipes and shared memory for the video data. The main parts of this are done. Some things like sending keystrokes via Lua script are not redone yet. I also have to redo the 3D audio -- audio is all normal stereo now and not positional like I had it before.

Back to the mini projects. I did get a virtual book demo done that renders pages in Node.js and then puts them in textures in the environment. That was for a C64 manual. I also did something similar with old ZX Spectrum magazines (also this video shows loading a wall of units representing part of a Spectrum software collection that you can browse in 3D):


Here is another video showing the full ZX Spectrum software collection visualization:


So the latest is that I have some basic support for shaders. There is a lua command to specify a shader to use with an emulator screen and I have converted a few libretro shaders to work with it. At the moment I am messing with that. It was working fine except it would not update the uniforms which I needed for things like frame_count to do a flicker effect etc. So I am in the middle of changing that and trying to make it work correctly. At the moment it is not handling that correctly and is crashing randomly around that shader demo. Which I have plans for how to address those problems but it is in progress.

My plan right now is to get the shader thing debugged and then get a bit more done and hopefully within a few months put a new version up on the website that will include plugins that have Lua code and maybe even all of the files (for educational purposes only of course) for a C64 and ZX Spectrum. After fixing the shader stuff, I want to add a shininess option, get the 3d audio working again, get the Lua command for sending keys working again, and then hopefully have a way to send keystrokes via clicking on the 3D model of the computer.

If possible I will port the old demos with the magazines and Spectrum bookcase etc. to the new version and that will be in the new download also. Once that is done I will put it up on the website and try to convince people again to actually download it. Lol.

August 31st, 2019, 15:41
So, this is a new emulator for the Spectrum?

July 15th, 2020, 13:31
No, it's a 3d Lua-programmable front-end for libretro, not an emulator. As I explained above and on vintagesimulator.com