compile error, plz T.T (cygwin + pspsdk + sdl + toolchain)

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

Moderators: cheriff, TyRaNiD

Post Reply
hd2dj07
Posts: 1
Joined: Fri Apr 15, 2005 9:06 pm

compile error, plz T.T (cygwin + pspsdk + sdl + toolchain)

Post by hd2dj07 »

Code: Select all

/*
	BRIX: professional edition

- Original Copyrights by 1989 TAITO "PUZZNIC", cloned by 1990 Epic Megagames "BRIX"
- Developed by Minan2DJ07 (Park Byeong-uk, [email protected])
- Font Algorithm by Tokigun (http://tokigun.net)
- SDL Library Version Information

  SDL 1.2.9
  SDL_image 1.2.4
  SDL_mixer 1.2.6

- This game is use only for Not-Commerce
- This Code is based on Windows32(VC++6) / Cygwin(PSPSDK+toolchain+SDL)
- Latest modified: 2006. 5.17
*/

#ifdef PSP
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#endif
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <SDL.h>
#include <SDL_mixer.h>
#include <SDL_image.h>
#include <SDL_endian.h>
#ifdef WIN32
#include "resource.h"
#endif

// Screen Size, Bitrate
#define screen_width 480
#define screen_height 272
#define screen_bitrate 32

// is it FULLSCREEN ?
#define opt_fullscreen 0

#define mode 6

// size of block graphic
#define blocksize 16

// start-point of stage
#define stage_x 128
#define stage_y 32

/******************************************************************************/
/* constants, variables */
// TitleBar Text
char version&#91;&#93; = "BRIX&#58; professional edition v0.0-dev-20060517";

// stage array, matrix&#91;y&#93;&#91;x&#93;
// size of matrix
int size_x = 22;
int size_y = 15;
int matrix&#91;15&#93;&#91;22&#93;=&#123;
&#123;-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,-1&#125;, // 0
&#123; 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1&#125;, // 1
&#123; 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1&#125;, // 2
&#123; 1, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 1&#125;, // 3
&#123; 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1&#125;, // 4
&#123; 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1&#125;, // 5
&#123; 1, 7, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 6, 1&#125;, // 6
&#123; 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1&#125;, // 7
&#123; 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1&#125;, // 8
&#123; 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1&#125;, // 9
&#123; 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1&#125;, // 10
&#123; 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1&#125;, // 11
&#123; 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1&#125;, // 12
&#123; 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 4, 5, 0, 0, 0, 0, 0, 0, 0, 3, 1, 1&#125;, // 13
&#123;-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,-1&#125;  // 14
&#125;;
int score = 0;
int highscore = 50000;
char mapname&#91;&#93; = "BRIX&#58; professional edition TEST MAP";
// point of cursor
int cursor_point&#91;2&#93; = &#123;128+32,32+32&#125;;

// is pressed select key &#40;space bar&#41; ?
int ispressed = 0;
// time of game start
int timer_start = 0;
// remove condition
int arg&#91;14&#93;&#91;3&#93;&#91;3&#93; = &#123;
&#123; &#123;0,0,0&#125;, &#123;1,1,1&#125;, &#123;0,0,0&#125; &#125;,
&#123; &#123;0,1,0&#125;, &#123;0,1,0&#125;, &#123;0,1,0&#125; &#125;,
&#123; &#123;0,1,1&#125;, &#123;0,1,0&#125;, &#123;0,0,0&#125; &#125;,
&#123; &#123;1,1,0&#125;, &#123;0,1,0&#125;, &#123;0,0,0&#125; &#125;,
&#123; &#123;0,0,0&#125;, &#123;0,1,0&#125;, &#123;1,1,0&#125; &#125;,
&#123; &#123;0,0,0&#125;, &#123;0,1,0&#125;, &#123;0,1,1&#125; &#125;,
&#123; &#123;1,0,0&#125;, &#123;1,1,0&#125;, &#123;0,0,0&#125; &#125;,
&#123; &#123;0,0,0&#125;, &#123;1,1,0&#125;, &#123;1,0,0&#125; &#125;,
&#123; &#123;0,0,1&#125;, &#123;0,1,1&#125;, &#123;0,0,0&#125; &#125;,
&#123; &#123;0,0,0&#125;, &#123;0,1,1&#125;, &#123;0,0,1&#125; &#125;,
&#123; &#123;0,1,0&#125;, &#123;0,1,0&#125;, &#123;0,0,0&#125; &#125;,
&#123; &#123;0,0,0&#125;, &#123;0,1,1&#125;, &#123;0,0,0&#125; &#125;,
&#123; &#123;0,0,0&#125;, &#123;0,1,0&#125;, &#123;0,1,0&#125; &#125;,
&#123; &#123;0,0,0&#125;, &#123;1,1,0&#125;, &#123;0,0,0&#125; &#125; &#125;;
// pieces of left blocks
int left_block&#91;8&#93; = &#123;0,&#125;;
// check stage clear
int isStageClear = 0;
// is game executing?
int done = 0;

// code by tokigun
#define ARRAYSIZE&#40;x&#41; &#40;sizeof&#40;x&#41;/sizeof&#40;*x&#41;&#41;

/******************************************************************************/
/* Setting about PSP */
#ifdef PSP
	// Define the module info section
	PSP_MODULE_INFO&#40;"BRIXPRO", 0, 1, 1&#41;;
	
	// Define the main thread's attribute value &#40;optional&#41;
	PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER | THREAD_ATTR_VFPU&#41;;
	
	// Define printf, just to make typing easier
	#define printf	pspDebugScreenPrintf
	
	void dump_threadstatus&#40;void&#41;;
		
	// PSP Controller
	SceCtrlData pad;
	
	// Exit callback
	int exit_callback&#40;int arg1, int arg2, void *common&#41;
	&#123;
		done = 1;
		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;
#endif

/******************************************************************************/
/* system dependent functions */
#ifdef WIN32
	#include <windows.h>

	// Output MessageBox
	int msg&#40;char *c,char *s&#41;
	&#123;
		char b&#91;512&#93;;
		sprintf&#40;b,c,s&#41;;
		return MessageBox&#40;0,b,version,0&#41;;
	&#125;

#else
	#include <dirent.h>

	// Output MessageBox
	int msg&#40;char *c,char *s&#41;
	&#123;
		return fprintf&#40;stderr,c,s&#41;;
	&#125;

#endif

/******************************************************************************/
/* general functions */

// function by tokigun
int is_space&#40;int n&#41; &#123; return!&#40;n-9&&n-10&&n-13&&n-32&#41;; &#125;

// return x,y point to matrix&#40;cell&#41; point
int x2cx&#40;int x&#41;
&#123;
	return &#40;x-stage_x&#41;/blocksize;
&#125;
int y2cy&#40;int y&#41;
&#123;
	return &#40;y-stage_y&#41;/blocksize;
