ZX81 emulator for iOS

Emulator and emulator development specific topics
User avatar
kpalser
Posts: 43
Joined: Sun Jun 03, 2012 1:18 pm
Location: Dundee, Scotland

Re: ZX81 emulator for iOS

Post by kpalser » Sat Oct 07, 2017 2:42 pm

Hi Philip

A recap first. There are two approaches for a user program, game in this case, to determine the keys being pressed:
1) rely on the ROM interrupt routine that will store the result in LASTK system variable
2) read the rows of the keyboard with IN Z80 instruction outside of the ROM routine

The former having the advantage of needing less code by the developer. However aside from SHIFT + Key combinations, it does not work for simultaneous keypresses. The latter approach is more involved to incorporate in programs but can be used to determine multiple simultaneous keypresses.
nama wrote:
Fri Oct 06, 2017 7:38 pm
Hi,
Is there a way to have an option where the virtual joystick activates in 'single push' mode. In other words, and as an example, if you push the virtual joystick left, and continue to hold it left, can it just be register as a single keystroke (on then off), as opposed to being seen as still having the key held down. Games like Chopperdrop act on single keypresses where only one key can be pressed at any one time. So presently when the joystick is pushed left and held there, you can't fire. Not fun.

Would be a great option.

Phil
Chopper Drop 3000 is a great game to have in the emulator so I was delighted when you allowed me to include it. You may recall that the initial versions of this iOS app had a bug and made the game run at an unplayable speed. Once I fixed that point and started added the gamepad controls I was keen to see how playable this game would be. As per your post we can tell it uses the ROM interrupt routine approach. Hence, at the time I added the single key press mode in the gamepad settings screen specifically with this game in mind. This option started off pretty much as your suggestion described, but I evolved the concept so that multiple keys could be pressed but the last key would take precedence in terms of the value that the ROM routine would see as being pressed and when released would then return to previous keys if still pressed. There is also some special timing logic to ensure keypresses were kept long enough to be logged despite another newer key then being pressed - this results in a small but sometimes perceptible time lag. Basically it's a fudge but most of the time a direction movement shouldn't stop a fire action.

As an experiment try quitting the game and see the effects of toggling the single key press mode on and off in conjunction with the characters displayed on the BASIC input screen. Other things to try are switching to the direction pad mode (as I suspect slight movement unintended vertical movement of the joystick control could be preempting the fire button sometimes) and also holding the fire key perhaps slightly longer to see that it does fire even when pressing another key.

The above aside, the ideal solution would be to remove the single keypress limitation from the game. So I contacted Johan Koelman of Dr Beep fame to ask if he would be willing to try and update Chopper Drop 3000 to use the other keyboard reading approach. He agreed. Obviously we're not talking TheMrCerebro rewrite or any branding changes. So Phillip if you agree, can Dr Beep have your blessing and take a look? If you have the source code that would be ideal but Johan says he's quite handy with a hex editor.

With the rate that Dr Beep releases new games the Software section of this iOS app could be called "Dr Beep et al." at this stage...

Kevin

dr beep
Posts: 1045
Joined: Thu Jun 16, 2011 7:35 am
Location: Boxmeer

Re: ZX81 emulator for iOS

Post by dr beep » Sat Oct 07, 2017 5:11 pm

kpalser wrote:
Sat Oct 07, 2017 2:42 pm

With the rate that Dr Beep releases new games the Software section of this iOS app could be called "Dr Beep et al." at this stage...
Kevin,

You are free to add them, it is not mandatory :D

Furthermore....
I think I will be working simultaneously on game 39 and game 40 since I don't know yet which one will be promoted game 40.
1 game is rather easy, but will get a figure from a classic game in it where the other game will be based on a game I played on elementary school bur NEVER is coded as a game for the PC

nama
Posts: 124
Joined: Fri May 09, 2008 3:49 pm

Re: ZX81 emulator for iOS

Post by nama » Sat Oct 07, 2017 9:53 pm

