src/video/nds/SDL_ndsrender.c
author Darren Alton <dalton@stevens.edu>
Sat, 19 Jul 2008 17:37:19 +0000
branchgsoc2008_nds
changeset 2680 4135aa9c5645
parent 2679 bc3e3e889f6d
child 2681 c15b6c758be5
permissions -rw-r--r--
More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
     1
/*
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
     3
    Copyright (C) 1997-2006 Sam Lantinga
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
     4
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
     6
    modify it under the terms of the GNU Lesser General Public
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
     8
    version 2.1 of the License, or (at your option) any later version.
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
     9
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    13
    Lesser General Public License for more details.
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    14
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    15
    You should have received a copy of the GNU Lesser General Public
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    16
    License along with this library; if not, write to the Free Software
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    18
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    19
    Sam Lantinga
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    20
    slouken@libsdl.org
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    21
*/
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    22
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    23
#include <stdio.h>
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    24
#include <stdlib.h>
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    25
#include <nds.h>
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    26
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    27
#include "SDL_config.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    28
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    29
#include "SDL_video.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    30
#include "../SDL_sysvideo.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    31
#include "../SDL_yuv_sw_c.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    32
#include "../SDL_renderer_sw.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    33
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    34
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    35
/* SDL surface based renderer implementation */
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    36
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    37
static SDL_Renderer *NDS_CreateRenderer(SDL_Window * window, Uint32 flags);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    38
static int NDS_ActivateRenderer(SDL_Renderer * renderer);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    39
static int NDS_DisplayModeChanged(SDL_Renderer * renderer);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    40
static int NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    41
static int NDS_QueryTexturePixels(SDL_Renderer * renderer,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    42
                                 SDL_Texture * texture, void **pixels,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    43
                                 int *pitch);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    44
static int NDS_SetTexturePalette(SDL_Renderer * renderer,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    45
                                SDL_Texture * texture,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    46
                                const SDL_Color * colors, int firstcolor,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    47
                                int ncolors);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    48
static int NDS_GetTexturePalette(SDL_Renderer * renderer,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    49
                                SDL_Texture * texture, SDL_Color * colors,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    50
                                int firstcolor, int ncolors);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    51
static int NDS_SetTextureColorMod(SDL_Renderer * renderer,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    52
                                 SDL_Texture * texture);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    53
static int NDS_SetTextureAlphaMod(SDL_Renderer * renderer,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    54
                                 SDL_Texture * texture);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    55
static int NDS_SetTextureBlendMode(SDL_Renderer * renderer,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    56
                                  SDL_Texture * texture);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    57
static int NDS_SetTextureScaleMode(SDL_Renderer * renderer,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    58
                                  SDL_Texture * texture);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    59
static int NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    60
                            const SDL_Rect * rect, const void *pixels,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    61
                            int pitch);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    62
static int NDS_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    63
                          const SDL_Rect * rect, int markDirty, void **pixels,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    64
                          int *pitch);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    65
static void NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    66
static void NDS_DirtyTexture(SDL_Renderer * renderer,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    67
                            SDL_Texture * texture, int numrects,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    68
                            const SDL_Rect * rects);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    69
static int NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g,
2671
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
    70
                              Uint8 b, Uint8 a, const SDL_Rect * rect);
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    71
static int NDS_RenderCopy(SDL_Renderer * renderer,
2671
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
    72
                              SDL_Texture * texture,
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
    73
                              const SDL_Rect * srcrect,
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
    74
                              const SDL_Rect * dstrect);
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    75
static void NDS_RenderPresent(SDL_Renderer * renderer);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    76
static void NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    77
static void NDS_DestroyRenderer(SDL_Renderer * renderer);
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    78
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    79
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    80
SDL_RenderDriver NDS_RenderDriver = {
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
    81
    NDS_CreateRenderer,
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
    82
    {   "nds", /* char* name */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
    83
        (SDL_RENDERER_SINGLEBUFFER|SDL_RENDERER_ACCELERATED), /* u32 flags */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
    84
        (SDL_TEXTUREMODULATE_NONE), /* u32 mod_modes */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
    85
        (SDL_TEXTUREBLENDMODE_NONE), /* u32 blend_modes */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
    86
        (SDL_TEXTURESCALEMODE_NONE), /* u32 scale_modes */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
    87
        3, /* u32 num_texture_formats */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
    88
        {
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
    89
            SDL_PIXELFORMAT_INDEX8,
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
    90
            SDL_PIXELFORMAT_RGB555,
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
    91
            SDL_PIXELFORMAT_RGB565
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
    92
        }, /* u32 texture_formats[20] */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
    93
        (256), /* int max_texture_width */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
    94
        (256), /* int max_texture_height */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
    95
    }
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    96
};
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    97
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    98
typedef struct
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
    99
{
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   100
    bg_attribute *bg;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   101
    u8 bg_taken[4];
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   102
    int sub;
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   103
} NDS_RenderData;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   104
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   105
typedef struct
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   106
{
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   107
    enum { NDSTX_BG, NDSTX_SPR } type;
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   108
    int hw_index;
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   109
    struct { int w, h, pitch, bpp; } dim;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   110
    u16 *vram;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   111
} NDS_TextureData;
2672
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   112
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   113
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   114
/* this is mainly hackish testing/debugging stuff to get cleaned up soon
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   115
   anything named sdlds_blah shouldn't make it into the stable version
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   116
 */
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   117
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   118
u16
2673
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   119
sdlds_rgb2bgr(u16 c)
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   120
{
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   121
/* hack to get the proper colors until I actually get BGR555 to work right */
2672
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   122
    u16 Rmask = 0x7C00, Bmask = 0x001F, GAmask = 0x83E0, r, b;
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   123
    r = (c & Rmask) >> 10;
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   124
    b = (c & Bmask) << 10;
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   125
    return (c & GAmask) | r | b;
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   126
}
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   127
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   128
void
2673
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   129
sdlds_print_pixfmt_info(SDL_PixelFormat * f)
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   130
{
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   131
    if (!f)
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   132
        return;
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   133
    printf("bpp: %d\nRGBA: %x %x %x %x\n",
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   134
           f->BitsPerPixel, f->Rmask, f->Gmask, f->Bmask, f->Amask);
2672
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   135
}
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   136
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   137
void
2673
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   138
sdlds_print_surface_info(SDL_Surface * s)
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   139
{
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   140
    if (!s)
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   141
        return;
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   142
    printf("flags: %x\nsize: %dx%d, pitch: %d\nlocked: %d, refcount: %d\n",
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   143
           s->flags, s->w, s->h, s->pitch, s->locked, s->refcount);
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   144
    sdlds_print_pixfmt_info(s->format);
2672
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   145
}
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   146
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   147
/* again the above shouldn't make it into the stable version */
2672
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   148
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   149
SDL_Renderer *
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   150
NDS_CreateRenderer(SDL_Window * window, Uint32 flags)
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   151
{
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   152
    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   153
    SDL_DisplayMode *displayMode = &display->current_mode;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   154
    SDL_Renderer *renderer;
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   155
    NDS_RenderData *data;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   156
    int i, n;
2672
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   157
    int bpp = 15;
2673
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   158
    Uint32 Rmask, Gmask, Bmask, Amask;
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   159
/*  Uint32 Rmask = 0x7C00, Gmask = 0x03E0, Bmask = 0x001F, Amask = 0x8000;
2672
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   160
    Uint32 Rmask = 0x001F, Gmask = 0x03E0, Bmask = 0x7C00, Amask = 0x8000;
2673
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   161
*/
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   162
printf("+NDS_CreateRenderer\n");
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   163
2673
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   164
    /* hard coded this to BGR555 for now */
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   165
    if (!SDL_PixelFormatEnumToMasks(SDL_PIXELFORMAT_BGR555, &bpp,
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   166
                                    &Rmask, &Gmask, &Bmask, &Amask)) {
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   167
        SDL_SetError("Unknown display format");
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   168
        return NULL;
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
   169
    }
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   170
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   171
    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   172
    if (!renderer) {
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   173
        SDL_OutOfMemory();
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   174
        return NULL;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   175
    }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   176
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   177
    data = (NDS_RenderData *) SDL_malloc(sizeof(*data));
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   178
    if (!data) {
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   179
        NDS_DestroyRenderer(renderer);
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   180
        SDL_OutOfMemory();
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   181
        return NULL;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   182
    }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   183
    SDL_zerop(data);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   184
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   185
    renderer->RenderFill = NDS_RenderFill;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   186
    renderer->RenderCopy = NDS_RenderCopy;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   187
    renderer->RenderPresent = NDS_RenderPresent;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   188
    renderer->DestroyRenderer = NDS_DestroyRenderer;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   189
    renderer->info.name = NDS_RenderDriver.info.name;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   190
    renderer->info.flags = 0;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   191
    renderer->window = window->id;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   192
    renderer->driverdata = data;
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   193
    renderer->CreateTexture = NDS_CreateTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   194
    renderer->QueryTexturePixels = NDS_QueryTexturePixels;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   195
    renderer->SetTexturePalette = NDS_SetTexturePalette;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   196
    renderer->GetTexturePalette = NDS_GetTexturePalette;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   197
    renderer->SetTextureColorMod = NDS_SetTextureColorMod;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   198
    renderer->SetTextureAlphaMod = NDS_SetTextureAlphaMod;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   199
    renderer->SetTextureBlendMode = NDS_SetTextureBlendMode;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   200
    renderer->SetTextureScaleMode = NDS_SetTextureScaleMode;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   201
    renderer->UpdateTexture = NDS_UpdateTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   202
    renderer->LockTexture = NDS_LockTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   203
    renderer->UnlockTexture = NDS_UnlockTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   204
    renderer->DirtyTexture = NDS_DirtyTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   205
    renderer->DestroyTexture = NDS_DestroyTexture;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   206
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   207
    renderer->info.mod_modes = NDS_RenderDriver.info.mod_modes;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   208
    renderer->info.blend_modes = NDS_RenderDriver.info.blend_modes;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   209
    renderer->info.scale_modes = NDS_RenderDriver.info.scale_modes;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   210
    renderer->info.num_texture_formats =
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   211
        NDS_RenderDriver.info.num_texture_formats;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   212
    SDL_memcpy(renderer->info.texture_formats,
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   213
               NDS_RenderDriver.info.texture_formats,
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   214
               sizeof(renderer->info.texture_formats));;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   215
    renderer->info.max_texture_width = NDS_RenderDriver.info.max_texture_width;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   216
    renderer->info.max_texture_height =
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   217
        NDS_RenderDriver.info.max_texture_height;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   218
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   219
    /*data->fb = (u16*)0x06020000;*/
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   220
    data->bg = &BACKGROUND;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   221
    data->bg_taken[2] = data->bg_taken[3] = 0;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   222
    data->sub = 0;
2672
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   223
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   224
printf("-NDS_CreateRenderer\n");
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   225
    return renderer;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   226
}
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   227
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   228
static int
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   229
NDS_ActivateRenderer(SDL_Renderer * renderer)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   230
{
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   231
    NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   232
    /* stub. TODO: figure out what needs to be done, if anything. */
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   233
printf("!NDS_ActivateRenderer\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   234
    return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   235
}
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   236
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   237
static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   238
NDS_DisplayModeChanged(SDL_Renderer * renderer)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   239
{
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   240
    NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   241
    /* stub. TODO: figure out what needs to be done */
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   242
printf("!NDS_DisplayModeChanged\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   243
    return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   244
}
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   245
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   246
static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   247
NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   248
{
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   249
    NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   250
    NDS_TextureData *txdat = NULL;
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   251
printf("+NDS_CreateTexture\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   252
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   253
        SDL_SetError("Unsupported texture format");
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   254
        return -1;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   255
    } else {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   256
        int bpp;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   257
        Uint32 Rmask, Gmask, Bmask, Amask;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   258
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   259
        if (!SDL_PixelFormatEnumToMasks
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   260
            (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   261
            SDL_SetError("Unknown texture format");
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   262
            return -1;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   263
        }
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   264
        /* conditional statements on w/h to place it as bg/sprite */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   265
        /*if(texture->w <= 64 && texture->h <= 64) {
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   266
            sprites not implemented yet.  elegant, I know.
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   267
        } else*/ if(texture->w <= 256 && texture->h <= 256) {
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   268
            int whichbg = -1;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   269
            if(!data->bg_taken[2]) {
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   270
                whichbg = 2;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   271
                data->bg->bg2_rotation.xdx = 0x100;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   272
                data->bg->bg2_rotation.xdy = 0;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   273
                data->bg->bg2_rotation.ydx = 0;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   274
                data->bg->bg2_rotation.ydy = 0x100;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   275
                data->bg->bg2_rotation.centerX = 0;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   276
                data->bg->bg2_rotation.centerY = 0;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   277
            } else if(!data->bg_taken[3]) {
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   278
                whichbg = 3;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   279
                data->bg->bg3_rotation.xdx = 0x100;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   280
                data->bg->bg3_rotation.xdy = 0;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   281
                data->bg->bg3_rotation.ydx = 0;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   282
                data->bg->bg3_rotation.ydy = 0x100;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   283
                data->bg->bg3_rotation.centerX = 0;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   284
                data->bg->bg3_rotation.centerY = 0;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   285
            }
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   286
            if(whichbg >= 0) {
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   287
                data->bg->control[whichbg] = (bpp == 8) ?
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   288
                    BG_BMP8_256x256 : BG_BMP16_256x256;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   289
                data->bg->scroll[whichbg].x = 0;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   290
                data->bg->scroll[whichbg].y = 0;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   291
                texture->driverdata = SDL_calloc(1, sizeof(NDS_TextureData));
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   292
                txdat = (NDS_TextureData*)texture->driverdata;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   293
                txdat->type = NDSTX_BG;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   294
                txdat->hw_index = whichbg;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   295
                txdat->dim.w = texture->w;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   296
                txdat->dim.h = texture->h;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   297
                txdat->dim.pitch = 256 * (bpp/8);
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   298
                txdat->dim.bpp = bpp;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   299
                txdat->vram = (u16*)(data->sub ?
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   300
                    BG_BMP_RAM_SUB(whichbg) : BG_BMP_RAM(whichbg));
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   301
            } else {
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   302
                SDL_SetError("Out of NDS backgrounds.");
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   303
            }
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   304
        } else {
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   305
            SDL_SetError("Texture too big for NDS hardware.");
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   306
        }
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   307
    }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   308
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   309
printf("-NDS_CreateTexture\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   310
    if (!texture->driverdata) {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   311
        return -1;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   312
    }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   313
    return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   314
}
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   315
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   316
static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   317
NDS_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   318
                      void **pixels, int *pitch)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   319
{
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   320
printf("+NDS_QueryTexturePixels\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   321
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   322
        SDL_SetError("Unsupported texture format");
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   323
        return -1;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   324
    } else {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   325
        NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   326
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   327
        *pixels = txdat->vram;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   328
        *pitch = txdat->dim.pitch;
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   329
printf("-NDS_QueryTexturePixels\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   330
        return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   331
    }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   332
}
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   333
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   334
static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   335
NDS_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   336
                     const SDL_Color * colors, int firstcolor, int ncolors)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   337
{
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   338
printf("+NDS_SetTexturePalette\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   339
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   340
        SDL_SetError("YUV textures don't have a palette");
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   341
        return -1;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   342
    } else {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   343
        NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   344
        /* TODO: mess with 8-bit modes and/or 16-color palette modes */
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   345
printf("-NDS_SetTexturePalette\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   346
        return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   347
    }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   348
}
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   349
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   350
static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   351
NDS_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   352
                     SDL_Color * colors, int firstcolor, int ncolors)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   353
{
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   354
printf("+NDS_GetTexturePalette\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   355
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   356
        SDL_SetError("YUV textures don't have a palette");
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   357
        return -1;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   358
    } else {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   359
        NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   360
printf("-NDS_GetTexturePalette\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   361
        /* TODO: mess with 8-bit modes and/or 16-color palette modes */
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   362
        return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   363
    }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   364
}
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   365
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   366
static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   367
NDS_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   368
{
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   369
printf("!NDS_SetTextureColorMod\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   370
    /* stub. TODO: figure out what needs to be done, if anything */
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   371
    return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   372
}
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   373
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   374
static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   375
NDS_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   376
{
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   377
printf("!NDS_SetTextureAlphaMod\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   378
    /* stub. TODO: figure out what needs to be done, if anything */
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   379
    return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   380
}
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   381
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   382
static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   383
NDS_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   384
{
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   385
printf("!NDS_SetTextureBlendMode\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   386
    /* stub. TODO: figure out what needs to be done, if anything */
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   387
    return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   388
}
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   389
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   390
static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   391
NDS_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   392
{
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   393
printf("!NDS_SetTextureScaleMode\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   394
    /* stub. TODO: figure out what needs to be done.
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   395
       (NDS hardware scaling is nearest neighbor.) */
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   396
    return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   397
}
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   398
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   399
static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   400
NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   401
                 const SDL_Rect * rect, const void *pixels, int pitch)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   402
{
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   403
printf("+NDS_UpdateTexture\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   404
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   405
        SDL_SetError("Unsupported texture format");
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   406
        return -1;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   407
    } else {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   408
        NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   409
        Uint8 *src, *dst;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   410
        int row;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   411
        size_t length;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   412
        /* IMPORTANT! copy the new pixels into the sprite or bg. */
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   413
        src = (Uint8 *) pixels;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   414
        dst =
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   415
            (Uint8 *) txdat->vram + rect->y * txdat->dim.pitch +
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   416
            rect->x * (txdat->dim.bpp/8);
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   417
        length = rect->w * (txdat->dim.bpp/8);
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   418
        for (row = 0; row < rect->h; ++row) {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   419
            SDL_memcpy(dst, src, length);
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   420
            src += pitch;
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   421
            dst += txdat->dim.pitch;
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   422
        }
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   423
printf("-NDS_UpdateTexture\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   424
        return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   425
    }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   426
}
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   427
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   428
static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   429
NDS_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   430
               const SDL_Rect * rect, int markDirty, void **pixels,
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   431
               int *pitch)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   432
{
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   433
printf("+NDS_LockTexture\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   434
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   435
        SDL_SetError("Unsupported texture format");
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   436
        return -1;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   437
    } else {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   438
        NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   439
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   440
        *pixels = (void *) ((u8 *)txdat->vram + rect->y * txdat->dim.pitch
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   441
                            + rect->x * (txdat->dim.bpp/8));
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   442
        *pitch = txdat->dim.pitch;
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   443
printf("-NDS_LockTexture\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   444
        return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   445
    }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   446
}
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   447
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   448
static void
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   449
NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   450
{
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   451
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   452
        SDL_SetError("Unsupported texture format");
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   453
    }
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   454
printf("!NDS_UnlockTexture\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   455
}
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   456
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   457
static void
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   458
NDS_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   459
                int numrects, const SDL_Rect * rects)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   460
{ /* stub */
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   461
printf("!NDS_DirtyTexture\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   462
}
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   463
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   464
static int
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   465
NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
2671
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
   466
                   Uint8 a, const SDL_Rect * rect)
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   467
{
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   468
    NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   469
    SDL_Rect real_rect = *rect;
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   470
    u16 color;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   471
    int i, j;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   472
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   473
printf("+NDS_RenderFill\n");
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   474
    /* TODO: make a single-color sprite and stretch it.
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   475
    color = RGB15(r>>3,g>>3,b>>3);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   476
    for (i = real_rect.x; i < real_rect.x+real_rect.w; ++i) {
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   477
        for (j = real_rect.y; j < real_rect.y+real_rect.h; ++j) {
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   478
            data->fb[(j + real_rect.y) * 256 + i + real_rect.x] = 
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   479
                0x8000 | color;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   480
        }
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   481
    }*/
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   482
printf("-NDS_RenderFill\n");
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   483
    return 0;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   484
}
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   485
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   486
static int
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   487
NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
2671
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
   488
                   const SDL_Rect * srcrect, const SDL_Rect * dstrect)
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   489
{
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   490
    NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   491
    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   492
    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   493
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   494
printf("+NDS_RenderCopy\n");
2672
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   495
#if 0
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   496
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   497
        SDL_Surface *target = data->screens[data->current_screen];
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   498
        void *pixels =
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   499
            (Uint8 *) target->pixels + dstrect->y * target->pitch +
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   500
            dstrect->x * target->format->BytesPerPixel;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   501
        return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata,
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   502
                                   srcrect, display->current_mode.format,
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   503
                                   dstrect->w, dstrect->h, pixels,
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   504
                                   target->pitch);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   505
    } else {
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   506
        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   507
        SDL_Surface *target = data->screens[data->current_screen];
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   508
        SDL_Rect real_srcrect = *srcrect;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   509
        SDL_Rect real_dstrect = *dstrect;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   510
        return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   511
    }
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   512
#endif
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   513
printf("-NDS_RenderCopy\n");
2672
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
   514
    return 0;
2671
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
   515
}
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
   516
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   517
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   518
static void
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   519
NDS_RenderPresent(SDL_Renderer * renderer)
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   520
{
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   521
    NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   522
    /* Send the data to the display TODO */
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   523
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   524
printf("+NDS_RenderPresent\n");
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   525
    /* Update the flipping chain, if any */
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   526
    if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) {
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   527
        swiWaitForVBlank();
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   528
    }
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   529
printf("-NDS_RenderPresent\n");
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   530
}
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   531
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   532
static void
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   533
NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   534
{
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   535
printf("+NDS_DestroyTexture\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   536
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   537
        SDL_SetError("Unsupported texture format");
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   538
    } else {
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   539
        /* free anything else allocated for texture */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   540
        SDL_free(texture->driverdata);
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   541
    }
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   542
printf("-NDS_DestroyTexture\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   543
}
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   544
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   545
static void
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   546
NDS_DestroyRenderer(SDL_Renderer * renderer)
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   547
{
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
   548
    NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   549
    /*SDL_Window *window = SDL_GetWindowFromID(renderer->window);
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   550
    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);*/
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   551
    int i;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   552
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   553
printf("+NDS_DestroyRenderer\n");
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   554
    if (data) {
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   555
        /* TODO: free anything relevant. */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   556
        /*for (i = 0; i < SDL_arraysize(data->texture); ++i) {
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   557
            if (data->texture[i]) {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   558
                DestroyTexture(data->renderer, data->texture[i]);
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   559
            }
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   560
        }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   561
        if (data->surface.format) {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   562
            SDL_SetSurfacePalette(&data->surface, NULL);
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   563
            SDL_FreeFormat(data->surface.format);
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   564
        }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   565
        if (display->palette) {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   566
            SDL_DelPaletteWatch(display->palette, DisplayPaletteChanged,
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   567
                                data);
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
   568
        }
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
   569
        SDL_FreeDirtyRects(&data->dirty);*/
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   570
        SDL_free(data);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   571
    }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   572
    SDL_free(renderer);
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
   573
printf("-NDS_DestroyRenderer\n");
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   574
}
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   575
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
   576
/* vi: set ts=4 sw=4 expandtab: */