splash screen for homebrew warning

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.
Post Reply
reaper2k2
DC Developer
DC Developer
Posts: 2648
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Sun Mar 24, 2002 7:48 pm
Has thanked: 0
Been thanked: 0
Contact:

splash screen for homebrew warning

Post by reaper2k2 »

any one got a simple bit of code to display a png on a timer

so say 5 sec then go on to yout program ive got one but it dont work

i cant get it working to my liking

Code: Select all

#include <kos.h>
#include <png/png.h>









pvr_ptr_t splash_tex;

/* draw background */
void draw_splash(void)
{
    pvr_poly_cxt_t cxt;
    pvr_poly_hdr_t hdr;
    pvr_vertex_t vert;

    pvr_poly_cxt_txr(&cxt, PVR_LIST_OP_POLY, PVR_TXRFMT_RGB565, 256, 256, splash_tex, PVR_FILTER_BILINEAR);
    pvr_poly_compile(&hdr, &cxt);
    pvr_prim(&hdr, sizeof(hdr));

    vert.argb = PVR_PACK_COLOR(1.0f, 1.0f, 1.0f, 1.0f);    
    vert.oargb = 0;
    vert.flags = PVR_CMD_VERTEX;
    
    vert.x = 1;
    vert.y = 1;
    vert.z = 1;
    vert.u = 0.0;
    vert.v = 0.0;
    pvr_prim(&vert, sizeof(vert));
    
    vert.x = 640;
    vert.y = 1;
    vert.z = 1;
    vert.u = 1.0;
    vert.v = 0.0;
    pvr_prim(&vert, sizeof(vert));
    
    vert.x = 1;
    vert.y = 480;
    vert.z = 1;
    vert.u = 0.0;
    vert.v = 1.0;
    pvr_prim(&vert, sizeof(vert));
    
    vert.x = 640;
    vert.y = 480;
    vert.z = 1;
    vert.u = 1.0;
    vert.v = 1.0;
    vert.flags = PVR_CMD_VERTEX_EOL;
    pvr_prim(&vert, sizeof(vert));
}

//main functions 

int main (int argc, char **argv)
{


	/* Draws splashscreen */    
    splash_tex = pvr_mem_malloc(256*256*2);
    png_to_texture("/cd/1.png", splash_tex, PNG_NO_ALPHA);
    
       pvr_wait_ready();
    pvr_scene_begin();
    
    pvr_list_begin(PVR_LIST_OP_POLY);
    draw_splash();
    pvr_list_finish();
    pvr_scene_finish();

    pvr_wait_ready();	/* Flip screen to first buffer */
    pvr_scene_begin();
    pvr_scene_finish();

	timer_spin_sleep(2000000);
	pvr_mem_free(splash_tex);
	
		return 0;
}
i need to start puting up a screen saying its freeware dont buy it ETC as i was told some people are selling some of the stuff i put out

thanks :D
http://homebrew.dcemulation.com/dcgames/ *homebrew webbrowser games *

http://r2k2gate.topcities.com *dev site and my releases*
Image
Im' a Commodorian are you?
User avatar
toastman
Iron Fist of Justice
Iron Fist of Justice
Posts: 4933
Joined: Sat Nov 10, 2001 3:08 am
Location: New Orleans
Has thanked: 0
Been thanked: 0
Contact:

Post by toastman »

timer_spin_sleep(int milliseconds)

It will pause execution of the program for the amount of time requested.
The vram should remain constant.
No signature.
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Post by BlackAura »

