Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - TheMachine02

Pages: [1]
1
TI Z80 / [Axiom] Introducing .... gLib a fast 3D library
« on: January 19, 2015, 10:52:39 am »
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  ;D
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  :P)

2
ASM / Multiplication using LUT
« on: June 11, 2014, 05:41:21 am »
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 :
Code: [Select]
    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 :

Code: [Select]
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   

CMULTABLE:
.DB 0, 0, 1, 2, 4, 6, 9, 12, 16, 20
.DB 25, 30, 36, 42, 49, 56, 64, 72, 81, 90
.DB 100, 110, 121, 132, 144, 156, 169, 182, 196, 210
.DB 225, 240, 0, 16, 33, 50, 68, 86, 105, 124
.DB 144, 164, 185, 206, 228, 250, 17, 40, 64, 88
.DB 113, 138, 164, 190, 217, 244, 16, 44, 73, 102
.DB 132, 162, 193, 224, 0, 32, 65, 98, 132, 166
.DB 201, 236, 16, 52, 89, 126, 164, 202, 241, 24
.DB 64, 104, 145, 186, 228, 14, 57, 100, 144, 188
.DB 233, 22, 68, 114, 161, 208, 0, 48, 97, 146
.DB 196, 246, 41, 92, 144, 196, 249, 46, 100, 154
.DB 209, 8, 64, 120, 177, 234, 36, 94, 153, 212
.DB 16, 76, 137, 198, 4, 66, 129, 192

.DB 0, 192, 129, 66, 4, 198, 137, 76, 16, 212
.DB 153, 94, 36, 234, 177, 120, 64, 8, 209, 154
.DB 100, 46, 249, 196, 144, 92, 41, 246, 196, 146
.DB 97, 48, 0, 208, 161, 114, 68, 22, 233, 188
.DB 144, 100, 57, 14, 228, 186, 145, 104, 64, 24
.DB 241, 202, 164, 126, 89, 52, 16, 236, 201, 166
.DB 132, 98, 65, 32, 0, 224, 193, 162, 132, 102
.DB 73, 44, 16, 244, 217, 190, 164, 138, 113, 88
.DB 64, 40, 17, 250, 228, 206, 185, 164, 144, 124
.DB 105, 86, 68, 50, 33, 16, 0, 240, 225, 210
.DB 196, 182, 169, 156, 144, 132, 121, 110, 100, 90
.DB 81, 72, 64, 56, 49, 42, 36, 30, 25, 20
.DB 16, 12, 9, 6, 4, 2, 1, 0

.DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
.DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
.DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
.DB 0, 0, 1, 1, 1, 1, 1, 1, 1, 1
.DB 1, 1, 1, 1, 1, 1, 2, 2, 2, 2
.DB 2, 2, 2, 2, 2, 2, 3, 3, 3, 3
.DB 3, 3, 3, 3, 4, 4, 4, 4, 4, 4
.DB 4, 4, 5, 5, 5, 5, 5, 5, 5, 6
.DB 6, 6, 6, 6, 6, 7, 7, 7, 7, 7
.DB 7, 8, 8, 8, 8, 8, 9, 9, 9, 9
.DB 9, 9, 10, 10, 10, 10, 10, 11, 11, 11
.DB 11, 12, 12, 12, 12, 12, 13, 13, 13, 13
.DB 14, 14, 14, 14, 15, 15, 15, 15

.DB 16, 15, 15, 15, 15, 14, 14, 14, 14, 13
.DB 13, 13, 13, 12, 12, 12, 12, 12, 11, 11
.DB 11, 11, 10, 10, 10, 10, 10, 9, 9, 9
.DB 9, 9, 9, 8, 8, 8, 8, 8, 7, 7
.DB 7, 7, 7, 7, 6, 6, 6, 6, 6, 6
.DB 5, 5, 5, 5, 5, 5, 5, 4, 4, 4
.DB 4, 4, 4, 4, 4, 3, 3, 3, 3, 3
.DB 3, 3, 3, 2, 2, 2, 2, 2, 2, 2
.DB 2, 2, 2, 1, 1, 1, 1, 1, 1, 1
.DB 1, 1, 1, 1, 1, 1, 1, 0, 0, 0
.DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
.DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
.DB 0, 0, 0, 0, 0, 0, 0, 0
So if someone can help me ....

3
ASM / Buffer fliping : messing with display
« on: April 24, 2014, 06:06:47 am »
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  :P
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.
 
Code: [Select]

_BufferFlip:

ld a, $06

out ($10), a

ld a, $BF

out ($10), a

;set LCD to Y-decrement mode and set the max row



_OutLoop:

push af

ld b, $0C

_GetByte:

ld a, (de)

cp (hl)

ld (de), 0

ld (hl),a

jr nz, _PutByte

dec hl

dec de

djnz _GetByte

;compare until  byte is find

pop af

dec a

cp $80

;if 0, a=$80, and return.

jr z, _End

jp _OutLoop:

_PutByte:

push af

ld a, b

add a, $33

;set the column

out ($10), a

pop af

;here not enough delay !!!

out ($11), a

;write the byte

jp _GetByte

_End:

ld a,$05

out ($10), a

;put back LCD in the correct mode

ret
 

4
TI Z80 / GLIB poll and FAQ
« on: January 13, 2014, 06:27:41 am »
 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 ?

5
TI Z80 / [Axe]Binary Error - a GLib demo
« on: January 12, 2014, 11:29:04 am »
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.

Enjoy  :D


6
TI Z80 / [Axe] - GLib TUTO
« on: November 11, 2013, 07:38:34 am »
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 :

