homebrew game help

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

homebrew game help

Post by Rangu2057 »

im having more troubles in my homebrew game im making, im just having trouble compiling it right without any errors. Cany anyone please tell me what im doing wrong

makefile

Code: Select all

TARGET = DeathCoreV0.1
OBJS = graphics.o mp3player.o main.o

INCDIR = 
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)


BUILD_PRX=1
PSP_FW_VERSION=390

LIBDIR =
LIBS = -lpng -lpspgu -lz -lmad -lpspaudiolib -lpspaudio -lpsppower 
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = DeathCoreV0.1

PSP_EBOOT_ICON = icon0.png
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
graphics.c

Code: Select all

#include <stdlib.h>
#include <malloc.h>
#include <pspdisplay.h>
#include <psputils.h>
#include <png.h>
#include <pspgu.h>
#include <pspge.h>

#include "graphics.h"
#include "framebuffer.h"

#define IS_ALPHA&#40;color&#41; &#40;&#40;&#40;color&#41;&0xff000000&#41;==0xff000000?0&#58;1&#41;
#define FRAMEBUFFER_SIZE &#40;PSP_LINE_SIZE*SCREEN_HEIGHT*4&#41;
#define MAX&#40;X, Y&#41; &#40;&#40;X&#41; > &#40;Y&#41; ? &#40;X&#41; &#58; &#40;Y&#41;&#41;

typedef struct
&#123;
	unsigned short u, v;
	short x, y, z;
&#125; Vertex;

extern u8 msx&#91;&#93;;

unsigned int __attribute__&#40;&#40;aligned&#40;16&#41;&#41;&#41; list&#91;262144&#93;;
static int dispBufferNumber;
static int initialized = 0;

static int getNextPower2&#40;int width&#41;
&#123;
	int b = width;
	int n;
	for &#40;n = 0; b != 0; n++&#41; b >>= 1;
	b = 1 << n;
	if &#40;b == 2 * width&#41; b >>= 1;
	return b;
&#125;

Color* getVramDrawBuffer&#40;&#41;
&#123;
	Color* vram = &#40;Color*&#41; g_vram_base;
	if &#40;dispBufferNumber == 0&#41; vram += FRAMEBUFFER_SIZE / sizeof&#40;Color&#41;;
	return vram;
&#125;

Color* getVramDisplayBuffer&#40;&#41;
&#123;
	Color* vram = &#40;Color*&#41; g_vram_base;
	if &#40;dispBufferNumber == 1&#41; vram += FRAMEBUFFER_SIZE / sizeof&#40;Color&#41;;
	return vram;
&#125;

void user_warning_fn&#40;png_structp png_ptr, png_const_charp warning_msg&#41;
&#123;
&#125;

Image* loadImage&#40;const char* filename&#41;
&#123;
	png_structp png_ptr;
	png_infop info_ptr;
	unsigned int sig_read = 0;
	png_uint_32 width, height;
	int bit_depth, color_type, interlace_type, x, y;
	u32* line;
	FILE *fp;
	Image* image = &#40;Image*&#41; malloc&#40;sizeof&#40;Image&#41;&#41;;
	if &#40;!image&#41; return NULL;

	if &#40;&#40;fp = fopen&#40;filename, "rb"&#41;&#41; == NULL&#41; return NULL;
	png_ptr = png_create_read_struct&#40;PNG_LIBPNG_VER_STRING, NULL, NULL, NULL&#41;;
	if &#40;png_ptr == NULL&#41; &#123;
		free&#40;image&#41;;
		fclose&#40;fp&#41;;
		return NULL;;
	&#125;
	png_set_error_fn&#40;png_ptr, &#40;png_voidp&#41; NULL, &#40;png_error_ptr&#41; NULL, user_warning_fn&#41;;
	info_ptr = png_create_info_struct&#40;png_ptr&#41;;
	if &#40;info_ptr == NULL&#41; &#123;
		free&#40;image&#41;;
		fclose&#40;fp&#41;;
		png_destroy_read_struct&#40;&png_ptr, png_infopp_NULL, png_infopp_NULL&#41;;
		return NULL;
	&#125;
	png_init_io&#40;png_ptr, fp&#41;;
	png_set_sig_bytes&#40;png_ptr, sig_read&#41;;
	png_read_info&#40;png_ptr, info_ptr&#41;;
	png_get_IHDR&#40;png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, int_p_NULL, int_p_NULL&#41;;
	if &#40;width > 512 || height > 512&#41; &#123;
		free&#40;image&#41;;
		fclose&#40;fp&#41;;
		png_destroy_read_struct&#40;&png_ptr, png_infopp_NULL, png_infopp_NULL&#41;;
		return NULL;
	&#125;
	image->imageWidth = width;
	image->imageHeight = height;
	image->textureWidth = getNextPower2&#40;width&#41;;
	image->textureHeight = getNextPower2&#40;height&#41;;
	png_set_strip_16&#40;png_ptr&#41;;
	png_set_packing&#40;png_ptr&#41;;
	if &#40;color_type == PNG_COLOR_TYPE_PALETTE&#41; png_set_palette_to_rgb&#40;png_ptr&#41;;
	if &#40;color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8&#41; png_set_gray_1_2_4_to_8&#40;png_ptr&#41;;
	if &#40;png_get_valid&#40;png_ptr, info_ptr, PNG_INFO_tRNS&#41;&#41; png_set_tRNS_to_alpha&#40;png_ptr&#41;;
	png_set_filler&#40;png_ptr, 0xff, PNG_FILLER_AFTER&#41;;
	image->data = &#40;Color*&#41; memalign&#40;16, image->textureWidth * image->textureHeight * sizeof&#40;Color&#41;&#41;;
	if &#40;!image->data&#41; &#123;
		free&#40;image&#41;;
		fclose&#40;fp&#41;;
		png_destroy_read_struct&#40;&png_ptr, png_infopp_NULL, png_infopp_NULL&#41;;
		return NULL;
	&#125;
	line = &#40;u32*&#41; malloc&#40;width * 4&#41;;
	if &#40;!line&#41; &#123;
		free&#40;image->data&#41;;
		free&#40;image&#41;;
		fclose&#40;fp&#41;;
		png_destroy_read_struct&#40;&png_ptr, png_infopp_NULL, png_infopp_NULL&#41;;
		return NULL;
	&#125;
	for &#40;y = 0; y < height; y++&#41; &#123;
		png_read_row&#40;png_ptr, &#40;u8*&#41; line, png_bytep_NULL&#41;;
		for &#40;x = 0; x < width; x++&#41; &#123;
			u32 color = line&#91;x&#93;;
			image->data&#91;x + y * image->textureWidth&#93; =  color;
		&#125;
	&#125;
	free&#40;line&#41;;
	png_read_end&#40;png_ptr, info_ptr&#41;;
	png_destroy_read_struct&#40;&png_ptr, &info_ptr, png_infopp_NULL&#41;;
	fclose&#40;fp&#41;;
	return image;
&#125;

void blitImageToImage&#40;int sx, int sy, int width, int height, Image* source, int dx, int dy, Image* destination&#41;
&#123;
	Color* destinationData = &destination->data&#91;destination->textureWidth * dy + dx&#93;;
	int destinationSkipX = destination->textureWidth - width;
	Color* sourceData = &source->data&#91;source->textureWidth * sy + sx&#93;;
	int sourceSkipX = source->textureWidth - width;
	int x, y;
	for &#40;y = 0; y < height; y++, destinationData += destinationSkipX, sourceData += sourceSkipX&#41; &#123;
		for &#40;x = 0; x < width; x++, destinationData++, sourceData++&#41; &#123;
			*destinationData = *sourceData;
		&#125;
	&#125;
&#125;

void blitImageToScreen&#40;int sx, int sy, int width, int height, Image* source, int dx, int dy&#41;
&#123;
	if &#40;!initialized&#41; return;
	Color* vram = getVramDrawBuffer&#40;&#41;;
	sceKernelDcacheWritebackInvalidateAll&#40;&#41;;
	guStart&#40;&#41;;
	sceGuCopyImage&#40;GU_PSM_8888, sx, sy, width, height, source->textureWidth, source->data, dx, dy, PSP_LINE_SIZE, vram&#41;;
	sceGuFinish&#40;&#41;;
	sceGuSync&#40;0,0&#41;;
&#125;

void blitAlphaImageToImage&#40;int sx, int sy, int width, int height, Image* source, int dx, int dy, Image* destination&#41;
&#123;
	// TODO Blend!
	Color* destinationData = &destination->data&#91;destination->textureWidth * dy + dx&#93;;
	int destinationSkipX = destination->textureWidth - width;
	Color* sourceData = &source->data&#91;source->textureWidth * sy + sx&#93;;
	int sourceSkipX = source->textureWidth - width;
	int x, y;
	for &#40;y = 0; y < height; y++, destinationData += destinationSkipX, sourceData += sourceSkipX&#41; &#123;
		for &#40;x = 0; x < width; x++, destinationData++, sourceData++&#41; &#123;
			Color color = *sourceData;
			if &#40;!IS_ALPHA&#40;color&#41;&#41; *destinationData = color;
		&#125;
	&#125;
