Example #1
0
int main(int argc, char* args[])
{
    if(SDL_Init(SDL_INIT_VIDEO) < 0)
    {
        //This is a nice alternative to printf in SDL 2
        SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "SDL", "SDL failed to initialize!", NULL);
        SDL_Quit();
        return 0;
    }

    //In SDL 2, SDL_SetVideoMode has been removed, we now create windows using SDL_CreateWindow to create windows
    Window = SDL_CreateWindow("I can talk!", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_SHOWN);

    //SDL_GetWindowSurface gets the backbuffer of the window we created with SDL_CreateWindow
    Backbuffer = SDL_GetWindowSurface(Window);

    if(!LoadFiles())
    {
      SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "SDL", SDL_GetError(), NULL);

        //SDL_DestroyWindow destroys a window we created with SDL_CreateWindow
        SDL_DestroyWindow(Window);
        FreeFiles();
        SDL_Quit();

        return 0;
    }

    while(ProgramIsRunning())
    {
        DrawImage(Background,Backbuffer, 0, 0);
        DrawRasterText(FontImage, Backbuffer, "All Systems Go!" , 100, 100, charSize);
        DrawRasterText(FontImage, Backbuffer, "Drawing Fonts is Fun!", 100, 116, charSize);

        SDL_Delay(20);

        //In SDL 2, SDL_UpdateWindowSurface replaces SDL_Flip
        SDL_UpdateWindowSurface(Window);
    }

    FreeFiles();

    //SDL_DestroyWindow destroys a window we created with SDL_CreateWindow
    SDL_DestroyWindow(Window);
    SDL_Quit();

    return 0;
}
Example #2
0
void FreeGame()
{
  //SDL_DestroyWindow destroys a window we created with SDL_CreateWindow
  SDL_DestroyWindow(Window);//Kill the window
  Mix_HaltMusic();    //Stop the music
  FreeFiles();        //Release the files we loaded
  Mix_CloseAudio();   //Close the audio system
  TTF_Quit();         //Close the font system
  SDL_Quit();         //Close SDL
}
Example #3
0
File: input.c Project: JWasm/JWasm
void InputFini( void )
/********************/
{
#ifdef DEBUG_OUT
    int   i;

    /* for the main source file, lines usually isn't filled yet */
    if ( ModuleInfo.g.FNames )
        ModuleInfo.g.FNames[ModuleInfo.srcfile].lines = src_stack->line_num;
    for( i = 0; i < ModuleInfo.g.cnt_fnames; i++ ) {
        if ( Options.log_all_files ) {
            if ( ModuleInfo.g.FNames[i].included > 1 )
                printf("%2u: %5u *%2u %s\n", i+1, ModuleInfo.g.FNames[i].lines, ModuleInfo.g.FNames[i].included, ModuleInfo.g.FNames[i].fname );
            else
                printf("%2u: %5u     %s\n", i+1, ModuleInfo.g.FNames[i].lines, ModuleInfo.g.FNames[i].fname );
        }
        DebugMsg(( "InputFini: idx=%u name=%s\n", i, ModuleInfo.g.FNames[i].fname ));
    }
#endif
    if ( ModuleInfo.g.IncludePath )
        MemFree( ModuleInfo.g.IncludePath );

    /* free items in ModuleInfo.g.FNames ( and FreeFile, if FASTMEM==0 ) */
    FreeFiles();
#ifdef DEBUG_OUT
    if ( Options.quiet == FALSE ) {
        printf("lines read(files)/processed in pass one: %" I32_SPEC "u / %" I32_SPEC "u\n", cntflines, cntlines );
        printf("invokations: PreprocessLine=%" I32_SPEC "u/%" I32_SPEC "u/%" I32_SPEC "u, Tokenize=%" I32_SPEC "u/%" I32_SPEC "u\n", cntppl0, cntppl1, cntppl2, cnttok0, cnttok1 );
    }
#endif
    ModuleInfo.tokenarray = NULL;
#ifdef DEBUG_OUT
    token_stringbuf = NULL;
    StringBufferEnd = NULL;
    commentbuffer = NULL;
    CurrSource = NULL;
#endif
    LclFree( srclinebuffer );
}
Example #4
0
void RebuildCpp_Main()
{
	if (ArgConstOpt != 0)
		Error(Error_System, "(RebuildCpp_Main) ArgConstOpt must be switched off");

	#ifdef CPP_SHOW_LINES
	InitFiles();
	#endif

	ArrayInit(&RebuildArray, sizeof(char), 0);
	ArrayInit(&LabelDone, sizeof(char), 0);

	memset(CppSyscallUsed, 0, sizeof(CppSyscallUsed));

	CppForceSysCallUsed("RBYTE");
	CppForceSysCallUsed("WBYTE");

	Rebuild_Mode = 1;
	CppUsedCallReg = 0;

	RebuildEmit("//****************************************\n");
	RebuildEmit("//          Generated Cpp code\n");
	RebuildEmit("//****************************************\n");

	RebuildEmit("\n");
	RebuildEmit("#include \"mstypeinfo.h\"\n");
	RebuildEmit("\n");

#if 0			//My Testing only
	RebuildCpp_EmitExtensionsProto();
#endif

	RebuildCpp_EmitProtos();

//	RebuildCpp_EmitDS();

//	RebuildEmit("class MoSyncCode\n");
//	RebuildEmit("{\n");

//	RebuildEmit("\n");					// Out in .h file
//	RebuildEmit("int sp;\n");
//	RebuildEmit("int __dbl_high;\n");

	RebuildEmit("\n");

//	RebuildCpp_EmitDS();
	RebuildCpp_StartUp();

	MaxEnumLabel = 0;

	RebuildCpp_Code();
	//RebuildCpp_EmitExtensions(1);
	RebuildCpp_CallReg();

//	RebuildEmit("}; // End of MosyncCode class\n");
//	RebuildEmit("// MaxEnumLabel=%d\n", MaxEnumLabel);

//	RebuildCpp_FlowClass();

	#ifdef CPP_SHOW_LINES
	FreeFiles();
	#endif

	ArrayWrite(&RebuildArray, "rebuild.build.cpp");
}
Example #5
0
int main(int argc, char* args[])
{
    if(SDL_Init(SDL_INIT_EVERYTHING) < 0)
    {
        printf("Failed to initialize SDL!\n");
        return 0;
    }

    Backbuffer = SDL_SetVideoMode(800, 600, 32, SDL_SWSURFACE);

    SDL_WM_SetCaption("Green is my pepper", NULL);

    if(!LoadFiles())
    {
        printf("Failed to load all files!\n");
        FreeFiles();
        SDL_Quit();

        return 0;
    }

    while(ProgramIsRunning())
    {
        //Update's the sprites frame
        FrameCounter++;

        if(FrameCounter > FrameDelay)
        {
            FrameCounter = 0;
            SpriteFrame++;
        }

        if(SpriteFrame > MaxSpriteFrame)
            SpriteFrame = 0;

        //Update's Background scrolling
        //BackgroundX-=6;
        //if(BackgroundX <= -800)
        //    BackgroundX = 0;

        //freeX += 3;
        //if(freeX >= 800)
        //	freeX = 0;

        // I ought to write a macro for this
        switch(direction){
        case NE:
        	// it's > N and E border
        	if(freeX >= 800-32 && freeY >= 600+32){
        		direction = SW;
        	}
        	// it's > E border
        	else if (freeX >= 800-32){
        		direction = NW;
        	}
        	// it's > N border
        	else if (freeY >= 600+32){
        		direction = SE;
        	}
        	// continue normally
        	else{
        		freeX+=INC;
        		freeY+=INC;
                //printf("NE\n");
        	}
        	break;
        case NW:
        	// it's greater than N and W border
        	if(freeX <= 0 && freeY >= 600+32){
        		direction = SE;
        	}
        	// it's > W border
        	else if (freeX <= 0){
        		direction = NE;
        	}
        	// it's > N border
        	else if (freeY >= 600 + 32){
        		direction = SW;
        	}
        	// continue normally
        	else{
        		freeX-=INC;
        		freeY+=INC;
                //printf("NW\n");
        	}
        	break;
        case SE:
        	// it's greater than S and E border
        	if(freeX >= 800-32 && freeY <= 0){
        		direction = NW;
        	}
        	// it's > E border
        	else if (freeX >= 800-32){
        		direction = SW;
        	}
        	// it's > S border
        	else if (freeY <= 0+32){
        		direction = NE;
        	}
        	else{
        		freeX+=INC;
        		freeY-=INC;
                //printf("SE\n");
        	}
        	break;
        case SW:
            // it's greater than S and W border
            if(freeX <= 0 && freeY <= 0){
                direction = NE;
            }
            // it's > W border
            else if (freeX <= 0){
                direction = SE;
            }
            // it's > S border
            else if (freeY <= 0+32){
                direction = NW;
            }
            // continue normally
            else{
                freeX-=INC;
                freeY-=INC;
                //printf("SW\n");
            }
            break;
        }



        //Render the scene
        DrawImage(Background,Backbuffer, BackgroundX, 0);
        DrawImage(Background,Backbuffer, BackgroundX+800, 0);
        DrawImage(SpriteImage, Backbuffer, freeX,600-freeY);

        SDL_Delay(20);
        SDL_Flip(Backbuffer);
    }

    FreeFiles();

    SDL_Quit();

    return 0;
}