Code: [Select]
prgmGCORE

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 :
Code: [Select]
Data(40r,-40r,40r)->GDB1
Data(40r,40r,40r
Data(-40r,-40r,40r
Data(-40r,40r,40r
Data(40r,-40r,-40r
Data(40r,40r,-40r
Data(-40r,-40r,-40r
Data(-40r,40r,-40r

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.

The function to define a camera is :

Code: [Select]
GNewCam(pointer to camera)
.Destroys r1

**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 :

Code: [Select]
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 :

This is the command used :
Code: [Select]
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 :

Code: [Select]
GGenVBO(8,GDB1)->G
.I used G, but you can used any way to save this value


Now we can start the main loop, with 3D calculations :

Code: [Select]
While 1
GUpdateVBO(G,0,7)

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
Code: [Select]
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)

We can now write this :
Code: [Select]
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  :P)

It's the GGetkey function.
The call is:
Code: [Select]
GGetkey()

End of the code :

Code: [Select]
GGetkey()

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 ! :D

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.

GLib provide one function for this :
Code: [Select]
GClipLine(ID_vertex1,ID_vertex2)
.destroy r1 to r6
This is assuming that a VBO has been set.

We need however to know what vertices will be linked with. So let's create a list of ID's. Just to remember though :

Code: [Select]
Data(40r,-40r,40r)→GDB1    .vertex ID 0
Data(40r,40r,40r           .vertex ID 1
Data(-40r,-40r,40r         .vertex ID 2
Data(-40r,40r,40r           ...
Data(40r,-40r,-40r
Data(40r,40r,-40r
Data(-40r,-40r,-40r
Data(-40r,40r,-40r

The link between vertices will be handle by an for loop and a constant list (containing the correct vertex ID to link)

so we now have :
Code: [Select]
Data(0,1,2,3,4,5,6,7)->°LinkList
Data(0,2,2,4,4,6,6,0
Data(1,3,3,5,5,7,7,1

and :
Code: [Select]
For(M,0,11)    .there is 12 line to draw in a cube
GClipLine({M*2+°LinkList},{M*2+1+°LinkList}
End

combining all of this , aaaaaaaaand  (yes I like big and) :



well I fail in the link data list --'
exercice : find the right data list :p

the whole code, as ever :

Spoiler For Spoiler:
Code: [Select]
.TEST
prgmGCORE

Data(40r,-40r,40r)→GDB1
Data(40r,40r,40r
Data(-40r,-40r,40r
Data(-40r,40r,40r
Data(40r,-40r,-40r
Data(40r,40r,-40r
Data(-40r,-40r,-40r
Data(-40r,40r,-40r

Data(0,1,2,3,4,5,6,7)->°LinkList
Data(0,2,2,4,4,6,6,0
Data(1,3,3,5,5,7,7,1


GNewCam(°GMODELVIEW)
GGenVBO(8,GDB1)->G

While 1

GUpdateVBO(G,0,7)

For(M,0,11)    .there is 12 line to draw in a cube
GClipLine({M*2+°LinkList},{M*2+1+°LinkList}
End


GGetkey()

DispgraphClrdraw
EndIf getkey(15)


correction of the exercice :
Spoiler For Spoiler:
Code: [Select]
Data(0,1,2,3,4,5,6,7)->°LinkList
Data(0,2,2,6,6,4,4,0
Data(1,3,3,7,7,5,5,1


III Shaders (part 1)

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 :

Code: [Select]
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.

Code: [Select]
Lbl Shader
GRestoreHL

Return

because some function need a correct hl you mostly want to restore it. As GLib do a goto before, hl get ecrased. But we have a variable to restore it  ;D

a very basic shader (do nothing more than the GLib's GVertex command) would be then this:

Code: [Select]
Lbl Shader
GRestoreHL
GRotate()
Lbl SubShader   .the famous sub_adress
Goto GProject


it's first call the fuction who convert the r1,r2,r3   (and need r3 in hl) to the rotated coordinate in 3D space into OP1+6
Code: [Select]
GRotate(x,z,y)
.destroy r1-r3
.write to OP
You will then have the vertex rotated coordinate to these variable :

Code: [Select]
GVertexX
GVertexY
GVertexZ

Then it call the projection function to retrieve the x,y coordinate on screen

Code: [Select]
GProject()
.need the 3D coordinate Inside OP1+6 (°GVertex+6)

...and you can retrieve the 2D coordinate to these vars : (note that this function keep the 3D coordinates safe)

Code: [Select]
GScreenX
GScreenY

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 :
Code: [Select]
GVertexShader(°GLIBFUNC)
yep it's the same function  :P  pretty easy isn't it ?

let's create a custom shader then  ;D
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.

We now have this as shader :
Code: [Select]
Lbl TEST
GRestoreHL
GRotate()
Lbl TESTSUB
GProject()
!If T
signed{Z^256+°GCos}//32+GScreenY+2->GScreenY
End
Return

for each vertex, the point will be move on screen.

And then in the main loop, add this:

Code: [Select]
0->T
!f A-GCPosX   .GCPosX is the X coordinate of the camera
!f B-GCPosY
+1->T   .hl abuse...
End
End

GCPosX->A
GCPosY->B
If T
96->Z
Else
Z+8->Z   .increase the angle, so we can have the mouvement
End


and with variables initialisation :

Code: [Select]
0->A->B->T

So the whole code is :
(note that I change vertices to be more a world thing)
Spoiler For Spoiler:
Code: [Select]
.TEST
prgmGCORE

Data(-64r,0r,64r)→GDB1
Data(64r,20r,64r
Data(-64r,0r,64r
Data(-64r,20r,64r
Data(64r,0r,-64r
Data(64r,20r,-64r
Data(-64r,0r,-64r
Data(-64r,20r,-64r

Data(0,1,2,3,4,5,6,7)->°LinkList
Data(0,2,2,4,4,6,6,0
Data(1,3,3,5,5,7,7,1


GNewCam(°GWORLDVIEW)
GGenVBO(8,GDB1)->G

0->A->B->T
GVertexShader(LTEST,LTESTSUB)  .actually the small liste operator.

While 1

GUpdateVBO(G,0,7)

For(M,0,11)    .there is 12 line to draw in a cube
GClipLine({M*2+°LinkList},{M*2+1+°LinkList}
End

0->T
!f A-GCPosX   .GCPosX is the X coordinate of the camera
!f B-GCPosY
+1->T   .hl abuse...
End
End

GCPosX->A
GCPosY->B
If T
96->Z
Else
Z+8->Z   .increase the angle, so we can have the mouvement
End

GGetkey()

DispgraphClrdraw
EndIf getkey(15)
Return

Lbl TEST
GRestoreHL
GRotate()
Lbl TESTSUB
GProject()
!If T
signed{Z^256+°GCos}//32+GScreenY+2->GScreenY
End
Return

well, screen have different vertices but run the same shader :



One thing to remember :
DO NOT USE r4 to r6 !!. r1-r3 are fine though (but only after rotating)


IV And then come polygons.... [WARNING OUTDATED ]


the polygon system is in a separate library. So to use it, download the GPOLYGON file, and then put :

Code: [Select]
prgmGPOLYGON

a little warning : GPOLYGON is in alpha, bug may still there ! (and so ram clear too =\)

at the begin of your program, after the inclusion of the GCORE file. You can then acess all the new functions !

There is 3 extremely important function :
Code: [Select]
GDrawArray(adr_array,nb_of_poly)
.destroy r1 to r6
GPrimitive(start_adr)
.destroy r1 to r6
GSetColor(flag)
.destroy r1


I'll first explain GSetColor and GDrawArray, later GPrimitive

GSetColor is I guess pretty obvious. It is used to set the current drawing color.
Two flag are possible :
°GBLACK or °GWHITE (yes, it's constants)

every polygon drawn will have the color you set. Black is the default color.

GDrawArray can draw polygons according to a big bunch of datas. Data have a particular structure :

Code: [Select]
Data(Type_polygon,Color
Data(idVertex1,idVertex2,...
.all of this is one byte value

This function handle 3 type of polygon, with a special one :
-triangles       type is °GTRI
-quadrilater    type is °GQUAD
-sphere          type is °GSPHERE

the number of vertices you want to put is obviously the number of vertices in the polygon.

Why I say sphere is a special thing ? Cause data structure is different :

Code: [Select]
Data(type,color)
Data(centerVertexId,radius

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 :

Code: [Select]
GSetColor(°GBLACK)
°GTRI->Gpolygon
GPrimitive(Data(0,1,2))

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.  :P  If a polygon you draw goes crazy, look if you don't forget this part.

And now, a little test program:


Code: [Select]
.TEST
prgmGCORE
prgmGPOLYGON

Data(40r,-40r,40r)→GDB1
Data(40r,40r,40r
Data(-40r,-40r,40r
Data(-40r,40r,40r
Data(40r,-40r,-40r
Data(40r,40r,-40r
Data(-40r,-40r,-40r
Data(-40r,40r,-40r

Data(0,1,2,3,4,5,6,7)->°LinkList
Data(0,2,2,4,4,6,6,0
Data(1,3,3,5,5,7,7,1

Buff(8*6)→GDB2


GNewCam(°GMODELVIEW)
GDB1→GVAdr
GDB2→GVStr

While 1

GDB1→r5
GDB2→r6

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 :
Code: [Select]
GSetCurVBO(L3)
.destroy r1

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 :

Code: [Select]
.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.

the screen coordiante is separate as follow :

Code: [Select]
.2 bytes X coordinate
.2 bytes Y coordinate
.1 byte clipping code

the cliping code can be computed, if the vertex position to classify is in the GVertexX to GVertexZ vars with :
Code: [Select]
GInFrustrum()/256
.destroy nothing
and return vertex status in hl :
-0 if the point is visible
-anything else if not


Now more about the GLib's pipeline. In fact, when you want to draw a line, or any polygon, the classical pipeline will be :


-green : vertex operation
-red : shader
-blue : geometric operation
-white : outside GLib data operation.

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.

7
Axe / [AXE] cohen sutherland algorithm... with a little bug
« on: June 26, 2013, 12:27:06 pm »
As I need a fast cliping line algorithm, I use this one.   ;D
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 ... ?

The code : (unoptimized, I know  :P )

Code: [Select]
.TE

ExprOn
pi0000->^^oINSIDE
pi0001->^^oLEFT
pi0010->^^oRIGHT
pi0100->^^oBOTTOM
pi1000->^^oTOP
.Code

L1->^^oXMAX+2->^^oYMAX+2->^^oYMIN+2->^^oXMIN+2->^^oGCode

0->XMIN->YMIN
95->XMAX
63->YMAX
0->F->G
Fix 5

Repeat getKey(15)
GCLine(F,G,48,32)
HLine(YMAX)
HLine(YMIN)
VLine(XMIN)
VLine(XMAX)
!If getKey(48)
getKey(3)-getKey(2)+F->F
getKey(1)-getKey(4)+G->G
Else
getKey(3)-getKey(2)+XMAX->XMAX
getKey(1)-getKey(4)+YMAX->YMAX
End
Text(1,1,F>Dec
Text G>Dec

DispGraphClrDraw
End
Fix 4
Return

Lbl GOutCode
^^oINSIDE->GCode
If r1-XMIN//32768
^^oLEFT->GCode
ElseIf XMAX-r1//32768
^^oRIGHT->GCode
End

If r2-YMIN//32768
GCode+^^oTOP->GCode  //or
ElseIf YMAX-r2//32768
GCode+^^oBOTTOM->GCode //or (16bit)
End
Return GCode

Lbl GCLine
GOutCode()->r5
sub(GOutCode^^r,r3,r4)->r6
Text(50,1,r5>Dec

While 1
!If r5+r6  //16-bit  or
Line(r1,r2,r3,r4
Return
End
ReturnIf r5.r6

If r5
r5->B
Else
r6->B
End

If B.^^oBOTTOM
r3-r1*(YMAX-r2)//(r4-r2)+r1->X
YMAX->Y
ElseIf B.^^oTOP
r3-r1*(YMIN-r2)//(r4-r2)+r1->X
YMIN->Y
ElseIf B.^^oRIGHT
r4-r2*(XMAX-r1)//(r3-r1)+r2->Y
XMAX->X
ElseIf B.^^oLEFT
r4-r2*(XMIN-r1)//(r3-r1)+r2->Y
XMIN->X
End

!If B-r5
GOutCode(X,Y)->r5
Else
X->r3
Y->r4
sub(GOutCode^^r,X,Y)->r6
End

ReturnIf getKey(15)
End
#ExprOff

A screenshot to show the bug :

8
TI Z80 / [2012 Apocalypse contest axe 1.1.2] Cataclysm
« on: November 15, 2012, 03:31:14 am »
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

EDIT2 : some change in the features

9
TI Z80 / Glib : a 3D graphics axe library
« on: October 10, 2012, 09:13:11 am »
hello everyone.

I would like to present a new axe librairy I devellope for my game NEMESIS.

The main goal of it is to create real-time 3D environnements, and this even at 6MHz
It is always in developpement, so you can wait new updates  :P

enjoy


LAST UPDATE : http://www.omnimaga.org/ti-z80-calculator-projects/glib-a-graphics-axe-3d-librairy/msg383996/#msg383996
TUTO : http://www.omnimaga.org/ti-z80-calculator-projects/(axe)-glib-tuto/

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

10
Introduce Yourself! / hello
« on: June 14, 2012, 11:03:03 am »
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   XD).

11
So, I tried to run (for edit) a source Axe, and

: 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

polysmlt
Axe
doors

Os: 1.19

anyone have an idea ?

12
TI Z80 / Nemesis- a new axe 3d rpg
« on: May 22, 2012, 10:04:06 am »
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

here's the source code

. Full3d
[1111111111111111->GDB1  //test map
[1000000000000001
[1999100000000001
[1888100000000001
[1777400000000001
[1888101199100001
[1999101199100001
[1999101199100001
[1999100100100001
[1555100100110001
[1111100100010001
[1111111111111111

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

Need optimization
(6 MHz)

->  is sto symbole

§  is theta


Pages: [1]