/* * gauche-sdl.h - Gauche SDL extension * * Copyright(C) 2003 by Michael Vess (mvess@michaelvess.com) * * Permission to use, copy, modify, distribute this software and * accompanying documentation for any purpose is hereby granted, * provided that existing copyright notices are retained in all * copies and that this notice is included verbatim in all * distributions. * This software is provided as is, without express or implied * warranty. In no circumstances the author(s) shall be liable * for any damages arising out of the use of this software. * * $Id: gauche-sdl.h,v 1.5 2003/09/10 17:22:01 mikiso Exp $ */ #ifndef GAUCHE_SDL_H #define GAUCHE_SDL_H #include #include /***************************************************************************** * Miscellaneous */ #define SCM_U8VECTOR_OR_NULL(obj) (SCM_FALSEP(obj)?NULL:SCM_U8VECTOR(obj)) #define SCM_U8VECTOR_OR_NULL_P(obj) (SCM_FALSEP(obj)||SCM_U8VECTORP(obj)) /***************************************************************************** * Video */ /* Rect */ typedef struct ScmSdlRectRec { SCM_HEADER; SDL_Rect rect; } ScmSdlRect; SCM_CLASS_DECL(Scm_SdlRectClass); #define SCM_CLASS_SDL_RECT (&Scm_SdlRectClass) #define SCM_SDL_RECT(obj) (&(((ScmSdlRect*)(obj))->rect)) #define SCM_SDL_RECT_P(obj) SCM_XTYPEP(obj, SCM_CLASS_SDL_RECT) #define SCM_SDL_RECT_OR_NULL(obj) (SCM_FALSEP(obj)?NULL:SCM_SDL_RECT(obj)) #define SCM_SDL_RECT_OR_NULL_P(obj) (SCM_FALSEP(obj)||SCM_SDL_RECT_P(obj)) /* Color */ typedef struct ScmSdlColorRec { SCM_HEADER; SDL_Color color; } ScmSdlColor; SCM_CLASS_DECL(Scm_SdlColorClass); #define SCM_CLASS_SDL_COLOR (&Scm_SdlColorClass) #define SCM_SDL_COLOR(obj) (&(((ScmSdlColor*)(obj))->color)) #define SCM_SDL_COLOR_P(obj) SCM_XTYPEP(obj, SCM_CLASS_SDL_COLOR) #define SCM_SDL_COLOR_OR_NULL(obj) (SCM_FALSEP(obj)?NULL:SCM_SDL_COLOR(obj)) #define SCM_SDL_COLOR_OR_NULL_P(obj) (SCM_FALSEP(obj)||SCM_SDL_COLOR_P(obj)) /* Palette */ typedef struct ScmSdlPaletteRec { SCM_HEADER; SDL_Palette palette; } ScmSdlPalette; SCM_CLASS_DECL(Scm_SdlPaletteClass); #define SCM_CLASS_SDL_PALETTE (&Scm_SdlPaletteClass) #define SCM_SDL_PALETTE(obj) (&(((ScmSdlPalette*)(obj))->palette)) #define SCM_SDL_PALETTE_P(obj) SCM_XTYPEP(obj, SCM_CLASS_SDL_PALETTE) #define SCM_SDL_PALETTE_OR_NULL(obj) (SCM_FALSEP(obj)?NULL:SCM_SDL_PALETTE(obj)) #define SCM_SDL_PALETTE_OR_NULL_P(obj) (SCM_FALSEP(obj)||SCM_SDL_PALETTE_P(obj)) /* PixelFormat */ typedef struct ScmSdlPixelFormatRec { SCM_HEADER; SDL_PixelFormat *format; } ScmSdlPixelFormat; SCM_CLASS_DECL(Scm_SdlPixelFormatClass); #define SCM_CLASS_SDL_PIXEL_FORMAT (&Scm_SdlPixelFormatClass) #define SCM_SDL_PIXEL_FORMAT(obj) (((ScmSdlPixelFormat*)(obj))->format) #define SCM_SDL_PIXEL_FORMAT_P(obj) SCM_XTYPEP(obj, SCM_CLASS_SDL_PIXEL_FORMAT) #define SCM_SDL_PIXEL_FORMAT_OR_NULL(obj) (SCM_FALSEP(obj)?NULL:SCM_SDL_PIXEL_FORMAT(obj)) #define SCM_SDL_PIXEL_FORMAT_OR_NULL_P(obj) (SCM_FALSEP(obj)||SCM_SDL_PIXEL_FORMAT_P(obj)) /* Surface */ typedef struct ScmSdlSurfaceRec { SCM_HEADER; SDL_Surface *surface; } ScmSdlSurface; SCM_CLASS_DECL(Scm_SdlSurfaceClass); #define SCM_CLASS_SDL_SURFACE (&Scm_SdlSurfaceClass) #define SCM_SDL_SURFACE(obj) (((ScmSdlSurface*)(obj))->surface) #define SCM_SDL_SURFACE_P(obj) SCM_XTYPEP(obj, SCM_CLASS_SDL_SURFACE) #define SCM_SDL_SURFACE_OR_NULL(obj) (SCM_FALSEP(obj)?NULL:SCM_SDL_SURFACE(obj)) #define SCM_SDL_SURFACE_OR_NULL_P(obj) (SCM_FALSEP(obj)||SCM_SDL_SURFACE_P(obj)) void sdl_surface_finalize(ScmObj obj, void *data); /* VideoInfo */ typedef struct ScmSdlVideoInfoRec { SCM_HEADER; SDL_VideoInfo *info; } ScmSdlVideoInfo; SCM_CLASS_DECL(Scm_SdlVideoInfoClass); #define SCM_CLASS_SDL_VIDEO_INFO (&Scm_SdlVideoInfoClass) #define SCM_SDL_VIDEO_INFO(obj) (((ScmSdlVideoInfo*)(obj))->info) #define SCM_SDL_VIDEO_INFO_P(obj) SCM_XTYPEP(obj, SCM_CLASS_SDL_VIDEO_INFO) #define SCM_SDL_VIDEO_INFO_OR_NULL(obj) (SCM_FALSEP(obj)?NULL:SCM_SDL_VIDEO_INFO(obj)) #define SCM_SDL_VIDEO_INFO_OR_NULL_P(obj) (SCM_FALSEP(obj)||SCM_SDL_VIDEO_INFO_P(obj)) /* Overlay */ typedef struct ScmSdlOverlayRec { SCM_HEADER; SDL_Overlay *overlay; } ScmSdlOverlay; SCM_CLASS_DECL(Scm_SdlOverlayClass); #define SCM_CLASS_SDL_OVERLAY (&Scm_SdlOverlayClass) #define SCM_SDL_OVERLAY(obj) (((ScmSdlOverlay*)(obj))->overlay) #define SCM_SDL_OVERLAY_P(obj) SCM_XTYPEP(obj, SCM_CLASS_SDL_OVERLAY) #define SCM_SDL_OVERLAY_OR_NULL(obj) (SCM_FALSEP(obj)?NULL:SCM_SDL_OVERLAY(obj)) #define SCM_SDL_OVERLAY_OR_NULL_P(obj) (SCM_FALSEP(obj)||SCM_SDL_OVERLAY_P(obj)) void sdl_overlay_finalize(ScmObj obj, void *data); /***************************************************************************** * Mouse */ /* Cursor */ typedef struct ScmSdlCursorRec { SCM_HEADER; SDL_Cursor *cursor; } ScmSdlCursor; SCM_CLASS_DECL(Scm_SdlCursorClass); #define SCM_CLASS_SDL_CURSOR (&Scm_SdlCursorClass) #define SCM_SDL_CURSOR(obj) (((ScmSdlCursor*)(obj))->cursor) #define SCM_SDL_CURSOR_P(obj) SCM_XTYPEP(obj, SCM_CLASS_SDL_CURSOR) #define SCM_SDL_CURSOR_OR_NULL(obj) (SCM_FALSEP(obj)?NULL:SCM_SDL_CURSOR(obj)) #define SCM_SDL_CURSOR_OR_NULL_P(obj) (SCM_FALSEP(obj)||SCM_SDL_CURSOR_P(obj)) void sdl_cursor_finalize(ScmObj obj, void *data); /***************************************************************************** * Event */ /* Event */ typedef struct ScmSdlEventRec { SCM_HEADER; SDL_Event event; } ScmSdlEvent; SCM_CLASS_DECL(Scm_SdlEventClass); #define SCM_CLASS_SDL_EVENT (&Scm_SdlEventClass) #define SCM_SDL_EVENT(obj) (&(((ScmSdlEvent*)(obj))->event)) #define SCM_SDL_EVENT_P(obj) SCM_XTYPEP(obj, SCM_CLASS_SDL_EVENT) #define SCM_SDL_EVENT_OR_NULL(obj) (SCM_FALSEP(obj)?NULL:SCM_SDL_EVENT(obj)) #define SCM_SDL_EVENT_OR_NULL_P(obj) (SCM_FALSEP(obj)||SCM_SDL_EVENT_P(obj)) /***************************************************************************** * Joystick */ /* Joystick */ /* HACK: Need SDL_sysjoystick.h from SDL source tree or we can't compile. * HACK: So make up a _SDL_Joystick structure instead. */ struct _SDL_Joystick { Uint8 index; /* Device index */ }; typedef struct ScmSdlJoystickRec { SCM_HEADER; SDL_Joystick joystick; } ScmSdlJoystick; SCM_CLASS_DECL(Scm_SdlJoystickClass); #define SCM_CLASS_SDL_JOYSTICK (&Scm_SdlJoystickClass) #define SCM_SDL_JOYSTICK(obj) (&(((ScmSdlJoystick*)(obj))->joystick)) #define SCM_SDL_JOYSTICK_P(obj) SCM_XTYPEP(obj, SCM_CLASS_SDL_JOYSTICK) #define SCM_SDL_JOYSTICK_OR_NULL(obj) (SCM_FALSEP(obj)?NULL:SCM_SDL_JOYSTICK(obj)) #define SCM_SDL_JOYSTICK_OR_NULL_P(obj) (SCM_FALSEP(obj)||SCM_SDL_JOYSTICK_P(obj)) /***************************************************************************** * Audio */ /* AudioSpec */ typedef struct ScmSdlAudioSpecRec { SCM_HEADER; SDL_AudioSpec audio; } ScmSdlAudioSpec; SCM_CLASS_DECL(Scm_SdlAudioSpecClass); #define SCM_CLASS_SDL_AUDIO_SPEC (&Scm_SdlAudioSpecClass) #define SCM_SDL_AUDIO_SPEC(obj) (&(((ScmSdlAudioSpec*)(obj))->audio)) #define SCM_SDL_AUDIO_SPEC_P(obj) SCM_XTYPEP(obj, SCM_CLASS_SDL_AUDIO_SPEC) #define SCM_SDL_AUDIO_SPEC_OR_NULL(obj) (SCM_FALSEP(obj)?NULL:SCM_SDL_AUDIO_SPEC(obj)) #define SCM_SDL_AUDIO_SPEC_OR_NULL_P(obj) (SCM_FALSEP(obj)||SCM_SDL_AUDIO_SPEC_P(obj)) /* AudioCVT */ typedef struct ScmSdlAudioCVTRec { SCM_HEADER; SDL_AudioCVT cvt; } ScmSdlAudioCVT; SCM_CLASS_DECL(Scm_SdlAudioCVTClass); #define SCM_CLASS_SDL_AUDIO_CVT (&Scm_SdlAudioCVTClass) #define SCM_SDL_AUDIO_CVT(obj) (&(((ScmSdlAudioCVT*)(obj))->cvt)) #define SCM_SDL_AUDIO_CVT_P(obj) SCM_XTYPEP(obj, SCM_CLASS_SDL_AUDIO_CVT) #define SCM_SDL_AUDIO_CVT_OR_NULL(obj) (SCM_FALSEP(obj)?NULL:SCM_SDL_AUDIO_CVT(obj)) #define SCM_SDL_AUDIO_CVT_OR_NULL_P(obj) (SCM_FALSEP(obj)||SCM_SDL_AUDIO_CVT_P(obj)) /* WAV */ typedef struct ScmSdlWAVRec { SCM_HEADER; SDL_AudioSpec spec; ScmObj buffer; } ScmSdlWAV; SCM_CLASS_DECL(Scm_SdlWAVClass); #define SCM_CLASS_SDL_WAV (&Scm_SdlWAVClass) #define SCM_SDL_WAV(obj) ((ScmSdlWAV*)(obj)) #define SCM_SDL_WAV_P(obj) SCM_XTYPEP(obj, SCM_CLASS_SDL_WAV) #define SCM_SDL_WAV_OR_NULL(obj) (SCM_FALSEP(obj)?NULL:SCM_SDL_WAV(obj)) #define SCM_SDL_WAV_OR_NULL_P(obj) (SCM_FALSEP(obj)||SCM_SDL_WAV_P(obj)) #define SCM_SDL_WAV_SPEC(obj) (((ScmSdlWAV*)(obj))->spec) #define SCM_SDL_WAV_BUFFER(obj) (((ScmSdlWAV*)(obj))->buffer) void sdl_wav_finalize(ScmObj obj, void *data); /***************************************************************************** * CD-ROM */ /* CD */ typedef struct ScmSdlCDRec { SCM_HEADER; SDL_CD *cd; } ScmSdlCD; SCM_CLASS_DECL(Scm_SdlCDClass); #define SCM_CLASS_SDL_CD (&Scm_SdlCDClass) #define SCM_SDL_CD(obj) (((ScmSdlCD*)(obj))->cd) #define SCM_SDL_CD_P(obj) SCM_XTYPEP(obj, SCM_CLASS_SDL_CD) #define SCM_SDL_CD_OR_NULL(obj) (SCM_FALSEP(obj)?NULL:SCM_SDL_CD(obj)) #define SCM_SDL_CD_OR_NULL_P(obj) (SCM_FALSEP(obj)||SCM_SDL_CD_P(obj)) /* CDtrack */ typedef struct ScmSdlCDtrackRec { SCM_HEADER; SDL_CDtrack *track; } ScmSdlCDtrack; SCM_CLASS_DECL(Scm_SdlCDtrackClass); #define SCM_CLASS_SDL_CD_TRACK (&Scm_SdlCDtrackClass) #define SCM_SDL_CD_TRACK(obj) (((ScmSdlCDtrack*)(obj))->track) #define SCM_SDL_CD_TRACK_P(obj) SCM_XTYPEP(obj, SCM_CLASS_SDL_CD_TRACK) #define SCM_SDL_CD_TRACK_OR_NULL(obj) (SCM_FALSEP(obj)?NULL:SCM_SDL_CD_TRACK(obj)) #define SCM_SDL_CD_TRACK_OR_NULL_P(obj) (SCM_FALSEP(obj)||SCM_SDL_CD_TRACK_P(obj)) /***************************************************************************** * Time */ /* SDL_TimerID */ typedef struct ScmSdlTimerIdRec { SCM_HEADER; SDL_TimerID id; } ScmSdlTimerId; SCM_CLASS_DECL(Scm_SdlTimerIdClass); #define SCM_CLASS_SDL_TIMER_ID (&Scm_SdlTimerIdClass) #define SCM_SDL_TIMER_ID(obj) (((ScmSdlTimerId*)(obj))->id) #define SCM_SDL_TIMER_ID_P(obj) SCM_XTYPEP(obj, SCM_CLASS_SDL_TIMER_ID) #define SCM_SDL_TIMER_ID_OR_NULL(obj) (SCM_FALSEP(obj)?NULL:SCM_SDL_TIMER_ID(obj)) #define SCM_SDL_TIMER_ID_OR_NULL_P(obj) (SCM_FALSEP(obj)||SCM_SDL_TIMER_ID_P(obj)) /***************************************************************************** * RWops */ /* RWops */ typedef struct ScmSdlRWopsRec { SCM_HEADER; SDL_RWops *rwops; } ScmSdlRWops; SCM_CLASS_DECL(Scm_SdlRWopsClass); #define SCM_CLASS_SDL_RWOPS (&Scm_SdlRWopsClass) #define SCM_SDL_RWOPS(obj) (((ScmSdlRWops*)(obj))->rwops) #define SCM_SDL_RWOPS_P(obj) SCM_XTYPEP(obj, SCM_CLASS_SDL_RWOPS) #define SCM_SDL_RWOPS_OR_NULL(obj) (SCM_FALSEP(obj)?NULL:SCM_SDL_RWOPS(obj)) #define SCM_SDL_RWOPS_OR_NULL_P(obj) (SCM_FALSEP(obj)||SCM_SDL_RWOPS_P(obj)) void sdl_rwops_finalize(ScmObj obj, void *data); #endif /* GAUCHE_SDL_H */