&#125;

/******************************************************************************/
/* general graphic functions */
// Main Screen Object
SDL_Surface *screen;
// Main Event Object
#ifdef WIN32
	SDL_Event event;
#endif

// Original Block BitmapData Surface
SDL_Surface *cursoroff;
SDL_Surface *cursoron;
SDL_Surface *blockdata_bg;
SDL_Surface *blockdata_blank;
SDL_Surface *blockdata_stage;
SDL_Surface *blockdata_sprite1;
SDL_Surface *blockdata_sprite2;
SDL_Surface *blockdata_sprite3;
SDL_Surface *blockdata_sprite4;
SDL_Surface *blockdata_sprite5;
SDL_Surface *blockdata_sprite6;
SDL_Surface *blockdata_sprite7;
SDL_Surface *blockdata_sprite8;

// code and functions by tokigun
SDL_Rect rect&#91;2&#93;; int _rect=0;
int getpixel&#40;SDL_Surface *s, int x, int y&#41;
	&#123; return&#40;&#40;Uint32*&#41;s->pixels&#41;&#91;x+y*s->pitch/4&#93;; &#125;
int putpixel&#40;SDL_Surface *s, int x, int y, int c&#41;
	&#123; return&#40;&#40;Uint32*&#41;s->pixels&#41;&#91;x+y*s->pitch/4&#93;=c; &#125;
int blend&#40;int x, int y, int a, int b&#41;
	&#123; int i=0;for&#40;;i<24;i+=8&#41;y+=&#40;&#40;x>>i&255&#41;-&#40;y>>i&255&#41;&#41;*a/b<<i;return y; &#125;
void putblendedpixel&#40;SDL_Surface *s, int x, int y, int c, int o&#41;
	&#123; putpixel&#40;s, x, y, blend&#40;getpixel&#40;s,x,y&#41;, c, o, 255&#41;&#41;; &#125;
SDL_Rect *newrect&#40;int x, int y, int w, int h&#41;
	&#123; SDL_Rect*r=rect+_rect++%2;r->x=x;r->y=y;r->w=w;r->h=h;return r; &#125;

// end functions by tokigun

// load image graphics to SDL Surface
#ifdef WIN32
SDL_Surface *loadimage&#40;const int resID, char *type&#41;
&#123;
	SDL_RWops *res_handle;
	HRSRC hres;
	HGLOBAL hnd;
	int rsz;

	res_handle = NULL;
	hres = FindResource&#40;NULL, MAKEINTRESOURCE&#40;resID&#41;, type&#41;;
	if&#40;hres&#41;
	&#123;
		hnd = LoadResource&#40;NULL, hres&#41;;
	&#125;
	if &#40;hnd&#41;
	&#123;
		hnd = LockResource&#40;hnd&#41;;
		rsz = SizeofResource&#40;NULL, hres&#41;;
	&#125;

	res_handle = SDL_RWFromMem&#40; hnd, rsz &#41;;
	if&#40;type == "BMP"&#41; return SDL_LoadBMP_RW&#40; res_handle, 1 &#41;;
	else return IMG_LoadTyped_RW&#40; res_handle, 1 , type &#41;;
&#125;
#endif
#ifdef PSP
SDL_Surface *loadimage&#40;char *file, char *type&#41;
&#123;
	if&#40;type == "BMP"&#41; return SDL_LoadBMP&#40;file&#41;;
	else return IMG_Load &#40;file&#41;;
&#125;
#endif

/******************************************************************************/
/* font functions */
// developed by tokigun
char*fontdata="#&#91;RCm#a&#e#;S&e#;C$#;#e&e2Y#e#G#f&#58;i&&#41;;V0a;*e%Y#&g7+CC2NP&#41;=aOS=NP"
	"I2+C#fbC&#40;Y;&#41;S#&#41;S/Y3&#hX&#91;S&#41;>OPV=Q<I>^#hh/S#&;#$mseNg#;S#hRe+g#;#&iG;O`YaDDB"
	">R0&#41;jW;C$&#41;a$e&mfh7jSe~a$p?hWir%;#e~C$'jpa/Y;J`YAV0Y;a#hs?S&./#g#b#lB1S$1S$"
	"YBkR&&#91;T#&#kR1&#91;D0I$e#b<C$htb$&#41;;C\\*mBebC\\Z;e#iRb0S#&#41;S#&#41;f#krF$f&mRF0Y2lb##h"
	"LkRl2S#hsepS#&#41;/;SC$iReya$g%ibg>fFhra/Y;F$eUeyi2$X88e#A$G2hq+SD0eDb$eHineRf"
	"&F$itA/V;C$e#F0F*hr_<&#41;f?F0I<_$hrb$e@a$fDb$q2C$mbJ0&#41;kbf&#125;b$gehraD$i#a$hr&#g#"
	"eHa#iRIT&#41;AS$*AO<&#41;iRg&#125;f'b$irZ`ZBNP&#41;lre&#125;VPZ>J$k2?;&f>F0I0?#hra$fMa$fhhra#gAN"
	"`I2*/#mBlreBC\\V#&/Y;a#ib;#j#hrgafviBi2YS$%lBNPY=b<F0hr$0Y@aS$*a?Z;$$hr$1O"
	"<_#nrb0S#*&#91;#*&#91;#*;b$hr_#&i#_#hr##';SC$&&#41;+#i0#S&&i#gB+SD0j&#123;r&#40;hrf^qBa/S#b/Y;F"
	"`&htC$&#41;;a$e0F0IBkBF0&#41;;C0Y;a#hy&#hPkRgBF`*;jB1OT&#41;;&#91;*&#41;f#jbgQb/#hdC$&#41;;a$gaF0&#41;"
	"hreJgPjR&/#f&&#eQhtC$Y;IT&#41;A&#91;TI<iR?S#j#hb##C@bP&#41;e#jr##CBe~f%jBa#h2gpmBa$&#41;;C"
	"$gub#hRb/S#&#jbe=i?gbC\\V#&#jb;CDB;C$&#41;>OT&#41;1#jrhqjBi2YS$%mBNPY=b<&jr$$e??;V"
	";$$nbV&#91;$&;#&;htb@C&?C&?C`*gr1C$e#S$f'1#e~f/n&###h=gGhrSHbJfLu%aT&&#41;";
Uint8 rawfont&#91;16&#93;&#91;96&#93;, &#40;*zoomfont&#91;16&#93;&#41;&#91;96&#93;=&#123;rawfont,0,&#125;;

int _fontprocess&#40;int x, int y, int z, int c, int s&#41; &#123;
	int i, j;
	for&#40;i=0; i<z; i++&#41;
		for&#40;j=&#40;s==1?z-i&#58;s==3?i+1&#58;0&#41;; j<&#40;s==2?i&#58;s==4?z-i-1&#58;z&#41;; j++&#41;
			zoomfont&#91;z-1&#93;&#91;&#40;y*z+i&#41;*z+j&#93;&#91;c&#93; |= 1<<&#40;7-x&#41;;
	return z;
