Emulated external hardware access common interface

want to talk about MESS/model b/beebem/b-em/electrem/elkulator? do it here!
Post Reply
User avatar
jgharston
Posts: 3723
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Emulated external hardware access common interface

Post by jgharston » Mon Feb 28, 2011 5:45 pm

Can I call on emulator writers to adopt some sort of mechanism that allows an emulator to pass calls to unimplemented hardware to an outside system so that emulated add-ons can be created for any emulator without having to modify a machine emulator itself. This is a specification I put together and registered seven years ago for RISC OS 6502 emulators. I have patched 6502Em to pass on unimplemented I/O access and have written a few emulated I/O devices.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

User avatar
SarahWalker
Posts: 1204
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: Emulated external hardware access common interface

Post by SarahWalker » Tue Mar 01, 2011 3:07 pm

I'm not sure that this is really worth doing - I did something similar for when I was working on RPCemu for podules, and that got no use at all.

Having said that, I propose the following as a first attempt. It's Windows DLL only for the moment I'm afraid, but it can probably be ported elsewhere. I'm not 100% sure about calling emulator functions from DLLs, so I'm working around that a little.

The DLL has to export 3 functions :

Code: Select all

void reset(ext *e);
uint8_t read(ext *e, uint16_t addr);
void write(ext *e, uint16_t addr, uint8_t val);
These should be fairly self explanatory, except for the 'ext *e'. This is a cheating terrible way of exporting emulator functions, and has the following structure :

Code: Select all

typedef struct
{
	void (*irq)(int state);
	void (*nmi)(int state);
	void (*settimer)(int cycles, void (*callback)(), int oneshot);
	void (*setsound)(void (*fill_buffer)(int16_t *buffer, int num, int freq));
} ext;
That should allow for everything that can be done from the 1 MHz bus.

Comments/criticism?

User avatar
jgharston
Posts: 3723
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: Emulated external hardware access common interface

Post by jgharston » Fri Mar 04, 2011 9:33 pm

TomWalker wrote:I'm not sure that this is really worth doing
I find it really useful on RISC OS, it means I can write additional hardware without having to hack into the emulator itself. I've written emulated BBC: IDE interface, byte-wide RAMCard, page-wide RAMCard, Spectrum: Centronics printer, ROM box.
I'm not 100% sure about calling emulator functions from DLLs, so I'm working around that a little.
No, it would be the other way around, calling DLL functions from an emulator. The emulator says "ah, access to &FCD0. I don't implement anything at that address, make a call to an external DLL to see if there's anything out there that does."

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

User avatar
SarahWalker
Posts: 1204
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: Emulated external hardware access common interface

Post by SarahWalker » Fri Mar 04, 2011 9:59 pm

Yes, but in order to set IRQs, timers etc the DLL will then have to call back into the emulator.

User avatar
SarahWalker
Posts: 1204
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: Emulated external hardware access common interface

Post by SarahWalker » Fri Mar 18, 2011 5:17 pm

No real interest has been shown in this, so I'm not proposing to take it any further.

Post Reply