Arduino code selector for Kites SAIO

User avatar
moooarcuuuus
Posts: 232
Joined: Tue Jul 04, 2017 1:28 am
Has thanked: 2 times
Been thanked: 94 times

Arduino code selector for Kites SAIO

Post by moooarcuuuus » Thu Dec 21, 2017 11:12 pm

Hello

Tl;dr: You can play scummvm adventures on your Gb. Tested with Monkey island 1 + 2, Sam and Max, Broken Sword, Simon the Sorcerer 1 + 2 and Kodi. There is a screensaver, after 4 minutes the screen backlight fades out. Perfect for listening game music/ Kodi. The screensaver is also included in the standard Gameboy layout

I have written two small programs to just flash the atmega32u4 on kites board. It is very simple and bleeding edge as hell. So it is better to make a backup first.

There are thwo methods.

The first method is the better one. No functions are required in the arduino code to navigate in ES, it works everytime. You need buttons on GPIO 24 and 25 of the Raspi, connected to GND (internal pullup is used). See: https://sudomod.com/forum/viewtopic.php ... =20#p50176


The second method works with a "vanilla Kite build". The arduino codes are items in the "Ports" menu.

Installation

See the commands here: https://github.com/MarcusKoe/moooarcuuuusCode

Pictures from the installation:
install001.png.png
install001.png.png (56.28 KiB) Viewed 10452 times
install002.png.png
install002.png.png (46.21 KiB) Viewed 10452 times
install003.png.png
install003.png.png (44.06 KiB) Viewed 10452 times
install004.png.png
install004.png.png (42.57 KiB) Viewed 10452 times
install005.png.png
install005.png.png (41.83 KiB) Viewed 10452 times
install006.png.png
install006.png.png (43.71 KiB) Viewed 10452 times
install007.png.png
install007.png.png (37.29 KiB) Viewed 10452 times
install008.png.png
install008.png.png (39.5 KiB) Viewed 10452 times
install009.png.png
install009.png.png (61.48 KiB) Viewed 10452 times
After the installation, the code is in /home/pi/moooarcuuuusCode/ there are logfiles from the python scripts too. If you put .hex files in "arduino-precompiled-ports/0.5|6/" or "arduino-precompiled-selectbutton/0.5|6/" after the next reboot (ports) you can select them. The arduino source is in "arduinosources". Feel free to modifiy or send me new code for sharing with others.

Method one:

Pin 24 is the selectbutton and pin 25 starts flashing. Have a look at the video. It describes everything important. I play DukeNukem3D with mouselook. Dpad is strafe, joystick mouselook, R1 fire, L1 jump, R2 run, L1 open/use.
VID002-final.mp4
(4.18 MiB) Downloaded 604 times

Method two:

The "ports" method. Have a look at the video. It describes everything important. So you can easily play old adventures with schummvm. For this you need an active ports menu. If there is no ports menu, just install KODI (please tell me if you have another simple metode to activate the port menu).

Code: Select all

sudo ~/RetroPie-Setup/retropie_setup.sh
Manage packages
Manage optional packages
309 kodi
Look at this video (on 1:40 it should be L1 not R1):
VID001-final.mp4
(8.22 MiB) Downloaded 569 times

After the first selection of a different code, the GB must be restarted in order to configure the input device (keyboard).



Configuration for SAIO_v2a.ino and SAIO_v2a-MouseKeyboard.ino:

Mode + L1 < 5sec
change mouse speed 1 - 5
Mode + R1 < 5sec
flip x and y axis
Mode + L1 > 5sec < 10sec
invert x axis
Mode + R1 > 5sec < 10sec
invert y axis
Mode + L1 > 10sec < 15 sec
change mouse mode, dpad or joystick
Mode + R1 > 10sec < 15 sec
screensaver on (or off), after 240 seconds (4 min) no button press, the screen backlight fades out

The buttons L1/R1 have to be on the L1/R1 pins on Kites board.
Mouse with joystick: The joystick must be calibrated at boot (one time).

If you change the configuration, there is visual feedback after each level (0, 5 and 10 seconds). The screen becomes gradually darker. If a configuration has been successfully changed, the screen turns off for 0.5 seconds.


Edit:
salami738 wrote:
Fri Dec 22, 2017 1:13 am
Hi, thanks for sharing. You have a extra space between setup. and sh.
NP. Removed space.
Last edited by moooarcuuuus on Sun Jan 07, 2018 5:52 am, edited 5 times in total.
Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep... Game Over

