diff --git a/30years/iffview/iffview.c b/30years/iffview/iffview.c
index 743f0a2..c7c586c 100644
--- a/30years/iffview/iffview.c
+++ b/30years/iffview/iffview.c
@@ -16,6 +16,7 @@
along with amiga30yrs. If not, see .
*/
#include
+#include
#include
#include
@@ -173,6 +174,7 @@ int main(int argc, char **argv)
}
ILBMData *ilbm_data = NULL;
ilbm_data = parse_file(argv[1]);
+ if (!ilbm_data) exit(0);
image.Width = ilbm_data->bmheader->w;
image.Height = ilbm_data->bmheader->h;
image.Depth = ilbm_data->bmheader->nPlanes;
@@ -186,6 +188,7 @@ int main(int argc, char **argv)
image.PlanePick = (1 << image.Depth) - 1;
/* Adjust the new screen according to the IFF image */
+ newscreen.ViewModes = ilbm_data->bmheader->camgFlags;
newscreen.Depth = image.Depth;
screen = OpenScreen(&newscreen);
if (screen) {
diff --git a/30years/iffview/ilbm.c b/30years/iffview/ilbm.c
index e5905be..868d7aa 100644
--- a/30years/iffview/ilbm.c
+++ b/30years/iffview/ilbm.c
@@ -33,7 +33,7 @@ BitMapHeader *read_BMHD(FILE *fp, int datasize)
BitMapHeader *header;
int bytes_read;
- header = malloc(sizeof(BitMapHeader));
+ header = calloc(1, sizeof(BitMapHeader));
bytes_read = fread(header, sizeof(char), datasize, fp);
#ifdef LITTLE_ENDIAN
@@ -156,7 +156,7 @@ ILBMData *read_chunks(FILE *fp, int filesize, int total_read)
if (!strncmp("BMHD", buffer, 4)) bmheader = read_BMHD(fp, datasize);
else if (!strncmp("CMAP", buffer, 4)) colors = read_CMAP(fp, datasize, &result->num_colors);
else if (!strncmp("CRNG", buffer, 4)) read_CRNG(fp, datasize);
- else if (!strncmp("CAMG", buffer, 4)) read_CAMG(fp, datasize);
+ else if (!strncmp("CAMG", buffer, 4)) bmheader->camgFlags = read_CAMG(fp, datasize);
else if (!strncmp("BODY", buffer, 4)) imgdata = read_BODY(fp, datasize, bmheader, &imgdata_size);
else {
#ifdef DEBUG
@@ -285,14 +285,17 @@ int main(int argc, char **argv)
} else {
ILBMData *data = parse_file(argv[1]);
print_ilbm_info(data);
-
- int wordwidth = (data->bmheader->w + 16) / 16;
- int destWidth = wordwidth * 16;
- int destHeight = data->bmheader->h;
+ int dest_width = data->bmheader->w;
+ int mod16 = dest_width % 16;
+ if (mod16 > 0) {
+ dest_width += mod16;
+ }
+ int wordwidth = dest_width / 16;
+ int dest_height = data->bmheader->h;
int finalsize = wordwidth * data->bmheader->h * data->bmheader->nPlanes * 2;
printf("loaded size: %d, final size: %d\n", data->data_bytes, finalsize);
char *dest = calloc(finalsize, sizeof(char));
- ilbm_to_image_data(dest, data, destWidth, destHeight);
+ ilbm_to_image_data(dest, data, dest_width, dest_height);
free(dest);
free_ilbm_data(data);
}
diff --git a/30years/iffview/ilbm.h b/30years/iffview/ilbm.h
index 7cb2553..a0f6a1c 100644
--- a/30years/iffview/ilbm.h
+++ b/30years/iffview/ilbm.h
@@ -58,15 +58,16 @@ typedef UBYTE Compression;
#define cmpByteRun1 1
typedef struct {
- UWORD w, h;
- WORD x, y;
- UBYTE nPlanes;
- Masking masking;
- Compression compression;
- UBYTE pad1;
- UWORD transparentColor;
- UBYTE xAspect, yAspect;
- WORD pageWidth, pageHeight;
+ UWORD w, h;
+ WORD x, y;
+ UBYTE nPlanes;
+ Masking masking;
+ Compression compression;
+ UBYTE pad1;
+ UWORD transparentColor;
+ UBYTE xAspect, yAspect;
+ WORD pageWidth, pageHeight;
+ ULONG camgFlags;
} BitMapHeader;
/* Colors are in the range 0-255 */
diff --git a/requesters/filereq.c b/requesters/filereq.c
index cd02e30..81f6210 100644
--- a/requesters/filereq.c
+++ b/requesters/filereq.c
@@ -7,7 +7,6 @@
#include "filereq.h"
-#define REQ_TEXT_XOFFSET 10
#define REQ_WIDTH 240
#define REQ_HEIGHT 175
#define TOPAZ_BASELINE 8
@@ -21,19 +20,25 @@
#define OK_BUTTON_WIDTH 40
#define CANCEL_BUTTON_WIDTH 60
-#define STR_GADGET_X 90
-#define STR_GADGET_Y 120
-#define PATH_GADGET_WIDTH 100
+#define DRAWER_GADGET_X 80
+#define DRAWER_GADGET_Y 95
+#define FILE_GADGET_X 80
+#define FILE_GADGET_Y 115
+#define PATH_GADGET_WIDTH 120
+#define STR_LABEL_XOFFSET -70
+#define STR_LABEL_YOFFSET 2
static struct Requester requester;
static BOOL req_opened = FALSE;
static struct Window *req_window;
-static struct IntuiText labels[] = {
- {1, 0, JAM2, REQ_TEXT_XOFFSET, STR_GADGET_Y, NULL, "Enter file path", NULL},
- {1, 0, JAM2, 10, TOPAZ_BASELINE - 4, NULL, "Ok", NULL},
- {1, 0, JAM2, 10, TOPAZ_BASELINE - 4, NULL, "Cancel", NULL} /* TOPAZ_BASELINE is 8 */
-};
+static struct IntuiText drawer_str_label = {1, 0, JAM2, STR_LABEL_XOFFSET, STR_LABEL_YOFFSET, NULL,
+ "Drawer", NULL};
+static struct IntuiText file_str_label = {1, 0, JAM2, STR_LABEL_XOFFSET, STR_LABEL_YOFFSET, NULL,
+ "File", NULL};
+static struct IntuiText ok_button_label = {1, 0, JAM2, 10, TOPAZ_BASELINE - 4, NULL, "Ok", NULL};
+static struct IntuiText cancel_button_label = {1, 0, JAM2, 10, TOPAZ_BASELINE - 4, NULL,
+ "Cancel", NULL};
static WORD gadget_border_points[3][10] = {
{0, 0, OK_BUTTON_WIDTH, 0, OK_BUTTON_WIDTH, BUTTON_HEIGHT, 0, BUTTON_HEIGHT, 0, 0},
@@ -43,14 +48,14 @@ static WORD gadget_border_points[3][10] = {
{-2, -2, PATH_GADGET_WIDTH, -2, PATH_GADGET_WIDTH, 10, -2, 10, -2, -2}
};
-static struct Border gadget_borders[] = {
- {0, 0, 1, 0, JAM1, 5, gadget_border_points[0], NULL},
- {0, 0, 1, 0, JAM1, 5, gadget_border_points[1], NULL},
- {0, 0, 1, 0, JAM1, 5, gadget_border_points[2], NULL}
-};
+static struct Border ok_button_border = {0, 0, 1, 0, JAM1, 5, gadget_border_points[0], NULL};
+static struct Border cancel_button_border = {0, 0, 1, 0, JAM1, 5, gadget_border_points[1], NULL};
+static struct Border str_gadget_border = {0, 0, 1, 0, JAM1, 5, gadget_border_points[2], NULL};
-static UBYTE buffer[81], undobuffer[81];
-static struct StringInfo strinfo = {buffer, undobuffer, 0, 80, 0, 0, 0, 0, 0, 0, NULL, 0, NULL};
+static UBYTE buffer1[82], undobuffer1[82];
+static struct StringInfo strinfo1 = {buffer1, undobuffer1, 0, 80, 0, 0, 0, 0, 0, 0, NULL, 0, NULL};
+static UBYTE buffer2[82], undobuffer2[82];
+static struct StringInfo strinfo2 = {buffer2, undobuffer2, 0, 80, 0, 0, 0, 0, 0, 0, NULL, 0, NULL};
#define REQWIN_WIDTH 260
#define REQWIN_HEIGHT 180
@@ -58,8 +63,8 @@ static struct StringInfo strinfo = {buffer, undobuffer, 0, 80, 0, 0, 0, 0, 0, 0,
static struct NewWindow newwin = {
0, 0, REQWIN_WIDTH, REQWIN_HEIGHT, 0, 1,
- IDCMP_CLOSEWINDOW | IDCMP_GADGETUP,
- WFLG_CLOSEGADGET | WFLG_SMART_REFRESH | WFLG_ACTIVATE | WFLG_DRAGBAR | WFLG_DEPTHGADGET,
+ IDCMP_GADGETUP,
+ WFLG_CLOSEGADGET | WFLG_SMART_REFRESH | WFLG_ACTIVATE | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_NOCAREREFRESH,
NULL, NULL, WIN_TITLE,
NULL, NULL,
REQWIN_WIDTH, REQWIN_HEIGHT,
@@ -73,14 +78,17 @@ static struct NewWindow newwin = {
*/
static struct Gadget gadgets[] = {
{&gadgets[1], OK_BUTTON_X, BUTTON_Y, OK_BUTTON_WIDTH, BUTTON_HEIGHT, GFLG_GADGHCOMP,
- GACT_RELVERIFY, GTYP_BOOLGADGET | GTYP_REQGADGET, &gadget_borders[0], NULL,
- &labels[1], 0, NULL, REQ_OK_BUTTON_ID, NULL},
+ GACT_RELVERIFY, GTYP_BOOLGADGET | GTYP_REQGADGET, &ok_button_border, NULL,
+ &ok_button_label, 0, NULL, REQ_OK_BUTTON_ID, NULL},
{&gadgets[2], CANCEL_BUTTON_X, BUTTON_Y, CANCEL_BUTTON_WIDTH, BUTTON_HEIGHT, GFLG_GADGHCOMP,
- GACT_RELVERIFY, GTYP_BOOLGADGET | GTYP_REQGADGET, &gadget_borders[1], NULL,
- &labels[2], 0, NULL, REQ_CANCEL_BUTTON_ID, NULL},
- {NULL, STR_GADGET_X, STR_GADGET_Y, PATH_GADGET_WIDTH, 10,
- GFLG_GADGHCOMP, GACT_RELVERIFY, GTYP_STRGADGET, &gadget_borders[2], NULL,
- &labels[3], 0, &strinfo, 103, NULL},
+ GACT_RELVERIFY, GTYP_BOOLGADGET | GTYP_REQGADGET, &cancel_button_border, NULL,
+ &cancel_button_label, 0, NULL, REQ_CANCEL_BUTTON_ID, NULL},
+ {&gadgets[3], DRAWER_GADGET_X, DRAWER_GADGET_Y, PATH_GADGET_WIDTH, 10,
+ GFLG_GADGHCOMP, GACT_RELVERIFY, GTYP_STRGADGET, &str_gadget_border, NULL,
+ &drawer_str_label, 0, &strinfo1, 103, NULL},
+ {NULL, FILE_GADGET_X, FILE_GADGET_Y, PATH_GADGET_WIDTH, 10,
+ GFLG_GADGHCOMP, GACT_RELVERIFY, GTYP_STRGADGET, &str_gadget_border, NULL,
+ &file_str_label, 0, &strinfo2, 104, NULL},
};
#define PATHBUFFER_SIZE 200
@@ -100,9 +108,7 @@ static void print_fileinfo(struct FileInfoBlock *fileinfo)
static void close_requester()
{
- puts("close_requester()");
if (req_opened) {
- puts("EndRequest()");
EndRequest(&requester, req_window);
req_opened = FALSE;
}
@@ -121,12 +127,9 @@ static void handle_events()
if (msg = (struct IntuiMessage *) GetMsg(req_window->UserPort)) {
msgClass = msg->Class;
switch (msgClass) {
- case IDCMP_CLOSEWINDOW:
- close_requester();
- done = TRUE;
- break;
case IDCMP_GADGETUP:
buttonId = (int) ((struct Gadget *) (msg->IAddress))->GadgetID;
+ ReplyMsg((struct Message *) msg);
if (buttonId == REQ_OK_BUTTON_ID) {
close_requester();
done = TRUE;
@@ -139,7 +142,6 @@ static void handle_events()
default:
break;
}
- ReplyMsg((struct Message *) msg);
}
}
}
@@ -153,11 +155,11 @@ void open_file(struct Window *window)
requester.TopEdge = 20;
requester.Width = REQ_WIDTH;
requester.Height = REQ_HEIGHT;
- requester.Flags = 0;
+ requester.Flags = SIMPLEREQ;
requester.BackFill = 0;
requester.ReqGadget = &gadgets[0];
- requester.ReqBorder = NULL; // &req_border;
- requester.ReqText = &labels[0];
+ requester.ReqBorder = NULL;
+ requester.ReqText = NULL;
/* scan current directory */
/*
@@ -184,9 +186,7 @@ void open_file(struct Window *window)
UnLock(flock);
*/
if (req_opened = Request(&requester, req_window)) {
- puts("handle requester events...");
handle_events();
- puts("quit handling requester events");
CloseWindow(req_window);
req_window = NULL;
} else {
diff --git a/requesters/main.c b/requesters/main.c
index de30ea5..e3e76f4 100644
--- a/requesters/main.c
+++ b/requesters/main.c
@@ -85,12 +85,7 @@ static void cleanup()
static BOOL handle_menu(UWORD menuNum, UWORD itemNum, UWORD subItemNum)
{
- printf("menu, menu num: %d, item num: %d, sub item num: %d\n",
- (int) menuNum, (int) itemNum, (int) subItemNum);
- if (menuNum == FILE_MENU_NUM && itemNum == QUIT_MENU_ITEM_NUM) {
- /* quit */
- return TRUE;
- }
+ if (menuNum == FILE_MENU_NUM && itemNum == QUIT_MENU_ITEM_NUM) return TRUE;
if (menuNum == FILE_MENU_NUM && itemNum == OPEN_MENU_ITEM_NUM) {
open_file(window);
}
@@ -106,22 +101,21 @@ static void handle_events()
int buttonId;
while (!done) {
- puts("main, wait...");
Wait(1 << window->UserPort->mp_SigBit);
if (msg = (struct IntuiMessage *) GetMsg(window->UserPort)) {
msgClass = msg->Class;
+ menuCode = msg->Code;
+ ReplyMsg((struct Message *) msg);
switch (msgClass) {
case IDCMP_CLOSEWINDOW:
done = TRUE;
break;
case IDCMP_MENUPICK:
- menuCode = msg->Code;
done = handle_menu(MENUNUM(menuCode), ITEMNUM(menuCode), SUBNUM(menuCode));
break;
default:
break;
}
- ReplyMsg((struct Message *) msg);
}
}
}
@@ -172,7 +166,6 @@ int main(int argc, char **argv)
setup_menu();
handle_events();
}
- puts("main cleanup");
cleanup();
return 1;
}