Merge branch 'master' into next

This commit is contained in:
Alam Ed Arias 2016-07-21 18:49:33 -04:00
commit 5c234a817a
9 changed files with 107 additions and 51 deletions

View file

@ -189,6 +189,10 @@ ifdef FREEBSD
UNIXCOMMON=1 UNIXCOMMON=1
endif endif
ifdef MACOSX
UNIXCOMMON=1
endif
ifdef NDS ifdef NDS
NOPNG=1 NOPNG=1
NONET=1 NONET=1
@ -594,11 +598,15 @@ ifndef WINDOWSHELL
-$(GZIP) $(GZIP_OPT2) $(BIN)/$(DBGNAME).txt -$(GZIP) $(GZIP_OPT2) $(BIN)/$(DBGNAME).txt
endif endif
endif endif
# mac os x lsdlsrb2 does not like objcopy
ifndef MACOSX
ifndef PSP ifndef PSP
$(OBJCOPY) $(BIN)/$(EXENAME) $(BIN)/$(DBGNAME) $(OBJCOPY) $(BIN)/$(EXENAME) $(BIN)/$(DBGNAME)
$(OBJCOPY) --strip-debug $(BIN)/$(EXENAME) $(OBJCOPY) --strip-debug $(BIN)/$(EXENAME)
-$(OBJCOPY) --add-gnu-debuglink=$(BIN)/$(DBGNAME) $(BIN)/$(EXENAME) -$(OBJCOPY) --add-gnu-debuglink=$(BIN)/$(DBGNAME) $(BIN)/$(EXENAME)
endif endif
endif
ifndef NOUPX ifndef NOUPX
-$(UPX) $(UPX_OPTS) $(BIN)/$(EXENAME) -$(UPX) $(UPX_OPTS) $(BIN)/$(EXENAME)
endif endif
@ -746,6 +754,11 @@ $(OBJDIR)/%.o: %.c
$(OBJDIR)/%.o: $(INTERFACE)/%.c $(OBJDIR)/%.o: $(INTERFACE)/%.c
$(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@
ifdef MACOSX
$(OBJDIR)/%.o: sdl/macosx/%.c
$(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@
endif
$(OBJDIR)/%.o: hardware/%.c $(OBJDIR)/%.o: hardware/%.c
$(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@

View file

@ -406,6 +406,15 @@ else
WINDRES=windres WINDRES=windres
endif endif
# because Apple screws with us on this
# need to get bintools from homebrew
ifdef MACOSX
CC=clang
CXX=clang
OBJCOPY=gobjcopy
OBJDUMP=gobjdump
endif
OBJDUMP_OPTS?=--wide --source --line-numbers OBJDUMP_OPTS?=--wide --source --line-numbers
LD=$(CC) LD=$(CC)

View file

@ -92,7 +92,7 @@ typedef long ssize_t;
#endif #endif
#ifdef __APPLE_CC__ #ifdef __APPLE_CC__
#define DIRECTFULLSCREEN #define DIRECTFULLSCREEN 1
#define DEBUG_LOG #define DEBUG_LOG
#define NOIPX #define NOIPX
#endif #endif

View file

@ -874,9 +874,9 @@ void R_DrawTiltedSplat_8(void)
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
val = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]]; val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
*dest = val; *dest = colormap[val];
dest++; dest++;
iz += ds_sz.x; iz += ds_sz.x;
uz += ds_su.x; uz += ds_su.x;
@ -913,9 +913,9 @@ void R_DrawTiltedSplat_8(void)
for (i = SPANSIZE-1; i >= 0; i--) for (i = SPANSIZE-1; i >= 0; i--)
{ {
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
val = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]]; val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
*dest = val; *dest = colormap[val];
dest++; dest++;
u += stepu; u += stepu;
v += stepv; v += stepv;
@ -931,9 +931,9 @@ void R_DrawTiltedSplat_8(void)
u = (INT64)(startu); u = (INT64)(startu);
v = (INT64)(startv); v = (INT64)(startv);
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
val = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]]; val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
*dest = val; *dest = colormap[val];
} }
else else
{ {
@ -954,9 +954,9 @@ void R_DrawTiltedSplat_8(void)
for (; width != 0; width--) for (; width != 0; width--)
{ {
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
val = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]]; val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
*dest = val; *dest = colormap[val];
dest++; dest++;
u += stepu; u += stepu;
v += stepv; v += stepv;
@ -1124,49 +1124,49 @@ void R_DrawTranslucentSplat_8 (void)
// need! // need!
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
dest[0] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[0])]; dest[0] = colormap[*(ds_transmap + (val << 8) + dest[0])];
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
dest[1] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[1])]; dest[1] = colormap[*(ds_transmap + (val << 8) + dest[1])];
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
dest[2] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[2])]; dest[2] = colormap[*(ds_transmap + (val << 8) + dest[2])];
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
dest[3] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[3])]; dest[3] = colormap[*(ds_transmap + (val << 8) + dest[3])];
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
dest[4] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[4])]; dest[4] = colormap[*(ds_transmap + (val << 8) + dest[4])];
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
dest[5] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[5])]; dest[5] = colormap[*(ds_transmap + (val << 8) + dest[5])];
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
dest[6] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[6])]; dest[6] = colormap[*(ds_transmap + (val << 8) + dest[6])];
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
dest[7] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[7])]; dest[7] = colormap[*(ds_transmap + (val << 8) + dest[7])];
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
@ -1175,9 +1175,9 @@ void R_DrawTranslucentSplat_8 (void)
} }
while (count--) while (count--)
{ {
val =colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
*dest = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dest)]; *dest = colormap[*(ds_transmap + (val << 8) + *dest)];
dest++; dest++;
xposition += xstep; xposition += xstep;

View file

@ -919,9 +919,9 @@ void R_SkyboxFrame(player_t *player)
} }
} }
if (mh->skybox_scalez > 0) if (mh->skybox_scalez > 0)
viewz += player->awayviewmobj->z / mh->skybox_scalez; viewz += (player->awayviewmobj->z + 20*FRACUNIT) / mh->skybox_scalez;
else if (mh->skybox_scalez < 0) else if (mh->skybox_scalez < 0)
viewz += player->awayviewmobj->z * -mh->skybox_scalez; viewz += (player->awayviewmobj->z + 20*FRACUNIT) * -mh->skybox_scalez;
} }
else if (thiscam->chase) else if (thiscam->chase)
{ {
@ -966,9 +966,9 @@ void R_SkyboxFrame(player_t *player)
} }
} }
if (mh->skybox_scalez > 0) if (mh->skybox_scalez > 0)
viewz += thiscam->z / mh->skybox_scalez; viewz += (thiscam->z + (thiscam->height>>1)) / mh->skybox_scalez;
else if (mh->skybox_scalez < 0) else if (mh->skybox_scalez < 0)
viewz += thiscam->z * -mh->skybox_scalez; viewz += (thiscam->z + (thiscam->height>>1)) * -mh->skybox_scalez;
} }
else else
{ {

View file

@ -1488,7 +1488,7 @@ static void R_RenderSegLoop (void)
{ {
// note: don't use min/max macros, since casting from INT32 to INT16 is involved here // note: don't use min/max macros, since casting from INT32 to INT16 is involved here
if (markceiling) if (markceiling)
ceilingclip[rw_x] = (yh >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; ceilingclip[rw_x] = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1;
if (markfloor) if (markfloor)
floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight; floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight;
} }
@ -1523,10 +1523,10 @@ static void R_RenderSegLoop (void)
ceilingclip[rw_x] = -1; ceilingclip[rw_x] = -1;
} }
else else
ceilingclip[rw_x] = (yh >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; ceilingclip[rw_x] = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1;
} }
else if (markceiling) // no top wall else if (markceiling) // no top wall
ceilingclip[rw_x] = (yh >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1; ceilingclip[rw_x] = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1;
if (bottomtexture) if (bottomtexture)
{ {

View file

@ -56,6 +56,15 @@ ifdef FREEBSD
LIBS+=-lipx -lkvm LIBS+=-lipx -lkvm
endif endif
#
#here is Mac OS X
#
ifdef MACOSX
OBJS+=$(OBJDIR)/mac_resources.o
OBJS+=$(OBJDIR)/mac_alert.o
LIBS+=-framework CoreFoundation
endif
# #
#here is GP2x (arm-gp2x-linux) #here is GP2x (arm-gp2x-linux)
# #

View file

@ -25,19 +25,38 @@
#include "mac_alert.h" #include "mac_alert.h"
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#define CFSTRINGIFY(x) CFStringCreateWithCString(NULL, x, kCFStringEncodingASCII)
int MacShowAlert(const char *title, const char *message, const char *button1, const char *button2, const char *button3) int MacShowAlert(const char *title, const char *message, const char *button1, const char *button2, const char *button3)
{ {
CFOptionFlags results; CFOptionFlags results;
CFUserNotificationDisplayAlert(0, CFStringRef cf_title = CFSTRINGIFY(title);
kCFUserNotificationStopAlertLevel | kCFUserNotificationNoDefaultButtonFlag, CFStringRef cf_message = CFSTRINGIFY(message);
NULL, NULL, NULL, CFStringRef cf_button1 = NULL;
CFStringCreateWithCString(NULL, title, kCFStringEncodingASCII), CFStringRef cf_button2 = NULL;
CFStringCreateWithCString(NULL, message, kCFStringEncodingASCII), CFStringRef cf_button3 = NULL;
button1 != NULL ? CFStringCreateWithCString(NULL, button1, kCFStringEncodingASCII) : NULL,
button2 != NULL ? CFStringCreateWithCString(NULL, button2, kCFStringEncodingASCII) : NULL, if (button1 != NULL)
button3 != NULL ? CFStringCreateWithCString(NULL, button3, kCFStringEncodingASCII) : NULL, cf_button1 = CFSTRINGIFY(button1);
&results); if (button2 != NULL)
cf_button2 = CFSTRINGIFY(button2);
if (button3 != NULL)
cf_button3 = CFSTRINGIFY(button3);
CFOptionFlags alert_flags = kCFUserNotificationStopAlertLevel | kCFUserNotificationNoDefaultButtonFlag;
CFUserNotificationDisplayAlert(0, alert_flags, NULL, NULL, NULL, cf_title, cf_message,
cf_button1, cf_button2, cf_button3, &results);
if (cf_button1 != NULL)
CFRelease(cf_button1);
if (cf_button2 != NULL)
CFRelease(cf_button2);
if (cf_button3 != NULL)
CFRelease(cf_button3);
CFRelease(cf_message);
CFRelease(cf_title);
return (int)results; return (int)results;
} }

View file

@ -9,23 +9,29 @@ void OSX_GetResourcesPath(char * buffer)
mainBundle = CFBundleGetMainBundle(); mainBundle = CFBundleGetMainBundle();
if (mainBundle) if (mainBundle)
{ {
const int BUF_SIZE = 256; // because we somehow always know that
CFURLRef appUrlRef = CFBundleCopyBundleURL(mainBundle); CFURLRef appUrlRef = CFBundleCopyBundleURL(mainBundle);
CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle); CFStringRef macPath;
CFStringRef resources = CFStringCreateWithCString(kCFAllocatorMalloc, "/Contents/Resources", kCFStringEncodingASCII); if (appUrlRef != NULL)
const void* rawarray[2] = {macPath, resources}; macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle);
CFArrayRef array = CFArrayCreate(kCFAllocatorMalloc, rawarray, 2, NULL); else
CFStringRef separator = CFStringCreateWithCString(kCFAllocatorMalloc, "", kCFStringEncodingASCII); macPath = NULL;
CFStringRef fullPath = CFStringCreateByCombiningStrings(kCFAllocatorMalloc, array, separator);
const char * path = CFStringGetCStringPtr(fullPath, kCFStringEncodingASCII); const char* rawPath;
strcpy(buffer, path);
CFRelease(fullPath); if (macPath != NULL)
path = NULL; rawPath = CFStringGetCStringPtr(macPath, kCFStringEncodingASCII);
CFRelease(array); else
CFRelease(resources); rawPath = NULL;
if (rawPath != NULL && (CFStringGetLength(macPath) + strlen("/Contents/Resources") < BUF_SIZE))
{
strcpy(buffer, rawPath);
strcat(buffer, "/Contents/Resources");
}
CFRelease(macPath); CFRelease(macPath);
CFRelease(appUrlRef); CFRelease(appUrlRef);
//CFRelease(mainBundle);
CFRelease(separator);
} }
} }