Beispiel #1
0
bool CDbgLuaHelper::Eval(const char *szCode, char* szRet)
{
    CoverGlobals();

    int top = lua_gettop(L);
    int status = luaL_loadbuffer(L, szCode, xr_strlen(szCode), szCode);
    if ( status )
        sprintf(szRet, "%s", luaL_checkstring(L, -1));
    else
    {
        status = lua_pcall(L, 0, LUA_MULTRET, 0);  /* call main */
        if ( status )
        {
            const char* szErr = luaL_checkstring(L, -1);
            const char* szErr2 = strstr(szErr, ": ");
            sprintf(szRet, "%s", szErr2?(szErr2+2):szErr);
        }
        else
            Describe(szRet, -1);
    }

    lua_settop(L, top);

    RestoreGlobals();

    return !status;
}
Beispiel #2
0
void PolyDrawLinePortal::Render(int portalDepth)
{
	SaveGlobals();

	// Find portal destination line and make sure it faces the right way
	line_t *clipLine = Portal ? Portal->mDestination : Mirror;
	DVector2 pt1 = clipLine->v1->fPos() - PolyRenderer::Instance()->Viewpoint.Pos;
	DVector2 pt2 = clipLine->v2->fPos() - PolyRenderer::Instance()->Viewpoint.Pos;
	bool backfacing = (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0);

	PortalViewpoint = PolyRenderer::Instance()->SetupPerspectiveMatrix(Mirror != nullptr);
	PortalViewpoint.StencilValue = StencilValue;
	PortalViewpoint.PortalDepth = portalDepth;
	PortalViewpoint.PortalEnterLine = clipLine;
	PortalViewpoint.PortalEnterSector = backfacing ? clipLine->frontsector : clipLine->backsector;

	PolyRenderer::Instance()->Scene.Render(&PortalViewpoint);

	RestoreGlobals();
}
Beispiel #3
0
void PolyDrawSectorPortal::Render(int portalDepth)
{
	if (Portal->mType == PORTS_HORIZON || Portal->mType == PORTS_PLANE)
		return;

	/*angle_t angle1 = PolyCull::PointToPseudoAngle(v1->fX(), v1->fY());
	angle_t angle2 = PolyCull::PointToPseudoAngle(v2->fX(), v2->fY());
	Segments.clear();
	Segments.push_back({ angle1, angle2 });*/

	SaveGlobals();

	PortalViewpoint = PolyRenderer::Instance()->SetupPerspectiveMatrix();
	PortalViewpoint.StencilValue = StencilValue;
	PortalViewpoint.PortalDepth = portalDepth;
	PortalViewpoint.PortalEnterSector = Portal->mDestination;

	PolyRenderer::Instance()->Scene.Render(&PortalViewpoint);
	
	RestoreGlobals();
}
void DrawN()
{
	unsigned char end = 1;

	redraw = 1;
    do
    {   
		vsync();
		
		end = 1;
        if(redraw)
        {
			ResetVideo();
			set_xres(256, xres_flags);
			scroll(0, 0, -32, 0, 240, 0xC0);
#ifndef CDROM1
			load_background(n_bg, n_pal, n_map, 32, 20);
#else
			set_screen_size(SCR_SIZE_32x32); 
			cd_loaddata(GPHX_OVERLAY, OFS_N_PAL_bin, palCD, SIZE_N_PAL_bin); 
			load_palette(0, palCD, 16); 
			cd_loadvram(GPHX_OVERLAY, OFS_N_DATA_bin, 0x1000, SIZE_N_DATA_bin);
			cd_loadvram(GPHX_OVERLAY, OFS_N_BAT_bin, 0, SIZE_N_BAT_bin);
			// Why these get zapped to 0 when in CDROM1...
			RestoreGlobals();
#endif
            redraw = 0;
			disp_on();
        }

        controller = joy(0);
        
		if(controller & JOY_SEL)
			end = 0;
    }while(!end);
}
void main()
{
    int sel = 0;

	redraw = 1;
	refresh = 1;
	

#ifndef CDROM
	xres_flags = XRES_SOFT;
	Enabled240p = 1;
	UseDefault = 0;
	EnabledSoft = 1;
	Enabled_C_BW = 0;
#endif

#ifdef CDROM
	RestoreGlobals();
#endif

#ifdef CDROM1	
	if(prev_select)
	{
		sel = prev_select;
		prev_select = 0;
	}
#endif

	disp_off();
	set_xres(320, xres_flags);
	if(Enabled240p)
		Set240p();

#ifndef CDROM
	disp_on();
	DrawIntro();
	disp_off();
#endif

    while(1)
    {   	
		vsync();
	
#ifdef CDROM1
		if(!HelpItem)
		{
#endif

        if(redraw)
        {
			RedrawMain();
            redraw = 0;
			refresh = 1;
			disp_on();
        }
		
		set_font_pal(15);
		
		if(refresh)
        {
            RefreshMain(sel);

            refresh = 0;
        }

        controller = joytrg(0);
		
		if (controller & JOY_SEL)
		{
#ifdef CDROM1
			x_g = 0;
#endif
			Options();
			redraw = 1;
		}
        
        if (controller & JOY_DOWN) 
        {
            sel++;
            if(sel > 14)
                sel = 0;
            refresh = 1;
        }

        if (controller & JOY_UP) 
        {
            sel--;
            if(sel < 0)
                sel = 14;
            refresh = 1;
        }
		
		if (controller & JOY_RUN)
		{
			showHelp(GENERAL_HELP);
			redraw = 1;
		}
#ifdef CDROM1
		}
		else
		{
			if(HelpItem <= OPTIONS_HELP)
			{
				sel = HelpItem;
				controller = JOY_I;
			}
				
			HelpItem = 0;
		}
#endif
		
		if (controller & JOY_I)
		{
			disp_off();
			ResetVideo();
			switch(sel)
			{
				case 0:
#ifndef CDROM1
					TestPatterns();
#else
					xres_flags_g = xres_flags;
					Enabled240p_g = Enabled240p;
					UseDefault_g = UseDefault;
					EnabledSoft_g = EnabledSoft;
					Enabled_C_BW_g = Enabled_C_BW;
					
					set_font_pal(14);
					put_string("Loading...", 27, 26);
					cd_execoverlay(PATTERNS_OVERLAY);
#endif
					break;
				case 1:
					DropShadow();
					break;
				case 2:
					StripedSprite();
					break;
				case 3:
					LagTest();
					break;
				case 4:
					ManualLagTest();
					break;
				case 5:
					ScrollTest();
					break;
				case 6:
					VScrollTest();
					break;
				case 7:
					DrawStripes();
					break;
				case 8:
					DrawCheck();
					break;
				case 9:
					LEDZoneTest();
					break;
				case 10:
					SoundTest();
					break;
				case 11:
					AudioSyncTest();
					break;
				case 12:
#ifdef CDROM1
					prev_select = sel;
#endif
					Options();
					break;
				case 13:
#ifdef CDROM1
					prev_select = sel;
#endif
					showHelp(GENERAL_HELP);
					break;
				case 14:
					DrawCredits();
					break;
			}
			redraw = 1;			
			disp_off();
		}
    }
}