Changeset 684 for soft/giet_vm/applications/raycast/disp.c
- Timestamp:
- Aug 3, 2015, 7:07:03 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/raycast/disp.c
r683 r684 34 34 // Local functions 35 35 36 static void dispDrawColumnTex(int x, int y0, int y1, unsigned char * tex, int tx)36 static void dispDrawColumnTex(int x, int y0, int y1, unsigned char *line) 37 37 { 38 38 int y; … … 47 47 int ty = (y - y0) * TEX_SIZE / (y1 - y0); 48 48 49 buf[cur_buf][y * FBUF_X_SIZE + x] = tex[ty * TEX_SIZE + tx];49 buf[cur_buf][y * FBUF_X_SIZE + x] = line[ty]; 50 50 } 51 51 } … … 66 66 } 67 67 68 static void dispDrawSlice(Game *game, int x, int height, int type, float tx)68 static void dispDrawSlice(Game *game, int x, int height, int type, int tx) 69 69 { 70 70 // Ceiling … … 82 82 (FBUF_Y_SIZE - height) / 2, 83 83 (FBUF_Y_SIZE + height) / 2, 84 tex, 85 (int)(tx * TEX_SIZE)); 84 &tex[tx * TEX_SIZE]); 86 85 } 87 86 else { … … 172 171 } 173 172 173 static void dispMirror(unsigned char *buf, unsigned int size) 174 { 175 int i, j; 176 unsigned char pixel; 177 178 for (i = 0; i < size; i++) { 179 for (j = i + 1; j < size; j++) { 180 int ai = i * size + j; 181 int bi = j * size + i; 182 183 pixel = buf[ai]; 184 buf[ai] = buf[bi]; 185 buf[bi] = pixel; 186 } 187 } 188 } 189 174 190 static unsigned char *dispLoadTexture(char *path) 175 191 { … … 186 202 giet_fat_read(fd, tex, TEX_SIZE * TEX_SIZE); 187 203 giet_fat_close(fd); 204 205 dispMirror(tex, TEX_SIZE); 206 188 207 giet_tty_printf("[RAYCAST] loaded tex %s\n", path); 189 208 … … 253 272 254 273 // Draw ceiling, wall and floor 255 dispDrawSlice(game, x, FBUF_Y_SIZE / dist, type, tx );274 dispDrawSlice(game, x, FBUF_Y_SIZE / dist, type, tx * TEX_SIZE); 256 275 257 276 // Signal this slice is done
Note: See TracChangeset
for help on using the changeset viewer.