Implemented fix from Main (#34)

This commit is contained in:
Dimitris Panokostas 2017-01-21 17:26:51 +01:00
parent 03c6ffd4c2
commit 5deaae7bc2
3 changed files with 6161 additions and 6115 deletions

View file

@ -2434,41 +2434,42 @@ static void init_hz (bool fullinit)
{
int isntsc;
int omaxvpos = maxvpos;
int hzc = 0;
int hzc = 0;
if (fullinit)
vpos_count = 0;
vpos_count_diff = vpos_count;
if ((beamcon0 & 0xA0) != (new_beamcon0 & 0xA0))
hzc = 1;
if (beamcon0 != new_beamcon0) {
if ((beamcon0 & 0xA0) != (new_beamcon0 & 0xA0))
hzc = 1;
if (beamcon0 != new_beamcon0) {
vpos_count_diff = vpos_count = 0;
}
}
beamcon0 = new_beamcon0;
isntsc = (beamcon0 & 0x20) ? 0 : 1;
if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
isntsc = currprefs.ntscmode ? 1 : 0;
if (!isntsc) {
maxvpos = MAXVPOS_PAL;
maxhpos = MAXHPOS_PAL;
minfirstline = VBLANK_ENDLINE_PAL;
vblank_hz = VBLANK_HZ_PAL;
sprite_vblank_endline = VBLANK_SPRITE_PAL;
if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
isntsc = currprefs.ntscmode ? 1 : 0;
if (!isntsc) {
maxvpos = MAXVPOS_PAL;
maxhpos = MAXHPOS_PAL;
minfirstline = VBLANK_ENDLINE_PAL;
vblank_hz = VBLANK_HZ_PAL;
sprite_vblank_endline = VBLANK_SPRITE_PAL;
equ_vblank_endline = EQU_ENDLINE_PAL;
equ_vblank_toggle = true;
} else {
maxvpos = MAXVPOS_NTSC;
maxhpos = MAXHPOS_NTSC;
minfirstline = VBLANK_ENDLINE_NTSC;
vblank_hz = VBLANK_HZ_NTSC;
sprite_vblank_endline = VBLANK_SPRITE_NTSC;
}
else {
maxvpos = MAXVPOS_NTSC;
maxhpos = MAXHPOS_NTSC;
minfirstline = VBLANK_ENDLINE_NTSC;
vblank_hz = VBLANK_HZ_NTSC;
sprite_vblank_endline = VBLANK_SPRITE_NTSC;
equ_vblank_endline = EQU_ENDLINE_NTSC;
equ_vblank_toggle = false;
}
// long/short field refresh rate adjustment
vblank_hz = vblank_hz * (maxvpos * 2 + 1) / ((maxvpos + lof_current) * 2);
}
// long/short field refresh rate adjustment
// vblank_hz = vblank_hz * (maxvpos * 2 + 1) / ((maxvpos + lof_current) * 2);
maxvpos_nom = maxvpos;
maxvpos_display = maxvpos;
@ -2477,53 +2478,64 @@ static void init_hz (bool fullinit)
// (someone poked VPOSW)
if (vpos_count < 10)
vpos_count = 10;
float new_hz = (isntsc ? 15734.0 : 15625.0) / (float)vpos_count;
vblank_hz = (int)(new_hz + 0.5);
vblank_hz = (isntsc ? 15734.0 : 15625.0) / vpos_count;
maxvpos_nom = vpos_count - (lof_current ? 1 : 0);
if ((maxvpos_nom >= 256 && maxvpos_nom <= 313) || (beamcon0 & 0x80)) {
maxvpos_display = maxvpos_nom;
} else if (maxvpos_nom < 256) {
}
else if (maxvpos_nom < 256) {
maxvpos_display = 255;
} else {
}
else {
maxvpos_display = 313;
}
reset_drawing ();
} else if (vpos_count == 0) {
reset_drawing();
}
else if (vpos_count == 0) {
// mode reset
vpos_count = maxvpos;
vpos_count_diff = maxvpos;
}
if (beamcon0 & 0x80) {
// programmable scanrates (ECS Agnus)
if (vtotal >= MAXVPOS)
vtotal = MAXVPOS - 1;
maxvpos = vtotal + 1;
if (htotal >= MAXHPOS)
htotal = MAXHPOS - 1;
maxhpos = htotal + 1;
float new_hz = 227.0 * 312.0 * 50.0 / (float)(maxvpos * maxhpos);
vblank_hz = (int)(new_hz + 0.5);
minfirstline = vsstop > vbstop ? vsstop : vbstop;
if (minfirstline > maxvpos / 2)
minfirstline = vsstop > vbstop ? vbstop : vsstop;
if (minfirstline < 2)
minfirstline = 2;
if (minfirstline >= maxvpos)
minfirstline = maxvpos - 1;
sprite_vblank_endline = minfirstline - 2;
if (beamcon0 & 0x80) {
// programmable scanrates (ECS Agnus)
if (vtotal >= MAXVPOS)
vtotal = MAXVPOS - 1;
maxvpos = vtotal + 1;
if (htotal >= MAXHPOS)
htotal = MAXHPOS - 1;
maxhpos = htotal + 1;
vblank_hz = 227.0 * 312.0 * 50.0 / (maxvpos * maxhpos);
if ((beamcon0 & 0x1000) && (beamcon0 & 0x0200)) { // VARVBEN + VARVSYEN
minfirstline = vsstop > vbstop ? vsstop : vbstop;
if (minfirstline > maxvpos / 2)
minfirstline = vsstop > vbstop ? vbstop : vsstop;
}
else if (beamcon0 & 0x0200) {
minfirstline = vsstop;
if (minfirstline > maxvpos / 2)
minfirstline = 0;
}
else if (beamcon0 & 0x1000) {
minfirstline = vbstop;
if (minfirstline > maxvpos / 2)
minfirstline = 0;
}
if (minfirstline < 2)
minfirstline = 2;
if (minfirstline >= maxvpos)
minfirstline = maxvpos - 1;
sprite_vblank_endline = minfirstline - 2;
maxvpos_nom = maxvpos;
maxvpos_display = maxvpos;
equ_vblank_endline = -1;
vpos_count = maxvpos_nom;
vpos_count_diff = maxvpos_nom;
hzc = 1;
#ifdef WITH_INGAME_WARNING
char _info[64];
sprintf(_info, "Programmend HZ: %d", vblank_hz);
InGameMessage(_info);
#endif
}
hzc = 1;
}
if (maxvpos_nom >= MAXVPOS)
maxvpos_nom = MAXVPOS;
if (maxvpos_display >= MAXVPOS)
@ -2531,26 +2543,26 @@ static void init_hz (bool fullinit)
if (maxvpos != omaxvpos)
hzc = 1;
/* limit to sane values */
if (vblank_hz < 10)
vblank_hz = 10;
if (vblank_hz > 300)
vblank_hz = 300;
eventtab[ev_hsync].oldcycles = get_cycles ();
eventtab[ev_hsync].evtime = get_cycles() + HSYNCTIME;
events_schedule ();
if (hzc) {
reset_drawing ();
}
if (vblank_hz < 10)
vblank_hz = 10;
if (vblank_hz > 300)
vblank_hz = 300;
eventtab[ev_hsync].oldcycles = get_cycles();
eventtab[ev_hsync].evtime = get_cycles() + HSYNCTIME;
events_schedule();
if (hzc) {
reset_drawing();
}
maxvpos_total = (currprefs.chipset_mask & CSMASK_ECS_AGNUS) ? (MAXVPOS_LINES_ECS - 1) : (MAXVPOS_LINES_OCS - 1);
if (maxvpos_total > MAXVPOS)
maxvpos_total = MAXVPOS;
compute_framesync ();
compute_framesync();
#ifdef PICASSO96
init_hz_p96 ();
init_hz_p96();
#endif
inputdevice_tablet_strobe ();
inputdevice_tablet_strobe();
if (fullinit)
vpos_count_diff = maxvpos_nom;
@ -4533,7 +4545,7 @@ static void vsync_handler_pre (void)
// emulated hardware vsync
static void vsync_handler_post (void)
{
DISK_vsync ();
DISK_vsync();
if (bplcon0 & 4) {
lof_store = lof_store ? 0 : 1;
@ -4557,37 +4569,47 @@ static void vsync_handler_post (void)
lof_changed = 0;
}
lof_changing = 0;
} else {
}
else {
lof_changed_previous_field = 0;
lof_lace = false;
}
#ifdef JIT
if (currprefs.cachesize) {
vsyncmintime = last_synctime;
frh_count = 0;
}
else
if (currprefs.cachesize) {
vsyncmintime = last_synctime;
frh_count = 0;
}
else
#endif
{
vsyncmintime = last_synctime + vsynctimebase * (maxvpos_display - LAST_SPEEDUP_LINE) / maxvpos_display;
}
{
vsyncmintime = last_synctime + vsynctimebase * (maxvpos_display - LAST_SPEEDUP_LINE) / maxvpos_display;
}
#ifdef PICASSO96
if (picasso_on)
{
vpos_count = (int) maxvpos * vblank_hz / 60;
vtotal = vpos_count;
}
#endif
if ((beamcon0 & (0x20 | 0x80)) != (new_beamcon0 & (0x20 | 0x80))) {
init_hz ();
} else if (vpos_count > 0 && abs (vpos_count - vpos_count_diff) > 1 && vposw_change < 4) {
init_hz ();
} else if (lof_changed) {
compute_framesync ();
}
init_hz();
}
else if (vpos_count > 0 && abs(vpos_count - vpos_count_diff) > 1 && vposw_change < 4) {
init_hz();
}
else if (lof_changed) {
compute_framesync();
}
lof_changed = 0;
vposw_change = 0;
eventtab[ev_copper].active = 0;
COPJMP (1, 1);
eventtab[ev_copper].active = 0;
COPJMP(1, 1);
init_hardware_frame ();
init_hardware_frame();
}
#ifdef JIT

