home *** CD-ROM | disk | FTP | other *** search
- /* Simple ASCII Table hack I did while avoiding work */
- /* \251 (c) A. Caleb Gattegno, this is freely redistributable and all that
- * stuff.
- * Notes: Written with Manx 3.40a
- * Warnings: This program is not at all smart. In fact it might be called
- * brain damaged. What I mean is that I have a feeling it won't look at
- * all pretty if you are not using a standard font. I don't think it will
- * eat your computer, but as this is a "hack I did while avoiding work"
- * I'm not gonna worry about it too much. Eventually, I'll make this
- * resizable, and allow for custom fonts, but not until I get my current
- * jobs done. In other words, expect more out of me NOT RSN! }:->
- * Aside from that, enjoy this for what it is.
- * Requests: As I do plan on doing more with this, up to and including, having
- * this be a part of my eventual text editor, please don't go around
- * making changes/additions to the source and u/ling it. Feel free to
- * use this code for education, though I don't thinks it's worth much on
- * that line, and for your own toying, but PLEASE don't put any "new and
- * improved" versions on the nets as I might get confused :-(
- *
- * In any case, enjoy and happy ASCIIing! ACG 7-23-88
- * CI$ UID: 76164,3006 "Can be found" haunting AMIGATECH
- */
- #include <exec/types.h>
- #include <exec/execbase.h>
- #include <graphics/gfxbase.h>
- #include <intuition/intuition.h>
- #include "DecHexTables.h"
-
- IMPORT struct ExecBase *SysBase;
-
- struct GfxBase *GfxBase = NULL;
- struct IntuitionBase *IntuitionBase = NULL;
-
- struct Window *Window = NULL;
- struct RastPort *RP;
-
- UBYTE ASCIITop;
-
- main()
- {
- VOID Wait(), ReplyMsg(), *OpenLibrary(), *OpenWindow();
- struct NewWindow nw;
- struct IntuiMessage *msg, *GetMsg();
-
- if (!(GfxBase = OpenLibrary("graphics.library", 0))) CleanUp(101);
- if (!(IntuitionBase = OpenLibrary("intuition.library", 0)))
- CleanUp(102);
-
- nw.LeftEdge = 460;
- nw.TopEdge = 10;
- nw.Width = 176;
- nw.Height = 140;
- nw.DetailPen = -1;
- nw.BlockPen = -1;
- nw.IDCMPFlags = CLOSEWINDOW | RAWKEY | REFRESHWINDOW;
- nw.Flags = WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH | SIMPLE_REFRESH;
- nw.FirstGadget = NULL;
- nw.CheckMark = NULL;
- nw.Title = "ASCII Table";
- nw.Screen = NULL;
- nw.BitMap = NULL;
- nw.MinWidth = 0;
- nw.MinHeight = 0;
- nw.MaxWidth = 176;
- nw.MaxHeight = 150;
- nw.Type = WBENCHSCREEN;
-
- if (!(Window = OpenWindow(&nw))) CleanUp(201);
- RP = Window->RPort;
- SetAPen(RP, 1);
- SetBPen(RP, 0);
- SetDrMd(RP, JAM2);
-
- ASCIITop = 0;
- ListASCII();
- FOREVER {
- Wait(1 << Window->UserPort->mp_SigBit);
-
- while (msg = GetMsg(Window->UserPort)) {
- ULONG class;
- UWORD code;
-
- class = msg->Class;
- code = msg->Code;
-
- ReplyMsg(msg);
-
- switch (class) {
- case REFRESHWINDOW:
- ListASCII();
- break;
- case CLOSEWINDOW:
- CleanUp(0);
- break;
- case RAWKEY:
- if (code == 0x4c) { /* Up Arrow */
- if (ASCIITop)
- ASCIITop -= 32;
- else
- ASCIITop = 224;
- ListASCII();
- } else if (code == 0x4d) { /* Down Arrow */
- if (ASCIITop == 224)
- ASCIITop = 0;
- else
- ASCIITop += 32;
- ListASCII();
- }
- break;
- } /* switch */
- } /* while */
- } /* FOREVER */
- }
-
- ListASCII()
- {
- REGISTER UBYTE i, j;
- UBYTE c;
-
- Move(RP, 88, 10);
- Draw(RP, 88, 148);
- for (i = 16, j = ASCIITop; i < 144; i += 8, j++) {
- Move(RP, 8, i);
- Text(RP, Decimal[j], 3);
- Move(RP, 40, i);
- Text(RP, Hex[j], 3);
- c = j;
- Move(RP, 72, i);
- Text(RP, &c, 1);
-
- Move(RP, 96, i);
- Text(RP, Decimal[j + 16], 3);
- Move(RP, 128, i);
- Text(RP, Hex[j + 16], 3);
- c = j + 16;
- Move(RP, 160, i);
- Text(RP, &c, 1);
- }
- }
-
- CleanUp(errcode)
- ULONG errcode;
- {
- VOID CloseWindow(), CloseLibrary();
-
- if (Window) CloseWindow(Window);
- if (IntuitionBase) CloseLibrary(IntuitionBase);
- if (GfxBase) CloseLibrary(GfxBase);
-
- exit(errcode);
- }
-