mirror of
https://github.com/captain-amygdala/pistorm.git
synced 2026-02-17 04:57:06 +00:00
Panning fixes
Workbench now works, can be panned. Something's still off with the screen addresses.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
uint8_t busy = 0, rtg_on = 0, rtg_initialized = 0;
|
||||
extern uint8_t *rtg_mem;
|
||||
extern uint32_t framebuffer_addr;
|
||||
extern uint32_t framebuffer_addr_adj;
|
||||
|
||||
extern uint16_t rtg_display_width, rtg_display_height;
|
||||
extern uint16_t rtg_display_format;
|
||||
@@ -53,7 +54,7 @@ void *rtgThread(void *args) {
|
||||
int reinit = 0;
|
||||
rtg_on = 1;
|
||||
|
||||
uint32_t *indexed_buf;
|
||||
uint32_t *indexed_buf = NULL;
|
||||
|
||||
rtg_share_data.format = &rtg_display_format;
|
||||
rtg_share_data.width = &rtg_display_width;
|
||||
@@ -63,7 +64,7 @@ void *rtgThread(void *args) {
|
||||
rtg_share_data.offset_y = &rtg_offset_y;
|
||||
rtg_share_data.memory = rtg_mem;
|
||||
rtg_share_data.running = &rtg_on;
|
||||
rtg_share_data.addr = &framebuffer_addr;
|
||||
rtg_share_data.addr = &framebuffer_addr_adj;
|
||||
struct rtg_shared_data *data = &rtg_share_data;
|
||||
|
||||
uint16_t width = rtg_display_width;
|
||||
@@ -125,7 +126,6 @@ reinit_sdl:;
|
||||
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);
|
||||
@@ -138,10 +138,17 @@ reinit_sdl:;
|
||||
if (renderer && win && img) {
|
||||
SDL_RenderClear(renderer);
|
||||
if (*data->running) {
|
||||
if (format == RTGFMT_RGB32)
|
||||
SDL_UpdateTexture(img, NULL, &data->memory[*data->addr], pitch);
|
||||
else
|
||||
SDL_UpdateTexture(img, NULL, (uint8_t *)indexed_buf, pitch);
|
||||
switch (format) {
|
||||
case RTGFMT_RGB32:
|
||||
SDL_UpdateTexture(img, NULL, &data->memory[*data->addr], pitch);
|
||||
break;
|
||||
case RTGFMT_RBG565:
|
||||
SDL_UpdateTexture(img, NULL, (uint8_t *)indexed_buf, width * 2);
|
||||
break;
|
||||
case RTGFMT_8BIT:
|
||||
SDL_UpdateTexture(img, NULL, (uint8_t *)indexed_buf, width * 4);
|
||||
break;
|
||||
}
|
||||
SDL_RenderCopy(renderer, img, NULL, NULL);
|
||||
}
|
||||
SDL_RenderPresent(renderer);
|
||||
@@ -155,14 +162,14 @@ reinit_sdl:;
|
||||
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)]];
|
||||
indexed_buf[x + (y * width)] = palette[data->memory[*data->addr + x + (y * pitch)]];
|
||||
}
|
||||
}
|
||||
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)]);
|
||||
((uint16_t *)indexed_buf)[x + (y * width)] = be16toh(((uint16_t *)data->memory)[(*data->addr / 2) + x + (y * (pitch / 2))]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -186,6 +193,9 @@ shutdown_sdl:;
|
||||
|
||||
if (reinit)
|
||||
goto reinit_sdl;
|
||||
|
||||
if (indexed_buf)
|
||||
free(indexed_buf);
|
||||
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
SDL_Quit();
|
||||
|
||||
@@ -23,6 +23,7 @@ uint16_t rtg_offset_x, rtg_offset_y;
|
||||
uint8_t *rtg_mem; // FIXME
|
||||
|
||||
uint32_t framebuffer_addr;
|
||||
uint32_t framebuffer_addr_adj;
|
||||
|
||||
static void handle_rtg_command(uint32_t cmd);
|
||||
static struct timespec f1, f2;
|
||||
@@ -185,11 +186,13 @@ static void handle_rtg_command(uint32_t cmd) {
|
||||
rtg_display_width = rtg_x[0];
|
||||
rtg_display_height = rtg_y[0];
|
||||
if (rtg_u8[0]) {
|
||||
rtg_pitch = rtg_x[1];
|
||||
//rtg_pitch = rtg_display_width << rtg_format;
|
||||
framebuffer_addr_adj = framebuffer_addr + (rtg_offset_x << rtg_display_format) + (rtg_offset_y * rtg_pitch);
|
||||
rtg_total_rows = rtg_y[1];
|
||||
}
|
||||
else {
|
||||
rtg_pitch = rtg_x[1];
|
||||
//rtg_pitch = rtg_display_width << rtg_format;
|
||||
framebuffer_addr_adj = framebuffer_addr + (rtg_offset_x << rtg_display_format) + (rtg_offset_y * rtg_pitch);
|
||||
rtg_total_rows = rtg_y[1];
|
||||
}
|
||||
printf("Set RTG mode:\n");
|
||||
@@ -202,8 +205,9 @@ static void handle_rtg_command(uint32_t cmd) {
|
||||
rtg_offset_y = rtg_y[1];
|
||||
rtg_pitch = (rtg_x[0] << rtg_display_format);
|
||||
framebuffer_addr = rtg_address[0] - (PIGFX_RTG_BASE + PIGFX_REG_SIZE);
|
||||
framebuffer_addr += (rtg_offset_x << rtg_display_format) + (rtg_offset_y * rtg_pitch);
|
||||
printf("Set panning to $%.8X\n", framebuffer_addr);
|
||||
framebuffer_addr_adj = framebuffer_addr + (rtg_offset_x << rtg_display_format) + (rtg_offset_y * rtg_pitch);
|
||||
printf("Set panning to $%.8X (%.8X)\n", framebuffer_addr, rtg_address[0]);
|
||||
printf("(Panned: $%.8X)\n", framebuffer_addr_adj);
|
||||
printf("Offset X/Y: %d/%d\n", rtg_offset_x, rtg_offset_y);
|
||||
printf("Pitch: %d (%d bytes)\n", rtg_x[0], rtg_pitch);
|
||||
break;
|
||||
@@ -241,6 +245,7 @@ static void handle_rtg_command(uint32_t cmd) {
|
||||
void rtg_fillrect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint32_t color, uint16_t pitch, uint16_t format, uint8_t mask) {
|
||||
if (mask || pitch) {}
|
||||
uint8_t *dptr = &rtg_mem[framebuffer_addr + (x << format) + (y * rtg_pitch)];
|
||||
//printf("FillRect: %d,%d to %d,%d C%.8X, p:%d dp: %d m:%.2X\n", x, y, x+w, y+h, color, pitch, rtg_pitch, mask);
|
||||
switch(format) {
|
||||
case RTGFMT_8BIT: {
|
||||
//printf("Incoming 8-bit color: %.8X\n", color);
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
#include <stdio.h>
|
||||
#include "boardinfo.h"
|
||||
|
||||
#define WRITESHORT(cmd, val) *(unsigned short *)((unsigned int)(b->RegisterBase)+cmd) = val;
|
||||
#define WRITELONG(cmd, val) *(unsigned int *)((unsigned int)(b->RegisterBase)+cmd) = val;
|
||||
#define WRITEBYTE(cmd, val) *(unsigned char *)((unsigned int)(b->RegisterBase)+cmd) = val;
|
||||
#define WRITESHORT(cmd, val) *(unsigned short *)((unsigned long)(b->RegisterBase)+cmd) = val;
|
||||
#define WRITELONG(cmd, val) *(unsigned long *)((unsigned long)(b->RegisterBase)+cmd) = val;
|
||||
#define WRITEBYTE(cmd, val) *(unsigned char *)((unsigned long)(b->RegisterBase)+cmd) = val;
|
||||
|
||||
#define CARD_OFFSET 0x70000000
|
||||
#define CARD_REGSIZE 0x00010000
|
||||
@@ -99,7 +99,7 @@ UWORD SetSwitch (__REGA0(struct BoardInfo *b), __REGD0(UWORD enabled));
|
||||
UWORD SetDisplay (__REGA0(struct BoardInfo *b), __REGD0(UWORD enabled));
|
||||
|
||||
UWORD CalculateBytesPerRow (__REGA0(struct BoardInfo *b), __REGD0(UWORD width), __REGD7(RGBFTYPE format));
|
||||
APTR CalculateMemory (__REGA0(struct BoardInfo *b), __REGA1(unsigned int addr), __REGD7(RGBFTYPE format));
|
||||
APTR CalculateMemory (__REGA0(struct BoardInfo *b), __REGA1(unsigned long addr), __REGD7(RGBFTYPE format));
|
||||
ULONG GetCompatibleFormats (__REGA0(struct BoardInfo *b), __REGD7(RGBFTYPE format));
|
||||
|
||||
LONG ResolvePixelClock (__REGA0(struct BoardInfo *b), __REGA1(struct ModeInfo *mode_info), __REGD0(ULONG pixel_clock), __REGD7(RGBFTYPE format));
|
||||
@@ -406,7 +406,7 @@ void SetPanning (__REGA0(struct BoardInfo *b), __REGA1(UBYTE *addr), __REGD0(UWO
|
||||
b->XOffset = x_offset;
|
||||
b->YOffset = y_offset;
|
||||
|
||||
WRITELONG(RTG_ADDR1, (unsigned int)addr);
|
||||
WRITELONG(RTG_ADDR1, (unsigned long)addr);
|
||||
WRITESHORT(RTG_X1, width);
|
||||
WRITESHORT(RTG_X2, b->XOffset);
|
||||
WRITESHORT(RTG_Y2, b->YOffset);
|
||||
@@ -424,7 +424,7 @@ void SetColorArray (__REGA0(struct BoardInfo *b), __REGD0(UWORD start), __REGD1(
|
||||
//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);
|
||||
unsigned long xrgb = 0 | (b->CLUT[i].Red << 16) | (b->CLUT[i].Green << 8) | (b->CLUT[i].Blue);
|
||||
WRITEBYTE(RTG_U81, (unsigned char)i);
|
||||
WRITELONG(RTG_RGB1, xrgb);
|
||||
WRITESHORT(RTG_COMMAND, RTGCMD_SETCLUT);
|
||||
@@ -447,7 +447,7 @@ UWORD CalculateBytesPerRow (__REGA0(struct BoardInfo *b), __REGD0(UWORD width),
|
||||
}
|
||||
}
|
||||
|
||||
APTR CalculateMemory (__REGA0(struct BoardInfo *b), __REGA1(unsigned int addr), __REGD7(RGBFTYPE format)) {
|
||||
APTR CalculateMemory (__REGA0(struct BoardInfo *b), __REGA1(unsigned long addr), __REGD7(RGBFTYPE format)) {
|
||||
/*if (!b)
|
||||
return (APTR)addr;
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user