- Timestamp:
- 09/09/2017 01:52:56 PM (7 years ago)
- Branches:
- master
- Children:
- 99cc90a
- Parents:
- cd50b8c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
emu/lcd.c
rcd50b8c rc6f1cf5 104 104 last = now; 105 105 106 void *buf; 107 int32_t pitch; 108 109 if (SDL_LockTexture(gfx, NULL, &buf, &pitch) < 0) { 110 fail("SDL_LockTexture() failed: %s", SDL_GetError()); 111 } 112 113 uint32_t *pix = buf; 114 115 for (int32_t y = 0; y < GFX_H; ++y) { 116 for (int32_t x = 0; x < GFX_W * GFX_PIX; ++x) { 117 *pix++ = GFX_BGR; 118 } 119 120 pix += pitch / 4 - GFX_W * GFX_PIX; 106 if (SDL_FillRect(txt, NULL, TXT_BGR) < 0) { 107 fail("SDL_FillRect() failed: %s", SDL_GetError()); 121 108 } 122 109 123 110 if (SDL_AtomicGet(&ena) == 0) { 124 SDL_UnlockTexture(gfx); 125 126 if (SDL_RenderCopy(ren, gfx, NULL, NULL) < 0) { 111 SDL_Texture *tex = SDL_CreateTextureFromSurface(ren, txt); 112 113 if (tex == NULL) { 114 fail("SDL_CreateTextureFromSurface() failed: %s", SDL_GetError()); 115 } 116 117 if (SDL_RenderCopy(ren, tex, NULL, NULL) < 0) { 127 118 fail("SDL_RenderCopy() failed: %s", SDL_GetError()); 128 119 } 129 120 121 SDL_DestroyTexture(tex); 130 122 SDL_RenderPresent(ren); 131 123 return; 132 }133 134 pix = buf;135 136 for (int32_t y = 0; y < GFX_H; ++y) {137 for (int32_t x = 0; x < GFX_W; ++x) {138 uint8_t b = mem_gfx[y * GFX_W + x];139 140 for (int32_t p = 0; p < GFX_PIX; ++p) {141 if ((b & (1 << (7 - p))) != 0) {142 *pix = GFX_FGR;143 }144 145 ++pix;146 }147 }148 149 pix += pitch / 4 - GFX_W * GFX_PIX;150 }151 152 SDL_UnlockTexture(gfx);153 154 if (SDL_FillRect(txt, NULL, TXT_BGR) < 0) {155 fail("SDL_FillRect() failed: %s", SDL_GetError());156 124 } 157 125 … … 207 175 SDL_DestroyTexture(tex); 208 176 177 void *buf; 178 int32_t pitch; 179 180 if (SDL_LockTexture(gfx, NULL, &buf, &pitch) < 0) { 181 fail("SDL_LockTexture() failed: %s", SDL_GetError()); 182 } 183 184 uint32_t *pix = buf; 185 186 for (int32_t y = 0; y < GFX_H; ++y) { 187 for (int32_t x = 0; x < GFX_W; ++x) { 188 uint8_t b = mem_gfx[y * GFX_W + x]; 189 190 for (int32_t p = 0; p < GFX_PIX; ++p) { 191 bool set = (b & (1 << (7 - p))) != 0; 192 *pix++ = set ? GFX_FGR : GFX_BGR; 193 } 194 } 195 196 pix += pitch / 4 - GFX_W * GFX_PIX; 197 } 198 199 SDL_UnlockTexture(gfx); 200 209 201 if (SDL_RenderCopy(ren, gfx, NULL, NULL) < 0) { 210 202 fail("SDL_RenderCopy() failed: %s", SDL_GetError());
Note:
See TracChangeset
for help on using the changeset viewer.