Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] AmigaOS 3.x Support #1

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d06594e
Begin adding AmigaOS3.x support
MBeijer Feb 17, 2020
ecb800b
Merge branch 'SDL-1.2' of github.com:AmigaPorts/SDL into SDL-1.2-Amig…
MBeijer Feb 17, 2020
5272d27
Add some missing files
MBeijer Feb 17, 2020
3e10983
Add more missing files
MBeijer Feb 17, 2020
5ff6109
Fix joystick support
MBeijer Feb 17, 2020
480ac6d
Add AmigaOS3 makefile
MBeijer Feb 17, 2020
5668d8a
Cleanup add support for AmigaOS4 in CMakeLists.txt
MBeijer Feb 17, 2020
64ba323
Remove old conflicting ExecBase, OS4 version now compiles
MBeijer Feb 17, 2020
d38b3f9
OS4 build should now build with makefile again
MBeijer Feb 17, 2020
ad2cd1c
Delete SDL_main.h
MBeijer Feb 17, 2020
fe16bbf
Apply suggestions from code review
MBeijer Feb 17, 2020
9a0ce1a
Re-enable OpenGL for AmigaOS4
MBeijer Feb 17, 2020
1528bde
Merge branch 'SDL-1.2' into SDL-1.2-AmigaOS3
MBeijer Feb 17, 2020
a72e4d9
Add support for shared libs, as AmigaOS4 supports them
MBeijer Feb 18, 2020
4ab302c
Only install shared object if SHARED is built
MBeijer Feb 19, 2020
a139e60
Remove Vampire SDL_flip hack
MBeijer Feb 19, 2020
62baa83
Update src/video/SDL_video.c
MBeijer Feb 22, 2020
55f1a21
Apply suggestions from code review
MBeijer Feb 22, 2020
4a54350
Update src/video/SDL_video.c
MBeijer Feb 22, 2020
dcb3a4b
ASM-VASM is now ASM_VASM in updated OS3 toolchain
MBeijer May 29, 2020
0d3f5e3
Enable -Wall in CMake builds
MBeijer Jun 21, 2020
c59f102
Backport OS4 AHI driver to OS3
MBeijer Jun 21, 2020
eb484f4
Re add wrongfully removed part of SDL_audio.c
MBeijer Jun 21, 2020
ce14716
Merge remote-tracking branch 'amiagaports/SDL-1.2-AmigaOS3' into Amig…
MBeijer May 15, 2021
065b715
Cleanup PR
MBeijer May 15, 2021
4335d23
Cleanup PR
MBeijer May 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ build-deps
*.dll
*.exe
*.o
*.go
*.obj
*.lib
*.a
*.ao
*.la
*.ll
*.dSYM
*,e1f
*,ff8
Expand Down Expand Up @@ -52,6 +55,13 @@ Release
*.suo
*.sdf

# for CLion
/Default/
.idea/
build/
cmake-build-*/*
build-*/

test/stdout.txt
test/stderr.txt
test/checkkeys
Expand Down
17 changes: 17 additions & 0 deletions CMake/git.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function(get_git_tag output_var)
execute_process(
COMMAND git describe --abbrev=0 --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(${output_var} ${GIT_TAG} PARENT_SCOPE)
endfunction(get_git_tag)

function(get_git_commit_hash output_var)
execute_process(
COMMAND git log -1 --format=-%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(${output_var} ${GIT_COMMIT_HASH} PARENT_SCOPE)
endfunction(get_git_commit_hash)
3 changes: 3 additions & 0 deletions CMake/out_of_tree.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(WARNING [[In-source build detected, please eg. create a new directory and use `cmake ..`]])
endif()
316 changes: 316 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,316 @@
cmake_minimum_required(VERSION 3.10)

include(CMake/out_of_tree.cmake)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()

option(DEBUG "Enable debug mode in engine" OFF)
option(APOLLOBLIT "Enable AMMX blitting for Vampire Accelerators" ON)
option(DEBUG_RELEASE "Enable options for debug release" OFF)

if(DEBUG_RELEASE)
set(CMAKE_BUILD_TYPE "Debug")
set(DEBUG ON)
endif()

include(CMake/git.cmake)
get_git_tag(GIT_TAG)
if(NOT CMAKE_BUILD_TYPE MATCHES "Release")
get_git_commit_hash(GIT_COMMIT_HASH)
endif()

project(SDL1.2
VERSION ${GIT_TAG}
LANGUAGES C ASM)

# Lowercase project name for binaries and packaging
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME_LOWER)
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} SYSTEM_ARCH_LOWER)

include(GNUInstallDirs)

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake")

