As some of you already know, I passed the last few month to convert GLib to an axiom, and if you doesn't know/or guess it, well SURPRISE ! : I am proud to finally present this works, and hope we will be able to see some 3D project appears. Of course keep in mind that this is a calculator engine, even if performances are definitly WAY more superior to axe version (thanks to asm/code refactoring).
In cliping, for example, I've got almost a 50%, even 55% performances boost....
For the new features/ changes from the axe version : -library now use matrix, way more powerful than the previous method that I used, and for now faster -VBO has been limited to 8 and for now can't be supressed (but don't worry you will soon be able to do that, and I'll post in tuto a way to do it from axe point of view) -Many many many optimization, size wise and speed wise. Standard cube (example provided) run at more than 40 fps ....
Anyway, the little test screen :
note that the white a the begining is definitly a gif bug >_>
And of course, the download is attached. (I hope I don't forget anything in it !) Wait a little for a tuto update, and you will be able to play with it at is full potential Concerning the source, I am pretty sure that Asm guru will find a lot, lot of optimization, feel free to take a look Also, there is most likely going to have update, for example new optimization, bug fixes, but the syntax won't hopefully change (except if a small change can boost performance like hell )
So ... I trying to get the maximum speed of the multiplication, since for each vertex (3d), 8 multiplications is performed (yeah, 64 multiplication for one cube).
I currently have a unrolled multiplication (from Xeda), sightly modified :
ld hl,0 or a ret z rlca jr nc,$+6 or a sbc hl, de add hl, hl
rla \ jr c, _7Set rla \ jr c, _6Set rla \ jr c, _5Set rla \ jr c, _4Set rla \ jr c, _3Set rla \ jr c, _2Set rla \ jr c, _1Set
ret
_7Set: add hl, de
add hl, hl rla jr nc, $+3 _6Set: add hl, de add hl, hl rla jr nc, $+3 _5Set: add hl, de add hl, hl rla jr nc, $+3 _4Set: add hl, de add hl, hl rla jr nc, $+3 _3Set: add hl, de add hl, hl rla jr nc, $+3 _2Set: add hl, de
add hl, hl rla ret nc _1Set: add hl, de ret
I was wondering if using LUT would not be faster. Of course LUT must fit the calculator memory :p
I know two method : antilog/log the x²/4 method.
The problem is I need a 9bit*8bit signed, (DE*A), with A between [-64,64] and DE between [-512,512] (result in HL) I try to extend this routine , but I haven't succed :
MulAE: ;A in [-64,64] , E in [-64,64] ; MULTABLE is a 512 bytes aligned area (starting at $xx00) ; CMULTABLE is copied there during init. ;f(A+E)-f(A-E)
sub e ld h, MULTABLE/256 ld l, a add a, e add a, e ld e, (hl) inc h ld d, (hl) ld l, a ld a, (hl) dec h ld l, (hl) ld h, a sbc hl, de ret
So, I was trying to have a routine who update only part of screen who have to be updated (since wireframe 3D as a lot of white in there...), but my routine totally failed. I suppose there is a place where I didn't put enough dealy (wich I have specified), but increasing a delay here doesn't relly change anything Basically, it take two buffer, pointed by hl-767 and de-767, hl is wich is on the screen and de is what I want to display. So I was wondering if there is a way to correct this routine and/or make more faster and optimized.
The poll I said in main topic, and if anyone have a question about using the Library, well you can specify it here.
Just to specify : GCORE have VBO, rotation, projection, cliping, vertex shader, camera gestion (getkey), and main function. Do you see function that I can add to it or it is enough ?
I try to do a demo for GLib and here the result. This is a succession of short sequence, the whole thing last 1 min. This is at 6MHz and the file is 3800 bytes.
This is my first tuto ever, so please tell me is something is unclear, or ununderstandable. New tuto using the new GCORE and final version !
I puting this here, to don't make confusion with other.
First of all, please download the file attached to this post, (not in the GLib main thread, 'cause I didn't update it) (GCORE). Last version is 2.0 omega Place it preferably in archive : warning ! this file is pretty huge (6400 bytes !!).
I THE BASIS
Let's create a rotating cube !
First of all, include the GCORE prog inside of your axe source :
Once you did this you have access to all the GLib functions.
We need to define the 3D coordinates of each point of the cube, so we can rotate and display them afterwards. Those points are just a bunch of data, so no real explanations are needed here :
Just remember that a 3D point is always defined as X,Z,Y using the standard 3D axis (X goes from left to right, Y from down to up and Z from near to far). Each coordinate takes 2 bytes, so don't forget the r.
By default GLib has no camera defined. So we must specify what type of camera we want to use. In this example, I want to be able to rotate my cube : this is a GMODELVIEW camera (I don't want the camera to move, only the model to rotate). If we actually wanted to have a worldview (fps mode) camera, we would use the °GWORLDVIEW constant.
**But but but .... I don't know how to create my camera, and I need a pointer to it ! STOP don't worry, GLib provides two pointers to some really basic cameras ! These are the °GMODELVIEW and °GWORLDVIEW cameras.
So I just give one of those pointers to the function and my new camera is created :
GNewCam(°GMODELVIEW) Glib also need a special structure, allowing easy vertex processing/clipping. It's called a VBO : vertex buffer object. Basically, it's just a ram area. You need at the begining of your program to generate such structure :
GGenVBO(size,data_to_match) .destroy r1,r2 your size is the number of vertices you want to have. data_to_match is the raw (not processed) vertices coordinates (here it's GDB1) It also set the current VBO to the one created , so it will be used by all other command.
The function return a special value, that you have to store somewhere : it's the VBO id. We now have this :
this piece of code "update" (transform the vertices) for the specified VBO. You can see that we are passing the id we have previously store. 0 and 7 are the start and the end of vertices we should transform. Here it transform from the vertx 0,...., to the vertx 7 (the last one)
And now we want display our points. GLib provide the
GVBOPoint(id_vertex) .destroy r1 function to retrieve a point from VBO. It's store the x-coord and y-coord on screen to GScreenX and GSreenY var (alias OP1 and OP1+2) It also return in hl a clipping information : 0 if the point is visible, anything else (=/= from 0)
For(M,0,7) GVBOPoint(M) !If Rect(GScreenX,GScreenY,2,2 End End
the code loop from the first vertice, to the last one, retrieve on screen coordinate and then disp it if it is visible.
We need now to handle the arrow keys, so we can rotate our cube. GLib provides an in-built function, which handles everything (life is beautiful isn't it )
DispgraphClrdraw // we want to have something on screen ! EndIf getkey(15) // stop the While loop if [clear] is pressed
Now time to compile it ... aaaaaaaaaand ...
It works !
II Let's put some line
Well, let's take the previous code we used. He only display dot point, that not super funny. So let's put some line in there !! In fact, there is almost nothing more to add to your code. I want to display line, and possibly clipped lines between them. We don't want to draw point, so the previous for() loop is useless.
you may wonder what is a shader, and what you can do with it. In fact, the shader is a way to override the static pipeline of the 3D calculations. You are able then to do a lot of thing with it. However, some vars, (r3 to r6) musn't be used inside shader functions, due to GLib using these.
Well, anyway, let get started ! The standard function to set a shader is :
GVertexShader(adress_of_function,sub_adress_projection) .destroy r1,r2 you can of course get the adresse with the L operator. sub_adresse_projection is kindy tricky. It is the adresse in your shader, where th projection calculation starts.
Once you've put this code, anywhere in your program, GLib's functions will get override.
So let's see what you have to put inside this function.
Based on this you can either : -modify the vertex position before any rotation or after -build your own rotation routine and projection (for example to have more precision) -and everything you want...
Once you've done with the shader, you can disable it by doing :
GVertexShader(°GLIBFUNC) yep it's the same function pretty easy isn't it ?
let's create a custom shader then The goal is to make the camera moving up and down like in old fps. When the player is not moving, there should be no mouvement. Let create a vars T who hold the current active/not active state. Each frame, compare the X,Y coordinate of the player with previous stored one. (A,B) - if it different, increase the Z var, use to hold an angle : the cosinus will give us the mouvemnt.
where the centerVertexId is the id of the vertex representing the center of the sphere.
and then the GPrimitive function. I guess this is the most difficult.
the GPrimitive function take in input the pointer to a list of vertices' id, an you must set a particular variable before the call ; the GPolygon var. Simply put the type ( the constant ) in it. The call will the look like this :
it wil draw, in black, a triangle between the first three vertex.
One last thing before the test code though, you remember the GVAdr and GVStr variables for the line clipping ? Well polygon work the same. Every function need correct value in these var. Meaning that you have to rotate your vertex, store them, before call the Polygon function. If a polygon you draw goes crazy, look if you don't forget this part.
For(8) GVertex({r5}r,{r5+2}r,{r5+4}r copy(°GVertex,r6,6 r6+6→r6 r5+6→r5 End
For(M,0,11) .there is 12 line to draw in a cube GClipLine({M*2+°LinkList},{M*2+1+°LinkList} End
°GQUAD->GPolygon GPrimitive(Data(0,1,3,2)) .warning ! vertex must be clockwise or anticlockwise!
GGetkey(°GMODEL)
DispgraphClrdraw EndIf getkey(15)
not much change ,heh ? and the screen =)
still pretty strong, running at 20fps with a fully clipped model.
V VBO, extra functions, and pipeline informations...
We have already talked about VBO ... but how they work precisely ? follow the guide !
VBO are just a free place in memory, with an particular structure, and an id. What is a VBO Id ? In fact, it is no more than the adress of the start of it. Base on that, we can perfectly create our own VBO, without passing by the GGenVBO() command.You can perfectly, is L3 has been perfectly set up use this :
Bascially this command will change the current active VBO (read : used for rendering) to the one you specify. So, what is this particular structure ? It is the following :
.1 bytes -- reserved field for GLib's, used for delete VBO (you don't really need this) .2 bytes --number of vertices the VBO should handle at max .2 bytes --raw vertices adress .5*number of vertices bytes --the vertex on screen position, with their respective cliping code .6*number of vertices bytes --the rotated vertices coordinates.
Indeed, this is a simplified one - especially into the graphics commands. The last stage can be decomposed in many other one, but the GCORE lib doesn't really touch these. It's more the goal of the GPOLY lib (wich is for the moment outdated).
Other tutorials are coming, I will then organize this post with them.
As I need a fast cliping line algorithm, I use this one. So I program it, and he looks to be fine. But, in some cases the line is completly false (it draws another line that I need) I simply can't find why he does that. If someone has an idea ... ?
you know that I participate to the 2012 apocalypse contest, so here my thread.
I think this will be a isometric/RPG game you are at 1h30 from the 21 december 2012 0h am. you are the commander of a spatial ship. Something strange happen....
features : -very few animations -secondary quests -a final boss -over 20 rooms to explore -cool effects -30-40 min of gamplay (if you are fast) -dynamic battle systeme -four grey levels
EDIT : I forgot to precise, this will be an AXE game
lot of things have change ... make sure to read the topic =)
What is implement so far: -texture (but outdated) -rotation/projection -perfect 3D cliping -vertex/pixel/geometry shader (!!!) -polygon drawing
TODO -light -backface culling -implementation of texture shader and precalculated normal, binormal and tangent -polygon sorting -reimplement proprely polygons drawing and pixel/geomety shader
I am someone which creates a group with his friends (TheMachine) who are programmers on calculator. I was a little interrested assembler, but I still prefer the axe I have a ti 84 +, 83 +, 83. You will see me a little on the forum: my dream is to create the best rpg on calculator (NEMESIS) (but not winning ).
: ERROR: SYNTAX then he should have me open it ....
I will check if doors is enabled, and surprise:no doors or Axe parser ... : The apps were suppressed
I'll look into the memory and I see one program (I did not create) named "dcsasmex" was the very end of the list ... And when I see the list of program from "prgm", there is not this program ....
PS: I can delete this prgm with no effect I use a TI83 + fr with
Bonjour je suis nouveau sur le site et j'essaie de créer un nouveau rpg en 3d avec un moteur raycasting. Les menus sont quasiment terminés. J'aimerai de l'aide pour le moteur raycasting
voici le code source
Hello I am new to the site and I try to create a new RPG with 3D ray casting engine. The menus are almost completed. I'd like to help with the ray casting engine
E0->S E500->X->Y Diagnosticoff Repeat getkey(15) Repeat getkey(0) Pause 11 Disgraph' End Disgraph'Clrdraw'' getkey(2)-getkey(3)*8+S->S sin()->Q cos(S)->P If getkey(4)+getkey(1) If getkey(1) -P->P // negative symbole (not operator) -Q->Q // the same End !If Check(X+P,Y-Q)->U*(U<4) X+P->P Y-Q->Q End End E3->A cos(-45)->L // negative symbole S+45->S While -S+45 //operator cos(Z)->I sin(Z)->J E0->C-32->G //oper. X->P Y->Q EF->K Ray() A+2->A cos(-48)->L //operator Z-2->Z End End Return
Lbl Check nib{/256*156+{°r1+1}+(GDB1*2)} Return
Lbl Draw !If H-r2-G->r2<<0 Rect(A,G+32,2,r2,r1) End Return
Lbl Ray P+I->P Q-J->Q If Check(P,Q)->§*(K>=§) 180/(L*C/256+8)->H*§/5->W G+H>256?-H->G // negative signe If Check(P,Q+J)->V+§-2*V Draw(L6,V*H/5 End V-§?Draw(L3,W),Draw(L6,W Return!If §->K-1 G+r2->G End ReturnIf C++>50 Goto Ray