Jump to content
IGNORED

Clock Signal emulator updated


ThomH

Recommended Posts

This emulator has been updated to correct two timing errors:

  • an M1 delay has been added; and
  • the SN-generated WAIT has been extended to the correct length, having been off by over 90% (!). Some people don't always spot sentences about clock dividers.

Otherwise, as a reminder, it's:

  • a completely Cocoa-native application on the Mac;
  • that also supports building for SDL for other UNIX platforms;
  • which emulates at full cycle fidelity (the CPU, the VDP, everything);
  • including its Super Game Module emulation;
  • which builds its audio stream by producing a full machine clock-rate audio stream and then filtering that down to whatever your machine can handle (so: all speech effects, etc, should work perfectly, despite the code containing zero special cases);
  • which builds its video stream as genuine composite video and then decodes the same on your GPU;
  • which supports USB and Bluetooth joypads;
  • which puts no restrictions whatsoever on window sizes, or how many ColecoVisions you have running at once, across however many screens (or even tabbed); and
  • which requires no setup whatsoever. Just double click your game and play.

It's MIT licensed, and available here. Feedback always appreciated!

 

post-24504-0-37227800-1551580933.gif

 

post-24504-0-22773800-1551581337_thumb.png

post-24504-0-28333800-1551581347_thumb.png

post-24504-0-56554400-1551581394_thumb.png

  • Like 1
Link to comment
Share on other sites

Is there anything by way of documentation on how this should function? Opening ROMs (ColecoVision) from within the application immediately crashes out on macOS 10.13.6 ... I feel user error may be at fault, but it's not clear how to obtain what is demonstrated in the thumbnails above.

Link to comment
Share on other sites

Works for me. Is there anyway to get rid of the CRT looking glow?

 

 

And you're doing anything other than File>Open [rom file]? Which OS and version?

 

If not, I guess the question becomes what's the source of the crash-on-load issue that's unavoidable for me.

Link to comment
Share on other sites

 

 

And you're doing anything other than File>Open [rom file]? Which OS and version?

 

If not, I guess the question becomes what's the source of the crash-on-load issue that's unavoidable for me.

I tried both, from the file menu and double clicking the rom with no issues. Donkey Kong, Hero, Burgertime and Beamrider.

 

I'm on 10.14.3 though.

Link to comment
Share on other sites

I tried both, from the file menu and double clicking the rom with no issues. Donkey Kong, Hero, Burgertime and Beamrider.

 

I'm on 10.14.3 though.

 

 

Funny, I tried two of those three titles, myself. :)

 

Hmm ... I suppose I could attach a crash file in case someone wants to look. Not interested in migrating up to 10.14 just yet to see if lagging behind on 10.13 is the culprit. Thanks for providing at least one difference in use cases to explore, though.

  • Like 2
Link to comment
Share on other sites

Yeah, now I think of it, it's probably very dodgy of me still to claim compatibility back to 10.10 as I haven't tested on anything other than 10.14 for a while; I'll either dig out my 10.13 Mac or, if I can find it for download, put it in a virtual machine. This is absolutely not user error — the app should work exactly like any other native app, including for File -> Open, file associations and — option three — dragging and dropping onto its icon on the Dock.

 

Re: the CRT look, that's actually a consequence of the full composite video pipeline. It's not deliberately downgrading it, that's genuinely the best composite decoding I've so far managed to produce — though the TMS's in-phase video (in NTSC, anyway) makes composite even worse than it usually is. This, I'm certain, is what the Karl Guttag memos mean by the rainbow effect.

 

That excuse being made, the emulator can also do S-Video and RGB pipelines from the TMS. So I'll just enable one or both of those for the ColecoVision. My original thinking was a bit hard line probably, i.e. that the real ColecoVision has only an RF connector, and composite is as close as I get to RF, so that's that.

 

That should be a really easy change. Definitely possible tomorrow.

 

(EDIT: nerd aside: that's not some dumb "startup effect" making the screen bounce like that when you switch the machine on, by the way, that's because my emulated CRT really needs to establish sync with the input machine. Since it's just decoding a linear video stream and all, it doesn't have foreknowledge of the 2d-ness of it all.)

Edited by ThomH
  • Like 1
Link to comment
Share on other sites

Attached; a build that allows S-Video output from the ColecoVision.

 

@mumbai it's late, so I might be very askew on my guess, but to me that looks potentially like I've got a dumb race condition on machine startup. So if it correlates at all with running the thing on 10.13 then that's purely luck. Try the attached, but failing that I'll throw myself back at it tomorrow.

 

