help:having problem compiling modified simple turn demo

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

Moderators: cheriff, TyRaNiD

Post Reply
annerajb
Posts: 40
Joined: Thu Mar 31, 2005 6:16 am

help:having problem compiling modified simple turn demo

Post by annerajb »

hello i am having some problems compiling the simple turn demo. from a modified source code i am modifiying it to use the controller library by skippy911. but it give me an error because the files arent been build.


Code: Select all


D:\controller\SIMPLETURN-PSP-050510\source>d:\ps2dev\ee\bin\ee-gcc -march=r4000
-g -mgp32 -mlong32 -c main.c
main.c: In function `rgb2col':
main.c(198) : parse error at end of input

D:\controller\SIMPLETURN-PSP-050510\source>d:\ps2dev\ee\bin\ee-gcc -march=r4000
-g -mgp32 -mlong32 -c pg.c

D:\controller\SIMPLETURN-PSP-050510\source>d:\ps2dev\ee\bin\ee-gcc -march=r4000
-g -mgp32 -c -xassembler -O -o startup.o startup.s

D:\controller\SIMPLETURN-PSP-050510\source>d:\ps2dev\ee\bin\ee-ld -O0 startup.o
main.o pg.o -M -Ttext 8900000 -q -o out  1>SimpleTurn.map
/cygdrive/d/ps2dev/ee/bin/ee-ld: cannot open main.o: No such file or directory

D:\controller\SIMPLETURN-PSP-050510\source>pause
Press any key to continue . . .

if somebody can help me i will really apreciate it.
pspfreaks.broadphase.com/public_html/do ... source.rar
Warren
Posts: 175
Joined: Sat Jan 24, 2004 8:26 am
Location: San Diego, CA

Post by Warren »

Erm you have an error in the rgb2col funtion in main.cpp?
annerajb
Posts: 40
Joined: Thu Mar 31, 2005 6:16 am

Post by annerajb »

in the link at the end is the code. i already know that i have an error there but i cannot find out was is wrong with it .btw my text editor says that the programs has 197 lines of code.

Code: Select all

#include "pg.h"
#include "controller.c"

#define SCOREFILE_PATH "fatms0:/PSP/GAME/SIMPLETURN/HIGHSCORE.DAT"

static int high_score;

unsigned short rgb2col(unsigned char r,unsigned char g,unsigned char b) {
	return &#40;&#40;&#40;&#40;b>>3&#41; & 0x1F&#41;<<10&#41;+&#40;&#40;&#40;g>>3&#41; & 0x1F&#41;<<5&#41;+&#40;&#40;&#40;r>>3&#41; & 0x1F&#41;<<0&#41;+0x8000&#41;;
/*
&#125;

void wait_button&#40;void&#41; &#123;
	ctrl_data_t ctl;
	int btn;
//all of this is commented
	btn=1;
	while&#40;btn!=0&#41;&#123;
		pgWaitV&#40;&#41;;
		sceCtrlRead&#40;&ctl,1&#41;;
		btn = &#40;&#40;ctl.buttons & 0xF000&#41; != 0&#41;;
	&#125;
	btn=0;
	while&#40;btn==0&#41;&#123;
		pgWaitV&#40;&#41;;
		sceCtrlRead&#40;&ctl,1&#41;;
		btn = &#40;&#40;ctl.buttons & 0xF000&#41; != 0&#41;;
	&#125;
&#125;// all of this is commented
*/
//Display score
void DisplayScore&#40;int x,int y,int back_col,int col,int num&#41; &#123;
	unsigned char str&#91;4&#93;;
	int px,py,n;
	unsigned short *vr;

	for&#40;py=0;py<8;py++&#41; &#123;
		vr = &#40;unsigned short *&#41;pgGetVramAddr&#40;x*8,y*8+py&#41;;
		for&#40;px=0;px<24;px++&#41; *vr++ = back_col;
	&#125;

	n = &#40;num / 100&#41; % 10;
	if &#40;n==0&#41; &#123; str&#91;0&#93; = ' '; &#125; else &#123; str&#91;0&#93; = '0'+n; &#125;
	n = &#40;num / 10&#41; % 10;
	if &#40;n==0&#41; &#123; str&#91;1&#93; = ' '; &#125; else &#123; str&#91;1&#93; = '0'+n; &#125;
	str&#91;2&#93; = '0'+&#40;num % 10&#41;;
	str&#91;3&#93; = 0;
	pgPrint&#40;x,y,col,str&#41;;
&#125;

// Hiscore
void ReadHighScore&#40;void&#41; &#123;
	int fd;
	fd = sceIoOpen&#40;SCOREFILE_PATH,O_RDWR&#41;;
	if &#40;fd>=0&#41; &#123;
		sceIoRead&#40;fd, &#40;void *&#41;&high_score, sizeof&#40;int&#41;&#41;;
		sceIoClose&#40;fd&#41;;
	&#125; else &#123;
		pgFillvram&#40;rgb2col&#40;0,0,0&#41;&#41;;
		pgPrint&#40;0,0,rgb2col&#40;255,0,0&#41;,"ERROR &#58; CANNOT READ"&#41;;
		pgPrint&#40;0,1,rgb2col&#40;255,0,0&#41;,SCOREFILE_PATH&#41;;
		wait_button&#40;&#41;;
		pgFillvram&#40;rgb2col&#40;0,0,0&#41;&#41;;
	&#125;
&#125;

void WriteHighScore&#40;void&#41; &#123;
	int fd;
	fd = sceIoOpen&#40;SCOREFILE_PATH,O_RDWR&#41;;
	if &#40;fd>=0&#41; &#123;
		sceIoWrite&#40;fd, &#40;void *&#41;&high_score, sizeof&#40;int&#41;&#41;;
		sceIoClose&#40;fd&#41;;
	&#125;
&#125;

// title
void Title&#40;void&#41; &#123;
	pgWaitV&#40;&#41;;
	pgFillvram&#40;rgb2col&#40;0,0,0&#41;&#41;;
	pgPrint&#40;20,12,0xffff,"S i m p l e  T u r n"&#41;;
	pgPrint&#40;22,24,0xffff,"High Score &#58; "&#41;;
	DisplayScore&#40;35,24,rgb2col&#40;0,0,0&#41;,0xffff,high_score&#41;;
	wait_button&#40;&#41;;
&#125;

// game
void Game&#40;void&#41; &#123;
	int				x,y,my_x,my_y,btn,flg,dir,score;
	unsigned short	*vr,*vr2,col;
	int				back_col;
	ctrl_data_t		ctl;

	// �‰Šú‰»
	my_x     = 0;
	my_y     = 0;
	dir      = 0;
	score    = 0;
	back_col = rgb2col&#40;0,0,64&#41;;

	// ƒQ�&#91;ƒ€ƒtƒB�&#91;ƒ‹ƒh•`‰æ
	pgWaitV&#40;&#41;;
	pgFillvram&#40;back_col&#41;;
	col = rgb2col&#40;128,128,128&#41;;
	for&#40;y=0;y<8;y++&#41; &#123;
		vr = &#40;unsigned short *&#41;pgGetVramAddr&#40;0,y&#41;;
		for&#40;x=0;x<SCREEN_WIDTH;x++&#41; *vr++ = col;
	&#125;
	for&#40;y=8;y<&#40;SCREEN_HEIGHT-16&#41;;y++&#41; &#123;
		vr  = &#40;unsigned short *&#41;pgGetVramAddr&#40;0,y&#41;;
		vr2 = &#40;unsigned short *&#41;pgGetVramAddr&#40;SCREEN_WIDTH-8,y&#41;;
		for&#40;x=0;x<8;x++&#41; &#123; *vr++ = col; *vr2++ = col; &#125;
	&#125;
	for&#40;y=0;y<8;y++&#41; &#123;
		vr = &#40;unsigned short *&#41;pgGetVramAddr&#40;0,&#40;SCREEN_HEIGHT-16&#41;+y&#41;;
		for&#40;x=0;x<SCREEN_WIDTH;x++&#41; *vr++ = col;
	&#125;
	pgPrint&#40;49,33,0xffff,"Score &#58; "&#41;;
	DisplayScore&#40;57,33,back_col,0xffff,score&#41;;

	//help here 
	sceCtrlRead&#40;&ctl,1&#41;;
	btn   = &#40;&#40;ctl.buttons & 0xF000&#41; != 0&#41;;
	flg   = btn;

	// help her how do i point out the btn
	while&#40;1&#41; &#123;
		// Ž©‹@•`‰æ
		col = rgb2col&#40;255,255,255&#41;;
		for&#40;y=0;y<8;y++&#41; &#123;
			vr  = &#40;unsigned short *&#41;pgGetVramAddr&#40;my_x*8+8,my_y*8+8+y&#41;;
			for&#40;x=0;x<8;x++&#41; *vr++ = col;
		&#125;

		// ƒ&#123;ƒ^ƒ“”»’è
		sceCtrlRead&#40;&ctl,1&#41;;//help here
		btn = &#40;&#40;ctl.buttons & 0xF000&#41; != 0&#41;;
		if &#40;btn&#41; &#123;
			if &#40;!flg&#41; &#123;
				dir = &#40;dir+1&#41; % 4;
				score++;
				DisplayScore&#40;57,33,back_col,0xffff,score&#41;;
			&#125;
			flg = 1;
		&#125; else &#123;
			flg = 0;
		&#125;

		// �i�s
		switch&#40;dir&#41; &#123;
		case 0&#58;		my_x++; break;
		case 1&#58;		my_y++; break;
		case 2&#58;		my_x--;	break;
		default&#58;	my_y--;	break;
		&#125;

		// �Õ“Ë”»’è
		vr  = &#40;unsigned short *&#41;pgGetVramAddr&#40;my_x*8+8,my_y*8+8&#41;;
		if &#40;*vr != back_col&#41; break;

		// VSync‘Ò‚¿
		pgWaitV&#40;&#41;;
	&#125;

	// ƒQ�&#91;ƒ€ƒI�&#91;ƒo�&#91;
	pgWaitV&#40;&#41;;
	pgPrint4&#40;3,3,rgb2col&#40;255,255,0&#41;,"GAME OVER"&#41;;
	if &#40;high_score < score&#41; &#123;
		pgPrint2&#40;6,9,rgb2col&#40;255,0,0&#41;,"--- HIGH SCORE! ---"&#41;;
		high_score = score;
		WriteHighScore&#40;&#41;;
	&#125;
	pgWaitVn&#40;30&#41;;
	pgPrint&#40;23,21,rgb2col&#40;255,255,0&#41;,"PRESS ANY KEY"&#41;;
	
	wait_button&#40;&#41;;
&#125;



int xmain&#40;void&#41;
&#123;
	// Initialize
	pgInit&#40;&#41;;
	pgScreenFrame&#40;1,0&#41;;
	sceCtrlInit&#40;0&#41;;
	sceCtrlSetAnalogMode&#40;0&#41;;

	high_score = 0;
	ReadHighScore&#40;&#41;;

	while&#40;1&#41; &#123;
		Title&#40;&#41;;
		Game&#40;&#41;;
	&#125;

	return 0;
&#125;
skippy911
Posts: 46
Joined: Fri May 06, 2005 10:20 am

Post by skippy911 »

Your problem is you have part of a comment remaining:

unsigned short rgb2col(unsigned char r,unsigned char g,unsigned char b) {
return ((((b>>3) & 0x1F)<<10)+(((g>>3) & 0x1F)<<5)+(((r>>3) & 0x1F)<<0)+0x8000);
}


Make you code look like the above with the /* removed
Post Reply