Clock Signal — an Oric emulator for macOS and Linux

Comments, problems, suggestions about Oric emulators (Euphoric, Mess, Amoric, etc...) it's the right place to ask. And don't hesitate to give your tips and tricks that help using these emulations in the best possible way on your favorite operating system.
ThomH
Flying Officer
Posts: 238
Joined: Thu Oct 13, 2016 9:55 pm

Clock Signal — an Oric emulator for macOS and Linux

Post by ThomH »

EDIT: releases are now habitually here.

It's not like anybody is clamouring, so a brief rundown of the essentials:
  • cross platform in principle, Mac only at present;
  • an ordinary document-model app just like anything else on the OS — open as many Orics as you want, size and place windows however you want (including full screen), keep them in tabs if you have 10.11;
  • attempts to do the intelligent signals processing things — generates a 1Mhz audio wave, resamples it down to your computer rate; composite video mode involves building the composite signal and then decoding the composite signal, all GPU-side — no subjectivity applied for a hopefully non-tacky version of TV emulation;
  • several efforts at minimising latency;
  • cycle accurate;
  • phosphor decay and a genuine 60 different frames per second if your computer is 60Hz; 144 different frames if your computer is 144Hz, etc. Think like pointing a 60fps camera at your display, even if it's 50Hz;
  • also emulates some other machines. But who cares?
... it's just a shame that you currently can't load a single piece of software and the audio being produced is the silent wave, regardless of what you write to the PSG. Also the 6522 emulation is probably terrible. The timers are definitely [half-]cycle correct, but everything else is negligible.

Will provide binaries when there's even the slightest chance of it being interesting to anybody, i.e. when it'll load things and produce the intended audio.

Screenshots are all of composite video output. I've assumed colour phase advances by a quarter of a cycle on every line, hence the diagonals. That's not true of every machine, so might not be true of the Oric, I've yet to find out so just did the most PAL-conformant thing. Also I've used a vanilla RGB to PAL encoder, paying no attention to the machine specifics so might be way off. There's also an RGB mode because the real machine also has an RGB mode.
BASIC screenshot
BASIC screenshot
HIRES screenshot
HIRES screenshot
Diagnostic ROM screenshot
Diagnostic ROM screenshot
Last edited by ThomH on Tue Apr 03, 2018 7:16 pm, edited 3 times in total.
User avatar
ibisum
Wing Commander
Posts: 1643
Joined: Fri Apr 03, 2009 8:56 am
Location: Vienna, Austria
Contact:

Re: Yet Another

Post by ibisum »

This looks absolutely bonkers! Can't wait to see where you take it, and I'll definitely be a user the moment you release something ..
User avatar
Chema
Game master
Posts: 3013
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Yet Another

Post by Chema »

Hey! That is great news indeed! Keep on the good work. I'm looking forward to seeing what you come up with!
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Yet Another

Post by Dbug »

Interesting :)

Regarding timers, I wrote some benchmarking code few years ago which allowed us to notice discrepancies between real Orics, Oricutron and Euphoric, so when you have something that can run code, we should be able to help with your timings.
Godzil
Squad Leader
Posts: 774
Joined: Sat May 21, 2011 7:21 pm
Location: Between UK and France
Contact:

Re: Yet Another

Post by Godzil »

Dbug wrote:Interesting :)

Regarding timers, I wrote some benchmarking code few years ago which allowed us to notice discrepancies between real Orics, Oricutron and Euphoric, so when you have something that can run code, we should be able to help with your timings.
Where can we find that code? I would be interested :D
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Yet Another

Post by Dbug »

Godzil wrote:
Dbug wrote:Interesting :)

Regarding timers, I wrote some benchmarking code few years ago which allowed us to notice discrepancies between real Orics, Oricutron and Euphoric, so when you have something that can run code, we should be able to help with your timings.
Where can we find that code? I would be interested :D
http://forum.defence-force.org/viewtopi ... 8&start=15
ThomH
Flying Officer
Posts: 238
Joined: Thu Oct 13, 2016 9:55 pm

