ZX81 Emulator (sz81) D-Pad remapping


Asmo

Advanced Member
Joined
Oct 18, 2008
Messages
2,279
Many moons ago Streak released a port of a pretty good Sinclair ZX81 emulator, "sz81". It's still linked to via the Pandora Wiki, see the emulators list page.


The only problem with it was that the remapping function seems to work only for externally connected joypads, and the D-Pad is set to the cursor keys - though not the ones expected by most games, it's set to the CODE-SHIFTed cursors, really only used for moving the cursor within lines of code when editing. Games that use the 'cursors' usually mean keys 5.6.7.8 and 0 - no CODE SHIFT (the red left shift button) used.


The result being that if you wanted to play 3D Monster Maze, featured on the cover of Retro Gamer's 99th issue recently, you had to use the Pandora's 5,6,7,8 and 0 keys. Tricky.


Anyhoo, purely by accident I noticed that when you exit sz81 it prompts you "Write to sz81rc?". Highlight yes and press Enter, and a config file called sz81rc is created in a hidden folder in:


pandora/appdata/sz81-app/


The hidden folder in there is called .sz81 - the file you want is in there.


The original default sz81rc file looks like this:

version=2.1.7


show_input_id=FALSE


joystick_dead_zone=75


key_repeat.delay=320


key_repeat.interval=120


emulator.speed=100


emulator.frameskip=1


emulator.model=MODEL_ZX81


emulator.ramsize=16


emulator.invert=FALSE


sound.volume=128


sound.device=DEVICE_NONE


sound.stereo=FALSE


vkeyb.alpha=255


vkeyb.autohide=FALSE


vkeyb.toggle_shift=FALSE


colour.emu_fg=202018


colour.emu_bg=f0f0e8


colour.hs_load_selected=00ff00


colour.hs_load_pressed=ffc000


colour.hs_vkeyb_zx80_selected=00ff00


colour.hs_vkeyb_zx80_pressed=ffff00


colour.hs_vkeyb_zx80_toggle_pressed=ff4000


colour.hs_vkeyb_zx81_selected=00ff00


colour.hs_vkeyb_zx81_pressed=ffc000


colour.hs_vkeyb_zx81_toggle_pressed=ff4000


colour.hs_ctb_selected=00ff00


colour.hs_ctb_pressed=ffc000


colour.hs_options_selected=00ff00


colour.hs_options_pressed=ffc000


ctrl_remap.components=COMP_ALL


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_RSHIFT


ctrl_remap.remap_device=DEVICE_KEYBOARD


ctrl_remap.remap_id=SDLK_LSHIFT


ctrl_remap.remap_mod_id=


ctrl_remap.components=COMP_EMU | COMP_VKEYB


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_UP


ctrl_remap.remap_device=DEVICE_KEYBOARD


ctrl_remap.remap_id=SDLK_7


ctrl_remap.remap_mod_id=SDLK_LSHIFT


ctrl_remap.components=COMP_EMU | COMP_VKEYB


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_DOWN


ctrl_remap.remap_device=DEVICE_KEYBOARD


ctrl_remap.remap_id=SDLK_6


ctrl_remap.remap_mod_id=SDLK_LSHIFT


ctrl_remap.components=COMP_EMU | COMP_VKEYB


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_LEFT


ctrl_remap.remap_device=DEVICE_KEYBOARD


ctrl_remap.remap_id=SDLK_5


ctrl_remap.remap_mod_id=SDLK_LSHIFT


ctrl_remap.components=COMP_EMU | COMP_VKEYB


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_RIGHT


ctrl_remap.remap_device=DEVICE_KEYBOARD


ctrl_remap.remap_id=SDLK_8


ctrl_remap.remap_mod_id=SDLK_LSHIFT


ctrl_remap.components=COMP_EMU | COMP_VKEYB


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_BACKSPACE


ctrl_remap.remap_device=DEVICE_KEYBOARD


ctrl_remap.remap_id=SDLK_0


ctrl_remap.remap_mod_id=SDLK_LSHIFT


ctrl_remap.components=COMP_EMU | COMP_VKEYB


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_COMMA


ctrl_remap.remap_device=DEVICE_KEYBOARD


ctrl_remap.remap_id=SDLK_PERIOD


ctrl_remap.remap_mod_id=SDLK_LSHIFT


ctrl_remap.components=COMP_LOAD


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_PAGEUP


ctrl_remap.remap_device=DEVICE_KEYBOARD


ctrl_remap.remap_id=SDLK_q


ctrl_remap.remap_mod_id=SDLK_LSHIFT


ctrl_remap.components=COMP_LOAD


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_PAGEDOWN


ctrl_remap.remap_device=DEVICE_KEYBOARD


ctrl_remap.remap_id=SDLK_a


ctrl_remap.remap_mod_id=SDLK_LSHIFT


ctrl_remap.components=COMP_LDFILE | COMP_SSTATE | COMP_DIALOG | COMP_RUNOPTS_ALL


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_LEFT


ctrl_remap.remap_device=DEVICE_CURSOR


ctrl_remap.remap_id=CURSOR_W


ctrl_remap.remap_mod_id=


ctrl_remap.components=COMP_LDFILE | COMP_SSTATE | COMP_DIALOG | COMP_RUNOPTS_ALL


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_RIGHT


ctrl_remap.remap_device=DEVICE_CURSOR


