Author Topic: Vectors on CPC  (Read 994 times)

0 Members and 1 Guest are viewing this topic.

Offline zhulien

  • 6128 Plus
  • ******
  • Posts: 792
  • Country: au
  • aka Vorax
    • 8bitology
    • Awards
Vectors on CPC
« on: 03:00, 09 July 21 »
Last night i watched this video on youtube.


I was thinking a vector library / RSX set could be a good thing for BASIC games if I were to code those.  I did notice howeve the video seems to be isometric rather than perspective.  Does anyone know if perspective has a more taxing load than isometric on a z80?


Also has anyone already got experience coding this stuff who would like to provide their code to me to bundle into an RSX library?  I'm thinking fast rendering of 3d object lists with some collision detection options.  Perhaps automatic rotations or animation like my JS sprite library - the same principles could work.


Likewise does anyone have any superfast line drawing routines for different modes?


List vector games on CPC:

- 3D Tennis
- Battle of the Planets (very fast and smooth)
- Cholo (a bit slow, I didnt really get the game)
- Elite (fantastic game with not bad vectors)
- Mercenary (I didn't really get the point of this game)
- Starglider (awesome game and vectors)
- Starion (not bad game but awesome vectors)
- 3d Star Strike (I really like this, and fast if not chunky)
- Star Wars (nicer looking than 3d Star Strike but not as fast/smooth)
- Empire Strikes back (slightly better than Star Wars vectors)
- Thrust (very smooth, a classic game)
- Top Gun (fast)

Filled in Vectors (not really wanting the initial library to cater for graphics like these):


- Freescape games
- Star Strike 2 (looks fantastic and fairly fast)
- Battle Command
- Carrier Command (both fantastic achievements)
- Sherman M4


https://www.youtube.com/watch?v=nUuxp0-KRJQ&t=25s
« Last Edit: 04:07, 12 July 21 by zhulien »

Online Bryce

  • The Hardware Guy.
  • Supporter
  • 6128 Plus
  • *
  • Posts: 12.453
  • Country: wf
  • It's not broken, it just hasn't been fixed yet.
    • index.php?action=treasury
    • Awards
Re: Vectors on CPC
« Reply #1 on: 10:35, 09 July 21 »
The Thrust games.

Bryce.

Offline sigh

  • 6128 Plus
  • ******
  • Posts: 1.333
    • Awards
Re: Vectors on CPC
« Reply #2 on: 13:43, 09 July 21 »
Does 3D Tennis help?
Out of the list you did, Starion is the most outstanding too me. It's so fast and smooth; I'm blown away at how this was achieved.

Offline Targhan

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.406
  • Country: fr
    • Awards
Re: Vectors on CPC
« Reply #3 on: 14:30, 09 July 21 »
For full-3D, also add:
- Battle Command
- Carrier Command (both fantastic achievements)
- Sherman M4
Targhan/Arkos

Arkos Tracker 2.0.1 now released! - Follow the news on Twitter!
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

Offline eto

  • Supporter
  • 464 Plus
  • *
  • Posts: 435
  • Country: de
    • Awards
Re: Vectors on CPC
« Reply #4 on: 15:50, 09 July 21 »
So, these games have one thing in common: the faster it is, the more limited is the 3D display.

Complete freedom is slow, some "clever" limitations (like the limitation to convex bodies in Elite or Starion) is already pretty fast, and pseudo 3D then is even faster (3D Star Strike doesn't look like that are real 3D calculations at all, more like a clever drawing routine, that looks like it's 3D).

I doubt that it will be possible to create a library for Basic that will be fast enough for any action based game or simulation. The Basic overhead is just too big.

(One thing that came to my mind a few weeks ago was to use a PIC or other CPU as a coprocessor for the Amstrad. So a library would basically delegate calculations to the much faster external CPU. But that would kind of cheating and limit any software to owners of such an add-on.)
« Last Edit: 16:16, 09 July 21 by eto »

Offline Targhan

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.406
  • Country: fr
    • Awards
Re: Vectors on CPC
« Reply #5 on: 10:37, 10 July 21 »
So a library would basically delegate calculations to the much faster external CPU
No, this wouldn't really improve the framerate. It is not the calculation that really takes time, but the display. In that your additional CPU wouldn't help you.
Targhan/Arkos

Arkos Tracker 2.0.1 now released! - Follow the news on Twitter!
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

Offline eto

  • Supporter
  • 464 Plus
  • *
  • Posts: 435
  • Country: de
    • Awards
Re: Vectors on CPC
« Reply #6 on: 11:51, 10 July 21 »
No, this wouldn't really improve the framerate. It is not the calculation that really takes time, but the display. In that your additional CPU wouldn't help you.

Oh, ok. Now I am curious. From my memory, the 3D calculation is a lot of multiplication. Or are there fast routines for that?

Offline MaV

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.124
  • Country: at
  • Ius summum saepe summa est malitia.
    • Awards
Re: Vectors on CPC
« Reply #7 on: 17:41, 10 July 21 »
Oh, ok. Now I am curious. From my memory, the 3D calculation is a lot of multiplication. Or are there fast routines for that?
Nothing of this is fast on the CPC (or Z80 in general).
3D Star Strike is not pseudo 3D, but takes a few short cuts (as does Starglider). Starion looks faster than the other games but does only implement parallel projection (which looks like shit) instead of perspective projection like in Starglider.
Black Mesa Transit Announcement System:
"Work safe, work smart. Your future depends on it."

Offline MaV

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.124
  • Country: at
  • Ius summum saepe summa est malitia.
    • Awards
Re: Vectors on CPC
« Reply #8 on: 22:11, 10 July 21 »
I might add that Starglider also uses hidden line removal for the main body of an object ("only" that is, so the battle tanks cannon is exempt, as is the Walker's legs).


Starglider was developed by Realtime Games Software which did all the Z80 8-bit ports and the IBM PC port (from the 68k originals by Argonaut games).
Many of their games have already been mentioned here:
Star Strike
Star Strike 2
Starglider
Battle Command
Carrier Command

So, if you'd like to program a mostly complete engine, take a deep dive into their games. But the viewports for most of these games are 128x64, and you're mostly in single digit framerate territory.
And that's about what you can expect of a feature rich Z80 3D engine. Any optimisation leads to a specialised 3D graphics engine that's not usable for a lot of other purposes. Demos with 3D graphics usually take such short cuts somewhere if they want to impress with speed.

An additional CPU wouldn't help much because communication with the co-processor will eat a sizeable bunch of Z80 cycles from the cycles you think you saved, and you'd still have to render every frame of the image with the Z80 in the CPC (something Targhan alluded to already in his post above).

Once you tread on that path, you could basically just use another faster computer altogether.
Black Mesa Transit Announcement System:
"Work safe, work smart. Your future depends on it."

Offline ajcasado

  • Supporter
  • CPC664
  • *
  • Posts: 58
  • Country: es
    • Awards
Re: Vectors on CPC
« Reply #9 on: 23:02, 10 July 21 »
Top Gun is also a good one.
CPC 664

Empiezas a envejecer cuando dejas de aprender.
You start to get old when you stop learning.

Offline zhulien

  • 6128 Plus
  • ******
  • Posts: 792
  • Country: au
  • aka Vorax
    • 8bitology
    • Awards
Re: Vectors on CPC
« Reply #10 on: 04:12, 12 July 21 »
No, this wouldn't really improve the framerate. It is not the calculation that really takes time, but the display. In that your additional CPU wouldn't help you.


I was thinking that via BASIC we can program the scene with a couple of RSXs to manipulate the scene, as well as RSXs to update the display, and a collision detection RSX.  The core game logic could be in BASIC still.


As for Matrix calculations, we are a community, maybe we can put the best Z80 calculations in there, with the best line-drawing routine in the renderer too.


Does anyone have any existing fast 3d vector calculations and line drawing routines for CPC?

Offline Targhan

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.406
  • Country: fr
    • Awards
Re: Vectors on CPC
« Reply #11 on: 10:29, 12 July 21 »
What is the point of having fast code if Basic is used? It would simply completely slow down the whole stuff. If you want speed, use assembler all along, especially in 3D. Think about what would be the "bottleneck". It wouldn't be the display anymore... but the Basic.
Targhan/Arkos

Arkos Tracker 2.0.1 now released! - Follow the news on Twitter!
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.003
    • Awards
Re: Vectors on CPC
« Reply #12 on: 11:35, 12 July 21 »
Yeah, I suspect for fast 3D you need to eek every last ounce of performance out of the machine. Dropping back to BASIC for anything is going to undermine that to the point you might just as well keep all the 3D logic in BASIC anyway where it'll at least be readable to BASIC coders.

Offline eto

  • Supporter
  • 464 Plus
  • *
  • Posts: 435
  • Country: de
    • Awards
Re: Vectors on CPC
« Reply #13 on: 14:54, 12 July 21 »
I was thinking that via BASIC we can program the scene with a couple of RSXs to manipulate the scene, as well as RSXs to update the display, and a collision detection RSX.  The core game logic could be in BASIC still.

Calling machine code from Basic has significant overhead. I just recently did some tests and for an RSX call, you "waste" between 1 and 2ms of CPU time, just for the pure RSX call. Plus almost. 0.5ms PER parameter that you send to your code. So easily 2.5ms for an RSX call with 2 parameters. If I am not mistaken, that would be the equivalent of 2500 NOPs that already have been wasted before anything relevant happens.

So an RSX library would probably not make a lot of sense for any action game. But maybe for something where frame rate is not relevant, like a text adventure with added 3D graphics.




Offline fgbrain

  • CPC6128
  • ****
  • Posts: 247
  • Country: gr
    • index.php?action=treasury
    • Chaos CPC Homepage
    • Awards
Re: Vectors on CPC
« Reply #14 on: 13:25, 13 July 21 »
Besides the games mentioned above, I remember my personal fave: Stunt Car Racer
Was fast and very playable!!

On the subject, back in the 20th century, I did some work with vector objects in Basic.


The fastest way is to have all your calculations done and stored ready in an array for all angles. And use results in integer only .
_____

6128 (UK keyboard, Crtc type 0/2), 6128+ (UK keyboard), 3.5" and 5.25" drives, Reset switch and Digiblaster (selfmade), Inicron Romram box, Bryce Megaflash, SVideo & PS/2 mouse, , Magnum Lightgun, X-MEM, X4 Board, C4CPC, Multiface2 X4, RTC X4 and Gotek USB Floppy emulator.

Offline zhulien

  • 6128 Plus
  • ******
  • Posts: 792
  • Country: au
  • aka Vorax
    • 8bitology
    • Awards
Re: Vectors on CPC
« Reply #15 on: 05:38, 14 July 21 »
What is the point of having fast code if Basic is used? It would simply completely slow down the whole stuff. If you want speed, use assembler all along, especially in 3D. Think about what would be the "bottleneck". It wouldn't be the display anymore... but the Basic.


What is the point of a print command that can print strings in BASIC if you have a print command that can only print a character and a loop?  Surely BASIC couldn't allow programmers with BASIC knowledge to print strings faster with a print command that can prints strings vs a print command that can print characters only?

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.003
    • Awards
Re: Vectors on CPC
« Reply #16 on: 10:41, 14 July 21 »
The difference is that machine code is fast enough to do the printing and have lots of time left over  to accomplish other work in BASIC.


There is barely enough grunt in an 8-bit machine to run a purely machine code 3D solution, you are almost certainly having to cheat slightly and squeezing every last cycle you possibly can for performance.


Handing any of the work at all over to the slow world of interpreted BASIC will entirely undo that and drop you straight back into a world of frames per minute rather than per second. And when you are that slow, the performance becomes irrelevant - the 3D aspect is going to only be useful for static content anyway, so you may as well let BASIC do all the work.