--- uae/src/picasso96.c 2018/04/24 16:42:09 1.1.1.2 +++ uae/src/picasso96.c 2018/04/24 16:44:50 1.1.1.4 @@ -26,6 +26,8 @@ * * TODO: * - add panning capability + * - we want to add a manual switch to override SetSwitch for hardware banging + * programs started from a Picasso workbench. */ #include "sysconfig.h" @@ -44,6 +46,13 @@ #ifdef PICASSO96 +/*#define P96TRACING_ENABLED */ +#ifdef P96TRACING_ENABLED +#define P96TRACE(x) do { write_log x; } while(0) +#else +#define P96TRACE(x) +#endif + static uae_u32 gfxmem_lget (uaecptr) REGPARAM; static uae_u32 gfxmem_wget (uaecptr) REGPARAM; static uae_u32 gfxmem_bget (uaecptr) REGPARAM; @@ -57,7 +66,7 @@ static void write_gfx_long (uaecptr addr static void write_gfx_word (uaecptr addr, uae_u16 value); static void write_gfx_byte (uaecptr addr, uae_u8 value); -static uae_u8 all_ones_bitmap, all_zeros_bitmap; /* yuk */ +static uae_u8 all_ones_bitmap, all_zeros_bitmap; struct picasso96_state_struct picasso96_state; struct picasso_vidbuf_description picasso_vidinfo; @@ -70,7 +79,7 @@ struct ScreenResolution planar = { 320, struct ScreenResolution chunky = { 640, 480 }; struct ScreenResolution hicolour = { 640, 480 }; struct ScreenResolution truecolour = { 640, 480 }; -struct ScreenResolution alphacolour = { 460, 480 }; +struct ScreenResolution alphacolour = { 640, 480 }; uae_u16 picasso96_pixel_format = RGBFF_CHUNKY; @@ -117,7 +126,7 @@ static void DumpLibResolutionStructure ( { int i; uaecptr amigamodeinfoptr; - struct LibResolution *uaememptr = (struct LibResolution *)get_mem_bank(amigalibresptr).xlateaddr(amigalibresptr); + struct LibResolution *uaememptr = (struct LibResolution *)get_mem_bank (amigalibresptr).xlateaddr(amigalibresptr); return; @@ -141,7 +150,7 @@ static void DumpLibResolutionStructure ( } } -static char binary_byte[8]; +static char binary_byte[9]; static char *BuildBinaryString (uae_u8 value) { @@ -149,6 +158,7 @@ static char *BuildBinaryString (uae_u8 v for (i = 0; i < 8; i++) { binary_byte[i] = (value & (1 << (7 - i))) ? '#' : '.'; } + binary_byte[8] = '\0'; return binary_byte; } @@ -227,7 +237,7 @@ static int CopyRenderInfoStructureA2U (u { uaecptr memp = get_long (amigamemptr + PSSO_RenderInfo_Memory); - if (valid_address (memp, 1 /* FIXME */)) { + if (valid_address (memp, PSSO_RenderInfo_sizeof)) { ri->Memory = get_real_address (memp); ri->BytesPerRow = get_word (amigamemptr + PSSO_RenderInfo_BytesPerRow); ri->RGBFormat = get_long (amigamemptr + PSSO_RenderInfo_RGBFormat); @@ -240,7 +250,7 @@ static int CopyRenderInfoStructureA2U (u static int CopyPatternStructureA2U (uaecptr amigamemptr, struct Pattern *pattern) { uaecptr memp = get_long (amigamemptr + PSSO_Pattern_Memory); - if (valid_address (memp, 1 /* FIXME */)) { + if (valid_address (memp, PSSO_Pattern_sizeof)) { pattern->Memory = get_real_address (memp); pattern->XOffset = get_word (amigamemptr + PSSO_Pattern_XOffset); pattern->YOffset = get_word (amigamemptr + PSSO_Pattern_YOffset); @@ -313,9 +323,9 @@ static void CopyLibResolutionStructureU2 char *uaememptr = 0; int i; - uaememptr = gfxmem_xlate(amigamemptr); /* I know that amigamemptr is inside my gfxmem chunk, so I can just do the xlate() */ - memset(uaememptr, 0, PSSO_LibResolution_sizeof); /* zero out our LibResolution structure */ - strcpy(uaememptr + PSSO_LibResolution_P96ID, libres->P96ID); + uaememptr = gfxmem_xlate (amigamemptr); /* I know that amigamemptr is inside my gfxmem chunk, so I can just do the xlate() */ + memset (uaememptr, 0, PSSO_LibResolution_sizeof); /* zero out our LibResolution structure */ + strcpy (uaememptr + PSSO_LibResolution_P96ID, libres->P96ID); put_long (amigamemptr + PSSO_LibResolution_DisplayID, libres->DisplayID); put_word (amigamemptr + PSSO_LibResolution_Width, libres->Width); put_word (amigamemptr + PSSO_LibResolution_Height, libres->Height); @@ -560,9 +570,9 @@ static int renderinfo_is_current_screen { if (! picasso_on) return 0; - if (ri->Memory != gfxmemory + (picasso96_state.Address - gfxmem_start)) { + if (ri->Memory != gfxmemory + (picasso96_state.Address - gfxmem_start)) return 0; - } + return 1; } @@ -629,16 +639,16 @@ static void FillBoardInfo (uaecptr amiga { char *uaememptr; switch (dm->depth) { - case 1: + case 1: res->Modes[CHUNKY] = amigamemptr; break; - case 2: + case 2: res->Modes[HICOLOR] = amigamemptr; break; - case 3: + case 3: res->Modes[TRUECOLOR] = amigamemptr; break; - default: + default: res->Modes[TRUEALPHA] = amigamemptr; break; } @@ -667,6 +677,30 @@ static void FillBoardInfo (uaecptr amiga put_long (amigamemptr + PSSO_ModeInfo_PixelClock, dm->res.width * dm->res.height * dm->refresh); } +static uae_u32 AssignModeID (int i, int count) +{ + if (DisplayModes[i].res.width == 320 && DisplayModes[i].res.height == 200) + return 0x50001000; + else if (DisplayModes[i].res.width == 320 && DisplayModes[i].res.height == 240) + return 0x50011000; + else if (DisplayModes[i].res.width == 640 && DisplayModes[i].res.height == 400) + return 0x50021000; + else if (DisplayModes[i].res.width == 640 && DisplayModes[i].res.height == 480) + return 0x50031000; + else if (DisplayModes[i].res.width == 800 && DisplayModes[i].res.height == 600) + return 0x50041000; + else if (DisplayModes[i].res.width == 1024 && DisplayModes[i].res.height == 768) + return 0x50051000; + else if (DisplayModes[i].res.width == 1152 && DisplayModes[i].res.height == 864) + return 0x50061000; + else if (DisplayModes[i].res.width == 1280 && DisplayModes[i].res.height == 1024) + return 0x50071000; + else if (DisplayModes[i].res.width == 1600 && DisplayModes[i].res.height == 1280) + return 0x50081000; + + return 0x50091000 + count * 0x10000; +} + /**************************************** * InitCard() * @@ -707,7 +741,7 @@ uae_u32 picasso_InitCard (void) for (i = 0; i < mode_count;) { int j = i; /* Add a LibResolution structure to the ResolutionsList MinList in our BoardInfo */ - res.DisplayID = 0x50001000 + LibResolutionStructureCount * 0x10000; + res.DisplayID = AssignModeID (i, LibResolutionStructureCount); res.BoardInfo = AmigaBoardInfo; res.Width = DisplayModes[i].res.width; res.Height = DisplayModes[i].res.height; @@ -719,7 +753,7 @@ uae_u32 picasso_InitCard (void) res.P96ID[4] = '0'; res.P96ID[5] = ':'; strcpy (res.Name, "uaegfx:"); - strncat (res.Name, DisplayModes[i].name, strchr(DisplayModes[i].name, ',') - DisplayModes[i].name); + strncat (res.Name, DisplayModes[i].name, strchr (DisplayModes[i].name, ',') - DisplayModes[i].name); res.Modes[PLANAR] = 0; res.Modes[CHUNKY] = 0; res.Modes[HICOLOR] = 0; @@ -820,7 +854,7 @@ uae_u32 picasso_SetColorArray (void) DX_SetPalette (start, count); } /*write_log ("SetColorArray(%d,%d)\n", start, count); */ - return m68k_dreg (regs, 0); + return 1; } /* @@ -837,7 +871,7 @@ uae_u32 picasso_SetDAC (void) * Lets us keep track of what pixel format the Amiga is thinking about in our frame-buffer */ write_log ("SetDAC()\n"); - return m68k_dreg (regs, 0); + return 1; } /* @@ -872,7 +906,7 @@ uae_u32 picasso_SetGC (void) wgfx_linestart = 0xFFFFFFFF; picasso_refresh (); - return m68k_dreg (regs, 0); + return 1; } /* @@ -923,7 +957,7 @@ uae_u32 picasso_SetPanning (void) wgfx_linestart = 0xFFFFFFFF; picasso_refresh (); - return m68k_dreg (regs, 0); + return 1; } static void do_xor8 (uae_u8 *ptr, long len, uae_u32 val) @@ -1382,7 +1416,7 @@ uae_u32 picasso_BlitPattern (void) uae_u8 Mask = (uae_u8)m68k_dreg (regs, 4); uae_u32 RGBFmt = m68k_dreg (regs, 7); - uae_u8 Bpp = GetBytesPerPixel(RGBFmt); + uae_u8 Bpp = GetBytesPerPixel (RGBFmt); int inversion = 0; struct RenderInfo ri; struct Pattern pattern; @@ -1804,7 +1838,7 @@ uae_u32 picasso_BlitPlanar2Chunky (void) if (minterm != 0x0C) { write_log ("ERROR - BlitPlanar2Chunky() has minterm 0x%x, which I don't handle. Using fall-back routine.\n", - minterm); + minterm); return 0; } if (! CopyRenderInfoStructureA2U (ri, &local_ri) @@ -1820,7 +1854,7 @@ uae_u32 picasso_BlitPlanar2Chunky (void) local_ri.BytesPerRow, 0, 0, dstx, dsty, width, height, 0); - return m68k_dreg (regs, 0); + return 1; } /* NOTE: Watch for those planeptrs of 0x00000000 and 0xFFFFFFFF for all zero / all one bitmaps !!!! */