1 /***************************************************************************
2                           sdl.h  -  description
3                              -------------------
4     begin                : Thu Apr 20 2000
5     copyright            : (C) 2000 by Michael Speck
6     email                : kulkanie@gmx.net
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 
18 #ifndef SDL_H
19 #define SDL_H
20 
21 #include <SDL.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 //#define DEBUG
28 
29 // draw region //
30 #define DR_SETSRC(p, i, j) {dr_src.s = p; dr_src.r.x = i; dr_src.r.y = j; dr_src.r.w = dr_dst.r.w; dr_src.r.h = dr_dst.r.h;}
31 #define DR_SETDST(p, i, j, k, l) {dr_dst.s = p; dr_dst.r.x = i; dr_dst.r.y = j; dr_dst.r.w = k; dr_dst.r.h = l;}
32 #define DR_SETFULLSRC(p) {dr_src.s = p; dr_src.r.x = 0; dr_src.r.y = 0; dr_src.r.w = dr_dst.r.w; dr_src.r.h = dr_dst.r.h;}
33 #define DR_SETFULLDST(p) {dr_dst.s = p; dr_dst.r.x = 0; dr_dst.r.y = 0; dr_dst.r.w = (p)->w; dr_dst.r.h = (p)->h;}
34 typedef struct {
35     SDL_Surface *s;
36     SDL_Rect    r;
37 } DrawRgn;
38 
39 // Sdl Surface //
40 SDL_Surface* SSur_Load(char *fname, int f);
41 SDL_Surface* SSur_Create(int w, int h, int f);
42 int  SSur_DisplayFormat(SDL_Surface *sur);
43 void SSur_Begin(SDL_Surface *sur);
44 void SSur_End(SDL_Surface *sur);
45 void SSur_Blit(void);
46 void SSur_AlphaBlit(int alpha);
47 void SSur_Fill(int c);
48 
49 // Sdl Font //
50 #define TA_X_LEFT	(1L<<1)
51 #define TA_X_CENTER	(1L<<2)
52 #define TA_X_RIGHT	(1L<<3)
53 #define TA_Y_TOP	(1L<<4)
54 #define TA_Y_CENTER	(1L<<5)
55 #define TA_Y_BOTTOM	(1L<<6)
56 typedef struct {
57     SDL_Surface        *sur;
58     int         algn;
59     int         clr;
60     int         lh;
61     char        lw[256];
62     int         loff[256];
63     char        keys[256];
64     char        off;
65     char        num;
66     //last written rect
67     int     	lastX;
68     int         lastY;
69     int	        lastW;
70     int	        lastH;
71 } SFnt;
72 SFnt* SFnt_Load(char *fname);
73 SFnt* SFnt_LoadFixed(char *fname, int off, int len, int w);
74 void SFnt_Free(SFnt *sfnt);
75 int  SFnt_Write(SFnt *sfnt, SDL_Surface *dest, int x, int y, char *str, int alpha);
76 void SFnt_Begin(SFnt *sfnt);
77 void SFnt_End(SFnt *sfnt);
78 SDL_Rect SFnt_LastRect(SFnt *fnt);
79 int  SFnt_TextWidth(SFnt *fnt, char *str);
80 
81 // Sdl //
82 #define SDL_DIM_STEPS   8
83 #define SDL_DIM_DELAY   20
84 #define SDL_DIM()   Sdl_Dim(SDL_DIM_STEPS, SDL_DIM_DELAY, 255)
85 #define SDL_UNDIM() Sdl_UnDim(SDL_DIM_STEPS, SDL_DIM_DELAY, 255)
86 typedef struct {
87     SDL_Surface *scr;
88 } Sdl;
89 void Sdl_Init(int f);
90 void Sdl_Quit();
91 int  Sdl_SetVideoMode(int w, int h, int d, int f);
92 void Sdl_Update(int x, int y, int w, int h);
93 void Sdl_FullUpdate();
94 void Sdl_Dim(int steps, int delay, int trp);
95 void Sdl_UnDim(int steps, int delay, int trp);
96 int  Sdl_WaitForKey();
97 void Sdl_WaitForClick();
98 // hardware funcs //
99 /*void Sdl_Begin();
100 void Sdl_End();
101 void Sdl_Flip();
102 void Sdl_SetClipRgn(int x, int y, int w, int h);*/
103 
104 #ifdef __cplusplus
105 };
106 #endif
107 
108 #endif
109