This should work (as long as I've not made a typo) - it's a butchered version of the PNG example.

Code: Select all

#include <kos.h>
#include <png/png.h>

static pvr_ptr_t back_tex;

static void draw_splash(float fadevalue)
{
    pvr_poly_cxt_t cxt;
    pvr_poly_hdr_t hdr;
    pvr_vertex_t vert;

    pvr_wait_ready();
    pvr_scene_begin();
    pvr_list_begin(PVR_LIST_OP_POLY);
    
    pvr_poly_cxt_txr(&cxt, PVR_LIST_OP_POLY, PVR_TXRFMT_RGB565, 512, 512, back_tex, PVR_FILTER_BILINEAR);
    pvr_poly_compile(&hdr, &cxt);
    pvr_prim(&hdr, sizeof(hdr));

    vert.argb = PVR_PACK_COLOR(fadevalue, fadevalue, fadevalue, 1.0f);    
    vert.oargb = 0;
    vert.flags = PVR_CMD_VERTEX;
    
    vert.x = 1;
    vert.y = 1;
    vert.z = 1;
    vert.u = 0.0;
    vert.v = 0.0;
    pvr_prim(&vert, sizeof(vert));
    
    vert.x = 640;
    vert.y = 1;
    vert.z = 1;
    vert.u = 1.0;
    vert.v = 0.0;
    pvr_prim(&vert, sizeof(vert));
    
    vert.x = 1;
    vert.y = 480;
    vert.z = 1;
    vert.u = 0.0;
    vert.v = 1.0;
    pvr_prim(&vert, sizeof(vert));
    
    vert.x = 640;
    vert.y = 480;
    vert.z = 1;
    vert.u = 1.0;
    vert.v = 1.0;
    vert.flags = PVR_CMD_VERTEX_EOL;
    pvr_prim(&vert, sizeof(vert));

    pvr_list_finish();
    pvr_list_begin(PVR_LIST_TR_POLY);
    pvr_list_finish();
    pvr_scene_finish();
}

void hbsplash_draw(void)
{
	float i;

	// Init everything
    pvr_init_defaults();      
    back_tex = pvr_mem_malloc(512*512*2);
    png_to_texture("/rd/hbsplash.png", back_tex, PNG_NO_ALPHA);
 
	// Fade in
	for(i = 0.0f; i < 1.0f; i += 0.05f)
	{
		draw_frame(i);
		timer_spin_sleep(100);
	}

	// Show for 5 seconds
	draw_frame(1.0f);
	timer_spin_sleep(5000);

	// Fade out
	for(i = 1.0f; i > 0.0f; i -= 0.05f)
	{
		draw_frame(i);
		timer_spin_sleep(100);
	}
    
	return 0;
}
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Post by BlueCrab »

Or you could do your splash screen in SDL, like so (this is taken from the game I'm writing)

Code: Select all

#include "SDL.h"
int main(int argc, char *argv[])	{
	uint32 flags = SDL_HWSURFACE | SDL_DOUBLEBUF;
	SDL_Surface * screen, * image;

	if(SDL_Init(SDL_INIT_VIDEO) < 0)	{
		return -1;
	}

	/* Set our video mode to 640x480 16bpp */
	screen = SDL_SetVideoMode(640, 480, 16, flags);

/* This stuff, right now, is only applicable to the DC version. */
#ifdef _arch_dreamcast

	/* Load up disclaimer */
	image = SDL_LoadBMP("/cd/images/discl.bmp");

	/* Put up the Disclaimer */
	SDL_BlitSurface(image, NULL, screen, NULL);
	SDL_Flip(screen);

	SDL_Delay(20000);

	/* Get rid of the image */
	SDL_FreeSurface(image);

#endif

/* put the rest of your game here, of course, in different functions */
	return 0;
}
And that's it. Of course you could experiment with SDL_image, and get other types to work, I've gotten PNG to work, and thats all I need, I'll post the modified SDL_image sometime, probably after I finish my homework.

Later.
reaper2k2
DC Developer
DC Developer
Posts: 2648
Joined: Sun Mar 24, 2002 7:48 pm
Has thanked: 0
Been thanked: 0
Contact:

hi

Post by reaper2k2 »

Code: Select all

ernel/arch/dreamcast/include -c example.c -o example.o
example.c: In function `hbsplash_draw':
example.c:71: warning: implicit declaration of function `draw_frame'
example.c:86: warning: `return' with a value, in function returning void
example.c: At top level:
example.c:7: warning: `draw_splash' defined but not used
/usr/local/dc/kos/utils/genromfs/genromfs -f romdisk_boot.img -d romdisk_boot -v
0    rom 3e184e3e         [0xffffffff, 0xffffffff] 37777777777, sz     0, at 0x0
1    .                    [0x2ee9    , 0x9c0c355f] 0040755, sz     0, at 0x20
1    ..                   [0x2ee9    , 0xc5c2af21] 0040755, sz     0, at 0x40     [lin
k to 0x20    ]
1    Thumbs.db            [0x2ee9    , 0xb0a0c872] 0100644, sz 19456, at 0x60
1    1.png                [0x2ee9    , 0x4e87662f] 0100644, sz 37800, at 0x4c80
/usr/local/dc/kos/utils/bin2o/bin2o romdisk_boot.img romdisk_boot romdisk_boot.o
/usr/local/dc/sh-elf/bin/sh-elf-gcc -Wall -g -ml -m4-single-only -O1     -ml -m4-singl
e-only -nostartfiles -nostdlib -Wl,-Ttext=0x8c010000 -L/usr/local/dc/kos/lib -o exampl
e.elf /usr/local/dc/kos/kernel/arch/dreamcast/kernel/startup.o example.o romdisk_boot.
o -lpng -lz -lm -lkallisti -lgcc
example.o: In function `hbsplash_draw':
/usr/local/dc/kos/examples/dreamcast/png/example.c:87: undefined reference to `draw_fr
ame'
/usr/local/dc/kos/lib/libkallisti.a(main.o): In function `arch_main':
/usr/local/dc/kos/kernel/arch/dreamcast/kernel/main.c:135: undefined reference to `mai
n'
collect2: ld returned 1 exit status
make: *** [example.elf] Error 1
is what i got i think some thing is acting up not sure

ive not tryed any think with it yet just typed make

and it gave me those errors im sure its nothing to do with you
http://homebrew.dcemulation.com/dcgames/ *homebrew webbrowser games *

http://r2k2gate.topcities.com *dev site and my releases*
Image
Im' a Commodorian are you?
reaper2k2
DC Developer
DC Developer
Posts: 2648
Joined: Sun Mar 24, 2002 7:48 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by reaper2k2 »

BLUE CRAB splash screen
small edit by reaper2k2


Code: Select all

#include "SDL.h" 
int main(int argc, char *argv[])   { 
   uint32 flags = (SDL_HWSURFACE|SDL_FULLSCREEN); //i changed this
   SDL_Surface * screen, * image; 

   if(SDL_Init(SDL_INIT_VIDEO) < 0)   { 
      return -1; 
   } 

   /* Set our video mode to 640x480 16bpp */ 
   screen = SDL_SetVideoMode(640, 480, 16, flags); 

/* This stuff, right now, is only applicable to the DC version. */ 
#ifdef _arch_dreamcast 

   /* Load up disclaimer */ 
   image = SDL_LoadBMP("/cd/splash.bmp"); 

   /* Put up the Disclaimer */ 
   SDL_BlitSurface(image, NULL, screen, NULL); 
   SDL_Flip(screen); 

   SDL_Delay(200000); 

   /* Get rid of the image */ 
   SDL_FreeSurface(image); 

#endif 

/* put the rest of your game here, of course, in different functions */ 
   return 0; 
}
only one error i fixed that might be my system only but it compiles with no errors now works nice!
http://homebrew.dcemulation.com/dcgames/ *homebrew webbrowser games *

http://r2k2gate.topcities.com *dev site and my releases*
Image
Im' a Commodorian are you?
reaper2k2
DC Developer
DC Developer
Posts: 2648
Joined: Sun Mar 24, 2002 7:48 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by reaper2k2 »

can we some how display this screen then and play a modfile with the modplug example but make it turn off when the screen goes out the music goes off

i had this some what working but the sound in my main program is then messed up

im asking this because i dont know if kos lets this happen every time i say turn on a s3m file then int anther sound system the next one after the s3m or mod is just static ..

wow its 341 am lol
http://homebrew.dcemulation.com/dcgames/ *homebrew webbrowser games *

http://r2k2gate.topcities.com *dev site and my releases*
Image
Im' a Commodorian are you?
User avatar
toastman
Iron Fist of Justice
Iron Fist of Justice
Posts: 4933
Joined: Sat Nov 10, 2001 3:08 am
Location: New Orleans
Has thanked: 0
Been thanked: 0
Contact:

Post by toastman »

Oh sure, let's all jump on the easy question. ;)
No signature.
reaper2k2
DC Developer
DC Developer
Posts: 2648
Joined: Sun Mar 24, 2002 7:48 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by reaper2k2 »

JUST to let you guys know its now working ive put this in mame i used SDL as i find it easyer to grasp it

thanks a million THIS is GREAT make the single game mame releases look nice
http://homebrew.dcemulation.com/dcgames/ *homebrew webbrowser games *

http://r2k2gate.topcities.com *dev site and my releases*
Image
Im' a Commodorian are you?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Post by BlueCrab »

You're welcome. I wish you luck.
reaper2k2
DC Developer
DC Developer
Posts: 2648
Joined: Sun Mar 24, 2002 7:48 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by reaper2k2 »

IVE got your name in the credits in the 2ND splash screen after the first one which has now turned into a themable title screen

so its like a old skool c64 demo allmost hee

look NIIIIIIIICE
http://homebrew.dcemulation.com/dcgames/ *homebrew webbrowser games *

http://r2k2gate.topcities.com *dev site and my releases*
Image
Im' a Commodorian are you?
dragonsimoto
DC Developer
DC Developer
Posts: 78
Joined: Wed Oct 17, 2001 7:44 pm
Location: USA
Has thanked: 0
Been thanked: 0
Contact:

Post by dragonsimoto »

look at the .h for the sound system your using.. Ive havent programmed dc for months but i know Dan has a s3m_init(); type function then s3m_play(file); then s3m_pause||s3m_stop()||s3m_kill(); Take a look at that... should solve your problems.

As for the splash, i did have mine for my 2d fighter i started... worked great but i believe i lost it in a repartitioning...but you got it working so good luck.
"If your a 'tard use the pictures on the left for navigation."

<img src="http://www.caskam.com/images/plan9avatar.gif"></img>
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Post by BlackAura »

Reaper - I made a slight typo in my code. draw_frame() should have been draw_splash(). :oops:

As for the sound thing, you could use the Modplug library, and the sound system you use in MAME to play a MOD file. I have some code to do that with KOS's sound system, which you could use for the intro, then switch the KOS sound system off, and then activate the MAME sound system. That should work.
reaper2k2
DC Developer
DC Developer
Posts: 2648
Joined: Sun Mar 24, 2002 7:48 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by reaper2k2 »

OK ill have to try get that working one time im just awake lol so just browser at the moment cygwin is turned off for the moment
http://homebrew.dcemulation.com/dcgames/ *homebrew webbrowser games *

http://r2k2gate.topcities.com *dev site and my releases*
Image
Im' a Commodorian are you?
Post Reply