Emulator setup to make all ROM area writes use bank 15 SWR

want to talk about MESS/model b/beebem/b-em/electrem/elkulator? do it here!
Post Reply
Kevin Edwards
Posts: 97
Joined: Tue Mar 14, 2006 9:16 pm
Contact:

Emulator setup to make all ROM area writes use bank 15 SWR

Post by Kevin Edwards » Tue May 29, 2018 4:19 pm

Hi,

I'm trying to get some old source code to compile under emulation. However, it has certain requirements that i can't quite configure in B-Em or BeebEm.

The code is split across multiple files and these are assembled one at a time using a simple overlaying system. O% is set to &8000 at the start to make the object code write into SWR - which it assumes is located in bank 15 ( Perhaps this was the default location on some ROM/RAM expansion boards in a Model B )?

It also assumes Basic 2 is present in bank 14 which isn't a problem and I have configured BeebEm to do this.

The main question is how do I control which ( default ) RAM bank is written to if BASIC is the current language and it writes to the address space &8000-&BFFF? I need to set this to bank 15 if possible. In BeebEm I did set bank 15 to RAM, but IT doesn't seem to have worked.

Can someone point me in the right direction.
A8Assemble.jpg
A8Crash.jpg
Thanks,
Kevin.

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

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Rich Talbot-Watkins » Tue May 29, 2018 4:35 pm

I think all the emulators emulate the type of hardware where writes go to whichever bank's in ROMSEL (&FE30). I reckon you'd probably need to patch and recompile the emulator of your choice to make it work the way you want.

I do remember the type of Sideways RAM expansion you're talking about though. You could load a ROM image with *LOAD ROM 8000 and it would just magically get written to the right place.

Edit: Oooh, the Alien8 source code! With the tape protection system?

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

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Pernod » Tue May 29, 2018 4:41 pm

Kevin Edwards wrote:
Tue May 29, 2018 4:19 pm
The code is split across multiple files and these are assembled one at a time using a simple overlaying system. O% is set to &8000 at the start to make the object code write into SWR - which it assumes is located in bank 15 ( Perhaps this was the default location on some ROM/RAM expansion boards in a Model B )?
The ATPL Sidewise board had a single 16K SWR in bank 15. You could simply load a ROM into it with *LOAD ROM 8000, no need for any fancy code to select banks. Don't think any emulators support this at the moment.
- Nigel

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

Kevin Edwards
Posts: 97
Joined: Tue Mar 14, 2006 9:16 pm
Contact:

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Kevin Edwards » Tue May 29, 2018 4:44 pm

Hi Rich,

Yes, I think it was an early SideWise ROM/RAM card with an 8K Static RAM chip installed - but that's what i believe is installed in my friends machine.

All writes, irrespective of ROMSEL went to this RAM.

What I need is a ROMSEL( RAMSELl? ) override in the emulator. :D

It's a rather messy build process full of hard-coded magic numbers for addresses etc. that i wanted to avoid touching!

Perhaps I can re-work the assembly overlay system to use main memory or possibly a co-pro - this is what i did for larger 6502 projects.

Thanks for the help,
Kevin.

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

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Rich Talbot-Watkins » Tue May 29, 2018 4:55 pm

Something of a long shot, but could you use BAS128 on the Master, under emulation? That gave a virtual address space of &10000-&1FFFF in the Master's 4 sideways RAM banks, so you could just change your O% from &8000 to &18000, and put a HIMEM=&18000.

http://chrisacorns.computinghistory.org ... AN/033.pdf

It's in the LIBRARY directory on this ADFS disc image.
M128Welc.zip
(134.95 KiB) Downloaded 6 times

User avatar
ctr
Posts: 164
Joined: Wed Jul 16, 2014 2:53 pm
Contact:

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by ctr » Tue May 29, 2018 5:13 pm

I used a similar build system for my sideways ROM projects bitd. I had a Watford board, which works as you describe.

They build fine using beebem and the code ends up in RAM bank 4.

User avatar
dv8
Posts: 140
Joined: Mon Jun 22, 2009 9:07 pm
Contact:

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by dv8 » Tue May 29, 2018 5:14 pm

