writing PRIZM video driver
This commit is contained in:
parent
127f666333
commit
57a084f989
|
@ -9,35 +9,68 @@ CC = sh-elf-gcc
|
|||
CONFIG_H = include/SDL_config.h
|
||||
TARGET = libSDL_prizm.a
|
||||
SOURCES = \
|
||||
src/*.c \
|
||||
src/audio/*.c \
|
||||
src/cdrom/*.c \
|
||||
src/cpuinfo/*.c \
|
||||
src/events/*.c \
|
||||
src/file/*.c \
|
||||
src/joystick/*.c \
|
||||
src/stdlib/*.c \
|
||||
src/thread/*.c \
|
||||
src/timer/*.c \
|
||||
src/video/*.c \
|
||||
src/audio/dummy/*.c \
|
||||
src/video/dummy/*.c \
|
||||
src/joystick/dummy/*.c \
|
||||
src/cdrom/dummy/*.c \
|
||||
src/thread/generic/*.c \
|
||||
src/timer/dummy/*.c \
|
||||
src/loadso/dummy/*.c \
|
||||
src/SDL.c \
|
||||
src/SDL_error.c \
|
||||
src/SDL_fatal.c \
|
||||
src/audio/SDL_audio.c \
|
||||
src/audio/SDL_audiocvt.c \
|
||||
src/cpuinfo/SDL_cpuinfo.c \
|
||||
src/events/SDL_active.c \
|
||||
src/events/SDL_events.c \
|
||||
src/events/SDL_expose.c \
|
||||
src/events/SDL_keyboard.c \
|
||||
src/events/SDL_mouse.c \
|
||||
src/events/SDL_quit.c \
|
||||
src/events/SDL_resize.c \
|
||||
src/file/SDL_rwops.c \
|
||||
src/joystick/SDL_joystick.c \
|
||||
src/stdlib/SDL_getenv.c \
|
||||
src/stdlib/SDL_iconv.c \
|
||||
src/stdlib/SDL_malloc.c \
|
||||
src/stdlib/SDL_qsort.c \
|
||||
src/stdlib/SDL_stdlib.c \
|
||||
src/stdlib/SDL_string.c \
|
||||
src/thread/SDL_thread.c \
|
||||
src/thread/generic/SDL_syscond.c \
|
||||
src/thread/generic/SDL_sysmutex.c \
|
||||
src/thread/generic/SDL_syssem.c \
|
||||
src/thread/generic/SDL_systhread.c \
|
||||
src/timer/SDL_timer.c \
|
||||
src/timer/prizm/SDL_systimer.c \
|
||||
src/video/SDL_blit.c \
|
||||
src/video/SDL_blit_0.c \
|
||||
src/video/SDL_blit_1.c \
|
||||
src/video/SDL_blit_A.c \
|
||||
src/video/SDL_blit_N.c \
|
||||
src/video/SDL_bmp.c \
|
||||
src/video/SDL_cursor.c \
|
||||
src/video/SDL_gamma.c \
|
||||
src/video/SDL_pixels.c \
|
||||
src/video/SDL_RLEaccel.c \
|
||||
src/video/SDL_stretch.c \
|
||||
src/video/SDL_surface.c \
|
||||
src/video/SDL_video.c \
|
||||
src/video/SDL_yuv.c \
|
||||
src/video/SDL_yuv_mmx.c \
|
||||
src/video/SDL_yuv_sw.c \
|
||||
src/video/prizm/SDL_prizmevents.c \
|
||||
src/video/prizm/SDL_prizmfonts.c \
|
||||
src/video/prizm/SDL_prizmnti.c \
|
||||
src/video/prizm/SDL_prizmutils.c \
|
||||
src/video/prizm/SDL_prizmvideo.c
|
||||
|
||||
OBJECTS = $(shell echo $(SOURCES) | sed -e 's,\.c,\.o,g')
|
||||
OBJECTS = $(SOURCES:.c=.o)
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(CONFIG_H) $(OBJECTS)
|
||||
$(AR) crv $@ $^
|
||||
$(TARGET): $(OBJECTS)
|
||||
#cp $(CONFIG_H).default $(CONFIG_H)
|
||||
$(AR) cr $@ $^
|
||||
$(RANLIB) $@
|
||||
#$(STRIP) --strip-unneeded $@
|
||||
|
||||
$(CONFIG_H):
|
||||
cp $(CONFIG_H).default $(CONFIG_H)
|
||||
.c.o:
|
||||
$(CC) $(INCLUDE) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET) $(OBJECTS)
|
||||
rm -f $(OBJECTS) $(TARGET)
|
||||
|
|
|
@ -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 :
|
||||
|
|
@ -15,6 +15,8 @@
|
|||
</Build>
|
||||
<Unit filename="Makefile.prizm" />
|
||||
<Unit filename="README.md" />
|
||||
<Unit filename="TODO.txt" />
|
||||
<Unit filename="cSDL1_2_15.layout" />
|
||||
<Unit filename="include/SDL.h" />
|
||||
<Unit filename="include/SDL_active.h" />
|
||||
<Unit filename="include/SDL_audio.h" />
|
||||
|
@ -193,6 +195,9 @@
|
|||
<Unit filename="src/timer/dummy/SDL_systimer.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/timer/prizm/SDL_systimer.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/SDL_RLEaccel.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
|
@ -270,6 +275,25 @@
|
|||
<Unit filename="src/video/e_sqrt.h" />
|
||||
<Unit filename="src/video/math_private.h" />
|
||||
<Unit filename="src/video/mmx.h" />
|
||||
<Unit filename="src/video/prizm/SDL_prizmevents.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/prizm/SDL_prizmevents_c.h" />
|
||||
<Unit filename="src/video/prizm/SDL_prizmfonts.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/prizm/SDL_prizmfonts.h" />
|
||||
<Unit filename="src/video/prizm/SDL_prizmnti.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/prizm/SDL_prizmnti.h" />
|
||||
<Unit filename="src/video/prizm/SDL_prizmutils.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/prizm/SDL_prizmvideo.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/prizm/SDL_prizmvideo.h" />
|
||||
<Extensions>
|
||||
<lib_finder disable_auto="1" />
|
||||
</Extensions>
|
||||
|
|
|
@ -2,19 +2,77 @@
|
|||
<CodeBlocks_layout_file>
|
||||
<FileVersion major="1" minor="0" />
|
||||
<ActiveTarget name="Release" />
|
||||
<File name="include/SDL_config.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="src/video/prizm/SDL_prizmevents.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1755" topLine="40" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/prizm/SDL_prizmvideo.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="0" topLine="11" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/prizm/SDL_prizmfonts.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="159" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/prizm/SDL_prizmutils.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="307" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="Makefile.prizm" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1727" topLine="47" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/prizm/SDL_prizmvideo.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="0" topLine="72" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="include/SDL_config_prizm.h" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="2746" topLine="12" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/SDL_sysvideo.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="12039" topLine="392" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="include/SDL_config.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1297" topLine="15" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="Makefile.prizm" open="1" top="1" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="src/video/prizm/SDL_prizmnti.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="69" topLine="0" />
|
||||
<Cursor1 position="762" topLine="3" />
|
||||
</Cursor>
|
||||
<Folding>
|
||||
<Collapse line="5" />
|
||||
</Folding>
|
||||
</File>
|
||||
<File name="src/video/prizm/SDL_prizmfonts.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="567" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="include/SDL_config_prizm.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="src/video/prizm/SDL_prizmevents_c.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1675" topLine="48" />
|
||||
<Cursor1 position="2002" topLine="69" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/SDL_blit.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1552" topLine="468" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="include/SDL_video.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="8312" topLine="258" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
|
|
|
@ -23,8 +23,12 @@
|
|||
#ifndef _SDL_config_h
|
||||
#define _SDL_config_h
|
||||
|
||||
#define FXCG50 1
|
||||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
|
||||
|
||||
/* Add any platform that doesn't build using the configure system */
|
||||
#if defined(__DREAMCAST__)
|
||||
#include "SDL_config_dreamcast.h"
|
||||
|
@ -44,8 +48,7 @@
|
|||
#include "SDL_config_prizm.h"
|
||||
|
||||
#else
|
||||
//#include "SDL_config_minimal.h"
|
||||
#include "SDL_config_prizm.h"
|
||||
#include "SDL_config_minimal.h"
|
||||
#endif /* platform config */
|
||||
|
||||
#endif /* _SDL_config_h */
|
||||
|
|
|
@ -29,6 +29,23 @@
|
|||
|
||||
#include <gint/gint.h>
|
||||
|
||||
|
||||
#define PRZ_DEBUG_BUILD 1
|
||||
//#define DEBUG_BUILD 1
|
||||
//#define DEBUG_VIDEO 1
|
||||
//#define DEBUG_ERROR 1
|
||||
|
||||
|
||||
#define PRZ_WARNING(s) fprintf(stderr, "[nSDL] Warning: %s\n", s)
|
||||
|
||||
#if PRZ_DEBUG_BUILD
|
||||
#define PRZ_DEBUG(fmt, args...) \
|
||||
fprintf(stderr, "[nSDL] %s(): " fmt "\n", __FUNCTION__, ## args)
|
||||
#else
|
||||
#define PRZ_DEBUG(fmt, args...) (void)0
|
||||
#endif
|
||||
|
||||
|
||||
#define SDL_HAS_64BIT_TYPE 1
|
||||
|
||||
/* Endianness */
|
||||
|
@ -80,4 +97,24 @@
|
|||
#define SDL_TIMER_DUMMY 1
|
||||
|
||||
|
||||
/* Enable various timer systems */
|
||||
#define SDL_TIMER_PRIZM 1
|
||||
|
||||
/* Enable various video drivers */
|
||||
#define SDL_VIDEO_DRIVER_PRIZM 1
|
||||
|
||||
/* Enable assembly routines */
|
||||
#define SDL_ASSEMBLY_ROUTINES 1
|
||||
|
||||
/* Fonts; needs to match nsp_font_charmaps in SDL_tinspirefonts.c */
|
||||
enum {
|
||||
NSDL_FONT_THIN = 0,
|
||||
NSDL_FONT_SPACE,
|
||||
NSDL_FONT_VGA,
|
||||
NSDL_FONT_FANTASY,
|
||||
NSDL_FONT_TINYTYPE,
|
||||
NSP_NUMFONTS
|
||||
};
|
||||
|
||||
|
||||
#endif /* _SDL_config_prizm_h */
|
||||
|
|
|
@ -253,6 +253,62 @@ typedef enum {
|
|||
#define SDL_PHYSPAL 0x02
|
||||
/*@}*/
|
||||
|
||||
/* Public Casio PRIZM-specific stuff */
|
||||
#ifdef __CASIOPRIZM__
|
||||
|
||||
#define PRZ_FONT_NUMCHARS 256
|
||||
#define PRZ_FONT_WIDTH 8
|
||||
#define PRZ_FONT_HEIGHT 8
|
||||
|
||||
typedef struct nSDL_Font {
|
||||
SDL_Surface *chars[PRZ_FONT_NUMCHARS];
|
||||
Uint8 char_width[PRZ_FONT_NUMCHARS];
|
||||
int hspacing, vspacing;
|
||||
SDL_bool monospaced;
|
||||
} nSDL_Font;
|
||||
|
||||
nSDL_Font *nSDL_LoadFont(int font_index, Uint8 r, Uint8 g, Uint8 b);
|
||||
void nSDL_SetFontSpacing(nSDL_Font *font, int hspacing, int vspacing);
|
||||
void nSDL_EnableFontMonospaced(nSDL_Font *font, SDL_bool toggle);
|
||||
void nSDL_FreeFont(nSDL_Font *font);
|
||||
int nSDL_DrawString(SDL_Surface *surface, nSDL_Font *font,
|
||||
int x, int y, const char *format, ...);
|
||||
int nSDL_GetStringWidth(nSDL_Font *font, const char *s);
|
||||
int nSDL_GetStringHeight(nSDL_Font *font, const char *s);
|
||||
SDL_Surface *nSDL_LoadImage(Uint16 *data);
|
||||
int nSDL_EnableRelativePaths(char **argv);
|
||||
|
||||
#define PRZ_PIXEL_ADDR(origin, x, y, pitch, bpp) ((Uint8 *)origin + ((x) * (bpp)) + ((y) * (pitch)))
|
||||
|
||||
#define PXL(bpp) PRZ_PIXEL_ADDR(surface->pixels, x, y, surface->pitch, bpp)
|
||||
|
||||
static __inline__ __attribute__((always_inline))
|
||||
Uint32 nSDL_GetPixel(SDL_Surface *surface, int x, int y)
|
||||
{
|
||||
switch ( surface->format->BytesPerPixel ) {
|
||||
case 2: return(*(Uint16 *)PXL(2));
|
||||
case 1: return(*PXL(1));
|
||||
case 4: return(*(Uint32 *)PXL(4));
|
||||
case 3: SDL_Unsupported();
|
||||
default: return(0);
|
||||
}
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline))
|
||||
void nSDL_SetPixel(SDL_Surface *surface, int x, int y, Uint32 color)
|
||||
{
|
||||
switch ( surface->format->BytesPerPixel ) {
|
||||
case 2: *(Uint16 *)PXL(2) = (Uint16)color; return;
|
||||
case 1: *PXL(1) = (Uint8)color; return;
|
||||
case 4: *(Uint32 *)PXL(4) = (Uint32)color; return;
|
||||
case 3: SDL_Unsupported();
|
||||
default: return;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
|
@ -314,11 +370,11 @@ extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width, int height, int bpp, Uint
|
|||
|
||||
/**
|
||||
* Return a pointer to an array of available screen dimensions for the
|
||||
* given format and video flags, sorted largest to smallest. Returns
|
||||
* NULL if there are no dimensions available for a particular format,
|
||||
* given format and video flags, sorted largest to smallest. Returns
|
||||
* NULL if there are no dimensions available for a particular format,
|
||||
* or (SDL_Rect **)-1 if any dimension is okay for the given format.
|
||||
*
|
||||
* If 'format' is NULL, the mode list will be for the format given
|
||||
* If 'format' is NULL, the mode list will be for the format given
|
||||
* by SDL_GetVideoInfo()->vfmt
|
||||
*/
|
||||
extern DECLSPEC SDL_Rect ** SDLCALL SDL_ListModes(SDL_PixelFormat *format, Uint32 flags);
|
||||
|
@ -347,21 +403,21 @@ extern DECLSPEC SDL_Rect ** SDLCALL SDL_ListModes(SDL_PixelFormat *format, Uint3
|
|||
* Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all
|
||||
* of the colors exactly the way they are requested, and you should look
|
||||
* at the video surface structure to determine the actual palette.
|
||||
* If SDL cannot guarantee that the colors you request can be set,
|
||||
* If SDL cannot guarantee that the colors you request can be set,
|
||||
* i.e. if the colormap is shared, then the video surface may be created
|
||||
* under emulation in system memory, overriding the SDL_HWSURFACE flag.
|
||||
*
|
||||
* If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set
|
||||
* a fullscreen video mode. The default is to create a windowed mode
|
||||
* if the current graphics system has a window manager.
|
||||
* If the SDL library is able to set a fullscreen video mode, this flag
|
||||
* If the SDL library is able to set a fullscreen video mode, this flag
|
||||
* will be set in the surface that is returned.
|
||||
*
|
||||
* If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up
|
||||
* two surfaces in video memory and swap between them when you call
|
||||
* two surfaces in video memory and swap between them when you call
|
||||
* SDL_Flip(). This is usually slower than the normal single-buffering
|
||||
* scheme, but prevents "tearing" artifacts caused by modifying video
|
||||
* memory while the monitor is refreshing. It should only be used by
|
||||
* scheme, but prevents "tearing" artifacts caused by modifying video
|
||||
* memory while the monitor is refreshing. It should only be used by
|
||||
* applications that redraw the entire screen on every update.
|
||||
*
|
||||
* If SDL_RESIZABLE is set in 'flags', the SDL library will allow the
|
||||
|
@ -416,7 +472,7 @@ extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface *screen);
|
|||
/**
|
||||
* Set the gamma correction for each of the color channels.
|
||||
* The gamma values range (approximately) between 0.1 and 10.0
|
||||
*
|
||||
*
|
||||
* If this function isn't supported directly by the hardware, it will
|
||||
* be emulated using gamma ramps, if available. If successful, this
|
||||
* function returns 0, otherwise it returns -1.
|
||||
|
@ -429,7 +485,7 @@ extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue);
|
|||
* representing a mapping between the input and output for that channel.
|
||||
* The input is the index into the array, and the output is the 16-bit
|
||||
* gamma value at that index, scaled to the output color precision.
|
||||
*
|
||||
*
|
||||
* You may pass NULL for any of the channels to leave it unchanged.
|
||||
* If the call succeeds, it will return 0. If the display driver or
|
||||
* hardware does not support gamma translation, or otherwise fails,
|
||||
|
@ -439,7 +495,7 @@ extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 *red, const Uint16 *gr
|
|||
|
||||
/**
|
||||
* Retrieve the current values of the gamma translation tables.
|
||||
*
|
||||
*
|
||||
* You must pass in valid pointers to arrays of 256 16-bit quantities.
|
||||
* Any of the pointers may be NULL to ignore that channel.
|
||||
* If the call succeeds, it will return 0. If the display driver or
|
||||
|
@ -457,13 +513,13 @@ extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16
|
|||
* determine the actual color palette.
|
||||
*
|
||||
* When 'surface' is the surface associated with the current display, the
|
||||
* display colormap will be updated with the requested colors. If
|
||||
* display colormap will be updated with the requested colors. If
|
||||
* SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors()
|
||||
* will always return 1, and the palette is guaranteed to be set the way
|
||||
* you desire, even if the window colormap has to be warped or run under
|
||||
* emulation.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface *surface,
|
||||
extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface *surface,
|
||||
SDL_Color *colors, int firstcolor, int ncolors);
|
||||
|
||||
/**
|
||||
|
@ -537,7 +593,7 @@ extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
|
|||
* two surfaces in video memory, SDL will try to place the surface in
|
||||
* video memory. If this isn't possible or if there is no hardware
|
||||
* acceleration available, the surface will be placed in system memory.
|
||||
* SDL_SRCALPHA means that the surface will be used for alpha blits and
|
||||
* SDL_SRCALPHA means that the surface will be used for alpha blits and
|
||||
* if the hardware supports hardware acceleration of alpha blits between
|
||||
* two surfaces in video memory, to place the surface in video memory
|
||||
* if possible, otherwise it will be placed in system memory.
|
||||
|
@ -551,7 +607,7 @@ extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
|
|||
* the SDL_HWSURFACE flag set, and will be created in system memory instead.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurface
|
||||
(Uint32 flags, int width, int height, int depth,
|
||||
(Uint32 flags, int width, int height, int depth,
|
||||
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
|
||||
/** @sa SDL_CreateRGBSurface */
|
||||
extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
|
||||
|
@ -562,8 +618,8 @@ extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface);
|
|||
/**
|
||||
* SDL_LockSurface() sets up a surface for directly accessing the pixels.
|
||||
* Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write
|
||||
* to and read from 'surface->pixels', using the pixel format stored in
|
||||
* 'surface->format'. Once you are done accessing the surface, you should
|
||||
* to and read from 'surface->pixels', using the pixel format stored in
|
||||
* 'surface->format'. Once you are done accessing the surface, you should
|
||||
* use SDL_UnlockSurface() to release it.
|
||||
*
|
||||
* Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates
|
||||
|
@ -571,7 +627,7 @@ extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface);
|
|||
* pixel format of the surface will not change. In particular, if the
|
||||
* SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you
|
||||
* will not need to lock the display surface before accessing it.
|
||||
*
|
||||
*
|
||||
* No operating system or library calls should be made between lock/unlock
|
||||
* pairs, as critical system locks may be held during this time.
|
||||
*
|
||||
|
@ -605,7 +661,7 @@ extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
|
|||
|
||||
/**
|
||||
* Sets the color key (transparent pixel) in a blittable surface.
|
||||
* If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL),
|
||||
* If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL),
|
||||
* 'key' will be the transparent pixel in the source image of a blit.
|
||||
* SDL_RLEACCEL requests RLE acceleration for the surface if present,
|
||||
* and removes RLE acceleration if absent.
|
||||
|
@ -654,11 +710,11 @@ extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface *surface, const SDL
|
|||
extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect);
|
||||
|
||||
/**
|
||||
* Creates a new surface of the specified format, and then copies and maps
|
||||
* the given surface to it so the blit of the converted surface will be as
|
||||
* Creates a new surface of the specified format, and then copies and maps
|
||||
* the given surface to it so the blit of the converted surface will be as
|
||||
* fast as possible. If this function fails, it returns NULL.
|
||||
*
|
||||
* The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those
|
||||
* The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those
|
||||
* semantics. You can also pass SDL_RLEACCEL in the flags parameter and
|
||||
* SDL will try to RLE accelerate colorkey and alpha blits in the resulting
|
||||
* surface.
|
||||
|
@ -690,7 +746,7 @@ extern DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface
|
|||
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
||||
* RGB values of the source colour key, ignoring alpha in the
|
||||
* comparison.
|
||||
*
|
||||
*
|
||||
* RGB->RGBA:
|
||||
* SDL_SRCALPHA set:
|
||||
* alpha-blend (using the source per-surface alpha value);
|
||||
|
@ -700,7 +756,7 @@ extern DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface
|
|||
* both:
|
||||
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
||||
* source colour key.
|
||||
*
|
||||
*
|
||||
* RGBA->RGBA:
|
||||
* SDL_SRCALPHA set:
|
||||
* alpha-blend (using the source alpha channel) the RGB values;
|
||||
|
@ -711,8 +767,8 @@ extern DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface
|
|||
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
||||
* RGB values of the source colour key, ignoring alpha in the
|
||||
* comparison.
|
||||
*
|
||||
* RGB->RGB:
|
||||
*
|
||||
* RGB->RGB:
|
||||
* SDL_SRCALPHA set:
|
||||
* alpha-blend (using the source per-surface alpha value).
|
||||
* SDL_SRCALPHA not set:
|
||||
|
@ -722,7 +778,7 @@ extern DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface
|
|||
* source colour key.
|
||||
*
|
||||
* If either of the surfaces were in video memory, and the blit returns -2,
|
||||
* the video memory was lost, so it should be reloaded with artwork and
|
||||
* the video memory was lost, so it should be reloaded with artwork and
|
||||
* re-blitted:
|
||||
* @code
|
||||
* while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) {
|
||||
|
@ -760,7 +816,7 @@ extern DECLSPEC int SDLCALL SDL_LowerBlit
|
|||
* The given rectangle is clipped to the destination surface clip area
|
||||
* and the final fill rectangle is saved in the passed in pointer.
|
||||
* If 'dstrect' is NULL, the whole surface will be filled with 'color'
|
||||
* The color should be a pixel of the format used by the surface, and
|
||||
* The color should be a pixel of the format used by the surface, and
|
||||
* can be generated by the SDL_MapRGB() function.
|
||||
* This function returns 0 on success, or -1 on error.
|
||||
*/
|
||||
|
@ -813,7 +869,7 @@ extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay *overlay);
|
|||
|
||||
/** Blit a video overlay to the display surface.
|
||||
* The contents of the video surface underneath the blit destination are
|
||||
* not defined.
|
||||
* not defined.
|
||||
* The width and height of the destination rectangle may be different from
|
||||
* that of the overlay, but currently only 2x scaling is supported.
|
||||
*/
|
||||
|
@ -908,7 +964,7 @@ extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void);
|
|||
* If the display surface does not require locking before accessing
|
||||
* the pixel information, then the memory pointers will not change.
|
||||
*
|
||||
* If this function was able to toggle fullscreen mode (change from
|
||||
* If this function was able to toggle fullscreen mode (change from
|
||||
* running in a window to fullscreen, or vice-versa), it will return 1.
|
||||
* If it is not implemented, or fails, it returns 0.
|
||||
*
|
||||
|
@ -941,7 +997,7 @@ extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode);
|
|||
/** @internal Not in public API at the moment - do not use! */
|
||||
extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect,
|
||||
SDL_Surface *dst, SDL_Rect *dstrect);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
BIN
libSDL_prizm.a
BIN
libSDL_prizm.a
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 */
|
|
@ -53,7 +53,7 @@ struct SDL_VideoDevice {
|
|||
/* * * */
|
||||
/* Initialization/Query functions */
|
||||
|
||||
/* Initialize the native video subsystem, filling 'vformat' with the
|
||||
/* Initialize the native video subsystem, filling 'vformat' with the
|
||||
"best" display pixel format, returning 0 or -1 if there's an error.
|
||||
*/
|
||||
int (*VideoInit)(_THIS, SDL_PixelFormat *vformat);
|
||||
|
@ -119,7 +119,7 @@ struct SDL_VideoDevice {
|
|||
|
||||
/* The pixel format used when SDL_CreateRGBSurface creates SDL_HWSURFACEs with alpha */
|
||||
SDL_PixelFormat* displayformatalphapixel;
|
||||
|
||||
|
||||
/* Allocates a surface in video memory */
|
||||
int (*AllocHWSurface)(_THIS, SDL_Surface *surface);
|
||||
|
||||
|
@ -195,7 +195,7 @@ struct SDL_VideoDevice {
|
|||
GLuint texture;
|
||||
#endif
|
||||
int is_32bit;
|
||||
|
||||
|
||||
/* * * */
|
||||
/* Window manager functions */
|
||||
|
||||
|
@ -410,6 +410,9 @@ extern VideoBootStrap AALIB_bootstrap;
|
|||
#if SDL_VIDEO_DRIVER_CACA
|
||||
extern VideoBootStrap CACA_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_PRIZME
|
||||
extern VideoBootStrap PRZ_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_DUMMY
|
||||
extern VideoBootStrap DUMMY_bootstrap;
|
||||
#endif
|
||||
|
|
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);
|
||||
this->hidden->win_x = win_x;
|
||||
} else
|
||||
this->hidden->offset = this->hidden->win_x = 0;
|
||||
|
||||
if ( bpp == 16 ) {
|
||||
rmask = PRZ_RMASK16;
|
||||
gmask = PRZ_GMASK16;
|
||||
bmask = PRZ_BMASK16;
|
||||
}
|
||||
|
||||
if ( this->hidden->buffer ) {
|
||||
SDL_free( this->hidden->buffer );
|
||||
}
|
||||
|
||||
|
||||
this->hidden->buffer2 = SDL_malloc((bpp / 8) * DWIDTH * DHEIGHT);
|
||||
if ( ! this->hidden->buffer2 ) {
|
||||
//SDL_SetError("Couldn't allocate buffer2 for requested mode");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
this->hidden->buffer = SDL_malloc((bpp / 8) * width * height);
|
||||
if ( ! this->hidden->buffer ) {
|
||||
SDL_free(this->hidden->buffer2);
|
||||
//SDL_SetError("Couldn't allocate buffer for requested mode");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
memset(this->hidden->buffer2, 0, (bpp / 8) * DWIDTH * DHEIGHT);
|
||||
memset(this->hidden->buffer, 0, (bpp / 8) * width * height);
|
||||
|
||||
/* Allocate the new pixel format for the screen */
|
||||
if ( ! SDL_ReallocFormat(current, bpp, rmask, gmask, bmask, 0) ) {
|
||||
SDL_free(this->hidden->buffer);
|
||||
this->hidden->buffer = NULL;
|
||||
//SDL_SetError("Couldn't allocate new pixel format for requested mode");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Set up the new mode framebuffer */
|
||||
current->flags = flags;
|
||||
this->hidden->w = this->info.current_w = current->w = width;
|
||||
this->hidden->h = this->info.current_h = current->h = height;
|
||||
current->pitch = (bpp / 8) * current->w;
|
||||
current->pixels = this->hidden->buffer;
|
||||
|
||||
//NSP_DEBUG("Done (0x%p)", current);
|
||||
|
||||
/* We're done */
|
||||
return(current);
|
||||
}
|
||||
|
||||
#define PRZ_DRAW_LOOP(code) do { \
|
||||
while ( rows-- ) { \
|
||||
j = 0, k = 0; \
|
||||
code \
|
||||
src_addr += src_skip; \
|
||||
dst_addr += dst_skip; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static void PRZ_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
|
||||
{
|
||||
int src_skip = SDL_VideoSurface->pitch;
|
||||
int dst_skip = (2 * DWIDTH);
|
||||
int i, j, k;
|
||||
|
||||
if ( this->hidden->buffer2 == NULL )
|
||||
return;
|
||||
|
||||
for ( i = 0; i < numrects; ++i ) {
|
||||
SDL_Rect *rect = &rects[i];
|
||||
Uint8 *src_addr, *dst_addr;
|
||||
SDL_bool odd_left, odd_right;
|
||||
int row_bytes, rows;
|
||||
|
||||
if ( ! rect )
|
||||
continue;
|
||||
|
||||
src_addr = PRZ_PIXEL_ADDR(SDL_VideoSurface->pixels, rect->x, rect->y,
|
||||
SDL_VideoSurface->pitch, SDL_VideoSurface->format->BytesPerPixel);
|
||||
dst_addr = PRZ_PIXEL_ADDR(this->hidden->buffer2, rect->x, rect->y, 2 * DWIDTH, 2);
|
||||
dst_addr += this->hidden->offset;
|
||||
|
||||
odd_left = (this->hidden->win_x + rect->x) & 1;
|
||||
odd_right = (this->hidden->win_x + rect->x + rect->w) & 1;
|
||||
row_bytes = SDL_VideoSurface->format->BytesPerPixel * ((rect->x + rect->w > DWIDTH) ? DWIDTH : rect->w);
|
||||
rows = (rect->y + rect->h > DHEIGHT) ? DHEIGHT : rect->h;
|
||||
|
||||
if ( ! this->hidden->cx && odd_right )
|
||||
--row_bytes;
|
||||
|
||||
if ( this->hidden->cx ) {
|
||||
if ( SDL_VideoSurface->format->BitsPerPixel == 16 ) {
|
||||
/* 16 bpp SW, 16 bpp HW */
|
||||
PRZ_DRAW_LOOP(
|
||||
SDL_memcpy(dst_addr, src_addr, row_bytes);
|
||||
);
|
||||
}
|
||||
dupdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define PRZ_MAP_RGB(r, g, b) ((((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)))
|
||||
|
||||
static int PRZ_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
|
||||
{
|
||||
int i;
|
||||
for ( i = firstcolor; i < firstcolor + ncolors; ++i )
|
||||
prz_palette[i] = PRZ_MAP_RGB(colors[i].r, colors[i].g, colors[i].b);
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* Note: If we are terminated, this could be called in the middle of
|
||||
another SDL video routine -- notably UpdateRects.
|
||||
*/
|
||||
static void PRZ_VideoQuit(_THIS)
|
||||
{
|
||||
//NSP_DEBUG("Closing video");
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
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 "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_prizmvideo_h
|
||||
#define _SDL_prizmvideo_h
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
/* Hidden "this" pointer for the video functions */
|
||||
#define _THIS SDL_VideoDevice *this
|
||||
|
||||
#define PRZ_BUF_SIZE 512
|
||||
|
||||
#define PRZ_RMASK16 0xF800
|
||||
#define PRZ_GMASK16 0x07E0
|
||||
#define PRZ_BMASK16 0x001F
|
||||
|
||||
/* Private display data */
|
||||
|
||||
struct SDL_PrivateVideoData {
|
||||
int w, h;
|
||||
int offset;
|
||||
int win_x;
|
||||
void *buffer;
|
||||
void *buffer2;
|
||||
int cx;
|
||||
};
|
||||
|
||||
#endif /* _SDL_tinspirevideo_h */
|
Loading…
Reference in New Issue