Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Making room for test prog's
Browse files Browse the repository at this point in the history
  • Loading branch information
Darren Alton committed Aug 13, 2008
1 parent bc9b3c7 commit 1d24b75
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 14,713 deletions.
1 change: 1 addition & 0 deletions src/audio/nds/SDL_ndsaudio.c
Expand Up @@ -50,6 +50,7 @@ NDSAUD_PlayDevice(_THIS)
sound->vol = 127; /* volume [0..127] for [min..max] */
sound->pan = 64; /* balance [0..127] for [left..right] */
sound->format = 0; /* 0 for 16-bit, 1 for 8-bit */
/*playSound(sound);*/
/* stub */
}

Expand Down
220 changes: 91 additions & 129 deletions src/video/nds/SDL_ndsrender.c
Expand Up @@ -32,7 +32,7 @@
#include "../SDL_renderer_sw.h"


/* SDL surface based renderer implementation */
/* SDL NDS renderer implementation */

static SDL_Renderer *NDS_CreateRenderer(SDL_Window * window, Uint32 flags);
static int NDS_ActivateRenderer(SDL_Renderer * renderer);
Expand Down Expand Up @@ -99,14 +99,15 @@ typedef struct
{
bg_attribute *bg;
u8 bg_taken[4];
/* todo for sprites: pSpriteRotation and pSpriteEntry. pointers to OAM */
int sub;
} NDS_RenderData;

typedef struct
{
enum { NDSTX_BG, NDSTX_SPR } type;
int hw_index;
struct { int w, h, pitch, bpp; } dim;
struct { int hdx, hdy, vdx, vdy, pitch, bpp; } dim;
u16 *vram;
} NDS_TextureData;

Expand All @@ -125,25 +126,6 @@ sdlds_rgb2bgr(u16 c)
return (c & GAmask) | r | b;
}

void
sdlds_print_pixfmt_info(SDL_PixelFormat * f)
{
if (!f)
return;
printf("bpp: %d\nRGBA: %x %x %x %x\n",
f->BitsPerPixel, f->Rmask, f->Gmask, f->Bmask, f->Amask);
}

void
sdlds_print_surface_info(SDL_Surface * s)
{
if (!s)
return;
printf("flags: %x\nsize: %dx%d, pitch: %d\nlocked: %d, refcount: %d\n",
s->flags, s->w, s->h, s->pitch, s->locked, s->refcount);
sdlds_print_pixfmt_info(s->format);
}

/* again the above shouldn't make it into the stable version */

SDL_Renderer *
Expand Down Expand Up @@ -269,20 +251,8 @@ printf("+NDS_CreateTexture\n");
int whichbg = -1;
if(!data->bg_taken[2]) {
whichbg = 2;
data->bg->bg2_rotation.xdx = 0x100;
data->bg->bg2_rotation.xdy = 0;
data->bg->bg2_rotation.ydx = 0;
data->bg->bg2_rotation.ydy = 0x100;
data->bg->bg2_rotation.centerX = 0;
data->bg->bg2_rotation.centerY = 0;
} else if(!data->bg_taken[3]) {
whichbg = 3;
data->bg->bg3_rotation.xdx = 0x100;
data->bg->bg3_rotation.xdy = 0;
data->bg->bg3_rotation.ydx = 0;
data->bg->bg3_rotation.ydy = 0x100;
data->bg->bg3_rotation.centerX = 0;
data->bg->bg3_rotation.centerY = 0;
}
if(whichbg >= 0) {
data->bg->control[whichbg] = (bpp == 8) ?
Expand All @@ -293,18 +263,16 @@ printf("+NDS_CreateTexture\n");
txdat = (NDS_TextureData*)texture->driverdata;
txdat->type = NDSTX_BG;
txdat->hw_index = whichbg;
txdat->dim.w = texture->w;
txdat->dim.h = texture->h;
txdat->dim.hdx = 0x100; txdat->dim.hdy = 0;
txdat->dim.vdx = 0; txdat->dim.vdy = 0x100;
txdat->dim.pitch = 256 * (bpp/8);
txdat->dim.bpp = bpp;
txdat->vram = (u16*)(data->sub ?
BG_BMP_RAM_SUB(whichbg) : BG_BMP_RAM(whichbg));
for(i = 0; i < 256*256; ++i) {
txdat->vram[i] = 0x8000|RGB15(0,31,31);
}
for(i = 0; i < 60; ++i) swiWaitForVBlank();
} else {
SDL_SetError("Out of NDS backgrounds.");
printf("ran out.\n");
}
} else {
SDL_SetError("Texture too big for NDS hardware.");
Expand Down Expand Up @@ -336,71 +304,6 @@ printf("-NDS_QueryTexturePixels\n");
}
}

static int
NDS_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Color * colors, int firstcolor, int ncolors)
{
printf("+NDS_SetTexturePalette\n");
if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
SDL_SetError("YUV textures don't have a palette");
return -1;
} else {
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
/* TODO: mess with 8-bit modes and/or 16-color palette modes */
printf("-NDS_SetTexturePalette\n");
return 0;
}
}

static int
NDS_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
SDL_Color * colors, int firstcolor, int ncolors)
{
printf("+NDS_GetTexturePalette\n");
if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
SDL_SetError("YUV textures don't have a palette");
return -1;
} else {
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
printf("-NDS_GetTexturePalette\n");
/* TODO: mess with 8-bit modes and/or 16-color palette modes */
return 0;
}
}

