1
0
mirror of https://github.com/weiju/amiga-stuff synced 2025-11-20 00:09:58 +00:00

sprite fix added for Kickstart >= 3.0

This commit is contained in:
Wei-ju Wu
2016-01-27 21:01:15 -08:00
parent 23379213dd
commit a20c596b9c
2 changed files with 49 additions and 10 deletions

1
hardware/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
startup

View File

@ -6,6 +6,7 @@
#include <clib/intuition_protos.h>
#include <exec/execbase.h>
#include <graphics/gfxbase.h>
#include <graphics/videocontrol.h>
#include <stdio.h>
/*
@ -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();