Пример #1
0
// ************* Game_Init *************
// initializes game settings like character position
// and health
void Game_Init(void){
  ClearLCDgameStarted();
  ClearKeys();
  Change_Song(0);
  linkHealth = LINK_HEALTH;
  bossHealth = BOSS_HEALTH;
  mute = 0;
  gameEnd = 0;
  gameStarted = 0;
  // Boss's initial position and size
  Boss.Xpos = BOSS_START_X_POS;
  Boss.Ypos = BOSS_START_Y_POS;
  Boss.Direction = DOWN;
  Boss.Graphic = &boss[0];
  Boss.Height = BOSS_HEIGHT;
  Boss.Width = BOSS_WIDTH;
  // Link's initial position and size
  Link.Xpos = LINK_START_X_POS;
  Link.Ypos = LINK_START_Y_POS;
  Link.Direction = DOWN;
  Link.Graphic = &linkDown[0];
  Link.Height = LINK_HEIGHT;
  Link.Width = LINK_WIDTH;
  // displays the title screen
  LCD12864GraphicClear();
  LCD12864ImageDraw(&display[0],&splash[0],splash,0,0,LCD_WIDTH,LCD_HEIGHT);
  LCD12864Refresh(&display[0]);
  Timer1A_Disable();
}
Пример #2
0
int32
S9xMainWindow::KeyThread(void *o)
{
	S9xMainWindow *d = (S9xMainWindow *)o;
	while(1) {
		key_info info;
		if(d->IsActive() && get_key_info(&info) == B_NO_ERROR) {
			for(int i = 0; i < 128; i++)
				d->key[i].pressed = info.key_states[i >> 3] & (1 << (7 - (i % 8)));
		}
		ClearKeys(d->key);
		snooze(100000 / 30);
	}
	return 0;
}
Пример #3
0
int main (int argc, char **argv)
{
    int index,index2,tv,found=0;
    int dloop=1, rcc=-1, flsh=0, cupd=0;
    char rstr[BUFSIZE], *rptr, *aptr;
    time_t tm1,tm2;
    unsigned int alpha;
    clock_t tk1=0;
    FILE *fh;

    if(argc<2)
    {
        ShowUsage();
        return 0;
    }
    dloop=0;
    for(tv=1; !dloop && tv<argc; tv++)
    {
        aptr=argv[tv];
        if((rptr=strchr(aptr,'='))!=NULL)
        {
            rptr++;
            if(strstr(aptr,"size=")!=NULL)
            {
                if(sscanf(rptr,"%d",&size)!=1)
                {
                    dloop=1;
                }
            }
            else
            {
                if(strstr(aptr,"title=")!=NULL)
                {
                    title=strdup(rptr);
                    CatchTabs(title);
                    if(strcmp(title,"none")==0)
                    {
                        header=0;
                    }
                    /*
                    						tpos=0;
                    						while(*rptr)
                    						{
                    							if(*rptr!='~')
                    							{
                    								nstr[tpos]=*rptr;
                    							}
                    							else
                    							{
                    								rc=*(rptr+1);
                    								found=0;
                    								for(i=0; i<sizeof(sc) && !found; i++)
                    								{
                    									if(rc==sc[i])
                    									{
                    										rc=tc[i];
                    										found=1;
                    									}
                    								}
                    								if(found)
                    								{
                    									nstr[tpos]=rc;
                    									++rptr;
                    								}
                    								else
                    								{
                    									nstr[tpos]=*rptr;
                    								}
                    							}
                    							++tpos;
                    							++rptr;
                    						}
                    						nstr[tpos]=0;
                    						title=strdup(nstr);
                    */
                }
                else
                {
                    if(strstr(aptr,"timeout=")!=NULL)
                    {
                        if(sscanf(rptr,"%d",&timeout)!=1)
                        {
                            dloop=1;
                        }
                    }
                    else
                    {
                        if(strstr(aptr,"msg=")!=NULL)
                        {
                            dloop=Transform_Msg(rptr);
                            if(timeout==0)
                            {
                                if((timeout=Read_Neutrino_Cfg("timing.epg"))<0)
                                    timeout=300;
                            }
                            type=1;
                        }
                        else
                        {
                            if(strstr(aptr,"popup=")!=NULL)
                            {
                                dloop=Transform_Msg(rptr);
                                if(timeout==0)
                                {
                                    if((timeout=Read_Neutrino_Cfg("timing.infobar"))<0)
                                        timeout=6;
                                }
                                type=2;
                            }
                            else
                            {
                                if(strstr(aptr,"refresh=")!=NULL)
                                {
                                    if(sscanf(rptr,"%d",&refresh)!=1)
                                    {
                                        dloop=1;
                                    }
                                }
                                else
                                {
                                    if(strstr(aptr,"select=")!=NULL)
                                    {
                                        dloop=GetSelection(rptr);
                                    }
                                    else
                                    {
                                        if(strstr(aptr,"default=")!=NULL)
                                        {
                                            if((sscanf(rptr,"%d",&selection)!=1) || selection<1)
                                            {
                                                dloop=1;
                                            }
                                        }
                                        else
                                        {
                                            if(strstr(aptr,"order=")!=NULL)
                                            {
                                                if(sscanf(rptr,"%d",&bpline)!=1)
                                                {
                                                    dloop=1;
                                                }
                                            }
                                            else
                                            {
                                                if(strstr(aptr,"echo=")!=NULL)
                                                {
                                                    if(sscanf(rptr,"%d",&echo)!=1)
                                                    {
                                                        dloop=1;
                                                    }
                                                }
                                                else
                                                {
                                                    if(strstr(aptr,"absolute=")!=NULL)
                                                    {
                                                        if(sscanf(rptr,"%d",&absolute)!=1)
                                                        {
                                                            dloop=1;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if(strstr(aptr,"hide=")!=NULL)
                                                        {
                                                            if(sscanf(rptr,"%d",&mute)!=1)
                                                            {
                                                                dloop=1;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if(strstr(aptr,"cyclic=")!=NULL)
                                                            {
                                                                if(sscanf(rptr,"%d",&cyclic)!=1)
                                                                {
                                                                    dloop=1;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                dloop=2;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        switch (dloop)
        {
        case 1:
            printf("msgbox <param error: %s>\n",aptr);
            return 0;
            break;

        case 2:
            printf("msgbox <unknown command: %s>\n\n",aptr);
            ShowUsage();
            return 0;
            break;
        }
    }
    /*for(tv=0; tv<buttons; tv++)
    {
    	printf("%cButton %d: %s\n",(tv==selection-1)?'>':' ',tv+1,butmsg[tv]);
    }
    return 0;*/

    if(!echo)
    {
        printf("\nmsgbox  Message-Box Version %.2f\n",M_VERSION);
    }
    if(!buttons)
    {
        butmsg[0]=strdup("OK");
        buttons=1;
    }
    /*
    		if(selection>buttons)
    		{
    			printf("msgbox <param error: default=%d>\n",selection);
    			return 0;
    		}
    */
    if(!absolute)
    {
        for(tv=0; tv<buttons; tv++)
        {
            rbutt[tv]=tv+1;
        }
    }
    if(selection)
    {
        for(tv=0; tv<buttons && !found; tv++)
        {
            if(rbutt[tv]==selection)
            {
                selection=tv+1;
                found=1;
            }
        }
        if(!found)
        {
            printf("msgbox <param error: default=%d>\n",selection);
            return 0;
        }
    }
    else
    {
        for(tv=0; tv<buttons && !selection; tv++)
        {
            if(strlen(butmsg[tv]))
            {
                selection=tv+1;
            }
        }
    }
    /*		for(tv=0; selection!=rbutt[tv] && tv<buttons; tv++);

    		if(tv>=buttons)
    		{
    			selection=1;
    		}
    */
    if(!title)
    {
        title=strdup("Information");
    }
    if((line_buffer=calloc(BUFSIZE+1, sizeof(char)))==NULL)
    {
        printf(NOMEM);
        return -1;
    }

    if((debounce=Read_Neutrino_Cfg("repeat_genericblocker"))<0)
        debounce=200;

    if((rblock=Read_Neutrino_Cfg("repeat_blocker"))<0)
        rblock=50;

    if(((sx=Read_Neutrino_Cfg("screen_StartX"))<0)&&((sx=Read_Neutrino_Cfg("/enigma/plugins/needoffsets/left"))<0))
        sx=80;

    if(((ex=Read_Neutrino_Cfg("screen_EndX"))<0)&&((ex=Read_Neutrino_Cfg("/enigma/plugins/needoffsets/right"))<0))
        ex=620;

    if(((sy=Read_Neutrino_Cfg("screen_StartY"))<0)&&((sy=Read_Neutrino_Cfg("/enigma/plugins/needoffsets/top"))<0))
        sy=80;

    if(((ey=Read_Neutrino_Cfg("screen_EndY"))<0)&&((ey=Read_Neutrino_Cfg("/enigma/plugins/needoffsets/bottom"))<0))
        ey=505;

    if(Read_Neutrino_Cfg("rounded_corners")>0)
        radius=9;
    else
        radius=0;

    if((trstr=malloc(BUFSIZE))==NULL)
    {
        printf(NOMEM);
        return -1;
    }

    fb = open(FB_DEVICE, O_RDWR);
#ifdef HAVE_DBOX_HARDWARE
    ioctl(fb, AVIA_GT_GV_GET_BLEV, &alpha);
#endif
    rc = open(RC_DEVICE, O_RDONLY);
    fcntl(rc, F_SETFL, (fcntl(rc, F_GETFL) | O_EXCL) | O_NONBLOCK);

    //init framebuffer

    if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1)
    {
        printf("msgbox <FBIOGET_FSCREENINFO failed>\n");
        return -1;
    }
    if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1)
    {
        printf("msgbox <FBIOGET_VSCREENINFO failed>\n");
        return -1;
    }

    if(ioctl(fb, FBIOGETCMAP, &oldcmap) == -1)
    {
        printf("msgbox <FBIOGETCMAP failed>\n");
        return -1;
    }
    /*
    		fh=fopen("/tmp/cmap.log","w");
    		fprintf(fh,"Start: %d, LEN: %d\n",oldcmap.start,oldcmap.len);
    		for(tv=0; tv<256; tv++)
    		{
    			fprintf(fh,"%02d %04x %04x %04x %04x\n",tv,oldcmap.red[tv],oldcmap.green[tv],oldcmap.blue[tv],oldcmap.transp[tv]);
    		}
    		fclose(fh);
    */
    for(index=0; index<8; index++)
    {
        sprintf(rstr,"menu_%s_alpha",menucoltxt[index]);
        if((tv=Read_Neutrino_Cfg(rstr))>=0)
            for(index2=0; index2<7; index2++)
                otr[menucolval[index]+index2]=(tv<<8);
    }

    ord[FLASH]=ord[CMCT];
    ogn[FLASH]=ogn[CMCT];
    obl[FLASH]=obl[CMCT];
    otr[FLASH]=otr[CMCT];
    /*
    		fh=fopen("/tmp/cmap2.log","w");
    		fprintf(fh,"Start: %d, LEN: %d\n",oldcmap.start,oldcmap.len);
    		for(tv=0; tv<256; tv++)
    		{
    			fprintf(fh,"%02d %04x %04x %04x %04x\n",tv,oldcmap.red[tv],oldcmap.green[tv],oldcmap.blue[tv],oldcmap.transp[tv]);
    		}
    		fclose(fh);

    */
    /*
    {
    int i;
    printf("unsigned short rd[] = {");
    for(i=CMCST; i<=CMH;i++)
    printf("0x%02x<<8, ",(ord[i]>>8)&0xFF);
    printf("\nunsigned short gn[] = {");
    for(i=CMCST; i<=CMH;i++)
    printf("0x%02x<<8, ",(ogn[i]>>8)&0xFF);
    printf("\nunsigned short bl[] = {");
    for(i=CMCST; i<=CMH;i++)
    printf("0x%02x<<8, ",(obl[i]>>8)&0xFF);
    printf("\nunsigned short tr[] = {");
    for(i=CMCST; i<=CMH;i++)
    printf("0x%02x<<8, ",(otr[i]>>8)&0xFF);
    printf("\n");
    }
    return 0;
    */

    if(ioctl(fb, FBIOPUTCMAP, &oldcmap) == -1)
    {
        printf("msgbox <FBIOPUTCMAP failed>\n");
        return -1;
    }

    if(!(lfb = (unsigned char*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0)))
    {
        printf("msgbox <mapping of Framebuffer failed>\n");
        return -1;
    }

    //init fontlibrary

    if((error = FT_Init_FreeType(&library)))
    {
        printf("msgbox <FT_Init_FreeType failed with Errorcode 0x%.2X>", error);
        munmap(lfb, fix_screeninfo.smem_len);
        return -1;
    }

    if((error = FTC_Manager_New(library, 1, 2, 0, &MyFaceRequester, NULL, &manager)))
    {
        printf("msgbox <FTC_Manager_New failed with Errorcode 0x%.2X>\n", error);
        FT_Done_FreeType(library);
        munmap(lfb, fix_screeninfo.smem_len);
        return -1;
    }

    if((error = FTC_SBitCache_New(manager, &cache)))
    {
        printf("msgbox <FTC_SBitCache_New failed with Errorcode 0x%.2X>\n", error);
        FTC_Manager_Done(manager);
        FT_Done_FreeType(library);
        munmap(lfb, fix_screeninfo.smem_len);
        return -1;
    }

    if((error = FTC_Manager_Lookup_Face(manager, FONT, &face)))
    {
        printf("msgbox <FTC_Manager_Lookup_Face failed with Errorcode 0x%.2X>\n", error);
        FTC_Manager_Done(manager);
        FT_Done_FreeType(library);
        munmap(lfb, fix_screeninfo.smem_len);
        return -1;
    }

    use_kerning = FT_HAS_KERNING(face);

#ifdef FT_NEW_CACHE_API
    desc.face_id = FONT;
#else
    desc.font.face_id = FONT;
#endif

#if FREETYPE_MAJOR == 2 && FREETYPE_MINOR == 0
    desc.image_type = ftc_image_mono;
#else
    desc.flags = FT_LOAD_MONOCHROME;
#endif

    //init backbuffer

    if(!(lbb = malloc(var_screeninfo.xres*var_screeninfo.yres)))
    {
        printf("msgbox <allocating of Backbuffer failed>\n");
        FTC_Manager_Done(manager);
        FT_Done_FreeType(library);
        munmap(lfb, fix_screeninfo.smem_len);
        return -1;
    }

    if(!(obb = malloc(var_screeninfo.xres*var_screeninfo.yres)))
    {
        printf("msgbox <allocating of Backbuffer failed>\n");
        FTC_Manager_Done(manager);
        FT_Done_FreeType(library);
        free(lbb);
        munmap(lfb, fix_screeninfo.smem_len);
        return -1;
    }

    if(!(hbb = malloc(var_screeninfo.xres*var_screeninfo.yres)))
    {
        printf("msgbox <allocating of Backbuffer failed>\n");
        FTC_Manager_Done(manager);
        FT_Done_FreeType(library);
        free(lbb);
        free(obb);
        munmap(lfb, fix_screeninfo.smem_len);
        return -1;
    }

    if(!(ibb = malloc(var_screeninfo.xres*var_screeninfo.yres)))
    {
        printf("msgbox <allocating of Backbuffer failed>\n");
        FTC_Manager_Done(manager);
        FT_Done_FreeType(library);
        free(lbb);
        free(obb);
        free(hbb);
        munmap(lfb, fix_screeninfo.smem_len);
        return -1;
    }

    if(refresh & 1)
    {
        memcpy(ibb, lfb, var_screeninfo.xres*var_screeninfo.yres);
    }
    else
    {
        memset(ibb, TRANSP, var_screeninfo.xres*var_screeninfo.yres);
    }
    if(mute==2)
    {
        memcpy(hbb, lfb, var_screeninfo.xres*var_screeninfo.yres);
    }
    else
    {
        memset(hbb, TRANSP, var_screeninfo.xres*var_screeninfo.yres);
    }
    if(refresh & 2)
    {
        memcpy(obb, lfb, var_screeninfo.xres*var_screeninfo.yres);
    }
    else
    {
        memset(obb, TRANSP, var_screeninfo.xres*var_screeninfo.yres);
    }

    startx = sx /*+ (((ex-sx) - 620)/2)*/;
    starty = sy /* + (((ey-sy) - 505)/2)*/;


    /* Set up signal handlers. */
    signal(SIGINT, quit_signal);
    signal(SIGTERM, quit_signal);
    signal(SIGQUIT, quit_signal);

    put_instance(instance=get_instance()+1);

    show_txt(0);
//FBEnterWord( 100, 100, 100,20,CMCT);
//rc=RC_HOME;

    time(&tm1);
    tm2=tm1;
    tk1=clock()/(CLOCKS_PER_SEC/1000);
#ifdef HAVE_DREAMBOX_HARDWARE
    ClearKeys();
#endif

    //main loop

    while((rcc!=RC_HOME) && (rcc!=RC_OK) && ((timeout==-1)||((tm2-tm1)<timeout)))
    {
        rcc=GetRCCode();
        if(rcc!=-1)
        {
            time(&tm1);
        }
        else
        {
            if(++cupd>10)
            {
                if(cyclic)
                {
                    show_txt(0);
                    cupd=0;
                }
            }
            usleep(100000L);
        }
        if(mute && rcc==RC_MUTE)
        {
            hide^=1;
            show_txt(0);
            usleep(500000L);
            while(GetRCCode()!=-1);
            if(hide)
            {
                if((fh=fopen(HDF_FILE,"w"))!=NULL)
                {
                    fprintf(fh,"hidden");
                    fclose(fh);
                }
            }
            else
            {
                remove(HDF_FILE);
            }
        }
        if((!hide) && (rcc!=RC_HOME) && (rcc!=RC_OK))
        {
            switch(rcc)
            {
            case RC_LEFT:
                if(!hide && (--selection<1))
                {
                    selection=buttons;
                }
                show_txt(1);
                break;

            case RC_RIGHT:
                if(!hide && (++selection>buttons))
                {
                    selection=1;
                }
                show_txt(1);
                break;

            case RC_UP:
                if(!hide && ((selection-=bpline)<1))
                {
                    selection=1;
                }
                show_txt(1);
                break;

            case RC_DOWN:
                if(!hide && ((selection+=bpline)>buttons))
                {
                    selection=buttons;
                }
                show_txt(1);
                break;

            default:
                if(++flsh==7)
                {
                    flsh=0;
                    flash^=1;

                    ord[FLASH]=(flash)?ord[CMC]:ord[CMCT];
                    ogn[FLASH]=(flash)?ogn[CMC]:ogn[CMCT];
                    obl[FLASH]=(flash)?obl[CMC]:obl[CMCT];
                    otr[FLASH]=(flash)?otr[CMC]:otr[CMCT];
                    ioctl(fb, FBIOPUTCMAP, &oldcmap);
                }
                break;
            }
        }
        time(&tm2);
        if(hide)
        {
            rcc=-1;
        }
    }
    if((type!=1) || (rcc!=RC_OK))
    {
        selection=0;
    }


    //cleanup

    // clear Display
//	memset(lbb, TRANSP, var_screeninfo.xres*var_screeninfo.yres);
//	memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres);

    memcpy(lfb, obb, var_screeninfo.xres*var_screeninfo.yres);
    munmap(lfb, fix_screeninfo.smem_len);
#ifdef HAVE_DBOX_HARDWARE
    ioctl(fb, AVIA_GT_GV_SET_BLEV, alpha);
#endif
    close(fb);
    free(lbb);

    put_instance(get_instance()-1);

    if(echo && selection>0)
    {
        printf("%s\n",butmsg[selection-1]);
    }

    for(tv=0; tv<buttons; tv++)
    {
        free(butmsg[tv]);
    }
    free(trstr);
    free(line_buffer);
    free(title);

    FTC_Manager_Done(manager);
    FT_Done_FreeType(library);

    free(obb);
    free(hbb);
    free(ibb);

    close(rc);

    remove("/tmp/msgbox.tmp");

    if(selection)
    {
        return rbutt[selection-1];
    }
    return 0;
}
Пример #4
0
Document::~Document(void)
{
	ClearKeys();
	delete _calculator;
}