Sega Genesis Dev Kit (SGDK)

SGDK only sub forum

Moderator: Stef

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef »

Chilly Willy wrote: Okay, how about this -

waitTick:
if (intlevel > 3) wait using VDP status in busy loop
else wait using vints

waitMs:
wait using CPU busy loop (use table lookup for loop count for small ms, use calculation for count for large ms)
Hmm yeah i'm just wondering now why i did not think about that sooner ^^
just use passive cpu loop wait in every case, even for ticks... actually it will be even more accurate this way !
Well, i'll reopen the issue i just closed :p
Chilly Willy
Very interested
Posts: 2993
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy »

Well, I was thinking this is just an old console - no reason to worry about busy looping. How many people have accelerated 68000s in their MD? Being able to use "bad" programming makes things easy. :lol:
sega16
Very interested
Posts: 251
Joined: Sat Jan 29, 2011 3:16 pm
Location: U.S.A.

Post by sega16 »

Stef wrote:He really nice ! I am impatient to see the final result :)
The megadrive is really not designed to do bitmap drawing so it's always impressive to get that sort of effect out of it.
Did you saw the cube 3D sample ? I initially had a gouraud shaded version of it sometime ago but gouraud shading do not look really good with MD palette so i only keep flat shaded version.
Speaking of the cube demo how are the mesh values calculated is there some kind of converter for a model format?
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef »

oh no absolutly not :p
I just use a table of vertices and as we are anyway *very* limited for the number of vertices i think there is no really need of any model standard ;)
sega16
Very interested
Posts: 251
Joined: Sat Jan 29, 2011 3:16 pm
Location: U.S.A.

Post by sega16 »

I still don't understand the format in meshes.c
usually in 3d rendering there are many polygons and polygons are all made up of triangles so why not just store everything in triangles maybe something like this

Code: Select all

	1


2		3
1x,1y,1z,2x,2y,2z,3x,3y,3z

well I guess I have some work to do......
Chilly Willy
Very interested
Posts: 2993
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy »

From math.h

Code: Select all

/**
 *  \struct Vect3D_f16
 *      3D Vector structure - f16 (fix16) type.
 */
typedef struct
{
    fix16 x;
    fix16 y;
    fix16 z;
} Vect3D_f16;
and from meshs.c

Code: Select all

//    CUBE
//
//    7----6
//   /|   /|
//  3-+--2 |
//  | |  | |
//  | 4--+-5
//  |/   |/
//  0----1

const Vect3D_f16 cube_coord[8] =
{
    {intToFix16(-1), intToFix16(-1), intToFix16(-1)},
    {intToFix16(1), intToFix16(-1), intToFix16(-1)},
    {intToFix16(1), intToFix16(1), intToFix16(-1)},
    {intToFix16(-1), intToFix16(1), intToFix16(-1)},
    {intToFix16(-1), intToFix16(-1), intToFix16(1)},
    {intToFix16(1), intToFix16(-1), intToFix16(1)},
    {intToFix16(1), intToFix16(1), intToFix16(1)},
    {intToFix16(-1), intToFix16(1), intToFix16(1)}
};
So it's obviously x/y/z on each line, and the line # corresponds to the numbers in the ascii image in the comment.
bioloid
Very interested
Posts: 184
Joined: Fri May 18, 2012 8:22 pm

Post by bioloid »

sega16 wrote:I still don't understand the format in meshes.c
usually in 3d rendering there are many polygons and polygons are all made up of triangles so why not just store everything in triangles maybe something like this

Code: Select all

	1


2		3
1x,1y,1z,2x,2y,2z,3x,3y,3z

well I guess I have some work to do......
Well, there are at least two things:
- vertex array
- index array which refers the used vertice per poly
Like this vertice are transformed/projected only once, and so on for all vertex attributes, which is the case in the sgdk.
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef »

sega16 wrote:I still don't understand the format in meshes.c
usually in 3d rendering there are many polygons and polygons are all made up of triangles so why not just store everything in triangles maybe something like this

Code: Select all

	1


2		3
1x,1y,1z,2x,2y,2z,3x,3y,3z

well I guess I have some work to do......
Actually SGDK do not provide any 3D rendering capabilities, you just have 2D polygon drawing then you do whatever you want with it.
The meshs.c file contains severals tables which give all informations about the 3D cube. As said bioloid, you have the vertex array which contains points coordinates then index array which contains vertex index to define polygon or whatever.

When you have flat rendering i use this index table :

Code: Select all

cube_poly_ind[6 * 4] =
{
    7, 4, 5, 6,
    0, 3, 2, 1,
    3, 7, 6, 2,
    4, 0, 1, 5,
    1, 2, 6, 5,
    4, 7, 3, 0
};
To define quad polygon and draw them.
Why i use quad instead of triangle ? Just because it's faster :p
I actually have less edge calculation by drawing quad there.

When i draw in wireframe (enable with START key) i use this index table :

Code: Select all

const u16 cube_line_ind[12 * 2] =
{
    0, 1,
    1, 2,
    2, 3,
    3, 0,
    4, 5,
    5, 6,
    6, 7,
    7, 4,
    0, 4,
    1, 5,
    2, 6,
    3, 7
};
to find line to draw.
Chilly Willy
Very interested
Posts: 2993
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy »

Well, no one complained about my last post on controller support, so I committed the code to the repo. GSDK now supports EA 4Way Play, Team Player, 3 button pads, 6 button pads, the MegaMouse, the Menacer, the Justifier, and the SEGA Sports Pad (SMS trackball controller).

The example program for reading all these things is in the joytest3 archive I posted, which I'll post here as well. I imagine that after controller support is finalized, an example will make it into the gsdk sample directory.

joytest3.zip
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef »

Updated to version 0.92, Thanks again Chilly Willy for the better controller support :)
djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch »

I'll be testing it soon.

I did a quick check of the source. The new types for Echo support should be in a separate stdint.h file since the Echo code uses that header. I should've been more clear on what the changes required. Sorry about that.
Chilly Willy
Very interested
Posts: 2993
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy »

Stef wrote:Updated to version 0.92, Thanks again Chilly Willy for the better controller support :)
You're welcome... I'll work on those "network" thingys next (probably). I've got both the ZT cable, and KRIKzz's USB link devices.
bioloid
Very interested
Posts: 184
Joined: Fri May 18, 2012 8:22 pm

Post by bioloid »

"ld: address 0x5aa7fc of out/rom.out section .text is not within region rom"

Just to be sure, is there different max rom size setup or it's reaching the true maximum limit ?
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef »

You are limited to 4 MB then you have to use bank switch... unfortunately SGDK does not permit to do > 4MB rom even with bank switch because of the strict limitation in the md.ld file.
From your log you are trying to use 5941244 bytes of data.
bioloid
Very interested
Posts: 184
Joined: Fri May 18, 2012 8:22 pm

Post by bioloid »

Ok, thanks ! 4Mb should be enough!
Post Reply