&#125;

void blitAlphaImageToScreen&#40;int sx, int sy, int width, int height, Image* source, int dx, int dy&#41;
&#123;
	if &#40;!initialized&#41; return;

	sceKernelDcacheWritebackInvalidateAll&#40;&#41;;
	guStart&#40;&#41;;
	sceGuTexImage&#40;0, source->textureWidth, source->textureHeight, source->textureWidth, &#40;void*&#41; source->data&#41;;
	float u = 1.0f / &#40;&#40;float&#41;source->textureWidth&#41;;
	float v = 1.0f / &#40;&#40;float&#41;source->textureHeight&#41;;
	sceGuTexScale&#40;u, v&#41;;
	
	int j = 0;
	while &#40;j < width&#41; &#123;
		Vertex* vertices = &#40;Vertex*&#41; sceGuGetMemory&#40;2 * sizeof&#40;Vertex&#41;&#41;;
		int sliceWidth = 64;
		if &#40;j + sliceWidth > width&#41; sliceWidth = width - j;
		vertices&#91;0&#93;.u = sx + j;
		vertices&#91;0&#93;.v = sy;
		vertices&#91;0&#93;.x = dx + j;
		vertices&#91;0&#93;.y = dy;
		vertices&#91;0&#93;.z = 0;
		vertices&#91;1&#93;.u = sx + j + sliceWidth;
		vertices&#91;1&#93;.v = sy + height;
		vertices&#91;1&#93;.x = dx + j + sliceWidth;
		vertices&#91;1&#93;.y = dy + height;
		vertices&#91;1&#93;.z = 0;
		sceGuDrawArray&#40;GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, vertices&#41;;
		j += sliceWidth;
	&#125;
	
	sceGuFinish&#40;&#41;;
	sceGuSync&#40;0, 0&#41;;
&#125;

Image* createImage&#40;int width, int height&#41;
&#123;
	Image* image = &#40;Image*&#41; malloc&#40;sizeof&#40;Image&#41;&#41;;
	if &#40;!image&#41; return NULL;
	image->imageWidth = width;
	image->imageHeight = height;
	image->textureWidth = getNextPower2&#40;width&#41;;
	image->textureHeight = getNextPower2&#40;height&#41;;
	image->data = &#40;Color*&#41; memalign&#40;16, image->textureWidth * image->textureHeight * sizeof&#40;Color&#41;&#41;;
	if &#40;!image->data&#41; return NULL;
	memset&#40;image->data, 0, image->textureWidth * image->textureHeight * sizeof&#40;Color&#41;&#41;;
	return image;
&#125;

void freeImage&#40;Image* image&#41;
&#123;
	free&#40;image->data&#41;;
	free&#40;image&#41;;
&#125;

void clearImage&#40;Color color, Image* image&#41;
&#123;
	int i;
	int size = image->textureWidth * image->textureHeight;
	Color* data = image->data;
	for &#40;i = 0; i < size; i++, data++&#41; *data = color;
&#125;

void clearScreen&#40;Color color&#41;
&#123;
	if &#40;!initialized&#41; return;
	guStart&#40;&#41;;
	sceGuClearDepth&#40;0&#41;;
	sceGuClear&#40;GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT&#41;;
	sceGuFinish&#40;&#41;;
	sceGuSync&#40;0, 0&#41;;
&#125;

void fillImageRect&#40;Color color, int x0, int y0, int width, int height, Image* image&#41;
&#123;
	int skipX = image->textureWidth - width;
	int x, y;
	Color* data = image->data + x0 + y0 * image->textureWidth;
	for &#40;y = 0; y < height; y++, data += skipX&#41; &#123;
		for &#40;x = 0; x < width; x++, data++&#41; *data = color;
	&#125;
&#125;

void fillScreenRect&#40;Color color, int x0, int y0, int width, int height&#41;
&#123;
	if &#40;!initialized&#41; return;
	int skipX = PSP_LINE_SIZE - width;
	int x, y;
	Color* data = getVramDrawBuffer&#40;&#41; + x0 + y0 * PSP_LINE_SIZE;
	for &#40;y = 0; y < height; y++, data += skipX&#41; &#123;
		for &#40;x = 0; x < width; x++, data++&#41; *data = color;
	&#125;
&#125;

void putPixelScreen&#40;Color color, int x, int y&#41;
&#123;
	Color* vram = getVramDrawBuffer&#40;&#41;;
	vram&#91;PSP_LINE_SIZE * y + x&#93; = color;
&#125;

void putPixelImage&#40;Color color, int x, int y, Image* image&#41;
&#123;
	image->data&#91;x + y * image->textureWidth&#93; = color;
&#125;

Color getPixelScreen&#40;int x, int y&#41;
&#123;
	Color* vram = getVramDrawBuffer&#40;&#41;;
	return vram&#91;PSP_LINE_SIZE * y + x&#93;;
&#125;

Color getPixelImage&#40;int x, int y, Image* image&#41;
&#123;
	return image->data&#91;x + y * image->textureWidth&#93;;
&#125;

void printTextScreen&#40;int x, int y, const char* text, u32 color&#41;
&#123;
	int c, i, j, l;
	u8 *font;
	Color *vram_ptr;
	Color *vram;
	
	if &#40;!initialized&#41; return;

	for &#40;c = 0; c < strlen&#40;text&#41;; c++&#41; &#123;
		if &#40;x < 0 || x + 8 > SCREEN_WIDTH || y < 0 || y + 8 > SCREEN_HEIGHT&#41; break;
		char ch = text&#91;c&#93;;
		vram = getVramDrawBuffer&#40;&#41; + x + y * PSP_LINE_SIZE;
		
		font = &msx&#91; &#40;int&#41;ch * 8&#93;;
		for &#40;i = l = 0; i < 8; i++, l += 8, font++&#41; &#123;
			vram_ptr  = vram;
			for &#40;j = 0; j < 8; j++&#41; &#123;
				if &#40;&#40;*font & &#40;128 >> j&#41;&#41;&#41; *vram_ptr = color;
				vram_ptr++;
			&#125;
			vram += PSP_LINE_SIZE;
		&#125;
		x += 8;
	&#125;
&#125;

void printTextImage&#40;int x, int y, const char* text, u32 color, Image* image&#41;
&#123;
	int c, i, j, l;
	u8 *font;
	Color *data_ptr;
	Color *data;
	
	if &#40;!initialized&#41; return;

	for &#40;c = 0; c < strlen&#40;text&#41;; c++&#41; &#123;
		if &#40;x < 0 || x + 8 > image->imageWidth || y < 0 || y + 8 > image->imageHeight&#41; break;
		char ch = text&#91;c&#93;;
		data = image->data + x + y * image->textureWidth;
		
		font = &msx&#91; &#40;int&#41;ch * 8&#93;;
		for &#40;i = l = 0; i < 8; i++, l += 8, font++&#41; &#123;
			data_ptr  = data;
			for &#40;j = 0; j < 8; j++&#41; &#123;
				if &#40;&#40;*font & &#40;128 >> j&#41;&#41;&#41; *data_ptr = color;
				data_ptr++;
			&#125;
			data += image->textureWidth;
		&#125;
		x += 8;
	&#125;
&#125;

void saveImage&#40;const char* filename, Color* data, int width, int height, int lineSize, int saveAlpha&#41;
&#123;
	png_structp png_ptr;
	png_infop info_ptr;
	FILE* fp;
	int i, x, y;
	u8* line;
	
	if &#40;&#40;fp = fopen&#40;filename, "wb"&#41;&#41; == NULL&#41; return;
	png_ptr = png_create_write_struct&#40;PNG_LIBPNG_VER_STRING, NULL, NULL, NULL&#41;;
	if &#40;!png_ptr&#41; return;
	info_ptr = png_create_info_struct&#40;png_ptr&#41;;
	if &#40;!info_ptr&#41; &#123;
		png_destroy_write_struct&#40;&png_ptr, &#40;png_infopp&#41;NULL&#41;;
		return;
	&#125;
	png_init_io&#40;png_ptr, fp&#41;;
	png_set_IHDR&#40;png_ptr, info_ptr, width, height, 8,
		saveAlpha ? PNG_COLOR_TYPE_RGBA &#58; PNG_COLOR_TYPE_RGB,
		PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT&#41;;
	png_write_info&#40;png_ptr, info_ptr&#41;;
	line = &#40;u8*&#41; malloc&#40;width * &#40;saveAlpha ? 4 &#58; 3&#41;&#41;;
	for &#40;y = 0; y < height; y++&#41; &#123;
		for &#40;i = 0, x = 0; x < width; x++&#41; &#123;
			Color color = data&#91;x + y * lineSize&#93;;
			u8 r = color & 0xff; 
			u8 g = &#40;color >> 8&#41; & 0xff;
			u8 b = &#40;color >> 16&#41; & 0xff;
			u8 a = saveAlpha ? &#40;color >> 24&#41; & 0xff &#58; 0xff;
			line&#91;i++&#93; = r;
			line&#91;i++&#93; = g;
			line&#91;i++&#93; = b;
			if &#40;saveAlpha&#41; line&#91;i++&#93; = a;
		&#125;
		png_write_row&#40;png_ptr, line&#41;;
	&#125;
	free&#40;line&#41;;
	png_write_end&#40;png_ptr, info_ptr&#41;;
	png_destroy_write_struct&#40;&png_ptr, &#40;png_infopp&#41;NULL&#41;;
	fclose&#40;fp&#41;;
&#125;

void flipScreen&#40;&#41;
&#123;
	if &#40;!initialized&#41; return;
	sceGuSwapBuffers&#40;&#41;;
	dispBufferNumber ^= 1;
&#125;

static void drawLine&#40;int x0, int y0, int x1, int y1, int color, Color* destination, int width&#41;
&#123;
	int dy = y1 - y0;
	int dx = x1 - x0;
	int stepx, stepy;
	
	if &#40;dy < 0&#41; &#123; dy = -dy;  stepy = -width; &#125; else &#123; stepy = width; &#125;
	if &#40;dx < 0&#41; &#123; dx = -dx;  stepx = -1; &#125; else &#123; stepx = 1; &#125;
	dy <<= 1;
	dx <<= 1;
	
	y0 *= width;
	y1 *= width;
	destination&#91;x0+y0&#93; = color;
	if &#40;dx > dy&#41; &#123;
		int fraction = dy - &#40;dx >> 1&#41;;
		while &#40;x0 != x1&#41; &#123;
			if &#40;fraction >= 0&#41; &#123;
				y0 += stepy;
				fraction -= dx;
			&#125;
			x0 += stepx;
			fraction += dy;
			destination&#91;x0+y0&#93; = color;
		&#125;
	&#125; else &#123;
		int fraction = dx - &#40;dy >> 1&#41;;
		while &#40;y0 != y1&#41; &#123;
			if &#40;fraction >= 0&#41; &#123;
				x0 += stepx;
				fraction -= dy;
			&#125;
			y0 += stepy;
			fraction += dx;
			destination&#91;x0+y0&#93; = color;
		&#125;
	&#125;
&#125;

void drawLineScreen&#40;int x0, int y0, int x1, int y1, Color color&#41;
&#123;
	drawLine&#40;x0, y0, x1, y1, color, getVramDrawBuffer&#40;&#41;, PSP_LINE_SIZE&#41;;
&#125;

void drawLineImage&#40;int x0, int y0, int x1, int y1, Color color, Image* image&#41;
&#123;
	drawLine&#40;x0, y0, x1, y1, color, image->data, image->textureWidth&#41;;
&#125;

#define BUF_WIDTH &#40;512&#41;
#define SCR_WIDTH &#40;480&#41;
#define SCR_HEIGHT &#40;272&#41;
#define PIXEL_SIZE &#40;4&#41; /* change this if you change to another screenmode */
#define FRAME_SIZE &#40;BUF_WIDTH * SCR_HEIGHT * PIXEL_SIZE&#41;
#define ZBUF_SIZE &#40;BUF_WIDTH SCR_HEIGHT * 2&#41; /* zbuffer seems to be 16-bit? */

void initGraphics&#40;&#41;
&#123;
	dispBufferNumber = 0;

	sceGuInit&#40;&#41;;

	guStart&#40;&#41;;
	sceGuDrawBuffer&#40;GU_PSM_8888, &#40;void*&#41;FRAMEBUFFER_SIZE, PSP_LINE_SIZE&#41;;
	sceGuDispBuffer&#40;SCREEN_WIDTH, SCREEN_HEIGHT, &#40;void*&#41;0, PSP_LINE_SIZE&#41;;
	sceGuClear&#40;GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT&#41;;
	sceGuDepthBuffer&#40;&#40;void*&#41; &#40;FRAMEBUFFER_SIZE*2&#41;, PSP_LINE_SIZE&#41;;
	sceGuOffset&#40;2048 - &#40;SCREEN_WIDTH / 2&#41;, 2048 - &#40;SCREEN_HEIGHT / 2&#41;&#41;;
	sceGuViewport&#40;2048, 2048, SCREEN_WIDTH, SCREEN_HEIGHT&#41;;
	sceGuDepthRange&#40;0xc350, 0x2710&#41;;
	sceGuScissor&#40;0, 0, SCREEN_WIDTH, SCREEN_HEIGHT&#41;;
	sceGuEnable&#40;GU_SCISSOR_TEST&#41;;
	sceGuAlphaFunc&#40;GU_GREATER, 0, 0xff&#41;;
	sceGuEnable&#40;GU_ALPHA_TEST&#41;;
	sceGuDepthFunc&#40;GU_GEQUAL&#41;;
	sceGuEnable&#40;GU_DEPTH_TEST&#41;;
	sceGuFrontFace&#40;GU_CW&#41;;
	sceGuShadeModel&#40;GU_SMOOTH&#41;;
	sceGuEnable&#40;GU_CULL_FACE&#41;;
	sceGuEnable&#40;GU_TEXTURE_2D&#41;;
	sceGuEnable&#40;GU_CLIP_PLANES&#41;;
	sceGuTexMode&#40;GU_PSM_8888, 0, 0, 0&#41;;
	sceGuTexFunc&#40;GU_TFX_REPLACE, GU_TCC_RGBA&#41;;
	sceGuTexFilter&#40;GU_NEAREST, GU_NEAREST&#41;;
	sceGuAmbientColor&#40;0xffffffff&#41;;
	sceGuEnable&#40;GU_BLEND&#41;;
	sceGuBlendFunc&#40;GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0&#41;;
	sceGuFinish&#40;&#41;;
	sceGuSync&#40;0, 0&#41;;

	sceDisplayWaitVblankStart&#40;&#41;;
	sceGuDisplay&#40;GU_TRUE&#41;;
	initialized = 1;
&#125;

void disableGraphics&#40;&#41;
&#123;
	initialized = 0;
&#125;

void guStart&#40;&#41;
&#123;
	sceGuStart&#40;GU_DIRECT, list&#41;;
&#125;
mp3player.c

Code: Select all

// mp3player.c&#58; MP3 Player Implementation in C for Sony PSP
//
////////////////////////////////////////////////////////////////////////////

#include <pspkernel.h>
#include <pspdebug.h>
#include <pspiofilemgr.h>
#include <pspdisplay.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#include <pspaudiolib.h>
#include "mp3player.h"


#define FALSE 0
#define TRUE !FALSE
#define min&#40;a,b&#41; &#40;&#40;&#40;a&#41;<&#40;b&#41;&#41;?&#40;a&#41;&#58;&#40;b&#41;&#41;
#define max&#40;a,b&#41; &#40;&#40;&#40;a&#41;>&#40;b&#41;&#41;?&#40;a&#41;&#58;&#40;b&#41;&#41;
#define MadErrorString&#40;x&#41; mad_stream_errorstr&#40;x&#41;
#define INPUT_BUFFER_SIZE	&#40;5*8192&#41;
#define OUTPUT_BUFFER_SIZE	2048	/* Must be an integer multiple of 4. */


/* This table represents the subband-domain filter characteristics. It
* is initialized by the ParseArgs&#40;&#41; function and is used as
* coefficients against each subband samples when DoFilter is non-nul.
*/
mad_fixed_t Filter&#91;32&#93;;

/* DoFilter is non-nul when the Filter table defines a filter bank to
* be applied to the decoded audio subbands.
*/
int DoFilter = 0;
/* Define printf, just to make typing easier */
#define printf	pspDebugScreenPrintf

#define NUMCHANNELS 2
u8 *ptr;
long size;
long samplesInOutput = 0;

//////////////////////////////////////////////////////////////////////
// Global local variables
//////////////////////////////////////////////////////////////////////

//libmad lowlevel stuff

// The following variables contain the music data, ie they don't change value until you load a new file
struct mad_stream Stream;
struct mad_frame Frame;
struct mad_synth Synth;
mad_timer_t Timer;
signed short OutputBuffer&#91;OUTPUT_BUFFER_SIZE&#93;;
unsigned char InputBuffer&#91;INPUT_BUFFER_SIZE + MAD_BUFFER_GUARD&#93;,
    *OutputPtr = &#40;unsigned char *&#41; OutputBuffer, *GuardPtr = NULL;
