home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 2
/
FFMCD02.bin
/
new
/
amigalibdisks
/
disk944
/
blocked
/
blocked.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-12-21
|
29KB
|
1,212 lines
/*
* Copyright (C) 1989 Andrew Kemmis
*
* All Rights Reserved
*
* Date: Mar 1989
*/
#define AK___CRYPT
#include <ak/stdak.h>
char Program_name[] = "BlockEd";
int Version = CRYPTNUM(1);
int MinorVer = CRYPTNUM(4);
char Date[] = "Oct 1993";
char CRDate[] = "1989-93";
#include <ak/err.h>
#include <ak/err_num.h>
#include <ak/pool.h>
#include <ak/dev.h>
#include <ak/dos.h>
#include <ak/menu.h>
#include <ak/gad.h>
#include <ak/filesystem.h>
#include <ak/rawkey.h>
#include <intuition/intuition.h>
#include <graphics/gfxbase.h>
#include <ctype.h>
#include "blocked.qi"
#define STRINGJUST (Hex ? STRINGCENTER : (Left ? 0L : STRINGRIGHT))
#define INTUITION_MESSAGE (1L<<MyWin->UserPort->mp_SigBit)
extern char *strchr();
extern char *strrchr();
extern struct Window *OpenWindow();
extern struct Screen *OpenScreen();
extern struct IntuiMessage *GetMsg();
extern struct MenuItem *ItemAddress();
extern struct TextFont *OpenDiskFont();
extern LONG Wait();
extern void *AllocMem();
int cli;
struct IBASE *IBASE = (struct IBASE *)NULL;
struct GfxBase *GfxBase = (struct GfxBase *)NULL;
struct Library *DiskfontBase = (struct Library *)NULL;
Static struct AkMenu AkMenu = AKMENUINIT;
Static struct TextFont *Opal = (struct TextFont *)NULL;
Static struct TextAttr OpalAttr = { (STRPTR)NULL, 0, 0, 0 }; /* Setup in main */
Static UWORD FXSize;
Static UWORD FYSize;
Static UWORD FYBase;
Static int Inhibited = 0;
Static struct AkGad AkGad = AKGADINIT;
Static struct Gadget *BlkGad;
Static struct Gadget *DirGad;
Static struct Gadget *NumGad;
Static char *Device;
Static struct AkDevStuff Stuff = DEVSTUFFINIT;
Static ulong TheBlock;
Static char TheBlockBuf[10+1];
Static ulong CurBlock = 0;
Static ulong *Buffer;
Static ulong *Buffer2;
Static uchar *BufPtr;
Static long Dev = -1;
Static int LongPos = 0;
Static int BytePos = 0;
Static struct Menu *ProjectMenu;
Static struct MenuItem *RestoreItem;
Static struct RastPort *rp;
Static char DirBuf[FILENAMELENGTH+1];
Static char NumBuf[10+1];
#define EDIT_NO 0
#define EDIT_YES 1
Static int Edit = EDIT_NO;
#define MENUFLAGS (USHORT)MENUENABLED
#define ITEMFLAGS (USHORT)(ITEMTEXT | COMMSEQ | HIGHBOX)
#define MOREITEMFLAGS (USHORT)(ITEMENABLED | ITEMFLAGS)
#define EXTRAITEMFLAGS (USHORT)(CHECKIT | MENUTOGGLE | MOREITEMFLAGS)
Static struct PoolKey GenPoolKey;
Static struct Screen *MyScreen = (struct Screen *)NULL;
Static struct NewScreen MyNewScreen =
{
0, 0, 640, 330, 2,
0, 1,
LACE | SPRITES | HIRES,
CUSTOMSCREEN | SCREENBEHIND | BEEPING,
&OpalAttr,
(UBYTE *)Program_name,
(struct Gadget *)NULL,
(struct BitMap *)NULL
};
Static struct Window *MyWin = (struct Window *)NULL;
Static struct NewWindow MyNewWin =
{
0, 7,
640, 323,
-1, -1,
MENUVERIFY | MOUSEBUTTONS | GADGETDOWN | GADGETUP | MENUPICK | CLOSEWINDOW | RAWKEY,
WINDOWCLOSE | SMART_REFRESH | REPORTMOUSE | NOCAREREFRESH | ACTIVATE,
(struct Gadget *)NULL,
(struct Image *)NULL,
(UBYTE *)Program_name,
(struct Screen *)NULL,
(struct BitMap *)NULL,
0, 0, 0, 0,
CUSTOMSCREEN
};
#define MoveTo(x, y) Move(rp, (long)(x), (long)(y))
#define TextTo(s, n) Text(rp, (s), (long)(n))
Static send(str, x, y, len)
REG char *str;
REG int x;
REG int y;
REG int len;
{
MoveTo(x, y);
TextTo(str, len);
}
#define DSP_BIG 1
#define DSP_MEDIUM 2
#define DSP_TINY 4
Static display_num(x, y, num, size, buf)
REG int x;
REG int y;
REG ulong num;
int size;
char *buf;
{
static char Str[11];
REG int hex;
REG int dec;
switch (size)
{
case DSP_BIG:
hex = 8;
dec = 10;
break;
case DSP_MEDIUM:
hex = 4;
dec = 6;
break;
case DSP_TINY:
hex = 2;
dec = 4;
break;
}
if (!buf)
{ if (Hex)
sprintf(Str, " %0*lx ", hex, num);
else
if (Left)
sprintf(Str, "%-*lu", dec, num);
else
sprintf(Str, "%*lu", dec, num);
send(Str, x, y, dec);
}
else
{ if (Hex)
sprintf(buf, "%0*lx", hex, num);
else
sprintf(buf, "%lu", num);
}
}
#define NXTIMES ((FXSize * 10) + 4)
#define NYTIMES FYSize
#define AXTIMES FXSize
#define AYTIMES FYSize
#define NXPLUS 7
#define NYPLUS (FYSize * 4)
#define AXPLUS ((FXSize * 42) + 6)
#define AYPLUS (FYSize * 4)
#define ACTIVE 1
#define BACKGR 0
Static display_pos(pos, active)
REG int pos;
REG int active;
{
REG int xn;
REG int xs;
REG int y;
REG uchar ptr[4];
int i;
for (i = (ByteMove ? 0 : 3); i >= 0; i--)
if (isprint(BufPtr[i+pos]))
ptr[i] = BufPtr[i+pos];
else
ptr[i] = NullChar;
xn = (pos / 4) % 4;
xs = pos % 16;
y = pos / 16;
if (active == ACTIVE)
{ SetAPen(rp, SelectPen);
SetBPen(rp, OtherPen);
}
else
{ SetAPen(rp, DataPen);
SetBPen(rp, BackPen);
}
display_num(xn * NXTIMES + NXPLUS, y * NYTIMES + NYPLUS, Buffer[pos/4], DSP_BIG, NULL);
send(ptr, xs * AXTIMES + AXPLUS, y * AYTIMES + AYPLUS, ByteMove ? 1 : 4);
}
#define PT_STR 0
#define PT_NUM 1
#define PT_BUF 2
#define PT_PTR 3
#define PT_NPT 4
#define PT_DEV 5
#define PT_LON 6
#define PT_BYT 7
#define PT_SAV 8
#define PT_END 9
#define DRAW_ONCE_ONLY 1
#define DRAW_EACH_BLOCK 2
#define DRAW_EACH_CHECKSUM 4
#define DRAW_EACH_MOVE 8
#define DRAW_MARK_EDIT 16
#define DRAW_UNMARK_EDIT 32
#define BLKGAD_SAV 0L
#define DIRGAD_SAV 1L
#define MAX_SAV 1L
Static struct
{ int x;
int y;
} saves[MAX_SAV+1];
Static draw_page(often)
REG int often;
{
static struct ScrDat
{ char *str;
int often;
int reset;
int xt;
int xa;
int yt;
int ya;
int type;
long *pen;
} Page[] =
{
"Offset", 1, 1, 1, 2, 2, 4, PT_STR, &DataPen,
"O", 1, 0, 0, 0, 0, 0, PT_STR, &SelectPen,
(char *)BLKGAD_SAV, 1, 0, 7, 0, 0, 0, PT_SAV, NULL,
"Long", 1, 0, 16, 0, 0, 0, PT_STR, &DataPen,
(char *)&LongPos, 10, 0, 5, 0, 0, 0, PT_LON, &SelectPen,
"Byte", 1, 0, 11, 0, 0, 0, PT_STR, &DataPen,
(char *)&BytePos, 10, 0, 5, 0, 0, 0, PT_BYT, &SelectPen,
"Root", 1, 0, 14, 4, 0, 0, PT_STR, &OtherPen,
"R", 1, 0, 0, 0, 0, 0, PT_STR, &SelectPen,
(char *)&Stuff.Info.Root, 3, 0, 10, -4, 0, 0, PT_NUM, &DataPen,
"Parent", 1, 0, -10, 4, 1, 4, PT_STR, &OtherPen,
"P", 1, 0, 0, 0, 0, 0, PT_STR, &SelectPen,
(char *)POS_PAR, 3, 0, 10, -4, 0, 0, PT_BUF, &DataPen,
"Key", 1, 0, -10, 4, 1, 0, PT_STR, &OtherPen,
"K", 1, 0, 0, 0, 0, 0, PT_STR, &SelectPen,
(char *)POS_KEY, 3, 0, 10, -4, 0, 0, PT_BUF, &DataPen,
"HashChain", 1, 0, -10, 4, 1, 0, PT_STR, &OtherPen,
"H", 1, 0, 0, 0, 0, 0, PT_STR, &SelectPen,
(char *)POS_HASH_CH, 3, 0, 10, -4, 0, 0, PT_BUF, &DataPen,
"Extension", 1, 0, -10, 4, 1, 0, PT_STR, &OtherPen,
"E", 1, 0, 0, 0, 0, 0, PT_STR, &SelectPen,
(char *)POS_EXT, 3, 0, 10, -4, 0, 0, PT_BUF, &DataPen,
"FirstData", 1, 0, -10, 4, 1, 0, PT_STR, &OtherPen,
"F", 1, 0, 0, 0, 0, 0, PT_STR, &SelectPen,
(char *)POS_FST_DAT, 3, 0, 10, -4, 0, 0, PT_BUF, &DataPen,
"NextData", 1, 0, -10, 4, 1, 0, PT_STR, &OtherPen,
"N", 1, 0, 0, 0, 0, 0, PT_STR, &SelectPen,
(char *)POS_D_NXT_DAT, 3, 0, 10, -4, 0, 0, PT_BUF, &DataPen,
"CheckSum", 1, 0, -10, 4, 1, 0, PT_STR, &OtherPen,
"C", 1, 0, 0, 0, 0, 0, PT_STR, &SelectPen,
(char *)POS_CHKSUM,