glOric - a Fast 3D Engine for C and Assembler projects

Since we do not have native C compilers on the Oric, this forum will be mostly be used by people using CC65 or the OSDK. But any general C related post will be welcome !
jbperin
Pilot Officer
Posts: 85
Joined: Wed Nov 06, 2019 11:00 am

Re: glOric - a Fast 3D Engine for C and Assembler projects

Post by jbperin »

8bit-Dude wrote:
Mon May 18, 2020 8:06 am
I have a request by the way: Could you add a function that specifies the area of screen for rendering? (so that an interface can be placed around it)
Viewport size is currently defined by two macros in both glOric_vXY.s and glOric_vXY.h files:

Code: Select all

#define SCREEN_WIDTH            40
#define SCREEN_HEIGHT           26
By redefining these macro, you can configure your viewport size at compilation time.
If you do so, you'll have to create your own buffer2screen function to copy the content of fbuffer [SCREEN_WIDTH*SCREEN_HEIGHT] to the proper display adress area in memory. Because you cannot use the buffer2screen contained in glOric.

Other way to add a user interface surrounding the view port is to write it right in the glOric's fbuffer before copying this buffer to screen. Just consider fbuffer as your screen start adress.
That way, you can easily provide the user with the possibility to swithc between full screen mode (where no interface is displayed) and a normal mode in which you draw the interface.

It is not possible (and I don't think it will one day be possible) to dynamically change the viewport size because it would drastically alter the performance.

A 1.2 version will soon be released and i'll try to describe these approach a bit further.

jbperin
Pilot Officer
Posts: 85
Joined: Wed Nov 06, 2019 11:00 am

glOric - v1.2 released

Post by jbperin »

glOric v1.2 is available in glOric release directory

Changes since v1.1 mainly consist in optimizations.

I had my code reviewed by Dbug the great, he gaves me some very good advices on how to make glOric go faster:
- auto patched code in bressenham line and face drawing
- use zero page for some intensively used state variables
- use interleaved geometry buffers to save some useless increments
- reduce context saving in stack as much as possible.
- unroll some loop to save cpu cycle
I also found a tricky way to simplify filling and clipping by using logarithmic division to compute slope coupled with a clever handling of screen border saturation.

glOric v1.2 also includes some new features:
- the glDrawParticules function is now coded in assembly language and is incorporated into glOric (no longer need to ).
- two important functions of glOric are C binded to ease their use from C programs:

Code: Select all

zplot(unsigned char X, unsigned char Y, unsigned char dist, char char2disp)
and

Code: Select all

projectPoint(signed char x, signed char y, signed char z, unsigned char options, signed char *ah, signed char *av, unsigned int *dist)
. By using theses function, it becomes very easy to dynamically incorporate your own content into 3D scenes such as tiles, background, sky, horizon and more .. while taking advantage of glOric powerful projection function and zbuffering.

For people wanting to discover how to use glOric, you can have a look at the 3Dwalthrough source code.

Remarks and questions are welcome.

User avatar
iss
Wing Commander
Posts: 1062
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: glOric - a Fast 3D Engine for C and Assembler projects

Post by iss »

Congrats! This looks really cool and pro, I'll definitely give it a try asap.

Two small advises for assembler to avoid unpredictable and hard to debug side-effects:
- don't use comments after #define. For instance:

Code: Select all

* = $1000
#define VALUE_ADDRESS $1000 ; this is very important value
	LDA		VALUE_ADDRESS,X
will be compiled to (hex representation of the binary):

Code: Select all

AD 00 10
which is LDA $1000 without indexing by X register, because the assembler actually compiles this :) :

Code: Select all

	LDA		$1000 ; this is very important value ,X
- instead of bcc *+4 use labels for the relative branches. It looks cool and hacker-ish, but with label it will be more readable and human friendly ;).

Just my two cents...

jbperin
Pilot Officer
Posts: 85
Joined: Wed Nov 06, 2019 11:00 am

Re: glOric - a Fast 3D Engine for C and Assembler projects

Post by jbperin »

iss wrote:
Sat Jun 06, 2020 7:48 pm
- don't use comments after #define.
- instead of bcc *+4 use labels for the relative branches.
Just my two cents...
Thank you very much ISS for this review ! I really need this kind of advice to enhance the quality and robustness of glOric.
I'm going to take into account your remark and I'll update the source before I put a release tag on this 1.2.

If you find any other suspicious practice in my code .. please tel me know.

And also, I would be very pleased and honored that you give glOric a try.

User avatar
Dbug
Site Admin
Posts: 3335
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: glOric - a Fast 3D Engine for C and Assembler projects

Post by Dbug »

jbperin wrote:
Sun Jun 07, 2020 9:55 am
And also, I would be very pleased and honored that you give glOric a try.
Imo, the best way to show what it can do, and motivate people, is to provide a number of demos that show specific things in isolation, like:
- The current scene, because it shows what it can do
- Minimum code to just draw a triangle moving around
- A simple rotating cube
- A few rotating cubes of different colors moving around and passing in front of each other

Ideally, put all that one one single floppy or tape file with a small selection menu to go through the various scenes, eventually using the three lines of text at the bottom to explain what is being demonstrated, and the url to the project repository :)

jbperin
Pilot Officer
Posts: 85
Joined: Wed Nov 06, 2019 11:00 am

Re: glOric - a Fast 3D Engine for C and Assembler projects

Post by jbperin »

