SpectROM - Speccy emulator for the Pi co-pro

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
RobC
Posts: 2182
Joined: Sat Sep 01, 2007 9:41 pm
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by RobC » Tue Feb 13, 2018 8:33 pm

tricky wrote:remember to set the sound volume to silent...
Thanks tricky. Presumably this is the volume for tone generator 1 rather than the noise channel?

It should be fairly easy for me to try this out so I'll give it a go in the next day or so. (I've just started looking at a CPC emulator so that's taking up most of my free time...)

User avatar
tricky
Posts: 2457
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by tricky » Wed Feb 14, 2018 6:58 am

Yes.
I found one of my sprint videos for what it sounds like.


http://youtu.be/enupZbjSNck

PS it doesn't sound quite like I remember it, in my head it was more like manic miner.

RobC
Posts: 2182
Joined: Sat Sep 01, 2007 9:41 pm
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by RobC » Wed Feb 14, 2018 7:49 am

Thanks tricky - I'll give it a go.
KenLowe wrote: I notice that a lot of downloadable snapshot games are in .z80 format and not the .sna format used by SpectROM.
Thanks for the tip Ken. I could add .z80 support if required as I only chose .SNA because I had a CD full of them - I think it came with the !Z80Em emulator I bought at an Acorn show years ago...

User avatar
Rich Talbot-Watkins
Posts: 1280
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by Rich Talbot-Watkins » Wed Feb 14, 2018 8:28 am

RobC wrote:
tricky wrote:remember to set the sound volume to silent...
Thanks tricky. Presumably this is the volume for tone generator 1 rather than the noise channel?

It should be fairly easy for me to try this out so I'll give it a go in the next day or so. (I've just started looking at a CPC emulator so that's taking up most of my free time...)
A CPC emulator's going to push the Beeb, I think, for a couple of reasons:

1) There are plenty of CPC games which perform software scrolling, which could run faster than the Beeb can keep up with. The CPC screen is 16k so that's double the Speccy's size - it might just be a bit too slow sometimes.
2) There are also a good few CPC games that do vertical rupture type tricks or split palette/modes which would have to be emulated accurately timing-wise on the host. As far as I remember, the CPC doesn't have the equivalent of a VIA for precise timing - I think it just gets an interrupt every 50 or so scanlines, so that would make life a bit easier perhaps. You'd almost certainly need an approach a bit like the one I suggested for the Spectrum emulator, where each packet from the parasite contains the scanline number it should be done at, and the host counts scanlines from vsync.

In other aspects though, the Beeb + VideoNuLA are a match made in heaven! Same CRTC and similar sound chip, and plus that lovely palette.

RobC
Posts: 2182
Joined: Sat Sep 01, 2007 9:41 pm
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by RobC » Wed Feb 14, 2018 8:43 am

Thanks Rich - I've only just started looking into it as I don't know too much about the CPC. The similarities between the hardware made me think that it's worth exploring.

The Spectrum emulator already has a mechanism for timing host actions (e.g. border and sound) based on the number of tstates so I could use this for CRTC changes. And I guess they'd only need to be accurate to the nearest row anyway.

On the speed, it may well be too much for scrolling games although I do have some more ideas that I could try out.

My other concern is the shadow screen memory - there's no way to implement this on a standard B!

User avatar
Rich Talbot-Watkins
Posts: 1280
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by Rich Talbot-Watkins » Wed Feb 14, 2018 11:13 am

I may be wrong, but I didn't think the CPC464 had something like shadow screen memory. It just uses CRTC R12/R13 like we do in Beeb land. Whether it can address more than 32k of RAM is a different question I guess. Certainly 32k screens (as are occasionally used on the CPC) are already a hardware impossibility on the Beeb, unless you use no zero page, no stack, and have no program in main RAM :?

RobC
Posts: 2182
Joined: Sat Sep 01, 2007 9:41 pm
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by RobC » Wed Feb 14, 2018 11:58 am

