src/gb/renderers/software.c (view raw)
1/* Copyright (c) 2013-2016 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#include "software.h"
7
8#include "gb/io.h"
9#include "util/memory.h"
10
11static void GBVideoSoftwareRendererInit(struct GBVideoRenderer* renderer, enum GBModel model);
12static void GBVideoSoftwareRendererDeinit(struct GBVideoRenderer* renderer);
13static uint8_t GBVideoSoftwareRendererWriteVideoRegister(struct GBVideoRenderer* renderer, uint16_t address, uint8_t value);
14static void GBVideoSoftwareRendererWritePalette(struct GBVideoRenderer* renderer, int index, uint16_t value);
15static void GBVideoSoftwareRendererDrawRange(struct GBVideoRenderer* renderer, int startX, int endX, int y, struct GBObj** obj, size_t oamMax);
16static void GBVideoSoftwareRendererFinishScanline(struct GBVideoRenderer* renderer, int y);
17static void GBVideoSoftwareRendererFinishFrame(struct GBVideoRenderer* renderer);
18static void GBVideoSoftwareRendererGetPixels(struct GBVideoRenderer* renderer, unsigned* stride, const void** pixels);
19static void GBVideoSoftwareRendererPutPixels(struct GBVideoRenderer* renderer, unsigned stride, void* pixels);
20
21static void GBVideoSoftwareRendererDrawBackground(struct GBVideoSoftwareRenderer* renderer, uint8_t* maps, int startX, int endX, int y, int sx, int sy);
22static void GBVideoSoftwareRendererDrawObj(struct GBVideoSoftwareRenderer* renderer, struct GBObj* obj, int startX, int endX, int y);
23
24void GBVideoSoftwareRendererCreate(struct GBVideoSoftwareRenderer* renderer) {
25 renderer->d.init = GBVideoSoftwareRendererInit;
26 renderer->d.deinit = GBVideoSoftwareRendererDeinit;
27 renderer->d.writeVideoRegister = GBVideoSoftwareRendererWriteVideoRegister;
28 renderer->d.writePalette = GBVideoSoftwareRendererWritePalette,
29 renderer->d.drawRange = GBVideoSoftwareRendererDrawRange;
30 renderer->d.finishScanline = GBVideoSoftwareRendererFinishScanline;
31 renderer->d.finishFrame = GBVideoSoftwareRendererFinishFrame;
32 renderer->d.getPixels = GBVideoSoftwareRendererGetPixels;
33 renderer->d.putPixels = 0;
34
35 renderer->temporaryBuffer = 0;
36}
37
38static void GBVideoSoftwareRendererInit(struct GBVideoRenderer* renderer, enum GBModel model) {
39 struct GBVideoSoftwareRenderer* softwareRenderer = (struct GBVideoSoftwareRenderer*) renderer;
40 softwareRenderer->scy = 0;
41 softwareRenderer->scx = 0;
42 softwareRenderer->wy = 0;
43 softwareRenderer->currentWy = 0;
44 softwareRenderer->wx = 0;
45 softwareRenderer->model = model;
46
47 int y;
48 for (y = 0; y < GB_VIDEO_VERTICAL_PIXELS; ++y) {
49 color_t* row = &softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * y];
50 int x;
51 for (x = 0; x < GB_VIDEO_HORIZONTAL_PIXELS; ++x) {
52 row[x] = softwareRenderer->palette[0];
53 }
54 }
55}
56
57static void GBVideoSoftwareRendererDeinit(struct GBVideoRenderer* renderer) {
58 struct GBVideoSoftwareRenderer* softwareRenderer = (struct GBVideoSoftwareRenderer*) renderer;
59 UNUSED(softwareRenderer);
60}
61
62static uint8_t GBVideoSoftwareRendererWriteVideoRegister(struct GBVideoRenderer* renderer, uint16_t address, uint8_t value) {
63 struct GBVideoSoftwareRenderer* softwareRenderer = (struct GBVideoSoftwareRenderer*) renderer;
64 switch (address) {
65 case REG_LCDC:
66 softwareRenderer->lcdc = value;
67 break;
68 case REG_SCY:
69 softwareRenderer->scy = value;
70 break;
71 case REG_SCX:
72 softwareRenderer->scx = value;
73 break;
74 case REG_WY:
75 softwareRenderer->wy = value;
76 softwareRenderer->currentWy = value;
77 break;
78 case REG_WX:
79 softwareRenderer->wx = value;
80 break;
81 }
82 return value;
83}
84
85static void GBVideoSoftwareRendererWritePalette(struct GBVideoRenderer* renderer, int index, uint16_t value) {
86 struct GBVideoSoftwareRenderer* softwareRenderer = (struct GBVideoSoftwareRenderer*) renderer;
87#ifdef COLOR_16_BIT
88#ifdef COLOR_5_6_5
89 color_t color = 0;
90 color |= (value & 0x001F) << 11;
91 color |= (value & 0x03E0) << 1;
92 color |= (value & 0x7C00) >> 10;
93#else
94 color_t color = value;
95#endif
96#else
97 color_t color = 0;
98 color |= (value << 3) & 0xF8;
99 color |= (value << 6) & 0xF800;
100 color |= (value << 9) & 0xF80000;
101#endif
102 softwareRenderer->palette[index] = color;
103}
104
105static void GBVideoSoftwareRendererDrawRange(struct GBVideoRenderer* renderer, int startX, int endX, int y, struct GBObj** obj, size_t oamMax) {
106 struct GBVideoSoftwareRenderer* softwareRenderer = (struct GBVideoSoftwareRenderer*) renderer;
107 uint8_t* maps = &softwareRenderer->d.vram[GB_BASE_MAP];
108 if (GBRegisterLCDCIsTileMap(softwareRenderer->lcdc)) {
109 maps += GB_SIZE_MAP;
110 }
111 if (GBRegisterLCDCIsBgEnable(softwareRenderer->lcdc)) {
112 GBVideoSoftwareRendererDrawBackground(softwareRenderer, maps, startX, endX, y, softwareRenderer->scx, softwareRenderer->scy);
113
114 if (GBRegisterLCDCIsWindow(softwareRenderer->lcdc) && softwareRenderer->wy <= y && endX >= softwareRenderer->wx - 7) {
115 maps = &softwareRenderer->d.vram[GB_BASE_MAP];
116 if (GBRegisterLCDCIsWindowTileMap(softwareRenderer->lcdc)) {
117 maps += GB_SIZE_MAP;
118 }
119 GBVideoSoftwareRendererDrawBackground(softwareRenderer, maps, softwareRenderer->wx - 7, endX, y, 7 - softwareRenderer->wx, (softwareRenderer->currentWy - y) - softwareRenderer->wy);
120 }
121 } else {
122 memset(&softwareRenderer->row[startX], 0, endX - startX);
123 }
124
125 if (GBRegisterLCDCIsObjEnable(softwareRenderer->lcdc)) {
126 size_t i;
127 for (i = 0; i < oamMax; ++i) {
128 GBVideoSoftwareRendererDrawObj(softwareRenderer, obj[i], startX, endX, y);
129 }
130 }
131 color_t* row = &softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * y];
132 int x;
133 for (x = startX; x < (endX & ~7); x += 8) {
134 row[x] = softwareRenderer->palette[softwareRenderer->row[x] & 0x7F];
135 row[x + 1] = softwareRenderer->palette[softwareRenderer->row[x + 1] & 0x7F];
136 row[x + 2] = softwareRenderer->palette[softwareRenderer->row[x + 2] & 0x7F];
137 row[x + 3] = softwareRenderer->palette[softwareRenderer->row[x + 3] & 0x7F];
138 row[x + 4] = softwareRenderer->palette[softwareRenderer->row[x + 4] & 0x7F];
139 row[x + 5] = softwareRenderer->palette[softwareRenderer->row[x + 5] & 0x7F];
140 row[x + 6] = softwareRenderer->palette[softwareRenderer->row[x + 6] & 0x7F];
141 row[x + 7] = softwareRenderer->palette[softwareRenderer->row[x + 7] & 0x7F];
142 }
143 for (; x < endX; ++x) {
144 row[x] = softwareRenderer->palette[softwareRenderer->row[x] & 0x7F];
145 }
146}
147
148static void GBVideoSoftwareRendererFinishScanline(struct GBVideoRenderer* renderer, int y) {
149 struct GBVideoSoftwareRenderer* softwareRenderer = (struct GBVideoSoftwareRenderer*) renderer;
150 if (GBRegisterLCDCIsBgEnable(softwareRenderer->lcdc) && GBRegisterLCDCIsWindow(softwareRenderer->lcdc) && softwareRenderer->wy <= y && softwareRenderer->wx - 7 < GB_VIDEO_HORIZONTAL_PIXELS) {
151 ++softwareRenderer->currentWy;
152 }
153}
154
155static void GBVideoSoftwareRendererFinishFrame(struct GBVideoRenderer* renderer) {
156 struct GBVideoSoftwareRenderer* softwareRenderer = (struct GBVideoSoftwareRenderer*) renderer;
157
158 if (softwareRenderer->temporaryBuffer) {
159 mappedMemoryFree(softwareRenderer->temporaryBuffer, GB_VIDEO_HORIZONTAL_PIXELS * GB_VIDEO_VERTICAL_PIXELS * 4);
160 softwareRenderer->temporaryBuffer = 0;
161 }
162 softwareRenderer->currentWy = softwareRenderer->wy;
163}
164
165static void GBVideoSoftwareRendererDrawBackground(struct GBVideoSoftwareRenderer* renderer, uint8_t* maps, int startX, int endX, int y, int sx, int sy) {
166 uint8_t* data = renderer->d.vram;
167 uint8_t* attr = &maps[GB_SIZE_VRAM_BANK0];
168 if (!GBRegisterLCDCIsTileData(renderer->lcdc)) {
169 data += 0x1000;
170 }
171 int topY = (((y + sy) >> 3) & 0x1F) * 0x20;
172 int bottomY = (y + sy) & 7;
173 if (startX < 0) {
174 startX = 0;
175 }
176 int x;
177 if ((startX + sx) & 7) {
178 int startX2 = startX + 8 - ((startX + sx) & 7);
179 for (x = startX; x < startX2; ++x) {
180 uint8_t* localData = data;
181 int localY = bottomY;
182 int topX = ((x + sx) >> 3) & 0x1F;
183 int bottomX = 7 - ((x + sx) & 7);
184 int bgTile;
185 if (GBRegisterLCDCIsTileData(renderer->lcdc)) {
186 bgTile = maps[topX + topY];
187 } else {
188 bgTile = ((int8_t*) maps)[topX + topY];
189 }
190 int p = 0;
191 if (renderer->model >= GB_MODEL_CGB) {
192 GBObjAttributes attrs = attr[topX + topY];
193 p = GBObjAttributesGetCGBPalette(attrs) * 4;
194 if (GBObjAttributesIsPriority(attrs)) {
195 p |= 0x80;
196 }
197 if (GBObjAttributesIsBank(attrs)) {
198 localData += GB_SIZE_VRAM_BANK0;
199 }
200 if (GBObjAttributesIsYFlip(attrs)) {
201 localY = 7 - bottomY;
202 }
203 if (GBObjAttributesIsXFlip(attrs)) {
204 bottomX = 7 - bottomX;
205 }
206 }
207 uint8_t tileDataLower = localData[(bgTile * 8 + localY) * 2];
208 uint8_t tileDataUpper = localData[(bgTile * 8 + localY) * 2 + 1];
209 tileDataUpper >>= bottomX;
210 tileDataLower >>= bottomX;
211 renderer->row[x] = p | ((tileDataUpper & 1) << 1) | (tileDataLower & 1);
212 }
213 startX = startX2;
214 }
215 for (x = startX; x < endX; x += 8) {
216 uint8_t* localData = data;
217 int localY = bottomY;
218 int topX = ((x + sx) >> 3) & 0x1F;
219 int bgTile;
220 if (GBRegisterLCDCIsTileData(renderer->lcdc)) {
221 bgTile = maps[topX + topY];
222 } else {
223 bgTile = ((int8_t*) maps)[topX + topY];
224 }
225 int p = 0;
226 if (renderer->model >= GB_MODEL_CGB) {
227 GBObjAttributes attrs = attr[topX + topY];
228 p = GBObjAttributesGetCGBPalette(attrs) * 4;
229 if (GBObjAttributesIsPriority(attrs)) {
230 p |= 0x80;
231 }
232 if (GBObjAttributesIsBank(attrs)) {
233 localData += GB_SIZE_VRAM_BANK0;
234 }
235 if (GBObjAttributesIsYFlip(attrs)) {
236 localY = 7 - bottomY;
237 }
238 if (GBObjAttributesIsXFlip(attrs)) {
239 uint8_t tileDataLower = localData[(bgTile * 8 + localY) * 2];
240 uint8_t tileDataUpper = localData[(bgTile * 8 + localY) * 2 + 1];
241 renderer->row[x + 0] = p | ((tileDataUpper & 1) << 1) | (tileDataLower & 1);
242 renderer->row[x + 1] = p | (tileDataUpper & 2) | ((tileDataLower & 2) >> 1);
243 renderer->row[x + 2] = p | ((tileDataUpper & 4) >> 1) | ((tileDataLower & 4) >> 2);
244 renderer->row[x + 3] = p | ((tileDataUpper & 8) >> 2) | ((tileDataLower & 8) >> 3);
245 renderer->row[x + 4] = p | ((tileDataUpper & 16) >> 3) | ((tileDataLower & 16) >> 4);
246 renderer->row[x + 5] = p | ((tileDataUpper & 32) >> 4) | ((tileDataLower & 32) >> 5);
247 renderer->row[x + 6] = p | ((tileDataUpper & 64) >> 5) | ((tileDataLower & 64) >> 6);
248 renderer->row[x + 7] = p | ((tileDataUpper & 128) >> 6) | ((tileDataLower & 128) >> 7);
249 continue;
250 }
251 }
252 uint8_t tileDataLower = localData[(bgTile * 8 + localY) * 2];
253 uint8_t tileDataUpper = localData[(bgTile * 8 + localY) * 2 + 1];
254 renderer->row[x + 7] = p | ((tileDataUpper & 1) << 1) | (tileDataLower & 1);
255 renderer->row[x + 6] = p | (tileDataUpper & 2) | ((tileDataLower & 2) >> 1);
256 renderer->row[x + 5] = p | ((tileDataUpper & 4) >> 1) | ((tileDataLower & 4) >> 2);
257 renderer->row[x + 4] = p | ((tileDataUpper & 8) >> 2) | ((tileDataLower & 8) >> 3);
258 renderer->row[x + 3] = p | ((tileDataUpper & 16) >> 3) | ((tileDataLower & 16) >> 4);
259 renderer->row[x + 2] = p | ((tileDataUpper & 32) >> 4) | ((tileDataLower & 32) >> 5);
260 renderer->row[x + 1] = p | ((tileDataUpper & 64) >> 5) | ((tileDataLower & 64) >> 6);
261 renderer->row[x + 0] = p | ((tileDataUpper & 128) >> 6) | ((tileDataLower & 128) >> 7);
262 }
263}
264
265static void GBVideoSoftwareRendererDrawObj(struct GBVideoSoftwareRenderer* renderer, struct GBObj* obj, int startX, int endX, int y) {
266 int ix = obj->x - 8;
267 if (endX < ix || startX >= ix + 8) {
268 return;
269 }
270 if (obj->x < endX) {
271 endX = obj->x;
272 }
273 if (obj->x - 8 > startX) {
274 startX = obj->x - 8;
275 }
276 if (startX < 0) {
277 startX = 0;
278 }
279 uint8_t* data = renderer->d.vram;
280 int tileOffset = 0;
281 int bottomY;
282 if (GBObjAttributesIsYFlip(obj->attr)) {
283 bottomY = 7 - ((y - obj->y - 16) & 7);
284 if (GBRegisterLCDCIsObjSize(renderer->lcdc) && y - obj->y < -8) {
285 ++tileOffset;
286 }
287 } else {
288 bottomY = (y - obj->y - 16) & 7;
289 if (GBRegisterLCDCIsObjSize(renderer->lcdc) && y - obj->y >= -8) {
290 ++tileOffset;
291 }
292 }
293 if (GBRegisterLCDCIsObjSize(renderer->lcdc) && obj->tile & 1) {
294 --tileOffset;
295 }
296 uint8_t mask = GBObjAttributesIsPriority(obj->attr) ? ~0x1C : ~0x9F;
297 uint8_t mask2 = GBObjAttributesIsPriority(obj->attr) ? 0 : 0x83;
298 int p;
299 if (renderer->model >= GB_MODEL_CGB) {
300 p = (GBObjAttributesGetCGBPalette(obj->attr) + 8) * 4;
301 if (GBObjAttributesIsBank(obj->attr)) {
302 data += GB_SIZE_VRAM_BANK0;
303 }
304 } else {
305 p = (GBObjAttributesGetPalette(obj->attr) + 8) * 4;
306 }
307 int bottomX;
308 int x = startX;
309 if ((x - obj->x) & 7) {
310 for (; x < endX; ++x) {
311 if (GBObjAttributesIsXFlip(obj->attr)) {
312 bottomX = (x - obj->x) & 7;
313 } else {
314 bottomX = 7 - ((x - obj->x) & 7);
315 }
316 int objTile = obj->tile + tileOffset;
317 uint8_t tileDataLower = data[(objTile * 8 + bottomY) * 2];
318 uint8_t tileDataUpper = data[(objTile * 8 + bottomY) * 2 + 1];
319 tileDataUpper >>= bottomX;
320 tileDataLower >>= bottomX;
321 color_t current = renderer->row[x];
322 if (((tileDataUpper | tileDataLower) & 1) && !(current & mask) && (current & mask2) <= 0x80) {
323 renderer->row[x] = p | ((tileDataUpper & 1) << 1) | (tileDataLower & 1);
324 }
325 }
326 } else if (GBObjAttributesIsXFlip(obj->attr)) {
327 int objTile = obj->tile + tileOffset;
328 uint8_t tileDataLower = data[(objTile * 8 + bottomY) * 2];
329 uint8_t tileDataUpper = data[(objTile * 8 + bottomY) * 2 + 1];
330 color_t current;
331 current = renderer->row[x];
332 if (((tileDataUpper | tileDataLower) & 1) && !(current & mask) && (current & mask2) <= 0x80) {
333 renderer->row[x] = p | ((tileDataUpper & 1) << 1) | (tileDataLower & 1);
334 }
335 current = renderer->row[x + 1];
336 if (((tileDataUpper | tileDataLower) & 2) && !(current & mask) && (current & mask2) <= 0x80) {
337 renderer->row[x + 1] = p | (tileDataUpper & 2) | ((tileDataLower & 2) >> 1);
338 }
339 current = renderer->row[x + 2];
340 if (((tileDataUpper | tileDataLower) & 4) && !(current & mask) && (current & mask2) <= 0x80) {
341 renderer->row[x + 2] = p | ((tileDataUpper & 4) >> 1) | ((tileDataLower & 4) >> 2);
342 }
343 current = renderer->row[x + 3];
344 if (((tileDataUpper | tileDataLower) & 8) && !(current & mask) && (current & mask2) <= 0x80) {
345 renderer->row[x + 3] = p | ((tileDataUpper & 8) >> 2) | ((tileDataLower & 8) >> 3);
346 }
347 current = renderer->row[x + 4];
348 if (((tileDataUpper | tileDataLower) & 16) && !(current & mask) && (current & mask2) <= 0x80) {
349 renderer->row[x + 4] = p | ((tileDataUpper & 16) >> 3) | ((tileDataLower & 16) >> 4);
350 }
351 current = renderer->row[x + 5];
352 if (((tileDataUpper | tileDataLower) & 32) && !(current & mask) && (current & mask2) <= 0x80) {
353 renderer->row[x + 5] = p | ((tileDataUpper & 32) >> 4) | ((tileDataLower & 32) >> 5);
354 }
355 current = renderer->row[x + 6];
356 if (((tileDataUpper | tileDataLower) & 64) && !(current & mask) && (current & mask2) <= 0x80) {
357 renderer->row[x + 6] = p | ((tileDataUpper & 64) >> 5) | ((tileDataLower & 64) >> 6);
358 }
359 current = renderer->row[x + 7];
360 if (((tileDataUpper | tileDataLower) & 128) && !(current & mask) && (current & mask2) <= 0x80) {
361 renderer->row[x + 7] = p | ((tileDataUpper & 128) >> 6) | ((tileDataLower & 128) >> 7);
362 }
363 } else {
364 int objTile = obj->tile + tileOffset;
365 uint8_t tileDataLower = data[(objTile * 8 + bottomY) * 2];
366 uint8_t tileDataUpper = data[(objTile * 8 + bottomY) * 2 + 1];
367 color_t current;
368 current = renderer->row[x + 7];
369 if (((tileDataUpper | tileDataLower) & 1) && !(current & mask) && (current & mask2) <= 0x80) {
370 renderer->row[x + 7] = p | ((tileDataUpper & 1) << 1) | (tileDataLower & 1);
371 }
372 current = renderer->row[x + 6];
373 if (((tileDataUpper | tileDataLower) & 2) && !(current & mask) && (current & mask2) <= 0x80) {
374 renderer->row[x + 6] = p | (tileDataUpper & 2) | ((tileDataLower & 2) >> 1);
375 }
376 current = renderer->row[x + 5];
377 if (((tileDataUpper | tileDataLower) & 4) && !(current & mask) && (current & mask2) <= 0x80) {
378 renderer->row[x + 5] = p | ((tileDataUpper & 4) >> 1) | ((tileDataLower & 4) >> 2);
379 }
380 current = renderer->row[x + 4];
381 if (((tileDataUpper | tileDataLower) & 8) && !(current & mask) && (current & mask2) <= 0x80) {
382 renderer->row[x + 4] = p | ((tileDataUpper & 8) >> 2) | ((tileDataLower & 8) >> 3);
383 }
384 current = renderer->row[x + 3];
385 if (((tileDataUpper | tileDataLower) & 16) && !(current & mask) && (current & mask2) <= 0x80) {
386 renderer->row[x + 3] = p | ((tileDataUpper & 16) >> 3) | ((tileDataLower & 16) >> 4);
387 }
388 current = renderer->row[x + 2];
389 if (((tileDataUpper | tileDataLower) & 32) && !(current & mask) && (current & mask2) <= 0x80) {
390 renderer->row[x + 2] = p | ((tileDataUpper & 32) >> 4) | ((tileDataLower & 32) >> 5);
391 }
392 current = renderer->row[x + 1];
393 if (((tileDataUpper | tileDataLower) & 64) && !(current & mask) && (current & mask2) <= 0x80) {
394 renderer->row[x + 1] = p | ((tileDataUpper & 64) >> 5) | ((tileDataLower & 64) >> 6);
395 }
396 current = renderer->row[x];
397 if (((tileDataUpper | tileDataLower) & 128) && !(current & mask) && (current & mask2) <= 0x80) {
398 renderer->row[x] = p | ((tileDataUpper & 128) >> 6) | ((tileDataLower & 128) >> 7);
399 }
400 }
401}
402
403static void GBVideoSoftwareRendererGetPixels(struct GBVideoRenderer* renderer, unsigned* stride, const void** pixels) {
404 struct GBVideoSoftwareRenderer* softwareRenderer = (struct GBVideoSoftwareRenderer*) renderer;
405 // TODO: Share with GBAVideoSoftwareRendererGetPixels
406#ifdef COLOR_16_BIT
407 *stride = GB_VIDEO_HORIZONTAL_PIXELS;
408 if (!softwareRenderer->temporaryBuffer) {
409 softwareRenderer->temporaryBuffer = anonymousMemoryMap(GB_VIDEO_HORIZONTAL_PIXELS * GB_VIDEO_VERTICAL_PIXELS * 4);
410 }
411 *pixels = softwareRenderer->temporaryBuffer;
412 unsigned y, x;
413 for (y = 0; y < GB_VIDEO_VERTICAL_PIXELS; ++y) {
414 for (x = 0; x < GB_VIDEO_HORIZONTAL_PIXELS; ++x) {
415 color_t inColor = softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * y + x];
416 uint32_t outColor;
417#ifdef COLOR_5_6_5
418 outColor = (inColor & 0x1F) << 19;
419 outColor |= (inColor & 0x7C0) << 5;
420 outColor |= (inColor & 0xF800) >> 8;
421#else
422 outColor = (inColor & 0x1F) << 3;
423 outColor |= (inColor & 0x3E0) << 6;
424 outColor |= (inColor & 0x7C00) << 9;
425#endif
426 softwareRenderer->temporaryBuffer[GB_VIDEO_HORIZONTAL_PIXELS * y + x] = outColor;
427 }
428 }
429#else
430 *stride = softwareRenderer->outputBufferStride;
431 *pixels = softwareRenderer->outputBuffer;
432#endif
433}