Removed mono mode
This commit is contained in:
parent
ac4ec0928a
commit
5b59215829
|
@ -22,8 +22,11 @@ static Uint8 blending[4][16] = {
|
||||||
{1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1},
|
{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}};
|
{2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2}};
|
||||||
|
|
||||||
static Uint32 palette_mono[] = {
|
static int
|
||||||
0x0f000000, 0x0fffffff};
|
clamp(int val, int min, int max)
|
||||||
|
{
|
||||||
|
return (val >= min) ? (val <= max) ? val : max : min;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
screen_write(UxnScreen *p, Layer *layer, Uint16 x, Uint16 y, Uint8 color)
|
screen_write(UxnScreen *p, Layer *layer, Uint16 x, Uint16 y, Uint8 color)
|
||||||
|
@ -44,7 +47,6 @@ screen_fill(UxnScreen *p, Layer *layer, Uint16 x1, Uint16 y1, Uint16 x2, Uint16
|
||||||
for(v = y1; v < y2; v++)
|
for(v = y1; v < y2; v++)
|
||||||
for(h = x1; h < x2; h++)
|
for(h = x1; h < x2; h++)
|
||||||
screen_write(p, layer, h, v, color);
|
screen_write(p, layer, h, v, color);
|
||||||
layer->changed = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -111,31 +113,11 @@ screen_redraw(UxnScreen *p)
|
||||||
Uint32 i, size = p->width * p->height, palette[16];
|
Uint32 i, size = p->width * p->height, palette[16];
|
||||||
for(i = 0; i < 16; i++)
|
for(i = 0; i < 16; i++)
|
||||||
palette[i] = p->palette[(i >> 2) ? (i >> 2) : (i & 3)];
|
palette[i] = p->palette[(i >> 2) ? (i >> 2) : (i & 3)];
|
||||||
if(p->mono) {
|
for(i = 0; i < size; i++)
|
||||||
for(i = 0; i < size; i++)
|
p->pixels[i] = palette[p->fg.pixels[i] << 2 | p->bg.pixels[i]];
|
||||||
p->pixels[i] = palette_mono[(p->fg.pixels[i] ? p->fg.pixels[i] : p->bg.pixels[i]) & 0x1];
|
|
||||||
} else {
|
|
||||||
for(i = 0; i < size; i++)
|
|
||||||
p->pixels[i] = palette[p->fg.pixels[i] << 2 | p->bg.pixels[i]];
|
|
||||||
}
|
|
||||||
p->fg.changed = p->bg.changed = 0;
|
p->fg.changed = p->bg.changed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
clamp(int val, int min, int max)
|
|
||||||
{
|
|
||||||
return (val >= min) ? (val <= max) ? val : max : min;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
screen_mono(UxnScreen *p)
|
|
||||||
{
|
|
||||||
p->mono = !p->mono;
|
|
||||||
screen_redraw(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* IO */
|
|
||||||
|
|
||||||
Uint8
|
Uint8
|
||||||
screen_dei(Uxn *u, Uint8 addr)
|
screen_dei(Uxn *u, Uint8 addr)
|
||||||
{
|
{
|
||||||
|
@ -153,12 +135,10 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
|
||||||
{
|
{
|
||||||
switch(port) {
|
switch(port) {
|
||||||
case 0x3:
|
case 0x3:
|
||||||
if(!FIXED_SIZE)
|
screen_resize(&uxn_screen, clamp(PEEK2(d + 2), 1, 1024), uxn_screen.height);
|
||||||
screen_resize(&uxn_screen, clamp(PEEK2(d + 2), 1, 1024), uxn_screen.height);
|
|
||||||
break;
|
break;
|
||||||
case 0x5:
|
case 0x5:
|
||||||
if(!FIXED_SIZE)
|
screen_resize(&uxn_screen, uxn_screen.width, clamp(PEEK2(d + 4), 1, 1024));
|
||||||
screen_resize(&uxn_screen, uxn_screen.width, clamp(PEEK2(d + 4), 1, 1024));
|
|
||||||
break;
|
break;
|
||||||
case 0xe: {
|
case 0xe: {
|
||||||
Uint16 x = PEEK2(d + 0x8), y = PEEK2(d + 0xa);
|
Uint16 x = PEEK2(d + 0x8), y = PEEK2(d + 0xa);
|
||||||
|
@ -167,8 +147,8 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
|
||||||
screen_fill(&uxn_screen, layer, (d[0xe] & 0x10) ? 0 : x, (d[0xe] & 0x20) ? 0 : y, (d[0xe] & 0x10) ? x : uxn_screen.width, (d[0xe] & 0x20) ? y : uxn_screen.height, d[0xe] & 0x3);
|
screen_fill(&uxn_screen, layer, (d[0xe] & 0x10) ? 0 : x, (d[0xe] & 0x20) ? 0 : y, (d[0xe] & 0x10) ? x : uxn_screen.width, (d[0xe] & 0x20) ? y : uxn_screen.height, d[0xe] & 0x3);
|
||||||
else {
|
else {
|
||||||
screen_write(&uxn_screen, layer, x, y, d[0xe] & 0x3);
|
screen_write(&uxn_screen, layer, x, y, d[0xe] & 0x3);
|
||||||
if(d[0x6] & 0x01) POKE2(d + 0x8, x + 1); /* auto x+1 */
|
if(d[0x6] & 0x1) POKE2(d + 0x8, x + 1); /* auto x+1 */
|
||||||
if(d[0x6] & 0x02) POKE2(d + 0xa, y + 1); /* auto y+1 */
|
if(d[0x6] & 0x2) POKE2(d + 0xa, y + 1); /* auto y+1 */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -189,9 +169,9 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
|
||||||
addr += (d[0x6] & 0x04) << (1 + twobpp);
|
addr += (d[0x6] & 0x04) << (1 + twobpp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
POKE2(d + 0xc, addr); /* auto addr+length */
|
if(d[0x6] & 0x1) POKE2(d + 0x8, x + dx); /* auto x+8 */
|
||||||
POKE2(d + 0x8, x + dx); /* auto x+8 */
|
if(d[0x6] & 0x2) POKE2(d + 0xa, y + dy); /* auto y+8 */
|
||||||
POKE2(d + 0xa, y + dy); /* auto y+8 */
|
if(d[0x6] & 0x4) POKE2(d + 0xc, addr); /* auto addr+length */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
WITH REGARD TO THIS SOFTWARE.
|
WITH REGARD TO THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define FIXED_SIZE 0
|
|
||||||
|
|
||||||
typedef struct Layer {
|
typedef struct Layer {
|
||||||
Uint8 *pixels, changed;
|
Uint8 *pixels, changed;
|
||||||
} Layer;
|
} Layer;
|
||||||
|
@ -20,7 +18,6 @@ typedef struct UxnScreen {
|
||||||
Uint32 palette[4], *pixels;
|
Uint32 palette[4], *pixels;
|
||||||
Uint16 width, height;
|
Uint16 width, height;
|
||||||
Layer fg, bg;
|
Layer fg, bg;
|
||||||
Uint8 mono;
|
|
||||||
} UxnScreen;
|
} UxnScreen;
|
||||||
|
|
||||||
extern UxnScreen uxn_screen;
|
extern UxnScreen uxn_screen;
|
||||||
|
@ -28,8 +25,6 @@ extern UxnScreen uxn_screen;
|
||||||
void screen_palette(UxnScreen *p, Uint8 *addr);
|
void screen_palette(UxnScreen *p, Uint8 *addr);
|
||||||
void screen_resize(UxnScreen *p, Uint16 width, Uint16 height);
|
void screen_resize(UxnScreen *p, Uint16 width, Uint16 height);
|
||||||
void screen_redraw(UxnScreen *p);
|
void screen_redraw(UxnScreen *p);
|
||||||
void screen_mono(UxnScreen *p);
|
|
||||||
|
|
||||||
Uint8 screen_dei(Uxn *u, Uint8 addr);
|
Uint8 screen_dei(Uxn *u, Uint8 addr);
|
||||||
void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port);
|
void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port);
|
||||||
int clamp(int val, int min, int max);
|
|
||||||
|
|
Loading…
Reference in New Issue