set(LIBNAME "SDL")

# Make version variables
string(REPLACE "." ";" VERSION_LIST ${GIT_TAG})
list(GET VERSION_LIST 0 SDL_MAJOR_VERSION)
list(GET VERSION_LIST 1 SDL_MINOR_VERSION)
list(GET VERSION_LIST 2 SDL_PATCHLEVEL)

message(STATUS "SDL version: ${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_PATCHLEVEL}")

# Build date Information
string(TIMESTAMP VER_YEAR "%Y")
string(TIMESTAMP VER_MONTH "%m")
string(TIMESTAMP VER_DAY "%d")
string(REGEX REPLACE "^0+" "" VER_MONTH "${VER_MONTH}")
string(REGEX REPLACE "^0+" "" VER_DAY "${VER_DAY}")

# Set Amiga version
set(AMIGA_VERSION "${SDL_MAJOR_VERSION}${SDL_MINOR_VERSION}.${SDL_PATCHLEVEL}")

# Final build filename, for example "SDL1.2-1.2.16-AmigaOS.zip"
set(BUILD_FILENAME "SDL-${GIT_TAG}-${SYSTEM_NAME_LOWER}-${SYSTEM_ARCH_LOWER}")

set(CPACK_GENERATOR ZIP)
set(CPACK_PACKAGE_NAME ${PROJECT_NAME_LOWER})
set(CPACK_PACKAGE_VENDOR "AmigaDev Team")
set(CPACK_PACKAGE_CONTACT "support@amigadev.com")
set(CPACK_PACKAGE_FILE_NAME ${BUILD_FILENAME})
set(CPACK_PACKAGE_VERSION_MAJOR ${SDL_MAJOR_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR ${SDL_MINOR_VERSION})
set(CPACK_PACKAGE_VERSION_PATCH ${SDL_PATCHLEVEL})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "SDL1.2")
include(CPack)

# SET COMPILE TARGETS
set(LIB_TARGET "STATIC")

# Generate version header from the above
configure_file(
${PROJECT_SOURCE_DIR}/include/SDL_version.h.in
${PROJECT_BINARY_DIR}/include/SDL_version.h
)

configure_file(
${PROJECT_SOURCE_DIR}/include/SDL_amigaversion.h.in
${PROJECT_BINARY_DIR}/include/SDL_amigaversion.h
)

set(CMAKE_CXX_STANDARD 14)

set(SOURCE_FILES
# MAIN
${PROJECT_SOURCE_DIR}/src/SDL.c
${PROJECT_SOURCE_DIR}/src/SDL_error.c
${PROJECT_SOURCE_DIR}/src/SDL_fatal.c

# CDROM
${PROJECT_SOURCE_DIR}/src/cdrom/SDL_cdrom.c

# CPUINFO
${PROJECT_SOURCE_DIR}/src/cpuinfo/SDL_cpuinfo.c

# AUDIO
${PROJECT_SOURCE_DIR}/src/audio/SDL_audio.c
${PROJECT_SOURCE_DIR}/src/audio/SDL_audiocvt.c
${PROJECT_SOURCE_DIR}/src/audio/SDL_mixer.c
${PROJECT_SOURCE_DIR}/src/audio/SDL_mixer_m68k.c
${PROJECT_SOURCE_DIR}/src/audio/SDL_wave.c
#${PROJECT_SOURCE_DIR}/src/audio/dummy/SDL_dummyaudio.c
#${PROJECT_SOURCE_DIR}/src/audio/disk/SDL_diskaudio.c

# VIDEO
${PROJECT_SOURCE_DIR}/src/video/SDL_RLEaccel.c
${PROJECT_SOURCE_DIR}/src/video/SDL_blit.c
${PROJECT_SOURCE_DIR}/src/video/SDL_blit_0.c
${PROJECT_SOURCE_DIR}/src/video/SDL_blit_1.c
${PROJECT_SOURCE_DIR}/src/video/SDL_blit_A.c
${PROJECT_SOURCE_DIR}/src/video/SDL_blit_N.c
${PROJECT_SOURCE_DIR}/src/video/SDL_bmp.c
${PROJECT_SOURCE_DIR}/src/video/SDL_cursor.c
${PROJECT_SOURCE_DIR}/src/video/SDL_pixels.c
${PROJECT_SOURCE_DIR}/src/video/SDL_surface.c
${PROJECT_SOURCE_DIR}/src/video/SDL_stretch.c
${PROJECT_SOURCE_DIR}/src/video/SDL_yuv.c
${PROJECT_SOURCE_DIR}/src/video/SDL_yuv_sw.c
${PROJECT_SOURCE_DIR}/src/video/SDL_video.c
${PROJECT_SOURCE_DIR}/src/video/SDL_gamma.c

# TIMER
${PROJECT_SOURCE_DIR}/src/timer/SDL_timer.c

# JOYSTICK
${PROJECT_SOURCE_DIR}/src/joystick/SDL_joystick.c

# EVENTS
${PROJECT_SOURCE_DIR}/src/events/SDL_active.c
${PROJECT_SOURCE_DIR}/src/events/SDL_events.c
${PROJECT_SOURCE_DIR}/src/events/SDL_expose.c
${PROJECT_SOURCE_DIR}/src/events/SDL_keyboard.c
${PROJECT_SOURCE_DIR}/src/events/SDL_mouse.c
${PROJECT_SOURCE_DIR}/src/events/SDL_quit.c
${PROJECT_SOURCE_DIR}/src/events/SDL_resize.c

# FILE
${PROJECT_SOURCE_DIR}/src/file/SDL_rwops.c

# THREADS
${PROJECT_SOURCE_DIR}/src/thread/SDL_thread.c
${PROJECT_SOURCE_DIR}/src/thread/generic/SDL_syscond.c

# STDLIB
${PROJECT_SOURCE_DIR}/src/stdlib/SDL_getenv.c
${PROJECT_SOURCE_DIR}/src/stdlib/SDL_iconv.c
${PROJECT_SOURCE_DIR}/src/stdlib/SDL_malloc.c
${PROJECT_SOURCE_DIR}/src/stdlib/SDL_qsort.c
${PROJECT_SOURCE_DIR}/src/stdlib/SDL_stdlib.c
${PROJECT_SOURCE_DIR}/src/stdlib/SDL_string.c)

