NDS update
Frank Zago to SDL I've cleaned up a few bugs in the nds code. A few more tests now pass. There's still a few things to do, but overall I think it's starting to be in a good shape. The patch also includes a bug fix for SDL_ConvertSurfaceFormat() (gcc warning).
This commit is contained in:
parent
85ad17e7d6
commit
3b72fdeffe
7 changed files with 84 additions and 61 deletions
|
@ -131,7 +131,7 @@ NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
SDL_free(txdat);
|
||||
}
|
||||
|
||||
/* size is no more than 1024. */
|
||||
/* size is no more than 512. */
|
||||
static int get_gltexture_size(unsigned int size)
|
||||
{
|
||||
if (size > 256)
|
||||
|
@ -155,12 +155,10 @@ static int NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
{
|
||||
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
|
||||
|
||||
SDL_Log("enter %s\n", __func__);
|
||||
|
||||
glLoadTileSet(txdat->image,
|
||||
rect->w, rect->h,
|
||||
rect->w, rect->h,
|
||||
GL_RGBA,
|
||||
texture->format == SDL_PIXELFORMAT_ABGR1555 ? GL_RGBA : GL_RGB,
|
||||
get_gltexture_size(rect->w),
|
||||
get_gltexture_size(rect->h),
|
||||
TEXGEN_OFF, 0, NULL,
|
||||
|
@ -184,8 +182,25 @@ static void NDS_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
}
|
||||
|
||||
static int NDS_RenderClear(SDL_Renderer *renderer)
|
||||
{
|
||||
glClearColor(renderer->r >> 3,
|
||||
renderer->g >> 3,
|
||||
renderer->b >> 3,
|
||||
renderer->a >> 3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void NDS_RenderPresent(SDL_Renderer * renderer)
|
||||
{
|
||||
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
|
||||
static int frame =0;
|
||||
|
||||
glEnd2D();
|
||||
|
||||
glFlush(0);
|
||||
|
||||
swiWaitForVBlank();
|
||||
|
||||
/* wait for capture unit to be ready */
|
||||
while(REG_DISPCAPCNT & DCAP_ENABLE);
|
||||
|
@ -205,22 +220,6 @@ static int NDS_RenderClear(SDL_Renderer *renderer)
|
|||
}
|
||||
|
||||
glBegin2D();
|
||||
|
||||
glClearColor(renderer->r >> 3,
|
||||
renderer->g >> 3,
|
||||
renderer->b >> 3,
|
||||
renderer->a >> 3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void NDS_RenderPresent(SDL_Renderer * renderer)
|
||||
{
|
||||
// SDL_Log("enter %s\n", __func__);
|
||||
|
||||
glEnd2D();
|
||||
|
||||
glFlush( 0 );
|
||||
}
|
||||
|
||||
static int NDS_RenderDrawPoints(SDL_Renderer *renderer, const SDL_Point *points,
|
||||
|
@ -323,14 +322,8 @@ NDS_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
renderer->info.name = NDS_RenderDriver.info.name;
|
||||
renderer->info.flags = 0;
|
||||
renderer->info.num_texture_formats = NDS_RenderDriver.info.num_texture_formats;
|
||||
SDL_memcpy(renderer->info.texture_formats,
|
||||
NDS_RenderDriver.info.texture_formats,
|
||||
sizeof(renderer->info.texture_formats));
|
||||
renderer->info.max_texture_width = NDS_RenderDriver.info.max_texture_width;
|
||||
renderer->info.max_texture_height = NDS_RenderDriver.info.max_texture_height;
|
||||
renderer->info = NDS_RenderDriver.info;
|
||||
renderer->info.flags = SDL_RENDERER_ACCELERATED;
|
||||
|
||||
renderer->UpdateViewport = NDS_UpdateViewport;
|
||||
renderer->CreateTexture = NDS_CreateTexture;
|
||||
|
@ -345,6 +338,8 @@ NDS_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
renderer->RenderDrawLines = NDS_RenderDrawLines;
|
||||
renderer->RenderFillRects = NDS_RenderFillRects;
|
||||
|
||||
renderer->driverdata = data;
|
||||
|
||||
return renderer;
|
||||
}
|
||||
|
||||
|
@ -353,7 +348,7 @@ SDL_RenderDriver NDS_RenderDriver = {
|
|||
.info = {
|
||||
.name = "nds",
|
||||
.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC,
|
||||
.num_texture_formats = 1,
|
||||
.num_texture_formats = 2,
|
||||
.texture_formats = { [0] = SDL_PIXELFORMAT_ABGR1555,
|
||||
[1] = SDL_PIXELFORMAT_BGR555,
|
||||
},
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include "SDL_timer.h"
|
||||
|
||||
/* Will wrap afetr 49 days. Shouldn't be an issue. */
|
||||
/* Will wrap after 49 days. Shouldn't be an issue. */
|
||||
static volatile Uint32 timer_ticks;
|
||||
|
||||
static void
|
||||
|
|
|
@ -866,7 +866,7 @@ SDL_ConvertSurfaceFormat(SDL_Surface * surface, Uint32 pixel_format,
|
|||
Uint32 flags)
|
||||
{
|
||||
SDL_PixelFormat *fmt;
|
||||
SDL_Surface *convert;
|
||||
SDL_Surface *convert = NULL;
|
||||
|
||||
fmt = SDL_AllocFormat(pixel_format);
|
||||
if (fmt) {
|
||||
|
|
|
@ -44,7 +44,9 @@ NDS_PumpEvents(_THIS)
|
|||
SDL_SendMouseButton(0, SDL_RELEASED, 0);
|
||||
}
|
||||
if (keysHeld() & KEY_TOUCH) {
|
||||
touchPosition t = touchReadXY();
|
||||
touchPosition t;
|
||||
|
||||
touchRead(&t);
|
||||
SDL_SendMouseMotion(0, 0, t.px, t.py);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -249,6 +249,8 @@ static int NDS_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode
|
|||
{
|
||||
display->driverdata = mode->driverdata;
|
||||
|
||||
powerOn(POWER_ALL_2D);
|
||||
|
||||
#ifdef USE_HW_RENDERER
|
||||
|
||||
videoSetMode(MODE_5_3D);
|
||||
|
@ -256,17 +258,13 @@ static int NDS_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode
|
|||
|
||||
/* initialize gl2d */
|
||||
glScreen2D();
|
||||
glBegin2D();
|
||||
|
||||
vramSetBankA(VRAM_A_TEXTURE);
|
||||
vramSetBankA(VRAM_A_TEXTURE);
|
||||
vramSetBankB(VRAM_B_TEXTURE );
|
||||
vramSetBankC(VRAM_C_SUB_BG_0x06200000);
|
||||
vramSetBankC(VRAM_C_SUB_BG_0x06200000);
|
||||
vramSetBankE(VRAM_E_TEX_PALETTE);
|
||||
|
||||
powerOn(POWER_ALL_2D);
|
||||
|
||||
irqInit();
|
||||
irqEnable(IRQ_VBLANK);
|
||||
|
||||
// sub sprites hold the bottom image when 3D directed to top
|
||||
initSubSprites();
|
||||
|
||||
|
@ -279,16 +277,11 @@ static int NDS_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode
|
|||
videoSetMode(MODE_5_2D);
|
||||
videoSetModeSub(MODE_5_2D);
|
||||
|
||||
vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
|
||||
vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
|
||||
vramSetBankB(VRAM_B_TEXTURE );
|
||||
vramSetBankC(VRAM_C_SUB_BG_0x06200000);
|
||||
vramSetBankC(VRAM_C_SUB_BG_0x06200000);
|
||||
vramSetBankE(VRAM_E_TEX_PALETTE);
|
||||
|
||||
powerOn(POWER_ALL_2D);
|
||||
|
||||
irqInit();
|
||||
irqEnable(IRQ_VBLANK);
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
@ -311,7 +304,7 @@ static int NDS_VideoInit(_THIS)
|
|||
|
||||
SDL_zero(mode);
|
||||
|
||||
mode.format = SDL_PIXELFORMAT_UNKNOWN; // shoud be SDL_PIXELFORMAT_ABGR1555;
|
||||
mode.format = SDL_PIXELFORMAT_UNKNOWN; // should be SDL_PIXELFORMAT_ABGR1555;
|
||||
mode.w = SCREEN_WIDTH;
|
||||
mode.h = 2*SCREEN_HEIGHT+SCREEN_GAP;
|
||||
mode.refresh_rate = 60;
|
||||
|
@ -379,8 +372,8 @@ static SDL_VideoDevice *NDS_CreateDevice(int devindex)
|
|||
device->PumpEvents = NDS_PumpEvents;
|
||||
device->free = NDS_DeleteDevice;
|
||||
|
||||
/* Set the debug output. Use only for under an emulator. Will crash the DS. */
|
||||
#if 1
|
||||
/* Set the debug output. Use only under an emulator. Will crash the DS. */
|
||||
#if 0
|
||||
SDL_LogSetOutputFunction(NDS_DebugOutput, NULL);
|
||||
#endif
|
||||
|
||||
|
@ -392,4 +385,14 @@ VideoBootStrap NDS_bootstrap = {
|
|||
NDS_Available, NDS_CreateDevice
|
||||
};
|
||||
|
||||
double SDLCALL SDL_pow(double x, double y)
|
||||
{
|
||||
static int once = 1;
|
||||
if (once) {
|
||||
SDL_Log("SDL_pow called but not supported on this platform");
|
||||
once = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue