Frontier Elite II - BBC and Pi Native ARM CoPro

developing/porting a new game or gaming framework? post in here!
User avatar
dudleysoft71
Posts: 89
Joined: Tue May 26, 2020 6:56 pm
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by dudleysoft71 » Fri Jul 10, 2020 7:58 pm

I've spent a bit of time exploring the original assembly source and experimented with various methods of implementing timing and I've found a method of updating the timer, the host code increments a frame counter in the vsync interrupt, the parasite reads it when it updates the input.

I found the location where it holds the in game counter which keeps track of time and runs the physics simulation. So now the game runs at the right speed, however it now ignores the star-dreamer time multiplier (which also controls Hyper-space speed, so currently the trip to Barnards star will take about a week in real-time)

I've also added two key combinations Ctrl-J which turns joystick mouse on and Ctrl-M which turns on mouse support. The mouse is untested, it uses adval 7,8 and 9, which seemed like the most compatible method.

I will put a new build up soon, I want to sort out the time-step so you can Hyper-space in a reasonable time.

User avatar
trixster
Posts: 1042
Joined: Wed May 06, 2015 12:45 pm
Location: York
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by trixster » Fri Jul 10, 2020 8:25 pm

tested the latest version, works well! shame i cant remember how to play it correctly!

Interested in mouse support - i might have to hook up a smally mouse and give that a whirl once it's implemented.

What are your thoughts on sound?

User avatar
dudleysoft71
Posts: 89
Joined: Tue May 26, 2020 6:56 pm
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by dudleysoft71 » Fri Jul 10, 2020 8:34 pm

trixster wrote:
Fri Jul 10, 2020 8:25 pm
What are your thoughts on sound?
The sound chip on the Atari ST is similar to the beeb's, it has 1 noise channel and 3 square wave channels. If I can find the original sound parameters then I should be able to put them in the beeb version. I'm not sure where the music data is, if i can track that down then I can put the music on too.

User avatar
trixster
Posts: 1042
Joined: Wed May 06, 2015 12:45 pm
Location: York
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by trixster » Fri Jul 10, 2020 8:41 pm

is there any way to bring up the options? it's normally using the Escape key - sometimes this flashes up briefly but it never seems to 'stick'. i can't work out how to invoke it from the icons at the bottom.

User avatar
Yrrah2
Posts: 470
Joined: Tue Feb 06, 2007 6:06 pm
Location: Netherlands
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by Yrrah2 » Fri Jul 10, 2020 8:50 pm

As far as I know, there wasn't an options menu.
You had the function keys that made the images on the bottom of the screen change, and gave the other function keys other functions again. #-o #-o
And some function keys would give you options during flight, like calling for help or something.
Happy with my BBC Master
www.mybbcmaster.nl

User avatar
dudleysoft71
Posts: 89
Joined: Tue May 26, 2020 6:56 pm
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by dudleysoft71 » Fri Jul 10, 2020 8:56 pm

Escape is definitely the options menu. I don't know why it closes immediately, I'm going to look at clearing the escape key on screen flip to see if that helps.

User avatar
Yrrah2
Posts: 470
Joined: Tue Feb 06, 2007 6:06 pm
Location: Netherlands
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by Yrrah2 » Fri Jul 10, 2020 8:58 pm

dudleysoft71 wrote:
Fri Jul 10, 2020 8:56 pm
Escape is definitely the options menu. I don't know why it closes immediately, I'm going to look at clearing the escape key on screen flip to see if that helps.
ok, my mistake :^o
Happy with my BBC Master
www.mybbcmaster.nl

User avatar
dudleysoft71
Posts: 89
Joined: Tue May 26, 2020 6:56 pm
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by dudleysoft71 » Mon Jul 13, 2020 5:06 pm

Okay, a few new updates.

Firstly I've fixed the options menu, turns out F3 was mapped to the same key as Escape #-o . Once I'd fixed that the menu works fine.

Secondly I've updated my framerate code so it uses the timescale from the stardreamer, so now the game runs at the right speed all the time.

Thirdly, I've been working on the file selector, while it doesn't show any file, it doesn't crash, so pressing 5 from the intro wont hang the game (though TAB still does, but then it hangs the PC build too).

Fourthly, I've updated the font a bit, a lot of the characters are narrower now, so more text fits on the screen.