set(INCLUDE_PATHS
${PROJECT_SOURCE_DIR}/
${PROJECT_SOURCE_DIR}/include
${PROJECT_BINARY_DIR}/include
${PROJECT_SOURCE_DIR}/include-GL
${PROJECT_SOURCE_DIR}/src/audio
${PROJECT_SOURCE_DIR}/src/audio/dummy
${PROJECT_SOURCE_DIR}/src/audio/disk
${PROJECT_SOURCE_DIR}/src/audio/amigaos
${PROJECT_SOURCE_DIR}/src/events
${PROJECT_SOURCE_DIR}/src/joystick
${PROJECT_SOURCE_DIR}/src/main/amigaos
${PROJECT_SOURCE_DIR}/src/thread
${PROJECT_SOURCE_DIR}/src/thread/amigaos
${PROJECT_SOURCE_DIR}/src/thread/pth
${PROJECT_SOURCE_DIR}/src/thread/pthread
${PROJECT_SOURCE_DIR}/src/timer
${PROJECT_SOURCE_DIR}/src/video
${PROJECT_SOURCE_DIR}/src/video/cybergfx
${PROJECT_SOURCE_DIR}/src/video/apollo
${PROJECT_SOURCE_DIR}/src/video/dummy)

if(AMIGA)
if(AMIGAOS3)
list(APPEND SOURCE_FILES
# MAIN
${PROJECT_SOURCE_DIR}/src/main/amigaos/SDL_lutstub.s

# CDROM
${PROJECT_SOURCE_DIR}/src/cdrom/dummy/SDL_syscdrom.c
#${PROJECT_SOURCE_DIR}/src/cdrom/amigaos/SDL_syscdrom.c

# AUDIO
${PROJECT_SOURCE_DIR}/src/audio/amigaos/SDL_ahiaudio.c

# VIDEO
${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgxvideo.c
${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgxmodes.c
${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgximage.c
${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_amigaevents.c
${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_amigamouse.c
${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgxgl.c
${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgxwm.c
${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgxyuv.c
${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgxaccel.c
${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgxgl_wrapper.c

# TIMER
${PROJECT_SOURCE_DIR}/src/timer/amigaos/SDL_systimer.c

# JOYSTICK
${PROJECT_SOURCE_DIR}/src/joystick/amigaos/SDL_sysjoystick.c

# THREADS
${PROJECT_SOURCE_DIR}/src/thread/amigaos/SDL_sysmutex.c
${PROJECT_SOURCE_DIR}/src/thread/amigaos/SDL_syssem.c
${PROJECT_SOURCE_DIR}/src/thread/amigaos/SDL_systhread.c
${PROJECT_SOURCE_DIR}/src/thread/amigaos/SDL_thread.c
${PROJECT_SOURCE_DIR}/src/thread/amigaos/SDL_syscond.c

# LOADSO
${PROJECT_SOURCE_DIR}/src/loadso/dummy/SDL_sysloadso.c
)
elseif(AMIGAOS4)
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
list(APPEND LIB_TARGET "SHARED")
list(APPEND SOURCE_FILES
# MAIN
${PROJECT_SOURCE_DIR}/src/main/amigaos4/SDL_os4timer.c

# CDROM
${PROJECT_SOURCE_DIR}/src/cdrom/amigaos4/SDL_syscdrom.c

# AUDIO
${PROJECT_SOURCE_DIR}/src/audio/amigaos4/SDL_os4audio.c

# VIDEO
${PROJECT_SOURCE_DIR}/src/video/amigaos4/SDL_os4_wrapper.c
${PROJECT_SOURCE_DIR}/src/video/amigaos4/SDL_os4blit.c
${PROJECT_SOURCE_DIR}/src/video/amigaos4/SDL_os4events.c
${PROJECT_SOURCE_DIR}/src/video/amigaos4/SDL_os4gl.c
${PROJECT_SOURCE_DIR}/src/video/amigaos4/SDL_os4surface.c
${PROJECT_SOURCE_DIR}/src/video/amigaos4/SDL_os4utils.c
${PROJECT_SOURCE_DIR}/src/video/amigaos4/SDL_os4video.c
${PROJECT_SOURCE_DIR}/src/video/amigaos4/SDL_os4wm.c

# TIMER
${PROJECT_SOURCE_DIR}/src/timer/amigaos4/SDL_systimer.c

# JOYSTICK
${PROJECT_SOURCE_DIR}/src/joystick/amigaos4/SDL_sysjoystick.c

# THREADS
${PROJECT_SOURCE_DIR}/src/thread/amigaos4/SDL_sysmutex.c
${PROJECT_SOURCE_DIR}/src/thread/amigaos4/SDL_syssem.c
${PROJECT_SOURCE_DIR}/src/thread/amigaos4/SDL_systhread.c

# LOADSO
${PROJECT_SOURCE_DIR}/src/loadso/amigaos4/SDL_sysloadso.c

)
endif()
endif()

foreach(target ${LIB_TARGET})
add_library(${target}
${target}
${SOURCE_FILES})
target_include_directories(${target}
PRIVATE
${INCLUDE_PATHS})
set_target_properties(${target} PROPERTIES OUTPUT_NAME ${LIBNAME})

target_compile_definitions(${target} PRIVATE $<$<COMPILE_LANGUAGE:C>:NOIXEMUL _HAVE_STDINT_H>)

if(NOT DEBUG)
target_compile_options(${target} PUBLIC $<$<COMPILE_LANGUAGE:C>:-O3 -ffast-math -Wall>)
endif()

if(AMIGA)
if(NOT DEBUG)
target_compile_definitions(${target} PRIVATE $<$<COMPILE_LANGUAGE:C>:NO_AMIGADEBUG>)
endif()

if(APOLLOBLIT AND AMIGAOS3)
target_compile_definitions(${target} PRIVATE $<$<COMPILE_LANGUAGE:C>:APOLLO_BLIT>)
target_compile_options(${target} PRIVATE -I${CMAKE_SYSROOT}/m68k-amigaos/ndk-include)
target_include_directories(${target} PUBLIC video/apollo)
enable_language(ASM_VASM)
target_sources(${target}
PRIVATE
# APOLLO AMMX
src/video/apollo/blitapollo.asm
src/video/apollo/apolloammxenable.asm
src/video/apollo/colorkeyapollo.asm)
endif()
endif()
endforeach(target)

file(GLOB INCLUDE_FILES ${PROJECT_SOURCE_DIR}/include/*.h)
file(GLOB BIN_INCLUDE_FILES ${PROJECT_BINARY_DIR}/include/*.h)
list(APPEND INCLUDE_FILES ${BIN_INCLUDE_FILES})

file(GLOB GL_INCLUDE_FILES include-GL/*.h)

install(FILES ${PROJECT_BINARY_DIR}/libSDL.a DESTINATION "lib${LIB_SUFFIX}")

if("SHARED" IN_LIST LIB_TARGET)
install(FILES ${PROJECT_BINARY_DIR}/libSDL.so DESTINATION "lib${LIB_SUFFIX}")
endif()

install(FILES ${INCLUDE_FILES} DESTINATION include/SDL)
install(FILES ${GL_INCLUDE_FILES} DESTINATION include/GL)

install(FILES
README
README-SDL.txt
README.AmigaOS
CREDITS
COPYING
BUGS
DESTINATION ./)
Loading