salami738
Posts: 128
Joined: Sat Sep 09, 2017 6:06 am
Location: Germany
Has thanked: 60 times
Been thanked: 37 times

Re: Arduino code selector for Kites SAIO

Post by salami738 » Fri Dec 22, 2017 1:13 am

moooarcuuuus wrote:
Thu Dec 21, 2017 11:12 pm
...

Code: Select all

sudo ~/RetroPie-Setup/retropie_setup. sh
Manage packages
Manage optional packages
309 kodi
...
Hi, thanks for sharing. You have a extra space between setup. and sh.
Maybe you could upload your code to github or bitbucket, so everyone can push back changes easily?

User avatar
moooarcuuuus
Posts: 232
Joined: Tue Jul 04, 2017 1:28 am
Has thanked: 2 times
Been thanked: 94 times

Re: Arduino code selector for Kites SAIO

Post by moooarcuuuus » Fri Dec 22, 2017 1:48 am

Next year
Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep... Game Over

salami738
Posts: 128
Joined: Sat Sep 09, 2017 6:06 am
Location: Germany
Has thanked: 60 times
Been thanked: 37 times

Re: Arduino code selector for Kites SAIO

Post by salami738 » Wed Dec 27, 2017 8:49 am

Some ideas from me for this interesting solution:

- Check, if the flashing can be done automatically, before a ScummVM game (or Amiga, ...) is started
- Use a custom HID ID String for the different Arduino implementation, so we can distinguish the different firmwares (commandline 'lsusb -l'). So we only have to flash a new one, if it is an other implementation

User avatar
starmagoo
Posts: 70
Joined: Mon Mar 27, 2017 1:56 pm
Location: Germany
Has thanked: 69 times
Been thanked: 8 times
Contact:

Re: Arduino code selector for Kites SAIO

Post by starmagoo » Sat Dec 30, 2017 5:03 pm

Great idea!
Flashing worsk fine and i can choose joystick. "B = left click and A = right click" don't work in the RetroPie menu to choose the game.

sgtgrumbles
Posts: 28
Joined: Mon Jun 05, 2017 9:53 pm
Has thanked: 3 times
Been thanked: 7 times

Re: Arduino code selector for Kites SAIO

Post by sgtgrumbles » Sat Dec 30, 2017 10:30 pm

Very cool!

I was able to get the SCUMM games workings (Monkey Island 1 & 2) as well as other DOS games (Wolfenstein 3D, Discworld) using DOSBox. I remapped the buttons on the SAIO to mouse/keyboard inputs using a program called joymap (version 0.4.1).

Each game has a custom run script in roms/pc (e.g., monkey1.sh, monkey2.sh, wolf3d.sh). The script runs joymap using game-specific input remappings then launches DOSBox. Here's an example of what that all looks like with Monkey Island 2:

Here's the joymap configuration file (monkey2_joymap.map) to remap the inputs:

Code: Select all

# Linux joystick mappings for Kite SAIO SNES-style controller for DosBox Monkey Island 2 using joymap 0.4.1 (MUST BE 0.4.1)
#   button "src" values found by running jstest /dev/input/js0
#   button "button" values for keyboard found in joymap's keys.txt file (joymap-0.4.1/keys.txt)
#   "vendor" and "product" values found in /proc/bus/input/devices
#   Monkey Island keyboard controls found in game's user manual
# Kite SAIO Gameboy Zero, Arduino LLC Arduino Leonardo, Vendor=2341 Product=8036 Version=0101

# map controller d-pad to mouse movement
axis vendor=0x2341 product=0x8036 src=16 target=mouse axis=0 flags="trinary"
axis vendor=0x2341 product=0x8036 src=17 target=mouse axis=1 flags="trinary"

# controller X to mouse right click (highlighted verb)
button vendor=0x2341 product=0x8036 src=3 target=mouse button=1

# controller A to mouse left click (walk to)
button vendor=0x2341 product=0x8036 src=0 target=mouse button=0

# controller Y to keyboard ESC key (skip cutscene)
button vendor=0x2341 product=0x8036 src=2 target=kbd button="esc"

# controller L to keyboard Q key (item page up)
button vendor=0x2341 product=0x8036 src=7 target=kbd button="q"

# controller R to keyboard A key (item page down)
button vendor=0x2341 product=0x8036 src=9 target=kbd button="a"