&#125;

void fontprocess&#40;int z&#41; &#123;
	int i, j, k, l, t&#91;1596&#93;;
	if&#40;z&#41; &#123;
		if&#40;zoomfont&#91;z-1&#93;&#41; return;
		zoomfont&#91;z-1&#93; = malloc&#40;96*16*z*z&#41;;
		for&#40;i=0; i<96; i++&#41; &#123;
			for&#40;j=0; j<16*z*z; j++&#41;
				zoomfont&#91;z-1&#93;&#91;j&#93;&#91;i&#93; = 0;
			for&#40;j=0; j<16; j++&#41;
				for&#40;k=0; k<8; k++&#41; &#123;
					l = &#40;j>0?rawfont&#91;j-1&#93;&#91;i&#93;<<k>>6&7&#58;0&#41;<<6 |
						&#40;rawfont&#91;j&#93;&#91;i&#93;<<k>>6&7&#41;<<3 |
						&#40;j<15?rawfont&#91;j+1&#93;&#91;i&#93;<<k>>6&7&#58;0&#41;;
					if&#40;&#40;i==3 || i==20&#41; && k<2&#41; l |= &#40;l & 0222&#41; << 1;
					if&#40;&#40;i==3 || i==20&#41; && k>6&#41; l |= &#40;l & 0222&#41; >> 1;
					if&#40;l & 0x10&#41; &#123;
						_fontprocess&#40;k, j, z, i, 0&#41;;
					&#125; else &#123;
						if&#40;&#40;l & 0xda&#41; == 0xa || &#40;l & 0x3f&#41; == 0xb&#41; /* /| */
							_fontprocess&#40;k, j, z, i, 1&#41;;
						if&#40;&#40;l & 0x1b2&#41; == 0x22 || &#40;l & 0x3f&#41; == 0x26&#41; /* |\ */
							_fontprocess&#40;k, j, z, i, 2&#41;;
						if&#40;&#40;l & 0x9b&#41; == 0x88 || &#40;l & 0x1f8&#41; == 0xc8&#41; /* \| */
							_fontprocess&#40;k, j, z, i, 3&#41;;
						if&#40;&#40;l & 0xb6&#41; == 0xa0 || &#40;l & 0x1f8&#41; == 0x1a0&#41; /* |/ */
							_fontprocess&#40;k, j, z, i, 4&#41;;
					&#125;
				&#125;
		&#125;
	&#125; else &#123;
		for&#40;i=j=k=0; i<1536; fontdata++&#41; &#123;
			if&#40;*fontdata > 98&#41; &#123;
				for&#40;k=*fontdata++-97; --k; i++&#41; t&#91;i&#93; = t&#91;i-*fontdata+34&#93;;
			&#125; else if&#40;*fontdata > 34&#41; &#123;
				j |= &#40;*fontdata - 35&#41; << k*6%8;
				if&#40;k++&3&#41; &#123; t&#91;i++&#93; = j & 0xff; j >>= 8; &#125;
			&#125;
		&#125;
		for&#40;i=0; i<1536; i++&#41; rawfont&#91;i%16&#93;&#91;i/16&#93; = t&#91;i&#93;;
	&#125;
&#125;

void fontfinalize&#40;&#41; &#123;
	int i;
	for&#40;i=1; i<ARRAYSIZE&#40;zoomfont&#41;; i++&#41;
		if&#40;zoomfont&#91;i&#93;&#41; free&#40;zoomfont&#91;i&#93;&#41;;
&#125;

int printchar&#40;SDL_Surface *s, int x, int y, int z, int c, int u, int v&#41; &#123;
	int i, j;
	if&#40;!is_space&#40;c&#41;&#41; &#123;
		c -= &#40;c<0 ? -96 &#58; c<33 || c>126 ? c &#58; 32&#41;;
		for&#40;i=0; i<16*z; i++&#41;
			for&#40;j=0; j<8*z; j++&#41;
				if&#40;zoomfont&#91;z-1&#93;&#91;i*z+j%z&#93;&#91;c&#93;&&#40;1<<&#40;7-j/z&#41;&#41;&#41;
					putpixel&#40;s, x+9*j/10, y+9*i/10, blend&#40;u, v, i, 16*z-1&#41;&#41;;
	&#125;
	return 8*z;
&#125;

void printstr&#40;SDL_Surface *s, int x, int y, int z, char *c, int u, int v&#41;
	&#123; while&#40;*c&#41;x+=printchar&#40;s,x,y,z,&#40;Uint8&#41;*c++,u,v&#41;; &#125;
// end devoloped by tokigun

// print text string to screen surface
void text&#40;char *c, int x, int y, int u, int v&#41;
&#123;
	printstr&#40;screen, x, y, 1, c, u, v&#41;;
&#125;

/******************************************************************************/
/* main routines */

void load_blockdata&#40;&#41;
&#123;
	#ifdef WIN32
		cursoroff = loadimage&#40;IDR_CURSOROFF,"PNG"&#41;;
		cursoron = loadimage&#40;IDR_CURSORON,"PNG"&#41;;
		blockdata_bg = loadimage&#40;IDR_BGBLOCK,"PNG"&#41;;
		blockdata_stage = loadimage&#40;IDR_STAGEBLOCK,"PNG"&#41;;
		blockdata_blank = loadimage&#40;IDR_BLANK,"PNG"&#41;;
		blockdata_sprite1 = loadimage&#40;IDR_SPRITE1,"PNG"&#41;;
		blockdata_sprite2 = loadimage&#40;IDR_SPRITE2,"PNG"&#41;;
		blockdata_sprite3 = loadimage&#40;IDR_SPRITE3,"PNG"&#41;;
		blockdata_sprite4 = loadimage&#40;IDR_SPRITE4,"PNG"&#41;;
		blockdata_sprite5 = loadimage&#40;IDR_SPRITE5,"PNG"&#41;;
		blockdata_sprite6 = loadimage&#40;IDR_SPRITE6,"PNG"&#41;;
		blockdata_sprite7 = loadimage&#40;IDR_SPRITE7,"PNG"&#41;;
		blockdata_sprite8 = loadimage&#40;IDR_SPRITE8,"PNG"&#41;;
	#else
		cursoroff = loadimage&#40;"cursorblock.png","PNG"&#41;;
		cursoron = loadimage&#40;"cursorblock_selected.png","PNG"&#41;;
		blockdata_bg = loadimage&#40;"bgblock.png","PNG"&#41;;
		blockdata_stage = loadimage&#40;"stageblock.png","PNG"&#41;;
		blockdata_blank = loadimage&#40;"blankblock.png","PNG"&#41;;
		blockdata_sprite1 = loadimage&#40;"spriteblock1.png","PNG"&#41;;
		blockdata_sprite2 = loadimage&#40;"spriteblock2.png","PNG"&#41;;
		blockdata_sprite3 = loadimage&#40;"spriteblock3.png","PNG"&#41;;
		blockdata_sprite4 = loadimage&#40;"spriteblock4.png","PNG"&#41;;
		blockdata_sprite5 = loadimage&#40;"spriteblock5.png","PNG"&#41;;
		blockdata_sprite6 = loadimage&#40;"spriteblock6.png","PNG"&#41;;
		blockdata_sprite7 = loadimage&#40;"spriteblock7.png","PNG"&#41;;
		blockdata_sprite8 = loadimage&#40;"spriteblock8.png","PNG"&#41;;
	#endif
