#
FIND = find
+FINDSDL2 := $(shell which $(CROSS)sdl2-config 2> /dev/null)
# Figure out which system we're compiling for, and set the appropriate variables
-ifeq "$(OSTYPE)" "msys" # Win32
+ifeq "$(CROSS)" ""
+OSTYPE := $(shell uname -a)
+
+# Win32
+ifeq "$(findstring Msys,$(OSTYPE))" "Msys"
SYSTYPE = __GCCWIN32__
EXESUFFIX = .exe
SDLLIBTYPE = --libs
MSG = Win32 on MinGW
-else
-#ifeq "$(OSTYPE)" "darwin"
-ifeq "darwin" "$(findstring darwin,$(OSTYPE))" # Should catch both 'darwin' and 'darwin7.0'
+# Should catch both 'darwin' and 'darwin7.0'
+else ifeq "$(findstring Darwin,$(OSTYPE))" "Darwin"
SYSTYPE = __GCCUNIX__ -D_OSX_
EXESUFFIX =
SDLLIBTYPE = --static-libs
MSG = Mac OS X
-else # *nix
+# *nix
+else ifeq "$(findstring Linux,$(OSTYPE))" "Linux"
SYSTYPE = __GCCUNIX__
EXESUFFIX =
SDLLIBTYPE = --libs
MSG = generic Unix/Linux
+# Throw error, unknown OS
+else
+
+$(error OS TYPE UNDETECTED)
+
endif
+# Cross compile using MXE under Linux host
+else
+
+SYSTYPE = __GCCWIN32__
+EXESUFFIX = .exe
+ICON = obj/icon.o
+SDLLIBTYPE = --libs
+MSG = Win32 under MXE (cross compile)
+
endif
-CC = gcc
-LD = gcc
+CC = $(CROSS)gcc
+LD = $(CROSS)gcc
TARGET = apple2
+SDL_CFLAGS = `$(CROSS)sdl2-config --cflags`
+SDL_LIBS = `$(CROSS)sdl2-config $(SDLLIBTYPE)`
+DEFINES = -D$(SYSTYPE)
+GCC_DEPS = -MMD
+
# Note that we use optimization level 2 instead of 3--3 doesn't seem to gain much over 2
#CFLAGS = -MMD -Wall -Wno-switch -O2 -D$(SYSTYPE) -ffast-math -fomit-frame-pointer `sdl2-config --cflags`
#CPPFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -O2 -D$(SYSTYPE) \
#CPPFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -D$(SYSTYPE) \
# -ffast-math -fomit-frame-pointer `sdl2-config --cflags` -fprofile-arcs -ftest-coverage
# No optimization for profiling with gprof...
-CFLAGS = -MMD -Wall -Wno-switch -D$(SYSTYPE) \
- -ffast-math `sdl2-config --cflags` -pg -g
-CPPFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -D$(SYSTYPE) \
- -ffast-math `sdl2-config --cflags` -pg -g
+#CFLAGS = -MMD -Wall -Wno-switch -D$(SYSTYPE) \
+# -ffast-math `sdl2-config --cflags` -pg -g
+#CPPFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -D$(SYSTYPE) \
+# -ffast-math `sdl2-config --cflags` -pg -g
# -fomit-frame-pointer `sdl2-config --cflags` -g
# -fomit-frame-pointer `sdl2-config --cflags` -DLOG_UNMAPPED_MEMORY_ACCESSES
+CFLAGS = $(GCC_DEPS) -Wall -Wno-switch $(DEFINES) -ffast-math $(SDL_CFLAGS) -pg -g
+CPPFLAGS = $(GCC_DEPS) -Wall -Wno-switch -Wno-non-virtual-dtor $(DEFINES) \
+ -ffast-math $(SDL_CFLAGS) -pg -g
LDFLAGS =
# Link in the gcov library (for profiling purposes)
#LIBS = -L/usr/local/lib -L/usr/lib `sdl2-config $(SDLLIBTYPE)` -lstdc++ -lz $(GLLIB) -lgcov
# Link in the gprof lib
-LIBS = -L/usr/local/lib -L/usr/lib `sdl2-config $(SDLLIBTYPE)` -lstdc++ -lz $(GLLIB) -pg
+#LIBS = -L/usr/local/lib -L/usr/lib `sdl2-config $(SDLLIBTYPE)` -lstdc++ -lz $(GLLIB) -pg
+LIBS = -L/usr/local/lib -L/usr/lib $(SDL_LIBS) -lstdc++ -lz $(GLLIB) -pg
-INCS = -I. -I./src -I/usr/local/include -I/usr/include
+#INCS = -I. -I./src -I/usr/local/include -I/usr/include
+INCS = -I. -I./src
OBJS = \
obj/button.o \
checkenv:
@echo
@echo -en "\033[01;33m***\033[00;32m Checking compilation environment... \033[00m"
-ifeq "" "$(shell which sdl2-config)"
+ifeq "$(FINDSDL2)" ""
@echo
@echo
- @echo -e "\033[01;33mIt seems that you don't have the SDL 2 development libraries installed.
+ @echo -e "\033[01;33mIt seems that you don't have the SDL 2 development libraries installed. If you"
@echo -e "have installed them, make sure that the sdl2-config file is somewhere in your"
@echo -e "path and is executable.\033[00m"
@echo
#Is there a better way to break out of the makefile?
- @break
+ @false;
+# @break
+# YES! But ignores all the echo's above... :-/
+#$(error SDL2 MISSING)
+
else
@echo -e "\033[01;37mOK\033[00m"
endif
ifneq "" "$(ICON)"
$(ICON): res/$(TARGET).rc res/$(TARGET).ico
@echo -e "\033[01;33m***\033[00;32m Processing icon...\033[00m"
- @windres -i res/$(TARGET).rc -o $(ICON) --include-dir=./res
+ @$(CROSS)windres -i res/$(TARGET).rc -o $(ICON) --include-dir=./res
endif
obj/%.o: src/%.c
void GUI2::Init(SDL_Renderer * renderer)
{
-// overlay = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888,
-// SDL_TEXTUREACCESS_STREAMING, 128, 256);
overlay = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888,
SDL_TEXTUREACCESS_TARGET, 128, 380);
if (SDL_SetTextureBlendMode(overlay, SDL_BLENDMODE_BLEND) == -1)
WriteLog("GUI: Could not set blend mode for overlay.\n");
-// uint32_t * texturePointer = (uint32_t *)scrBuffer;
-
for(uint32_t i=0; i<128*380; i++)
- texturePointer[i] = 0xA0A000A0;
+ texturePointer[i] = 0xB0A000A0;
SDL_UpdateTexture(overlay, NULL, texturePointer, 128 * sizeof(Uint32));
-// olSrc.x = olSrc.y = 0;
-// olSrc.w = 128;
-// olSrc.h = 380;
olDst.x = VIRTUAL_SCREEN_WIDTH;
olDst.y = 2;
olDst.w = 128;
olDst.h = 380;
- iconSelection = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888,
- SDL_TEXTUREACCESS_STATIC, 54, 54);
- disk1Icon = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888,
- SDL_TEXTUREACCESS_STATIC, 40, 40);
- disk2Icon = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888,
- SDL_TEXTUREACCESS_STATIC, 40, 40);
- powerOffIcon = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888,
- SDL_TEXTUREACCESS_STATIC, 40, 40);
- powerOnIcon = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888,
- SDL_TEXTUREACCESS_STATIC, 40, 40);
- SDL_SetTextureBlendMode(iconSelection, SDL_BLENDMODE_BLEND);
- SDL_SetTextureBlendMode(disk1Icon, SDL_BLENDMODE_BLEND);
- SDL_SetTextureBlendMode(disk2Icon, SDL_BLENDMODE_BLEND);
- SDL_SetTextureBlendMode(powerOffIcon, SDL_BLENDMODE_BLEND);
- SDL_SetTextureBlendMode(powerOnIcon, SDL_BLENDMODE_BLEND);
- Bitmap * bm1 = (Bitmap *)((void *)&icon_selection);
- SDL_UpdateTexture(iconSelection, NULL, (Uint32 *)bm1->pixelData, 54 * sizeof(Uint32));
- bm1 = (Bitmap *)((void *)&disk_1);
- SDL_UpdateTexture(disk1Icon, NULL, (Uint32 *)bm1->pixelData, 40 * sizeof(Uint32));
- bm1 = (Bitmap *)((void *)&disk_2);
- SDL_UpdateTexture(disk2Icon, NULL, (Uint32 *)bm1->pixelData, 40 * sizeof(Uint32));
- bm1 = (Bitmap *)((void *)&power_off);
- SDL_UpdateTexture(powerOffIcon, NULL, (Uint32 *)bm1->pixelData, 40 * sizeof(Uint32));
- bm1 = (Bitmap *)((void *)&power_on);
- SDL_UpdateTexture(powerOnIcon, NULL, (Uint32 *)bm1->pixelData, 40 * sizeof(Uint32));
+ iconSelection = CreateTexture(renderer, &icon_selection);
+ disk1Icon = CreateTexture(renderer, &disk_1);
+ disk2Icon = CreateTexture(renderer, &disk_2);
+ powerOffIcon = CreateTexture(renderer, &power_off);
+ powerOnIcon = CreateTexture(renderer, &power_on);
if (SDL_SetRenderTarget(renderer, overlay) < 0)
{
}
else
{
- SDL_Texture * icons[7] = { powerOnIcon, disk1Icon, disk2Icon, powerOffIcon, powerOffIcon, powerOffIcon, powerOffIcon };
- SDL_Rect dst;
- dst.w = dst.h = 40;
- dst.x = 24;
- dst.y = 2 + 7;
-
- for(int i=0; i<7; i++)
- {
- SDL_RenderCopy(renderer, icons[i], NULL, &dst);
- dst.y += 54;
- }
-
+ DrawSidebarIcons(renderer);
// Set render target back to default
SDL_SetRenderTarget(renderer, NULL);
}
}
+SDL_Texture * GUI2::CreateTexture(SDL_Renderer * renderer, const void * source)
+{
+ Bitmap * bitmap = (Bitmap *)source;
+ SDL_Texture * texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888,
+ SDL_TEXTUREACCESS_STATIC, bitmap->width, bitmap->height);
+ SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
+ SDL_UpdateTexture(texture, NULL, (Uint32 *)bitmap->pixelData,
+ bitmap->width * sizeof(Uint32));
+
+ return texture;
+}
+
+
void GUI2::MouseDown(int32_t x, int32_t y, uint32_t buttons)
{
}
{
if (x < (VIRTUAL_SCREEN_WIDTH - 100))
{
- iconSelected = -1;
- lastIconSelected = -1;
+ iconSelected = lastIconSelected = -1;
HandleIconSelection(sdlRenderer);
//printf("GUI: sidebar hiding[2] (x = %i)...\n", x);
-// sidebarOut = false;
sidebarState = SBS_HIDING;
dx = 8;
}
// something!
else
{
- if (y < 3 || y > 382)
+ if (y < 4 || y > 383)
{
iconSelected = -1;
}
else
- iconSelected = (y - 2) / 54;
+ iconSelected = (y - 4) / 54;
if (iconSelected != lastIconSelected)
{
return;
}
- SDL_Rect dst;// = { 54, 54, 24 - 7, 2 };
- dst.w = dst.h = 54;
- dst.x = 24 - 7;
- dst.y = 2;
-
+ // Draw the icon selector, if an icon is selected
if (iconSelected >= 0)
{
- dst.y += iconSelected * 54;
+ SDL_Rect dst;// = { 54, 54, 24 - 7, 2 };
+ dst.w = dst.h = 54;
+ dst.x = 24 - 7;
+ dst.y = 2 + (iconSelected * 54);
+
SDL_RenderCopy(renderer, iconSelection, NULL, &dst);
}
-#if 1
DrawSidebarIcons(renderer);
-#else
- SDL_Texture * icons[7] = { powerOnIcon, disk1Icon, disk2Icon, powerOffIcon, powerOffIcon, powerOffIcon, powerOffIcon };
- dst.w = dst.h = 40;
- dst.x = 24;
- dst.y = 2 + 7;
-
- for(int i=0; i<7; i++)
- {
- SDL_RenderCopy(renderer, icons[i], NULL, &dst);
- dst.y += 54;
- }
-#endif
// Set render target back to default
SDL_SetRenderTarget(renderer, NULL);