EpicAsian's Dreamcast Endeavours:D

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
User avatar
epicasian
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 23
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Fri Mar 26, 2010 8:34 pm
Location: WoFoCo, KY
Has thanked: 0
Been thanked: 0

EpicAsian's Dreamcast Endeavours:D

Post by epicasian »

I've been wondering if it is there is a port of Box2D on Dreamcast. One of my upcoming projects is physics based, and I would love to port it to the Dreamcast. The only problem I see with Box2D on the Dreamcast is the floating point math calculations. Also, if you guys know, is Box2D more optimized than Chipmunk (or vice versa)?

Thanks in advance.
Last edited by epicasian on Fri Oct 22, 2010 10:13 pm, edited 1 time in total.
Image
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Box2D on Dreamcast?

Post by BlueCrab »

I've certainly never seen a port of it (in fact, I'd never heard of it until I saw this topic). That said, the only way to find out if it'll work is to try.

For its time, the Dreamcast was pretty good at floating-point stuff, just make sure you stick to single-precision mode (which, if you're using the default way the toolchain is built and all, should be the case always because of -m4-single-only).
User avatar
epicasian
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 23
Joined: Fri Mar 26, 2010 8:34 pm
Location: WoFoCo, KY
Has thanked: 0
Been thanked: 0

Re: Box2D on Dreamcast?

Post by epicasian »

The only reason I was somewhat worried, is because when Box2D was ported to the 360, the performance started chugging at about 10-20 active physics objects. And I'm changing this thread to my DC dev questions thread, since I'm going to have a lot of them.

I also have another question. I'm trying to learn how to link a texture to a polygon; so I was looking through pvr.h and the data types. I saw something about a polygon header, what's that? Also, by using the pvr_vertex_t type, can I link/bind a texture to that? Where would I find the info on how to do that?

Sorry if I seem like a complete and utter moron, I just really want to learn how to make DC games.

Thanks for all for your help:D
Image
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: EpicAsian's Dreamcast Endeavours:D

Post by BlueCrab »

Well, if the performance was that bad on the 360, I would expect it to be quite awful on the Dreamcast. I didn't look too closely at it to have any sort of real opinion...

As for texturing, take a look at the png example for the simplest look at texturing. You might also find the pvr/texture_render example to be a good place to look too (although, the part where its rendering to a texture in that might be a bit confusing).
User avatar
epicasian
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 23
Joined: Fri Mar 26, 2010 8:34 pm
Location: WoFoCo, KY
Has thanked: 0
Been thanked: 0

Re: EpicAsian's Dreamcast Endeavours:D

Post by epicasian »

When I looked at the texture_render example, all I saw was the code coloring the vertices; I didn't see loading an image and applying it to a poly.

I successfully took the code from the png example, and created a basic player class with the coordinates, texture, and functions to draw, update and take input. The only input I currently know how to take, is the DPAD, and the A, B, X, and Y buttons. Where would I find how to use the analog stick?

Also, where would I find how to load from a spritesheet, and use a selected frame?

And does KOS/PVR need something to regulate framerate?

Thanks again,
Image
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: EpicAsian's Dreamcast Endeavours:D

Post by BlueCrab »

epicasian wrote:When I looked at the texture_render example, all I saw was the code coloring the vertices; I didn't see loading an image and applying it to a poly.
The texture_render example actually has the PVR render to a texture, and then applies that to the polygons when its activated (so it doesn't load a file off the disc).
I successfully took the code from the png example, and created a basic player class with the coordinates, texture, and functions to draw, update and take input. The only input I currently know how to take, is the DPAD, and the A, B, X, and Y buttons. Where would I find how to use the analog stick?
If you know how to do the dpad and normal buttons, the rest is easy. The cont_state_t structure you should be using for that also has stuff about the analog sticks in (joyx and joyy, I believe). Negative values for that mean either left (joyx) or up (joyy), positive is right (joyx) or down (joyy). I believe the range is from -128 to 127, but I'm not entirely positive on that (I haven't looked in a while and this is all from memory).
Also, where would I find how to load from a spritesheet, and use a selected frame?
Usually you'd use the U/V coordinates in the pvr_vertex_t structure to deal with that. U goes from 0-1.0 from left to right, and V goes from 0-1.0 from top to bottom. Basically, if you had an 8 frame by 8 frame grid of sprite frames, each one would be 0.125 on that scale. So for the 2nd row, 3rd column, you'd specify the following U/V coordinates: top-left: (0.25, 0.125), top-right: (0.375, 0.125), bottom-left: (0.25, 0.25), bottom-right: (0.375, 0.25). I would recommend that if you're going to have any blank areas in your spritesheet, you look into splitting things up into individual files per frame instead. You'd end up wasting quite a bit of space otherwise (you only have a bit over 4MB to work with for textures, so keep things reasonable).
And does KOS/PVR need something to regulate framerate?
As long as you're using pvr_wait_ready() before your pvr_scene_begin(), you shouldn't have to worry about it.
Thanks again,
No problem.
User avatar
epicasian
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 23
Joined: Fri Mar 26, 2010 8:34 pm
Location: WoFoCo, KY
Has thanked: 0
Been thanked: 0

Re: EpicAsian's Dreamcast Endeavours:D

Post by epicasian »

So basically all I would have to do for animated sprites, is change the U/V values with a timer?

What about multiple controllers? I've seen this post:
viewtopic.php?f=29&t=27922

And would this be the correct way to assign controller 2:

Code: Select all

maple_device_t *cont2_addr;
cont_state_t *cont2_status;

//The first number is the port and the second the unit.
//This will get you the second controller.
cont2_addr = maple_enum_dev(1, 0);

if(cont2_addr->buttons & CONT_A)
      doEpicStuff();
Also, how do you go about hardware texture compressing?

EdiT:: If I load a romdisk, and I have over 4 megs of data "on" it, will it occupy that memory? Or do I have to "use" the data before it takes up memory?

EdIt2:: What about accessories like the rumble pack? or the VMU?
Image
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: EpicAsian's Dreamcast Endeavours:D

Post by BlueCrab »

epicasian wrote:So basically all I would have to do for animated sprites, is change the U/V values with a timer?
Basically, yeah.
What about multiple controllers? I've seen this post:
viewtopic.php?f=29&t=27922

And would this be the correct way to assign controller 2:

Code: Select all

maple_device_t *cont2_addr;
cont_state_t *cont2_status;

//The first number is the port and the second the unit.
//This will get you the second controller.
cont2_addr = maple_enum_dev(1, 0);

if(cont2_addr->buttons & CONT_A)
      doEpicStuff();
Well, I'd recommend using maple_enum_type instead of maple_enum_dev... It'll work regardless of what port the controllers are in:

Code: Select all

maple_device_t *dev1, *dev2;
dev1 = maple_enum_type(0, MAPLE_FUNC_CONTROLLER);
dev2 = maple_enum_type(1, MAPLE_FUNC_CONTROLLER);
Then of course you'd get the status from maple_dev_status() passing whatever controller you want the status for.
Also, how do you go about hardware texture compressing?
KOS includes a program to do it in the utils.
EdiT:: If I load a romdisk, and I have over 4 megs of data "on" it, will it occupy that memory? Or do I have to "use" the data before it takes up memory?
The romdisk goes in RAM. Until you load the file up with the texture and have it copy into the video ram, you're not using up any of the texture space.
EdIt2:: What about accessories like the rumble pack? or the VMU?
There are plenty of topics around about various accessories... The VMU (for saving) you just access like any other file... Just remember that VMU saves need to have the VMU file header on them (which KOS has functions for filling in and the like). As for the rumble pack, take a look at the kos/kernel/arch/dreamcast/include/dc/maple/purupuru.h file for more information (or take a look around here, since I know there's been topics about it in the recentish past).
User avatar
epicasian
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 23
Joined: Fri Mar 26, 2010 8:34 pm
Location: WoFoCo, KY
Has thanked: 0
Been thanked: 0

Re: EpicAsian's Dreamcast Endeavours:D

Post by epicasian »

I've tried mucking around with the rumble pack, and every time I call purupuru_rumble(), I get a freeze or a crash.

Here is my code that uses the purupuru:

Code: Select all

        maple_device_t* myPuru;
	purupuru_effect_t* effect;

        myPuru = maple_enum_type(0, MAPLE_FUNC_PURUPURU);
		effect->duration = 255;
		effect->effect2 = PURUPURU_EFFECT2_LINTENSITY(7)
                    | PURUPURU_EFFECT2_PULSE;;
		effect->effect1 = PURUPURU_EFFECT1_INTENSITY(7)
                    | PURUPURU_EFFECT1_PULSE;
		effect->special = PURUPURU_SPECIAL_MOTOR1 | PURUPURU_SPECIAL_PULSE;
        purupuru_rumble(myPuru, effect);
Image
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: EpicAsian's Dreamcast Endeavours:D

Post by BlueCrab »

You're writing to a pointer that hasn't been initialized to anything (namely your effect pointer there).

Change the purupuru_effect_t *effect; to remove the pointer, fix all the structure references (so change the -> to .), and change the purupuru_rumble like so: purupuru_rumble(myPuru, &effect);

That should make it at least not crash.

I'd recommend reading up a bit more on how pointers and such work in C. You'll run into lots of pointers when dealing with any sort of non-trivial C program, and knowing how these things work will help you not run into such problems later when they'll be a whole lot more difficult to trace. :wink:

Pointers are one of those things that are awesome to deal with when you know what you're doing, but quite a pain to debug when something goes horribly wrong (especially when you have no memory protection like on the Dreamcast with KOS).
User avatar
epicasian
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 23
Joined: Fri Mar 26, 2010 8:34 pm
Location: WoFoCo, KY
Has thanked: 0
Been thanked: 0

Re: EpicAsian's Dreamcast Endeavours:D

Post by epicasian »

I did some more messing around and finally got it to work. The reason why it was crashing was because one of my purupurus that I was testing was dead.
Image
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: EpicAsian's Dreamcast Endeavours:D

Post by BlueCrab »

epicasian wrote:I did some more messing around and finally got it to work. The reason why it was crashing was because one of my purupurus that I was testing was dead.
I don't think (in theory anyway) that that should make it crash. The purupuru would have to send back some really wonky responses to make that happen, I'd think.
User avatar
epicasian
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 23
Joined: Fri Mar 26, 2010 8:34 pm
Location: WoFoCo, KY
Has thanked: 0
Been thanked: 0

Re: EpicAsian's Dreamcast Endeavours:D

Post by epicasian »

How would I "uninitialized" a KOS Romdisk to remove it from memory so that I can initialize another?

Would I do something like:

Code: Select all

...
KOS_INIT_ROMDISK(romdisk_boot);
...
KOS_INIT_ROMDISK(NULL);
...
KOS_INIT_ROMDISK(LevelOneRomdisk);
...
Edit: Also, what util is used for texture compressing?

And is there any way to split the screen into two halves?

EdIT::And what about about *.PNGs and transparencies?
Image
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: EpicAsian's Dreamcast Endeavours:D

Post by BlueCrab »

epicasian wrote:How would I "uninitialized" a KOS Romdisk to remove it from memory so that I can initialize another?

Would I do something like:

Code: Select all

...
KOS_INIT_ROMDISK(romdisk_boot);
...
KOS_INIT_ROMDISK(NULL);
...
KOS_INIT_ROMDISK(LevelOneRomdisk);
...
You wouldn't use the KOS_INIT_ROMDISK if you want to be able to swap them out. What you would do is load the file up from somewhere with the data on it (for instance off of /cd), read the file into a block of memory allocated by malloc(), then use fs_romdisk_mount(). You can then unmount that romdisk by using fs_romdisk_unmount(). Both of them are documented in kos/include/kos/fs_romdisk.h .
Edit: Also, what util is used for texture compressing?
vqenc
And is there any way to split the screen into two halves?
I'm not sure what you mean by this? You simply draw to what you want to draw to. There's no real splitting needed.
EdIT::And what about about *.PNGs and transparencies?
They work just fine. Assuming you're using png_to_texture() as the example does, pass PNG_FULL_ALPHA instead of PNG_NO_ALPHA. Also, you'll have to change your PVR texture format to PVR_TXRFMT_ARGB4444 instead of PVR_TXRFMT_RGB565. See kos-ports/include/png/png.h and kos/kernel/arch/dreamcast/include/dc/pvr.h for more info if you need it.

Also, I recommend reading through the header files of KOS to look for stuff. Its the best/fastest way to figure out how to do things, and the headers are usually named pretty well (to help you figure out what ones to look at). I especially recommend reading through the PVR header (kos/kernel/arch/dreamcast/include/dc/pvr.h), as that one has a lot of stuff in it.
User avatar
epicasian
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 23
Joined: Fri Mar 26, 2010 8:34 pm
Location: WoFoCo, KY
Has thanked: 0
Been thanked: 0

Re: EpicAsian's Dreamcast Endeavours:D

Post by epicasian »

About my post on splitting the screen: Take for example if you were writing a 2 player game for the PC. This game is a sidescroller, and you want both players to use one keyboard. How would you (if you even can with the PVR) split the screen in half so that both players can have their own "virtual" screen. I'm asking this beause the way I'm designing an upcoming project, I would need to be able to split the screen for a short time. If this isn't possible, please let me know.

And thanks again, BlueCrab, for you help with all my noobish questions =D
Image
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: EpicAsian's Dreamcast Endeavours:D

Post by BlueCrab »

epicasian wrote:About my post on splitting the screen: Take for example if you were writing a 2 player game for the PC. This game is a sidescroller, and you want both players to use one keyboard. How would you (if you even can with the PVR) split the screen in half so that both players can have their own "virtual" screen. I'm asking this beause the way I'm designing an upcoming project, I would need to be able to split the screen for a short time. If this isn't possible, please let me know.
There's no concept of virtual screens in KOS. The PVR stuff sits directly on top of the hardware, after all. Its extremely easy to just draw each person's stuff to their half of the screen though (there's really no reason for a "virtual" screen as you describe it, in my opinion).
And thanks again, BlueCrab, for you help with all my noobish questions =D
No problem, all of us were noobs at one point or another. :wink: Just so happens I've had time to answer them (although I probably won't have so much free time this upcoming week, due to classes :| ).

One thing I forgot to mention about translucent things earlier... You have to use the PVR_LIST_TR_POLY to draw them (or PVR_LIST_PT_POLY if you want punchthrus instead of translucent things). This has to be both in the polygon header (as made with pvr_poly_cxt_txr/pvr_poly_cxt_col) and when actually drawing (you have to be drawing them between a pvr_list_begin(PVR_LIST_TR_POLY); and a pvr_list_finish(); ).
User avatar
epicasian
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 23
Joined: Fri Mar 26, 2010 8:34 pm
Location: WoFoCo, KY
Has thanked: 0
Been thanked: 0

Re: EpicAsian's Dreamcast Endeavours:D

Post by epicasian »

What's the difference between punch throughs and translucency? Also, I don't think you ever answered my question about what is a polygon header on one of the first few posts, lol.

Here is a really crappy representation of what I mean:
split screen.png
split screen.png (38.19 KiB) Viewed 2944 times
Image
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: EpicAsian's Dreamcast Endeavours:D

Post by BlueCrab »

epicasian wrote:What's the difference between punch throughs and translucency?
Punchthrus have only one level of transparency on a pixel. Either the pixel is opaque or its completely transparent (no middle ground). They, however, are faster for the hardware to render than translucent polygons (basically as fast as opaque ones).
Also, I don't think you ever answered my question about what is a polygon header on one of the first few posts, lol.
Well, a polygon header is what you send to the hardware to tell it about what the vertices you're going to send are for. It specifies the texture in use (if any), as well as a whole bunch of other parameters. There are several different polygon header and vertex types, but KOS only has support built-in for a limited subset of them (basically the most general ones).
Here is a really crappy representation of what I mean:
split screen.png
I'm still not sure how this requires any sort of special stuff... Like I said in the last post, it should be easy enough with a 2D game to simply do things like this:
1. Open Opaque list
2. Draw background for player 1 on left half of screen (as well as any other opaque parts for p1).
3. Draw background for player 2 on right half of screen (ditto on the parenthesis)
4. Close Opaque list, open translucent list.
5. Draw any translucent parts for p1 on the left half.
6. Draw any translucent parts for p2 on the right half.

I don't see how you need any special support to do that kind of stuff. You have complete control over where things draw by specifying X/Y/Z/U/V coordinates for all the polygons, so it should be really easy to do what I said. There's nothing that forces you to draw to the whole screen. Heck, you could just render on half the screen all day long if you wanted to and leave the other side completely blank. Its all in how you represent things in the end. You can do many things in designing to make such a "split-screen" type thing easier, but that's more of a game design problem than a pure programming thing.

Always come up with a good plan for what you want to do before you try to jump headlong into it. That's one thing I've learned about game programming from what I've done in the past.
nymus
DC Developer
DC Developer
Posts: 968
Joined: Tue Feb 11, 2003 4:12 pm
Location: In a Dream
Has thanked: 5 times
Been thanked: 5 times

Re: EpicAsian's Dreamcast Endeavours:D

Post by nymus »

Hi epicasian. Just a few suggestions if you haven't settled on a system. You could take a look at the Tsunami library which has a c++ wrapping around the texturing and animation work one might need. It was used in Feet of Fury.

As for the romdisk conundrum, you generally only need one romdisk for testing purposes. If you are looking to save some memory and load your files on-the-fly like a real game and assuming you have a BBA just design your directory structure as it would appear on a CD with the executable at the root, make an ISO of it and reference this structure in your code as "/cd" and use dcload's ISO redirection.
behold the mind
inspired by Dreamcast
User avatar
epicasian
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 23
Joined: Fri Mar 26, 2010 8:34 pm
Location: WoFoCo, KY
Has thanked: 0
Been thanked: 0

Re: EpicAsian's Dreamcast Endeavours:D

Post by epicasian »

@nymus I don't know how to explain this but, I feel as though I have more control if I use the lower level part of the library. Also, I can only afford to burn multisession CDs at the moment. If I can get my hand on one of the Chinese SD card adapters, I would be a lot more productive.

I'm currently trying to try to display a punchthrough image and am getting strange runtime errors. I change everything you told me to, BlueCrab but I still don't know what is going wrong. If and when you have time, could you look at my source and tell me what's wrong?

Here is the image:
http://i203.photobucket.com/albums/aa16 ... 1288145963

And here is the code:
http://pastebin.com/zAg7GR5k
Image
Image
Post Reply