From b4ed097fad7abf5afcd5abad0d86d0858f5cb27f Mon Sep 17 00:00:00 2001 From: Wei-ju Wu Date: Fri, 5 Feb 2016 20:52:36 -0800 Subject: [PATCH] startup and file requester change - hardware startup: added copper macros - file requester: add blocking requester for parent window --- hardware/startup.c | 41 ++++++++++++++++++++++++----------------- requesters/filereq.c | 31 ++++++++++++++++++++++++++++--- requesters/main.c | 4 ++-- utils/jpg2ham6 | 10 ++++++++++ 4 files changed, 64 insertions(+), 22 deletions(-) create mode 100755 utils/jpg2ham6 diff --git a/hardware/startup.c b/hardware/startup.c index b123cab..de7956a 100644 --- a/hardware/startup.c +++ b/hardware/startup.c @@ -30,26 +30,33 @@ void waitmouse() = "waitmouse:\n\tbtst\t#6,$bfe001\n\tbne\twaitmouse"; #define VFREQ_PAL 50 #define WB_SCREEN_NAME "Workbench" +#define BPLCON0 0x100 +#define COLOR00 0x180 + +#define BPLCON0_COLOR (1 << 9) + +#define COP_MOVE(addr, data) addr, data +#define COP_WAIT_END 0xffff, 0xfffe + static UWORD __chip coplist_pal[] = { - 0x100, 0x200, // otherwise no display! - 0x180, 0x00, - 0x8107, 0xfffe, // wait for $8107,$fffe - 0x180, - 0xf0f, // background red - 0xd607, 0xfffe, // wait for $d607,$fffe - 0x180, 0xff0, // background yellow - 0xffff, 0xfffe, - 0xffff, 0xfffe + COP_MOVE(BPLCON0, BPLCON0_COLOR), + COP_MOVE(COLOR00, 0x000), + 0x8107, 0xfffe, // wait for $8107,$fffe + COP_MOVE(COLOR00, 0xf00), + 0xd607, 0xfffe, // wait for $d607,$fffe + COP_MOVE(COLOR00, 0xff0), + COP_WAIT_END, + COP_WAIT_END }; static UWORD __chip coplist_ntsc[] = { - 0x100, 0x0200, // otherwise no display! - 0x180, 0x00, - 0x6e07, 0xfffe, // wait for $6e07,$fffe - 0x180, 0xf00, // background red - 0xb007, 0xfffe, // wait for $b007,$fffe - 0x180, 0xff0, // background yellow - 0xffff, 0xfffe, - 0xffff, 0xfffe + COP_MOVE(BPLCON0, BPLCON0_COLOR), + COP_MOVE(COLOR00, 0x000), + 0x6e07, 0xfffe, // wait for $6e07,$fffe + COP_MOVE(COLOR00, 0xf00), + 0xb007, 0xfffe, // wait for $b007,$fffe + COP_MOVE(COLOR00, 0xff0), + COP_WAIT_END, + COP_WAIT_END }; static struct Screen *wbscreen; diff --git a/requesters/filereq.c b/requesters/filereq.c index a5c29be..2f04e70 100644 --- a/requesters/filereq.c +++ b/requesters/filereq.c @@ -1,10 +1,12 @@ #include #include +#include #include #include #include #include +#include #include #include @@ -87,6 +89,9 @@ enum { LIST_UP_ID, LIST_DOWN_ID } GadgetIDs; +// This requester's purpose is simply to block the parent window's input +static struct Requester block_requester; + static struct Requester requester; static BOOL req_opened = FALSE; static struct Window *req_window; @@ -149,7 +154,7 @@ static struct PropInfo propinfo = {AUTOKNOB | FREEVERT, 0, 0, MAXBODY, MAXBODY, static struct NewWindow newwin = { 0, 0, 0, REQWIN_HEIGHT, 0, 1, IDCMP_GADGETUP | IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE, - WFLG_CLOSEGADGET | WFLG_SMART_REFRESH | WFLG_ACTIVATE | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_NOCAREREFRESH, + WFLG_CLOSEGADGET | WFLG_ACTIVATE | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_SIMPLE_REFRESH | WFLG_NOCAREREFRESH, NULL, NULL, WIN_TITLE, NULL, NULL, 0, REQWIN_HEIGHT, @@ -275,9 +280,11 @@ int vertpot2entry(int vertpot) static void render_list_backbuffer() { + LockLayer(0L, requester.ReqLayer); ClipBlit(&filelist_rastport, 0, 0, requester.ReqLayer->rp, FILE_LIST_BM_MARGIN, FILE_LIST_BM_MARGIN, filelist_bm_width, filelist_bm_height, 0xc0); + UnlockLayer(requester.ReqLayer); } static void draw_selection(struct RastPort *src_rp, int view_index) @@ -317,7 +324,6 @@ static void draw_list() // layer's rastport, because it is rendered on top of the // parent window and obscures the content struct RastPort *src_rp = &filelist_rastport; - struct RastPort *dst_rp = requester.ReqLayer->rp; // make sure drawing is clipped, otherwise it will // draw somewhere else into memory @@ -589,7 +595,7 @@ void init_sizes(struct Window *window, struct Requester *requester) requester->ReqText = NULL; } -void open_file(struct Window *window) +static void open_request_window(struct Window *window) { InitRequester(&requester); init_sizes(window, &requester); @@ -622,3 +628,22 @@ void open_file(struct Window *window) puts("OpenWindow() failed !!!"); } } + +void open_file(struct Window *window) +{ + InitRequester(&block_requester); + // note that the Request() call fails, when everything is set to 0, + // contrary to the docs. + block_requester.Width = 1; + block_requester.Height = 1; + block_requester.LeftEdge = REQ_HMARGIN; + block_requester.TopEdge = REQ_VMARGIN; + + if (Request(&block_requester, window)) { + printf("top request opened\n"); + open_request_window(window); + EndRequest(&block_requester, window); + } else { + printf("top request failed\n"); + } +} diff --git a/requesters/main.c b/requesters/main.c index ecd9b0f..41ea554 100644 --- a/requesters/main.c +++ b/requesters/main.c @@ -48,8 +48,8 @@ static struct NewWindow newwin = { WIN_LEFT, WIN_TOP, WIN_WIDTH, WIN_HEIGHT, 0, 1, - IDCMP_CLOSEWINDOW | IDCMP_MENUPICK | IDCMP_GADGETUP | IDCMP_REQCLEAR, - WINDOWCLOSE | SMART_REFRESH | ACTIVATE | WINDOWSIZING | WINDOWDRAG | WINDOWDEPTH, + IDCMP_CLOSEWINDOW | IDCMP_MENUPICK | IDCMP_GADGETUP, + WFLG_CLOSEGADGET | WFLG_SIMPLE_REFRESH | WFLG_ACTIVATE | WFLG_SIZEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_NOCAREREFRESH, NULL, NULL, WIN_TITLE, NULL, NULL, WIN_MIN_WIDTH, WIN_MIN_HEIGHT, diff --git a/utils/jpg2ham6 b/utils/jpg2ham6 new file mode 100755 index 0000000..a107beb --- /dev/null +++ b/utils/jpg2ham6 @@ -0,0 +1,10 @@ +#!/bin/bash + +# jpg2ham6 - a tool to convert jpg images to HAM6 IFF/ILBM +# requires Netpbm + +if [ "$#" -ne 2 ]; then + echo "Usage: $0 " +else + jpegtopnm $1 | ppmtoilbm -ham6 -ecs > $2 +fi