Progress on update and wait functions, Pong update

This commit is contained in:
OctoSpacc 2023-11-14 00:29:48 +01:00
parent 3917df3b67
commit 33ebd6ca69
9 changed files with 197 additions and 256 deletions

View File

@ -3,7 +3,7 @@ image: debian:latest
before_script: |
apt update
apt install -y \
make gcc mingw-w64 wine cc65 emscripten curl p7zip-full python3 python3-pil \
make gcc mingw-w64 wine cc65 emscripten curl wget p7zip-full python3 python3-pil \
libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev libsdl-mixer1.2-dev \
libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev \
;

View File

@ -58,7 +58,7 @@ bool MainLoop( void *args )
return false;
}
if( !MultiSpacc_WaitUpdateDisplay( margs->window, &nextTick ) )
if( !MultiSpacc_UpdateDisplay( margs->window ) )
{
MultiSpacc_PrintDebug("[E] Error Updating Screen.\n");
return false;
@ -104,5 +104,5 @@ int main( int argc, char *argv[] )
MultiSpacc_PrintText( "Hello, World!", margs.background, &windowConfig, 2, 2, margs.tilesImg );
return MultiSpacc_SetMainLoop( MainLoop, &margs );
return MultiSpacc_SetMainLoop( MainLoop, NULL, &margs );
}

View File

@ -3,18 +3,20 @@
#define AppName "Pong"
bool paused = false;
Uint32 nextTick;
int scoreSx = 0;
int scoreDx = 0;
int ballX;
int ballY;
int accelX = 2;
int accelY = 2;
int accelX = 3;
int accelY = 3;
int paddleSxY;
int paddleDxY;
signed char paddleSxMove = 0;
signed char paddleDxMove = 0;
char paddleSxMove = 0;
char paddleDxMove = 0;
char scoreChar[6];
MultiSpacc_SurfaceConfig windowConfig = {0};
MultiSpacc_Window *window;
@ -24,20 +26,20 @@ MultiSpacc_Surface *tilesImg;
#define BallSize 8
#define PaddleWidth 8
#define PaddleHeight 4
#define PaddleHeightTiles 4
#define PaddleHeightPx 8*PaddleHeightTiles
#define BallTile 128
#define PaddleTile 129
#define BallSprite 0
#define PaddleSxSprite 1
#define PaddleDxSprite 1 + PaddleHeight
#define PaddleDxSprite 1 + PaddleHeightTiles
#define PaddleSxX PaddleWidth
#define PaddleDxX windowConfig.width - 2*PaddleWidth
#define PaddleAccel 2
#define DeltaTime 1
#define PaddleAccel 4
/*{pal:"nes",layout:"nes"}*/
const char palette[32] = {
@ -62,74 +64,133 @@ const unsigned char paddleMetaSprite[] = {
MultiSpacc_SpritesMap msdata;
void ResetBall(void)
{
ballX = windowConfig.width/2;
ballY = windowConfig.height/2;
}
void UpdateBall(void)
{
ballX += accelX;
ballY += accelY;
if( ballX <= 0-BallSize )
{
++scoreDx;
ResetBall();
}
else if( ballX >= windowConfig.width )
{
++scoreSx;
ResetBall();
}
#define IsTouchingPaddleSx ( ballX >= PaddleSxX-BallSize && ballX <= PaddleSxX+BallSize && ballY >= paddleSxY-BallSize && ballY <= paddleSxY+PaddleHeightPx )
#define IsTouchingPaddleDx ( ballX >= PaddleDxX-BallSize && ballX <= PaddleDxX+BallSize && ballY >= paddleDxY-BallSize && ballY <= paddleDxY+PaddleHeightPx )
if( IsTouchingPaddleSx || IsTouchingPaddleDx )
{
accelX *= -1;
ballX += accelX;
ballY += accelY;
}
// TODO: fix collision with upper borders of paddle, currently too aggressive and also broken? disabling everything makes the ball stick to paddles tho --- edit: with current setup it's kinda better but can still get stuck near the bottom/top of the screen and between paddle and side border, should fix (simply: don't allow paddle or ball near the very bottom of screen, put a mini-wall)
if( ballY <= 0 || ballY >= (windowConfig.height - BallSize) || (IsTouchingPaddleSx && ballX >= PaddleSxX && ballX <= PaddleSxX+BallSize) || (IsTouchingPaddleDx && ballX >= PaddleDxX && ballX <= PaddleDxX+BallSize) )
{
accelY *= -1;
ballX += accelX;
ballY += accelY;
}
}
void UpdatePlayer(void)
{
// if (paddleSxMove == -1)
// {
// paddleSxY -= PaddleAccel;
// paddleSxMove = 0;
// }
// else if (paddleSxMove == +1)
// {
// paddleSxY += PaddleAccel;
// paddleSxMove = 0;
// }
paddleSxY += PaddleAccel*paddleSxMove;
paddleSxMove = 0;
}
void UpdateCpuPlayer(void)
{
#define PaddleDxYCenter paddleDxY+PaddleHeightPx/2
if( accelX <= 0 )
{
if( paddleDxY < windowConfig.height/2 )
{
paddleDxY += PaddleAccel;
}
else if( paddleDxY > windowConfig.height/2 )
{
paddleDxY -= PaddleAccel;
}
}
else if( rand() % PaddleAccel != 1 )
{
if ( PaddleDxYCenter < ballY )
{
paddleDxY += PaddleAccel;
}
else if ( PaddleDxYCenter > ballY )
{
paddleDxY -= PaddleAccel;
}
}
}
bool FixedUpdate( void *args )
{
if(!paused)
{
ballX += accelX * DeltaTime;
ballY += accelY * DeltaTime;
if( ballX <= 0 || ballX >= (windowConfig.width - BallSize) )
{
accelX *= -1;
}
if( ballY <= 0 || ballY >= (windowConfig.height - BallSize) )
{
accelY *= -1;
}
#define TouchingPaddleSx ( ballX <= PaddleSxX+BallSize && ballY >= paddleSxY-BallSize && ballY <= (paddleSxY + 8*PaddleHeight) )
#define TouchingPaddleDx ( ballX >= PaddleDxX-BallSize && ballY >= paddleDxY-BallSize && ballY <= (paddleDxY + 8*PaddleHeight) )
if( TouchingPaddleSx || TouchingPaddleDx )
{
accelX *= -1;
}
if (paddleSxMove == 1)
{
paddleSxY -= PaddleAccel * DeltaTime;
paddleSxMove = 0;
}
else if (paddleSxMove == 2)
{
paddleSxY += PaddleAccel * DeltaTime;
paddleSxMove = 0;
}
UpdateBall();
UpdatePlayer();
UpdateCpuPlayer();
}
return true;
}
bool RealUpdate( void *args, double deltaTime )
{
//MultiSpacc_WaitFrame(&nextTick);
if(!paused)
{
//SDL_FillRect( background, &background->clip_rect, SDL_MapRGB( background->format, 0, 0, 0 ) );
MultiSpacc_BlitLayer( background, screen );
//printf("%d %f %f %d\n", ballX, deltaTime, accelX*deltaTime, ballX+accelX*deltaTime);
MultiSpacc_SetSprite( BallSprite, ballX+accelX*deltaTime, ballY+accelY*deltaTime, BallTile, tilesImg, screen );
#define PaddleSxYDisplay (paddleSxMove == 0 ? paddleSxY : paddleSxY+PaddleAccel*deltaTime)
#define PaddleDxYDisplay (paddleDxMove == 0 ? paddleDxY : paddleDxY+PaddleAccel*deltaTime)
MultiSpacc_SetMetaSprite( PaddleSxSprite, PaddleSxX, paddleSxY, &msdata, PaddleHeight, tilesImg, screen );
MultiSpacc_SetMetaSprite( PaddleDxSprite, PaddleDxX, paddleDxY, &msdata, PaddleHeight, tilesImg, screen );
}
#define PaddleSxYDisplay (paddleSxY + PaddleAccel*paddleSxMove*deltaTime)
#define PaddleDxYDisplay (paddleDxY + PaddleAccel*paddleDxMove*deltaTime)
MultiSpacc_SetMetaSprite( PaddleSxSprite, PaddleSxX, PaddleSxYDisplay, &msdata, PaddleHeightTiles, tilesImg, screen );
MultiSpacc_SetMetaSprite( PaddleDxSprite, PaddleDxX, PaddleDxYDisplay, &msdata, PaddleHeightTiles, tilesImg, screen );
if( paddleSxY > 0 && MultiSpacc_CheckKey( MultiSpacc_Key_Up, 0 ) )
{
//paddleSxY -= PaddleAccel * DeltaTime;
paddleSxMove = 1;
}
else if( paddleSxY < (windowConfig.height - 8*PaddleHeight) && MultiSpacc_CheckKey( MultiSpacc_Key_Down, 0 ) )
{
//paddleSxY += PaddleAccel * DeltaTime;
paddleSxMove = 2;
//itoa(scoreSx, scoreChar, 10);
//MultiSpacc_PrintText( scoreChar, screen, &windowConfig, 1, 1, tilesImg );
//itoa(scoreDx, scoreChar, 10);
//MultiSpacc_PrintText( scoreChar, screen, &windowConfig, windowConfig.width/8-6, 1, tilesImg );
if( paddleSxY > 0 && MultiSpacc_CheckKey( MultiSpacc_Key_Up, 0 ) )
{
paddleSxMove = -1;
}
else if( paddleSxY < windowConfig.height-PaddleHeightPx && MultiSpacc_CheckKey( MultiSpacc_Key_Down, 0 ) )
{
paddleSxMove = +1;
}
}
// TODO: listen for OS terminate signal
// TODO: fix SDL not waiting for key release with inputs checked this way
// TODO: proper pause menu
if( MultiSpacc_CheckKey( MultiSpacc_Key_Pause, 0 ) )
{
if(!paused)
@ -144,7 +205,6 @@ bool RealUpdate( void *args, double deltaTime )
}
}
//if( !MultiSpacc_WaitUpdateDisplay( window, &nextTick ) )
if( !MultiSpacc_UpdateDisplay(window) )
{
MultiSpacc_PrintDebug("[E] Error Updating Screen.\n");
@ -154,72 +214,6 @@ bool RealUpdate( void *args, double deltaTime )
return true;
}
/*
bool MainLoop( void *args )
{
MultiSpacc_WaitFrame(&nextTick);
if (!paused)
{
MultiSpacc_BlitLayer( background, screen );
MultiSpacc_SetSprite( BallSprite, ballX, ballY, BallTile, tilesImg, screen );
MultiSpacc_SetMetaSprite( PaddleSxSprite, PaddleSxX, paddleSxY, &msdata, PaddleHeight, tilesImg, screen );
MultiSpacc_SetMetaSprite( PaddleDxSprite, PaddleDxX, paddleDxY, &msdata, PaddleHeight, tilesImg, screen );
ballX += accelX * DeltaTime;
ballY += accelY * DeltaTime;
if( ballX <= 0 || ballX >= (windowConfig.width - BallSize) )
{
accelX *= -1;
}
if( ballY <= 0 || ballY >= (windowConfig.height - BallSize) )
{
accelY *= -1;
}
#define TouchingPaddleSx ( ballX <= PaddleSxX+BallSize && ballY >= paddleSxY-BallSize && ballY <= (paddleSxY + 8*PaddleHeight) )
#define TouchingPaddleDx ( ballX >= PaddleDxX-BallSize && ballY >= paddleDxY-BallSize && ballY <= (paddleDxY + 8*PaddleHeight) )
if( TouchingPaddleSx || TouchingPaddleDx )
{
accelX *= -1;
}
}
else
{
MultiSpacc_PrintText( "Pause", background, &windowConfig, 3, 3, tilesImg );
}
if( paddleSxY > 0 && MultiSpacc_CheckKey( MultiSpacc_Key_Up, 0 ) )
{
paddleSxY -= PaddleAccel * DeltaTime;
}
else if( paddleSxY < (windowConfig.height - 8*PaddleHeight) && MultiSpacc_CheckKey( MultiSpacc_Key_Down, 0 ) )
{
paddleSxY += PaddleAccel * DeltaTime;
}
// TODO: listen for OS terminate signal
if( MultiSpacc_CheckKey( MultiSpacc_Key_Pause, 0 ) )
{
if (!paused) paused = true;
else return false;
}
//if( !MultiSpacc_WaitUpdateDisplay( window, &nextTick ) )
if( !MultiSpacc_UpdateDisplay(window) )
{
MultiSpacc_PrintDebug("[E] Error Updating Screen.\n");
return false;
}
return true;
}
*/
int main( int argc, char *argv[] )
{
int chr[] = { 129, 129, 129, 129 };
@ -254,11 +248,9 @@ int main( int argc, char *argv[] )
return -1;
}
ballX = windowConfig.width/2;
ballY = windowConfig.height/2;
ResetBall();
paddleSxY = windowConfig.height/2 - 24;
paddleDxY = windowConfig.height/2 - 24;
//return MultiSpacc_SetMainLoop( MainLoop, NULL );
return MultiSpacc_SetMainLoop( FixedUpdate, RealUpdate, &nextTick, NULL );
return MultiSpacc_SetMainLoop( FixedUpdate, RealUpdate, NULL );
}

View File

@ -66,8 +66,13 @@ int MultiSpacc_SetColorKey( MultiSpacc_Surface *Surface, bool Flag, Uint32 Key )
#ifndef MultiSpacc_Target_SDLCom
void MultiSpacc_Sleep( int milliseconds )
{
/* TODO: 50 or 60 FPS based on region for appropriate consoles */
int frames = (60 * milliseconds / 1000);
#if defined(MultiSpacc_Target_NDS)
#define NativeFps 60
#elif defined(MultiSpacc_Target_NES)
#define NativeFps 50
#endif
int frames = (NativeFps * milliseconds / 1000);
while( --frames )
{
#if defined(MultiSpacc_Target_NDS)
@ -135,40 +140,54 @@ MultiSpacc_Surface *MultiSpacc_CreateSurface( MultiSpacc_SurfaceConfig *surfaceC
// partially copied from Unity's implementation, see <https://docs.unity3d.com/Manual/TimeFrameManagement.html>
bool MultiSpacc_MainLoopHandler( MultiSpacc_MainLoopHandlerArgs *handlerArgs )
{
#if defined(MultiSpacc_Target_SDLStandard)
//if( !handlerArgs->functionFixedUpdate(handlerArgs->args) || !handlerArgs->functionUpdate( handlerArgs->args, *handlerArgs->nextTick ) ){
// return false;
//}
#define AssertDirectCallUpdates ( ( handlerArgs->functionFixedUpdate != NULL && !handlerArgs->functionFixedUpdate(handlerArgs->args) ) || ( handlerArgs->functionRealUpdate != NULL && !handlerArgs->functionRealUpdate( handlerArgs->args, 1 ) ) )
#if defined(MultiSpacc_Target_SDLCommon)
Uint32 ticksNow;
Uint32 deltaTime;
//int cyclesSinceLast;
Uint32 realDeltaTime;
double fixedDeltaTime;
//MultiSpacc_WaitFrame(handlerArgs->nextTick);
ticksNow = SDL_GetTicks();
deltaTime = (ticksNow - handlerArgs->elapsedRealTime);
handlerArgs->elapsedRealTime += deltaTime;
//cyclesSinceLast = deltaTime / (1000 / MultiSpacc_GameTick);
realDeltaTime = (ticksNow - handlerArgs->elapsedRealTime);
handlerArgs->elapsedRealTime += realDeltaTime;
fixedDeltaTime = (double)(handlerArgs->elapsedRealTime - handlerArgs->elapsedFixedTime) / (double)(1000 / MultiSpacc_GameTick);
while ( handlerArgs->elapsedRealTime - handlerArgs->elapsedFixedTime > (1000 / MultiSpacc_GameTick) ) {
//for( int i=0; i<cyclesSinceLast; i++ ){
//if( handlerArgs->elapsedTime - handlerArgs->elapsedFixedTime > (1000 / MultiSpacc_GameTick) ){
if( !handlerArgs->functionFixedUpdate(handlerArgs->args) ){
while ( (handlerArgs->elapsedRealTime - handlerArgs->elapsedFixedTime) > (1000 / MultiSpacc_GameTick) ) {
if( handlerArgs->functionFixedUpdate != NULL && !handlerArgs->functionFixedUpdate(handlerArgs->args) ){
return false;
}
//handlerArgs->ticksLast = SDL_GetTicks();
handlerArgs->elapsedFixedTime += (1000 / MultiSpacc_GameTick);
}
if( !handlerArgs->functionRealUpdate( handlerArgs->args, (double)(handlerArgs->elapsedRealTime - handlerArgs->elapsedFixedTime)/((double)1000 / MultiSpacc_GameTick) ) ){
// TODO: limit real updates on native platforms, otherwise we waste infinite CPU cycles
if( handlerArgs->functionRealUpdate != NULL && !handlerArgs->functionRealUpdate( handlerArgs->args, fixedDeltaTime ) ){
return false;
}
#elif defined(MultiSpacc_Target_NES)
ppu_wait_frame();
if( !handlerArgs->functionFixedUpdate(handlerArgs->args) || !handlerArgs->functionRealUpdate( handlerArgs->args, 1 ) ){
if( AssertDirectCallUpdates ){
return false;
}
#endif
#elif defined(MultiSpacc_Target_NDS)
// TODO: limit FixedUpdate to 50 FPS, since NDS vblank is 60 Hz
swiWaitForVBlank();
if( AssertDirectCallUpdates ){
return false;
}
#endif
return true;
}
bool MultiSpacc_UpdateDisplay( MultiSpacc_Window *window )
{
#if defined(MultiSpacc_Target_SDL12)
return !SDL_Flip(window);
#elif defined(MultiSpacc_Target_SDL20)
return !SDL_UpdateWindowSurface(window);
#else
return true;
#endif
}

View File

@ -1,7 +1,7 @@
#ifndef _MultiSpacc_MultiSpacc_h_
#define _MultiSpacc_MultiSpacc_h_
// Fixed amount of times per second to call the FixedUpdate function
// Amount of times per second to call the FixedUpdate function, independent from video rate and hardcoded in some places due to consoles, don't change
#define MultiSpacc_GameTick 50
#include <stdarg.h>
@ -11,6 +11,7 @@
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef MultiSpacc_Target_SDL12
@ -108,8 +109,6 @@ typedef struct MultiSpacc_MainLoopHandlerArgs {
bool (*functionFixedUpdate)( void *args );
bool (*functionRealUpdate)( void *args, double deltaTime );
void *args;
//Uint32 *nextTick;
//Uint32 ticksLast;
Uint32 elapsedRealTime;
Uint32 elapsedFixedTime;
} MultiSpacc_MainLoopHandlerArgs;
@ -122,7 +121,7 @@ MultiSpacc_Surface *MultiSpacc_GetWindowSurface( MultiSpacc_Window *Window );
void MultiSpacc_SetAppTitle( MultiSpacc_Window *Window, const char Title[] );
void MultiSpacc_SetAppIcon( MultiSpacc_Window *Window, MultiSpacc_Surface *Icon );
bool MultiSpacc_SetMainLoop( bool functionFixedUpdate( void *args ), bool functionRealUpdate( void *args, double deltaTime ), Uint32 *nextTick, void *args );
bool MultiSpacc_SetMainLoop( bool functionFixedUpdate( void *args ), bool functionRealUpdate( void *args, double deltaTime ), void *args );
MultiSpacc_Surface *MultiSpacc_LoadImage( char FilePath[], MultiSpacc_Surface *Screen, Uint32 *ColorKey );
int MultiSpacc_SetColorKey( MultiSpacc_Surface *Surface, bool Flag, Uint32 Key );
@ -138,7 +137,8 @@ void MultiSpacc_SetMetaSprite( int id, int x, int y, MultiSpacc_SpritesMap *map,
MultiSpacc_Surface *MultiSpacc_CreateSurface( MultiSpacc_SurfaceConfig *surfaceConfig );
void MultiSpacc_BlitLayer( MultiSpacc_Surface *source, MultiSpacc_Surface *destination );
bool MultiSpacc_UpdateDisplay( MultiSpacc_Window *window );
#include "./Keys.h"
#include "./VideoCycle.h"
#endif // _MultiSpacc_MultiSpacc_h_

View File

@ -1,14 +1,12 @@
#include "./MultiSpacc.h"
bool MultiSpacc_SetMainLoop( bool functionFixedUpdate( void *args ), bool functionRealUpdate( void *args, double deltaTime ), Uint32 *nextTick, void *args )
bool MultiSpacc_SetMainLoop( bool functionFixedUpdate( void *args ), bool functionRealUpdate( void *args, double deltaTime ), void *args )
{
MultiSpacc_MainLoopHandlerArgs handlerArgs;
handlerArgs.functionFixedUpdate = functionFixedUpdate;
handlerArgs.functionRealUpdate = functionRealUpdate;
handlerArgs.args = args;
//handlerArgs.nextTick = nextTick;
//handlerArgs.ticksLast = 0;
handlerArgs.elapsedRealTime = 0;
handlerArgs.elapsedFixedTime = 0;
@ -16,10 +14,6 @@ bool MultiSpacc_SetMainLoop( bool functionFixedUpdate( void *args ), bool functi
emscripten_set_main_loop_arg( (em_arg_callback_func)MultiSpacc_MainLoopHandler, &handlerArgs, -1, true );
#else
while(true){
//MultiSpacc_WaitFrame(nextTick);
//if( !functionUpdate(args) || !functionFixedUpdate(args) ){
// return false;
//}
if ( !MultiSpacc_MainLoopHandler(&handlerArgs) ){
return false;
}
@ -28,6 +22,34 @@ bool MultiSpacc_SetMainLoop( bool functionFixedUpdate( void *args ), bool functi
return true;
}
MultiSpacc_Window *MultiSpacc_SetWindow( MultiSpacc_SurfaceConfig *windowConfig )
{
#if defined(MultiSpacc_Target_SDL12)
return SDL_SetVideoMode( windowConfig->width, windowConfig->height, windowConfig->bits, windowConfig->flags );
#elif defined(MultiSpacc_Target_SDL20)
return SDL_CreateWindow( NULL, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, windowConfig->width, windowConfig->height, windowConfig->flags );
#elif defined(MultiSpacc_Target_NDS)
PrintConsole *bottomScreen = NULL;
videoSetModeSub(MODE_0_2D);
vramSetBankC(VRAM_C_SUB_BG);
bottomScreen = consoleInit(bottomScreen, 3, BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
consoleSelect(bottomScreen);
return bottomScreen;
#elif defined(MultiSpacc_Target_NES)
windowConfig->width = 256;
windowConfig->height = 240;
oam_clear();
pal_all(windowConfig->palette);
ppu_on_all();
#endif
}
void MultiSpacc_SetAppTitle( MultiSpacc_Window *Window, const char *Title )
{
#if defined(MultiSpacc_Target_SDL12)

View File

@ -1,50 +0,0 @@
#include "./MultiSpacc.h"
// todo: frame-indepentent movements with delta time
void MultiSpacc_WaitFrame( Uint32 *nextTick )
{
#if defined(MultiSpacc_Target_SDLStandard)
Uint32 now = SDL_GetTicks();
if ( *nextTick <= now ) {
MultiSpacc_Sleep(0);
} else {
MultiSpacc_Sleep( *nextTick - now );
}
//*nextTick += 1000/MultiSpacc_GameTick;
*nextTick = SDL_GetTicks() + 1000/MultiSpacc_GameTick;
#elif defined(MultiSpacc_Target_NDS)
swiWaitForVBlank();
#elif defined(MultiSpacc_Target_NES)
ppu_wait_frame();
//ppu_wait_nmi();
#endif
}
bool MultiSpacc_UpdateDisplay( MultiSpacc_Window *window )
{
#if defined(MultiSpacc_Target_SDL12)
return !SDL_Flip(window);
#elif defined(MultiSpacc_Target_SDL20)
return !SDL_UpdateWindowSurface(window);
#else
return true;
#endif
}
bool MultiSpacc_WaitUpdateDisplay( MultiSpacc_Window *window, Uint32 *nextTick )
{
if( !MultiSpacc_UpdateDisplay(window) ){
return false;
}
MultiSpacc_WaitFrame(nextTick);
return true;
}
// #if defined(MultiSpacc_Target_NES)
// bool MultiSpacc_WaitUpdateDisplay_NES(void)
// {
// MultiSpacc_UpdateDisplay(NULL);
// MultiSpacc_WaitFrame(NULL);
// return true;
// }
// #endif

View File

@ -1,13 +0,0 @@
#ifndef _MultiSpacc_VideoCycle_h_
#define _MultiSpacc_VideoCycle_h_
void MultiSpacc_WaitFrame( Uint32 *nextTick );
bool MultiSpacc_UpdateDisplay( MultiSpacc_Window *window );
bool MultiSpacc_WaitUpdateDisplay( MultiSpacc_Window *window, Uint32 *nextTick );
//#if defined(MultiSpacc_Target_NES)
//bool MultiSpacc_WaitUpdateDisplay_NES(void);
//#define MultiSpacc_WaitUpdateDisplay( a, b ) MultiSpacc_WaitUpdateDisplay_NES()
//#endif
#endif // _MultiSpacc_VideoCycle_h_

View File

@ -1,29 +0,0 @@
#include "./MultiSpacc.h"
MultiSpacc_Window *MultiSpacc_SetWindow( MultiSpacc_SurfaceConfig *windowConfig )
{
#if defined(MultiSpacc_Target_SDL12)
return SDL_SetVideoMode( windowConfig->width, windowConfig->height, windowConfig->bits, windowConfig->flags );
#elif defined(MultiSpacc_Target_SDL20)
return SDL_CreateWindow( NULL, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, windowConfig->width, windowConfig->height, windowConfig->flags );
#elif defined(MultiSpacc_Target_NDS)
PrintConsole *bottomScreen = NULL;
videoSetModeSub(MODE_0_2D);
vramSetBankC(VRAM_C_SUB_BG);
bottomScreen = consoleInit(bottomScreen, 3, BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
consoleSelect(bottomScreen);
return bottomScreen;
#elif defined(MultiSpacc_Target_NES)
windowConfig->width = 256;
windowConfig->height = 240;
oam_clear();
pal_all(windowConfig->palette);
ppu_on_all();
#endif
}