ctrl_remap.remap_id=CURSOR_E


ctrl_remap.remap_mod_id=


ctrl_remap.components=COMP_LDFILE | COMP_SSTATE | COMP_DIALOG | COMP_RUNOPTS_ALL


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_RETURN


ctrl_remap.remap_device=DEVICE_CURSOR


ctrl_remap.remap_id=CURSOR_HIT


ctrl_remap.remap_mod_id=


ctrl_remap.components=COMP_SSTATE | COMP_RUNOPTS_ALL


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_UP


ctrl_remap.remap_device=DEVICE_CURSOR


ctrl_remap.remap_id=CURSOR_N


ctrl_remap.remap_mod_id=


ctrl_remap.components=COMP_SSTATE | COMP_RUNOPTS_ALL


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_DOWN


ctrl_remap.remap_device=DEVICE_CURSOR


ctrl_remap.remap_id=CURSOR_S


ctrl_remap.remap_mod_id=


Paragraphs 4-7 of that determine what keys the D-Pad is mapped to.


Those are the paragraphs beginning with:


ctrl_remap.components=COMP_EMU | COMP_VKEYB


You can see the references to keys 5,6,7,8 in the 2nd last lines.


To remove the left (red) shift key binding to the cursors (56780) so the D-Pad will work as cursors in games that use them you need to delete the reference to SDLK_LSHIFT in the last line each of each paragraph.


So, for D-Pad cursor conrol in games like 3D Monster Maze, those lines in the sz81rc file that has been edited will look like:

ctrl_remap.components=COMP_EMU | COMP_VKEYB


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_UP


ctrl_remap.remap_device=DEVICE_KEYBOARD


ctrl_remap.remap_id=SDLK_7


ctrl_remap.remap_mod_id=


ctrl_remap.components=COMP_EMU | COMP_VKEYB


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_DOWN


ctrl_remap.remap_device=DEVICE_KEYBOARD


ctrl_remap.remap_id=SDLK_6


ctrl_remap.remap_mod_id=


ctrl_remap.components=COMP_EMU | COMP_VKEYB


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_LEFT


ctrl_remap.remap_device=DEVICE_KEYBOARD


ctrl_remap.remap_id=SDLK_5


ctrl_remap.remap_mod_id=


ctrl_remap.components=COMP_EMU | COMP_VKEYB


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_RIGHT


ctrl_remap.remap_device=DEVICE_KEYBOARD


ctrl_remap.remap_id=SDLK_8


ctrl_remap.remap_mod_id=


Obviously, you could change the references to 5,6,7,8 in those to any other keys if you want to play a game with the D-Pad that doesn't support cursors.


Now a question - the paragraph that follows those in the sz81rc file maps the Backspace (delete) function to the Pandora DEL key. This isn't needed, as SHIFT+0 will do that anyway. I don't know if additional paragraphs can be added (I presume so, haven't tried yet) but at least this one could be changed to map your choice of 'fire' key to one of the Pandora's A,B,X,Y buttons rather than having to use whatever key on the actual keyboard a game uses.


So does anyone know what the "SDLK_" assignation for any of the Pandora's A,B,X,Y buttons would be, if posssible, so that they can be remapped too?


Fortunately, 3D Monster Maze has no fire button, so you could get stuck into that without any more remapping. :)
 
Last edited by a moderator:

gruso

thunderbox
Joined
Feb 28, 2008
Messages
7,461
Age
44
Location
Sydney, Australia
Website
pandorapress.net
So does anyone know what the "SDLK_" assignation for any of the Pandora's A,B,X,Y buttons would be, if posssible, so that they can be remapped too?
I think this is what you seek. A more complete list is difficult to find in any Pandora related resources (perhaps because the QWERTY stuff uses generic SDL codes, not Pandora specific). In any case, what we know should probably be added here: http://www.pandorawiki.org/Keyboard
 
Last edited by a moderator:

Asmo

Advanced Member
Joined
Oct 18, 2008
Messages
2,279
I think this is what you seek. A more complete list is difficult to find in any Pandora related resources (perhaps because the QWERTY stuff uses generic SDL codes, not Pandora specific).

Perfect. That was it, thanks! I know a few people were curious about this when it was on the repo, hopefully they'll see this and give it a shot now.


You can indeed add extra paragraphs, so mapping keyboard buttons to the A,B,X,Y 'fire' buttons is straightforward.


For example, add the following paragraph to map 0 (Zero - the 'fire' key in a game using 'cursor' keys) to the Pandora X button -


ctrl_remap.components=COMP_EMU | COMP_VKEYB


ctrl_remap.protected=TRUE


ctrl_remap.device=DEVICE_KEYBOARD


ctrl_remap.id=SDLK_PAGEDOWN


ctrl_remap.remap_device=DEVICE_KEYBOARD


ctrl_remap.remap_id=SDLK_0


line 4 identifies the X button


last line maps the 0 key to it


As Gruso's link says, the A,B,X,Y buttons are identified as;


A SDLK_HOME


B SDLK_END


X SDLK_PAGEDOWN


Y SDLK_PAGEUP


So just add additional paragraphs with one of those in the 4th line, and the key of choice to map to it in the last as in the sample above.


Joy. Silent, black & white joy. Must be because The Artist won the Oscars.
 
Last edited by a moderator:
Top