(there's more complicated threading than most emulators primarily in an attempt to reduce latency — e.g. so that decisions about the size of my audio packets are completely distinct from any video-frame-related considerations. In practice I aim for 5–10ms latency on audio)

Clock Signal.zip

post-24504-0-39522900-1551586923_thumb.png

Edited by ThomH
Link to comment
Share on other sites

Attached; a build that allows S-Video output from the ColecoVision.

 

@mumbai it's late, so I might be very askew on my guess, but to me that looks potentially like I've got a dumb race condition on machine startup. So if it correlates at all with running the thing on 10.13 then that's purely luck. Try the attached, but failing that I'll throw myself back at it tomorrow.

 

Thanks for the attachment. Same behavior as before, though.

Link to comment
Share on other sites

That looks much better!

 

It's still only S-Video, so the two colour channels are being QAM encoded and decoded, giving them an upper bandwidth bound, but you'll probably be hard-pressed to spot it.

 

 

I hate typing this, but the 20190303 release still crashes out on my laptop. Log attached.

 

attachicon.gifclocksignal-20190303-macos10.13.6-crashlog.txt.zip

 

 

It's a completely different issue at least: GL_FRAMEBUFFER_UNSUPPORTED; presumably from my attempt to use a stencil buffer, though that surprises me a lot since they've been supported in hardware for 20 years. Out of interest, which GPU does your Mac have? I've tested on a 2011 MacBook Air, which I had assumed to be one of the lowliest Macs for 10.13 with its Intel integrated non-Metal-compatible GPU, but I guess that wasn't a safe assumption.

 

I'll do some research. You might be able to use one of the older releases, which don't attempt to use a stencil at all. But we'll see. And the timing will be slightly off — no M1 delay, short SN waits — and you'll get composite video only. With some luminance aliasing, but it's another thing it'd possibly be hard to notice with ColecoVision software.

Edited by ThomH
Link to comment
Share on other sites

It's a completely different issue at least: GL_FRAMEBUFFER_UNSUPPORTED; presumably from my attempt to use a stencil buffer, though that surprises me a lot since they've been supported in hardware for 20 years. Out of interest, which GPU does your Mac have? I've tested on a 2011 MacBook Air, which I had assumed to be one of the lowliest Macs for 10.13 with its Intel integrated non-Metal-compatible GPU, but I guess that wasn't a safe assumption.

 

I'll do some research. You might be able to use one of the older releases, which don't attempt to use a stencil at all. But we'll see. And the timing will be slightly off — no M1 delay, short SN waits — and you'll get composite video only. With some luminance aliasing, but it's another thing it'd possibly be hard to notice with ColecoVision software.

 

 

I'm on a mid-2012 Retina MBP, which I'd like to think outclasses a 2011 MBA. System profiler reports thus:

 

Intel HD Graphics 4000:

Chipset Model: Intel HD Graphics 4000

Type: GPU

Bus: Built-In

VRAM (Dynamic, Max): 1536 MB

Vendor: Intel

Device ID: 0x0166

Revision ID: 0x0009

Automatic Graphics Switching: Supported

gMux Version: 3.2.19 [3.2.8]

Metal: Supported, feature set macOS GPUFamily1 v3

Displays:

Color LCD:

Display Type: Built-In Retina LCD

Resolution: 2880 x 1800 Retina

Framebuffer Depth: 24-Bit Color (ARGB8888)

Main Display: Yes

Mirror: Off

Online: Yes

Rotation: Supported

Automatically Adjust Brightness: No

NVIDIA GeForce GT 650M:

Chipset Model: NVIDIA GeForce GT 650M

Type: GPU

Bus: PCIe

PCIe Lane Width: x8

VRAM (Dynamic, Max): 1024 MB

Vendor: NVIDIA (0x10de)

Device ID: 0x0fd5

Revision ID: 0x00a2

ROM Revision: 3688

Automatic Graphics Switching: Supported

gMux Version: 3.2.19 [3.2.8]

Metal: Supported, feature set macOS GPUFamily1 v3

Crash occurs when plugged into the wall, so the latter GPU is in play, not the integrated Intel chipset.

Link to comment
Share on other sites

Addendum: If I force use of the integrated GPU only, no crash. If I force use of the discrete GPU, crash as reported.

 

I guess this is why your MBA wins out.

 

Not certain what's "wrong" with the GeForce that isn't with the Intel GPU w/r/t Clock Signal.

Link to comment
Share on other sites

Addendum: If I force use of the integrated GPU only, no crash. If I force use of the discrete GPU, crash as reported.

 

I guess this is why your MBA wins out.

 

Not certain what's "wrong" with the GeForce that isn't with the Intel GPU w/r/t Clock Signal.

 

 

Having a quick review, I'm actually asking for a slightly odd stencil mode — a 1bpp stencil. The only reason I did that was that I really only need one bit. Would you be willing to try the attached build, which ups the request to 8 bits, for no reason other than it being a little more likely to be supported?

 

I'm really grateful for the feedback so far, regardless!

Clock Signal 8bpp stencil.zip

Link to comment
Share on other sites

Having a quick review, I'm actually asking for a slightly odd stencil mode — a 1bpp stencil. The only reason I did that was that I really only need one bit. Would you be willing to try the attached build, which ups the request to 8 bits, for no reason other than it being a little more likely to be supported?

 

The attached build appears to address the crash-on-load in all cases: forced integrated graphics, forced discrete graphics, and dynamic graphics switching. Interesting.

 

Was able to idly generate an unrelated crash using "revert to saved" on Goonies.

 

clocksignal-8bppstencial-revertosaved-crash.txt.zip

Link to comment
Share on other sites

 

The attached build appears to address the crash-on-load in all cases: forced integrated graphics, forced discrete graphics, and dynamic graphics switching. Interesting.

 

Was able to idly generate an unrelated crash using "revert to saved" on Goonies.

 

attachicon.gifclocksignal-8bppstencial-revertosaved-crash.txt.zip

 

 

Cool! That's the big one dealt with then, at least.

 

It strikes me now that I have actually never once tried to use the 'revert to saved' menu entry with my emulator. So I've no offhand guesses there; I'll file it and fix it, naturally, but it might be more like weeks than days, especially given that the weekend is almost at an end.

 

Thanks again for all your input and help!

Link to comment
Share on other sites

To sneak in some extra information on this while I'm sitting at my desk, watching some very slow automated tasks in my day job:

 

Re: the stencil; this is used because the CRT is its own sealed component trying to act like a real CRT. So it's attempting to sync to any incoming signal, and it paints scans to a virtual set of phosphors, which subsequently suffer exponential decay. It actually does this in a matter decoupled from your machine's frame rate for the reason that if you have a gaming monitor at 120Hz or 144Hz it can then provide 120 or 144 distinct frames per second, just like a real-life CRT doesn't atomically flip from one frame to the next, and you gain a big graphical latency reduction. The stencil is related to the exponential decay — that's just a discrete in-framebuffer effect, as you'd probably guess, but given that machines may not produce regular sync, which may cause the number of pixels painted sometimes not to reach the edges of the display, an extra means is needed to keep track of which pixels haven't been repainted by the normal scan.

 

A ColecoVision produces an entirely stable display, so it's not actually much help here, other than possibly for clearing up after the bouncing that happens during initial switch on. It is nevertheless essential to allow the virtual CRT to fulfill its stated contract, and in practice a big help to other machines the emulator implements.

 

Re: 'revert to saved'; the Mac version is, as stated, a full native application. Specifically it's an NSDocument/NSDocumentController-type application with XIBs aplenty, utilising an NSOpenGLView, CVDisplayLink, CoreAudio and IOKit for joypads and so on. That's nice because I get all the window management and most of the default menu bar items and their implementations for free. But it means I have to respond properly to the NSDocument messages. So every so often it turns out there's a menu option that isn't working because I'm not responding to a message like I should. It's just usually not immediately obvious what I've done wrong because I'm relatively weak at AppKit. It's not like I've tried to add a 'revert to saved' feature and failed to test it, I've actually been entirely oblivious to the menu entry.

 

The SDL port, which allows use under Linux and similar environments, is completely distinct. Not one jot of SDL is used on the Mac.

 

I have every intention of switching to Metal given that OpenGL is now deprecated on the Mac, and as of this overhaul the use of OpenGL by a particular binding is entirely optional. In practice it can be specified at runtime, which gives me a fallback for non-Metal Macs. It's just unfortunate that I don't presently know that much about Metal right now.

 

Tech nerd asides: if you've any experience of pootling around in emulation source code, you might now be imagining a viper's nest of #ifdefs and equivalent runtime selection mechanisms, and a project that will surely die quickly under its own weight. There's none of that. The machine owner supplies the delegates to receive audio and video content, and pushes changes in input controls, and that's the end of that. I keep angling towards a Windows or Android port and, if ever I go that way, that will mean extra code to handle DirectX and/or OpenGL ES, but will require zero lines difference within the emulation. It'll just be a new consumer, or two, of the information the emulation puts out.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...