fread(cfg->map_data[index], cfg->rom_size[index], 1, in);
fclose(in);
displayRomInfo(cfg->map_data[index]);
+ if (cfg->map_size[index] == cfg->rom_size[index])
+ m68k_add_rom_range(cfg->map_offset[index], cfg->map_high[index], cfg->map_data[index]);
break;
case MAPTYPE_REGISTER:
default:
}
printf("[CFG] [MAP %d] Added %s mapping for range %.8lX-%.8lX ID: %s\n", index, map_type_names[type], cfg->map_offset[index], cfg->map_high[index] - 1, cfg->map_id[index] ? cfg->map_id[index] : "None");
- if (cfg->map_size[index] == cfg->rom_size[index])
- m68k_add_rom_range(cfg->map_offset[index], cfg->map_high[index], cfg->map_data[index]);
return;
return result;
}
#else
-
- uint32_t address = ADDRESS_68K(REG_PC);
REG_PC += 2;
- for (int i = 0; i < read_ranges; i++) {
- if(address >= read_addr[i] && address < read_upper[i]) {
- return be16toh(((unsigned short *)(read_data[i] + (address - read_addr[i])))[0]);
- }
- }
-
return m68k_read_immediate_16(address);
#endif /* M68K_EMULATE_PREFETCH */
}
return temp_val;
#else
- m68ki_set_fc(FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */
- m68ki_check_address_error(REG_PC, MODE_READ, FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */
- uint32_t address = ADDRESS_68K(REG_PC);
REG_PC += 4;
- for (int i = 0; i < read_ranges; i++) {
- if(address >= read_addr[i] && address < read_upper[i]) {
- return be32toh(((unsigned int *)(read_data[i] + (address - read_addr[i])))[0]);
- }
- }
return m68k_read_immediate_32(address);
#endif /* M68K_EMULATE_PREFETCH */
case 0x45: // FDSQRT
case 0x41: // FSSQRT
case 0x04: // FSQRT
+ case 0x05: // FSQRT
{
REG_FP[dst] = floatx80_sqrt(source, &status);
SET_CONDITION_CODES(REG_FP[dst]);
break;
}
case 0x06: // FLOGNP1
+ case 0x07: // FLOGNP1
{
REG_FP[dst] = floatx80_lognp1 (source, &status);
SET_CONDITION_CODES(REG_FP[dst]);
break;
}
case 0x0a: // FATAN
+ case 0x0b: // FATAN
{
REG_FP[dst] = floatx80_atan(source, &status);
SET_CONDITION_CODES(REG_FP[dst]);
break;
}
case 0x12: // FTENTOX
+ case 0x13: // FTENTOX
{
REG_FP[dst] = floatx80_tentox(source, &status);
SET_CONDITION_CODES(REG_FP[dst]);
break;
}
case 0x16: // FLOG2
+ case 0x17: // FLOG2
{
REG_FP[dst] = floatx80_log2(source, &status);
SET_CONDITION_CODES(REG_FP[dst]);
case 0x5e: // FDNEG
case 0x5a: // FSNEG
case 0x1a: // FNEG
+ case 0x1b: // FNEG
{
REG_FP[dst] = source;
REG_FP[dst].high ^= 0x8000;
USE_CYCLES(11); // ? (value is from FMUL)
break;
}
- case 0x6a: // FDSUB
+ case 0x6c: // FDSUB
case 0x68: // FSSUB
case 0x28: // FSUB
+ case 0x29: // FSUB
+ case 0x2a: // FSUB
+ case 0x2b: // FSUB
+ case 0x2c: // FSUB
+ case 0x2d: // FSUB
+ case 0x2e: // FSUB
+ case 0x2f: // FSUB
{
REG_FP[dst] = floatx80_sub(REG_FP[dst], source, &status);
SET_CONDITION_CODES(REG_FP[dst]);
break;
}
case 0x38: // FCMP
+ case 0x39: // FCMP
+ case 0x3c: // FCMP
+ case 0x3d: // FCMP
{
floatx80 res;
res = floatx80_sub(REG_FP[dst], source, &status);
break;
}
case 0x3a: // FTST
+ case 0x3b: // FTST
+ case 0x3e: // FTST
+ case 0x3f: // FTST
{
floatx80 res;
res = source;
cdtv_mode = 1;
}
if (strcmp(var, "rtg") == 0 && !rtg_enabled) {
- if (init_rtg_data()) {
+ if (init_rtg_data(cfg)) {
printf("[AMIGA] RTG Enabled.\n");
rtg_enabled = 1;
adjust_ranges_amiga(cfg);
PI_CMD_MEMCPY = 0x0108, // [W] Copy written longword of bytes from one area of memory (PTR1)
// to another (PTR2).
PI_CMD_GET_FB = 0x010C, // [R] Get the current framebuffer address.
+ PI_CMD_COPYRECT = 0x0110, // [W] Generic memory copyrect with source and destination pitch.
+ PI_CMD_COPYRECT_EX = 0x0112, // [W] Extended memory copyrect with additional source/destination X/Y coordinates.
PI_CMD_QBASIC = 0x0FFC, // QBasic
PI_CMD_NIBBLES = 0x0FFE, // Nibbles
PI_PTR2 = 0x2034, // [W] For instance for loading large files to Amiga RAM or
PI_PTR3 = 0x2038, // [W] transferring over files from the Pi side of things.
PI_PTR4 = 0x203C, // [W]
+ PI_WORD5 = 0x2040, // [RW]
+ PI_WORD6 = 0x2042, // [RW]
+ PI_WORD7 = 0x2044, // [RW]
+ PI_WORD8 = 0x2046, // [RW]
+ PI_WORD9 = 0x2048, // [RW]
+ PI_WORD10 = 0x204A, // [RW]
+ PI_WORD11 = 0x204C, // [RW]
+ PI_WORD12 = 0x204E, // [RW]
PI_CMDRESULT = 0x2100, // [R] Check the result of any command that provides a "return value".
};
char cfg_filename[256] = "default.cfg";
char tmp_string[256];
-static uint8_t pi_byte[8];
-static uint16_t pi_word[4];
-static uint32_t pi_longword[4];
-static uint32_t pi_string[4];
-static uint32_t pi_ptr[4];
+static uint8_t pi_byte[32];
+static uint16_t pi_word[32];
+static uint32_t pi_longword[32];
+static uint32_t pi_string[32];
+static uint32_t pi_ptr[32];
-static uint32_t pi_dbg_val[4];
-static uint32_t pi_dbg_string[4];
+static uint32_t pi_dbg_val[32];
+static uint32_t pi_dbg_string[32];
static uint32_t pi_cmd_result = 0, shutdown_confirm = 0xFFFFFFFF;
pi_byte[addr - PI_BYTE1] = (val & 0xFF);
break;
case PI_WORD1: case PI_WORD2: case PI_WORD3: case PI_WORD4:
- DEBUG("[PISTORM-DEV] Set WORD %d to %d ($%.4X)\n", (addr - PI_WORD1) / 2, (val & 0xFFFF), (val & 0xFFFF));
+ //DEBUG("[PISTORM-DEV] Set WORD %d to %d ($%.4X)\n", (addr - PI_WORD1) / 2, (val & 0xFFFF), (val & 0xFFFF));
pi_word[(addr - PI_WORD1) / 2] = (val & 0xFFFF);
break;
+ case PI_WORD5: case PI_WORD6: case PI_WORD7: case PI_WORD8:
+ case PI_WORD9: case PI_WORD10: case PI_WORD11: case PI_WORD12:
+ //DEBUG("[PISTORM-DEV] Set WORD %d to %d ($%.4X)\n", (addr - PI_WORD5) / 2, (val & 0xFFFF), (val & 0xFFFF));
+ pi_word[(addr - PI_WORD5) / 2] = (val & 0xFFFF);
+ break;
case PI_LONGWORD1: case PI_LONGWORD2: case PI_LONGWORD3: case PI_LONGWORD4:
- DEBUG("[PISTORM-DEV] Set LONGWORD %d to %d ($%.8X)\n", (addr - PI_LONGWORD1) / 4, val, val);
+ //DEBUG("[PISTORM-DEV] Set LONGWORD %d to %d ($%.8X)\n", (addr - PI_LONGWORD1) / 4, val, val);
pi_longword[(addr - PI_LONGWORD1) / 4] = val;
break;
case PI_STR1: case PI_STR2: case PI_STR3: case PI_STR4:
pi_string[(addr - PI_STR1) / 4] = val;
break;
case PI_PTR1: case PI_PTR2: case PI_PTR3: case PI_PTR4:
- DEBUG("[PISTORM-DEV] Set DATA POINTER %d to $%.8X\n", (addr - PI_PTR1) / 4, val);
+ //DEBUG("[PISTORM-DEV] Set DATA POINTER %d to $%.8X\n", (addr - PI_PTR1) / 4, val);
pi_ptr[(addr - PI_PTR1) / 4] = val;
break;
pi_ptr[0] = 0;
break;
case PI_CMD_MEMCPY:
- DEBUG("[PISTORM-DEV} Write to MEMCPY: %d (%.8X)\n", val, val);
+ //DEBUG("[PISTORM-DEV} Write to MEMCPY: %d (%.8X)\n", val, val);
if (pi_ptr[0] == 0 || pi_ptr[1] == 0) {
printf("[PISTORM-DEV] MEMCPY from/to null pointer not allowed. Aborting.\n");
pi_cmd_result = PI_RES_INVALIDVALUE;
int32_t src = get_mapped_item_by_address(cfg, pi_ptr[0]);
int32_t dst = get_mapped_item_by_address(cfg, pi_ptr[1]);
if (dst != -1 && src != -1) {
- printf("doing super memcpy\n");
+ //printf("doing super memcpy\n");
uint8_t *src_ptr = &cfg->map_data[src][(pi_ptr[0] - cfg->map_offset[src])];
uint8_t *dst_ptr = &cfg->map_data[dst][(pi_ptr[1] - cfg->map_offset[dst])];
memcpy(dst_ptr, src_ptr, val);
} else {
- printf("doing manual memcpy\n");
+ printf("!!! doing manual memcpy\n");
uint8_t tmp = 0;
for (uint32_t i = 0; i < val; i++) {
if (src == -1) tmp = read8(pi_ptr[0] + i);
- else tmp = cfg->map_data[src][pi_ptr[0] - cfg->map_offset[src]];
+ else tmp = cfg->map_data[src][pi_ptr[0] - cfg->map_offset[src] + i];
if (dst == -1) write8(pi_ptr[1] + i, tmp);
- else cfg->map_data[dst][pi_ptr[1] - cfg->map_offset[dst]] = tmp;
+ else cfg->map_data[dst][pi_ptr[1] - cfg->map_offset[dst] + i] = tmp;
+ }
+ }
+ //DEBUG("[PISTORM-DEV] Copied %d bytes from $%.8X to $%.8X\n", val, pi_ptr[0], pi_ptr[1]);
+ }
+ break;
+ case PI_CMD_COPYRECT:
+ case PI_CMD_COPYRECT_EX:
+ if (pi_ptr[0] == 0 || pi_ptr[1] == 0) {
+ printf("[PISTORM-DEV] COPYRECT/EX from/to null pointer not allowed. Aborting.\n");
+ pi_cmd_result = PI_RES_INVALIDVALUE;
+ } else if (pi_word[2] == 0 || pi_word[3] == 0) {
+ printf("[PISTORM-DEV] COPYRECT/EX called with a width/height of 0. Aborting.\n");
+ pi_cmd_result = PI_RES_INVALIDVALUE;
+ } else {
+ int32_t src = get_mapped_item_by_address(cfg, pi_ptr[0]);
+ int32_t dst = get_mapped_item_by_address(cfg, pi_ptr[1]);
+
+ if (dst != -1 && src != -1) {
+ uint8_t *src_ptr = &cfg->map_data[src][(pi_ptr[0] - cfg->map_offset[src])];
+ uint8_t *dst_ptr = &cfg->map_data[dst][(pi_ptr[1] - cfg->map_offset[dst])];
+
+ if (addr == PI_CMD_COPYRECT_EX) {
+ // Adjust pointers in the case of available src/dst coordinates.
+ src_ptr += pi_word[4] + (pi_word[5] * pi_word[0]);
+ dst_ptr += pi_word[6] + (pi_word[7] * pi_word[1]);
+ }
+
+ for (int i = 0; i < pi_word[3]; i++) {
+ memcpy(dst_ptr, src_ptr, pi_word[2]);
+
+ src_ptr += pi_word[0];
+ dst_ptr += pi_word[1];
+ }
+ } else {
+ printf("!!! doing manual copyrect\n");
+
+ if (addr != PI_CMD_COPYRECT_EX) {
+ // Clear out the src/dst coordinates in case something else set them previously.
+ pi_word[4] = pi_word[5] = pi_word[6] = pi_word[7] = 0;
+ }
+
+ uint32_t src_offset = 0, dst_offset = 0;
+ uint8_t tmp = 0;
+
+ if (addr == PI_CMD_COPYRECT_EX) {
+ src_offset += pi_word[4] + (pi_word[5] * pi_word[0]);
+ dst_offset += pi_word[6] + (pi_word[7] * pi_word[1]);
+ }
+
+ for (uint32_t y = 0; y < pi_word[3]; y++) {
+ for (uint32_t x = 0; x < pi_word[2]; x++) {
+ if (src == -1) tmp = read8(pi_ptr[0] + src_offset + x);
+ else tmp = cfg->map_data[src][(pi_ptr[0] + src_offset + x) - cfg->map_offset[src]];
+
+ if (dst == -1) write8(pi_ptr[1] + dst_offset + x, tmp);
+ else cfg->map_data[dst][(pi_ptr[1] + dst_offset + x) - cfg->map_offset[dst]] = tmp;
+ }
+ src_offset += pi_word[0];
+ dst_offset += pi_word[1];
}
}
- DEBUG("[PISTORM-DEV] Copied %d bytes from $%.8X to $%.8X\n", val, pi_ptr[0], pi_ptr[1]);
}
break;
case PI_CMD_RTGSTATUS:
DEBUG("[PISTORM-DEV] Write to RTGSTATUS: %d\n", val);
if (val == 1 && !rtg_enabled) {
- init_rtg_data();
+ init_rtg_data(cfg);
rtg_enabled = 1;
pi_cmd_result = PI_RES_OK;
} else if (val == 0 && rtg_enabled) {
return piscsi_enabled;
break;
case PI_CMD_GET_FB:
- DEBUG("[PISTORM-DEV] %s read from GET_FB: %.8X\n", op_type_names[type], rtg_get_fb());
+ //DEBUG("[PISTORM-DEV] %s read from GET_FB: %.8X\n", op_type_names[type], rtg_get_fb());
return rtg_get_fb();
case PI_DBG_VAL1: case PI_DBG_VAL2: case PI_DBG_VAL3: case PI_DBG_VAL4:
DEBUG("[PISTORM-DEV] Read WORD %d (%d / $%.4X)\n", (addr - PI_WORD1) / 2, pi_word[(addr - PI_WORD1) / 2], pi_word[(addr - PI_WORD1) / 2]);
return pi_word[(addr - PI_WORD1) / 2];
break;
+ case PI_WORD5: case PI_WORD6: case PI_WORD7: case PI_WORD8:
+ case PI_WORD9: case PI_WORD10: case PI_WORD11: case PI_WORD12:
+ DEBUG("[PISTORM-DEV] Read WORD %d (%d / $%.4X)\n", (addr - PI_WORD5) / 2, pi_word[(addr - PI_WORD5) / 2], pi_word[(addr - PI_WORD5) / 2]);
+ return pi_word[(addr - PI_WORD5) / 2];
+ break;
case PI_LONGWORD1: case PI_LONGWORD2: case PI_LONGWORD3: case PI_LONGWORD4:
DEBUG("[PISTORM-DEV] Read LONGWORD %d (%d / $%.8X)\n", (addr - PI_LONGWORD1) / 4, pi_longword[(addr - PI_LONGWORD1) / 4], pi_longword[(addr - PI_LONGWORD1) / 4]);
return pi_longword[(addr - PI_LONGWORD1) / 4];
break;
case PI_CMDRESULT:
- DEBUG("[PISTORM-DEV] %s Read from CMDRESULT: %d\n", op_type_names[type], pi_cmd_result);
+ //DEBUG("[PISTORM-DEV] %s Read from CMDRESULT: %d\n", op_type_names[type], pi_cmd_result);
return pi_cmd_result;
break;
RETURN_CMDRES;
}
+// Generic memory copyrect, assuming that the src/dst offsets are already adjusted for X/Y coordinates.
+void pi_copyrect(unsigned char *dst, unsigned char *src,
+ unsigned short src_pitch, unsigned short dst_pitch,
+ unsigned short w, unsigned short h) {
+ WRITELONG(PI_PTR1, (unsigned int)src);
+ WRITELONG(PI_PTR2, (unsigned int)dst);
+ WRITESHORT(PI_WORD1, src_pitch);
+ WRITESHORT(PI_WORD2, dst_pitch);
+ WRITESHORT(PI_WORD3, w);
+ WRITESHORT(PI_WORD4, h);
+
+ WRITESHORT(PI_CMD_COPYRECT, 1);
+}
+
+// Extended memory copyrect, allowing specifying of source/dest X/Y coordinates.
+void pi_copyrect_ex(unsigned char *dst, unsigned char *src,
+ unsigned short src_pitch, unsigned short dst_pitch,
+ unsigned short src_x, unsigned short src_y,
+ unsigned short dst_x, unsigned short dst_y,
+ unsigned short w, unsigned short h) {
+ WRITELONG(PI_PTR1, (unsigned int)src);
+ WRITELONG(PI_PTR2, (unsigned int)dst);
+ WRITESHORT(PI_WORD1, src_pitch);
+ WRITESHORT(PI_WORD2, dst_pitch);
+ WRITESHORT(PI_WORD3, w);
+ WRITESHORT(PI_WORD4, h);
+
+ WRITESHORT(PI_WORD5, src_x);
+ WRITESHORT(PI_WORD6, src_y);
+ WRITESHORT(PI_WORD7, dst_x);
+ WRITESHORT(PI_WORD8, dst_y);
+
+ WRITESHORT(PI_CMD_COPYRECT_EX, 1);
+}
+
// PiSCSI stuff
// TODO: There's currently no way to read back what drives are mounted at which SCSI index.
unsigned short pi_piscsi_map_drive(char *filename, unsigned char index) {
unsigned short pi_get_filesize(char *filename, unsigned int *file_size);
unsigned short pi_transfer_file(char *filename, unsigned char *dest_ptr);
unsigned short pi_memcpy(unsigned char *dst, unsigned char *src, unsigned int size);
+void pi_copyrect(unsigned char *dst, unsigned char *src, unsigned short src_pitch, unsigned short dst_pitch, unsigned short w, unsigned short h);
+void pi_copyrect_ex(unsigned char *dst, unsigned char *src, unsigned short src_pitch, unsigned short dst_pitch, unsigned short src_x, unsigned short src_y, unsigned short dst_x, unsigned short dst_y, unsigned short w, unsigned short h);
unsigned int pi_get_fb(void);
unsigned short pi_load_config(char *filename);
vec4 texelColor = texture2D(texture0, fragTexCoord);
vec4 color = vec4(1.0, 1.0, 1.0, 1.0);
- vec2 bukCoord = vec2(texelColor.r, 0.0);
+ vec2 bukCoord = vec2(texelColor.r, 0.5);
+
+ if (texelColor.r == 1.0) {
+ bukCoord = vec2(0.9999, 0.5);
+ }
vec4 colorx = texture2D(texture1, bukCoord);
gl_FragColor = vec4(colorx.r, colorx.g, colorx.b, 1.0);
extern uint8_t realtime_graphics_debug;
+uint8_t cursor_data[256 * 256];
+
void rtg_fillrect_solid(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint32_t color, uint16_t pitch, uint16_t format) {
uint8_t *dptr = &rtg_mem[rtg_address_adj[0] + (x << format) + (y * pitch)];
switch(format) {
cur_byte++;
cur_byte %= src_line_pitch;
}
+ }
+ dptr += pitch;
+ if ((line_y + sy + 1) % h)
+ bmp_data += src_line_pitch;
+ else
+ bmp_data = bmp_data_src;
+ cur_bit = base_bit;
+ cur_byte = base_byte;
+ }
+}
+
+void rtg_p2d (int16_t sx, int16_t sy, int16_t dx, int16_t dy, int16_t w, int16_t h, uint8_t draw_mode, uint8_t planes, uint8_t mask, uint8_t layer_mask, uint16_t src_line_pitch, uint8_t *bmp_data_src) {
+ uint16_t pitch = rtg_x[3];
+ uint8_t *dptr = &rtg_mem[rtg_address_adj[0] + (dy * pitch)];
+
+ uint8_t cur_bit, base_bit, base_byte;
+ uint16_t cur_byte = 0, u8_fg = 0;
+ //uint32_t color_mask = 0xFFFFFFFF;
+ uint32_t plane_size = src_line_pitch * h;
+ uint8_t *bmp_data = bmp_data_src;
+
+ cur_bit = base_bit = (0x80 >> (sx % 8));
+ cur_byte = base_byte = ((sx / 8) % src_line_pitch);
+
+ if (realtime_graphics_debug) {
+ printf("P2D: %d,%d - %d,%d (%dx%d) %d, %.2X\n", sx, sy, dx, dy, w, h, planes, layer_mask);
+ printf("Mask: %.2X Minterm: %.2X\n", mask, draw_mode);
+ printf("Pitch: %d Src Pitch: %d (!!!: %.4X)\n", pitch, src_line_pitch, rtg_user[0]);
+ printf("Curbyte: %d Curbit: %d\n", cur_byte, cur_bit);
+ printf("Plane size: %d Total size: %d (%X)\n", plane_size, plane_size * planes, plane_size * planes);
+ printf("Source: %.8X - %.8X\n", rtg_address[1], rtg_address_adj[1]);
+ printf("Target: %.8X - %.8X\n", rtg_address[0], rtg_address_adj[0]);
+ fflush(stdout);
+
+ printf("Grabbing data from RTG memory.\nData:\n");
+ for (int i = 0; i < h; i++) {
+ for (int k = 0; k < planes; k++) {
+ for (int j = 0; j < src_line_pitch; j++) {
+ printf("%.2X", bmp_data_src[j + (i * src_line_pitch) + (plane_size * k)]);
+ }
+ printf(" ");
+ }
+ printf("\n");
+ }
+ }
+
+ uint32_t *clut = (uint32_t *)bmp_data_src;
+ bmp_data += (256 * 4);
+ bmp_data_src += (256 * 4);
+
+ for (int16_t line_y = 0; line_y < h; line_y++) {
+ for (int16_t x = dx; x < dx + w; x++) {
+ u8_fg = 0;
+ if (draw_mode & 0x01) {
+ DECODE_INVERTED_PLANAR_PIXEL(u8_fg)
+ }
+ else {
+ DECODE_PLANAR_PIXEL(u8_fg)
+ }
+
+ uint32_t fg_color = clut[u8_fg];
+
+ if (mask == 0xFF && (draw_mode == MINTERM_SRC || draw_mode == MINTERM_NOTSRC)) {
+ switch (rtg_display_format) {
+ case RTGFMT_RBG565:
+ ((uint16_t *)dptr)[x] = (fg_color >> 16);
+ break;
+ case RTGFMT_RGB32:
+ ((uint32_t *)dptr)[x] = fg_color;
+ break;
+ }
+ goto skip;
+ }
+
+ skip:;
+ if ((cur_bit >>= 1) == 0) {
+ cur_bit = 0x80;
+ cur_byte++;
+ cur_byte %= src_line_pitch;
+ }
}
dptr += pitch;
if ((line_y + sy + 1) % h)
// SPDX-License-Identifier: MIT
+#include "config_file/config_file.h"
#include "emulator.h"
#include "rtg.h"
struct rtg_shared_data rtg_share_data;
static uint32_t palette[256];
+static uint32_t cursor_palette[256];
+
+extern uint8_t cursor_data[256 * 256];
void rtg_update_screen() {}
PIXELFORMAT_UNCOMPRESSED_R5G5B5A1,
};
+uint32_t rtg_pixel_size[RTGFMT_NUM] = {
+ 1,
+ 2,
+ 4,
+ 2,
+};
+
void *rtgThread(void *args) {
printf("RTG thread running\n");
uint16_t format = rtg_display_format;
uint16_t pitch = rtg_pitch;
- Texture raylib_texture;
- Texture raylib_clut_texture;
- Image raylib_fb, raylib_clut;
+ Texture raylib_texture, raylib_cursor_texture;
+ Texture raylib_clut_texture, raylib_cursor_clut_texture;
+ Image raylib_fb, raylib_cursor, raylib_clut, raylib_cursor_clut;
InitWindow(GetScreenWidth(), GetScreenHeight(), "Pistorm RTG");
HideCursor();
SetTargetFPS(60);
- Color bef;
- bef.r = 0;
- bef.g = 64;
- bef.b = 128;
- bef.a = 255;
+ Color bef = { 0, 64, 128, 255 };
Shader clut_shader = LoadShader(NULL, "platforms/amiga/rtg/clut.shader");
Shader swizzle_shader = LoadShader(NULL, "platforms/amiga/rtg/argbswizzle.shader");
raylib_clut.mipmaps = 1;
raylib_clut.data = palette;
+ raylib_cursor_clut.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
+ raylib_cursor_clut.width = 256;
+ raylib_cursor_clut.height = 1;
+ raylib_cursor_clut.mipmaps = 1;
+ raylib_cursor_clut.data = cursor_palette;
+
raylib_clut_texture = LoadTextureFromImage(raylib_clut);
+ raylib_cursor_clut_texture = LoadTextureFromImage(raylib_cursor_clut);
+
+ raylib_cursor.format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE;
+ raylib_cursor.width = 256;
+ raylib_cursor.height = 256;
+ raylib_cursor.mipmaps = 1;
+ raylib_cursor.data = cursor_data;
+ raylib_cursor_texture = LoadTextureFromImage(raylib_cursor);
Rectangle srchax, dsthax;
Vector2 originhax;
printf("Setting up raylib framebuffer image.\n");
raylib_fb.format = rtg_to_raylib[format];
- raylib_fb.width = width;
- raylib_fb.height = height;
- raylib_fb.mipmaps = 1;
- raylib_fb.data = &data->memory[*data->addr];
-
- raylib_texture = LoadTextureFromImage(raylib_fb);
switch (format) {
case RTGFMT_RBG565:
+ raylib_fb.width = width;
indexed_buf = calloc(1, width * height * 2);
break;
default:
+ raylib_fb.width = pitch / rtg_pixel_size[format];
break;
}
+ raylib_fb.height = height;
+ raylib_fb.mipmaps = 1;
+ raylib_fb.data = &data->memory[*data->addr];
+ printf("Width: %d\nPitch: %d\nBPP: %d\n", raylib_fb.width, pitch, rtg_pixel_size[format]);
+
+ raylib_texture = LoadTextureFromImage(raylib_fb);
srchax.x = srchax.y = 0;
srchax.width = width;
DrawTexturePro(raylib_texture, srchax, dsthax, originhax, 0.0f, RAYWHITE);
}
else {
- DrawTexture(raylib_texture, 0, 0, RAYWHITE);
+ Rectangle srcrect = { 0, 0, width, height };
+ DrawTexturePro(raylib_texture, srcrect, srcrect, originhax, 0.0f, RAYWHITE);
+ //DrawTexture(raylib_texture, 0, 0, RAYWHITE);
}
switch (format) {
break;
}
#ifdef DEBUG_RAYLIB_RTG
- DrawTexture(raylib_clut_texture, 0, 0, RAYWHITE);
+ if (format == RTGFMT_8BIT) {
+ Rectangle srcrect = { 0, 0, 256, 1 };
+ Rectangle dstrect = { 0, 0, 1024, 8 };
+ //DrawTexture(raylib_clut_texture, 0, 0, RAYWHITE);
+ DrawTexturePro(raylib_clut_texture, srcrect, dstrect, originhax, 0.0f, RAYWHITE);
+ }
#endif
DrawFPS(width - 200, 0);
DrawText("RTG is currently sleeping.", 16, 16, 12, RAYWHITE);
EndDrawing();
}
- if (height != *data->height || width != *data->width || format != *data->format) {
+ if (pitch != *data->pitch || height != *data->height || width != *data->width || format != *data->format) {
printf("Reinitializing due to something change.\n");
reinit = 1;
goto shutdown_raylib;
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include "rtg.h"
#include "config_file/config_file.h"
+#include "rtg.h"
uint8_t rtg_u8[4];
uint16_t rtg_x[8], rtg_y[8];
"15BPP RGB (555)",
};
*/
-int init_rtg_data() {
+int init_rtg_data(struct emulator_config *cfg_) {
rtg_mem = calloc(1, 40 * SIZE_MEGA);
if (!rtg_mem) {
printf("Failed to allocate RTG video memory.\n");
}
m68k_add_ram_range(PIGFX_RTG_BASE + PIGFX_REG_SIZE, PIGFX_RTG_SIZE - PIGFX_REG_SIZE, rtg_mem);
- add_mapping(cfg, MAPTYPE_RAM_NOALLOC, PIGFX_RTG_BASE + PIGFX_REG_SIZE, PIGFX_RTG_SIZE - PIGFX_REG_SIZE, -1, rtg_mem, "rtg_mem");
+ add_mapping(cfg_, MAPTYPE_RAM_NOALLOC, PIGFX_RTG_BASE + PIGFX_REG_SIZE, PIGFX_RTG_SIZE - PIGFX_REG_SIZE, -1, (char *)rtg_mem, "rtg_mem");
return 1;
}
//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);
+ //printf("Pitch: %d (%d bytes)\n", rtg_x[0], rtg_pitch);
break;
case RTGCMD_SETCLUT: {
//printf("Command: SetCLUT.\n");
break;
case RTGCMD_P2C:
rtg_p2c(rtg_x[0], rtg_y[0], rtg_x[1], rtg_y[1], rtg_x[2], rtg_y[2], rtg_u8[1], rtg_u8[2], rtg_u8[0], (rtg_user[0] >> 0x8), rtg_x[4], (uint8_t *)&rtg_mem[rtg_address_adj[1]]);
- //rtg_p2c_broken(rtg_x[0], rtg_y[0], rtg_x[1], rtg_y[1], rtg_x[2], rtg_y[2], rtg_x[3], rtg_u8[0], rtg_u8[1], rtg_u8[2], rtg_user[0]);
gdebug("Planar2Chunky\n");
break;
case RTGCMD_P2D:
+ rtg_p2d(rtg_x[0], rtg_y[0], rtg_x[1], rtg_y[1], rtg_x[2], rtg_y[2], rtg_u8[1], rtg_u8[2], rtg_u8[0], (rtg_user[0] >> 0x8), rtg_x[4], (uint8_t *)&rtg_mem[rtg_address_adj[1]]);
+ gdebug("Planar2Direct\n");
break;
}
}
unsigned int rtg_get_fb();
-int init_rtg_data();
+int init_rtg_data(struct emulator_config *cfg);
void shutdown_rtg();
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);
void rtg_drawline (int16_t x1_, int16_t y1_, int16_t x2_, int16_t y2_, uint16_t len, uint16_t pattern, uint16_t pattern_offset, uint32_t fgcol, uint32_t bgcol, uint16_t pitch, uint16_t format, uint8_t mask, uint8_t draw_mode);
void rtg_p2c (int16_t sx, int16_t sy, int16_t dx, int16_t dy, int16_t w, int16_t h, uint8_t draw_mode, uint8_t planes, uint8_t mask, uint8_t layer_mask, uint16_t src_line_pitch, uint8_t *bmp_data_src);
+void rtg_p2d (int16_t sx, int16_t sy, int16_t dx, int16_t dy, int16_t w, int16_t h, uint8_t draw_mode, uint8_t planes, uint8_t mask, uint8_t layer_mask, uint16_t src_line_pitch, uint8_t *bmp_data_src);
#define PATTERN_LOOPX \
tmpl_x ^= 0x01; \
b->PaletteChipType = PCT_MNT_ZZ9000;
b->GraphicsControllerType = GCT_MNT_ZZ9000;
- b->Flags = BIF_INDISPLAYCHAIN | BIF_GRANTDIRECTACCESS;
+ b->Flags = BIF_INDISPLAYCHAIN | BIF_GRANTDIRECTACCESS;// | BIF_HARDWARESPRITE;
b->RGBFormats = 1 | 2 | 512 | 1024 | 2048;
b->SoftSpriteFlags = 0;
b->BitsPerCannon = 8;
//b->ScrollPlanar = (void *)NULL;
//b->UpdatePlanar = (void *)NULL;
- //b->BlitPlanar2Chunky = (void *)BlitPlanar2Chunky;
- //b->BlitPlanar2Direct = (void *)NULL;
+ b->BlitPlanar2Chunky = (void *)BlitPlanar2Chunky;
+ b->BlitPlanar2Direct = (void *)BlitPlanar2Direct;
b->FillRect = (void *)FillRect;
b->InvertRect = (void *)InvertRect;
void InvertRect (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), __REGD0(WORD x), __REGD1(WORD y), __REGD2(WORD w), __REGD3(WORD h), __REGD4(UBYTE mask), __REGD7(RGBFTYPE format)) {
if (!r)
return;
+
+ if (mask != 0xFF) {
+ b->InvertRectDefault(b, r, x, y, w, h, mask, format);
+ return;
+ }
+
WRITELONG(RTG_ADDR1, (unsigned long)r->Memory);
WRITESHORT(RTG_FORMAT, rgbf_to_rtg[format]);
WRITESHORT(RTG_COMMAND, RTGCMD_DRAWLINE);
}
-void BlitPlanar2Chunky_Broken (__REGA0(struct BoardInfo *b), __REGA1(struct BitMap *bm), __REGA2(struct RenderInfo *r), __REGD0(SHORT x), __REGD1(SHORT y), __REGD2(SHORT dx), __REGD3(SHORT dy), __REGD4(SHORT w), __REGD5(SHORT h), __REGD6(UBYTE minterm), __REGD7(UBYTE mask)) {
- if (!r || !b || !bm) return;
+void BlitPlanar2Chunky (__REGA0(struct BoardInfo *b), __REGA1(struct BitMap *bm), __REGA2(struct RenderInfo *r), __REGD0(SHORT x), __REGD1(SHORT y), __REGD2(SHORT dx), __REGD3(SHORT dy), __REGD4(SHORT w), __REGD5(SHORT h), __REGD6(UBYTE minterm), __REGD7(UBYTE mask)) {
+ if (!b || !r)
+ return;
+
+ uint32_t plane_size = bm->BytesPerRow * bm->Rows;
- //unsigned long bmp_size = bm->BytesPerRow * bm->Rows;
- unsigned char planemask_0 = 0, planemask = 0;
- //unsigned short line_size = (w >> 3) + 2;
- //unsigned long output_plane_size = line_size * h;
- unsigned long plane_size = bm->BytesPerRow * bm->Rows;
- short x_offset = (x >> 3);
+ uint32_t template_addr = CARD_SCRATCH;
- unsigned long dest = CARD_SCRATCH;
+ uint16_t plane_mask = mask;
+ uint8_t ff_mask = 0x00;
+ uint8_t cur_plane = 0x01;
+
+ uint16_t line_size = (w >> 3) + 2;
+ uint32_t output_plane_size = line_size * h;
+ uint16_t x_offset = (x >> 3);
WRITELONG(RTG_ADDR1, (unsigned long)r->Memory);
- WRITELONG(RTG_ADDR2, (unsigned long)dest);
- WRITELONG(RTG_ADDR3, (unsigned long)bm->Planes[0]);
+ WRITELONG(RTG_ADDR2, template_addr);
+ WRITESHORT(RTG_X4, r->BytesPerRow);
+ WRITESHORT(RTG_X5, line_size);
+ WRITESHORT(RTG_FORMAT, rgbf_to_rtg[r->RGBFormat]);
- for (unsigned short i = 0; i < bm->Depth; i++) {
- if ((unsigned long)bm->Planes[i] == 0xFFFFFFFF) {
- planemask |= (1 << i);
- }
- else if (bm->Planes[i] == NULL) {
- planemask_0 |= (1 << i);
+ WRITEBYTE(RTG_U81, mask);
+ WRITEBYTE(RTG_U82, minterm);
+
+ for (int16_t i = 0; i < bm->Depth; i++) {
+ uint16_t x_offset = (x >> 3);
+ if ((uint32_t)bm->Planes[i] == 0xFFFFFFFF) {
+ uint8_t* dest = (uint8_t*)((uint32_t)template_addr);
+ memset(dest, 0xFF, output_plane_size);
}
- else {
- unsigned long bmp_mem = (unsigned long)(bm->Planes[i]) + x_offset + (y * bm->BytesPerRow);
- unsigned long plane_dest = dest;
- for (unsigned short y_line = 0; y_line < h; y_line++) {
- memcpy((unsigned char *)plane_dest, (unsigned char *)bmp_mem, bm->BytesPerRow);
- plane_dest += bm->BytesPerRow;
+ else if (bm->Planes[i] != NULL) {
+ uint8_t* bmp_mem = (uint8_t*)bm->Planes[i] + (y * bm->BytesPerRow) + x_offset;
+ uint8_t* dest = (uint8_t*)((uint32_t)template_addr);
+ for (int16_t y_line = 0; y_line < h; y_line++) {
+ memcpy(dest, bmp_mem, line_size);
+ dest += line_size;
bmp_mem += bm->BytesPerRow;
}
}
- dest += plane_size;
+ else {
+ plane_mask &= (cur_plane ^ 0xFF);
+ }
+ cur_plane <<= 1;
+ template_addr += output_plane_size;
}
- WRITESHORT(RTG_X1, x % 0x07);
+ WRITESHORT(RTG_X1, (x & 0x07));
WRITESHORT(RTG_X2, dx);
WRITESHORT(RTG_X3, w);
WRITESHORT(RTG_Y1, 0);
WRITESHORT(RTG_Y2, dy);
WRITESHORT(RTG_Y3, h);
- WRITESHORT(RTG_Y4, bm->Rows);
- WRITESHORT(RTG_X4, r->BytesPerRow);
- WRITESHORT(RTG_U1, planemask_0 << 8 | planemask);
- WRITESHORT(RTG_U2, bm->BytesPerRow);
-
- WRITEBYTE(RTG_U81, mask);
- WRITEBYTE(RTG_U82, minterm);
+ WRITESHORT(RTG_U1, (plane_mask << 8 | ff_mask));
WRITEBYTE(RTG_U83, bm->Depth);
WRITESHORT(RTG_COMMAND, RTGCMD_P2C);
}
-void BlitPlanar2Chunky (__REGA0(struct BoardInfo *b), __REGA1(struct BitMap *bm), __REGA2(struct RenderInfo *r), __REGD0(SHORT x), __REGD1(SHORT y), __REGD2(SHORT dx), __REGD3(SHORT dy), __REGD4(SHORT w), __REGD5(SHORT h), __REGD6(UBYTE minterm), __REGD7(UBYTE mask)) {
+void BlitPlanar2Direct (__REGA0(struct BoardInfo *b), __REGA1(struct BitMap *bm), __REGA2(struct RenderInfo *r), __REGA3(struct ColorIndexMapping *clut), __REGD0(SHORT x), __REGD1(SHORT y), __REGD2(SHORT dx), __REGD3(SHORT dy), __REGD4(SHORT w), __REGD5(SHORT h), __REGD6(UBYTE minterm), __REGD7(UBYTE mask)) {
if (!b || !r)
return;
WRITEBYTE(RTG_U81, mask);
WRITEBYTE(RTG_U82, minterm);
+ memcpy((uint8_t*)((uint32_t)template_addr), clut->Colors, (256 << 2));
+ template_addr += (256 << 2);
+
for (int16_t i = 0; i < bm->Depth; i++) {
uint16_t x_offset = (x >> 3);
if ((uint32_t)bm->Planes[i] == 0xFFFFFFFF) {
- //memset((uint8_t*)(((uint32_t)b->memory)+template_addr), 0xFF, output_plane_size);
- ff_mask |= cur_plane;
+ uint8_t* dest = (uint8_t*)((uint32_t)template_addr);
+ memset(dest, 0xFF, output_plane_size);
}
else if (bm->Planes[i] != NULL) {
uint8_t* bmp_mem = (uint8_t*)bm->Planes[i] + (y * bm->BytesPerRow) + x_offset;
WRITESHORT(RTG_U1, (plane_mask << 8 | ff_mask));
WRITEBYTE(RTG_U83, bm->Depth);
- WRITESHORT(RTG_COMMAND, RTGCMD_P2C);
-}
-
-void BlitPlanar2Direct (__REGA0(struct BoardInfo *b), __REGA1(struct BitMap *bmp), __REGA2(struct RenderInfo *r), __REGA3(struct ColorIndexMapping *clut), __REGD0(SHORT x), __REGD1(SHORT y), __REGD2(SHORT dx), __REGD3(SHORT dy), __REGD4(SHORT w), __REGD5(SHORT h), __REGD6(UBYTE minterm), __REGD7(UBYTE mask)) {
-
+ WRITESHORT(RTG_COMMAND, RTGCMD_P2D);
}