# controller START to keyboard F5 key (menu)
button vendor=0x2341 product=0x8036 src=4 target=kbd button="f5"

# controller SELECT to keyboard ALT-x keys (press twice to exit)
button vendor=0x2341 product=0x8036 src=5 target=kbd button="y REL y leftalt x REL x REL leftalt
Here's the DOSBox config (monkey2.conf):

Code: Select all

[sdl]
sensitivity=950

[joystick]
joysticktype=none
And here's the Bash script I launch in Emulationstation to run the game (monkey2.sh):

Code: Select all

#!/bin/bash
# make sure this file is executable (i.e., chmod +x monkey2.sh)

# load the Linux joymap controller mappings (don't use DosBox's joypad support)
sudo /home/pi/joymap/joymap-0.4.1/loadmap /home/pi/RetroPie/roms/pc/monkey2_joymap.map &

# launch DosBox (use loadmap to simulate mouse and keyboard events)
"/opt/retropie/emulators/dosbox/bin/dosbox" \
-userconf \
-conf '/home/pi/RetroPie/roms/pc/monkey2.conf' \
-c "MOUNT C /home/pi/RetroPie/roms/pc/.monkey2" \
-c 'C:\' \
-c 'MONKEY2.EXE' \
-c "exit"

# stop Linux joymap controller mappings
sudo killall loadmap