static int
NDS_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
printf("!NDS_SetTextureColorMod\n");
/* stub. TODO: figure out what needs to be done, if anything */
return 0;
}

static int
NDS_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
printf("!NDS_SetTextureAlphaMod\n");
/* stub. TODO: figure out what needs to be done, if anything */
return 0;
}

static int
NDS_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
printf("!NDS_SetTextureBlendMode\n");
/* stub. TODO: figure out what needs to be done, if anything */
return 0;
}

static int
NDS_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
printf("!NDS_SetTextureScaleMode\n");
/* stub. TODO: figure out what needs to be done.
(NDS hardware scaling is nearest neighbor.) */
return 0;
}

static int
NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels, int pitch)
Expand Down Expand Up @@ -443,12 +346,14 @@ printf("+NDS_LockTexture\n");
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;

if (markDirty) {
printf("wanted to mark dirty\n");
/*SDL_AddDirtyRect(&txdat->dirty, rect);*/
}

*pixels = (void *) ((u8 *)txdat->vram + rect->y * txdat->dim.pitch
+ rect->x * (txdat->dim.bpp/8));
*pitch = txdat->dim.pitch;
printf(" pixels = %08x\n", (u32)*pixels);
printf("-NDS_LockTexture\n");
return 0;
}
Expand Down Expand Up @@ -501,32 +406,22 @@ NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
// SDL_Window *window = SDL_GetWindowFromID(renderer->window);
// SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
int i;
int bpp = SDL_BYTESPERPIXEL(texture->format);
int pitch = txdat->dim.pitch;
printf("+NDS_RenderCopy\n");
/*for(i = 0; i <= 0xFFFF; ++i) {
txdat->vram[i] = 0x8000|i;
}*/
printf("/txdat->hw_index = %d\n", txdat->hw_index);
#if 0
if (txdat->dirty.list) {
SDL_DirtyRect *dirty;
void *pixels;
int bpp = SDL_BYTESPERPIXEL(texture->format);
int pitch = txdat->pitch;
/* below was borrowed from SDL_renderer_gl.c. doesn't work, obv.
figure out how to get the graphics data into VRAM. */

for (dirty = txdat->dirty.list; dirty; dirty = dirty->next) {
SDL_Rect *rect = &dirty->rect;
/*pixels =
(void *) ((Uint8 *) txdat->vram + rect->y * pitch +
rect->x * bpp);
data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y,
rect->w, rect->h, texturedata->format,
texturedata->formattype, pixels);*/
}
SDL_ClearDirtyRects(&txdat->dirty);
if(txdat->type == NDSTX_BG) {
bg_rotation *tmpbg = (txdat->hw_index == 2) ?
&(data->bg->bg2_rotation) : &(data->bg->bg3_rotation);
tmpbg->xdx = txdat->dim.hdx;
tmpbg->xdy = txdat->dim.hdy;
tmpbg->ydx = txdat->dim.vdx;
tmpbg->ydy = txdat->dim.vdy;
tmpbg->centerX = 0;
tmpbg->centerY = 0;
} else {
/* sprites not implemented yet */
}
#endif
printf(" txdat->hw_index = %d\n", txdat->hw_index);
printf("-NDS_RenderCopy\n");
return 0;
}
Expand All @@ -537,9 +432,11 @@ NDS_RenderPresent(SDL_Renderer * renderer)
{
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
/* Send the data to the display TODO */

/* shouldn't it already be there at this point?
I guess set the BG's and sprites "visible" flags here. */
printf("+NDS_RenderPresent\n");
/* Update the flipping chain, if any */

/* vsync for NDS */
if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) {
swiWaitForVBlank();
}
Expand Down Expand Up @@ -592,4 +489,69 @@ printf("+NDS_DestroyRenderer\n");
printf("-NDS_DestroyRenderer\n");
}

static int
NDS_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Color * colors, int firstcolor, int ncolors)
{
printf("+NDS_SetTexturePalette\n");
if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
SDL_SetError("YUV textures don't have a palette");
return -1;
} else {
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
/* TODO: mess with 8-bit modes and/or 16-color palette modes */
printf("-NDS_SetTexturePalette\n");
return 0;
}
}

static int
NDS_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
SDL_Color * colors, int firstcolor, int ncolors)
{
printf("+NDS_GetTexturePalette\n");
if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
SDL_SetError("YUV textures don't have a palette");
return -1;
} else {
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
printf("-NDS_GetTexturePalette\n");
/* TODO: mess with 8-bit modes and/or 16-color palette modes */
return 0;
}
}

static int
NDS_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
printf("!NDS_SetTextureColorMod\n");
/* stub. TODO: figure out what needs to be done, if anything */
return 0;
}

static int
NDS_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
printf("!NDS_SetTextureAlphaMod\n");
/* stub. TODO: figure out what needs to be done, if anything */
return 0;
}

static int
NDS_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
printf("!NDS_SetTextureBlendMode\n");
/* stub. TODO: figure out what needs to be done, if anything */
return 0;
}

static int
NDS_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
printf("!NDS_SetTextureScaleMode\n");
/* stub. TODO: figure out what needs to be done.
(NDS hardware scaling is nearest neighbor.) */
return 0;
}

/* vi: set ts=4 sw=4 expandtab: */

0 comments on commit 1d24b75

Please sign in to comment.