From a20c596b9c8da408f725a66ebf43a6fcaf95cab2 Mon Sep 17 00:00:00 2001 From: Wei-ju Wu Date: Wed, 27 Jan 2016 21:01:15 -0800 Subject: [PATCH] sprite fix added for Kickstart >= 3.0 --- hardware/.gitignore | 1 + hardware/startup.c | 58 +++++++++++++++++++++++++++++++++++++-------- 2 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 hardware/.gitignore diff --git a/hardware/.gitignore b/hardware/.gitignore new file mode 100644 index 0000000..efcfc5a --- /dev/null +++ b/hardware/.gitignore @@ -0,0 +1 @@ +startup diff --git a/hardware/startup.c b/hardware/startup.c index b1e74d8..b123cab 100644 --- a/hardware/startup.c +++ b/hardware/startup.c @@ -6,6 +6,7 @@ #include #include #include +#include #include /* @@ -27,6 +28,7 @@ void waitmouse() = "waitmouse:\n\tbtst\t#6,$bfe001\n\tbne\twaitmouse"; #define EXEC_BASE (4L) #define TASK_PRIORITY 127 #define VFREQ_PAL 50 +#define WB_SCREEN_NAME "Workbench" static UWORD __chip coplist_pal[] = { 0x100, 0x200, // otherwise no display! @@ -50,6 +52,39 @@ static UWORD __chip coplist_ntsc[] = { 0xffff, 0xfffe }; +static struct Screen *wbscreen; +static ULONG oldresolution; + +static void ApplySpriteFix() +{ + if (wbscreen = LockPubScreen(WB_SCREEN_NAME)) { + struct TagItem video_control_tags[] = { + {VTAG_SPRITERESN_GET, SPRITERESN_ECS}, + {TAG_DONE, 0} + }; + struct TagItem video_control_tags2[] = { + {VTAG_SPRITERESN_SET, SPRITERESN_140NS}, + {TAG_DONE, 0} + }; + VideoControl(wbscreen->ViewPort.ColorMap, video_control_tags); + oldresolution = video_control_tags[0].ti_Data; + VideoControl(wbscreen->ViewPort.ColorMap, video_control_tags2); + MakeScreen(wbscreen); + RethinkDisplay(); + } +} +static void UnapplySpriteFix() +{ + if (wbscreen) { + struct TagItem video_control_tags[] = { + {VTAG_SPRITERESN_SET, oldresolution}, + {TAG_DONE, 0} + }; + VideoControl(wbscreen->ViewPort.ColorMap, video_control_tags); + MakeScreen(wbscreen); + UnlockPubScreen(NULL, wbscreen); + } +} int main(int argc, char **argv) { @@ -57,24 +92,27 @@ int main(int argc, char **argv) struct Task *current_task = FindTask(NULL); BYTE old_prio = SetTaskPri(current_task, TASK_PRIORITY); struct View *current_view = ((struct GfxBase *) GfxBase)->ActiView; + UWORD lib_version = ((struct Library *) GfxBase)->lib_Version; + BOOL is_pal; + LoadView(NULL); WaitTOF(); WaitTOF(); - // Assuming 1.x, TODO: add handling for >= 2.x - // Note: FS-UAE reports 0 this, so essentially, there is no information - // for 1.x - if (((struct ExecBase *) EXEC_BASE)->VBlankFrequency == VFREQ_PAL) { - // Handle PAL - printf("PAL: %d\n", (int) ((struct ExecBase *) EXEC_BASE)->VBlankFrequency); - custom.cop1lc = (ULONG) coplist_pal; + // Kickstart > 3.0: fix sprite bug + if (lib_version >= 39) { + ApplySpriteFix(); + is_pal = (((struct GfxBase *) GfxBase)->DisplayFlags & PAL) == PAL; } else { - // Handle NTSC - printf("NTSC: %d\n", (int) ((struct ExecBase *) EXEC_BASE)->VBlankFrequency); - custom.cop1lc = (ULONG) coplist_ntsc; + // Note: FS-UAE reports 0 this, so essentially, there is no information + // for 1.x + printf("PAL/NTSC: %d\n", (int) ((struct ExecBase *) EXEC_BASE)->VBlankFrequency); + is_pal = ((struct ExecBase *) EXEC_BASE)->VBlankFrequency == VFREQ_PAL; } + custom.cop1lc = is_pal ? (ULONG) coplist_pal : (ULONG) coplist_ntsc; waitmouse(); + if (lib_version >= 39) UnapplySpriteFix(); LoadView(current_view); WaitTOF(); WaitTOF();