Final merge of Google Summer of Code 2008 work...
Port SDL 1.3 to the Nintendo DS by Darren Alton, mentored by Sam Lantinga --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403188
This commit is contained in:
parent
e6faee6b2a
commit
ede44c4b85
123 changed files with 6082 additions and 388 deletions
129
Makefile.ds
Normal file
129
Makefile.ds
Normal file
|
@ -0,0 +1,129 @@
|
|||
|
||||
#LibSDL 1.3 porting and enhancements by Darren Alton (lifning)
|
||||
#LibSDL 1.2.9 DS porting by Troy Davis(GPF)
|
||||
|
||||
ifeq ($(strip $(DEVKITPRO)),)
|
||||
$(error "Please set DEVKITPRO in your environment (available from http://www.devkitpro.org). export DEVKITPRO=<path to>devkitPro")
|
||||
endif
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
DEVKITARM = $(DEVKITPRO)/devkitARM
|
||||
endif
|
||||
PATH := $(PATH):$(DEVKITARM)/bin
|
||||
|
||||
CC = arm-eabi-gcc
|
||||
AR = arm-eabi-ar
|
||||
RANLIB = arm-eabi-ranlib
|
||||
|
||||
#ifdef GL
|
||||
#DEFS += -DSDL_VIDEO_OPENGL=1
|
||||
#TARGET = libSDL_gl.a
|
||||
#else
|
||||
TARGET = libSDL.a
|
||||
#endif
|
||||
|
||||
#CFLAGS=$(DEFS) -Iinclude
|
||||
CFLAGS = -mthumb -mthumb-interwork \
|
||||
-march=armv5te -mtune=arm946e-s \
|
||||
-O2 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
|
||||
-DARM9 -D__NDS__ -I$(DEVKITPRO)/libnds/include -DENABLE_NDS -DNO_SIGNAL_H -DDISABLE_THREADS -DPACKAGE=\"SDL\" -DVERSION=\"1.3\" -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1 \
|
||||
-Iinclude -Isrc -Isrc/audio -Isrc/cdrom -Isrc/endian -Isrc/events -Isrc/joystick -Isrc/thread/nds -Isrc/thread -Isrc/timer -Isrc/video
|
||||
|
||||
#src/audio/disk/SDL_diskaudio.c \
|
||||
#src/audio/dummy/SDL_dummyaudio.c \
|
||||
|
||||
SRCS = \
|
||||
src/SDL.c \
|
||||
src/SDL_compat.c \
|
||||
src/SDL_error.c \
|
||||
src/SDL_fatal.c \
|
||||
src/audio/nds/SDL_ndsaudio.c \
|
||||
src/audio/SDL_audio.c \
|
||||
src/audio/SDL_audiocvt.c \
|
||||
src/audio/SDL_audiodev.c \
|
||||
src/audio/SDL_audiotypecvt.c \
|
||||
src/audio/SDL_mixer.c \
|
||||
src/audio/SDL_mixer_m68k.c \
|
||||
src/audio/SDL_mixer_MMX.c \
|
||||
src/audio/SDL_mixer_MMX_VC.c \
|
||||
src/audio/SDL_wave.c \
|
||||
src/cdrom/dummy/SDL_syscdrom.c \
|
||||
src/cdrom/SDL_cdrom.c \
|
||||
src/cpuinfo/SDL_cpuinfo.c \
|
||||
src/events/SDL_events.c \
|
||||
src/events/SDL_keyboard.c \
|
||||
src/events/SDL_mouse.c \
|
||||
src/events/SDL_quit.c \
|
||||
src/events/SDL_windowevents.c \
|
||||
src/file/SDL_rwops.c \
|
||||
src/joystick/nds/SDL_sysjoystick.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/nds/SDL_syscond.c \
|
||||
src/thread/nds/SDL_sysmutex.c \
|
||||
src/thread/nds/SDL_syssem.c \
|
||||
src/thread/nds/SDL_systhread.c \
|
||||
src/timer/nds/SDL_systimer.c \
|
||||
src/timer/SDL_timer.c \
|
||||
src/video/nds/SDL_ndsevents.c \
|
||||
src/video/nds/SDL_ndsrender.c \
|
||||
src/video/nds/SDL_ndsvideo.c \
|
||||
src/video/dummy/SDL_nullevents.c \
|
||||
src/video/dummy/SDL_nullrender.c \
|
||||
src/video/dummy/SDL_nullvideo.c \
|
||||
src/video/SDL_blit_0.c \
|
||||
src/video/SDL_blit_1.c \
|
||||
src/video/SDL_blit_A.c \
|
||||
src/video/SDL_blit_auto.c \
|
||||
src/video/SDL_blit.c \
|
||||
src/video/SDL_blit_copy.c \
|
||||
src/video/SDL_blit_N.c \
|
||||
src/video/SDL_blit_slow.c \
|
||||
src/video/SDL_bmp.c \
|
||||
src/video/SDL_fill.c \
|
||||
src/video/SDL_gamma.c \
|
||||
src/video/SDL_pixels.c \
|
||||
src/video/SDL_rect.c \
|
||||
src/video/SDL_renderer_gl.c \
|
||||
src/video/SDL_renderer_sw.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_mmx.c \
|
||||
src/video/SDL_yuv_sw.c \
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
TEST = \
|
||||
test/nds-test-progs/general/general.nds \
|
||||
test/nds-test-progs/sprite/sprite.nds \
|
||||
test/nds-test-progs/sprite2/sprite2.nds \
|
||||
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): copy_config \
|
||||
$(OBJS)
|
||||
$(AR) rc $(TARGET) $(OBJS)
|
||||
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
|
||||
|
||||
install: $(TARGET)
|
||||
@cp libSDL.a $(DEVKITPRO)/libnds/lib/
|
||||
@mkdir -p $(DEVKITPRO)/libnds/include/SDL/
|
||||
@cp include/*.h $(DEVKITPRO)/libnds/include/SDL/
|
||||
|
||||
nds_test:
|
||||
$(MAKE) -C test/nds-test-progs
|
||||
|
||||
copy_config:
|
||||
@cp include/SDL_config.h.default include/SDL_config.h
|
||||
|
||||
clean:
|
||||
rm -f include/SDL_config.h $(OBJS)
|
||||
|
|
@ -26,7 +26,9 @@
|
|||
#include "SDL_platform.h"
|
||||
|
||||
/* Add any platform that doesn't build using the configure system */
|
||||
#if defined(__DREAMCAST__)
|
||||
#if defined(__NINTENDODS__)
|
||||
#include "SDL_config_nintendods.h"
|
||||
#elif defined(__DREAMCAST__)
|
||||
#include "SDL_config_dreamcast.h"
|
||||
#elif defined(__MACOSX__)
|
||||
#include "SDL_config_macosx.h"
|
||||
|
|
|
@ -177,6 +177,7 @@
|
|||
#undef SDL_AUDIO_DRIVER_MMEAUDIO
|
||||
#undef SDL_AUDIO_DRIVER_NAS
|
||||
#undef SDL_AUDIO_DRIVER_NAS_DYNAMIC
|
||||
#undef SDL_AUDIO_DRIVER_NDS
|
||||
#undef SDL_AUDIO_DRIVER_OSS
|
||||
#undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H
|
||||
#undef SDL_AUDIO_DRIVER_PAUDIO
|
||||
|
@ -211,6 +212,7 @@
|
|||
#undef SDL_JOYSTICK_IOKIT
|
||||
#undef SDL_JOYSTICK_LINUX
|
||||
#undef SDL_JOYSTICK_MINT
|
||||
#undef SDL_JOYSTICK_NDS
|
||||
#undef SDL_JOYSTICK_OS2
|
||||
#undef SDL_JOYSTICK_RISCOS
|
||||
#undef SDL_JOYSTICK_WINMM
|
||||
|
@ -233,6 +235,7 @@
|
|||
/* Enable various threading systems */
|
||||
#undef SDL_THREAD_BEOS
|
||||
#undef SDL_THREAD_DC
|
||||
#undef SDL_THREAD_NDS
|
||||
#undef SDL_THREAD_OS2
|
||||
#undef SDL_THREAD_PTH
|
||||
#undef SDL_THREAD_PTHREAD
|
||||
|
@ -246,6 +249,7 @@
|
|||
#undef SDL_TIMER_DC
|
||||
#undef SDL_TIMER_DUMMY
|
||||
#undef SDL_TIMER_MINT
|
||||
#undef SDL_TIMER_NDS
|
||||
#undef SDL_TIMER_OS2
|
||||
#undef SDL_TIMER_RISCOS
|
||||
#undef SDL_TIMER_UNIX
|
||||
|
@ -263,6 +267,7 @@
|
|||
#undef SDL_VIDEO_DRIVER_GEM
|
||||
#undef SDL_VIDEO_DRIVER_IPOD
|
||||
#undef SDL_VIDEO_DRIVER_NANOX
|
||||
#undef SDL_VIDEO_DRIVER_NDS
|
||||
#undef SDL_VIDEO_DRIVER_OS2FS
|
||||
#undef SDL_VIDEO_DRIVER_PHOTON
|
||||
#undef SDL_VIDEO_DRIVER_PS2GS
|
||||
|
|
119
include/SDL_config_nintendods.h
Normal file
119
include/SDL_config_nintendods.h
Normal file
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 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
|
||||
*/
|
||||
|
||||
#ifndef _SDL_config_nintendods_h
|
||||
#define _SDL_config_nintendods_h
|
||||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/* This is a set of defines to configure the SDL features */
|
||||
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef signed long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
|
||||
/* LiF: __PTRDIFF_TYPE__ was causing errors of conflicting typedefs with the
|
||||
<stdint.h> shipping with devkitARM. copied a similar ifdef from it. */
|
||||
#ifndef __PTRDIFF_TYPE__
|
||||
typedef unsigned long uintptr_t;
|
||||
#else
|
||||
typedef unsigned __PTRDIFF_TYPE__ uintptr_t;
|
||||
#endif
|
||||
|
||||
|
||||
#define SDL_HAS_64BIT_TYPE 1
|
||||
|
||||
/* Useful headers */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_STDIO_H 1
|
||||
#define STDC_HEADERS 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_CTYPE_H 1
|
||||
|
||||
/* C library functions */
|
||||
#define HAVE_MALLOC 1
|
||||
#define HAVE_CALLOC 1
|
||||
#define HAVE_REALLOC 1
|
||||
#define HAVE_FREE 1
|
||||
#define HAVE_ALLOCA 1
|
||||
#define HAVE_GETENV 1
|
||||
#define HAVE_PUTENV 1
|
||||
#define HAVE_QSORT 1
|
||||
#define HAVE_ABS 1
|
||||
#define HAVE_BCOPY 1
|
||||
#define HAVE_MEMSET 1
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MEMCMP 1
|
||||
#define HAVE_STRLEN 1
|
||||
#define HAVE_STRDUP 1
|
||||
#define HAVE_INDEX 1
|
||||
#define HAVE_RINDEX 1
|
||||
#define HAVE_STRCHR 1
|
||||
#define HAVE_STRRCHR 1
|
||||
#define HAVE_STRSTR 1
|
||||
#define HAVE_STRTOL 1
|
||||
#define HAVE_STRTOD 1
|
||||
#define HAVE_ATOI 1
|
||||
#define HAVE_ATOF 1
|
||||
#define HAVE_STRCMP 1
|
||||
#define HAVE_STRNCMP 1
|
||||
#define HAVE_STRICMP 1
|
||||
#define HAVE_STRCASECMP 1
|
||||
#define HAVE_SSCANF 1
|
||||
#define HAVE_SNPRINTF 1
|
||||
#define HAVE_VSNPRINTF 1
|
||||
|
||||
/* DS isn't that sophisticated */
|
||||
#define LACKS_SYS_MMAN_H 1
|
||||
|
||||
/* Enable various audio drivers */
|
||||
#define SDL_AUDIO_DRIVER_NDS 1
|
||||
/*#define SDL_AUDIO_DRIVER_DUMMY 1 TODO: uncomment this later*/
|
||||
|
||||
/* DS doesn't have optical media */
|
||||
#define SDL_CDROM_DISABLED 1
|
||||
|
||||
/* Enable various input drivers */
|
||||
#define SDL_JOYSTICK_NDS 1
|
||||
/*#define SDL_JOYSTICK_DUMMY 1 TODO: uncomment this later*/
|
||||
|
||||
/* DS has no dynamic linking afaik */
|
||||
#define SDL_LOADSO_DISABLED 1
|
||||
|
||||
/* Enable various threading systems */
|
||||
/*#define SDL_THREAD_NDS 1*/
|
||||
#define SDL_THREADS_DISABLED 1
|
||||
|
||||
/* Enable various timer systems */
|
||||
#define SDL_TIMER_NDS 1
|
||||
|
||||
/* Enable various video drivers */
|
||||
#define SDL_VIDEO_DRIVER_NDS 1
|
||||
/*#define SDL_VIDEO_DRIVER_DUMMY 1 TODO: uncomment this later*/
|
||||
|
||||
#endif /* _SDL_config_nintendods_h */
|
|
@ -146,12 +146,18 @@ enum
|
|||
SDL_PIXELFORMAT_RGB555 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_1555, 15, 2),
|
||||
SDL_PIXELFORMAT_BGR555 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
|
||||
SDL_PACKEDLAYOUT_1555, 15, 2),
|
||||
SDL_PIXELFORMAT_ARGB4444 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDLAYOUT_4444, 16, 2),
|
||||
SDL_PIXELFORMAT_ARGB1555 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDLAYOUT_1555, 16, 2),
|
||||
SDL_PIXELFORMAT_ABGR1555 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
|
||||
SDL_PACKEDLAYOUT_1555, 16, 2),
|
||||
SDL_PIXELFORMAT_RGB565 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_565, 16, 2),
|
||||
|
|
|
@ -97,4 +97,9 @@
|
|||
#define __WIN32__ 1
|
||||
#endif
|
||||
|
||||
#if defined(__NDS__)
|
||||
#undef __NINTENDODS__
|
||||
#define __NINTENDODS__ 1
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_platform_h */
|
||||
|
|
|
@ -147,8 +147,12 @@ SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
|
|||
SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
|
||||
SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
|
||||
SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
|
||||
#ifndef __NINTENDODS__ /* TODO: figure out why the following happens:
|
||||
include/SDL_stdinc.h:150: error: size of array 'SDL_dummy_uint64' is negative
|
||||
include/SDL_stdinc.h:151: error: size of array 'SDL_dummy_sint64' is negative */
|
||||
SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
|
||||
SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
|
||||
#endif
|
||||
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
|
||||
/* Check to make sure enums are the size of ints, for structure packing.
|
||||
|
@ -162,12 +166,14 @@ SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
|
|||
#endif
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
|
||||
#ifndef __NINTENDODS__ /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */
|
||||
typedef enum
|
||||
{
|
||||
DUMMY_ENUM_VALUE
|
||||
} SDL_DUMMY_ENUM;
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
|
||||
#endif
|
||||
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
|
||||
#include "begin_code.h"
|
||||
|
@ -425,6 +431,9 @@ extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string);
|
|||
#ifdef HAVE_WCSLEN
|
||||
#define SDL_wcslen wcslen
|
||||
#else
|
||||
#if !defined(wchar_t) && defined(__NINTENDODS__)
|
||||
#define wchar_t short /* TODO: figure out why libnds doesn't have this */
|
||||
#endif
|
||||
extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t * string);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -693,6 +693,7 @@ SDL_UpdateRect(SDL_Surface * screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h)
|
|||
SDL_UpdateRects(screen, 1, &rect);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_UpdateRects(SDL_Surface * screen, int numrects, SDL_Rect * rects)
|
||||
{
|
||||
|
|
|
@ -180,8 +180,8 @@ SDL_GetErrorMsg(char *errstr, unsigned int maxlen)
|
|||
case 's':
|
||||
len =
|
||||
SDL_snprintf(msg, maxlen, tmp,
|
||||
SDL_LookupString(error->
|
||||
args[argi++].buf));
|
||||
SDL_LookupString(error->args[argi++].
|
||||
buf));
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
break;
|
||||
|
|
|
@ -70,6 +70,7 @@ extern AudioBootStrap DUMMYAUD_bootstrap;
|
|||
extern AudioBootStrap DCAUD_bootstrap;
|
||||
extern AudioBootStrap MMEAUDIO_bootstrap;
|
||||
extern AudioBootStrap DART_bootstrap;
|
||||
extern AudioBootStrap NDSAUD_bootstrap;
|
||||
|
||||
|
||||
/* Available audio drivers */
|
||||
|
@ -144,6 +145,9 @@ static AudioBootStrap *bootstrap[] = {
|
|||
#endif
|
||||
#if SDL_AUDIO_DRIVER_DART
|
||||
&DART_bootstrap,
|
||||
#endif
|
||||
#if SDL_AUDIO_DRIVER_NDS
|
||||
&NDSAUD_bootstrap,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
@ -167,31 +171,38 @@ SDL_AudioDetectDevices_Default(int iscapture)
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_AudioThreadInit_Default(_THIS)
|
||||
{ /* no-op. */
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_AudioWaitDevice_Default(_THIS)
|
||||
{ /* no-op. */
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_AudioPlayDevice_Default(_THIS)
|
||||
{ /* no-op. */
|
||||
}
|
||||
|
||||
static Uint8 *
|
||||
SDL_AudioGetDeviceBuf_Default(_THIS)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_AudioWaitDone_Default(_THIS)
|
||||
{ /* no-op. */
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_AudioCloseDevice_Default(_THIS)
|
||||
{ /* no-op. */
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_AudioDeinitialize_Default(void)
|
||||
{ /* no-op. */
|
||||
|
|
|
@ -462,8 +462,7 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
|
|||
}
|
||||
/* 2 Uint32's for chunk header+len, plus the lenread */
|
||||
headerDiff += lenread + 2 * sizeof(Uint32);
|
||||
}
|
||||
while ((chunk.magic == FACT) || (chunk.magic == LIST));
|
||||
} while ((chunk.magic == FACT) || (chunk.magic == LIST));
|
||||
|
||||
/* Decode the audio data format */
|
||||
format = (WaveFMT *) chunk.data;
|
||||
|
@ -564,8 +563,7 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
|
|||
*audio_buf = chunk.data;
|
||||
if (chunk.magic != DATA)
|
||||
headerDiff += lenread + 2 * sizeof(Uint32);
|
||||
}
|
||||
while (chunk.magic != DATA);
|
||||
} while (chunk.magic != DATA);
|
||||
headerDiff += 2 * sizeof(Uint32); /* for the data chunk and len */
|
||||
|
||||
if (MS_ADPCM_encoded) {
|
||||
|
|
|
@ -259,16 +259,19 @@ swizzle_alsa_channels_6_64bit(_THIS)
|
|||
{
|
||||
SWIZ6(Uint64);
|
||||
}
|
||||
|
||||
static __inline__ void
|
||||
swizzle_alsa_channels_6_32bit(_THIS)
|
||||
{
|
||||
SWIZ6(Uint32);
|
||||
}
|
||||
|
||||
static __inline__ void
|
||||
swizzle_alsa_channels_6_16bit(_THIS)
|
||||
{
|
||||
SWIZ6(Uint16);
|
||||
}
|
||||
|
||||
static __inline__ void
|
||||
swizzle_alsa_channels_6_8bit(_THIS)
|
||||
{
|
||||
|
|
|
@ -270,8 +270,7 @@ BSDAUDIO_PlayDevice(_THIS)
|
|||
|| ((written < 0) && ((errno == 0) || (errno == EAGAIN)))) {
|
||||
SDL_Delay(1); /* Let a little CPU time go by */
|
||||
}
|
||||
}
|
||||
while (p < written);
|
||||
} while (p < written);
|
||||
|
||||
/* If timer synchronization is enabled, set the next write frame */
|
||||
if (this->hidden->frame_ticks) {
|
||||
|
|
|
@ -62,8 +62,8 @@ DARTEventFunc(ULONG ulStatus, PMCI_MIX_BUFFER pBuffer, ULONG ulFlags)
|
|||
pBufDesc->iBufferUsage = BUFFER_EMPTY;
|
||||
// And notify DART feeder thread that it will have to work a bit.
|
||||
if (pSDLAudioDevice)
|
||||
DosPostEventSem(pSDLAudioDevice->hidden->
|
||||
hevAudioBufferPlayed);
|
||||
DosPostEventSem(pSDLAudioDevice->
|
||||
hidden->hevAudioBufferPlayed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -312,10 +312,11 @@ DART_PlayDevice(_THIS)
|
|||
(pMixBufferDesc) _this->hidden->pMixBuffers[iFreeBuf].ulUserParm;
|
||||
pBufDesc->iBufferUsage = BUFFER_USED;
|
||||
// Send it to DART to be queued
|
||||
_this->hidden->MixSetupParms.pmixWrite(_this->hidden->MixSetupParms.
|
||||
ulMixHandle,
|
||||
&(_this->hidden->
|
||||
pMixBuffers[iFreeBuf]), 1);
|
||||
_this->hidden->MixSetupParms.pmixWrite(_this->hidden->
|
||||
MixSetupParms.ulMixHandle,
|
||||
&(_this->
|
||||
hidden->pMixBuffers[iFreeBuf]),
|
||||
1);
|
||||
|
||||
_this->hidden->iLastPlayedBuf = iFreeBuf;
|
||||
iFreeBuf = (iFreeBuf + 1) % _this->hidden->iCurrNumBufs;
|
||||
|
@ -333,8 +334,8 @@ DART_GetDeviceBuf(_THIS)
|
|||
if (_this->hidden) {
|
||||
iFreeBuf = _this->hidden->iNextFreeBuffer;
|
||||
pBufDesc =
|
||||
(pMixBufferDesc) _this->hidden->pMixBuffers[iFreeBuf].
|
||||
ulUserParm;
|
||||
(pMixBufferDesc) _this->hidden->
|
||||
pMixBuffers[iFreeBuf].ulUserParm;
|
||||
|
||||
if (pBufDesc) {
|
||||
if (pBufDesc->iBufferUsage == BUFFER_EMPTY) {
|
||||
|
|
|
@ -498,8 +498,7 @@ DMA_GetDeviceBuf(_THIS)
|
|||
this->enabled = 0;
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
while (frame_ticks && (info.blocks < 1));
|
||||
} while (frame_ticks && (info.blocks < 1));
|
||||
#ifdef DEBUG_AUDIO
|
||||
if (info.blocks > 1) {
|
||||
printf("Warning: audio underflow (%d frags)\n", info.blocks - 1);
|
||||
|
|
|
@ -154,8 +154,7 @@ ESD_PlayDevice(_THIS)
|
|||
if ((written < 0) && ((errno == 0) || (errno == EAGAIN))) {
|
||||
SDL_Delay(1); /* Let a little CPU time go by */
|
||||
}
|
||||
}
|
||||
while ((written < 0) &&
|
||||
} while ((written < 0) &&
|
||||
((errno == 0) || (errno == EAGAIN) || (errno == EINTR)));
|
||||
|
||||
/* Set the next write frame */
|
||||
|
|
130
src/audio/nds/SDL_ndsaudio.c
Normal file
130
src/audio/nds/SDL_ndsaudio.c
Normal file
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 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
|
||||
|
||||
This file written by Ryan C. Gordon (icculus@icculus.org)
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Output audio to NDS */
|
||||
|
||||
#include <nds.h>
|
||||
|
||||
#include "SDL_audio.h"
|
||||
#include "../SDL_audio_c.h"
|
||||
#include "SDL_ndsaudio.h"
|
||||
|
||||
static int
|
||||
NDSAUD_OpenDevice(_THIS, const char *devname, int iscapture)
|
||||
{
|
||||
SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
|
||||
int valid_datatype = 0;
|
||||
|
||||
this->hidden = SDL_malloc(sizeof(*(this->hidden)));
|
||||
if (!this->hidden) {
|
||||
SDL_OutOfMemory();
|
||||
return 0;
|
||||
}
|
||||
SDL_memset(this->hidden, 0, (sizeof *this->hidden));
|
||||
|
||||
while ((!valid_datatype) && (test_format)) {
|
||||
this->spec.format = test_format;
|
||||
switch (test_format) {
|
||||
case AUDIO_S8:
|
||||
/*case AUDIO_S16LSB: */
|
||||
valid_datatype = 1;
|
||||
break;
|
||||
default:
|
||||
test_format = SDL_NextAudioFormat();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* set the generic sound parameters */
|
||||
setGenericSound(22050, /* sample rate */
|
||||
127, /* volume */
|
||||
64, /* panning/balance */
|
||||
0); /* sound format */
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
NDSAUD_PlayDevice(_THIS)
|
||||
{
|
||||
TransferSoundData *sound = SDL_malloc(sizeof(TransferSoundData));
|
||||
if (!sound) {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
playGenericSound(this->hidden->mixbuf, this->hidden->mixlen);
|
||||
#if 0
|
||||
// sound->data = this->hidden->mixbuf;/* pointer to raw audio data */
|
||||
// sound->len = this->hidden->mixlen; /* size of raw data pointed to above */
|
||||
// sound->rate = 22050; /* sample rate = 22050Hz */
|
||||
// sound->vol = 127; /* volume [0..127] for [min..max] */
|
||||
// sound->pan = 64; /* balance [0..127] for [left..right] */
|
||||
// sound->format = 0; /* 0 for 16-bit, 1 for 8-bit */
|
||||
// playSound(sound);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static Uint8 *
|
||||
NDSAUD_GetDeviceBuf(_THIS)
|
||||
{
|
||||
return this->hidden->mixbuf; /* is this right? */
|
||||
}
|
||||
|
||||
static void
|
||||
NDSAUD_WaitDevice(_THIS)
|
||||
{
|
||||
/* stub */
|
||||
}
|
||||
|
||||
static void
|
||||
NDSAUD_CloseDevice(_THIS)
|
||||
{
|
||||
/* stub */
|
||||
}
|
||||
|
||||
static int
|
||||
NDSAUD_Init(SDL_AudioDriverImpl * impl)
|
||||
{
|
||||
/* Set the function pointers */
|
||||
impl->OpenDevice = NDSAUD_OpenDevice;
|
||||
impl->PlayDevice = NDSAUD_PlayDevice;
|
||||
impl->WaitDevice = NDSAUD_WaitDevice;
|
||||
impl->GetDeviceBuf = NDSAUD_GetDeviceBuf;
|
||||
impl->CloseDevice = NDSAUD_CloseDevice;
|
||||
|
||||
/* and the capabilities */
|
||||
impl->HasCaptureSupport = 1;
|
||||
impl->OnlyHasDefaultOutputDevice = 1;
|
||||
impl->OnlyHasDefaultInputDevice = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
AudioBootStrap NDSAUD_bootstrap = {
|
||||
"nds", "SDL NDS audio driver", NDSAUD_Init, 0 /*1? */
|
||||
};
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
44
src/audio/nds/SDL_ndsaudio.h
Normal file
44
src/audio/nds/SDL_ndsaudio.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 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"
|
||||
|
||||
#ifndef _SDL_ndsaudio_h
|
||||
#define _SDL_ndsaudio_h
|
||||
|
||||
#include "../SDL_sysaudio.h"
|
||||
#include <nds/arm9/sound.h>
|
||||
|
||||
/* Hidden "this" pointer for the audio functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
||||
struct SDL_PrivateAudioData
|
||||
{
|
||||
TransferSoundData *sound;
|
||||
/* The file descriptor for the audio device */
|
||||
Uint8 *mixbuf;
|
||||
Uint32 mixlen;
|
||||
Uint32 write_delay;
|
||||
Uint32 initial_calls;
|
||||
};
|
||||
|
||||
#endif /* _SDL_ndsaudio_h */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -154,8 +154,7 @@ NTO_WaitDevice(_THIS)
|
|||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (1);
|
||||
} while (1);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -213,8 +212,7 @@ NTO_PlayDevice(_THIS)
|
|||
towrite -= written;
|
||||
pcmbuffer += written * this->spec.channels;
|
||||
}
|
||||
}
|
||||
while ((towrite > 0) && (this->enabled));
|
||||
} while ((towrite > 0) && (this->enabled));
|
||||
|
||||
/* If we couldn't write, assume fatal error for now */
|
||||
if (towrite != 0) {
|
||||
|
|
|
@ -208,8 +208,7 @@ PAUDIO_PlayDevice(_THIS)
|
|||
if ((written < 0) && ((errno == 0) || (errno == EAGAIN))) {
|
||||
SDL_Delay(1); /* Let a little CPU time go by */
|
||||
}
|
||||
}
|
||||
while ((written < 0) &&
|
||||
} while ((written < 0) &&
|
||||
((errno == 0) || (errno == EAGAIN) || (errno == EINTR)));
|
||||
|
||||
/* If timer synchronization is enabled, set the next write frame */
|
||||
|
|
|
@ -218,8 +218,7 @@ UMS_PlayAudio(_THIS)
|
|||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (samplesToWrite > 0);
|
||||
} while (samplesToWrite > 0);
|
||||
|
||||
SDL_LockAudio();
|
||||
SDL_memcpy(&swpbuf, &this->hidden->playbuf, sizeof(UMSAudioTypes_Buffer));
|
||||
|
@ -326,8 +325,7 @@ UMS_OpenAudio(_THIS, SDL_AudioSpec * spec)
|
|||
if (!success) {
|
||||
test_format = SDL_NextAudioFormat();
|
||||
}
|
||||
}
|
||||
while (!success && test_format);
|
||||
} while (!success && test_format);
|
||||
|
||||
if (success == 0) {
|
||||
SDL_SetError("Couldn't find any hardware audio formats");
|
||||
|
|
|
@ -107,8 +107,8 @@ WINWAVEOUT_WaitDevice(_THIS)
|
|||
Uint8 *
|
||||
WINWAVEOUT_GetDeviceBuf(_THIS)
|
||||
{
|
||||
return (Uint8 *) (this->hidden->wavebuf[this->hidden->next_buffer].
|
||||
lpData);
|
||||
return (Uint8 *) (this->hidden->
|
||||
wavebuf[this->hidden->next_buffer].lpData);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -136,8 +136,7 @@ WINWAVEOUT_WaitDone(_THIS)
|
|||
if (left > 0) {
|
||||
SDL_Delay(100);
|
||||
}
|
||||
}
|
||||
while (left > 0);
|
||||
} while (left > 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -278,8 +278,9 @@ DSOUND_GetDeviceBuf(_THIS)
|
|||
IDirectSoundBuffer_Restore(this->hidden->mixbuf);
|
||||
result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor,
|
||||
this->hidden->mixlen,
|
||||
(LPVOID *) & this->hidden->
|
||||
locked_buf, &rawlen, NULL, &junk, 0);
|
||||
(LPVOID *) & this->
|
||||
hidden->locked_buf, &rawlen, NULL,
|
||||
&junk, 0);
|
||||
}
|
||||
if (result != DS_OK) {
|
||||
SetDSerror("DirectSound Lock", result);
|
||||
|
|
|
@ -44,6 +44,7 @@ struct CDcaps SDL_CDcaps = {
|
|||
NULL, /* Eject */
|
||||
NULL, /* Close */
|
||||
};
|
||||
|
||||
int SDL_numcds;
|
||||
|
||||
int
|
||||
|
|
|
@ -181,8 +181,7 @@ CheckMounts()
|
|||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (ret == 0);
|
||||
} while (ret == 0);
|
||||
|
||||
#ifdef DEBUG_CDROM
|
||||
fprintf(stderr, "Read %d vmount structures\n", ret);
|
||||
|
@ -211,8 +210,7 @@ CheckMounts()
|
|||
}
|
||||
ptr = (struct vmount *) ((char *) ptr + ptr->vmt_length);
|
||||
ret--;
|
||||
}
|
||||
while (ret > 0);
|
||||
} while (ret > 0);
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
@ -247,8 +245,7 @@ CheckNonmounts()
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (ret == 0);
|
||||
} while (ret == 0);
|
||||
ret = endfsent_r(&fsFile);
|
||||
if (ret != 0)
|
||||
return -1;
|
||||
|
@ -275,8 +272,7 @@ CheckNonmounts()
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (entry != NULL);
|
||||
} while (entry != NULL);
|
||||
endfsent();
|
||||
#endif
|
||||
}
|
||||
|
@ -326,8 +322,7 @@ SDL_SYS_CDInit(void)
|
|||
} else {
|
||||
SDLcdrom = NULL;
|
||||
}
|
||||
}
|
||||
while (SDLcdrom);
|
||||
} while (SDLcdrom);
|
||||
SDL_stack_free(cdpath);
|
||||
}
|
||||
|
||||
|
|
|
@ -193,8 +193,7 @@ SDL_SYS_CDInit(void)
|
|||
} else {
|
||||
SDLcdrom = NULL;
|
||||
}
|
||||
}
|
||||
while (SDLcdrom);
|
||||
} while (SDLcdrom);
|
||||
SDL_stack_free(cdpath);
|
||||
}
|
||||
|
||||
|
|
|
@ -286,8 +286,7 @@ SDL_SYS_CDInit(void)
|
|||
} else {
|
||||
SDLcdrom = NULL;
|
||||
}
|
||||
}
|
||||
while (SDLcdrom);
|
||||
} while (SDLcdrom);
|
||||
SDL_stack_free(cdpath);
|
||||
}
|
||||
|
||||
|
|
|
@ -176,8 +176,7 @@ SDL_SYS_CDInit(void)
|
|||
} else {
|
||||
SDLcdrom = NULL;
|
||||
}
|
||||
}
|
||||
while (SDLcdrom);
|
||||
} while (SDLcdrom);
|
||||
SDL_stack_free(cdpath);
|
||||
}
|
||||
|
||||
|
|
|
@ -312,8 +312,7 @@ SDL_SYS_CDInit(void)
|
|||
} else {
|
||||
SDLcdrom = NULL;
|
||||
}
|
||||
}
|
||||
while (SDLcdrom);
|
||||
} while (SDLcdrom);
|
||||
SDL_stack_free(cdpath);
|
||||
}
|
||||
|
||||
|
|
|
@ -311,8 +311,7 @@ AudioFilePlayer_OpenFile(AudioFilePlayer * afp, const FSRef * inRef,
|
|||
|
||||
/* Skip the chunk data */
|
||||
offset = chunk.ckSize;
|
||||
}
|
||||
while (chunk.ckID != 'SSND');
|
||||
} while (chunk.ckID != 'SSND');
|
||||
|
||||
/* Read the header of the SSND chunk. After this, we are positioned right
|
||||
at the start of the audio data. */
|
||||
|
|
|
@ -335,9 +335,8 @@ FileReaderThread_ReadNextChunk(FileReaderThread * frt)
|
|||
}
|
||||
/* construct pointer */
|
||||
char *writePtr = (char *) (theItem->GetFileBuffer(theItem) +
|
||||
(theItem->
|
||||
mWriteToFirstBuffer ? 0 : theItem->
|
||||
mChunkSize));
|
||||
(theItem->mWriteToFirstBuffer ? 0 :
|
||||
theItem->mChunkSize));
|
||||
|
||||
/* read data */
|
||||
result = theItem->Read(theItem, writePtr, &dataChunkSize);
|
||||
|
@ -486,8 +485,7 @@ AudioFileManager_GetFileData(AudioFileManager * afm, void **inOutData,
|
|||
} else {
|
||||
*inOutDataSize = afm->mChunkSize;
|
||||
*inOutData =
|
||||
afm->mReadFromFirstBuffer ? afm->mFileBuffer : (afm->
|
||||
mFileBuffer +
|
||||
afm->mReadFromFirstBuffer ? afm->mFileBuffer : (afm->mFileBuffer +
|
||||
afm->mChunkSize);
|
||||
}
|
||||
|
||||
|
|
|
@ -400,8 +400,7 @@ ListTrackFiles(FSVolumeRefNum theVolume, FSRef * trackFiles, int numTracks)
|
|||
}
|
||||
CFRelease(name);
|
||||
}
|
||||
}
|
||||
while (noErr == result);
|
||||
} while (noErr == result);
|
||||
FSCloseIterator(iterator);
|
||||
}
|
||||
|
||||
|
|
|
@ -184,8 +184,7 @@ SDL_SYS_CDInit(void)
|
|||
} else {
|
||||
SDLcdrom = NULL;
|
||||
}
|
||||
}
|
||||
while (SDLcdrom);
|
||||
} while (SDLcdrom);
|
||||
SDL_stack_free(cdpath);
|
||||
}
|
||||
|
||||
|
|
|
@ -199,8 +199,7 @@ SDL_SYS_CDInit(void)
|
|||
} else {
|
||||
SDLcdrom = NULL;
|
||||
}
|
||||
}
|
||||
while (SDLcdrom);
|
||||
} while (SDLcdrom);
|
||||
SDL_stack_free(cdpath);
|
||||
}
|
||||
|
||||
|
|
|
@ -184,8 +184,7 @@ SDL_SYS_CDInit(void)
|
|||
} else {
|
||||
SDLcdrom = NULL;
|
||||
}
|
||||
}
|
||||
while (SDLcdrom);
|
||||
} while (SDLcdrom);
|
||||
SDL_stack_free(cdpath);
|
||||
}
|
||||
|
||||
|
@ -357,8 +356,7 @@ SDL_SYS_CDStatus(SDL_CD * cdrom, int *position)
|
|||
devctlret = ENXIO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while ((devctlret == EAGAIN) || (devctlret == ESTALE));
|
||||
} while ((devctlret == EAGAIN) || (devctlret == ESTALE));
|
||||
|
||||
if (devctlret != 0) {
|
||||
if (devctlret == ENXIO) {
|
||||
|
|
|
@ -73,6 +73,7 @@ SDL_Lock_EventThread(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_Unlock_EventThread(void)
|
||||
{
|
||||
|
|
|
@ -51,6 +51,7 @@ static unsigned char default_cdata[] = {
|
|||
0x03, 0x00,
|
||||
0x00, 0x00
|
||||
};
|
||||
|
||||
static unsigned char default_cmask[] = {
|
||||
0xC0, 0x00,
|
||||
0xE0, 0x00,
|
||||
|
@ -90,6 +91,7 @@ static unsigned char default_cdata[] = {
|
|||
0x03, 0x00,
|
||||
0x00, 0x00
|
||||
};
|
||||
|
||||
static unsigned char default_cmask[] = {
|
||||
0x40, 0x00,
|
||||
0xE0, 0x00,
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
#include "SDL_endian.h"
|
||||
#include "SDL_rwops.h"
|
||||
|
||||
#ifdef __NDS__
|
||||
/* include libfat headers for fatInitDefault(). */
|
||||
#include <fat.h>
|
||||
#endif /* __NDS__ */
|
||||
|
||||
#ifdef __WIN32__
|
||||
|
||||
|
@ -132,6 +136,7 @@ win32_file_open(SDL_RWops * context, const char *filename, const char *mode)
|
|||
|
||||
return 0; /* ok */
|
||||
}
|
||||
|
||||
static long SDLCALL
|
||||
win32_file_seek(SDL_RWops * context, long offset, int whence)
|
||||
{
|
||||
|
@ -173,6 +178,7 @@ win32_file_seek(SDL_RWops * context, long offset, int whence)
|
|||
SDL_Error(SDL_EFSEEK);
|
||||
return -1; /* error */
|
||||
}
|
||||
|
||||
static size_t SDLCALL
|
||||
win32_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
|
||||
{
|
||||
|
@ -226,6 +232,7 @@ win32_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
|
|||
}
|
||||
return (total_read / size);
|
||||
}
|
||||
|
||||
static size_t SDLCALL
|
||||
win32_file_write(SDL_RWops * context, const void *ptr, size_t size,
|
||||
size_t num)
|
||||
|
@ -265,6 +272,7 @@ win32_file_write(SDL_RWops * context, const void *ptr, size_t size,
|
|||
nwritten = byte_written / size;
|
||||
return nwritten;
|
||||
}
|
||||
|
||||
static int SDLCALL
|
||||
win32_file_close(SDL_RWops * context)
|
||||
{
|
||||
|
@ -298,6 +306,7 @@ stdio_seek(SDL_RWops * context, long offset, int whence)
|
|||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
static size_t SDLCALL
|
||||
stdio_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
|
||||
{
|
||||
|
@ -309,6 +318,7 @@ stdio_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
|
|||
}
|
||||
return (nread);
|
||||
}
|
||||
|
||||
static size_t SDLCALL
|
||||
stdio_write(SDL_RWops * context, const void *ptr, size_t size, size_t num)
|
||||
{
|
||||
|
@ -320,6 +330,7 @@ stdio_write(SDL_RWops * context, const void *ptr, size_t size, size_t num)
|
|||
}
|
||||
return (nwrote);
|
||||
}
|
||||
|
||||
static int SDLCALL
|
||||
stdio_close(SDL_RWops * context)
|
||||
{
|
||||
|
@ -368,6 +379,7 @@ mem_seek(SDL_RWops * context, long offset, int whence)
|
|||
context->hidden.mem.here = newpos;
|
||||
return (context->hidden.mem.here - context->hidden.mem.base);
|
||||
}
|
||||
|
||||
static size_t SDLCALL
|
||||
mem_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
|
||||
{
|
||||
|
@ -390,6 +402,7 @@ mem_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
|
|||
|
||||
return (total_bytes / size);
|
||||
}
|
||||
|
||||
static size_t SDLCALL
|
||||
mem_write(SDL_RWops * context, const void *ptr, size_t size, size_t num)
|
||||
{
|
||||
|
@ -400,12 +413,14 @@ mem_write(SDL_RWops * context, const void *ptr, size_t size, size_t num)
|
|||
context->hidden.mem.here += num * size;
|
||||
return (num);
|
||||
}
|
||||
|
||||
static size_t SDLCALL
|
||||
mem_writeconst(SDL_RWops * context, const void *ptr, size_t size, size_t num)
|
||||
{
|
||||
SDL_SetError("Can't write to read-only memory");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static int SDLCALL
|
||||
mem_close(SDL_RWops * context)
|
||||
{
|
||||
|
@ -463,6 +478,13 @@ SDL_RWFromFP(FILE * fp, SDL_bool autoclose)
|
|||
{
|
||||
SDL_RWops *rwops = NULL;
|
||||
|
||||
#if 0
|
||||
/*#ifdef __NDS__*/
|
||||
/* set it up so we can use stdio file function */
|
||||
fatInitDefault();
|
||||
printf("called fatInitDefault()");
|
||||
#endif /* __NDS__ */
|
||||
|
||||
rwops = SDL_AllocRW();
|
||||
if (rwops != NULL) {
|
||||
rwops->seek = stdio_seek;
|
||||
|
|
|
@ -149,8 +149,8 @@ HIDCreateOpenDeviceInterface(io_object_t hidDevice, recDevice * pDevice)
|
|||
(*ppPlugInInterface)->QueryInterface(ppPlugInInterface,
|
||||
CFUUIDGetUUIDBytes
|
||||
(kIOHIDDeviceInterfaceID),
|
||||
(void *) &(pDevice->
|
||||
interface));
|
||||
(void *)
|
||||
&(pDevice->interface));
|
||||
if (S_OK != plugInResult)
|
||||
HIDReportErrorNum
|
||||
("CouldnÕt query HID class device interface from plugInInterface",
|
||||
|
|
|
@ -89,6 +89,7 @@ struct joystick_logical_mapping
|
|||
static struct joystick_logical_mapping mp88xx_1_logical_axismap[] = {
|
||||
{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}
|
||||
};
|
||||
|
||||
static struct joystick_logical_mapping mp88xx_1_logical_buttonmap[] = {
|
||||
{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8},
|
||||
{0, 9}, {0, 10}, {0, 11}
|
||||
|
@ -98,6 +99,7 @@ static struct joystick_logical_mapping mp88xx_2_logical_axismap[] = {
|
|||
{0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {0, 3},
|
||||
{1, 2}, {1, 3}, {0, 4}, {0, 5}, {1, 4}, {1, 5}
|
||||
};
|
||||
|
||||
static struct joystick_logical_mapping mp88xx_2_logical_buttonmap[] = {
|
||||
{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8},
|
||||
{0, 9}, {0, 10}, {0, 11},
|
||||
|
@ -110,6 +112,7 @@ static struct joystick_logical_mapping mp88xx_3_logical_axismap[] = {
|
|||
{1, 2}, {1, 3}, {2, 0}, {2, 1}, {2, 2}, {2, 3},
|
||||
{0, 4}, {0, 5}, {1, 4}, {1, 5}, {2, 4}, {2, 5}
|
||||
};
|
||||
|
||||
static struct joystick_logical_mapping mp88xx_3_logical_buttonmap[] = {
|
||||
{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8},
|
||||
{0, 9}, {0, 10}, {0, 11},
|
||||
|
@ -125,6 +128,7 @@ static struct joystick_logical_mapping mp88xx_4_logical_axismap[] = {
|
|||
{3, 0}, {3, 1}, {3, 2}, {3, 3}, {0, 4}, {0, 5},
|
||||
{1, 4}, {1, 5}, {2, 4}, {2, 5}, {3, 4}, {3, 5}
|
||||
};
|
||||
|
||||
static struct joystick_logical_mapping mp88xx_4_logical_buttonmap[] = {
|
||||
{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8},
|
||||
{0, 9}, {0, 10}, {0, 11},
|
||||
|
@ -147,15 +151,18 @@ struct joystick_logical_layout
|
|||
static struct joystick_logical_layout mp88xx_1_logical_layout[] = {
|
||||
{6, 0, 0, 12}
|
||||
};
|
||||
|
||||
static struct joystick_logical_layout mp88xx_2_logical_layout[] = {
|
||||
{6, 0, 0, 12},
|
||||
{6, 0, 0, 12}
|
||||
};
|
||||
|
||||
static struct joystick_logical_layout mp88xx_3_logical_layout[] = {
|
||||
{6, 0, 0, 12},
|
||||
{6, 0, 0, 12},
|
||||
{6, 0, 0, 12}
|
||||
};
|
||||
|
||||
static struct joystick_logical_layout mp88xx_4_logical_layout[] = {
|
||||
{6, 0, 0, 12},
|
||||
{6, 0, 0, 12},
|
||||
|
@ -953,8 +960,8 @@ HandleHat(SDL_Joystick * stick, Uint8 hat, int axis, int value)
|
|||
#endif /* USE_LOGICAL_JOYSTICKS */
|
||||
|
||||
SDL_PrivateJoystickHat(stick, hat,
|
||||
position_map[the_hat->axis[1]][the_hat->
|
||||
axis[0]]);
|
||||
position_map[the_hat->
|
||||
axis[1]][the_hat->axis[0]]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1085,13 +1092,13 @@ EV_HandleEvents(SDL_Joystick * joystick)
|
|||
code -= BTN_MISC;
|
||||
#ifndef NO_LOGICAL_JOYSTICKS
|
||||
if (!LogicalJoystickButton(joystick,
|
||||
joystick->hwdata->
|
||||
key_map[code],
|
||||
joystick->
|
||||
hwdata->key_map[code],
|
||||
events[i].value))
|
||||
#endif
|
||||
SDL_PrivateJoystickButton(joystick,
|
||||
joystick->hwdata->
|
||||
key_map[code],
|
||||
joystick->
|
||||
hwdata->key_map[code],
|
||||
events[i].value);
|
||||
}
|
||||
break;
|
||||
|
@ -1113,12 +1120,12 @@ EV_HandleEvents(SDL_Joystick * joystick)
|
|||
EV_AxisCorrect(joystick, code, events[i].value);
|
||||
#ifndef NO_LOGICAL_JOYSTICKS
|
||||
if (!LogicalJoystickAxis(joystick,
|
||||
joystick->hwdata->
|
||||
abs_map[code], events[i].value))
|
||||
joystick->hwdata->abs_map[code],
|
||||
events[i].value))
|
||||
#endif
|
||||
SDL_PrivateJoystickAxis(joystick,
|
||||
joystick->hwdata->
|
||||
abs_map[code],
|
||||
joystick->
|
||||
hwdata->abs_map[code],
|
||||
events[i].value);
|
||||
break;
|
||||
}
|
||||
|
|
172
src/joystick/nds/SDL_sysjoystick.c
Normal file
172
src/joystick/nds/SDL_sysjoystick.c
Normal file
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifdef SDL_JOYSTICK_NDS
|
||||
|
||||
/* This is the system specific header for the SDL joystick API */
|
||||
#include <nds.h>
|
||||
#include <stdio.h> /* For the definition of NULL */
|
||||
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_joystick.h"
|
||||
#include "SDL_sysjoystick.h"
|
||||
#include "SDL_joystick_c.h"
|
||||
|
||||
#include "../../video/nds/SDL_ndsevents_c.h"
|
||||
|
||||
/* Function to scan the system for joysticks.
|
||||
* This function should set SDL_numjoysticks to the number of available
|
||||
* joysticks. Joystick 0 should be the system default joystick.
|
||||
* It should return 0, or -1 on an unrecoverable fatal error.
|
||||
*/
|
||||
int
|
||||
SDL_SYS_JoystickInit(void)
|
||||
{
|
||||
SDL_numjoysticks = 1;
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Function to get the device-dependent name of a joystick */
|
||||
const char *
|
||||
SDL_SYS_JoystickName(int index)
|
||||
{
|
||||
if (!index)
|
||||
return "NDS builtin joypad";
|
||||
SDL_SetError("No joystick available with that index");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* Function to open a joystick for use.
|
||||
The joystick to open is specified by the index field of the joystick.
|
||||
This should fill the nbuttons and naxes fields of the joystick structure.
|
||||
It returns 0, or -1 if there is an error.
|
||||
*/
|
||||
int
|
||||
SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
|
||||
{
|
||||
joystick->nbuttons = 8;
|
||||
joystick->nhats = 0;
|
||||
joystick->nballs = 0;
|
||||
joystick->naxes = 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Function to update the state of a joystick - called as a device poll.
|
||||
* This function shouldn't update the joystick structure directly,
|
||||
* but instead should call SDL_PrivateJoystick*() to deliver events
|
||||
* and update joystick device state.
|
||||
*/
|
||||
void
|
||||
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
|
||||
{
|
||||
u32 keysd, keysu;
|
||||
int magnitude = 16384;
|
||||
|
||||
/*scanKeys(); */
|
||||
keysd = keysDown();
|
||||
keysu = keysUp();
|
||||
|
||||
if ((keysd & KEY_UP)) {
|
||||
SDL_PrivateJoystickAxis(joystick, 1, -magnitude);
|
||||
}
|
||||
if ((keysd & KEY_DOWN)) {
|
||||
SDL_PrivateJoystickAxis(joystick, 1, magnitude);
|
||||
}
|
||||
if ((keysd & KEY_LEFT)) {
|
||||
SDL_PrivateJoystickAxis(joystick, 0, -magnitude);
|
||||
}
|
||||
if ((keysd & KEY_RIGHT)) {
|
||||
SDL_PrivateJoystickAxis(joystick, 0, magnitude);
|
||||
}
|
||||
if ((keysu & (KEY_UP | KEY_DOWN))) {
|
||||
SDL_PrivateJoystickAxis(joystick, 1, 0);
|
||||
}
|
||||
if ((keysu & (KEY_LEFT | KEY_RIGHT))) {
|
||||
SDL_PrivateJoystickAxis(joystick, 0, 0);
|
||||
}
|
||||
if ((keysd & KEY_A)) {
|
||||
SDL_PrivateJoystickButton(joystick, 0, SDL_PRESSED);
|
||||
}
|
||||
if ((keysd & KEY_B)) {
|
||||
SDL_PrivateJoystickButton(joystick, 1, SDL_PRESSED);
|
||||
}
|
||||
if ((keysd & KEY_X)) {
|
||||
SDL_PrivateJoystickButton(joystick, 2, SDL_PRESSED);
|
||||
}
|
||||
if ((keysd & KEY_Y)) {
|
||||
SDL_PrivateJoystickButton(joystick, 3, SDL_PRESSED);
|
||||
}
|
||||
if ((keysd & KEY_L)) {
|
||||
SDL_PrivateJoystickButton(joystick, 4, SDL_PRESSED);
|
||||
}
|
||||
if ((keysd & KEY_R)) {
|
||||
SDL_PrivateJoystickButton(joystick, 5, SDL_PRESSED);
|
||||
}
|
||||
if ((keysd & KEY_SELECT)) {
|
||||
SDL_PrivateJoystickButton(joystick, 6, SDL_PRESSED);
|
||||
}
|
||||
if ((keysd & KEY_START)) {
|
||||
SDL_PrivateJoystickButton(joystick, 7, SDL_PRESSED);
|
||||
}
|
||||
if ((keysu & KEY_A)) {
|
||||
SDL_PrivateJoystickButton(joystick, 0, SDL_RELEASED);
|
||||
}
|
||||
if ((keysu & KEY_B)) {
|
||||
SDL_PrivateJoystickButton(joystick, 1, SDL_RELEASED);
|
||||
}
|
||||
if ((keysu & KEY_X)) {
|
||||
SDL_PrivateJoystickButton(joystick, 2, SDL_RELEASED);
|
||||
}
|
||||
if ((keysu & KEY_Y)) {
|
||||
SDL_PrivateJoystickButton(joystick, 3, SDL_RELEASED);
|
||||
}
|
||||
if ((keysu & KEY_L)) {
|
||||
SDL_PrivateJoystickButton(joystick, 4, SDL_RELEASED);
|
||||
}
|
||||
if ((keysu & KEY_R)) {
|
||||
SDL_PrivateJoystickButton(joystick, 5, SDL_RELEASED);
|
||||
}
|
||||
if ((keysu & KEY_SELECT)) {
|
||||
SDL_PrivateJoystickButton(joystick, 6, SDL_RELEASED);
|
||||
}
|
||||
if ((keysu & KEY_START)) {
|
||||
SDL_PrivateJoystickButton(joystick, 7, SDL_RELEASED);
|
||||
}
|
||||
}
|
||||
|
||||
/* Function to close a joystick after use */
|
||||
void
|
||||
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
|
||||
{
|
||||
}
|
||||
|
||||
/* Function to perform any system-specific joystick related cleanup */
|
||||
void
|
||||
SDL_SYS_JoystickQuit(void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* SDL_JOYSTICK_NDS */
|
|
@ -616,8 +616,8 @@ search_linked_libs(const struct mach_header *mh, const char *symbol)
|
|||
|| (LC_LOAD_WEAK_DYLIB == lc->cmd)) {
|
||||
if ((wh = (struct mach_header *)
|
||||
my_find_image((char
|
||||
*) (((struct dylib_command *) lc)->
|
||||
dylib.name.offset + (char *) lc)))) {
|
||||
*) (((struct dylib_command *) lc)->dylib.
|
||||
name.offset + (char *) lc)))) {
|
||||
if (dyld_NSIsSymbolNameDefinedInImage(wh, symbol)) {
|
||||
nssym = dyld_NSLookupSymbolInImage(wh,
|
||||
symbol,
|
||||
|
@ -1067,6 +1067,7 @@ dlsym_auto_underscore(void *handle, const char *symbol)
|
|||
return answer;
|
||||
|
||||
}
|
||||
|
||||
static void *
|
||||
dlsym_auto_underscore_intern(void *handle, const char *symbol)
|
||||
{
|
||||
|
|
|
@ -78,8 +78,7 @@ SDL_InitBeApp(void)
|
|||
|
||||
do {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
while ((be_app == NULL) || be_app->IsLaunching());
|
||||
} while ((be_app == NULL) || be_app->IsLaunching());
|
||||
|
||||
/* Mark the application active */
|
||||
SDL_BeAppActive = 0;
|
||||
|
|
|
@ -135,6 +135,7 @@ _allmul()
|
|||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
void
|
||||
__declspec(naked)
|
||||
_alldiv()
|
||||
|
@ -222,6 +223,7 @@ L8:
|
|||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
void
|
||||
__declspec(naked)
|
||||
_aulldiv()
|
||||
|
@ -279,6 +281,7 @@ L2:
|
|||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
void
|
||||
__declspec(naked)
|
||||
_allrem()
|
||||
|
@ -365,6 +368,7 @@ L8:
|
|||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
void
|
||||
__declspec(naked)
|
||||
_aullrem()
|
||||
|
@ -423,6 +427,7 @@ L2:
|
|||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
void
|
||||
__declspec(naked)
|
||||
_alldvrm()
|
||||
|
@ -532,6 +537,7 @@ L8:
|
|||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
void
|
||||
__declspec(naked)
|
||||
_aulldvrm()
|
||||
|
@ -604,6 +610,7 @@ L2:
|
|||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
void
|
||||
__declspec(naked)
|
||||
_allshl()
|
||||
|
@ -630,6 +637,7 @@ RETZERO:
|
|||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
void
|
||||
__declspec(naked)
|
||||
_aullshr()
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
#include "irix/SDL_systhread_c.h"
|
||||
#elif SDL_THREAD_WIN32
|
||||
#include "win32/SDL_systhread_c.h"
|
||||
#elif SDL_THREAD_NDS
|
||||
#include "nds/SDL_systhread_c.h"
|
||||
#else
|
||||
#error Need thread implementation for this platform
|
||||
#include "generic/SDL_systhread_c.h"
|
||||
|
|
|
@ -55,9 +55,11 @@ union semun {
|
|||
static struct sembuf op_trywait[2] = {
|
||||
{0, -1, (IPC_NOWAIT | SEM_UNDO)} /* Decrement semaphore, no block */
|
||||
};
|
||||
|
||||
static struct sembuf op_wait[2] = {
|
||||
{0, -1, SEM_UNDO} /* Decrement semaphore */
|
||||
};
|
||||
|
||||
static struct sembuf op_post[1] = {
|
||||
{0, 1, (IPC_NOWAIT | SEM_UNDO)} /* Increment semaphore */
|
||||
};
|
||||
|
@ -170,8 +172,7 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
|
|||
break;
|
||||
}
|
||||
SDL_Delay(1);
|
||||
}
|
||||
while (SDL_GetTicks() < timeout);
|
||||
} while (SDL_GetTicks() < timeout);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
|
229
src/thread/nds/SDL_syscond.c
Normal file
229
src/thread/nds/SDL_syscond.c
Normal file
|
@ -0,0 +1,229 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
#ifdef SAVE_RCSID
|
||||
static char rcsid =
|
||||
"@(#) $Id: SDL_syscond.c,v 1.2 2001/04/26 16:50:18 hercules Exp $";
|
||||
#endif
|
||||
|
||||
/* An implementation of condition variables using semaphores and mutexes */
|
||||
/*
|
||||
This implementation borrows heavily from the BeOS condition variable
|
||||
implementation, written by Christopher Tate and Owen Smith. Thanks!
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_thread.h"
|
||||
|
||||
struct SDL_cond
|
||||
{
|
||||
SDL_mutex *lock;
|
||||
int waiting;
|
||||
int signals;
|
||||
SDL_sem *wait_sem;
|
||||
SDL_sem *wait_done;
|
||||
};
|
||||
|
||||
/* Create a condition variable */
|
||||
SDL_cond *
|
||||
SDL_CreateCond(void)
|
||||
{
|
||||
SDL_cond *cond;
|
||||
|
||||
cond = (SDL_cond *) malloc(sizeof(SDL_cond));
|
||||
if (cond) {
|
||||
cond->lock = SDL_CreateMutex();
|
||||
cond->wait_sem = SDL_CreateSemaphore(0);
|
||||
cond->wait_done = SDL_CreateSemaphore(0);
|
||||
cond->waiting = cond->signals = 0;
|
||||
if (!cond->lock || !cond->wait_sem || !cond->wait_done) {
|
||||
SDL_DestroyCond(cond);
|
||||
cond = NULL;
|
||||
}
|
||||
} else {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
return (cond);
|
||||
}
|
||||
|
||||
/* Destroy a condition variable */
|
||||
void
|
||||
SDL_DestroyCond(SDL_cond * cond)
|
||||
{
|
||||
if (cond) {
|
||||
if (cond->wait_sem) {
|
||||
SDL_DestroySemaphore(cond->wait_sem);
|
||||
}
|
||||
if (cond->wait_done) {
|
||||
SDL_DestroySemaphore(cond->wait_done);
|
||||
}
|
||||
if (cond->lock) {
|
||||
SDL_DestroyMutex(cond->lock);
|
||||
}
|
||||
free(cond);
|
||||
}
|
||||
}
|
||||
|
||||
/* Restart one of the threads that are waiting on the condition variable */
|
||||
int
|
||||
SDL_CondSignal(SDL_cond * cond)
|
||||
{
|
||||
if (!cond) {
|
||||
SDL_SetError("Passed a NULL condition variable");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If there are waiting threads not already signalled, then
|
||||
signal the condition and wait for the thread to respond.
|
||||
*/
|
||||
SDL_LockMutex(cond->lock);
|
||||
if (cond->waiting > cond->signals) {
|
||||
++cond->signals;
|
||||
SDL_SemPost(cond->wait_sem);
|
||||
SDL_UnlockMutex(cond->lock);
|
||||
SDL_SemWait(cond->wait_done);
|
||||
} else {
|
||||
SDL_UnlockMutex(cond->lock);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Restart all threads that are waiting on the condition variable */
|
||||
int
|
||||
SDL_CondBroadcast(SDL_cond * cond)
|
||||
{
|
||||
if (!cond) {
|
||||
SDL_SetError("Passed a NULL condition variable");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If there are waiting threads not already signalled, then
|
||||
signal the condition and wait for the thread to respond.
|
||||
*/
|
||||
SDL_LockMutex(cond->lock);
|
||||
if (cond->waiting > cond->signals) {
|
||||
int i, num_waiting;
|
||||
|
||||
num_waiting = (cond->waiting - cond->signals);
|
||||
cond->signals = cond->waiting;
|
||||
for (i = 0; i < num_waiting; ++i) {
|
||||
SDL_SemPost(cond->wait_sem);
|
||||
}
|
||||
/* Now all released threads are blocked here, waiting for us.
|
||||
Collect them all (and win fabulous prizes!) :-)
|
||||
*/
|
||||
SDL_UnlockMutex(cond->lock);
|
||||
for (i = 0; i < num_waiting; ++i) {
|
||||
SDL_SemWait(cond->wait_done);
|
||||
}
|
||||
} else {
|
||||
SDL_UnlockMutex(cond->lock);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Wait on the condition variable for at most 'ms' milliseconds.
|
||||
The mutex must be locked before entering this function!
|
||||
The mutex is unlocked during the wait, and locked again after the wait.
|
||||
|
||||
Typical use:
|
||||
|
||||
Thread A:
|
||||
SDL_LockMutex(lock);
|
||||
while ( ! condition ) {
|
||||
SDL_CondWait(cond);
|
||||
}
|
||||
SDL_UnlockMutex(lock);
|
||||
|
||||
Thread B:
|
||||
SDL_LockMutex(lock);
|
||||
...
|
||||
condition = true;
|
||||
...
|
||||
SDL_UnlockMutex(lock);
|
||||
*/
|
||||
int
|
||||
SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
|
||||
{
|
||||
int retval;
|
||||
|
||||
if (!cond) {
|
||||
SDL_SetError("Passed a NULL condition variable");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Obtain the protection mutex, and increment the number of waiters.
|
||||
This allows the signal mechanism to only perform a signal if there
|
||||
are waiting threads.
|
||||
*/
|
||||
SDL_LockMutex(cond->lock);
|
||||
++cond->waiting;
|
||||
SDL_UnlockMutex(cond->lock);
|
||||
|
||||
/* Unlock the mutex, as is required by condition variable semantics */
|
||||
SDL_UnlockMutex(mutex);
|
||||
|
||||
/* Wait for a signal */
|
||||
if (ms == SDL_MUTEX_MAXWAIT) {
|
||||
retval = SDL_SemWait(cond->wait_sem);
|
||||
} else {
|
||||
retval = SDL_SemWaitTimeout(cond->wait_sem, ms);
|
||||
}
|
||||
|
||||
/* Let the signaler know we have completed the wait, otherwise
|
||||
the signaler can race ahead and get the condition semaphore
|
||||
if we are stopped between the mutex unlock and semaphore wait,
|
||||
giving a deadlock. See the following URL for details:
|
||||
http://www-classic.be.com/aboutbe/benewsletter/volume_III/Issue40.html
|
||||
*/
|
||||
SDL_LockMutex(cond->lock);
|
||||
if (cond->signals > 0) {
|
||||
/* If we timed out, we need to eat a condition signal */
|
||||
if (retval > 0) {
|
||||
SDL_SemWait(cond->wait_sem);
|
||||
}
|
||||
/* We always notify the signal thread that we are done */
|
||||
SDL_SemPost(cond->wait_done);
|
||||
|
||||
/* Signal handshake complete */
|
||||
--cond->signals;
|
||||
}
|
||||
--cond->waiting;
|
||||
SDL_UnlockMutex(cond->lock);
|
||||
|
||||
/* Lock the mutex, as is required by condition variable semantics */
|
||||
SDL_LockMutex(mutex);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Wait on the condition variable forever */
|
||||
int
|
||||
SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex)
|
||||
{
|
||||
return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT);
|
||||
}
|
26
src/thread/nds/SDL_syscond_c.h
Normal file
26
src/thread/nds/SDL_syscond_c.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
#ifdef SAVE_RCSID
|
||||
static char rcsid =
|
||||
"@(#) $Id: SDL_syscond_c.h,v 1.2 2001/04/26 16:50:18 hercules Exp $";
|
||||
#endif
|
142
src/thread/nds/SDL_sysmutex.c
Normal file
142
src/thread/nds/SDL_sysmutex.c
Normal file
|
@ -0,0 +1,142 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
#ifdef SAVE_RCSID
|
||||
static char rcsid =
|
||||
"@(#) $Id: SDL_sysmutex.c,v 1.2 2001/04/26 16:50:18 hercules Exp $";
|
||||
#endif
|
||||
|
||||
/* An implementation of mutexes using semaphores */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_thread.h"
|
||||
#include "SDL_systhread_c.h"
|
||||
|
||||
|
||||
struct SDL_mutex
|
||||
{
|
||||
int recursive;
|
||||
Uint32 owner;
|
||||
SDL_sem *sem;
|
||||
};
|
||||
|
||||
/* Create a mutex */
|
||||
SDL_mutex *
|
||||
SDL_CreateMutex(void)
|
||||
{
|
||||
SDL_mutex *mutex;
|
||||
|
||||
/* Allocate mutex memory */
|
||||
mutex = (SDL_mutex *) malloc(sizeof(*mutex));
|
||||
if (mutex) {
|
||||
/* Create the mutex semaphore, with initial value 1 */
|
||||
mutex->sem = SDL_CreateSemaphore(1);
|
||||
mutex->recursive = 0;
|
||||
mutex->owner = 0;
|
||||
if (!mutex->sem) {
|
||||
free(mutex);
|
||||
mutex = NULL;
|
||||
}
|
||||
} else {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
return mutex;
|
||||
}
|
||||
|
||||
/* Free the mutex */
|
||||
void
|
||||
SDL_DestroyMutex(SDL_mutex * mutex)
|
||||
{
|
||||
if (mutex) {
|
||||
if (mutex->sem) {
|
||||
SDL_DestroySemaphore(mutex->sem);
|
||||
}
|
||||
free(mutex);
|
||||
}
|
||||
}
|
||||
|
||||
/* Lock the semaphore */
|
||||
int
|
||||
SDL_mutexP(SDL_mutex * mutex)
|
||||
{
|
||||
#ifdef DISABLE_THREADS
|
||||
return 0;
|
||||
#else
|
||||
Uint32 this_thread;
|
||||
|
||||
if (mutex == NULL) {
|
||||
SDL_SetError("Passed a NULL mutex");
|
||||
return -1;
|
||||
}
|
||||
|
||||
this_thread = SDL_ThreadID();
|
||||
if (mutex->owner == this_thread) {
|
||||
++mutex->recursive;
|
||||
} else {
|
||||
/* The order of operations is important.
|
||||
We set the locking thread id after we obtain the lock
|
||||
so unlocks from other threads will fail.
|
||||
*/
|
||||
SDL_SemWait(mutex->sem);
|
||||
mutex->owner = this_thread;
|
||||
mutex->recursive = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif /* DISABLE_THREADS */
|
||||
}
|
||||
|
||||
/* Unlock the mutex */
|
||||
int
|
||||
SDL_mutexV(SDL_mutex * mutex)
|
||||
{
|
||||
#ifdef DISABLE_THREADS
|
||||
return 0;
|
||||
#else
|
||||
if (mutex == NULL) {
|
||||
SDL_SetError("Passed a NULL mutex");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If we don't own the mutex, we can't unlock it */
|
||||
if (SDL_ThreadID() != mutex->owner) {
|
||||
SDL_SetError("mutex not owned by this thread");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mutex->recursive) {
|
||||
--mutex->recursive;
|
||||
} else {
|
||||
/* The order of operations is important.
|
||||
First reset the owner so another thread doesn't lock
|
||||
the mutex and set the ownership before we reset it,
|
||||
then release the lock semaphore.
|
||||
*/
|
||||
mutex->owner = 0;
|
||||
SDL_SemPost(mutex->sem);
|
||||
}
|
||||
return 0;
|
||||
#endif /* DISABLE_THREADS */
|
||||
}
|
26
src/thread/nds/SDL_sysmutex_c.h
Normal file
26
src/thread/nds/SDL_sysmutex_c.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
#ifdef SAVE_RCSID
|
||||
static char rcsid =
|
||||
"@(#) $Id: SDL_sysmutex_c.h,v 1.2 2001/04/26 16:50:18 hercules Exp $";
|
||||
#endif
|
228
src/thread/nds/SDL_syssem.c
Normal file
228
src/thread/nds/SDL_syssem.c
Normal file
|
@ -0,0 +1,228 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
#ifdef SAVE_RCSID
|
||||
static char rcsid =
|
||||
"@(#) $Id: SDL_syssem.c,v 1.2 2001/04/26 16:50:18 hercules Exp $";
|
||||
#endif
|
||||
|
||||
/* An implementation of semaphores using mutexes and condition variables */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_thread.h"
|
||||
#include "SDL_systhread_c.h"
|
||||
|
||||
|
||||
#ifdef DISABLE_THREADS
|
||||
|
||||
SDL_sem *
|
||||
SDL_CreateSemaphore(Uint32 initial_value)
|
||||
{
|
||||
SDL_SetError("SDL not configured with thread support");
|
||||
return (SDL_sem *) 0;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_DestroySemaphore(SDL_sem * sem)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SemTryWait(SDL_sem * sem)
|
||||
{
|
||||
SDL_SetError("SDL not configured with thread support");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
|
||||
{
|
||||
SDL_SetError("SDL not configured with thread support");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SemWait(SDL_sem * sem)
|
||||
{
|
||||
SDL_SetError("SDL not configured with thread support");
|
||||
return -1;
|
||||
}
|
||||
|
||||
Uint32
|
||||
SDL_SemValue(SDL_sem * sem)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SemPost(SDL_sem * sem)
|
||||
{
|
||||
SDL_SetError("SDL not configured with thread support");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
struct SDL_semaphore
|
||||
{
|
||||
Uint32 count;
|
||||
Uint32 waiters_count;
|
||||
SDL_mutex *count_lock;
|
||||
SDL_cond *count_nonzero;
|
||||
};
|
||||
|
||||
SDL_sem *
|
||||
SDL_CreateSemaphore(Uint32 initial_value)
|
||||
{
|
||||
SDL_sem *sem;
|
||||
|
||||
sem = (SDL_sem *) malloc(sizeof(*sem));
|
||||
if (!sem) {
|
||||
SDL_OutOfMemory();
|
||||
return (0);
|
||||
}
|
||||
sem->count = initial_value;
|
||||
sem->waiters_count = 0;
|
||||
|
||||
sem->count_lock = SDL_CreateMutex();
|
||||
sem->count_nonzero = SDL_CreateCond();
|
||||
if (!sem->count_lock || !sem->count_nonzero) {
|
||||
SDL_DestroySemaphore(sem);
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (sem);
|
||||
}
|
||||
|
||||
/* WARNING:
|
||||
You cannot call this function when another thread is using the semaphore.
|
||||
*/
|
||||
void
|
||||
SDL_DestroySemaphore(SDL_sem * sem)
|
||||
{
|
||||
if (sem) {
|
||||
sem->count = 0xFFFFFFFF;
|
||||
while (sem->waiters_count > 0) {
|
||||
SDL_CondSignal(sem->count_nonzero);
|
||||
SDL_Delay(10);
|
||||
}
|
||||
SDL_DestroyCond(sem->count_nonzero);
|
||||
SDL_mutexP(sem->count_lock);
|
||||
SDL_mutexV(sem->count_lock);
|
||||
SDL_DestroyMutex(sem->count_lock);
|
||||
free(sem);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SemTryWait(SDL_sem * sem)
|
||||
{
|
||||
int retval;
|
||||
|
||||
if (!sem) {
|
||||
SDL_SetError("Passed a NULL semaphore");
|
||||
return -1;
|
||||
}
|
||||
|
||||
retval = SDL_MUTEX_TIMEDOUT;
|
||||
SDL_LockMutex(sem->count_lock);
|
||||
if (sem->count > 0) {
|
||||
--sem->count;
|
||||
retval = 0;
|
||||
}
|
||||
SDL_UnlockMutex(sem->count_lock);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
|
||||
{
|
||||
int retval;
|
||||
|
||||
if (!sem) {
|
||||
SDL_SetError("Passed a NULL semaphore");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* A timeout of 0 is an easy case */
|
||||
if (timeout == 0) {
|
||||
return SDL_SemTryWait(sem);
|
||||
}
|
||||
|
||||
SDL_LockMutex(sem->count_lock);
|
||||
++sem->waiters_count;
|
||||
retval = 0;
|
||||
while ((sem->count == 0) && (retval != SDL_MUTEX_TIMEDOUT)) {
|
||||
retval = SDL_CondWaitTimeout(sem->count_nonzero,
|
||||
sem->count_lock, timeout);
|
||||
}
|
||||
--sem->waiters_count;
|
||||
--sem->count;
|
||||
SDL_UnlockMutex(sem->count_lock);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SemWait(SDL_sem * sem)
|
||||
{
|
||||
return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT);
|
||||
}
|
||||
|
||||
Uint32
|
||||
SDL_SemValue(SDL_sem * sem)
|
||||
{
|
||||
Uint32 value;
|
||||
|
||||
value = 0;
|
||||
if (sem) {
|
||||
SDL_LockMutex(sem->count_lock);
|
||||
value = sem->count;
|
||||
SDL_UnlockMutex(sem->count_lock);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SemPost(SDL_sem * sem)
|
||||
{
|
||||
if (!sem) {
|
||||
SDL_SetError("Passed a NULL semaphore");
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_LockMutex(sem->count_lock);
|
||||
if (sem->waiters_count > 0) {
|
||||
SDL_CondSignal(sem->count_nonzero);
|
||||
}
|
||||
++sem->count;
|
||||
SDL_UnlockMutex(sem->count_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* DISABLE_THREADS */
|
26
src/thread/nds/SDL_syssem_c.h
Normal file
26
src/thread/nds/SDL_syssem_c.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
#ifdef SAVE_RCSID
|
||||
static char rcsid =
|
||||
"@(#) $Id: SDL_syssem_c.h,v 1.2 2001/04/26 16:50:18 hercules Exp $";
|
||||
#endif
|
63
src/thread/nds/SDL_systhread.c
Normal file
63
src/thread/nds/SDL_systhread.c
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
#ifdef SAVE_RCSID
|
||||
static char rcsid =
|
||||
"@(#) $Id: SDL_systhread.c,v 1.2 2001/04/26 16:50:18 hercules Exp $";
|
||||
#endif
|
||||
|
||||
/* Thread management routines for SDL */
|
||||
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_thread.h"
|
||||
#include "SDL_systhread.h"
|
||||
|
||||
int
|
||||
SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
|
||||
{
|
||||
SDL_SetError("Threads are not supported on this platform");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SYS_SetupThread(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Uint32
|
||||
SDL_ThreadID(void)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SYS_WaitThread(SDL_Thread * thread)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SYS_KillThread(SDL_Thread * thread)
|
||||
{
|
||||
return;
|
||||
}
|
28
src/thread/nds/SDL_systhread_c.h
Normal file
28
src/thread/nds/SDL_systhread_c.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
/* Stub until we implement threads on this platform */
|
||||
typedef int SYS_ThreadHandle;
|
||||
|
||||
#ifndef DISABLE_THREADS
|
||||
#define DISABLE_THREADS
|
||||
#endif
|
|
@ -125,8 +125,7 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
|
|||
break;
|
||||
}
|
||||
SDL_Delay(1);
|
||||
}
|
||||
while (SDL_GetTicks() < timeout);
|
||||
} while (SDL_GetTicks() < timeout);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
|
|
@ -177,8 +177,7 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
|
|||
break;
|
||||
}
|
||||
SDL_Delay(1);
|
||||
}
|
||||
while (SDL_GetTicks() < timeout);
|
||||
} while (SDL_GetTicks() < timeout);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
|
120
src/timer/nds/SDL_systimer.c
Normal file
120
src/timer/nds/SDL_systimer.c
Normal file
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 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"
|
||||
|
||||
#ifdef SDL_TIMER_NDS
|
||||
|
||||
#include <nds.h>
|
||||
#include <nds/timers.h>
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "../SDL_timer_c.h"
|
||||
#include "../SDL_systimer.h"
|
||||
|
||||
/* Data to handle a single periodic alarm */
|
||||
static int timer_alive = 0;
|
||||
static Uint32 timer_ticks;
|
||||
|
||||
void
|
||||
SDL_StartTicks(void)
|
||||
{
|
||||
if (!timer_alive) {
|
||||
SDL_SYS_TimerInit();
|
||||
SDL_SYS_StartTimer();
|
||||
}
|
||||
|
||||
timer_ticks = 0;
|
||||
}
|
||||
|
||||
Uint32
|
||||
SDL_GetTicks(void)
|
||||
{
|
||||
return timer_ticks;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_Delay(Uint32 ms)
|
||||
{
|
||||
Uint32 start = SDL_GetTicks();
|
||||
while (timer_alive) {
|
||||
if ((SDL_GetTicks() - start) >= ms)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
RunTimer(void *unused)
|
||||
{
|
||||
while (timer_alive) {
|
||||
if (SDL_timer_running) {
|
||||
}
|
||||
SDL_Delay(1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
NDS_TimerInterrupt(void)
|
||||
{
|
||||
timer_ticks++;
|
||||
}
|
||||
|
||||
/* This is only called if the event thread is not running */
|
||||
int
|
||||
SDL_SYS_TimerInit(void)
|
||||
{
|
||||
timer_alive = 1;
|
||||
timer_ticks = 0;
|
||||
TIMER_CR(3) = TIMER_DIV_1024 | TIMER_IRQ_REQ;
|
||||
TIMER_DATA(3) = TIMER_FREQ_1024(1000);
|
||||
irqSet(IRQ_TIMER3, NDS_TimerInterrupt);
|
||||
irqEnable(IRQ_TIMER3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SYS_TimerQuit(void)
|
||||
{
|
||||
if (timer_alive) {
|
||||
TIMER_CR(3) = 0;
|
||||
}
|
||||
timer_alive = 0;
|
||||
irqDisable(IRQ_TIMER3);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SYS_StartTimer(void)
|
||||
{
|
||||
TIMER_CR(3) |= TIMER_ENABLE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SYS_StopTimer(void)
|
||||
{
|
||||
TIMER_CR(3) &= ~TIMER_ENABLE;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#endif /* SDL_TIMER_NDS */
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -130,8 +130,7 @@ SDL_Delay(Uint32 ms)
|
|||
pthread_yield();
|
||||
#endif
|
||||
|
||||
}
|
||||
while (1);
|
||||
} while (1);
|
||||
}
|
||||
|
||||
#if SDL_THREADS_DISABLED
|
||||
|
|
|
@ -137,8 +137,7 @@ SDL_Delay(Uint32 ms)
|
|||
|
||||
was_error = select(0, NULL, NULL, NULL, &tv);
|
||||
#endif /* HAVE_NANOSLEEP */
|
||||
}
|
||||
while (was_error && (errno == EINTR));
|
||||
} while (was_error && (errno == EINTR));
|
||||
#endif /* SDL_THREAD_PTH */
|
||||
}
|
||||
|
||||
|
|
|
@ -1154,8 +1154,7 @@ SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect,
|
|||
ofs += run;
|
||||
} else if (!ofs)
|
||||
goto done;
|
||||
}
|
||||
while (ofs < w);
|
||||
} while (ofs < w);
|
||||
|
||||
/* skip padding */
|
||||
srcbuf += (uintptr_t) srcbuf & 2;
|
||||
|
@ -1168,10 +1167,8 @@ SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect,
|
|||
run = ((Uint16 *) srcbuf)[1];
|
||||
srcbuf += 4 * (run + 1);
|
||||
ofs += run;
|
||||
}
|
||||
while (ofs < w);
|
||||
}
|
||||
while (--vskip);
|
||||
} while (ofs < w);
|
||||
} while (--vskip);
|
||||
} else {
|
||||
/* the 32/32 interleaved format */
|
||||
vskip <<= 1; /* opaque and translucent have same format */
|
||||
|
@ -1187,10 +1184,8 @@ SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect,
|
|||
ofs += run;
|
||||
} else if (!ofs)
|
||||
goto done;
|
||||
}
|
||||
while (ofs < w);
|
||||
}
|
||||
while (--vskip);
|
||||
} while (ofs < w);
|
||||
} while (--vskip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1567,8 +1562,7 @@ RLEAlphaSurface(SDL_Surface * surface)
|
|||
runstart += len;
|
||||
run -= len;
|
||||
}
|
||||
}
|
||||
while (x < w);
|
||||
} while (x < w);
|
||||
|
||||
/* Make sure the next output address is 32-bit aligned */
|
||||
dst += (uintptr_t) dst & 2;
|
||||
|
@ -1604,8 +1598,7 @@ RLEAlphaSurface(SDL_Surface * surface)
|
|||
}
|
||||
if (!blankline)
|
||||
lastline = dst;
|
||||
}
|
||||
while (x < w);
|
||||
} while (x < w);
|
||||
|
||||
src += surface->pitch >> 2;
|
||||
}
|
||||
|
@ -1771,8 +1764,7 @@ RLEColorkeySurface(SDL_Surface * surface)
|
|||
}
|
||||
if (!blankline)
|
||||
lastline = dst;
|
||||
}
|
||||
while (x < w);
|
||||
} while (x < w);
|
||||
|
||||
srcbuf += surface->pitch;
|
||||
}
|
||||
|
@ -1911,8 +1903,7 @@ UnRLEAlpha(SDL_Surface * surface)
|
|||
ofs += run;
|
||||
} else if (!ofs)
|
||||
return (SDL_TRUE);
|
||||
}
|
||||
while (ofs < w);
|
||||
} while (ofs < w);
|
||||
|
||||
/* skip padding if needed */
|
||||
if (bpp == 2)
|
||||
|
@ -1929,8 +1920,7 @@ UnRLEAlpha(SDL_Surface * surface)
|
|||
srcbuf += uncopy_transl(dst + ofs, srcbuf, run, df, sf);
|
||||
ofs += run;
|
||||
}
|
||||
}
|
||||
while (ofs < w);
|
||||
} while (ofs < w);
|
||||
dst += surface->pitch >> 2;
|
||||
}
|
||||
/* Make the compiler happy */
|
||||
|
|
|
@ -80,6 +80,7 @@ BlitBto1(SDL_BlitInfo * info)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
BlitBto2(SDL_BlitInfo * info)
|
||||
{
|
||||
|
@ -116,6 +117,7 @@ BlitBto2(SDL_BlitInfo * info)
|
|||
dst += dstskip;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
BlitBto3(SDL_BlitInfo * info)
|
||||
{
|
||||
|
@ -154,6 +156,7 @@ BlitBto3(SDL_BlitInfo * info)
|
|||
dst += dstskip;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
BlitBto4(SDL_BlitInfo * info)
|
||||
{
|
||||
|
|
|
@ -184,6 +184,7 @@ Blit1to2(SDL_BlitInfo * info)
|
|||
}
|
||||
#endif /* USE_DUFFS_LOOP */
|
||||
}
|
||||
|
||||
static void
|
||||
Blit1to3(SDL_BlitInfo * info)
|
||||
{
|
||||
|
@ -232,6 +233,7 @@ Blit1to3(SDL_BlitInfo * info)
|
|||
dst += dstskip;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Blit1to4(SDL_BlitInfo * info)
|
||||
{
|
||||
|
|
|
@ -283,8 +283,8 @@ BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo * info)
|
|||
amult = alpha | (alpha << 8);
|
||||
amult = amult | (amult << 16);
|
||||
chanmask =
|
||||
(0xff << df->Rshift) | (0xff << df->Gshift) | (0xff << df->
|
||||
Bshift);
|
||||
(0xff << df->Rshift) | (0xff << df->
|
||||
Gshift) | (0xff << df->Bshift);
|
||||
mm_alpha = _mm_set_pi32(0, amult & chanmask); /* 0000AAAA -> mm_alpha, minus 1 chan */
|
||||
mm_alpha = _mm_unpacklo_pi8(mm_alpha, mm_zero); /* 0A0A0A0A -> mm_alpha, minus 1 chan */
|
||||
/* at this point mm_alpha can be 000A0A0A or 0A0A0A00 or another combo */
|
||||
|
@ -526,8 +526,8 @@ calc_swizzle32(const SDL_PixelFormat * srcfmt, const SDL_PixelFormat * dstfmt)
|
|||
/* Use zero for alpha if either surface doesn't have alpha */
|
||||
if (dstfmt->Amask) {
|
||||
amask =
|
||||
((srcfmt->Amask) ? RESHIFT(srcfmt->Ashift) : 0x10) << (dstfmt->
|
||||
Ashift);
|
||||
((srcfmt->Amask) ? RESHIFT(srcfmt->
|
||||
Ashift) : 0x10) << (dstfmt->Ashift);
|
||||
} else {
|
||||
amask =
|
||||
0x10101010 & ((dstfmt->Rmask | dstfmt->Gmask | dstfmt->Bmask) ^
|
||||
|
|
|
@ -141,8 +141,8 @@ calc_swizzle32(const SDL_PixelFormat * srcfmt, const SDL_PixelFormat * dstfmt)
|
|||
/* Use zero for alpha if either surface doesn't have alpha */
|
||||
if (dstfmt->Amask) {
|
||||
amask =
|
||||
((srcfmt->Amask) ? RESHIFT(srcfmt->Ashift) : 0x10) << (dstfmt->
|
||||
Ashift);
|
||||
((srcfmt->Amask) ? RESHIFT(srcfmt->
|
||||
Ashift) : 0x10) << (dstfmt->Ashift);
|
||||
} else {
|
||||
amask =
|
||||
0x10101010 & ((dstfmt->Rmask | dstfmt->Gmask | dstfmt->Bmask) ^
|
||||
|
@ -1435,6 +1435,7 @@ static const Uint32 RGB565_ARGB8888_LUT[512] = {
|
|||
0x00001ce6, 0xffff8100, 0x00001cee, 0xffffa100,
|
||||
0x00001cf6, 0xffffc200, 0x00001cff, 0xffffe200
|
||||
};
|
||||
|
||||
static void
|
||||
Blit_RGB565_ARGB8888(SDL_BlitInfo * info)
|
||||
{
|
||||
|
@ -1572,6 +1573,7 @@ static const Uint32 RGB565_ABGR8888_LUT[512] = {
|
|||
0xffe61c00, 0x000081ff, 0xffee1c00, 0x0000a1ff,
|
||||
0xfff61c00, 0x0000c2ff, 0xffff1c00, 0x0000e2ff
|
||||
};
|
||||
|
||||
static void
|
||||
Blit_RGB565_ABGR8888(SDL_BlitInfo * info)
|
||||
{
|
||||
|
@ -1709,6 +1711,7 @@ static const Uint32 RGB565_RGBA8888_LUT[512] = {
|
|||
0x001ce6ff, 0xff810000, 0x001ceeff, 0xffa10000,
|
||||
0x001cf6ff, 0xffc20000, 0x001cffff, 0xffe20000,
|
||||
};
|
||||
|
||||
static void
|
||||
Blit_RGB565_RGBA8888(SDL_BlitInfo * info)
|
||||
{
|
||||
|
@ -1846,6 +1849,7 @@ static const Uint32 RGB565_BGRA8888_LUT[512] = {
|
|||
0xe61c0000, 0x0081ffff, 0xee1c0000, 0x00a1ffff,
|
||||
0xf61c0000, 0x00c2ffff, 0xff1c0000, 0x00e2ffff
|
||||
};
|
||||
|
||||
static void
|
||||
Blit_RGB565_BGRA8888(SDL_BlitInfo * info)
|
||||
{
|
||||
|
@ -1930,6 +1934,7 @@ Blit_RGB888_index8_map(SDL_BlitInfo * info)
|
|||
}
|
||||
#endif /* USE_DUFFS_LOOP */
|
||||
}
|
||||
|
||||
static void
|
||||
BlitNto1(SDL_BlitInfo * info)
|
||||
{
|
||||
|
@ -2340,6 +2345,7 @@ static const struct blit_table normal_blit_1[] = {
|
|||
/* Default for 8-bit RGB source, an invalid combination */
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, NULL},
|
||||
};
|
||||
|
||||
static const struct blit_table normal_blit_2[] = {
|
||||
#if SDL_ALTIVEC_BLITTERS
|
||||
/* has-altivec */
|
||||
|
@ -2366,10 +2372,12 @@ static const struct blit_table normal_blit_2[] = {
|
|||
/* Default for 16-bit RGB source, used if no other blitter matches */
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0}
|
||||
};
|
||||
|
||||
static const struct blit_table normal_blit_3[] = {
|
||||
/* Default for 24-bit RGB source, never optimized */
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0}
|
||||
};
|
||||
|
||||
static const struct blit_table normal_blit_4[] = {
|
||||
#if SDL_ALTIVEC_BLITTERS
|
||||
/* has-altivec | dont-use-prefetch */
|
||||
|
@ -2396,6 +2404,7 @@ static const struct blit_table normal_blit_4[] = {
|
|||
/* Default for 32-bit RGB source, used if no other blitter matches */
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0}
|
||||
};
|
||||
|
||||
static const struct blit_table *normal_blit[] = {
|
||||
normal_blit_1, normal_blit_2, normal_blit_3, normal_blit_4
|
||||
};
|
||||
|
|
|
@ -70,6 +70,7 @@ CalculateGammaRamp(float gamma, Uint16 * ramp)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
CalculateGammaFromRamp(float *gamma, Uint16 * ramp)
|
||||
{
|
||||
|
|
|
@ -168,12 +168,16 @@ SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask,
|
|||
break;
|
||||
case 15:
|
||||
switch (Rmask) {
|
||||
case 0x001F:
|
||||
return SDL_PIXELFORMAT_BGR555;
|
||||
case 0x7C00:
|
||||
return SDL_PIXELFORMAT_RGB555;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
switch (Rmask) {
|
||||
case 0x001F:
|
||||
return SDL_PIXELFORMAT_ABGR1555;
|
||||
case 0x0F00:
|
||||
return SDL_PIXELFORMAT_ARGB4444;
|
||||
case 0x7C00:
|
||||
|
@ -748,6 +752,7 @@ SDL_InvalidateMap(SDL_BlitMap * map)
|
|||
map->info.table = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst)
|
||||
{
|
||||
|
|
|
@ -388,8 +388,9 @@ SW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
void **pixels, int *pitch)
|
||||
{
|
||||
if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
|
||||
return SDL_SW_QueryYUVTexturePixels((SDL_SW_YUVTexture *) texture->
|
||||
driverdata, pixels, pitch);
|
||||
return SDL_SW_QueryYUVTexturePixels((SDL_SW_YUVTexture *)
|
||||
texture->driverdata, pixels,
|
||||
pitch);
|
||||
} else {
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
|
||||
|
@ -464,8 +465,9 @@ SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
const SDL_Rect * rect, const void *pixels, int pitch)
|
||||
{
|
||||
if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
|
||||
return SDL_SW_UpdateYUVTexture((SDL_SW_YUVTexture *) texture->
|
||||
driverdata, rect, pixels, pitch);
|
||||
return SDL_SW_UpdateYUVTexture((SDL_SW_YUVTexture *)
|
||||
texture->driverdata, rect, pixels,
|
||||
pitch);
|
||||
} else {
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
Uint8 *src, *dst;
|
||||
|
@ -492,9 +494,9 @@ SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
int *pitch)
|
||||
{
|
||||
if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
|
||||
return SDL_SW_LockYUVTexture((SDL_SW_YUVTexture *) texture->
|
||||
driverdata, rect, markDirty, pixels,
|
||||
pitch);
|
||||
return SDL_SW_LockYUVTexture((SDL_SW_YUVTexture *)
|
||||
texture->driverdata, rect, markDirty,
|
||||
pixels, pitch);
|
||||
} else {
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
|
||||
|
@ -535,8 +537,8 @@ SW_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
|
|||
|
||||
color = SDL_MapRGBA(data->surface.format, r, g, b, a);
|
||||
|
||||
if (data->renderer->
|
||||
LockTexture(data->renderer, data->texture[data->current_texture],
|
||||
if (data->renderer->LockTexture(data->renderer,
|
||||
data->texture[data->current_texture],
|
||||
rect, 1, &data->surface.pixels,
|
||||
&data->surface.pitch) < 0) {
|
||||
return -1;
|
||||
|
@ -566,8 +568,8 @@ SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
SDL_AddDirtyRect(&data->dirty, dstrect);
|
||||
}
|
||||
|
||||
if (data->renderer->
|
||||
LockTexture(data->renderer, data->texture[data->current_texture],
|
||||
if (data->renderer->LockTexture(data->renderer,
|
||||
data->texture[data->current_texture],
|
||||
dstrect, 1, &data->surface.pixels,
|
||||
&data->surface.pitch) < 0) {
|
||||
return -1;
|
||||
|
|
|
@ -409,8 +409,8 @@ SDL_GetSurfaceBlendMode(SDL_Surface * surface, int *blendMode)
|
|||
return 0;
|
||||
}
|
||||
|
||||
switch (surface->map->info.
|
||||
flags & (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD |
|
||||
switch (surface->map->
|
||||
info.flags & (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD |
|
||||
SDL_COPY_MOD)) {
|
||||
case SDL_COPY_MASK:
|
||||
*blendMode = SDL_TEXTUREBLENDMODE_MASK;
|
||||
|
|
|
@ -369,6 +369,9 @@ extern VideoBootStrap OS2FSLib_bootstrap;
|
|||
#if SDL_VIDEO_DRIVER_DUMMY
|
||||
extern VideoBootStrap DUMMY_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_NDS
|
||||
extern VideoBootStrap NDS_bootstrap;
|
||||
#endif
|
||||
|
||||
#define SDL_CurrentDisplay (_this->displays[_this->current_display])
|
||||
|
||||
|
|
|
@ -103,6 +103,9 @@ static VideoBootStrap *bootstrap[] = {
|
|||
#if SDL_VIDEO_DRIVER_OS2FS
|
||||
&OS2FSLib_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_NDS
|
||||
&NDS_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_DUMMY
|
||||
&DUMMY_bootstrap,
|
||||
#endif
|
||||
|
|
|
@ -349,8 +349,8 @@ SDL_AtariGL_MakeCurrent(_THIS)
|
|||
}
|
||||
|
||||
if (!
|
||||
(_this->gl_data->
|
||||
OSMesaMakeCurrent(gl_ctx, surface->pixels, type, surface->w,
|
||||
(_this->
|
||||
gl_data->OSMesaMakeCurrent(gl_ctx, surface->pixels, type, surface->w,
|
||||
surface->h))) {
|
||||
SDL_SetError("Can not make OpenGL context current");
|
||||
return -1;
|
||||
|
@ -512,10 +512,10 @@ InitNew(_THIS, SDL_Surface * current)
|
|||
|
||||
gl_ctx =
|
||||
_this->gl_data->OSMesaCreateContextExt(osmesa_format,
|
||||
_this->gl_config.
|
||||
depth_size,
|
||||
_this->gl_config.
|
||||
stencil_size,
|
||||
_this->
|
||||
gl_config.depth_size,
|
||||
_this->
|
||||
gl_config.stencil_size,
|
||||
newaccumsize, NULL);
|
||||
|
||||
if (gl_ctx) {
|
||||
|
|
|
@ -670,8 +670,8 @@ extern "C"
|
|||
_this->gl_config.driver_loaded = 1;
|
||||
SDL_strlcpy(_this->gl_config.driver_path,
|
||||
"libGL.so",
|
||||
SDL_arraysize(_this->gl_config.
|
||||
driver_path));
|
||||
SDL_arraysize(_this->
|
||||
gl_config.driver_path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,8 +135,7 @@ keyboard_update(void)
|
|||
for (i = 0; i < sizeof(sdl_shift); i++) {
|
||||
if ((shiftkeys >> i) & 1) {
|
||||
keysym.sym = sdl_shift[i];
|
||||
SDL_PrivateKeyboard(((state->
|
||||
shift_keys >> i) & 1) ? SDL_PRESSED :
|
||||
SDL_PrivateKeyboard(((state->shift_keys >> i) & 1) ? SDL_PRESSED :
|
||||
SDL_RELEASED, &keysym);
|
||||
}
|
||||
}
|
||||
|
@ -146,8 +145,7 @@ keyboard_update(void)
|
|||
int key = sdl_key[i];
|
||||
if (key) {
|
||||
keysym.sym = key;
|
||||
SDL_PrivateKeyboard(state->
|
||||
matrix[i] ? SDL_PRESSED :
|
||||
SDL_PrivateKeyboard(state->matrix[i] ? SDL_PRESSED :
|
||||
SDL_RELEASED, &keysym);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,6 +158,7 @@ DC_VideoInit(_THIS, SDL_PixelFormat * vformat)
|
|||
const static SDL_Rect RECT_800x600 = { 0, 0, 800, 600 }, RECT_640x480 = {
|
||||
0, 0, 640, 480}, RECT_320x240 = {
|
||||
0, 0, 320, 240};
|
||||
|
||||
const static SDL_Rect *vid_modes[] = {
|
||||
&RECT_800x600,
|
||||
&RECT_640x480,
|
||||
|
@ -296,6 +297,7 @@ DC_AllocHWSurface(_THIS, SDL_Surface * surface)
|
|||
{
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static void
|
||||
DC_FreeHWSurface(_THIS, SDL_Surface * surface)
|
||||
{
|
||||
|
|
|
@ -383,33 +383,25 @@ DirectFB_PumpEvents(_THIS)
|
|||
switch (evt.type) {
|
||||
case DIET_BUTTONPRESS:
|
||||
posted += SDL_PrivateMouseButton(SDL_PRESSED,
|
||||
DirectFB_TranslateButton(evt.
|
||||
button),
|
||||
0, 0);
|
||||
DirectFB_TranslateButton
|
||||
(evt.button), 0, 0);
|
||||
break;
|
||||
case DIET_BUTTONRELEASE:
|
||||
posted += SDL_PrivateMouseButton(SDL_RELEASED,
|
||||
DirectFB_TranslateButton(evt.
|
||||
button),
|
||||
0, 0);
|
||||
DirectFB_TranslateButton
|
||||
(evt.button), 0, 0);
|
||||
break;
|
||||
case DIET_KEYPRESS:
|
||||
posted += SDL_PrivateKeyboard(SDL_PRESSED,
|
||||
DirectFB_TranslateKey(evt.
|
||||
key_id,
|
||||
evt.
|
||||
key_symbol,
|
||||
mod,
|
||||
&keysym));
|
||||
DirectFB_TranslateKey
|
||||
(evt.key_id, evt.key_symbol,
|
||||
mod, &keysym));
|
||||
break;
|
||||
case DIET_KEYRELEASE:
|
||||
posted += SDL_PrivateKeyboard(SDL_RELEASED,
|
||||
DirectFB_TranslateKey(evt.
|
||||
key_id,
|
||||
evt.
|
||||
key_symbol,
|
||||
mod,
|
||||
&keysym));
|
||||
DirectFB_TranslateKey
|
||||
(evt.key_id, evt.key_symbol,
|
||||
mod, &keysym));
|
||||
break;
|
||||
case DIET_AXISMOTION:
|
||||
if (evt.flags & DIEF_AXISREL) {
|
||||
|
|
|
@ -85,14 +85,15 @@ DirectFB_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
|||
dsc.height = surface->h;
|
||||
dsc.pixelformat = DSPF_ARGB;
|
||||
|
||||
SDL_DFB_CHECKERR(devdata->dfb->
|
||||
CreateSurface(devdata->dfb, &dsc, &curdata->surf));
|
||||
SDL_DFB_CHECKERR(devdata->
|
||||
dfb->CreateSurface(devdata->dfb, &dsc, &curdata->surf));
|
||||
curdata->hotx = hot_x;
|
||||
curdata->hoty = hot_y;
|
||||
cursor->driverdata = curdata;
|
||||
|
||||
SDL_DFB_CHECKERR(curdata->surf->
|
||||
Lock(curdata->surf, DSLF_WRITE, (void *) &dest, &pitch));
|
||||
SDL_DFB_CHECKERR(curdata->
|
||||
surf->Lock(curdata->surf, DSLF_WRITE, (void *) &dest,
|
||||
&pitch));
|
||||
|
||||
//FIXME: Implies a lot of things, e.g. rgba format for SDL_SURFACE ....
|
||||
p = surface->pixels;
|
||||
|
@ -131,18 +132,18 @@ DirectFB_ShowCursor(SDL_Cursor * cursor)
|
|||
DFB_WindowData *windata = (DFB_WindowData *) window->driverdata;
|
||||
|
||||
if (cursor)
|
||||
SDL_DFB_CHECKERR(windata->window->
|
||||
SetCursorShape(windata->window, curdata->surf,
|
||||
curdata->hotx, curdata->hoty));
|
||||
SDL_DFB_CHECKERR(windata->window->SetCursorShape(windata->window,
|
||||
curdata->surf,
|
||||
curdata->hotx,
|
||||
curdata->hoty));
|
||||
//TODO: Check administrative
|
||||
SDL_DFB_CHECKERR(dispdata->layer->
|
||||
SetCooperativeLevel(dispdata->layer,
|
||||
SDL_DFB_CHECKERR(dispdata->layer->SetCooperativeLevel(dispdata->layer,
|
||||
DLSCL_ADMINISTRATIVE));
|
||||
SDL_DFB_CHECKERR(dispdata->layer->
|
||||
SetCursorOpacity(dispdata->layer,
|
||||
cursor ? 0xC0 : 0x00));
|
||||
SDL_DFB_CHECKERR(dispdata->layer->
|
||||
SetCooperativeLevel(dispdata->layer, DLSCL_SHARED));
|
||||
SDL_DFB_CHECKERR(dispdata->layer->SetCursorOpacity(dispdata->layer,
|
||||
cursor ? 0xC0 :
|
||||
0x00));
|
||||
SDL_DFB_CHECKERR(dispdata->layer->SetCooperativeLevel(dispdata->layer,
|
||||
DLSCL_SHARED));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -181,8 +182,8 @@ DirectFB_WarpMouse(SDL_Mouse * mouse, SDL_WindowID windowID, int x, int y)
|
|||
int cx, cy;
|
||||
|
||||
SDL_DFB_CHECKERR(windata->window->GetPosition(windata->window, &cx, &cy));
|
||||
SDL_DFB_CHECKERR(dispdata->layer->
|
||||
WarpCursor(dispdata->layer, cx + x, cy + y));
|
||||
SDL_DFB_CHECKERR(dispdata->
|
||||
layer->WarpCursor(dispdata->layer, cx + x, cy + y));
|
||||
|
||||
error:
|
||||
return;
|
||||
|
|
|
@ -314,8 +314,8 @@ DirectFB_VideoInit(_THIS)
|
|||
SDL_DFB_CHECKERR(dfb->GetScreen(dfb, devdata->screenid[i], &screen));
|
||||
|
||||
devdata->aux = i;
|
||||
SDL_DFB_CHECKERR(screen->
|
||||
EnumDisplayLayers(screen, &cbLayers, devdata));
|
||||
SDL_DFB_CHECKERR(screen->EnumDisplayLayers
|
||||
(screen, &cbLayers, devdata));
|
||||
#if (DIRECTFB_MAJOR_VERSION >= 1)
|
||||
screen->GetSize(screen, &tcw[i], &tch[i]);
|
||||
#else
|
||||
|
@ -338,12 +338,12 @@ DirectFB_VideoInit(_THIS)
|
|||
|
||||
for (i = 0; i < devdata->numscreens; i++) {
|
||||
//SDL_DFB_CHECKERR( dfb->GetDisplayLayer (dfb, DLID_PRIMARY, &layer) );
|
||||
SDL_DFB_CHECKERR(dfb->
|
||||
GetDisplayLayer(dfb, devdata->gralayer[i], &layer));
|
||||
SDL_DFB_CHECKERR(dfb->GetDisplayLayer
|
||||
(dfb, devdata->gralayer[i], &layer));
|
||||
//SDL_DFB_CHECKERR( dfb->CreateInputEventBuffer (dfb, DICAPS_ALL, DFB_FALSE, &events) );
|
||||
|
||||
SDL_DFB_CHECKERR(layer->
|
||||
SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE));
|
||||
SDL_DFB_CHECKERR(layer->SetCooperativeLevel
|
||||
(layer, DLSCL_ADMINISTRATIVE));
|
||||
layer->EnableCursor(layer, 1);
|
||||
SDL_DFB_CHECKERR(layer->SetCursorOpacity(layer, 0xC0));
|
||||
SDL_DFB_CHECKERR(layer->SetCooperativeLevel(layer, DLSCL_SHARED));
|
||||
|
@ -379,8 +379,8 @@ DirectFB_VideoInit(_THIS)
|
|||
/* Enumerate the available fullscreen modes */
|
||||
SDL_DFB_CALLOC(dispdata->modelist, DFB_MAX_MODES,
|
||||
sizeof(SDL_DisplayMode));
|
||||
SDL_DFB_CHECKERR(dfb->
|
||||
EnumVideoModes(dfb, EnumModesCallback, &display));
|
||||
SDL_DFB_CHECKERR(dfb->EnumVideoModes
|
||||
(dfb, EnumModesCallback, &display));
|
||||
|
||||
SDL_AddVideoDisplay(&display);
|
||||
}
|
||||
|
@ -433,13 +433,14 @@ DirectFB_VideoQuit(_THIS)
|
|||
DFB_DisplayData *dispdata =
|
||||
(DFB_DisplayData *) _this->displays[i].driverdata;
|
||||
if (dispdata->layer) {
|
||||
SDL_DFB_CHECK(dispdata->layer->
|
||||
SetCooperativeLevel(dispdata->layer,
|
||||
SDL_DFB_CHECK(dispdata->
|
||||
layer->SetCooperativeLevel(dispdata->layer,
|
||||
DLSCL_ADMINISTRATIVE));
|
||||
SDL_DFB_CHECK(dispdata->layer->
|
||||
SetCursorOpacity(dispdata->layer, 0x00));
|
||||
SDL_DFB_CHECK(dispdata->layer->
|
||||
SetCooperativeLevel(dispdata->layer, DLSCL_SHARED));
|
||||
SDL_DFB_CHECK(dispdata->
|
||||
layer->SetCursorOpacity(dispdata->layer, 0x00));
|
||||
SDL_DFB_CHECK(dispdata->
|
||||
layer->SetCooperativeLevel(dispdata->layer,
|
||||
DLSCL_SHARED));
|
||||
}
|
||||
SDL_DFB_RELEASE(dispdata->layer);
|
||||
|
||||
|
@ -578,8 +579,8 @@ DirectFB_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
|
|||
DFBResult ret;
|
||||
DFB_WindowData *win;
|
||||
|
||||
SDL_DFB_CHECKERR(data->layer->
|
||||
SetCooperativeLevel(data->layer, DLSCL_ADMINISTRATIVE));
|
||||
SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer,
|
||||
DLSCL_ADMINISTRATIVE));
|
||||
|
||||
SDL_DFB_CHECKERR(data->layer->GetConfiguration(data->layer, &config));
|
||||
config.flags = DLCONF_WIDTH | DLCONF_HEIGHT; // | DLCONF_BUFFERMODE;
|
||||
|
@ -604,8 +605,8 @@ DirectFB_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
|
|||
SDL_DFB_DEBUG("Trace\n");
|
||||
config.flags &= ~fail;
|
||||
SDL_DFB_CHECKERR(data->layer->SetConfiguration(data->layer, &config));
|
||||
SDL_DFB_CHECKERR(data->layer->
|
||||
SetCooperativeLevel(data->layer, DLSCL_ADMINISTRATIVE));
|
||||
SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer,
|
||||
DLSCL_ADMINISTRATIVE));
|
||||
|
||||
/* Double check */
|
||||
SDL_DFB_CHECKERR(data->layer->GetConfiguration(data->layer, &rconfig));
|
||||
|
@ -674,10 +675,10 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
|
|||
SDL_DFB_CALLOC(window->driverdata, 1, sizeof(DFB_WindowData));
|
||||
windata = (DFB_WindowData *) window->driverdata;
|
||||
|
||||
SDL_DFB_CHECKERR(devdata->dfb->
|
||||
SetCooperativeLevel(devdata->dfb, DFSCL_NORMAL));
|
||||
SDL_DFB_CHECKERR(dispdata->layer->
|
||||
SetCooperativeLevel(dispdata->layer,
|
||||
SDL_DFB_CHECKERR(devdata->
|
||||
dfb->SetCooperativeLevel(devdata->dfb, DFSCL_NORMAL));
|
||||
SDL_DFB_CHECKERR(dispdata->
|
||||
layer->SetCooperativeLevel(dispdata->layer,
|
||||
DLSCL_ADMINISTRATIVE));
|
||||
|
||||
/* Fill the window description. */
|
||||
|
@ -725,8 +726,8 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
|
|||
desc.surface_caps = DSCAPS_DOUBLE | DSCAPS_TRIPLE / DSCAPS_PREMULTIPLIED;
|
||||
|
||||
/* Create the window. */
|
||||
SDL_DFB_CHECKERR(dispdata->layer->
|
||||
CreateWindow(dispdata->layer, &desc, &windata->window));
|
||||
SDL_DFB_CHECKERR(dispdata->layer->CreateWindow(dispdata->layer, &desc,
|
||||
&windata->window));
|
||||
|
||||
windata->window->GetOptions(windata->window, &wopts);
|
||||
#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 0)
|
||||
|
@ -744,12 +745,13 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
|
|||
|
||||
windata->window->SetOptions(windata->window, wopts);
|
||||
/* Get the window's surface. */
|
||||
SDL_DFB_CHECKERR(windata->window->
|
||||
GetSurface(windata->window, &windata->surface));
|
||||
SDL_DFB_CHECKERR(windata->
|
||||
window->GetSurface(windata->window, &windata->surface));
|
||||
windata->window->SetOpacity(windata->window, 0xFF);
|
||||
SDL_DFB_CHECKERR(windata->window->
|
||||
CreateEventBuffer(windata->window,
|
||||
&(windata->eventbuffer)));
|
||||
SDL_DFB_CHECKERR(windata->window->CreateEventBuffer(windata->window,
|
||||
&
|
||||
(windata->
|
||||
eventbuffer)));
|
||||
SDL_DFB_CHECKERR(windata->window->
|
||||
EnableEvents(windata->window,
|
||||
DWET_POSITION | DWET_SIZE | DWET_CLOSE |
|
||||
|
@ -812,6 +814,7 @@ DirectFB_SetWindowTitle(_THIS, SDL_Window * window)
|
|||
//return -1;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
DirectFB_SetWindowPosition(_THIS, SDL_Window * window)
|
||||
{
|
||||
|
@ -886,6 +889,7 @@ DirectFB_HideWindow(_THIS, SDL_Window * window)
|
|||
windata->window->SetOpacity(windata->window, 0);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
DirectFB_RaiseWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
|
@ -907,6 +911,7 @@ DirectFB_MaximizeWindow(_THIS, SDL_Window * window)
|
|||
SDL_Unsupported();
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
DirectFB_MinimizeWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
|
@ -928,6 +933,7 @@ DirectFB_RestoreWindow(_THIS, SDL_Window * window)
|
|||
SDL_Unsupported();
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
DirectFB_SetWindowGrab(_THIS, SDL_Window * window)
|
||||
{
|
||||
|
@ -1156,8 +1162,8 @@ DirectFB_GL_SwapWindow(_THIS, SDL_Window * window)
|
|||
devdata->glFlush();
|
||||
|
||||
SDL_DFB_CHECKERR(windata->gl_context->Unlock(windata->gl_context));
|
||||
SDL_DFB_CHECKERR(windata->surface->
|
||||
Flip(windata->surface, ®ion, DSFLIP_ONSYNC));
|
||||
SDL_DFB_CHECKERR(windata->
|
||||
surface->Flip(windata->surface, ®ion, DSFLIP_ONSYNC));
|
||||
SDL_DFB_CHECKERR(windata->gl_context->Lock(windata->gl_context));
|
||||
|
||||
return;
|
||||
|
|
|
@ -37,6 +37,7 @@ WaitVBL(_THIS)
|
|||
/* wait until we're past the start */
|
||||
while ((tdfx_in32(TDFX_STATUS) & STATUS_RETRACE) == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
WaitIdle(_THIS)
|
||||
{
|
||||
|
|
|
@ -268,8 +268,7 @@ eloWaitReply(unsigned char type, unsigned char *reply, int fd)
|
|||
if (result == 0) {
|
||||
i--;
|
||||
}
|
||||
}
|
||||
while (!ok && (i > 0));
|
||||
} while (!ok && (i > 0));
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
|
|
@ -545,8 +545,7 @@ detect_imps2(int fd)
|
|||
if (select(fd + 1, &fdset, 0, 0, &tv) < 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
while ((read(fd, &ch, sizeof(ch)) == sizeof(ch)) &&
|
||||
} while ((read(fd, &ch, sizeof(ch)) == sizeof(ch)) &&
|
||||
((ch == 0xFA) || (ch == 0xAA)));
|
||||
|
||||
/* Experimental values (Logitech wheelmouse) */
|
||||
|
@ -970,6 +969,7 @@ switch_vt_prep(_THIS)
|
|||
ioctl(keyboard_fd, KDSETMODE, KD_TEXT);
|
||||
ioctl(keyboard_fd, VT_UNLOCKSWITCH, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
switch_vt_done(_THIS)
|
||||
{
|
||||
|
@ -995,6 +995,7 @@ switch_vt_done(_THIS)
|
|||
(SDL_APPACTIVE | SDL_APPINPUTFOCUS |
|
||||
SDL_APPMOUSEFOCUS));
|
||||
}
|
||||
|
||||
static void
|
||||
switch_vt(_THIS, unsigned short which)
|
||||
{
|
||||
|
@ -1113,8 +1114,7 @@ FB_PumpEvents(_THIS)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (posted);
|
||||
} while (posted);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -41,6 +41,7 @@ WaitVBL(_THIS)
|
|||
count = mga_in32(0x1E20) + 2;
|
||||
while (mga_in32(0x1E20) < count);
|
||||
}
|
||||
|
||||
static void
|
||||
WaitIdle(_THIS)
|
||||
{
|
||||
|
|
|
@ -40,6 +40,7 @@ WaitVBL(_THIS)
|
|||
while ((*port & 0x08));
|
||||
while (!(*port & 0x08));
|
||||
}
|
||||
|
||||
static void
|
||||
NV3WaitIdle(_THIS)
|
||||
{
|
||||
|
@ -47,6 +48,7 @@ NV3WaitIdle(_THIS)
|
|||
while ((Rop->FifoFree < FifoEmptyCount) ||
|
||||
(*(mapped_io + PGRAPH_OFFSET + 0x000006B0) & 0x01));
|
||||
}
|
||||
|
||||
static void
|
||||
NV4WaitIdle(_THIS)
|
||||
{
|
||||
|
|
|
@ -82,6 +82,7 @@ static const SDL_Rect checkres[] = {
|
|||
{0, 0, 320, 240},
|
||||
{0, 0, 320, 200}
|
||||
};
|
||||
|
||||
static const struct
|
||||
{
|
||||
int xres;
|
||||
|
@ -323,15 +324,13 @@ read_fbmodes_line(FILE * f, char *line, int length)
|
|||
blank = 1;
|
||||
else
|
||||
blank = 0;
|
||||
}
|
||||
while (blank);
|
||||
} while (blank);
|
||||
/* remove whitespace at the begining of the string */
|
||||
i = 0;
|
||||
do {
|
||||
line[i] = c[i];
|
||||
i++;
|
||||
}
|
||||
while (c[i] != 0);
|
||||
} while (c[i] != 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -347,8 +346,7 @@ read_fbmodes_mode(FILE * f, struct fb_var_screeninfo *vinfo)
|
|||
return 0;
|
||||
if (SDL_strncmp(line, "geometry", 8) == 0)
|
||||
break;
|
||||
}
|
||||
while (1);
|
||||
} while (1);
|
||||
|
||||
SDL_sscanf(line, "geometry %d %d %d %d %d", &vinfo->xres, &vinfo->yres,
|
||||
&vinfo->xres_virtual, &vinfo->yres_virtual,
|
||||
|
@ -394,8 +392,7 @@ read_fbmodes_mode(FILE * f, struct fb_var_screeninfo *vinfo)
|
|||
if (SDL_strncmp(option, "true", 4) == 0)
|
||||
vinfo->vmode |= FB_VMODE_DOUBLE;
|
||||
}
|
||||
}
|
||||
while (SDL_strncmp(line, "endmode", 7) != 0);
|
||||
} while (SDL_strncmp(line, "endmode", 7) != 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -826,6 +823,7 @@ print_vinfo(struct fb_var_screeninfo *vinfo)
|
|||
fprintf(stderr, "\talpha: %d/%d\n", vinfo->transp.length,
|
||||
vinfo->transp.offset);
|
||||
}
|
||||
|
||||
static void
|
||||
print_finfo(struct fb_fix_screeninfo *finfo)
|
||||
{
|
||||
|
@ -1193,6 +1191,7 @@ FB_InitHWSurfaces(_THIS, SDL_Surface * screen, char *base, int size)
|
|||
screen->hwdata = (struct private_hwdata *) &surfaces;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
FB_FreeHWSurfaces(_THIS)
|
||||
{
|
||||
|
@ -1283,6 +1282,7 @@ FB_AllocHWSurface(_THIS, SDL_Surface * surface)
|
|||
surface->hwdata = (struct private_hwdata *) bucket;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
FB_FreeHWSurface(_THIS, SDL_Surface * surface)
|
||||
{
|
||||
|
@ -1352,6 +1352,7 @@ FB_LockHWSurface(_THIS, SDL_Surface * surface)
|
|||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
FB_UnlockHWSurface(_THIS, SDL_Surface * surface)
|
||||
{
|
||||
|
|
|
@ -340,8 +340,7 @@ GAPI_CreateDevice(int devindex)
|
|||
gx.GXSuspend,
|
||||
"?GXSuspend@@YAHXZ")
|
||||
LINK(GXResume, gx.GXResume, "?GXResume@@YAHXZ") LINK(GXSetViewport,
|
||||
gx.
|
||||
GXSetViewport,
|
||||
gx.GXSetViewport,
|
||||
"?GXSetViewport@@YAHKKKK@Z")
|
||||
LINK(GXIsDisplayDRAMBuffer, gx.GXIsDisplayDRAMBuffer,
|
||||
"?GXIsDisplayDRAMBuffer@@YAHXZ")
|
||||
|
@ -807,6 +806,7 @@ GAPI_AllocHWSurface(_THIS, SDL_Surface * surface)
|
|||
{
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static void
|
||||
GAPI_FreeHWSurface(_THIS, SDL_Surface * surface)
|
||||
{
|
||||
|
|
|
@ -526,8 +526,7 @@ iPod_PumpEvents(_THIS)
|
|||
}
|
||||
if (dbgout)
|
||||
fprintf(dbgout, "\n");
|
||||
}
|
||||
while (posted);
|
||||
} while (posted);
|
||||
}
|
||||
|
||||
// enough space for 160x128x2
|
||||
|
@ -570,8 +569,7 @@ M_lcd_wait_write(void)
|
|||
do {
|
||||
if ((inl(lcd_base) & (unsigned int) 0x8000) == 0)
|
||||
break;
|
||||
}
|
||||
while (M_timer_check(start, 1000) == 0);
|
||||
} while (M_timer_check(start, 1000) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -681,10 +679,10 @@ C_lcd_wait_write(void)
|
|||
do {
|
||||
if ((inl(0x70008A0C) & 0x80000000) == 0)
|
||||
break;
|
||||
}
|
||||
while (C_timer_check(start, 1000) == 0);
|
||||
} while (C_timer_check(start, 1000) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
C_lcd_cmd_data(int cmd, int data)
|
||||
{
|
||||
|
@ -780,10 +778,12 @@ iPod_UpdateRects(_THIS, int nrects, SDL_Rect * rects)
|
|||
ipod_scr[y * (lcd_width / 4) + x / 4] |=
|
||||
(((Uint8 *) (SDL_VideoSurface->pixels))[y *
|
||||
SDL_VideoSurface->
|
||||
pitch
|
||||
+
|
||||
x] &
|
||||
3) << (2 * (x % 4));
|
||||
pitch +
|
||||
x] & 3) << (2
|
||||
*
|
||||
(x
|
||||
%
|
||||
4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
54
src/video/nds/SDL_ndsevents.c
Normal file
54
src/video/nds/SDL_ndsevents.c
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 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"
|
||||
|
||||
/* Being a null driver, there's no event stream. We just define stubs for
|
||||
most of the API. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <nds.h>
|
||||
|
||||
#include "SDL.h"
|
||||
#include "../../events/SDL_sysevents.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
#include "SDL_ndsvideo.h"
|
||||
#include "SDL_ndsevents_c.h"
|
||||
|
||||
void
|
||||
NDS_PumpEvents(_THIS)
|
||||
{
|
||||
scanKeys();
|
||||
/* TODO: defer click-age */
|
||||
if (keysDown() & KEY_TOUCH) {
|
||||
SDL_SendMouseButton(0, SDL_PRESSED, 0);
|
||||
} else if (keysUp() & KEY_TOUCH) {
|
||||
SDL_SendMouseButton(0, SDL_RELEASED, 0);
|
||||
}
|
||||
if (keysHeld() & KEY_TOUCH) {
|
||||
touchPosition t = touchReadXY();
|
||||
SDL_SendMouseMotion(0, 0, t.px, t.py);
|
||||
}
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
28
src/video/nds/SDL_ndsevents_c.h
Normal file
28
src/video/nds/SDL_ndsevents_c.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 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_ndsvideo.h"
|
||||
|
||||
extern void NDS_PumpEvents(_THIS);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
660
src/video/nds/SDL_ndsrender.c
Normal file
660
src/video/nds/SDL_ndsrender.c
Normal file
|
@ -0,0 +1,660 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <nds.h>
|
||||
#include <nds/arm9/video.h>
|
||||
#include <nds/arm9/sprite.h>
|
||||
#include <nds/arm9/trig_lut.h>
|
||||
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../SDL_yuv_sw_c.h"
|
||||
#include "../SDL_renderer_sw.h"
|
||||
|
||||
/* NDS sprite-related functions */
|
||||
#define SPRITE_DMA_CHANNEL 3
|
||||
#define SPRITE_ANGLE_MASK 0x01FF
|
||||
|
||||
void
|
||||
NDS_OAM_Update(tOAM * oam, int sub)
|
||||
{
|
||||
DC_FlushAll();
|
||||
dmaCopyHalfWords(SPRITE_DMA_CHANNEL, oam->spriteBuffer,
|
||||
sub ? OAM_SUB : OAM, SPRITE_COUNT * sizeof(SpriteEntry));
|
||||
}
|
||||
|
||||
void
|
||||
NDS_OAM_RotateSprite(SpriteRotation * spriteRotation, u16 angle)
|
||||
{
|
||||
s16 s = SIN[angle & SPRITE_ANGLE_MASK] >> 4;
|
||||
s16 c = COS[angle & SPRITE_ANGLE_MASK] >> 4;
|
||||
|
||||
spriteRotation->hdx = c;
|
||||
spriteRotation->hdy = s;
|
||||
spriteRotation->vdx = -s;
|
||||
spriteRotation->vdy = c;
|
||||
}
|
||||
|
||||
void
|
||||
NDS_OAM_Init(tOAM * oam, int sub)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < SPRITE_COUNT; i++) {
|
||||
oam->spriteBuffer[i].attribute[0] = ATTR0_DISABLED;
|
||||
oam->spriteBuffer[i].attribute[1] = 0;
|
||||
oam->spriteBuffer[i].attribute[2] = 0;
|
||||
}
|
||||
for (i = 0; i < MATRIX_COUNT; i++) {
|
||||
NDS_OAM_RotateSprite(&(oam->matrixBuffer[i]), 0);
|
||||
}
|
||||
swiWaitForVBlank();
|
||||
NDS_OAM_Update(oam, sub);
|
||||
}
|
||||
|
||||
void
|
||||
NDS_OAM_HideSprite(SpriteEntry * spriteEntry)
|
||||
{
|
||||
spriteEntry->isRotoscale = 0;
|
||||
spriteEntry->isHidden = 1;
|
||||
}
|
||||
|
||||
void
|
||||
NDS_OAM_ShowSprite(SpriteEntry * spriteEntry, int affine, int double_bound)
|
||||
{
|
||||
if (affine) {
|
||||
spriteEntry->isRotoscale = 1;
|
||||
spriteEntry->rsDouble = double_bound;
|
||||
} else {
|
||||
spriteEntry->isHidden = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* SDL NDS renderer implementation */
|
||||
|
||||
static SDL_Renderer *NDS_CreateRenderer(SDL_Window * window, Uint32 flags);
|
||||
static int NDS_ActivateRenderer(SDL_Renderer * renderer);
|
||||
static int NDS_DisplayModeChanged(SDL_Renderer * renderer);
|
||||
static int NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
static int NDS_QueryTexturePixels(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture, void **pixels,
|
||||
int *pitch);
|
||||
static int NDS_SetTexturePalette(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture,
|
||||
const SDL_Color * colors, int firstcolor,
|
||||
int ncolors);
|
||||
static int NDS_GetTexturePalette(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture, SDL_Color * colors,
|
||||
int firstcolor, int ncolors);
|
||||
static int NDS_SetTextureColorMod(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
static int NDS_SetTextureAlphaMod(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
static int NDS_SetTextureBlendMode(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
static int NDS_SetTextureScaleMode(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
static int NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels,
|
||||
int pitch);
|
||||
static int NDS_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, int markDirty,
|
||||
void **pixels, int *pitch);
|
||||
static void NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
static void NDS_DirtyTexture(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture, int numrects,
|
||||
const SDL_Rect * rects);
|
||||
static int NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g,
|
||||
Uint8 b, Uint8 a, const SDL_Rect * rect);
|
||||
static int NDS_RenderCopy(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_Rect * dstrect);
|
||||
static void NDS_RenderPresent(SDL_Renderer * renderer);
|
||||
static void NDS_DestroyTexture(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
static void NDS_DestroyRenderer(SDL_Renderer * renderer);
|
||||
|
||||
|
||||
SDL_RenderDriver NDS_RenderDriver = {
|
||||
NDS_CreateRenderer,
|
||||
{"nds", /* char* name */
|
||||
(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC), /* u32 flags */
|
||||
(SDL_TEXTUREMODULATE_NONE), /* u32 mod_modes */
|
||||
(SDL_TEXTUREBLENDMODE_MASK), /* u32 blend_modes */
|
||||
(SDL_TEXTURESCALEMODE_FAST), /* u32 scale_modes */
|
||||
3, /* u32 num_texture_formats */
|
||||
{
|
||||
SDL_PIXELFORMAT_INDEX8,
|
||||
SDL_PIXELFORMAT_ABGR1555,
|
||||
SDL_PIXELFORMAT_BGR555,
|
||||
}, /* u32 texture_formats[20] */
|
||||
(256), /* int max_texture_width */
|
||||
(256), /* int max_texture_height */
|
||||
}
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bg_attribute *bg; /* backgrounds */
|
||||
tOAM oam_copy; /* sprites */
|
||||
u8 bg_taken[4];
|
||||
int sub;
|
||||
} NDS_RenderData;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
enum
|
||||
{ NDSTX_BG, NDSTX_SPR } type; /* represented in a bg or sprite. */
|
||||
int hw_index; /* sprite: index in the OAM. / bg: 2 or 3. */
|
||||
struct
|
||||
{
|
||||
int hdx, hdy, vdx, vdy; /* affine transformation, used for scaling. */
|
||||
int pitch, bpp; /* some useful info */
|
||||
} dim;
|
||||
u16 *vram_pixels; /* where the pixel data is stored (a pointer into VRAM) */
|
||||
u16 *vram_palette; /* where the palette data is stored if it's indexed. */
|
||||
/*int size; */
|
||||
} NDS_TextureData;
|
||||
|
||||
|
||||
|
||||
SDL_Renderer *
|
||||
NDS_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
{
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
|
||||
SDL_DisplayMode *displayMode = &display->current_mode;
|
||||
SDL_Renderer *renderer;
|
||||
NDS_RenderData *data;
|
||||
int i, n;
|
||||
int bpp;
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
|
||||
if (!SDL_PixelFormatEnumToMasks(displayMode->format, &bpp,
|
||||
&Rmask, &Gmask, &Bmask, &Amask)) {
|
||||
SDL_SetError("Unknown display format");
|
||||
return NULL;
|
||||
}
|
||||
switch (displayMode->format) {
|
||||
case SDL_PIXELFORMAT_INDEX8:
|
||||
case SDL_PIXELFORMAT_ABGR1555:
|
||||
case SDL_PIXELFORMAT_BGR555:
|
||||
/* okay */
|
||||
break;
|
||||
case SDL_PIXELFORMAT_RGB555:
|
||||
case SDL_PIXELFORMAT_RGB565:
|
||||
case SDL_PIXELFORMAT_ARGB1555:
|
||||
/* we'll take these too for now */
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Warning: wrong display format for NDS!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
if (!renderer) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (NDS_RenderData *) SDL_malloc(sizeof(*data));
|
||||
if (!data) {
|
||||
NDS_DestroyRenderer(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
SDL_zerop(data);
|
||||
|
||||
renderer->RenderFill = NDS_RenderFill;
|
||||
renderer->RenderCopy = NDS_RenderCopy;
|
||||
renderer->RenderPresent = NDS_RenderPresent;
|
||||
renderer->DestroyRenderer = NDS_DestroyRenderer;
|
||||
renderer->info.name = NDS_RenderDriver.info.name;
|
||||
renderer->info.flags = 0;
|
||||
renderer->window = window->id;
|
||||
renderer->driverdata = data;
|
||||
renderer->CreateTexture = NDS_CreateTexture;
|
||||
renderer->QueryTexturePixels = NDS_QueryTexturePixels;
|
||||
renderer->SetTexturePalette = NDS_SetTexturePalette;
|
||||
renderer->GetTexturePalette = NDS_GetTexturePalette;
|
||||
renderer->SetTextureColorMod = NDS_SetTextureColorMod;
|
||||
renderer->SetTextureAlphaMod = NDS_SetTextureAlphaMod;
|
||||
renderer->SetTextureBlendMode = NDS_SetTextureBlendMode;
|
||||
renderer->SetTextureScaleMode = NDS_SetTextureScaleMode;
|
||||
renderer->UpdateTexture = NDS_UpdateTexture;
|
||||
renderer->LockTexture = NDS_LockTexture;
|
||||
renderer->UnlockTexture = NDS_UnlockTexture;
|
||||
renderer->DirtyTexture = NDS_DirtyTexture;
|
||||
renderer->DestroyTexture = NDS_DestroyTexture;
|
||||
|
||||
renderer->info.mod_modes = NDS_RenderDriver.info.mod_modes;
|
||||
renderer->info.blend_modes = NDS_RenderDriver.info.blend_modes;
|
||||
renderer->info.scale_modes = NDS_RenderDriver.info.scale_modes;
|
||||
renderer->info.num_texture_formats =
|
||||
NDS_RenderDriver.info.num_texture_formats;
|
||||
SDL_memcpy(renderer->info.texture_formats,
|
||||
NDS_RenderDriver.info.texture_formats,
|
||||
sizeof(renderer->info.texture_formats));
|
||||
renderer->info.max_texture_width =
|
||||
NDS_RenderDriver.info.max_texture_width;
|
||||
renderer->info.max_texture_height =
|
||||
NDS_RenderDriver.info.max_texture_height;
|
||||
|
||||
data->sub = 0; /* TODO: this is hard-coded to the "main" screen.
|
||||
figure out how to detect whether to set it to
|
||||
"sub" screen. window->id, perhaps? */
|
||||
if (!data->sub) {
|
||||
data->bg = &BACKGROUND;
|
||||
} else {
|
||||
data->bg = &BACKGROUND_SUB;
|
||||
}
|
||||
data->bg_taken[2] = data->bg_taken[3] = 0;
|
||||
|
||||
NDS_OAM_Init(&(data->oam_copy), data->sub); /* init sprites. */
|
||||
|
||||
return renderer;
|
||||
}
|
||||
|
||||
static int
|
||||
NDS_ActivateRenderer(SDL_Renderer * renderer)
|
||||
{
|
||||
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
NDS_DisplayModeChanged(SDL_Renderer * renderer)
|
||||
{
|
||||
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
|
||||
NDS_TextureData *txdat = NULL;
|
||||
int i;
|
||||
int bpp;
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
|
||||
if (!SDL_PixelFormatEnumToMasks
|
||||
(texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
|
||||
SDL_SetError("Unknown texture format");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* conditional statements on w/h to place it as bg/sprite
|
||||
depending on which one it fits. */
|
||||
if (texture->w <= 64 && texture->h <= 64) {
|
||||
int whichspr = -1;
|
||||
printf("Tried to make a sprite.\n");
|
||||
txdat->type = NDSTX_SPR;
|
||||
for (i = 0; i < SPRITE_COUNT; ++i) {
|
||||
if (data->oam_copy.spriteBuffer[i].attribute[0] & ATTR0_DISABLED) {
|
||||
whichspr = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (whichspr >= 0) {
|
||||
SpriteEntry *sprent = &(data->oam_copy.spriteBuffer[whichspr]);
|
||||
int maxside = texture->w > texture->h ? texture->w : texture->h;
|
||||
int pitch;
|
||||
|
||||
texture->driverdata = SDL_calloc(1, sizeof(NDS_TextureData));
|
||||
txdat = (NDS_TextureData *) texture->driverdata;
|
||||
if (!txdat) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
|
||||
sprent->objMode = OBJMODE_BITMAP;
|
||||
sprent->posX = 0;
|
||||
sprent->posY = 0;
|
||||
sprent->colMode = OBJCOLOR_16; /* OBJCOLOR_256 for INDEX8 */
|
||||
|
||||
/* the first 32 sprites get transformation matrices.
|
||||
first come, first served */
|
||||
if (whichspr < MATRIX_COUNT) {
|
||||
sprent->isRotoscale = 1;
|
||||
sprent->rsMatrixIdx = whichspr;
|
||||
}
|
||||
|
||||
/* containing shape (square or 2:1 rectangles) */
|
||||
sprent->objShape = OBJSHAPE_SQUARE;
|
||||
if (texture->w / 2 >= texture->h) {
|
||||
sprent->objShape = OBJSHAPE_WIDE;
|
||||
} else if (texture->h / 2 >= texture->w) {
|
||||
sprent->objShape = OBJSHAPE_TALL;
|
||||
}
|
||||
|
||||
/* size in pixels */
|
||||
/* FIXME: "pitch" is hardcoded for 2bytes per pixel. */
|
||||
sprent->objSize = OBJSIZE_64;
|
||||
pitch = 128;
|
||||
if (maxside <= 8) {
|
||||
sprent->objSize = OBJSIZE_8;
|
||||
pitch = 16;
|
||||
} else if (maxside <= 16) {
|
||||
sprent->objSize = OBJSIZE_16;
|
||||
pitch = 32;
|
||||
} else if (maxside <= 32) {
|
||||
sprent->objSize = OBJSIZE_32;
|
||||
pitch = 64;
|
||||
}
|
||||
|
||||
/* FIXME: this is hard-coded and will obviously only work for one
|
||||
sprite-texture. tells it to look at the beginning of SPRITE_GFX
|
||||
for its pixels. */
|
||||
sprent->tileIdx = 0;
|
||||
|
||||
/* now for the texture data */
|
||||
txdat->type = NDSTX_SPR;
|
||||
txdat->hw_index = whichspr;
|
||||
txdat->dim.hdx = 0x100;
|
||||
txdat->dim.hdy = 0;
|
||||
txdat->dim.vdx = 0;
|
||||
txdat->dim.vdy = 0x100;
|
||||
txdat->dim.pitch = pitch;
|
||||
txdat->dim.bpp = bpp;
|
||||
txdat->vram_pixels = (u16 *) (data->sub ? SPRITE_GFX_SUB : SPRITE_GFX); /* FIXME: use tileIdx*boundary
|
||||
to point to proper location */
|
||||
} else {
|
||||
SDL_SetError("Out of NDS sprites.");
|
||||
}
|
||||
} else if (texture->w <= 256 && texture->h <= 256) {
|
||||
int whichbg = -1, base = 0;
|
||||
if (!data->bg_taken[2]) {
|
||||
whichbg = 2;
|
||||
} else if (!data->bg_taken[3]) {
|
||||
whichbg = 3;
|
||||
base = 4;
|
||||
}
|
||||
if (whichbg >= 0) {
|
||||
texture->driverdata = SDL_calloc(1, sizeof(NDS_TextureData));
|
||||
txdat = (NDS_TextureData *) texture->driverdata;
|
||||
if (!txdat) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* this is hard-coded to being 256x256 ABGR1555 for now. */
|
||||
data->bg->control[whichbg] = (bpp == 8) ?
|
||||
BG_BMP8_256x256 : BG_BMP16_256x256;
|
||||
|
||||
data->bg->control[whichbg] |= BG_BMP_BASE(base);
|
||||
|
||||
data->bg->scroll[whichbg].x = 0;
|
||||
data->bg->scroll[whichbg].y = 0;
|
||||
|
||||
txdat->type = NDSTX_BG;
|
||||
txdat->hw_index = whichbg;
|
||||
txdat->dim.hdx = 0x100;
|
||||
txdat->dim.hdy = 0;
|
||||
txdat->dim.vdx = 0;
|
||||
txdat->dim.vdy = 0x100;
|
||||
txdat->dim.pitch = 512;
|
||||
txdat->dim.bpp = bpp;
|
||||
txdat->vram_pixels = (u16 *) (data->sub ?
|
||||
BG_BMP_RAM_SUB(base) :
|
||||
BG_BMP_RAM(base));
|
||||
|
||||
/*txdat->size = txdat->dim.pitch * texture->h; */
|
||||
} else {
|
||||
SDL_SetError("Out of NDS backgrounds.");
|
||||
}
|
||||
} else {
|
||||
SDL_SetError("Texture too big for NDS hardware.");
|
||||
}
|
||||
|
||||
if (!texture->driverdata) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
NDS_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
void **pixels, int *pitch)
|
||||
{
|
||||
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
|
||||
*pixels = txdat->vram_pixels;
|
||||
*pitch = txdat->dim.pitch;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels, int pitch)
|
||||
{
|
||||
NDS_TextureData *txdat;
|
||||
Uint8 *src, *dst;
|
||||
int row;
|
||||
size_t length;
|
||||
|
||||
txdat = (NDS_TextureData *) texture->driverdata;
|
||||
|
||||
src = (Uint8 *) pixels;
|
||||
dst =
|
||||
(Uint8 *) txdat->vram_pixels + rect->y * txdat->dim.pitch +
|
||||
rect->x * ((txdat->dim.bpp + 1) / 8);
|
||||
length = rect->w * ((txdat->dim.bpp + 1) / 8);
|
||||
|
||||
if (rect->w == texture->w) {
|
||||
dmaCopy(src, dst, length * rect->h);
|
||||
} else {
|
||||
for (row = 0; row < rect->h; ++row) {
|
||||
dmaCopy(src, dst, length);
|
||||
src += pitch;
|
||||
dst += txdat->dim.pitch;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
NDS_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, int markDirty, void **pixels,
|
||||
int *pitch)
|
||||
{
|
||||
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
|
||||
|
||||
*pixels = (void *) ((u8 *) txdat->vram_pixels + rect->y
|
||||
* txdat->dim.pitch +
|
||||
rect->x * ((txdat->dim.bpp + 1) / 8));
|
||||
*pitch = txdat->dim.pitch;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
/* stub! */
|
||||
}
|
||||
|
||||
static void
|
||||
NDS_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
int numrects, const SDL_Rect * rects)
|
||||
{
|
||||
/* stub! */
|
||||
}
|
||||
|
||||
static int
|
||||
NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
|
||||
Uint8 a, const SDL_Rect * rect)
|
||||
{
|
||||
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
|
||||
SDL_Rect real_rect = *rect;
|
||||
u16 color;
|
||||
int i, j;
|
||||
|
||||
color = RGB8(r, g, b); /* <-- macro in libnds that makes an ARGB1555 pixel */
|
||||
/* TODO: make a single-color sprite and stretch it.
|
||||
calculate the "HDX" width modifier of the sprite by:
|
||||
let S be the actual sprite's width (like, 32 pixels for example)
|
||||
let R be the rectangle's width (maybe 50 pixels)
|
||||
HDX = (R<<8) / S;
|
||||
(it's fixed point, hence the bit shift. same goes for vertical.
|
||||
be sure to use 32-bit int's for the bit shift before the division!)
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_Rect * dstrect)
|
||||
{
|
||||
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
|
||||
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
|
||||
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
|
||||
int i;
|
||||
int bpp = SDL_BYTESPERPIXEL(texture->format);
|
||||
int pitch = txdat->dim.pitch;
|
||||
|
||||
if (txdat->type == NDSTX_BG) {
|
||||
bg_rotation *bgrot = (txdat->hw_index == 2) ?
|
||||
&(data->bg->bg2_rotation) : &(data->bg->bg3_rotation);
|
||||
bgrot->xdx = txdat->dim.hdx;
|
||||
bgrot->xdy = txdat->dim.hdy;
|
||||
bgrot->ydx = txdat->dim.vdx;
|
||||
bgrot->ydy = txdat->dim.vdy;
|
||||
bgrot->centerX = 0;
|
||||
bgrot->centerY = 0;
|
||||
|
||||
data->bg->scroll[txdat->hw_index].x = dstrect->x;
|
||||
data->bg->scroll[txdat->hw_index].y = dstrect->y;
|
||||
} else {
|
||||
/* sprites not fully implemented yet */
|
||||
SpriteEntry *spr = &(data->oam_copy.spriteBuffer[txdat->hw_index]);
|
||||
spr->posX = dstrect->x;
|
||||
spr->posY = dstrect->y;
|
||||
if (txdat->hw_index < MATRIX_COUNT && spr->isRotoscale) {
|
||||
SpriteRotation *sprot =
|
||||
&(data->oam_copy.matrixBuffer[txdat->hw_index]);
|
||||
sprot->hdx = txdat->dim.hdx;
|
||||
sprot->hdy = txdat->dim.hdy;
|
||||
sprot->vdx = txdat->dim.vdx;
|
||||
sprot->vdy = txdat->dim.vdy;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
NDS_RenderPresent(SDL_Renderer * renderer)
|
||||
{
|
||||
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
|
||||
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
|
||||
|
||||
/* update sprites */
|
||||
NDS_OAM_Update(&(data->oam_copy), data->sub);
|
||||
/* vsync for NDS */
|
||||
if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) {
|
||||
swiWaitForVBlank();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
NDS_TextureData *txdat = texture->driverdata;
|
||||
/* free anything else allocated for texture */
|
||||
SDL_free(txdat);
|
||||
}
|
||||
|
||||
static void
|
||||
NDS_DestroyRenderer(SDL_Renderer * renderer)
|
||||
{
|
||||
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
|
||||
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
|
||||
int i;
|
||||
|
||||
if (data) {
|
||||
/* free anything else relevant if anything else is allocated. */
|
||||
SDL_free(data);
|
||||
}
|
||||
SDL_free(renderer);
|
||||
}
|
||||
|
||||
static int
|
||||
NDS_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Color * colors, int firstcolor, int ncolors)
|
||||
{
|
||||
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
|
||||
/* set 8-bit modes in the background control registers
|
||||
for backgrounds, BGn_CR |= BG_256_COLOR */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
NDS_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
SDL_Color * colors, int firstcolor, int ncolors)
|
||||
{
|
||||
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
|
||||
/* stub! */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
NDS_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
/* stub! */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
NDS_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
/* stub! */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
NDS_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
/* stub! */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
NDS_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
/* stub! (note: NDS hardware scaling is nearest neighbor.) */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
28
src/video/nds/SDL_ndsrender_c.h
Normal file
28
src/video/nds/SDL_ndsrender_c.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 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"
|
||||
|
||||
/* SDL surface based renderer implementation */
|
||||
|
||||
extern SDL_RenderDriver NDS_RenderDriver;
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
168
src/video/nds/SDL_ndsvideo.c
Normal file
168
src/video/nds/SDL_ndsvideo.c
Normal file
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 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"
|
||||
|
||||
/* SDL Nintendo DS video driver implementation
|
||||
* based on dummy driver:
|
||||
* Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion
|
||||
* of this was cut-and-pasted from Stephane Peter's work in the AAlib
|
||||
* SDL video driver. Renamed to "DUMMY" by Sam Lantinga.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <nds.h>
|
||||
#include <nds/arm9/video.h>
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_mouse.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../SDL_pixels_c.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
#include "SDL_ndsvideo.h"
|
||||
#include "SDL_ndsevents_c.h"
|
||||
#include "SDL_ndsrender_c.h"
|
||||
|
||||
#define NDSVID_DRIVER_NAME "nds"
|
||||
|
||||
/* Initialization/Query functions */
|
||||
static int NDS_VideoInit(_THIS);
|
||||
static int NDS_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
|
||||
static void NDS_VideoQuit(_THIS);
|
||||
|
||||
|
||||
/* SDL NDS driver bootstrap functions */
|
||||
static int
|
||||
NDS_Available(void)
|
||||
{
|
||||
return (1); /* always here */
|
||||
}
|
||||
|
||||
static void
|
||||
NDS_DeleteDevice(SDL_VideoDevice * device)
|
||||
{
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_VideoDevice *
|
||||
NDS_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_VideoDevice *device;
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
|
||||
if (!device) {
|
||||
SDL_OutOfMemory();
|
||||
if (device) {
|
||||
SDL_free(device);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Set the function pointers */
|
||||
device->VideoInit = NDS_VideoInit;
|
||||
device->VideoQuit = NDS_VideoQuit;
|
||||
device->SetDisplayMode = NDS_SetDisplayMode;
|
||||
device->PumpEvents = NDS_PumpEvents;
|
||||
|
||||
device->num_displays = 2; /* DS = dual screens */
|
||||
|
||||
device->free = NDS_DeleteDevice;
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
VideoBootStrap NDS_bootstrap = {
|
||||
NDSVID_DRIVER_NAME, "SDL NDS video driver",
|
||||
NDS_Available, NDS_CreateDevice
|
||||
};
|
||||
|
||||
int
|
||||
NDS_VideoInit(_THIS)
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
int i;
|
||||
|
||||
/* simple 256x192x16x60 for now */
|
||||
mode.w = 256;
|
||||
mode.h = 192;
|
||||
mode.format = SDL_PIXELFORMAT_ABGR1555;
|
||||
mode.refresh_rate = 60;
|
||||
mode.driverdata = NULL;
|
||||
|
||||
SDL_AddBasicVideoDisplay(&mode);
|
||||
SDL_AddRenderDriver(0, &NDS_RenderDriver);
|
||||
|
||||
SDL_zero(mode);
|
||||
SDL_AddDisplayMode(0, &mode);
|
||||
|
||||
powerON(POWER_ALL_2D);
|
||||
irqInit();
|
||||
irqEnable(IRQ_VBLANK);
|
||||
NDS_SetDisplayMode(_this, &mode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
NDS_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
|
||||
{
|
||||
/* right now this function is just hard-coded for 256x192 ABGR1555 */
|
||||
videoSetMode(MODE_5_2D | DISPLAY_BG2_ACTIVE | DISPLAY_BG3_ACTIVE | DISPLAY_BG_EXT_PALETTE | DISPLAY_SPR_1D_LAYOUT | DISPLAY_SPR_1D_BMP | DISPLAY_SPR_1D_BMP_SIZE_256 | /* (try 128 if 256 is trouble.) */
|
||||
DISPLAY_SPR_ACTIVE | DISPLAY_SPR_EXT_PALETTE); /* display on main core
|
||||
with lots of flags set for
|
||||
flexibility/capacity to render */
|
||||
|
||||
/* hopefully these cover all the various things we might need to do */
|
||||
vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
|
||||
vramSetBankB(VRAM_B_MAIN_BG_0x06020000);
|
||||
vramSetBankC(VRAM_C_SUB_BG_0x06200000);
|
||||
vramSetBankD(VRAM_D_MAIN_BG_0x06040000); /* not a typo. vram d can't sub */
|
||||
vramSetBankE(VRAM_E_MAIN_SPRITE);
|
||||
vramSetBankF(VRAM_F_OBJ_EXT_PALETTE);
|
||||
vramSetBankG(VRAM_G_BG_EXT_PALETTE);
|
||||
vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);
|
||||
vramSetBankI(VRAM_I_SUB_SPRITE);
|
||||
|
||||
videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); /* debug text on sub
|
||||
TODO: this will change
|
||||
when multi-head is
|
||||
introduced in render */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
NDS_VideoQuit(_THIS)
|
||||
{
|
||||
videoSetMode(DISPLAY_SCREEN_OFF);
|
||||
videoSetModeSub(DISPLAY_SCREEN_OFF);
|
||||
vramSetMainBanks(VRAM_A_LCD, VRAM_B_LCD, VRAM_C_LCD, VRAM_D_LCD);
|
||||
vramSetBankE(VRAM_E_LCD);
|
||||
vramSetBankF(VRAM_F_LCD);
|
||||
vramSetBankG(VRAM_G_LCD);
|
||||
vramSetBankH(VRAM_H_LCD);
|
||||
vramSetBankI(VRAM_I_LCD);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
31
src/video/nds/SDL_ndsvideo.h
Normal file
31
src/video/nds/SDL_ndsvideo.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 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"
|
||||
|
||||
#ifndef _SDL_ndsvideo_h
|
||||
#define _SDL_ndsvideo_h
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
#endif /* _SDL_ndsvideo_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -440,8 +440,8 @@ WndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|||
if ((!pVideo->hidden->pSDLSurface) ||
|
||||
((pVideo->hidden->pSDLSurface)
|
||||
&&
|
||||
((pVideo->hidden->pSDLSurface->
|
||||
flags & SDL_RESIZABLE) == 0)))
|
||||
((pVideo->hidden->
|
||||
pSDLSurface->flags & SDL_RESIZABLE) == 0)))
|
||||
FSLib_ToggleFSMode(hwnd, !FSLib_QueryFSMode(hwnd));
|
||||
#ifdef DEBUG_BUILD
|
||||
else
|
||||
|
@ -552,11 +552,11 @@ WndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|||
{
|
||||
|
||||
iXScaleError =
|
||||
(pVideo->hidden->SrcBufferDesc.
|
||||
uiXResolution - 1) / swp.cx;
|
||||
(pVideo->hidden->SrcBufferDesc.uiXResolution -
|
||||
1) / swp.cx;
|
||||
iYScaleError =
|
||||
(pVideo->hidden->SrcBufferDesc.
|
||||
uiYResolution - 1) / swp.cy;
|
||||
(pVideo->hidden->SrcBufferDesc.uiYResolution -
|
||||
1) / swp.cy;
|
||||
if (iXScaleError < 0)
|
||||
iXScaleError = 0;
|
||||
if (iYScaleError < 0)
|
||||
|
@ -577,24 +577,22 @@ WndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|||
iTop =
|
||||
(swp.cy -
|
||||
rcl.yTop) *
|
||||
pVideo->hidden->SrcBufferDesc.
|
||||
uiYResolution / swp.cy - iYScaleError;
|
||||
pVideo->hidden->SrcBufferDesc.uiYResolution /
|
||||
swp.cy - iYScaleError;
|
||||
iLeft =
|
||||
rcl.xLeft *
|
||||
pVideo->hidden->SrcBufferDesc.
|
||||
uiXResolution / swp.cx - iXScaleError;
|
||||
pVideo->hidden->SrcBufferDesc.uiXResolution /
|
||||
swp.cx - iXScaleError;
|
||||
iWidth =
|
||||
((rcl.xRight -
|
||||
rcl.xLeft) *
|
||||
pVideo->hidden->SrcBufferDesc.
|
||||
uiXResolution + swp.cx - 1) / swp.cx +
|
||||
2 * iXScaleError;
|
||||
pVideo->hidden->SrcBufferDesc.uiXResolution +
|
||||
swp.cx - 1) / swp.cx + 2 * iXScaleError;
|
||||
iHeight =
|
||||
((rcl.yTop -
|
||||
rcl.yBottom) *
|
||||
pVideo->hidden->SrcBufferDesc.
|
||||
uiYResolution + swp.cy - 1) / swp.cy +
|
||||
2 * iYScaleError;
|
||||
pVideo->hidden->SrcBufferDesc.uiYResolution +
|
||||
swp.cy - 1) / swp.cy + 2 * iYScaleError;
|
||||
|
||||
iWidth += iXScaleError2;
|
||||
iHeight += iYScaleError2;
|
||||
|
@ -606,20 +604,19 @@ WndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|||
if (iTop + iHeight >
|
||||
pVideo->hidden->SrcBufferDesc.uiYResolution)
|
||||
iHeight =
|
||||
pVideo->hidden->SrcBufferDesc.
|
||||
uiYResolution - iTop;
|
||||
pVideo->hidden->SrcBufferDesc.uiYResolution -
|
||||
iTop;
|
||||
if (iLeft + iWidth >
|
||||
pVideo->hidden->SrcBufferDesc.uiXResolution)
|
||||
iWidth =
|
||||
pVideo->hidden->SrcBufferDesc.
|
||||
uiXResolution - iLeft;
|
||||
pVideo->hidden->SrcBufferDesc.uiXResolution -
|
||||
iLeft;
|
||||
|
||||
#ifdef DEBUG_BUILD
|
||||
printf
|
||||
("WM_PAINT : BitBlt: %d %d -> %d %d (Buf %d x %d)\n",
|
||||
iTop, iLeft, iWidth, iHeight,
|
||||
pVideo->hidden->SrcBufferDesc.
|
||||
uiXResolution,
|
||||
pVideo->hidden->SrcBufferDesc.uiXResolution,
|
||||
pVideo->hidden->SrcBufferDesc.uiYResolution);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
@ -693,15 +690,15 @@ WndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|||
WinQueryWindowPos(hwnd, &swp);
|
||||
if ((!pVideo->hidden->pSDLSurface) ||
|
||||
((pVideo->hidden->pSDLSurface) &&
|
||||
(pVideo->hidden->pSDLSurface->
|
||||
flags & SDL_RESIZABLE)
|
||||
(pVideo->hidden->
|
||||
pSDLSurface->flags & SDL_RESIZABLE)
|
||||
&&
|
||||
((swp.cx !=
|
||||
pVideo->hidden->SrcBufferDesc.
|
||||
uiXResolution)
|
||||
|| (swp.cy !=
|
||||
pVideo->hidden->
|
||||
SrcBufferDesc.uiYResolution))
|
||||
SrcBufferDesc.uiXResolution)
|
||||
|| (swp.cy !=
|
||||
pVideo->hidden->SrcBufferDesc.
|
||||
uiYResolution))
|
||||
&& (!FSLib_QueryFSMode(hwnd)))) {
|
||||
// Resizable surface and in resizing!
|
||||
// So, don't blit now!
|
||||
|
@ -718,14 +715,12 @@ WndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|||
fflush(stdout);
|
||||
#endif
|
||||
FSLIB_BITBLT(hwnd,
|
||||
pVideo->hidden->
|
||||
pchSrcBuffer, 0,
|
||||
pVideo->hidden->pchSrcBuffer, 0,
|
||||
0,
|
||||
pVideo->hidden->
|
||||
SrcBufferDesc.
|
||||
uiXResolution,
|
||||
pVideo->hidden->
|
||||
SrcBufferDesc.uiYResolution);
|
||||
SrcBufferDesc.uiXResolution,
|
||||
pVideo->hidden->SrcBufferDesc.
|
||||
uiYResolution);
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_BUILD
|
||||
|
@ -773,8 +768,8 @@ WndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|||
&swpClient);
|
||||
ptl.x = 0;
|
||||
ptl.y = 0;
|
||||
WinMapWindowPoints(pVideo->hidden->
|
||||
hwndClient, HWND_DESKTOP, &ptl, 1);
|
||||
WinMapWindowPoints(pVideo->hidden->hwndClient,
|
||||
HWND_DESKTOP, &ptl, 1);
|
||||
pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */
|
||||
WinSetPointerPos(HWND_DESKTOP,
|
||||
ptl.x + swpClient.cx / 2,
|
||||
|
@ -825,8 +820,8 @@ WndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|||
&swpClient);
|
||||
ptl.x = 0;
|
||||
ptl.y = 0;
|
||||
WinMapWindowPoints(pVideo->hidden->
|
||||
hwndClient, HWND_DESKTOP, &ptl, 1);
|
||||
WinMapWindowPoints(pVideo->hidden->hwndClient,
|
||||
HWND_DESKTOP, &ptl, 1);
|
||||
pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */
|
||||
WinSetPointerPos(HWND_DESKTOP,
|
||||
ptl.x + swpClient.cx / 2,
|
||||
|
@ -867,8 +862,8 @@ WndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|||
&swpClient);
|
||||
ptl.x = 0;
|
||||
ptl.y = 0;
|
||||
WinMapWindowPoints(pVideo->hidden->
|
||||
hwndClient, HWND_DESKTOP, &ptl, 1);
|
||||
WinMapWindowPoints(pVideo->hidden->hwndClient,
|
||||
HWND_DESKTOP, &ptl, 1);
|
||||
pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */
|
||||
WinSetPointerPos(HWND_DESKTOP,
|
||||
ptl.x + swpClient.cx / 2,
|
||||
|
@ -910,8 +905,8 @@ WndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|||
&swpClient);
|
||||
ptl.x = 0;
|
||||
ptl.y = 0;
|
||||
WinMapWindowPoints(pVideo->hidden->
|
||||
hwndClient, HWND_DESKTOP, &ptl, 1);
|
||||
WinMapWindowPoints(pVideo->hidden->hwndClient,
|
||||
HWND_DESKTOP, &ptl, 1);
|
||||
pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */
|
||||
WinSetPointerPos(HWND_DESKTOP,
|
||||
ptl.x + swpClient.cx / 2,
|
||||
|
@ -1378,6 +1373,7 @@ memnot(Uint8 * dst, Uint8 * src, int len)
|
|||
while (len-- > 0)
|
||||
*dst++ = ~*src++;
|
||||
}
|
||||
|
||||
static void
|
||||
memxor(Uint8 * dst, Uint8 * src1, Uint8 * src2, int len)
|
||||
{
|
||||
|
@ -1635,6 +1631,7 @@ os2fslib_AllocHWSurface(_THIS, SDL_Surface * surface)
|
|||
{
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static void
|
||||
os2fslib_FreeHWSurface(_THIS, SDL_Surface * surface)
|
||||
{
|
||||
|
@ -2505,23 +2502,27 @@ os2fslib_SetVideoMode(_THIS, SDL_Surface * current,
|
|||
pResult = SDL_CreateRGBSurface(SDL_SWSURFACE,
|
||||
pModeInfoFound->uiXResolution,
|
||||
pModeInfoFound->uiYResolution,
|
||||
pModeInfoFound->uiBPP,
|
||||
((unsigned int) pModeInfoFound->
|
||||
pModeInfoFound->uiBPP, ((unsigned int)
|
||||
pModeInfoFound->
|
||||
PixelFormat.
|
||||
ucRedMask) << pModeInfoFound->
|
||||
PixelFormat.ucRedPosition,
|
||||
((unsigned int) pModeInfoFound->
|
||||
ucRedMask)
|
||||
<< pModeInfoFound->PixelFormat.
|
||||
ucRedPosition, ((unsigned int)
|
||||
pModeInfoFound->
|
||||
PixelFormat.
|
||||
ucGreenMask) << pModeInfoFound->
|
||||
PixelFormat.ucGreenPosition,
|
||||
((unsigned int) pModeInfoFound->
|
||||
ucGreenMask)
|
||||
<< pModeInfoFound->PixelFormat.
|
||||
ucGreenPosition, ((unsigned int)
|
||||
pModeInfoFound->
|
||||
PixelFormat.
|
||||
ucBlueMask) << pModeInfoFound->
|
||||
PixelFormat.ucBluePosition,
|
||||
((unsigned int) pModeInfoFound->
|
||||
ucBlueMask)
|
||||
<< pModeInfoFound->PixelFormat.
|
||||
ucBluePosition, ((unsigned int)
|
||||
pModeInfoFound->
|
||||
PixelFormat.
|
||||
ucAlphaMask) << pModeInfoFound->
|
||||
PixelFormat.ucAlphaPosition);
|
||||
ucAlphaMask)
|
||||
<< pModeInfoFound->PixelFormat.
|
||||
ucAlphaPosition);
|
||||
|
||||
if (pResult == NULL) {
|
||||
DosReleaseMutexSem(_this->hidden->hmtxUseSrcBuffer);
|
||||
|
@ -2535,23 +2536,27 @@ os2fslib_SetVideoMode(_THIS, SDL_Surface * current,
|
|||
|
||||
// Adjust pixel format mask!
|
||||
pResult->format->Rmask =
|
||||
((unsigned int) pModeInfoFound->PixelFormat.
|
||||
ucRedMask) << pModeInfoFound->PixelFormat.ucRedPosition;
|
||||
((unsigned int) pModeInfoFound->
|
||||
PixelFormat.ucRedMask) << pModeInfoFound->PixelFormat.
|
||||
ucRedPosition;
|
||||
pResult->format->Rshift = pModeInfoFound->PixelFormat.ucRedPosition;
|
||||
pResult->format->Rloss = pModeInfoFound->PixelFormat.ucRedAdjust;
|
||||
pResult->format->Gmask =
|
||||
((unsigned int) pModeInfoFound->PixelFormat.
|
||||
ucGreenMask) << pModeInfoFound->PixelFormat.ucGreenPosition;
|
||||
((unsigned int) pModeInfoFound->
|
||||
PixelFormat.ucGreenMask) << pModeInfoFound->PixelFormat.
|
||||
ucGreenPosition;
|
||||
pResult->format->Gshift = pModeInfoFound->PixelFormat.ucGreenPosition;
|
||||
pResult->format->Gloss = pModeInfoFound->PixelFormat.ucGreenAdjust;
|
||||
pResult->format->Bmask =
|
||||
((unsigned int) pModeInfoFound->PixelFormat.
|
||||
ucBlueMask) << pModeInfoFound->PixelFormat.ucBluePosition;
|
||||
((unsigned int) pModeInfoFound->
|
||||
PixelFormat.ucBlueMask) << pModeInfoFound->PixelFormat.
|
||||
ucBluePosition;
|
||||
pResult->format->Bshift = pModeInfoFound->PixelFormat.ucBluePosition;
|
||||
pResult->format->Bloss = pModeInfoFound->PixelFormat.ucBlueAdjust;
|
||||
pResult->format->Amask =
|
||||
((unsigned int) pModeInfoFound->PixelFormat.
|
||||
ucAlphaMask) << pModeInfoFound->PixelFormat.ucAlphaPosition;
|
||||
((unsigned int) pModeInfoFound->
|
||||
PixelFormat.ucAlphaMask) << pModeInfoFound->PixelFormat.
|
||||
ucAlphaPosition;
|
||||
pResult->format->Ashift = pModeInfoFound->PixelFormat.ucAlphaPosition;
|
||||
pResult->format->Aloss = pModeInfoFound->PixelFormat.ucAlphaAdjust;
|
||||
|
||||
|
@ -2738,10 +2743,8 @@ os2fslib_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
|
|||
for (i = 0; _this->hidden->pListModesResult[i]; i++) {
|
||||
iNumOfSlots++;
|
||||
if (iPlace == -1) {
|
||||
if ((_this->hidden->
|
||||
pListModesResult[i]->w *
|
||||
_this->hidden->
|
||||
pListModesResult[i]->h) <
|
||||
if ((_this->hidden->pListModesResult[i]->w *
|
||||
_this->hidden->pListModesResult[i]->h) <
|
||||
(pRect->w * pRect->h)) {
|
||||
iPlace = i;
|
||||
}
|
||||
|
@ -2754,14 +2757,10 @@ os2fslib_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
|
|||
// printf("!!! From %d slots, it will be at %d\n", iNumOfSlots, iPlace);
|
||||
#endif
|
||||
|
||||
pNewList =
|
||||
(SDL_Rect **) SDL_realloc(_this->
|
||||
hidden->
|
||||
pListModesResult,
|
||||
(iNumOfSlots
|
||||
+
|
||||
1) *
|
||||
sizeof(SDL_Rect *));
|
||||
pNewList = (SDL_Rect **)
|
||||
SDL_realloc(_this->hidden->pListModesResult,
|
||||
(iNumOfSlots +
|
||||
1) * sizeof(SDL_Rect *));
|
||||
if (pNewList) {
|
||||
for (i = iNumOfSlots; i > iPlace; i--)
|
||||
pNewList[i] = pNewList[i - 1];
|
||||
|
@ -2816,23 +2815,25 @@ os2fslib_VideoInit(_THIS, SDL_PixelFormat * vformat)
|
|||
vformat->BytesPerPixel = (vformat->BitsPerPixel + 7) / 8;
|
||||
|
||||
vformat->Rmask =
|
||||
((unsigned int) pDesktopMode->PixelFormat.ucRedMask) << pDesktopMode->
|
||||
PixelFormat.ucRedPosition;
|
||||
((unsigned int) pDesktopMode->PixelFormat.
|
||||
ucRedMask) << pDesktopMode->PixelFormat.ucRedPosition;
|
||||
vformat->Rshift = pDesktopMode->PixelFormat.ucRedPosition;
|
||||
vformat->Rloss = pDesktopMode->PixelFormat.ucRedAdjust;
|
||||
vformat->Gmask =
|
||||
((unsigned int) pDesktopMode->PixelFormat.
|
||||
ucGreenMask) << pDesktopMode->PixelFormat.ucGreenPosition;
|
||||
((unsigned int) pDesktopMode->
|
||||
PixelFormat.ucGreenMask) << pDesktopMode->PixelFormat.
|
||||
ucGreenPosition;
|
||||
vformat->Gshift = pDesktopMode->PixelFormat.ucGreenPosition;
|
||||
vformat->Gloss = pDesktopMode->PixelFormat.ucGreenAdjust;
|
||||
vformat->Bmask =
|
||||
((unsigned int) pDesktopMode->PixelFormat.
|
||||
ucBlueMask) << pDesktopMode->PixelFormat.ucBluePosition;
|
||||
((unsigned int) pDesktopMode->
|
||||
PixelFormat.ucBlueMask) << pDesktopMode->PixelFormat.ucBluePosition;
|
||||
vformat->Bshift = pDesktopMode->PixelFormat.ucBluePosition;
|
||||
vformat->Bloss = pDesktopMode->PixelFormat.ucBlueAdjust;
|
||||
vformat->Amask =
|
||||
((unsigned int) pDesktopMode->PixelFormat.
|
||||
ucAlphaMask) << pDesktopMode->PixelFormat.ucAlphaPosition;
|
||||
((unsigned int) pDesktopMode->
|
||||
PixelFormat.ucAlphaMask) << pDesktopMode->PixelFormat.
|
||||
ucAlphaPosition;
|
||||
vformat->Ashift = pDesktopMode->PixelFormat.ucAlphaPosition;
|
||||
vformat->Aloss = pDesktopMode->PixelFormat.ucAlphaAdjust;
|
||||
|
||||
|
@ -2937,10 +2938,10 @@ os2fslib_VideoInit(_THIS, SDL_PixelFormat * vformat)
|
|||
sizeof(_this->hidden->SrcBufferDesc));
|
||||
// Allocate new video buffer!
|
||||
_this->hidden->pchSrcBuffer =
|
||||
(char *) SDL_malloc(_this->hidden->pAvailableFSLibVideoModes->
|
||||
uiScanLineSize *
|
||||
_this->hidden->pAvailableFSLibVideoModes->
|
||||
uiYResolution);
|
||||
(char *) SDL_malloc(_this->hidden->
|
||||
pAvailableFSLibVideoModes->uiScanLineSize *
|
||||
_this->hidden->
|
||||
pAvailableFSLibVideoModes->uiYResolution);
|
||||
if (!_this->hidden->pchSrcBuffer) {
|
||||
#ifdef DEBUG_BUILD
|
||||
printf
|
||||
|
|
|
@ -315,11 +315,14 @@ ph_SetupOpenGLContext(_THIS, int width, int height, int bpp, Uint32 flags)
|
|||
&& (this->gl_config.accum_blue_size != 0)
|
||||
&& (this->gl_config.accum_green_size != 0)) {
|
||||
qnxgl_attribs_slide = qnxgl_attrib_set_accum(qnxgl_attribs_slide,
|
||||
this->gl_config.
|
||||
accum_red_size +
|
||||
this->gl_config.
|
||||
accum_blue_size +
|
||||
this->gl_config.
|
||||
this->
|
||||
gl_config.accum_red_size
|
||||
+
|
||||
this->
|
||||
gl_config.accum_blue_size
|
||||
+
|
||||
this->
|
||||
gl_config.
|
||||
accum_green_size +
|
||||
this->gl_config.
|
||||
accum_alpha_size);
|
||||
|
|
|
@ -244,9 +244,8 @@ ph_SetupFullScreenImage(_THIS, SDL_Surface * screen)
|
|||
}
|
||||
|
||||
if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
|
||||
OCImage.FrameData1 =
|
||||
(unsigned char *) PdGetOffscreenContextPtr(OCImage.
|
||||
offscreen_backcontext);
|
||||
OCImage.FrameData1 = (unsigned char *)
|
||||
PdGetOffscreenContextPtr(OCImage.offscreen_backcontext);
|
||||
if (OCImage.FrameData1 == NULL) {
|
||||
SDL_SetError
|
||||
("ph_SetupFullScreenImage(back): PdGetOffscreenContextPtr() function failed !\n");
|
||||
|
|
|
@ -149,8 +149,8 @@ ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format,
|
|||
&overlay->hwdata->caps);
|
||||
if (rtncode == 0) {
|
||||
if (overlay->hwdata->caps.format == format) {
|
||||
if ((overlay->hwdata->caps.
|
||||
flags & Pg_SCALER_CAP_DST_CHROMA_KEY) ==
|
||||
if ((overlay->hwdata->
|
||||
caps.flags & Pg_SCALER_CAP_DST_CHROMA_KEY) ==
|
||||
Pg_SCALER_CAP_DST_CHROMA_KEY) {
|
||||
overlay->hwdata->ischromakey = 1;
|
||||
}
|
||||
|
@ -161,8 +161,7 @@ ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format,
|
|||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
while (1);
|
||||
} while (1);
|
||||
|
||||
|
||||
if (vidport == -1) {
|
||||
|
|
|
@ -479,8 +479,7 @@ detect_imps2(int fd)
|
|||
if (select(fd + 1, &fdset, 0, 0, &tv) < 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
while ((read(fd, &ch, sizeof(ch)) == sizeof(ch)) &&
|
||||
} while ((read(fd, &ch, sizeof(ch)) == sizeof(ch)) &&
|
||||
((ch == 0xFA) || (ch == 0xAA)));
|
||||
|
||||
/* Experimental values (Logitech wheelmouse) */
|
||||
|
@ -833,8 +832,7 @@ GS_PumpEvents(_THIS)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (posted);
|
||||
} while (posted);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -232,6 +232,7 @@ static unsigned long long tex_tags[] __attribute__ ((aligned(16))) = {
|
|||
0x0e, /* A+D */
|
||||
0, /* 2 */
|
||||
PS2_GS_TEX0_1, (1 << 5) + (1 << 6), PS2_GS_TEX1_1, 0, PS2_GS_TEXFLUSH};
|
||||
|
||||
static unsigned long long scale_tags[] __attribute__ ((aligned(16))) = {
|
||||
5 | (1LL << 60), /* GIFtag */
|
||||
0x0e, /* A+D */
|
||||
|
@ -573,11 +574,13 @@ GS_AllocHWSurface(_THIS, SDL_Surface * surface)
|
|||
{
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static void
|
||||
GS_FreeHWSurface(_THIS, SDL_Surface * surface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static int
|
||||
GS_LockHWSurface(_THIS, SDL_Surface * surface)
|
||||
{
|
||||
|
@ -606,6 +609,7 @@ GS_LockHWSurface(_THIS, SDL_Surface * surface)
|
|||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
GS_UnlockHWSurface(_THIS, SDL_Surface * surface)
|
||||
{
|
||||
|
|
|
@ -286,6 +286,7 @@ RISCOS_AllocHWSurface(_THIS, SDL_Surface * surface)
|
|||
{
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static void
|
||||
RISCOS_FreeHWSurface(_THIS, SDL_Surface * surface)
|
||||
{
|
||||
|
|
|
@ -207,8 +207,7 @@ SVGA_PumpEvents(_THIS)
|
|||
posted = 0;
|
||||
mouse_update();
|
||||
keyboard_update();
|
||||
}
|
||||
while (posted);
|
||||
} while (posted);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -467,6 +467,7 @@ SVGA_AllocHWSurface(_THIS, SDL_Surface * surface)
|
|||
{
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static void
|
||||
SVGA_FreeHWSurface(_THIS, SDL_Surface * surface)
|
||||
{
|
||||
|
@ -480,6 +481,7 @@ SVGA_LockHWSurface(_THIS, SDL_Surface * surface)
|
|||
/* The waiting is done in SVGA_FlipHWSurface() */
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
SVGA_UnlockHWSurface(_THIS, SDL_Surface * surface)
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue