--- uae/src/picasso96.c 2018/04/24 16:40:02 1.1 +++ uae/src/picasso96.c 2018/04/24 16:46:13 1.1.1.5 @@ -25,10 +25,9 @@ * accesses which may be rather slow. * * TODO: - * - add an 8 bit emulation for hicolor/truecolor screens. This would allow - * users to select an 8 bit Workbench resolution that would work regardless - * of which color depth the display is currently in. * - 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" @@ -47,10 +46,12 @@ #ifdef PICASSO96 -extern uae_u8 *lockscr (void); -extern void unlockscr (void); - -#define MyOutputDebugString printf +/*#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; @@ -65,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; @@ -78,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; @@ -94,63 +95,62 @@ static uae_u32 p2ctab[256][2]; static void DumpModeInfoStructure (uaecptr amigamodeinfoptr) { - int i; - MyOutputDebugString ("ModeInfo Structure Dump:\n"); - MyOutputDebugString (" Node.ln_Succ = 0x%x\n", get_long (amigamodeinfoptr)); - MyOutputDebugString (" Node.ln_Pred = 0x%x\n", get_long (amigamodeinfoptr + 4)); - MyOutputDebugString (" Node.ln_Type = 0x%x\n", get_byte (amigamodeinfoptr + 8)); - MyOutputDebugString (" Node.ln_Pri = %d\n", get_byte (amigamodeinfoptr + 9)); - /*MyOutputDebugString (" Node.ln_Name = %s\n", uaememptr->Node.ln_Name); */ - MyOutputDebugString (" OpenCount = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_OpenCount)); - MyOutputDebugString (" Active = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_Active)); - MyOutputDebugString (" Width = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_Width)); - MyOutputDebugString (" Height = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_Height)); - MyOutputDebugString (" Depth = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_Depth)); - MyOutputDebugString (" Flags = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_Flags)); - MyOutputDebugString (" HorTotal = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorTotal)); - MyOutputDebugString (" HorBlankSize = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorBlankSize)); - MyOutputDebugString (" HorSyncStart = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorSyncStart)); - MyOutputDebugString (" HorSyncSize = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorSyncSize)); - MyOutputDebugString (" HorSyncSkew = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_HorSyncSkew)); - MyOutputDebugString (" HorEnableSkew = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_HorEnableSkew)); - MyOutputDebugString (" VerTotal = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerTotal)); - MyOutputDebugString (" VerBlankSize = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerBlankSize)); - MyOutputDebugString (" VerSyncStart = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerSyncStart)); - MyOutputDebugString (" VerSyncSize = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerSyncSize)); - MyOutputDebugString (" Clock = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_first_union)); - MyOutputDebugString (" ClockDivide = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_second_union)); - MyOutputDebugString (" PixelClock = %d\n", get_long (amigamodeinfoptr + PSSO_ModeInfo_PixelClock)); + write_log ("ModeInfo Structure Dump:\n"); + write_log (" Node.ln_Succ = 0x%x\n", get_long (amigamodeinfoptr)); + write_log (" Node.ln_Pred = 0x%x\n", get_long (amigamodeinfoptr + 4)); + write_log (" Node.ln_Type = 0x%x\n", get_byte (amigamodeinfoptr + 8)); + write_log (" Node.ln_Pri = %d\n", get_byte (amigamodeinfoptr + 9)); + /*write_log (" Node.ln_Name = %s\n", uaememptr->Node.ln_Name); */ + write_log (" OpenCount = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_OpenCount)); + write_log (" Active = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_Active)); + write_log (" Width = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_Width)); + write_log (" Height = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_Height)); + write_log (" Depth = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_Depth)); + write_log (" Flags = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_Flags)); + write_log (" HorTotal = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorTotal)); + write_log (" HorBlankSize = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorBlankSize)); + write_log (" HorSyncStart = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorSyncStart)); + write_log (" HorSyncSize = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorSyncSize)); + write_log (" HorSyncSkew = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_HorSyncSkew)); + write_log (" HorEnableSkew = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_HorEnableSkew)); + write_log (" VerTotal = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerTotal)); + write_log (" VerBlankSize = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerBlankSize)); + write_log (" VerSyncStart = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerSyncStart)); + write_log (" VerSyncSize = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerSyncSize)); + write_log (" Clock = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_first_union)); + write_log (" ClockDivide = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_second_union)); + write_log (" PixelClock = %d\n", get_long (amigamodeinfoptr + PSSO_ModeInfo_PixelClock)); } static void DumpLibResolutionStructure (uaecptr amigalibresptr) { 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; - MyOutputDebugString ("LibResolution Structure Dump:\n"); + write_log ("LibResolution Structure Dump:\n"); if (get_long (amigalibresptr + PSSO_LibResolution_DisplayID) == 0xFFFFFFFF) { - MyOutputDebugString (" Finished With LibResolutions...\n"); + write_log (" Finished With LibResolutions...\n"); } else { - MyOutputDebugString (" Name = %s\n", uaememptr->P96ID); - MyOutputDebugString (" DisplayID = 0x%x\n", get_long (amigalibresptr + PSSO_LibResolution_DisplayID)); - MyOutputDebugString (" Width = %d\n", get_word (amigalibresptr + PSSO_LibResolution_Width)); - MyOutputDebugString (" Height = %d\n", get_word (amigalibresptr + PSSO_LibResolution_Height)); - MyOutputDebugString (" Flags = %d\n", get_word (amigalibresptr + PSSO_LibResolution_Flags)); + write_log (" Name = %s\n", uaememptr->P96ID); + write_log (" DisplayID = 0x%x\n", get_long (amigalibresptr + PSSO_LibResolution_DisplayID)); + write_log (" Width = %d\n", get_word (amigalibresptr + PSSO_LibResolution_Width)); + write_log (" Height = %d\n", get_word (amigalibresptr + PSSO_LibResolution_Height)); + write_log (" Flags = %d\n", get_word (amigalibresptr + PSSO_LibResolution_Flags)); for (i = 0; i < MAXMODES; i++) { amigamodeinfoptr = get_long (amigalibresptr + PSSO_LibResolution_Modes + i*4); - MyOutputDebugString (" ModeInfo[%d] = 0x%x\n", i, amigamodeinfoptr); + write_log (" ModeInfo[%d] = 0x%x\n", i, amigamodeinfoptr); if (amigamodeinfoptr) - DumpModeInfoStructure(amigamodeinfoptr); + DumpModeInfoStructure (amigamodeinfoptr); } - MyOutputDebugString (" BoardInfo = 0x%x\n", get_long (amigalibresptr + PSSO_LibResolution_BoardInfo)); + write_log (" BoardInfo = 0x%x\n", get_long (amigalibresptr + PSSO_LibResolution_BoardInfo)); } } -static char binary_byte[8]; +static char binary_byte[9]; static char *BuildBinaryString (uae_u8 value) { @@ -158,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; } @@ -168,9 +169,9 @@ static void DumpPattern (struct Pattern for (row = 0; row < (1 << patt->Size); row++) { mem = patt->Memory + row * 2; for (col = 0; col < 2; col++) { - MyOutputDebugString ("%s", BuildBinaryString (*mem++)); + write_log ("%s", BuildBinaryString (*mem++)); } - MyOutputDebugString ("\n"); + write_log ("\n"); } } @@ -179,13 +180,13 @@ static void DumpTemplate (struct Templat uae_u8 *mem = tmp->Memory; int row, col, width; width = (w + 7) >> 3; - MyOutputDebugString ("xoffset = %d, bpr = %d\n", tmp->XOffset, tmp->BytesPerRow); + write_log ("xoffset = %d, bpr = %d\n", tmp->XOffset, tmp->BytesPerRow); for (row = 0; row < h; row++) { mem = tmp->Memory + row * tmp->BytesPerRow; for (col = 0; col < width; col++) { - MyOutputDebugString ("%s", BuildBinaryString (*mem++)); + write_log ("%s", BuildBinaryString (*mem++)); } - MyOutputDebugString ("\n"); + write_log ("\n"); } } @@ -196,7 +197,36 @@ static void ShowSupportedResolutions (vo return; for (i = 0; i < mode_count; i++) - MyOutputDebugString ("%s\n", DisplayModes[i].name); + write_log ("%s\n", DisplayModes[i].name); +} + +static uae_u8 GetBytesPerPixel (uae_u32 RGBfmt) +{ + switch (RGBfmt) { + case RGBFB_CLUT: + return 1; + + case RGBFB_A8R8G8B8: + case RGBFB_A8B8G8R8: + case RGBFB_R8G8B8A8: + case RGBFB_B8G8R8A8: + return 4; + + case RGBFB_B8G8R8: + case RGBFB_R8G8B8: + return 3; + + case RGBFB_R5G5B5: + case RGBFB_R5G6B5: + case RGBFB_R5G6B5PC: + case RGBFB_R5G5B5PC: + case RGBFB_B5G6R5PC: + case RGBFB_B5G5R5PC: + return 2; + default: + write_log ("ERROR - GetBytesPerPixel() was unsuccessful with 0x%x?!\n", RGBfmt); + return 0; + } } /* @@ -207,20 +237,20 @@ 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); return 1; } - MyOutputDebugString ("ERROR - Invalid RenderInfo memory area...\n"); + write_log ("ERROR - Invalid RenderInfo memory area...\n"); return 0; } 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); @@ -230,7 +260,7 @@ static int CopyPatternStructureA2U (uaec pattern->DrawMode = get_byte (amigamemptr + PSSO_Pattern_DrawMode); return 1; } - MyOutputDebugString ("ERROR - Invalid Pattern memory area...\n"); + write_log ("ERROR - Invalid Pattern memory area...\n"); return 0; } @@ -284,7 +314,7 @@ static int CopyTemplateStructureA2U (uae tmpl->BgPen = get_long (amigamemptr + PSSO_Template_BgPen); return 1; } - MyOutputDebugString ("ERROR - Invalid Template memory area...\n"); + write_log ("ERROR - Invalid Template memory area...\n"); return 0; } @@ -293,23 +323,23 @@ 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); - put_long(amigamemptr + PSSO_LibResolution_DisplayID, libres->DisplayID); - put_word(amigamemptr + PSSO_LibResolution_Width, libres->Width); - put_word(amigamemptr + PSSO_LibResolution_Height, libres->Height); - put_word(amigamemptr + PSSO_LibResolution_Flags, libres->Flags); + 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); + put_word (amigamemptr + PSSO_LibResolution_Flags, libres->Flags); for (i = 0; i < MAXMODES; i++) - put_long(amigamemptr + PSSO_LibResolution_Modes + i*4, libres->Modes[i]); + put_long (amigamemptr + PSSO_LibResolution_Modes + i*4, libres->Modes[i]); #if 0 - put_long(amigamemptr, libres->Node.ln_Succ); - put_long(amigamemptr + 4, libres->Node.ln_Pred); - put_byte(amigamemptr + 8, libres->Node.ln_Type); - put_byte(amigamemptr + 9, libres->Node.ln_Pri); + put_long (amigamemptr, libres->Node.ln_Succ); + put_long (amigamemptr + 4, libres->Node.ln_Pred); + put_byte (amigamemptr + 8, libres->Node.ln_Type); + put_byte (amigamemptr + 9, libres->Node.ln_Pri); #endif - put_long(amigamemptr + 10, amigamemptr + PSSO_LibResolution_P96ID); - put_long(amigamemptr + PSSO_LibResolution_BoardInfo, libres->BoardInfo); + put_long (amigamemptr + 10, amigamemptr + PSSO_LibResolution_P96ID); + put_long (amigamemptr + PSSO_LibResolution_BoardInfo, libres->BoardInfo); } /* list is Amiga address of list, in correct endian format for UAE @@ -320,24 +350,24 @@ static void AmigaListAddTail (uaecptr li if (get_long (list + 8) == list) { /* Empty list - set it up */ - put_long(list, node); /* point the lh_Head to our new node */ - put_long(list + 4, 0); /* set the lh_Tail to NULL */ - put_long(list + 8, node); /* point the lh_TailPred to our new node */ + put_long (list, node); /* point the lh_Head to our new node */ + put_long (list + 4, 0); /* set the lh_Tail to NULL */ + put_long (list + 8, node); /* point the lh_TailPred to our new node */ /* Adjust the new node - don't rely on it being zeroed out */ - put_long(node, 0); /* ln_Succ */ - put_long(node + 4, 0); /* ln_Pred */ + put_long (node, 0); /* ln_Succ */ + put_long (node + 4, 0); /* ln_Pred */ } else { amigamemptr = get_long (list + 8); /* get the lh_TailPred contents */ - put_long(list + 8, node); /* point the lh_TailPred to our new node */ + put_long (list + 8, node); /* point the lh_TailPred to our new node */ /* Adjust the previous lh_TailPred node */ - put_long(amigamemptr, node); /* point the ln_Succ to our new node */ + put_long (amigamemptr, node); /* point the ln_Succ to our new node */ /* Adjust the new node - don't rely on it being zeroed out */ - put_long(node, 0); /* ln_Succ */ - put_long(node + 4, amigamemptr); /* ln_Pred */ + put_long (node, 0); /* ln_Succ */ + put_long (node + 4, amigamemptr); /* ln_Pred */ } } @@ -353,7 +383,6 @@ static void AmigaListAddTail (uaecptr li static void do_fillrect (uae_u8 *src, int x, int y, int width, int height) { - int lines; uae_u8 *dst; /* Try OS specific fillrect function here; and return if successful. */ @@ -362,16 +391,40 @@ static void do_fillrect (uae_u8 *src, in return; width *= picasso96_state.BytesPerPixel; - dst = lockscr (); + dst = gfx_lock_picasso (); if (!dst) - return; + goto out; + + dst += y*picasso_vidinfo.rowbytes + x*picasso_vidinfo.pixbytes; + if (picasso_vidinfo.rgbformat == picasso96_state.RGBFormat) { + while (height-- > 0) { + memcpy (dst, src, width); + dst += picasso_vidinfo.rowbytes; + } + } else { + int psiz = GetBytesPerPixel (picasso_vidinfo.rgbformat); + if (picasso96_state.RGBFormat != RGBFB_CHUNKY) + abort (); - dst += y*picasso_vidinfo.rowbytes + x*picasso96_state.BytesPerPixel; - while (height-- > 0) { - memcpy (dst, src, width); - dst += picasso_vidinfo.rowbytes; + while (height-- > 0) { + int i; + switch (psiz) { + case 2: + for (i = 0; i < width; i++) + *((uae_u16 *)dst + i) = picasso_vidinfo.clut[src[i]]; + break; + case 4: + for (i = 0; i < width; i++) + *((uae_u32 *)dst + i) = picasso_vidinfo.clut[src[i]]; + break; + default: + abort (); + } + dst += picasso_vidinfo.rowbytes; + } } - unlockscr (); + out: + gfx_unlock_picasso (); } /* @@ -400,21 +453,46 @@ static void do_blit (uae_u8 *srcp, unsig if (! picasso_vidinfo.extra_mem) return; - width *= picasso96_state.BytesPerPixel; - dstp = lockscr (); + dstp = gfx_lock_picasso (); if (dstp == 0) - return; + goto out; /* The areas can't overlap: the source is always in the Picasso frame buffer, * and the destination is a different buffer owned by the graphics code. */ - dstp += dsty * picasso_vidinfo.rowbytes + dstx * picasso96_state.BytesPerPixel; - while (height-- > 0) { - memcpy (dstp, srcp, width); - srcp += src_rowbytes; - dstp += picasso_vidinfo.rowbytes; + dstp += dsty * picasso_vidinfo.rowbytes + dstx * picasso_vidinfo.pixbytes; + if (picasso_vidinfo.rgbformat == picasso96_state.RGBFormat) { + width *= picasso96_state.BytesPerPixel; + while (height-- > 0) { + memcpy (dstp, srcp, width); + srcp += src_rowbytes; + dstp += picasso_vidinfo.rowbytes; + } + } else { + int psiz = GetBytesPerPixel (picasso_vidinfo.rgbformat); + if (picasso96_state.RGBFormat != RGBFB_CHUNKY) + abort (); + + while (height-- > 0) { + int i; + switch (psiz) { + case 2: + for (i = 0; i < width; i++) + *((uae_u16 *)dstp + i) = picasso_vidinfo.clut[srcp[i]]; + break; + case 4: + for (i = 0; i < width; i++) + *((uae_u32 *)dstp + i) = picasso_vidinfo.clut[srcp[i]]; + break; + default: + abort (); + } + srcp += src_rowbytes; + dstp += picasso_vidinfo.rowbytes; + } } - unlockscr (); + out: + gfx_unlock_picasso (); } /* @@ -426,7 +504,7 @@ static void do_blit (uae_u8 *srcp, unsig static void do_invertrect (uae_u8 *src, unsigned long src_rowbytes, int x, int y, int width, int height) { - /* Try OS specific invertrect function here; and return if successful. */ + /* TODO: Try OS specific invertrect function here; and return if successful. */ do_blit (src, src_rowbytes, 0, 0, x, y, width, height, 0); } @@ -444,43 +522,67 @@ static void wgfx_do_flushline (void) if (! picasso_vidinfo.extra_mem) goto out; - dstp = lockscr (); + dstp = gfx_lock_picasso (); if (dstp == 0) goto out; /*printf("flushing %d (%x %x %x)\n", wgfx_y, wgfx_linestart, wgfx_min, wgfx_max); */ - src = (gfxmemory + wgfx_min); + src = gfxmemory + wgfx_min; + + if (picasso_vidinfo.rgbformat == picasso96_state.RGBFormat) { + dstp += wgfx_y * picasso_vidinfo.rowbytes + wgfx_min - wgfx_linestart; + memcpy (dstp, src, wgfx_max - wgfx_min); + } else { + int width = wgfx_max - wgfx_min; + int i; + int psiz = GetBytesPerPixel (picasso_vidinfo.rgbformat); - dstp += wgfx_y * picasso_vidinfo.rowbytes + wgfx_min - wgfx_linestart; - memcpy (dstp, src, wgfx_max - wgfx_min); - unlockscr (); + if (picasso96_state.RGBFormat != RGBFB_CHUNKY) + abort (); + + dstp += wgfx_y * picasso_vidinfo.rowbytes + (wgfx_min - wgfx_linestart) * psiz; + switch (psiz) { + case 2: + for (i = 0; i < width; i++) + *((uae_u16 *)dstp + i) = picasso_vidinfo.clut[src[i]]; + break; + case 4: + for (i = 0; i < width; i++) + *((uae_u32 *)dstp + i) = picasso_vidinfo.clut[src[i]]; + break; + default: + abort (); + } + } out: + gfx_unlock_picasso (); wgfx_linestart = 0xFFFFFFFF; } static __inline__ void wgfx_flushline (void) { - if (wgfx_linestart == 0xFFFFFFFF) + if (wgfx_linestart == 0xFFFFFFFF || ! picasso_on) return; wgfx_do_flushline (); } - static int renderinfo_is_current_screen (struct RenderInfo *ri) { 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; } /* Clear our screen, since we've got a new Picasso screen-mode, and refresh with the proper contents - * NOTE: This is called in two cases: - * 1. Amiga-->Picasso transition, via SetSwitch() - * 2. Picasso-->Picasso transition, via SetPanning(). */ -static void picasso_refresh (void) + * This is called on several occasions: + * 1. Amiga-->Picasso transition, via SetSwitch() + * 2. Picasso-->Picasso transition, via SetPanning(). + * 3. whenever the graphics code notifies us that the screen contents have been lost. + */ +void picasso_refresh (void) { struct RenderInfo ri; @@ -496,9 +598,9 @@ static void picasso_refresh (void) ri.RGBFormat = picasso96_state.RGBFormat; do_blit (ptr, picasso96_state.BytesPerRow, 0, 0, 0, 0, picasso96_state.Width, picasso96_state.Height, 0); - MyOutputDebugString ("picasso_refresh() successful.\n"); + write_log ("picasso_refresh() successful.\n"); } else - MyOutputDebugString ("ERROR - picasso_refresh() can't refresh!\n"); + write_log ("ERROR - picasso_refresh() can't refresh!\n"); } /* @@ -518,15 +620,14 @@ static void picasso_refresh (void) */ uae_u32 picasso_FindCard (void) { - int loop; - uaecptr AmigaBoardInfo = m68k_areg(regs, 0); + uaecptr AmigaBoardInfo = m68k_areg (regs, 0); /* NOTES: See BoardInfo struct definition in Picasso96 dev info */ - if (gfxmem_size && !picasso96_state.CardFound) { + if (allocated_gfxmem && !picasso96_state.CardFound) { /* Fill in MemoryBase, MemorySize */ - put_long(AmigaBoardInfo + PSSO_BoardInfo_MemoryBase, gfxmem_start); + put_long (AmigaBoardInfo + PSSO_BoardInfo_MemoryBase, gfxmem_start); /* size of memory, minus a 32K chunk: 16K for pattern bitmaps, 16K for resolution list */ - put_long(AmigaBoardInfo + PSSO_BoardInfo_MemorySize, gfxmem_size - 32768); + put_long (AmigaBoardInfo + PSSO_BoardInfo_MemorySize, allocated_gfxmem - 32768); picasso96_state.CardFound = 1; /* mark our "card" as being found */ return -1; @@ -538,42 +639,66 @@ 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; } uaememptr = gfxmem_xlate(amigamemptr); /* I know that amigamemptr is inside my gfxmem chunk, so I can just do the xlate() */ memset(uaememptr, 0, PSSO_ModeInfo_sizeof); /* zero out our ModeInfo struct */ - put_word(amigamemptr + PSSO_ModeInfo_Width, dm->res.width); - put_word(amigamemptr + PSSO_ModeInfo_Height, dm->res.height); - put_byte(amigamemptr + PSSO_ModeInfo_Depth, dm->depth * 8); - put_byte(amigamemptr + PSSO_ModeInfo_Flags, 0); - put_word(amigamemptr + PSSO_ModeInfo_HorTotal, dm->res.width); - put_word(amigamemptr + PSSO_ModeInfo_HorBlankSize, 0); - put_word(amigamemptr + PSSO_ModeInfo_HorSyncStart, 0); - put_word(amigamemptr + PSSO_ModeInfo_HorSyncSize, 0); - put_byte(amigamemptr + PSSO_ModeInfo_HorSyncSkew, 0); - put_byte(amigamemptr + PSSO_ModeInfo_HorEnableSkew, 0); - - put_word(amigamemptr + PSSO_ModeInfo_VerTotal, dm->res.height); - put_word(amigamemptr + PSSO_ModeInfo_VerBlankSize, 0); - put_word(amigamemptr + PSSO_ModeInfo_VerSyncStart, 0); - put_word(amigamemptr + PSSO_ModeInfo_VerSyncSize, 0); - - put_byte(amigamemptr + PSSO_ModeInfo_first_union, 98); - put_byte(amigamemptr + PSSO_ModeInfo_second_union, 14); + put_word (amigamemptr + PSSO_ModeInfo_Width, dm->res.width); + put_word (amigamemptr + PSSO_ModeInfo_Height, dm->res.height); + put_byte (amigamemptr + PSSO_ModeInfo_Depth, dm->depth * 8); + put_byte (amigamemptr + PSSO_ModeInfo_Flags, 0); + put_word (amigamemptr + PSSO_ModeInfo_HorTotal, dm->res.width); + put_word (amigamemptr + PSSO_ModeInfo_HorBlankSize, 0); + put_word (amigamemptr + PSSO_ModeInfo_HorSyncStart, 0); + put_word (amigamemptr + PSSO_ModeInfo_HorSyncSize, 0); + put_byte (amigamemptr + PSSO_ModeInfo_HorSyncSkew, 0); + put_byte (amigamemptr + PSSO_ModeInfo_HorEnableSkew, 0); + + put_word (amigamemptr + PSSO_ModeInfo_VerTotal, dm->res.height); + put_word (amigamemptr + PSSO_ModeInfo_VerBlankSize, 0); + put_word (amigamemptr + PSSO_ModeInfo_VerSyncStart, 0); + put_word (amigamemptr + PSSO_ModeInfo_VerSyncSize, 0); + + put_byte (amigamemptr + PSSO_ModeInfo_first_union, 98); + put_byte (amigamemptr + PSSO_ModeInfo_second_union, 14); + + 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; - put_long(amigamemptr + PSSO_ModeInfo_PixelClock, dm->res.width * dm->res.height * dm->refresh); + return 0x50091000 + count * 0x10000; } /**************************************** @@ -598,25 +723,25 @@ uae_u32 picasso_InitCard (void) int i; int ModeInfoStructureCount = 1, LibResolutionStructureCount = 0; uaecptr amigamemptr = 0; - uaecptr AmigaBoardInfo = m68k_areg(regs, 2); - put_word(AmigaBoardInfo + PSSO_BoardInfo_BitsPerCannon, DX_BitsPerCannon()); - put_word(AmigaBoardInfo + PSSO_BoardInfo_RGBFormats, picasso96_pixel_format); - put_word(AmigaBoardInfo + PSSO_BoardInfo_SoftSpriteFlags, picasso96_pixel_format); - put_word(AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 0, planar.width); - put_word(AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 2, chunky.width); - put_word(AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 4, hicolour.width); - put_word(AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 6, truecolour.width); - put_word(AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 8, alphacolour.width); - put_word(AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 0, planar.height); - put_word(AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 2, chunky.height); - put_word(AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 4, hicolour.height); - put_word(AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 6, truecolour.height); - put_word(AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 8, alphacolour.height); + uaecptr AmigaBoardInfo = m68k_areg (regs, 2); + put_word (AmigaBoardInfo + PSSO_BoardInfo_BitsPerCannon, DX_BitsPerCannon()); + put_word (AmigaBoardInfo + PSSO_BoardInfo_RGBFormats, picasso96_pixel_format); + put_word (AmigaBoardInfo + PSSO_BoardInfo_SoftSpriteFlags, picasso96_pixel_format); + put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 0, planar.width); + put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 2, chunky.width); + put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 4, hicolour.width); + put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 6, truecolour.width); + put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 8, alphacolour.width); + put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 0, planar.height); + put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 2, chunky.height); + put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 4, hicolour.height); + put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 6, truecolour.height); + put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 8, alphacolour.height); 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; @@ -628,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; @@ -637,14 +762,14 @@ uae_u32 picasso_InitCard (void) do { /* Handle this display mode's depth */ - amigamemptr = gfxmem_start + gfxmem_size - (PSSO_ModeInfo_sizeof * ModeInfoStructureCount++); + amigamemptr = gfxmem_start + allocated_gfxmem - (PSSO_ModeInfo_sizeof * ModeInfoStructureCount++); FillBoardInfo(amigamemptr, &res, &DisplayModes[i]); i++; } while (i < mode_count && DisplayModes[i].res.width == DisplayModes[j].res.width && DisplayModes[i].res.height == DisplayModes[j].res.height); - amigamemptr = gfxmem_start + gfxmem_size - 16384 + (PSSO_LibResolution_sizeof * LibResolutionStructureCount++); + amigamemptr = gfxmem_start + allocated_gfxmem - 16384 + (PSSO_LibResolution_sizeof * LibResolutionStructureCount++); CopyLibResolutionStructureU2A (&res, amigamemptr); DumpLibResolutionStructure( amigamemptr); AmigaListAddTail (AmigaBoardInfo + PSSO_BoardInfo_ResolutionsList, amigamemptr); @@ -669,14 +794,13 @@ extern int x_size, y_size; */ uae_u32 picasso_SetSwitch (void) { - uae_u16 flag = m68k_dreg(regs, 0) & 0xFFFF; - uae_u32 result; + uae_u16 flag = m68k_dreg (regs, 0) & 0xFFFF; /* Do not switch immediately. Tell the custom chip emulation about the * desired state, and wait for custom.c to call picasso_enablescreen * whenever it is ready to change the screen state. */ picasso_requested_on = !!flag; - MyOutputDebugString ("SetSwitch() - trying to show %s screen\n", flag ? "picasso96":"amiga"); + write_log ("SetSwitch() - trying to show %s screen\n", flag ? "picasso96":"amiga"); /* Put old switch-state in D0 */ return !flag; @@ -686,7 +810,7 @@ void picasso_enablescreen (int on) { wgfx_linestart = 0xFFFFFFFF; picasso_refresh (); - MyOutputDebugString ("SetSwitch() - showing %s screen\n", on ? "picasso96":"amiga"); + write_log ("SetSwitch() - showing %s screen\n", on ? "picasso96": "amiga"); } /* @@ -705,50 +829,32 @@ uae_u32 picasso_SetColorArray (void) { /* Fill in some static UAE related structure about this new CLUT setting * We need this for CLUT-based displays, and for mapping CLUT to hi/true colour */ - uae_u16 start = m68k_dreg(regs, 0); - uae_u16 count = m68k_dreg(regs, 1); + uae_u16 start = m68k_dreg (regs, 0); + uae_u16 count = m68k_dreg (regs, 1); int i; - uaecptr boardinfo = m68k_areg(regs, 0); + uaecptr boardinfo = m68k_areg (regs, 0); uaecptr clut = boardinfo + PSSO_BoardInfo_CLUT + start * 3; + int changed = 0; for (i = start; i < start + count; i++) { - picasso96_state.CLUT[i].Red = get_byte (clut); - picasso96_state.CLUT[i].Green = get_byte (clut + 1); - picasso96_state.CLUT[i].Blue = get_byte (clut + 2); + int r = get_byte (clut); + int g = get_byte (clut + 1); + int b = get_byte (clut + 2); + + changed |= (picasso96_state.CLUT[i].Red != r + || picasso96_state.CLUT[i].Green != g + || picasso96_state.CLUT[i].Blue != b); + + picasso96_state.CLUT[i].Red = r; + picasso96_state.CLUT[i].Green = g; + picasso96_state.CLUT[i].Blue = b; clut += 3; } - DX_SetPalette(start, count); - /*MyOutputDebugString ("SetColorArray(%d,%d)\n", start, count); */ - return m68k_dreg(regs, 0); -} - -static uae_u8 GetBytesPerPixel(uae_u32 RGBfmt) -{ - switch (RGBfmt) { - case RGBFB_CLUT: - return 1; - - case RGBFB_A8R8G8B8: - case RGBFB_A8B8G8R8: - case RGBFB_R8G8B8A8: - case RGBFB_B8G8R8A8: - return 4; - - case RGBFB_B8G8R8: - case RGBFB_R8G8B8: - return 3; - - case RGBFB_R5G5B5: - case RGBFB_R5G6B5: - case RGBFB_R5G6B5PC: - case RGBFB_R5G5B5PC: - case RGBFB_B5G6R5PC: - case RGBFB_B5G5R5PC: - return 2; - default: - MyOutputDebugString ("ERROR - GetBytesPerPixel() was unsuccessful with 0x%x?!\n", RGBfmt); - return 0; + if (changed) { + DX_SetPalette (start, count); } + /*write_log ("SetColorArray(%d,%d)\n", start, count); */ + return 1; } /* @@ -764,8 +870,8 @@ uae_u32 picasso_SetDAC (void) /* Fill in some static UAE related structure about this new DAC setting * Lets us keep track of what pixel format the Amiga is thinking about in our frame-buffer */ - MyOutputDebugString ("SetDAC()\n"); - return m68k_dreg(regs, 0); + write_log ("SetDAC()\n"); + return 1; } /* @@ -782,7 +888,7 @@ uae_u32 picasso_SetDAC (void) uae_u32 picasso_SetGC (void) { /* Fill in some static UAE related structure about this new ModeInfo setting */ - uaecptr modeinfo = m68k_areg(regs, 1); + uaecptr modeinfo = m68k_areg (regs, 1); picasso96_state.Width = get_word (modeinfo + PSSO_ModeInfo_Width); picasso96_state.VirtualWidth = picasso96_state.Width; /* in case SetPanning doesn't get called */ @@ -793,14 +899,14 @@ uae_u32 picasso_SetGC (void) picasso96_state.GC_Depth = get_byte (modeinfo + PSSO_ModeInfo_Depth); picasso96_state.GC_Flags = get_byte (modeinfo + PSSO_ModeInfo_Flags); - MyOutputDebugString ("SetGC(%d,%d,%d)\n", picasso96_state.Width, picasso96_state.Height, picasso96_state.GC_Depth); + write_log ("SetGC(%d,%d,%d)\n", picasso96_state.Width, picasso96_state.Height, picasso96_state.GC_Depth); gfx_set_picasso_modeinfo (picasso96_state.Width, picasso96_state.Height, - picasso96_state.GC_Depth); + picasso96_state.GC_Depth, picasso96_state.RGBFormat); wgfx_linestart = 0xFFFFFFFF; picasso_refresh (); - return m68k_dreg(regs, 0); + return 1; } /* @@ -827,29 +933,31 @@ uae_u32 picasso_SetGC (void) */ uae_u32 picasso_SetPanning (void) { - uae_u16 Width = m68k_dreg(regs, 0); - uaecptr start_of_screen = m68k_areg(regs, 1); + uae_u16 Width = m68k_dreg (regs, 0); + uaecptr start_of_screen = m68k_areg (regs, 1); picasso96_state.Address = start_of_screen; /* Amiga-side address */ - picasso96_state.XOffset = (uae_s16)m68k_dreg(regs, 1); - picasso96_state.YOffset = (uae_s16)m68k_dreg(regs, 2); + picasso96_state.XOffset = (uae_s16)m68k_dreg (regs, 1); + picasso96_state.YOffset = (uae_s16)m68k_dreg (regs, 2); picasso96_state.VirtualWidth = Width; - picasso96_state.RGBFormat = m68k_dreg(regs, 7); - picasso96_state.BytesPerPixel = GetBytesPerPixel(picasso96_state.RGBFormat); + picasso96_state.RGBFormat = m68k_dreg (regs, 7); + picasso96_state.BytesPerPixel = GetBytesPerPixel (picasso96_state.RGBFormat); picasso96_state.BytesPerRow = Width * picasso96_state.BytesPerPixel; /* I assume SetGC() has been called, so I can calculate the Extent */ picasso96_state.Extent = picasso96_state.Address + (picasso96_state.BytesPerRow * picasso96_state.Height); - MyOutputDebugString ("SetPanning(%d, %d, %d) Start 0x%x, BPR %d\n", - Width,picasso96_state.XOffset, picasso96_state.YOffset, + write_log ("SetPanning(%d, %d, %d) Start 0x%x, BPR %d\n", + Width, picasso96_state.XOffset, picasso96_state.YOffset, start_of_screen, picasso96_state.BytesPerRow); - DX_SetPalette(0, 256); + gfx_set_picasso_modeinfo (picasso96_state.Width, picasso96_state.Height, + picasso96_state.GC_Depth, picasso96_state.RGBFormat); + DX_SetPalette (0, 256); wgfx_linestart = 0xFFFFFFFF; picasso_refresh (); - return m68k_dreg(regs, 0); + return 1; } static void do_xor8 (uae_u8 *ptr, long len, uae_u32 val) @@ -900,46 +1008,43 @@ static void do_xor8 (uae_u8 *ptr, long l */ uae_u32 picasso_InvertRect (void) { - uaecptr boardinfo = m68k_areg(regs, 0); - uaecptr renderinfo = m68k_areg(regs, 1); - long X = (uae_u16)m68k_dreg(regs, 0); - long Y = (uae_u16)m68k_dreg(regs, 1); - long Width = (uae_u16)m68k_dreg(regs, 2); - long Height = (uae_u16)m68k_dreg(regs, 3); - uae_u32 mask = m68k_dreg(regs, 4); - int Bpp = GetBytesPerPixel (m68k_dreg(regs, 7)); + uaecptr renderinfo = m68k_areg (regs, 1); + unsigned long X = (uae_u16)m68k_dreg (regs, 0); + unsigned long Y = (uae_u16)m68k_dreg (regs, 1); + unsigned long Width = (uae_u16)m68k_dreg (regs, 2); + unsigned long Height = (uae_u16)m68k_dreg (regs, 3); + uae_u32 mask = m68k_dreg (regs, 4); + int Bpp = GetBytesPerPixel (m68k_dreg (regs, 7)); uae_u32 xorval; - int lines; + unsigned int lines; struct RenderInfo ri; uae_u8 *uae_mem, *rectstart; - long width_in_bytes; + unsigned long width_in_bytes; wgfx_flushline (); - if (!CopyRenderInfoStructureA2U (renderinfo, &ri)) + if (! CopyRenderInfoStructureA2U (renderinfo, &ri)) return 0; - /*MyOutputDebugString ("InvertRect %d %lx\n", Bpp, (long)mask);*/ + /*write_log ("InvertRect %d %lx\n", Bpp, (long)mask);*/ /* ??? Brian? mask used to be 32 bit, but it appears that only 8 bit * values are passed to this function. This code here seems to work * much better... */ if (mask != 0xFF && Bpp > 8) { - MyOutputDebugString ("InvertRect: not obeying mask 0x%x properly with Bpp %d.\n", mask, Bpp); + write_log ("InvertRect: not obeying mask 0x%x properly with Bpp %d.\n", mask, Bpp); mask = 0xFF; } if ((mask & ~0xFF) != 0) { - MyOutputDebugString ("InvertRect: mask has high bits set!\n"); + write_log ("InvertRect: mask has high bits set!\n"); } xorval = 0x01010101 * (mask & 0xFF); width_in_bytes = Bpp * Width; rectstart = uae_mem = ri.Memory + Y*ri.BytesPerRow + X*Bpp; - for (lines = 0; lines < Height; lines++, uae_mem += ri.BytesPerRow) { - int j; - uae_u8 *start = uae_mem; + for (lines = 0; lines < Height; lines++, uae_mem += ri.BytesPerRow) do_xor8 (uae_mem, width_in_bytes, xorval); - } + if (renderinfo_is_current_screen (&ri)) { if (mask == 0xFF) do_invertrect (rectstart, ri.BytesPerRow, X, Y, Width, Height); @@ -965,34 +1070,32 @@ FillRect: ***********************************************************/ uae_u32 picasso_FillRect (void) { - uaecptr boardinfo = m68k_areg(regs, 0); - uaecptr renderinfo = m68k_areg(regs, 1); - unsigned long X = (uae_u16)m68k_dreg(regs, 0); - unsigned long Y = (uae_u16)m68k_dreg(regs, 1); - unsigned long Width = (uae_u16)m68k_dreg(regs, 2); - unsigned long Height = (uae_u16)m68k_dreg(regs, 3); - uae_u32 Pen = m68k_dreg(regs, 4); - uae_u8 Mask = (uae_u8)m68k_dreg(regs, 5); - uae_u32 RGBFormat = m68k_dreg(regs, 7); + uaecptr renderinfo = m68k_areg (regs, 1); + unsigned long X = (uae_u16)m68k_dreg (regs, 0); + unsigned long Y = (uae_u16)m68k_dreg (regs, 1); + unsigned long Width = (uae_u16)m68k_dreg (regs, 2); + unsigned long Height = (uae_u16)m68k_dreg (regs, 3); + uae_u32 Pen = m68k_dreg (regs, 4); + uae_u8 Mask = (uae_u8)m68k_dreg (regs, 5); + uae_u32 RGBFormat = m68k_dreg (regs, 7); uae_u8 *src, *dst; uae_u8 *start, *oldstart; - struct RenderInfo local_ri; unsigned long lines, cols; int Bpp; struct RenderInfo ri; wgfx_flushline (); - if (! CopyRenderInfoStructureA2U(renderinfo, &ri) || Y == 0xFFFF) + if (! CopyRenderInfoStructureA2U (renderinfo, &ri) || Y == 0xFFFF) return 0; if (ri.RGBFormat != RGBFormat) - MyOutputDebugString ("Weird Stuff!\n"); + write_log ("Weird Stuff!\n"); - Bpp = GetBytesPerPixel(RGBFormat); + Bpp = GetBytesPerPixel (RGBFormat); - /*MyOutputDebugString ("FillRect(%d, %d, %d, %d) Pen 0x%x BPP %d BPR %d Mask 0x%x\n", + /*write_log ("FillRect(%d, %d, %d, %d) Pen 0x%x BPP %d BPR %d Mask 0x%x\n", X, Y, Width, Height, Pen, Bpp, ri.BytesPerRow, Mask); */ if (Mask == 0xFF) { @@ -1028,11 +1131,11 @@ uae_u32 picasso_FillRect (void) dst = src + ri.BytesPerRow; /* next, we do the remaining line fills via memcpy() */ for (lines = 0; lines < (Height - 1); lines++, dst += ri.BytesPerRow) - memcpy(dst, src, Width * Bpp); + memcpy (dst, src, Width * Bpp); - if (renderinfo_is_current_screen (&ri)) { + if (renderinfo_is_current_screen (&ri)) do_fillrect (src, X, Y, Width, Height); - } + return 1; } @@ -1044,13 +1147,17 @@ uae_u32 picasso_FillRect (void) Pen &= Mask; Mask = ~Mask; - oldstart = start = ri.Memory + Y*ri.BytesPerRow + X*Bpp; - for (lines = 0; lines < Height; lines++, start += ri.BytesPerRow) { - uae_u8 *p = start; - for (cols = 0; cols < Width; cols++) { - uae_u32 tmpval = do_get_mem_byte (p) & Mask; - do_put_mem_byte (p, Pen | tmpval); - p++; + oldstart = ri.Memory + Y*ri.BytesPerRow + X*Bpp; + { + uae_u8 *start = oldstart; + uae_u8 *end = start + Height * ri.BytesPerRow; + for (; start != end; start += ri.BytesPerRow) { + uae_u8 *p = start; + unsigned long cols; + for (cols = 0; cols < Width; cols++) { + uae_u32 tmpval = do_get_mem_byte (p + cols) & Mask; + do_put_mem_byte (p + cols, Pen | tmpval); + } } } if (renderinfo_is_current_screen (&ri)) @@ -1064,11 +1171,11 @@ uae_u32 picasso_FillRect (void) * NOTE: If dstri is NULL, then we're only dealing with one RenderInfo area, and called from picasso_BlitRect() */ static void BlitRect (struct RenderInfo *ri, struct RenderInfo *dstri, - uae_u16 srcx, uae_u16 srcy, uae_u16 dstx, uae_u16 dsty, - uae_u16 width, uae_u16 height, uae_u8 mask) + unsigned long srcx, unsigned long srcy, unsigned long dstx, unsigned long dsty, + unsigned long width, unsigned long height, uae_u8 mask) { uae_u8 *src, *dst, *tmp, *tmp2, *tmp3; - int lines; + unsigned long lines; uae_u8 Bpp = GetBytesPerPixel(ri->RGBFormat); uae_u8 *blitsrc; unsigned long total_width = width * Bpp; @@ -1093,20 +1200,20 @@ static void BlitRect (struct RenderInfo dst = dstri->Memory + dstx*Bpp + dsty*dstri->BytesPerRow; blitsrc = dst; if (mask != 0xFF && Bpp > 1) - MyOutputDebugString ("ERROR - not obeying BlitRect() mask 0x%x properly with Bpp %d.\n", mask, Bpp); + write_log ("ERROR - not obeying BlitRect() mask 0x%x properly with Bpp %d.\n", mask, Bpp); if (mask == 0xFF || Bpp > 1) { /* handle normal case efficiently */ if (ri->Memory == dstri->Memory && dsty == srcy) { - int i; + unsigned long i; for (i = 0; i < height; i++, src += ri->BytesPerRow, dst += dstri->BytesPerRow) memmove (dst, src, total_width); } else if (dsty < srcy) { - int i; + unsigned long i; for (i = 0; i < height; i++, src += ri->BytesPerRow, dst += dstri->BytesPerRow) memcpy (dst, src, total_width); } else { - int i; + unsigned long i; src += (height-1) * ri->BytesPerRow; dst += (height-1) * dstri->BytesPerRow; for (i = 0; i < height; i++, src -= ri->BytesPerRow, dst -= dstri->BytesPerRow) @@ -1129,7 +1236,7 @@ static void BlitRect (struct RenderInfo /* copy the temporary buffer to the destination */ for (lines = 0; lines < height; lines++, dst += dstri->BytesPerRow, tmp += linewidth) { - int cols; + unsigned long cols; for (cols = 0; cols < width; cols++) { dst[cols] &= ~mask; dst[cols] |= tmp[cols] & mask; @@ -1159,26 +1266,24 @@ BlitRect: ***********************************************************/ uae_u32 picasso_BlitRect (void) { - uaecptr boardinfo = m68k_areg(regs, 0); - uaecptr renderinfo = m68k_areg(regs, 1); - uae_u16 srcx = (uae_u16)m68k_dreg(regs, 0); - uae_u16 srcy = (uae_u16)m68k_dreg(regs, 1); - uae_u16 dstx = (uae_u16)m68k_dreg(regs, 2); - uae_u16 dsty = (uae_u16)m68k_dreg(regs, 3); - uae_u16 width = (uae_u16)m68k_dreg(regs, 4); - uae_u16 height = (uae_u16)m68k_dreg(regs, 5); - uae_u8 Mask = (uae_u8)m68k_dreg(regs, 6); - uae_u32 RGBFormat = m68k_dreg(regs, 7); + uaecptr renderinfo = m68k_areg (regs, 1); + unsigned long srcx = (uae_u16)m68k_dreg (regs, 0); + unsigned long srcy = (uae_u16)m68k_dreg (regs, 1); + unsigned long dstx = (uae_u16)m68k_dreg (regs, 2); + unsigned long dsty = (uae_u16)m68k_dreg (regs, 3); + unsigned long width = (uae_u16)m68k_dreg (regs, 4); + unsigned long height = (uae_u16)m68k_dreg (regs, 5); + uae_u8 Mask = (uae_u8)m68k_dreg (regs, 6); struct RenderInfo ri; wgfx_flushline (); - if (!CopyRenderInfoStructureA2U (renderinfo, &ri)) + if (! CopyRenderInfoStructureA2U (renderinfo, &ri)) return 0; BlitRect(&ri, NULL, srcx, srcy, dstx, dsty, width, height, Mask); - /*MyOutputDebugString ("BlitRect(%d, %d, %d, %d, %d, %d, 0x%x)\n", srcx, srcy, dstx, dsty, width, height, Mask); */ + /*write_log ("BlitRect(%d, %d, %d, %d, %d, %d, 0x%x)\n", srcx, srcy, dstx, dsty, width, height, Mask); */ return 1; } @@ -1203,34 +1308,32 @@ BlitRectNoMaskComplete: ***********************************************************/ uae_u32 picasso_BlitRectNoMaskComplete (void) { - uaecptr boardinfo = m68k_areg(regs, 0); - uaecptr srcri = m68k_areg(regs, 1); - uaecptr dstri = m68k_areg(regs, 2); - uae_u16 srcx = m68k_dreg(regs, 0); - uae_u16 srcy = m68k_dreg(regs, 1); - uae_u16 dstx = m68k_dreg(regs, 2); - uae_u16 dsty = m68k_dreg(regs, 3); - uae_u16 width = m68k_dreg(regs, 4); - uae_u16 height = m68k_dreg(regs, 5); - uae_u8 OpCode = m68k_dreg(regs, 6); - uae_u32 RGBFmt = m68k_dreg(regs, 7); - - uae_u8 Bpp = GetBytesPerPixel(RGBFmt), *srcri_ptr = NULL, *dstri_ptr = NULL; + uaecptr srcri = m68k_areg (regs, 1); + uaecptr dstri = m68k_areg (regs, 2); + unsigned long srcx = (uae_u16)m68k_dreg (regs, 0); + unsigned long srcy = (uae_u16)m68k_dreg (regs, 1); + unsigned long dstx = (uae_u16)m68k_dreg (regs, 2); + unsigned long dsty = (uae_u16)m68k_dreg (regs, 3); + unsigned long width = (uae_u16)m68k_dreg (regs, 4); + unsigned long height = (uae_u16)m68k_dreg (regs, 5); + uae_u8 OpCode = m68k_dreg (regs, 6); + uae_u32 RGBFmt = m68k_dreg (regs, 7); struct RenderInfo src_ri, dst_ri; wgfx_flushline (); - if (!CopyRenderInfoStructureA2U(srcri, &src_ri) || !CopyRenderInfoStructureA2U(dstri, &dst_ri)) + if (! CopyRenderInfoStructureA2U (srcri, &src_ri) + || ! CopyRenderInfoStructureA2U (dstri, &dst_ri)) return 0; - /*MyOutputDebugString ("BlitRectNoMaskComplete() op 0x%2x, Bpp %d, xy(%4d,%4d) --> xy(%4d,%4d), wh(%4d,%4d)\n", + /*write_log ("BlitRectNoMaskComplete() op 0x%2x, Bpp %d, xy(%4d,%4d) --> xy(%4d,%4d), wh(%4d,%4d)\n", OpCode, Bpp, srcx, srcy, dstx, dsty, width, height); */ - /*MyOutputDebugString ("-- src mem 0x%x BPR %d, dst mem 0x%x BPR %d, screen-mem 0x%x - 0x%x\n", + /*write_log ("-- src mem 0x%x BPR %d, dst mem 0x%x BPR %d, screen-mem 0x%x - 0x%x\n", src_ri.Memory, src_ri.BytesPerRow, dst_ri.Memory, dst_ri.BytesPerRow, picasso96_state.Address, picasso96_state.Extent); */ switch (OpCode) { case 0x0C: - BlitRect(&src_ri, &dst_ri, srcx, srcy, dstx, dsty, width, height, 0xFF); + BlitRect (&src_ri, &dst_ri, srcx, srcy, dstx, dsty, width, height, 0xFF); return 1; default: @@ -1308,29 +1411,29 @@ static __inline__ void PixelWrite(uae_u8 */ uae_u32 picasso_BlitPattern (void) { - uaecptr boardinfo = m68k_areg(regs, 0); - uaecptr rinf = m68k_areg(regs, 1); - uaecptr pinf = m68k_areg(regs, 2); - long X = (uae_u16)m68k_dreg(regs, 0); - long Y = (uae_u16)m68k_dreg(regs, 1); - long W = (uae_u16)m68k_dreg(regs, 2); - long H = (uae_u16)m68k_dreg(regs, 3); - uae_u8 Mask = (uae_u8)m68k_dreg(regs, 4); - uae_u32 RGBFmt = m68k_dreg(regs, 7); + uaecptr rinf = m68k_areg (regs, 1); + uaecptr pinf = m68k_areg (regs, 2); + unsigned long X = (uae_u16)m68k_dreg (regs, 0); + unsigned long Y = (uae_u16)m68k_dreg (regs, 1); + unsigned long W = (uae_u16)m68k_dreg (regs, 2); + unsigned long H = (uae_u16)m68k_dreg (regs, 3); + 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; - uae_u16 rows; - uae_u32 fgpen, bgpen, value; + unsigned long rows; + uae_u32 fgpen; uae_u8 *uae_mem, *frame_buffer_UAM; - unsigned long ysize_mask; int xshift; + unsigned long ysize_mask; wgfx_flushline (); - if (!CopyRenderInfoStructureA2U(rinf, &ri) || !CopyPatternStructureA2U(pinf, &pattern)) + if (! CopyRenderInfoStructureA2U (rinf, &ri) + || ! CopyPatternStructureA2U (pinf, &pattern)) return 0; Bpp = GetBytesPerPixel(ri.RGBFormat); @@ -1342,15 +1445,15 @@ uae_u32 picasso_BlitPattern (void) pattern.DrawMode &= 0x03; if (Mask != 0xFF) { if (Bpp > 1) - MyOutputDebugString ("ERROR - not obeying BlitPattern() mask 0x%x properly with Bpp %d.\n", Mask, Bpp); + write_log ("ERROR - not obeying BlitPattern() mask 0x%x properly with Bpp %d.\n", Mask, Bpp); else if (pattern.DrawMode == COMP) { - MyOutputDebugString ("ERROR - Unsupported Mask value 0x%x with COMP Draw in BlitPattern(), using fallback method.\n", Mask); + write_log ("ERROR - Unsupported Mask value 0x%x with COMP Draw in BlitPattern(), using fallback method.\n", Mask); return 0; } } - /*MyOutputDebugString ("BlitPattern() xy(%d,%d), wh(%d,%d) draw 0x%x, off(%d,%d), ph %d\n", - X, Y, W, H, pattern.DrawMode, pattern.XOffset, pattern.YOffset, 1<> (16 - xshift)); @@ -1382,15 +1485,15 @@ uae_u32 picasso_BlitPattern (void) if (inversion) bit_set = !bit_set; if (bit_set) - PixelWrite(uae_mem2, bits, pattern.FgPen, Bpp, Mask); + PixelWrite (uae_mem2, bits, pattern.FgPen, Bpp, Mask); break; case JAM2: if (inversion) bit_set = !bit_set; if (bit_set) - PixelWrite(uae_mem2, bits, pattern.FgPen, Bpp, Mask); + PixelWrite (uae_mem2, bits, pattern.FgPen, Bpp, Mask); else - PixelWrite(uae_mem2, bits, pattern.BgPen, Bpp, Mask); + PixelWrite (uae_mem2, bits, pattern.BgPen, Bpp, Mask); break; case COMP: if (bit_set) { @@ -1458,25 +1561,25 @@ BlitTemplate: uae_u32 picasso_BlitTemplate (void) { uae_u8 inversion = 0; - uaecptr rinf = m68k_areg(regs, 1); - uaecptr tmpl = m68k_areg(regs, 2); - uae_u16 X = m68k_dreg(regs, 0); - uae_u16 Y = m68k_dreg(regs, 1); - uae_u16 W = m68k_dreg(regs, 2); - uae_u16 H = m68k_dreg(regs, 3); - uae_u16 Mask = m68k_dreg(regs, 4); - uae_u32 Fmt = m68k_dreg(regs, 7); + uaecptr rinf = m68k_areg (regs, 1); + uaecptr tmpl = m68k_areg (regs, 2); + unsigned long X = (uae_u16)m68k_dreg (regs, 0); + unsigned long Y = (uae_u16)m68k_dreg (regs, 1); + unsigned long W = (uae_u16)m68k_dreg (regs, 2); + unsigned long H = (uae_u16)m68k_dreg (regs, 3); + uae_u16 Mask = (uae_u16)m68k_dreg (regs, 4); struct Template tmp; struct RenderInfo ri; - long rows; + unsigned long rows; int bitoffset; - uae_u32 fgpen, bgpen, value; - uae_u8 *uae_mem, *uae_mem2, Bpp, *frame_buffer_UAM; + uae_u32 fgpen; + uae_u8 *uae_mem, Bpp, *frame_buffer_UAM; uae_u8 *tmpl_base; wgfx_flushline (); - if (!CopyRenderInfoStructureA2U(rinf, &ri) || !CopyTemplateStructureA2U(tmpl, &tmp)) + if (! CopyRenderInfoStructureA2U (rinf, &ri) + || ! CopyTemplateStructureA2U (tmpl, &tmp)) return 0; Bpp = GetBytesPerPixel(ri.RGBFormat); @@ -1488,14 +1591,14 @@ uae_u32 picasso_BlitTemplate (void) tmp.DrawMode &= 0x03; if (Mask != 0xFF) { if (Bpp > 1) - MyOutputDebugString ("ERROR - not obeying BlitTemplate() mask 0x%x properly with Bpp %d.\n", Mask, Bpp); + write_log ("ERROR - not obeying BlitTemplate() mask 0x%x properly with Bpp %d.\n", Mask, Bpp); else if (tmp.DrawMode == COMP) { - MyOutputDebugString ("ERROR - Unsupported Mask value 0x%x with COMP Draw in BlitTemplate(), using fallback method.\n", Mask); + write_log ("ERROR - Unsupported Mask value 0x%x with COMP Draw in BlitTemplate(), using fallback method.\n", Mask); return 0; } } - /*MyOutputDebugString ("BlitTemplate() xy(%d,%d), wh(%d,%d) draw 0x%x fg 0x%x bg 0x%x \n", + /*write_log ("BlitTemplate() xy(%d,%d), wh(%d,%d) draw 0x%x fg 0x%x bg 0x%x \n", X, Y, W, H, tmp.DrawMode, tmp.FgPen, tmp.BgPen); */ bitoffset = tmp.XOffset % 8; @@ -1507,7 +1610,7 @@ uae_u32 picasso_BlitTemplate (void) tmpl_base = tmp.Memory + tmp.XOffset/8; for (rows = 0; rows < H; rows++, uae_mem += ri.BytesPerRow, tmpl_base += tmp.BytesPerRow) { - long cols; + unsigned long cols; uae_u8 *tmpl_mem = tmpl_base; uae_u8 *uae_mem2 = uae_mem; unsigned int data = *tmpl_mem; @@ -1600,11 +1703,11 @@ uae_u32 picasso_BlitTemplate (void) */ uae_u32 picasso_CalculateBytesPerRow (void) { - uae_u16 width = m68k_dreg(regs, 0); - uae_u32 type = m68k_dreg(regs, 7); + uae_u16 width = m68k_dreg (regs, 0); + uae_u32 type = m68k_dreg (regs, 7); width = GetBytesPerPixel(type)*width; - /*MyOutputDebugString ("CalculateBytesPerRow() = %d\n",width); */ + /*write_log ("CalculateBytesPerRow() = %d\n",width); */ return width; } @@ -1619,8 +1722,8 @@ uae_u32 picasso_CalculateBytesPerRow (vo */ uae_u32 picasso_SetDisplay (void) { - uae_u32 state = m68k_dreg(regs, 0); - /*MyOutputDebugString ("SetDisplay(%d)\n", state);*/ + uae_u32 state = m68k_dreg (regs, 0); + write_log ("SetDisplay(%d)\n", state); return !state; } @@ -1631,24 +1734,27 @@ uae_u32 picasso_SetDisplay (void) */ uae_u32 picasso_WaitVerticalSync (void) { - /*MyOutputDebugString ("WaitVerticalSync()\n");*/ + /*write_log ("WaitVerticalSync()\n");*/ return 1; } /* NOTE: Watch for those planeptrs of 0x00000000 and 0xFFFFFFFF for all zero / all one bitmaps !!!! */ -static void PlanarToChunky(struct RenderInfo *ri, struct BitMap *bm, long srcx, long srcy, - long dstx, long dsty, long width, long height, uae_u8 mask) +static void PlanarToChunky(struct RenderInfo *ri, struct BitMap *bm, + unsigned long srcx, unsigned long srcy, + unsigned long dstx, unsigned long dsty, + unsigned long width, unsigned long height, + uae_u8 mask) { - int j, bits; + int j; uae_u8 *PLANAR[8], *image = ri->Memory + dstx * GetBytesPerPixel (ri->RGBFormat) + dsty*ri->BytesPerRow; int Depth = bm->Depth; - uae_u16 rows, total_bits, value, bitoffset = srcx & 7; + unsigned long rows, bitoffset = srcx & 7; long eol_offset; /* if (mask != 0xFF) - MyOutputDebugString ("P2C - pixel-width = %d, bit-offset = %d\n", width, bitoffset); */ - + write_log ("P2C - pixel-width = %d, bit-offset = %d\n", width, bitoffset); */ + /* Set up our bm->Planes[] pointers to the right horizontal offset */ for (j = 0; j < Depth; j++) { uae_u8 *p = bm->Planes[j]; @@ -1658,9 +1764,9 @@ static void PlanarToChunky(struct Render if ((mask & (1 << j)) == 0) PLANAR[j] = &all_zeros_bitmap; } - eol_offset = (long)bm->BytesPerRow - ((width + 7) >> 3); + eol_offset = (long)bm->BytesPerRow - (long)((width + 7) >> 3); for (rows = 0; rows < height; rows++, image += ri->BytesPerRow) { - long cols; + unsigned long cols; for (cols = 0; cols < width; cols += 8) { int k; @@ -1722,48 +1828,47 @@ static void PlanarToChunky(struct Render */ uae_u32 picasso_BlitPlanar2Chunky (void) { - uaecptr bi = m68k_areg(regs, 0); - uaecptr bm = m68k_areg(regs, 1); - uaecptr ri = m68k_areg(regs, 2); - uae_u16 srcx = m68k_dreg(regs, 0) & 0xFFFF; - uae_u16 srcy = m68k_dreg(regs, 1) & 0xFFFF; - uae_u16 dstx = m68k_dreg(regs, 2) & 0xFFFF; - uae_u16 dsty = m68k_dreg(regs, 3) & 0xFFFF; - uae_u16 width = m68k_dreg(regs, 4) & 0xFFFF; - uae_u16 height = m68k_dreg(regs, 5) & 0xFFFF; - uae_u8 minterm = m68k_dreg(regs, 6) & 0xFF; - uae_u8 mask = m68k_dreg(regs, 7) & 0xFF; - int i; + uaecptr bm = m68k_areg (regs, 1); + uaecptr ri = m68k_areg (regs, 2); + unsigned long srcx = (uae_u16)m68k_dreg (regs, 0); + unsigned long srcy = (uae_u16)m68k_dreg (regs, 1); + unsigned long dstx = (uae_u16)m68k_dreg (regs, 2); + unsigned long dsty = (uae_u16)m68k_dreg (regs, 3); + unsigned long width = (uae_u16)m68k_dreg (regs, 4); + unsigned long height = (uae_u16)m68k_dreg (regs, 5); + uae_u8 minterm = m68k_dreg (regs, 6) & 0xFF; + uae_u8 mask = m68k_dreg (regs, 7) & 0xFF; struct RenderInfo local_ri; - uae_u8 *uaebm = NULL; struct BitMap local_bm; wgfx_flushline (); if (minterm != 0x0C) { - MyOutputDebugString ("ERROR - BlitPlanar2Chunky() has minterm 0x%x, which I don't handle. Using fall-back routine.\n", - minterm); + write_log ("ERROR - BlitPlanar2Chunky() has minterm 0x%x, which I don't handle. Using fall-back routine.\n", + minterm); return 0; } - if (!CopyRenderInfoStructureA2U(ri, &local_ri) || !CopyBitMapStructureA2U(bm, &local_bm)) + if (! CopyRenderInfoStructureA2U (ri, &local_ri) + || ! CopyBitMapStructureA2U (bm, &local_bm)) return 0; - /*MyOutputDebugString ("BlitPlanar2Chunky(%d, %d, %d, %d, %d, %d) Minterm 0x%x, Mask 0x%x, Depth %d\n", + /*write_log ("BlitPlanar2Chunky(%d, %d, %d, %d, %d, %d) Minterm 0x%x, Mask 0x%x, Depth %d\n", srcx, srcy, dstx, dsty, width, height, minterm, mask, local_bm.Depth); - MyOutputDebugString ("P2C - BitMap has %d BPR, %d rows\n", local_bm.BytesPerRow, local_bm.Rows); */ - PlanarToChunky(&local_ri, &local_bm, srcx, srcy, dstx, dsty, width, height, mask); + write_log ("P2C - BitMap has %d BPR, %d rows\n", local_bm.BytesPerRow, local_bm.Rows); */ + PlanarToChunky (&local_ri, &local_bm, srcx, srcy, dstx, dsty, width, height, mask); if (renderinfo_is_current_screen (&local_ri)) do_blit (local_ri.Memory + dstx * GetBytesPerPixel (local_ri.RGBFormat) + dsty * local_ri.BytesPerRow, 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 !!!! */ static void PlanarToDirect(struct RenderInfo *ri, struct BitMap *bm, - long srcx, long srcy, long dstx, long dsty, - long width, long height, uae_u8 mask, + unsigned long srcx, unsigned long srcy, + unsigned long dstx, unsigned long dsty, + unsigned long width, unsigned long height, uae_u8 mask, struct ColorIndexMapping *cim) { int j; @@ -1771,7 +1876,7 @@ static void PlanarToDirect(struct Render uae_u8 *PLANAR[8]; uae_u8 *image = ri->Memory + dstx * bpp + dsty * ri->BytesPerRow; int Depth = bm->Depth; - long rows; + unsigned long rows; long eol_offset; /* Set up our bm->Planes[] pointers to the right horizontal offset */ @@ -1784,9 +1889,9 @@ static void PlanarToDirect(struct Render PLANAR[j] = &all_zeros_bitmap; } - eol_offset = (long)bm->BytesPerRow - ((width + (srcx & 7)) >> 3); + eol_offset = (long)bm->BytesPerRow - (long)((width + (srcx & 7)) >> 3); for (rows = 0; rows < height; rows++, image += ri->BytesPerRow) { - long cols; + unsigned long cols; uae_u8 *image2 = image; unsigned int bitoffs = 7 - (srcx & 7); int i; @@ -1865,41 +1970,40 @@ static void PlanarToDirect(struct Render */ uae_u32 picasso_BlitPlanar2Direct (void) { - uaecptr bi = m68k_areg(regs, 0); - uaecptr bm = m68k_areg(regs, 1); - uaecptr ri = m68k_areg(regs, 2); - uaecptr cim = m68k_areg(regs, 3); - uae_u16 srcx = m68k_dreg(regs, 0); - uae_u16 srcy = m68k_dreg(regs, 1); - uae_u16 dstx = m68k_dreg(regs, 2); - uae_u16 dsty = m68k_dreg(regs, 3); - uae_u16 width = m68k_dreg(regs, 4); - uae_u16 height = m68k_dreg(regs, 5); - uae_u8 minterm = m68k_dreg(regs, 6); - uae_u8 Mask = m68k_dreg(regs, 7); + uaecptr bm = m68k_areg (regs, 1); + uaecptr ri = m68k_areg (regs, 2); + uaecptr cim = m68k_areg (regs, 3); + unsigned long srcx = (uae_u16)m68k_dreg (regs, 0); + unsigned long srcy = (uae_u16)m68k_dreg (regs, 1); + unsigned long dstx = (uae_u16)m68k_dreg (regs, 2); + unsigned long dsty = (uae_u16)m68k_dreg (regs, 3); + unsigned long width = (uae_u16)m68k_dreg (regs, 4); + unsigned long height = (uae_u16)m68k_dreg (regs, 5); + uae_u8 minterm = m68k_dreg (regs, 6); + uae_u8 Mask = m68k_dreg (regs, 7); struct RenderInfo local_ri; - uae_u8 *uaebm = NULL; struct BitMap local_bm; struct ColorIndexMapping local_cim; wgfx_flushline (); if (minterm != 0x0C) { - MyOutputDebugString ("ERROR - BlitPlanar2Direct() has op-code 0x%x, which I don't handle. Using fall-back routine.\n", - minterm); + write_log ("ERROR - BlitPlanar2Direct() has op-code 0x%x, which I don't handle. Using fall-back routine.\n", + minterm); return 0; } if (Mask != 0xFF) { - MyOutputDebugString ("ERROR - Unsupported Mask value 0x%x in BlitPlanar2Direct(), using fallback method.\n", Mask); + write_log ("ERROR - Unsupported Mask value 0x%x in BlitPlanar2Direct(), using fallback method.\n", Mask); return 0; } - if (!CopyRenderInfoStructureA2U (ri, &local_ri) || !CopyBitMapStructureA2U (bm, &local_bm)) + if (! CopyRenderInfoStructureA2U (ri, &local_ri) + || ! CopyBitMapStructureA2U (bm, &local_bm)) return 0; CopyColorIndexMappingA2U (cim, &local_cim); - /* MyOutputDebugString ("BlitPlanar2Direct(%d, %d, %d, %d, %d, %d) Minterm 0x%x, Mask 0x%x, Depth %d\n", - srcx, srcy, dstx, dsty, width, height, minterm, Mask, local_bm.Depth); */ - PlanarToDirect(&local_ri, &local_bm, srcx, srcy, dstx, dsty, width, height, Mask, &local_cim); + /* write_log ("BlitPlanar2Direct(%d, %d, %d, %d, %d, %d) Minterm 0x%x, Mask 0x%x, Depth %d\n", + srcx, srcy, dstx, dsty, width, height, minterm, Mask, local_bm.Depth); */ + PlanarToDirect (&local_ri, &local_bm, srcx, srcy, dstx, dsty, width, height, Mask, &local_cim); if (renderinfo_is_current_screen (&local_ri)) do_blit (local_ri.Memory + dstx * GetBytesPerPixel (local_ri.RGBFormat) + dsty * local_ri.BytesPerRow, local_ri.BytesPerRow, @@ -1955,10 +2059,10 @@ static void write_gfx_long (uaecptr addr x = xbytes / picasso96_state.BytesPerPixel; if (x < picasso96_state.Width && y < picasso96_state.Height) { - dst = lockscr(); + dst = gfx_lock_picasso (); if (dst) { do_put_mem_long ((uae_u32 *)(dst + y * picasso_vidinfo.rowbytes + xbytes), value); - unlockscr(); + gfx_unlock_picasso (); } } #else @@ -2011,10 +2115,10 @@ static void write_gfx_word (uaecptr addr x = xbytes / picasso96_state.BytesPerPixel; if (x < picasso96_state.Width && y < picasso96_state.Height) { - dst = lockscr(); + dst = gfx_lock_picasso (); if (dst) { do_put_mem_word ((uae_u16 *)(dst + y * picasso_vidinfo.rowbytes + xbytes), value); - unlockscr(); + gfx_unlock_picasso (); } } #else @@ -2067,10 +2171,10 @@ static void write_gfx_byte (uaecptr addr x = xbytes / picasso96_state.BytesPerPixel; if (x < picasso96_state.Width && y < picasso96_state.Height) { - dst = lockscr(); + dst = gfx_lock_picasso (); if (dst) { *(uae_u8 *)(dst + y * picasso_vidinfo.rowbytes + xbytes) = value; - unlockscr(); + gfx_unlock_picasso (); } } #else @@ -2147,7 +2251,7 @@ static int REGPARAM2 gfxmem_check (uaecp { addr -= gfxmem_start & gfxmem_mask; addr &= gfxmem_mask; - return (addr + size) < gfxmem_size; + return (addr + size) < allocated_gfxmem; } static uae_u8 REGPARAM2 *gfxmem_xlate (uaecptr addr) @@ -2184,6 +2288,8 @@ void InitPicasso96 (void) { static int first_time = 1; + memset (&picasso96_state, 0, sizeof(struct picasso96_state_struct)); + if (first_time) { int i; @@ -2197,15 +2303,6 @@ void InitPicasso96 (void) | ((i & 2) ? 0x0100 : 0) | ((i & 1) ? 0x01 : 0)); } -#if 0 - /* If we have some gfxmem settings, then we want Picasso96 support */ - if (gfxmem_size > 0) { - gfxmem_mask = gfxmem_size - 1; - gfxmemory = (uae_u8 *)xmalloc (gfxmem_size); - map_banks(&gfxmem_bank, 0x800, gfxmem_size >> 16); - } -#endif - memset(&picasso96_state, 0, sizeof(struct picasso96_state_struct)); mode_count = DX_FillResolutions (&picasso96_pixel_format); qsort (DisplayModes, mode_count, sizeof (struct PicassoResolution), resolution_compare); @@ -2241,14 +2338,10 @@ void InitPicasso96 (void) break; } } - ShowSupportedResolutions(); + ShowSupportedResolutions (); first_time = 0; } - - if (gfxmem_size > 0) { - memset(&picasso96_state, 0, sizeof(struct picasso96_state_struct)); - } } #endif