summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2015-01-18 21:11:00 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2015-01-18 21:11:00 +0000
commit2eb41ed77b2deb3a1c54c7b6b94a7c31fb603714 (patch)
tree1c93c241db79a2646e701a932a592a2f1b8b5fa4
parentd6052d3955ffa1aca81c3363b7c53aec51cb6208 (diff)
downloadnetsurf-2eb41ed77b2deb3a1c54c7b6b94a7c31fb603714.tar.gz
netsurf-2eb41ed77b2deb3a1c54c7b6b94a7c31fb603714.tar.bz2
More OS3 fixes
-rw-r--r--amiga/libs.c23
-rwxr-xr-xamiga/login.c3
-rw-r--r--amiga/menu.c24
-rwxr-xr-xamiga/misc.c11
-rwxr-xr-xamiga/object.c5
-rw-r--r--amiga/os3support.c11
-rw-r--r--amiga/os3support.h15
-rwxr-xr-xamiga/plotters.c23
8 files changed, 98 insertions, 17 deletions
diff --git a/amiga/libs.c b/amiga/libs.c
index ec41ee22e..7810fad6e 100644
--- a/amiga/libs.c
+++ b/amiga/libs.c
@@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "amiga/os3support.h"
+
#include "amiga/libs.h"
#include "amiga/misc.h"
#include "utils/utils.h"
@@ -24,6 +26,7 @@
#include <proto/exec.h>
#include <proto/utility.h>
+#ifdef __amigaos4__
#define AMINS_LIB_OPEN(LIB, LIBVER, PREFIX, INTERFACE, INTVER, FAIL) \
LOG(("Opening %s v%d", LIB, LIBVER)); \
if((PREFIX##Base = OpenLibrary(LIB, LIBVER))) { \
@@ -48,6 +51,26 @@
#define AMINS_LIB_STRUCT(PREFIX) \
struct Library *PREFIX##Base; \
struct PREFIX##IFace *I##PREFIX;
+#else
+#define AMINS_LIB_OPEN(LIB, LIBVER, PREFIX, INTERFACE, INTVER, FAIL) \
+ LOG(("Opening %s v%d", LIB, LIBVER)); \
+ if((PREFIX##Base = OpenLibrary(LIB, LIBVER))) { \
+ } else { \
+ LOG(("Failed to open %s v%d", LIB, LIBVER)); \
+ if(FAIL == true) { \
+ STRPTR error = ASPrintf("Unable to open %s v%d", LIB, LIBVER); \
+ ami_misc_fatal_error(error); \
+ FreeVec(error); \
+ return false; \
+ } \
+ }
+
+#define AMINS_LIB_CLOSE(PREFIX) \
+ if(PREFIX##Base) CloseLibrary(PREFIX##Base);
+
+#define AMINS_LIB_STRUCT(PREFIX) \
+ struct Library *PREFIX##Base;
+#endif
#define GraphicsBase GfxBase /* graphics.library is a bit weird */
diff --git a/amiga/login.c b/amiga/login.c
index e9e221bbc..fe476acc1 100755
--- a/amiga/login.c
+++ b/amiga/login.c
@@ -61,8 +61,7 @@ void gui_401login_open(nsurl *url, const char *realm,
nserror (*cb)(bool proceed, void *pw), void *cbpw)
{
const char *auth;
- struct gui_login_window *lw = AllocVecTags(sizeof(struct gui_login_window),
- AVT_ClearWithValue, 0, TAG_DONE);
+ struct gui_login_window *lw = ami_misc_allocvec_clear(sizeof(struct gui_login_window), 0);
lwc_string *host = nsurl_get_component(url, NSURL_HOST);
assert(host != NULL);
diff --git a/amiga/menu.c b/amiga/menu.c
index 3eb8a9846..e5d35a974 100644
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "amiga/os3support.h"
+
#include <string.h>
#include <proto/dos.h>
@@ -196,7 +198,7 @@ static void ami_init_menulabs(struct gui_window_2 *gwin)
{
int i;
- gwin->menutype = AllocVecTags(AMI_MENU_AREXX_MAX + 1, AVT_ClearWithValue, 0, TAG_DONE);
+ gwin->menutype = ami_misc_allocvec_clear(AMI_MENU_AREXX_MAX + 1, 0);
for(i=0;i <= AMI_MENU_AREXX_MAX;i++)
{
@@ -333,6 +335,7 @@ void ami_menu_refresh(struct gui_window_2 *gwin)
static void ami_menu_load_glyphs(struct DrawInfo *dri)
{
+#ifdef __amigaos4__
for(int i = 0; i < NSA_GLYPH_MAX; i++)
menu_glyph[i] = NULL;
@@ -350,10 +353,12 @@ static void ami_menu_load_glyphs(struct DrawInfo *dri)
(ULONG *)&menu_glyph_width[NSA_GLYPH_AMIGAKEY]);
menu_glyphs_loaded = true;
+#endif
}
void ami_menu_free_glyphs(void)
{
+#ifdef __amigaos4__
int i;
if(menu_glyphs_loaded == false) return;
@@ -363,6 +368,7 @@ void ami_menu_free_glyphs(void)
};
menu_glyphs_loaded = false;
+#endif
}
static int ami_menu_calc_item_width(struct gui_window_2 *gwin, int j, struct RastPort *rp)
@@ -413,7 +419,7 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
j++;
} while((gwin->menutype[j] != NM_TITLE) && (gwin->menutype[j] != 0));
}
-
+#ifdef __amigaos4__
if(LIB_IS_AT_LEAST((struct Library *)GadToolsBase, 53, 6)) {
/* GadTools 53.6+ only. For now we will only create the menu
using label.image if there's a bitmap associated with the item. */
@@ -495,7 +501,7 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
if(gwin->menuobj[i]) gwin->menutype[i] |= MENU_IMAGE;
}
}
-
+#endif
gwin->menu[i].nm_Type = gwin->menutype[i];
if(gwin->menuobj[i])
@@ -520,8 +526,7 @@ static struct gui_window_2 *ami_menu_layout(struct gui_window_2 *gwin)
struct NewMenu *ami_create_menu(struct gui_window_2 *gwin)
{
- gwin->menu = AllocVecTags(sizeof(struct NewMenu) * (AMI_MENU_AREXX_MAX + 1),
- AVT_ClearWithValue, 0, TAG_DONE);
+ gwin->menu = ami_misc_allocvec_clear(sizeof(struct NewMenu) * (AMI_MENU_AREXX_MAX + 1), 0);
ami_init_menulabs(gwin);
ami_menu_scan(ami_tree_get_tree(hotlist_window), gwin);
ami_menu_arexx_scan(gwin);
@@ -835,7 +840,7 @@ static void ami_menu_item_project_about(struct Hook *hook, APTR window, struct I
temp2 = ami_utf8_easy(temp);
FreeVec(temp);
-
+#ifdef __amigaos4__
sel = TimedDosRequesterTags(TDR_ImageType,TDRIMAGE_INFO,
TDR_TitleString, messages_get("NetSurf"),
TDR_Window, gwin->win,
@@ -844,7 +849,12 @@ static void ami_menu_item_project_about(struct Hook *hook, APTR window, struct I
TDR_Arg1,netsurf_version,
TDR_Arg2,verdate,
TAG_DONE);
-
+#else
+ /*\todo proper requester for OS3
+ * at the moment menus are disabled so won't get here anyway */
+ printf("NetSurf %s\nBuild date %s\n", netsurf_version, verdate);
+ sel = 0;
+#endif
free(temp2);
if(sel == 2) {
diff --git a/amiga/misc.c b/amiga/misc.c
index 0cd3baedd..73a87e78d 100755
--- a/amiga/misc.c
+++ b/amiga/misc.c
@@ -52,7 +52,7 @@ static LONG ami_misc_req(const char *message, uint32 type)
LONG ret = 0;
LOG(("%s", message));
-
+#ifdef __amigaos4__
ret = TimedDosRequesterTags(
TDR_TitleString, messages_get("NetSurf"),
TDR_FormatString, message,
@@ -60,7 +60,9 @@ static LONG ami_misc_req(const char *message, uint32 type)
TDR_ImageType, type,
TDR_Window, cur_gw ? cur_gw->shared->win : NULL,
TAG_DONE);
-
+#else
+ printf("%s\n", message);
+#endif
return ret;
}
@@ -84,6 +86,7 @@ void warn_user(const char *warning, const char *detail)
int32 ami_warn_user_multi(const char *body, const char *opt1, const char *opt2, struct Window *win)
{
int res = 0;
+#ifdef __amigaos4__
char *utf8text = ami_utf8_easy(body);
char *utf8gadget1 = ami_utf8_easy(messages_get(opt1));
char *utf8gadget2 = ami_utf8_easy(messages_get(opt2));
@@ -100,7 +103,9 @@ int32 ami_warn_user_multi(const char *body, const char *opt1, const char *opt2,
if(utf8text) free(utf8text);
if(utf8gadgets) FreeVec(utf8gadgets);
-
+#else
+#warning write this for os3
+#endif
return res;
}
diff --git a/amiga/object.c b/amiga/object.c
index 0c848aa5f..99f359ad1 100755
--- a/amiga/object.c
+++ b/amiga/object.c
@@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "amiga/os3support.h"
+
#include <stdlib.h>
#include <proto/exec.h>
@@ -24,6 +26,7 @@
#include "amiga/filetype.h"
#include "amiga/font.h"
+#include "amiga/misc.h"
#include "amiga/object.h"
struct MinList *NewObjList(void)
@@ -43,7 +46,7 @@ struct nsObject *AddObject(struct MinList *objlist, ULONG otype)
{
struct nsObject *dtzo;
- dtzo = (struct nsObject *)AllocVecTags(sizeof(struct nsObject), AVT_ClearWithValue, 0, TAG_DONE);
+ dtzo = (struct nsObject *)ami_misc_allocvec_clear(sizeof(struct nsObject), 0);
AddTail((struct List *)objlist,(struct Node *)dtzo);
diff --git a/amiga/os3support.c b/amiga/os3support.c
index cc567f641..dda3df31e 100644
--- a/amiga/os3support.c
+++ b/amiga/os3support.c
@@ -23,6 +23,17 @@
#ifndef __amigaos4__
#include "os3support.h"
+#include <inttypes.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <proto/exec.h>
+#include <proto/intuition.h>
+#include <proto/dos.h>
+
+#define SUCCESS (TRUE)
+#define FAILURE (FALSE)
+#define NO !
+
/* DOS */
int64 GetFileSize(BPTR fh)
{
diff --git a/amiga/os3support.h b/amiga/os3support.h
index 5fb113466..93bb0ba11 100644
--- a/amiga/os3support.h
+++ b/amiga/os3support.h
@@ -37,6 +37,14 @@
#include <exec/memory.h>
#endif
+#ifndef ASM
+#define ASM
+#endif
+
+#ifndef REG
+#define REG(reg,arg) arg __asm(#reg)
+#endif
+
/* Macros */
#define IsMinListEmpty(L) (L)->mlh_Head->mln_Succ == 0
@@ -93,6 +101,7 @@
#define IDCMP_EXTENDEDMOUSE 0
#define WINDOW_BACKMOST 0
#define DN_FULLPATH 0
+#define BGBACKFILL JAM1
/* Renamed structures */
#define AnchorPathOld AnchorPath
@@ -183,6 +192,12 @@ enum {
ASOT_PORT = 1
};
+/* Requester types */
+enum {
+ TDRIMAGE_ERROR = 1,
+ TDRIMAGE_WARNING
+};
+
/* Functions */
/* DOS */
int64 GetFileSize(BPTR fh);
diff --git a/amiga/plotters.c b/amiga/plotters.c
index 855d10497..490d51955 100755
--- a/amiga/plotters.c
+++ b/amiga/plotters.c
@@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "amiga/os3support.h"
+
#include <proto/Picasso96API.h>
#include <proto/exec.h>
#include <proto/intuition.h>
@@ -46,7 +48,9 @@
#include "amiga/gui.h"
#include "amiga/utf8.h"
+#ifdef __amigaos4__
static void ami_bitmap_tile_hook(struct Hook *hook,struct RastPort *rp,struct BackFillMessage *bfmsg);
+#endif
struct bfbitmap {
struct BitMap *bm;
@@ -138,7 +142,6 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height)
InitRastPort(gg->rp);
gg->rp->BitMap = gg->bm;
- /* Is all this safe to do to an existing window RastPort? */
SetDrMd(gg->rp,BGBACKFILL);
gg->rp->Layer = CreateUpfrontLayer(gg->layerinfo,gg->rp->BitMap,0,0,
@@ -232,9 +235,11 @@ void ami_plot_release_pens(struct MinList *shared_pens)
static void ami_plot_setapen(ULONG colr)
{
if(palette_mapped == false) {
+#ifdef __amigaos4__
SetRPAttrs(glob->rp, RPTAG_APenColor,
ns_color_to_nscss(colr),
TAG_DONE);
+#endif
} else {
LONG pen = ami_plot_obtain_pen(glob->shared_pens, colr);
if(pen != -1) SetAPen(glob->rp, pen);
@@ -244,9 +249,11 @@ static void ami_plot_setapen(ULONG colr)
static void ami_plot_setopen(ULONG colr)
{
if(palette_mapped == false) {
+#ifdef __amigaos4__
SetRPAttrs(glob->rp, RPTAG_OPenColor,
ns_color_to_nscss(colr),
TAG_DONE);
+#endif
} else {
LONG pen = ami_plot_obtain_pen(glob->shared_pens, colr);
if(pen != -1) SetOPen(glob->rp, pen);
@@ -521,7 +528,7 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma
if((tag_data = (ULONG)ami_bitmap_get_mask(bitmap, width, height, tbm)))
minterm = (ABC|ABNC|ANBC);
}
-
+#ifdef __amigaos4__
BltBitMapTags(BLITA_Width,width,
BLITA_Height,height,
BLITA_Source,tbm,
@@ -533,6 +540,10 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma
BLITA_Minterm, minterm,
tag, tag_data,
TAG_DONE);
+#else
+ /* Assume mask is always required */
+ BltMaskBitMapRastPort(tbm, 0, 0, glob->rp, x, y, width, height, tag_data, minterm);
+#endif
}
if((bitmap->dto == NULL) && (tbm != bitmap->nativebm))
@@ -562,7 +573,7 @@ bool ami_bitmap_tile(int x, int y, int width, int height,
if(!(repeat_x || repeat_y))
return ami_bitmap(x, y, width, height, bitmap);
-
+#ifdef __amigaos4__
/* If it is a one pixel transparent image, we are wasting our time */
if((bitmap->opaque == false) && (bitmap->width == 1) && (bitmap->height == 1))
return true;
@@ -641,10 +652,13 @@ bool ami_bitmap_tile(int x, int y, int width, int height,
{
p96FreeBitMap(tbm);
}
-
+#else
+#warning FIXME: bitmap tiling uses backfill hooks
+#endif
return true;
}
+#ifdef __amigaos4__
static void ami_bitmap_tile_hook(struct Hook *hook,struct RastPort *rp,struct BackFillMessage *bfmsg)
{
int xf,yf;
@@ -700,6 +714,7 @@ static void ami_bitmap_tile_hook(struct Hook *hook,struct RastPort *rp,struct Ba
}
}
}
+#endif
bool ami_group_start(const char *name)
{