ZX81 emulator for iOS

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

Re: ZX81 emulator for iOS

Post by kpalser »

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 8: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: 2059
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: ZX81 emulator for iOS

Post by dr beep »

kpalser wrote: Sat Oct 07, 2017 3: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: 128
Joined: Fri May 09, 2008 4:49 pm

Re: ZX81 emulator for iOS

Post by nama »

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: 2059
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: ZX81 emulator for iOS

Post by dr beep »

nama wrote: Sat Oct 07, 2017 10: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: 5087
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: ZX81 emulator for iOS

Post by 1024MAK »

dr beep wrote: Sat Oct 07, 2017 11:03 pmThe 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
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
User avatar
kpalser
Posts: 80
Joined: Sun Jun 03, 2012 2:18 pm
Location: Dundee, Scotland

Re: ZX81 emulator for iOS

Post by kpalser »

Hi Philip,

Glad to hear that the controls work better for you in the more recent versions.
nama wrote: Sat Oct 07, 2017 10: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 10: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
User avatar
kpalser
Posts: 80
Joined: Sun Jun 03, 2012 2:18 pm
Location: Dundee, Scotland

Re: ZX81 emulator for iOS

Post by kpalser »

It’s been a while since I’ve posted on this topic thread. A new update (v1.6.0) has just been released on the App Store, which incorporates Chroma colour support.

The main limitation still exists of not being permitted to load programs except those already included with the app. The Apple developer program license agreement seems to be more opaque about their reasoning - boils down to not wanting to loose control with apps behaving like mini independent app stores. There is no intention ever to build in any back doors into the app and flout their rules.

In addition to Chroma colour functionality, accuracy and performance updates, since the last post there have been numerous improvements:
  • Growing list of included programs thanks to the permission of their developers. The software section has an improved split screen layout (for larger iOS devices) with a search filter option.
  • Core interface (generally not including program descriptions) translated into German, Russian and Portuguese.
  • More RAM and ROM options including corresponding virtual keyboard styles.
  • ZON-X(81) and UDG peripheral support.
  • Memory/Computer state saving to allow users to restore sessions.
  • Various miscellaneous functionality points such as display screenshots (without the rest of the interface).
dr beep
Posts: 2059
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: ZX81 emulator for iOS

Post by dr beep »

And due to Apple rules a few version ago my FRUITMACHINESIMULATOR had to be removed.
User avatar
mrtinb
Posts: 1905
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: ZX81 emulator for iOS

Post by mrtinb »

Any explanation for the removal?
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
User avatar
1024MAK
Posts: 5087
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: ZX81 emulator for iOS

Post by 1024MAK »

kpalser wrote: Mon May 27, 2019 5:05 pm It’s been a while since I’ve posted on this topic thread. A new update (v1.6.0) has just been released on the App Store, which incorporates Chroma colour support.
Great news 👍 :D 👏

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
Post Reply