6 Fixes:
-[FIX] On conditional jumps vm_pc doesn't get updated if jump is not taken. -[FIX] Palette members are reversed -[FIX] Memory offset after each character is wrong -[FIX] LOCATE: cursors are reversed -[FIX] PRINT/PUTCHAR: cursor_y offset is wrong -[FIX] PUTCHAR: parameters are grabbed reversed
This commit is contained in:
53
vdp.cpp
53
vdp.cpp
@@ -35,21 +35,21 @@ static int data_stack_pos = 0;
|
||||
|
||||
static Uint8 palette[16][4] = {
|
||||
{ 255, 0, 0, 255 },
|
||||
{ 255, 0, 255, 0 },
|
||||
{ 255, 255, 0, 0 },
|
||||
{ 255, 255, 0, 255 },
|
||||
{ 0, 255, 0, 255 },
|
||||
{ 0, 0, 255, 255 },
|
||||
{ 255, 0, 255, 255 },
|
||||
{ 255, 255, 255, 0 },
|
||||
{ 255, 255, 0, 255 },
|
||||
{ 0, 255, 255, 255 },
|
||||
{ 255, 255, 255, 255 },
|
||||
{ 255, 0, 0, 0 },
|
||||
{ 255, 0, 0, 128 },
|
||||
{ 255, 0, 128, 0 },
|
||||
{ 255, 128, 0, 0 },
|
||||
{ 255, 128, 0, 128 },
|
||||
{ 255, 0, 128, 128 },
|
||||
{ 255, 128, 128, 0 },
|
||||
{ 255, 128, 128, 128 },
|
||||
{ 255, 0, 0, 0 },
|
||||
{ 0, 0, 0, 255 },
|
||||
{ 128, 0, 0, 255 },
|
||||
{ 0, 128, 0, 255 },
|
||||
{ 0, 0, 128, 255 },
|
||||
{ 128, 0, 128, 255 },
|
||||
{ 128, 128, 0, 255 },
|
||||
{ 0, 128, 128, 255 },
|
||||
{ 128, 128, 128, 255 },
|
||||
{ 0, 0, 0, 255 },
|
||||
};
|
||||
|
||||
void vdp_init() {
|
||||
@@ -58,16 +58,17 @@ void vdp_init() {
|
||||
sdlRenderer = SDL_CreateRenderer(sdlWindow, -1, SDL_RENDERER_PRESENTVSYNC);
|
||||
//SDL_SetRenderDrawBlendMode(sdlRenderer, SDL_BLENDMODE_BLEND);
|
||||
SDL_RenderSetLogicalSize(sdlRenderer, 152, 120);
|
||||
SDL_SetRenderDrawColor(sdlRenderer, palette[border][3], palette[border][2], palette[border][1], palette[border][0]);
|
||||
SDL_SetRenderDrawColor(sdlRenderer, palette[border][0], palette[border][1], palette[border][2], palette[border][3]);
|
||||
|
||||
for (int i = 0; i < 16 * 12; i++) screen_map[i] = i;
|
||||
for (int i = 0; i < 16 * 12; i++) screen_map[i] = 32;
|
||||
for (int i = 0; i < 16 * 12; i++) screen_color[i] = color;
|
||||
//jtexture texture = (jtexture)malloc(sizeof(jtexture_t));
|
||||
//FILE* f = fopen("font.png", "rb");
|
||||
//if (!f) { error = 2; return; }
|
||||
//int c;
|
||||
//int size = 128;
|
||||
//Uint8* buffer = stbi_load_from_file(f, &size, &size, &c, 4);
|
||||
sdlTexture = SDL_CreateTexture(sdlRenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, 128, 128);
|
||||
sdlTexture = SDL_CreateTexture(sdlRenderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STATIC, 128, 128);
|
||||
//SDL_UpdateTexture(sdlTexture, NULL, buffer, 128 * sizeof(Uint32));
|
||||
//SDL_SetTextureBlendMode(sdlTexture, SDL_BLENDMODE_BLEND);
|
||||
//stbi_image_free(buffer);
|
||||
@@ -102,12 +103,12 @@ static void flip() {
|
||||
if (*cm & 8) memcpy(sbt, palette[*sc & 0x0F], 4); else memcpy(sbt, palette[*sc >> 4], 4); sbt += 4;
|
||||
if (*cm & 4) memcpy(sbt, palette[*sc & 0x0F], 4); else memcpy(sbt, palette[*sc >> 4], 4); sbt += 4;
|
||||
if (*cm & 2) memcpy(sbt, palette[*sc & 0x0F], 4); else memcpy(sbt, palette[*sc >> 4], 4); sbt += 4;
|
||||
if (*cm & 1) memcpy(sbt, palette[*sc & 0x0F], 4); else memcpy(sbt, palette[*sc >> 4], 4); sbt += 512;
|
||||
if (*cm & 1) memcpy(sbt, palette[*sc & 0x0F], 4); else memcpy(sbt, palette[*sc >> 4], 4); sbt += (512-32+4);
|
||||
cm++;
|
||||
}
|
||||
sm++; sc++; sb += 32;
|
||||
}
|
||||
sb += 3584;
|
||||
sb += 3584; //3584;
|
||||
}
|
||||
SDL_UpdateTexture(sdlTexture, NULL, screen_buffer, 128 * sizeof(Uint32));
|
||||
SDL_RenderClear(sdlRenderer);
|
||||
@@ -123,19 +124,19 @@ void vdp_cmd_out(const unsigned char& value) {
|
||||
Uint8 n;
|
||||
switch (value) {
|
||||
case VDP_CMD_LOCATE:
|
||||
cursor_y = data_stack[--data_stack_pos]; cursor_x = data_stack[--data_stack_pos]; break;
|
||||
cursor_x = data_stack[--data_stack_pos]; cursor_y = data_stack[--data_stack_pos]; break;
|
||||
case VDP_CMD_PRINT:
|
||||
for (int i = 0; i < data_stack_pos; i++) {
|
||||
screen_map[cursor_x + (cursor_y << 7)] = data_stack[i];
|
||||
screen_color[cursor_x + (cursor_y << 7)] = color;
|
||||
for (int i = data_stack_pos-1; i >= 0; i--) {
|
||||
screen_map[cursor_x + (cursor_y << 4)] = data_stack[i];
|
||||
screen_color[cursor_x + (cursor_y << 4)] = color;
|
||||
cursor_x++; if (cursor_x == 16) { cursor_x = 0; cursor_y++; }
|
||||
}
|
||||
break;
|
||||
case VDP_CMD_PUTCHAR:
|
||||
cursor_x = data_stack[data_stack_pos - 4];
|
||||
cursor_y = data_stack[data_stack_pos - 3];
|
||||
screen_map[cursor_x + (cursor_y << 7)] = data_stack[data_stack_pos-2];
|
||||
screen_color[cursor_x + (cursor_y << 7)] = data_stack[data_stack_pos - 1];
|
||||
cursor_x = data_stack[data_stack_pos - 1];
|
||||
cursor_y = data_stack[data_stack_pos - 2];
|
||||
screen_map[cursor_x + (cursor_y << 4)] = data_stack[data_stack_pos-3];
|
||||
screen_color[cursor_x + (cursor_y << 4)] = data_stack[data_stack_pos - 4];
|
||||
break;
|
||||
case VDP_CMD_SETCHAR:
|
||||
n = data_stack[data_stack_pos - 9];
|
||||
|
||||
Reference in New Issue
Block a user