Author Topic: Roland, probably the worst Amstrad CPC emulator  (Read 17736 times)

0 Members and 1 Guest are viewing this topic.

Offline antoniovillena

  • CPC664
  • ***
  • Posts: 87
  • Liked: 88
  • Likes Given: 3
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #25 on: 20:29, 21 September 11 »
Now you can record games with Roland, look at these examples:

http://roland.antoniovillena.es/464s?TnmT0w.rec
http://amstradcpc.es/emulador/464.html?TnocxQ.rec

As easy as pressing F6 when you end your game

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.018
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3452
  • Likes Given: 6208
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #26 on: 21:07, 21 September 11 »
Heeey, this is pretty neat!

I always wondered, how is this done?

Offline antoniovillena

  • CPC664
  • ***
  • Posts: 87
  • Liked: 88
  • Likes Given: 3
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #27 on: 22:35, 21 September 11 »
Heeey, this is pretty neat!

I always wondered, how is this done?


The recordings are made with the emulator itself. Just launch a game (from roland.antoniovillena.es or amstradcpc.es) and press F6 key when finish. You can interrupt the playback with F3, or go to the end of the playback with F4, and then, continue playing.

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.018
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3452
  • Likes Given: 6208
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #28 on: 10:13, 22 September 11 »
Well, yes, I gathered that much, but *how* does the emulator do it? How does it record it?

One way to do it in other emulators is to record input, but this doesn't work in non-predetermined games...

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1016
  • Likes Given: 926
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #29 on: 12:32, 22 September 11 »
Well, yes, I gathered that much, but *how* does the emulator do it? How does it record it?

One way to do it in other emulators is to record input, but this doesn't work in non-predetermined games...

Why not?
When the timing is 100% accurate, also "random values" are the same!