const unsigned char *OutputBufferEnd = &#40;unsigned char *&#41; OutputBuffer + OUTPUT_BUFFER_SIZE * 2;
int Status = 0, i;
unsigned long FrameCount = 0;

// The following variables are maintained and updated by the tracker during playback
static int isPlaying;		// Set to true when a mod is being played

//////////////////////////////////////////////////////////////////////
// These are the public functions
//////////////////////////////////////////////////////////////////////
static int myChannel;
static int eos;

/* Define printf, just to make typing easier */
#define printf	pspDebugScreenPrintf

/*void MP3setStubs&#40;codecStubs * stubs&#41;
&#123;
    stubs->init = MP3_Init;
    stubs->load = MP3_Load;
    stubs->play = MP3_Play;
    stubs->pause = MP3_Pause;
    stubs->stop = MP3_Stop;
    stubs->end = MP3_End;
    stubs->time = MP3_GetTimeString;
    stubs->tick = NULL;
    stubs->eos = MP3_EndOfStream;
    memcpy&#40;stubs->extension, "mp3\0" "\0\0\0\0", 2 * 4&#41;;
&#125;*/

static int PrintFrameInfo&#40;struct mad_header *Header&#41;
&#123;
    const char *Layer, *Mode, *Emphasis;

    /* Convert the layer number to it's printed representation. */
    switch &#40;Header->layer&#41; &#123;
    case MAD_LAYER_I&#58;
	Layer = "I";
	break;
    case MAD_LAYER_II&#58;
	Layer = "II";
	break;
    case MAD_LAYER_III&#58;
	Layer = "III";
	break;
    default&#58;
	Layer = "&#40;unexpected layer value&#41;";
	break;
    &#125;

    /* Convert the audio mode to it's printed representation. */
    switch &#40;Header->mode&#41; &#123;
    case MAD_MODE_SINGLE_CHANNEL&#58;
	Mode = "single channel";
	break;
    case MAD_MODE_DUAL_CHANNEL&#58;
	Mode = "dual channel";
	break;
    case MAD_MODE_JOINT_STEREO&#58;
	Mode = "joint &#40;MS/intensity&#41; stereo";
	break;
    case MAD_MODE_STEREO&#58;
	Mode = "normal LR stereo";
	break;
    default&#58;
	Mode = "&#40;unexpected mode value&#41;";
	break;
    &#125;

    /* Convert the emphasis to it's printed representation. Note that
     * the MAD_EMPHASIS_RESERVED enumeration value appeared in libmad
     * version 0.15.0b.
     */
    switch &#40;Header->emphasis&#41; &#123;
    case MAD_EMPHASIS_NONE&#58;
	Emphasis = "no";
	break;
    case MAD_EMPHASIS_50_15_US&#58;
	Emphasis = "50/15 us";
	break;
    case MAD_EMPHASIS_CCITT_J_17&#58;
	Emphasis = "CCITT J.17";
	break;
#if &#40;MAD_VERSION_MAJOR>=1&#41; || \
  &#40;&#40;MAD_VERSION_MAJOR==0&#41; && &#40;MAD_VERSION_MINOR>=15&#41;&#41;
    case MAD_EMPHASIS_RESERVED&#58;
	Emphasis = "reserved&#40;!&#41;";
	break;
#endif
    default&#58;
	Emphasis = "&#40;unexpected emphasis value&#41;";
	break;
    &#125;
    pspDebugScreenSetXY&#40;0, 29&#41;;
    printf&#40;"%lu kb/s audio MPEG layer %s stream at %dHz\n", Header->bitrate / 1000, Layer, Header->samplerate&#41;;
    sceDisplayWaitVblankStart&#40;&#41;;
    return &#40;0&#41;;
&#125;

/****************************************************************************
* Applies a frequency-domain filter to audio data in the subband-domain.	*
****************************************************************************/
static void ApplyFilter&#40;struct mad_frame *Frame&#41;
&#123;
    int Channel, Sample, Samples, SubBand;

    /* There is two application loops, each optimized for the number
     * of audio channels to process. The first alternative is for
     * two-channel frames, the second is for mono-audio.
     */
    Samples = MAD_NSBSAMPLES&#40;&Frame->header&#41;;
    if &#40;Frame->header.mode != MAD_MODE_SINGLE_CHANNEL&#41;
	for &#40;Channel = 0; Channel < 2; Channel++&#41;
	    for &#40;Sample = 0; Sample < Samples; Sample++&#41;
		for &#40;SubBand = 0; SubBand < 32; SubBand++&#41;
		    Frame->sbsample&#91;Channel&#93;&#91;Sample&#93;&#91;SubBand&#93; =
			mad_f_mul&#40;Frame->sbsample&#91;Channel&#93;&#91;Sample&#93;&#91;SubBand&#93;, Filter&#91;SubBand&#93;&#41;;
    else
	for &#40;Sample = 0; Sample < Samples; Sample++&#41;
	    for &#40;SubBand = 0; SubBand < 32; SubBand++&#41;
		Frame->sbsample&#91;0&#93;&#91;Sample&#93;&#91;SubBand&#93; = mad_f_mul&#40;Frame->sbsample&#91;0&#93;&#91;Sample&#93;&#91;SubBand&#93;, Filter&#91;SubBand&#93;&#41;;
&#125;

/****************************************************************************
* Converts a sample from libmad's fixed point number format to a signed	*
* short &#40;16 bits&#41;.															*
****************************************************************************/
static signed short MadFixedToSshort&#40;mad_fixed_t Fixed&#41;
&#123;
    /* A fixed point number is formed of the following bit pattern&#58;
     *
     * SWWWFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     * MSB                          LSB
     * S ==> Sign &#40;0 is positive, 1 is negative&#41;
     * W ==> Whole part bits
     * F ==> Fractional part bits
     *
     * This pattern contains MAD_F_FRACBITS fractional bits, one
     * should alway use this macro when working on the bits of a fixed
     * point number. It is not guaranteed to be constant over the
     * different platforms supported by libmad.
     *
     * The signed short value is formed, after clipping, by the least
     * significant whole part bit, followed by the 15 most significant
     * fractional part bits. Warning&#58; this is a quick and dirty way to
     * compute the 16-bit number, madplay includes much better
     * algorithms.
     */

    /* Clipping */
    if &#40;Fixed >= MAD_F_ONE&#41;
	return &#40;SHRT_MAX&#41;;
    if &#40;Fixed <= -MAD_F_ONE&#41;
	return &#40;-SHRT_MAX&#41;;

    /* Conversion. */
    Fixed = Fixed >> &#40;MAD_F_FRACBITS - 15&#41;;
    return &#40;&#40;signed short&#41; Fixed&#41;;
&#125;

static void MP3Callback&#40;void *_buf2, unsigned int numSamples, void *pdata&#41;
&#123;
  short *_buf = &#40;short *&#41;_buf2;
    unsigned long samplesOut = 0;
    //      u8 justStarted = 1;

    if &#40;isPlaying == TRUE&#41; &#123;	//  Playing , so mix up a buffer
	if &#40;samplesInOutput > 0&#41; &#123;
	    //printf&#40;"%d samples in buffer\n", samplesInOutput&#41;;
	    if &#40;samplesInOutput > numSamples&#41; &#123;
		memcpy&#40;&#40;char *&#41; _buf, &#40;char *&#41; OutputBuffer, numSamples * 2 * 2&#41;;
		samplesOut = numSamples;
		samplesInOutput -= numSamples;
	    &#125; else &#123;
		memcpy&#40;&#40;char *&#41; _buf, &#40;char *&#41; OutputBuffer, samplesInOutput * 2 * 2&#41;;
		samplesOut = samplesInOutput;
		samplesInOutput = 0;
	    &#125;
	&#125;
	while &#40;samplesOut < numSamples&#41; &#123;
	    if &#40;Stream.buffer == NULL || Stream.error == MAD_ERROR_BUFLEN&#41; &#123;
		//size_t ReadSize, Remaining;
		//unsigned char *ReadStart;

		/* &#123;2&#125; libmad may not consume all bytes of the input
		 * buffer. If the last frame in the buffer is not wholly
		 * contained by it, then that frame's start is pointed by
		 * the next_frame member of the Stream structure. This
		 * common situation occurs when mad_frame_decode&#40;&#41; fails,
		 * sets the stream error code to MAD_ERROR_BUFLEN, and
		 * sets the next_frame pointer to a non NULL value. &#40;See
		 * also the comment marked &#123;4&#125; bellow.&#41;
		 *
		 * When this occurs, the remaining unused bytes must be
		 * put back at the beginning of the buffer and taken in
		 * account before refilling the buffer. This means that
		 * the input buffer must be large enough to hold a whole
		 * frame at the highest observable bit-rate &#40;currently 448
		 * kb/s&#41;. XXX=XXX Is 2016 bytes the size of the largest
		 * frame? &#40;448000*&#40;1152/32000&#41;&#41;/8
		 */
		/*if&#40;Stream.next_frame!=NULL&#41;
		   &#123;
		   Remaining=Stream.bufend-Stream.next_frame;
		   memmove&#40;InputBuffer,Stream.next_frame,Remaining&#41;;
		   ReadStart=InputBuffer+Remaining;
		   ReadSize=INPUT_BUFFER_SIZE-Remaining;
		   &#125;
		   else
		   ReadSize=INPUT_BUFFER_SIZE,
		   ReadStart=InputBuffer,
		   Remaining=0;
		 */
		/* Fill-in the buffer. If an error occurs print a message
		 * and leave the decoding loop. If the end of stream is
		 * reached we also leave the loop but the return status is
		 * left untouched.
		 */
		//ReadSize=BstdRead&#40;ReadStart,1,ReadSize,BstdFile&#41;;
		//printf&#40;"readsize&#58; %d\n", ReadSize&#41;;
		//sceDisplayWaitVblankStart&#40;&#41;;
		/*if&#40;ReadSize<=0&#41;
		   &#123;
		   //printf&#40;"read error on bit-stream &#40;%s - %d&#41;\n", error_to_string&#40;errno&#41;, errno&#41;;
		   //   Status=1;

		   if&#40;BstdFile->eof&#41; &#123;
		   printf&#40;"end of input stream\n"&#41;;
		   sceDisplayWaitVblankStart&#40;&#41;;
		   &#125;
		   //break;
		   printf&#40;"Readsize was <=0 in player callback\n"&#41;;
		   sceDisplayWaitVblankStart&#40;&#41;;
		   &#125; */

		/* &#123;3&#125; When decoding the last frame of a file, it must be
		 * followed by MAD_BUFFER_GUARD zero bytes if one wants to
		 * decode that last frame. When the end of file is
		 * detected we append that quantity of bytes at the end of
		 * the available data. Note that the buffer can't overflow
		 * as the guard size was allocated but not used the the
		 * buffer management code. &#40;See also the comment marked
		 * &#123;1&#125;.&#41;
		 *
		 * In a message to the mad-dev mailing list on May 29th,
		 * 2001, Rob Leslie explains the guard zone as follows&#58;
		 *
		 *    "The reason for MAD_BUFFER_GUARD has to do with the
		 *    way decoding is performed. In Layer III, Huffman
		 *    decoding may inadvertently read a few bytes beyond
		 *    the end of the buffer in the case of certain invalid
		 *    input. This is not detected until after the fact. To
		 *    prevent this from causing problems, and also to
		 *    ensure the next frame's main_data_begin pointer is
		 *    always accessible, MAD requires MAD_BUFFER_GUARD
		 *    &#40;currently 8&#41; bytes to be present in the buffer past
		 *    the end of the current frame in order to decode the
		 *    frame."
		 */
		/*if&#40;BstdFileEofP&#40;BstdFile&#41;&#41;
		   &#123;
		   GuardPtr=ReadStart+ReadSize;
		   memset&#40;GuardPtr,0,MAD_BUFFER_GUARD&#41;;
		   ReadSize+=MAD_BUFFER_GUARD;
		   &#125; */

		/* Pipe the new buffer content to libmad's stream decoder
		 * facility.
		 */
		mad_stream_buffer&#40;&Stream, ptr, size&#41;;
		Stream.error = 0;
	    &#125;

	    /* Decode the next MPEG frame. The streams is read from the
	     * buffer, its constituents are break down and stored the the
	     * Frame structure, ready for examination/alteration or PCM
	     * synthesis. Decoding options are carried in the Frame
	     * structure from the Stream structure.
	     *
	     * Error handling&#58; mad_frame_decode&#40;&#41; returns a non zero value
	     * when an error occurs. The error condition can be checked in
	     * the error member of the Stream structure. A mad error is
	     * recoverable or fatal, the error status is checked with the
	     * MAD_RECOVERABLE macro.
	     *
	     * &#123;4&#125; When a fatal error is encountered all decoding
	     * activities shall be stopped, except when a MAD_ERROR_BUFLEN
	     * is signaled. This condition means that the
	     * mad_frame_decode&#40;&#41; function needs more input to complete
	     * its work. One shall refill the buffer and repeat the
	     * mad_frame_decode&#40;&#41; call. Some bytes may be left unused at
	     * the end of the buffer if those bytes forms an incomplete
	     * frame. Before refilling, the remaining bytes must be moved
	     * to the beginning of the buffer and used for input for the
	     * next mad_frame_decode&#40;&#41; invocation. &#40;See the comments
	     * marked &#123;2&#125; earlier for more details.&#41;
	     *
	     * Recoverable errors are caused by malformed bit-streams, in
	     * this case one can call again mad_frame_decode&#40;&#41; in order to
	     * skip the faulty part and re-sync to the next frame.
	     */
	    if &#40;mad_frame_decode&#40;&Frame, &Stream&#41;&#41; &#123;
		if &#40;MAD_RECOVERABLE&#40;Stream.error&#41;&#41; &#123;
		    /* Do not print a message if the error is a loss of
		     * synchronization and this loss is due to the end of
		     * stream guard bytes. &#40;See the comments marked &#123;3&#125;
		     * supra for more informations about guard bytes.&#41;
		     */
		    if &#40;Stream.error != MAD_ERROR_LOSTSYNC || Stream.this_frame != GuardPtr&#41; &#123;
			printf&#40;"recoverable frame level error &#40;%s&#41;\n", MadErrorString&#40;&Stream&#41;&#41;;
			sceDisplayWaitVblankStart&#40;&#41;;
		    &#125;
		    return;	//continue;
		&#125; else if &#40;Stream.error == MAD_ERROR_BUFLEN&#41; &#123;
		    eos = 1;
		    return;	//continue;
		&#125; else &#123;
		    printf&#40;"unrecoverable frame level error &#40;%s&#41;.\n", MadErrorString&#40;&Stream&#41;&#41;;
		    sceDisplayWaitVblankStart&#40;&#41;;
		    Status = 1;
		    MP3_Stop&#40;&#41;;	//break;
		&#125;
	    &#125;

	    /* The characteristics of the stream's first frame is printed
	     * on stderr. The first frame is representative of the entire
	     * stream.
	     */
	    if &#40;FrameCount == 0&#41;
		if &#40;PrintFrameInfo&#40;&Frame.header&#41;&#41; &#123;
		    Status = 1;
		    //break;
		&#125;

	    /* Accounting. The computed frame duration is in the frame
	     * header structure. It is expressed as a fixed point number
	     * whole data type is mad_timer_t. It is different from the
	     * samples fixed point format and unlike it, it can't directly
	     * be added or subtracted. The timer module provides several
	     * functions to operate on such numbers. Be careful there, as
	     * some functions of libmad's timer module receive some of
	     * their mad_timer_t arguments by value!
	     */
	    FrameCount++;
	    mad_timer_add&#40;&Timer, Frame.header.duration&#41;;

	    /* Between the frame decoding and samples synthesis we can
	     * perform some operations on the audio data. We do this only
	     * if some processing was required. Detailed explanations are
	     * given in the ApplyFilter&#40;&#41; function.
	     */
	    if &#40;DoFilter&#41;
		ApplyFilter&#40;&Frame&#41;;

	    /* Once decoded the frame is synthesized to PCM samples. No errors
	     * are reported by mad_synth_frame&#40;&#41;;
	     */
	    mad_synth_frame&#40;&Synth, &Frame&#41;;

	    /* Synthesized samples must be converted from libmad's fixed
	     * point number to the consumer format. Here we use unsigned
	     * 16 bit big endian integers on two channels. Integer samples
	     * are temporarily stored in a buffer that is flushed when
	     * full.
	     */

	    for &#40;i = 0; i < Synth.pcm.length; i++&#41; &#123;
		signed short Sample;
		//printf&#40;"%d < %d\n", samplesOut, numSamples&#41;;
		if &#40;samplesOut < numSamples&#41; &#123;
		    //printf&#40;"I really get here\n"&#41;;
		    /* Left channel */
		    Sample = MadFixedToSshort&#40;Synth.pcm.samples&#91;0&#93;&#91;i&#93;&#41;;
		    // *&#40;OutputPtr++&#41;=Sample>>8;
		    // *&#40;OutputPtr++&#41;=Sample&0xff;
		    _buf&#91;samplesOut * 2&#93; = Sample;

		    /* Right channel. If the decoded stream is monophonic then
		     * the right output channel is the same as the left one.
		     */
		    if &#40;MAD_NCHANNELS&#40;&Frame.header&#41; == 2&#41;
			Sample = MadFixedToSshort&#40;Synth.pcm.samples&#91;1&#93;&#91;i&#93;&#41;;
		    // *&#40;OutputPtr++&#41;=Sample>>8;
		    // *&#40;OutputPtr++&#41;=Sample&0xff;
		    //_buf&#91;samplesOut*2&#93;=0;//Sample;
		    _buf&#91;samplesOut * 2 + 1&#93; = Sample;
		    samplesOut++;
		&#125; else &#123;
		    //printf&#40;"%d < %d of %d\n", samplesOut, numSamples, Synth.pcm.length&#41;;
		    Sample = MadFixedToSshort&#40;Synth.pcm.samples&#91;0&#93;&#91;i&#93;&#41;;
		    OutputBuffer&#91;samplesInOutput * 2&#93; = Sample;
		    //OutputBuffer&#91;samplesInOutput*4+1&#93;=0;//Sample>>8;
		    //OutputBuffer&#91;samplesInOutput*4+2&#93;=0;//Sample&0xff;
		    if &#40;MAD_NCHANNELS&#40;&Frame.header&#41; == 2&#41;
			Sample = MadFixedToSshort&#40;Synth.pcm.samples&#91;1&#93;&#91;i&#93;&#41;;
		    OutputBuffer&#91;samplesInOutput * 2 + 1&#93; = Sample;
		    //OutputBuffer&#91;samplesInOutput*4+3&#93;=0;//Sample>>8;
		    //OutputBuffer&#91;samplesInOutput*4+4&#93;=0;//Sample&0xff;
		    samplesInOutput++;
		&#125;

	    &#125;
	&#125;
    &#125; else &#123;			//  Not Playing , so clear buffer
	&#123;
	    int count;
	    for &#40;count = 0; count < numSamples * 2; count++&#41;
		*&#40;_buf + count&#41; = 0;
	&#125;
    &#125;
