mirror of https://github.com/weiju/amiga-stuff
outfactored initialization cleanup to common.c in hardware
This commit is contained in:
parent
d4217b995a
commit
24f4e04928
|
@ -6,11 +6,11 @@ all: startup sprites playfield1
|
|||
clean:
|
||||
rm -f *.o startup sprites playfield1
|
||||
|
||||
startup: startup.o
|
||||
startup: startup.o common.o
|
||||
$(CC) $(CFLAGS) $^ -lamiga -lauto -o $@
|
||||
|
||||
sprites: sprites.o
|
||||
sprites: sprites.o common.o
|
||||
$(CC) $(CFLAGS) $^ -lamiga -lauto -o $@
|
||||
|
||||
playfield1: playfield1.o
|
||||
playfield1: playfield1.o common.o
|
||||
$(CC) $(CFLAGS) $^ -lamiga -lauto -o $@
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
#include <clib/graphics_protos.h>
|
||||
#include <clib/intuition_protos.h>
|
||||
#include <exec/execbase.h>
|
||||
#include <graphics/gfxbase.h>
|
||||
#include <graphics/videocontrol.h>
|
||||
#include <hardware/custom.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
extern struct Custom custom;
|
||||
extern struct Library *GfxBase;
|
||||
static struct Screen *wbscreen;
|
||||
static ULONG oldresolution;
|
||||
|
||||
static void ApplySpriteFix(void)
|
||||
{
|
||||
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(void)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL init_display(UWORD lib_version)
|
||||
{
|
||||
BOOL is_pal;
|
||||
|
||||
LoadView(NULL); // clear display, reset hardware registers
|
||||
WaitTOF(); // 2 WaitTOFs to wait for 1. long frame and
|
||||
WaitTOF(); // 2. short frame copper lists to finish (if interlaced)
|
||||
|
||||
// Kickstart > 3.0: fix sprite bug
|
||||
if (lib_version >= 39) {
|
||||
ApplySpriteFix();
|
||||
is_pal = (((struct GfxBase *) GfxBase)->DisplayFlags & PAL) == PAL;
|
||||
} else {
|
||||
// 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;
|
||||
}
|
||||
return is_pal;
|
||||
}
|
||||
|
||||
void reset_display(struct View *current_view, UWORD lib_version)
|
||||
{
|
||||
if (lib_version >= 39) UnapplySpriteFix();
|
||||
LoadView(current_view);
|
||||
WaitTOF();
|
||||
WaitTOF();
|
||||
custom.cop1lc = (ULONG) ((struct GfxBase *) GfxBase)->copinit;
|
||||
RethinkDisplay();
|
||||
}
|
|
@ -50,4 +50,7 @@
|
|||
#define COP_MOVE(addr, data) addr, data
|
||||
#define COP_WAIT_END 0xffff, 0xfffe
|
||||
|
||||
extern BOOL init_display(UWORD lib_version);
|
||||
extern void reset_display(struct View *current_view, UWORD lib_version);
|
||||
|
||||
#endif /* __COMMON_DEFS_H__ */
|
||||
|
|
|
@ -54,72 +54,6 @@ static UWORD __chip coplist[] = {
|
|||
COP_WAIT_END
|
||||
};
|
||||
|
||||
static struct Screen *wbscreen;
|
||||
static ULONG oldresolution;
|
||||
|
||||
static void ApplySpriteFix(void)
|
||||
{
|
||||
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(void)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL init_display(UWORD lib_version)
|
||||
{
|
||||
BOOL is_pal;
|
||||
|
||||
LoadView(NULL); // clear display, reset hardware registers
|
||||
WaitTOF(); // 2 WaitTOFs to wait for 1. long frame and
|
||||
WaitTOF(); // 2. short frame copper lists to finish (if interlaced)
|
||||
|
||||
// Kickstart > 3.0: fix sprite bug
|
||||
if (lib_version >= 39) {
|
||||
ApplySpriteFix();
|
||||
is_pal = (((struct GfxBase *) GfxBase)->DisplayFlags & PAL) == PAL;
|
||||
} else {
|
||||
// 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;
|
||||
}
|
||||
return is_pal;
|
||||
}
|
||||
|
||||
static void reset_display(struct View *current_view, UWORD lib_version)
|
||||
{
|
||||
if (lib_version >= 39) UnapplySpriteFix();
|
||||
LoadView(current_view);
|
||||
WaitTOF();
|
||||
WaitTOF();
|
||||
custom.cop1lc = (ULONG) ((struct GfxBase *) GfxBase)->copinit;
|
||||
RethinkDisplay();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// translated startup.asm
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
#include <hardware/custom.h>
|
||||
#include <hardware/cia.h>
|
||||
|
||||
#include <clib/exec_protos.h>
|
||||
#include <clib/graphics_protos.h>
|
||||
#include <clib/intuition_protos.h>
|
||||
#include <exec/execbase.h>
|
||||
#include <graphics/gfxbase.h>
|
||||
#include <graphics/videocontrol.h>
|
||||
#include <hardware/custom.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/*
|
||||
* A simple setup to display a sprite.
|
||||
*/
|
||||
|
@ -44,72 +40,6 @@ static UWORD __chip spdat0[] = {
|
|||
0x0000, 0x0000
|
||||
};
|
||||
|
||||
static struct Screen *wbscreen;
|
||||
static ULONG oldresolution;
|
||||
|
||||
static void ApplySpriteFix(void)
|
||||
{
|
||||
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(void)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL init_display(UWORD lib_version)
|
||||
{
|
||||
BOOL is_pal;
|
||||
|
||||
LoadView(NULL); // clear display, reset hardware registers
|
||||
WaitTOF(); // 2 WaitTOFs to wait for 1. long frame and
|
||||
WaitTOF(); // 2. short frame copper lists to finish (if interlaced)
|
||||
|
||||
// Kickstart > 3.0: fix sprite bug
|
||||
if (lib_version >= 39) {
|
||||
ApplySpriteFix();
|
||||
is_pal = (((struct GfxBase *) GfxBase)->DisplayFlags & PAL) == PAL;
|
||||
} else {
|
||||
// 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;
|
||||
}
|
||||
return is_pal;
|
||||
}
|
||||
|
||||
static void reset_display(struct View *current_view, UWORD lib_version)
|
||||
{
|
||||
if (lib_version >= 39) UnapplySpriteFix();
|
||||
LoadView(current_view);
|
||||
WaitTOF();
|
||||
WaitTOF();
|
||||
custom.cop1lc = (ULONG) ((struct GfxBase *) GfxBase)->copinit;
|
||||
RethinkDisplay();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// translated startup.asm
|
||||
|
|
|
@ -47,73 +47,6 @@ static UWORD __chip coplist_ntsc[] = {
|
|||
COP_WAIT_END
|
||||
};
|
||||
|
||||
static struct Screen *wbscreen;
|
||||
static ULONG oldresolution;
|
||||
|
||||
static void ApplySpriteFix(void)
|
||||
{
|
||||
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(void)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL init_display(UWORD lib_version)
|
||||
{
|
||||
BOOL is_pal;
|
||||
|
||||
LoadView(NULL); // clear display, reset hardware registers
|
||||
WaitTOF(); // 2 WaitTOFs to wait for 1. long frame and
|
||||
WaitTOF(); // 2. short frame copper lists to finish (if interlaced)
|
||||
|
||||
// Kickstart > 3.0: fix sprite bug
|
||||
if (lib_version >= 39) {
|
||||
ApplySpriteFix();
|
||||
is_pal = (((struct GfxBase *) GfxBase)->DisplayFlags & PAL) == PAL;
|
||||
} else {
|
||||
// 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;
|
||||
return is_pal;
|
||||
}
|
||||
|
||||
static void reset_display(struct View *current_view, UWORD lib_version)
|
||||
{
|
||||
if (lib_version >= 39) UnapplySpriteFix();
|
||||
LoadView(current_view);
|
||||
WaitTOF();
|
||||
WaitTOF();
|
||||
custom.cop1lc = (ULONG) ((struct GfxBase *) GfxBase)->copinit;
|
||||
RethinkDisplay();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// translated startup.asm
|
||||
|
@ -122,7 +55,8 @@ int main(int argc, char **argv)
|
|||
struct View *current_view = ((struct GfxBase *) GfxBase)->ActiView;
|
||||
UWORD lib_version = ((struct Library *) GfxBase)->lib_Version;
|
||||
|
||||
init_display(lib_version);
|
||||
BOOL is_pal = init_display(lib_version);
|
||||
custom.cop1lc = is_pal ? (ULONG) coplist_pal : (ULONG) coplist_ntsc;
|
||||
|
||||
waitmouse();
|
||||
|
||||
|
|
Loading…
Reference in New Issue