Sadly the VSync in JavaCPC seem to be not 100% accurate...
Recordings get out of sync after a while... :(
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.018
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3452
  • Likes Given: 6208
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #30 on: 12:34, 22 September 11 »
Maybe I don't understand something about how games are modified at launch.

If you get a game where the enemies are found in random positions with each new game, or where the items are in random rooms etc. etc, what good would input recording do?

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1016
  • Likes Given: 926
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #31 on: 12:36, 22 September 11 »
Well, random numbers are generated in Z80.
A recording looks like this:
- Take a SNA snapshot
- keep this snapshot in memory
- record keyboard input
- When done, save SNA with attached keyboard inputs.

The random values so are always the same!
(You can try in BASIC! When you print a random number with a "RANDOMIZE xxx" before, the random numbers are always the same after a RUN)
So a SNA also does a kind like "RANDOMIZE" when loaded...
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.018
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3452
  • Likes Given: 6208
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #32 on: 12:38, 22 September 11 »
Ah, yeah, I thought of the snapshot thing, but I thought I can't be that clever - so it must be something else :D

Ok, simpler than I thought then. Thanks!

Offline PhilZeVibe

  • 464 Plus
  • *****
  • Posts: 471
  • Country: fr
    • CPCBox - CPC emulator in JavaScript
  • Liked: 165
  • Likes Given: 187
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #33 on: 12:51, 22 September 11 »
In fact, a snapshot is not even necessary.
With emulators, you can achieve 100% deterministic behaviour too with an auto-boot from the dsk.
Atwood's law (2007): "Any application that can be written in JavaScript, will eventually be written in JavaScript."

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.018
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3452
  • Likes Given: 6208
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #34 on: 12:54, 22 September 11 »
Yeah, I guess this makes sense: determine the initial conditions and you're all set...

Offline antoniovillena

  • CPC664
  • ***
  • Posts: 87
  • Liked: 88
  • Likes Given: 3
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #35 on: 14:41, 22 September 11 »
Yes, the key is that all in a computer is deterministic. If you save the state of a machine and record exactly all the input (keystrokes and mouse events), then you will show the same results in the output (screen and audio)

As Devilmarkus says, the emulator must be accurate to work with other emulators recordings (there is a SNP format). If JavaCPC fails in VSYNC, probably Roland fails in other stuff. So it uses their own recording format.

As phi2x says, Roland uses TAPs and DSKs in normal cases. Also there is a special case (for example if you want to record only the second level of a game) where you can use also SNAs.

So Gryzor, there is not any secret in input recording. The only change in the emulator is that now I sample the keystate every frame (because keystrokes are recorded in frame units, 20ms). Not necesary if you use CPU cycles as time unit.
« Last Edit: 15:01, 22 September 11 by antoniovillena »

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1016
  • Likes Given: 926
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #36 on: 15:07, 22 September 11 »
Not necesary if you use CPU cycles as time unit.

I also tried with CPU cycles!
There's still a sync problem with!
Funny:
When I just change a bit of the code it already causes these problems!
I mean: Use the same code but with different variable names for example!

And that's really strange....
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Offline PhilZeVibe

  • 464 Plus
  • *****
  • Posts: 471
  • Country: fr
    • CPCBox - CPC emulator in JavaScript
  • Liked: 165
  • Likes Given: 187
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #37 on: 15:30, 22 September 11 »
This game recording stuff makes me think about a technology somehow related: the "Sands of time" rewinding functionality.
It became quite popular lately on console emulators.

Instead of trying to describe it, I think that video will do it better to understand what this is and what's the point:
[youtube]36u0oJkB_pY[/youtube]

So, would it be a desirable feature to have for a CPC emulator?
Would it help us enjoy insanely difficult games? Or would it spoil all the fun?
Atwood's law (2007): "Any application that can be written in JavaScript, will eventually be written in JavaScript."

Offline antoniovillena

  • CPC664
  • ***
  • Posts: 87
  • Liked: 88
  • Likes Given: 3
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #38 on: 16:03, 22 September 11 »
So, would it be a desirable feature to have for a CPC emulator?
Would it help us enjoy insanely difficult games? Or would it spoil all the fun?

You can do rollback in Roland (with F3 and F4). Then if you save the gameplay, you will
see the perfect playgame (the mistakes were deleted in the recording).

Yes, It's not exactly the REWIND feature, but running backwards an emulator is a very difficult task. You must save a log with past values in not reverseable instructions (like ld bc,0). Also the reverseable instructions (like add a, b) must log some flags.

Offline PhilZeVibe

  • 464 Plus
  • *****
  • Posts: 471
  • Country: fr
    • CPCBox - CPC emulator in JavaScript
  • Liked: 165
  • Likes Given: 187
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #39 on: 16:29, 22 September 11 »
Yes, It's not exactly the REWIND feature, but running backwards an emulator is a very difficult task. You must save a log with past values in not reverseable instructions (like ld bc,0). Also the reverseable instructions (like add a, b) must log some flags.

Another solution would be storing differential snapshots on a frame per frame basis. It would probably be less of an headache than reversing on opcode basis.
And a CPC can't do all that much in a frame time. So, my guess is that the average differential snapshot would be about 8KB.

So, how much memory would be required for a 30 seconds rewind buffer?
Let's do the math: 8KB * 50 frames * 30 seconds = 12000KB = 12MB

A bargain for our multi gigabytes computers of today. ;)
Atwood's law (2007): "Any application that can be written in JavaScript, will eventually be written in JavaScript."

Offline PhilZeVibe

  • 464 Plus
  • *****
  • Posts: 471
  • Country: fr
    • CPCBox - CPC emulator in JavaScript
  • Liked: 165
  • Likes Given: 187
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #40 on: 16:48, 22 September 11 »
Thinking about it a bit more, differential snapshots are not that practical because you have to process every differential since the first one to extract that snapshot when you'll want to rewind. So, it will be very heavy on the CPU.
It's like video encoding in a way. What they do in video encoders is storing keyframes at regular intervals between differential frames.
So, it would be a mix of full snapshots (every 10 frames?) and differential ones.

Let's do the math again:
full snapshots : 128KB * 5 frames * 30 seconds = 19200KB
+ differential snapshots: 8KB * 45 frames * 30 seconds = 10800KB

19200KB + 10800KB = 30000KB = 30MB

Still a bargain  :) ... but more complex than I thought!
« Last Edit: 16:49, 22 September 11 by phi2x »
Atwood's law (2007): "Any application that can be written in JavaScript, will eventually be written in JavaScript."

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.018
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3452
  • Likes Given: 6208
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #41 on: 17:21, 22 September 11 »
Holy frak, rewinding is fantastic!!!! I want it for the CPC emulators now...