View file

@ -438,20 +438,41 @@ extern void gui_message (const TCHAR *,...);
* Byte-swapping functions
*/
#ifdef ARMV6_ASSEMBLY
STATIC_INLINE uae_u32 do_byteswap_32(uae_u32 v) {__asm__ (
/* Try to use system bswap_16/bswap_32 functions. */
#if defined HAVE_BSWAP_16 && defined HAVE_BSWAP_32
# include <byteswap.h>
# ifdef HAVE_BYTESWAP_H
# include <byteswap.h>
# endif
#else
# ifdef ARMV6_ASSEMBLY
STATIC_INLINE uae_u32 do_byteswap_32(uae_u32 v) {
__asm__(
"rev %0, %0"
: "=r" (v) : "0" (v) ); return v;}
: "=r" (v) : "0" (v)); return v;
}
STATIC_INLINE uae_u32 do_byteswap_16(uae_u32 v) {__asm__ (
STATIC_INLINE uae_u32 do_byteswap_16(uae_u32 v) {
__asm__(
"revsh %0, %0\n\t"
"uxth %0, %0"
: "=r" (v) : "0" (v) ); return v;}
#endif
: "=r" (v) : "0" (v)); return v;
}
#define bswap_16(x) do_byteswap_16(x)
#define bswap_32(x) do_byteswap_32(x)
# else
/* Else, if using SDL, try SDL's endian functions. */
# ifdef USE_SDL
# include <SDL_endian.h>
# define bswap_16(x) SDL_Swap16(x)
# define bswap_32(x) SDL_Swap32(x)
# else
/* Otherwise, we'll roll our own. */
#define bswap_16(x) (((x) >> 8) | (((x) & 0xFF) << 8))
#define bswap_32(x) (((x) << 24) | (((x) << 8) & 0x00FF0000) | (((x) >> 8) & 0x0000FF00) | ((x) >> 24))
# endif
#endif
#endif
#endif

