hardware: clean out main modules

made the init_display() and reset_display() functions
more indepenent from their callers
This commit is contained in:
Wei-ju Wu 2016-09-21 21:19:59 -07:00
parent ffe2349c08
commit b31f5a40aa
5 changed files with 13 additions and 44 deletions

View File

@ -46,8 +46,9 @@ static void UnapplySpriteFix(void)
}
}
BOOL init_display(UWORD lib_version)
BOOL init_display(void)
{
UWORD lib_version = ((struct Library *) GfxBase)->lib_Version;
BOOL is_pal;
LoadView(NULL); // clear display, reset hardware registers
@ -67,8 +68,10 @@ BOOL init_display(UWORD lib_version)
return is_pal;
}
void reset_display(struct View *current_view, UWORD lib_version)
void reset_display(void)
{
struct View *current_view = ((struct GfxBase *) GfxBase)->ActiView;
UWORD lib_version = ((struct Library *) GfxBase)->lib_Version;
if (lib_version >= 39) UnapplySpriteFix();
LoadView(current_view);
WaitTOF();

View File

@ -50,8 +50,8 @@
#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);
extern BOOL init_display(void);
extern void reset_display(void);
// VBCC Inline assembly
void waitmouse(void) = "waitmouse:\n\tbtst\t#6,$bfe001\n\tbne\twaitmouse";

View File

@ -1,12 +1,5 @@
#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 <stdio.h>
#include "common.h"
@ -34,7 +27,6 @@
* A simple setup to display a playfield with a depth of 1 bit.
*/
extern struct Custom custom;
extern struct Library *GfxBase;
static UWORD __chip coplist[] = {
COP_MOVE(BPL1PTH, 0),
@ -56,13 +48,7 @@ int main(int argc, char **argv)
// translated startup.asm
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 = init_display(lib_version);
ULONG pl1data = (ULONG) image_data;
ULONG pl2data = ((ULONG) &image_data[20 * NUM_RASTER_LINES]);
BOOL is_pal = init_display();
// hardcoded for UAE, since it seems that the mode returned is always NTSC
is_pal = USE_PAL;
@ -97,6 +83,6 @@ int main(int argc, char **argv)
waitmouse();
reset_display(current_view, lib_version);
reset_display();
return 0;
}

View File

@ -1,16 +1,12 @@
#include <clib/exec_protos.h>
#include <graphics/gfxbase.h>
#include <hardware/custom.h>
#include <stdio.h>
#include "common.h"
/*
* A simple setup to display a sprite.
*/
extern struct Custom custom;
extern struct Library *GfxBase;
static UWORD __chip coplist_pal[] = {
COP_MOVE(SPR0PTH, 0x0000),
@ -39,13 +35,9 @@ static UWORD __chip spdat0[] = {
int main(int argc, char **argv)
{
// translated startup.asm
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 = init_display(lib_version);
BOOL is_pal = init_display();
coplist_ntsc[1] = ((ULONG) spdat0) & 0xffff;
coplist_ntsc[3] = (((ULONG) spdat0) >> 16) & 0xffff;
coplist_pal[1] = ((ULONG) spdat0) & 0xffff;
@ -55,6 +47,6 @@ int main(int argc, char **argv)
waitmouse();
reset_display(current_view, lib_version);
reset_display();
return 0;
}

View File

@ -1,12 +1,5 @@
#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 <stdio.h>
#include "common.h"
@ -21,7 +14,6 @@
* A great starting point to use as a template for demos and games.
*/
extern struct Custom custom;
extern struct Library *GfxBase;
static UWORD __chip coplist_pal[] = {
COP_MOVE(BPLCON0, BPLCON0_COMPOSITE_COLOR),
@ -46,17 +38,13 @@ static UWORD __chip coplist_ntsc[] = {
int main(int argc, char **argv)
{
// translated startup.asm
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 = init_display(lib_version);
BOOL is_pal = init_display();
custom.cop1lc = is_pal ? (ULONG) coplist_pal : (ULONG) coplist_ntsc;
waitmouse();
reset_display(current_view, lib_version);
reset_display();
return 0;
}