BeebEm supports write-through, but only to the lowest numbered RAM bank.

If you make sure that bank 15 is the only one configured as RAM it should work.

Kevin Edwards
Posts: 97
Joined: Tue Mar 14, 2006 9:16 pm
Contact:

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Kevin Edwards » Tue May 29, 2018 5:55 pm

Thanks everyone for the suggestions and information

I shall try re-wiring the RAM bank mappings so that there is only one bank ( 4 ) and hack the build code to select bank 4 when it saves out the object code.

Fingers crossed!

All the best,
Kevin.

PS. Rich, sadly I threw out 95% of the decoder/encoder source and master maker disks many moons ago. I always kept game code source, if present, but the decoders went to the recycle! However, I do still have some of the decoder source for Exile - tame in its severity compared with Nightshade.

Kevin Edwards
Posts: 97
Joined: Tue Mar 14, 2006 9:16 pm
Contact:

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Kevin Edwards » Tue May 29, 2018 6:50 pm

Yay! It lives.

Solution was to set Bank 15 to RAM and remove ALL other RAM banks - great advice dv8.

Bank 14 was set to Basic II.

Thanks everyone!
Kevin.

Alien8_Start.jpg
Alien8_Run1.jpg
Alien8_Run2.jpg

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

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Rich Talbot-Watkins » Tue May 29, 2018 7:46 pm

Kevin Edwards wrote:
Tue May 29, 2018 5:55 pm
PS. Rich, sadly I threw out 95% of the decoder/encoder source and master maker disks many moons ago. I always kept game code source, if present, but the decoders went to the recycle! However, I do still have some of the decoder source for Exile - tame in its severity compared with Nightshade.
Shame! Would've loved to see the source code for all that stuff, though I can imagine it was lots of little steps that needed to be done by hand (set off the encoding process for main code with hacked OS, go to bed, save results in the morning, run tape maker program (with pre-encoded tape loader binary), etc.

Kevin Edwards
Posts: 97
Joined: Tue Mar 14, 2006 9:16 pm
Contact:

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Kevin Edwards » Tue May 29, 2018 8:37 pm

The encoding phase took less than 30 minutes IIRC. 255 iterations of the encoder. Then hit break and save out the data. I changed the Video memory start address to show the memory being encoded so that I knew when it had completed. Repeat for each decoder - Exile and Nightshade had lots of them!

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

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Rich Talbot-Watkins » Wed May 30, 2018 12:42 pm

I just tried the tape version of Exile in jsbeeb to see how it loads - definitely one of your trademark decrypters (length &301 ;) ) in ExileL and ExileB!

Do you remember why you decided to ditch the custom tape format (one long block) in favour of the standard Acorn format with interblock gaps? I always liked the Ultimate style continuous data streams, but I guess it was harder to recover from loading errors. (That said, By Fair Means Or Foul loaded in a continuous block, and provided a way to recover from data errors by rewinding back a little way).

Kevin Edwards
Posts: 97
Joined: Tue Mar 14, 2006 9:16 pm
Contact:

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Kevin Edwards » Wed May 30, 2018 1:13 pm

Hi Rich,

I stopped using the continuous stream because of tape loading errors and feedback. Your average user was use to rewinding the tape if they got an error and continuing and I didn't support that at the time. It was easier to go back to 'familiar' acorn tape data format. I could have spent more time introducing some block gaps but didn't feel it was worth the effort.

I dug out the two Exile Decoders for you so that you could see the full source for them - no game included, just my decoder source. They are for the SWRAM version of the game ( Decoder3 and Decoder 4 )

I hope you find them of interest - from 1988.

Cheers,
Kevin.
Attachments
EXILEDEC3.DSD
(400 KiB) Downloaded 12 times

User avatar
davidb
Posts: 2150
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by davidb » Wed May 30, 2018 1:44 pm

A couple of non-technical questions from me. :)

Was the protection on the tape versions (particularly on the Electron) ever shown to be effective at countering "piracy"? I realise that the Beeb scene had lots of users who could crack games to disk and share them that way but there didn't seem to be so many Electron users with disk drives. Plus, crackers would have had to do serious work to run it from disk, and tape-to-tape would still have been an effective way to copy the games in any case.

Did you update the routines between different releases based on feedback about circumvention techniques, either from publishers or from rumours in "the scene"? ;) Or did you just upgrade them based on your own gut instincts and knowledge of the weaknesses in the protection techniques you used?

Kevin Edwards
Posts: 97
Joined: Tue Mar 14, 2006 9:16 pm
Contact:

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Kevin Edwards » Wed May 30, 2018 2:03 pm

Based on feedback I got from publishers and hackers, the protection was very effective at slowing down the rate of piracy - you can never stop it!

My aim was to make transfering the games from tape to disk as difficult as possible. It certainly did work and I know countless people who gave up trying, many of them were very competent hackers who were defeated by the 6522 decoders.

Some of the later titles I protected were only copied by a handful of people which greatly slowed down the speed at which copied disk versions could be passed around - lunar Jetman and nightshade being two examples.

Decoders were changed for each game - small or minor improvements. Every 6 monts or so I would totally re-work them from scrtach. I knew the weaknesses of some implementations and how hardware could be used so I adapted my code to try and improve them.

The Electron didn't have a 6522 VIA to make things more secure so they were not as well protected as the Beeb implementations.

Kevin.

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

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Rich Talbot-Watkins » Wed May 30, 2018 2:48 pm

Thanks Kevin! It all looks so straightforward when you see it like that! :lol:

I'm one of your statistics who was beaten by Alien8. I had a double challenge though, because I had to try to make it Master compatible at the same time (armed with an image of OS 1.20 from a school Beeb!). I think the "emulate the timers and the decoder" approach would've worked OK for Alien8, even on a Master, but there's no way it'd ever have worked for Nightshade with all those mad IRQ edge cases that it relies on.

Did you have any tricks for the Electron protection, in the absence of VIAs?

Coeus
Posts: 963
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Coeus » Wed May 30, 2018 2:50 pm

Rich Talbot-Watkins wrote:
Tue May 29, 2018 4:35 pm
I think all the emulators emulate the type of hardware where writes go to whichever bank's in ROMSEL (&FE30). I reckon you'd probably need to patch and recompile the emulator of your choice to make it work the way you want.

I do remember the type of Sideways RAM expansion you're talking about though. You could load a ROM image with *LOAD ROM 8000 and it would just magically get written to the right place.
Apart from the Watford board which had only one bank of SWRAM and, AFAIK, always wrote to it, ignoring ROMSEL, Solidisk did a board which had flying leads that attached to the user port so the read bank and write bank were selectable independently. Their WD1770 FDC board also had the spare pins of the latch available - there was a set of four holes into which you could solder wires or put a four pin header. I wonder if they had it in mind that this could drive the write bank selection of their SWRAM product but they also bundled software that assumed it was connected to the user port.

On the *LOAD advantage to that arrangement I think a DFS ROM could achieve this another way with a little work. When reading from floppy the data is normally read from the FDC and written to its proper destination by the NMI routine which is sitting in RAM. When that reaches the end of the sector it will set a flag which is picked up by a polling loop in the DFS ROM so what would be needed to have the DFS read directly into SWRAM would be to also copy that polling loop to RAM and have it page in the DFS ROM again before returning to it.

Kevin Edwards
Posts: 97
Joined: Tue Mar 14, 2006 9:16 pm
Contact:

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Kevin Edwards » Wed May 30, 2018 2:56 pm

That raises a good point.

Are the various copies of Alien 8, Knight Lore etc. compatible with a Master 128 ( with MOS, not OS1.2 )- has somone patched them up? I have the source now and could probably sort them out.

The Electron decoder was basically the same without 6522 code. You couldn't modify the decoder or memory following it else it would decode incorrectly. So in that respect it was not easy to pull-apart. I think i messed about with the filname / load addresses, but can't honestly remember. The game data ( main file ) was scrambled up too.

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

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Rich Talbot-Watkins » Wed May 30, 2018 3:27 pm

Kevin Edwards wrote:
Wed May 30, 2018 2:56 pm
Are the various copies of Alien 8, Knight Lore etc. compatible with a Master 128 ( with MOS, not OS1.2 )- has somone patched them up? I have the source now and could probably sort them out.
I don't know if the bbcmicro.co.uk or STH archives have patched versions. I remember having to patch pretty much all the Ultimate games back in the day so I could play them on my Master. Paul Proctor's favourite trick was changing screen mode without clearing screen memory by calling directly into OS 1.20. And there were other things like assuming the font was at &C000, or leaving a custom IRQ routine by JMPing directly to the OS 1.20 entry point.

In any case, from an archival point of view, I find it more interesting to have the original releases out there, protection and all!
Kevin Edwards wrote:
Wed May 30, 2018 2:56 pm
The Electron decoder was basically the same without 6522 code. You couldn't modify the decoder or memory following it else it would decode incorrectly. So in that respect it was not easy to pull-apart. I think i messed about with the filname / load addresses, but can't honestly remember. The game data ( main file ) was scrambled up too.
I guess you could implement some kind of software timer with a custom IRQ handler using the tape interrupts, just to make it a bit harder. But it was the barely-documented cycle stretching behaviour that made the 6522 protection so evil!

Kevin Edwards
Posts: 97
Joined: Tue Mar 14, 2006 9:16 pm
Contact:

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Kevin Edwards » Wed May 30, 2018 3:46 pm

Alien 8

I have spotted 2 calls directly into OS1.20

1.) JSR &CCB3 - The back end of the CLS code, clearing from &6B00 to &7FFFF.
2.) JSR &E9B6 - Wait for VSYNC ( &240 chainging value )

All to save memory. The quick CLS code saves a lot of memory and wouldn't be easy to patch in. We do have multiple OSs for Master 128 to consider!

I shall leave this as it's not a quick fix...possibly more to come.

Some of the other Ultimate games do indeed use the system font data directly ( &C000 on OS1.2 ).

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

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Rich Talbot-Watkins » Wed May 30, 2018 3:55 pm

Kevin Edwards wrote:
Wed May 30, 2018 3:46 pm
1.) JSR &CCB3 - The back end of the CLS code, clearing from &6B00 to &7FFFF.
2.) JSR &E9B6 - Wait for VSYNC ( &240 chainging value )

All to save memory. The quick CLS code saves a lot of memory and wouldn't be easy to patch in. We do have multiple OSs for Master 128 to consider!
My patches for the Master just stuck the system font and extra code into HAZEL which was always paged in anyway. I think the screen clear only happens at the beginning, so it doesn't really need to be unrolled as per OS 1.20.

Did you guys know Chris Roberts as well? I remember some of his code using similar kind of tricks (and actually wasn't Wizadore another one you protected Kevin?)

Kevin Edwards
Posts: 97
Joined: Tue Mar 14, 2006 9:16 pm
Contact:

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Kevin Edwards » Wed May 30, 2018 4:00 pm

Yes, Paul Proctor, Chris Roberts, Martin Galway and myself all went to the same high school and we wrote software for the Beeb in a ( friendly ) competitive manner!

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

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Pernod » Wed May 30, 2018 4:04 pm

Kevin Edwards wrote:
Wed May 30, 2018 4:00 pm
Yes, Paul Proctor, Chris Roberts, Martin Galway and myself all went to the same high school and we wrote software for the Beeb in a ( friendly ) competitive manner!
What did Martin Galway do for the Beeb? Thought he was purely C64 music.
- Nigel

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

Kevin Edwards
Posts: 97
Joined: Tue Mar 14, 2006 9:16 pm
Contact:

Re: Emulator setup to make all ROM area writes use bank 15 SWR

Post by Kevin Edwards » Wed May 30, 2018 4:11 pm

You can see a list of the work he has done here.

http://www.mobygames.com/developer/shee ... erId,4639/

The first commercial game he did audio for was Atomic Protector on the BBC Micro.

He then did Music and SFX for the following Beeb games:-

Crazee Rider,
Galaforce
Galaforce 2
Wizadore,
Stryker's Run,
Match Day,
Sabre Wulf,
Knight Lore,
Alien 8
etc.

Post Reply