⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 disclaimer.c

📁 DC的SEGA_GG模拟器源代码
💻 C
字号:
/* KallistiOS 0.80

   disclaimer.c
   (c)2001 Dan Potter

   Moded for use with Libdream and SMS Plus!

*/

//static char id[] = "KOS $Id: disclaimer.c,v 1.1 2001/02/05 04:17:04 bard Exp $";

/* If you make a CD bootable image, you'll want to enable a disclaimer such
   as this one to tell the users that this program was not made or endorsed
   by Sega. You can consider this a required practice as far as making
   hobbyist productions goes. If you are only using this for yourself or
   you are just developing, then there's no point of course. Just make sure
   it's enable somewhere before you distribute a bootable image. */

//#include <kallisti/thread.h>
//#include <kallisti/ta.h>
//#include <kallisti/biosfont.h>
#include <dream.h>
#include <ta.h>

static uint32 txr_alloc_base;
uint32 ta_txr_allocate(uint32 size);
void ta_poly_hdr_col(poly_hdr_t *target, int translucent);
void ta_txr_release_all();


/* Builds a little disclaimer texture (easier than doing a bunch of font
   polygons) */
static uint32 disc_txr;
static void disc_texture() {
	uint16	*txrtmp;
        int     i, x, y = (480 - 9*24)/2;
        char    *msg[] = {
"This program is a hobbyist production",
"and was not actually produced by or",
"under license from Sega",
"Enterprises(tm). It was produced",
"using the KallistiOS operating system",
"from Cryptic Allusion. For more",
"information, please visit",
"",
"http://www.allusion.net/dcdev/"
        };
/*
        int     i, x, y = (480 - 9*32)/2;
        char *msg[] = {
"This program is not licensed by",
"warrented by, or associated in any",
"other way with Sega Enterprises, Ltd.",
"",
"This program is not to be sold, if",
"you purchased this program then",
"contact me as soon as possible.",
"",
"http://devcast.dcemulation.com/"
        };*/
serial_printf("1\n");
	/* Allocate texture space */
	disc_txr = ta_txr_allocate(512*512*2);
//        txrtmp = (uint16*)ta_txr_map(disc_txr);
//        txrtmp = (uint16*)ta_texture_map(disc_txr);
        txrtmp = (uint16*)0xa4000000 + disc_txr;

	/* Draw a message into it */
	for (i=0; i<9; i++) {
		x = 256 - (strlen(msg[i]) * 12)/2;
//                bfont_draw_str(txrtmp + y*512+x, 512, 0, msg[i]);
                bfont_draw_str(txrtmp + y*512+x, 512, msg[i]);
		y += 25;
	}
serial_printf("2\n");
}

static void disc_display(float fade) {
	vertex_ot_t	v;
	poly_hdr_t	hdr;

	if (fade < 0.0f) fade = 0.0f;

//        ta_poly_hdr_txr(&hdr, TA_OPAQUE, TA_RGB565, 512, 512, disc_txr, TA_NO_FILTER);
        ta_build_poly_hdr(&hdr, TA_OPAQUE, TA_RGB565, 512, 512, disc_txr, TA_NO_FILTER);
	ta_commit_poly_hdr(&hdr);

	/* - -
	   + - */
	v.flags = TA_VERTEX_NORMAL;
	v.x = 64.0f;
	v.y = 480.0f;
	v.z = 1.0f;
	v.u = 0.0f; v.v = 480.0f/512.0f;
	v.a = 1.0f; v.r = v.g = v.b = fade;
	v.oa = v.or = v.og = v.ob = 0.0f;
	ta_commit_vertex(&v, sizeof(v));

	/* + -
	   - - */
	v.y = 0.0f;
	v.v = 0.0f;
	ta_commit_vertex(&v, sizeof(v));

	/* - -
	   - + */
	v.x = 640.0f - 64.0f;
	v.y = 480.0f;
	v.u = 1.0f; v.v = 480.0f / 512.0f;
	ta_commit_vertex(&v, sizeof(v));

	/* - +
	   - - */
	v.flags = TA_VERTEX_EOL;
	v.y = 0.0f;
	v.v = 0.0f;
	ta_commit_vertex(&v, sizeof(v));
}

static void disc_blank() {
	poly_hdr_t	hdr;

	ta_poly_hdr_col(&hdr, TA_TRANSLUCENT);
	ta_commit_poly_hdr(&hdr);
}

void disclaimer() {
	float f;
	
	/* Setup the texture */
	disc_texture();

	/* Fade in the disclaimer */
	for (f=0.0f; f<1.0f; f+=0.01f) {
		ta_begin_render();
		disc_display(f);
		ta_commit_eol();
		disc_blank();
		ta_commit_eol();
		ta_finish_frame();
	}

	/* Pause */
	for (f=0.0f; f<360.0f; f+=1.0f) {
		ta_begin_render();
		disc_display(1.0f);
		ta_commit_eol();
		disc_blank();
		ta_commit_eol();
		ta_finish_frame();
	}

	/* Fade out the disclaimer */
	for (f=1.0f; f>=-0.03f; f-=0.01f) {
		ta_begin_render();
		disc_display(f);
		ta_commit_eol();
		disc_blank();
		ta_commit_eol();
		ta_finish_frame();
	}

	/* Free up the texture RAM */
	ta_txr_release_all();
}

/* Allocate space for a texture of the given size; the returned value
   must still be run through ta_txr_map() to get the proper address. */
uint32 ta_txr_allocate(uint32 size) {
	uint32 rv;

	rv = txr_alloc_base;
	if (size % 16)
		size = (size & 0xfff0) + 0x10;
	txr_alloc_base += size;
	return rv;
}

/* Build a polygon header from the given parameters; this is pretty
   incomplete right now but it's better than having to do it by hand. */
void ta_poly_hdr_col(poly_hdr_t *target, int translucent) {
	if (!translucent) {
		target->flags1 = 0x80840012;
		target->flags2 = 0x90800000;
		target->flags3 = 0x20800440;
		target->flags4 = 0x00000000;
		target->dummy1 = target->dummy2
			= target->dummy3 = target->dummy4 = 0xffffffff;
	} else  {
		target->flags1 = 0x82840012;
		target->flags2 = 0x90800000;
		target->flags3 = 0x949004c0;
		target->flags4 = 0x00000000;
		target->dummy1 = target->dummy2
			= target->dummy3 = target->dummy4 = 0xffffffff;
	}
}

/* Release all allocated texture space (start at zero) */
void ta_txr_release_all() {
	txr_alloc_base = 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -