mirror of https://github.com/weiju/amiga-stuff
outfactored getting arguments into common module
This commit is contained in:
parent
ddeeb941cb
commit
c18ccf30b7
|
@ -0,0 +1,70 @@
|
|||
#include <clib/graphics_protos.h>
|
||||
#include <clib/dos_protos.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "global_defs.h"
|
||||
#include "common.h"
|
||||
|
||||
static ULONG get_mode_id_os3(void)
|
||||
{
|
||||
ULONG modeid = INVALID_ID;
|
||||
struct DimensionInfo diminfo;
|
||||
DisplayInfoHandle dih;
|
||||
|
||||
if ((dih = FindDisplayInfo(VGAPRODUCT_KEY))) {
|
||||
if (GetDisplayInfoData(dih, (APTR) &diminfo, sizeof(diminfo), DTAG_DIMS, 0)) {
|
||||
if (diminfo.MaxDepth >= BLOCKSDEPTH) modeid = VGAPRODUCT_KEY;
|
||||
}
|
||||
}
|
||||
return modeid;
|
||||
}
|
||||
|
||||
ULONG get_mode_id(BOOL option_how, BOOL option_ntsc)
|
||||
{
|
||||
ULONG modeid;
|
||||
|
||||
if (option_how) {
|
||||
modeid = get_mode_id_os3();
|
||||
|
||||
if (modeid == INVALID_ID) {
|
||||
if (option_ntsc) modeid = NTSC_MONITOR_ID | HIRESLACE_KEY;
|
||||
else modeid = PAL_MONITOR_ID | HIRESLACE_KEY;
|
||||
}
|
||||
} else {
|
||||
if (option_ntsc) modeid = NTSC_MONITOR_ID;
|
||||
else modeid = PAL_MONITOR_ID;
|
||||
}
|
||||
return modeid;
|
||||
}
|
||||
|
||||
BOOL get_arguments(struct PrgOptions *options, char *s)
|
||||
{
|
||||
struct RDArgs *myargs;
|
||||
LONG args[NUM_ARGS];
|
||||
|
||||
for (int i = 0; i < NUM_ARGS; i++) args[i] = 0;
|
||||
if (!(myargs = ReadArgs(ARG_TEMPLATE, args, 0))) {
|
||||
Fault(IoErr(), 0, s, 255);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (args[ARG_SPEED]) options->speed = TRUE;
|
||||
if (args[ARG_NTSC]) options->ntsc = TRUE;
|
||||
if (args[ARG_HOW]) {
|
||||
options->how = TRUE;
|
||||
options->speed = FALSE;
|
||||
}
|
||||
if (args[ARG_SKY] && (!options->speed)) {
|
||||
options->sky = TRUE;
|
||||
}
|
||||
if (args[ARG_FMODE]) {
|
||||
options->fetchmode = *(LONG *) args[ARG_FMODE];
|
||||
}
|
||||
FreeArgs(myargs);
|
||||
|
||||
if (options->fetchmode < 0 || options->fetchmode > 3) {
|
||||
strcpy(s, "Invalid fetch mode. Must be 0 .. 3!");
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
#ifndef __COMMON_H__
|
||||
#define __COMMON_H__
|
||||
|
||||
#include <exec/types.h>
|
||||
|
||||
struct PrgOptions {
|
||||
BOOL ntsc, how, speed, sky;
|
||||
WORD fetchmode;
|
||||
};
|
||||
|
||||
struct FetchInfo
|
||||
{
|
||||
WORD ddfstart;
|
||||
WORD ddfstop;
|
||||
WORD modulooffset;
|
||||
WORD bitmapoffset;
|
||||
WORD scrollpixels;
|
||||
};
|
||||
|
||||
extern ULONG get_mode_id(BOOL option_how, BOOL option_ntsc);
|
||||
extern BOOL get_arguments(struct PrgOptions *options, char *s);
|
||||
|
||||
#endif /* __COMMON_H__ */
|
|
@ -53,15 +53,10 @@ UBYTE *mapdata;
|
|||
|
||||
UWORD colors[BLOCKSCOLORS];
|
||||
|
||||
LONG Args[NUM_ARGS];
|
||||
|
||||
BOOL option_ntsc,option_how,option_speed,option_sky;
|
||||
WORD option_fetchmode;
|
||||
|
||||
struct PrgOptions options;
|
||||
BPTR MyHandle;
|
||||
char s[256];
|
||||
|
||||
|
||||
#if EXTRAWIDTH == 32
|
||||
|
||||
// bitmap width aligned to 32 Pixels
|
||||
|
@ -95,8 +90,7 @@ static void Cleanup (char *msg)
|
|||
{
|
||||
WORD rc;
|
||||
|
||||
if (msg)
|
||||
{
|
||||
if (msg) {
|
||||
printf("Error: %s\n",msg);
|
||||
rc = RETURN_WARN;
|
||||
} else {
|
||||
|
@ -105,14 +99,12 @@ static void Cleanup (char *msg)
|
|||
|
||||
if (scr) CloseScreen(scr);
|
||||
|
||||
if (ScreenBitmap)
|
||||
{
|
||||
if (ScreenBitmap) {
|
||||
WaitBlit();
|
||||
FreeBitMap(ScreenBitmap);
|
||||
}
|
||||
|
||||
if (BlocksBitmap)
|
||||
{
|
||||
if (BlocksBitmap) {
|
||||
WaitBlit();
|
||||
FreeBitMap(BlocksBitmap);
|
||||
}
|
||||
|
@ -122,41 +114,6 @@ static void Cleanup (char *msg)
|
|||
exit(rc);
|
||||
}
|
||||
|
||||
static void GetArguments(void)
|
||||
{
|
||||
struct RDArgs *MyArgs;
|
||||
|
||||
if (!(MyArgs = ReadArgs(ARG_TEMPLATE,Args,0)))
|
||||
{
|
||||
Fault(IoErr(),0,s,255);
|
||||
Cleanup(s);
|
||||
}
|
||||
|
||||
if (Args[ARG_SPEED]) option_speed = TRUE;
|
||||
if (Args[ARG_NTSC]) option_ntsc = TRUE;
|
||||
if (Args[ARG_HOW])
|
||||
{
|
||||
option_how = TRUE;
|
||||
option_speed = FALSE;
|
||||
}
|
||||
if (Args[ARG_SKY] && (!option_speed))
|
||||
{
|
||||
option_sky = TRUE;
|
||||
}
|
||||
|
||||
if (Args[ARG_FMODE])
|
||||
{
|
||||
option_fetchmode = *(LONG *)Args[ARG_FMODE];
|
||||
}
|
||||
|
||||
FreeArgs(MyArgs);
|
||||
|
||||
if (option_fetchmode < 0 || option_fetchmode > MAX_FETCHMODE)
|
||||
{
|
||||
Cleanup("Invalid fetch mode. Must be 0 .. " MAX_FETCHMODE_S "!");
|
||||
}
|
||||
}
|
||||
|
||||
static void OpenMap(void)
|
||||
{
|
||||
LONG l;
|
||||
|
@ -181,7 +138,8 @@ static void OpenMap(void)
|
|||
Cleanup(s);
|
||||
}
|
||||
|
||||
Close(MyHandle);MyHandle = 0;
|
||||
Close(MyHandle);
|
||||
MyHandle = 0;
|
||||
|
||||
mapdata = Map->data;
|
||||
mapwidth = Map->mapwidth;
|
||||
|
@ -212,8 +170,8 @@ static void OpenBlocks(void)
|
|||
|
||||
l = BLOCKSWIDTH * BLOCKSHEIGHT * BLOCKSDEPTH / 8;
|
||||
|
||||
if (Read(MyHandle,BlocksBitmap->Planes[0],l) != l) {
|
||||
Fault(IoErr(),0,s,255);
|
||||
if (Read(MyHandle, BlocksBitmap->Planes[0], l) != l) {
|
||||
Fault(IoErr(), 0, s, 255);
|
||||
Cleanup(s);
|
||||
}
|
||||
Close(MyHandle);
|
||||
|
@ -235,7 +193,7 @@ static void OpenDisplay(void)
|
|||
}
|
||||
|
||||
frontbuffer = ScreenBitmap->Planes[0];
|
||||
frontbuffer += (fetchinfo[option_fetchmode].bitmapoffset / 8);
|
||||
frontbuffer += (fetchinfo[options.fetchmode].bitmapoffset / 8);
|
||||
|
||||
if (!(TypeOfMem(ScreenBitmap->Planes[0]) & MEMF_CHIP))
|
||||
{
|
||||
|
@ -246,22 +204,20 @@ static void OpenDisplay(void)
|
|||
Cleanup("Screen bitmap is not in interleaved format!??");
|
||||
}
|
||||
|
||||
modeid = get_mode_id(option_how, option_ntsc);
|
||||
modeid = get_mode_id(options.how, options.ntsc);
|
||||
if (!(scr = OpenScreenTags(0,SA_Width,BITMAPWIDTH,
|
||||
SA_Height,bitmapheight,
|
||||
SA_Depth,BLOCKSDEPTH,
|
||||
SA_DisplayID,modeid,
|
||||
SA_BitMap,ScreenBitmap,
|
||||
option_how ? SA_Overscan : TAG_IGNORE,OSCAN_TEXT,
|
||||
option_how ? SA_AutoScroll : TAG_IGNORE,TRUE,
|
||||
options.how ? SA_Overscan : TAG_IGNORE,OSCAN_TEXT,
|
||||
options.how ? SA_AutoScroll : TAG_IGNORE,TRUE,
|
||||
SA_Quiet,TRUE,
|
||||
TAG_DONE)))
|
||||
{
|
||||
TAG_DONE))) {
|
||||
Cleanup("Can't open screen!");
|
||||
}
|
||||
|
||||
if (scr->RastPort.BitMap->Planes[0] != ScreenBitmap->Planes[0])
|
||||
{
|
||||
if (scr->RastPort.BitMap->Planes[0] != ScreenBitmap->Planes[0]) {
|
||||
Cleanup("Screen was not created with the custom bitmap I supplied!??");
|
||||
}
|
||||
|
||||
|
@ -277,15 +233,15 @@ static void InitCopperlist(void)
|
|||
WaitVBL();
|
||||
|
||||
custom->dmacon = 0x7FFF;
|
||||
custom->beamcon0 = option_ntsc ? 0 : DISPLAYPAL;
|
||||
custom->beamcon0 = options.ntsc ? 0 : DISPLAYPAL;
|
||||
|
||||
CopFETCHMODE[1] = option_fetchmode;
|
||||
CopFETCHMODE[1] = options.fetchmode;
|
||||
|
||||
// bitplane control registers
|
||||
CopBPLCON0[1] = ((BLOCKSDEPTH * BPL0_BPU0_F) & BPL0_BPUMASK) +
|
||||
((BLOCKSDEPTH / 8) * BPL0_BPU3_F) +
|
||||
BPL0_COLOR_F +
|
||||
(option_speed ? 0 : BPL0_USEBPLCON3_F);
|
||||
((BLOCKSDEPTH / 8) * BPL0_BPU3_F) +
|
||||
BPL0_COLOR_F +
|
||||
(options.speed ? 0 : BPL0_USEBPLCON3_F);
|
||||
|
||||
CopBPLCON1[1] = 0;
|
||||
|
||||
|
@ -293,7 +249,7 @@ static void InitCopperlist(void)
|
|||
|
||||
// bitplane modulos
|
||||
l = BITMAPBYTESPERROW * BLOCKSDEPTH -
|
||||
SCREENBYTESPERROW - fetchinfo[option_fetchmode].modulooffset;
|
||||
SCREENBYTESPERROW - fetchinfo[options.fetchmode].modulooffset;
|
||||
|
||||
CopBPLMODA[1] = l;
|
||||
CopBPLMODB[1] = l;
|
||||
|
@ -303,25 +259,22 @@ static void InitCopperlist(void)
|
|||
CopDIWSTOP[1] = DIWSTOP;
|
||||
|
||||
// display data fetch start/stop
|
||||
CopDDFSTART[1] = fetchinfo[option_fetchmode].ddfstart;
|
||||
CopDDFSTOP[1] = fetchinfo[option_fetchmode].ddfstop;
|
||||
CopDDFSTART[1] = fetchinfo[options.fetchmode].ddfstart;
|
||||
CopDDFSTOP[1] = fetchinfo[options.fetchmode].ddfstop;
|
||||
|
||||
// plane pointers
|
||||
wp = CopPLANE1H;
|
||||
|
||||
for(l = 0;l < BLOCKSDEPTH;l++)
|
||||
{
|
||||
for (l = 0; l < BLOCKSDEPTH; l++) {
|
||||
wp[1] = (WORD)(((ULONG)ScreenBitmap->Planes[l]) >> 16);
|
||||
wp[3] = (WORD)(((ULONG)ScreenBitmap->Planes[l]) & 0xFFFF);
|
||||
wp += 4;
|
||||
}
|
||||
|
||||
if (option_sky)
|
||||
{
|
||||
if (options.sky) {
|
||||
// activate copper sky
|
||||
CopSKY[0] = 0x290f;
|
||||
}
|
||||
|
||||
custom->intena = 0x7FFF;
|
||||
custom->dmacon = DMAF_SETCLR | DMAF_BLITTER | DMAF_COPPER | DMAF_RASTER | DMAF_MASTER;
|
||||
custom->cop2lc = (ULONG)CopperList;
|
||||
|
@ -329,14 +282,12 @@ static void InitCopperlist(void)
|
|||
|
||||
/******************* SCROLLING **********************/
|
||||
|
||||
static void DrawBlock(LONG x,LONG y,LONG mapx,LONG mapy)
|
||||
static void DrawBlock(LONG x, LONG y, LONG mapx, LONG mapy)
|
||||
{
|
||||
UBYTE block;
|
||||
|
||||
// x = in pixels
|
||||
// y = in "planelines" (1 realline = BLOCKSDEPTH planelines)
|
||||
|
||||
|
||||
x = (x / 8) & 0xFFFE;
|
||||
y = y * BITMAPBYTESPERROW;
|
||||
|
||||
|
@ -344,11 +295,11 @@ static void DrawBlock(LONG x,LONG y,LONG mapx,LONG mapy)
|
|||
|
||||
mapx = (block % BLOCKSPERROW) * (BLOCKWIDTH / 8);
|
||||
mapy = (block / BLOCKSPERROW) * (BLOCKPLANELINES * BLOCKSBYTESPERROW);
|
||||
|
||||
if (option_how) OwnBlitter();
|
||||
|
||||
if (options.how) OwnBlitter();
|
||||
|
||||
HardWaitBlit();
|
||||
|
||||
|
||||
custom->bltcon0 = 0x9F0; // use A and D. Op: D = A
|
||||
custom->bltcon1 = 0;
|
||||
custom->bltafwm = 0xFFFF;
|
||||
|
@ -357,23 +308,20 @@ static void DrawBlock(LONG x,LONG y,LONG mapx,LONG mapy)
|
|||
custom->bltdmod = BITMAPBYTESPERROW - (BLOCKWIDTH / 8);
|
||||
custom->bltapt = blocksbuffer + mapy + mapx;
|
||||
custom->bltdpt = frontbuffer + y + x;
|
||||
|
||||
custom->bltsize = BLOCKPLANELINES * 64 + (BLOCKWIDTH / 16);
|
||||
|
||||
if (option_how) DisownBlitter();
|
||||
if (options.how) DisownBlitter();
|
||||
}
|
||||
|
||||
static void FillScreen(void)
|
||||
{
|
||||
WORD a,b,x,y;
|
||||
|
||||
for (b = 0;b < BITMAPBLOCKSPERCOL;b++)
|
||||
{
|
||||
for (a = 0;a < BITMAPBLOCKSPERROW;a++)
|
||||
{
|
||||
WORD a, b, x, y;
|
||||
|
||||
for (b = 0; b < BITMAPBLOCKSPERCOL; b++) {
|
||||
for (a = 0; a < BITMAPBLOCKSPERROW; a++) {
|
||||
x = a * BLOCKWIDTH;
|
||||
y = b * BLOCKPLANELINES;
|
||||
DrawBlock(x,y,a,b);
|
||||
DrawBlock(x, y, a, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -389,21 +337,18 @@ static void ScrollLeft(void)
|
|||
|
||||
mapx = mapposx / BLOCKWIDTH;
|
||||
mapy = mapposx & (NUMSTEPS - 1);
|
||||
|
||||
|
||||
x = ROUND2BLOCKWIDTH(videoposx);
|
||||
y = mapy * BLOCKPLANELINES;
|
||||
|
||||
if (previous_direction == DIRECTION_RIGHT)
|
||||
{
|
||||
|
||||
if (previous_direction == DIRECTION_RIGHT) {
|
||||
HardWaitBlit();
|
||||
*savewordpointer = saveword;
|
||||
}
|
||||
|
||||
savewordpointer = (WORD *)(frontbuffer + y * BITMAPBYTESPERROW + (x / 8));
|
||||
saveword = *savewordpointer;
|
||||
|
||||
DrawBlock(x,y,mapx,mapy);
|
||||
|
||||
previous_direction = DIRECTION_LEFT;
|
||||
}
|
||||
|
||||
|
@ -412,19 +357,17 @@ static void ScrollRight(void)
|
|||
WORD mapx,mapy,x,y;
|
||||
|
||||
if (mapposx >= (mapwidth * BLOCKWIDTH - SCREENWIDTH - BLOCKWIDTH)) return;
|
||||
|
||||
|
||||
mapx = mapposx / BLOCKWIDTH + BITMAPBLOCKSPERROW;
|
||||
mapy = mapposx & (NUMSTEPS - 1);
|
||||
|
||||
|
||||
x = BITMAPWIDTH + ROUND2BLOCKWIDTH(videoposx);
|
||||
y = mapy * BLOCKPLANELINES;
|
||||
|
||||
if (previous_direction == DIRECTION_LEFT)
|
||||
{
|
||||
|
||||
if (previous_direction == DIRECTION_LEFT) {
|
||||
HardWaitBlit();
|
||||
*savewordpointer = saveword;
|
||||
}
|
||||
|
||||
savewordpointer = (WORD *)(frontbuffer + (y + BLOCKPLANELINES - 1) * BITMAPBYTESPERROW + (x / 8));
|
||||
saveword = *savewordpointer;
|
||||
|
||||
|
@ -432,28 +375,24 @@ static void ScrollRight(void)
|
|||
|
||||
mapposx++;
|
||||
videoposx = mapposx;
|
||||
|
||||
previous_direction = DIRECTION_RIGHT;
|
||||
}
|
||||
|
||||
static void CheckJoyScroll(void)
|
||||
{
|
||||
WORD i,count;
|
||||
|
||||
if (JoyFire()) count = 8; else count = 1;
|
||||
|
||||
if (JoyLeft())
|
||||
{
|
||||
for(i = 0;i < count;i++)
|
||||
{
|
||||
if (JoyFire()) count = 8;
|
||||
else count = 1;
|
||||
|
||||
if (JoyLeft()) {
|
||||
for (i = 0; i < count; i++) {
|
||||
ScrollLeft();
|
||||
}
|
||||
}
|
||||
|
||||
if (JoyRight())
|
||||
{
|
||||
for(i = 0;i < count;i++)
|
||||
{
|
||||
|
||||
if (JoyRight()) {
|
||||
for (i = 0;i < count;i++) {
|
||||
ScrollRight();
|
||||
}
|
||||
}
|
||||
|
@ -462,94 +401,76 @@ static void CheckJoyScroll(void)
|
|||
static void UpdateCopperlist(void)
|
||||
{
|
||||
ULONG pl;
|
||||
WORD xpos,planeaddx,scroll,i;
|
||||
WORD xpos, planeaddx, scroll, i;
|
||||
WORD *wp;
|
||||
|
||||
i = fetchinfo[option_fetchmode].scrollpixels;
|
||||
|
||||
i = fetchinfo[options.fetchmode].scrollpixels;
|
||||
|
||||
xpos = videoposx + i - 1;
|
||||
|
||||
planeaddx = (xpos / i) * (i / 8);
|
||||
i = (i - 1) - (xpos & (i - 1));
|
||||
|
||||
scroll = (i & 15) * 0x11;
|
||||
|
||||
if (i & 16) scroll |= (0x400 + 0x4000);
|
||||
if (i & 32) scroll |= (0x800 + 0x8000);
|
||||
|
||||
|
||||
// set scroll register in BPLCON1
|
||||
|
||||
CopBPLCON1[1] = scroll;
|
||||
|
||||
// set plane pointers
|
||||
|
||||
wp = CopPLANE1H;
|
||||
|
||||
for(i = 0;i < BLOCKSDEPTH;i++)
|
||||
{
|
||||
for (i = 0; i < BLOCKSDEPTH; i++) {
|
||||
pl = ((ULONG)ScreenBitmap->Planes[i]) + planeaddx;
|
||||
|
||||
wp[1] = (WORD)(pl >> 16);
|
||||
wp[3] = (WORD)(pl & 0xFFFF);
|
||||
|
||||
wp += 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void ShowWhatCopperWouldDo(void)
|
||||
{
|
||||
WORD x;
|
||||
|
||||
x = (videoposx+16) % BITMAPWIDTH;
|
||||
WORD x = (videoposx+16) % BITMAPWIDTH;
|
||||
|
||||
SetWriteMask(ScreenRastPort,1);
|
||||
SetAPen(ScreenRastPort,0);
|
||||
RectFill(ScreenRastPort,0,bitmapheight - 3,BITMAPWIDTH-1,bitmapheight - 3);
|
||||
SetAPen(ScreenRastPort,1);
|
||||
|
||||
if (x <= EXTRAWIDTH)
|
||||
{
|
||||
if (x <= EXTRAWIDTH) {
|
||||
RectFill(ScreenRastPort,x,bitmapheight - 3,x+SCREENWIDTH-1,bitmapheight - 3);
|
||||
} else {
|
||||
RectFill(ScreenRastPort,x,bitmapheight - 3,BITMAPWIDTH-1,bitmapheight - 3);
|
||||
RectFill(ScreenRastPort,0,bitmapheight - 3,x - EXTRAWIDTH,bitmapheight - 3);
|
||||
RectFill(ScreenRastPort,0,bitmapheight - 3,x - EXTRAWIDTH,bitmapheight - 3);
|
||||
}
|
||||
}
|
||||
|
||||
static void MainLoop(void)
|
||||
{
|
||||
if (!option_how)
|
||||
{
|
||||
if (!options.how) {
|
||||
HardWaitBlit();
|
||||
WaitVBL();
|
||||
|
||||
// activate copperlist
|
||||
custom->copjmp2 = 0;
|
||||
}
|
||||
|
||||
while (!LMBDown())
|
||||
{
|
||||
if (!option_how)
|
||||
{
|
||||
|
||||
while (!LMBDown()) {
|
||||
if (!options.how) {
|
||||
WaitVBeam(199);
|
||||
WaitVBeam(200);
|
||||
} else {
|
||||
Delay(1);
|
||||
}
|
||||
|
||||
if (option_speed) *(WORD *)0xdff180 = 0xFF0;
|
||||
|
||||
if (options.speed) *(WORD *)0xdff180 = 0xFF0;
|
||||
|
||||
CheckJoyScroll();
|
||||
|
||||
if (option_speed) *(WORD *)0xdff180 = 0xF00;
|
||||
|
||||
if (!option_how)
|
||||
{
|
||||
UpdateCopperlist();
|
||||
} else {
|
||||
ShowWhatCopperWouldDo();
|
||||
}
|
||||
|
||||
if (options.speed) *(WORD *)0xdff180 = 0xF00;
|
||||
if (!options.how) UpdateCopperlist();
|
||||
else ShowWhatCopperWouldDo();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -557,13 +478,14 @@ static void MainLoop(void)
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GetArguments();
|
||||
BOOL res = get_arguments(&options, s);
|
||||
if (!res) Cleanup(s);
|
||||
|
||||
OpenMap();
|
||||
OpenBlocks();
|
||||
OpenDisplay();
|
||||
|
||||
if (!option_how)
|
||||
{
|
||||
if (!options.how) {
|
||||
Delay(2*50);
|
||||
KillSystem();
|
||||
InitCopperlist();
|
||||
|
@ -571,11 +493,7 @@ int main(int argc, char **argv)
|
|||
FillScreen();
|
||||
MainLoop();
|
||||
|
||||
if (!option_how)
|
||||
{
|
||||
ActivateSystem();
|
||||
}
|
||||
if (!options.how) ActivateSystem();
|
||||
Cleanup(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,12 +46,8 @@ LONG mapwidth;
|
|||
UBYTE *mapdata;
|
||||
|
||||
UWORD colors[BLOCKSCOLORS];
|
||||
LONG Args[NUM_ARGS];
|
||||
|
||||
struct PrgOptions options;
|
||||
BOOL option_ntsc,option_how,option_speed,option_sky;
|
||||
WORD option_fetchmode;
|
||||
|
||||
BPTR MyHandle;
|
||||
char s[256];
|
||||
|
||||
|
@ -91,34 +87,6 @@ static void Cleanup(char *msg)
|
|||
exit(rc);
|
||||
}
|
||||
|
||||
static void GetArguments(struct PrgOptions *options)
|
||||
{
|
||||
struct RDArgs *MyArgs;
|
||||
|
||||
if (!(MyArgs = ReadArgs(ARG_TEMPLATE,Args,0))) {
|
||||
Fault(IoErr(),0,s,255);
|
||||
Cleanup(s);
|
||||
}
|
||||
|
||||
if (Args[ARG_SPEED]) option_speed = TRUE;
|
||||
if (Args[ARG_NTSC]) option_ntsc = TRUE;
|
||||
if (Args[ARG_HOW]) {
|
||||
option_how = TRUE;
|
||||
option_speed = FALSE;
|
||||
}
|
||||
if (Args[ARG_SKY] && (!option_speed)) {
|
||||
option_sky = TRUE;
|
||||
}
|
||||
if (Args[ARG_FMODE]) {
|
||||
option_fetchmode = *(LONG *)Args[ARG_FMODE];
|
||||
}
|
||||
FreeArgs(MyArgs);
|
||||
|
||||
if (option_fetchmode < 0 || option_fetchmode > 3) {
|
||||
Cleanup("Invalid fetch mode. Must be 0 .. 3!");
|
||||
}
|
||||
}
|
||||
|
||||
static void OpenMap(void)
|
||||
{
|
||||
LONG l;
|
||||
|
@ -189,7 +157,7 @@ static void OpenDisplay(void)
|
|||
Cleanup("Can't alloc screen bitmap!");
|
||||
}
|
||||
frontbuffer = ScreenBitmap->Planes[0];
|
||||
frontbuffer += (fetchinfo[option_fetchmode].bitmapoffset / 8);
|
||||
frontbuffer += (fetchinfo[options.fetchmode].bitmapoffset / 8);
|
||||
|
||||
if (!(TypeOfMem(ScreenBitmap->Planes[0]) & MEMF_CHIP)) {
|
||||
Cleanup("Screen bitmap is not in CHIP RAM!?? If you have a gfx card try disabling \"planes to fast\" or similiar options in your RTG system!");
|
||||
|
@ -198,15 +166,15 @@ static void OpenDisplay(void)
|
|||
if (!IS_BITMAP_INTERLEAVED(ScreenBitmap)) {
|
||||
Cleanup("Screen bitmap is not in interleaved format!??");
|
||||
}
|
||||
modeid = get_mode_id(option_how, option_ntsc);
|
||||
modeid = get_mode_id(options.how, options.ntsc);
|
||||
|
||||
if (!(scr = OpenScreenTags(0,SA_Width,BITMAPWIDTH,
|
||||
SA_Height,BITMAPHEIGHT + 3,
|
||||
SA_Depth,BLOCKSDEPTH,
|
||||
SA_DisplayID,modeid,
|
||||
SA_BitMap,ScreenBitmap,
|
||||
option_how ? SA_Overscan : TAG_IGNORE,OSCAN_TEXT,
|
||||
option_how ? SA_AutoScroll : TAG_IGNORE,TRUE,
|
||||
options.how ? SA_Overscan : TAG_IGNORE,OSCAN_TEXT,
|
||||
options.how ? SA_AutoScroll : TAG_IGNORE,TRUE,
|
||||
SA_Quiet,TRUE,
|
||||
TAG_DONE))) {
|
||||
Cleanup("Can't open screen!");
|
||||
|
@ -226,21 +194,21 @@ static void InitCopperlist(void)
|
|||
|
||||
WaitVBL();
|
||||
custom->dmacon = 0x7FFF;
|
||||
custom->beamcon0 = option_ntsc ? 0 : DISPLAYPAL;
|
||||
CopFETCHMODE[1] = option_fetchmode;
|
||||
custom->beamcon0 = options.ntsc ? 0 : DISPLAYPAL;
|
||||
CopFETCHMODE[1] = options.fetchmode;
|
||||
|
||||
// bitplane control registers
|
||||
CopBPLCON0[1] = ((BLOCKSDEPTH * BPL0_BPU0_F) & BPL0_BPUMASK) +
|
||||
((BLOCKSDEPTH / 8) * BPL0_BPU3_F) +
|
||||
BPL0_COLOR_F +
|
||||
(option_speed ? 0 : BPL0_USEBPLCON3_F);
|
||||
(options.speed ? 0 : BPL0_USEBPLCON3_F);
|
||||
|
||||
CopBPLCON1[1] = 0;
|
||||
CopBPLCON3[1] = BPLCON3_BRDNBLNK;
|
||||
|
||||
// bitplane modulos
|
||||
l = BITMAPBYTESPERROW * BLOCKSDEPTH -
|
||||
SCREENBYTESPERROW - fetchinfo[option_fetchmode].modulooffset;
|
||||
SCREENBYTESPERROW - fetchinfo[options.fetchmode].modulooffset;
|
||||
|
||||
CopBPLMODA[1] = l;
|
||||
CopBPLMODB[1] = l;
|
||||
|
@ -250,8 +218,8 @@ static void InitCopperlist(void)
|
|||
CopDIWSTOP[1] = DIWSTOP;
|
||||
|
||||
// display data fetch start/stop
|
||||
CopDDFSTART[1] = fetchinfo[option_fetchmode].ddfstart;
|
||||
CopDDFSTOP[1] = fetchinfo[option_fetchmode].ddfstop;
|
||||
CopDDFSTART[1] = fetchinfo[options.fetchmode].ddfstart;
|
||||
CopDDFSTOP[1] = fetchinfo[options.fetchmode].ddfstop;
|
||||
|
||||
// plane pointers
|
||||
|
||||
|
@ -263,7 +231,7 @@ static void InitCopperlist(void)
|
|||
wp += 4;
|
||||
}
|
||||
|
||||
if (option_sky) {
|
||||
if (options.sky) {
|
||||
// activate copper sky
|
||||
CopSKY[0] = 0x290f;
|
||||
}
|
||||
|
@ -289,7 +257,7 @@ static void DrawBlock(LONG x, LONG y, LONG mapx, LONG mapy)
|
|||
mapx = (block % BLOCKSPERROW) * (BLOCKWIDTH / 8);
|
||||
mapy = (block / BLOCKSPERROW) * (BLOCKPLANELINES * BLOCKSBYTESPERROW);
|
||||
|
||||
if (option_how) OwnBlitter();
|
||||
if (options.how) OwnBlitter();
|
||||
|
||||
HardWaitBlit();
|
||||
|
||||
|
@ -303,7 +271,7 @@ static void DrawBlock(LONG x, LONG y, LONG mapx, LONG mapy)
|
|||
custom->bltdpt = frontbuffer + y + x;
|
||||
custom->bltsize = BLOCKPLANELINES * 64 + (BLOCKWIDTH / 16);
|
||||
|
||||
if (option_how) DisownBlitter();
|
||||
if (options.how) DisownBlitter();
|
||||
}
|
||||
|
||||
static void FillScreen(void)
|
||||
|
@ -378,7 +346,7 @@ static void UpdateCopperlist(void)
|
|||
WORD xpos,planeaddx,scroll,i;
|
||||
WORD *wp;
|
||||
|
||||
i = fetchinfo[option_fetchmode].scrollpixels;
|
||||
i = fetchinfo[options.fetchmode].scrollpixels;
|
||||
|
||||
xpos = videoposx + i - 1;
|
||||
|
||||
|
@ -415,7 +383,7 @@ static void ShowWhatCopperWouldDo(void)
|
|||
|
||||
static void MainLoop(void)
|
||||
{
|
||||
if (!option_how) {
|
||||
if (!options.how) {
|
||||
// activate copperlist
|
||||
HardWaitBlit();
|
||||
WaitVBL();
|
||||
|
@ -423,17 +391,17 @@ static void MainLoop(void)
|
|||
}
|
||||
|
||||
while (!LMBDown()) {
|
||||
if (!option_how) {
|
||||
if (!options.how) {
|
||||
WaitVBeam(199);
|
||||
WaitVBeam(200);
|
||||
} else Delay(1);
|
||||
|
||||
if (option_speed) *(WORD *)0xdff180 = 0xFF0;
|
||||
if (options.speed) *(WORD *)0xdff180 = 0xFF0;
|
||||
|
||||
CheckJoyScroll();
|
||||
|
||||
if (option_speed) *(WORD *)0xdff180 = 0xF00;
|
||||
if (!option_how) UpdateCopperlist();
|
||||
if (options.speed) *(WORD *)0xdff180 = 0xF00;
|
||||
if (!options.how) UpdateCopperlist();
|
||||
else ShowWhatCopperWouldDo();
|
||||
}
|
||||
}
|
||||
|
@ -442,12 +410,13 @@ static void MainLoop(void)
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GetArguments(&options);
|
||||
BOOL res = get_arguments(&options, s);
|
||||
if (!res) Cleanup(s);
|
||||
OpenMap();
|
||||
OpenBlocks();
|
||||
OpenDisplay();
|
||||
|
||||
if (!option_how) {
|
||||
if (!options.how) {
|
||||
Delay(2*50);
|
||||
KillSystem();
|
||||
InitCopperlist();
|
||||
|
@ -455,7 +424,7 @@ int main(int argc, char **argv)
|
|||
FillScreen();
|
||||
MainLoop();
|
||||
|
||||
if (!option_how) ActivateSystem();
|
||||
if (!options.how) ActivateSystem();
|
||||
Cleanup(0);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue