Changes in / [67fecc3:18cbd53] in buchla-emu
Legend:
- Unmodified
- Added
- Removed
-
emu/vid.c
r67fecc3 r18cbd53 64 64 65 65 typedef struct { 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]; 66 int32_t x, y, w, h; 73 67 uint16_t *mem; 74 68 bool tran; … … 93 87 static SDL_atomic_t frame; 94 88 95 static uint16_t *rend_bm(uint16_t *vid, int32_t w, int32_t h, uint32_t *pix, int32_t pitch)89 static void rend_bm(uint16_t *vid, int32_t w, int32_t h, uint32_t *pix, int32_t pitch) 96 90 { 97 91 for (int32_t y = 0; y < h; ++y) { … … 107 101 pix += pitch / 4 - w; 108 102 } 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, 103 } 104 105 static void rend_tx(uint16_t *vid, int32_t w, int32_t h, int32_t fon_h, 114 106 uint32_t *pix, int32_t pitch) 115 107 { … … 162 154 pix += pitch / 4 - w; 163 155 } 164 165 return vid;166 156 } 167 157 … … 192 182 193 183 pal[0] = obj->tran ? pal[0] & 0xffffff00 : pal[0] | 0x000000ff; 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 } 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()); 232 219 } 233 220 } … … 370 357 } 371 358 372 if (n_flips % 2 != 0) {359 if (n_flips == 1) { 373 360 flips[n_flips] = SCR_H; 374 361 ++n_flips; … … 396 383 397 384 obj->x = x; 385 obj->y = flips[0]; 398 386 obj->w = w; 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 387 obj->h = flips[1] - flips[0]; 406 388 obj->mem = mem + off; 407 389 obj->tran = tde; 408 390 obj->fon_h = fon_h; 409 391 410 ver2("vid obj %d %c %c %d:%d %d+%d %d0x%05x",411 i, cb ? 'c' : 'b', tde ? 't' : '-', flips[0], flips[1], x, w, fon_h,off);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); 412 394 413 395 ++n_objs;
Note:
See TracChangeset
for help on using the changeset viewer.