&#125;

void MP3_Init&#40;int channel&#41;
&#123;
    myChannel = channel;
    isPlaying = FALSE;
    pspAudioSetChannelCallback&#40;myChannel, MP3Callback,0&#41;;
    /* First the structures used by libmad must be initialized. */
    mad_stream_init&#40;&Stream&#41;;
    mad_frame_init&#40;&Frame&#41;;
    mad_synth_init&#40;&Synth&#41;;
    mad_timer_reset&#40;&Timer&#41;;
    //ModPlay_Load&#40;"",data&#41;;
&#125;


void MP3_FreeTune&#40;&#41;
&#123;
    /* The input file was completely read; the memory allocated by our
     * reading module must be reclaimed.
     */
    if &#40;ptr&#41;
	free&#40;ptr&#41;;
    //sceIoClose&#40;BstdFile->fd&#41;;
    //BstdFileDestroy&#40;BstdFile&#41;;

    /* Mad is no longer used, the structures that were initialized must
     * now be cleared.
     */
    mad_synth_finish&#40;&Synth&#41;;
    mad_frame_finish&#40;&Frame&#41;;
    mad_stream_finish&#40;&Stream&#41;;

    /* If the output buffer is not empty and no error occurred during
     * the last write, then flush it.
     */
    /*if&#40;OutputPtr!=OutputBuffer && Status!=2&#41;
       &#123;
       size_t       BufferSize=OutputPtr-OutputBuffer;

       if&#40;fwrite&#40;OutputBuffer,1,BufferSize,OutputFp&#41;!=BufferSize&#41;
       &#123;
       fprintf&#40;stderr,"%s&#58; PCM write error &#40;%s&#41;.\n",
       ProgName,strerror&#40;errno&#41;&#41;;
       Status=2;
       &#125;
       &#125; */

    /* Accounting report if no error occurred. */
    if &#40;!Status&#41; &#123;
	char Buffer&#91;80&#93;;

	/* The duration timer is converted to a human readable string
	 * with the versatile, but still constrained mad_timer_string&#40;&#41;
	 * function, in a fashion not unlike strftime&#40;&#41;. The main
	 * difference is that the timer is broken into several
	 * values according some of it's arguments. The units and
	 * fracunits arguments specify the intended conversion to be
	 * executed.
	 *
	 * The conversion unit &#40;MAD_UNIT_MINUTES in our example&#41; also
	 * specify the order and kind of conversion specifications
	 * that can be used in the format string.
	 *
	 * It is best to examine libmad's timer.c source-code for details
	 * of the available units, fraction of units, their meanings,
	 * the format arguments, etc.
	 */
	mad_timer_string&#40;Timer, Buffer, "%lu&#58;%02lu.%03u", MAD_UNITS_MINUTES, MAD_UNITS_MILLISECONDS, 0&#41;;
	printf&#40;"%lu frames decoded &#40;%s&#41;.\n", FrameCount, Buffer&#41;;
	sceDisplayWaitVblankStart&#40;&#41;;
	sceKernelDelayThread&#40;500000&#41;;
    &#125;
&#125;


void MP3_End&#40;&#41;
&#123;
    MP3_Stop&#40;&#41;;
    pspAudioSetChannelCallback&#40;myChannel, 0,0&#41;;
    MP3_FreeTune&#40;&#41;;
&#125;

//////////////////////////////////////////////////////////////////////
// Functions - Local and not public
//////////////////////////////////////////////////////////////////////

//  This is the initialiser and module loader
//  This is a general call, which loads the module from the 
//  given address into the modplayer
//
//  It basically loads into an internal format, so once this function
//  has returned the buffer at 'data' will not be needed again.
int MP3_Load&#40;char *filename&#41;
&#123;
    int fd;
    eos = 0;
    //psp_stats pstat;
    //sceIoGetstat&#40;filename, &pstat&#41;;
    if &#40;&#40;fd = sceIoOpen&#40;filename, PSP_O_RDONLY, 0777&#41;&#41; > 0&#41; &#123;
	//  opened file, so get size now
	size = sceIoLseek&#40;fd, 0, PSP_SEEK_END&#41;;
	sceIoLseek&#40;fd, 0, PSP_SEEK_SET&#41;;
	ptr = &#40;unsigned char *&#41; malloc&#40;size + 8&#41;;
	memset&#40;ptr, 0, size + 8&#41;;
	if &#40;ptr != 0&#41; &#123;		// Read file in
	    sceIoRead&#40;fd, ptr, size&#41;;
	&#125; else &#123;
	    printf&#40;"Error allocing\n"&#41;;
	    sceIoClose&#40;fd&#41;;
	    return 0;
	&#125;
	// Close file
	sceIoClose&#40;fd&#41;;
    &#125; else &#123;
	return 0;
    &#125;
    //  Set volume to full ready to play
    //SetMasterVolume&#40;64&#41;;
    isPlaying = FALSE;
    return 1;
&#125;

// This function initialises for playing, and starts
int MP3_Play&#40;&#41;
&#123;
    // See if I'm already playing
    if &#40;isPlaying&#41;
	return FALSE;

    isPlaying = TRUE;
    return TRUE;
&#125;

void MP3_Pause&#40;&#41;
&#123;
    isPlaying = !isPlaying;
&#125;

int MP3_Stop&#40;&#41;
&#123;
    //stop playing
    isPlaying = FALSE;

    //clear buffer
    memset&#40;OutputBuffer, 0, OUTPUT_BUFFER_SIZE&#41;;
    OutputPtr = &#40;unsigned char *&#41; OutputBuffer;

    //seek to beginning of file
    //sceIoLseek&#40;BstdFile->fd, 0, SEEK_SET&#41;;

    return TRUE;
&#125;

void MP3_GetTimeString&#40;char *dest&#41;
&#123;
    mad_timer_string&#40;Timer, dest, "%02lu&#58;%02u&#58;%02u", MAD_UNITS_HOURS, MAD_UNITS_MILLISECONDS, 0&#41;;
&#125;

int MP3_EndOfStream&#40;&#41;
&#123;
    if &#40;eos == 1&#41;
	return 1;
    return 0;
&#125;
main.c

Code: Select all

#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspaudio.h>
#include <psppower.h>
#include <png.h>

#include "mp3player.h"
#include "graphics.h"

PSP_MODULE_INFO&#40;"deathcore", 0, 1, 1&#41;;
#define printf pspDebugScreenPrintf

/* Exit callback */
int exit_callback&#40;&#41; &#123;
 	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41; &#123;
  int cbid;
	cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
	sceKernelRegisterExitCallback&#40;cbid&#41;;
	sceKernelSleepThreadCB&#40;&#41;;
	return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41; &#123;
	int thid = 0;
	thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
	if&#40;thid >= 0&#41; &#123;
  	sceKernelStartThread&#40;thid, 0, 0&#41;;
	&#125;
	return thid;
&#125;

int Music_player&#40;char* fileName&#41;
&#123;
	pspAudioInit&#40;&#41;;
	MP3_Init&#40;1&#41;;
	MP3_Load&#40;fileName&#41;;
	MP3_Play&#40;&#41;;
if&#40;MP3_EndOfStream&#41;
	&#123;
	MP3_Stop&#40;&#41;;
	MP3_FreeTune&#40;&#41;;
	&#125;
    return 0;
&#125;

int SetupMenu&#40;void&#41;
&#123;
pspDebugScreenSetXY&#40;0,0&#41;;
printf&#40;"\t\t\t\t<--DeathCorev1.0 by Rangu2057-->\n\n"&#41;;
printf&#40;"\t\t\tNew Game\n\n"&#41;;
printf&#40;"\t\t\tLoad Game\n\n"&#41;;
printf&#40;"\t\t\tCredits\n\n"&#41;;
&#125;

int main&#40;void&#41;&#123;

SceCtrlData pad;
pspDebugScreenInit&#40;&#41;;
SetupCallbacks;

Image* bg;
bg = loadImage&#40;"./menu.png"&#41;;

while&#40;1&#41; &#123;
      sceCtrlReadBufferPositive&#40;&pad, 1&#41;;

	blitAlphaImageToScreen&#40;0, 0 , 480, 272, bg, 0, 0&#41;;

	sceDisplayWaitVblankStart&#40;&#41;;
	flipScreen&#40;&#41;;
	&#125;
SetupMenu&#40;&#41;;
Music_player&#40;"menu.mp3"&#41;;
if&#40;pad.buttons & PSP_CTRL_HOME&#41;
	&#123;
	MP3_Stop&#40;&#41;;
	MP3_FreeTune&#40;&#41;;
	sceKernelExitGame&#40;&#41;;
	&#125;
&#125;
my errors

Code: Select all

graphics.c&#58;173&#58; error&#58; expected declaration specifiers or '...' before 'Image'
graphics.c&#58;174&#58; error&#58; expected '=', ',', ';', 'asm' or '__attribute__' before '
&#123;' token
graphics.c&#58;207&#58; error&#58; expected declaration specifiers before 'Image'
graphics.c&#58;221&#58; error&#58; expected '&#41;' before '*' token
graphics.c&#58;227&#58; error&#58; expected '&#41;' before 'color'
graphics.c&#58;235&#58; error&#58; expected '&#41;' before 'color'
graphics.c&#58;245&#58; error&#58; expected '&#41;' before 'color'
graphics.c&#58;255&#58; error&#58; expected '&#41;' before 'color'
graphics.c&#58;266&#58; error&#58; expected '&#41;' before 'color'
graphics.c&#58;272&#58; error&#58; expected '&#41;' before 'color'
graphics.c&#58;277&#58; error&#58; expected declaration specifiers before 'Color'
graphics.c&#58;283&#58; error&#58; expected declaration specifiers before 'Color'
graphics.c&#58;289&#58; error&#58; expected '=', ',', ';', 'asm' or '__attribute__' before '
&#123;' token
graphics.c&#58;315&#58; error&#58; expected declaration specifiers or '...' before 'Image'
graphics.c&#58;316&#58; error&#58; expected '=', ',', ';', 'asm' or '__attribute__' before '
&#123;' token
graphics.c&#58;342&#58; error&#58; expected declaration specifiers or '...' before 'Color'
graphics.c&#58;343&#58; error&#58; expected '=', ',', ';', 'asm' or '__attribute__' before '
&#123;' token
graphics.c&#58;385&#58; error&#58; expected '=', ',', ';', 'asm' or '__attribute__' before '
&#123;' token
graphics.c&#58;391&#58; error&#58; expected declaration specifiers or '...' before 'Color'
graphics.c&#58;392&#58; error&#58; expected '=', ',', ';', 'asm' or '__attribute__' before '
&#123;' token
graphics.c&#58;430&#58; error&#58; expected declaration specifiers or '...' before 'Color'
graphics.c&#58;431&#58; error&#58; expected '=', ',', ';', 'asm' or '__attribute__' before '
&#123;' token
graphics.c&#58;435&#58; error&#58; expected declaration specifiers or '...' before 'Color'
graphics.c&#58;435&#58; error&#58; expected declaration specifiers or '...' before 'Image'
graphics.c&#58;436&#58; error&#58; expected '=', ',', ';', 'asm' or '__attribute__' before '
&#123;' token
graphics.c&#58;448&#58; error&#58; expected '=', ',', ';', 'asm' or '__attribute__' before '
&#123;' token
graphics.c&#58;487&#58; error&#58; expected '=', ',', ';', 'asm' or '__attribute__' before '
&#123;' token
graphics.c&#58;492&#58; error&#58; expected '=', ',', ';', 'asm' or '__attribute__' before '
&#123;' token
graphics.c&#58;26&#58; error&#58; declaration for parameter 'initialized' but no such parame
ter
graphics.c&#58;25&#58; error&#58; declaration for parameter 'dispBufferNumber' but no such p
arameter
graphics.c&#58;24&#58; error&#58; declaration for parameter 'list' but no such parameter
graphics.c&#58;22&#58; error&#58; declaration for parameter 'msx' but no such parameter
graphics.c&#58;20&#58; error&#58; declaration for parameter 'Vertex' but no such parameter
framebuffer.h&#58;6&#58; error&#58; declaration for parameter 'g_vram_base' but no such para
meter
graphics.h&#58;294&#58; error&#58; declaration for parameter 'guStart' but no such parameter

graphics.h&#58;278&#58; error&#58; declaration for parameter 'drawLineImage' but no such par
ameter
graphics.h&#58;266&#58; error&#58; declaration for parameter 'drawLineScreen' but no such pa
rameter
graphics.h&#58;254&#58; error&#58; declaration for parameter 'disableGraphics' but no such p
arameter
graphics.h&#58;249&#58; error&#58; declaration for parameter 'initGraphics' but no such para
meter
graphics.h&#58;244&#58; error&#58; declaration for parameter 'flipScreen' but no such parame
ter
graphics.h&#58;239&#58; error&#58; declaration for parameter 'saveImage' but no such paramet
er
graphics.h&#58;226&#58; error&#58; declaration for parameter 'printTextImage' but no such pa
rameter
graphics.h&#58;215&#58; error&#58; declaration for parameter 'printTextScreen' but no such p
arameter
graphics.h&#58;106&#58; error&#58; declaration for parameter 'blitAlphaImageToScreen' but no
 such parameter
