Esempio n. 1
0
void show_sdfuse_pic(void)
{
	#if defined(CONFIG_S9) || defined(CONFIG_A9)
	show_sdfluse_pic(pic_auto_sdfuse, 0, 0, 1, 1, 1);
	#else
  show_pic(pic_auto_sdfuse, 0, 0, 1, 1, 1);
	#endif
}
Esempio n. 2
0
static void refresh_screen()
{
	erase_both ();
	show_pic ();
	blit_both ();
	commit_both ();
	put_screen ();
}
Esempio n. 3
0
/**
 * Display inventory items.
 */
void inventory ()
{
	int old_fg, old_bg;
	int n;

	/* screen is white with black text */
	old_fg = game.color_fg;
	old_bg = game.color_bg;
	game.color_fg = 0;
	game.color_bg = 15;
	clear_screen (game.color_bg);

	print_text (YOUHAVE_MSG, 0, YOUHAVE_X, YOUHAVE_Y, 40,
		STATUS_FG, STATUS_BG);

	/* FIXME: doesn't check if objects overflow off screen... */

	intobj = malloc (4 + game.num_objects);
	memset(intobj, 0, (4 + game.num_objects));

	n = show_items ();

	if (getflag (F_status_selects_items)) {
		print_text (SELECT_MSG, 0, SELECT_X, SELECT_Y, 40,
			STATUS_FG, STATUS_BG);
	} else {
		print_text (ANY_KEY_MSG, 0, ANY_KEY_X, ANY_KEY_Y, 40,
			STATUS_FG, STATUS_BG);
	}
 
	flush_screen ();

	/* If flag 13 is set, we want to highlight & select an item.
	 * opon selection, put objnum in var 25. Then on esc put in
	 * var 25 = 0xff.
	 */
 
	if (getflag (F_status_selects_items))
		select_items (n);

	free (intobj);

	if (!getflag (F_status_selects_items))
		wait_any_key();

	clear_screen (0);
	write_status ();
	show_pic ();
	game.color_fg = old_fg;
	game.color_bg = old_bg;
	game.has_prompt = 0;
	flush_lines (game.line_user_input, 24);
}
Esempio n. 4
0
/* ------------------------------------------------------------------------- */
#define DM9000_Tacs  (0x0)  // 0clk    address set-up
#define DM9000_Tcos  (0x4)  // 4clk    chip selection set-up
#define DM9000_Tacc  (0xE)  // 14clk  access cycle
#define DM9000_Tcoh  (0x1)  // 1clk    chip selection hold
#define DM9000_Tah  (0x4)  // 4clk    address holding time
#define DM9000_Tacp  (0x6)  // 6clk    page mode access cycle
#define DM9000_PMC  (0x0)  // normal(1data)page mode configuration

int resume_system;
int sdfuse_system;
int force_erase_flag;
extern volatile int is_lcdon;
static inline void delay(unsigned long loops)
{
  __asm__ volatile ("1:\n" "subs %0, %1, #1\n" "bne 1b":"=r" (loops):"0"(loops));
}

#ifdef FORCE_EARSE_XINWANJIA  /*新万佳--*/
void force_erase()
{
  char run_cmd[128];
  printf("force_erase_flag = %d\n", force_erase_flag);
  if(force_erase_flag)
  {
    show_sdfuse_pic();
    run_command("sdfuse erase userdata", 0);
    run_command("sdfuse erase cache", 0);
    sprintf(run_cmd, "fatformat mmc %d:%d", BOOT_MMC, EXTSD_PART_NUM);
    run_command(run_cmd, 0);
    mdelay10(100);
    show_pic(PIC_BOOT, 0, 0, 0, 0, 0);
  }
}
Esempio n. 5
0
int load_game(char* s)
{
	int i, ver, vt_entries = MAX_VIEWTABLE;
	UINT8 t;
	SINT16 parm[7];
	char sig[8];
	char id[8];
	char description[256];
	FILE *f = fopen(s, "rb");

	if(!f)
		return err_BadFileOpen;

	read_bytes(f, sig, 8);
	if (strncmp (sig, strSig, 8)) {
		fclose(f);
		return err_BadFileOpen;
	}

	read_string (f, description);

	ver = read_uint8(f);
	if (ver == 0)
		vt_entries = 64;
	game.state = read_uint8(f);
	/* game.name - not saved */
	read_string(f, id);
	if(strcmp(id, game.id)) {
		fclose(f);
		return err_BadFileOpen;
	}
	/* game.crc - not saved */

	for (i = 0; i < MAX_FLAGS; i++)
		game.flags[i] = read_uint8(f);
	for (i = 0; i < MAX_VARS; i++)
		game.vars[i] = read_uint8(f);

	game.horizon = read_sint16(f);
	game.line_status = read_sint16(f);
	game.line_user_input = read_sint16(f);
	game.line_min_print = read_sint16(f);

	/* These are never saved */
	game.cursor_pos = 0;
	game.input_buffer[0] = 0;
	game.echo_buffer[0] = 0;
	game.keypress = 0;

	game.input_mode = read_sint16(f);
	game.lognum = read_sint16(f);

	game.player_control = read_sint16(f);
	game.quit_prog_now = read_sint16(f);
	game.status_line = read_sint16(f);
	game.clock_enabled = read_sint16(f);
	game.exit_all_logics = read_sint16(f);
	game.picture_shown = read_sint16(f);
	game.has_prompt = read_sint16(f);
	game.game_flags = read_sint16(f);
	game.input_enabled = !read_sint16(f);

	for (i = 0; i < _HEIGHT; i++)
		game.pri_table[i] = read_uint8(f);

	if(game.has_window)
		close_window();
	game.msg_box_ticks = 0;
	game.block.active = FALSE;
	/* game.window - fixed by close_window() */
	/* game.has_window - fixed by close_window() */

	game.gfx_mode = read_sint16(f);
	game.cursor_char = read_uint8(f);
	game.color_fg = read_sint16(f);
	game.color_bg = read_sint16(f);

	/* game.hires (#ifdef USE_HIRES) - rebuilt from image stack */
	/* game.sbuf - rebuilt from image stack */

	/* game.ego_words - fixed by clean_input */
	/* game.num_ego_words - fixed by clean_input */

	game.num_objects = read_sint16(f);
	for(i = 0; i < (SINT16)game.num_objects; i++)
		object_set_location(i, read_sint16(f));

	/* Those are not serialized */
	for (i = 0; i < MAX_DIRS; i++) {
		game.ev_keyp[i].occured = FALSE;
	}

	for (i = 0; i < MAX_STRINGS; i++)
		read_string (f, game.strings[i]);

	for (i = 0; i < MAX_DIRS; i++) {
		if(read_uint8(f) & RES_LOADED)
			agi_load_resource (rLOGIC, i);
		else
			agi_unload_resource (rLOGIC, i);
		game.logics[i].sIP = read_sint16(f);
		game.logics[i].cIP = read_sint16(f);
	}

	for (i = 0; i < MAX_DIRS; i++) {
		if(read_uint8(f) & RES_LOADED)
			agi_load_resource(rPICTURE, i);
		else
			agi_unload_resource(rPICTURE, i);
	}

	for (i = 0; i < MAX_DIRS; i++) {
		if(read_uint8(f) & RES_LOADED)
			agi_load_resource(rVIEW, i);
		else
			agi_unload_resource(rVIEW, i);
	}

	for(i = 0; i < MAX_DIRS; i++) {
		if(read_uint8(f) & RES_LOADED)
			agi_load_resource(rSOUND, i);
		else
			agi_unload_resource(rSOUND, i);
	}

	/* game.pictures - loaded above */
	/* game.logics - loaded above */
	/* game.views - loaded above */
	/* game.sounds - loaded above */

	for (i = 0; i < vt_entries; i++) {
		struct vt_entry* v = &game.view_table[i];

		v->step_time = read_uint8(f);
		v->step_time_count = read_uint8(f);
		v->entry = read_uint8(f);
		v->x_pos = read_sint16(f);
		v->y_pos = read_sint16(f);
		v->current_view = read_uint8(f);

		/* v->view_data - fixed below  */

		v->current_loop = read_uint8(f);
		v->num_loops = read_uint8(f);

		/* v->loop_data - fixed below  */

		v->current_cel = read_uint8(f);
		v->num_cels = read_uint8(f);

		/* v->cel_data - fixed below  */
		/* v->cel_data_2 - fixed below  */
		
		v->x_pos2 = read_sint16(f);
		v->y_pos2 = read_sint16(f);

		/* v->s - fixed below */

		v->x_size = read_sint16(f);
		v->y_size = read_sint16(f);
		v->step_size = read_uint8(f);
		v->cycle_time = read_uint8(f);
		v->cycle_time_count = read_uint8(f);
		v->direction = read_uint8(f);

		v->motion = read_uint8(f);
		v->cycle = read_uint8(f);
		v->priority = read_uint8(f);

		v->flags = read_uint16(f);
		
		v->parm1 = read_uint8(f);
		v->parm2 = read_uint8(f);
		v->parm3 = read_uint8(f);
		v->parm4 = read_uint8(f);
	}
	for (i = vt_entries; i < MAX_VIEWTABLE; i++) {
		memset (&game.view_table[i], 0, sizeof (struct vt_entry));
	}

	/* Fix some pointers in viewtable */

	for (i = 0; i < MAX_VIEWTABLE; i++) {
		struct vt_entry* v = &game.view_table[i];

		if(game.dir_view[v->current_view].offset == _EMPTY)
			continue;

		if(!(game.dir_view[v->current_view].flags & RES_LOADED))
			agi_load_resource(rVIEW, v->current_view);

		set_view(v, v->current_view); /* Fix v->view_data */
		set_loop(v, v->current_loop); /* Fix v->loop_data */
		set_cel(v, v->current_cel);   /* Fix v->cel_data */
		v->cel_data_2 = v->cel_data;
		v->s = NULL;		/* not sure if it is used... */
	}

	erase_both();

	/* Clear input line */
	clear_screen(0);
	write_status();

	/* Recreate background from saved image stack */
	clear_image_stack();
	while ((t = read_uint8(f)) != 0) {
		for (i = 0; i < 7; i++)
			parm[i] = read_sint16(f);
		replay_image_stack_call (t, parm[0], parm[1], parm[2],
			parm[3], parm[4], parm[5], parm[6]);
	}

	fclose(f);

	setflag(F_restore_just_ran, TRUE);

	game.has_prompt = 0;	/* force input line repaint if necessary*/
	clean_input();
	
	erase_both();
	blit_both();
	commit_both();
	show_pic();
	do_update();

	return err_OK;
}
Esempio n. 6
0
/* If main_cycle returns false, don't process more events! */
int main_cycle() {
	unsigned int key, kascii;
	struct vt_entry *v = &game.view_table[0];

	poll_timer();		/* msdos driver -> does nothing */
	update_timer();

	if (game.ver == 0) {
		_text->message_box("Warning: game CRC not listed, assuming AGI version 2.917.");
		game.ver = -1;
	}

	key = do_poll_keyboard();

	/* In AGI Mouse emulation mode we must update the mouse-related
	 * vars in every interpreter cycle.
	 */
	if (opt.agimouse) {
		game.vars[28] = mouse.x / 2;
		game.vars[29] = mouse.y;
	}

	if (key == KEY_PRIORITY) {
		_sprites->erase_both();
		debug_.priority = !debug_.priority;
		show_pic();
		_sprites->blit_both();
		_sprites->commit_both();
		key = 0;
	}

	if (key == KEY_STATUSLN) {
		debug_.statusline = !debug_.statusline;
		_text->write_status();
		key = 0;
	}

	/* Click-to-walk mouse interface */
	if (game.player_control && v->flags & ADJ_EGO_XY) {
		v->direction = get_direction(v->x_pos, v->y_pos, v->parm1, v->parm2, v->step_size);

		if (v->direction == 0)
			in_destination(v);
	}

	kascii = KEY_ASCII(key);

	if (kascii)
		setvar(V_key, kascii);
	process_key:
	switch (game.input_mode) {
	case INPUT_NORMAL:
		if (!handle_controller(key)) {
			if (key == 0 || !game.input_enabled)
				break;
			handle_keys(key);

			/* if ESC pressed, activate menu before
			 * accept.input from the interpreter cycle
			 * sets the input mode to normal again
			 * (closes: #540856)
			 */
			if (key == KEY_ESCAPE) {
				key = 0;
				goto process_key;
			}

			/* commented out to close bug #438872
			 * if (key) game.keypress = key;
			 */
		}
		break;
	case INPUT_GETSTRING:
		handle_controller(key);
		handle_getstring(key);
		setvar(V_key, 0);	/* clear ENTER key */
		break;
	case INPUT_MENU:
		menu->keyhandler(key);
		do_update();
		return false;
	case INPUT_NONE:
		handle_controller(key);
		if (key)
			game.keypress = key;
		break;
	}

	do_update();

	if (game.msg_box_ticks > 0)
		game.msg_box_ticks--;

	return true;
}
Esempio n. 7
0
int view_pictures ()
{
	int ec = err_OK;
	char x[64];
	int i, pic = 0, dir = 1;

	game.line_min_print = 1;

	for (i = 0; ec == err_OK; i = 1) {
		while (game.dir_pic[pic].offset == _EMPTY) {
			pic += dir;
			if (pic < 0)
				pic = MAX_DIRS - 1;

			if (pic > MAX_DIRS - 1) {
				pic = 0;
				if (i == 0) {		/* no pics? */
					ec = 1;
					fprintf (stderr, "No pictures found\n");
					goto end_view;
				}
			}
		}
		
		_D ("picture = %d", pic);
		if ((ec = agi_load_resource (rPICTURE, pic)) != err_OK) {
			_D (_D_CRIT "Whoops. bad pic %d", pic);
			ec = err_OK;
			pic += dir;
			goto next_pic;
		}

		print_text ("[drawing]", 0, 16, 0, strlen (x) + 1, 0, 15);

		/* decodes the raw data to useable form */
		decode_picture (pic, TRUE);

		show_pic ();
		put_screen ();
		
update_statusline:
#ifdef USE_HIRES
		sprintf (x, "Picture:%3i                  Hi-res: %3s",
			pic, opt.hires ? " on" : "off");
#else
		sprintf (x, "Picture:%3i                  Hi-res: N/A", pic);
#endif
		print_text (x, 0, 0, 0, strlen (x) + 1, 0, 15);
		sprintf (x, "H:Hi-res    P:Vis/Prio   +:Next   -:Prev");
		print_text (x, 0, 0, 23, strlen (x) + 1, 15, 0);
		sprintf (x, "R:Redraw      D:Screen dump       Q:Quit");
		print_text (x, 0, 0, 24, strlen (x) + 1, 15, 0);

		while (42) {
			decode_picture (pic, TRUE);
    			switch (picviewer_get_key()) {
    			case 'q':
				goto end_view;
#ifdef USE_HIRES
#ifdef USE_MOUSE
			case BUTTON_RIGHT:
#endif
    			case 'h':
				opt.hires = !opt.hires;
				show_pic ();
				put_screen ();
				goto update_statusline;
#endif
    			case 'p':
				debug.priority = !debug.priority;
				show_pic ();
				put_screen ();
    				break;
			case 'd':
				/*opt.showscreendraw = !opt.showscreendraw;*/
				screen_dump();
				goto update_statusline;
			case 'r':
				goto next_pic;
#ifdef USE_MOUSE
			case BUTTON_LEFT:
				if (mouse.x < GFX_WIDTH / 2) 
					goto previous_pic;
#endif
				/* fall through */
    			case '+':
				_D ("next pic");
 				if (pic < MAX_DIRS - 1)
    					pic++;
    				else
    					pic = 0;
    				dir = 1;
				goto next_pic;
    			case '-':
			previous_pic:
				_D ("previous pic");
    				if (pic > 0)
    					pic--;
    				else
    					pic = MAX_DIRS - 1;
    				i = 0;
    				dir = -1;
				goto next_pic;
    			}
    		}
next_pic:
    		agi_unload_resource (rPICTURE, pic);
    		
	}

end_view:
	return ec;
}
Esempio n. 8
0
void PrintSDNN() {
    //*******************************COMPUTE SDNN***************************/
    //HRavg=AVGRRIVms
    unsigned int SDNN,HRAVG,VarRRIVms;
    unsigned long SumofRRIVms=0;
    //------------------------------------------算平均RRIVms(第一次)
    for(unsigned int i=0; i<SDNNStruct.RRIVCount; i++) {
        SumofRRIVms+=RRIVmsSaveFlash[i];
    }
    SDNNStruct.AVGRRIV=SumofRRIVms/SDNNStruct.RRIVCount;
    //------------------------------------------算平均RRIVms(第二次)
    SumofRRIVms=0;
    unsigned int CorrectRRIVCount=0;
    double VarofRRIVms=0;
    for(unsigned int i=0; i<SDNNStruct.RRIVCount; i++) {
        VarRRIVms=RRIVmsSaveFlash[i]-SDNNStruct.AVGRRIV;
        if((VarRRIVms*VarRRIVms)<(SDNNStruct.AVGRRIV*SDNNStruct.AVGRRIV*0.25)) {
            SumofRRIVms+=RRIVmsSaveFlash[i];
            CorrectRRIVCount++;
        }
    }
    SDNNStruct.AVGRRIV=SumofRRIVms/CorrectRRIVCount;
    //------------------------------------------
    CorrectRRIVCount=SDNNStruct.RRIVCount;
    HRAVG=(unsigned int)(60000/SDNNStruct.AVGRRIV);
    for(unsigned int i=0; i<SDNNStruct.RRIVCount; i++) {
        VarRRIVms=RRIVmsSaveFlash[i]-SDNNStruct.AVGRRIV;
        if((VarRRIVms*VarRRIVms)>(SDNNStruct.AVGRRIV*SDNNStruct.AVGRRIV*0.25)) {
            //50%標準差
            CorrectRRIVCount--;                            //無效RRIV
        } else {
            VarofRRIVms+=(double)(VarRRIVms*VarRRIVms);   //有效RRIV
        }
    }
    SDNN=floor(sqrt(VarofRRIVms/(CorrectRRIVCount-1))*100);
    //**********************************************************************/
    Draw_BG_Image();
    Full_Block(30,17,68,50,0x00);

    unsigned char SDNNDIGI[5];
    unsigned char K[12]= {'0','1','2','3','4','5','6','7','8','9',':',' '};
    SDNNDIGI[0]=(unsigned char)SDNN/10000;  //百位
    SDNNDIGI[1]=(unsigned char)(SDNN/1000)%10; //十位
    SDNNDIGI[2]=(unsigned char)(SDNN/100)%10;  //個位
    SDNNDIGI[3]=(unsigned char)(SDNN/10)%10; //小數第一位
    SDNNDIGI[4]=(unsigned char)(SDNN)%10; //小數第二位

    if(SDNNDIGI[0]==0) {
        SDNNDIGI[0]=11;
    }
    if(SDNNDIGI[4]==0) {
        SDNNDIGI[4]=11;
    }

    Print("S D N N",7,32,18,8);
    Print(&K[SDNNDIGI[0]],1,35,28,8);
    Print(&K[SDNNDIGI[1]],1,45,28,8);				//:
    Print(&K[SDNNDIGI[2]],1,55,28,8);
    Print(".",1,65,34,8);
    Print(&K[SDNNDIGI[3]],1,75,28,8);
    //Print(&K[SDNNDIGI[4]],1,85,28,8);

    DrawLine(30,38,98,38);

    Print("  H R  ",7,32,42,8);
    Print(&K[HRAVG/100],1,47,52,8);
    Print(&K[(HRAVG/10)%10],1,57,52,8);
    Print(&K[(HRAVG%10)],1,67,52,8);

    show_pic();
}
Esempio n. 9
0
bool Menu::keyhandler(int key) {
	static int clock_val;
	static int menu_active = false;
	static int button_used = 0;

	if (!getflag(F_menus_work))
		return false;

	if (!menu_active) {
		clock_val = game.clock_enabled;
		game.clock_enabled = false;
		draw_menu_bar();
	}
	/*
	 * Mouse handling
	 */
	if (mouse.button) {
		int hmenu, vmenu;

		button_used = 1;	/* Button has been used at least once */
		if (mouse.y <= CHAR_LINES) {
			/* on the menubar */
			hmenu = 0;

			MenuList::iterator iterh;
			for (iterh = menubar.begin(); iterh != menubar.end(); ++iterh) {
				agi_menu *m = *iterh;
				if (mouse_over_text(0, m->col, m->text)) {
					break;
				} else {
					hmenu++;
				}
			}

			if (hmenu <= h_max_menu) {
				if (h_cur_menu != hmenu) {
					v_cur_menu = -1;
					new_menu_selected(hmenu);
				}
				h_cur_menu = hmenu;
			}
		} else {
			/* not in menubar */
			vmenu = 0;

			agi_menu *m = get_menu(h_cur_menu);
			MenuOptionList::iterator iterv;
			for (iterv = m->down.begin(); iterv != m->down.end(); ++iterv) {
				agi_menu_option *do1 = *iterv;
				if (mouse_over_text(2 + do1->index, m->wincol + 1, do1->text)) {
					break;
				} else {
					vmenu++;
				}
			}

			if (vmenu <= v_max_menu[h_cur_menu]) {
				if (v_cur_menu != vmenu) {
					draw_menu_option(h_cur_menu);
					draw_menu_option_hilite(h_cur_menu, vmenu);
				}
				v_cur_menu = vmenu;
			}
		}
	} else if (button_used) {
		/* Button released */
		button_used = 0;

		debugC(6, kDebugLevelMenu | kDebugLevelInput, "button released!");

		if (v_cur_menu < 0)
			v_cur_menu = 0;

		draw_menu_option_hilite(h_cur_menu, v_cur_menu);

		if (mouse.y <= CHAR_LINES) {
			/* on the menubar */
		} else {
			/* see which option we selected */
			agi_menu *m = get_menu(h_cur_menu);
			MenuOptionList::iterator iterv;
			for (iterv = m->down.begin(); iterv != m->down.end(); ++iterv) {
				agi_menu_option *d = *iterv;
				if (mouse_over_text(2 + d->index, m->wincol + 1, d->text)) {
					/* activate that option */
					if (d->enabled) {
						debugC(6, kDebugLevelMenu | kDebugLevelInput, "event %d registered", d->event);
						game.ev_keyp[d->event].occured = true;
						game.ev_keyp[d->event].data = d->event;
						goto exit_menu;
					}
				}
			}
			goto exit_menu;
		}
	}

	if (!menu_active) {
		if (h_cur_menu >= 0) {
			draw_menu_hilite(h_cur_menu);
			draw_menu_option(h_cur_menu);
			if (!button_used && v_cur_menu >= 0)
				draw_menu_option_hilite(h_cur_menu, v_cur_menu);
		}
		menu_active = true;
	}

	switch (key) {
	case KEY_ESCAPE:
		debugC(6, kDebugLevelMenu | kDebugLevelInput, "KEY_ESCAPE");
		goto exit_menu;
	case KEY_ENTER:
	{
		debugC(6, kDebugLevelMenu | kDebugLevelInput, "KEY_ENTER");
		agi_menu_option* d = get_menu_option(h_cur_menu, v_cur_menu);
		if (d->enabled) {
			debugC(6, kDebugLevelMenu | kDebugLevelInput, "event %d registered", d->event);
			game.ev_keyp[d->event].occured = true;
			goto exit_menu;
		}
		break;
	}
	case KEY_DOWN:
	case KEY_UP:
		v_cur_menu += key == KEY_DOWN ? 1 : -1;

		if (v_cur_menu < 0)
			v_cur_menu = 0;
		if (v_cur_menu > v_max_menu[h_cur_menu])
			v_cur_menu = v_max_menu[h_cur_menu];

		draw_menu_option(h_cur_menu);
		draw_menu_option_hilite(h_cur_menu, v_cur_menu);
		break;
	case KEY_RIGHT:
	case KEY_LEFT:
		h_cur_menu += key == KEY_RIGHT ? 1 : -1;

		if (h_cur_menu < 0)
			h_cur_menu = h_max_menu;
		if (h_cur_menu > h_max_menu)
			h_cur_menu = 0;

		v_cur_menu = 0;
		new_menu_selected(h_cur_menu);
		draw_menu_option_hilite(h_cur_menu, v_cur_menu);
		break;
	}

	return true;

exit_menu:
	button_used = 0;
	show_pic();
	_text->write_status();

	setvar(V_key, 0);
	game.keypress = 0;
	game.clock_enabled = clock_val;
	old_input_mode();
	debugC(3, kDebugLevelMenu, "exit_menu: input mode reset to %d", game.input_mode);
	menu_active = false;

	return true;
}
Esempio n. 10
0
void Menu::new_menu_selected(int i) {
	show_pic();
	draw_menu_bar();
	draw_menu_hilite(i);
	draw_menu_option(i);
}