Re: Yet Another

Post by ThomH »

Dbug wrote:Interesting :)

Regarding timers, I wrote some benchmarking code few years ago which allowed us to notice discrepancies between real Orics, Oricutron and Euphoric, so when you have something that can run code, we should be able to help with your timings.
That's surely going to be the first thing I run when I get loading properly figured out. I've implemented what I understand to be the proper behaviour (i.e. interrupt fires 1.5 cycles after 0) but we'll see. Until it's properly tested, who knows?

It's now working for some tapes but not for others. I've made an attempt to support multiple-file TAPs so hopefully I've just made an error in determining file length or something silly like that. Everything's loading at genuine Oric speed so testing is a bit of a slog, but at least the titles below all loaded (all shown in composite-o-vision). Stormlord ended up at no behaviour, with a screen full of garbage, so I assume that loading failed and that it is so squeezed for RAM that it had also overwritten the display buffer. But we'll see.

I also added in the necessary hint about which display lines are in use to give my emulator a direct crop on the pixel part of the display. Given that my laptop has an 11" screen, it's quite helpful. I had a shot at implementing just the tone part of the AY but didn't succeed.

I probably also need to improve my French; being able to say thank you and ask where the train station is doesn't seem sufficient...
3d Munch
3d Munch
Xenon 1
Xenon 1
Manic Miner
Manic Miner
ThomH
Flying Officer
Posts: 238
Joined: Thu Oct 13, 2016 9:55 pm

Re: Yet Another

Post by ThomH »

I have to report a complete whiff on IRQ Bench, I'm afraid. BRK and Timer tests seem to be off by one, the IRQ test doesn't run at all. I haven't even looked at the source yet but I'm sure it'll teach me a lot.
Attachments
Timer test
Timer test
BRK test
BRK test
IRQ test; doesn't run.
IRQ test; doesn't run.
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Yet Another

Post by Dbug »

Glad to see that you managed to run it.

The code is nothing special to scream about, it's just that my crappy digit replayer was sounding very different on some emulators, so I tried to find out why. And then I realized I could just modify it a bit to give some baseline information that can be used to validate actual timings :)
ThomH
Flying Officer
Posts: 238
Joined: Thu Oct 13, 2016 9:55 pm

Re: Yet Another

Post by ThomH »

A very early build. With a million issues, at least half a million of which I'm aware of.

CPU usage is far too high for an emulator. On my development machine — the 2011 11" MacBook Air — it takes about 30% of a core to run. The Euphoric port takes 6%. The flattering version is that it's because I've preferred a clean structure and because I've got a full CRT emulation running (though you can't tell yet, because I've not implemented 60Hz output, so no fun image rolling when the resolutely 50Hz CRT loses synchronisation). But really I just need to work harder.

Audio sometimes drops out and never returns.

I don't think it's quite as cycle perfect as I'd intended yet. There's the occasional overlong noise. I haven't yet found a speech demo that was just on a .TAP but that might help to confirm or deny.

It being document oriented is possibly a curse as much as a blessing: you cannot get to an Oric without supplying a .tap file. Use any one you like. As I've not yet implemented an automatic typing of appropriate loading commands, you'll be free to use BASIC instead if you prefer.

I've yet to fix the 6522 off-by-one issue, but my guess is just that it's just because when you programmatically seed the timer I also tick it down that same cycle. Which might be just too many things to happen in the same cycle? I've also yet to implement latching or the shift register or figure out why my emulation of the IRQ Tester mentioned above fails when trying to test IRQs.

The options menu is presented in such a way as initially to have keyboard focus. Click on the emulation window to bring it to the front.

Tapes load without making a noise at their original speed. So patience is a virtue.

Enough pieces of software are working for it not to be a waste of time but not everything works yet. So your patience may even be wasted.

EDIT: oh, and in case it's helpful, the rest are hopefully obvious but your keyboard's backquote key is connected to the emulator's NMI line; it's definitely the one above tab on US keyboards and to the left of z on British keyboards. I've assumed the emulator will also catch the one above right shift on French keyboards but let me know if not.

EDIT2: upon further inspection, if one loads Stormlord while already in HIRES mode, it runs fine other than that the flashing attribute below some of the 'press fire' text runs right the way to the edge of the screen rather than ending in the right place. So it's a fairly safe assumption that something is at fault in my attribute detection — I must be parsing something that is meant to switch to graphics mode and something that is meant to end flashing mode as a character rather than as an attribute. It's a clue, at least.
ThomH
Flying Officer
Posts: 238
Joined: Thu Oct 13, 2016 9:55 pm

Re: Yet Another

Post by ThomH »

I've uploaded a new build; the best thing about it is that I've implemented automatic typing and fast loading so that those titles that work can be launched directly from the Finder — just double click and run.

Performance should also have taken a step in the right direction.

A fun screenshot to demonstrate the incredibly useful things having a full CRT emulation in there can do:
60Hz on a 50Hz screen
60Hz on a 50Hz screen
EDIT: I've bothered doing the numbers. On my work Mac Pro it's down from 10.9–11.0% CPU utilisation per Oric to 7.7–8.0%. So that's quite a bit better than I thought. I'm still hoping to do better. It remains somewhere in the mid-20s on my five-year-old MacBook Air.
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Yet Another

Post by Dbug »

Nice one :)
Does that mean that you can emulate having a "taller" screen in 60hz than in 50hz ?
User avatar
Chema
Game master
Posts: 3013
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Yet Another

Post by Chema »

Indeed! However I cannot remember my screen getting out of sync that way, it simply showed some garbage in the middle.
ThomH
Flying Officer
Posts: 238
Joined: Thu Oct 13, 2016 9:55 pm

Re: Yet Another

Post by ThomH »

Chema wrote:Indeed! However I cannot remember my screen getting out of sync that way, it simply showed some garbage in the middle.
What a screen does with an improper input is undefined, so I think a bunch of them act differently — e.g. my actual '90s-era TV just cut away to blue. So I just picked any one authentic version and ran with it.

Mine's edge triggered for horizontal sync with a pretend capacitor to charge up for vertical sync; detections feed a flywheel PLL. However the display either expects 50Hz input or it expects 60Hz input, and doesn't attempt automatically to switch. Real-life late-period CRTs were multi-standard and would happily to switch on the fly. I think this all got a lot easier for manufacturers to implement once electronics went digital.
Dbug wrote:Nice one :)
Does that mean that you can emulate having a "taller" screen in 60hz than in 50hz ?
I could if I told my CRT to try switching between 50 and 60 whenever it goes through a prolonged period of poor sync. One of the other emulated machines does that for itself, no reason I couldn't make it common to both. The "prolonged period" test would ensure that those games that use a short switch deliberately for a bouncing explosion effect continued to work as intended; obviously a real CRT can't see inside the machine so a test that operates only on the received signal is correct.
ThomH
Flying Officer
Posts: 238
Joined: Thu Oct 13, 2016 9:55 pm

Re: Yet Another

Post by ThomH »

A quick [repeat] post to highlight a new release. The primary fix is to my interpretation of the TAP file format. Which fixes Stormlord and a bunch of other things. I have read that there is meant to be a gap between header and data but due to an off-by-one error was recognising the 00 that comes before a file name as that which comes afterwards and putting a gap there.

The code changes have been more substantial that that, but that's mostly been about cleaning up. But I'm off on holiday for a couple of weeks so thought it was worth putting something out due to the seeming big increase in compatibility. We'll see.

EDIT: immediate plans, for the curious:
  • go on holiday;
  • fix my fast tape loader per what I just learnt about the ROM decoding routines — i.e. it's lengths of full cycles only, not segments;
  • implement a few other tape file formats — it's currently TAP only. No WAV, no ORT, nothing else;
  • correct some of my very poor GPU handling.
Post Reply