&#125;

void draw_bgsurface&#40;&#41;
&#123;
	int i,j;

	for&#40;i=0;i<480/blocksize;i++&#41;
	&#123;
		for&#40;j=0;j<272/blocksize;j++&#41;
		&#123;
			SDL_BlitSurface&#40; blockdata_bg, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;i*blocksize,j*blocksize,blocksize,blocksize&#41; &#41;;
		&#125;
	&#125;
&#125;

void draw_stagesurface&#40;&#41;
&#123;
	int i,j;

	for&#40;i=0;i<size_x;i++&#41;
	&#123;
		for&#40;j=0;j<size_y;j++&#41;
		&#123;
			if&#40;matrix&#91;j&#93;&#91;i&#93; == 0&#41; SDL_BlitSurface&#40; blockdata_blank, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;stage_x+i*blocksize,stage_y+j*blocksize,blocksize,blocksize&#41; &#41;;
			else if&#40;matrix&#91;j&#93;&#91;i&#93; == 1&#41; SDL_BlitSurface&#40; blockdata_stage, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;stage_x+i*blocksize,stage_y+j*blocksize,blocksize,blocksize&#41; &#41;;
			else if&#40;matrix&#91;j&#93;&#91;i&#93; == 2&#41; SDL_BlitSurface&#40; blockdata_sprite1, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;stage_x+i*blocksize,stage_y+j*blocksize,blocksize,blocksize&#41; &#41;;
			else if&#40;matrix&#91;j&#93;&#91;i&#93; == 3&#41; SDL_BlitSurface&#40; blockdata_sprite2, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;stage_x+i*blocksize,stage_y+j*blocksize,blocksize,blocksize&#41; &#41;;
			else if&#40;matrix&#91;j&#93;&#91;i&#93; == 4&#41; SDL_BlitSurface&#40; blockdata_sprite3, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;stage_x+i*blocksize,stage_y+j*blocksize,blocksize,blocksize&#41; &#41;;
			else if&#40;matrix&#91;j&#93;&#91;i&#93; == 5&#41; SDL_BlitSurface&#40; blockdata_sprite4, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;stage_x+i*blocksize,stage_y+j*blocksize,blocksize,blocksize&#41; &#41;;
			else if&#40;matrix&#91;j&#93;&#91;i&#93; == 6&#41; SDL_BlitSurface&#40; blockdata_sprite5, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;stage_x+i*blocksize,stage_y+j*blocksize,blocksize,blocksize&#41; &#41;;
			else if&#40;matrix&#91;j&#93;&#91;i&#93; == 7&#41; SDL_BlitSurface&#40; blockdata_sprite6, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;stage_x+i*blocksize,stage_y+j*blocksize,blocksize,blocksize&#41; &#41;;
			else if&#40;matrix&#91;j&#93;&#91;i&#93; == 8&#41; SDL_BlitSurface&#40; blockdata_sprite7, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;stage_x+i*blocksize,stage_y+j*blocksize,blocksize,blocksize&#41; &#41;;
			else if&#40;matrix&#91;j&#93;&#91;i&#93; == 9&#41; SDL_BlitSurface&#40; blockdata_sprite8, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;stage_x+i*blocksize,stage_y+j*blocksize,blocksize,blocksize&#41; &#41;;
		&#125;
	&#125;
&#125;

// get return of specified cell information
int get_matrix_cell&#40;int x, int y&#41;
&#123;
	return matrix&#91;y2cy&#40;y&#41;&#93;&#91;x2cx&#40;x&#41;&#93;;
&#125;

// move cell, by cursor, if block selected, move with block
void move&#40;int x, int y&#41;
&#123;
	int nextcell, nowcell;

	if&#40;x < stage_x&#41; x = stage_x;
	if&#40;x > screen_width - blocksize&#41; x = screen_width - blocksize;
	if&#40;y < stage_y&#41; y = stage_y;
	if&#40;y > screen_height - blocksize&#41; y = screen_height - blocksize;

	// get read of cell information
	nextcell = get_matrix_cell&#40;x,y&#41;;
	nowcell = get_matrix_cell&#40;cursor_point&#91;0&#93;,cursor_point&#91;1&#93;&#41;;
	if&#40;nowcell > 1 && nowcell < 10&#41;
	&#123;
		if&#40;ispressed == 1 && nextcell == 0&#41;
		&#123;
			matrix&#91;y2cy&#40;y&#41;&#93;&#91;x2cx&#40;x&#41;&#93; = nowcell;
			matrix&#91;y2cy&#40;cursor_point&#91;1&#93;&#41;&#93;&#91;x2cx&#40;cursor_point&#91;0&#93;&#41;&#93; = 0;
		&#125;
	&#125;
	cursor_point&#91;0&#93; = x;
	cursor_point&#91;1&#93; = y;
&#125;