Sorry - calling it "shadow screen memory" was misleading. According to this (and other sources I've found), the CPC can display screen data from any address in its 64KB RAM and use it for double buffering etc.: http://www.irespa.eu/daan/lib/howtoCPCemu.htm

I need to think whether this is going to be worth the effort!

atcurtis
Posts: 45
Joined: Fri Apr 08, 2016 9:47 am
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by atcurtis » Thu Feb 15, 2018 9:54 am

I've heard of someone using the BBC Master shadow memory in order to double the vertical resolution with interlacing.

RobC
Posts: 2182
Joined: Sat Sep 01, 2007 9:41 pm
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by RobC » Thu Feb 15, 2018 12:10 pm

atcurtis wrote:I've heard of someone using the BBC Master shadow memory in order to double the vertical resolution with interlacing.
Yes - I remember typing in a program that did this from Acorn User. Unfortunately, my monitor wasn't happy with it (or maybe I made a typo!)

If you search on 8bs for GLM PD disk 8, there's an example of this technique in a program by Lars Osterballe that shows pictures of Madonna. It runs on a normal Beeb by just using a smaller screen size but at double vertical resolution.

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

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by jgharston » Fri Feb 16, 2018 2:19 am

RobC wrote:
atcurtis wrote:I've heard of someone using the BBC Master shadow memory in order to double the vertical resolution with interlacing.
Yes - I remember typing in a program that did this from Acorn User. Unfortunately, my monitor wasn't happy with it (or maybe I made a typo!)
I remember that one, my eyes weren't very happy with it. :(

Code: Select all

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

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

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by jgharston » Fri Feb 16, 2018 2:23 am

KenLowe wrote:I found a dos utility (SPCONV) that can covert between z80 and sna formats, but it doesn't work on x64 windows machines.
Also on RISC OS, and can be done on BBC/Master (and DOS/Windows) in two steps with SnapToBIN followed by BINtoSnap.

Code: Select all

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

atcurtis
Posts: 45
Joined: Fri Apr 08, 2016 9:47 am
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by atcurtis » Fri Feb 16, 2018 10:41 am

jgharston wrote:
RobC wrote:
atcurtis wrote:I've heard of someone using the BBC Master shadow memory in order to double the vertical resolution with interlacing.
Yes - I remember typing in a program that did this from Acorn User. Unfortunately, my monitor wasn't happy with it (or maybe I made a typo!)
I remember that one, my eyes weren't very happy with it. :(
Could be still worth a try if the SCART to HDMI converters understand it.. especially as while using the TUBE, all that memory isn't being used.

User avatar
tricky
Posts: 2457
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by tricky » Fri Feb 16, 2018 10:56 am

It's only interlace, but the user manually has to choose to swap the fields if they are the wrong way around unless some one has found a way to detect which field is showing.
Rob, does NuLA know which field is showing/can it set it?

RobC
Posts: 2182
Joined: Sat Sep 01, 2007 9:41 pm
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by RobC » Fri Feb 16, 2018 11:07 am

tricky wrote:It's only interlace, but the user manually has to choose to swap the fields if they are the wrong way around unless some one has found a way to detect which field is showing.
Rob, does NuLA know which field is showing/can it set it?
I have a vague recollection that someone found that the timing of the sync pulses was different on odd and even frames but I can't remember whether this allows detection in software. (Also, I might be completely wrong and have just imagined the whole thing!)

VideoNuLA has no idea of which frame it's currently processing as it only really operates on the last one or two data bytes sent to it. Also, it doesn't get the sync signals so couldn't use those if they do differentiate between frames.

User avatar
tricky
Posts: 2457
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by tricky » Fri Feb 16, 2018 11:18 am

I was hoping that NuLA could control it and that a NuLA reset could be used to reset the frame, but I guess not.

RobC
Posts: 2182
Joined: Sat Sep 01, 2007 9:41 pm
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by RobC » Fri Feb 16, 2018 11:24 am

tricky wrote:I was hoping that NuLA could control it and that a NuLA reset could be used to reset the frame, but I guess not.
Unfortunately, all the sync stuff is controlled by the 6845. The Video ULA just outputs the serialised data and continues to do so unless told not to by the DISEN signal.

I'll try to find the thing about the sync pulses - might have been on here or on the mailing list...

EDIT: Found the links I had vague recollections of. Turns out one was on here and another was on the mailing list.

There's a (long) discussion about constructing a 640x512 display on a Master starting here:
http://mdfs.net/Archive/BBCMicro/2009/03/02/120143.htm

Interestingly, Sarah's demo shows how to avoid having to flip between frames.

There's also some discussion about the relationship between hsync and vsync on odd and even frames here:
viewtopic.php?t=6626#p65256

User avatar
Rich Talbot-Watkins
Posts: 1280
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by Rich Talbot-Watkins » Fri Feb 16, 2018 3:27 pm

Yeah I don't think there's a way to discriminate odd and even fields on a Beeb (funnily enough, it *is* possible in B-Em and jsbeeb, because they set CA1 high half a scanline too soon on odd fields - little bug there). The only way you could do it is if you could see the HSync signal, and then time the start of VSync from the last HSync.

But interlaced sync and video is how to get unchanging results, as demonstrated in that horrible bickering thread you just posted!

ThomasHarte
Posts: 458
Joined: Sat Dec 23, 2000 5:56 pm
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by ThomasHarte » Fri Feb 16, 2018 4:25 pm

I'm very late to the ball, but comments such as they might be helpful:
  • Cobra is probably the game that'd be hardest to get to work well in SpectROM as it's a 50Hz 2d scroller;
  • I, Of the Mask is also notable for throwing a lot at the display, but it already has obvious semi-frame updates, so you'll probably be fine;
  • one of the optimisations made by back-in-the-day SpectROM-type devices for other micros was to partition the screen into areas of high priority and low priority updates — for someone manually to flag up which parts were action and which were status. Then apply a rudimentary scheduler when the quantity of changes crosses your threshold.
As to the CPC, as noted the video has access to any of the first 64kb of memory, which is all of it on a 464 or 664. CRTC tricks are not uncommon, but mode changes are implemented in hardware so as to take effect only upon horizontal sync so at least that's something. Though I'll bet someone somewhere spoofs it: if you set up your horizontal sync to occur at 31khz I'll bet your TV image would still be rock solid and you'd get an extra 'hsync' in the middle of the display.

Perhaps the MSX/ColecoVision/etc TMS VDP might be a next move? That VDP is explicitly something that has its own memory, on its own bus, to which you have to post bytes or poll for them, with relatively limited bandwidth availability. It's primarily attribute-oriented like Spectrum (but more like the Timex), exactly the same resolution, and doesn't offer pixel scrolling. I think the main issue would be adding the hardware sprites, which are 1bpp but have their own colours. Also, it's tile based, so you can effect more visual change than the bandwidth alone would imply.

EDIT: also I think Skool Daze uses LDIR and LDDR for its scrolling, with a quick bit of dynamic reprogramming to pick one or the other. But that's just a piece of trivia I read somewhere, once. So a processor-emulation hack on LDIR would probably show up there?

RobC
Posts: 2182
Joined: Sat Sep 01, 2007 9:41 pm
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by RobC » Fri Feb 16, 2018 5:01 pm

Thanks Thomas - I'll take a look at those games. Also, the info on the CPC is very useful as I'm not very familiar with it apart from knowing that it uses a 6845!

I'd thought about the MSX-type machines as I have an Einstein and know a little bit about it. The sprites are a problem as each can have its own colour and you can have up to 4 per scanline. An overscan version of the 12MHz mode 1 might get close though.

One other possibility is the Oric as I think it has 8x1 attributes. It has some decent new games but they seem to use an odd graphics mode that I don't fully understand yet.

User avatar
Pernod
Posts: 1205
Joined: Fri Jun 08, 2012 10:01 pm
Location: Croydon, UK
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by Pernod » Fri Feb 16, 2018 5:13 pm

The Camputers Lynx may be easier than the CPC, it also uses a 6845. Not so much software out there for it though.
- Nigel

BBC Model B, ATPL Sidewise, Acorn Speech, 2xWatford Floppy Drives, AMX Mouse, Viglen case, BeebZIF, etc.

RobC
Posts: 2182
Joined: Sat Sep 01, 2007 9:41 pm
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by RobC » Fri Feb 16, 2018 5:43 pm

Pernod wrote:The Camputers Lynx may be easier than the CPC, it also uses a 6845. Not so much software out there for it though.
I have a Lynx and think it can do 8 colours at something like 256x256 with no attribute clash. Again, the 12MHz attribute mode might get close but it's not quite good enough.

And as you say, there's not much software for it!

ThomasHarte
Posts: 458
Joined: Sat Dec 23, 2000 5:56 pm
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by ThomasHarte » Fri Feb 16, 2018 5:54 pm

The Oric is another one I've emulated! Unfortunately it doesn't have 8x1 attributes, it has 6x1 attributes. Like Mode 7, attributes are serialised within the video stream, as are all other control characters, so each column is a full byte but with the space used for other things only six bits of each is pixels. Its ULA actually doesn't have any registers at all — even things like switching between 50 and 60 Hz are performed inline and just stick. It also doesn't produce interrupts; a moderately common hack is to connect the sync output from the RGB port to the cassette input. Some great software in the modern era though: Blake's 7, 1337 (Elite with an added plot), Stormlord and more. Mostly on that same page.

(EDIT: the inner loop of my implementation of Oric video; don't worry about the output_device_ stuff and it's fairly straightforward: if graphics mode is enabled then until line 200 do graphics-area fetching, otherwise do indirect text-type fetching; if both of the top two bits are 0 then it's a control code, so change something and output the background colour, otherwise output the low six bits as pixels, possibly with colours bit inverted. Those being the bits fetched indirectly if it's a text mode.)

(EDIT2: it's only 240 pixels across though, so if you missed two columns to make it 228 you might just be able to squeeze it onto a full overscan Mode 2 display? If you give that a go, skipping the two leftmost columns makes sense since a lot of games just use those to establish the line's initial foreground and background colour)

I think the Camputers Lynx might not fit the BBC's output abilities: if memory serves then it's 80 column, 3bpp (planar). It does one really cool thing though: instead of using the CRTC's cursor signal to generate a cursor, it uses it as an interrupt trigger. So you can set your ideal synchronisation points at column resolution.

User avatar
Lardo Boffin
Posts: 1071
Joined: Thu Aug 06, 2015 6:47 am
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by Lardo Boffin » Fri Feb 16, 2018 7:47 pm

Blimey - Blake’s 7 looks impressive. And I now cannot get the theme tune out of my head. Argh.
BBC model B 32k issue 4, 16k sideways RAM, Watford 12 ROM board, Retroclinic Datacentre + HDD, Viglen twin 40/80 5.25" discs, acorn cassette, Acorn 6502 coproc
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc
BBC Master

RobC
Posts: 2182
Joined: Sat Sep 01, 2007 9:41 pm
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by RobC » Fri Feb 16, 2018 8:38 pm

ThomasHarte wrote:The Oric is another one I've emulated! Unfortunately it doesn't have 8x1 attributes, it has 6x1
Ah! I just saw that attributes could be changed per scanline and assumed they were 8x1. I did own an Atmos for a bit so should have paid more attention!
ThomasHarte wrote:(EDIT2: it's only 240 pixels across though, so if you missed two columns to make it 228 you might just be able to squeeze it onto a full overscan Mode 2 display? If you give that a go, skipping the two leftmost columns makes sense since a lot of games just use those to establish the line's initial foreground and background colour)
It might well fit in the 12MHz mode 1 equivalent then - that's 240x256 with 4 out of 16 colours available in each 3x1 pixel block.
ThomasHarte wrote:I think the Camputers Lynx might not fit the BBC's output abilities: if memory serves then it's 80 column, 3bpp (planar). It does one really cool thing though: instead of using the CRTC's cursor signal to generate a cursor, it uses it as an interrupt trigger. So you can set your ideal synchronisation points at column resolution.
I think it's 3bpp but a 40 column display based on 6 pixel wide font (so 256 pixels rather than 320). Still beyond what can be done at that resolution on the Beeb though.
Lardo Boffin wrote:Blimey - Blake’s 7 looks impressive. And I now cannot get the theme tune out of my head. Argh.
The new games all look really good. There's also a very impressive port of Skool Daze.

User avatar
tricky
Posts: 2457
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by tricky » Mon Mar 05, 2018 6:36 pm

I know it is cheating even more, but is there a spare pin on the pi that could be connected to the audio in on the 1MHz bus to drive the audio from the pi?
Or even enough pins to use as a D2A to pipe in as audio (for other uses, eg 128+)?

I'm sure I've asked this somewhere before!

RobC
Posts: 2182
Joined: Sat Sep 01, 2007 9:41 pm
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by RobC » Tue Mar 06, 2018 10:37 am

tricky wrote:I know it is cheating even more, but is there a spare pin on the pi that could be connected to the audio in on the 1MHz bus to drive the audio from the pi?
I (very) briefly thought about this during development as you'd only need one spare pin (+GND) for the Spectrum's beeper and PiTubeDirect doesn't use all of the GPIO pins so it would be doable.

In the end, as it would require a branch of the PiTubeDirect software and changes to the way my emulator worked (as all the timing based stuff was on the Beeb side), I decided to focus on driving the sound through the Beeb.

The sound is okay for most games - when it works well, it probably sounds better than I expected it would!

User avatar
BigEd
Posts: 1825
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by BigEd » Tue Mar 06, 2018 10:42 pm

Rob, I was round at Dave's this afternoon, and were able to determine that - for your special case of an application running on native ARM - your application can indeed do some bitbanging on unused Pi GPIOs just by knowing the addresses of the memory-mapped peripherals.

Possibly a good choice of pin would be the one normally used for debug serial output, as Kjell provides a pinout for it.

More interesting perhaps, but not part of a standard speccy, would be to drive PWM audio out of one or two pins. On the full-size Pi models, there's an audio filter and a headphone socket whereas on the zero a bit of DIY is needed, and maybe only one channel is available.

On the other cpu models, the emulated ones, we'd need a development of PiTubeDirect to provide an output port for the parasite code, probably in or near the Tube registers. It might be good to do that, as it would allow for a telltale, for blinkenlights, for audio, and so on. (We've used a telltale in the past with a logic analyser to see how the timing of code on the Pi matches up with the interface activity.)

