(screen.c) Removed pixel function

This commit is contained in:
Devine Lu Linvega 2023-04-13 21:57:17 -07:00
parent d0db4f9223
commit b6e6839d25
1 changed files with 23 additions and 30 deletions

View File

@ -1,5 +1,4 @@
#include <stdlib.h>
#include <stdio.h>
#include "../uxn.h"
#include "screen.h"
@ -25,14 +24,6 @@ static Uint8 blending[4][16] = {
{1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1},
{2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2}};
static void
screen_pixel(UxnScreen *p, Layer *layer, Uint16 x, Uint16 y, Uint8 color)
{
if(x >= p->width || y >= p->height)
return;
layer->pixels[x + y * p->width] = color;
}
static void
screen_fill(UxnScreen *p, Layer *layer, Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2, Uint8 color)
{
@ -50,15 +41,14 @@ screen_blit(UxnScreen *p, Layer *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8
Uint16 c = sprite[v] | (twobpp ? (sprite[v + 8] << 8) : 0);
for(h = 7; h >= 0; --h, c >>= 1) {
Uint8 ch = (c & 1) | ((c >> 7) & 2);
if(opaque || ch)
screen_pixel(p,
layer,
x + (flipx ? 7 - h : h),
y + (flipy ? 7 - v : v),
blending[ch][color]);
if(opaque || ch) {
Uint16 xx = x + (flipx ? 7 - h : h);
Uint16 yy = y + (flipy ? 7 - v : v);
if(xx < p->width && yy < p->height)
layer->pixels[xx + yy * p->width] = blending[ch][color];
}
}
}
layer->changed = 1;
}
void
@ -158,29 +148,32 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
break;
}
case 0xf: {
Layer *layer = (d[0xf] & 0x40) ? &uxn_screen.fg : &uxn_screen.bg;
Uint8 i;
Uint8 ctrl = d[0xf];
Uint8 move = d[0x6];
Uint8 length = move >> 4;
Uint8 twobpp = !!(ctrl & 0x80);
Uint16 x = PEEK2(d + 0x8);
Uint16 y = PEEK2(d + 0xa);
Uint16 addr = PEEK2(d + 0xc);
Uint16 dx = (d[0x6] & 0x01) << 3;
Uint16 dy = (d[0x6] & 0x02) << 2;
Uint8 n = d[0x6] >> 4;
Uint8 twobpp = !!(d[0xf] & 0x80);
Uint8 i;
if(addr > 0x10000 - ((n + 1) << (3 + twobpp)))
Uint16 dx = (move & 0x1) << 3;
Uint16 dy = (move & 0x2) << 2;
Layer *layer = (ctrl & 0x40) ? &uxn_screen.fg : &uxn_screen.bg;
if(addr > 0x10000 - ((length + 1) << (3 + twobpp)))
return;
for(i = 0; i <= n; i++) {
if(!(d[0xf] & 0xf)) {
for(i = 0; i <= length; i++) {
if(!(ctrl & 0xf)) {
Uint16 ex = x + dy * i, ey = y + dx * i;
screen_fill(&uxn_screen, layer, ex, ey, ex + 8, ey + 8, 0);
} else {
screen_blit(&uxn_screen, layer, x + dy * i, y + dx * i, &ram[addr], d[0xf] & 0xf, d[0xf] & 0x10, d[0xf] & 0x20, twobpp);
addr += (d[0x6] & 0x04) << (1 + twobpp);
screen_blit(&uxn_screen, layer, x + dy * i, y + dx * i, &ram[addr], ctrl & 0xf, ctrl & 0x10, ctrl & 0x20, twobpp);
addr += (move & 0x04) << (1 + twobpp);
}
}
if(d[0x6] & 0x1) POKE2(d + 0x8, x + dx); /* auto x+8 */
if(d[0x6] & 0x2) POKE2(d + 0xa, y + dy); /* auto y+8 */
if(d[0x6] & 0x4) POKE2(d + 0xc, addr); /* auto addr+length */
layer->changed = 1;
if(move & 0x1) POKE2(d + 0x8, x + dx); /* auto x+8 */
if(move & 0x2) POKE2(d + 0xa, y + dy); /* auto y+8 */
if(move & 0x4) POKE2(d + 0xc, addr); /* auto addr+length */
break;
}
}