From 1e35f035a555a1144e256fc599766dee4bc944b6 Mon Sep 17 00:00:00 2001 From: Dimitris Panokostas Date: Mon, 31 Aug 2020 20:37:25 +0200 Subject: [PATCH] Picasso96 2.5.0+ screen dragging support. --- src/osdep/amiberry_gfx.cpp | 2 +- src/osdep/picasso96.cpp | 83 ++++++++++++++++++++++++++++---------- src/osdep/picasso96.h | 13 ++++-- 3 files changed, 72 insertions(+), 26 deletions(-) diff --git a/src/osdep/amiberry_gfx.cpp b/src/osdep/amiberry_gfx.cpp index f26f317b..c2f40ebb 100644 --- a/src/osdep/amiberry_gfx.cpp +++ b/src/osdep/amiberry_gfx.cpp @@ -1909,7 +1909,7 @@ int picasso_palette(struct MyCLUTEntry *CLUT, uae_u32 *clut) { auto changed = 0; - for (auto i = 0; i < 256; i++) { + for (auto i = 0; i < 256 * 2; i++) { int r = CLUT[i].Red; int g = CLUT[i].Green; int b = CLUT[i].Blue; diff --git a/src/osdep/picasso96.cpp b/src/osdep/picasso96.cpp index dd8c3917..09c5b54c 100644 --- a/src/osdep/picasso96.cpp +++ b/src/osdep/picasso96.cpp @@ -35,8 +35,6 @@ #include -#include "amiberry_gfx.h" - #if defined(PICASSO96) #define WINCURSOR 1 @@ -45,21 +43,24 @@ #define USE_HARDWARESPRITE 1 -#include "config.h" #include "options.h" #include "threaddep/thread.h" #include "memory.h" #include "custom.h" +#include "events.h" #include "newcpu.h" #include "xwin.h" #include "savestate.h" #include "autoconf.h" #include "traps.h" #include "native2amiga.h" +#include "drawing.h" +#include "inputdevice.h" #ifdef RETROPLATFORM #include "rp.h" #endif #include "picasso96.h" +#include "amiberry_gfx.h" #include "gfxboard.h" #include "devices.h" @@ -167,8 +168,8 @@ static int overlay_vram_offset; static int overlay_active; static int overlay_convert; static int overlay_occlusion; -static struct MyCLUTEntry overlay_clutc[256]; -static uae_u32 overlay_clut[256]; +static struct MyCLUTEntry overlay_clutc[256 * 2]; +static uae_u32 overlay_clut[256 * 2]; static uae_u32* p96_rgbx16_ovl; static int uaegfx_old, uaegfx_active; @@ -1422,10 +1423,14 @@ d7: RGBFTYPE RGBFormat static uae_u32 REGPARAM2 picasso_SetSpritePosition(TrapContext* ctx) { struct picasso96_state_struct* state = &picasso96_state; + struct picasso_vidbuf_description* vidinfo = &picasso_vidinfo; uaecptr bi = trap_get_areg(ctx, 0); boardinfo = bi; int x = (uae_s16)trap_get_word(ctx, bi + PSSO_BoardInfo_MouseX) - state->XOffset; int y = (uae_s16)trap_get_word(ctx, bi + PSSO_BoardInfo_MouseY) - state->YOffset; + if (vidinfo->splitypos >= 0) { + y += vidinfo->splitypos; + } newcursor_x = x; newcursor_y = y; if (!hwsprite) @@ -2295,6 +2300,7 @@ static void inituaegfx(TrapContext *ctx, uaecptr ABI) #if OVERLAY flags |= BIF_VIDEOWINDOW; #endif + flags |= BIF_VGASCREENSPLIT; trap_put_long(ctx, ABI + PSSO_BoardInfo_Flags, flags); trap_put_word(ctx, ABI + PSSO_BoardInfo_MaxHorResolution + 0, planar.width); @@ -2489,7 +2495,10 @@ static int updateclut(TrapContext* ctx, uaecptr clut, int start, int count) state->CLUT[i].Red = r; state->CLUT[i].Green = g; state->CLUT[i].Blue = b; -} + state->CLUT[i + 256].Red = r; + state->CLUT[i + 256].Green = g; + state->CLUT[i + 256].Blue = b; + } changed |= picasso_palette(state->CLUT, vidinfo->clut); return changed; @@ -2669,6 +2678,21 @@ static uae_u32 REGPARAM2 picasso_SetPanning(TrapContext* ctx) return 1; } +static uae_u32 picasso_SetSplitPosition(TrapContext* ctx) +{ + //lockrtg(); + //int monid = currprefs.rtgboards[0].monitor_id; + struct picasso_vidbuf_description* vidinfo = &picasso_vidinfo; + + uae_s16 pos = trap_get_dreg(ctx, 0) - 1; + if (pos != vidinfo->splitypos) { + vidinfo->splitypos = pos; + vidinfo->full_refresh = 1; + } + //unlockrtg(); + return 1; +} + #ifdef CPU_AARCH64 static void do_xor8(uae_u8* p, int w, uae_u32 v) { @@ -3745,11 +3769,19 @@ void picasso_statusline(uae_u8* dst) static void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width, int srcbytesperrow, int srcpixbytes, int dx, int dy, int dstbytesperrow, int dstpixbytes, bool direct, int convert_mode, uae_u32 *p96_rgbx16p) { struct picasso_vidbuf_description *vidinfo = &picasso_vidinfo; - uae_u8* src2 = src + y * srcbytesperrow; - uae_u8* dst2 = dst + dy * dstbytesperrow; int endx = x + width, endx4; int dstpix = dstpixbytes; int srcpix = srcpixbytes; + uae_u32* clut = vidinfo->clut; + + if (y >= vidinfo->splitypos && vidinfo->splitypos >= 0) { + src = gfxmem_banks[0]->start + regs.natmem_offset; + clut += 256; + y -= vidinfo->splitypos; + } + + uae_u8* src2 = src + y * srcbytesperrow; + uae_u8* dst2 = dst + dy * dstbytesperrow; if (direct) { memcpy(dst2 + x * dstpix, src2 + x * srcpix, width * dstpix); @@ -3946,26 +3978,26 @@ static void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width, int srcb case RGBFB_CLUT_RGBFB_32: { while ((x & 3) && x < endx) { - ((uae_u32*)dst2)[dx] = vidinfo->clut[src2[x]]; + ((uae_u32*)dst2)[dx] = clut[src2[x]]; x++; dx++; } while (x < endx4) { - ((uae_u32*)dst2)[dx] = vidinfo->clut[src2[x]]; + ((uae_u32*)dst2)[dx] = clut[src2[x]]; x++; dx++; - ((uae_u32*)dst2)[dx] = vidinfo->clut[src2[x]]; + ((uae_u32*)dst2)[dx] = clut[src2[x]]; x++; dx++; - ((uae_u32*)dst2)[dx] = vidinfo->clut[src2[x]]; + ((uae_u32*)dst2)[dx] = clut[src2[x]]; x++; dx++; - ((uae_u32*)dst2)[dx] = vidinfo->clut[src2[x]]; + ((uae_u32*)dst2)[dx] = clut[src2[x]]; x++; dx++; } while (x < endx) { - ((uae_u32*)dst2)[dx] = vidinfo->clut[src2[x]]; + ((uae_u32*)dst2)[dx] = clut[src2[x]]; x++; dx++; } @@ -3976,26 +4008,26 @@ static void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width, int srcb case RGBFB_CLUT_RGBFB_16: { while ((x & 3) && x < endx) { - ((uae_u16*)dst2)[dx] = vidinfo->clut[src2[x]]; + ((uae_u16*)dst2)[dx] = clut[src2[x]]; x++; dx++; } while (x < endx4) { - ((uae_u16*)dst2)[dx] = vidinfo->clut[src2[x]]; + ((uae_u16*)dst2)[dx] = clut[src2[x]]; x++; dx++; - ((uae_u16*)dst2)[dx] = vidinfo->clut[src2[x]]; + ((uae_u16*)dst2)[dx] = clut[src2[x]]; x++; dx++; - ((uae_u16*)dst2)[dx] = vidinfo->clut[src2[x]]; + ((uae_u16*)dst2)[dx] = clut[src2[x]]; x++; dx++; - ((uae_u16*)dst2)[dx] = vidinfo->clut[src2[x]]; + ((uae_u16*)dst2)[dx] = clut[src2[x]]; x++; dx++; } while (x < endx) { - ((uae_u16*)dst2)[dx] = vidinfo->clut[src2[x]]; + ((uae_u16*)dst2)[dx] = clut[src2[x]]; x++; dx++; } @@ -4563,13 +4595,18 @@ void fb_copyrow(uae_u8 *src, uae_u8 *dst, int x, int y, int width, int srcpixbyt static void copyallinvert(uae_u8 *src, uae_u8 *dst, int pwidth, int pheight, int srcbytesperrow, int srcpixbytes, int dstbytesperrow, int dstpixbytes, bool direct, int mode_convert) { + struct picasso_vidbuf_description* vidinfo = &picasso_vidinfo; int x, y, w; w = pwidth * dstpixbytes; if (direct) { for (y = 0; y < pheight; y++) { - for (x = 0; x < w; x++) + if (y == vidinfo->splitypos) { + src = gfxmem_banks[0]->start + regs.natmem_offset; + } + for (x = 0; x < w; x++) { dst[x] = src[x] ^ 0xff; + } dst += dstbytesperrow; src += srcbytesperrow; } @@ -4604,6 +4641,9 @@ static void copyall(uae_u8* src, uae_u8* dst, int pwidth, int pheight, int srcby const auto w = pwidth * vidinfo->pixbytes; for (auto y = 0; y < pheight; y++) { + if (y == vidinfo->splitypos) { + src = gfxmem_banks[0]->start + regs.natmem_offset; + } memcpy(dst, src, w); dst += dstbytesperrow; src += srcbytesperrow; @@ -5481,6 +5521,7 @@ static void inituaegfxfuncs(TrapContext* ctx, uaecptr start, uaecptr ABI) RTGCALL2X(PSSO_BoardInfo_CreateFeature, picasso_CreateFeature); RTGCALL2X(PSSO_BoardInfo_DeleteFeature, picasso_DeleteFeature); #endif + RTGCALL2(PSSO_SetSplitPosition, picasso_SetSplitPosition); RTGCALL2(PSSO_BoardInfo_SetInterrupt, picasso_SetInterrupt); diff --git a/src/osdep/picasso96.h b/src/osdep/picasso96.h index 87e4b2af..41029261 100644 --- a/src/osdep/picasso96.h +++ b/src/osdep/picasso96.h @@ -522,8 +522,8 @@ enum { #define PSSO_BoardInfo_Reserved0 PSSO_BoardInfo_BlitPlanar2DirectDefault + 4 #define PSSO_BoardInfo_Reserved0Default PSSO_BoardInfo_Reserved0 + 4 #define PSSO_BoardInfo_Reserved1 PSSO_BoardInfo_Reserved0Default + 4 -#define PSSO_BoardInfo_Reserved1Default PSSO_BoardInfo_Reserved1 + 4 -#define PSSO_BoardInfo_Reserved2 PSSO_BoardInfo_Reserved1Default + 4 +#define PSSO_SetSplitPosition PSSO_BoardInfo_Reserved1 + 4 +#define PSSO_BoardInfo_Reserved2 PSSO_SetSplitPosition + 4 #define PSSO_BoardInfo_Reserved2Default PSSO_BoardInfo_Reserved2 + 4 #define PSSO_BoardInfo_Reserved3 PSSO_BoardInfo_Reserved2Default + 4 #define PSSO_BoardInfo_Reserved3Default PSSO_BoardInfo_Reserved3 + 4 @@ -596,6 +596,8 @@ enum { #define BIB_NEEDSALIGNMENT 2 /* bitmaps have to be aligned (not yet supported!) */ #define BIB_CACHEMODECHANGE 3 /* board memory may be set to Imprecise (060) or Nonserialised (040) */ #define BIB_VBLANKINTERRUPT 4 /* board can cause a hardware interrupt on a vertical retrace */ +#define BIB_HASSPRITEBUFFER 5 /* board has allocated memory for software sprite image and save buffer */ +#define BIB_VGASCREENSPLIT 6 /* has a screen B with fixed screen position for split-screens */ #define BIB_DBLSCANDBLSPRITEY 8 /* hardware sprite y position is doubled on doublescan display modes */ #define BIB_ILACEHALFSPRITEY 9 /* hardware sprite y position is halved on interlace display modes */ #define BIB_ILACEDBLROWOFFSET 10 /* doubled row offset in interlaced display modes needs additional horizontal bit */ @@ -623,6 +625,8 @@ enum { #define BIF_NEEDSALIGNMENT (1 << BIB_NEEDSALIGNMENT) #define BIF_CACHEMODECHANGE (1 << BIB_CACHEMODECHANGE) #define BIF_VBLANKINTERRUPT (1 << BIB_VBLANKINTERRUPT) +#define BIF_HASSPRITEBUFFER (1 << BIB_HASSPRITEBUFFER) +#define BIF_VGASCREENSPLIT (1 << BIB_VGASCREENSPLIT) #define BIF_DBLSCANDBLSPRITEY (1 << BIB_DBLSCANDBLSPRITEY) #define BIF_ILACEHALFSPRITEY (1 << BIB_ILACEHALFSPRITEY) #define BIF_ILACEDBLROWOFFSET (1 << BIB_ILACEDBLROWOFFSET) @@ -649,7 +653,7 @@ enum { struct picasso96_state_struct { RGBFTYPE RGBFormat; /* true-colour, CLUT, hi-colour, etc.*/ - struct MyCLUTEntry CLUT[256]; /* Duh! */ + struct MyCLUTEntry CLUT[2 * 256]; /* Duh! */ uaecptr Address; /* Active screen address (Amiga-side)*/ uaecptr Extent; /* End address of screen (Amiga-side)*/ uae_u16 Width; /* Active display width (From SetGC)*/ @@ -703,7 +707,7 @@ struct picasso_vidbuf_description { int extra_mem; /* nonzero if there's a second buffer that must be updated */ uae_u32 rgbformat; RGBFTYPE selected_rgbformat; - uae_u32 clut[256]; + uae_u32 clut[256 * 2]; int picasso_convert, host_mode; int ohost_mode, orgbformat; int full_refresh; @@ -711,6 +715,7 @@ struct picasso_vidbuf_description { int rtg_clear_flag; bool picasso_active; bool picasso_changed; + uae_s16 splitypos; uae_atomic picasso_state_change; };