- Timestamp:
- 09/09/2017 05:52:04 PM (7 years ago)
- Branches:
- master
- Children:
- 67fecc3
- Parents:
- ca77925
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
emu/vid.c
rca77925 re26a632 64 64 65 65 typedef struct { 66 int32_t x, y, w, h; 66 int32_t y, h; 67 } ver_t; 68 69 typedef struct { 70 int32_t x, w; 71 int32_t n_vers; 72 ver_t vers[SCR_H / 2]; 67 73 uint16_t *mem; 68 74 bool tran; … … 87 93 static SDL_atomic_t frame; 88 94 89 static voidrend_bm(uint16_t *vid, int32_t w, int32_t h, uint32_t *pix, int32_t pitch)95 static uint16_t *rend_bm(uint16_t *vid, int32_t w, int32_t h, uint32_t *pix, int32_t pitch) 90 96 { 91 97 for (int32_t y = 0; y < h; ++y) { … … 101 107 pix += pitch / 4 - w; 102 108 } 103 } 104 105 static void rend_tx(uint16_t *vid, int32_t w, int32_t h, int32_t fon_h, 109 110 return vid; 111 } 112 113 static uint16_t *rend_tx(uint16_t *vid, int32_t w, int32_t h, int32_t fon_h, 106 114 uint32_t *pix, int32_t pitch) 107 115 { … … 154 162 pix += pitch / 4 - w; 155 163 } 164 165 return vid; 156 166 } 157 167 … … 182 192 183 193 pal[0] = obj->tran ? pal[0] & 0xffffff00 : pal[0] | 0x000000ff; 184 185 SDL_Rect src = { 186 .x = 0, .y = 0, .w = obj->w, .h = obj->h 187 }; 188 189 void *buf; 190 int32_t pitch; 191 192 if (SDL_LockTexture(tex, &src, &buf, &pitch) < 0) { 193 fail("SDL_LockTexture() failed: %s", SDL_GetError()); 194 } 195 196 if (obj->fon_h < 0) { 197 rend_bm(obj->mem, obj->w, obj->h, buf, pitch); 198 } 199 else { 200 rend_tx(obj->mem, obj->w, obj->h, obj->fon_h, buf, pitch); 201 } 202 203 SDL_UnlockTexture(tex); 204 205 SDL_Rect dst = { 206 .x = SCALE(obj->x), .y = SCALE(obj->y), 207 .w = SCALE(obj->w), .h = SCALE(obj->h) 208 }; 209 210 ver2("vid rend %d %dx%d -> (%d, %d) (%d, %d) %dx%d", 211 i, 212 obj->w, obj->h, 213 obj->x, obj->y, 214 SCALE(obj->x), SCALE(obj->y), 215 SCALE(obj->w), SCALE(obj->h)); 216 217 if (SDL_RenderCopy(ren, tex, &src, &dst) < 0) { 218 fail("SDL_RenderCopy() failed: %s", SDL_GetError()); 194 uint16_t *m = obj->mem; 195 196 for (int32_t k = 0; k < obj->n_vers; ++k) { 197 SDL_Rect src = { 198 .x = 0, .y = 0, .w = obj->w, .h = obj->vers[k].h 199 }; 200 201 void *buf; 202 int32_t pitch; 203 204 if (SDL_LockTexture(tex, &src, &buf, &pitch) < 0) { 205 fail("SDL_LockTexture() failed: %s", SDL_GetError()); 206 } 207 208 if (obj->fon_h < 0) { 209 m = rend_bm(m, obj->w, obj->vers[k].h, buf, pitch); 210 } 211 else { 212 m = rend_tx(m, obj->w, obj->vers[k].h, obj->fon_h, buf, pitch); 213 } 214 215 SDL_UnlockTexture(tex); 216 217 SDL_Rect dst = { 218 .x = SCALE(obj->x), .y = SCALE(obj->vers[k].y), 219 .w = SCALE(obj->w), .h = SCALE(obj->vers[k].h) 220 }; 221 222 ver2("vid rend %d %d %dx%d -> (%d, %d) (%d, %d) %dx%d", 223 i, k, 224 obj->w, obj->vers[k].h, 225 obj->x, obj->vers[k].y, 226 SCALE(obj->x), SCALE(obj->vers[k].y), 227 SCALE(obj->w), SCALE(obj->vers[k].h)); 228 229 if (SDL_RenderCopy(ren, tex, &src, &dst) < 0) { 230 fail("SDL_RenderCopy() failed: %s", SDL_GetError()); 231 } 219 232 } 220 233 } … … 357 370 } 358 371 359 if (n_flips == 1) {372 if (n_flips % 2 != 0) { 360 373 flips[n_flips] = SCR_H; 361 374 ++n_flips; … … 383 396 384 397 obj->x = x; 385 obj->y = flips[0];386 398 obj->w = w; 387 obj->h = flips[1] - flips[0]; 399 obj->n_vers = n_flips / 2; 400 401 for (int32_t k = 0; k < obj->n_vers; ++k) { 402 obj->vers[k].y = flips[2 * k]; 403 obj->vers[k].h = flips[2 * k + 1] - flips[2 * k]; 404 } 405 388 406 obj->mem = mem + off; 389 407 obj->tran = tde; 390 408 obj->fon_h = fon_h; 391 409 392 ver2("vid obj %d %c %c %d:%d %d+%d 0x%05x",393 i, cb ? 'c' : 'b', tde ? 't' : '-', flips[0], flips[1], x, w, off);410 ver2("vid obj %d %c %c %d:%d %d+%d %d 0x%05x", 411 i, cb ? 'c' : 'b', tde ? 't' : '-', flips[0], flips[1], x, w, fon_h, off); 394 412 395 413 ++n_objs;
Note:
See TracChangeset
for help on using the changeset viewer.