Well, I don't feel like doing all that packaging things for now with the menu and so on (even though I would learn a lot by doing it)

But I think I can write a tutorial to help deveoppers to quickly get into glOric for their own creation.

I've started writing it but I realise my english is very poor to be confortable at this task so it might takes time for me to finish it.

I think I shall try to focus on giving source code samples which are easily understandable and quickly reusable.

But I agree that it is a very good idea to ease the process of getting into gOric by writing some documentation. Thank you.

User avatar
ibisum
Wing Commander
Posts: 1285
Joined: Fri Apr 03, 2009 8:56 am
Location: Vienna, Austria
Contact:

Re: glOric - a Fast 3D Engine for C and Assembler projects

Post by ibisum »

I would love to see glOric pushed into use to make a tank simulation, a la Battlezone. Sort of simple, one-tank to find, and an occasional UFO. Anyway, I've had a look at glOric with this in mind, seems like a logical next-step for the demo to add moving objects ..

User avatar
Symoon
Archivist
Posts: 1875
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France
Contact:

Re: glOric - a Fast 3D Engine for C and Assembler projects

Post by Symoon »

Battlezone inspired Mercenary… :p

jbperin
Pilot Officer
Posts: 85
Joined: Wed Nov 06, 2019 11:00 am

Re: glOric - a Fast 3D Engine for C and Assembler projects

Post by jbperin »

iss wrote:
Sat Jun 06, 2020 7:48 pm
I'll definitely give it a try asap.
Well, I've just had an other code review by Dbug .. and it turns out that some major code refactoring are coming that will impact naming convention in the interface described in the glOric header.

So it's the good moment to wait and see .. :-(

https://lesjoiesducode.fr/quand-je-sors-de-5-heures-de-revue-de-code

ibisum wrote:
Mon Jun 08, 2020 9:00 pm
I would love to see glOric pushed into use to make a tank simulation, a la Battlezone.
I'm currently thinking of how a kind of battlezone clone could be done with glOric. It woud be a text mode version .. is that a problem ?
I've never played this game. I only watched the C64 version on youtube .. one question: is the player able to move in the scene or is he just able to rotate his sight ?

Even though I think of this game as an illustration of glOric .. I'm not able to do a full game .. so it will rather be a template

User avatar
ibisum
Wing Commander
Posts: 1285
Joined: Fri Apr 03, 2009 8:56 am
Location: Vienna, Austria
Contact:

Re: glOric - a Fast 3D Engine for C and Assembler projects

Post by ibisum »

Text-mode 3D works, but I don't see why it couldn't be Hires 3D? Perhaps in a narrower section of the screen.. The original Battlezone was pretty basic - yes, the player could move their tank around the world, but would bump into an edge eventually .. there were also obstacles to be navigated around, 3D cubes and cones and so on - as well as the odd UFO to chase and some nasty tanks that could be faster than you'd have liked ..

But anyway, just having a demo would be a great start. Perhaps you could do the basics and then others could come along and add some flair patches?

jbperin
Pilot Officer
Posts: 85
Joined: Wed Nov 06, 2019 11:00 am

Re: glOric - a Fast 3D Engine for C and Assembler projects

Post by jbperin »

OK

I took into account remarks from ISS about the code quality.
I took into account some remarks from Dbug about the naming convention used in the glOric interface and some types mistakes.
I wrote a small introduction on how to use glOric.

So the v1.3 of glOric is here.

I think the interface is stable now. People can safely build upon it because I don't think I'm going to make it evolve in a significant way in the future.
What may change in the future is the code cleanliness, some bug fixes, some performance enhancement and eventually some additions but the existing interface won't change.

jbperin
Pilot Officer
Posts: 85
Joined: Wed Nov 06, 2019 11:00 am

Re: glOric - a Fast 3D Engine for C and Assembler projects

Post by jbperin »

ibisum wrote:
Sat Jun 13, 2020 12:25 pm
but I don't see why it couldn't be Hires 3D? Perhaps in a narrower section of the screen..
ibisum, I think you were right. I made an attempt and here's what it gives:
NoTankYet.gif
NoTankYet.gif (123.63 KiB) Viewed 85 times
The glOric 3D is dirty in Hires (because it is design for lores mode) but it might remain playable.
Please have a look at this TAP file and give me your impression. It's just the basics.
battletank.tap
(24.11 KiB) Downloaded 5 times
ibisum wrote:
Sat Jun 13, 2020 12:25 pm
But anyway, just having a demo would be a great start. Perhaps you could do the basics and then others could come along and add some flair patches?
I putted the source code in this repository:
https://github.com/oric-software/BattleZone4Oric

If someone feels like contributing ..

EDIT: I realize that the killing raxiss team had already worked on a tank concept back in 2018. I need to see what it looks like .. perhaps is there some gameplay material to reuse.

User avatar
iss
Wing Commander
Posts: 1062
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: glOric - a Fast 3D Engine for C and Assembler projects

Post by iss »

jbperin wrote:
Sun Jul 05, 2020 7:39 pm
EDIT: I realize that the killing raxiss team had already worked on a tank concept back in 2018. I need to see what it looks like .. perhaps is there some gameplay material to reuse.[/b]
He, it's not this type of tank, we are peaceful people - it's just a fish-tank for relax and meditation :mrgreen: .

Else on topic: keep going with your incredible work! All 3D stuff is amazing, I just don't have the enough time to dive into it.
And what I really miss is a fixed-point math library optimized for 6502 ... any volunteer?

Post Reply