Simplify loops
[raycastlib.git] / testSDL.c
blobd5509f50223e92a65bc02bce14ffe8e8bc8aeeb7
1 /*
2 Raycasting SDL test. This is a port of my Pokitto demo.
4 author: Miloslav Ciz
5 license: CC0
6 */
8 #include <SDL2/SDL.h>
9 #include <stdio.h>
11 // redefine some parameters
12 #define FPS 40
13 #define GRAVITY_ACCELERATION (UNITS_PER_SQUARE * 3)
14 #define PLAYER_JUMP_SPEED 700
15 #define CAMERA_COLL_HEIGHT_BELOW ((3 * UNITS_PER_SQUARE) / 2)
16 #define HORIZONTAL_FOV (UNITS_PER_SQUARE / 5)
17 #define VERTICAL_FOV UNITS_PER_SQUARE // redefine camera vertical FOV
19 #include "raycastlib.h"
21 #define LEVEL_X_RES 29
22 #define LEVEL_Y_RES 21
24 #define SCREEN_WIDTH 640
25 #define SCREEN_HEIGHT 480
26 #define MIDDLE_ROW (SCREEN_HEIGHT / 2)
28 #define TRANSPARENT_COLOR 0b00000111
30 #define max(a,b) ((a) > (b) ? (a) : (b))
32 #define KEYS 8
33 #define KEY_UP 0
34 #define KEY_RIGHT 1
35 #define KEY_DOWN 2
36 #define KEY_LEFT 3
37 #define KEY_Q 4
38 #define KEY_W 5
39 #define KEY_A 6
40 #define KEY_S 7
42 int keys[KEYS];
44 unsigned long frame = 0;
46 Unit zBuffer[SCREEN_WIDTH]; ///< 1D z-buffer for visibility determination.
48 Camera camera;
50 uint32_t pixels[SCREEN_WIDTH * SCREEN_HEIGHT];
52 typedef struct
54 unsigned char *mImage;
55 Vector2D mPosition;
56 Unit mHeight;
57 Unit mPixelSize;
58 } Sprite;
60 uint32_t palette[256];
62 #define SPRITES 7
63 #define SPRITE_MAX_DISTANCE 5 * UNITS_PER_SQUARE
65 Sprite sprites[SPRITES];
67 /// For each level square says the texture index.
68 const unsigned char levelTexture[] =
70 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
71 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 0, 3, 3, 2, 2, 2, 2, // 0 20
72 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 1, 1, 2, // 1 19
73 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, // 2 18
74 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 1, 1, 2, // 3 17
75 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, // 4 16
76 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 1, 1, 2, // 5 15
77 1, 0, 1, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, // 6 14
78 1, 0, 1, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 2, // 7 13
79 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, // 8 12
80 1, 1, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, // 9 11
81 1, 1, 1, 1, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, // 10 10
82 1, 1, 1, 1, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, // 11 9
83 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, // 12 8
84 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, // 13 7
85 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // 14 6
86 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, // 15 5
87 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, // 16 4
88 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, // 17 3
89 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, // 18 2
90 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, // 19 1
91 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3 // 20 0
94 /// For each level square says the floor height.
95 const signed char levelFloor[] =
97 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
98 40,40,40,40,40,40,40,40,48,40,48,40,40,40,40,40,40,48,40,48,40,48,40,48,48,24,24,26,28, // 0 20
99 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,40, 2, 2, 2,40,32,32,32,32,32,32,32,48, 2, 2, 2,26, // 1 19
100 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,40, 2, 2, 2,40, 0, 0, 0, 0, 0,32,32,40, 2, 2, 2,26, // 2 18
101 40,16,12, 8, 4, 0,48, 0, 0, 0, 0, 0,24, 2,24, 8,24, 0, 0, 9, 9, 0,28,32,48, 2, 2, 2,24, // 3 17
102 40,20,48,48,48,48,48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0,24,32,40, 0, 0, 0,24, // 4 16
103 40,24,48,40,40,40,40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,20,32,48, 0, 0, 0,24, // 5 15
104 40,28,32,32,32,32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 8,12,16,32,40, 0, 0, 0,24, // 6 14
105 40,32,32,32,32,32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,32,32,32,32,32,32,48, 0, 0, 0,24, // 7 13
106 40, 0,48,40,40,40,40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,32,-3,-8,-8,-5,-2, 0, 0, 0, 0,24, // 8 12
107 40, 0,-3,-8,-8,-8,32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,32,-3,-8,-8, 0, 0, 0, 0, 0, 0,24, // 9 11
108 40, 0,-6,-8,-8,-8,32, 0, 0, 0,48,48, 0,48,48, 0, 0,36,32,36,-8,-8, 0, 0, 0, 0, 0, 0,24, // 10 10
109 40, 0,48,-8,-8,-8,32,32,32,32,40, 1, 0, 1,40,32,32,32,32,32,-8,-8, 0, 0, 0, 0, 0, 0,24, // 11 9
110 40, 0,48,-8,-8,-8,-8,-8,-8,-8,-8, 0, 0, 0,-8,-8,-8,36,32,36,-8,-8, 0, 0, 0, 0, 0, 0,24, // 12 8
111 40, 0,48,-8,-8,-8,-8,-8,-8,-8,-8, 0, 0, 0,-8,-8,-8,-8,-8,-8,-8,-8, 0, 0, 0, 0, 0, 0,24, // 13 7
112 40, 0,48, 0,-2,-2, 0,-8,-8,-8,-8, 0, 0, 0,-8,-8, 0, 0, 0, 0, 0, 0, 0, 0,24,24,10,24,24, // 14 6
113 40, 0, 0, 0,-2,-2, 0, 0, 0, 0, 8, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0,24, 0, 0, 0,24, // 15 5
114 40, 0, 0, 0,-2,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,24, 0, 0, 0,24, // 16 4
115 40,24,48,-2,-2,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,24, // 17 3
116 0,24,48,48,-2,-2,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,24, // 18 2
117 0,24,48,48,48,-2,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,24, 0, 0, 0,24, // 19 1
118 0,24,24,24,32,32,32,27,24,27,30,34,36,38,36,34,36,34,34,32,32,33,37,39,24,24,24,24,24 // 20 0
121 #define XX 127 // helper to keep a big number two-characters, for formatting
123 /// For each level square says the ceiling height.
124 const signed char levelCeiling[] =
126 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
127 40,40,40,40,40,40,40,XX,XX,XX,XX,36,40,40,40,40,40,36,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX, // 0 20
128 40,50,50,50,45,40,20,XX,XX,XX,XX,36,40,30,30,30,XX,36,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX, // 1 19
129 40,50,50,50,45,40,20,XX,XX,XX,XX,36,40,30,30,30,XX,36,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX, // 2 18
130 40,50,50,50,45,40,48,XX,XX,XX,XX,36,24,24,24,24,24,36,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX, // 3 17
131 40,50,48,48,48,48,47,XX,XX,XX,XX,36,36,36,36,36,36,36,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX, // 4 16
132 40,50,48,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX, // 5 15
133 40,50,48,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX, // 6 14
134 40,50,48,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX, // 7 13
135 40,50,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX, // 8 12
136 40,40,16,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX, // 9 11
137 40,30,16,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX, // 10 10
138 40,25,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX, // 11 9
139 40,20,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX, // 12 8
140 40,18,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,24,24,24,24,24,24, // 13 7
141 40,18,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,24,24,24,24,24,24, // 14 6
142 40,18,16,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,24,24,25,27,29,24, // 15 5
143 40,18,16,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,24,24,25,27,29,24, // 16 4
144 40,24,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,24,24,25,27,29,24, // 17 3
145 XX,24,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,24,24,25,27,29,24, // 18 2
146 XX,24,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,24,24,25,27,29,24, // 19 1
147 XX,24,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,XX,24,24,24,24,24,24 // 20 0
150 #undef XX
152 const unsigned char texture1[] =
153 { 32, 32 // width, height
154 ,0x12,0x65,0x65,0x6d,0x24,0x64,0x5b,0x12,0x12,0x64,0x5b,0x5b,0x12,0x51
155 ,0x12,0x09,0x00,0x6d,0x6d,0x6d,0x24,0x5b,0x5b,0x52,0x12,0x5b,0x52,0x5b
156 ,0x12,0x5b,0x52,0x09,0x12,0x5b,0x5b,0x5b,0x52,0x5b,0x5b,0x52,0x00,0x64
157 ,0x64,0x52,0x52,0x52,0x5b,0x00,0x09,0x6d,0x5b,0x5a,0x5b,0x5b,0x5a,0x51
158 ,0x12,0x64,0x5b,0x52,0x5b,0x52,0x5b,0x08,0x12,0x24,0x5b,0x5b,0x5b,0x5b
159 ,0x09,0x11,0x00,0x64,0x5b,0x5b,0x5a,0x09,0x09,0x08,0x00,0x5b,0x5b,0x5b
160 ,0x5a,0x64,0x12,0x51,0x00,0x64,0x5b,0x52,0x52,0x11,0x09,0x09,0x12,0x24
161 ,0x5b,0x5b,0x52,0x5a,0x12,0x09,0x00,0x5b,0x52,0x09,0x12,0x09,0x09,0x09
162 ,0x00,0x24,0x5a,0x5a,0x5b,0x51,0x12,0x08,0x09,0x25,0x5b,0x52,0x5b,0x52
163 ,0x11,0x09,0x12,0x64,0x5b,0x52,0x09,0x11,0x12,0x09,0x00,0x12,0x00,0x12
164 ,0x00,0x00,0x00,0x08,0x09,0x64,0x5b,0x51,0x12,0x11,0x12,0x08,0x09,0x64
165 ,0x5a,0x5b,0x12,0x12,0x09,0x09,0x12,0x65,0x5c,0x52,0x5a,0x5b,0x51,0x09
166 ,0x00,0x64,0x6d,0x6d,0x5c,0x65,0x64,0x09,0x00,0x24,0x64,0x5b,0x09,0x12
167 ,0x11,0x00,0x09,0x64,0x5b,0x52,0x52,0x12,0x12,0x08,0x00,0x64,0x52,0x52
168 ,0x52,0x52,0x5b,0x09,0x00,0x6d,0x5b,0x5b,0x52,0x5b,0x51,0x09,0x00,0x1b
169 ,0x5b,0x12,0x12,0x12,0x12,0x09,0x12,0x5b,0x11,0x09,0x11,0x09,0x09,0x09
170 ,0x09,0x5b,0x09,0x09,0x09,0x09,0x09,0x09,0x12,0x65,0x5b,0x5b,0x5b,0x52
171 ,0x5b,0x09,0x00,0x64,0x12,0x63,0x5b,0x12,0x5b,0x09,0x00,0x00,0x00,0x00
172 ,0x00,0x09,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5b
173 ,0x64,0x5b,0x09,0x5b,0x52,0x09,0x09,0x5b,0x11,0x52,0x09,0x12,0x09,0x08
174 ,0x00,0x1b,0x1b,0x23,0x1b,0x5a,0x5b,0x11,0x12,0x64,0x64,0x6d,0x24,0x5b
175 ,0x5b,0x09,0x00,0x5b,0x5a,0x52,0x52,0x09,0x08,0x09,0x12,0x5b,0x52,0x11
176 ,0x5a,0x11,0x12,0x08,0x08,0x1b,0x52,0x52,0x5b,0x5a,0x09,0x09,0x12,0x64
177 ,0x5b,0x64,0x12,0x12,0x12,0x08,0x00,0x00,0x00,0x12,0x09,0x00,0x09,0x00
178 ,0x12,0x24,0x5a,0x52,0x12,0x12,0x12,0x08,0x12,0x1b,0x12,0x5a,0x49,0x5a
179 ,0x52,0x09,0x12,0x6d,0x5b,0x52,0x5a,0x12,0x09,0x09,0x12,0x65,0x64,0x6d
180 ,0x6d,0x64,0x64,0x5b,0x00,0x5a,0x08,0x08,0x09,0x09,0x08,0x09,0x00,0x5b
181 ,0x5a,0x11,0x51,0x51,0x5a,0x09,0x12,0x6d,0x5b,0x5b,0x12,0x11,0x12,0x09
182 ,0x00,0x65,0x5b,0x64,0x5b,0x5b,0x5b,0x52,0x00,0x00,0x12,0x12,0x12,0x09
183 ,0x00,0x00,0x00,0x5a,0x52,0x52,0x09,0x52,0x09,0x09,0x12,0x63,0x5b,0x5a
184 ,0x09,0x5b,0x11,0x08,0x00,0x65,0x5b,0x5b,0x52,0x5b,0x52,0x52,0x00,0x65
185 ,0x6d,0x64,0x65,0x64,0x64,0x5b,0x00,0x5b,0x12,0x09,0x11,0x09,0x09,0x09
186 ,0x09,0x5b,0x11,0x08,0x09,0x09,0x09,0x08,0x00,0x64,0x64,0x5b,0x5b,0x5b
187 ,0x5b,0x09,0x00,0x5b,0x5b,0x5b,0x5b,0x5b,0x52,0x52,0x00,0x64,0x51,0x52
188 ,0x52,0x52,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x00,0x00,0x5b
189 ,0x5b,0x5b,0x52,0x52,0x5b,0x09,0x12,0x65,0x5b,0x5b,0x5b,0x52,0x5b,0x09
190 ,0x00,0x63,0x5a,0x51,0x51,0x51,0x5a,0x08,0x12,0x24,0x64,0x65,0x24,0x64
191 ,0x64,0x5b,0x00,0x5b,0x5b,0x52,0x5b,0x5b,0x52,0x09,0x00,0x64,0x5b,0x5b
192 ,0x12,0x52,0x5a,0x09,0x12,0x24,0x52,0x52,0x09,0x52,0x52,0x08,0x12,0x64
193 ,0x64,0x5b,0x5b,0x5b,0x64,0x52,0x00,0x6d,0x5b,0x52,0x5b,0x52,0x52,0x08
194 ,0x00,0x5b,0x5b,0x52,0x52,0x5b,0x52,0x09,0x00,0x1b,0x52,0x51,0x5a,0x52
195 ,0x09,0x09,0x12,0x64,0x52,0x5c,0x5b,0x64,0x5b,0x51,0x09,0x6d,0x5b,0x52
196 ,0x5b,0x52,0x11,0x09,0x00,0x64,0x5a,0x64,0x5b,0x52,0x5b,0x08,0x00,0x11
197 ,0x09,0x49,0x08,0x09,0x00,0x09,0x00,0x64,0x64,0x5b,0x52,0x5b,0x5b,0x09
198 ,0x12,0x65,0x64,0x5b,0x52,0x5b,0x52,0x09,0x12,0x64,0x64,0x64,0x52,0x09
199 ,0x5c,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x64,0x5b,0x64
200 ,0x52,0x5b,0x52,0x49,0x00,0x64,0x5b,0x52,0x52,0x5b,0x51,0x09,0x09,0x5b
201 ,0x09,0x09,0x09,0x08,0x09,0x12,0x00,0x6d,0x24,0x6d,0x24,0x64,0x64,0x5b
202 ,0x00,0x64,0x63,0x5b,0x5b,0x52,0x52,0x09,0x12,0x64,0x5b,0x5b,0x52,0x11
203 ,0x5b,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x12,0x6d,0x64,0x5b
204 ,0x52,0x64,0x5b,0x52,0x12,0x6d,0x5b,0x5b,0x5b,0x5b,0x5b,0x09,0x00,0x64
205 ,0x11,0x5a,0x52,0x5b,0x52,0x09,0x00,0x5b,0x5a,0x63,0x5a,0x23,0x12,0x00
206 ,0x12,0x6d,0x5b,0x11,0x5b,0x64,0x64,0x52,0x12,0x63,0x5b,0x5b,0x5b,0x5b
207 ,0x52,0x08,0x00,0x5c,0x52,0x5b,0x5b,0x52,0x52,0x08,0x08,0x5b,0x52,0x51
208 ,0x09,0x52,0x5a,0x09,0x00,0x6d,0x52,0x11,0x52,0x5b,0x52,0x09,0x12,0x64
209 ,0x5a,0x5b,0x52,0x5b,0x5b,0x08,0x00,0x5b,0x52,0x09,0x09,0x09,0x09,0x09
210 ,0x09,0x24,0x52,0x09,0x12,0x09,0x52,0x08,0x00,0x5b,0x5a,0x52,0x12,0x5b
211 ,0x5b,0x09,0x00,0x65,0x52,0x5b,0x5b,0x52,0x11,0x09,0x09,0x00,0x00,0x00
212 ,0x00,0x12,0x00,0x08,0x00,0x5b,0x52,0x51,0x09,0x09,0x09,0x09,0x00,0x64
213 ,0x5b,0x52,0x52,0x09,0x5b,0x09,0x12,0x6d,0x5b,0x5b,0x5b,0x5b,0x5a,0x11
214 ,0x00,0x6d,0x6d,0x24,0x64,0x64,0x5b,0x5b,0x00,0x5a,0x12,0x52,0x12,0x09
215 ,0x12,0x08,0x00,0x5b,0x12,0x09,0x09,0x09,0x08,0x09,0x00,0x64,0x5b,0x5b
216 ,0x52,0x5a,0x5b,0x09,0x12,0x6d,0x64,0x5a,0x5b,0x5b,0x5b,0x5b,0x00,0x5a
217 ,0x11,0x52,0x09,0x12,0x09,0x09,0x09,0x00,0x00,0x00,0x00,0x12,0x12,0x12
218 ,0x12,0x64,0x52,0x5b,0x5b,0x5b,0x5b,0x09,0x12,0x6d,0x12,0x5b,0x12,0x52
219 ,0x5b,0x52,0x09,0x5a,0x09,0x51,0x09,0x09,0x09,0x09,0x09,0x5c,0x64,0x6d
220 ,0x1b,0x24,0x64,0x08,0x12,0x64,0x5b,0x52,0x5b,0x5b,0x52,0x09,0x00,0x5b
221 ,0x5b,0x52,0x11,0x5b,0x12,0x09,0x08,0x5b,0x5a,0x09,0x51,0x52,0x12,0x08
222 ,0x00,0x5b,0x5b,0x11,0x5b,0x5b,0x5b,0x08,0x09,0x5b,0x12,0x52,0x52,0x09
223 ,0x09,0x09,0x00,0x6d,0x5b,0x52,0x52,0x12,0x12,0x09,0x08,0x11,0x00,0x49
224 ,0x09,0x00,0x09,0x00,0x00,0x6d,0x12,0x5b,0x52,0x5b,0x52,0x09,0x00,0x00
225 ,0x09,0x09,0x12,0x00,0x12,0x00,0x00,0x64,0x52,0x5b,0x52,0x5b,0x52,0x09
226 ,0x09,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x64,0x52,0x5b,0x5b,0x52
227 ,0x52,0x09
230 const unsigned char texture2[] =
231 { 32, 32 // width, height
232 ,0x65,0x1d,0x01,0x1c,0x12,0x0a,0x01,0x13,0x14,0x6e,0x2e,0x0b,0x1c,0x1d
233 ,0x2e,0x1d,0x13,0x0b,0x13,0x65,0x1d,0x1d,0x13,0x66,0x6f,0x6e,0x65,0x6f
234 ,0x77,0x7f,0x6f,0x6f,0x1d,0x14,0x13,0x6e,0x6e,0x66,0x6f,0x77,0x77,0x6f
235 ,0x66,0x66,0x13,0x25,0x0a,0x01,0x6e,0x66,0x01,0x12,0x02,0x01,0x1b,0x6e
236 ,0x77,0x77,0x77,0x77,0x77,0x6f,0x6f,0x6e,0x1c,0x1d,0x1c,0x77,0x67,0x6f
237 ,0x6f,0x77,0x67,0x77,0x77,0x66,0x13,0x0a,0x14,0x77,0x66,0x6f,0x77,0x66
238 ,0x1b,0x13,0x66,0x77,0x6f,0x77,0x6f,0x6f,0x6f,0x26,0x6e,0x1d,0x25,0x14
239 ,0x13,0x6e,0x6f,0x6f,0x77,0x6f,0x77,0x77,0x77,0x1d,0x1d,0x01,0x25,0x67
240 ,0x7f,0x6f,0x6f,0x66,0x66,0x14,0x66,0x6f,0x7f,0x6f,0x77,0x6f,0x1d,0x25
241 ,0x1d,0x66,0x1d,0x65,0x14,0x2e,0x26,0x77,0x6d,0x67,0x6f,0x25,0x6f,0x5e
242 ,0x5d,0x0b,0x5d,0x6f,0x6f,0x26,0x1d,0x77,0x66,0x1c,0x13,0x6f,0x6f,0x6f
243 ,0x66,0x67,0x66,0x65,0x6e,0x1c,0x1b,0x0a,0x01,0x1d,0x65,0x1e,0x6f,0x6e
244 ,0x67,0x66,0x66,0x65,0x14,0x1c,0x25,0x65,0x6e,0x66,0x66,0x6e,0x66,0x1c
245 ,0x02,0x1d,0x77,0x6e,0x77,0x66,0x25,0x13,0x5c,0x1d,0x0a,0x14,0x0b,0x14
246 ,0x6e,0x65,0x1d,0x66,0x1d,0x66,0x1d,0x66,0x14,0x25,0x14,0x6e,0x66,0x25
247 ,0x66,0x5d,0x66,0x25,0x0a,0x6e,0x6f,0x6f,0x6e,0x1d,0x13,0x65,0x5c,0x01
248 ,0x0a,0x15,0x1d,0x0a,0x01,0x5d,0x6e,0x5c,0x25,0x1d,0x1e,0x26,0x1d,0x1b
249 ,0x14,0x25,0x25,0x1d,0x14,0x1d,0x14,0x13,0x01,0x25,0x6e,0x25,0x25,0x25
250 ,0x1d,0x1c,0x01,0x0a,0x14,0x14,0x5d,0x14,0x14,0x0a,0x1d,0x5d,0x1c,0x6e
251 ,0x1d,0x65,0x5d,0x1d,0x0a,0x01,0x14,0x1c,0x25,0x0a,0x01,0x12,0x1c,0x0b
252 ,0x01,0x1c,0x14,0x25,0x0b,0x1b,0x25,0x14,0x25,0x02,0x1d,0x25,0x1d,0x09
253 ,0x13,0x1c,0x1d,0x66,0x1d,0x1c,0x0b,0x14,0x0b,0x65,0x2d,0x09,0x0a,0x09
254 ,0x14,0x66,0x6f,0x66,0x66,0x1c,0x0a,0x01,0x0b,0x14,0x66,0x1c,0x1d,0x1c
255 ,0x66,0x66,0x65,0x6e,0x1c,0x09,0x1c,0x1d,0x14,0x1c,0x0b,0x01,0x1d,0x6e
256 ,0x77,0x66,0x1c,0x1c,0x6e,0x6f,0x6f,0x77,0x7f,0x77,0x5e,0x6e,0x6f,0x67
257 ,0x6f,0x6f,0x0a,0x0a,0x66,0x67,0x66,0x25,0x13,0x1c,0x24,0x14,0x25,0x1c
258 ,0x0b,0x1d,0x6e,0x77,0x7f,0x77,0x5e,0x1c,0x65,0x6f,0x7f,0x6e,0x6f,0x77
259 ,0x6f,0x67,0x6f,0x6f,0x66,0x25,0x14,0x6f,0x6f,0x77,0x6f,0x67,0x6e,0x13
260 ,0x0a,0x09,0x13,0x12,0x1d,0x66,0x6f,0x66,0x5e,0x6e,0x66,0x25,0x14,0x25
261 ,0x26,0x25,0x6f,0x1d,0x77,0x6f,0x66,0x6e,0x66,0x1c,0x12,0x6f,0x6f,0x67
262 ,0x77,0x1d,0x77,0x13,0x66,0x77,0x6f,0x6f,0x6f,0x77,0x6f,0x66,0x77,0x77
263 ,0x6f,0x6e,0x13,0x25,0x26,0x25,0x66,0x65,0x66,0x66,0x6e,0x66,0x6e,0x14
264 ,0x09,0x66,0x6f,0x6e,0x2f,0x6e,0x26,0x1c,0x6f,0x66,0x6f,0x7f,0x6f,0x7f
265 ,0x6f,0x6f,0x6e,0x6e,0x66,0x6f,0x13,0x13,0x1d,0x66,0x1d,0x25,0x66,0x65
266 ,0x6e,0x1d,0x1d,0x0a,0x14,0x6f,0x77,0x77,0x2e,0x25,0x1c,0x0a,0x65,0x6f
267 ,0x6f,0x6f,0x7f,0x6f,0x77,0x77,0x66,0x6f,0x6e,0x6e,0x25,0x14,0x01,0x0a
268 ,0x09,0x0a,0x0b,0x14,0x1d,0x0a,0x14,0x13,0x66,0x6f,0x6f,0x25,0x1c,0x5d
269 ,0x65,0x01,0x66,0x1e,0x6f,0x6f,0x6f,0x77,0x6f,0x6f,0x6e,0x6f,0x66,0x1d
270 ,0x1d,0x0a,0x66,0x6f,0x66,0x2e,0x6e,0x6e,0x14,0x13,0x12,0x14,0x6f,0x6f
271 ,0x6e,0x6e,0x25,0x0a,0x13,0x12,0x6e,0x6f,0x66,0x6f,0x66,0x65,0x66,0x6f
272 ,0x66,0x25,0x66,0x25,0x0a,0x01,0x6e,0x77,0x77,0x6f,0x6f,0x6e,0x6e,0x14
273 ,0x1d,0x6e,0x1b,0x25,0x1d,0x1c,0x1d,0x14,0x01,0x25,0x25,0x66,0x6e,0x6f
274 ,0x1d,0x6f,0x66,0x1d,0x1d,0x1d,0x6e,0x1d,0x0b,0x6e,0x6f,0x77,0x7f,0x6f
275 ,0x77,0x77,0x66,0x66,0x13,0x5d,0x13,0x0a,0x01,0x1c,0x13,0x0a,0x6e,0x09
276 ,0x1d,0x65,0x25,0x66,0x66,0x6e,0x65,0x25,0x65,0x6e,0x1d,0x65,0x13,0x65
277 ,0x6f,0x77,0x67,0x7f,0x6f,0x77,0x6f,0x6e,0x14,0x1c,0x1c,0x6e,0x77,0x6e
278 ,0x77,0x6f,0x25,0x0a,0x1c,0x1d,0x1d,0x66,0x1d,0x6e,0x15,0x26,0x25,0x5e
279 ,0x25,0x13,0x1d,0x77,0x77,0x66,0x66,0x6e,0x6f,0x77,0x7f,0x6e,0x12,0x13
280 ,0x66,0x77,0x6f,0x77,0x6f,0x77,0x26,0x6f,0x0b,0x25,0x1c,0x25,0x25,0x25
281 ,0x66,0x1d,0x1b,0x25,0x0a,0x1d,0x6e,0x67,0x67,0x6f,0x66,0x1d,0x65,0x6e
282 ,0x67,0x6f,0x6e,0x13,0x77,0x7f,0x67,0x77,0x77,0x77,0x6f,0x6e,0x5d,0x13
283 ,0x14,0x1d,0x1c,0x1d,0x1d,0x14,0x1d,0x0a,0x09,0x1c,0x66,0x77,0x66,0x67
284 ,0x6e,0x1c,0x65,0x66,0x66,0x6d,0x1c,0x09,0x6e,0x67,0x6f,0x7f,0x6f,0x77
285 ,0x6f,0x6e,0x66,0x0a,0x01,0x13,0x1d,0x14,0x65,0x14,0x02,0x01,0x1d,0x1c
286 ,0x13,0x66,0x2e,0x66,0x77,0x6e,0x1e,0x25,0x25,0x6e,0x0a,0x13,0x6e,0x67
287 ,0x26,0x67,0x6f,0x77,0x67,0x6f,0x1d,0x6e,0x14,0x0a,0x01,0x13,0x01,0x25
288 ,0x66,0x77,0x66,0x65,0x1c,0x0b,0x66,0x25,0x66,0x66,0x25,0x6e,0x66,0x1d
289 ,0x14,0x0a,0x1d,0x66,0x66,0x66,0x6f,0x6e,0x6f,0x6f,0x5d,0x1d,0x0a,0x25
290 ,0x26,0x6f,0x6f,0x6f,0x7f,0x6f,0x6f,0x6f,0x77,0x0a,0x09,0x1d,0x6f,0x6e
291 ,0x15,0x25,0x1c,0x1d,0x1d,0x13,0x25,0x66,0x1c,0x6e,0x66,0x26,0x66,0x66
292 ,0x25,0x1c,0x0a,0x66,0x6f,0x7f,0x6f,0x6f,0x6f,0x66,0x6f,0x77,0x6e,0x66
293 ,0x0a,0x1b,0x26,0x1d,0x5e,0x1d,0x65,0x13,0x0a,0x1d,0x66,0x6e,0x25,0x6e
294 ,0x1d,0x1d,0x6e,0x25,0x13,0x1d,0x14,0x5e,0x77,0x27,0x7f,0x77,0x7f,0x67
295 ,0x66,0x67,0x1d,0x1d,0x13,0x09,0x76,0x66,0x24,0x1c,0x1b,0x13,0x13,0x1d
296 ,0x25,0x25,0x5e,0x1d,0x6e,0x25,0x1c,0x25,0x66,0x1d,0x09,0x1d,0x77,0x6f
297 ,0x66,0x6f,0x66,0x66,0x66,0x6e,0x65,0x66,0x65,0x1c,0x1d,0x1d,0x65,0x14
298 ,0x1c,0x25,0x0a,0x0a,0x0a,0x25,0x1d,0x66,0x14,0x25,0x66,0x6e,0x1d,0x25
299 ,0x09,0x1c,0x66,0x77,0x6f,0x66,0x7f,0x77,0x1d,0x6e,0x1c,0x1d,0x1d,0x0a
300 ,0x25,0x66,0x1d,0x25,0x13,0x0a,0x1d,0x14,0x1e,0x13,0x1d,0x14,0x65,0x66
301 ,0x66,0x25,0x1d,0x14,0x0a,0x14,0x15,0x65,0x7f,0x77,0x66,0x25,0x1d,0x1d
302 ,0x1d,0x6e,0x1c,0x14,0x13,0x65,0x1d,0x1c,0x0a,0x0a,0x65,0x1d,0x25,0x0a
303 ,0x1c,0x1d,0x1c,0x25,0x1d,0x1c,0x14,0x01,0x1b,0x0a,0x1d,0x65,0x6f,0x1d
304 ,0x66,0x65,0x6e,0x66,0x1d,0x14,0x0a,0x0a,0x1b,0x12,0x1c,0x0a,0x14,0x6e
305 ,0x66,0x25
308 const unsigned char texture3[] =
309 { 32, 32 // width, height
310 ,0xb6,0x3d,0x33,0x33,0x3e,0x33,0x2a,0x29,0x2a,0x29,0x2a,0x20,0x29,0x29
311 ,0x2a,0x29,0x10,0x10,0x10,0x49,0x58,0x99,0x50,0x50,0x10,0x4b,0x54,0x54
312 ,0x55,0x55,0x4a,0x49,0x29,0x3d,0x3d,0x7c,0x3d,0x33,0x34,0x3d,0x33,0x33
313 ,0x33,0x20,0x20,0x29,0x10,0x20,0x10,0x50,0x10,0x49,0x10,0x99,0x51,0x51
314 ,0x33,0x10,0x53,0x66,0x67,0x15,0x54,0x4b,0x7f,0x33,0x7f,0x3d,0x3e,0x3d
315 ,0x33,0x3d,0x29,0x29,0x2a,0x20,0x20,0x2a,0x10,0x20,0x10,0x51,0x50,0x50
316 ,0x58,0x51,0x51,0x51,0x33,0x33,0x10,0x55,0x5e,0x67,0x26,0x66,0x29,0x7f
317 ,0x3e,0x3d,0x3d,0x33,0x3d,0x33,0x29,0x10,0x10,0x20,0x33,0x10,0x10,0x2a
318 ,0x58,0x59,0x50,0x10,0x51,0x51,0x10,0x51,0x52,0x37,0x37,0x10,0x10,0x5d
319 ,0x53,0x55,0x6c,0x3e,0x3d,0x33,0x33,0x3d,0x33,0x29,0x10,0x2a,0x20,0x20
320 ,0x29,0x20,0x10,0x10,0x58,0x10,0x10,0x10,0x58,0x49,0x51,0x99,0x49,0x37
321 ,0x37,0x33,0x33,0x10,0x10,0x49,0x7f,0x7f,0x33,0x3d,0x3d,0x7f,0x33,0x3e
322 ,0x29,0x2a,0x29,0x2a,0x29,0x2a,0x20,0x20,0x20,0x50,0x51,0x10,0x58,0x51
323 ,0x51,0x99,0x49,0x00,0x33,0x10,0x10,0x10,0x10,0x10,0x3d,0x7f,0x3d,0x33
324 ,0x3d,0x3d,0x33,0x2a,0x2a,0x20,0x29,0x29,0x29,0x10,0x20,0x19,0x10,0x19
325 ,0x51,0x50,0x58,0x51,0x49,0x99,0x00,0x00,0x10,0x10,0x33,0x33,0x33,0x10
326 ,0x3d,0x7f,0x7f,0x33,0x3e,0x33,0x33,0x33,0x29,0x20,0x33,0x2a,0x20,0x58
327 ,0x58,0x19,0x19,0x51,0x10,0x51,0x59,0x51,0x51,0x51,0x00,0x10,0x10,0x00
328 ,0x00,0x10,0x10,0x10,0x3d,0xb6,0x2a,0x3e,0x33,0x3d,0x33,0x3d,0x2a,0x10
329 ,0x20,0x2a,0x10,0x58,0x58,0x19,0x50,0x19,0x58,0x10,0x58,0x99,0x51,0x49
330 ,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x3d,0x2a,0x6c,0x3d,0x3e,0x33
331 ,0x33,0x29,0x33,0x29,0x10,0x29,0x20,0x69,0x58,0x10,0x19,0x10,0x99,0x10
332 ,0x58,0x99,0x49,0x99,0x51,0x00,0x00,0x00,0x10,0x10,0x10,0x53,0xb6,0x3d
333 ,0x6c,0x33,0x33,0x33,0x3d,0x29,0x20,0x33,0x20,0x20,0x29,0x20,0x51,0x51
334 ,0x51,0x50,0x99,0x58,0x99,0x49,0x99,0x49,0x00,0x00,0x00,0x10,0x10,0x00
335 ,0x00,0x53,0x29,0x3e,0x7f,0x29,0x33,0x2a,0x33,0x29,0x29,0x33,0x20,0x29
336 ,0x10,0x58,0x10,0x49,0x51,0x58,0x99,0x49,0x49,0x51,0x51,0x00,0x00,0x00
337 ,0x00,0x00,0x00,0x00,0x53,0x33,0x29,0x33,0x7e,0x33,0xb6,0x2a,0x33,0x29
338 ,0x20,0x10,0x29,0x20,0x10,0x58,0x59,0x10,0x50,0x99,0x49,0x49,0x49,0x49
339 ,0x51,0x9a,0x4b,0x53,0x53,0x4a,0x4a,0x15,0x37,0x37,0x2d,0x7c,0x3e,0x3d
340 ,0x7f,0x29,0x2a,0x10,0x29,0x10,0x10,0x20,0x29,0x58,0x51,0x51,0x99,0x51
341 ,0x49,0x49,0x99,0x10,0x49,0x49,0x4a,0x4b,0x53,0x56,0x56,0x33,0x37,0x37
342 ,0x6c,0x33,0x3d,0x3d,0x3d,0x7f,0x20,0x10,0x29,0x10,0x10,0x99,0x10,0x58
343 ,0x51,0x49,0x49,0x49,0x49,0x58,0x49,0x51,0x4a,0x4b,0x4b,0x54,0x66,0x67
344 ,0x67,0x33,0x10,0x10,0xb6,0x3d,0x33,0x7f,0x29,0x3d,0x33,0x33,0x29,0x29
345 ,0xac,0x58,0x10,0x49,0x49,0x49,0x49,0x49,0x49,0x50,0x59,0x51,0x51,0x51
346 ,0x54,0x15,0x66,0x5e,0x33,0x10,0x56,0x54,0xb6,0x3d,0x33,0x33,0x3e,0x33
347 ,0x29,0x33,0x33,0x33,0x10,0x10,0x10,0x51,0x49,0x49,0x49,0x49,0x49,0x49
348 ,0x58,0x50,0x50,0x49,0x4b,0x54,0x54,0x55,0x55,0x55,0x4a,0x49,0x29,0x3d
349 ,0x3d,0x7c,0x7f,0x6c,0x2a,0x29,0x10,0x10,0x10,0x19,0x20,0x10,0x99,0x51
350 ,0x51,0x49,0x49,0x49,0x10,0x51,0x51,0x51,0x52,0x53,0x66,0x67,0x67,0x15
351 ,0x54,0x4b,0x29,0x33,0x7f,0x3d,0x6c,0x29,0x33,0x20,0x29,0x10,0x20,0x20
352 ,0x99,0x10,0x99,0x51,0x58,0x99,0x49,0x49,0x49,0x51,0x51,0x4b,0x4b,0x53
353 ,0x55,0x5e,0x5e,0x67,0x26,0x66,0x29,0x7f,0x3e,0x3d,0x29,0x29,0x33,0x2a
354 ,0x2a,0x20,0x33,0x20,0x61,0x20,0x58,0x10,0x10,0x99,0x99,0x49,0x49,0x10
355 ,0x51,0x52,0x4a,0x4b,0x53,0x54,0x54,0x5d,0x53,0x55,0x6c,0x7f,0x6c,0x29
356 ,0x33,0x3d,0x2a,0x20,0x29,0x2a,0x10,0x2a,0x20,0x20,0x58,0x10,0x10,0x58
357 ,0x99,0x51,0x51,0x49,0x99,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x54,0x54
358 ,0xb6,0xb6,0x33,0x3d,0x3e,0x3e,0x2a,0x33,0x20,0x2a,0x20,0x33,0x2a,0x58
359 ,0x58,0x50,0x10,0x58,0x10,0x10,0x58,0x99,0x00,0x99,0x00,0x00,0x00,0x00
360 ,0x33,0x10,0x00,0x49,0xb6,0x29,0x3f,0x33,0x33,0x33,0x3d,0x33,0x20,0x2a
361 ,0x33,0x2a,0x29,0x58,0x99,0x10,0x50,0x10,0x10,0x10,0x10,0x99,0x51,0x00
362 ,0x51,0x00,0x10,0x10,0x33,0x33,0x10,0x00,0x3d,0x6c,0x3d,0x33,0x3e,0x33
363 ,0x33,0x2a,0x2a,0x2a,0x33,0x29,0x10,0x58,0x58,0x10,0x10,0x10,0x51,0x10
364 ,0x50,0x99,0x51,0x51,0x00,0x00,0x00,0x10,0x10,0x37,0x37,0x10,0x7f,0xb6
365 ,0x33,0x3d,0x33,0x3f,0x2a,0x33,0x2a,0x33,0x29,0x10,0x10,0x29,0x10,0x33
366 ,0x10,0x50,0x49,0x10,0x51,0x51,0x51,0x51,0x51,0x00,0x00,0x00,0x00,0x33
367 ,0x37,0x33,0x3d,0x2a,0x3d,0x3d,0x3e,0x33,0x33,0x2a,0x2a,0x33,0x33,0x10
368 ,0x2a,0x20,0x10,0x10,0x10,0x50,0x49,0x58,0x51,0x51,0x58,0x99,0x00,0x00
369 ,0x00,0x00,0x00,0x10,0x33,0x33,0x7f,0x3d,0x33,0x7f,0x3d,0x3d,0x33,0x3d
370 ,0x20,0x29,0x20,0x33,0x2a,0x10,0x10,0x2a,0x10,0x10,0x10,0x58,0x99,0x51
371 ,0x59,0x99,0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x33,0x29,0x3e,0x3d,0x3d
372 ,0x7c,0x3e,0x2a,0x3d,0x2c,0x2a,0x20,0x33,0x29,0x20,0x10,0x2a,0x10,0x10
373 ,0x49,0x10,0x99,0x49,0x51,0x51,0x49,0x00,0x10,0x10,0x10,0x10,0x53,0x14
374 ,0x29,0x33,0x7e,0x33,0x3d,0x3d,0x33,0x33,0x29,0x20,0x20,0x33,0x20,0x20
375 ,0x20,0x20,0x10,0x51,0x50,0x10,0x99,0x49,0x49,0x51,0x9a,0x4b,0x53,0x53
376 ,0x4a,0x15,0x56,0x54,0x2d,0x7c,0x3e,0x3d,0x3d,0x7e,0x3d,0x3d,0x2a,0x33
377 ,0x10,0x29,0x2a,0x29,0x10,0x20,0x10,0x58,0x58,0x58,0x99,0x51,0x10,0x49
378 ,0x49,0x4a,0x4b,0x53,0x56,0x54,0x4b,0x54,0x6c,0x33,0x3d,0x3d,0x3d,0x33
379 ,0x3d,0x33,0x29,0x33,0x20,0x20,0x20,0x10,0x2a,0x10,0x50,0x99,0x58,0x58
380 ,0x51,0x51,0x51,0x4a,0x4b,0x4b,0x54,0x66,0x67,0x56,0x2e,0x5e,0xb6,0x3d
381 ,0x33,0x7f,0x29,0x3d,0x2a,0x29,0x33,0x29,0x20,0x2a,0x10,0x10,0x2a,0x10
382 ,0x10,0x50,0x10,0x50,0x59,0x51,0x51,0x51,0x51,0x54,0x15,0x66,0x5e,0x15
383 ,0x56,0x54
386 const unsigned char texture4[] =
387 { 32, 32 // width, height
388 ,0x12,0x1c,0x65,0x65,0x65,0x65,0x1c,0x1c,0x1c,0x1c,0x1c,0x1b,0x1b,0x1b
389 ,0x13,0x00,0x5b,0x5b,0xad,0xad,0xad,0xad,0x5b,0x00,0x64,0xad,0xad,0x64
390 ,0x64,0x64,0x5b,0x00,0x1c,0x1b,0x1b,0x1b,0x13,0x13,0x12,0x13,0x12,0x12
391 ,0x12,0x12,0x0a,0x0a,0x09,0x00,0x5b,0x5b,0xad,0xad,0xad,0x64,0x5b,0x00
392 ,0xad,0x64,0x64,0x64,0x64,0x64,0x5b,0x00,0x65,0x1b,0x1b,0x13,0x13,0x12
393 ,0x0a,0x0a,0x12,0x0a,0x0a,0x0a,0x0a,0x09,0x09,0x00,0x5b,0x5b,0xad,0xad
394 ,0xad,0x64,0x5b,0x00,0xad,0x64,0x64,0x64,0x64,0x64,0x5b,0x00,0x65,0x1b
395 ,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x0a,0x09,0x00
396 ,0x5b,0x5b,0xad,0xad,0x64,0x64,0x5b,0x00,0x64,0x64,0x64,0x64,0x64,0x64
397 ,0x12,0x00,0x65,0x13,0x12,0x00,0x09,0x09,0x0a,0x09,0x09,0x09,0x09,0x09
398 ,0x13,0x0a,0x09,0x00,0x5b,0x5b,0xad,0x64,0x64,0x5b,0x5b,0x00,0x64,0x64
399 ,0x64,0x64,0x64,0x64,0x5b,0x00,0x65,0x13,0x12,0x00,0x09,0x0a,0x12,0x12
400 ,0x0a,0x12,0x12,0x0a,0x1b,0x0a,0x09,0x00,0x5b,0x5b,0x64,0x64,0x5b,0x64
401 ,0x5b,0x00,0x64,0x64,0x64,0x64,0x64,0x64,0x5b,0x00,0x65,0x12,0x13,0x00
402 ,0x09,0x12,0x0a,0x0a,0x12,0x0a,0x0a,0x0a,0x1c,0x09,0x0a,0x00,0x5b,0x5b
403 ,0x64,0x64,0x64,0x64,0x5b,0x00,0x5b,0x5b,0x5b,0x12,0x5b,0x12,0x5b,0x00
404 ,0x65,0x13,0x12,0x00,0x09,0x12,0x0a,0x0a,0x0a,0x09,0x0a,0x09,0x1c,0x0a
405 ,0x0a,0x00,0x5b,0x5b,0xad,0x64,0x5b,0x64,0x5b,0x00,0x00,0x00,0x00,0x00
406 ,0x00,0x00,0x00,0x00,0x1c,0x12,0x0a,0x00,0x09,0x12,0x0a,0x0a,0x09,0x0a
407 ,0x09,0x09,0x1c,0x0a,0x0a,0x00,0x52,0x52,0x64,0x64,0x64,0x5b,0x5b,0x00
408 ,0xad,0xad,0xad,0xad,0xad,0xad,0x5b,0x00,0x1c,0x12,0x0a,0x00,0x09,0x0a
409 ,0x0a,0x0a,0x09,0x09,0x09,0x09,0x65,0x0a,0x09,0x00,0x5b,0x52,0x64,0x64
410 ,0x5b,0x64,0x5b,0x00,0xad,0xad,0xad,0xad,0xad,0x64,0x5b,0x00,0x1b,0x0a
411 ,0x12,0x00,0x09,0x0a,0x09,0x09,0x0a,0x0a,0x09,0x09,0x65,0x09,0x09,0x00
412 ,0x5b,0x5b,0x5b,0x64,0x5b,0x5b,0x5b,0x00,0xad,0xad,0xad,0xad,0xad,0x64
413 ,0x5b,0x00,0x1b,0x12,0x0a,0x00,0x09,0x0a,0x0a,0x09,0x0a,0x09,0x09,0x0a
414 ,0x1c,0x09,0x09,0x00,0x52,0x12,0x64,0x64,0x64,0x5b,0x5b,0x00,0xad,0xad
415 ,0xad,0xad,0x64,0x64,0x5b,0x00,0x1b,0x0a,0x09,0x09,0x13,0x1b,0x1c,0x1c
416 ,0x65,0x65,0x1c,0x1c,0x1b,0x09,0x09,0x00,0x5b,0x52,0x64,0x64,0x64,0x5b
417 ,0x12,0x00,0xad,0xad,0xad,0x64,0x64,0x5b,0x5b,0x00,0x1b,0x0a,0x09,0x0a
418 ,0x09,0x09,0x09,0x0a,0x09,0x0a,0x09,0x09,0x09,0x09,0x09,0x00,0x12,0x12
419 ,0x5b,0x5b,0x5b,0x5b,0x5b,0x00,0xad,0xad,0x64,0x64,0x5b,0x5b,0x12,0x00
420 ,0x13,0x09,0x09,0x09,0x09,0x09,0x0a,0x0a,0x09,0x09,0x09,0x09,0x09,0x09
421 ,0x09,0x00,0x09,0x09,0x5b,0x12,0x12,0x12,0x12,0x00,0xad,0xad,0x64,0x64
422 ,0x64,0x64,0x5b,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
423 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
424 ,0xad,0x64,0x64,0x5b,0x5b,0x5b,0x12,0x00,0x12,0x1c,0x65,0x65,0x65,0x65
425 ,0x1c,0x1c,0x1c,0x1c,0x1c,0x1b,0x1b,0x1b,0x13,0x00,0x5b,0x5b,0xad,0x64
426 ,0xad,0xad,0x5b,0x00,0x64,0x64,0x64,0x5b,0x5b,0x64,0x5b,0x00,0x1c,0x1b
427 ,0x1b,0x1b,0x1b,0x13,0x12,0x13,0x12,0x12,0x12,0x12,0x0a,0x0a,0x09,0x00
428 ,0x5b,0x5b,0xad,0xad,0xad,0x64,0x5b,0x00,0xad,0x64,0x5b,0x5b,0x5b,0x5b
429 ,0x5b,0x00,0x65,0x1b,0x1b,0x13,0x13,0x12,0x0a,0x0a,0x12,0x0a,0x0a,0x0a
430 ,0x0a,0x09,0x09,0x00,0x5b,0x5b,0xad,0x64,0x64,0x64,0x5b,0x00,0x64,0x64
431 ,0x64,0x64,0x5b,0x5b,0x5b,0x00,0x65,0x13,0x1b,0x00,0x00,0x00,0x00,0x00
432 ,0x00,0x00,0x00,0x00,0x09,0x0a,0x09,0x00,0x5b,0x5b,0x64,0x64,0x64,0x64
433 ,0x5b,0x00,0x64,0x64,0x64,0x64,0x5b,0x64,0x5b,0x00,0x65,0x1b,0x13,0x00
434 ,0x09,0x09,0x0a,0x09,0x09,0x09,0x09,0x09,0x1b,0x0a,0x09,0x00,0x5b,0x5b
435 ,0xad,0x64,0x5b,0x64,0x5b,0x00,0x64,0x64,0x64,0x64,0x5b,0x5b,0x5b,0x00
436 ,0x65,0x13,0x12,0x00,0x09,0x0a,0x12,0x12,0x0a,0x12,0x12,0x12,0x1b,0x0a
437 ,0x09,0x00,0x5b,0x52,0x64,0x64,0x5b,0x5b,0x5b,0x00,0x64,0x64,0x64,0x64
438 ,0x5b,0x5b,0x12,0x00,0x65,0x12,0x13,0x00,0x09,0x12,0x0a,0x0a,0x0a,0x0a
439 ,0x0a,0x0a,0x1c,0x09,0x0a,0x00,0x5b,0x5b,0x64,0x64,0x5b,0x64,0x5b,0x00
440 ,0x5b,0x5b,0x5b,0x5b,0x5b,0x12,0x5b,0x00,0x65,0x13,0x12,0x00,0x09,0x12
441 ,0x0a,0x0a,0x0a,0x09,0x0a,0x09,0x1c,0x0a,0x0a,0x00,0x5b,0x52,0x64,0x5b
442 ,0x64,0x5b,0x5b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x12
443 ,0x0a,0x00,0x09,0x12,0x0a,0x0a,0x09,0x0a,0x09,0x09,0x1c,0x0a,0x0a,0x00
444 ,0x52,0x5b,0x64,0x64,0x5b,0x5b,0x5b,0x00,0xad,0xad,0xad,0xad,0xad,0xad
445 ,0x5b,0x00,0x1c,0x12,0x0a,0x00,0x09,0x0a,0x0a,0x0a,0x09,0x09,0x09,0x09
446 ,0x65,0x0a,0x09,0x00,0x5b,0x52,0x64,0x64,0x5b,0x5b,0x5b,0x00,0xad,0xad
447 ,0xad,0xad,0xad,0x64,0x5b,0x00,0x1b,0x0a,0x12,0x00,0x09,0x0a,0x09,0x09
448 ,0x0a,0x0a,0x09,0x09,0x65,0x09,0x09,0x00,0x52,0x12,0x64,0x5b,0x5b,0x5b
449 ,0x5b,0x00,0xad,0xad,0xad,0xad,0xad,0x64,0x5b,0x00,0x1b,0x12,0x0a,0x00
450 ,0x09,0x0a,0x0a,0x09,0x0a,0x09,0x09,0x0a,0x1c,0x09,0x09,0x00,0x52,0x52
451 ,0x5b,0x5b,0x5b,0x64,0x5b,0x00,0xad,0xad,0xad,0xad,0x64,0x64,0x5b,0x00
452 ,0x1b,0x0a,0x09,0x09,0x13,0x1b,0x1c,0x1c,0x65,0x65,0x1c,0x1c,0x1b,0x09
453 ,0x09,0x00,0x12,0x12,0x5b,0x5b,0x5b,0x5b,0x5b,0x00,0xad,0xad,0xad,0xad
454 ,0xad,0x64,0x5b,0x00,0x1b,0x0a,0x09,0x0a,0x0a,0x09,0x09,0x09,0x09,0x09
455 ,0x09,0x09,0x09,0x09,0x09,0x00,0x12,0x12,0x5b,0x5b,0x5b,0x5b,0x12,0x00
456 ,0xad,0xad,0xad,0x64,0xad,0x64,0x5b,0x00,0x13,0x09,0x0a,0x09,0x09,0x09
457 ,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x00,0x09,0x12,0x5b,0x5b
458 ,0x5b,0x12,0x5b,0x00,0xad,0xad,0x64,0x64,0xad,0x64,0x5b,0x00,0x0a,0x00
459 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
460 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xad,0x64,0xad,0x64,0xad,0x64
461 ,0x12,0x00
464 const unsigned char sprite1[] =
465 { 32, 32 // width, height
466 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00
467 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x07,0x07
468 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
469 ,0x00,0x00,0x00,0x64,0x64,0x64,0x76,0x64,0x64,0x64,0x64,0x64,0x00,0x07
470 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
471 ,0x07,0x07,0x00,0x00,0x64,0x76,0x64,0x00,0x00,0x00,0x00,0x00,0x00,0x00
472 ,0x00,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07
473 ,0x07,0x07,0x07,0x07,0x00,0x00,0x76,0x64,0x00,0x00,0x00,0x09,0x09,0x09
474 ,0x00,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x52,0x76,0x76,0x64
475 ,0x52,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x76,0x64,0x00,0x09,0x09,0x09
476 ,0x09,0x09,0x52,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x52
477 ,0x09,0x76,0x52,0x64,0x52,0x00,0x07,0x07,0x07,0x00,0xff,0x76,0x09,0x09
478 ,0x52,0x09,0x52,0x09,0x09,0x52,0x09,0x00,0x07,0x07,0x07,0x07,0x07,0x07
479 ,0x00,0x76,0x76,0x64,0x52,0x64,0x09,0x64,0x52,0x00,0x07,0x07,0x00,0xff
480 ,0x09,0x09,0x09,0x52,0x09,0x52,0x09,0x52,0x52,0x52,0x52,0x00,0x00,0x07
481 ,0x07,0x07,0x07,0x00,0x52,0x76,0x52,0x64,0x09,0x76,0x52,0x64,0x52,0x00
482 ,0x07,0x00,0x76,0x52,0x52,0x64,0x64,0x52,0x52,0x52,0x52,0x64,0x52,0x64
483 ,0x64,0x64,0x64,0x00,0x07,0x07,0x00,0x52,0x09,0x76,0x09,0x64,0x52,0x76
484 ,0x09,0x64,0x52,0x00,0x00,0x76,0x64,0x00,0x00,0x00,0x00,0x00,0x64,0x52
485 ,0x52,0x52,0x52,0x52,0x00,0x00,0x00,0x07,0x07,0x07,0x00,0x52,0x09,0x64
486 ,0x52,0x64,0x52,0x76,0x52,0x64,0x52,0x00,0x00,0xff,0x00,0x07,0x07,0x07
487 ,0x07,0x07,0x00,0x64,0x52,0x52,0x52,0x00,0x00,0x00,0x07,0x07,0x07,0x07
488 ,0x00,0x00,0x09,0x76,0x09,0x64,0x09,0x64,0x52,0x52,0x52,0x00,0x07,0x00
489 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x64,0x52,0x00,0x00,0x76,0x76
490 ,0x00,0x07,0x07,0x07,0x00,0x64,0x09,0x76,0x52,0x64,0x09,0x76,0x09,0x52
491 ,0x52,0x00,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x07,0x00,0x64,0x09
492 ,0x00,0x76,0x64,0x00,0x00,0x07,0x07,0x07,0x00,0x52,0x00,0x76,0x09,0x52
493 ,0x09,0x64,0x52,0x64,0x52,0x00,0x07,0x00,0x07,0x07,0x00,0x64,0x76,0x64
494 ,0x00,0x07,0x00,0x09,0x76,0x64,0x76,0x00,0x76,0x00,0x07,0x00,0x64,0x64
495 ,0x09,0x64,0x52,0x64,0x09,0x76,0x52,0x64,0x52,0x00,0x00,0xff,0x00,0x00
496 ,0x76,0x00,0x00,0x64,0x64,0x00,0x52,0x52,0x64,0x00,0x00,0x76,0x64,0x64
497 ,0x00,0x64,0x00,0x00,0x09,0x76,0x09,0x64,0x09,0x76,0x52,0x52,0x52,0x00
498 ,0x07,0x00,0x76,0x76,0x00,0x07,0x07,0x00,0x64,0x00,0x09,0x64,0x52,0x64
499 ,0x64,0x64,0x00,0x00,0x64,0x00,0x00,0x52,0x09,0x64,0x09,0x52,0x00,0x76
500 ,0x09,0x64,0x52,0x00,0x07,0x07,0x00,0x00,0x07,0x07,0x07,0x00,0x64,0x52
501 ,0x64,0x52,0x52,0x64,0x64,0x00,0x07,0x07,0x00,0x07,0x00,0x52,0x09,0x64
502 ,0x52,0x52,0x00,0x64,0x09,0x52,0x52,0x00,0x07,0x07,0x00,0x00,0x07,0x07
503 ,0x07,0x00,0x64,0x52,0x64,0x52,0x52,0x52,0x64,0x00,0x07,0x07,0x00,0x07
504 ,0x00,0x52,0x00,0x64,0x09,0x64,0x00,0x64,0x09,0x52,0x52,0x00,0x07,0x00
505 ,0x64,0x64,0x00,0x07,0x07,0x00,0x52,0x00,0x09,0x64,0x52,0x52,0x52,0x64
506 ,0x00,0x00,0x64,0x00,0x00,0x09,0x00,0x76,0x09,0x52,0x00,0x76,0x09,0x52
507 ,0x52,0x00,0x00,0x64,0x00,0x00,0x64,0x00,0x00,0x52,0x64,0x00,0x52,0x52
508 ,0x64,0x00,0x00,0x64,0x64,0x64,0x00,0x64,0x00,0x00,0x00,0x64,0x09,0x52
509 ,0x00,0x64,0x52,0x52,0x52,0x00,0x07,0x00,0x07,0x07,0x00,0x52,0x64,0x52
510 ,0x00,0x07,0x00,0x09,0x64,0x64,0x64,0x00,0x64,0x00,0x07,0x00,0x64,0x64
511 ,0x00,0x64,0x09,0x52,0x00,0x64,0x09,0x64,0x52,0x00,0x07,0x07,0x07,0x07
512 ,0x07,0x00,0x00,0x00,0x07,0x00,0x64,0x00,0x00,0x64,0x52,0x00,0x00,0x07
513 ,0x07,0x07,0x00,0x52,0x09,0x64,0x52,0x52,0x00,0x64,0x52,0x52,0x52,0x00
514 ,0x07,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x64,0x00,0x00,0x00
515 ,0x64,0x64,0x00,0x07,0x07,0x07,0x00,0x64,0x00,0x64,0x09,0x52,0x00,0x52
516 ,0x09,0x52,0x52,0x00,0x00,0x64,0x00,0x07,0x07,0x07,0x07,0x07,0x00,0x64
517 ,0x00,0x00,0x09,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x52
518 ,0x52,0x52,0x00,0x64,0x09,0x52,0x52,0x00,0x00,0x64,0x64,0x00,0x00,0x00
519 ,0x00,0x00,0x64,0x00,0x00,0x09,0x09,0x09,0x00,0x00,0x00,0x00,0x07,0x07
520 ,0x00,0x00,0x00,0x64,0x09,0x52,0x00,0x52,0x09,0x52,0x52,0x00,0x07,0x00
521 ,0x64,0x00,0x09,0x52,0x52,0x52,0x09,0x09,0x52,0x09,0x52,0x52,0x52,0x52
522 ,0x52,0x00,0x00,0x07,0x00,0x09,0x00,0x52,0x09,0x52,0x00,0x52,0x52,0x52
523 ,0x52,0x00,0x07,0x07,0x00,0x64,0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09
524 ,0x09,0x09,0x09,0x00,0x00,0x00,0x07,0x07,0x07,0x00,0x09,0x64,0x52,0x52
525 ,0x00,0x64,0x09,0x52,0x52,0x00,0x07,0x07,0x07,0x00,0x64,0x64,0x00,0x09
526 ,0x09,0x52,0x09,0x09,0x09,0x09,0x52,0x00,0x00,0x07,0x07,0x07,0x07,0x07
527 ,0x00,0x52,0x52,0x52,0x00,0x52,0x09,0x52,0x52,0x00,0x07,0x07,0x07,0x07
528 ,0x00,0x00,0x64,0x64,0x09,0x09,0x09,0x52,0x09,0x52,0x09,0x00,0x00,0x00
529 ,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x64,0x52,0x52,0x52,0x00
530 ,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x64,0x64,0x09,0x09,0x52,0x09
531 ,0x52,0x09,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x09,0x52
532 ,0x52,0x52,0x52,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00
533 ,0x64,0x64,0x64,0x09,0x09,0x09,0x09,0x09,0x00,0x00,0x00,0x00,0x07,0x07
534 ,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x07,0x07
535 ,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x64,0x64,0x64,0x64,0x64,0x64,0x64
536 ,0x64,0x64,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
537 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x00
538 ,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
539 ,0x07,0x07
542 const unsigned char sprite2[] =
543 { 32, 32 // width, height
544 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
545 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
546 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
547 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
548 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
549 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
550 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
551 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
552 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
553 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
554 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
555 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
556 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x07,0x07,0x07
557 ,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07
558 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0xbf,0xbf
559 ,0xbf,0x00,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x27,0x00,0x07,0x07
560 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
561 ,0x07,0x00,0xbf,0x5b,0x5b,0x00,0x00,0x00,0x00,0x00,0x00,0x27,0x27,0x27
562 ,0x0c,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
563 ,0x07,0x07,0x07,0x07,0x00,0x52,0x6d,0x5b,0x09,0x0c,0x0c,0x0c,0x27,0x27
564 ,0x27,0x0c,0x0a,0x0a,0x0a,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
565 ,0x07,0x07,0x07,0x07,0x07,0x00,0x07,0x00,0x5b,0x09,0x09,0x09,0x0a,0x0a
566 ,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0b,0x0b,0x0a,0x00,0x07,0x07,0x00,0x00
567 ,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x3f,0x00,0x5b,0x09,0x5b
568 ,0x09,0x00,0x02,0x01,0x01,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x00
569 ,0x00,0x07,0x00,0x3e,0xb6,0x00,0x07,0x00,0x07,0x07,0x07,0x00,0x15,0x15
570 ,0x3d,0x09,0x09,0x09,0x00,0x01,0x01,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x01
571 ,0x01,0x01,0x01,0x52,0x52,0x00,0x07,0x00,0x3e,0x6d,0x00,0xb6,0x00,0x07
572 ,0x00,0x0c,0x0c,0x15,0x15,0x3d,0x00,0x00,0x0a,0x0a,0x00,0x00,0x00,0x01
573 ,0x01,0x01,0x01,0x01,0x01,0x01,0x52,0x6d,0x52,0x00,0x07,0x07,0x00,0x3d
574 ,0x5b,0x6d,0x00,0x00,0x27,0x27,0x0c,0x0c,0x15,0x3f,0x00,0x01,0x00,0x00
575 ,0x09,0x00,0x52,0x00,0x09,0x00,0x00,0x00,0x01,0x01,0x09,0xb6,0x09,0x00
576 ,0x07,0x07,0x07,0x00,0x3d,0x09,0x00,0x0a,0x0c,0x15,0x27,0x09,0x09,0x09
577 ,0x09,0x00,0x3f,0x00,0x52,0x09,0x64,0x00,0x3d,0x3d,0x3f,0x64,0x64,0x09
578 ,0xb6,0x6d,0x09,0x00,0x07,0x07,0x00,0xbf,0x6d,0x00,0x5b,0x52,0x0a,0x09
579 ,0x09,0x09,0x5b,0x6d,0x09,0x5b,0x3d,0x00,0x64,0x00,0x64,0x09,0x00,0x1d
580 ,0x3f,0x5b,0x52,0x52,0x09,0x52,0x00,0x00,0x07,0x00,0xb6,0xff,0x3e,0x00
581 ,0x3e,0x3e,0x3d,0x09,0x5b,0x6d,0xbf,0xb6,0x52,0x3e,0x1d,0x3d,0x00,0x64
582 ,0x00,0x52,0x00,0x00,0x09,0x52,0x52,0x12,0x09,0x00,0x00,0x00,0x00,0x3d
583 ,0x3d,0x3d,0x00,0x00,0x00,0x00,0x09,0x09,0x09,0x6d,0x6d,0x52,0x52,0x3e
584 ,0x1d,0x3d,0x00,0x64,0x00,0x52,0x00,0x02,0x00,0x00,0x09,0x00,0x00,0x01
585 ,0x00,0x00,0x07,0x00,0x52,0x5b,0x3d,0x00,0x3d,0x3f,0x3f,0x09,0x5b,0x52
586 ,0x5b,0x6d,0x52,0x3d,0x1d,0x3f,0x00,0x64,0x00,0x52,0x00,0x01,0x01,0x01
587 ,0x01,0x0a,0x0a,0x0a,0x00,0x00,0x07,0x07,0x00,0x52,0x5b,0x00,0x52,0x52
588 ,0x0a,0x27,0x09,0x09,0x09,0x09,0x52,0x5b,0x3f,0x00,0x00,0x64,0x00,0x52
589 ,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x07,0x07,0x07,0x07,0x00
590 ,0x3f,0x09,0x00,0x0a,0x0c,0x27,0x0c,0x15,0x3f,0x09,0x09,0x09,0x3f,0x00
591 ,0x64,0x00,0x52,0x09,0x00,0x3d,0x3f,0x5b,0x00,0x00,0x01,0x01,0x00,0x07
592 ,0x07,0x07,0x00,0x1d,0x52,0x5b,0x00,0x0c,0x27,0x0c,0x0c,0x15,0x0c,0x3d
593 ,0x00,0x00,0x00,0x00,0x52,0x09,0x00,0x00,0x3f,0x3e,0x3d,0x52,0x52,0x64
594 ,0x09,0x52,0x00,0x00,0x07,0x00,0x1d,0x5b,0x00,0x5b,0x00,0x27,0x0c,0x0c
595 ,0x15,0x15,0x15,0x3d,0x52,0x52,0x0a,0x52,0xbf,0x6d,0x00,0x00,0x00,0x3f
596 ,0x52,0x12,0x12,0x09,0x64,0xb6,0x52,0x00,0x00,0x3f,0x5b,0x00,0x07,0x00
597 ,0x07,0x00,0x00,0x0c,0x27,0x15,0x15,0x3e,0x00,0x09,0x52,0xbf,0x6d,0x5b
598 ,0x0a,0x0a,0x0a,0x01,0x00,0x00,0x00,0x00,0x00,0x64,0x09,0x00,0x00,0x00
599 ,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x27,0x3e,0x27,0x27,0x15
600 ,0x09,0x00,0x00,0x0a,0x0a,0x0a,0x0a,0x0a,0x01,0x01,0x01,0x00,0x00,0x09
601 ,0x09,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00
602 ,0x3d,0x0c,0x0c,0x27,0x27,0x27,0x27,0x15,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a
603 ,0x01,0x01,0x01,0x0a,0x00,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
604 ,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x27,0x27,0x27
605 ,0x27,0x15,0x15,0x0a,0x0a,0x0a,0x0a,0x0a,0x00,0x07,0x07,0x07,0x07,0x07
606 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
607 ,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x15,0x15,0x15,0x15,0x15,0x00,0x07
608 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
609 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00
610 ,0x00,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
611 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
612 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
613 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
614 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
615 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
616 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
617 ,0x07,0x07
620 const unsigned char sprite3[] =
621 { 32, 32 // width, height
622 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x7b,0x7b,0x58,0x07,0x07
623 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
624 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x7b,0x7b
625 ,0x7b,0x58,0x07,0x61,0x28,0x28,0x58,0x07,0x07,0x07,0x07,0x07,0x07,0x07
626 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
627 ,0x07,0x08,0x7b,0x7b,0x58,0x58,0x08,0x7b,0x28,0x28,0x08,0x08,0x07,0x08
628 ,0x08,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
629 ,0x07,0x7b,0x7b,0x28,0x58,0x08,0x7b,0x7b,0x58,0x58,0x7b,0x7b,0x28,0x28
630 ,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x07,0x07,0x07,0x07,0x07,0x07,0x07
631 ,0x07,0x07,0x07,0x07,0x07,0x7b,0x7b,0x7b,0x58,0x08,0x7b,0x7b,0x28,0x7b
632 ,0x7b,0x7b,0x08,0x08,0x08,0x58,0x58,0x08,0x58,0x58,0x58,0x07,0x07,0x07
633 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x7b,0x28,0x7b,0x08,0x58
634 ,0x28,0x7b,0x58,0x58,0x58,0x7b,0x58,0x08,0x08,0x58,0x58,0x58,0x58,0x58
635 ,0x08,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x13,0x07,0x07,0x28,0x7b
636 ,0x28,0x28,0x58,0x58,0x7b,0x7b,0x7b,0x28,0x7b,0x7b,0x58,0x08,0x08,0x08
637 ,0x58,0x08,0x08,0x08,0x08,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x13,0x09
638 ,0x07,0x07,0x28,0x7b,0x7b,0x28,0x28,0x7b,0x7b,0x7b,0x7b,0x28,0x7b,0x7b
639 ,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x58,0x58,0x58,0x58,0x08,0x07,0x07
640 ,0x07,0x07,0x65,0x09,0x07,0x07,0x58,0x28,0x7b,0x28,0x28,0x7b,0x7b,0x7b
641 ,0x28,0x28,0x7b,0x7b,0x08,0x08,0x58,0x58,0x7b,0x08,0x08,0x08,0x58,0x58
642 ,0x58,0x08,0x07,0x07,0x07,0x07,0x65,0x09,0x07,0x07,0x08,0x58,0x28,0x28
643 ,0x28,0x7b,0x7b,0x28,0x28,0x7b,0x7b,0x08,0x08,0x08,0x58,0x28,0x28,0x58
644 ,0x08,0x58,0x58,0x58,0x08,0x07,0x07,0x07,0x07,0x07,0x13,0x09,0x07,0x7b
645 ,0x08,0x08,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x08,0x08,0x08
646 ,0x58,0x28,0x28,0x58,0x08,0x08,0x08,0x08,0x08,0x07,0x07,0x07,0x07,0x65
647 ,0x13,0x09,0x7b,0x7b,0x08,0x58,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x7b
648 ,0x7b,0x08,0x08,0x58,0x58,0x58,0x28,0x08,0x08,0x08,0x08,0x08,0x08,0x07
649 ,0x07,0x07,0x65,0x65,0x13,0x09,0x7b,0x7b,0x7b,0x28,0x28,0x7b,0x7b,0x58
650 ,0x58,0x28,0x7b,0x7b,0x7b,0x28,0x08,0x08,0x58,0x58,0x28,0x08,0x08,0x08
651 ,0x08,0x08,0x08,0x08,0x07,0x07,0x65,0x13,0x09,0x13,0x7b,0x7b,0x28,0x28
652 ,0x28,0x28,0x7b,0x7b,0x58,0x58,0x7b,0x7b,0x28,0x28,0x08,0x08,0x08,0x08
653 ,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,0x65,0x13,0x13,0x65,0x13
654 ,0x07,0x7b,0x58,0x58,0x28,0x7b,0x7b,0x7b,0x58,0x58,0x58,0x28,0x28,0x28
655 ,0x08,0x08,0x08,0x08,0x08,0x08,0x58,0x58,0x28,0x28,0x08,0x08,0x09,0x13
656 ,0x13,0x65,0x65,0x13,0x7b,0x7b,0x7b,0x58,0x58,0x28,0x7b,0x7b,0x58,0x58
657 ,0x58,0x58,0x58,0x58,0x08,0x08,0x08,0x08,0x08,0x08,0x58,0x58,0x58,0x28
658 ,0x28,0x28,0x08,0x09,0x09,0x09,0x09,0x65,0x08,0x7b,0x7b,0x58,0x58,0x28
659 ,0x28,0x28,0x58,0x58,0x58,0x58,0x28,0x7b,0x28,0x58,0x08,0x08,0x08,0x08
660 ,0x08,0x58,0x28,0x28,0x28,0x28,0x28,0x09,0x13,0x65,0x65,0x65,0x58,0x7b
661 ,0x7b,0x7b,0x58,0x28,0x28,0x58,0x58,0x58,0x58,0x58,0x28,0x28,0x7b,0x58
662 ,0x08,0x08,0x08,0x08,0x08,0x08,0x58,0x28,0x28,0x28,0x09,0x09,0x13,0x13
663 ,0x13,0x09,0x58,0x7b,0x7b,0x28,0x28,0x28,0x28,0x58,0x58,0x58,0x58,0x58
664 ,0x28,0x7b,0x7b,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x58,0x58,0x08,0x08
665 ,0x09,0x09,0x09,0x09,0x09,0x09,0x07,0x28,0x28,0x28,0x28,0x28,0x7b,0x58
666 ,0x58,0x58,0x58,0x28,0x7b,0x28,0x08,0x08,0x08,0x08,0x28,0x28,0x08,0x58
667 ,0x58,0x28,0x08,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x07,0x28,0x58,0x28
668 ,0x28,0x28,0x7b,0x7b,0x28,0x28,0x58,0x7b,0x7b,0x7b,0x08,0x08,0x58,0x58
669 ,0x28,0x58,0x58,0x58,0x28,0x28,0x28,0x08,0x08,0x13,0x09,0x09,0x09,0x09
670 ,0x07,0x07,0x08,0x28,0x28,0x28,0x28,0x7b,0x7b,0x28,0x58,0x28,0x7b,0x7b
671 ,0x28,0x08,0x08,0x58,0x7b,0x08,0x58,0x58,0x28,0x28,0x28,0x08,0x08,0x07
672 ,0x13,0x09,0x09,0x09,0x07,0x07,0x58,0x28,0x28,0x7b,0x7b,0x7b,0x7b,0x28
673 ,0x58,0x58,0x28,0x28,0x28,0x08,0x08,0x08,0x28,0x08,0x08,0x58,0x58,0x58
674 ,0x08,0x08,0x07,0x07,0x07,0x13,0x09,0x09,0x07,0x07,0x28,0x7b,0x28,0x7b
675 ,0x28,0x7b,0x7b,0x58,0x08,0x08,0x08,0x08,0x28,0x08,0x08,0x08,0x58,0x08
676 ,0x08,0x08,0x58,0x08,0x08,0x07,0x07,0x07,0x07,0x13,0x13,0x09,0x07,0x07
677 ,0x28,0x7b,0x7b,0x7b,0x08,0x08,0x08,0x08,0x58,0x58,0x08,0x08,0x08,0x08
678 ,0x58,0x58,0x58,0x58,0x08,0x08,0x08,0x08,0x08,0x08,0x07,0x07,0x07,0x07
679 ,0x13,0x09,0x07,0x07,0x08,0x08,0x7b,0x7b,0x28,0x08,0x08,0x08,0x08,0x58
680 ,0x58,0x08,0x08,0x58,0x58,0x58,0x58,0x58,0x08,0x08,0x08,0x08,0x08,0x08
681 ,0x07,0x07,0x07,0x07,0x13,0x09,0x07,0x07,0x07,0x08,0x28,0x28,0x28,0x08
682 ,0x08,0x08,0x58,0x58,0x58,0x08,0x58,0x58,0x58,0x58,0x08,0x08,0x08,0x08
683 ,0x08,0x08,0x07,0x07,0x07,0x07,0x07,0x07,0x13,0x09,0x07,0x07,0x07,0x07
684 ,0x28,0x28,0x28,0x08,0x58,0x08,0x08,0x08,0x08,0x28,0x58,0x58,0x28,0x28
685 ,0x08,0x58,0x08,0x08,0x08,0x08,0x08,0x07,0x07,0x07,0x07,0x07,0x07,0x09
686 ,0x07,0x07,0x07,0x07,0x08,0x28,0x28,0x08,0x28,0x28,0x08,0x58,0x28,0x28
687 ,0x58,0x58,0x28,0x28,0x28,0x58,0x08,0x08,0x08,0x08,0x08,0x07,0x07,0x07
688 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x08,0x08,0x58,0x58,0x28,0x28
689 ,0x08,0x28,0x28,0x28,0x58,0x58,0x58,0x08,0x08,0x08,0x08,0x08,0x07,0x07
690 ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x08
691 ,0x58,0x08,0x28,0x28,0x08,0x08,0x28,0x28,0x08,0x08,0x08,0x08,0x08,0x08
692 ,0x08,0x08,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
693 ,0x07,0x07,0x07,0x07,0x07,0x28,0x28,0x58,0x58,0x08,0x18,0x18,0x08,0x08
694 ,0x08,0x08,0x08,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07
695 ,0x07,0x07
698 const unsigned char *textures[] = {texture1, texture2, texture3, texture4};
700 uint8_t rgbToIndex(uint8_t r, uint8_t g, uint8_t b)
702 return (r & 0b00000111) | ((g & 0b00000111) << 3) | ((b & 0b00000011) << 6);
705 uint8_t sampleImage(const unsigned char *image, Unit x, Unit y)
707 // TODO: optimize
709 x = wrap(x,UNITS_PER_SQUARE);
710 y = wrap(y,UNITS_PER_SQUARE);
712 int32_t index =
713 image[1] * ((image[0] * x) / UNITS_PER_SQUARE) + (image[0] * y) /
714 UNITS_PER_SQUARE;
716 return image[2 + index];
719 uint8_t addIntensity(uint8_t color, int16_t intensity)
721 uint8_t r = color & 0b00000111;
722 uint8_t g = (color & 0b00111000) >> 3;
723 uint8_t b = (color & 0b11000000) >> 6;
725 if (intensity >= 0)
727 r += intensity;
728 r = r > 7 ? 7 : r;
730 g += intensity;
731 g = g > 7 ? 7 : g;
733 b += intensity / 2;
734 b = b > 3 ? 3 : b;
736 else
738 intensity *= -1;
739 r = (intensity > r) ? 0 : r - intensity;
740 g = (intensity > g) ? 0 : g - intensity;
741 intensity /= 2;
742 b = intensity > b ? 0 : b - intensity;
745 return rgbToIndex(r,g,b);
748 Unit textureAt(int16_t x, int16_t y)
750 if (x >= 0 && x < LEVEL_X_RES && y >= 0 && y < LEVEL_Y_RES)
751 return levelTexture[(LEVEL_Y_RES - y -1) * LEVEL_X_RES + x];
753 return 0;
756 Unit floorHeightAt(int16_t x, int16_t y)
758 if (x == 6 && (y == 13 || y == 14)) // moving lift
759 return ((absVal(-1 * (frame % 64) + 32)) * UNITS_PER_SQUARE) / 8;
761 if (x >= 0 && x < LEVEL_X_RES && y >= 0 && y < LEVEL_Y_RES)
762 return (levelFloor[(LEVEL_Y_RES - y -1) * LEVEL_X_RES + x] * UNITS_PER_SQUARE) / 8;
764 int a = absVal(x - LEVEL_X_RES / 2) - LEVEL_X_RES / 2;
765 int b = absVal(y - LEVEL_Y_RES / 2) - LEVEL_Y_RES / 2;
767 return (a > b ? a : b) * UNITS_PER_SQUARE;
770 Unit ceilingHeightAt(int16_t x, int16_t y)
772 int v = 1024;
774 if (x >= 0 && x < LEVEL_X_RES && y >= 0 && y < LEVEL_Y_RES)
775 v = levelCeiling[(LEVEL_Y_RES - y -1) * LEVEL_X_RES + x];
777 return (v * UNITS_PER_SQUARE) / 8;
781 Draws a scaled sprite on screen in an optimized way. The sprite has to be
782 square in resolution.
784 void drawSpriteSquare(const unsigned char *sprite, int16_t x, int16_t y, Unit depth, int16_t size)
786 if (size < 0 || size > 512 || // let's not mess up with the incoming array
787 sprite[0] != sprite[1]) // only draw square sprites
788 return;
790 int16_t samplingIndices[size];
792 // optimization: precompute the indices
794 for (Unit i = 0; i < size; ++i)
795 samplingIndices[i] = (i * sprite[0]) / size;
797 x -= size / 2;
798 y -= size / 2;
800 Unit step = UNITS_PER_SQUARE / size;
802 uint8_t c;
804 int16_t jTo = size - max(0,y + size - SCREEN_HEIGHT);
805 int16_t iTo = size - max(0,x + size - SCREEN_WIDTH);
807 for (Unit i = max(-1 * x,0); i < iTo; ++i)
809 int16_t xPos = x + i;
811 if (zBuffer[xPos] <= depth)
812 continue;
814 int16_t columnLocation = 2 + samplingIndices[i] * sprite[0];
816 for (Unit j = max(-1 * y,0); j < jTo; ++j)
818 c = sprite[columnLocation + samplingIndices[j]];
820 if (c != TRANSPARENT_COLOR)
821 pixels[(y + j) * SCREEN_WIDTH + xPos] =
822 (((c & 0b00000111) * 36) << 24) |
823 ((((c & 0b00111000) >> 3) * 36) << 16) |
824 ((((c & 0b11000000) >> 6) * 85) << 8);
830 Function for drawing a single pixel (like fragment shader). Bottleneck =>
831 should be as fast as possible.
833 void pixelFunc(PixelInfo *pixel)
835 if (pixel->position.y == MIDDLE_ROW)
836 zBuffer[pixel->position.x] = pixel->depth;
838 uint8_t c;
840 if (pixel->isWall)
841 c = sampleImage(textures[pixel->hit.type],pixel->hit.textureCoord,pixel->textureCoordY);
842 else
843 c = pixel->isFloor ? 0b00010001 : 0b00001010;
845 int intensity = pixel->depth - 8 * UNITS_PER_SQUARE;
846 intensity = intensity < 0 ? 0 : intensity;
847 intensity = (intensity * 32) / UNITS_PER_SQUARE;
849 int32_t color = palette[c];
851 int32_t r = ((color & 0xFF000000) >> 24) - intensity;
852 r = r > 0 ? r : 0;
853 r = r << 24;
855 int32_t g = ((color & 0x00FF0000) >> 16) - intensity;
856 g = g > 0 ? g : 0;
857 g = g << 16;
859 int32_t b = ((color & 0x0000FF00) >> 8) - intensity;
860 b = b > 0 ? b : 0;
861 b = b << 8;
863 pixels[pixel->position.y * SCREEN_WIDTH + pixel->position.x] = r | g | b;
866 void draw()
868 RayConstraints c;
870 c.maxHits = 16;
871 c.maxSteps = 20;
873 c.computeTextureCoords = 1;
874 render(camera,floorHeightAt,ceilingHeightAt,textureAt,pixelFunc,c);
876 Unit previousDepth;
878 for (uint8_t i = 0; i < SPRITES; ++i)
880 // use Chebyshew distance instead Euclidean, it's faster
881 if (absVal(sprites[i].mPosition.x - camera.position.x) > SPRITE_MAX_DISTANCE)
882 continue;
884 if (absVal(sprites[i].mPosition.y - camera.position.y) > SPRITE_MAX_DISTANCE)
885 continue;
887 PixelInfo pos = mapToScreen(sprites[i].mPosition,sprites[i].mHeight,camera);
889 if (pos.depth > 0)
890 drawSpriteSquare(sprites[i].mImage,pos.position.x,pos.position.y,
891 pos.depth,perspectiveScale(sprites[i].mPixelSize,pos.depth));
893 /* trick: sort the sprites by distance with bubble sort as we draw - the
894 order will be correct in a few frames */
895 if (i != 0 && pos.depth > previousDepth)
897 Sprite tmp = sprites[i];
898 sprites[i] = sprites[i - 1];
899 sprites[i - 1] = tmp;
902 previousDepth = pos.depth;
906 int main()
908 for (int i = 0; i < SCREEN_WIDTH; ++i)
909 zBuffer[i] = 0;
911 for (uint8_t r = 0; r < 8; ++r)
912 for (uint8_t g = 0; g < 8; ++g)
913 for (uint8_t b = 0; b < 4; ++b)
914 palette[rgbToIndex(r,g,b)] = ((36 * r) << 24) | ((36 * g) << 16) | ((85 * b) << 8);
916 #define placeSprite(i,s,X,Y,z,n)\
917 sprites[i].mImage = s;\
918 sprites[i].mPosition.x = X * UNITS_PER_SQUARE + UNITS_PER_SQUARE / 2;\
919 sprites[i].mPosition.y = Y * UNITS_PER_SQUARE + UNITS_PER_SQUARE / 2;\
920 sprites[i].mHeight = z * UNITS_PER_SQUARE + UNITS_PER_SQUARE / 2;\
921 sprites[i].mPixelSize = n;
923 placeSprite(0,sprite1,10,5,1,1000);
924 placeSprite(1,sprite1,14,5,1,1000);
925 placeSprite(2,sprite2,15,19,1,1500);
926 placeSprite(3,sprite3,8,2,1,3000);
927 placeSprite(4,sprite3,20,5,1,3000);
928 placeSprite(5,sprite3,26,18,1,3000);
929 placeSprite(6,sprite3,16,12,1,3000);
931 #undef placeSprite
933 camera.position.x = UNITS_PER_SQUARE * 5;
934 camera.position.y = UNITS_PER_SQUARE * 4;
935 camera.shear = 0;
936 camera.direction = 0;
937 camera.height = UNITS_PER_SQUARE * 2;
938 camera.resolution.x = SCREEN_WIDTH;
939 camera.resolution.y = SCREEN_HEIGHT;
941 SDL_Window *window = SDL_CreateWindow("raycasting", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
942 SDL_Renderer *renderer = SDL_CreateRenderer(window,-1,0);
943 SDL_Texture *texture = SDL_CreateTexture(renderer,SDL_PIXELFORMAT_RGBX8888, SDL_TEXTUREACCESS_STATIC, SCREEN_WIDTH, SCREEN_HEIGHT);
944 SDL_Surface *screenSurface = SDL_GetWindowSurface(window);
945 SDL_Event event;
946 int running = 1;
948 while (running)
950 draw();
952 SDL_UpdateTexture(texture,NULL,pixels,SCREEN_WIDTH * sizeof(uint32_t));
954 while (SDL_PollEvent(&event))
956 int newState = 0;
957 int keyIndex = -1;
959 switch (event.type)
961 case SDL_KEYDOWN:
962 newState = 1;
963 case SDL_KEYUP:
964 switch (event.key.keysym.scancode)
966 case SDL_SCANCODE_ESCAPE: running = 0; break;
967 case SDL_SCANCODE_UP: keyIndex = KEY_UP; break;
968 case SDL_SCANCODE_RIGHT: keyIndex = KEY_RIGHT; break;
969 case SDL_SCANCODE_DOWN: keyIndex = KEY_DOWN; break;
970 case SDL_SCANCODE_LEFT: keyIndex = KEY_LEFT; break;
971 case SDL_SCANCODE_Q: keyIndex = KEY_Q; break;
972 case SDL_SCANCODE_W: keyIndex = KEY_W; break;
973 case SDL_SCANCODE_A: keyIndex = KEY_A; break;
974 case SDL_SCANCODE_S: keyIndex = KEY_S; break;
975 default: break;
977 break;
979 case SDL_QUIT:
980 running = 0;
981 break;
983 default:
984 break;
987 if (keyIndex >= 0)
988 keys[keyIndex] = newState;
991 int step = 1;
992 int step2 = 5;
994 Vector2D direction = angleToDirection(camera.direction);
996 direction.x /= 10;
997 direction.y /= 10;
999 if (keys[KEY_UP])
1001 camera.position.x += step * direction.x;
1002 camera.position.y += step * direction.y;
1004 else if (keys[KEY_DOWN])
1006 camera.position.x -= step * direction.x;
1007 camera.position.y -= step * direction.y;
1010 if (keys[KEY_Q])
1011 camera.height += step * 100;
1012 else if (keys[KEY_W])
1013 camera.height -= step * 100;
1015 if (keys[KEY_RIGHT])
1016 camera.direction += step2;
1017 else if (keys[KEY_LEFT])
1018 camera.direction -= step2;
1020 const int shearAdd = 10;
1022 if (keys[KEY_A])
1023 camera.shear = camera.shear + shearAdd <= SCREEN_HEIGHT ? camera.shear + shearAdd : SCREEN_HEIGHT;
1024 else if (keys[KEY_S])
1025 camera.shear = camera.shear - shearAdd >= -1 * SCREEN_HEIGHT ? camera.shear - shearAdd : -1 * SCREEN_HEIGHT;
1027 SDL_RenderClear(renderer);
1028 SDL_RenderCopy(renderer,texture,NULL,NULL);
1029 SDL_RenderPresent(renderer);
1031 frame++;
1034 return 0;