graphics.h&#58;88&#58; error&#58; declaration for parameter 'blitAlphaImageToImage' but no s
uch parameter
graphics.h&#58;69&#58; error&#58; declaration for parameter 'blitImageToScreen' but no such
parameter
graphics.h&#58;51&#58; error&#58; declaration for parameter 'blitImageToImage' but no such p
arameter
graphics.h&#58;23&#58; error&#58; declaration for parameter 'Image' but no such parameter
graphics.h&#58;10&#58; error&#58; declaration for parameter 'Color' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1438&#58; error&#58; declaration for parameter 'guSwap
BuffersBehaviour' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1426&#58; error&#58; declaration for parameter 'sceGuD
rawArrayN' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1424&#58; error&#58; declaration for parameter 'sceGuM
orphWeight' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1409&#58; error&#58; declaration for parameter 'sceGuB
oneMatrix' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1394&#58; error&#58; declaration for parameter 'sceGuS
etMatrix' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1380&#58; error&#58; declaration for parameter 'sceGuD
rawSpline' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1378&#58; error&#58; declaration for parameter 'sceGuP
atchPrim' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1371&#58; error&#58; declaration for parameter 'sceGuP
atchFrontFace' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1369&#58; error&#58; declaration for parameter 'sceGuP
atchDivide' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1361&#58; error&#58; declaration for parameter 'sceGuD
rawBezier' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1350&#58; error&#58; declaration for parameter 'sceGuV
iewport' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1335&#58; error&#58; declaration for parameter 'sceGuS
cissor' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1323&#58; error&#58; declaration for parameter 'sceGuO
ffset' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1308&#58; error&#58; declaration for parameter 'sceGuC
lutMode' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1292&#58; error&#58; declaration for parameter 'sceGuC
lutLoad' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1282&#58; error&#58; declaration for parameter 'sceGuT
exWrap' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1270&#58; error&#58; declaration for parameter 'sceGuT
exSync' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1262&#58; error&#58; declaration for parameter 'sceGuT
exSlope' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1261&#58; error&#58; declaration for parameter 'sceGuT
exScale' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1250&#58; error&#58; declaration for parameter 'sceGuT
exProjMapMode' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1237&#58; error&#58; declaration for parameter 'sceGuT
exOffset' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1226&#58; error&#58; declaration for parameter 'sceGuT
exMode' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1208&#58; error&#58; declaration for parameter 'sceGuT
exMapMode' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1194&#58; error&#58; declaration for parameter 'sceGuT
exLevelMode' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1181&#58; error&#58; declaration for parameter 'sceGuT
exImage' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1165&#58; error&#58; declaration for parameter 'sceGuT
exFunc' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1133&#58; error&#58; declaration for parameter 'sceGuT
exFlush' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1125&#58; error&#58; declaration for parameter 'sceGuT
exFilter' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1109&#58; error&#58; declaration for parameter 'sceGuT
exEnvColor' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1098&#58; error&#58; declaration for parameter 'sceGuC
opyImage' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1074&#58; error&#58; declaration for parameter 'sceGuS
hadeModel' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1063&#58; error&#58; declaration for parameter 'sceGuS
etDither' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1054&#58; error&#58; declaration for parameter 'sceGuL
ogicalOp' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1027&#58; error&#58; declaration for parameter 'sceGuF
rontFace' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1014&#58; error&#58; declaration for parameter 'sceGuS
pecular' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;1006&#58; error&#58; declaration for parameter 'sceGuS
tencilOp' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;986&#58; error&#58; declaration for parameter 'sceGuSt
encilFunc' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;967&#58; error&#58; declaration for parameter 'sceGuMo
delColor' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;962&#58; error&#58; declaration for parameter 'sceGuMa
terial' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;960&#58; error&#58; declaration for parameter 'sceGuBl
endFunc' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;924&#58; error&#58; declaration for parameter 'sceGuAm
bientColor' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;923&#58; error&#58; declaration for parameter 'sceGuAm
bient' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;921&#58; error&#58; declaration for parameter 'sceGuAl
phaFunc' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;902&#58; error&#58; declaration for parameter 'sceGuCo
lorMaterial' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;890&#58; error&#58; declaration for parameter 'sceGuCo
lorFunc' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;868&#58; error&#58; declaration for parameter 'sceGuCo
lor' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;861&#58; error&#58; declaration for parameter 'sceGuPi
xelMask' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;853&#58; error&#58; declaration for parameter 'sceGuCl
earStencil' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;845&#58; error&#58; declaration for parameter 'sceGuCl
earDepth' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;838&#58; error&#58; declaration for parameter 'sceGuCl
earColor' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;831&#58; error&#58; declaration for parameter 'sceGuCl
ear' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;819&#58; error&#58; declaration for parameter 'sceGuLi
ghtSpot' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;809&#58; error&#58; declaration for parameter 'sceGuLi
ghtMode' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;795&#58; error&#58; declaration for parameter 'sceGuLi
ghtColor' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;779&#58; error&#58; declaration for parameter 'sceGuLi
ghtAtt' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;769&#58; error&#58; declaration for parameter 'sceGuLi
ght' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;749&#58; error&#58; declaration for parameter 'sceGuDi
sable' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;740&#58; error&#58; declaration for parameter 'sceGuEn
able' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;717&#58; error&#58; declaration for parameter 'sceGuGe
tAllStatus' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;708&#58; error&#58; declaration for parameter 'sceGuSe
tAllStatus' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;699&#58; error&#58; declaration for parameter 'sceGuGe
tStatus' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;689&#58; error&#58; declaration for parameter 'sceGuSe
tStatus' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;679&#58; error&#58; declaration for parameter 'sceGuEn
dObject' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;674&#58; error&#58; declaration for parameter 'sceGuBe
ginObject' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;653&#58; error&#58; declaration for parameter 'sceGuDr
awArray' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;585&#58; error&#58; declaration for parameter 'sceGuSy
nc' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;562&#58; error&#58; declaration for parameter 'sceGuSw
apBuffers' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;555&#58; error&#58; declaration for parameter 'sceGuSe
ndList' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;542&#58; error&#58; declaration for parameter 'sceGuCh
eckList' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;535&#58; error&#58; declaration for parameter 'sceGuCa
llMode' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;527&#58; error&#58; declaration for parameter 'sceGuCa
llList' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;520&#58; error&#58; declaration for parameter 'sceGuFi
nishId' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;507&#58; error&#58; declaration for parameter 'sceGuFi
nish' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;492&#58; error&#58; declaration for parameter 'sceGuSt
art' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;477&#58; error&#58; declaration for parameter 'sceGuGe
tMemory' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;465&#58; error&#58; declaration for parameter 'sceGuSe
ndCommandi' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;455&#58; error&#58; declaration for parameter 'sceGuSe
ndCommandf' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;445&#58; error&#58; declaration for parameter 'sceGuSi
gnal' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;433&#58; error&#58; declaration for parameter 'sceGuSe
tCallback' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;420&#58; error&#58; declaration for parameter 'sceGuCo
ntinue' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;419&#58; error&#58; declaration for parameter 'sceGuBr
eak' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;417&#58; error&#58; declaration for parameter 'sceGuTe
rm' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;410&#58; error&#58; declaration for parameter 'sceGuIn
it' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;403&#58; error&#58; declaration for parameter 'sceGuFo
g' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;401&#58; error&#58; declaration for parameter 'sceGuDe
pthRange' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;386&#58; error&#58; declaration for parameter 'sceGuDe
pthOffset' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;384&#58; error&#58; declaration for parameter 'sceGuDe
pthMask' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;377&#58; error&#58; declaration for parameter 'sceGuDe
pthFunc' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;360&#58; error&#58; declaration for parameter 'sceGuDi
splay' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;348&#58; error&#58; declaration for parameter 'sceGuDr
awBufferList' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;339&#58; error&#58; declaration for parameter 'sceGuDr
awBuffer' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;319&#58; error&#58; declaration for parameter 'sceGuDi
spBuffer' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;303&#58; error&#58; declaration for parameter 'sceGuDe
pthBuffer' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspgu.h&#58;291&#58; error&#58; declaration for parameter 'GuSwapB
uffersCallback' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspge.h&#58;201&#58; error&#58; declaration for parameter 'sceGeUn
setCallback' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspge.h&#58;185&#58; error&#58; declaration for parameter 'sceGeDr
awSync' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspge.h&#58;176&#58; error&#58; declaration for parameter 'sceGeLi
stSync' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspge.h&#58;166&#58; error&#58; declaration for parameter 'PspGeSy
ncType' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspge.h&#58;156&#58; error&#58; declaration for parameter 'sceGeLi
stUpdateStallAddr' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspge.h&#58;146&#58; error&#58; declaration for parameter 'sceGeLi
stDeQueue' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspge.h&#58;137&#58; error&#58; declaration for parameter 'sceGeLi
stEnQueueHead' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspge.h&#58;124&#58; error&#58; declaration for parameter 'sceGeLi
stEnQueue' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspge.h&#58;93&#58; error&#58; declaration for parameter 'sceGeGet
Mtx' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspge.h&#58;83&#58; error&#58; declaration for parameter 'PspGeMat
rixTypes' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspge.h&#58;63&#58; error&#58; declaration for parameter 'sceGeGet
Cmd' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspge.h&#58;54&#58; error&#58; declaration for parameter 'sceGeEdr
amGetAddr' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspge.h&#58;47&#58; error&#58; declaration for parameter 'sceGeEdr
amGetSize' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspge.h&#58;40&#58; error&#58; declaration for parameter 'PspGeCal
lbackData' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspge.h&#58;27&#58; error&#58; declaration for parameter 'PspGeCal
lback' but no such parameter
C&#58;/pspsdk/psp/sdk/include/pspge.h&#58;24&#58; error&#58; declaration for parameter 'PspGeCon
text' but no such parameter
graphics.c&#58;494&#58; error&#58; expected '&#123;' at end of input
MAKE&#58; *** &#91;graphics.o&#93; Error 1

C&#58;\PSPSDK\DV1>
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

Post by Rangu2057 »

srry for the double post, but can anyone help me at all?
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

A first guess is you don't have the environment variables set so it can't find the includes. If you are setting the envvars, try a simpler example. See if you can compile anything correctly with your setup.
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

Post by Rangu2057 »

sorry for being a noob, but im not getting what you are trying to tell me J.F. sorry to be a bother,but can you please explain a little more please. Im pretty sure there shouldnt be anything wrong with the includes, because i tried compiling the samples and they compiled perfectly fine without any problems
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Well, if you can compile the examples, the envvars are probably okay, so it would have to be something wrong with the code.

You're just going to have to debug it. This is where programmers earn their living. Look at the FIRST error and figure out what's wrong with the code there. Ignore errors after the first because they may or may not actually be errors. Compilers commonly throw errors for code after the first error that don't exist because the parser is no longer in a valid state. So take errors one at a time (unless you know you repeated the first error elsewhere).
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

Post by Rangu2057 »

yea i know what you mean J.F. its all about trial and error in programming, ok ima try to start over and compile one thing at a time and see if anything comes up. Thanks for the help
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
Post Reply