There is a wrinkle, which is that there are essentially two flavours of Pi with the I/O addresses in two different address ranges. So the application will need to know, or figure out, which flavour of Pi it is on.

dp11
Posts: 797
Joined: Sun Aug 12, 2012 8:47 pm
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by dp11 » Wed Mar 07, 2018 3:54 am

Oprions

At compile time of pitubedirect we know the pi type. We could put that info at a known memory location which could be read.

I suspect by writing and reading some io device you can work out which pi you are on.

User avatar
BigEd
Posts: 1825
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by BigEd » Wed Mar 07, 2018 9:51 am

It's almost like you were in the room with us!

It would be nice to know of a free location - or, could it perhaps be left on the stack? We also noted there's an environment-reading mechanism, so for example the information could be left after the zero-terminated command line. (Like Unix, where the command line is followed by the env vars.)

RobC
Posts: 2182
Joined: Sat Sep 01, 2007 9:41 pm
Contact:

Re: SpectROM - Speccy emulator for the Pi co-pro

Post by RobC » Wed Mar 07, 2018 6:46 pm

Sounds good.

I'm working on some other stuff at the moment so, although I've been using SpectROM a lot, I've not been doing any more development on it. However, I'll keep an eye on PiTubeDirect developments and come back to it when I've got more time.

Post Reply