# wait for joymap's loadmap to die otherwise EmulationStation crashes with assertion failure
sleep 1
This script requires that the game be installed in /home/pi/RetroPie/roms/pc/.monkey2. I have my old Monkey Island IBM PC CD so I used that. I may have needed to initially run DOSBox to install the game to C:\ (mounted to ~/RetroPie/roms/pc/.monkey2 but I can't remember it was so long ago). In any case, here's what that folder looks like:

Code: Select all

pi@gameboyzero:~/RetroPie/roms/pc/.monkey2 $ ls -la
total 9180
drwxr-xr-x 3 pi pi    4096 Aug 13 23:01 .
drwxr-xr-x 9 pi pi    4096 Dec 31 00:12 ..
-r--r--r-- 1 pi pi   20736 Aug  9  1996 ADLIB.IMS
drwxr-xr-x 2 pi pi    4096 Aug 13 23:01 MKY2
-r--r--r-- 1 pi pi   11135 Feb 29  1992 MONKEY2.000
-r--r--r-- 1 pi pi 9080329 Feb 29  1992 MONKEY2.001
-r--r--r-- 1 pi pi  114195 Sep  6  1996 MONKEY2.EXE
-r--r--r-- 1 pi pi     967 Jun  5  1997 MONKEY2.PIF
-r--r--r-- 1 pi pi   18976 May 14  1992 ROL_330.IMS
-r--r--r-- 1 pi pi   18976 May 14  1992 ROL_332.IMS
-r--r--r-- 1 pi pi   18976 May 14  1992 ROL_334.IMS
-r--r--r-- 1 pi pi   18976 May 14  1992 ROL_336.IMS
-r--r--r-- 1 pi pi   18976 May 15  1992 ROLAND.IMS
-r--r--r-- 1 pi pi   24904 Aug  9  1996 SOUNBLAS.IMS
-r--r--r-- 1 pi pi   20062 May 15  1992 SPEAKER.IMS
If something goes wrong, check the log files in /var/run/shm/ for errors.

I also use a similar method to run C64 games (although that requires an additional level of input indirection -- i.e., I use loadmap in conjunction with vice's internal input remappings/hotkeys).

User avatar
moooarcuuuus
Posts: 232
Joined: Tue Jul 04, 2017 1:28 am
Has thanked: 2 times
Been thanked: 94 times

Re: Arduino code selector for Kites SAIO

Post by moooarcuuuus » Sun Jan 07, 2018 2:52 am

salami738 wrote:
Fri Dec 22, 2017 1:13 am
Maybe you could upload your code to github or bitbucket, so everyone can push back changes easily?
In one hour.
salami738 wrote:
Wed Dec 27, 2017 8:49 am
Some ideas from me for this interesting solution:

- Check, if the flashing can be done automatically, before a ScummVM game (or Amiga, ...) is started
- Use a custom HID ID String for the different Arduino implementation, so we can distinguish the different firmwares (commandline 'lsusb -l'). So we only have to flash a new one, if it is an other implementation
That will be a very good way. But my script should be a very simple ui for select binary and start avrdude. No changes in runcommands or something else.
starmagoo wrote:
Sat Dec 30, 2017 5:03 pm
Great idea!
Flashing worsk fine and i can choose joystick. "B = left click and A = right click" don't work in the RetroPie menu to choose the game.
It is a bit tricky. You have to restart the GB (or just emulation station) for configure the input (keyboard device) one time.
sgtgrumbles wrote:
Sat Dec 30, 2017 10:30 pm
Very cool!
Your way too. Thanks for the great tutorial.

There is a programm called "xboxdrv" that is very similar. https://github.com/RetroPie/RetroPie-Se ... ng-xboxdrv
Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep... Game Over

User avatar
moooarcuuuus
Posts: 232
Joined: Tue Jul 04, 2017 1:28 am
Has thanked: 2 times
Been thanked: 94 times

Re: Arduino code selector for Kites SAIO

Post by moooarcuuuus » Sun Jan 07, 2018 6:31 am

If you uncomment line 208 - 214 in the "saio-osd.py" from my repro and replace the original in "~/Super-AIO/release/saio/" with it, you become a logfile with column 1 runtime in deltaseconds and column2 voltage in decivolts/10. You can generate plots with it like this:
gnuplot01.png
gnuplot01.png (27.52 KiB) Viewed 10442 times
So you can see the charge and discharge curves of the battery.
Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep... Game Over

User avatar
starmagoo
Posts: 70
Joined: Mon Mar 27, 2017 1:56 pm
Location: Germany
Has thanked: 69 times
Been thanked: 8 times
Contact:

Re: Arduino code selector for Kites SAIO

Post by starmagoo » Mon Jan 08, 2018 2:41 pm

moooarcuuuus wrote:
Sun Jan 07, 2018 2:52 am
starmagoo wrote:
Sat Dec 30, 2017 5:03 pm
Great idea!
Flashing worsk fine and i can choose joystick. "B = left click and A = right click" don't work in the RetroPie menu to choose the game.
It is a bit tricky. You have to restart the GB (or just emulation station) for configure the input (keyboard device) one time.
In your video (01) you can return to the "Keyboard mode" by pressing the R1 key permanently. My DPad (up/down + right/left) also works but I can't use A and B to select a game or return (by pressing R1). Nothing's happened. You got it on video. How can I solve this?

salute

User avatar
moooarcuuuus
Posts: 232
Joined: Tue Jul 04, 2017 1:28 am
Has thanked: 2 times
Been thanked: 94 times

Re: Arduino code selector for Kites SAIO

Post by moooarcuuuus » Tue Jan 09, 2018 3:30 am

Hmm... Strange. Do you use the latest files from the repro? You can safety delete the whole folder with "rm -r moooarcuuuusCode" and make a "git clone https://github.com/MarcusKoe/moooarcuuuusCode.git" and setup again.

Lets test with the attached .zip file, it will delete your eeprom settings in the arduino. I assume you have a new 0.6 SAIO-board. Do not unzip the file in windows or some crappy os, do it on the pi0.

Copy the attached file in /home/pi/moooarcuuuusCode on the SD-Card
Log in over ssh go to the folder "cd moooarcuuuusCode"
Unzip the file "unzip SAIO_v2a-MouseKeyboard.ino.hex.zip"
Flash with the standard layout "sh flash.sh arduino-precompiled-ports/0.6/SAIO_v2a.ino.hex". It can take some time. Avrdude is ready after some "##########".
Press in emulation station "Start" (the Main Menu opens). Select "configure input". Say "yes" at "are you sure...".
The controller configuration should open: https://github.com/RetroPie/RetroPie-Se ... figuration
Now flash the new file "sh flash.sh SAIO_v2a-MouseKeyboard.ino.hex"
At this point, wlan should go off by itself. You can turn it later on again with "mode + A".
Now very important: Hold R1 and press X or Y. There should be a "keyboard" detected
Hold R1 and configure dpad, start, select and a, b, x, y. Skip all other.

It should work now. If R1 is pressed keyboard is active if not the dpad is a mouse and A, B are right and left click. You dont have to configure the controller again if you switch between gamepad (Kites code) and the keyboardmouse with the ports items.
Attachments
SAIO_v2a-MouseKeyboard.ino.hex.zip
(14.97 KiB) Downloaded 549 times
Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep... Game Over

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest