34 changed files with 2422 additions and 65 deletions
@ -0,0 +1,13 @@
|
||||
timers : src/timer/prizm/SDL_systimer.c |
||||
|
||||
implement : |
||||
void SDL_StartTicks(void); |
||||
Uint32 SDL_GetTicks (void); |
||||
void SDL_Delay (Uint32 ms) |
||||
|
||||
check if : |
||||
#include "SDL_thread.h" is working or not |
||||
|
||||
|
||||
video : |
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,107 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer |
||||
Copyright (C) 1997-2012 Sam Lantinga |
||||
|
||||
This library is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU Lesser General Public |
||||
License as published by the Free Software Foundation; either |
||||
version 2.1 of the License, or (at your option) any later version. |
||||
|
||||
This library is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
Lesser General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU Lesser General Public |
||||
License along with this library; if not, write to the Free Software |
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
||||
|
||||
Sam Lantinga |
||||
slouken@libsdl.org |
||||
*/ |
||||
|
||||
#include <gint/gint.h> |
||||
#include <gint/timer.h> |
||||
#include <gint/rtc.h> |
||||
|
||||
#include "SDL_config.h" |
||||
|
||||
#ifdef SDL_TIMER_PRIZM |
||||
|
||||
#include "SDL_timer.h" |
||||
#include "../SDL_timer_c.h" |
||||
|
||||
static volatile unsigned *value; |
||||
static volatile unsigned *control; |
||||
Uint32 tick_sum = 0; |
||||
Uint32 start = 0; |
||||
|
||||
/*
|
||||
Uses the first timer (0x900C0000) |
||||
TC: http://hackspire.unsads.com/wiki/index.php/Memory-mapped_I/O_ports#900C0000_-_First_timer
|
||||
CX: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0271d/Babehiha.html
|
||||
*/ |
||||
|
||||
void SDL_StartTicks(void) |
||||
{ |
||||
|
||||
} |
||||
|
||||
Uint32 SDL_GetTicks (void) |
||||
{ |
||||
|
||||
} |
||||
|
||||
void SDL_Delay (Uint32 ms) |
||||
{ |
||||
|
||||
} |
||||
|
||||
#include "SDL_thread.h" |
||||
|
||||
/* Data to handle a single periodic alarm */ |
||||
static int timer_alive = 0; |
||||
static SDL_Thread *timer = NULL; |
||||
|
||||
static int RunTimer(void *unused) |
||||
{ |
||||
while ( timer_alive ) { |
||||
if ( SDL_timer_running ) { |
||||
SDL_ThreadedTimerCheck(); |
||||
} |
||||
SDL_Delay(1); |
||||
} |
||||
return(0); |
||||
} |
||||
|
||||
/* This is only called if the event thread is not running */ |
||||
int SDL_SYS_TimerInit(void) |
||||
{ |
||||
timer_alive = 1; |
||||
timer = SDL_CreateThread(RunTimer, NULL); |
||||
if ( timer == NULL ) |
||||
return(-1); |
||||
return(SDL_SetTimerThreaded(1)); |
||||
} |
||||
|
||||
void SDL_SYS_TimerQuit(void) |
||||
{ |
||||
timer_alive = 0; |
||||
if ( timer ) { |
||||
SDL_WaitThread(timer, NULL); |
||||
timer = NULL; |
||||
} |
||||
} |
||||
|
||||
int SDL_SYS_StartTimer(void) |
||||
{ |
||||
//SDL_SetError("Timers not implemented on the TI-Nspire");
|
||||
return(-1); |
||||
} |
||||
|
||||
void SDL_SYS_StopTimer(void) |
||||
{ |
||||
return; |
||||
} |
||||
|
||||
#endif /* SDL_TIMER_PRIZM */ |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,100 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer |
||||
Copyright (C) 1997-2012 Sam Lantinga |
||||
|
||||
This library is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU Lesser General Public |
||||
License as published by the Free Software Foundation; either |
||||
version 2.1 of the License, or (at your option) any later version. |
||||
|
||||
This library is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
Lesser General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU Lesser General Public |
||||
License along with this library; if not, write to the Free Software |
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
||||
|
||||
Sam Lantinga |
||||
slouken@libsdl.org |
||||
*/ |
||||
#include "SDL_config.h" |
||||
|
||||
#include "SDL.h" |
||||
#include "../../events/SDL_sysevents.h" |
||||
#include "../../events/SDL_events_c.h" |
||||
#include "../SDL_cursor_c.h" |
||||
|
||||
#include <gint/keyboard.h> |
||||
|
||||
#include "SDL_prizmvideo.h" |
||||
#include "SDL_prizmevents_c.h" |
||||
|
||||
static int nspk_keymap[PRZ_NUMKEYS]; |
||||
static SDLKey sdlk_keymap[PRZ_NUMKEYS]; |
||||
static Uint8 key_state[PRZ_NUMKEYS]; |
||||
|
||||
static SDLKey sdlak_keymap[4] = {SDLK_UP, SDLK_RIGHT, SDLK_DOWN, SDLK_LEFT}; |
||||
static Uint8 arrow_key_state[4]; |
||||
|
||||
static void nsp_update_keyboard(void) |
||||
{ |
||||
int i; |
||||
for ( i = 0; i < PRZ_NUMKEYS; ++i ) { |
||||
bool key_pressed; |
||||
if ( sdlk_keymap[i] == SDLK_UNKNOWN ) |
||||
continue; |
||||
key_pressed = keydown(nspk_keymap[i]); |
||||
PRZ_UPDATE_KEY_EVENT(sdlk_keymap[i], i, key_state[i], key_pressed); |
||||
} |
||||
} |
||||
|
||||
static void nsp_update_arrow_keys(void) |
||||
{ |
||||
bool arrow_key_pressed[4] = { |
||||
keydown(KEY_UP), |
||||
keydown(KEY_RIGHT), |
||||
keydown(KEY_DOWN), |
||||
keydown(KEY_LEFT) |
||||
}; |
||||
int i; |
||||
for ( i = 0; i < 4; ++i ) |
||||
PRZ_UPDATE_KEY_EVENT(sdlak_keymap[i], i, arrow_key_state[i], arrow_key_pressed[i]); |
||||
} |
||||
|
||||
void PRZ_PumpEvents(_THIS) |
||||
{ |
||||
nsp_update_keyboard(); |
||||
nsp_update_arrow_keys(); |
||||
} |
||||
|
||||
void PRZ_InitOSKeymap(_THIS) |
||||
{ |
||||
/* Enum value -> KEY_NSPIRE_* */ |
||||
|
||||
|
||||
//nspk_keymap[NSP_KEY_RET] = KEY_NSPIRE_RET;
|
||||
|
||||
/*
|
||||
** |
||||
** |
||||
** |
||||
** |
||||
*/ |
||||
|
||||
/* Enum value -> SDLK_*
|
||||
This is the actual key mapping part. */ |
||||
|
||||
|
||||
// sdlk_keymap[NSP_KEY_A] = SDLK_a;
|
||||
/*
|
||||
** |
||||
** |
||||
** |
||||
** |
||||
*/ |
||||
} |
||||
|
||||
/* end of SDL_tinspireevents.c ... */ |
||||
|
@ -0,0 +1,102 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer |
||||
Copyright (C) 1997-2012 Sam Lantinga |
||||
|
||||
This library is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU Lesser General Public |
||||
License as published by the Free Software Foundation; either |
||||
version 2.1 of the License, or (at your option) any later version. |
||||
|
||||
This library is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
Lesser General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU Lesser General Public |
||||
License along with this library; if not, write to the Free Software |
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
||||
|
||||
Sam Lantinga |
||||
slouken@libsdl.org |
||||
*/ |
||||
#include "SDL_config.h" |
||||
|
||||
#include "SDL_prizmvideo.h" |
||||
|
||||
#define PRZ_UPDATE_KEY_EVENT(s, sc, ks, kp) do { \ |
||||
SDL_keysym keysym; \
|
||||
keysym.scancode = sc; \
|
||||
keysym.sym = s; \
|
||||
if ( ks == SDL_RELEASED ) { \
|
||||
if ( kp ) { \
|
||||
SDL_PrivateKeyboard(SDL_PRESSED, &keysym); \
|
||||
ks = SDL_PRESSED; \
|
||||
} \
|
||||
} else if ( ! kp ) { \
|
||||
SDL_PrivateKeyboard(SDL_RELEASED, &keysym); \
|
||||
ks = SDL_RELEASED; \
|
||||
} \
|
||||
} while (0) |
||||
|
||||
/* Keys */ |
||||
enum { |
||||
PRZ_KEY_F1, |
||||
PRZ_KEY_F2, |
||||
PRZ_KEY_F3, |
||||
PRZ_KEY_F4, |
||||
PRZ_KEY_F5, |
||||
PRZ_KEY_F6, |
||||
PRZ_KEY_SHIFT, |
||||
PRZ_KEY_OPTN, |
||||
PRZ_KEY_VARS, |
||||
PRZ_KEY_MENU, |
||||
PRZ_KEY_LEFT, |
||||
PRZ_KEY_UP, |
||||
PRZ_KEY_ALPHA, |
||||
PRZ_KEY_SQUARE, |
||||
PRZ_KEY_POWER, |
||||
PRZ_KEY_EXIT, |
||||
PRZ_KEY_DOWN, |
||||
PRZ_KEY_RIGHT, |
||||
PRZ_KEY_XOT, |
||||
PRZ_KEY_LOG, |
||||
PRZ_KEY_LN, |
||||
PRZ_KEY_SIN, |
||||
PRZ_KEY_COS, |
||||
PRZ_KEY_TAN, |
||||
PRZ_KEY_FRAC, |
||||
PRZ_KEY_FD, |
||||
PRZ_KEY_LEFTP, |
||||
PRZ_KEY_RIGHTP, |
||||
PRZ_KEY_COMMA, |
||||
PRZ_KEY_ARROW, |
||||
PRZ_KEY_7, |
||||
PRZ_KEY_8, |
||||
PRZ_KEY_9, |
||||
PRZ_KEY_DEL, |
||||
PRZ_KEY_4, |
||||
PRZ_KEY_5, |
||||
PRZ_KEY_6, |
||||
PRZ_KEY_MUL, |
||||
PRZ_KEY_DIV, |
||||
PRZ_KEY_1, |
||||
PRZ_KEY_2, |
||||
PRZ_KEY_3, |
||||
PRZ_KEY_ADD, |
||||
PRZ_KEY_SUB, |
||||
PRZ_KEY_0, |
||||
PRZ_KEY_DOT, |
||||
PRZ_KEY_EXP, |
||||
PRZ_KEY_NEG, |
||||
PRZ_KEY_EXE, |
||||
PRZ_KEY_ACON, |
||||
PRZ_NUMKEYS |
||||
}; |
||||
|
||||
/* Variables and functions exported by SDL_sysevents.c to other parts
|
||||
of the native video subsystem (SDL_sysvideo.c) |
||||
*/ |
||||
extern void PRZ_InitOSKeymap(_THIS); |
||||
extern void PRZ_PumpEvents(_THIS); |
||||
|
||||
/* end of SDL_tinspireevents_c.h ... */ |
@ -0,0 +1,133 @@
|
||||
#include "SDL_config.h" |
||||
#include "../SDL_sysvideo.h" |
||||
#include "SDL_prizmvideo.h" |
||||
#include "SDL_prizmfonts.h" |
||||
|
||||
nSDL_Font *nSDL_LoadFont(int font_index, Uint8 r, Uint8 g, Uint8 b) |
||||
{ |
||||
nSDL_Font *font; |
||||
int i, j, k; |
||||
|
||||
font = SDL_malloc(sizeof(*font)); |
||||
if ( font == NULL ) { |
||||
SDL_OutOfMemory(); |
||||
return(NULL); |
||||
} |
||||
|
||||
for ( i = 0; i < NSP_FONT_NUMCHARS; ++i ) { |
||||
int offset = 8 * i; |
||||
int max_width = 0; |
||||
Uint32 color; |
||||
SDL_Surface *tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, NSP_FONT_WIDTH, NSP_FONT_HEIGHT, |
||||
16, PRZ_RMASK16, PRZ_GMASK16, PRZ_BMASK16, 0); |
||||
if ( tmp == NULL ) { |
||||
SDL_OutOfMemory(); |
||||
return(NULL); |
||||
} |
||||
color = SDL_MapRGB(tmp->format, r, g, b); |
||||
SDL_FillRect(tmp, NULL, ! color); |
||||
SDL_SetColorKey(tmp, SDL_SRCCOLORKEY, ! color); |
||||
font->char_width[i] = NSP_FONT_WIDTH; |
||||
SDL_LockSurface(tmp); |
||||
for ( j = 0; j < NSP_FONT_HEIGHT; ++j ) |
||||
for ( k = 0; k < NSP_FONT_WIDTH; ++k ) { |
||||
if ( nsp_font_charmaps[font_index][offset + j] & (1 << (NSP_FONT_WIDTH - k - 1)) ) { /* "Pixel" set */ |
||||
if ( k > max_width ) { |
||||
font->char_width[i] = k + 1; |
||||
max_width = k; |
||||
} |
||||
nSDL_SetPixel(tmp, k, j, color); |
||||
} |
||||
} |
||||
SDL_UnlockSurface(tmp); |
||||
font->chars[i] = SDL_DisplayFormat(tmp); |
||||
SDL_FreeSurface(tmp); |
||||
font->hspacing = font->vspacing = 0; |
||||
font->monospaced = SDL_FALSE; |
||||
} |
||||
|
||||
return(font); |
||||
} |
||||
|
||||
void nSDL_SetFontSpacing(nSDL_Font *font, int hspacing, int vspacing) |
||||
{ |
||||
font->hspacing = hspacing; |
||||
font->vspacing = vspacing; |
||||
} |
||||
|
||||
void nSDL_EnableFontMonospaced(nSDL_Font *font, SDL_bool toggle) |
||||
{ |
||||
font->monospaced = toggle; |
||||
} |
||||
|
||||
void nSDL_FreeFont(nSDL_Font *font) |
||||
{ |
||||
int i; |
||||
if ( font == NULL ) |
||||
return; |
||||
for ( i = 0; i < NSP_FONT_NUMCHARS; ++i ) |
||||
SDL_FreeSurface(font->chars[i]); |
||||
SDL_free(font); |
||||
} |
||||
|
||||
int nSDL_DrawString(SDL_Surface *surface, nSDL_Font *font, |
||||
int x, int y, const char *format, ...) |
||||
{ |
||||
char buf[PRZ_BUF_SIZE]; |
||||
int length; |
||||
SDL_Rect pos; |
||||
va_list args; |
||||
int i; |
||||
|
||||
va_start(args, format); |
||||
if ( vsprintf(buf, format, args) < 0 ) |
||||
return(-1); |
||||
va_end(args); |
||||
length = (int)strlen(buf); |
||||
pos.x = x; |
||||
pos.y = y; |
||||
PRZ_DEBUG("\"%s\" at (%d, %d)", buf, pos.x, pos.y); |
||||
|
||||
for ( i = 0; i < length; ++i ) { |
||||
int c = buf[i]; |
||||
if ( c == '\n' ) { |
||||
pos.x = x; |
||||
pos.y += NSP_FONT_HEIGHT + font->vspacing; |
||||
} else { |
||||
SDL_Rect rect; |
||||
rect.x = rect.y = 0; |
||||
rect.w = font->char_width[c]; |
||||
rect.h = NSP_FONT_HEIGHT; |
||||
if ( SDL_BlitSurface(font->chars[c], &rect, surface, &pos) == -1 ) |
||||
return(-1); |
||||
pos.x += NSP_CHAR_WIDTH(font, c) + font->hspacing; |
||||
} |
||||
} |
||||
|
||||
return(0); |
||||
} |
||||
|
||||
int nSDL_GetStringWidth(nSDL_Font *font, const char *s) |
||||
{ |
||||
int width = 0; |
||||
int max_width = 0; |
||||
do { |
||||
if ( *s == '\n' || *s == '\0' ) { |
||||
if ( width > max_width ) |
||||
max_width = width; |
||||
width = 0; |
||||
} else |
||||
width += NSP_CHAR_WIDTH(font, *s) + font->hspacing; |
||||
} while ( *s++ ); |
||||
return(max_width - font->hspacing); |
||||
} |
||||
|
||||
int nSDL_GetStringHeight(nSDL_Font *font, const char *s) |
||||
{ |
||||
int height = 0; |
||||
do { |
||||
if ( *s == '\n' || *s == '\0' ) |
||||
height += NSP_FONT_HEIGHT + font->vspacing; |
||||
} while ( *s++ ); |
||||
return(height - font->vspacing); |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,38 @@
|
||||
#include "SDL_video.h" |
||||
#include "SDL_prizmvideo.h" |
||||
#include "SDL_prizmnti.h" |
||||
|
||||
static void nti_get_info(nti_info_t *nti_info, Uint16 *data) |
||||
{ |
||||
nti_info->magic = data[0] >> 8; |
||||
nti_info->version = data[0] & 0x00ff; |
||||
nti_info->width = data[1]; |
||||
nti_info->height = data[2]; |
||||
nti_info->reserved = data[3]; |
||||
} |
||||
|
||||
SDL_Surface *nSDL_LoadImage(Uint16 *data) |
||||
{ |
||||
SDL_Surface *image; |
||||
nti_info_t nti_info; |
||||
int i, j; |
||||
nti_get_info(&nti_info, data); |
||||
if ( nti_info.magic != 42 ) { |
||||
SDL_SetError("[PRZ] Invalid NTI image"); |
||||
return(NULL); |
||||
} |
||||
PRZ_DEBUG("Loading NTI v%d (%dx%d)", nti_info.version, nti_info.width, nti_info.height); |
||||
image = SDL_CreateRGBSurface(SDL_SWSURFACE, nti_info.width, nti_info.height, |
||||
16, PRZ_RMASK16, PRZ_GMASK16, PRZ_BMASK16, 0); |
||||
if ( image == NULL ) { |
||||
SDL_OutOfMemory(); |
||||
return(NULL); |
||||
} |
||||
data = (Uint16 *)(data + 4); |
||||
SDL_LockSurface(image); |
||||
for ( i = 0; i < nti_info.height; ++i ) |
||||
for( j = 0; j < nti_info.width; ++j) |
||||
nSDL_SetPixel(image, j, i, data[j + (nti_info.width * i)]); |
||||
SDL_UnlockSurface(image); |
||||
return(image); |
||||
} |
@ -0,0 +1,15 @@
|
||||
#ifndef _SDL_tinspirenti_h |
||||
#define _SDL_tinspirenti_h |
||||
|
||||
#include "SDL_stdinc.h" |
||||
|
||||
/* NTI specification: https://github.com/Hoffa/nSDL/wiki/NTI-specification */ |
||||
|
||||
typedef struct nti_info_t { |
||||
Uint8 magic; |
||||
Uint8 version; |
||||
Uint16 width, height; |
||||
Uint16 reserved; |
||||
} nti_info_t; |
||||
|
||||
#endif /* _SDL_tinspirenti_h */ |
@ -0,0 +1,17 @@
|
||||
#include <gint/gint.h> |
||||
#include "SDL_video.h" |
||||
#include "SDL_prizmvideo.h" |
||||
|
||||
int nSDL_EnableRelativePaths(char **argv) |
||||
{ |
||||
/*
|
||||
char buf[NSP_BUF_SIZE], *p; |
||||
strcpy(buf, argv[0]); |
||||
p = strrchr(buf, '/'); |
||||
if ( ! p ) |
||||
return(-1); |
||||
*p = '\0'; |
||||
return(NU_Set_Current_Dir(buf) ? -1 : 0); |
||||
*/ |
||||
return(0); |
||||
} |
@ -0,0 +1,257 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer |
||||
Copyright (C) 1997-2012 Sam Lantinga |
||||
|
||||
This library is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU Lesser General Public |
||||
License as published by the Free Software Foundation; either |
||||
version 2.1 of the License, or (at your option) any later version. |
||||
|
||||
This library is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
Lesser General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU Lesser General Public |
||||
License along with this library; if not, write to the Free Software |
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
||||
|
||||
Sam Lantinga |
||||
slouken@libsdl.org |
||||
*/ |
||||
|
||||
#include "SDL.h" |
||||
#include "SDL_config.h" |
||||
#include "SDL_mouse.h" |
||||
#include "../SDL_sysvideo.h" |
||||
#include "../SDL_pixels_c.h" |
||||
#include "../../events/SDL_events_c.h" |
||||
|
||||
#include "SDL_prizmvideo.h" |
||||
#include "SDL_prizmevents_c.h" |
||||
#include <gint/gint.h> |
||||
#include <gint/display.h> |
||||
|
||||
|
||||
//#include "SDL_tinspireevents_c.h"
|
||||
|
||||
static Uint16 prz_palette[256] = {0}; |
||||
|
||||
/* Initialization/Query functions */ |
||||
static int PRZ_VideoInit(_THIS, SDL_PixelFormat *vformat); |
||||
static SDL_Rect **PRZ_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); |
||||
static SDL_Surface *PRZ_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); |
||||
static int PRZ_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); |
||||
static void PRZ_VideoQuit(_THIS); |
||||
|
||||
/* etc. */ |
||||
static void PRZ_UpdateRects(_THIS, int numrects, SDL_Rect *rects); |
||||
|
||||
/* NSP driver bootstrap functions */ |
||||
static int PRZ_Available(void) |
||||
{ |
||||
return(1); |
||||
} |
||||
|
||||
static void PRZ_DeleteDevice(SDL_VideoDevice *device) |
||||
{ |
||||
SDL_free(device->hidden); |
||||
SDL_free(device); |
||||
} |
||||
|
||||
static SDL_VideoDevice *PRZ_CreateDevice(int devindex) |
||||
{ |
||||
SDL_VideoDevice *device; |
||||
|
||||
/* Initialize all variables that we clean on shutdown */ |
||||
device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); |
||||
if ( device ) { |
||||
SDL_memset(device, 0, (sizeof *device)); |
||||
device->hidden = (struct SDL_PrivateVideoData *) |
||||
SDL_malloc((sizeof *device->hidden)); |
||||
} |
||||
if ( (device == NULL) || (device->hidden == NULL) ) { |
||||
SDL_OutOfMemory(); |
||||
if ( device ) { |
||||
SDL_free(device); |
||||
} |
||||
return(0); |
||||
} |
||||
SDL_memset(device->hidden, 0, (sizeof *device->hidden)); |
||||
|
||||
/* Set the function pointers */ |
||||
device->VideoInit = PRZ_VideoInit; |
||||
device->ListModes = PRZ_ListModes; |
||||
device->SetVideoMode = PRZ_SetVideoMode; |
||||
device->SetColors = PRZ_SetColors; |
||||
device->UpdateRects = PRZ_UpdateRects; |
||||
device->VideoQuit = PRZ_VideoQuit; |
||||
device->InitOSKeymap = PRZ_InitOSKeymap; |
||||
device->PumpEvents = PRZ_PumpEvents; |
||||
|
||||
device->free = PRZ_DeleteDevice; |
||||
|
||||
return device; |
||||
} |
||||
|
||||
VideoBootStrap PRZ_bootstrap = { |
||||
"prizm", "SDL Casio PRIZM video driver", |
||||
PRZ_Available, PRZ_CreateDevice |
||||
}; |
||||
|
||||
static int PRZ_VideoInit(_THIS, SDL_PixelFormat *vformat) |
||||
{ |
||||
this->hidden->cx = (int) true; |
||||
this->info.current_w = DWIDTH; |
||||
this->info.current_h = DHEIGHT; |
||||
|
||||
if ( this->hidden->cx ) { |
||||
vformat->BitsPerPixel = 16; |
||||
vformat->Rmask = PRZ_RMASK16; |
||||
vformat->Gmask = PRZ_GMASK16; |
||||
vformat->Bmask = PRZ_BMASK16; |
||||
} |
||||
|
||||
return(0); |
||||
} |
||||
|
||||
static SDL_Rect **PRZ_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) |
||||
{ |
||||
return (SDL_Rect **) -1; |
||||
} |
||||
|
||||
static SDL_Surface *PRZ_SetVideoMode(_THIS, SDL_Surface *current, |
||||
int width, int height, int bpp, Uint32 flags) |
||||
{ |
||||
Uint32 rmask, gmask, bmask; |
||||
|
||||
//NSP_DEBUG("Initializing display (%dx%dx%d)", width, height, bpp);
|
||||
|
||||
//if ( flags != SDL_SWSURFACE )
|
||||
// NSP_WARNING("Initializing with non-typical flags");
|
||||
|
||||
if ( width < DWIDTH || height < DHEIGHT ) { |
||||
int win_x = (DWIDTH - width) / 2; |
||||
int win_y = (DHEIGHT - height) / 2; |
||||
this->hidden->offset = (int)PRZ_PIXEL_ADDR(0, win_x, win_y, 2 * DWIDTH, 2) |