The evolution of controller simulation

28 03 2015

When you start writing a gaming framework that should be controlled by a Joystick, you will end up defining callback functions for the controller functions.

To simulate a controller you will also implement callback functions for keyboard clicks and map these keyboard callbacks to controller callback functions.
You start with writing 5 callback functions:

  • cursor up
  • cursor down
  • cursor left
  • cursor right
  • fire

This is a good start and works well. It’s like 1979 you could say. We use a Atari CX40 (I hate it, because I’m left hander) and we could map our 5 callback functions to the CX40 functionality:
The 4 direction callback functions could be simulated on the keyboard by cursor up,down,left,right. The fire button could be emulated by space:

  • up = cursor up
  • down = cursor down
  • left = cursor left
  • right = cursor right
  • fire = space

We could already warp to 1983. We now use a competition pro joystick and all buttons sendings their “power on” signal on one wire. Nothing has to change in our framework.

Next we warp to 1984. The Atari 7800 has a joystick, the Atari CX24, that has to 2 different buttons connected to independent wires.
In your framework code our simulation of the fire button with the space key will not work anymore. A good way to handle this evolution will be to use the y key to simulate button a and the x key to simulate button b. The new mapping now looks like this:

  • up = cursor up
  • down = cursor down
  • left = cursor left
  • right = cursor right
  • button a = y
  • button b = x

At the same time the joypads emerge into gamerworld thanks to the Nintendo Entertainment Systems.
To cover the start and select button we have to extend our set of callback functions to simulate them as well. The two windows key on the keyboard are good candidates for this task.
My thinkpad has the page up and page down key next to the cursor up key, they would fit perfect, but the majority of keyboards have a different design, so we implement the windows keys.

That result in the following mapping:

  • up = cursor up
  • down = cursor down
  • left = cursor left
  • right = cursor right
  • button a = y
  • button b = x
  • start = windows left
  • select = windows right

It’s warptime again and we land in 1990. Our Super Nintendo have 4 buttons and 2 shoulder buttons beside the standard direction pad. Our x,y key approach does not fit anymore.
For me to use 4 keys, its more intuitive to go to the middle row on the keyboard instead of extend the use of the bottom row on the keyboard (c,v key), so the 4 buttons are a,s,d,f

Update 2: It was to early when I wrote it. If cause it hast to be w,a,s,d.

Update 3: First tests shows, that now that the x and y keys are free again, the start and select callbacks could be mapped to these keys 

The shoulder buttons will be strg left and strg right. The mapping now looks like this:

  • up = cursor up
  • down = cursor down
  • left = cursor left
  • right = cursor right
  • button up = w
  • button right = d
  • button down = s
  • button left = a
  • start = x
  • select = y
  • shoulder left = strg left
  • shoulder right = strg right

Last warp so far goes to 1994. We all have a playstation and use the psx pad. It adds 2 more shoulder buttons and rearange the should buttons to L1,L2,R1,R2. it also adds 2 analog sticks LS and RS. You could also press this sticks (L3,R3)
The new shoulder buttons (L2,R2) will be simulated by “alt left” and “alt right”.
The sticks are a challenge. My first idea is to simulate them with the number keys. 1-5 for the left stick and 6-0 for the right stick.

Update 1: Thanks to EarX / Linout we must warp to 2006 cause the L3 and R3 Button was not present on the PS2 but on the PS3. 

That a huge change to our framework and ends up in these mapping:

  • up = cursor up
  • down = cursor down
  • left = cursor left
  • right = cursor right
  • button up = w
  • button right = d
  • button down = s
  • button left = a
  • start = x
  • select = y
  • L1 = strg left
  • L2 = alt left
  • R1 = strg right
  • R2 = alt right
  • LS up = 1
  • LS down = 2
  • LS left = 3
  • LS right = 4
  • LB = 5
  • RS up = 6
  • RS down = 7
  • RS left = 8
  • RS right = 9
  • RB = 0




Atari cross compiling

4 10 2014

Today I had a small coding sprint to find out if I could compile assembler code and embed it in a C programm.

The sprint was successfull thanks to the work of:

  • saulot/nokturnal : created 2 articles about using gnu assembler and using virtual assembler to do the task.
  • Vincent Rivière’s: He created a tool chain for cross compiling for the Atari
  • Hatari team: I used the Hatari 1.8 Emulator to test the result

But I had some problems. The main one was that I forgot the leading tab or blank in the vasm assembler file, so I alsways got an error, that the memnonic was not found. Insane / .tSCc. helped me to find this minor error, thanks to him as well.

I also had think, that a complette example would be a great enhancement of soulot’s howto. So I put this example for both assembler in this article. First we setup our cross compiling environment.

Download and install tool chain

http://vincent.riviere.free.fr/soft/m68k-atari-mint/

Download and install Virtual Assembler

http://sun.hasenbraten.de/vasm/

Download and Install Hatari

Here a link to a former article of mine, which is still valid (beside the version numbers)
https://thornstot.wordpress.com/2014/01/23/hatari-1-7-installed-under-ubuntu-13-10/

GNU Assembler example

Link to soulots article: http://bus-error.nokturnal.pl/tiki-read_article.php?articleId=2

C Header: ex_gas.h

#ifndef PLUS_H
#define PLUS_H ;we want to include header once
#ifdef __cplusplus
extern "C" {
#endif
long plus(long a, long b);
#ifdef __cplusplus
}
#endif
#endif

C Code ex_gas.c

#include "ex_gas.h"
#include <stdio.h>
int main(int argc, char* argv[])
{
int a=0;
a=plus(2,1);
puts("Hello, world !");
return 0;
}

Assembler code ex_gas.s

 .globl _plus
_plus:
move.l 4(sp),d0
add.l 8(sp),d0
rts

Assemble
m68k-atari-mint-gcc -c ex_gas.s -Wa,-S -o ex_gas.o

Compile
m68k-atari-mint-gcc ex_gas.c ex_gas.o -o ex_gas.tos

 

Virtual Assembler example

Link to saulots article: http://bus-error.nokturnal.pl/tiki-read_article.php?articleId=1

C Header ex_vasm.h

#ifndef PLUS_H
#define PLUS_H ;we want to include header once
#ifdef __cplusplus
extern "C" {
#endif
void hello();
#ifdef __cplusplus
}
#endif
#endif

C Code ex_vasm.c

#include "ex_vasm.h"
#include <stdio.h>
int main(int argc, char* argv[])
{
int a=0;
hello();
puts("Hello, world !");
return 0;
}

Assembler code ex_vasm.s

Do not forget the leading tab in front of XDEF 🙂

 XDEF _hello
_hello:
movem.l d1-d2/a0-2,-(sp)
move.l #hi_msg,-(sp)
move.w #$09,-(sp)
trap #1
addq.l #6,sp
movem.l (sp)+,d1-d2/a0-2
rts
hi_msg:
dc.b "Hi from 68k!",$0d,$0a,$00

Assemble

vasmm68k_mot ex_vasm.s -Faout -quiet -x -m68000 -spaces -showopt -o ex_vasm.o

Compile

m68k-atari-mint-gcc ex_vasm.c ex_vasm.o -o ex_vasm.tos





NonConForm State Engine for Java Script. The first example

3 10 2014

I started to port my NonConForm library from the Falcon to Python a while ago. Now I started to port it to JavaScript as well. Today the state engine, the heart of the gaming menu framework is finished.

Here the first example:


-------------------------------------------------
declare states
-------------------------------------------------
var stGame = new NcfState("Game");
var tFinishFromGame = new NcfTransition("FinishFromGame","End",function() {});
stGame.addTransition(tFinishFromGame);
Ncf.addState(stGame);
-------------------------------------------------
define view
-------------------------------------------------
Ncf.getState("Game").setView(
function() {
Ncf.log("View");
Ncf.transit("FinishFromGame");
}
)
-------------------------------------------------
define controller
-------------------------------------------------
Ncf.getState("Game").setController(
function() {
Ncf.log("Controller");
Ncf.transit("FinishFromGame");
}
)
-------------------------------------------------
start engine
-------------------------------------------------
Ncf.setDebugMode(true);
Ncf.init(50,"Game");

and here is the output

initialize NonConForm
—————————–
start NonConForm state engine
—————————–
Leaving:Start
|——————Transit to——————|:Game
Entering:Game
NonConForm main loop started
Main Loop
View
Controller
Leaving:Game
|——————Transit to——————|:End
—————————–
finishing NonConForm
—————————–
NonConForm main loop stopped





OFAM 2014 Friday

27 09 2014

This year OFAM, the 10th anniversary of the event started around 6 o’clock when Mr.XY and I met in Sossenheim. We decided to take the A66 via Fulda to pass by the traditional traffic jams around Würzburg. The road works on the A66 around Neuhof are finished and for the first time we drove straight from Hanau to Fulda. Good start.

Next our stadard stop at the Burger King in Schweinfuhrt took place. Some funny moments with moving queues (we had luck and stand in the right one) and another double burger for free happend, but nothing special

Mr.XY had to learn, that it’s called “Das OFAM” and not “Die OFAM”. He is already very old, but I don’t give up hope for time to overcome this problem.

This time, the OFAM take place in a former school direct opposite the church. It was a little bit tricky to drive, but we got a parking place direct in front of it. Really strange to see a “Martin Luther” School in catholic Bavaria, but even there the (or some) clocks are turning forward.

Inside a buch of 10 people were alreay there eating traditonal Atarifahrt food like stinking Pizza. So we decided to not unpack in a hurry but unpack in 2 terms so that we could sit outsite under a tree in front of the church for a while. While we were sitting, some more people arrive, and we could explain them where to park.

After build up my Falcon I was able to get some missing parts like the VGA Adapter and a Mouse from friendly party people. I also get a NetUSB so my network was running, and I could save 2 old games of mine to my Linx machine. I also found the rest of my games, so espect some more files on this site soon.

Gagga who sit next to me forced me to show hidden .tSCc. gems like Project Vögeln. Always impressing to see it again after some month. One day I have to finish it.

I also demonstrated Spitzenreiter III and found out, that there are some good reasons to release a 20xx Edition of it. Maybe something for the next decadede.

Gagga was playing some link games on the ST together with Heinz. Heinz is a notorious Atari Gamer, but he never played Stunt Car Racer, so he had the chance to fill a gab in his life.
Still a great game. Beside SCR they played Lotus II a lot.

Insane had the idear that Subversion is also a link game, and for the next hours 3 people where busy transfering the files from one SD Card to another to find a way to create a Disk from the HFE or ST image. My Network was ok, so I was happy not to had that Problem.

Around 2 o’clock I went to bed. Good start, more to come





My new retro corner.

24 09 2014

After 2 years of auctions on ebay and giveaways to good friends, I finally reached the bottom line of my retro stuff. The things I still have are more or less the stuff I wanted to have and the stuff I will use. It was not that easy to give away some parts, but even some falcons found got hands and one is enough.

In my new flat in Frankfurt I build up only one Billy cupboard (and 2 Benno CD cupboards). Thanks to Sijmen and Sandra I was able to get most of the original boxes in the past month, so I could put all the stuff in original boxes and no  (or not that many) cables flying around.

20140921_144821

On the other side of the room I build up a monitor and little table with a Jaguar and a Raspberry Pie that could emulate an ST. Hope I find time to sit on my gamer chair and play a round Xenon II Megaplast soon.

20140921_144856

Here you could better see the Jaguar as well as the Raspberry Pie.

20140921_144911





Unity Sidebar finaly works fine

12 09 2014

I installed ubuntu 14.04 two weeks ago on my Thinkpad. This time I choosed the option to let the Unity sidebar slite out if not needed. And suprise, suprise it works fine. Before it often hangs, but now it works as designed. Well done Ubuntu.





A nice spaceship I did with Inkscape

25 06 2014

 

After I figured out how to use the gradiant fill function, I start to understand Inkscape a bit. This is a first nice result:

Bild

I was influenced by a Pac Man Tutorial. No it looks like a Ghostship.