Finally I've added experimental support for joystick and mouse control for the cursor, press Ctrl-J to turn on/off joystick and Ctrl-M to turn on mouse. If you don't have a suitable mouse setup it seems to continually fire the gun though, Ctrl-J will move the cursor to the bottom right corner if there's no joystick connected, but doesn't affect firing.

I've attached a new HD image here:
FE2Beeb_0.3.zip
(825.24 KiB) Downloaded 7 times

User avatar
trixster
Posts: 1042
Joined: Wed May 06, 2015 12:45 pm
Location: York
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by trixster » Mon Jul 13, 2020 5:33 pm

Tremendous! Will test this evening. I have a couple of SmallyMouse2 boards squirrelled away somewhere too, so I’ll give mouse control a try as well

User avatar
dudleysoft71
Posts: 89
Joined: Tue May 26, 2020 6:56 pm
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by dudleysoft71 » Mon Jul 13, 2020 6:21 pm

trixster wrote:
Mon Jul 13, 2020 5:33 pm
Tremendous! Will test this evening. I have a couple of SmallyMouse2 boards squirrelled away somewhere too, so I’ll give mouse control a try as well
I've merged jgharston's mouse rom with the VideoNULA rom in my Beeb, it uses adval 7,8 and 9 to read the mouse, if you're using similar then hopefully it should work. I should have my smallymouse in the next couple of days so then I will give it a proper shakedown.

User avatar
BeebMaster
Posts: 3419
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by BeebMaster » Tue Jul 14, 2020 4:31 pm

tricky wrote:
Sat Jul 04, 2020 11:11 pm
How about just building the data into the emulator?
It might be possible to do a special build of Pi Tube Direct with the data/program code that is loaded from the hard disc image into the Native ARM co-pro already there at start-up - I've done this recently with my own build which has ARMBASIC available without having to load it.
Image

User avatar
dudleysoft71
Posts: 89
Joined: Tue May 26, 2020 6:56 pm
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by dudleysoft71 » Tue Jul 14, 2020 4:59 pm

BeebMaster wrote:
Tue Jul 14, 2020 4:31 pm
It might be possible to do a special build of Pi Tube Direct with the data/program code that is loaded from the hard disc image into the Native ARM co-pro already there at start-up - I've done this recently with my own build which has ARMBASIC available without having to load it.
I wonder if it might be possible to add a new command to the core that loads a file from the SD card, I believe the OSCLI commands for the native arm are built into the code so presumably it might be possible.

User avatar
BeebMaster
Posts: 3419
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by BeebMaster » Tue Jul 14, 2020 5:04 pm

Possibly, although I don't know how all that would be handled...do you mean the Pi Tube SD card or the hard drive SD card? Probably people don't alter the contents of the Pi Tube SD card very much except on a firmware update.

Adding a command itself is easy enough, I added "*ARMBASIC" to the Native ARM command set which just jumps to the exec address of ARM BASIC already in Pi RAM.
Image

User avatar
dudleysoft71
Posts: 89
Joined: Tue May 26, 2020 6:56 pm
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by dudleysoft71 » Tue Jul 14, 2020 5:07 pm

BeebMaster wrote:
Tue Jul 14, 2020 5:04 pm
Possibly, although I don't know how all that would be handled...do you mean the Pi Tube SD card or the hard drive SD card? Probably people don't alter the contents of the Pi Tube SD card very much except on a firmware update.

Adding a command itself is easy enough, I added "*ARMBASIC" to the Native ARM command set which just jumps to the exec address of ARM BASIC already in Pi RAM.
I was thinking of only reading from the Pi Tube SD card, all it would do is load a single file to a fixed memory location, I can build the data file into the executable and simply move it to the emulator memory on load.

Both Doom and Frontier load at 8F00 and have 8F00 as the execution address too. Doom might be harder to do since it loads data from the wad file as needed whereas frontier loads all it's data at once.

User avatar
dudleysoft71
Posts: 89
Joined: Tue May 26, 2020 6:56 pm
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by dudleysoft71 » Tue Jul 14, 2020 9:16 pm

I spent some time today looking into running on the Arm7tdmi Co-processor, primarily so I can get it running in an emulator. I debugged the code and fixed a few issues and finally:
Screenshot 2020-07-14 10.03.05.png
Screenshot 2020-07-14 10.03.16.png
Screenshot 2020-07-14 10.03.57.png
Success, well sort of, the frame rate is terrible, only a couple of FPS. But it works. I don't know if that's the limit or if it can be optimised more.

I downloaded a build of BeebEm and upped the cycle rate of the core, however this then caused the emulator to lag beyond a certain point, I'm not sure how accurate the 64Mhz emulation is to real speed, though I guess with everything the code is doing it isn't the most efficient code, and modern CPUs can brute force running the game, and running a 68000 VM in an emulated Arm processor, connected to an emulated BBC Micro is asking a lot of a single CPU core.

So as an exercise it was successful, certainly enough to allow me to iterate testing of things like the filesystem, but less so for playing.

User avatar
dudleysoft71
Posts: 89
Joined: Tue May 26, 2020 6:56 pm
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by dudleysoft71 » Wed Jul 15, 2020 5:21 pm

I've improved the performance of the arm7tdmi build a little, I changed the interpolation code for rendering triangles from using floating point to fixed point, it doesn't make a lot of difference to the overall performance, but since the 3D rendering is the largest part and the triangle rasteriser is called a lot removing the reliance on the FPU (which the poor arm7tdmi doesn't have) should speed up that area of code, unfortunately it appears the game still uses floating point for it's 3D maths anyway so that will cost.

I've also fixed mouse support now I have a mouse here, there were a few problems with it since I couldn't test it. I've also changed how the keyboard is read, this may cause issues so I may have to revert it, I was basically scanning all 72 keys during the Vblank interrupt, however since the mouse uses interrupts to update itself I was spending too long in the vblank routine, I might be able to reduce it to a subset of keys that are actually required to play the game.

Anyway the new PiTube build is here:
FE2Beeb_0.4.zip
(824.79 KiB) Downloaded 8 times
Anyone mad enough to try the BeebEm build can download it here:
FE2Arm7.zip
(865.39 KiB) Downloaded 6 times
You will need to place the scsi0.dat and scsi0.dsc files in the BeebEm discims folder in documents, enable SCSI Hard Drive, switch to Master (since it has ADFS as standard, and enable the Arm7tdmi co-processor. Once you've done that you can call *FE2ULA to run the game (you may need to run *. first since it mine doesn't seem to have a default directory), loading takes a long time. If you install the mouse rom from http://mdfs.net/Info/Comp/BBC/Mouse/ and run *MOUSE ON before loading you should be able to press Ctrl-M to enable the mouse, however given the speed of the game in BeebEm, it probably wont be very usable but it will work.

User avatar
Yrrah2
Posts: 470
Joined: Tue Feb 06, 2007 6:06 pm
Location: Netherlands
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by Yrrah2 » Wed Jul 15, 2020 10:02 pm

dudleysoft71 wrote:
Wed Jul 15, 2020 5:21 pm
I've improved the performance of the arm7tdmi build a little, I changed the interpolation code for rendering triangles from using floating point to fixed point, it doesn't make a lot of difference to the overall performance, but since the 3D rendering is the largest part and the triangle rasteriser is called a lot removing the reliance on the FPU (which the poor arm7tdmi doesn't have) should speed up that area of code, unfortunately it appears the game still uses floating point for it's 3D maths anyway so that will cost.

I've also fixed mouse support now I have a mouse here, there were a few problems with it since I couldn't test it. I've also changed how the keyboard is read, this may cause issues so I may have to revert it, I was basically scanning all 72 keys during the Vblank interrupt, however since the mouse uses interrupts to update itself I was spending too long in the vblank routine, I might be able to reduce it to a subset of keys that are actually required to play the game.
Just gave it a try, and indeed the mouse works!! :D
But it seems the keyboard is indeed doing strange things. what exactly, I don’t know. But ot can happen that I start shooting when I press a function key. Or the function keys react verrrrry late.
But that is what you predicted in a way.
Or can it be that my mouse is very sensitive? In notice this when I use it with Wapping Editor or other mouse program. I have to select slow mouse mode to make it work better.

And when I tried to make a hyperspace jump I stayed in the hyperspace blue screen. (tried it when I left from Lave)

Is it an idea that you create CTRL+K to get back to the keyboard controls?

cheers!!!
Happy with my BBC Master
www.mybbcmaster.nl

User avatar
trixster
Posts: 1042
Joined: Wed May 06, 2015 12:45 pm
Location: York
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by trixster » Wed Jul 15, 2020 10:12 pm

you can get round the hyperspace bug by advancing time with the stardrive until you're through the hyperspace tunnel.

User avatar
dudleysoft71
Posts: 89
Joined: Tue May 26, 2020 6:56 pm
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by dudleysoft71 » Wed Jul 15, 2020 10:50 pm

Ctrl-M should turn the mouse off again. I can check if it does actually do that.

I think that modern mice are far too high resolution for the beeb to handle the messages, I have to move it slowly to make it work properly if I go too fast then it moves the wrong way.

I'll have to check the frame time, I thought the Hyper-space worked with the same as the stardreamer, guess I'll take another look see if there's another variable controlling the internal clock.

I think I'm going to return to the previous keyboard reading code, it didn't seem to affect the mouse much, I don't know how frequently the mouse updates when moving it might be alright.

RobC
Posts: 2924
Joined: Sat Sep 01, 2007 10:41 pm
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by RobC » Thu Jul 16, 2020 8:56 am

Looking forward to trying this when I have some time at the weekend. Do you mind if I record a video of it and put it up on Youtube?
dudleysoft71 wrote:
Wed Jul 15, 2020 10:50 pm
I think I'm going to return to the previous keyboard reading code, it didn't seem to affect the mouse much, I don't know how frequently the mouse updates when moving it might be alright.
How are you reading the keys? For my emulators and Doom, I use a hacked version of OSBYTE &79 from the OS 3.20 code that returns the lowest two keys pressed. I can then chain calls to cope with multiple keys being pressed at the same time (e.g. up, right and fire).

The B and B+ OS versions don't allow you to do this as they return the highest key pressed so you can't chain calls.

User avatar
dudleysoft71
Posts: 89
Joined: Tue May 26, 2020 6:56 pm
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by dudleysoft71 » Thu Jul 16, 2020 9:15 am

RobC wrote:
Thu Jul 16, 2020 8:56 am
How are you reading the keys? For my emulators and Doom, I use a hacked version of OSBYTE &79 from the OS 3.20 code that returns the lowest two keys pressed. I can then chain calls to cope with multiple keys being pressed at the same time (e.g. up, right and fire).

The B and B+ OS versions don't allow you to do this as they return the highest key pressed so you can't chain calls.
I'm using the following code:

Code: Select all

	lda #keyPressed+8
	sta keyAddr+1
	ldy #71
	lda #8
	sta temp+2
.keyLoop
	ldx keyCode,y
	stx &FE4F
	asl &FE4F
	rol a
	dec temp+2
	bne dontStore
.keyAddr
	sta keyPressed
	dec keyAddr+1
	lda #8
	sta temp+2
.dontStore
	dey
	bpl keyLoop
It scans the entire keyboard and sets a bit for each key that's pressed, the parasite side simply reads the 9 bytes across the tube. I was doing this in the vblank interrupt, obviously doing this for 72 keys takes a fair few cycles. I have moved it to be triggered in my OSWRCH code (by sending char 254) this is called after it's processed the previous input values, this should mean it gets called less often, but also seems to be less reliable.
I chose to scan all the keys since there's a distinct disconnect between the keyboard reading in the code and the processing in the VM, the original code uses SDL's keyDown/keyUp events to set the appropriate flags so the amount of keys isn't a problem, however we don't really have an equivalent on the Beeb. If you could send me the code for the hacked OSBYTE call I might be able to do something similar, if I could save cycles on the keyboard it would be worth it.

User avatar
Elminster
Posts: 4207
Joined: Wed Jun 20, 2012 9:09 am
Location: Essex, UK
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by Elminster » Thu Jul 16, 2020 8:14 pm

This brings back memories. I still have my original saved games from the Amiga version ... now if I could just load them into the Beeb version.....

User avatar
dudleysoft71
Posts: 89
Joined: Tue May 26, 2020 6:56 pm
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by dudleysoft71 » Thu Jul 16, 2020 9:20 pm

Elminster wrote:
Thu Jul 16, 2020 8:14 pm
This brings back memories. I still have my original saved games from the Amiga version ... now if I could just load them into the Beeb version.....
I'm not sure if they're binary compatible but its based on the ST version so it might be possible to export the saves put them on the HD and when the filesystem is working you may be able to load them.

RobC
Posts: 2924
Joined: Sat Sep 01, 2007 10:41 pm
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by RobC » Thu Jul 16, 2020 10:22 pm

dudleysoft71 wrote:
Thu Jul 16, 2020 9:15 am
If you could send me the code for the hacked OSBYTE call I might be able to do something similar, if I could save cycles on the keyboard it would be worth it.
I've literally taken the code from the Master 3.20 OS which starts around 0xF937. However, it's probably not directly applicable to what you want as it's designed to return a single key press (but can be chained to search for multiple key presses).

The one possibly useful thing I think it does differently from your code is, rather than testing each key individually, it has an outer loop over the keyboard columns and an inner loop over the rows. It then uses the keyboard interrupt (CA2 on the system VIA) to check for any key being pressed in the current column/outer loop.

If there's no interrupt, it just moves on to the next column so might be more efficient as it's benefiting from an early out. If the interrupt has occurred, only then does it scan each row/ in turn.

User avatar
dudleysoft71
Posts: 89
Joined: Tue May 26, 2020 6:56 pm
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by dudleysoft71 » Thu Jul 16, 2020 10:46 pm

Okay I'll try and take a look I did find a disassembly but didn't know exactly where to look.
I'll stick with the code I've got for now, I think I need to move it back to the vsync, I moved it out to try and help with the mouse interrupts, but i think the mouse is actually too hires and fast for the beeb. I need a slower mouse since it will move backwards if I move it too fast.

User avatar
dudleysoft71
Posts: 89
Joined: Tue May 26, 2020 6:56 pm
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by dudleysoft71 » Fri Jul 17, 2020 3:46 pm

Okay, I found an issue with the ARM7TDMI co-processor in BeebEm, it turns out the code was executing 8 ARM instructions for each 6502 instruction, that included a 2 cycle instruction like INX or a 7 cycle instruction like ASL absolute,X. Even though it was instructions and not cycles it meant the speed of the core was effectively somewhere between about 1.125MHz and about 16MHz. I've created a new build of BeebEm which changes the code to do 8 times the number of cycles the 6502 as taken, this has dramatically improved the speed of the emulation.
Here's a replacement BeebEm executable with the changes:
BeebEm.zip
(304.29 KiB) Downloaded 8 times
This replaces the BeebEm 4.15 executable.

Here's a video captured from BeebEm: https://youtu.be/eqTCXAhKI8U as you can see the performance is much better, I was able to launch into space and hyperspace to another star system while playing.

User avatar
dudleysoft71
Posts: 89
Joined: Tue May 26, 2020 6:56 pm
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by dudleysoft71 » Tue Jul 21, 2020 5:54 pm

Quick update, l I've fixed a long standing colour issue with white turning red, turns out my code that builds the NULA palette data was setting the index for colours over 15, this was adding to the blue colour bit, normally this wouldn't be as noticeable, except for white where on incremented both the blue and green values effectively zeroing them #-o

I notice a lot more flickering of the palette since I enabled the mouse, some frames the background will flicker to a totally different colour and the fairly stable control panel colour change flickers around too.

I'm looking at taking the screen compression and colour mapping code I've written and creating a small library that can be used with any Native ARM ports to provide screen updates easily.

Finally I've added a few sounds. Not all the sounds are there I can't find any reference for a lot and trying to create envelopes that sound like the samples is a pain, but I do have some sounds, so it's a start. Except they don't seem to work in the beeb ULA build for some reason even through it's the same code in both host side programs.

User avatar
trixster
Posts: 1042
Joined: Wed May 06, 2015 12:45 pm
Location: York
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by trixster » Fri Jul 31, 2020 8:09 am

@dudleysoft71

Is this of any use to you?

https://github.com/watsonmw/fe2-intro

User avatar
dudleysoft71
Posts: 89
Joined: Tue May 26, 2020 6:56 pm
Contact:

Re: Frontier Elite II - BBC and Pi Native ARM CoPro

Post by dudleysoft71 » Fri Jul 31, 2020 6:10 pm

trixster wrote:
Fri Jul 31, 2020 8:09 am
@dudleysoft71

Is this of any use to you?

https://github.com/watsonmw/fe2-intro
I did take a look, some interesting stuff linked, but not a lot of use, it seems that the amiga version uses MOD files for it's music and sampled sounds. I really need the original ST sound data which seems to have gone missing, along with the original sound playing code from the disassembly. :(

Post Reply

Return to “new projects in development: games”