// check matrix
void check_matrix&#40;&#41;
&#123;
	int i,j;
	int k,a,b;
	int isEqual;
	int cell;
	int cell_arg&#91;3&#93;&#91;3&#93; = &#123; &#123;0,0,0&#125;, &#123;0,1,0&#125;, &#123;0,0,0&#125; &#125;;
	int cell_arg2&#91;5&#93;&#91;5&#93; = &#123; &#123;0,0,0,0,0&#125;, &#123;0,0,0,0,0&#125;, &#123;0,0,1,0,0&#125;, &#123;0,0,0,0,0&#125;, &#123;0,0,0,0,0&#125; &#125;;

	for&#40;i=0;i<size_x;i++&#41;
	&#123;
		for&#40;j=0;j<size_y;j++&#41;
		&#123;
			cell = matrix&#91;j&#93;&#91;i&#93;;

			// check and block down
			// if down-cell is blank, block move down
			if&#40;matrix&#91;j+1&#93;&#91;i&#93; == 0 && matrix&#91;j&#93;&#91;i&#93; > 1 && matrix&#91;j&#93;&#91;i&#93; < 10&#41;
			&#123;
				matrix&#91;j+1&#93;&#91;i&#93; = matrix&#91;j&#93;&#91;i&#93;;
				matrix&#91;j&#93;&#91;i&#93; = 0;
			&#125;

			// check and block remove
			// if current cell is sprite block
			if&#40;matrix&#91;j&#93;&#91;i&#93; > 1 && matrix&#91;j&#93;&#91;i&#93; < 10&#41;
			&#123;
				// insert information
				// if&#40;current cell is equal side cell, insert 1, else 0;
				for&#40;a=0;a<5;a++&#41;
				&#123;
					for&#40;b=0;b<5;b++&#41;
					&#123;
						if&#40;matrix&#91;j&#93;&#91;i&#93; == matrix&#91;j+a-2&#93;&#91;i+b-2&#93;&#41; cell_arg2&#91;a&#93;&#91;b&#93; = 1;
						else cell_arg2&#91;a&#93;&#91;b&#93; = 0;
					&#125;
				&#125;
				// if outside is all 0
				if&#40;cell_arg2&#91;0&#93;&#91;0&#93; == 0 && cell_arg2&#91;0&#93;&#91;1&#93; == 0 && cell_arg2&#91;0&#93;&#91;2&#93; == 0 && cell_arg2&#91;0&#93;&#91;3&#93; == 0 && cell_arg2&#91;0&#93;&#91;4&#93; == 0
					&& cell_arg2&#91;1&#93;&#91;0&#93; == 0 && cell_arg2&#91;1&#93;&#91;4&#93; == 0 && cell_arg2&#91;2&#93;&#91;0&#93; == 0 && cell_arg2&#91;2&#93;&#91;4&#93; == 0 && cell_arg2&#91;3&#93;&#91;0&#93; == 0 && cell_arg2&#91;3&#93;&#91;4&#93; == 0
					&& cell_arg2&#91;4&#93;&#91;0&#93; == 0 && cell_arg2&#91;4&#93;&#91;1&#93; == 0 && cell_arg2&#91;4&#93;&#91;2&#93; == 0 && cell_arg2&#91;4&#93;&#91;3&#93; == 0 && cell_arg2&#91;4&#93;&#91;4&#93; == 0&#41;
				&#123;
					// insert cell information to another array
					for&#40;a=1;a<4;a++&#41;
					&#123;
						for&#40;b=1;b<4;b++&#41;
						&#123;
							cell_arg&#91;a-1&#93;&#91;b-1&#93; = cell_arg2&#91;a&#93;&#91;b&#93;;
						&#125;
					&#125;
					// check current cell information is matching remove arguments
					for&#40;k=0;k<14;k++&#41;
					&#123;
						isEqual = 0;
						// check array is all equal
						for&#40;a=0;a<3;a++&#41;
						&#123;
							for&#40;b=0;b<3;b++&#41;
							&#123;
								if&#40;cell_arg&#91;a&#93;&#91;b&#93; == arg&#91;k&#93;&#91;a&#93;&#91;b&#93;&#41; isEqual += 1;
							&#125;
						&#125;
						// if not equal all
						if&#40;isEqual != 9&#41; isEqual = 0;
						// if equal all
						else
						&#123;
							// number of removed pieces
							int piece_remove = 0;

							// remove block by arguments
							if&#40;cell_arg&#91;0&#93;&#91;0&#93; == 1&#41;
							&#123;
								matrix&#91;j-1&#93;&#91;i-1&#93; = 0;
								piece_remove++;
							&#125;
							if&#40;cell_arg&#91;0&#93;&#91;1&#93; == 1&#41;
							&#123;
								matrix&#91;j-1&#93;&#91;i&#93; = 0;
								piece_remove++;
							&#125;
							if&#40;cell_arg&#91;0&#93;&#91;2&#93; == 1&#41;
							&#123;
								matrix&#91;j-1&#93;&#91;i+1&#93; = 0;
								piece_remove++;
							&#125;
							if&#40;cell_arg&#91;1&#93;&#91;0&#93; == 1&#41;
							&#123;
								matrix&#91;j&#93;&#91;i-1&#93; = 0;
								piece_remove++;
							&#125;
							if&#40;cell_arg&#91;1&#93;&#91;1&#93; == 1&#41;
							&#123;
								matrix&#91;j&#93;&#91;i&#93; = 0;
								piece_remove++;
							&#125;
							if&#40;cell_arg&#91;1&#93;&#91;2&#93; == 1&#41;
							&#123;
								matrix&#91;j&#93;&#91;i+1&#93; = 0;
								piece_remove++;
							&#125;
							if&#40;cell_arg&#91;2&#93;&#91;0&#93; == 1&#41;
							&#123;
								matrix&#91;j+1&#93;&#91;i-1&#93; = 0;
								piece_remove++;
							&#125;
							if&#40;cell_arg&#91;2&#93;&#91;1&#93; == 1&#41;
							&#123;
								matrix&#91;j+1&#93;&#91;i&#93; = 0;
								piece_remove++;
							&#125;
							if&#40;cell_arg&#91;2&#93;&#91;2&#93; == 1&#41;
							&#123;
								matrix&#91;j+1&#93;&#91;i+1&#93; = 0;
								piece_remove++;
							&#125;

							// score adding
							score += piece_remove*100;
							// refrash left block
							if&#40;cell == 2&#41; left_block&#91;0&#93; -= piece_remove;
							else if&#40;cell == 3&#41; left_block&#91;1&#93; -= piece_remove;
							else if&#40;cell == 4&#41; left_block&#91;2&#93; -= piece_remove;
							else if&#40;cell == 5&#41; left_block&#91;3&#93; -= piece_remove;
							else if&#40;cell == 6&#41; left_block&#91;4&#93; -= piece_remove;
							else if&#40;cell == 7&#41; left_block&#91;5&#93; -= piece_remove;
							else if&#40;cell == 8&#41; left_block&#91;6&#93; -= piece_remove;
							else if&#40;cell == 9&#41; left_block&#91;7&#93; -= piece_remove;
						&#125;
					&#125;
				&#125;
			&#125;
		&#125;
	&#125;
&#125;

void get_left_block&#40;&#41;
&#123;
	int i,j;

	for&#40;i=0;i<size_x;i++&#41;
	&#123;
		for&#40;j=0;j<size_y;j++&#41;
		&#123;
			if&#40;matrix&#91;j&#93;&#91;i&#93; == 2&#41; left_block&#91;0&#93; += 1;
			if&#40;matrix&#91;j&#93;&#91;i&#93; == 3&#41; left_block&#91;1&#93; += 1;
			if&#40;matrix&#91;j&#93;&#91;i&#93; == 4&#41; left_block&#91;2&#93; += 1;
			if&#40;matrix&#91;j&#93;&#91;i&#93; == 5&#41; left_block&#91;3&#93; += 1;
			if&#40;matrix&#91;j&#93;&#91;i&#93; == 6&#41; left_block&#91;4&#93; += 1;
			if&#40;matrix&#91;j&#93;&#91;i&#93; == 7&#41; left_block&#91;5&#93; += 1;
			if&#40;matrix&#91;j&#93;&#91;i&#93; == 8&#41; left_block&#91;6&#93; += 1;
			if&#40;matrix&#91;j&#93;&#91;i&#93; == 9&#41; left_block&#91;7&#93; += 1;
		&#125;
	&#125;
&#125;

// Initialize Game
int initialize_stage&#40;&#41;
&#123;
	load_blockdata&#40;&#41;;
	draw_bgsurface&#40;&#41;;
	timer_start = SDL_GetTicks&#40;&#41;;
	get_left_block&#40;&#41;;
	//msg&#40;"Initialized Game",NULL&#41;;
	return 0;
&#125;

// Main Game Stage Processor
int stageproc&#40;&#41;
&#123;
	char bleft&#91;2&#93;;
	int i=0, r=0;
	int timer = 0, t_millisecond = 0, t_second = 0, t_minute = 0;
	char text_score&#91;32&#93;, text_highscore&#91;32&#93;, text_mapname&#91;64&#93;, text_time&#91;16&#93;;

	// check clear to proc
	if&#40;isStageClear == 1&#41;
	&#123;
		return 0;
	&#125;

	// check matrix
	check_matrix&#40;&#41;;

	// delete graphic memory in screen surface
	SDL_FreeSurface&#40;screen&#41;;

	// draw stage graphic by matrix cell information
	draw_bgsurface&#40;&#41;;
	draw_stagesurface&#40;&#41;;
	// cursor off
	if&#40;ispressed == 0&#41;
	&#123;
		SDL_BlitSurface&#40; cursoroff, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;cursor_point&#91;0&#93;,cursor_point&#91;1&#93;,blocksize,blocksize&#41; &#41;;
	&#125;
	// cursor on
	else if&#40;ispressed == 1&#41;
	&#123;
		SDL_BlitSurface&#40; cursoron, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;cursor_point&#91;0&#93;,cursor_point&#91;1&#93;,blocksize,blocksize&#41; &#41;;
	&#125;

	// Score Panel
	sprintf&#40;text_score,"%d",score&#41;;
	sprintf&#40;text_highscore,"%d",highscore&#41;;
	sprintf&#40;text_mapname, "MAP&#58; &#91;%s&#93;",mapname&#41;;
	text&#40;"PLAYER 1", 2, 1, 0x000000, 0x000000&#41;;
	text&#40;"PLAYER 1", 1, 0, 0xFFCC33, 0xFFCC33&#41;;
	text&#40;text_score, 81, 1, 0x000000, 0x000000&#41;;
	text&#40;text_score, 80, 0, 0xffffff, 0xffffff&#41;;
	text&#40;"HIGHSCORE",241,1, 0x000000, 0x000000&#41;;
	text&#40;"HIGHSCORE",240,0, 0x339900, 0x339900&#41;;
	text&#40;text_highscore, 321, 1, 0x000000, 0x000000&#41;;
	text&#40;text_highscore, 320, 0, 0xffffff, 0xffffff&#41;;
	// Map Name
	text&#40;text_mapname,6,16, 0x000000, 0x000000&#41;;
	text&#40;text_mapname,5,15, 0x7f7f7f, 0xffffff&#41;;
	// Mode Name
	if&#40;mode == 0&#41;
	&#123;
		text&#40;"&#91;ORIGINAL MODE&#93;",6,33, 0x000000, 0x000000&#41;;
		text&#40;"&#91;ORIGINAL MODE&#93;",5,32, 0x66FF00, 0x66FF00&#41;;
	&#125;
	else if&#40;mode == 1&#41;
	&#123;
		text&#40;"&#91;MANIAC MODE&#93;",13,33, 0x000000, 0x000000&#41;;
		text&#40;"&#91;MANIAC MODE&#93;",12,32, 0x66FF00, 0x66FF00&#41;;
	&#125;
	else if&#40;mode == 2&#41;
	&#123;
		text&#40;"&#91;ULTRA MODE&#93;",16,33, 0x000000, 0x000000&#41;;
		text&#40;"&#91;ULTRA MODE&#93;",15,32, 0x66FF00, 0x66FF00&#41;;
	&#125;
	else if&#40;mode == 3&#41;
	&#123;
		text&#40;"&#91;EASY MODE&#93;",20,33, 0x000000, 0x000000&#41;;
		text&#40;"&#91;EASY MODE&#93;",19,32, 0x66FF00, 0x66FF00&#41;;
	&#125;
	else if&#40;mode == 4&#41;
	&#123;
		text&#40;"&#91;NORMAL MODE&#93;",13,33, 0x000000, 0x000000&#41;;
		text&#40;"&#91;NORMAL MODE&#93;",12,32, 0x66FF00, 0x66FF00&#41;;
	&#125;
	else if&#40;mode == 5&#41;
	&#123;
		text&#40;"&#91;HARD MODE&#93;",20,33, 0x000000, 0x000000&#41;;
		text&#40;"&#91;HARD MODE&#93;",19,32, 0x66FF00, 0x66FF00&#41;;
	&#125;
	else if&#40;mode == 6&#41;
	&#123;
		text&#40;"&#91;LUNATIC MODE&#93;",9,33, 0x000000, 0x000000&#41;;
		text&#40;"&#91;LUNATIC MODE&#93;",8,32, 0x66FF00, 0x66FF00&#41;;
	&#125;

	// Timer Setting
	timer = SDL_GetTicks&#40;&#41; - timer_start;
	if&#40;mode == 0&#41; timer = 240000 - timer;
	else if&#40;mode == 1&#41; timer = 180000 - timer;
	else if&#40;mode == 2&#41; timer = 120000 - timer;
	t_millisecond = timer%1000;
	t_second = timer / 1000;
	if&#40;t_second > 59&#41;
	&#123;
		t_minute = t_second / 60;
		t_second -= 60*t_minute;
	&#125;
	if&#40;t_second < 10&#41; sprintf&#40;text_time, "%d&#58;0%d&#58;%d",t_minute,t_second,t_millisecond&#41;;
	else sprintf&#40;text_time, "%d&#58;%d&#58;%d",t_minute,t_second,t_millisecond&#41;;
	text&#40;text_time,34,46, 0x000000, 0x000000&#41;;
	text&#40;text_time,33,45, 0x33FFFF, 0x33FFFF&#41;;

	// draw lefted sprite panel
	SDL_FillRect&#40;screen, newrect&#40;5,60,118,71&#41;, 0xffffff&#41;;
	SDL_FillRect&#40;screen, newrect&#40;6,61,116,69&#41;, 0x000000&#41;;
	if&#40;left_block&#91;0&#93; != 0&#41;
	&#123;
		SDL_BlitSurface&#40; blockdata_sprite1, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;7,62,blocksize,blocksize&#41; &#41;;
		sprintf&#40;bleft, "%d",left_block&#91;0&#93;&#41;;
		text&#40;" x",19,62,0xffffff, 0xffffff&#41;;
		text&#40;bleft,35,62,0xffffff, 0xffffff&#41;;
	&#125;
	else SDL_FillRect&#40;screen, newrect&#40;7,62,55,16&#41;, 0x000000&#41;;
	if&#40;left_block&#91;1&#93; != 0&#41;
	&#123;
		SDL_BlitSurface&#40; blockdata_sprite2, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;64,62,blocksize,blocksize&#41; &#41;;
		sprintf&#40;bleft, "%d",left_block&#91;1&#93;&#41;;
		text&#40;" x",76,62,0xffffff, 0xffffff&#41;;
		text&#40;bleft,92,62,0xffffff, 0xffffff&#41;;
	&#125;
	else SDL_FillRect&#40;screen, newrect&#40;62,62,55,16&#41;, 0x000000&#41;;
	if&#40;left_block&#91;2&#93; != 0&#41;
	&#123;
		SDL_BlitSurface&#40; blockdata_sprite3, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;7,79,blocksize,blocksize&#41; &#41;;
		sprintf&#40;bleft, "%d",left_block&#91;2&#93;&#41;;
		text&#40;" x",19,79,0xffffff, 0xffffff&#41;;
		text&#40;bleft,35,79,0xffffff, 0xffffff&#41;;
	&#125;
	else SDL_FillRect&#40;screen, newrect&#40;7,79,55,16&#41;, 0x000000&#41;;
	if&#40;left_block&#91;3&#93; != 0&#41;
	&#123;
		SDL_BlitSurface&#40; blockdata_sprite4, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;64,79,blocksize,blocksize&#41; &#41;;
		sprintf&#40;bleft, "%d",left_block&#91;3&#93;&#41;;
		text&#40;" x",76,79,0xffffff, 0xffffff&#41;;
		text&#40;bleft,92,79,0xffffff, 0xffffff&#41;;
	&#125;
	else SDL_FillRect&#40;screen, newrect&#40;64,79,55,16&#41;, 0x000000&#41;;
	if&#40;left_block&#91;4&#93; != 0&#41;
	&#123;
		SDL_BlitSurface&#40; blockdata_sprite5, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;7,96,blocksize,blocksize&#41; &#41;;
		sprintf&#40;bleft, "%d",left_block&#91;4&#93;&#41;;
		text&#40;" x",19,96,0xffffff, 0xffffff&#41;;
		text&#40;bleft,35,96,0xffffff, 0xffffff&#41;;
	&#125;
	else SDL_FillRect&#40;screen, newrect&#40;7,96,55,16&#41;, 0x000000&#41;;
	if&#40;left_block&#91;5&#93; != 0&#41;
	&#123;
		SDL_BlitSurface&#40; blockdata_sprite6, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;64,96,blocksize,blocksize&#41; &#41;;
		sprintf&#40;bleft, "%d",left_block&#91;5&#93;&#41;;
		text&#40;" x",76,96,0xffffff, 0xffffff&#41;;
		text&#40;bleft,92,96,0xffffff, 0xffffff&#41;;
	&#125;
	else SDL_FillRect&#40;screen, newrect&#40;64,96,55,16&#41;, 0x000000&#41;;
	if&#40;left_block&#91;6&#93; != 0&#41;
	&#123;
		SDL_BlitSurface&#40; blockdata_sprite7, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;7,114,blocksize,blocksize&#41; &#41;;
		sprintf&#40;bleft, "%d",left_block&#91;6&#93;&#41;;
		text&#40;" x",19,114,0xffffff, 0xffffff&#41;;
		text&#40;bleft,35,114,0xffffff, 0xffffff&#41;;
	&#125;
	else SDL_FillRect&#40;screen, newrect&#40;7,114,55,16&#41;, 0x000000&#41;;
	if&#40;left_block&#91;7&#93; != 0&#41;
	&#123;
		SDL_BlitSurface&#40; blockdata_sprite8, newrect&#40;0,0,blocksize,blocksize&#41;, screen, newrect&#40;64,114,blocksize,blocksize&#41; &#41;;
		sprintf&#40;bleft, "%d",left_block&#91;7&#93;&#41;;
		text&#40;" x",76,114,0xffffff, 0xffffff&#41;;
		text&#40;bleft,92,114,0xffffff, 0xffffff&#41;;
	&#125;
	else SDL_FillRect&#40;screen, newrect&#40;64,114,55,16&#41;, 0x000000&#41;;

	// clear check
	for&#40;i=0;i<8;i++&#41;
	&#123;
		r += left_block&#91;i&#93;;
	&#125;
	if&#40;r <= 0&#41;
	&#123;
		isStageClear = 1;
	&#125;

	return 1;
&#125;

// Finalize Game
void finalize&#40;&#41;
&#123;
	// remove from memory
	fontfinalize&#40;&#41;;
	SDL_FreeSurface&#40;blockdata_bg&#41;;
	SDL_FreeSurface&#40;blockdata_stage&#41;;
	SDL_FreeSurface&#40;screen&#41;;
	// end of game
	SDL_Quit&#40;&#41;;
	msg&#40;"Finalized Game",NULL&#41;;
&#125;

/******************************************************************************/
/* entry point */
// Procedure
int procedure&#40;&#41;
&#123;
	#ifdef WIN32
		while&#40;SDL_PollEvent&#40;&event&#41;&#41;
		&#123;
			switch&#40;event.type&#41;
			&#123;
				case SDL_QUIT&#58; return 1;
				case SDL_KEYDOWN&#58;
					switch&#40;event.key.keysym.sym&#41;
					&#123;
						case SDLK_ESCAPE&#58; return 1;
						case SDLK_SPACE&#58;
							ispressed = 1;
							break;
						case SDLK_UP&#58;
							move&#40;cursor_point&#91;0&#93;, cursor_point&#91;1&#93;-blocksize&#41;;
							break;
						case SDLK_DOWN&#58;
							move&#40;cursor_point&#91;0&#93;, cursor_point&#91;1&#93;+blocksize&#41;;
							break;
						case SDLK_RIGHT&#58;
							move&#40;cursor_point&#91;0&#93;+blocksize, cursor_point&#91;1&#93;&#41;;
							break;
						case SDLK_LEFT&#58;
							move&#40;cursor_point&#91;0&#93;-blocksize, cursor_point&#91;1&#93;&#41;;
							break;
					&#125;
					break;
				case SDL_KEYUP&#58;
					switch&#40;event.key.keysym.sym&#41;
					&#123;
						case SDLK_SPACE&#58;
							ispressed = 0;
							break;
					&#125;
					break;
				case SDL_MOUSEMOTION&#58; break;
				case SDL_MOUSEBUTTONDOWN&#58; break;
				case SDL_MOUSEBUTTONUP&#58; break;
			&#125;
		&#125;
	#endif
	#ifdef PSP
		sceCtrlReadBufferPositive&#40;&pad, 1&#41;; 
	
		if &#40;pad.Buttons != 0&#41;&#123;
			if &#40;pad.Buttons & PSP_CTRL_SQUARE&#41;&#123;
				//
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_TRIANGLE&#41;&#123;
				//
			&#125; 
			if &#40;pad.Buttons & PSP_CTRL_CIRCLE&#41;&#123;
				if&#40;ispressed == 0&#41; ispressed = 1;
				else if&#40;ispressed == 1&#41; ispressed = 0;
			&#125; 
			if &#40;pad.Buttons & PSP_CTRL_CROSS&#41;&#123;
				//
			&#125; 
			if &#40;pad.Buttons & PSP_CTRL_UP&#41;&#123;
				move&#40;cursor_point&#91;0&#93;, cursor_point&#91;1&#93;-blocksize&#41;;
			&#125; 
			if &#40;pad.Buttons & PSP_CTRL_DOWN&#41;&#123;
				move&#40;cursor_point&#91;0&#93;, cursor_point&#91;1&#93;+blocksize&#41;;
			&#125; 
			if &#40;pad.Buttons & PSP_CTRL_LEFT&#41;&#123;
				move&#40;cursor_point&#91;0&#93;-blocksize, cursor_point&#91;1&#93;&#41;;
			&#125; 
			if &#40;pad.Buttons & PSP_CTRL_RIGHT&#41;&#123;
				move&#40;cursor_point&#91;0&#93;+blocksize, cursor_point&#91;1&#93;&#41;;
			&#125;      
			if &#40;pad.Buttons & PSP_CTRL_START&#41;&#123;
				//
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_SELECT&#41;&#123;
				//
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_HOME&#41;&#123;
				return 1;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_HOLD&#41;&#123;
				//
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_NOTE&#41;&#123;
				//
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_LTRIGGER&#41;&#123;
				//
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_RTRIGGER&#41;&#123;
				//
			&#125;      
		&#125;
	#endif
	return 0;
&#125;

// Entry Point
int main&#40;int argc, char *argv&#91;&#93;&#41;
&#123;
	#ifdef PSP
		pspDebugScreenInit&#40;&#41;;
		SetupCallbacks&#40;&#41;;
		pspDebugScreenSetXY&#40;481, 1&#41;;
		sceCtrlSetSamplingCycle&#40;0&#41;;
	#endif
	
	// initialize sdl
	if&#40;SDL_Init&#40;SDL_INIT_VIDEO|SDL_INIT_AUDIO&#41;<0&#41;
		return msg&#40;"SDL Initialization Failure&#58; %s", SDL_GetError&#40;&#41;&#41;;
	atexit&#40;SDL_Quit&#41;;
	// initialize sdl surface
	screen = SDL_SetVideoMode&#40;screen_width, screen_height, screen_bitrate, opt_fullscreen ? SDL_SWSURFACE|SDL_FULLSCREEN &#58; SDL_SWSURFACE|SDL_DOUBLEBUF&#41;;
	if&#40;!screen&#41; msg&#40;"SDL Video Initialization Failure&#58; %s", SDL_GetError&#40;&#41;&#41;;
	// set titlebar caption
	SDL_WM_SetCaption&#40;version, 0&#41;;
	// initialize font
	fontprocess&#40;0&#41;;
	fontprocess&#40;2&#41;;
	fontprocess&#40;3&#41;;

	SDL_EnableKeyRepeat&#40;100, 50&#41;;

	// initialize of game stage
	initialize_stage&#40;&#41;;
	//msg&#40;"Game Started",NULL&#41;;
	while&#40;!done&#41;
	&#123;
		if&#40;!procedure&#40;&#41;&#41; break;
		if&#40;stageproc&#40;&#41; == 0&#41; break;
		SDL_Flip&#40;screen&#41;;
	&#125;
	finalize&#40;&#41;;
	#ifdef PSP
		sceKernelExitGame&#40;&#41;;
	#endif
	return 0;
&#125;

Code: Select all

# --- puzzle02 makefile
# $ID&#58; $
#

PCCC     = gcc
PCCFLAGS = -O2 -g -Wall -DDEBUG -DNOTPSP
PCLIBS   = -L/usr/local/lib
PCINCLUDE = -I/usr/local/mingw32/include -I/usr/local/mingw32/include/SDL
OBJS = brixpro.o

TARGET = brixpro

CFLAGS = -O2 -g -Wall -DDEBUG
LIBS=
LIBDIR =
LDFLAGS =

EXTRA_TARGETS = EBOOT.PBP kxploit
EXTRA_CLEAN = pcclean

# --- PC SDL
PCCFLAGS += $&#40;shell sdl-config --cflags&#41;
PCLIBS += $&#40;shell sdl-config --libs&#41;
PCLIBS += -lSDL_mixer -lm -lSDL -lSDLmain -lSDL_image -lpng -lz

PSP_EBOOT_TITLE = BRIXPRO
PSP_DIR_NAME = BRIXPRO

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
PSPBIN = $&#40;PSPSDK&#41;/../bin
CFLAGS += $&#40;shell $&#40;PSPBIN&#41;/sdl-config --cflags&#41;
LIBS += $&#40;shell $&#40;PSPBIN&#41;/sdl-config --libs&#41;
LIBS += -lSDL_mixer -lm -lSDL -lSDLmain -lSDL_image -lpng -lz -ljpeg
include $&#40;PSPSDK&#41;/lib/build.mak




pc &#58; pcobjs
	$&#40;PCCC&#41; -o $&#40;TARGET&#41; $&#40;OBJS&#41; $&#40;PCLIBS&#41;

pcobjs &#58;
	$&#40;PCCC&#41; $&#40;PCCFLAGS&#41; $&#40;PCINCLUDE&#41; -c brixpro.c

pcclean &#58;
	rm -rf *.o $&#40;TARGET&#41; $&#40;TARGET&#41;% $&#40;TARGET&#41;.exe *~

bootmain.o &#58; brixpro.c
I can not compile this T.T
always "pngrtran.c" error T.T
Is that makefile is wrong?
or..... C source file is wrong?

cygwin and pspsdk, toolchain, sdl install is completed
another source with sdl is compiled successfully.
why?
Gary13579
Posts: 93
Joined: Mon Aug 15, 2005 7:43 am

Post by Gary13579 »

No offense, but good luck finding someone to read all that code.. especially when you don't paste the EXACT error it gives you when compiling.
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

all that code was not needed ...im guessing your
problem is most likely Makefile problem of not having
target to build this pngrtran.c to object if that is what it is
10011011 00101010 11010111 10001001 10111010
Post Reply