Hi Kevin,
Much thanks for the reply.
I understand now, and actually stand corrected. I thought I had the latest version, but after updating I see the game plays great. I'm not sure if the update had anything to do with the issue however. I also tried it on my wife's iPad and it played even better. If I can still make one comment. When playing on my iPhone I find the 'M' fire key to be way to close to the gamepad. Fat fingers don't help, but there just isn't enough room. If the 'M key was on the right side instead of the left this may help. Obviously it's better on an iPad compared to an iPhone.

One more suggestion, the settings 'cogs' icon is also very close to the virtual keys, it's very easy to accidentally tap this. Is there anyway to move further it away from the keys?

Well, it would certainly be great if dr beep could have a look at the code, however this game was actually written in BASIC, then 'ported' to MachineCode using the great Mcoder software http://www.zx81stuff.org.uk/zx81/tape/MCoder11 . So I don't actually have the source code per say, unless the BASIC source code counts.

Apologies for all the suggestions.

Phil

dr beep
Posts: 1045
Joined: Thu Jun 16, 2011 7:35 am
Location: Boxmeer

Re: ZX81 emulator for iOS

Post by dr beep » Sat Oct 07, 2017 10:03 pm

nama wrote:
Sat Oct 07, 2017 9:53 pm
Well, it would certainly be great if dr beep could have a look at the code, however this game was actually written in BASIC, then 'ported' to MachineCode using the great Mcoder software http://www.zx81stuff.org.uk/zx81/tape/MCoder11 . So I don't actually have the source code per say, unless the BASIC source code counts.
I took a look in the debugger while the code was running.
The way the program was "coded" made me think that is was either
1) Compiled from C-source
2) Compiled from other source

The ZX81 has in BASIC not the IN-command, but that could be solved with a small MC-routine. Question is if MCODER will accept that call.
First idea would be ; why not?

User avatar
1024MAK
Posts: 1764
Joined: Mon Sep 26, 2011 9:56 am
Location: Looking forward to summer in Somerset, UK...

Re: ZX81 emulator for iOS

Post by 1024MAK » Sat Oct 07, 2017 11:17 pm

dr beep wrote:
Sat Oct 07, 2017 10:03 pm
The ZX81 has in BASIC not the IN-command, but that could be solved with a small MC-routine. Question is if MCODER will accept that call.
Or maybe, put a PEEK instruction in the BASIC code, then after the conversion, replace the converted "PEEK" to a machine code IN instruction.

Mark

User avatar
kpalser
Posts: 43
Joined: Sun Jun 03, 2012 1:18 pm
Location: Dundee, Scotland

Re: ZX81 emulator for iOS

Post by kpalser » Sun Oct 08, 2017 12:20 pm

Hi Philip,

Glad to hear that the controls work better for you in the more recent versions.
nama wrote:
Sat Oct 07, 2017 9:53 pm
When playing on my iPhone I find the 'M' fire key to be way to close to the gamepad. Fat fingers don't help, but there just isn't enough room. If the 'M key was on the right side instead of the left this may help. Obviously it's better on an iPad compared to an iPhone.
As a temporary measure you can use the spinner control at the bottom of the gamepad settings screen to switch around the M / Y / N keys to have the order Y / N / M. I'll add that as the default game setting for the next store build.
nama wrote:
Sat Oct 07, 2017 9:53 pm
One more suggestion, the settings 'cogs' icon is also very close to the virtual keys, it's very easy to accidentally tap this. Is there anyway to move further it away from the keys?
It will take a bit more consideration for positioning. Getting it to work well for landscape vs portrait device orientations is a challenge across all iOS devices and settings. For example moving it up into unused space where the computer logo is displayed would only work in portrait when PAL mode is selected (i.e. not the width filling "Timex Sinclair TS1000" version). Had some fun when I prepared it for the yet to be released iPhone X safe area and not having the aspect ratio of the keyboard force the video display area to be minuscule - that's the main reason I recently rejigged the landscape view with left right side areas next to the virtual keyboard.

Regards,
Kevin

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests