summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
fea1cb9)
Workbench still doesn't work.
for (int i = 0; i < read_ranges; i++) {
if(address >= read_addr[i] && address < read_upper[i]) {
for (int i = 0; i < read_ranges; i++) {
if(address >= read_addr[i] && address < read_upper[i]) {
- return read_data[i][address];
+ return read_data[i][address - read_addr[i]];
for (int i = 0; i < write_ranges; i++) {
if(address >= write_addr[i] && address < write_upper[i]) {
for (int i = 0; i < write_ranges; i++) {
if(address >= write_addr[i] && address < write_upper[i]) {
- write_data[i][address] = (unsigned char)value;
+ write_data[i][address - write_addr[i]] = (unsigned char)value;
void rtg_update_screen() {}
uint32_t rtg_to_sdl2[RTGFMT_NUM] = {
void rtg_update_screen() {}
uint32_t rtg_to_sdl2[RTGFMT_NUM] = {
- SDL_PIXELFORMAT_BGRA8888,
+ SDL_PIXELFORMAT_ARGB8888,
- SDL_PIXELFORMAT_BGRA8888,
+ SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_RGB555,
};
SDL_PIXELFORMAT_RGB555,
};
printf("Created %dx%d texture.\n", width, height);
}
printf("Created %dx%d texture.\n", width, height);
}
- if (format == RTGFMT_8BIT) {
- indexed_buf = calloc(1, width * height * 4);
- pitch = width * 4;
+ switch (format) {
+ case RTGFMT_8BIT:
+ indexed_buf = calloc(1, width * height * 4);
+ pitch = width * 4;
+ break;
+ case RTGFMT_RBG565:
+ indexed_buf = calloc(1, width * height * 2);
+ break;
+ default:
+ break;
}
while (1) {
if (renderer && win && img) {
SDL_RenderClear(renderer);
if (*data->running) {
}
while (1) {
if (renderer && win && img) {
SDL_RenderClear(renderer);
if (*data->running) {
- SDL_UpdateTexture(img, NULL, (format != RTGFMT_8BIT) ? &data->memory[*data->addr] : (uint8_t *)indexed_buf, pitch);
+ if (format == RTGFMT_RGB32)
+ SDL_UpdateTexture(img, NULL, &data->memory[*data->addr], pitch);
+ else
+ SDL_UpdateTexture(img, NULL, (uint8_t *)indexed_buf, pitch);
SDL_RenderCopy(renderer, img, NULL, NULL);
}
SDL_RenderPresent(renderer);
SDL_RenderCopy(renderer, img, NULL, NULL);
}
SDL_RenderPresent(renderer);
reinit = 1;
goto shutdown_sdl;
}
reinit = 1;
goto shutdown_sdl;
}
- if (format == RTGFMT_8BIT) {
- for (int y = 0; y < height; y++) {
- for (int x = 0; x < width; x++) {
- indexed_buf[x + (y * width)] = palette[data->memory[*data->addr + x + (y * width)]];
+ switch (format) {
+ case RTGFMT_8BIT:
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ indexed_buf[x + (y * width)] = palette[data->memory[*data->addr + x + (y * width)]];
+ }
+ }
+ break;
+ case RTGFMT_RBG565:
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ ((uint16_t *)indexed_buf)[x + (y * width)] = be16toh(((uint16_t *)data->memory)[*data->addr + x + (y * width)]);
+ }
-void rtg_set_clut_entry(uint8_t index, uint8_t r, uint8_t g, uint8_t b) {
- //int r = (int)((float)rtg_u8[1] / 255.0f * 31.0f);
- //int g = (int)((float)rtg_u8[2] / 255.0f * 63.0f);
- //int b = (int)((float)rtg_u8[3] / 255.0f * 31.0f);
- palette[index] = (r << 24) | (g << 16) | (b << 8) | 0xFF;
+void rtg_set_clut_entry(uint8_t index, uint32_t xrgb) {
+ palette[index] = xrgb;
}
void rtg_init_display() {
}
void rtg_init_display() {
*(( uint16_t *) (&rtg_mem[address - PIGFX_REG_SIZE])) = htobe16(value);
break;
case OP_TYPE_LONGWORD:
*(( uint16_t *) (&rtg_mem[address - PIGFX_REG_SIZE])) = htobe16(value);
break;
case OP_TYPE_LONGWORD:
- *(( uint16_t *) (&rtg_mem[address - PIGFX_REG_SIZE] + 2)) = htobe16(value & 0xFFFF);
- *(( uint16_t *) (&rtg_mem[address - PIGFX_REG_SIZE])) = htobe16((value >> 16));
- //*(( uint32_t *) (&rtg_mem[address - PIGFX_REG_SIZE])) = htobe32(value);
+ *(( uint32_t *) (&rtg_mem[address - PIGFX_REG_SIZE])) = htobe32(value);
case OP_TYPE_BYTE:
switch (address) {
case RTG_U81:
case OP_TYPE_BYTE:
switch (address) {
case RTG_U81:
+ rtg_u8[0] = value;
+ break;
+ rtg_u8[1] = value;
+ break;
+ rtg_u8[2] = value;
+ break;
- rtg_u8[address - RTG_U81] = value;
+ rtg_u8[3] = value;
+ break;
}
break;
case OP_TYPE_WORD:
}
break;
case OP_TYPE_WORD:
break;
case RTGCMD_SETCLUT: {
//printf("Command: SetCLUT.\n");
break;
case RTGCMD_SETCLUT: {
//printf("Command: SetCLUT.\n");
- printf("Set palette entry %d to %d, %d, %d\n", rtg_u8[0], rtg_u8[1], rtg_u8[2], rtg_u8[3]);
- rtg_set_clut_entry(rtg_u8[0], rtg_u8[1], rtg_u8[2], rtg_u8[3]);
+ //printf("Set palette entry %d to %d, %d, %d\n", rtg_u8[0], rtg_u8[1], rtg_u8[2], rtg_u8[3]);
+ //printf("Set palette entry %d to 32-bit palette color: %.8X\n", rtg_u8[0], rtg_rgb[0]);
+ rtg_set_clut_entry(rtg_u8[0], rtg_rgb[0]);
break;
}
case RTGCMD_SETDISPLAY:
break;
}
case RTGCMD_SETDISPLAY:
uint8_t *dptr = &rtg_mem[framebuffer_addr + (x << format) + (y * rtg_pitch)];
switch(format) {
case RTGFMT_8BIT: {
uint8_t *dptr = &rtg_mem[framebuffer_addr + (x << format) + (y * rtg_pitch)];
switch(format) {
case RTGFMT_8BIT: {
+ //printf("Incoming 8-bit color: %.8X\n", color);
for (int xs = 0; xs < w; xs++) {
dptr[xs] = color & 0xFF;
}
break;
}
case RTGFMT_RBG565: {
for (int xs = 0; xs < w; xs++) {
dptr[xs] = color & 0xFF;
}
break;
}
case RTGFMT_RBG565: {
+ //printf("Incoming raw 16-bit color: %.8X\n", htobe32(color));
+ color = htobe16((color & 0xFFFF));
+ //printf("Incoming 16-bit color: %.8X\n", color);
uint16_t *ptr = (uint16_t *)dptr;
for (int xs = 0; xs < w; xs++) {
uint16_t *ptr = (uint16_t *)dptr;
for (int xs = 0; xs < w; xs++) {
- ptr[xs] = (color & 0xFFFF);
}
break;
}
case RTGFMT_RGB32: {
}
break;
}
case RTGFMT_RGB32: {
+ color = htobe32(color);
+ //printf("Incoming 32-bit color: %.8X\n", color);
uint32_t *ptr = (uint32_t *)dptr;
for (int xs = 0; xs < w; xs++) {
ptr[xs] = color;
uint32_t *ptr = (uint32_t *)dptr;
for (int xs = 0; xs < w; xs++) {
ptr[xs] = color;
void rtg_write(uint32_t address, uint32_t value, uint8_t mode);
unsigned int rtg_read(uint32_t address, uint8_t mode);
void rtg_write(uint32_t address, uint32_t value, uint8_t mode);
unsigned int rtg_read(uint32_t address, uint8_t mode);
-void rtg_set_clut_entry(uint8_t index, uint8_t r, uint8_t g, uint8_t b);
+void rtg_set_clut_entry(uint8_t index, uint32_t xrgb);
void rtg_init_display();
void rtg_shutdown_display();
void rtg_init_display();
void rtg_shutdown_display();
// Sets the color components of X color components for 8-bit paletted display modes.
if (!b->CLUT)
return;
// Sets the color components of X color components for 8-bit paletted display modes.
if (!b->CLUT)
return;
- for(int i = start; i < num; i++) {
+
+ int j = start + num;
+
+ for(int i = start; i < j; i++) {
+ //WRITEBYTE(RTG_U82, (unsigned char)b->CLUT[i].Red);
+ //WRITEBYTE(RTG_U83, (unsigned char)b->CLUT[i].Green);
+ //WRITEBYTE(RTG_U84, (unsigned char)b->CLUT[i].Blue);
+ unsigned int xrgb = 0 | (b->CLUT[i].Red << 16) | (b->CLUT[i].Green << 8) | (b->CLUT[i].Blue);
WRITEBYTE(RTG_U81, (unsigned char)i);
WRITEBYTE(RTG_U81, (unsigned char)i);
- WRITEBYTE(RTG_U82, (unsigned char)b->CLUT[i].Red);
- WRITEBYTE(RTG_U83, (unsigned char)b->CLUT[i].Green);
- WRITEBYTE(RTG_U84, (unsigned char)b->CLUT[i].Blue);
+ WRITELONG(RTG_RGB1, xrgb);
WRITESHORT(RTG_COMMAND, RTGCMD_SETCLUT);
}
}
WRITESHORT(RTG_COMMAND, RTGCMD_SETCLUT);
}
}