View file

@ -94,9 +94,9 @@ static struct PicassoResolution *newmodes = NULL;
static int picasso_convert, host_mode;
/* These are the maximum resolutions... They are filled in by GetSupportedResolutions() */
/* have to fill this in, otherwise problems occur on the Amiga side P96 s/w which expects
/* data here. */
/* These are the maximum resolutions... They are filled in by GetSupportedResolutions()
have to fill this in, otherwise problems occur on the Amiga side P96 s/w which expects
data here. */
static struct ScreenResolution planar = { 320, 240 };
static struct ScreenResolution chunky = { 640, 480 };
static struct ScreenResolution hicolour = { 640, 480 };
@ -1973,64 +1973,67 @@ FillRect:
* d5: UBYTE Mask
* d7: uae_u32 RGBFormat
***********************************************************/
__attribute__((optimize("O2"))) static uae_u32 REGPARAM2 picasso_FillRect (TrapContext *ctx)
//__attribute__((optimize("O2"))) is needed otherwise this crashes with O3!
__attribute__((optimize("O2"))) static uae_u32 REGPARAM2 picasso_FillRect(TrapContext *ctx)
{
uaecptr renderinfo = m68k_areg (regs, 1);
uae_u32 X = (uae_u16)m68k_dreg (regs, 0);
uae_u32 Y = (uae_u16)m68k_dreg (regs, 1);
uae_u32 Width = (uae_u16)m68k_dreg (regs, 2);
uae_u32 Height = (uae_u16)m68k_dreg (regs, 3);
uae_u32 Pen = m68k_dreg (regs, 4);
uae_u8 Mask = (uae_u8)m68k_dreg (regs, 5);
RGBFTYPE RGBFormat = (RGBFTYPE) m68k_dreg (regs, 7);
uae_u8 *oldstart;
int Bpp;
struct RenderInfo ri;
uae_u32 result = 0;
uaecptr renderinfo = m68k_areg(regs, 1);
uae_u32 X = (uae_u16)m68k_dreg(regs, 0);
uae_u32 Y = (uae_u16)m68k_dreg(regs, 1);
uae_u32 Width = (uae_u16)m68k_dreg(regs, 2);
uae_u32 Height = (uae_u16)m68k_dreg(regs, 3);
uae_u32 Pen = m68k_dreg(regs, 4);
uae_u8 Mask = (uae_u8)m68k_dreg(regs, 5);
RGBFTYPE RGBFormat = (RGBFTYPE) m68k_dreg(regs, 7);
uae_u8 *oldstart;
int Bpp;
struct RenderInfo ri;
uae_u32 result = 0;
if (NOBLITTER)
return 0;
if (CopyRenderInfoStructureA2U (renderinfo, &ri) && Y != 0xFFFF) {
Bpp = GetBytesPerPixel (RGBFormat);
if (NOBLITTER)
return 0;
if (CopyRenderInfoStructureA2U(renderinfo, &ri) && Y != 0xFFFF) {
Bpp = GetBytesPerPixel(RGBFormat);
P96TRACE((_T("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 (Bpp > 1)
Mask = 0xFF;
if (Bpp > 1)
Mask = 0xFF;
if (Mask == 0xFF) {
if (Mask == 0xFF) {
/* Do the fill-rect in the frame-buffer */
do_fillrect_frame_buffer (&ri, X, Y, Width, Height, Pen, Bpp);
result = 1;
/* Do the fill-rect in the frame-buffer */
do_fillrect_frame_buffer(&ri, X, Y, Width, Height, Pen, Bpp);
result = 1;
} else {
}
else {
/* We get here only if Mask != 0xFF */
if (Bpp != 1) {
write_log (_T("WARNING - FillRect() has unhandled mask 0x%x with Bpp %d. Using fall-back routine.\n"), Mask, Bpp);
} else {
Pen &= Mask;
Mask = ~Mask;
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, (uae_u8)(Pen | tmpval));
}
}
}
result = 1;
}
}
}
return result;
/* We get here only if Mask != 0xFF */
if (Bpp != 1) {
write_log(_T("WARNING - FillRect() has unhandled mask 0x%x with Bpp %d. Using fall-back routine.\n"), Mask, Bpp);
}
else {
Pen &= Mask;
Mask = ~Mask;
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, (uae_u8)(Pen | tmpval));
}
}
}
result = 1;
}
}
}
return result;
}
/*