Offline antoniovillena

  • CPC664
  • ***
  • Posts: 87
  • Liked: 88
  • Likes Given: 3
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #42 on: 17:41, 22 September 11 »
Thinking about it a bit more, differential snapshots are not that practical because you have to process every differential since the first one to extract that snapshot when you'll want to rewind. So, it will be very heavy on the CPU.
It's like video encoding in a way. What they do in video encoders is storing keyframes at regular intervals between differential frames.
So, it would be a mix of full snapshots (every 10 frames?) and differential ones.

Let's do the math again:
full snapshots : 128KB * 5 frames * 30 seconds = 19200KB
+ differential snapshots: 8KB * 45 frames * 30 seconds = 10800KB

19200KB + 10800KB = 30000KB = 30MB

Still a bargain  :) ... but more complex than I thought!

Another solution is saving full snaspshots every, for example, 5 seconds. If you rewind 2 seconds, and for example the last snapshot is saved 3 second back, you only have to emulate 1 second forwards to extract the correct snapshot. The worst case is to emulate 5 seconds forward but it's easy because you don't have to do in real time (cpu can be full throtle) and to show anything to screen or buffer sound.

The other question is that you must log a circular buffer every frame of last 5 seconds (or the time you want to rewind) to show the user the illusion of the rewind. But in this case you only must save the video screen (16Kb each frame).

So redoing the calcs, you need: 128K * 1/5 * 30 seconds= 768k
For video buffer: 16K * 50frames/second * 5 seconds= 4Mb (video buffer is the same indepently on recording duration)

I have made a recording of a difficult game (with rollback of course) here:

http://amstradcpc.es/emulador/664.html?TntBgA.rec





Offline antoniovillena

  • CPC664
  • ***
  • Posts: 87
  • Liked: 88
  • Likes Given: 3
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #43 on: 18:57, 22 September 11 »

In this link you can view the recorded gameplays, only the ones in that players fill user & comment field.

http://amstradcpc.es/emulador/partidas.php

Offline RockRiver

  • CPC664
  • ***
  • Posts: 115
  • Country: aq
  • Liked: 18
  • Likes Given: 52
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #44 on: 13:05, 07 December 11 »
I owns a ZX Spectrum +2A)
Thanks for your work!!! mate.
I recommend to you to acquire a +3 [disquette support compatible PCW and CPC] and then a 6128. These are two of my favorites retro-compus. HcX compatible too ;-)
Or study the great emus that support that... in +3 side I like so much RealSpectrum with "real"disquette reading like WinAPE. This make easy sharing software within my real and virtual machines.

Offline Mochilote

  • CPC464
  • **
  • Posts: 49
  • Country: es
    • CPCMania
  • Liked: 76
  • Likes Given: 24
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #45 on: 20:38, 29 December 11 »
Roland running at 9x% on iphone 4 (IOS 5.0.1):







it's a shame that can not be used because they have no on-screen keyboard... :D

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.018
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3452
  • Likes Given: 6208
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #46 on: 11:07, 07 February 12 »
Hmmm unfortunately the % doesn't show up on my Android browser... impressive though!

Offline antoniovillena

  • CPC664
  • ***
  • Posts: 87
  • Liked: 88
  • Likes Given: 3
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #47 on: 23:08, 16 February 12 »
I have seen this page:
http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/


So it's possible to map the joystick by clicking in the border. I have not Android or IOS mobile, so I can't try, but it's a good suggestion for the next version of Roland.


Code: [Select]
   |       |
---|-------|---
 U |       |
 D |       |
---|-------|---
 F |  L  R |


  Sorry the ugly Ascii, so I propose these locations for UP, DOWN, LEFT, RIGHT and FIRE.


  Another question, is all the keyboard mapped in these devices or i need remap some keys (or adding touch support)?
-----

Offline antoniovillena

  • CPC664
  • ***
  • Posts: 87
  • Liked: 88
  • Likes Given: 3
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #48 on: 01:25, 06 June 14 »
Updated emulator


Roland, probably the worst Amstrad CPC emulator


Because it lacks of sound in latest versions of Firefox. Now I have ported the Firefox code to Web Audio Api and works well.

Offline Zoe Robinson

  • Supporter
  • 6128 Plus
  • *
  • Posts: 708
  • Country: gb
  • I become a minor egg
    • ZoeRobinson.com
  • Liked: 747
  • Likes Given: 729
Re: Roland, probably the worst Amstrad CPC emulator
« Reply #49 on: 21:08, 20 June 14 »
Updated emulator


Thank you for removing any chance of me getting any work done today. :)


*goes back to playing Silkworm on your website*