Ejemplo n.º 1
0
/*===========================================================================*/
void _main(void) {
    short         i,j;
    unsigned long measure_val;
    char          tmpstr[50] = "Measuring, please wait ...";
    short         modes[6]   = { A_REPLACE,A_XOR,A_REVERSE,A_XOR,A_REPLACE,A_REVERSE};
    LCD_BUFFER    screen;

    LCD_save(screen);

    FontSetSys(F_4x6);

    OSFreeTimer(USER_TIMER);
    OSRegisterTimer(USER_TIMER,INITIAL_TIMER_VALUE);

    ClearScreen();
    DrawStr(0,0,tmpstr,A_REPLACE);

    do {
        //---------------------------------------------------------------------
        // built-in OS line drawing routine ...
        //---------------------------------------------------------------------
        OSTimerRestart(USER_TIMER);
        for (j=0;j<6 && !kbhit();j++) {
            short used_mode = modes[j];
            for (i=0;  i<160;i++) DrawLine(80,50,i,8,   used_mode);
            for (i=8;  i<100;i++) DrawLine(80,50,159,i, used_mode);
            for (i=159;i>=0; i--) DrawLine(80,50,i,99,  used_mode);
            for (i=99; i>=8; i--) DrawLine(80,50,0,i,   used_mode);
        }
        measure_val = OSTimerCurVal(USER_TIMER);
        sprintf(tmpstr,"OS Routine took %lu ticks",INITIAL_TIMER_VALUE-measure_val);
        memset(LCD_MEM,0,30*8);
        DrawStr(0,0,tmpstr,A_REPLACE);

        if (kbhit()) break;

        //---------------------------------------------------------------------
        // new line drawing routine ...
        //---------------------------------------------------------------------
        OSTimerRestart(USER_TIMER);
        for (j=0;j<6 && !kbhit();j++) {
            short used_mode = modes[j];
            for (i=0;  i<160;i++) FastDrawLine_R(LCD_MEM,80,50,i,8,   used_mode);
            for (i=8;  i<100;i++) FastDrawLine_R(LCD_MEM,80,50,159,i, used_mode);
            for (i=159;i>=0; i--) FastDrawLine_R(LCD_MEM,80,50,i,99,  used_mode);
            for (i=99; i>=8; i--) FastDrawLine_R(LCD_MEM,80,50,0,i,   used_mode);
        }
        measure_val = OSTimerCurVal(USER_TIMER);
        sprintf(tmpstr,"Own Routine took %lu ticks",INITIAL_TIMER_VALUE-measure_val);
        memset(LCD_MEM,0,30*8);
        DrawStr(0,0,tmpstr,A_REPLACE);
    }
    while (!kbhit());

    ngetchx();
    OSFreeTimer(USER_TIMER);
    LCD_restore(screen);
    GKeyFlush();
    ST_helpMsg(EXTGRAPH_VERSION_PWDSTR);
}
Ejemplo n.º 2
0
static inline void info(void) {
	int loop;
	const char * const str[12] = 
	{"Plinko V 1.0", "By Travis Fischer", "", "Win as many plinko chips as you can", 
	"by guessing the correct digit in the", "price of the given product.", 
	"Then, drop your chips down the plinko board", "and win BIG!!!", "--July 6, 2003--", "", 
	"Thanks to the TIGCC team and everyone at tict", 
	"*****@*****.**"};
	char buffer[45];
	
	ClearGrayScreen2B(Hiddenl, Hiddend);
	
	FontSetSys (F_4x6);
	
	for(loop = 0; loop < 12; loop ++) {
		sprintf (buffer, "%s", str[loop]);
		
		GrayDBufSetHiddenAMSPlane (LIGHT_PLANE);
			DrawStr((LCD_WIDTH - DrawStrWidth(buffer, F_4x6))/2 + 1, 1 + 8 * loop, buffer, A_NORMAL);
		GrayDBufSetHiddenAMSPlane (DARK_PLANE);
			DrawStr((LCD_WIDTH - DrawStrWidth(buffer, F_4x6))/2, 8 * loop, buffer, A_NORMAL);
		//DrawGrayStrExt2B(0, 8 * loop, (char*)str[loop], A_NORMAL|A_SHADOWED|A_CENTERED, F_4x6, 
		//Hiddenl, Hiddend);
	}
	GrayDBufToggleSync(); // switches two sets of planes
	wait_for_keypress();
}
Ejemplo n.º 3
0
// prints the hi-score table
void printHiScores(void) {
    int i = 0;
    GraySetAMSPlane(DARK_PLANE);
    clrscr();
    GraySetAMSPlane(LIGHT_PLANE);
    clrscr();
    GraySetAMSPlane(DARK_PLANE);
    FontSetSys(F_8x10);
    DrawStr(36,0,"Jet Blaster",A_NORMAL);
    DrawStr(36,12,"High Scores",A_NORMAL);
    FontSetSys(F_4x6);
    DrawStr(53,95,"Jet Blaster v 1.0 by Ben Cherry",A_NORMAL);
    FontSetSys(F_6x8);
    for (i = 1; i <= 5; i++) {
        printf_xy(10,i*9 + 26,"%d. %s - %lu",i,hiScores[i].name,hiScores[i].score);
    }
    GraySetAMSPlane(LIGHT_PLANE);
    FontSetSys(F_8x10);
    printf_xy(36,0,"Jet Blaster");
    printf_xy(36,12,"High Scores");
    FontSetSys(F_4x6);
    printf_xy(53,95,"Jet Blaster v 1.0 by Ben Cherry");
    FontSetSys(F_6x8);
    for (i = 1; i <= 5; i++) {
        printf_xy(10,i*9 + 26,"%d. %s - %lu",i,hiScores[i].name,hiScores[i].score);
    }
    while (ngetchx() != KEY_ENTER);
    GraySetAMSPlane(DARK_PLANE);
    clrscr();
    GraySetAMSPlane(LIGHT_PLANE);
    clrscr();
}
Ejemplo n.º 4
0
//+++++++++++++++++++++++++++++++++++++++++++++++++
// 2D描画本体
//-------------------------------------------------
// 描画の2D部分の描画を行う関数
//--in---------------------------------------------
// なし
//--out--------------------------------------------
// なし
//+++++++++++++++++++++++++++++++++++++++++++++++++
void DrawPict()
{
	//テクスチャ有効化
	glEnable(GL_TEXTURE_2D);	

	//2D用描画ゲーム遷移
	switch(g_nStatus)
	{
	case INIT:
		
		break;
	case STARTINIT:
		
		break;
	case START:

		break;
	case GAME_INIT:
	
		break;

	case GAME_FILLER_START:
		p_2D->Draw();
		break;
	case GAME_RESET:
		break;
	case GAME:
		//p_Score->Draw();		//スコアの出力
		p_BossHpBar->Draw();	//プレイヤーのHPバー
		p_PlayerHpBar->Draw();	//プレイヤーのHPバー
		p_Time->Draw();
		break;
	case RESULT_INIT:
		
		break;
	case RESULT:
		p_Result->Draw2D();
		break;
	/*case ENDINIT:
		
		break;*/
	case END:
		break;
	default:break;
	}



#if (DEBUG_OFF)

	DrawStr(0, 0, g_szDebug);	//FPS情報
	DrawStr(0, 0, g_szDebug2);	//コントローラ情報

#endif
}
Ejemplo n.º 5
0
Archivo: t2048.c Proyecto: 1cook/t2048
//draws the box on the screen
void drawBox(WIN_RECT box, char value){
	DrawClipRect(&box,ScrRect,A_NORMAL);

	if(value == 17)
		FontSetSys(F_4x6);//Make Text even more smaller for even more bigger numbers
	else if(value>13)
		FontSetSys(F_6x8);//Make text smaller for bigger numbers
			/*This game does not support going over 2^17 = 131072
			and you can't exceed that value in a normal game anyways.
			this check prevents accessing bad memory*/
	DrawStr((box.x0)+2, (box.y0)+5, strConv[value], A_NORMAL);
	FontSetSys(F_8x10);
}
Ejemplo n.º 6
0
void _main(void)
{
  char str[30];  
  
  ClrScr ();
  FontSetSys (F_8x10);
  
  sprintf(str, "RomDumper v%s", VERSION);
  DrawStr(0, 0, str, A_NORMAL);
  
  sprintf(str, "Type: HW%i", HW_VERSION);
  DrawStr(0, 20, str, A_NORMAL);
  
  sprintf(str, "ROM base: 0x%lx", (uint32_t)ROM_base);
  DrawStr(0, 40, str, A_NORMAL);  
  
  sprintf(str, "by The TiLP Team");
  DrawStr(0, 80, str, A_NORMAL);  
  
  Dump();
  
  return;
}
Ejemplo n.º 7
0
void SDLview::drawFPS(void)
{
	static double th[4] = {0.0, 0.0, 0.0, 0.0};
	static double t1 = 0.0, t2 = 0.0, t;
	char num_str[128];
    
    t1 = t2;
	if(Timing)
    {
		t2 = mtime();
		t = t2 - t1;
		if(t > 0.0001) t = 1.0 / t;
		
		glDisable(GL_LIGHTING);
		glDisable(GL_TEXTURE_2D);
		glDisable(GL_DEPTH_TEST);
		
		glColor3f(1.0, 1.0, 1.0);
		
		glMatrixMode (GL_PROJECTION);
		glLoadIdentity();
		glOrtho(0, w_win, 0, h_win, -10.0, 10.0);
		
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		
		glRasterPos2f(w_win-100.0, 15.0);

		sprintf(num_str, "%0.2f FPS", filter(t, th));
		DrawStr(num_str);
		
		glMatrixMode(GL_MODELVIEW);
		glEnable(GL_LIGHTING);
		glEnable(GL_DEPTH_TEST);
	}
	
    count++;
	
}
Ejemplo n.º 8
0
// Main Function
void _main(void)
{
	// declare the sprite positions
	int x1 = 20, y1 = 20, direction1 = RIGHT;
	int x2 = 40, y2 = 40, direction2 = LEFT;
	int x3 = 60, y3 = 60, direction3 = RIGHT;
	int x4 = 80, y4 = 80, direction4 = LEFT;
	int x5 = 50, y5 = 50, direction5 = RIGHT;
	
	// keycode variable
	int key = 0;
	
	// Define the pins
	unsigned char pinsprt[] = {0x18,0x3C,0x18,0x38,0x7C,0x7C,0x7C,0x38};
	unsigned long int balsprt[] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
																 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
																 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
																 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
																 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
																 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
																 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
																 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,};

	// clear the screen
	ClrScr();
	
	// Annotate the display
	DrawStr(0, 0, "These Are Bowling Pins!", A_NORMAL);
	
	// draw the sprites
	Sprite8(x1, y1, SPRITE_HEIGHT, pinsprt, LCD_MEM, SPRT_XOR);
	Sprite8(x2, y2, SPRITE_HEIGHT, pinsprt, LCD_MEM, SPRT_XOR);
	Sprite8(x3, y3, SPRITE_HEIGHT, pinsprt, LCD_MEM, SPRT_XOR);
	Sprite8(x4, y4, SPRITE_HEIGHT, pinsprt, LCD_MEM, SPRT_XOR);
	Sprite32(x5, y5, 32, balsprt, LCD_MEM, SPRT_XOR);
	
	// wait for a key before exit
	ngetchx();
}
Ejemplo n.º 9
0
void Nu_DrawScreen ()
{
	int y;

	BuildRGBPalette(MainRGBPalette, MainPalette, len_main_palette);
	BuildRGBPalette(CtrlRGBPalette, CtrlPalette, 16);

	y = logscreen2;
	logscreen2 = physcreen;
	DrawStr(280, 5, 15, mode_name(), 1);
	logscreen2 = y;

	draw_control_panel ();

	if (mouse_shown && in_mouse_mode()) {
		SDL_Rect rect = { input.abs_x, input.abs_y, 0, 0 };
		SDL_BlitSurface(cursor, NULL, sdlscrn, &rect);
		mouse_shown = 0;
	}

	SDL_Flip(sdlscrn);
}
Ejemplo n.º 10
0
//---------------------------------------------------------------------------------------
void CMenuItem::UpdateData(bool force)
{
	Redraw(true);

	if (param != NULL) {
		int delNumber = data.Length();

		param->GetValueText(data);
		int diff = data.Length() - maxLen;
		if (diff == 1)
			maxLen++;
		else if (diff > 1) {
			data.Delete(0, ++diff);
			data.Insert(0, "\34");
		}

		Redraw();

		diff = data.Length();
		delNumber -= diff;
		if (delNumber > 0) {
			int xx = x2 + (diff * 6);
			DrawStr(xx + 1, y, "", delNumber);

			if (param->GetType() == PTYPE_STRING)
				delNumber = maxLen - delNumber;

			delNumber *= 6;
			byte mod = xx & 0x07;
			if (mod > 0)
				xx += (8 - mod);

			DrawAttr(xx, y, colors[0], delNumber);
		}
	}
	else if (force)
		Redraw();
}
Ejemplo n.º 11
0
//---------------------------------------------------------------------------------------
void CMenuItem::UpdateData(const char *_data)
{
	if (strncmp(data, _data, strlen(_data)) != 0) {
		int delNumber = data.Length() - strlen(_data);

		data = _data;
		Redraw();

		if (delNumber > 0) {
			int xx = x2 + (data.Length() * 6);
			DrawStr(xx + 1, y, "", delNumber);

			if (param->GetType() != PTYPE_STRING) {
				delNumber *= 6;
				byte mod = xx & 0x07;
				if (mod > 0)
					xx += (8 - mod);

				DrawAttr(xx, y, colors[0], delNumber);
			}
		}
	}
}
Ejemplo n.º 12
0
static void draw_control_panel ()
{
	int x, y;
	unsigned short *pixels;
	unsigned char *scr = VideoRaster;
	
	/* this is a big f*****g hack to make starsystem names
	 * in the starmap show up. they are the only bitmap text
	 * things drawn within the fe2 3d renderer, which makes
	 * them f*****g annoying. */
	y = logscreen2;
	logscreen2 = physcreen;
	for (x=0; x<queued_string_pos; x++) {
		DrawStr (	queued_strings[x].x,
				queued_strings[x].y,
				queued_strings[x].col,
				queued_strings[x].str,
				FALSE);
	}
	logscreen2 = y;
	/****************************************************/
	
	if (SDL_MUSTLOCK(sdlscrn))
		SDL_LockSurface(sdlscrn);

	pixels = (unsigned int *) sdlscrn->pixels;

	for (y = 0; y < 168; y++)
		for (x = 0; x < 320; x++)
			*pixels++ = MainRGBPalette[*scr++];
	for (y = 168; y < 200; y++)
		for (x = 0; x < 320; x++)
			*pixels++ = CtrlRGBPalette[*scr++];

	if (SDL_MUSTLOCK(sdlscrn))
		SDL_UnlockSurface(sdlscrn);
}
Ejemplo n.º 13
0
//---------------------------------------------------------------------------------------
void CMenuItem::Redraw(bool justInit)
{
	char *name = (char *) origName;
	size = strlen(origName);

	y = origY;
	char *ptr = name;
	while (*ptr != 0) {
		if (*ptr++ == '\n') {
			byte offset = (ptr - name);
			DrawStrAttr(x, y, name, colors[3], offset - 1);
			name += offset;
			size -= offset;
			y++;
		}
	}

	DrawStrAttr(x, y, name, colors[3], size);

	x2 = x + (size * 6);
	byte mod = x2 & 0x07;
	if (mod > 0)
		x2 += (8 - mod);

	if (justInit) {
		maxLen = (256 - x2) / 6;
		return;
	}

	if (param->GetType() == PTYPE_STRING) {
		DrawStr(x2 + 1, y, data, maxLen);
		DrawAttr(x2, y, colors[state], 252 - x2);
	}
	else
		DrawStrAttr(x2 + 1, y, data, colors[state]);
}
Ejemplo n.º 14
0
// centerText - draws a string at the horizontal center of line y
inline void centerText(const char *str, short int y) {
	short int len = (short int)strlen(str), x = ((160 - (len * 6)) / 2);

	DrawStr(x,y,(char *)str,A_XOR);
}
Ejemplo n.º 15
0
void
Display(void)
{
    int i;
    static double th[4] = {0.0, 0.0, 0.0, 0.0};
	static double t1 = 0.0, t2 = 0.0, t;
	char num_str[128];
    
    t1 = t2;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    for (i = 0; i < NUM_SHARKS; i++) {
        glPushMatrix();
        FishTransform(&sharks[i]);
        DrawShark(&sharks[i]);
        glPopMatrix();
    }

    glPushMatrix();
    FishTransform(&dolph);
    DrawDolphin(&dolph);
    glPopMatrix();

    glPushMatrix();
    FishTransform(&momWhale);
    DrawWhale(&momWhale);
    glPopMatrix();

    glPushMatrix();
    FishTransform(&babyWhale);
    glScalef(0.45, 0.45, 0.3);
    DrawWhale(&babyWhale);
    glPopMatrix();
    
    if(Timing)
    {
		t2 = mtime();
		t = t2 - t1;
		if(t > 0.0001) t = 1.0 / t;
		
		glDisable(GL_LIGHTING);
		//glDisable(GL_DEPTH_TEST);
		
		glColor3f(1.0, 0.0, 0.0);
		
		glMatrixMode (GL_PROJECTION);
		glPushMatrix();
		glLoadIdentity();
		glOrtho(0, w_win, 0, h_win, -10.0, 10.0);
		
		glRasterPos2f(5.0, 5.0);
		
		switch(StrMode)
		{
			case GL_VENDOR:
				sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th), w_win, h_win);
				DrawStr(num_str);
				DrawStr(glGetString(GL_VENDOR));
			break;
			case GL_RENDERER:
				sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th), w_win, h_win);
				DrawStr(num_str);
				DrawStr(glGetString(GL_RENDERER));
			break;
			case GL_VERSION:
				sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th), w_win, h_win);
				DrawStr(num_str);
				DrawStr(glGetString(GL_VERSION));
			break;
			case GL_EXTENSIONS:
				sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th), w_win, h_win);
				DrawStr(num_str);
				DrawStr(glGetString(GL_EXTENSIONS));
			break;
		}
		
		glPopMatrix();
		glMatrixMode(GL_MODELVIEW);
		
		glEnable(GL_LIGHTING);
		//glEnable(GL_DEPTH_TEST);
	}
	
    count++;

    glutSwapBuffers();
}
Ejemplo n.º 16
0
// function to draw the main menu
void drawWords(unsigned int difficulty) {
    char * diffStr;
    if (difficulty == VERY_EASY) diffStr = (char *)"Very Easy";
    if (difficulty == EASY) diffStr = (char *)"Easy";
    if (difficulty == NORMAL) diffStr = (char *)"Normal";
    if (difficulty == HARD) diffStr = (char *)"Hard";
    if (difficulty == VERY_HARD) diffStr = (char *)"Very Hard";
    if (difficulty == IMPOSSIBLE) diffStr = (char *)"Impossible!";
    FontSetSys(F_8x10);
    GraySetAMSPlane(LIGHT_PLANE);
    DrawStr(20,20,"Play", A_NORMAL);
    DrawStr(20,35,"Diff -", A_NORMAL);
    DrawStr(80,35,diffStr, A_NORMAL);
    DrawStr(20,50,"High Scores", A_NORMAL);
    DrawStr(20,65,"Help", A_NORMAL);
    DrawStr(20,80,"Exit",A_NORMAL);
    GraySetAMSPlane(DARK_PLANE);
    DrawStr(20,20,"Play", A_NORMAL);
    DrawStr(20,35,"Diff -", A_NORMAL);
    DrawStr(80,35,diffStr, A_NORMAL);
    DrawStr(20,50,"High Scores", A_NORMAL);
    DrawStr(20,65,"Help", A_NORMAL);
    DrawStr(20,80,"Exit",A_NORMAL);
    FontSetSys(F_6x8);
}
Ejemplo n.º 17
0
// main menu
inline void title(void) {
	clrscr();
	DrawStr(LCD_WIDTH/2-30,LCD_HEIGHT/2-4,"HIT ENTER!",A_NORMAL);
	ngetchx();
}
Ejemplo n.º 18
0
// drawCopyright - prints the copyright notice at the bottom of the screen
inline void drawCopyright(void) {
	FontSetSys(F_4x6);
	DrawStr(COPYX,COPYY,(char *)intro[COPYRIGHT],A_XOR);
	DrawStr(URLX,URLY,(char *)intro[URL],A_XOR);
	FontSetSys(F_6x8);
}
Ejemplo n.º 19
0
// drawHiScoreBoard - draws the hiscore board, and updates it with the hiscore from the latest game
void drawHiScoreBoard(unsigned long int newscore) {
	SCORE scores[MAX_HISCORES];
	short int loop, pos = -1;
	char name[10], str[50], *error = "File I/O Error";
	HANDLE dlg;

	// restore interrupt handlers
	OSSetSR(0x0000);

	if (!loadHiScores(scores)) {
		// cannot open hiscore file -- display error
		DlgMessage(error,"Unable to Load HiScore Data",BT_OK,BT_NONE);
		return;
	}

	// check if latest score is a highscore
	for (loop = (MAX_HISCORES - 1); loop >= 0; loop--) {
		if (newscore > scores[loop].score) {
			// new HiScore!!
			pos = loop;
		}
	}

	if (pos != -1) {
		// if we found a new hiscore
		if ((dlg = DialogNewSimple(DLGWIDTH,DLGHEIGHT)) == H_NULL) {
			DlgMessage("Memory Allocation Error","Not Enough Free Memory!",BT_OK,BT_NONE);
		} else {
			DialogAddTitle(dlg,"New Hiscore!",BT_OK,BT_NONE);
			DialogAddRequest(dlg,5,25,"Your Name:",0,9,11);

			sprintf(str,"You earned the #%hd hiscore position!",pos+1);
			DialogAddText(dlg,5,15,str);

			do {
				// truncate name variable
				name[0] = 0;
			} while (DialogDo(dlg,CENTER,CENTER,name,NULL) != KEY_ENTER);

			// free the dialog box memory
			HeapFree(dlg);

			// move the hiscore list down
			if (pos < (MAX_HISCORES - 1)) {
				for (loop = (MAX_HISCORES - 1); loop > pos; loop--) {
					scores[loop].score = scores[loop - 1].score;
					scores[loop].name[0] = 0;
					strcpy(scores[loop].name,scores[loop - 1].name);
				}
			}

			// fill in the new hiscore
			scores[pos].score = newscore;
			scores[pos].name[0] = 0;
			strcpy(scores[pos].name,name);

			if (!saveHiScores(scores)) {
				DlgMessage(error,"Unable to save HiScore Board",BT_OK,BT_NONE);
			}
		}
	}

	// display the hiscore board

	// clear the screen
	ClrScr();

	// draw the screen borders
	drawBorder();

	// draw the game logo
	drawLogo();

	FontSetSys(F_8x10);
	DrawStr(25,35,"Hiscore Board",A_NORMAL);
	FontSetSys(F_6x8);

	for (loop = 0; loop < 5; loop++) {
		printf_xy(20,50+loop*10,"#%hd %-9s %lu",loop+1,scores[loop].name,scores[loop].score);
	}

	ngetchx();

	// disable interrupts
	OSSetSR(0x0700);

	// wait for keypresses to dissipate
	delay(KEYDELAY);
}
Ejemplo n.º 20
0
// Main Function
void _main(void)
{
signed char STATUS, a;
int plinkos;
unsigned char *Home = malloc(LCD_SIZE); // Allocate the SAVE_SCREEN buffer
if (Home == NULL) {
	Error_Memory();
	return;
}
LCD_save(Home);  // Save LCD HomeScreen Contents

virtual_dark = malloc ( LCD_SIZE );  // Allocate the dark buffer
if (virtual_dark == NULL) {Error_Memory(); return; }
virtual_light=malloc ( LCD_SIZE );  // Allocate the light buffer
if (virtual_light == NULL)	{
	free(virtual_dark);
	Error_Memory();
	return;
}

randomize();

if (Gray_prep() == QUIT) {
	Error_Memory();
	goto end;
}

if (makefile() == QUIT)  // Tests whether or not we need a default save file and installs one if the 
// user doesn't already have one on their calc
	goto end;

for(a = 10; a--;)
	FADE_LIGHTER();
// Clears both Hidden Gray planes
ClearGrayScreen2B(Hiddenl, Hiddend);

GraySpriteX8_OR(52, 37, 27, titlel, titled, 7, Hiddenl, Hiddend);

FontSetSys (F_4x6);
GrayDBufSetHiddenAMSPlane (DARK_PLANE); 
	DrawStr(122, 94, "-- By Fisch", A_NORMAL);
GrayDBufSetHiddenAMSPlane (LIGHT_PLANE); 
	DrawStr(123, 95, "-- By Fisch", A_NORMAL);
GrayDBufToggleSync(); // switches two sets of planes

for(a = 10; a--;)
	FADE_DARKER();
Waitkey();

NEW_GAME:

if ((STATUS = MENU()) == QUIT)
	goto end;

if ((plinkos = PRODUCTS()) == QUIT)
	goto end;

if ((STATUS = INTRO()) == QUIT)
	goto end;

if ((STATUS = main_game(plinkos)) == QUIT)
	goto end;

goto NEW_GAME;

end:
// Clean up at end of Program
Cleanup();
if (Home) {
	LCD_restore(Home);
	free(Home);
	
	GKeyFlush();
	ST_helpMsg("Plinko  --By Travis Fischer");
}
}
Ejemplo n.º 21
0
int Dump(void)
{
	int exit = 0;
	int ret;
	uint16_t cmd, len;
	uint32_t addr;
	char str[30];
	unsigned int i;
	uint8_t* ptr;
	
	while(!exit)
	{
		// wait for command
		ret = RecvPacket(&cmd, &len, buf);
		//if(ret) continue;	// pb with ret val
		
		// or keypress
		if(kbhit()) 
			exit = !0;
					
		// and process
		switch(cmd)
		{
			case CMD_IS_READY: 
				Send_OK();
			break;
			case CMD_EXIT: 
				Send_EXIT();
				exit = !0; 
			break;
			case CMD_REQ_SIZE: 
				Send_SIZE(ROM_size);
				
				sprintf(str, "Size: %lu KB", ROM_size >> 10);
				DrawStr(0, 60, str, A_REPLACE	);
			break;
			case CMD_REQ_BLOCK: 
			  addr  = ((uint32_t)buf[0] <<  0); addr |= ((uint32_t)buf[1] <<  8);
			  addr |= ((uint32_t)buf[2] << 16); addr |= ((uint32_t)buf[3] << 24);
				
				if(addr > ROM_size)
					Send_ERR();

#if 0				
				if(addr >= 0x10000 && addr < 0x12000)	// read protected (certificate)
					addr = 0;	
				if(addr >= 0x18000 && addr < 0x1A000)	// read protected (certificate)
					addr = 0;
#endif
			
			  //sprintf(str, "%02x %02x %02x %02x     ", buf[0], buf[1], buf[2], buf[3]);
			  //DrawStr(0, 80, str, A_REPLACE	);
				sprintf(str, "Done: %lu/%luKB     ", addr >> 10, ROM_size >> 10);
				DrawStr(0, 60, str, A_REPLACE	);
				
				// Check for filled blocks (like 0xff)
				ptr = (uint8_t *)(ROM_base + addr);
				for(i = 0; i < BLK_SIZE; i++)
					if(ptr[i] != ptr[0])
						break;
				
				if(i == BLK_SIZE)
					Send_RDATA(ptr[0]);
				else
					Send_DATA(BLK_SIZE, (uint8_t *)(ROM_base + addr));
			break;
			case CMD_NONE:
			break;
			default:
			break;			
		}
	}	

	USBLinkClose();	
	return 0;
}