├── .gitignore
├── Android
├── Android.mk
├── AndroidManifest.xml.in
├── assets
│ └── Resource.zip
├── default.properties
├── project_create.sh.in
├── res
│ ├── drawable-hdpi
│ │ ├── ic_action_search.png
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ ├── ic_action_search.png
│ │ └── ic_launcher.png
│ ├── drawable-xhdpi
│ │ ├── ic_action_search.png
│ │ └── ic_launcher.png
│ ├── layout
│ │ └── progress_dialog.xml
│ └── values
│ │ └── styles.xml
└── strings.xml.in
├── CMake
├── AndroidCommon.cmake
├── Common.cmake
├── Packages
│ ├── FindDoxygen.cmake
│ ├── FindFreetype.cmake
│ ├── FindGIF.cmake
│ ├── FindGLEW.cmake
│ ├── FindGStreamer.cmake
│ ├── FindJPEG.cmake
│ ├── FindPNG.cmake
│ ├── FindSDL.cmake
│ ├── FindSDL_mixer.cmake
│ ├── FindUnzip.cmake
│ └── FindZLIB.cmake
├── SetupDepends.cmake
├── Templates
│ └── merge_archives_unix.cmake.in
└── Utils
│ ├── CopyFile.cmake
│ ├── LibUtils.cmake
│ ├── LogFeature.cmake
│ ├── PkgUtils.cmake
│ ├── RmDupLibs.cmake
│ ├── android.toolchain.cmake
│ └── psp.toolchain.cmake
├── CMakeLists.txt
├── HISTORY.md
├── README.md
├── Xcoder
├── Libnge2.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── long.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── long.xcuserdatad
│ │ └── xcschemes
│ │ ├── Libnge2.xcscheme
│ │ └── xcschememanagement.plist
└── downloadUrl.txt
├── and_jni_base
├── nge_android_jni.c
└── nge_android_jni.h
├── coolaudio
├── CMakeLists.txt
├── LSAudioDeleCall.h
├── LSAudioDeleCall.m
├── LibCoolAudio.java
├── Makefile_lib
├── android_mediaplayer.c
├── android_mediaplayer.h
├── audio_android.c
├── audio_android.h
├── audio_codec.cpp
├── audio_codec.h
├── audio_parser.h
├── codecs
│ ├── mp3_codec.cpp
│ └── mp3_codec.h
├── common
│ ├── buffered_reader.c
│ ├── buffered_reader.h
│ ├── mem64.c
│ └── mem64.h
├── libLSAudio.m
├── libcoolaudio.c
├── nge_audio_linux.c
├── nge_audio_psp.cpp
├── nge_io_mem.c
├── nge_io_mem.h
└── parsers
│ ├── mp3_parser.cpp
│ ├── mp3_parser.h
│ ├── musepack_parser.cpp
│ ├── musepack_parser.h
│ ├── oggvorbis_parser.cpp
│ ├── oggvorbis_parser.h
│ ├── pcm_parser.cpp
│ └── pcm_parser.h
├── dirent
├── CMakeLists.txt
├── directory.c
├── directory.h
├── fat.c
├── fat.h
├── miniconv.c
├── miniconv.h
├── nge_ch_io_dir.h
├── nge_dirent.cpp
└── nge_dirent.hpp
├── doc
└── nge2_Doxyfile
├── helper
├── CMakeLists.txt
├── dictionary.c
├── iniparser.c
└── package.cpp
├── hge
├── CMakeLists.txt
├── hgecolor.cpp
├── hgedistort.cpp
├── hgeparticle.cpp
├── hgepmanager.cpp
├── hgerect.cpp
└── hgevector.cpp
├── include
├── audio_interface.h
├── helper
│ ├── dictionary.h
│ ├── iniparser.h
│ └── package.h
├── hge
│ ├── hgecolor.h
│ ├── hgedistort.h
│ ├── hgeparticle.h
│ ├── hgerect.h
│ └── hgevector.h
├── libnge2.h
├── libnge2pure.h
├── movie
│ └── nge_movie.h
├── msvc
│ └── stdint.h
├── nge.h
├── nge_app.h
├── nge_app.hpp
├── nge_bmp.h
├── nge_charsets.h
├── nge_color.h
├── nge_common.h
├── nge_debug_log.h
├── nge_dll_export.h
├── nge_endian_internal.h
├── nge_font.h
├── nge_font_internal.h
├── nge_gif.h
├── nge_graphics.h
├── nge_image.h
├── nge_image_effect.h
├── nge_image_ext.h
├── nge_input.h
├── nge_io_dir.h
├── nge_io_file.h
├── nge_io_file_internal.h
├── nge_jpg.h
├── nge_main.h
├── nge_misc.h
├── nge_mmgr.h
├── nge_package.h
├── nge_package_internal.h
├── nge_package_zip.h
├── nge_platform.h
├── nge_png.h
├── nge_rbtree.h
├── nge_ref_handle.h
├── nge_rle.h
├── nge_sys_compatible.h
├── nge_tex_cache.h
├── nge_tga.h
├── nge_timer.h
├── nge_utilskit.h
├── pmp.h
└── psp
│ └── nge_vram.h
├── mmgr
├── CMakeLists.txt
├── mmgr.cpp
├── mmgr.h
└── nommgr.h
├── movie
├── CMakeLists.txt
└── nge_movie.c
├── net
├── CMakeLists.txt
├── config.h
├── event-internal.h
├── event.c
├── event.h
├── log.c
├── log.h
├── nge_net_common.c
├── nge_net_common.h
├── queue.h
├── select.c
├── time_compatible.h
└── tree.h
├── samples
├── CMakeLists.txt
├── demo10
│ ├── CMakeLists.txt
│ └── test.cpp
├── demo11
│ ├── CMakeLists.txt
│ └── test.cpp
├── demo12
│ ├── CMakeLists.txt
│ ├── cAnimation.cpp
│ ├── cAnimation.h
│ └── test.cpp
├── demo13
│ ├── CMakeLists.txt
│ └── test.cpp
├── demo14
│ ├── CMakeLists.txt
│ └── test.cpp
├── demo15
│ ├── CMakeLists.txt
│ └── test.cpp
├── demo16
│ ├── CMakeLists.txt
│ └── test.cpp
├── demo17
│ ├── CMakeLists.txt
│ └── test.cpp
└── demo6
│ ├── CMakeLists.txt
│ └── test.cpp
├── script
├── down-androiddepends.sh
├── down-resources.sh
├── down-win32depends.sh
├── make-android.sh
├── make-linux.sh
├── make-psp.sh
├── pack-res.sh
└── replace.sh
└── src
├── android
├── NGE2.java
├── UnZipFile.java.in
├── UtilsKit.java
├── nge_jni.cpp
└── nge_utilskit.c
├── charsets
├── ascii.h
├── ces_gbk.h
├── cp936ext.h
├── gb2312.h
├── gbk.h
├── gbkext1.h
├── gbkext2.h
├── gbkext_inv.h
└── utf8.h
├── nge.c
├── nge_app.c
├── nge_app_cpp.cpp
├── nge_bmp.c
├── nge_charsets.c
├── nge_debug_log.c
├── nge_font.c
├── nge_font_bittype.h
├── nge_font_freetype.c
├── nge_font_hzk.c
├── nge_font_nfont.c
├── nge_gif_animation.c
├── nge_gif_show.c
├── nge_graphics.c
├── nge_image.c
├── nge_image_effect.c
├── nge_image_ext.c
├── nge_input.c
├── nge_io_dir.c
├── nge_io_file.c
├── nge_jpg.c
├── nge_main.c
├── nge_misc.c
├── nge_package.c
├── nge_package_zip.c
├── nge_png.c
├── nge_rbtree.c
├── nge_ref_handle.c
├── nge_rle.c
├── nge_sys_compatible.c
├── nge_tex_cache.c
├── nge_tga.c
├── nge_timer.c
└── psp
├── nge_graphics.c
└── vram.c
/.gitignore:
--------------------------------------------------------------------------------
1 | build*/
2 | temp/
3 | samples/res/
4 | samples/res.*
5 | *Depends/
6 | *Depends.7z
7 | Android/foreign/
8 | Android/libs/
9 |
--------------------------------------------------------------------------------
/Android/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 |
3 | include $(CLEAR_VARS)
4 | LOCAL_CFLAGS += -DANDROID -D_DEBUG_LOG
5 | LOCAL_CXXFLAGS += -DANDROID -D_DEBUG_LOG -fexceptions
6 | LOCAL_MODULE := nge2app-jni
7 | LOCAL_SRC_FILES := nge_jni.cpp
8 | LOCAL_C_INCLUDES += jni jni/depends/include jni/depends/libnge2/include
9 | LOCAL_LDLIBS := -Ljni/depends/libs -Ljni/libnge2/libs -ljpeg -lfreetype -lpng -lz -lungif -llog -lGLESv1_CM
10 | LOCAL_STATIC_LIBRARIES := libnge2
11 | include $(BUILD_SHARED_LIBRARY)
12 |
--------------------------------------------------------------------------------
/Android/AndroidManifest.xml.in:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Android/assets/Resource.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/Android/assets/Resource.zip
--------------------------------------------------------------------------------
/Android/default.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "build.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-8
12 |
--------------------------------------------------------------------------------
/Android/project_create.sh.in:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #this generates an ant based cli build of the android-jni project
3 | android update project --name @project_name@ \
4 | --path .
5 |
--------------------------------------------------------------------------------
/Android/res/drawable-hdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/Android/res/drawable-hdpi/ic_action_search.png
--------------------------------------------------------------------------------
/Android/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/Android/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Android/res/drawable-mdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/Android/res/drawable-mdpi/ic_action_search.png
--------------------------------------------------------------------------------
/Android/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/Android/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Android/res/drawable-xhdpi/ic_action_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/Android/res/drawable-xhdpi/ic_action_search.png
--------------------------------------------------------------------------------
/Android/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/Android/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Android/res/layout/progress_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
19 |
20 |
25 |
26 |
--------------------------------------------------------------------------------
/Android/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Android/strings.xml.in:
--------------------------------------------------------------------------------
1 |
2 |
3 | @app_name@
4 |
5 |
--------------------------------------------------------------------------------
/CMake/AndroidCommon.cmake:
--------------------------------------------------------------------------------
1 | ## Author: Kun Wang
2 | ## Version: $Id: Android.cmake,v 0.0 2012/04/04 06:07:14 ifreedom Exp $
3 |
4 | ##
5 | # This program is free software; you can redistribute it and/or modify
6 | # it under the terms of the GNU General Public License as published by
7 | # the Free Software Foundation; either version 2 of the License, or
8 | # (at your option) any later version.
9 | #
10 | # This program is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU General Public License for more details.
14 | #
15 | # You should have received a copy of the GNU General Public License
16 | # along with this program; if not, write to the Free Software
17 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 | ##
19 |
20 | function(set_output_root dir)
21 | set(LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_BINARY_DIR}/Android CACHE PATH "root for library output, set this to change where android libs are installed to" FORCE)
22 | if(EXISTS "${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt")
23 | set(EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for applications" FORCE)
24 | else()
25 | set(EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin" CACHE PATH "Output directory for applications" FORCE)
26 | endif()
27 | set(LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "path for android libs" FORCE)
28 | endfunction()
29 |
30 | ### Android.cmake ends here
31 |
--------------------------------------------------------------------------------
/CMake/Packages/FindFreetype.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find FreeType
2 | # Once done, this will define
3 | #
4 | # FREETYPE_FOUND - system has FreeType
5 | # FREETYPE_INCLUDE_DIRS - the FreeType include directories
6 | # FREETYPE_LIBRARY - link these to use FreeType
7 |
8 | if(NOT FREETYPE_FOUND)
9 | include(PkgUtils)
10 | findpkg_begin(FREETYPE)
11 |
12 | # prefer static library over framework
13 | set(CMAKE_FIND_FRAMEWORK "LAST")
14 |
15 | define_find_pkg(FREETYPE
16 | PKG_CONFIG_NAME freetype2
17 | LIBRARY_HINTS freetype2311 freetype239 freetype238 freetype235 freetype219 freetype
18 | HEADER_HINTS freetype/freetype.h
19 | HEADER_SUFFIXES freetype2)
20 |
21 | find_path(FREETYPE_FT2BUILD_INCLUDE_DIR NAMES ft2build.h HINTS ${FREETYPE_INC_SEARCH_PATH} ${FREETYPE_PKGC_INCLUDE_DIRS})
22 |
23 | # Reset framework finding
24 | set(CMAKE_FIND_FRAMEWORK "FIRST")
25 |
26 | findpkg_finish(FREETYPE)
27 | mark_as_advanced(FREETYPE_FT2BUILD_INCLUDE_DIR)
28 | if (NOT FREETYPE_FT2BUILD_INCLUDE_DIR STREQUAL FREETYPE_INCLUDE_DIR)
29 | list(APPEND FREETYPE_INCLUDE_DIRS ${FREETYPE_FT2BUILD_INCLUDE_DIR})
30 | endif ()
31 | endif()
32 |
--------------------------------------------------------------------------------
/CMake/Packages/FindGIF.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find GIF
2 | # Once done, this will define
3 | #
4 | # GIF_INCLUDE_DIR, where to find gif_lib.h, etc.
5 | # GIF_LIBRARIES, the libraries to link against to use giflib.
6 | # GIF_FOUND, If false, do not try to use giflib.
7 |
8 | if(NOT GIF_FOUND)
9 | include(PkgUtils)
10 | findpkg_begin(GIF)
11 |
12 | define_find_pkg(GIF
13 | LIBRARY_HINTS gif libgif ungif libungif giflib
14 | HEADER_HINTS gif_lib.h)
15 |
16 | findpkg_finish(GIF)
17 | endif()
18 |
--------------------------------------------------------------------------------
/CMake/Packages/FindGLEW.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Try to find GLEW library and include path.
3 | # Once done this will define
4 | #
5 | # GLEW_FOUND
6 | # GLEW_INCLUDE_PATH
7 | # GLEW_LIBRARY
8 | #
9 |
10 | if(NOT GLEW_FOUND)
11 | include(PkgUtils)
12 | findpkg_begin(GLEW)
13 |
14 | define_find_pkg(GLEW
15 | PKG_CONFIG_NAME glew
16 | LIBRARY_HINTS glew GLEW glew32 glew32s libglew libglew32
17 | HEADER_HINTS gl/glew.h GL/glew.h)
18 |
19 | findpkg_finish(GLEW)
20 | endif()
--------------------------------------------------------------------------------
/CMake/Packages/FindGStreamer.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find GStreamer
2 | # Once done, this will define
3 | #
4 | # GSTREAMER_LIBRARIES, the name of the library to link against
5 | # GSTREAMER_FOUND, if false, do not try to link to SDL mixer
6 | # GSTREAMER_INCLUDE_DIRS, where to find headers
7 |
8 | if(NOT GSTREAMER_FOUND)
9 | include(PkgUtils)
10 | findpkg_begin(GSTREAMER)
11 |
12 | prepare_find_pkg_vars(GSTREAMER)
13 | use_pkgconfig(GSTREAMER_PKGC gstreamer-0.10)
14 |
15 | set(GSTREAMER_INCLUDE_DIR ${GSTREAMER_PKGC_INCLUDE_DIRS})
16 | set(GSTREAMER_LIBRARY_REL ${GSTREAMER_PKGC_LIBRARIES})
17 | make_library_set(GSTREAMER_LIBRARY)
18 |
19 | findpkg_finish(GSTREAMER)
20 | endif()
21 |
22 |
--------------------------------------------------------------------------------
/CMake/Packages/FindJPEG.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find JPEG
2 | # Once done, this will define
3 | #
4 | # JPEG_FOUND - system has JPEGlib
5 | # JPEG_INCLUDE_DIR - the JPEGlib include directories
6 | # JPEG_LIBRARY - link these to use JPGElib
7 |
8 | if(NOT JPEG_FOUND)
9 | include(PkgUtils)
10 | findpkg_begin(JPEG)
11 |
12 | define_find_pkg(JPEG
13 | LIBRARY_HINTS jpeg libjpeg
14 | HEADER_HINTS jpeglib.h)
15 |
16 | findpkg_finish(JPEG)
17 | endif()
18 |
--------------------------------------------------------------------------------
/CMake/Packages/FindPNG.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find PNG
2 | # Once done, this will define
3 | #
4 | # PNG_INCLUDE_DIRS, where to find png.h, etc.
5 | # PNG_LIBRARIES, the libraries to link against to use PNG.
6 | # PNG_FOUND, If false, do not try to use PNG.
7 | # None of the above will be defined unles zlib can be found.
8 | # PNG depends on Zlib
9 |
10 | if(NOT PNG_FOUND)
11 | include(PkgUtils)
12 | findpkg_begin(PNG)
13 |
14 | find_package(ZLIB)
15 | if(NOT ZLIB_FOUND)
16 | message(SEND_ERROR "PNG depends on Zlib")
17 | return()
18 | endif()
19 |
20 | define_find_pkg(PNG
21 | PKG_CONFIG_NAME libpng
22 | LIBRARY_HINTS png libpng png15 libpng15 png14 libpng14 png12 libpng12
23 | HEADER_HINTS png.h)
24 |
25 | findpkg_finish(PNG)
26 |
27 | list(APPEND PNG_LIBRARIES ${ZLIB_LIBRARY})
28 | endif()
29 |
--------------------------------------------------------------------------------
/CMake/Packages/FindSDL.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find SDL
2 | # Once done, this will define
3 | #
4 | # SDL_LIBRARIES, the name of the library to link against
5 | # SDL_FOUND, if false, do not try to link to SDL
6 | # SDL_INCLUDE_DIRS, where to find SDL.h
7 | #
8 | # This module responds to the the flag:
9 | # SDL_BUILDING_LIBRARY
10 | # If this is defined, then no SDL_main will be linked in because
11 | # only applications need main().
12 | # Otherwise, it is assumed you are building an application and this
13 | # module will attempt to locate and set the the proper link flags
14 | # as part of the returned SDL_LIBRARY variable.
15 |
16 | if(NOT SDL_FOUND)
17 | include(PkgUtils)
18 | findpkg_begin(SDL)
19 |
20 | # SDL may require threads on your system.
21 | # The Apple build may not need an explicit flag because one of the
22 | # frameworks may already provide it.
23 | # But for non-OSX systems, I will use the CMake Threads package.
24 | IF(NOT APPLE)
25 | FIND_PACKAGE(Threads)
26 | ENDIF(NOT APPLE)
27 |
28 | define_find_pkg(SDL
29 | PKG_CONFIG_NAME sdl
30 | LIBRARY_HINTS SDL SDL-1.1
31 | HEADER_HINTS SDL.h
32 | HEADER_SUFFIXES SDL)
33 |
34 | findpkg_finish(SDL)
35 |
36 | # For SDLmain
37 | IF(NOT SDL_BUILDING_LIBRARY)
38 | find_library(SDLMAIN_LIBRARY NAMES SDLmain SDLmain-1.1 HINTS ${SDL_LIB_SEARCH_PATH} ${SDL_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "")
39 | IF(SDLMAIN_LIBRARY)
40 | SET(SDL_LIBRARY_TEMP ${SDLMAIN_LIBRARY} ${SDL_LIBRARY_TEMP})
41 | ENDIF(SDLMAIN_LIBRARY)
42 | ENDIF(NOT SDL_BUILDING_LIBRARY)
43 |
44 | # MinGW needs an additional library, mwindows
45 | # It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows
46 | # (Actually on second look, I think it only needs one of the m* libraries.)
47 | IF(MINGW)
48 | list(APPEND SDL_LIBRARIES mingw32)
49 | ENDIF(MINGW)
50 |
51 | # For OS X, SDL uses Cocoa as a backend so it must link to Cocoa.
52 | # CMake doesn't display the -framework Cocoa string in the UI even
53 | # though it actually is there if I modify a pre-used variable.
54 | # I think it has something to do with the CACHE STRING.
55 | # So I use a temporary variable until the end so I can set the
56 | # "real" variable in one-shot.
57 | IF(APPLE)
58 | list(APPEND SDL_LIBRARIES "-framework Cocoa")
59 | ENDIF(APPLE)
60 |
61 | # For threads, as mentioned Apple doesn't need this.
62 | # In fact, there seems to be a problem if I used the Threads package
63 | # and try using this line, so I'm just skipping it entirely for OS X.
64 | IF(NOT APPLE)
65 | list(APPEND SDL_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
66 | ENDIF(NOT APPLE)
67 | endif()
68 |
--------------------------------------------------------------------------------
/CMake/Packages/FindSDL_mixer.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find SDL mixer
2 | # Once done, this will define
3 | #
4 | # SDLMIXER_LIBRARIES, the name of the library to link against
5 | # SDLMIXER_FOUND, if false, do not try to link to SDL mixer
6 | # SDLMIXER_INCLUDE_DIRS, where to find headers
7 |
8 | if(NOT SDLMIXER_FOUND)
9 | include(PkgUtils)
10 | findpkg_begin(SDLMIXER)
11 |
12 | define_find_pkg(SDLMIXER
13 | PKG_CONFIG_NAME SDL_mixer
14 | LIBRARY_HINTS SDL_mixer
15 | HEADER_HINTS SDL_mixer.h)
16 |
17 | findpkg_finish(SDLMIXER)
18 | endif()
19 |
--------------------------------------------------------------------------------
/CMake/Packages/FindUnzip.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find unzip
2 | # Once done, this will define
3 | #
4 | # UNZIP_INCLUDE_DIRS, where to find png.h, etc.
5 | # UNZIP_LIBRARIES, the libraries to link against to use UNZIP.
6 | # UNZIP_FOUND, If false, do not try to use UNZIP.
7 |
8 | if(NOT UNZIP_FOUND)
9 | include(PkgUtils)
10 | findpkg_begin(UNZIP)
11 |
12 | define_find_pkg(UNZIP
13 | LIBRARY_HINTS libunzip unzip
14 | HEADER_HINTS unzip.h)
15 |
16 | findpkg_finish(UNZIP)
17 | endif()
18 |
--------------------------------------------------------------------------------
/CMake/Packages/FindZLIB.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find ZLIB
2 | # Once done, this will define
3 | #
4 | # ZLIB_FOUND - system has ZLIB
5 | # ZLIB_INCLUDE_DIRS - the ZLIB include directories
6 | # ZLIB_LIBRARIES - link these to use ZLIB
7 |
8 | if(NOT ZLIB_FOUND)
9 | include(PkgUtils)
10 | findpkg_begin(ZLIB)
11 |
12 | define_find_pkg(ZLIB
13 | PKG_CONFIG_NAME zzip-zlib-config
14 | LIBRARY_HINTS z zlib zdll
15 | HEADER_HINTS zlib.h)
16 |
17 | findpkg_finish(ZLIB)
18 | endif()
19 |
--------------------------------------------------------------------------------
/CMake/SetupDepends.cmake:
--------------------------------------------------------------------------------
1 | include(LogFeature)
2 | include(PkgUtils)
3 | prepare_dep_search(NGE2)
4 |
5 | ################################################################################
6 | # nge2
7 | set(NGE2_DEP_LIBS)
8 | # Find zlib
9 | find_package(ZLIB)
10 | log_feature(ZLIB_FOUND "zlib" "Simple data compression library" "http://www.zlib.net" REQUIRED)
11 | add_package(ZLIB NGE2_DEP_LIBS)
12 |
13 | find_package(JPEG)
14 | log_feature(JPEG_FOUND "libjpeg" "Library for JPEG image compression" "http://sourceforge.net/projects/libjpeg" REQUIRED)
15 | add_package(JPEG NGE2_DEP_LIBS)
16 |
17 | find_package(PNG)
18 | log_feature(PNG_FOUND "libpng" "Official PNG reference library" "http://www.libpng.org/pub/png/libpng.html" REQUIRED)
19 | add_package(PNG NGE2_DEP_LIBS)
20 |
21 | if(NOT ANDROID)
22 | find_package(GIF)
23 | log_feature(GIF_FOUND "giflib" " A library for processing GIF" "http://sourceforge.net/projects/giflib" REQUIRED)
24 | add_package(GIF NGE2_DEP_LIBS)
25 | endif()
26 |
27 | # Find FreeType
28 | find_package(Freetype)
29 | log_feature(FREETYPE_FOUND "freetype" "Portable font engine" "http://www.freetype.org" REQUIRED)
30 | add_package(FREETYPE NGE2_DEP_LIBS)
31 |
32 | if(WIN32 OR LINUX)
33 | if(NOT ANDROID)
34 | # Find OpenGL
35 | find_package(OpenGL)
36 | log_feature(OPENGL_FOUND "OpenGL" "OpenGL render system" "http://www.opengl.org/" REQUIRED)
37 | add_package(OPENGL NGE2_DEP_LIBS)
38 | find_package(GLEW)
39 | log_feature(GLEW_FOUND "GLEW" "The OpenGL Extension Wrangler Library" "http://glew.sourceforge.net/" REQUIRED)
40 | add_package(GLEW NGE2_DEP_LIBS)
41 | endif()
42 | endif()
43 |
44 | find_package(Unzip)
45 | log_feature(UNZIP_FOUND "unzip" "a unzip library, you can download it from download page." "" REQUIRED)
46 |
47 | ################################################################################
48 | # coolauido
49 | if(LINUX AND NOT ANDROID)
50 | find_package(GStreamer)
51 | log_feature(GSTREAMER_FOUND "Gstreamer" "Open source multimedia framework" "http://gstreamer.freedesktop.org/" REQUIRED)
52 | endif()
53 |
54 | ################################################################################
55 | # Tools
56 | find_package(Doxygen)
57 | log_feature(DOXYGEN_FOUND "Doxygen" "Tool for building API documentation" "http://doxygen.org")
58 |
59 | # Display results, terminate if anything required is missing
60 | set(MISS_FEATURE_CUSTOM_MSG "-- If you are in Windows, try passing -DNGE2_DEPENDENCIES_DIR=")
61 | display_feature_log()
62 |
--------------------------------------------------------------------------------
/CMake/Templates/merge_archives_unix.cmake.in:
--------------------------------------------------------------------------------
1 | # This script merges many static libraries into
2 | # one big library on Unix.
3 | set(target_location "@target_location@")
4 | set(target "@target@")
5 | set(static_libs "@static_libs@")
6 | set(CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@")
7 | set(CMAKE_AR "@CMAKE_AR@")
8 | set(CMAKE_RANLIB "@CMAKE_RANLIB@")
9 |
10 |
11 | set(temp_dir ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${target})
12 | make_directory(${temp_dir})
13 | # Extract each archive to its own subdirectory(avoid object filename clashes)
14 | foreach(lib ${static_libs})
15 | get_filename_component(name_no_ext ${lib} NAME_WE)
16 | set(temp_subdir ${temp_dir}/${name_no_ext})
17 | make_directory(${temp_subdir})
18 | execute_process(
19 | COMMAND ${CMAKE_AR} -x ${lib}
20 | WORKING_DIRECTORY ${temp_subdir}
21 | )
22 |
23 | file(GLOB_RECURSE lib_objects "${temp_subdir}/*")
24 | set(objects ${objects} ${lib_objects})
25 | endforeach()
26 |
27 | # Use relative paths, makes command line shorter.
28 | get_filename_component(abs_temp_dir ${temp_dir} ABSOLUTE)
29 | foreach(obj ${objects})
30 | file(RELATIVE_PATH obj ${abs_temp_dir} ${obj})
31 | file(TO_NATIVE_PATH ${obj} obj)
32 | set(all_objects ${all_objects} ${obj})
33 | endforeach()
34 |
35 | file(TO_NATIVE_PATH ${target_location} ${target_location})
36 | # Now pack the objects into library with ar.
37 | execute_process(
38 | COMMAND ${CMAKE_AR} -r ${target_location} ${all_objects}
39 | WORKING_DIRECTORY ${temp_dir}
40 | )
41 | execute_process(
42 | COMMAND ${CMAKE_RANLIB} ${target_location}
43 | WORKING_DIRECTORY ${temp_dir}
44 | )
45 |
46 | # Cleanup
47 | file(REMOVE_RECURSE ${temp_dir})
48 |
--------------------------------------------------------------------------------
/CMake/Utils/CopyFile.cmake:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # this file provide function which can copy file on build time.
3 | ################################################################################
4 |
5 | if(NOT COMMAND add_copy_file)
6 | function(copy_file output fromfile tofile)
7 | add_custom_command(
8 | OUTPUT "${output}"
9 | DEPENDS "${fromfile}"
10 | COMMAND "${CMAKE_COMMAND}" -E copy
11 | "${fromfile}"
12 | "${tofile}"
13 | )
14 | endfunction()
15 |
16 | function(add_copy_file outputs from to)
17 | if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
18 | return()
19 | endif()
20 |
21 | if(NOT to)
22 | set(to ${from})
23 | endif()
24 |
25 | copy_file(${to} "${CMAKE_CURRENT_SOURCE_DIR}/${from}" "${CMAKE_CURRENT_BINARY_DIR}/${to}")
26 | list(APPEND ${outputs} ${to})
27 | set(${outputs} ${${outputs}} PARENT_SCOPE)
28 | endfunction()
29 | endif()
30 |
--------------------------------------------------------------------------------
/CMake/Utils/LibUtils.cmake:
--------------------------------------------------------------------------------
1 | # Following macros are exported
2 | #
3 | # - merge_static_libs(target
4 | # [OUTPUT_NAME output_name]
5 | # LIBRARIES lib1 ... libN)
6 | # This macro merges several static libraries into a single one.
7 |
8 | if(NOT COMMAND merge_static_libs)
9 | include(CMakeParseArguments)
10 |
11 | # Merge static libraries into a big static lib. The resulting library
12 | # should not not have dependencies on other static libraries.
13 | function(merge_static_libs target)
14 | set(options)
15 | set(oneValueArgs OUTPUT_NAME)
16 | set(multiValueArgs LIBRARIES)
17 | cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
18 |
19 | # To produce a library we need at least one source file.
20 | # It is created by ADD_CUSTOM_COMMAND below and will helps
21 | # also help to track dependencies.
22 | set(source_file ${CMAKE_CURRENT_BINARY_DIR}/${target}_depends.c)
23 | add_library(${target} STATIC ${source_file})
24 |
25 | if(arg_OUTPUT_NAME)
26 | set_target_properties(${target} PROPERTIES OUTPUT_NAME ${arg_OUTPUT_NAME})
27 | endif()
28 |
29 | set(oslibs)
30 | set(static_libs)
31 | foreach(lib ${arg_LIBRARIES})
32 | get_target_property(lib_location ${lib} LOCATION_${CMAKE_BUILD_TYPE})
33 | get_target_property(lib_type ${lib} TYPE)
34 | if(NOT lib_location)
35 | list(APPEND oslibs ${lib})
36 | else()
37 | # This is a target in current project
38 | # (can be a static or shared lib)
39 | if(lib_type STREQUAL "STATIC_LIBRARY")
40 | list(APPEND static_libs ${lib_location})
41 | add_dependencies(${target} ${lib})
42 | endif()
43 | endif()
44 | endforeach()
45 | if(OSLIBS)
46 | list(REMOVE_DUPLICATES OSLIBS)
47 | target_link_libraries(${TARGET} ${OSLIBS})
48 | endif()
49 |
50 | # Make the generated dummy source file depended on all static input
51 | # libs. If input lib changes,the source file is touched
52 | # which causes the desired effect (relink).
53 | add_custom_command(
54 | OUTPUT ${source_file}
55 | COMMAND ${CMAKE_COMMAND} -E touch ${source_file}
56 | DEPENDS ${static_libs})
57 |
58 | if(MSVC)
59 | # To merge libs, just pass them to lib.exe command line.
60 | set(linker_extra_flags "")
61 | foreach(lib ${static_libs})
62 | set(linker_extra_flags "${linker_extra_flags} ${lib}")
63 | endforeach()
64 | set_target_properties(${target} PROPERTIES STATIC_LIBRARY_FLAGS
65 | "${linker_extra_flags}")
66 | else()
67 | get_target_property(target_location ${target} LOCATION_${CMAKE_BUILD_TYPE})
68 | if(APPLE)
69 | # Use OSX's libtool to merge archives (ihandles universal
70 | # binaries properly)
71 | add_custom_command(TARGET ${target} POST_BUILD
72 | COMMAND rm ${target_location}
73 | COMMAND /usr/bin/libtool -static -o ${target_location}
74 | ${static_libs}
75 | )
76 | else()
77 | # Generic Unix, Cygwin or MinGW. In post-build step, call
78 | # script, that extracts objects from archives with "ar x"
79 | # and repacks them with "ar r"
80 | configure_file(
81 | ${CMAKE_TEMPLATE_PATH}/merge_archives_unix.cmake.in
82 | ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${target}.cmake
83 | @ONLY
84 | )
85 | add_custom_command(TARGET ${target} POST_BUILD
86 | COMMAND rm ${target_location}
87 | COMMAND ${CMAKE_COMMAND} -P
88 | ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${target}.cmake
89 | )
90 | endif()
91 | endif()
92 | endfunction()
93 | endif()
94 |
--------------------------------------------------------------------------------
/CMake/Utils/RmDupLibs.cmake:
--------------------------------------------------------------------------------
1 | #######################################################################
2 | # This file takes care of lib depends for target.
3 | #######################################################################
4 |
5 | if(NOT COMMAND RM_DUP_LIB)
6 | macro(check_specifier var prefix)
7 | set(${prefix})
8 | foreach(_spec "optimized" "debug")
9 | set(${prefix}_${_spec})
10 | if(${${var}} STREQUAL ${_spec})
11 | set(${prefix} 1)
12 | set(${prefix}_${_spec} 1)
13 | break()
14 | endif()
15 | endforeach()
16 | endmacro()
17 |
18 | function(pick_out_lib lib return)
19 | # Watch out for -framework options (OS X)
20 | IF (NOT lib MATCHES "-framework.*|.*framework")
21 | # Remove absolute path and add it to _LIB_DIRS.
22 | IF(lib MATCHES "/.*")
23 | STRING(REGEX REPLACE "/.*/(.*)" "\\1" lib ${lib})
24 | ENDIF()
25 |
26 | # Remove .a/.so/.dylib.
27 | STRING(REGEX REPLACE "lib(.*)\\.(a|so|dylib)" "\\1" lib ${lib})
28 |
29 | # Remove -l prefix if it's there already.
30 | STRING(REGEX REPLACE "-l(.*)" "\\1" lib ${lib})
31 | ENDIF()
32 | set(${return} ${lib} PARENT_SCOPE)
33 | endfunction()
34 |
35 | macro(check_lib)
36 | set(_llib)
37 | check_specifier(_lib _skip)
38 | if(_skip) # spec lib
39 | set(_spec ${_lib})
40 |
41 | math(EXPR _idx "${_idx} + 1")
42 | list(GET _libs ${_idx} _lib)
43 |
44 | pick_out_lib(${_lib} _llib)
45 | set("_lib_var_${_llib}_${_spec}" ${_spec} ${_lib})
46 | list(APPEND _lib_vars "_lib_var_${_llib}_${_spec}")
47 | else() # normal lib
48 | pick_out_lib(${_lib} _llib)
49 | set("_lib_var_${_llib}" ${_lib})
50 | list(APPEND _lib_vars "_lib_var_${_llib}")
51 | endif()
52 | endmacro()
53 |
54 | function(rm_dup_lib libs_var)
55 | set(_libs ${${libs_var}})
56 | set(_lib_vars)
57 | set(_idx 0)
58 | list(LENGTH _libs _max_idx)
59 | while(_idx LESS _max_idx)
60 | list(GET _libs ${_idx} _lib)
61 | if(_lib)
62 | check_lib()
63 | else()
64 | break()
65 | endif()
66 | math(EXPR _idx "${_idx} + 1")
67 | endwhile()
68 |
69 | list(REVERSE _lib_vars)
70 | list(REMOVE_DUPLICATES _lib_vars)
71 | list(REVERSE _lib_vars)
72 |
73 | set(_libs)
74 | foreach(_var ${_lib_vars})
75 | list(APPEND _libs ${${_var}})
76 | endforeach()
77 | set(${libs_var} ${_libs} PARENT_SCOPE)
78 | endfunction()
79 | endif()
80 |
--------------------------------------------------------------------------------
/HISTORY.md:
--------------------------------------------------------------------------------
1 | 2006-07-01 前身
2 | -----------------
3 | 2006-07-xx 我开了一个坑叫中国象棋PSP,最初是用SDL(注1)开发的UI,不过个人觉得太难看,软件加速的FPS相当的低,使用非常不方便,所以打算用 opengl和GU做图形加速,结果效果很好,后来把这几个cpp拿出来,这就是NGE第一版的由来。那时也叫改进图形系统的SDL,NGE的名字就代表 Not a Game Engine的递归缩写,表示它不是一个游戏引擎,只是一个辅助的库。由于当时JGE的分屏的BUG非常使人懊恼(随机出现),所以NGE也拥有一些用户,一些人改进它做了自己的显示模块。
4 | 注1:【目前SDL已经走到死路,所有的都是软件加速,还好它自己也在进化,SDL1.3完全不兼容以前的SDL了,采用的是硬件加速,函数接口也改变了】
5 |
6 | 2007-12-02 起航
7 | -----------------
8 | 2007-12-02 一个偶然的机会,认识了澄空的朝比奈みくる得知TA在移植ToHeart2的 PSP版,TA需要一个跨平台的开发库来移植这个游戏,而TA使用过NGE1,打算用它来移植,由于ToHeart2用了XviD的库作为了它的动画播放的库,而XviD是采用GPL而不是LGPL,需要开发所有源代码,而日本公司也是足够的厚道,有人指出来,它就按照规则开放了源代码。所以我们得到了 ToHeart2的全部源代码,并且编译了。然后准备用这份代码进行移植。开发人员只有我和朝比奈みくる,由我负责图形显示的开发,由朝比奈みくる负责音频的开发和引擎的移植,经过一个月左右的移植,代码基本熟悉了,引擎核心代码移植成功。由于ToHeart2是2000年的技术,采用的是HDC的方式直接画问题,所有效果变换都是软件实现(比如渐入渐出,图片转场)内存消耗极大,峰值内存到达200M,所有资源文件一次读入Orz。所以重要的是对内存消耗的减少。
9 | 2008-03-02 我主要负责显示部分,所以打算做一个高度独立的开发库用于显示,windows采用Opengl,PSP上采用GU,可以载入主流的图片格式,提供硬件加速模式的画面效果。由于有NGE的积累,所以很快就实现了显示接口,兼容NGE第一版的高效图像显示。NGE2的雏形就这样产生了。期间经历朝比奈みくる远赴日本停止开发等诸多事件。
10 | 2008-6-xx ToHeart2的音频和引擎移植成功,并且能再PSP上播放了,看到了移植的曙光。
11 | 2008-9-xx NGE2的原型出来了,并且开始了基本的测试。
12 |
13 | 2009-2-14 发展
14 | -----------------
15 | 2009-2-14 这是个值得纪念的日子,NGE2正式版发布,支持PSP和windows,可以在windows下编写PSP程序。
16 | 2009-2-xx TOPOC的第一个项目,大家来找茬PSP确定,又菜菜主刀,newcreat提供技术支持,采用NGE2制作,为了测试NGE2的稳定性。期间有多个NGE2的小游戏发布,NGE2为开发者所熟悉。
17 | 2009-3-xx ToHeart2由于官方要发布游戏,所以宣布费坑。
18 | 2009-3-xx 由于NGE2是为AVG游戏制作的,所以提供很多AVG的特效函数,抽象为效果器effector。白枫计划开发基于NGE2开发库的AVG游戏引擎 AVG Maker Portable(AMP)。
19 | 2009-5-xx 菜菜写了NGE2效果库,在渐入渐出效果的基础上,增加了画面转场效果器。
20 | 2009-6-xx 白枫整合了各种效果器的测试代码,并做了一个demo展示。
21 | 2009-6-xx 大家来找茬PSP发布,发布后颇受好评,也引发了PSP软件开发的高潮。
22 | 2009-7-xx-----2009-8-xx 移植nge2到iPhone.
23 | 2009-08-15 NGE2 的iPhone版移植,基本功能有了,缺少音频。
24 | 2009-08-----2009-10 新的音频库libcoolaudio接口确定,由newcreat开发windows版,cooleyes开发psp版,菜菜开发iPhone版。并在 10月份完成基本功能。
25 |
26 | 2009-10-01 进化
27 | -----------------
28 | 2009-10----2010-1 进一步完善NGE2,iPhone版彻底完成。准备写Iphone版教程.为NGE2做iPhone游戏并且贩卖游戏打下基础。
29 | 2009-12-xx yangxiuliang开放了了基于NGE2的联想输入法源代码。
30 | 2009-12-xx NGE2的GUI库NGE2 WIN7项目启动。由菜菜开发。
31 | 2010-1-xx 白枫的AMP0.57发布,附带了多个AVG游戏。NGE2继续为AMP提供优先支持。
32 | 2010-1-xx 大家来找茬PSP开放了源代码。
33 | 2010-2 未完待续
34 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/README.md
--------------------------------------------------------------------------------
/Xcoder/Libnge2.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Xcoder/Libnge2.xcodeproj/project.xcworkspace/xcuserdata/long.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/Xcoder/Libnge2.xcodeproj/project.xcworkspace/xcuserdata/long.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/Xcoder/Libnge2.xcodeproj/xcuserdata/long.xcuserdatad/xcschemes/Libnge2.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
14 |
20 |
21 |
22 |
23 |
24 |
29 |
30 |
31 |
32 |
41 |
42 |
43 |
44 |
50 |
51 |
53 |
54 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/Xcoder/Libnge2.xcodeproj/xcuserdata/long.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | Libnge2.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | FD2F5EAD1606FD2800A291AE
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Xcoder/downloadUrl.txt:
--------------------------------------------------------------------------------
1 | Download xCoder Project:
2 | https://github.com/ifreedom/libnge2/downloads/Xcoder.zip
3 | And cover it!
--------------------------------------------------------------------------------
/and_jni_base/nge_android_jni.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file nge_android_jni.c
3 | * @author Kun Wang
4 | * @date 2012/10/21 14:43:03
5 | *
6 | * Copyright 2012 Kun Wang
7 | *
8 | */
9 | #include
10 | #include
11 | #include "nge_android_jni.h"
12 |
13 | JavaVM* javaVM = NULL;
14 |
15 | jint JNI_OnLoad(JavaVM* vm, void* reserved)
16 | {
17 | (void)reserved;
18 | javaVM = vm;
19 | return JNI_VERSION_1_2;
20 | }
21 |
22 | JNIEnv* nge_GetEnv()
23 | {
24 | JNIEnv* env = NULL;
25 | if (javaVM) (*javaVM)->GetEnv(javaVM, (void**)&env, JNI_VERSION_1_2);
26 | return env;
27 | }
28 |
--------------------------------------------------------------------------------
/and_jni_base/nge_android_jni.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file nge_android_jni.h
3 | * @author Kun Wang
4 | * @date 2012/10/21 14:46:24
5 | *
6 | * Copyright 2012 Kun Wang
7 | *
8 | */
9 |
10 | #ifndef _NGE_ANDROID_JNI_H
11 | #define _NGE_ANDROID_JNI_H
12 |
13 | #ifdef __cplusplus
14 | extern "C" {
15 | #endif
16 |
17 | JNIEnv* nge_GetEnv();
18 |
19 | #ifdef __cplusplus
20 | }
21 | #endif
22 |
23 | #endif /* _NGE_ANDROID_JNI_H */
24 |
--------------------------------------------------------------------------------
/coolaudio/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | project(coolaudio C CXX)
2 | set(COOLAUDIO_SRCS)
3 | set(COOLAUDIO_LIBS)
4 | set(COOLAUDIO_VERSION 1.1)
5 |
6 | include_directories(. ../and_jni_base ../include)
7 |
8 | if(PSP OR IPHONE)
9 | list(APPEND COOLAUDIO_SRCS libcoolaudio.c)
10 | endif()
11 |
12 | if(ANDROID)
13 | list(APPEND COOLAUDIO_SRCS
14 | android_mediaplayer.c
15 | audio_android.c)
16 | elseif(PSP)
17 | list(APPEND COOLAUDIO_SRCS
18 | audio_codec.cpp
19 | codecs/mp3_codec.cpp
20 | common/buffered_reader.c
21 | common/mem64.c
22 | nge_audio_psp.cpp
23 | parsers/mp3_parser.cpp
24 | parsers/oggvorbis_parser.cpp
25 | parsers/pcm_parser.cpp
26 | nge_io_mem.c
27 | )
28 | elseif(IPHONE) # IPHONEOS?
29 | list(APPEND COOLAUDIO_SRCS
30 | LSAudioDeleCall.m
31 | libLSAudio.m
32 | )
33 | elseif(LINUX)
34 | list(APPEND COOLAUDIO_SRCS
35 | nge_audio_linux.c)
36 | add_package(GSTREAMER COOLAUDIO_LIBS)
37 | endif()
38 |
39 | if(PSP)
40 | list(APPEND COOLAUDIO_LIBS vorbisfile vorbis ogg pspmpeg pspaudiocodec pspaudio)
41 | ADD_PSPSDK_LIBS(COOLAUDIO_LIBS)
42 | endif()
43 |
44 | if(ANDROID)
45 | add_library(coolaudio STATIC ${COOLAUDIO_SRCS})
46 | elseif(PSP OR LINUX)
47 | add_library(coolaudio STATIC ${COOLAUDIO_SRCS})
48 | install(TARGETS coolaudio DESTINATION lib)
49 | elseif(WIN32)
50 | find_library(COOLAUDIO_LOC NAMES coolaudio libcoolaudio PATHS "${CMAKE_SOURCE_DIR}/Win32Depends" ${NGE2_DEPENDENCIES_DIR} PATH_SUFFIXES lib)
51 | set(COOLAUDIO_LIBRARY ${COOLAUDIO_LOC} PARENT_SCOPE)
52 | endif()
53 |
54 | if(WIN32 OR PSP OR LINUX)
55 | set(COOLAUDIO_LIBS ${COOLAUDIO_LIBS} PARENT_SCOPE)
56 | endif()
57 |
58 | if(ANDROID)
59 | include(CopyFile)
60 | set(COOLAUDIO_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" FORCE)
61 | function(copy_coolaudio_android_files app_name android_dir)
62 | configure_file(
63 | "${COOLAUDIO_DIR}/LibCoolAudio.java"
64 | "${android_dir}/src/org/libnge/nge2/LibCoolAudio.java" COPYONLY)
65 | endfunction()
66 | endif()
67 |
--------------------------------------------------------------------------------
/coolaudio/LSAudioDeleCall.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/coolaudio/LSAudioDeleCall.h
--------------------------------------------------------------------------------
/coolaudio/LSAudioDeleCall.m:
--------------------------------------------------------------------------------
1 | //
2 | // LSAudioDeleCall.m
3 | // LSAudio
4 | //
5 | // Created by jock li on 8/21/09.
6 | // Copyright 2009 topoc. All rights reserved.
7 | //
8 |
9 | #import "LSAudioDeleCall.h"
10 |
11 |
12 | @implementation LSAudioDeleCall
13 |
14 | @synthesize mcoreaudio;
15 |
16 | - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
17 | {
18 | if(mcoreaudio == NULL || mcoreaudio->player == NULL)
19 | return;
20 | if (flag) {
21 | // REPLAY IF NEED
22 | if(mcoreaudio->playcount>1)
23 | {
24 | mcoreaudio->play((audio_play_p)mcoreaudio, mcoreaudio->playcount-1, mcoreaudio->autostop);
25 | }
26 | else if(mcoreaudio->autostop)
27 | {
28 | mcoreaudio->stop((audio_play_p)mcoreaudio);
29 | }
30 | }
31 | else {
32 | // CALL STOP
33 | mcoreaudio->stop((audio_play_p)mcoreaudio);
34 | }
35 |
36 | }
37 |
38 | - (void)initWithCoreAudioPlay:(core_audio_play_p) pcoreaudio
39 | {
40 | self.mcoreaudio = pcoreaudio;
41 | }
42 | @end
43 |
--------------------------------------------------------------------------------
/coolaudio/Makefile_lib:
--------------------------------------------------------------------------------
1 | TARGET_LIB = libcoolaudio.a
2 | OBJS = nge_audio_psp.o audio_codec.o \
3 | common/buffered_reader.o common/mem64.o \
4 | parsers/pcm_parser.o parsers/mp3_parser.o parsers/oggvorbis_parser.o \
5 | codecs/mp3_codec.o libcoolaudio.o
6 |
7 | INCDIR =
8 | CFLAGS = -G0 -Wall -O2 -DCOOLAUDIO_PSP
9 | CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions
10 | ASFLAGS = $(CFLAGS)
11 |
12 | PSPSDK=$(shell psp-config --pspsdk-path)
13 | PSPBIN = $(PSPSDK)/../bin
14 | include $(PSPSDK)/lib/build.mak
15 | install:
16 | cp $(TARGET_LIB) ../../lib/
17 | cp audio_interface.h ../../include/
18 |
--------------------------------------------------------------------------------
/coolaudio/android_mediaplayer.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file android_mediaplayer.h
3 | * @author Kun Wang
4 | * @date 2012/10/21 14:58:37
5 | *
6 | * Copyright 2012 Kun Wang
7 | *
8 | */
9 |
10 | #ifndef _ANDROID_MEDIAPLAYER_H
11 | #define _ANDROID_MEDIAPLAYER_H
12 |
13 | #ifdef __cplusplus
14 | extern "C" {
15 | #endif
16 |
17 | void load_CA();
18 | void release_CA();
19 | audio_play_p android_mediaplayer_create();
20 |
21 | #ifdef __cplusplus
22 | }
23 | #endif
24 |
25 | #endif /* _ANDROID_MEDIAPLAYER_H */
26 |
--------------------------------------------------------------------------------
/coolaudio/audio_android.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file audio_android.c
3 | * @author Kun Wang
4 | * @date 2011/06/12 14:56:05
5 | *
6 | * Copyright 2011 Kun Wang
7 | *
8 | */
9 | #include
10 | #include "nge_android_jni.h"
11 | #include "audio_android.h"
12 |
13 | #include "android_mediaplayer.h"
14 |
15 | #include
16 | #include
17 | #include
18 |
19 | static JNIEnv* env;
20 |
21 | #define GetEnv() env = nge_GetEnv()
22 |
23 | void CoolAudioDefaultInit()
24 | {
25 | load_CA();
26 | }
27 |
28 | void CoolAudioDefaultFini()
29 | {
30 | release_CA();
31 | }
32 |
33 | jobject createFD(JNIEnv* env, int fd)
34 | {
35 | jobject fdsc;
36 | jclass cls;
37 | jmethodID cons_mid;
38 | jfieldID field;
39 |
40 | GetEnv();
41 |
42 | cls = (*env)->FindClass(env, "java/io/FileDescriptor");
43 | cons_mid = (*env)->GetMethodID(env, cls, "", "()V");
44 | fdsc = (*env)->NewObject(env, cls, cons_mid);
45 | field = (*env)->GetFieldID(env, cls, "fd", "I");
46 | (*env)->SetIntField(env, fdsc, field, fd);
47 | return fdsc;
48 | }
49 |
50 | audio_play_p CreateWavPlayer()
51 | {
52 | return (audio_play_p) android_mediaplayer_create();
53 | }
54 |
55 | audio_play_p CreateMp3Player()
56 | {
57 | return (audio_play_p) android_mediaplayer_create();
58 | }
59 |
60 | audio_play_p CreateOggPlayer()
61 | {
62 | return (audio_play_p) android_mediaplayer_create();
63 | }
64 |
--------------------------------------------------------------------------------
/coolaudio/audio_android.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file audio_android.h
3 | * @author Kun Wang
4 | * @date 2012/10/21 14:52:37
5 | *
6 | * Copyright 2012 Kun Wang
7 | *
8 | */
9 |
10 | #ifndef _AUDIO_ANDROID_H
11 | #define _AUDIO_ANDROID_H
12 |
13 | #include "audio_interface.h"
14 | #include
15 |
16 | #define FALSE 0
17 | #define TRUE 1
18 |
19 | #define LOG_TAG "libcoolaudio"
20 |
21 | #define LOG_GOTO_ERROR(str) LOGE(str); goto error
22 |
23 | #ifdef __cplusplus
24 | extern "C" {
25 | #endif
26 |
27 | static inline void LOGI(const char* fmt, ...) {
28 | va_list args;
29 | va_start(args, fmt);
30 | __android_log_vprint(ANDROID_LOG_INFO,LOG_TAG, fmt, args);
31 | va_end(args);
32 | }
33 | static inline void LOGE(const char* fmt, ...) {
34 | va_list args;
35 | va_start(args, fmt);
36 | __android_log_vprint(ANDROID_LOG_ERROR,LOG_TAG, fmt, args);
37 | va_end(args);
38 | }
39 |
40 | jobject createFD(JNIEnv* env, int fd);
41 |
42 | #ifdef __cplusplus
43 | }
44 | #endif
45 |
46 | #endif /* _AUDIO_ANDROID_H */
47 |
--------------------------------------------------------------------------------
/coolaudio/audio_codec.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "audio_codec.h"
3 | #include "codecs/mp3_codec.h"
4 |
5 | AudioCodec* AudioCodec::create_audio_codec(CodecId id)
6 | {
7 | AudioCodec* codec = NULL;
8 | switch(id){
9 | case MP3:
10 | codec = new Mp3Codec;
11 | break;
12 | case ATRAC3:
13 | break;
14 | case AAC:
15 | break;
16 | case TTA:
17 | break;
18 | case WMA:
19 | break;
20 | default:
21 | break;
22 | }
23 | return codec;
24 | }
25 |
--------------------------------------------------------------------------------
/coolaudio/audio_codec.h:
--------------------------------------------------------------------------------
1 | /*
2 | * _____ _ _____
3 | * / ___|(_) / __ \
4 | * \ `--. _ _ __ ___ _ __ ___ __ __`' / /'
5 | * `--. \| || '__|/ _ \| '_ \ / __| \ \ / / / /
6 | * /\__/ /| || | | __/| | | |\__ \ \ V / ./ /___
7 | * \____/ |_||_| \___||_| |_||___/ \_/ \_____/
8 | *
9 | *
10 | * Copyright (C) 2007 cooleyes
11 | * eyes.cooleyes@gmail.com
12 | *
13 | * This Program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2, or (at your option)
16 | * any later version.
17 | *
18 | * This Program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with GNU Make; see the file COPYING. If not, write to
25 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 | * http://www.gnu.org/copyleft/gpl.html
27 | *
28 | */
29 |
30 | #ifndef __SIRENS2_AUDIO_CODEC_H__
31 | #define __SIRENS2_AUDIO_CODEC_H__
32 |
33 | #include
34 | //#include "codecs/mp3_codec.h"
35 | typedef struct AudioCodecInitData {
36 | uint32_t samplerate;
37 | uint32_t sample_bits;
38 | uint32_t channels;
39 | uint32_t samples_per_frame;
40 | uint32_t samples_per_decoded;
41 | uint32_t frame_align;
42 | uint8_t* extra_data;
43 | uint32_t extra_data_len;
44 | } AudioCodecInitData;
45 |
46 | //class Mp3Codec;
47 |
48 | class AudioCodec {
49 | public:
50 | typedef enum {ATRAC3, MP3, AAC, TTA, WMA} CodecId;
51 | virtual ~AudioCodec() {};
52 | virtual char* initialize(AudioCodecInitData* init_data) = 0;
53 | virtual void finalize() = 0;
54 | virtual int32_t decode(void* data, uint32_t data_len, void* pcm_data) = 0;
55 | virtual void reset() {};
56 | virtual bool frame_decode_finished() {return true;};
57 | static AudioCodec* create_audio_codec(CodecId id);
58 | };
59 |
60 | #endif
61 |
--------------------------------------------------------------------------------
/coolaudio/audio_parser.h:
--------------------------------------------------------------------------------
1 | /*
2 | * _____ _ _____
3 | * / ___|(_) / __ \
4 | * \ `--. _ _ __ ___ _ __ ___ __ __`' / /'
5 | * `--. \| || '__|/ _ \| '_ \ / __| \ \ / / / /
6 | * /\__/ /| || | | __/| | | |\__ \ \ V / ./ /___
7 | * \____/ |_||_| \___||_| |_||___/ \_/ \_____/
8 | *
9 | *
10 | * Copyright (C) 2007 cooleyes
11 | * eyes.cooleyes@gmail.com
12 | *
13 | * This Program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2, or (at your option)
16 | * any later version.
17 | *
18 | * This Program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with GNU Make; see the file COPYING. If not, write to
25 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 | * http://www.gnu.org/copyleft/gpl.html
27 | *
28 | */
29 |
30 | #ifndef __SIRENS2_AUDIO_PARSER_H__
31 | #define __SIRENS2_AUDIO_PARSER_H__
32 |
33 | #include
34 | #include "common/buffered_reader.h"
35 | #include "audio_codec.h"
36 |
37 | typedef struct AudioFrameIndex {
38 | uint32_t frame_position;
39 | uint32_t frame_size;
40 | } AudioFrameIndex;
41 |
42 | class AudioParser {
43 | public:
44 | virtual ~AudioParser() {};
45 | virtual char* open(const char* filename) = 0;
46 | virtual char* open_cb(audio_callbacks cb,int handle)=0;
47 | virtual void close() = 0;
48 |
49 | virtual uint32_t get_samplerate() = 0;
50 | virtual uint32_t get_channels() = 0;
51 | virtual uint64_t get_duration() = 0;
52 | virtual uint32_t get_samples_per_frame() = 0;
53 | virtual uint32_t get_max_samples_per_frame() = 0;
54 |
55 | virtual uint64_t seek_time(uint64_t time) = 0;
56 | virtual char* get_frame(void** pcm, uint32_t* samples) = 0;
57 |
58 | };
59 |
60 | #endif
61 |
--------------------------------------------------------------------------------
/coolaudio/codecs/mp3_codec.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * _____ _ _____
3 | * / ___|(_) / __ \
4 | * \ `--. _ _ __ ___ _ __ ___ __ __`' / /'
5 | * `--. \| || '__|/ _ \| '_ \ / __| \ \ / / / /
6 | * /\__/ /| || | | __/| | | |\__ \ \ V / ./ /___
7 | * \____/ |_||_| \___||_| |_||___/ \_/ \_____/
8 | *
9 | *
10 | * Copyright (C) 2007 cooleyes
11 | * eyes.cooleyes@gmail.com
12 | *
13 | * This Program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2, or (at your option)
16 | * any later version.
17 | *
18 | * This Program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with GNU Make; see the file COPYING. If not, write to
25 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 | * http://www.gnu.org/copyleft/gpl.html
27 | *
28 | */
29 | #include "mp3_codec.h"
30 | #include
31 | #include
32 | #include
33 |
34 | Mp3Codec::Mp3Codec() {
35 | init_flag = false;
36 | };
37 |
38 | Mp3Codec::~Mp3Codec() {
39 | };
40 |
41 | char* Mp3Codec::initialize(AudioCodecInitData* init_data) {
42 | audio_samplerate = init_data->samplerate;
43 | audio_samples_per_frame = init_data->samples_per_frame;
44 | audio_type = 0x1002;
45 |
46 | memset(me_audio_codec_buffer, 0, 65*sizeof(uint32_t));
47 | if ( sceAudiocodecCheckNeedMem((long unsigned int*) me_audio_codec_buffer, audio_type) < 0 )
48 | return "Mp3Codec : sceAudiocodecCheckNeedMem fail";
49 | if ( sceAudiocodecGetEDRAM((long unsigned int*)me_audio_codec_buffer, audio_type) < 0 )
50 | return "Mp3Codec : sceAudiocodecGetEDRAM fail";
51 | if ( sceAudiocodecInit((long unsigned int*)me_audio_codec_buffer, audio_type) < 0 ) {
52 | sceAudiocodecReleaseEDRAM((long unsigned int*)me_audio_codec_buffer);
53 | return "Mp3Codec : sceAudiocodecInit fail";
54 | }
55 | init_flag = true;
56 | return 0;
57 | };
58 |
59 | void Mp3Codec::finalize() {
60 | if( init_flag ) {
61 | sceAudiocodecReleaseEDRAM((long unsigned int*)me_audio_codec_buffer);
62 | init_flag = false;
63 | }
64 | };
65 |
66 | int32_t Mp3Codec::decode(void* data, uint32_t data_len, void* pcm_data) {
67 | if( init_flag ) {
68 | me_audio_codec_buffer[6] = (uint32_t)data;
69 | me_audio_codec_buffer[8] = (uint32_t)pcm_data;
70 | me_audio_codec_buffer[7] = data_len;
71 | me_audio_codec_buffer[10] = data_len;
72 | me_audio_codec_buffer[9] = audio_samples_per_frame << 2;
73 | if ( sceAudiocodecDecode((long unsigned int*)me_audio_codec_buffer, audio_type) < 0 )
74 | ;//return 0;
75 | return audio_samples_per_frame;
76 | }
77 | else
78 | return -1;
79 | };
80 |
--------------------------------------------------------------------------------
/coolaudio/codecs/mp3_codec.h:
--------------------------------------------------------------------------------
1 | /*
2 | * _____ _ _____
3 | * / ___|(_) / __ \
4 | * \ `--. _ _ __ ___ _ __ ___ __ __`' / /'
5 | * `--. \| || '__|/ _ \| '_ \ / __| \ \ / / / /
6 | * /\__/ /| || | | __/| | | |\__ \ \ V / ./ /___
7 | * \____/ |_||_| \___||_| |_||___/ \_/ \_____/
8 | *
9 | *
10 | * Copyright (C) 2007 cooleyes
11 | * eyes.cooleyes@gmail.com
12 | *
13 | * This Program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2, or (at your option)
16 | * any later version.
17 | *
18 | * This Program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with GNU Make; see the file COPYING. If not, write to
25 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 | * http://www.gnu.org/copyleft/gpl.html
27 | *
28 | */
29 |
30 | #ifndef __SIRENS2_MP3_CODEC_H__
31 | #define __SIRENS2_MP3_CODEC_H__
32 |
33 | #include "audio_codec.h"
34 |
35 |
36 |
37 | class Mp3Codec : public AudioCodec {
38 | private:
39 | uint32_t me_audio_codec_buffer[65] __attribute__((aligned(64)));
40 | uint32_t audio_type;
41 | uint32_t audio_samplerate;
42 | uint32_t audio_samples_per_frame;
43 |
44 | bool init_flag;
45 | public:
46 | Mp3Codec();
47 | ~Mp3Codec();
48 | char* initialize(AudioCodecInitData* init_data);
49 | void finalize();
50 | int32_t decode(void* data, uint32_t data_len, void* pcm_data);
51 | };
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/coolaudio/common/buffered_reader.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2006 cooleyes
3 | * eyes.cooleyes@gmail.com
4 | *
5 | * This Program is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 2, or (at your option)
8 | * any later version.
9 | *
10 | * This Program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with GNU Make; see the file COPYING. If not, write to
17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 | * http://www.gnu.org/copyleft/gpl.html
19 | *
20 | */
21 |
22 | #ifndef __COOLEYES_BUFFERED_READER_H__
23 | #define __COOLEYES_BUFFERED_READER_H__
24 |
25 | #include
26 |
27 | typedef struct {
28 | int (*read_func) (void *ptr, int count, int size, int handle);
29 | int (*seek_func) (int handle, int offset, int whence);
30 | int (*close_func) (int handle);
31 | long (*tell_func) (int handle);
32 | }audio_callbacks;
33 |
34 | typedef struct {
35 | SceUID handle;
36 | int32_t length;
37 | int32_t buffer_size;
38 | int32_t seek_mode;
39 | uint8_t* buffer_0;//[BUFFERED_READER_BUFFER_SIZE];
40 | uint8_t* buffer_1;//[BUFFERED_READER_BUFFER_SIZE];
41 | uint8_t* buffer_2;//[BUFFERED_READER_BUFFER_SIZE];
42 | uint8_t* first_buffer;
43 | uint8_t* second_buffer;
44 | uint8_t* third_buffer;
45 | int32_t position_0;
46 | int32_t position_1;
47 | int32_t position_2;
48 | int32_t position_3;
49 | int32_t current_position;
50 | //add by newcreat
51 | int use_callbacks;
52 | audio_callbacks callbacks;
53 | } buffered_reader_t;
54 |
55 | #ifdef __cplusplus
56 | extern "C" {
57 | #endif
58 |
59 | //typedef void* buffered_reader_t;
60 |
61 | buffered_reader_t* buffered_reader_open(const char* path, int32_t buffer_size, int32_t seek_mode);
62 |
63 | buffered_reader_t* buffered_reader_open_cb(audio_callbacks cb, int handle,int32_t buffer_size, int32_t seek_mode);
64 |
65 | int32_t buffered_reader_length(buffered_reader_t* reader);
66 |
67 | int32_t buffered_reader_seek(buffered_reader_t* reader, const int32_t position);
68 |
69 | int32_t buffered_reader_position(buffered_reader_t* reader);
70 |
71 | uint32_t buffered_reader_read(buffered_reader_t* reader, void* buffer, uint32_t size);
72 |
73 | void buffered_reader_close(buffered_reader_t* reader);
74 |
75 | #ifdef __cplusplus
76 | }
77 | #endif
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/coolaudio/common/mem64.c:
--------------------------------------------------------------------------------
1 | /*
2 | PMP Mod
3 | Copyright (C) 2006 jonny
4 |
5 | Homepage: http://jonny.leffe.dnsalias.com
6 | E-mail: jonny@leffe.dnsalias.com
7 |
8 | This program is free software; you can redistribute it and/or modify
9 | it under the terms of the GNU General Public License as published by
10 | the Free Software Foundation; either version 2 of the License, or
11 | (at your option) any later version.
12 |
13 | This program is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with this program; if not, write to the Free Software
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 | */
22 |
23 | /*
24 | 64 bytes aligned malloc, with the me is crucial to well enclose data (due to cache)
25 | */
26 |
27 |
28 | #include "mem64.h"
29 |
30 |
31 | void *malloc_64(int size)
32 | {
33 | int mod_64 = size & 0x3f;
34 |
35 | if (mod_64 != 0) size += 64 - mod_64;
36 |
37 | return(memalign(64, size));
38 | }
39 |
40 |
41 | void free_64(void *p)
42 | {
43 | free(p);
44 | }
45 |
--------------------------------------------------------------------------------
/coolaudio/common/mem64.h:
--------------------------------------------------------------------------------
1 | /*
2 | PMP Mod
3 | Copyright (C) 2006 jonny
4 |
5 | Homepage: http://jonny.leffe.dnsalias.com
6 | E-mail: jonny@leffe.dnsalias.com
7 |
8 | This program is free software; you can redistribute it and/or modify
9 | it under the terms of the GNU General Public License as published by
10 | the Free Software Foundation; either version 2 of the License, or
11 | (at your option) any later version.
12 |
13 | This program is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with this program; if not, write to the Free Software
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 | */
22 |
23 | /*
24 | 64 bytes aligned malloc, with the me is crucial to well enclose data (due to cache)
25 | */
26 |
27 |
28 | #ifndef mem64_h
29 | #define mem64_h
30 |
31 |
32 | #include
33 | #include
34 |
35 | #ifdef __cplusplus
36 | extern "C" {
37 | #endif
38 | void *malloc_64(int size);
39 | void free_64(void *p);
40 | #ifdef __cplusplus
41 | }
42 | #endif
43 |
44 | #endif
45 |
--------------------------------------------------------------------------------
/coolaudio/libcoolaudio.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "audio_interface.h"
4 |
5 | #if defined IPHONEOS
6 | void CoolAudioDefaultInit() {}
7 | void CoolAudioDefaultFini() {}
8 |
9 | #elif defined _PSP
10 | #include
11 | #include
12 | #include
13 | #include
14 | //for PSP
15 | //default init for psp ,load prxs
16 | void CoolAudioDefaultInit()
17 | {
18 | #ifdef PSP_FW_VERSION_1XX
19 | int result = pspSdkLoadStartModule("flash0:/kd/me_for_vsh.prx", PSP_MEMORY_PARTITION_KERNEL);
20 | result = pspSdkLoadStartModule("flash0:/kd/videocodec.prx", PSP_MEMORY_PARTITION_KERNEL);
21 | result = pspSdkLoadStartModule("flash0:/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL);
22 | result = pspSdkLoadStartModule("flash0:/kd/mpegbase.prx", PSP_MEMORY_PARTITION_KERNEL);
23 | result = pspSdkLoadStartModule("flash0:/kd/mpeg_vsh.prx", PSP_MEMORY_PARTITION_USER);
24 | pspSdkFixupImports(result);
25 | #else
26 | int result = sceUtilityLoadAvModule(0);
27 | result = sceUtilityLoadAvModule(3);
28 | #endif
29 | sceMpegInit();
30 | }
31 |
32 | void CoolAudioDefaultFini()
33 | {
34 |
35 | }
36 | #endif
37 |
--------------------------------------------------------------------------------
/coolaudio/nge_io_mem.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "nge_io_mem.h"
5 |
6 |
7 |
8 | typedef struct tagMemFile{
9 | const char* memptr;
10 | int msize;
11 | int mflag;
12 | int mpos;
13 | int eosflag;
14 | }MFILE;
15 |
16 |
17 | int io_mopen(const char* mem,int size,int flag)
18 | {
19 | MFILE* mf;
20 | if(mem ==NULL || size==0)
21 | return 0;
22 | mf = (MFILE*)malloc(sizeof(MFILE));
23 | memset(mf,0,sizeof(MFILE));
24 | mf->memptr = mem;
25 | mf->msize = size;
26 | mf->mflag = IO_RDONLY;
27 | return (int)mf;
28 | }
29 |
30 | int io_mread(void* buffer,int count,int size,int handle)
31 | {
32 | MFILE* mf = (MFILE*)handle;
33 | char* buf = buffer;
34 | int len = count*size;
35 | if(mf == NULL||len <= 0)
36 | return -1;
37 | if(mf->eosflag == 1)
38 | return -1;
39 |
40 | if(mf->msize-mf->mpos>=len){
41 | memcpy((char*)buffer,mf->memptr+mf->mpos,len);
42 | mf->mpos += len;
43 | if(mf->mpos == mf->msize)
44 | mf->eosflag = 1;
45 | }
46 | else{
47 | len = mf->msize-mf->mpos;
48 | memcpy((char*)buffer,mf->memptr+mf->mpos,len);
49 | mf->eosflag = 1;
50 | }
51 | return len;
52 |
53 | }
54 |
55 | int io_mwrite(void* buffer,int count,int size,int handle)
56 | {
57 | MFILE* mf = (MFILE*)handle;
58 | if(mf == NULL)
59 | return 0;
60 | return 1;
61 | }
62 |
63 | int io_mseek(int handle,int offset,int flag)
64 | {
65 | MFILE* mf = (MFILE*)handle;
66 | if(mf == NULL)
67 | return -1;
68 | switch(flag)
69 | {
70 | case IO_SEEK_SET:
71 | mf->mpos = offset;
72 | if(mf->mpos>mf->msize)
73 | mf->mpos = mf->msize;
74 | if(mf->mpos <0)
75 | mf->mpos = 0;
76 | break;
77 | case IO_SEEK_END:
78 | mf->mpos = mf->msize - offset;
79 | if(mf->mpos>mf->msize)
80 | mf->mpos = mf->msize;
81 | if(mf->mpos <0)
82 | mf->mpos = 0;
83 | break;
84 | case IO_SEEK_CUR:
85 | mf->mpos +=offset;
86 | if(mf->mpos>mf->msize)
87 | mf->mpos = mf->msize;
88 | if(mf->mpos <0)
89 | mf->mpos = 0;
90 | break;
91 | default:
92 | break;
93 | }
94 | mf->eosflag = 0;
95 | return 0;
96 | }
97 |
98 | int io_mtell(int handle)
99 | {
100 | MFILE* mf = (MFILE*)handle;
101 | if(mf == NULL)
102 | return -1;
103 | if(mf->eosflag)
104 | return -1;
105 | return mf->mpos;
106 | }
107 |
108 | int io_mclose(int handle)
109 | {
110 | MFILE* mf = (MFILE*)handle;
111 | if(mf == NULL)
112 | return -1;
113 | free(mf);
114 | return 0;
115 | }
116 |
117 | int io_msize(int handle)
118 | {
119 | MFILE* mf = (MFILE*)handle;
120 | if(mf == NULL)
121 | return -1;
122 | return mf->msize;
123 | }
124 |
125 |
126 |
127 |
128 |
--------------------------------------------------------------------------------
/coolaudio/nge_io_mem.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/coolaudio/nge_io_mem.h
--------------------------------------------------------------------------------
/coolaudio/parsers/mp3_parser.h:
--------------------------------------------------------------------------------
1 | /*
2 | * _____ _ _____
3 | * / ___|(_) / __ \
4 | * \ `--. _ _ __ ___ _ __ ___ __ __`' / /'
5 | * `--. \| || '__|/ _ \| '_ \ / __| \ \ / / / /
6 | * /\__/ /| || | | __/| | | |\__ \ \ V / ./ /___
7 | * \____/ |_||_| \___||_| |_||___/ \_/ \_____/
8 | *
9 | *
10 | * Copyright (C) 2007 cooleyes
11 | * eyes.cooleyes@gmail.com
12 | *
13 | * This Program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2, or (at your option)
16 | * any later version.
17 | *
18 | * This Program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with GNU Make; see the file COPYING. If not, write to
25 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 | * http://www.gnu.org/copyleft/gpl.html
27 | *
28 | */
29 |
30 | #ifndef __SIRENS2_MP3_PARSER_H__
31 | #define __SIRENS2_MP3_PARSER_H__
32 |
33 | #include "audio_parser.h"
34 | #include "common/buffered_reader.h"
35 |
36 | class Mp3Parser : public AudioParser {
37 | private:
38 | AudioCodecInitData init_data;
39 | AudioCodec* codec;
40 | bool codec_initialize;
41 | AudioFrameIndex* frame_index;
42 | bool is_open;
43 | uint32_t total_samples;
44 | uint32_t total_frames;
45 | uint32_t current_frame;
46 | buffered_reader_t* reader;
47 | uint32_t mp3_data_start;
48 | uint32_t mp3_data_length;
49 | uint32_t mp3_version;
50 | uint32_t mp3_level;
51 |
52 | void *output_buffer;
53 | void *read_buffer;
54 |
55 | void initialize();
56 |
57 | void finalize();
58 |
59 | char* skip_id3v2_and_get_header_info();
60 |
61 | public:
62 | Mp3Parser();
63 | ~Mp3Parser();
64 | char* open(const char* filename);
65 | char* open_cb(audio_callbacks cb,int handle);
66 | void close();
67 |
68 | uint32_t get_samplerate();
69 | uint32_t get_channels();
70 | uint64_t get_duration();
71 | uint32_t get_samples_per_frame();
72 | uint32_t get_max_samples_per_frame();
73 |
74 | uint64_t seek_time(uint64_t time);
75 | char* get_frame(void** pcm, uint32_t* samples);
76 | };
77 |
78 | #endif
79 |
--------------------------------------------------------------------------------
/coolaudio/parsers/musepack_parser.h:
--------------------------------------------------------------------------------
1 | /*
2 | * _____ _ _____
3 | * / ___|(_) / __ \
4 | * \ `--. _ _ __ ___ _ __ ___ __ __`' / /'
5 | * `--. \| || '__|/ _ \| '_ \ / __| \ \ / / / /
6 | * /\__/ /| || | | __/| | | |\__ \ \ V / ./ /___
7 | * \____/ |_||_| \___||_| |_||___/ \_/ \_____/
8 | *
9 | *
10 | * Copyright (C) 2007 cooleyes
11 | * eyes.cooleyes@gmail.com
12 | *
13 | * This Program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2, or (at your option)
16 | * any later version.
17 | *
18 | * This Program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with GNU Make; see the file COPYING. If not, write to
25 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 | * http://www.gnu.org/copyleft/gpl.html
27 | *
28 | */
29 |
30 | #ifndef __SIRENS2_MUSEPACK_PARSER_H__
31 | #define __SIRENS2_MUSEPACK_PARSER_H__
32 |
33 | #include "audio_parser.h"
34 | #include "common/buffered_reader.h"
35 |
36 | class MusepackParser : public AudioParser {
37 | private:
38 | AudioCodecInitData init_data;
39 | bool is_open;
40 | void* musepack_demux;
41 | void* musepack_reader;
42 | uint32_t total_samples;
43 | buffered_reader_t* reader;
44 |
45 | void *output_buffer;
46 |
47 | void initialize();
48 |
49 | void finalize();
50 |
51 | public:
52 | MusepackParser();
53 | ~MusepackParser();
54 | char* open(const char* filename);
55 | char* open_cb(audio_callbacks cb,int handle);
56 | void close();
57 |
58 | uint32_t get_samplerate();
59 | uint32_t get_channels();
60 | uint64_t get_duration();
61 | uint32_t get_samples_per_frame();
62 | uint32_t get_max_samples_per_frame();
63 |
64 | uint64_t seek_time(uint64_t time);
65 | char* get_frame(void** pcm, uint32_t* samples);
66 | };
67 |
68 | #endif
69 |
--------------------------------------------------------------------------------
/coolaudio/parsers/oggvorbis_parser.h:
--------------------------------------------------------------------------------
1 | /*
2 | * _____ _ _____
3 | * / ___|(_) / __ \
4 | * \ `--. _ _ __ ___ _ __ ___ __ __`' / /'
5 | * `--. \| || '__|/ _ \| '_ \ / __| \ \ / / / /
6 | * /\__/ /| || | | __/| | | |\__ \ \ V / ./ /___
7 | * \____/ |_||_| \___||_| |_||___/ \_/ \_____/
8 | *
9 | *
10 | * Copyright (C) 2007 cooleyes
11 | * eyes.cooleyes@gmail.com
12 | *
13 | * This Program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2, or (at your option)
16 | * any later version.
17 | *
18 | * This Program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with GNU Make; see the file COPYING. If not, write to
25 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 | * http://www.gnu.org/copyleft/gpl.html
27 | *
28 | */
29 |
30 | #ifndef __SIRENS2_OGGVORBIS_PARSER_H__
31 | #define __SIRENS2_OGGVORBIS_PARSER_H__
32 |
33 | #include "audio_parser.h"
34 | #include "common/buffered_reader.h"
35 |
36 | class OggVorbisParser : public AudioParser {
37 | private:
38 | void* ogg_vorbis_file;
39 | AudioCodecInitData init_data;
40 | bool is_open;
41 | uint32_t total_samples;
42 | buffered_reader_t* reader;
43 |
44 | void *output_buffer;
45 |
46 | void initialize();
47 |
48 | void finalize();
49 |
50 | public:
51 | OggVorbisParser();
52 | ~OggVorbisParser();
53 | char* open(const char* filename);
54 | char* open_cb(audio_callbacks cb,int handle);
55 | void close();
56 |
57 | uint32_t get_samplerate();
58 | uint32_t get_channels();
59 | uint64_t get_duration();
60 | uint32_t get_samples_per_frame();
61 | uint32_t get_max_samples_per_frame();
62 |
63 | uint64_t seek_time(uint64_t time);
64 | char* get_frame(void** pcm, uint32_t* samples);
65 |
66 | };
67 |
68 | #endif
69 |
--------------------------------------------------------------------------------
/coolaudio/parsers/pcm_parser.h:
--------------------------------------------------------------------------------
1 | /*
2 | * _____ _ _____
3 | * / ___|(_) / __ \
4 | * \ `--. _ _ __ ___ _ __ ___ __ __`' / /'
5 | * `--. \| || '__|/ _ \| '_ \ / __| \ \ / / / /
6 | * /\__/ /| || | | __/| | | |\__ \ \ V / ./ /___
7 | * \____/ |_||_| \___||_| |_||___/ \_/ \_____/
8 | *
9 | *
10 | * Copyright (C) 2007 cooleyes
11 | * eyes.cooleyes@gmail.com
12 | *
13 | * This Program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2, or (at your option)
16 | * any later version.
17 | *
18 | * This Program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with GNU Make; see the file COPYING. If not, write to
25 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 | * http://www.gnu.org/copyleft/gpl.html
27 | *
28 | */
29 |
30 | #ifndef __SIRENS2_PCM_PARSER_H__
31 | #define __SIRENS2_PCM_PARSER_H__
32 |
33 | #include "audio_parser.h"
34 | #include "common/buffered_reader.h"
35 |
36 | class PcmParser : public AudioParser {
37 | private:
38 | AudioCodecInitData init_data;
39 | bool is_open;
40 | uint32_t total_samples;
41 | uint32_t current_samples;
42 | buffered_reader_t* reader;
43 |
44 | uint32_t pcm_data_start;
45 | uint32_t pcm_data_length;
46 |
47 | void *output_buffer;
48 |
49 | void initialize();
50 |
51 | void finalize();
52 |
53 | public:
54 | PcmParser();
55 | ~PcmParser();
56 | char* open(const char* filename);
57 | char* open_cb(audio_callbacks cb,int handle);
58 | void close();
59 |
60 | uint32_t get_samplerate();
61 | uint32_t get_channels();
62 | uint64_t get_duration();
63 | uint32_t get_samples_per_frame();
64 | uint32_t get_max_samples_per_frame();
65 |
66 | uint64_t seek_time(uint64_t time);
67 | char* get_frame(void** pcm, uint32_t* samples);
68 |
69 | };
70 |
71 | #endif
72 |
--------------------------------------------------------------------------------
/dirent/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(DIRENT_SRCS
2 | directory.c
3 | fat.c
4 | miniconv.c
5 | nge_dirent.cpp
6 | )
7 |
8 | add_addon_srcs(dirent
9 | INCLUDE_THIS_DIR
10 | SRCS ${DIRENT_SRCS})
11 |
--------------------------------------------------------------------------------
/dirent/directory.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2006 cooleyes
3 | * eyes.cooleyes@gmail.com
4 | *
5 | * This Program is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 2, or (at your option)
8 | * any later version.
9 | *
10 | * This Program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with GNU Make; see the file COPYING. If not, write to
17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 | * http://www.gnu.org/copyleft/gpl.html
19 | *
20 | */
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include "fat.h"
26 | #include "directory.h"
27 |
28 | int open_ms0_directory(const char* dir, char* sdir, directory_item_struct** list)
29 | {
30 | int item_count;
31 | p_fat_info info;
32 |
33 | if ( strncmp(dir,"ms0:", 4) != 0 )
34 | {
35 | /* only 'ms0:/...' file/dir is supported */
36 | return -1;
37 | }
38 |
39 | if(*list != NULL)
40 | {
41 | free((void *)(*list));
42 | *list = NULL;
43 | }
44 |
45 | u32 count = fat_readdir(dir, sdir, &info);
46 | if(count == INVALID)
47 | return 0;
48 | u32 i, cur_count = 0;
49 | for(i = 0; i < count; i ++)
50 | {
51 | if(cur_count % 256 == 0)
52 | {
53 | if(cur_count == 0)
54 | {
55 | if(*list == NULL)
56 | {
57 | *list = (directory_item_struct*)malloc(sizeof(directory_item_struct) * 256);
58 | }
59 | }
60 | else
61 | {
62 | *list = (directory_item_struct*)realloc(*list, sizeof(directory_item_struct) * (cur_count + 256));
63 | }
64 |
65 | if(*list == NULL)
66 | {
67 | free((void *)info);
68 | return 0;
69 | }
70 | }
71 |
72 | if(info[i].attr & FAT_FILEATTR_DIRECTORY)
73 | {
74 | (*list)[cur_count].filetype = FS_DIRECTORY;
75 | strcpy((*list)[cur_count].shortname, info[i].filename);
76 | strcpy((*list)[cur_count].longname, info[i].longname);
77 | }
78 | else
79 | {
80 | //if(info[i].filesize == 0)
81 | //continue;
82 | (*list)[cur_count].filetype = FS_FILE;
83 | strcpy((*list)[cur_count].shortname, info[i].filename);
84 | strcpy((*list)[cur_count].longname, info[i].longname);
85 | (*list)[cur_count].filesize = info[i].filesize;
86 | (*list)[cur_count].cdate = info[i].cdate;
87 | (*list)[cur_count].ctime = info[i].ctime;
88 | (*list)[cur_count].mdate = info[i].mdate;
89 | (*list)[cur_count].mtime = info[i].mtime;
90 | }
91 |
92 | cur_count ++;
93 | }
94 |
95 | free((void *)info);
96 | item_count = cur_count;
97 | return item_count;
98 | }
99 |
--------------------------------------------------------------------------------
/dirent/directory.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2006 cooleyes
3 | * eyes.cooleyes@gmail.com
4 | *
5 | * This Program is free software; you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation; either version 2, or (at your option)
8 | * any later version.
9 | *
10 | * This Program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with GNU Make; see the file COPYING. If not, write to
17 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 | * http://www.gnu.org/copyleft/gpl.html
19 | *
20 | */
21 | #ifndef __DIRECTORY_H__
22 | #define __DIRECTORY_H__
23 | #define MAX_FILENAME_LENGTH 1024
24 | typedef enum
25 | {
26 | FS_DIRECTORY = 0,
27 | FS_FILE
28 | } file_type_enum;
29 |
30 | typedef struct
31 | {
32 | const char * ext;
33 | file_type_enum filetype;
34 | } file_type_ext_struct;
35 |
36 | typedef struct
37 | {
38 | char shortname[MAX_FILENAME_LENGTH];
39 | char longname[MAX_FILENAME_LENGTH];
40 | u32 filesize;
41 | u16 cdate;
42 | u16 ctime;
43 | u16 mdate;
44 | u16 mtime;
45 | file_type_enum filetype;
46 | } directory_item_struct;
47 |
48 | #ifdef __cplusplus
49 | extern "C" {
50 | #endif
51 |
52 | int open_ms0_directory(const char* dir, char* sdir, directory_item_struct** list);
53 |
54 | #ifdef __cplusplus
55 | }
56 | #endif
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/dirent/fat.h:
--------------------------------------------------------------------------------
1 | #ifndef __FAT_H__
2 | #define __FAT_H__
3 |
4 | #include
5 |
6 | #ifndef INVALID
7 | #define INVALID ((u32)-1)
8 | #endif
9 |
10 | struct _fat_mbr_dpt {
11 | u8 active;
12 | u8 start[3];
13 | u8 id;
14 | u8 ending[3];
15 | u32 start_sec;
16 | u32 total_sec;
17 | } __attribute__((packed));
18 |
19 | struct _fat_mbr {
20 | u8 mb_data[0x1BE];
21 | struct _fat_mbr_dpt dpt[4];
22 | u16 ending_flag;
23 | } __attribute__((packed));
24 | typedef struct _fat_mbr t_fat_mbr, * p_fat_mbr;
25 |
26 | struct _fat_dbr {
27 | u8 jmp_boot[3];
28 | char oem_name[8];
29 | u16 bytes_per_sec;
30 | u8 sec_per_clus;
31 | u16 reserved_sec;
32 | u8 num_fats;
33 | u16 root_entry;
34 | u16 total_sec;
35 | u8 media_type;
36 | u16 sec_per_fat;
37 | u16 sec_per_track;
38 | u16 heads;
39 | u32 hidd_sec;
40 | u32 big_total_sec;
41 | union {
42 | struct {
43 | u8 drv_num;
44 | u8 reserved;
45 | u8 boot_sig;
46 | u8 vol_id[4];
47 | char vol_lab[11];
48 | char file_sys_type[8];
49 | } __attribute__((packed)) fat16;
50 | struct {
51 | u32 sec_per_fat;
52 | u16 extend_flag;
53 | u16 sys_ver;
54 | u32 root_clus;
55 | u16 info_sec;
56 | u16 back_sec;
57 | u8 reserved[10];
58 | } __attribute__((packed)) fat32;
59 | } __attribute__((packed)) ufat;
60 | u8 exe_code[448];
61 | u16 ending_flag;
62 | } __attribute__((packed));
63 | typedef struct _fat_dbr t_fat_dbr, * p_fat_dbr;
64 |
65 | struct _fat_normentry {
66 | char filename[8];
67 | char fileext[3];
68 | u8 attr;
69 | u8 flag;
70 | u8 cr_time_msec;
71 | u16 cr_time;
72 | u16 cr_date;
73 | u16 last_visit;
74 | u16 clus_high;
75 | u16 last_mod_time;
76 | u16 last_mod_date;
77 | u16 clus;
78 | u32 filesize;
79 | } __attribute__((packed));
80 |
81 | struct _fat_longfile {
82 | u8 order;
83 | u16 uni_name[5];
84 | u8 sig;
85 | u8 reserved;
86 | u8 checksum;
87 | u16 uni_name2[6];
88 | u16 clus;
89 | u16 uni_name3[2];
90 | } __attribute__((packed));
91 |
92 | union _fat_entry {
93 | struct _fat_normentry norm;
94 | struct _fat_longfile longfile;
95 | } __attribute__((packed));
96 | typedef union _fat_entry t_fat_entry, * p_fat_entry;
97 |
98 | #define FAT_FILEATTR_READONLY 0x01
99 | #define FAT_FILEATTR_HIDDEN 0x02
100 | #define FAT_FILEATTR_SYSTEM 0x04
101 | #define FAT_FILEATTR_VOLUME 0x08
102 | #define FAT_FILEATTR_DIRECTORY 0x10
103 | #define FAT_FILEATTR_ARCHIVE 0x20
104 |
105 | #define MAX_FILENAME_LENGTH 1024
106 | typedef struct {
107 | char filename[MAX_FILENAME_LENGTH];
108 | char longname[MAX_FILENAME_LENGTH];
109 | u32 filesize;
110 | u16 cdate;
111 | u16 ctime;
112 | u16 mdate;
113 | u16 mtime;
114 | u32 clus;
115 | u8 attr;
116 | } t_fat_info, * p_fat_info;
117 |
118 | #ifdef __cplusplus
119 | extern "C" {
120 | #endif
121 |
122 | int fat_init(int devkitVersion);
123 | int fat_locate(const char * name, char * sname, u32 clus, p_fat_entry info);
124 | u32 fat_readdir(const char * dir, char * sdir, p_fat_info * info);
125 | void fat_free();
126 |
127 | #ifdef __cplusplus
128 | }
129 | #endif
130 |
131 | #endif
132 |
--------------------------------------------------------------------------------
/dirent/miniconv.h:
--------------------------------------------------------------------------------
1 | #ifndef __MINICONV_H__
2 | #define __MINICONV_H__
3 |
4 | typedef char* (*utf8_convert_function)(const unsigned char*);
5 |
6 | #ifdef __cplusplus
7 | extern "C" {
8 | #endif
9 |
10 | char* utf16le_to_utf8(const unsigned short* utf16le);
11 | char* utf16be_to_utf8(const unsigned short* utf16be);
12 | #ifdef GBK_CONV
13 | char* gbk_to_utf8(const unsigned char* gbk);
14 | #endif
15 |
16 |
17 |
18 | char* big5_to_utf8(const unsigned char* big5);
19 |
20 |
21 | #ifdef SJIS_CONV
22 | char* sjis_to_utf8(const unsigned char* sjis);
23 | #endif
24 | #ifdef EUC_KR_CONV
25 | char* euc_kr_to_utf8(const unsigned char* euc_kr);
26 | #endif
27 | #ifdef MS_EE_CONV
28 | char* ms_ee_to_utf8(const unsigned char* ms_ee);
29 | #endif
30 | #ifdef MS_CYRL_CONV
31 | char* ms_cyrl_to_utf8(const unsigned char* ms_cyrl);
32 | #endif
33 | #ifdef MS_ARAB_CONV
34 | char* ms_arab_to_utf8(const unsigned char* ms_cyrl);
35 | #endif
36 | #ifdef ISO8859_6_CONV
37 | char* iso8859_6_to_utf8(const unsigned char* iso8859_6);
38 | #endif
39 | #ifdef ISO8859_2_CONV
40 | char* iso8859_2_to_utf8(const unsigned char* iso8859_2);
41 | #endif
42 | #ifdef ISO8859_1_CONV
43 | char* iso8859_1_to_utf8(const unsigned char* iso8859_1);
44 | #endif
45 | char* miniConvUTF16LEConv(const unsigned short* utf16le);
46 | char* miniConvUTF16BEConv(const unsigned short* utf16be);
47 | int miniConvGetConvCount();
48 | char* miniConvGetConvCharset(int index);
49 | void miniConvSetFileSystemConv(const char* charset);
50 | int miniConvHaveFileSystemConv();
51 | char* miniConvFileSystemConv(const unsigned char* s);
52 | void miniConvSetDefaultSubtitleConv(const char* charset);
53 | int miniConvHaveDefaultSubtitleConv();
54 | int miniConvHaveSubtitleConv(const char* charset);
55 | char* miniConvDefaultSubtitleConv(const unsigned char* s);
56 | char* miniConvSubtitleConv(const unsigned char* s, const char* charset);
57 | void miniConvFreeMemory(void* mem);
58 | #ifdef __cplusplus
59 | }
60 | #endif
61 |
62 | //#include "bkdebug.h"
63 |
64 | #endif
65 |
--------------------------------------------------------------------------------
/dirent/nge_ch_io_dir.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * nge_ch_io_dir.h
3 | *
4 | * 2011/03/25 08:49:34
5 | * Copyright 2011 Kun Wang
6 | ****************************************************************************/
7 | /*
8 | * This program is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This program is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 | */
22 |
23 | #ifndef _NGE_CH_IO_DIR_H
24 | #define _NGE_CH_IO_DIR_H
25 |
26 | #include "nge_dirent.hpp"
27 | #warning nge_ch_io_dir.h will be deprecated, please use nge_dirent.hpp!
28 |
29 | #endif /* _NGE_CH_IO_DIR_H */
30 |
--------------------------------------------------------------------------------
/dirent/nge_dirent.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/dirent/nge_dirent.cpp
--------------------------------------------------------------------------------
/dirent/nge_dirent.hpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/dirent/nge_dirent.hpp
--------------------------------------------------------------------------------
/helper/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(HELPER_SRCS
2 | CppSQLite3.cpp
3 | dictionary.c
4 | iniparser.c
5 | package.cpp
6 | )
7 |
8 | if(SQLITE3_FOUND)
9 | add_addon_srcs(helper
10 | HAS_SUBDIR_IN_INCLUDE
11 | SRCS ${HELPER_SRCS}
12 | LIBS ${SQLITE3_LIBRARIES}
13 | INCLUDES ${SQLITE3_INCLUDE_DIR})
14 | endif()
15 |
--------------------------------------------------------------------------------
/helper/package.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/helper/package.cpp
--------------------------------------------------------------------------------
/hge/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | aux_source_directory(hge _HGE_SRCS)
2 |
3 | add_addon_srcs(hge
4 | HAS_SUBDIR_IN_INCLUDE
5 | SRC_NO_SUBDIR
6 | SRCS ${_HGE_SRCS})
7 |
--------------------------------------------------------------------------------
/hge/hgecolor.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Thanks to Dr.Watson JGE++!
3 | ** Haaf's Game Engine 1.7
4 | ** Copyright (C) 2003-2007, Relish Games
5 | ** hge.relishgames.com
6 | **
7 | ** hgeColor*** helper classes implementation
8 | */
9 |
10 | #include
11 | #include "hgecolor.h"
12 |
13 |
14 | #ifndef min
15 | #define min(x, y) ((xy)?x:y)
20 | #endif
21 |
22 | void hgeColorHSV::SetHWColor(uint32_t col)
23 | {
24 | float r, g, b;
25 | float minv, maxv, delta;
26 | float del_R, del_G, del_B;
27 |
28 | a = (col>>24) / 255.0f;
29 | r = ((col>>16) & 0xFF) / 255.0f;
30 | g = ((col>>8) & 0xFF) / 255.0f;
31 | b = (col & 0xFF) / 255.0f;
32 |
33 | minv = min(min(r, g), b);
34 | maxv = max(max(r, g), b);
35 | delta = maxv - minv;
36 |
37 | v = maxv;
38 |
39 | if (delta == 0)
40 | {
41 | h = 0;
42 | s = 0;
43 | }
44 | else
45 | {
46 | s = delta / maxv;
47 | del_R = (((maxv - r) / 6) + (delta / 2)) / delta;
48 | del_G = (((maxv - g) / 6) + (delta / 2)) / delta;
49 | del_B = (((maxv - b) / 6) + (delta / 2)) / delta;
50 |
51 | if (r == maxv) {h = del_B - del_G;}
52 | else if (g == maxv) {h = (1 / 3) + del_R - del_B;}
53 | else if (b == maxv) {h = (2 / 3) + del_G - del_R;}
54 |
55 | if (h < 0) h += 1;
56 | if (h > 1) h -= 1;
57 | }
58 | }
59 |
60 | uint32_t hgeColorHSV::GetHWColor() const
61 | {
62 | float r, g, b;
63 | float xh, i, p1, p2, p3;
64 |
65 | if (s == 0)
66 | {
67 | r = v;
68 | g = v;
69 | b = v;
70 | }
71 | else
72 | {
73 | xh = h * 6;
74 | if(xh == 6) xh=0;
75 | i = floorf(xh);
76 | p1 = v * (1 - s);
77 | p2 = v * (1 - s * (xh - i));
78 | p3 = v * (1 - s * (1 - (xh - i)));
79 |
80 | if (i == 0) {r = v; g = p3; b = p1;}
81 | else if (i == 1) {r = p2; g = v; b = p1;}
82 | else if (i == 2) {r = p1; g = v; b = p3;}
83 | else if (i == 3) {r = p1; g = p2; b = v; }
84 | else if (i == 4) {r = p3; g = p1; b = v; }
85 | else {r = v; g = p1; b = p2;}
86 | }
87 |
88 | return (MAKE_RGBA_8888((int)(r*255.0f), (int)(g*255.0f), (int)(b*255.0f),(int)(a*255.0f)));
89 | }
90 |
91 |
--------------------------------------------------------------------------------
/hge/hgepmanager.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** Haaf's Game Engine 1.7
3 | ** Copyright (C) 2003-2007, Relish Games
4 | ** hge.relishgames.com
5 | **
6 | ** hgeParticleManager helper class implementation
7 | */
8 |
9 |
10 | #include "hgeparticle.h"
11 |
12 |
13 | hgeParticleManager::hgeParticleManager()
14 | {
15 | nPS=0;
16 | tX=tY=0.0f;
17 | }
18 |
19 | hgeParticleManager::~hgeParticleManager()
20 | {
21 | int i;
22 | for(i=0;iUpdate(dt);
31 | if(psList[i]->GetAge()==-2.0f && psList[i]->GetParticlesAlive()==0)
32 | {
33 | delete psList[i];
34 | psList[i]=psList[nPS-1];
35 | nPS--;
36 | i--;
37 | }
38 | }
39 | }
40 |
41 | void hgeParticleManager::Render()
42 | {
43 | int i;
44 | for(i=0;iRender();
45 | }
46 |
47 | hgeParticleSystem* hgeParticleManager::SpawnPS(hgeParticleSystemInfo *psi, float x, float y)
48 | {
49 | if(nPS==MAX_PSYSTEMS) return 0;
50 | psList[nPS]=new hgeParticleSystem(psi);
51 | psList[nPS]->FireAt(x,y);
52 | psList[nPS]->Transpose(tX,tY);
53 | nPS++;
54 | return psList[nPS-1];
55 | }
56 |
57 | BOOL hgeParticleManager::IsPSAlive(hgeParticleSystem *ps) const
58 | {
59 | int i;
60 | for(i=0;iTranspose(x,y);
68 | tX=x; tY=y;
69 | }
70 |
71 | void hgeParticleManager::KillPS(hgeParticleSystem *ps)
72 | {
73 | int i;
74 | for(i=0;i
12 |
13 |
14 | void hgeRect::Encapsulate(float x, float y)
15 | {
16 | if(bClean)
17 | {
18 | x1=x2=x;
19 | y1=y2=y;
20 | bClean=0;
21 | }
22 | else
23 | {
24 | if(xx2) x2=x;
26 | if(yy2) y2=y;
28 | }
29 | }
30 |
31 | BOOL hgeRect::TestPoint(float x, float y) const
32 | {
33 | if(x>=x1 && x=y1 && yx1 - rect->x2) < (x2 - x1 + rect->x2 - rect->x1))
41 | if(fabs(y1 + y2 - rect->y1 - rect->y2) < (y2 - y1 + rect->y2 - rect->y1))
42 | return 1;
43 |
44 | return 0;
45 | }
46 |
--------------------------------------------------------------------------------
/hge/hgevector.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** Haaf's Game Engine 1.7
3 | ** Copyright (C) 2003-2007, Relish Games
4 | ** hge.relishgames.com
5 | **
6 | ** hgeVector helper class implementation
7 | */
8 |
9 |
10 | #include "hgevector.h"
11 |
12 | float InvSqrt(float x)
13 | {
14 | union
15 | {
16 | int intPart;
17 | float floatPart;
18 | } convertor;
19 |
20 | convertor.floatPart = x;
21 | convertor.intPart = 0x5f3759df - (convertor.intPart >> 1);
22 | return convertor.floatPart*(1.5f - 0.4999f*x*convertor.floatPart*convertor.floatPart);
23 | }
24 |
25 | /*
26 | hgeVector *hgeVector::Normalize()
27 | {
28 | float lenRcp;
29 |
30 | lenRcp=sqrtf(Dot(this));
31 |
32 | if(lenRcp)
33 | {
34 | lenRcp=1.0f/lenRcp;
35 |
36 | x*=lenRcp;
37 | y*=lenRcp;
38 | }
39 |
40 | return this;
41 | }
42 | */
43 |
44 | float hgeVector::Angle(const hgeVector *v) const
45 | {
46 | if(v)
47 | {
48 | hgeVector s=*this, t=*v;
49 |
50 | s.Normalize(); t.Normalize();
51 | return acosf(s.Dot(&t));
52 | }
53 | else return atan2f(y, x);
54 | }
55 |
56 | hgeVector *hgeVector::Rotate(float a)
57 | {
58 | hgeVector v;
59 |
60 | v.x=x*cosf(a) - y*sinf(a);
61 | v.y=x*sinf(a) + y*cosf(a);
62 |
63 | x=v.x; y=v.y;
64 |
65 | return this;
66 | }
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/include/audio_interface.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/audio_interface.h
--------------------------------------------------------------------------------
/include/helper/package.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/helper/package.h
--------------------------------------------------------------------------------
/include/hge/hgecolor.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Thanks to Dr.Watson JGE++!
3 | ** Haaf's Game Engine 1.7
4 | ** Copyright (C) 2003-2007, Relish Games
5 | ** hge.relishgames.com
6 | **
7 | ** hgeColor*** helper classes
8 | */
9 |
10 |
11 | #ifndef HGECOLOR_H
12 | #define HGECOLOR_H
13 |
14 | #include "nge_common.h"
15 | #include "nge_color.h"
16 |
17 | #define hgeColor hgeColorRGB
18 |
19 | inline void ColorClamp(float &x) { if(x<0.0f) x=0.0f; if(x>1.0f) x=1.0f; }
20 |
21 | class NGE_CLASS hgeColorRGB
22 | {
23 | public:
24 | float r,g,b,a;
25 |
26 | hgeColorRGB(float _r, float _g, float _b, float _a) { r=_r; g=_g; b=_b; a=_a; }
27 | hgeColorRGB(uint32_t col) { SetHWColor(col); }
28 | hgeColorRGB() { r=g=b=a=0; }
29 |
30 | hgeColorRGB operator- (const hgeColorRGB &c) const { return hgeColorRGB(r-c.r, g-c.g, b-c.b, a-c.a); }
31 | hgeColorRGB operator+ (const hgeColorRGB &c) const { return hgeColorRGB(r+c.r, g+c.g, b+c.b, a+c.a); }
32 | hgeColorRGB operator* (const hgeColorRGB &c) const { return hgeColorRGB(r*c.r, g*c.g, b*c.b, a*c.a); }
33 | hgeColorRGB& operator-= (const hgeColorRGB &c) { r-=c.r; g-=c.g; b-=c.b; a-=c.a; return *this; }
34 | hgeColorRGB& operator+= (const hgeColorRGB &c) { r+=c.r; g+=c.g; b+=c.b; a+=c.a; return *this; }
35 | BOOL operator== (const hgeColorRGB &c) const { return (r==c.r && g==c.g && b==c.b && a==c.a); }
36 | BOOL operator!= (const hgeColorRGB &c) const { return (r!=c.r || g!=c.g || b!=c.b || a!=c.a); }
37 |
38 | hgeColorRGB operator/ (const float scalar) const { return hgeColorRGB(r/scalar, g/scalar, b/scalar, a/scalar); }
39 | hgeColorRGB operator* (const float scalar) const { return hgeColorRGB(r*scalar, g*scalar, b*scalar, a*scalar); }
40 | hgeColorRGB& operator*= (const float scalar) { r*=scalar; g*=scalar; b*=scalar; a*=scalar; return *this; }
41 |
42 | void Clamp() { ColorClamp(r); ColorClamp(g); ColorClamp(b); ColorClamp(a); }
43 | void SetHWColor(uint32_t col) { a = (col>>24)/255.0f; r = ((col>>16) & 0xFF)/255.0f; g = ((col>>8) & 0xFF)/255.0f; b = (col & 0xFF)/255.0f; }
44 | uint32_t GetHWColor() const { return MAKE_RGBA_8888(((int)(r*255.0f)), ((int)(g*255.0f)), ((int)(b*255.0f)),((int)(a*255.0f))); }
45 | };
46 |
47 | inline hgeColorRGB operator* (const float sc, const hgeColorRGB &c) { return c*sc; }
48 |
49 |
50 | class NGE_CLASS hgeColorHSV
51 | {
52 | public:
53 | float h,s,v,a;
54 |
55 | hgeColorHSV(float _h, float _s, float _v, float _a) { h=_h; s=_s; v=_v; a=_a; }
56 | hgeColorHSV(uint32_t col) { SetHWColor(col); }
57 | hgeColorHSV() { h=s=v=a=0; }
58 |
59 | hgeColorHSV operator- (const hgeColorHSV &c) const { return hgeColorHSV(h-c.h, s-c.s, v-c.v, a-c.a); }
60 | hgeColorHSV operator+ (const hgeColorHSV &c) const { return hgeColorHSV(h+c.h, s+c.s, v+c.v, a+c.a); }
61 | hgeColorHSV operator* (const hgeColorHSV &c) const { return hgeColorHSV(h*c.h, s*c.s, v*c.v, a*c.a); }
62 | hgeColorHSV& operator-= (const hgeColorHSV &c) { h-=c.h; s-=c.s; v-=c.v; a-=c.a; return *this; }
63 | hgeColorHSV& operator+= (const hgeColorHSV &c) { h+=c.h; s+=c.s; v+=c.v; a+=c.a; return *this; }
64 | BOOL operator== (const hgeColorHSV &c) const { return (h==c.h && s==c.s && v==c.v && a==c.a); }
65 | BOOL operator!= (const hgeColorHSV &c) const { return (h!=c.h || s!=c.s || v!=c.v || a!=c.a); }
66 |
67 | hgeColorHSV operator/ (const float scalar) const { return hgeColorHSV(h/scalar, s/scalar, v/scalar, a/scalar); }
68 | hgeColorHSV operator* (const float scalar) const { return hgeColorHSV(h*scalar, s*scalar, v*scalar, a*scalar); }
69 | hgeColorHSV& operator*= (const float scalar) { h*=scalar; s*=scalar; v*=scalar; a*=scalar; return *this; }
70 |
71 | void Clamp() { ColorClamp(h); ColorClamp(s); ColorClamp(v); ColorClamp(a); }
72 | void SetHWColor(uint32_t col);
73 | uint32_t GetHWColor() const;
74 | };
75 |
76 | inline hgeColorHSV operator* (const float sc, const hgeColorHSV &c) { return c*sc; }
77 |
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/include/hge/hgedistort.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** Haaf's Game Engine 1.7
3 | ** Copyright (C) 2003-2007, Relish Games
4 | ** hge.relishgames.com
5 | **
6 | ** hgeDistortionMesh helper class header
7 | */
8 |
9 |
10 | #ifndef HGEDISTORT_H
11 | #define HGEDISTORT_H
12 |
13 |
14 | #include "nge_common.h"
15 | #include "nge_graphics.h"
16 |
17 | #define HGEDISP_NODE 0
18 | #define HGEDISP_TOPLEFT 1
19 | #define HGEDISP_CENTER 2
20 |
21 | /*
22 | ** HGE Distortion mesh class
23 | */
24 | class NGE_CLASS hgeDistortionMesh
25 | {
26 | public:
27 | hgeDistortionMesh(int cols, int rows);
28 | hgeDistortionMesh(const hgeDistortionMesh &dm);
29 | ~hgeDistortionMesh();
30 |
31 | hgeDistortionMesh& operator= (const hgeDistortionMesh &dm);
32 |
33 | void Render(float x, float y);
34 | void Clear(uint32_t col=0xFFFFFFFF, float z=0.0f);
35 |
36 | void SetTexture(image_p tex);
37 | void SetTextureRect(float x, float y, float w, float h);
38 | void SetColor(int col, int row, uint32_t color);
39 | void SetDisplacement(int col, int row, float dx, float dy, int ref);
40 |
41 | image_p GetTexture() const {return quad.tex;}
42 | void GetTextureRect(float *x, float *y, float *w, float *h) const { *x=tx; *y=ty; *w=width; *h=height; }
43 | uint32_t GetColor(int col, int row) const;
44 | void GetDisplacement(int col, int row, float *dx, float *dy, int ref) const;
45 |
46 | int GetRows() { return nRows; }
47 | int GetCols() { return nCols; }
48 |
49 | private:
50 | hgeDistortionMesh();
51 |
52 | vertexf *disp_array;
53 | int nRows, nCols;
54 | float cellw,cellh;
55 | float tx,ty,width,height;
56 | quadf quad;
57 | };
58 | #endif
--------------------------------------------------------------------------------
/include/hge/hgeparticle.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** Haaf's Game Engine 1.7
3 | ** Copyright (C) 2003-2007, Relish Games
4 | ** hge.relishgames.com
5 | **
6 | ** hgeParticleSystem helper class header
7 | */
8 | #ifndef HGEPARTICLE_H
9 | #define HGEPARTICLE_H
10 |
11 | #include "nge_common.h"
12 | #include "hgevector.h"
13 | #include "hgecolor.h"
14 | #include "hgerect.h"
15 | #include "nge_graphics.h"
16 | #include
17 |
18 | #define MAX_PARTICLES 500
19 | #define MAX_PSYSTEMS 100
20 | #ifndef M_PI_2
21 | #define M_PI_2 1.57079632679489661923f
22 | #endif
23 |
24 | typedef struct {
25 | image_p sprite_image;
26 | rectf sprite_clip;
27 | pointf sprite_center;
28 | int sprite_src_blend;
29 | int sprite_des_blend;
30 | }sprite_t,*sprite_p;
31 |
32 | struct hgeParticle
33 | {
34 | hgeVector vecLocation;
35 | hgeVector vecVelocity;
36 |
37 | float fGravity;
38 | float fRadialAccel;
39 | float fTangentialAccel;
40 |
41 | float fSpin;
42 | float fSpinDelta;
43 |
44 | float fSize;
45 | float fSizeDelta;
46 |
47 | hgeColor colColor; // + alpha
48 | hgeColor colColorDelta;
49 |
50 | float fAge;
51 | float fTerminalAge;
52 | };
53 |
54 | struct hgeParticleSystemInfo
55 | {
56 | sprite_p sprite; // texture+rectf
57 | int nEmission; // particles per sec
58 | float fLifetime;
59 |
60 | float fParticleLifeMin;
61 | float fParticleLifeMax;
62 |
63 | float fDirection;
64 | float fSpread;
65 | int /*BOOL*/ bRelative;
66 |
67 | float fSpeedMin;
68 | float fSpeedMax;
69 |
70 | float fGravityMin;
71 | float fGravityMax;
72 |
73 | float fRadialAccelMin;
74 | float fRadialAccelMax;
75 |
76 | float fTangentialAccelMin;
77 | float fTangentialAccelMax;
78 |
79 | float fSizeStart;
80 | float fSizeEnd;
81 | float fSizeVar;
82 |
83 | float fSpinStart;
84 | float fSpinEnd;
85 | float fSpinVar;
86 |
87 | hgeColor colColorStart; // + alpha
88 | hgeColor colColorEnd;
89 | float fColorVar;
90 | float fAlphaVar;
91 | };
92 |
93 | class NGE_CLASS hgeParticleSystem
94 | {
95 | public:
96 | hgeParticleSystemInfo info;
97 |
98 | hgeParticleSystem(const char *filename, sprite_p sprite);
99 | hgeParticleSystem(hgeParticleSystemInfo *psi);
100 | hgeParticleSystem(const hgeParticleSystem &ps);
101 | ~hgeParticleSystem() { }
102 |
103 | hgeParticleSystem& operator= (const hgeParticleSystem &ps);
104 |
105 | static void FixInfoEndian(hgeParticleSystemInfo& info);
106 | static bool ReadInfoFromFile(hgeParticleSystemInfo& info, const char* filename);
107 | static bool SaveInfoToFile(hgeParticleSystemInfo& info, const char* filename);
108 |
109 | void Render();
110 | void FireAt(float x, float y);
111 | void Fire();
112 | void Stop(BOOL bKillParticles = 0);
113 | void Update(float fDeltaTime);
114 | void MoveTo(float x, float y, BOOL bMoveParticles = 0);
115 | void Transpose(float x, float y) { fTx=x; fTy=y; }
116 | void TrackBoundingBox(BOOL bTrack) { bUpdateBoundingBox=bTrack; }
117 |
118 | int GetParticlesAlive() const { return nParticlesAlive; }
119 | float GetAge() const { return fAge; }
120 | void GetPosition(float *x, float *y) const { *x=vecLocation.x; *y=vecLocation.y; }
121 | void GetTransposition(float *x, float *y) const { *x=fTx; *y=fTy; }
122 | hgeRect* GetBoundingBox(hgeRect *rect) const { memcpy(rect, &rectBoundingBox, sizeof(hgeRect)); return rect; }
123 |
124 | private:
125 | hgeParticleSystem();
126 |
127 | float fAge;
128 | float fEmissionResidue;
129 |
130 | hgeVector vecPrevLocation;
131 | hgeVector vecLocation;
132 | float fTx, fTy;
133 |
134 | int nParticlesAlive;
135 | hgeRect rectBoundingBox;
136 | BOOL bUpdateBoundingBox;
137 |
138 | hgeParticle particles[MAX_PARTICLES];
139 |
140 | float mTimer;
141 | };
142 |
143 | class NGE_CLASS hgeParticleManager
144 | {
145 | public:
146 | hgeParticleManager();
147 | ~hgeParticleManager();
148 |
149 | void Update(float dt);
150 | void Render();
151 |
152 | hgeParticleSystem* SpawnPS(hgeParticleSystemInfo *psi, float x, float y);
153 | BOOL IsPSAlive(hgeParticleSystem *ps) const;
154 | void Transpose(float x, float y);
155 | void GetTransposition(float *dx, float *dy) const {*dx=tX; *dy=tY;}
156 | void KillPS(hgeParticleSystem *ps);
157 | void KillAll();
158 |
159 | private:
160 | hgeParticleManager(const hgeParticleManager &);
161 | hgeParticleManager& operator= (const hgeParticleManager &);
162 |
163 | int nPS;
164 | float tX;
165 | float tY;
166 | hgeParticleSystem* psList[MAX_PSYSTEMS];
167 | };
168 |
169 |
170 | #endif
171 |
--------------------------------------------------------------------------------
/include/hge/hgerect.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Thanks to Dr.Watson JGE++!
3 | ** Haaf's Game Engine 1.7
4 | ** Copyright (C) 2003-2007, Relish Games
5 | ** hge.relishgames.com
6 | **
7 | ** hgeRect helper class
8 | */
9 |
10 |
11 | #ifndef HGERECT_H
12 | #define HGERECT_H
13 |
14 | #include "nge_common.h"
15 |
16 | class NGE_CLASS hgeRect
17 | {
18 | public:
19 | float x1, y1, x2, y2;
20 |
21 | hgeRect(float _x1, float _y1, float _x2, float _y2) {x1=_x1; y1=_y1; x2=_x2; y2=_y2; bClean=0; }
22 | hgeRect() {bClean=1;}
23 |
24 | void Clear() {bClean=1;}
25 | BOOL IsClean() const {return bClean;}
26 | void Set(float _x1, float _y1, float _x2, float _y2) { x1=_x1; x2=_x2; y1=_y1; y2=_y2; bClean=0; }
27 | void SetRadius(float x, float y, float r) { x1=x-r; x2=x+r; y1=y-r; y2=y+r; bClean=0; }
28 | void Encapsulate(float x, float y);
29 | BOOL TestPoint(float x, float y) const;
30 | BOOL Intersect(const hgeRect *rect) const;
31 |
32 | private:
33 | BOOL bClean;
34 | };
35 |
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/include/hge/hgevector.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** Haaf's Game Engine 1.7
3 | ** Copyright (C) 2003-2007, Relish Games
4 | ** hge.relishgames.com
5 | **
6 | ** hgeVector helper class
7 | */
8 |
9 |
10 | #ifndef HGEVECTOR_H
11 | #define HGEVECTOR_H
12 |
13 | #include "nge_common.h"
14 | #include
15 |
16 | /*
17 | ** Fast 1.0/sqrtf(float) routine
18 | */
19 | float InvSqrt(float x);
20 |
21 | class NGE_CLASS hgeVector
22 | {
23 | public:
24 | float x,y;
25 |
26 | hgeVector(float _x, float _y) { x=_x; y=_y; }
27 | hgeVector() { x=0; y=0; }
28 |
29 | hgeVector operator- () const { return hgeVector(-x, -y); }
30 | hgeVector operator- (const hgeVector &v) const { return hgeVector(x-v.x, y-v.y); }
31 | hgeVector operator+ (const hgeVector &v) const { return hgeVector(x+v.x, y+v.y); }
32 | hgeVector& operator-= (const hgeVector &v) { x-=v.x; y-=v.y; return *this; }
33 | hgeVector& operator+= (const hgeVector &v) { x+=v.x; y+=v.y; return *this; }
34 | bool operator== (const hgeVector &v) const { return (x==v.x && y==v.y); }
35 | bool operator!= (const hgeVector &v) const { return (x!=v.x || y!=v.y); }
36 |
37 | hgeVector operator/ (const float scalar) const { return hgeVector(x/scalar, y/scalar); }
38 | hgeVector operator* (const float scalar) const { return hgeVector(x*scalar, y*scalar); }
39 | hgeVector& operator*= (const float scalar) { x*=scalar; y*=scalar; return *this; }
40 |
41 | float Dot(const hgeVector *v) const { return x*v->x + y*v->y; }
42 | float Length() const { return sqrtf(Dot(this)); }
43 | float Angle(const hgeVector *v = 0) const;
44 |
45 | void Clamp(const float max) { if(Length() > max) { Normalize(); x *= max; y *= max; } }
46 | hgeVector* Normalize() { float rc=InvSqrt(Dot(this)); x*=rc; y*=rc; return this; }
47 | hgeVector* Rotate(float a);
48 | };
49 |
50 | inline hgeVector operator* (const float s, const hgeVector &v) { return v*s; }
51 | inline float operator^ (const hgeVector &v, const hgeVector &u) { return v.Angle(&u); }
52 | inline float operator% (const hgeVector &v, const hgeVector &u) { return v.Dot(&u); }
53 |
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/include/libnge2.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * libnge2.h
3 | *
4 | * 2011/04/27 16:58:20
5 | * Copyright 2011 Kun Wang
6 | ****************************************************************************/
7 | /*
8 | * This program is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This program is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 | */
22 |
23 | #ifndef _LIBNGE2_H
24 | #define _LIBNGE2_H
25 |
26 | #include "nge_common.h"
27 | #include "libnge2pure.h"
28 | #include "audio_interface.h"
29 | #include "nge_ref_handle.h"
30 | #include "nge_package.h"
31 | #include "nge_main.h"
32 | #include "nge_app.h"
33 |
34 | #endif /* _LIBNGE2_H */
35 |
--------------------------------------------------------------------------------
/include/libnge2pure.h:
--------------------------------------------------------------------------------
1 | #ifndef LIBNGE2PURE_H_
2 | #define LIBNGE2PURE_H_
3 |
4 | #include "nge_common.h"
5 | #include "nge_debug_log.h"
6 | #include "nge_sys_compatible.h"
7 | #include "nge_ref_handle.h"
8 | #include "nge_io_file.h"
9 | #include "nge_io_dir.h"
10 | #include "nge_package.h"
11 | #include "nge_package_zip.h"
12 | #include "nge_image.h"
13 | #include "nge_font.h"
14 | #include "nge_graphics.h"
15 | #include "nge_image_ext.h"
16 | #include "nge_input.h"
17 | #include "nge.h"
18 | #include "nge_misc.h"
19 | #include "nge_timer.h"
20 | #include "nge_gif.h"
21 |
22 | #endif
23 |
--------------------------------------------------------------------------------
/include/movie/nge_movie.h:
--------------------------------------------------------------------------------
1 | #ifndef NGE_MOVIE_PLAY_H
2 | #define NGE_MOVIE_PLAY_H
3 | //use libpmp to play movie
4 |
5 | // load file and do file init
6 | typedef int (*md_load) (const char *);
7 | // play movie
8 | typedef int (*md_play) (void);
9 | // return 1 if movie is end
10 | typedef int (*md_eos) (void);
11 | //stop movie and free CURRENT FILE resource
12 | typedef int (*md_stop) (void);
13 |
14 | typedef struct {
15 | md_load load;
16 | md_play play;
17 | md_stop stop;
18 | md_eos eos;
19 | char extension[256];
20 | }movie_ops;
21 |
22 | //the interface
23 | #ifdef _cplusplus
24 | extern "C"
25 | #endif
26 |
27 | void MoviePlayInit(movie_ops *ops);
28 | void MoviePlayFini(void);
29 |
30 | #ifdef _cplusplus
31 | }
32 | #endif
33 |
34 |
35 |
36 | #endif
37 |
38 |
--------------------------------------------------------------------------------
/include/nge.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge.h
--------------------------------------------------------------------------------
/include/nge_app.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * nge_app.h
3 | *
4 | * 2011/03/25 06:45:09
5 | * Copyright 2010 TOPOC. All rights reserved.
6 | * Copyright 2011 Kun Wang
7 | ****************************************************************************/
8 | /*
9 | * This program is free software; you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation; either version 2 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with this program; if not, write to the Free Software
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 | */
23 |
24 | #ifndef _NGE_APP_H
25 | #define _NGE_APP_H
26 |
27 | #include "nge_common.h"
28 |
29 | enum{
30 | NGE_APP_NORMAL = 0,
31 | NGE_APP_QUIT
32 | };
33 |
34 | typedef struct nge_app {
35 | int (*init) (void);
36 | int (*mainloop) (void);
37 | int (*fini) (void);
38 | int (*pause)(void);
39 | int (*resume)(void);
40 | int (*start)(void);
41 | int (*stop)(void);
42 | } nge_app_t;
43 |
44 | #ifdef __cplusplus
45 | extern "C" {
46 | #endif
47 |
48 | NGE_API void nge_register_app(nge_app_t *app);
49 | NGE_API nge_app_t* nge_get_app();
50 | NGE_API void nge_init_app(nge_app_t *app);
51 |
52 | #ifdef __cplusplus
53 | }
54 | #endif
55 |
56 | #endif /* _NGE_APP_H */
57 |
--------------------------------------------------------------------------------
/include/nge_app.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * @file nge_app.hpp
3 | * @author Kun Wang
4 | * @date 2011/08/08 13:25:02
5 | *
6 | * Copyright 2011 Kun Wang
7 | *
8 | * This program is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This program is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 | */
22 |
23 | #ifndef _NGE_APP_HPP
24 | #define _NGE_APP_HPP
25 |
26 | #include "nge_common.h"
27 | #include "nge_app.h"
28 |
29 | class CNgeApp
30 | {
31 | public:
32 | CNgeApp() { mFps = 60; };
33 | virtual ~CNgeApp() {};
34 | virtual int Init() = 0;
35 | virtual int Mainloop() = 0;
36 | virtual int Fini() = 0;
37 | virtual int Pause() {return 0;}
38 | virtual int Resume(){return 0;}
39 | virtual int Start(){return 0;}
virtual int Stop(){return 0;}
40 | public:
41 | int mFps;
42 | };
43 |
44 | extern "C" {
45 | NGE_API void nge_registerApp(CNgeApp *app);
46 | }
47 |
48 | #endif /* _NGE_APP_HPP */
49 |
--------------------------------------------------------------------------------
/include/nge_bmp.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_bmp.h
--------------------------------------------------------------------------------
/include/nge_charsets.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_charsets.h
--------------------------------------------------------------------------------
/include/nge_color.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_color.h
--------------------------------------------------------------------------------
/include/nge_common.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * nge_common.h
3 | *
4 | * 2011/03/25 06:23:30
5 | * Copyright 2011 Kun Wang
6 | ****************************************************************************/
7 | /*
8 | * This program is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This program is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 | */
22 |
23 | #ifndef _NGE_COMMON_H
24 | #define _NGE_COMMON_H
25 |
26 | #define NGE_MAJOR_VERSION 2
27 | #define NGE_MINOR_VERSION 1
28 | #define NGE_PATCHLEVEL 0
29 | #define NGE_VERSION "2.1.0"
30 |
31 | #include "nge_platform.h"
32 | #include "nge_dll_export.h"
33 |
34 | #ifndef FALSE
35 | #define FALSE 0
36 | #endif
37 |
38 | #ifndef TRUE
39 | #define TRUE 1
40 | #endif
41 |
42 | #ifndef NULL
43 | #ifdef __cplusplus
44 | #define NULL 0
45 | #else
46 | #define NULL ((void *)0)
47 | #endif
48 | #endif
49 |
50 | #if defined(_MSC_VER) &&(_MSC_VER) < 1600
51 | /* for vs before vs2010 */
52 | #include "msvc/stdint.h"
53 | #else
54 | /* for c99 compatible, include vs2010 */
55 | #include
56 | #endif
57 |
58 |
59 | #if defined(NGE_IPHONE)
60 | #ifndef BOOL
61 | #define BOOL int
62 | #endif
63 | #else
64 | #ifdef _MSC_VER
65 | typedef int BOOL;
66 | #else
67 | typedef uint8_t BOOL;
68 | #endif
69 | #endif
70 |
71 |
72 | #define SAFE_FREE(ptr) free(ptr);ptr = NULL
73 |
74 | #if defined(_MSC_VER) && !defined(__cplusplus)
75 | #define inline __inline
76 | #endif
77 |
78 | #endif /* _NGE_COMMON_H */
79 |
--------------------------------------------------------------------------------
/include/nge_debug_log.h:
--------------------------------------------------------------------------------
1 | /* kid ! do not modify this file if you do not know what to do! X:D */
2 | #ifndef __NGE_DEBUG_LOG_H__
3 | #define __NGE_DEBUG_LOG_H__
4 |
5 | #include "nge_common.h"
6 |
7 | #ifdef MMGR
8 | #include "nge_mmgr.h"
9 | #endif
10 |
11 | /**
12 | * debug log function
13 | */
14 | #ifndef NDEBUG
15 | #if defined NGE_PSP
16 | #include
17 | #define printf pspDebugScreenPrintf
18 | #endif
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | NGE_API void nge_log(const char* pMessage, ...);
25 | NGE_API void nge_error(const char* pMessage, ...);
26 | NGE_API void nge_debug_quitgame();
27 | NGE_API void nge_mem_log();
28 | #define nge_line() nge_log("%s(line:%d): ",__FILE__,__LINE__)
29 | #define nge_print nge_log
30 |
31 | #ifdef __cplusplus
32 | }
33 | #endif
34 | #else /* defined NDEBUG */
35 | #ifndef NGE_NEED_PRINTF
36 | #include
37 | #ifdef WIN32
38 | #define printf()
39 | #else
40 | #define printf(...)
41 | #endif
42 | #endif
43 |
44 | #ifdef WIN32
45 | #pragma warning(disable :4002)
46 | #define nge_log()
47 | #define nge_print nge_log
48 | #define nge_error()
49 | #define nge_debug_quitgame();
50 | #define nge_line()
51 | #else
52 | #define nge_log(...)
53 | #define nge_print nge_log
54 | #define nge_error(...)
55 | #define nge_debug_quitgame(...);
56 | #define nge_line(...)
57 | #endif
58 | #endif /* _DEBUG_LOG */
59 |
60 | #endif /* __NGELOG_H__ */
61 |
--------------------------------------------------------------------------------
/include/nge_dll_export.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file nge_dll_export.h
3 | * @author Kun Wang
4 | * @date 2012/03/04 05:53:38
5 | *
6 | * Copyright 2012 Kun Wang
7 | *
8 | */
9 |
10 | #ifndef _NGE_DLL_EXPORT_H
11 | #define _NGE_DLL_EXPORT_H
12 |
13 | #ifndef NGE_API
14 | #ifdef NGE_LIBTYPE_STATIC
15 | #define NGE_API
16 | #define NGE_CLASS
17 | #elif defined WIN32
18 | #ifdef NGE2_EXPORTS
19 | #define NGE_API __declspec(dllexport)
20 | #else
21 | #define NGE_API __declspec(dllimport)
22 | #endif
23 | #define NGE_CLASS NGE_API
24 | #else
25 | #define NGE_API extern
26 | #define NGE_CLASS
27 | #endif
28 | #endif
29 |
30 | #ifdef WIN32
31 | #define NGE_APIENTRY __cdecl
32 | #else
33 | #define NGE_APIENTRY
34 | #endif
35 |
36 | #endif /* _NGE_DLL_EXPORT_H */
37 |
--------------------------------------------------------------------------------
/include/nge_endian_internal.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file nge_endian_internal.h
3 | * @author Kun Wang
4 | * @date 2012/03/23 14:00:37
5 | *
6 | * Copyright 2012 Kun Wang
7 | *
8 | */
9 |
10 | #ifndef _NGE_ENDIAN_INTERNAL_H
11 | #define _NGE_ENDIAN_INTERNAL_H
12 |
13 | #include "nge_common.h"
14 |
15 | #define OP_LITTLEENDIAN '<'
16 | #define OP_BIGENDIAN '>'
17 | #define OP_NATIVE '='
18 |
19 | inline static int doendian(int c)
20 | {
21 | int x=1;
22 | int e=*(char*)&x;
23 | if (c==OP_LITTLEENDIAN) return !e;
24 | if (c==OP_BIGENDIAN) return e;
25 | if (c==OP_NATIVE) return 0;
26 | return 0;
27 | }
28 |
29 | inline static void doswap(int swap, void *p, size_t n)
30 | {
31 | if (swap)
32 | {
33 | char *a=(char*)p;
34 | int i,j;
35 | for (i=0, j=n-1, n=n/2; n--; i++, j--)
36 | {
37 | char t=a[i]; a[i]=a[j]; a[j]=t;
38 | }
39 | }
40 | }
41 |
42 | #define DECL_ENDIAN() uint8_t __swap__ = 0
43 | #define SET_ENDIAN(endian) __swap__ = doendian(endian)
44 | #define DO_ENDIAN(type, ptr) \
45 | doswap(__swap__, (void*)(ptr), sizeof(type))
46 |
47 | #define PUSH_STRUCT(type, ptr, mem) \
48 | memcpy(mem, (ptr), sizeof(type)); \
49 | mem += sizeof(type)
50 | #define POP_STRUCT(type, ptr, mem) \
51 | memcpy((ptr), mem, sizeof(type)); \
52 | mem += sizeof(type)
53 |
54 | #define PUSH_UINT8(val, mem) \
55 | mem[0] = (uint8_t)val; \
56 | mem += 1
57 | #define POP_UINT8(val, mem) \
58 | val = mem[0]; \
59 | mem += 1
60 |
61 | #define PUSH_UINT8S(ptr, mem, size) \
62 | memcpy(&(mem[0]), ptr, size); \
63 | mem += size
64 | #define POP_UINT8S(val, mem, size) \
65 | memcpy(ptr, &(mem[0]), size); \
66 | mem += size
67 |
68 | #define PUSH_FLOAT(val, mem) \
69 | memcpy(&(mem[0]), &(val), sizeof(float)); \
70 | mem += sizeof(float)
71 | #define POP_FLOAT(val, mem) \
72 | memcpy(&(val), &(mem[0]), sizeof(float)); \
73 | mem += sizeof(float)
74 |
75 | #define PUSH_FLOATS(ptr, mem, size) \
76 | memcpy(&(mem[0]), ptr, size * sizeof(float)); \
77 | mem += size * sizeof(float)
78 | #define POP_FLOATS(ptr, mem, size) \
79 | memcpy(ptr, &(mem[0]), size * sizeof(float)); \
80 | mem += size * sizeof(float)
81 |
82 | #define PUSH_TYPE(type, val, mem) \
83 | memcpy(&(mem[0]), &(val), sizeof(type)); \
84 | DO_ENDIAN(type, &(mem[0])); \
85 | mem += sizeof(type)
86 | #define POP_TYPE(type, val, mem) \
87 | memcpy(&(val), &(mem[0]), sizeof(type)); \
88 | DO_ENDIAN(type, &(var)); \
89 | mem += sizeof(type)
90 |
91 | #define SKIP_SIZE(mem, size) \
92 | mem += size
93 |
94 | #endif /* _NGE_ENDIAN_INTERNAL_H */
95 |
--------------------------------------------------------------------------------
/include/nge_font.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_font.h
--------------------------------------------------------------------------------
/include/nge_font_internal.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file nge_font_internal.h
3 | * @author Kun Wang
4 | * @date 2012/03/05 12:08:10
5 | *
6 | * Copyright 2012 Kun Wang
7 | *
8 | */
9 |
10 | #ifndef _NGE_FONT_INTERNAL_H
11 | #define _NGE_FONT_INTERNAL_H
12 |
13 | //type flags
14 | #define FONT_TYPE_HZK 1
15 | #define FONT_TYPE_GBK 2
16 | #define FONT_TYPE_FREETYPE 4
17 |
18 | //freetype private flags
19 | #define FONT_ANTIALIAS 32
20 | #define FONT_KERNING 64
21 | #define FLAGS_FREETYPE_BOLD 1
22 | #define FLAGS_FREETYPE_ITALICS (1 << 1)
23 |
24 | typedef struct {
25 | /**
26 | * Maximum advance width of any character.
27 | */
28 | int maxwidth;
29 | /**
30 | * Height of "most characters" in the font. This does not include any
31 | * leading (blank space between lines of text).
32 | * Always equal to (baseline+descent).
33 | */
34 | int height;
35 | /**
36 | * The ascent (height above the baseline) of "most characters" in
37 | * the font.
38 | *
39 | * Note: This member variable should be called "ascent", to be
40 | * consistent with FreeType 2, and also to be internally consistent
41 | * with the "descent" member. It has not been renamed because that
42 | * would break backwards compatibility. FIXME
43 | */
44 | int baseline;
45 | /**
46 | * The descent (height below the baseline) of "most characters" in
47 | * the font.
48 | *
49 | * Should be a POSITIVE number.
50 | */
51 | int descent;
52 | /**
53 | * Maximum height of any character above the baseline.
54 | */
55 | int maxascent;
56 | /**
57 | * Maximum height of any character below the baseline.
58 | * Should be a POSITIVE number.
59 | */
60 | int maxdescent;
61 | /**
62 | * The distance between the baselines of two consecutive lines of text.
63 | * This is usually height plus some font-specific "leading" value.
64 | */
65 | int linespacing;
66 | /**
67 | * First character in the font.
68 | */
69 | int firstchar;
70 | /**
71 | * Last character in the font.
72 | */
73 | int lastchar;
74 | /**
75 | * True (nonzero) if font is fixed width. In that case, maxwidth
76 | * gives the width for every character in the font.
77 | */
78 | BOOL fixed;
79 | /**
80 | * Table of character advance widths for characters 0-255.
81 | * Note that fonts can contain characters with codes >255 - in that
82 | * case this table contains the advance widths for some but not all
83 | * characters. Also note that if the font contains kerning
84 | * information, the advance width of the string "AV" may differ from
85 | * the sum of the advance widths for the characters 'A' and 'V'.
86 | */
87 | uint8_t widths[256];
88 | } FontInfo, *PFontInfo;
89 |
90 | struct _fontproc{
91 | BOOL (*GetFontInfo)(PFont pfont, PFontInfo pfontinfo);
92 | void (*GetTextSize)(PFont pfont, const void *text, int cc,int flags, int *pwidth, int *pheight,int *pbase);
93 | void (*GetTextBits)(PFont pfont, int ch, const uint8_t **retmap,int *pwidth, int *pheight,int *pbase);
94 | void (*DestroyFont)(PFont pfont);
95 | void (*DrawText)(PFont pfont, image_p pimage, int x, int y,const void *str, int count, int flags);
96 | void (*DrawTextShadow)(PFont pfont, image_p pimage, int x, int y,const void *str, int count, int flags);
97 | uint32_t (*SetFontColor)(PFont pfont, uint32_t color);
98 | void (*SetFontSize)(PFont pfont, int fontsize);
99 | void (*SetFontRotation)(PFont pfont, int rot);
100 | void (*SetFontAttr)(PFont pfont, int setflags, int clrflags);
101 | PFont (*Duplicate) (PFont psrcfont, int fontsize);
102 | void (*SetFlags)(PFont pfont,int flags);
103 | void (*SetShadowColor)(PFont pfont, uint32_t color_fg,uint32_t color_bg,uint32_t color_sh);
104 | };
105 |
106 | typedef struct _fontproc FontProcs;
107 | typedef struct _fontproc *PFontProcs;
108 |
109 | typedef struct{
110 | char* data;
111 | int datalen;
112 | } workbuf;
113 |
114 | struct _pfont { /* common hdr for all font structures*/
115 | struct _fontproc* procs; /* font-specific rendering routines*/
116 | int size; /* font height in pixels*/
117 | int rotation; /* font rotation*/
118 | uint32_t disp; /* font attributes: kerning/antialias*/
119 | int flags;
120 | workbuf encodingBuf;
121 |
122 | /* font-specific rendering data here*/
123 | };
124 |
125 | typedef struct _pfont TFont;
126 |
127 | extern uint8_t nge_font_encoding;
128 |
129 | #endif /* _NGE_FONT_INTERNAL_H */
130 |
--------------------------------------------------------------------------------
/include/nge_gif.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_gif.h
--------------------------------------------------------------------------------
/include/nge_graphics.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_graphics.h
--------------------------------------------------------------------------------
/include/nge_image.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_image.h
--------------------------------------------------------------------------------
/include/nge_image_effect.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_image_effect.h
--------------------------------------------------------------------------------
/include/nge_image_ext.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_image_ext.h
--------------------------------------------------------------------------------
/include/nge_input.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_input.h
--------------------------------------------------------------------------------
/include/nge_io_dir.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_io_dir.h
--------------------------------------------------------------------------------
/include/nge_io_file.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_io_file.h
--------------------------------------------------------------------------------
/include/nge_io_file_internal.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file nge_io_file_internal.h
3 | * @author Kun Wang
4 | * @date 2012/03/18 04:40:28
5 | *
6 | * Copyright 2012 Kun Wang
7 | *
8 | */
9 |
10 | #ifndef _NGE_IO_FILE_INTERNAL_H
11 | #define _NGE_IO_FILE_INTERNAL_H
12 |
13 | typedef struct ngeVFOperation_s ngeVFOperation;
14 |
15 | typedef struct ngeVF_s {
16 | ngeVFOperation* op;
17 | } ngeVF;
18 |
19 | struct ngeVFOperation_s
20 | {
21 | /**
22 | Close a file.
23 |
24 | Return 1 if anything went well, 0 to throw an error.
25 | */
26 | int (*Close)(ngeVF *f);
27 |
28 | /**
29 | Read in a file. (optional)
30 |
31 | Returns the number of bytes effectively read.
32 | */
33 | int (*Read)(void *buf, size_t size, size_t n, ngeVF* f);
34 |
35 | /**
36 | Write in a file (optional)
37 |
38 | Returns the number of bytes effectively written.
39 | */
40 | int (*Write)(const void *buf, size_t size, size_t n, ngeVF* f);
41 |
42 | /**
43 | Moving in the file (optional)
44 |
45 | Sets the current file position and returns the old one. The flag parameter uses the same values as stdio (IO_SEEK_SET, IO_SEEK_CUR, IO_SEEK_END).
46 | */
47 | int (*Seek)(ngeVF *f, int offset, int flag);
48 |
49 | /**
50 | Get current file position (optional)
51 |
52 | Returns the current pointer position in the file.
53 | */
54 | int (*Tell)(ngeVF *f);
55 |
56 | /**
57 | End of file (optional)
58 |
59 | Returns true (1) if it's the end of the file, false (0) else.
60 | */
61 | int (*Eof)(ngeVF *f);
62 |
63 | /**
64 | Size of file (optional)
65 | */
66 | int (*Size)(ngeVF *f);
67 | };
68 |
69 | #ifdef __cplusplus
70 | extern "C" {
71 | #endif
72 |
73 | NGE_API int ngeVFAdd(ngeVF* f);
74 |
75 | #ifdef __cplusplus
76 | }
77 | #endif
78 |
79 | #endif /* _NGE_IO_FILE_INTERNAL_H */
80 |
--------------------------------------------------------------------------------
/include/nge_jpg.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_jpg.h
--------------------------------------------------------------------------------
/include/nge_main.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * nge_main.h
3 | *
4 | * 2011/03/26 01:50:11
5 | * Copyright 2011 Kun Wang
6 | ****************************************************************************/
7 |
8 | #ifndef _NGE_MAIN_H
9 | #define _NGE_MAIN_H
10 |
11 | #ifdef main
12 | #undef main
13 | #endif
14 |
15 | #define main NGE_main
16 |
17 | #endif /* _NGE_MAIN_H */
18 |
--------------------------------------------------------------------------------
/include/nge_misc.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_misc.h
--------------------------------------------------------------------------------
/include/nge_mmgr.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * nge_mmgr.h
3 | *
4 | * 2011/03/25 12:40:34
5 | * Copyright 2011 Kun Wang
6 | ****************************************************************************/
7 | /*
8 | * This program is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This program is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 | */
22 |
23 | #ifndef _NGE_MMGR_H
24 | #define _NGE_MMGR_H
25 |
26 | #include "nge_common.h"
27 |
28 | #ifdef __cplusplus
29 | extern "C" {
30 | #endif
31 |
32 | #ifndef NDEBUG
33 | #ifdef MMGR
34 | //for debug -- mmgr can use in ANSI C ...
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include "mmgr.h"
40 | #endif
41 | #endif
42 |
43 | #ifdef __cplusplus
44 | }
45 | #endif
46 |
47 | #endif /* _NGE_MMGR_H */
48 |
--------------------------------------------------------------------------------
/include/nge_package.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_package.h
--------------------------------------------------------------------------------
/include/nge_package_internal.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_package_internal.h
--------------------------------------------------------------------------------
/include/nge_package_zip.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_package_zip.h
--------------------------------------------------------------------------------
/include/nge_platform.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file nge_platform.h
3 | * @author Kun Wang
4 | * @date 2011/08/07 09:11:47
5 | *
6 | * Copyright 2011 Kun Wang
7 | */
8 |
9 | #ifndef _NGE_PLATFORM_H
10 | #define _NGE_PLATFORM_H
11 |
12 | #if defined _PSP
13 | #define NGE_PSP
14 |
15 | #elif defined TARGET_OS_IPHONE || defined TARGET_IPHONE_SIMULATOR
16 | #define NGE_IPHONE
17 |
18 | #elif defined __ANDROID_API__ || defined ANDROID
19 | #define NGE_ANDROID
20 |
21 | #elif defined _WIN32
22 | #define NGE_WIN
23 |
24 | #elif defined __APPLE__
25 | #define NGE_MAC
26 |
27 | /*
28 | put linux to last one, because some other platform
29 | is build on top of linux, like android
30 | */
31 | #elif defined __linux__
32 | #define NGE_LINUX
33 |
34 | #endif
35 |
36 | #if defined NGE_PSP
37 | #define NGE_PLATFORM_CONSOLE
38 | #endif
39 |
40 | #if defined NGE_IPHONE || defined NGE_ANDROID
41 | #define NGE_PLATFORM_MOBILE
42 | #endif
43 |
44 | #if defined NGE_WIN || defined NGE_LINUX || defined NGE_MAC
45 | #define NGE_PLATFORM_DESKTOP
46 | #endif
47 |
48 | #endif /* _NGE_PLATFORM_H */
49 |
--------------------------------------------------------------------------------
/include/nge_png.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_png.h
--------------------------------------------------------------------------------
/include/nge_rbtree.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_rbtree.h
--------------------------------------------------------------------------------
/include/nge_ref_handle.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_ref_handle.h
--------------------------------------------------------------------------------
/include/nge_rle.h:
--------------------------------------------------------------------------------
1 | #ifndef __NGE_RLE_H__
2 | #define __NGE_RLE_H__
3 |
4 | #include "nge_common.h"
5 |
6 | //#define assembler_decode__
7 | #ifdef __cplusplus
8 | extern "C"{
9 | #endif
10 | NGE_API void decodeRLE( void* src, int srcLen, void* dst, int dstLen, int bits );
11 |
12 | // returns RLE encoded size of data, linesz gives number of pixels after which to stop any runs
13 | // dstLen should be srcLen + srcLen/4 to make sure all of src can be encoded.
14 | NGE_API long encodeRLE( void* src, int srcLen, int linesz, void* dst, int dstLen, int bits );
15 | #ifdef __cplusplus
16 | }
17 | #endif
18 |
19 | #endif
20 |
21 |
--------------------------------------------------------------------------------
/include/nge_sys_compatible.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_sys_compatible.h
--------------------------------------------------------------------------------
/include/nge_tex_cache.h:
--------------------------------------------------------------------------------
1 | #ifndef NGE_TEX_CACHE_H_
2 | #define NGE_TEX_CACHE_H_
3 |
4 | #include "nge_common.h"
5 |
6 | #ifdef __cplusplus
7 | extern "C" {
8 | #endif
9 |
10 | NGE_API void tex_cache_init (int size);
11 | NGE_API int tex_cache_getid(int imgid,int* cacheid);
12 | NGE_API int tex_cache_free(int imgid);
13 | NGE_API void tex_cache_fini();
14 | NGE_API int tex_cache_add(int i,int texid);
15 | NGE_API void tex_cache_clear();
16 |
17 | #ifdef __cplusplus
18 | }
19 | #endif
20 |
21 | #endif
22 |
23 |
--------------------------------------------------------------------------------
/include/nge_tga.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_tga.h
--------------------------------------------------------------------------------
/include/nge_timer.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/include/nge_timer.h
--------------------------------------------------------------------------------
/include/nge_utilskit.h:
--------------------------------------------------------------------------------
1 | #ifndef NGE_UTILSKIT_H_
2 | #define NGE_UTILSKIT_H_
3 | #include "nge_common.h"
4 |
5 | typedef void (*PayFeedBackCall)(int error,char* errorStr,void* userdata);
6 |
7 | #ifdef __cplusplus
8 | extern "C"{
9 | #endif
10 |
11 | NGE_API void UtilsKitDefaultInit();
12 |
13 |
14 | NGE_API void UtilsKitDefaultFini();
15 |
16 | //for ad
17 | NGE_API int CreateAdHandle(const char* adKey,const char* adType);
18 |
19 | NGE_API void SetAdPos(int adHandle,int x,int y);
20 |
21 | NGE_API void ShowAd(int adHandle,int bShow);
22 |
23 | NGE_API void DestroyAdHandle(int adHandle);
24 |
25 | //for payment
26 | NGE_API int CreatePayHandle(const char* payType,const char* partner,const char* seller,const char* privateRSA,const char* publicRSA);
27 |
28 | NGE_API int Pay(int payHandle,const char* title,const char* body,const char* total,PayFeedBackCall pCall,void* userData);
29 |
30 | // for share
31 | NGE_API int Share(int shareHandle,const char* str,const char* imgName);
32 |
33 | //for more game
34 | NGE_API void MoreGame(int type);
35 |
36 | #ifdef __cplusplus
37 | }
38 | #endif
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/include/pmp.h:
--------------------------------------------------------------------------------
1 | /*
2 | PMP Mod - mini lib
3 | Copyright (C) 2006 jonny
4 | Copyright (C) 2007 Raphael
5 |
6 | Homepage: http://jonny.leffe.dnsalias.com
7 | http://wordpress.fx-world.org
8 | E-mail: jonny@leffe.dnsalias.com
9 |
10 | This program is free software; you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation; either version 2 of the License, or
13 | (at your option) any later version.
14 |
15 | This program is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with this program; if not, write to the Free Software
22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 | */
24 |
25 | /*
26 | this lib should be used to play .pmp files
27 | */
28 |
29 |
30 | #ifndef pmp_h
31 | #define pmp_h
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | // Call once on startup to initialize pmp playback (loads the codecs)
38 | char* pmp_init();
39 |
40 | // play file s and decode in pixelformat 'format' (see pspmpeg.h for modes, possible are 4444,5650,5551 and 8888)
41 | // if show is set to 1 the display of the video will be handled by the output thread
42 | // else the caller has to display the video itself by querying the frames with pmp_get_frame and somehow getting them
43 | // displayed on screen
44 | char *pmp_play(char *s, int show, int format);
45 |
46 | // return pointer to current frame, also set frame format, width, height and buffer width
47 | void* pmp_get_frame(int* format, int* width, int* height, int* vbw );
48 |
49 | // Stop the playback and free all resources
50 | void pmp_stop();
51 |
52 | // Check if playback is still running
53 | int pmp_isplaying();
54 |
55 | #ifdef __cplusplus
56 | }
57 | #endif
58 |
59 | #endif
60 |
--------------------------------------------------------------------------------
/include/psp/nge_vram.h:
--------------------------------------------------------------------------------
1 | #ifndef common_vram_h
2 | #define common_vram_h
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | /*
9 | The following are a few helperfunctions to help manage vram in gu-examples.
10 | Do not use for your own code, it's better you manage it in your own way.
11 | */
12 |
13 | /* get vram offset */
14 | unsigned int getStaticVramOffset();
15 | /* make a static allocation of vram memory and return pointer relative to vram start */
16 | void* getStaticVramBuffer(unsigned int width, unsigned int height, unsigned int psm);
17 | /* make a static allocation of vram memory and return absolute pointer */
18 | void* getStaticVramTexture(unsigned int width, unsigned int height, unsigned int psm);
19 |
20 | // the following is not yet implemented
21 | /*
22 | void beginDynamicVramFrame();
23 | void endDynamicVramFrame();
24 |
25 | void* getDynamicVramBuffer(unsigned int width, unsigned int height, unsigned int psm);
26 | void* getDynamicVramTexture(unsigned int width, unsigned int height, unsigned int psm);
27 | */
28 |
29 | #ifdef __cplusplus
30 | }
31 | #endif
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/mmgr/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(MMGR_SRCS
2 | mmgr.cpp
3 | )
4 |
5 | add_addon_srcs(mmgr INCLUDE_THIS_DIR SRCS ${MMGR_SRCS})
6 |
--------------------------------------------------------------------------------
/mmgr/nommgr.h:
--------------------------------------------------------------------------------
1 | // ---------------------------------------------------------------------------------------------------------------------------------
2 | // Copyright 2000, Paul Nettle. All rights reserved.
3 | //
4 | // You are free to use this source code in any commercial or non-commercial product.
5 | //
6 | // nommgr.h - Memory manager & tracking software
7 | //
8 | // The most recent version of this software can be found at: ftp://ftp.GraphicsPapers.com/pub/ProgrammingTools/MemoryManagers/
9 | //
10 | // [NOTE: Best when viewed with 8-character tabs]
11 | // ---------------------------------------------------------------------------------------------------------------------------------
12 |
13 | #ifdef malloc
14 | #undef malloc
15 | #endif
16 |
17 | #ifdef calloc
18 | #undef calloc
19 | #endif
20 |
21 | #ifdef realloc
22 | #undef realloc
23 | #endif
24 |
25 | #ifdef free
26 | #undef free
27 | #endif
28 |
29 | //#ifdef memalign
30 | //#undef memalign
31 | //#endif
32 |
33 |
34 | // ---------------------------------------------------------------------------------------------------------------------------------
35 | // nommgr.h - End of file
36 | // ---------------------------------------------------------------------------------------------------------------------------------
37 |
--------------------------------------------------------------------------------
/movie/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(MOVIE_SRCS
2 | nge_movie.c
3 | )
4 |
5 | add_addon_srcs(movie
6 | HAS_SUBDIR_IN_INCLUDE
7 | SRCS ${MOVIE_SRCS})
8 |
--------------------------------------------------------------------------------
/movie/nge_movie.c:
--------------------------------------------------------------------------------
1 | //Modified by Kun Wang 2011-03-20 22:06
2 | #include "nge_movie.h"
3 |
4 | static int PMP_Load (const char *);
5 | static int PMP_Play (void);
6 | static int PMP_Stop (void);
7 | static int PMP_Eos (void);
8 |
9 | // Call once on startup to initialize pmp playback (loads the codecs)
10 | char* pmp_init();
11 |
12 | // play file s and decode in pixelformat 'format' (see pspmpeg.h for modes, possible are 4444,5650,5551 and 8888)
13 | // if show is set to 1 the display of the video will be handled by the output thread
14 | // else the caller has to display the video itself by querying the frames with pmp_get_frame and somehow getting them
15 | // displayed on screen
16 | char *pmp_play(char *s, int show, int format);
17 |
18 | // return pointer to current frame, also set frame format, width, height and buffer width
19 | void* pmp_get_frame(int* format, int* width, int* height, int* vbw );
20 |
21 | // Stop the playback and free all resources
22 | void pmp_stop();
23 |
24 | // Check if playback is still running
25 | int pmp_isplaying();
26 |
27 | void MoviePlayInit(movie_ops* ops)
28 | {
29 |
30 | ops->load = PMP_Load;
31 | ops->play = PMP_Play;
32 | ops->stop = PMP_Stop;
33 | ops->eos = PMP_Eos;
34 | }
35 |
36 | void MoviePlayFini(void) {} //cleanup
37 |
38 | #if defined _PSP
39 | /*
40 | #define SCE_MPEG_AVC_FORMAT_DEFAULT -1
41 | #define SCE_MPEG_AVC_FORMAT_5650 0
42 | #define SCE_MPEG_AVC_FORMAT_5551 1
43 | #define SCE_MPEG_AVC_FORMAT_4444 2
44 | #define SCE_MPEG_AVC_FORMAT_8888 3
45 | */
46 | #include "pmp.h"
47 | #include "nge_io_file.h"
48 |
49 | int flags = 1;
50 | static char filename[256];
51 |
52 | int PMP_Load (const char *name)
53 | {
54 | //check file;
55 | pmp_init();
56 | int handle = io_fopen(name,IO_RDONLY);
57 | if(handle <= 0){
58 | flags = 0;
59 | return 0;
60 | }
61 | else{
62 | io_fclose(handle);
63 | strncpy(filename,name,256);
64 | return 1;
65 | }
66 |
67 | }
68 | int PMP_Play (void)
69 | {
70 | if(flags)
71 | pmp_play(filename, 1,3);
72 | return 1;
73 | }
74 | int PMP_Stop (void)
75 | {
76 | pmp_stop();
77 | return 1;
78 | }
79 |
80 | int PMP_Eos (void)
81 | {
82 | return pmp_isplaying()==1?0:1;
83 | }
84 |
85 | #else //win32, linux, iphone
86 | #include
87 | int PMP_Load (const char *name)
88 | {
89 | return 1;
90 | }
91 | int PMP_Play (void)
92 | {
93 | printf("NOW Play The Movie X:D\n");
94 | return 1;
95 | }
96 | int PMP_Stop (void)
97 | {
98 | return 1;
99 | }
100 |
101 | int PMP_Eos (void)
102 | {
103 | return 1;
104 | }
105 | #endif
106 |
--------------------------------------------------------------------------------
/net/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(NET_SRCS
2 | event.c
3 | log.c
4 | nge_net_common.c
5 | select.c
6 | )
7 |
8 | add_definitions(-DNGE2_NET)
9 | add_addon_srcs(net
10 | INCLUDE_THIS_DIR
11 | SRCS ${NET_SRCS})
12 |
--------------------------------------------------------------------------------
/net/config.h:
--------------------------------------------------------------------------------
1 | #ifndef NGE_CONFIG_H
2 | #define NGE_CONFIG_H
3 | //add your config here
4 |
5 | #endif
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/net/event-internal.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2004 Niels Provos
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in the
12 | * documentation and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 | #ifndef _EVENT_INTERNAL_H_
28 | #define _EVENT_INTERNAL_H_
29 |
30 | #ifdef __cplusplus
31 | extern "C" {
32 | #endif
33 |
34 | struct event_base {
35 | const struct eventop *evsel;
36 | void *evbase;
37 | int event_count; /* counts number of total events */
38 | int event_count_active; /* counts number of active events */
39 |
40 | int event_gotterm; /* Set to terminate loop */
41 |
42 | /* active event management */
43 | struct event_list **activequeues;
44 | int nactivequeues;
45 |
46 | struct event_list eventqueue;
47 | struct timeval event_tv;
48 |
49 | RB_HEAD(event_tree, event) timetree;
50 | };
51 |
52 | #ifdef __cplusplus
53 | }
54 | #endif
55 |
56 | #endif /* _EVENT_INTERNAL_H_ */
57 |
--------------------------------------------------------------------------------
/net/log.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2004 Niels Provos
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in the
12 | * documentation and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 | #ifndef _LOG_H_
28 | #define _LOG_H_
29 |
30 | void event_err(int eval, const char *fmt, ...);
31 | void event_warn(const char *fmt, ...);
32 | void event_errx(int eval, const char *fmt, ...);
33 | void event_warnx(const char *fmt, ...);
34 | void event_msgx(const char *fmt, ...);
35 | void _event_debugx(const char *fmt, ...);
36 |
37 | #ifdef USE_DEBUG
38 | #define event_debug(x) _event_debugx x
39 | #else
40 | #define event_debug(x) do {;} while (0)
41 | #endif
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/net/nge_net_common.c:
--------------------------------------------------------------------------------
1 | #include "nge_net_common.h"
2 | #ifdef WIN32
3 | #include
4 | #else
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #endif
17 |
18 | int socket_create(int af,int type,int protocol)
19 | {
20 | return socket(af, type, protocol);
21 | }
22 |
23 | int socket_setopt(int fd,int level,int optname,const char* optval,int optlen)
24 | {
25 | return setsockopt(fd, level, optname,optval,optlen);
26 | }
27 |
28 | int socket_setnoblock(int fd)
29 | {
30 | #ifdef WIN32//win32
31 | unsigned long argp =1;
32 | int ret = ioctlsocket(fd,FIONBIO,&argp);
33 | if(ret == SOCKET_ERROR)
34 | {
35 | socket_close(fd);
36 | return -1;//SET_SOCK_OPT_FAIL
37 | }
38 | #else //unix
39 | int flags;
40 | flags = fcntl(fd, F_GETFL);
41 | if (flags < 0)
42 | return flags;
43 | flags |= O_NONBLOCK;
44 | if (fcntl(fd, F_SETFL, flags) < 0){
45 | socket_close(fd);
46 | return -1;
47 | }
48 | #endif
49 | return 1;
50 | }
51 |
52 | int socket_recv(int fd,const char *buf,int len)
53 | {
54 | int rlen = 0;
55 | #ifdef WIN32
56 | rlen = recv(fd,(char *)buf,len,0);
57 | #else
58 | rlen = read(fd, buf, len);
59 | #endif
60 | return rlen;
61 | }
62 |
63 | int socket_send(int fd,const char *buf,int len)
64 | {
65 | int wlen;
66 | #ifdef WIN32
67 | wlen = send(fd,(const char *)buf,len,0);
68 | #else
69 | wlen = write(fd, buf, len);
70 | #endif
71 | return wlen;
72 | }
73 |
74 | int socket_close(int fd)
75 | {
76 | #ifdef WIN32
77 | return closesocket(fd);
78 | #else
79 | return close(fd);
80 | #endif
81 | }
82 |
--------------------------------------------------------------------------------
/net/nge_net_common.h:
--------------------------------------------------------------------------------
1 | #ifndef NGE_NET_COMMON_H_
2 | #define NGE_NET_COMMON_H_
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | /**
9 | * 创建一个socket
10 | *@param int af,地址簇指定,通常填写AF_INET
11 | *@param int type,socket类型,可填写SOCK_STREAM(TCP)和SOCK_DGRAM(UDP)
12 | *@param int protocol,协议簇,通常填0
13 | *@return int,socket句柄,用此句柄做后续操作,<=0代表出错
14 | */
15 | int socket_create(int af,int type,int protocol);
16 | /**
17 | * 设置socket选项,通常是不需要设置选项的
18 | *@param int fd,socket handle,填入由socket_create()创建的handle
19 | *@param int level,选项定义的层次:目前仅支持SOL_SOCKET和IPPROTO_TCP层次.
20 | *@param int optname,需设置的选项,较常用的是SO_REUSEADDR
21 | *@param const char* optval,指向存放选项值的缓冲区
22 | *@param int optval,缓冲区的长度
23 | *@return int,返回值小于等于0出错
24 | */
25 | int socket_setopt(int fd,int level,int optname,const char* optval,int optlen);
26 | /**
27 | * 设置网络为非阻塞模式
28 | *@param int fd,socket handle,填入由socket_create()创建的handle
29 | *@return int, 返回值小于等于0出错
30 | */
31 | int socket_setnoblock(int fd);
32 | /**
33 | *@param int fd,socket handle,填入由socket_create()创建的handle
34 | *@param const char* buf,接收buf缓存
35 | *@param int len,buf的长度
36 | *@return int, 返回实际接收的长度,<=0为出错,对TCP来说(等于0为Client正常断开链接,小于0为发生其他错误)
37 | */
38 | int socket_recv(int fd,const char *buf,int len);
39 | /**
40 | *@param int fd,socket handle,填入由socket_create()创建的handle
41 | *@param const char* buf,发送buf缓存
42 | *@param int len,buf的长度
43 | *@return int, 返回实际发送的长度,<=0为出错,在设置noblock后直接返回否则为阻塞发送
44 | */
45 | int socket_send(int fd,const char *buf,int len);
46 | /**
47 | * 关闭一个socket
48 | *@param int fd,socket handle,填入由socket_create()创建的handle
49 | *@return int,返回值大于0成功
50 | */
51 | int socket_close(int fd);
52 |
53 | #ifdef __cplusplus
54 | }
55 | #endif
56 |
57 | #endif
58 |
--------------------------------------------------------------------------------
/samples/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include(RmDupLibs)
2 | function(add_nge_executable nm)
3 | set(_ARGS)
4 | set(_LIBS)
5 | set(_LIBS_PRE)
6 | set(_IS_LIB)
7 | set(_IS_LIB_PRE)
8 |
9 | foreach(arg ${ARGN})
10 | if(${arg} STREQUAL "LIBRARIES")
11 | set(_IS_LIB 1)
12 | set(_IS_LIB_PRE)
13 | elseif(${arg} STREQUAL "LIBRARIES_PRE")
14 | set(_IS_LIB)
15 | set(_IS_LIB_PRE 1)
16 | else()
17 | if(_IS_LIB)
18 | list(APPEND _LIBS ${arg})
19 | elseif(_IS_LIB_PRE)
20 | list(APPEND _LIBS_PRE ${arg})
21 | else()
22 | list(APPEND _ARGS ${arg})
23 | endif()
24 | endif()
25 | endforeach()
26 |
27 | if(ANDROID)
28 | add_library(${nm} SHARED ${NGE_ANDROID_JNI_FILE} ${_ARGS})
29 | set(_LIBS ${_LIBS_PRE} nge2 ${_LIBS} ${NGE2_LIBS})
30 | else()
31 | add_executable(${nm} WIN32 ${_ARGS})
32 | set(_LIBS ${_LIBS_PRE} nge2_main nge2 ${_LIBS} ${NGE2_LIBS})
33 | endif()
34 |
35 | rm_dup_lib(_LIBS)
36 | target_link_libraries(${nm} ${_LIBS})
37 | if(PSP)
38 | pack_psp_eboot(${nm})
39 | elseif(ANDROID)
40 | if(${NGE2_BUILD_TYPE} STREQUAL Debug)
41 | set(LIB_OUTPUT_NAME lib${nm}${CMAKE_DEBUG_POSTFIX})
42 | elseif(${NGE2_BUILD_TYPE} STREQUAL RelWithDebInfo)
43 | set(LIB_OUTPUT_NAME lib${nm}${CMAKE_RELWITHDEBINFO_POSTFIX})
44 | elseif(${NGE2_BUILD_TYPE} STREQUAL MinSizeRel)
45 | set(LIB_OUTPUT_NAME lib${nm}${CMAKE_MINSIZEREL_POSTFIX})
46 | else()
47 | set(LIB_OUTPUT_NAME lib${nm}${CMAKE_RELEASE_POSTFIX})
48 | endif()
49 |
50 | # execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory
51 | # "${CMAKE_SOURCE_DIR}/Android/assets"
52 | # "${nm}/assets"
53 | # WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
54 |
55 | set(app_name "${nm}")
56 | set(project_name "${nm}")
57 | set(package_name "org.libnge.nge2.${nm}")
58 |
59 | execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory
60 | "${CMAKE_SOURCE_DIR}/Android/res"
61 | "${nm}/res"
62 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
63 | configure_file("${CMAKE_SOURCE_DIR}/Android/strings.xml.in"
64 | "${nm}/res/values/strings.xml" @ONLY)
65 |
66 | configure_file("${CMAKE_SOURCE_DIR}/Android/default.properties"
67 | "${nm}/default.properties" COPYONLY)
68 | configure_file("${CMAKE_SOURCE_DIR}/Android/AndroidManifest.xml.in"
69 | "${nm}/AndroidManifest.xml" @ONLY)
70 | configure_file("${CMAKE_SOURCE_DIR}/Android/project_create.sh.in"
71 | "${nm}/project_create.sh" @ONLY)
72 |
73 | copy_coolaudio_android_files(${nm} ${CMAKE_CURRENT_BINARY_DIR}/${nm})
74 | copy_nge_android_java_files(${nm} ${CMAKE_CURRENT_BINARY_DIR}/${nm})
75 |
76 | add_custom_command(
77 | TARGET ${nm}
78 | POST_BUILD
79 | COMMAND "${CMAKE_COMMAND}" -E copy
80 | "${LIBRARY_OUTPUT_PATH}/${LIB_OUTPUT_NAME}.so"
81 | "${CMAKE_CURRENT_BINARY_DIR}/${nm}/libs/${ARMEABI_NDK_NAME}/libnge2app-jni.so"
82 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${nm}"
83 | )
84 | endif()
85 | endfunction()
86 |
87 | function(add_resource all_res dir)
88 | set(res)
89 | foreach(arg ${ARGN})
90 | list(APPEND res ${dir}/${arg})
91 | endforeach()
92 | list(APPEND ${all_res} ${res})
93 | set(${all_res} ${${all_res}} PARENT_SCOPE)
94 | endfunction()
95 |
96 | include(CopyFile)
97 | function(copy_res_files target)
98 | set(files)
99 |
100 | if(ANDROID)
101 | set(prefix Resources/)
102 | else()
103 | set(prefix "")
104 | endif()
105 |
106 | foreach(arg ${ARGN})
107 | add_copy_file(files ../res/${arg} ${prefix}${arg})
108 | endforeach()
109 | # message("files : ${files}")
110 | add_custom_target(${target}_res DEPENDS ${files})
111 | add_dependencies(${target} ${target}_res)
112 | endfunction()
113 |
114 | # demo6 is gif demo
115 | foreach(i 10 11 12 13 14 15 16 17)
116 | add_subdirectory(demo${i})
117 | endforeach()
118 |
--------------------------------------------------------------------------------
/samples/demo10/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | string(REGEX MATCH "demo(.+)" D_NAME ${CMAKE_CURRENT_SOURCE_DIR})
2 | aux_source_directory(. ${D_NAME}_SRCS)
3 | add_nge_executable(${D_NAME} ${${D_NAME}_SRCS})
4 |
5 | add_resource(${D_NAME}_all_res images
6 | demo0.jpg
7 | nge2logo.png)
8 |
9 | copy_res_files(${D_NAME} ${${D_NAME}_all_res})
10 |
--------------------------------------------------------------------------------
/samples/demo10/test.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/samples/demo10/test.cpp
--------------------------------------------------------------------------------
/samples/demo11/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | string(REGEX MATCH "demo(.+)" D_NAME ${CMAKE_CURRENT_SOURCE_DIR})
2 | aux_source_directory(. ${D_NAME}_SRCS)
3 | add_nge_executable(${D_NAME} ${${D_NAME}_SRCS})
4 |
5 | add_resource(${D_NAME}_all_res images
6 | demo1_bg.jpg
7 | demo1_box.jpg
8 | demo1_icon0.bmp
9 | demo1_icon1.png)
10 |
11 | add_resource(${D_NAME}_all_res movies
12 | OP.mp4)
13 |
14 | add_resource(${D_NAME}_all_res fonts
15 | GBK14
16 | ASC14
17 | simfang.ttf)
18 |
19 | copy_res_files(${D_NAME} ${${D_NAME}_all_res})
20 |
--------------------------------------------------------------------------------
/samples/demo11/test.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/samples/demo11/test.cpp
--------------------------------------------------------------------------------
/samples/demo12/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | string(REGEX MATCH "demo(.+)" D_NAME ${CMAKE_CURRENT_SOURCE_DIR})
2 | aux_source_directory(. ${D_NAME}_SRCS)
3 | add_nge_executable(${D_NAME} ${${D_NAME}_SRCS})
4 |
5 | add_resource(${D_NAME}_all_res images
6 | demo4_bg.png
7 | demo4_man.png)
8 |
9 | copy_res_files(${D_NAME} ${${D_NAME}_all_res})
10 |
--------------------------------------------------------------------------------
/samples/demo12/cAnimation.h:
--------------------------------------------------------------------------------
1 | #ifndef CANIMATION_H_
2 | #define CANIMATION_H_
3 | #include "libnge2.h"
4 | extern int game_quit;
5 |
6 | enum{
7 | ANI_RIGHT = 0,
8 | ANI_LEFT ,
9 | ANI_UP,
10 | ANI_DOWN
11 | };
12 |
13 | typedef struct {
14 | float x;
15 | float y;
16 | float w;
17 | float h;
18 | }rect;
19 |
20 | class CAnimation
21 | {
22 | public:
23 |
24 | CAnimation(const char* filename);
25 | ~CAnimation();
26 | //Moves the stick figure
27 | void Update();
28 | void Input();
29 | //Shows the stick figure
30 | void Show();
31 | static float velocity_x;
32 | static float velocity_y;
33 | protected:
34 | void set_clip();
35 | void InputInit();
36 | static void btn_down(int keycode);
37 | static void btn_up(int keycode);
38 | private:
39 |
40 | //Its current frame
41 | int frame;
42 |
43 | float offset_x;
44 | float offset_y;
45 | //Its animation status
46 | int status;
47 | //The areas of the sprite sheet
48 | rect clipsRight[ 4 ];
49 | rect clipsLeft[ 4 ];
50 | rect clipsUp[ 4 ];
51 | rect clipsDown[ 4 ];
52 | image_p resouce;
53 | //Its rate of movement
54 |
55 | };
56 |
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/samples/demo12/test.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/samples/demo12/test.cpp
--------------------------------------------------------------------------------
/samples/demo13/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | string(REGEX MATCH "demo(.+)" D_NAME ${CMAKE_CURRENT_SOURCE_DIR})
2 | aux_source_directory(. ${D_NAME}_SRCS)
3 | add_nge_executable(${D_NAME} ${${D_NAME}_SRCS})
4 |
5 | add_resource(${D_NAME}_all_res music
6 | simple1.mp3
7 | simple3.wav
8 | test.ogg)
9 |
10 | copy_res_files(${D_NAME} ${${D_NAME}_all_res})
11 |
--------------------------------------------------------------------------------
/samples/demo13/test.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/samples/demo13/test.cpp
--------------------------------------------------------------------------------
/samples/demo14/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | string(REGEX MATCH "demo(.+)" D_NAME ${CMAKE_CURRENT_SOURCE_DIR})
2 | aux_source_directory(. ${D_NAME}_SRCS)
3 | add_nge_executable(${D_NAME} ${${D_NAME}_SRCS})
4 |
5 | add_resource(${D_NAME}_all_res images
6 | demo2_bg.jpg)
7 | add_resource(${D_NAME}_all_res database
8 | data.zip)
9 |
10 | copy_res_files(${D_NAME} ${${D_NAME}_all_res})
11 |
--------------------------------------------------------------------------------
/samples/demo14/test.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/samples/demo14/test.cpp
--------------------------------------------------------------------------------
/samples/demo15/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | string(REGEX MATCH "demo(.+)" D_NAME ${CMAKE_CURRENT_SOURCE_DIR})
2 | aux_source_directory(. ${D_NAME}_SRCS)
3 | add_nge_executable(${D_NAME} ${${D_NAME}_SRCS})
4 |
5 | add_resource(${D_NAME}_all_res par
6 | particles.png
7 | particle1.psi)
8 |
9 | copy_res_files(${D_NAME} ${${D_NAME}_all_res})
10 |
--------------------------------------------------------------------------------
/samples/demo15/test.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/samples/demo15/test.cpp
--------------------------------------------------------------------------------
/samples/demo16/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | string(REGEX MATCH "demo(.+)" D_NAME ${CMAKE_CURRENT_SOURCE_DIR})
2 | aux_source_directory(. ${D_NAME}_SRCS)
3 | add_nge_executable(${D_NAME} ${${D_NAME}_SRCS})
4 |
--------------------------------------------------------------------------------
/samples/demo16/test.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/samples/demo16/test.cpp
--------------------------------------------------------------------------------
/samples/demo17/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | string(REGEX MATCH "demo(.+)" D_NAME ${CMAKE_CURRENT_SOURCE_DIR})
2 | aux_source_directory(. ${D_NAME}_SRCS)
3 | add_nge_executable(${D_NAME} ${${D_NAME}_SRCS})
4 |
5 | add_resource(${D_NAME}_all_res images
6 | nge2logo.png
7 | demo0.jpg)
8 |
9 | copy_res_files(${D_NAME} ${${D_NAME}_all_res})
10 |
--------------------------------------------------------------------------------
/samples/demo17/test.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/samples/demo17/test.cpp
--------------------------------------------------------------------------------
/samples/demo6/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | string(REGEX MATCH "demo(.+)" D_NAME ${CMAKE_CURRENT_SOURCE_DIR})
2 | aux_source_directory(. ${D_NAME}_SRCS)
3 | add_nge_executable(${D_NAME} ${${D_NAME}_SRCS})
4 |
5 | add_resource(${D_NAME}_all_res images
6 | demo0.jpg
7 | simple.gif)
8 |
9 | copy_res_files(${D_NAME} ${${D_NAME}_all_res})
10 |
--------------------------------------------------------------------------------
/samples/demo6/test.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/samples/demo6/test.cpp
--------------------------------------------------------------------------------
/script/down-androiddepends.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ $1 = "clean" ]; then
4 | CLEAN=1
5 | fi
6 |
7 | test_cmd() {
8 | for cmd in $@; do
9 | which $cmd 1>/dev/null 2>&1
10 | if [ $? = 0 ]; then
11 | echo $cmd
12 | break
13 | fi
14 | done
15 | }
16 |
17 | _7z_cmd="`test_cmd 7z 7zr 7za`"
18 |
19 | (( CLEAN )) && rm -f AndroidDepends.7z
20 | (( CLEAN )) && rm -rf AndroidDepends
21 |
22 | wget https://github.com/downloads/ifreedom/libnge2/AndroidDepends.7z --no-check-certificate
23 | $_7z_cmd x -y AndroidDepends.7z
24 |
--------------------------------------------------------------------------------
/script/down-resources.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ### down-resources.sh --- download res.zip and extract it to samples dir.
3 |
4 | if [ $1 = "clean" ]; then
5 | CLEAN=1
6 | fi
7 |
8 | test_cmd() {
9 | for cmd in $@; do
10 | which $cmd 1>/dev/null 2>&1
11 | if [ $? = 0 ]; then
12 | echo $cmd
13 | break
14 | fi
15 | done
16 | }
17 | _7z_cmd="`test_cmd 7z 7zr 7za`"
18 |
19 | cd samples
20 |
21 | (( CLEAN )) && rm -f res.7z
22 | (( CLEAN )) && rm -rf res
23 |
24 | wget https://github.com/downloads/ifreedom/libnge2/res.7z --no-check-certificate
25 | $_7z_cmd x -y res.7z
26 |
--------------------------------------------------------------------------------
/script/down-win32depends.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ $1 = "clean" ]; then
4 | CLEAN=1
5 | fi
6 |
7 | test_cmd() {
8 | for cmd in $@; do
9 | which $cmd 1>/dev/null 2>&1
10 | if [ $? = 0 ]; then
11 | echo $cmd
12 | break
13 | fi
14 | done
15 | }
16 |
17 | _7z_cmd="`test_cmd 7z 7zr 7za`"
18 |
19 | (( CLEAN )) && rm -f Win32Depends.7z
20 | (( CLEAN )) && rm -rf Win32Depends
21 |
22 | wget -O Win32Depends2.7z https://open.ge.tt/1/files/7Th6r3E/0/blob --no-check-certificate
23 | $_7z_cmd x -y Win32Depends.7z
24 |
--------------------------------------------------------------------------------
/script/make-android.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | if [ "x$1" = "x--help" ]; then
4 | cat </dev/null 2>&1
6 | if [ $? = 0 ]; then
7 | echo $cmd
8 | break
9 | fi
10 | done
11 | }
12 |
13 | _7z_cmd="`test_cmd 7z 7zr 7za`"
14 |
15 | cd samples
16 |
17 | rm -f res.7z
18 |
19 | $_7z_cmd a res.7z res
20 |
--------------------------------------------------------------------------------
/script/replace.sh:
--------------------------------------------------------------------------------
1 | #! /bin/bash
2 |
3 | temp=temp.tmp
4 |
5 | do_sed () {
6 | sed $1 $2 >$temp
7 | mv -f $temp $2
8 | }
9 |
10 | do_change() {
11 | do_sed 's/uint8_t/t____001_____t/g' $1
12 | do_sed 's/uint16_t/t____002_____t/g' $1
13 | do_sed 's/uint32_t/t____003_____t/g' $1
14 |
15 | do_sed 's/int8_t/t____004_____t/g' $1
16 | do_sed 's/int16_t/t____005_____t/g' $1
17 | do_sed 's/int32_t/t____006_____t/g' $1
18 |
19 | do_sed 's/uint8/t____001_____t/g' $1
20 | do_sed 's/uint16/t____002_____t/g' $1
21 | do_sed 's/uint32/t____003_____t/g' $1
22 |
23 | do_sed 's/sint8/t____004_____t/g' $1
24 | do_sed 's/sint16/t____005_____t/g' $1
25 | do_sed 's/sint32/t____006_____t/g' $1
26 |
27 | do_sed 's/int8/t____004_____t/g' $1
28 | do_sed 's/int16/t____005_____t/g' $1
29 | do_sed 's/int32/t____006_____t/g' $1
30 |
31 | do_sed 's/t____001_____t/uint8_t/g' $1
32 | do_sed 's/t____002_____t/uint16_t/g' $1
33 | do_sed 's/t____003_____t/uint32_t/g' $1
34 |
35 | do_sed 's/t____004_____t/int8_t/g' $1
36 | do_sed 's/t____005_____t/int16_t/g' $1
37 | do_sed 's/t____006_____t/int32_t/g' $1
38 | }
39 |
40 | get_ext() {
41 | local filename extension
42 | filename=`basename "$1"`
43 | extension="${filename##*.}"
44 | echo $extension
45 | }
46 |
47 | do_dir() {
48 | local ext
49 | ls $1| while read f; do
50 | if [ -f $1/$f ]; then
51 | ext="`get_ext $f`"
52 |
53 | if [[ "$ext" == "c" || "$ext" == "cpp" || "$ext" == "h" || "$ext" == "hpp" ]]; then
54 | do_change $1/$f
55 | fi
56 | fi
57 | if [ -d $1/$f ]; then
58 | do_dir $1/$f
59 | fi
60 | done
61 | }
62 |
63 | do_dir include
64 | do_dir src
65 | do_dir dirent
66 | do_dir hge
67 | do_dir movie
68 | do_dir net
69 |
--------------------------------------------------------------------------------
/src/android/UnZipFile.java.in:
--------------------------------------------------------------------------------
1 | package org.libnge.nge2;
2 |
3 | import java.io.BufferedInputStream;
4 | import java.io.BufferedOutputStream;
5 | import java.io.File;
6 | import java.io.FileOutputStream;
7 | import java.io.InputStream;
8 | import java.text.MessageFormat;
9 | import java.util.zip.ZipEntry;
10 | import java.util.zip.ZipInputStream;
11 | import android.util.Log;
12 |
13 | import org.libnge.nge2.@nge_app_name@.R;
14 |
15 | import android.app.Dialog;
16 | import android.content.Context;
17 | import android.os.AsyncTask;
18 | import android.widget.ProgressBar;
19 | import android.widget.TextView;
20 |
21 | /**
22 | * 解压数据库文件操作类
23 | */
24 | public class UnZipFile extends AsyncTask {
25 | private String TAG = "nge2";
26 |
27 | private Context mContext = null;
28 | private ProgressBar progress = null;
29 | private TextView progress_label = null;
30 | private Dialog customDialog;
31 | private int streamLength = 0;
32 | private CallBack mCallBack;
33 |
34 | /**
35 | * 解压zip数据库文件
36 | * @param context activity
37 | * @param SavePath 保存路径
38 | * @param ResourcesIndex 资源文件索引
39 | */
40 | public UnZipFile(Context pContext,CallBack pCallBack) {
41 | mContext = pContext;
42 | mCallBack = pCallBack;
43 | }
44 |
45 | @Override
46 | protected Integer doInBackground(String... params) {
47 | int byteLength = 4096*1000;
48 | byte data[] = new byte[byteLength];
49 | BufferedOutputStream bufferStream = null; // 缓冲输出流
50 |
51 | int progress = 0;
52 |
53 | try {
54 | InputStream ZipIs = mContext.getAssets().open(params[0]);// 获取文件流
55 | ZipInputStream zis = new ZipInputStream(new BufferedInputStream(ZipIs));
56 |
57 | streamLength = (int)(ZipIs.available()*2);// 获取文件大小
58 |
59 | ZipEntry entry; // 每个zip条目的实例
60 | while ((entry = zis.getNextEntry()) != null) {
61 | try {
62 | String entryFileName = entry.getName();
63 | if(entry.isDirectory()){
64 | continue;
65 | }
66 | else {
67 | int count;
68 | File file = new File(params[1] + "/" + entryFileName);
69 |
70 | File parent = file.getParentFile();
71 | if(parent!=null && !parent.exists()) {
72 | parent.mkdirs();
73 | }
74 |
75 | FileOutputStream fos = new FileOutputStream(file);
76 | bufferStream = new BufferedOutputStream(fos, byteLength);
77 | while ((count = zis.read(data, 0, byteLength)) != -1) {
78 | bufferStream.write(data, 0, count);
79 | progress += count;
80 | publishProgress(progress); // 更新进度条
81 | }
82 | bufferStream.flush();
83 | bufferStream.close();
84 | }
85 | } catch (Exception ex) {
86 | ex.printStackTrace();
87 | }
88 | }
89 | zis.close();
90 | } catch (Exception ex) {
91 | ex.printStackTrace();
92 | }
93 | return (int)streamLength;
94 | }
95 |
96 | @Override
97 | protected void onPostExecute(Integer result) {
98 | super.onPostExecute(result);
99 | progress.setProgress(result);
100 | if (customDialog != null)
101 | customDialog.dismiss();
102 | if(mCallBack != null){
103 | mCallBack.onCallBack();
104 | }
105 | }
106 |
107 | @Override
108 | protected void onPreExecute() {
109 | super.onPreExecute();
110 | customDialog = new Dialog(mContext);
111 | customDialog.setTitle("文件解压");
112 | customDialog.setContentView(R.layout.progress_dialog);
113 | progress = (ProgressBar)customDialog.findViewById(R.id.progressBar);
114 | progress_label = (TextView)customDialog.findViewById(R.id.progress_label);
115 | customDialog.show();
116 | }
117 |
118 | private MessageFormat mf = new MessageFormat("第一次启动解压资源文件,请稍后({0}%)...");
119 | @Override
120 | protected void onProgressUpdate(Integer... values) {
121 | super.onProgressUpdate(values);
122 | /**
123 | * 更改进度条状态
124 | */
125 | if (streamLength != progress.getMax()){
126 | progress.setMax((int)streamLength);
127 | }
128 | progress.setProgress(values[0]);
129 | if(values[0]>streamLength){
130 | values[0] = streamLength;
131 | }
132 | int value = values[0]*100/streamLength;
133 | if(value<0)value = 0;
134 | if(value>100)value = 100;
135 | progress_label.setText(mf.format(new String[]{String.valueOf(value)}));
136 | }
137 | public interface CallBack{
138 | public void onCallBack();
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/src/android/UtilsKit.java:
--------------------------------------------------------------------------------
1 | package org.libnge.nge2;
2 |
3 | import android.content.Context;
4 | import android.net.wifi.WifiInfo;
5 | import android.net.wifi.WifiManager;
6 | import android.telephony.TelephonyManager;
7 | import android.util.Log;
8 |
9 | public class UtilsKit extends Object{
10 | private static final String TAG = "LibUtilsKit";
11 |
12 | public int init() {
13 | return 0;
14 | }
15 | public static NGE2 app;
16 | /**
17 | * @param adKey adkey
18 | * @param adType 目前仅支持admob
19 | * @return 广告袋标识符
20 | */
21 | public int CreateAdHandle(final String adKey,String adType){
22 |
23 | return 1;
24 | }
25 | public void SetAdPos(int adHandle,int x,int y){
26 | //View adView = app.getAdView();
27 | //adView.setPadding(x, y, adView.getRight(), adView.getBottom());
28 | String msg = String.format("adHandle = %d ,x = %d,y = %d", adHandle , x, y);
29 | Log.d(TAG,msg);
30 | }
31 | public void ShowAd(int adHandle,int bShow){
32 |
33 | }
34 | public void DestroyAdHandle(int adHandle){
35 | //app.DestroyAdHandle(adHandle);
36 | String msg = String.format("adHandle = %d", adHandle);
37 | Log.d(TAG,msg);
38 | }
39 |
40 |
41 | /**
42 | * 支付接口定义
43 | * @param title 交易物品名称
44 | * @param body 交易明细
45 | * @param total 交易总价格
46 | * @return 返回成功与否,目前0失败 1成功
47 | */
48 | private int result = 0;
49 | private native void nativePayFeedBack(int error,String errStr);
50 | public int Pay(final int payHandle,final String title,final String body,final String total){
51 | result = 0;
52 | return result;
53 | }
54 | /**
55 | * @param payType 目前只支持 alipay
56 | * @param partner 账户ID。用签约支付宝账号登录ms.alipay.com后,在账户信息页面获取。
57 | * @param seller 账户ID。用签约支付宝账号登录ms.alipay.com后,在账户信息页面获取。
58 | * @param privateRSA 商户(RSA)私钥
59 | * @param publicRSA 支付宝(RSA)公钥 用签约支付宝账号登录ms.alipay.com后,在密钥管理页面获取。
60 | * @return
61 | */
62 | public int CreatePayHandle(String payType,String partner,String seller,String privateRSA,String publicRSA){
63 | return 0;
64 | }
65 |
66 |
67 | public int Share(int type,final String str,final String imgName){
68 | return 0;
69 | }
70 |
71 | public void MoreGame(int type){
72 | }
73 |
74 | /**
75 | * 获取机器的mac地址
76 | * 需要添加权限
77 | *
78 | * @return
79 | */
80 | public static String getMacAddress() {
81 | WifiManager wifi = (WifiManager) app.getSystemService(Context.WIFI_SERVICE);
82 | WifiInfo info = wifi.getConnectionInfo();
83 | return info.getMacAddress();
84 | }
85 |
86 | public static String getCustomIMSI(){
87 | TelephonyManager telephonyManager=(TelephonyManager) app.getSystemService(Context.TELEPHONY_SERVICE);
88 | return telephonyManager.getSubscriberId();
89 | }
90 |
91 | /**
92 | * 返回当前程序版本名
93 | */
94 | public static String getAppVersionName() {
95 | return "";
96 | }
97 |
98 | public static void registeredDevices(){
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/src/charsets/ascii.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 1999-2001 Free Software Foundation, Inc.
3 | * Copyright 2012 Kun Wang
4 | *
5 | * This file is under GPL or LGPL License.
6 | */
7 |
8 | /*
9 | * ASCII
10 | */
11 |
12 | inline static int
13 | ascii_mbtowc (ucs4_t *pwc, const unsigned char *s, int n)
14 | {
15 | unsigned char c = *s;
16 | if (c < 0x80) {
17 | *pwc = (ucs4_t) c;
18 | return 1;
19 | }
20 | return RET_ILSEQ;
21 | }
22 |
23 | inline static int
24 | ascii_wctomb (unsigned char *r, ucs4_t wc, int n)
25 | {
26 | if (wc < 0x0080) {
27 | *r = wc;
28 | return 1;
29 | }
30 | return RET_ILUNI;
31 | }
32 |
--------------------------------------------------------------------------------
/src/charsets/ces_gbk.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 1999-2001, 2005 Free Software Foundation, Inc.
3 | * Copyright 2012 Kun Wang
4 | *
5 | * This file is under GPL or LGPL License.
6 | */
7 |
8 | /*
9 | * GBK
10 | */
11 |
12 | inline static int
13 | ces_gbk_mbtowc (ucs4_t *pwc, const unsigned char *s, int n)
14 | {
15 | unsigned char c = *s;
16 |
17 | /* Code set 0 (ASCII or GB 1988-89) */
18 | if (c < 0x80)
19 | return ascii_mbtowc(pwc,s,n);
20 | /* Code set 1 (GBK) */
21 | if (c >= 0x81 && c < 0xff) {
22 | if (n < 2)
23 | return RET_TOOFEW(0);
24 | return gbk_mbtowc(pwc,s,2);
25 | }
26 | return RET_ILSEQ;
27 | }
28 |
29 | inline static int
30 | ces_gbk_wctomb (unsigned char *r, ucs4_t wc, int n)
31 | {
32 | unsigned char buf[2];
33 | int ret;
34 |
35 | /* Code set 0 (ASCII or GB 1988-89) */
36 | ret = ascii_wctomb(r,wc,n);
37 | if (ret != RET_ILUNI)
38 | return ret;
39 |
40 | /* Code set 1 (GBK) */
41 | ret = gbk_wctomb(buf,wc,2);
42 | if (ret != RET_ILUNI) {
43 | if (ret != 2) abort();
44 | if (n < 2)
45 | return RET_TOOSMALL;
46 | r[0] = buf[0];
47 | r[1] = buf[1];
48 | return 2;
49 | }
50 |
51 | return RET_ILUNI;
52 | }
53 |
--------------------------------------------------------------------------------
/src/charsets/cp936ext.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 1999-2001 Free Software Foundation, Inc.
3 | * Copyright 2012 Kun Wang
4 | *
5 | * This file is under GPL or LGPL License.
6 | */
7 |
8 | /*
9 | * CP936 extensions
10 | */
11 |
12 | static const unsigned short cp936ext_2uni_pagea6[181-159] = {
13 | /* 0xa6 */
14 | 0xfe35,
15 | 0xfe36, 0xfe39, 0xfe3a, 0xfe3f, 0xfe40, 0xfe3d, 0xfe3e, 0xfe41,
16 | 0xfe42, 0xfe43, 0xfe44, 0xfffd, 0xfffd, 0xfe3b, 0xfe3c, 0xfe37,
17 | 0xfe38, 0xfe31, 0xfffd, 0xfe33, 0xfe34,
18 | };
19 | static const unsigned short cp936ext_2uni_pagea8[128-122] = {
20 | /* 0xa8 */
21 | 0x0251, 0xfffd, 0x0144, 0x0148, 0xfffd, 0x0261,
22 | };
23 |
24 | static int
25 | cp936ext_mbtowc (ucs4_t *pwc, const unsigned char *s, int n)
26 | {
27 | unsigned char c1 = s[0];
28 | if ((c1 == 0xa6) || (c1 == 0xa8)) {
29 | if (n >= 2) {
30 | unsigned char c2 = s[1];
31 | if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0x80 && c2 < 0xff)) {
32 | unsigned int i = 190 * (c1 - 0x81) + (c2 - (c2 >= 0x80 ? 0x41 : 0x40));
33 | unsigned short wc = 0xfffd;
34 | if (i < 7410) {
35 | if (i >= 7189 && i < 7211)
36 | wc = cp936ext_2uni_pagea6[i-7189];
37 | } else {
38 | if (i >= 7532 && i < 7538)
39 | wc = cp936ext_2uni_pagea8[i-7532];
40 | }
41 | if (wc != 0xfffd) {
42 | *pwc = (ucs4_t) wc;
43 | return 2;
44 | }
45 | }
46 | return RET_ILSEQ;
47 | }
48 | return RET_TOOFEW(0);
49 | }
50 | return RET_ILSEQ;
51 | }
52 |
53 | static const unsigned short cp936ext_page01[16] = {
54 | 0x0000, 0x0000, 0x0000, 0x0000, 0xa8bd, 0x0000, 0x0000, 0x0000, /*0x40-0x47*/
55 | 0xa8be, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x48-0x4f*/
56 | };
57 | static const unsigned short cp936ext_page02[24] = {
58 | 0x0000, 0xa8bb, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x50-0x57*/
59 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x58-0x5f*/
60 | 0x0000, 0xa8c0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x60-0x67*/
61 | };
62 | static const unsigned short cp936ext_pagefe[24] = {
63 | 0x0000, 0xa6f2, 0x0000, 0xa6f4, 0xa6f5, 0xa6e0, 0xa6e1, 0xa6f0, /*0x30-0x37*/
64 | 0xa6f1, 0xa6e2, 0xa6e3, 0xa6ee, 0xa6ef, 0xa6e6, 0xa6e7, 0xa6e4, /*0x38-0x3f*/
65 | 0xa6e5, 0xa6e8, 0xa6e9, 0xa6ea, 0xa6eb, 0x0000, 0x0000, 0x0000, /*0x40-0x47*/
66 | };
67 |
68 | static int
69 | cp936ext_wctomb (unsigned char *r, ucs4_t wc, int n)
70 | {
71 | if (n >= 2) {
72 | unsigned short c = 0;
73 | if (wc >= 0x0140 && wc < 0x0150)
74 | c = cp936ext_page01[wc-0x0140];
75 | else if (wc >= 0x0250 && wc < 0x0268)
76 | c = cp936ext_page02[wc-0x0250];
77 | else if (wc >= 0xfe30 && wc < 0xfe48)
78 | c = cp936ext_pagefe[wc-0xfe30];
79 | if (c != 0) {
80 | r[0] = (c >> 8); r[1] = (c & 0xff);
81 | return 2;
82 | }
83 | return RET_ILUNI;
84 | }
85 | return RET_TOOSMALL;
86 | }
87 |
--------------------------------------------------------------------------------
/src/charsets/utf8.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 1999-2001, 2004 Free Software Foundation, Inc.
3 | * Copyright 2012 Kun Wang
4 | *
5 | * This file is under GPL or LGPL License.
6 | */
7 |
8 | /*
9 | * UTF-8
10 | */
11 |
12 | /* Specification: RFC 3629 */
13 |
14 | inline static int
15 | utf8_mbtowc (ucs4_t *pwc, const unsigned char *s, int n)
16 | {
17 | unsigned char c = s[0];
18 |
19 | if (c < 0x80) {
20 | *pwc = c;
21 | return 1;
22 | } else if (c < 0xc2) {
23 | return RET_ILSEQ;
24 | } else if (c < 0xe0) {
25 | if (n < 2)
26 | return RET_TOOFEW(0);
27 | if (!((s[1] ^ 0x80) < 0x40))
28 | return RET_ILSEQ;
29 | *pwc = ((ucs4_t) (c & 0x1f) << 6)
30 | | (ucs4_t) (s[1] ^ 0x80);
31 | return 2;
32 | } else if (c < 0xf0) {
33 | if (n < 3)
34 | return RET_TOOFEW(0);
35 | if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
36 | && (c >= 0xe1 || s[1] >= 0xa0)))
37 | return RET_ILSEQ;
38 | *pwc = ((ucs4_t) (c & 0x0f) << 12)
39 | | ((ucs4_t) (s[1] ^ 0x80) << 6)
40 | | (ucs4_t) (s[2] ^ 0x80);
41 | return 3;
42 | } else if (c < 0xf8 && sizeof(ucs4_t)*8 >= 32) {
43 | if (n < 4)
44 | return RET_TOOFEW(0);
45 | if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
46 | && (s[3] ^ 0x80) < 0x40
47 | && (c >= 0xf1 || s[1] >= 0x90)))
48 | return RET_ILSEQ;
49 | *pwc = ((ucs4_t) (c & 0x07) << 18)
50 | | ((ucs4_t) (s[1] ^ 0x80) << 12)
51 | | ((ucs4_t) (s[2] ^ 0x80) << 6)
52 | | (ucs4_t) (s[3] ^ 0x80);
53 | return 4;
54 | } else if (c < 0xfc && sizeof(ucs4_t)*8 >= 32) {
55 | if (n < 5)
56 | return RET_TOOFEW(0);
57 | if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
58 | && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
59 | && (c >= 0xf9 || s[1] >= 0x88)))
60 | return RET_ILSEQ;
61 | *pwc = ((ucs4_t) (c & 0x03) << 24)
62 | | ((ucs4_t) (s[1] ^ 0x80) << 18)
63 | | ((ucs4_t) (s[2] ^ 0x80) << 12)
64 | | ((ucs4_t) (s[3] ^ 0x80) << 6)
65 | | (ucs4_t) (s[4] ^ 0x80);
66 | return 5;
67 | } else if (c < 0xfe && sizeof(ucs4_t)*8 >= 32) {
68 | if (n < 6)
69 | return RET_TOOFEW(0);
70 | if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
71 | && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
72 | && (s[5] ^ 0x80) < 0x40
73 | && (c >= 0xfd || s[1] >= 0x84)))
74 | return RET_ILSEQ;
75 | *pwc = ((ucs4_t) (c & 0x01) << 30)
76 | | ((ucs4_t) (s[1] ^ 0x80) << 24)
77 | | ((ucs4_t) (s[2] ^ 0x80) << 18)
78 | | ((ucs4_t) (s[3] ^ 0x80) << 12)
79 | | ((ucs4_t) (s[4] ^ 0x80) << 6)
80 | | (ucs4_t) (s[5] ^ 0x80);
81 | return 6;
82 | } else
83 | return RET_ILSEQ;
84 | }
85 |
86 | inline static int
87 | utf8_wctomb (unsigned char *r, ucs4_t wc, int n) /* n == 0 is acceptable */
88 | {
89 | int count;
90 | if (wc < 0x80)
91 | count = 1;
92 | else if (wc < 0x800)
93 | count = 2;
94 | else if (wc < 0x10000)
95 | count = 3;
96 | else if (wc < 0x200000)
97 | count = 4;
98 | else if (wc < 0x4000000)
99 | count = 5;
100 | else if (wc <= 0x7fffffff)
101 | count = 6;
102 | else
103 | return RET_ILUNI;
104 | if (n < count)
105 | return RET_TOOSMALL;
106 | switch (count) { /* note: code falls through cases! */
107 | case 6: r[5] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x4000000;
108 | case 5: r[4] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x200000;
109 | case 4: r[3] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x10000;
110 | case 3: r[2] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0x800;
111 | case 2: r[1] = 0x80 | (wc & 0x3f); wc = wc >> 6; wc |= 0xc0;
112 | case 1: r[0] = wc;
113 | }
114 | return count;
115 | }
116 |
--------------------------------------------------------------------------------
/src/nge.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file nge.c
3 | * @author Kun Wang
4 | * @date 2012/02/12 06:42:41
5 | *
6 | * Copyright 2012 Kun Wang
7 | *
8 | */
9 | #include "nge_debug_log.h"
10 | #include "nge.h"
11 | #include "nge_graphics.h"
12 | #include "nge_input.h"
13 | #include "audio_interface.h"
14 | #include
15 | #include
16 |
17 | #ifdef NGE_PSP
18 | int psp_exit_callback_id = 0;
19 | void NGE_RegisterPSPExitCallback(int cb_id) {
20 | psp_exit_callback_id = cb_id;
21 | }
22 | #endif
23 |
24 | static char set_ori_default = 0;
25 |
26 | void NGE_SetScreenContext(const char* winname,int screen_width,int screen_height,int screen_bpp,int screen_full)
27 | {
28 | screen_context_p screen = GetScreenContext();
29 | int len;
30 |
31 | if (screen->name != NULL)
32 | free(screen->name);
33 |
34 | if(winname == NULL)
35 | screen->name = NULL;
36 | else {
37 | len = strlen(winname) + 1;
38 | screen->name = malloc(len);
39 | strncpy(screen->name,winname,len);
40 | }
41 |
42 | screen->width = screen_width;
43 | screen->height = screen_height;
44 | screen->bpp = screen_bpp;
45 | screen->fullscreen = screen_full;
46 | if(set_ori_default == 0){
47 | screen->ori_width = screen_width;
48 | screen->ori_height = screen_height;
49 | screen->rate_h = screen->rate_w = 1.0f;
50 | }
51 | }
52 |
53 | void NGE_SetOriginalResolution(int width,int height)
54 | {
55 | screen_context_p screen = GetScreenContext();
56 | screen->ori_width = width;
57 | screen->ori_height = height;
58 | screen->rate_w = 1.0f * width/screen->width;
59 | screen->rate_h = 1.0f * height/screen->height;
60 | set_ori_default = 1;
61 | }
62 |
63 | char *NGE_OP_Path = NULL;
64 | void NGE_SetOPMoviePath(const char* path) {
65 | NGE_OP_Path = (char*)path;
66 | }
67 |
68 | static int initFlags = 0;
69 |
70 | void NGE_Init(int flags)
71 | {
72 | if(initFlags==0){
73 | #ifndef NGE_IPHONE
74 | if(flags&INIT_VIDEO)
75 | InitGraphics();
76 | if(flags&INIT_AUDIO)
77 | CoolAudioDefaultInit();
78 | #endif
79 | initFlags = flags;
80 | }
81 | }
82 |
83 | void NGE_Quit()
84 | {
85 | if(initFlags){
86 | #ifndef NGE_IPHONE
87 | FiniInput();
88 | if(initFlags&INIT_VIDEO)
89 | FiniGraphics();
90 | if(initFlags&INIT_AUDIO)
91 | CoolAudioDefaultFini();
92 | #endif
93 | initFlags = 0;
94 |
95 | #ifdef MMGR
96 | m_dumpMemoryReport();
97 | #endif
98 | }
99 | }
100 |
101 | /* just for export dll symbol */
102 | void _______fake_CreateMp3Player() {
103 | CreateMp3Player();
104 | }
105 | void _______fake_CreateWavPlayer() {
106 | CreateWavPlayer();
107 | }
108 | void _______fake_CreateOggPlayer() {
109 | CreateOggPlayer();
110 | }
111 |
--------------------------------------------------------------------------------
/src/nge_app.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file nge_app.c
3 | * @author Kun Wang
4 | * @date 2011/08/08 13:38:36
5 | *
6 | * Copyright 2011 Kun Wang
7 | *
8 | * This program is free software; you can redistribute it and/or modify
9 | * it under the terms of the GNU General Public License as published by
10 | * the Free Software Foundation; either version 2 of the License, or
11 | * (at your option) any later version.
12 | *
13 | * This program is distributed in the hope that it will be useful,
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | * GNU General Public License for more details.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program; if not, write to the Free Software
20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 | */
22 | #include "nge_app.h"
23 |
24 | static nge_app_t *s_app = 0;
25 |
26 | void nge_init_app(nge_app_t *app) {
27 | app->init = NULL;
28 | app->mainloop = NULL;
29 | app->fini = NULL;
30 | app->pause = NULL;
31 | app->resume = NULL;
32 | app->start = NULL;
33 | app->stop = NULL;
34 | }
35 |
36 | void nge_register_app(nge_app_t *app) {
37 | s_app = app;
38 | }
39 |
40 | nge_app_t* nge_get_app() {
41 | return s_app;
42 | }
43 |
--------------------------------------------------------------------------------
/src/nge_app_cpp.cpp:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | * nge_app.cpp
3 | *
4 | * 2011/03/25 06:55:37
5 | * Copyright 2010 TOPOC. All rights reserved.
6 | * Copyright 2011 Kun Wang
7 | ****************************************************************************/
8 | /*
9 | * This program is free software; you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation; either version 2 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | *
19 | * You should have received a copy of the GNU General Public License
20 | * along with this program; if not, write to the Free Software
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 | */
23 | #include "nge_app.hpp"
24 |
25 | static nge_app_t s_app;
26 | static CNgeApp *s_App = 0;
27 |
28 |
static int app_init() {
29 | return s_App->Init();
30 | }
31 |
32 | static int app_mainloop() {
33 | return s_App->Mainloop();
34 | }
35 |
36 | static int app_fini() {
37 | return s_App->Fini();
38 | }
39 |
40 | static int app_pause(){
41 | return s_App->Pause();
42 | }
43 |
44 | static int app_resume(){
45 | return s_App->Resume();
46 | }
47 |
48 | static int app_start(){
49 | return s_App->Start();
50 | }
51 |
52 | static int app_stop(){
53 | return s_App->Stop();
54 | }
55 |
56 | void nge_registerApp(CNgeApp *app) {
57 | s_App = app;
58 | s_app.init = app_init;
59 | s_app.mainloop = app_mainloop;
60 | s_app.fini = app_fini;
61 | s_app.pause = app_pause;
62 | s_app.resume = app_resume;
63 | s_app.start = app_start;
64 | s_app.stop = app_stop;
65 | nge_register_app(&s_app);
66 | }
--------------------------------------------------------------------------------
/src/nge_charsets.c:
--------------------------------------------------------------------------------
1 | // charset.cpp: implementation of the charset class.
2 | //
3 | //////////////////////////////////////////////////////////////////////
4 |
5 |
6 | //////////////////////////////////////////////////////////////////////
7 | // Construction/Destruction
8 | //////////////////////////////////////////////////////////////////////
9 |
10 | #include "nge_debug_log.h"
11 | #include "nge_charsets.h"
12 | #include
13 | #include
14 |
15 | /* definitions */
16 |
17 | typedef uint32_t ucs4_t;
18 | /* Return code if invalid. (xxx_mbtowc) */
19 | #define RET_ILSEQ -1
20 | /* Return code if only a shift sequence of n bytes was read. (xxx_mbtowc) */
21 | #define RET_TOOFEW(n) (-2-(n))
22 | /* Return code if invalid. (xxx_wctomb) */
23 | #define RET_ILUNI -1
24 | /* Return code if output buffer is too small. (xxx_wctomb) */
25 | #define RET_TOOSMALL -2
26 |
27 | typedef struct {
28 | uint16_t indx; /* index into big table */
29 | uint16_t used; /* bitmask of used entries */
30 | } Summary16;
31 |
32 | #include "charsets/ascii.h"
33 | #include "charsets/utf8.h"
34 | #include "charsets/gbk.h"
35 | #include "charsets/ces_gbk.h"
36 |
37 | int nge_charset_gbk_to_ucs2(const uint8_t* in, uint16_t* out, int len, int n) {
38 | ucs4_t wc = 0;
39 | int cur = 0, ret;
40 | uint16_t *pOut = out, *pEnd = out+n/2;
41 |
42 | while (cur < len) {
43 | ret = ces_gbk_mbtowc(&wc, in+cur, len-cur);
44 | if (ret < 0 || wc > 0xffff)
45 | return 0;
46 | *pOut = (uint16_t)wc;
47 | cur += ret;
48 | pOut++;
49 | if (pOut > pEnd)
50 | return NGE_RET_BUFFER_SMALL;
51 | }
52 | *pOut = 0x0;
53 | return pOut - (uint16_t*)out;
54 | }
55 |
56 | int nge_charset_utf8_to_ucs2(const uint8_t* in, uint16_t* out, int len, int n) {
57 | ucs4_t wc = 0;
58 | int cur = 0, ret;
59 | uint16_t *pOut = out, *pEnd = out+n/2;
60 |
61 | while (cur < len) {
62 | ret = utf8_mbtowc(&wc, in+cur, len-cur);
63 | if (ret < 0 || wc > 0xffff)
64 | return 0;
65 | *pOut = (uint16_t)wc;
66 | cur += ret;
67 | pOut++;
68 | if (pOut > pEnd)
69 | return NGE_RET_BUFFER_SMALL;
70 | }
71 | *pOut = 0x0;
72 | return pOut - (uint16_t*)out;
73 | }
74 |
75 | int nge_charsets_utf8_to_gbk(const uint8_t* in, uint8_t* out, int len, int n) {
76 | ucs4_t wc = 0;
77 | int cur = 0, ret;
78 | uint8_t *pOut = out, *pEnd = out+n;
79 |
80 | while (cur < len) {
81 | ret = utf8_mbtowc(&wc, in+cur, len-cur);
82 | if (ret < 0)
83 | return 0;
84 | cur += ret;
85 |
86 | ret = ces_gbk_wctomb(pOut, wc, n);
87 | if (ret < 0)
88 | return 0;
89 | pOut += ret;
90 | n -= ret;
91 |
92 | if (pOut > pEnd)
93 | return NGE_RET_BUFFER_SMALL;
94 | }
95 | *pOut = 0x0;
96 | return pOut - out - 1;
97 | }
98 |
99 | int nge_charsets_gbk_to_utf8(const uint8_t* in, uint8_t* out, int len, int n) {
100 | ucs4_t wc = 0;
101 | int cur = 0, ret;
102 | uint8_t *pOut = out, *pEnd = out+n;
103 |
104 | while (cur < len) {
105 | ret = ces_gbk_mbtowc(&wc, in+cur, len-cur);
106 | if (ret < 0)
107 | return 0;
108 | cur += ret;
109 |
110 | ret = utf8_wctomb(pOut, wc, n);
111 | if (ret < 0)
112 | return 0;
113 | pOut += ret;
114 | n -= ret;
115 |
116 | if (pOut > pEnd)
117 | return NGE_RET_BUFFER_SMALL;
118 | }
119 | *pOut = 0x0;
120 | return pOut - out - 1;
121 | }
122 |
--------------------------------------------------------------------------------
/src/nge_debug_log.c:
--------------------------------------------------------------------------------
1 | #ifndef NDEBUG
2 |
3 | #include "nge_platform.h"
4 | #include "nge_debug_log.h"
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | #ifdef NGE_PSP
11 | #include
12 | #endif
13 |
14 | #if defined NGE_LINUX || defined NGE_PSP
15 | #define _vsnprintf vsnprintf
16 | #endif
17 |
18 | #if !defined NGE_ANDROID && !defined NGE_IPHONE
19 | FILE *g_logfile = NULL, *g_errorfile = NULL;
20 |
21 | /**
22 | * nge_printf
23 | */
24 | inline void nge_printf (FILE** pFile, const char* filename, const char* pMessage, va_list ArgPtr)
25 | {
26 | char Message[1024] = {0};
27 | char* FirstLog = "-------------------------=NGE LOG=-------------------------\n";
28 |
29 | if(!(*pFile)){
30 | *pFile = fopen (filename, "a+b");
31 | fwrite (FirstLog, strlen (FirstLog), 1, *pFile);
32 | #if defined NGE_WIN && defined _DEBUG_STDOUT
33 | freopen("CONOUT$","w+t",stdout);
34 | freopen("CONIN$","r+t",stdin);
35 | #endif
36 | }
37 | _vsnprintf (Message, sizeof (Message), pMessage, ArgPtr);
38 |
39 | #ifdef _DEBUG_STDOUT
40 | printf (Message);
41 | #endif
42 | fwrite (Message, strlen (Message), 1, *pFile);
43 | // fclose (*pFile); -- notice: I don't close it, because system will close it when quit.
44 | }
45 | #endif
46 |
47 | #ifdef NGE_ANDROID
48 | #include
49 | #define LOG_TAG "libnge2"
50 | #define NGE_LOG(msg, argptr) __android_log_vprint(ANDROID_LOG_INFO, LOG_TAG, msg, argptr)
51 | #define NGE_ERR(msg, argptr) __android_log_vprint(ANDROID_LOG_ERROR, LOG_TAG, msg, argptr)
52 | #elif defined NGE_IPHONE
53 | // -- fixme
54 | #define NGE_LOG(msg, argptr)
55 | #define NGE_ERR(msg, argptr)
56 | #else
57 | #define NGE_LOG(msg, argptr) nge_printf(&g_logfile, "neg_log.txt", msg, argptr)
58 | #define NGE_ERR(msg, argptr) nge_printf(&g_errorfile, "neg_error.txt", msg, argptr)
59 | #endif
60 |
61 | void nge_log(const char* pMessage, ...)
62 | {
63 | va_list ArgPtr;
64 |
65 | va_start (ArgPtr, pMessage);
66 | NGE_LOG(pMessage, ArgPtr);
67 | va_end (ArgPtr);
68 | }
69 |
70 | void nge_error(const char* pMessage, ...)
71 | {
72 | va_list ArgPtr;
73 |
74 | va_start (ArgPtr, pMessage);
75 | NGE_ERR(pMessage, ArgPtr);
76 | va_end (ArgPtr);
77 | }
78 |
79 | void nge_mem_log()
80 | {
81 | #ifdef MMGR
82 | m_dumpMemoryReport();
83 | #endif
84 | }
85 |
86 | void nge_debug_quitgame()
87 | {
88 | #if defined NGE_PSP
89 | sceKernelExitGame();
90 | #endif
91 | exit(-1);
92 | }
93 | #endif
94 |
--------------------------------------------------------------------------------
/src/nge_font.c:
--------------------------------------------------------------------------------
1 | #include "nge_debug_log.h"
2 | #include "nge_font.h"
3 | #include "nge_font_internal.h"
4 |
5 | uint8_t nge_font_encoding = NGE_ENCODING_GBK;
6 |
7 | void NGE_SetFontEncoding(uint8_t encoding) {
8 | nge_font_encoding = encoding;
9 | }
10 |
11 | void font_drawtext(PFont pf,const char* text,int len,image_p textarea,int dx,int dy,int flags)
12 | {
13 | PFontProcs procs;
14 |
15 | if(pf == NULL || text == NULL || textarea ==NULL || len == 0)
16 | return;
17 | procs = pf->procs;
18 | if(flags == FONT_SHOW_SHADOW){
19 | if(procs->DrawTextShadow!=NULL){
20 | procs->DrawTextShadow(pf,textarea,dx,dy,text,len,0);
21 | }
22 | else{
23 | procs->DrawText(pf,textarea,dx,dy,text,len,0);
24 | }
25 | }
26 | else{
27 | procs->DrawText(pf,textarea,dx,dy,text,len,0);
28 | }
29 | }
30 |
31 | void font_setattr(PFont pf,int attr,int setflag)
32 | {
33 | PFontProcs procs;
34 | if(pf == NULL)
35 | return;
36 | procs = pf->procs;
37 | if(procs->SetFontAttr!=NULL)
38 | procs->SetFontAttr(pf,attr,setflag);
39 | }
40 |
41 | void font_destory(PFont pf)
42 | {
43 | PFontProcs procs;
44 | if(pf == NULL)
45 | return;
46 | procs = pf->procs;
47 | if(procs->DestroyFont != NULL)
48 | procs->DestroyFont(pf);
49 | }
50 |
51 | int font_setcolor(PFont pf,uint32_t color)
52 | {
53 | PFontProcs procs;
54 | if(pf == NULL)
55 | return 0;
56 | procs = pf->procs;
57 | if(procs->SetFontColor != NULL)
58 | return procs->SetFontColor(pf,color);
59 | return 0;
60 | }
61 |
62 | void font_setcolor_ex(PFont pf, uint32_t color_fg,uint32_t color_bg ,uint32_t color_sh )
63 | {
64 | PFontProcs procs;
65 | if(pf == NULL)
66 | return;
67 | procs = pf->procs;
68 | if(procs->SetShadowColor!=NULL)
69 | procs->SetShadowColor(pf,color_fg,color_bg,color_sh);
70 | else
71 | procs->SetFontColor(pf,color_fg);
72 | }
73 |
74 | void font_textsize(PFont pf, const void *text, int cc,int *pwidth, int *pheight,int *pbase)
75 | {
76 | PFontProcs procs;
77 | if(pf == NULL)
78 | return ;
79 | procs = pf->procs;
80 | if(procs->GetTextSize != NULL)
81 | procs->GetTextSize(pf,text,cc,0/*flag*/,pwidth,pheight,pbase);
82 | }
83 |
--------------------------------------------------------------------------------
/src/nge_graphics.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/src/nge_graphics.c
--------------------------------------------------------------------------------
/src/nge_image.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/src/nge_image.c
--------------------------------------------------------------------------------
/src/nge_image_effect.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/src/nge_image_effect.c
--------------------------------------------------------------------------------
/src/nge_image_ext.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/src/nge_image_ext.c
--------------------------------------------------------------------------------
/src/nge_input.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/src/nge_input.c
--------------------------------------------------------------------------------
/src/nge_main.c:
--------------------------------------------------------------------------------
1 | #include "nge_platform.h"
2 | #include "nge_app.h"
3 | #include "nge.h"
4 |
5 | #include
6 |
7 | #ifdef NGE_WIN
8 | #define WIN32_LEAN_AND_MEAN
9 | #include
10 | #endif
11 |
12 | extern int NGE_main(int argc, char *argv[]);
13 |
14 | #ifdef NGE_PSP
15 | #include
16 | #include
17 | #include
18 | #include
19 |
20 | int cbid = 0;
21 |
22 | PSP_MODULE_INFO("NGE APP", 0, 1, 1);
23 | PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_VFPU|THREAD_ATTR_USER);
24 | PSP_HEAP_SIZE_KB(18*1024);
25 |
26 | int nge_psp_exit_callback(int arg1, int arg2, void *common)
27 | {
28 | sceKernelDelayThread(500000);
29 | sceKernelExitGame();
30 | return 0;
31 | }
32 |
33 | int nge_psp_callback_thread(SceSize args, void *argp)
34 | {
35 | //int cbid;
36 | cbid = sceKernelCreateCallback("Exit Callback",nge_psp_exit_callback, NULL);
37 | NGE_RegisterPSPExitCallback(cbid);
38 | sceKernelRegisterExitCallback(cbid);
39 | sceKernelSleepThreadCB();
40 | return 0;
41 | }
42 |
43 | int nge_psp_setup_callbacks(void)
44 | {
45 | int thid = 0;
46 | thid = sceKernelCreateThread("update_thread",nge_psp_callback_thread, 0x11, 0xFA0, 0, 0);
47 | if(thid >= 0)
48 | sceKernelStartThread(thid, 0, 0);
49 | return thid;
50 | }
51 | #endif
52 |
53 | #ifdef NGE_WIN
54 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
55 | LPSTR lpCmdLine, int iCmdShow)
56 | #else
57 | int main(int argc, char *argv[])
58 | #endif
59 | {
60 | nge_app_t *app;
61 | int ret = 0;
62 |
63 | #ifdef NGE_WIN
64 | static int argc = 0;
65 | static char* argv[] = { NULL };
66 | #ifdef _DEBUG_STDOUT
67 | AllocConsole();
68 | freopen("CONOUT$","w+t",stdout);
69 | freopen("CONIN$","r+t",stdin);
70 | #endif
71 | #endif
72 |
73 | #ifdef NGE_PSP
74 | #ifndef NDEBUG
75 | pspDebugScreenInit();
76 | #endif
77 | nge_psp_setup_callbacks();
78 | #endif
79 |
80 | (void)NGE_main(argc, argv);
81 | app = nge_get_app();
82 | if (app) {
83 | app->init();
84 | while (1) {
85 | if (app->mainloop() == NGE_APP_QUIT)
86 | break;
87 | }
88 | ret = app->fini();
89 | }
90 |
91 | #ifdef NGE_PSP
92 | /* Delay 0.5 seconds before returning to the OS. */
93 | sceKernelDelayThread(500000);
94 | sceKernelExitGame();
95 | return 0;
96 | #endif
97 | return ret;
98 | }
99 |
--------------------------------------------------------------------------------
/src/nge_misc.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/src/nge_misc.c
--------------------------------------------------------------------------------
/src/nge_package.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file nge_package.c
3 | * @author Kun Wang
4 | * @date 2012/03/18 07:18:54
5 | *
6 | * Copyright 2012 Kun Wang
7 | *
8 | */
9 | #include "nge_package.h"
10 | #include "nge_package_internal.h"
11 | #include
12 |
13 | static ngePackageFormat* formats[NGE_MAX_PACKAGE_FORMAT];
14 | static uint8_t len = 0;
15 |
16 | int ngePackageRegister(ngePackageFormat* format) {
17 | if (len > NGE_MAX_PACKAGE_FORMAT)
18 | return -1;
19 |
20 | formats[len] = format;
21 | len++;
22 | return 0;
23 | }
24 |
25 | ngePackage* ngeLoadPackage(const char* fname, int option) {
26 | ngePackageFormat *format = NULL;
27 | char* p, ext[10];
28 | int i;
29 |
30 | p = strrchr(fname, '.');
31 | if (p == NULL)
32 | return NULL;
33 |
34 | strcpy(ext, p+1);
35 | for (i=0; iextension) == 0) {
37 | format = formats[i];
38 | break;
39 | }
40 | }
41 |
42 | if (format == NULL)
43 | return NULL;
44 |
45 | return format->op->Open(fname, option);
46 | }
47 |
48 | void ngeClosePackage(ngePackage* pkg) {
49 | pkg->op->Close(pkg);
50 | }
51 |
52 | int ngeOpenInPackage(ngePackage* pkg, const char* fname, int flag) {
53 | return pkg->op->OpenFile(pkg, fname, flag);
54 | }
55 |
56 | ngeRefHandle ngeCreatePackageHandle(ngePackage* pkg) {
57 | return ngeRefHandleCreate((fn_ngeDeleteCallback)ngeClosePackage, (void*)pkg);
58 | }
59 |
--------------------------------------------------------------------------------
/src/nge_package_zip.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file nge_package_zip.c
3 | * @author Kun Wang
4 | * @date 2012/03/18 07:57:30
5 | *
6 | * Copyright 2012 Kun Wang
7 | *
8 | */
9 | #include
10 | #include
11 | #include "nge_package.h"
12 | #include "nge_package_internal.h"
13 | #include "nge_io_file_internal.h"
14 | #include "nge_package_zip.h"
15 | #include "unzip.h"
16 |
17 | typedef struct ngePackageZip {
18 | ngePackageOperation* op;
19 | char *fname, *passwd;
20 | } ngePackageZip;
21 |
22 | static ngePackage* Open(const char* fname,int option);
23 | static void Close(ngePackage* pkg);
24 | static int OpenFile(ngePackage* pkg, const char* fname,int flag);
25 |
26 | static ngePackageOperation zipOperation = {
27 | Open,
28 | Close,
29 | OpenFile
30 | };
31 |
32 | ngePackage* Open(const char* fname,int option) {
33 | ngePackageZip* zip = (ngePackageZip*)malloc(sizeof(ngePackageZip));
34 | int len = strlen(fname);
35 |
36 | zip->fname = (char*)malloc(len+1);
37 | strcpy(zip->fname, fname);
38 | zip->passwd = NULL;
39 |
40 | zip->op = &zipOperation;
41 | return (ngePackage*)zip;
42 | }
43 |
44 | void Close(ngePackage* pkg) {
45 | ngePackageZip* zip = (ngePackageZip*)pkg;
46 |
47 | free(zip->fname);
48 | if (zip->passwd != NULL)
49 | free(zip->passwd);
50 |
51 | free(zip);
52 | }
53 |
54 | void ngePackageZipSetPassword(ngePackage* pkg, const char* passwd) {
55 | ngePackageZip* zip = (ngePackageZip*)pkg;
56 | int len = strlen(passwd);
57 |
58 | zip->passwd = (char*)malloc(len+1);
59 | strcpy(zip->passwd, passwd);
60 | }
61 |
62 | static ngePackageFormat zipPackage = {
63 | "zip",
64 | &zipOperation,
65 | };
66 |
67 | void ngePackageZipInit() {
68 | ngePackageRegister(&zipPackage);
69 | }
70 |
71 | /* zip file operations */
72 | typedef struct {
73 | ngeVFOperation* op;
74 | unzFile file;
75 | } ngeVFZip;
76 |
77 | static int FileClose(ngeVF* f) {
78 | ngeVFZip* zip = (ngeVFZip*)f;
79 | unzCloseCurrentFile(zip->file);
80 | unzClose(zip->file);
81 | free(zip);
82 | return 0;
83 | }
84 |
85 | static int Read(void *buf, size_t size, size_t n, ngeVF* f) {
86 | ngeVFZip* zip = (ngeVFZip*)f;
87 |
88 | return unzReadCurrentFile(zip->file, buf, size*n);
89 | }
90 |
91 | static int Tell(ngeVF *f) {
92 | ngeVFZip* zip = (ngeVFZip*)f;
93 |
94 | return unztell(zip->file);
95 | }
96 |
97 | static int Eof(ngeVF *f) {
98 | ngeVFZip* zip = (ngeVFZip*)f;
99 |
100 | return unzeof(zip->file);
101 | }
102 |
103 | static int Size(ngeVF* f) {
104 | ngeVFZip* zip = (ngeVFZip*)f;
105 | unz_file_info info;
106 |
107 | if(unzGetCurrentFileInfo(zip->file, &info, NULL, 0, NULL, 0, NULL, 0) != UNZ_OK)
108 | return -1;
109 |
110 | return info.uncompressed_size;
111 | }
112 |
113 | static ngeVFOperation zipFileOperation = {
114 | FileClose,
115 | Read,
116 | NULL,
117 | NULL,
118 | Tell,
119 | Eof,
120 | Size
121 | };
122 |
123 | int OpenFile(ngePackage* pkg, const char* fname,int flag) {
124 | ngePackageZip* zip = (ngePackageZip*)pkg;
125 | ngeVFZip* f;
126 | unzFile file;
127 |
128 | if (flag != IO_RDONLY)
129 | return 0;
130 |
131 | file = unzOpen(zip->fname);
132 | if (file == NULL)
133 | return 0;
134 |
135 | if(unzLocateFile(file, fname, 0) != UNZ_OK)
136 | goto fail;
137 |
138 | if (zip->passwd == NULL) {
139 | if (unzOpenCurrentFile(file) != UNZ_OK)
140 | goto fail;
141 | }
142 | else {
143 | if (unzOpenCurrentFilePassword(file, zip->passwd) != UNZ_OK)
144 | goto fail;
145 | }
146 |
147 | f = (ngeVFZip*)malloc(sizeof(ngeVFZip));
148 | f->file = file;
149 |
150 | f->op = &zipFileOperation;
151 | return ngeVFAdd((ngeVF*)f);
152 |
153 | fail:
154 | unzClose(file);
155 | return 0;
156 | }
157 |
--------------------------------------------------------------------------------
/src/nge_ref_handle.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file nge_ref_handle.c
3 | * @author Kun Wang
4 | * @date 2012/03/18 03:30:10
5 | *
6 | * Copyright 2012 Kun Wang
7 | *
8 | */
9 | #include "nge_ref_handle.h"
10 | #include
11 | #include
12 |
13 | typedef struct ngeRefHandleImpl
14 | {
15 | void* ptr;
16 | fn_ngeDeleteCallback cb;
17 | int *ref;
18 | } ngeRefHandleImpl;
19 |
20 | ngeRefHandle ngeRefHandleCreate(fn_ngeDeleteCallback cb, void* ptr) {
21 | ngeRefHandleImpl* handle = (ngeRefHandleImpl*)malloc(sizeof(ngeRefHandleImpl));
22 | handle->ref = (int*)malloc(sizeof(int));
23 |
24 | *handle->ref = 1;
25 | handle->ptr = ptr;
26 | handle->cb = cb;
27 |
28 | return (ngeRefHandle)handle;
29 | }
30 |
31 | void ngeRefHandleRelease(ngeRefHandle handle) {
32 | ngeRefHandleImpl* h = (ngeRefHandleImpl*)handle;
33 | (*h->ref)--;
34 | if (*h->ref == 0) {
35 | h->cb(h->ptr);
36 | free(h->ref);
37 | }
38 |
39 | free(h);
40 | }
41 |
42 | ngeRefHandle ngeRefHandleCopy(ngeRefHandle handle) {
43 | ngeRefHandleImpl* h = (ngeRefHandleImpl*)handle;
44 | ngeRefHandleImpl* o;
45 |
46 | (*h->ref)++;
47 |
48 | o = (ngeRefHandleImpl*)malloc(sizeof(ngeRefHandleImpl));
49 | memcpy(o, h, sizeof(ngeRefHandleImpl));
50 | return (ngeRefHandle)o;
51 | }
52 |
53 | void ngeRef(ngeRefHandle handle) {
54 | ngeRefHandleImpl* h = (ngeRefHandleImpl*)handle;
55 | (*h->ref)++;
56 | }
57 |
58 | void ngeUnref(ngeRefHandle handle) {
59 | ngeRefHandleImpl* h = (ngeRefHandleImpl*)handle;
60 | (*h->ref)--;
61 | }
62 |
63 | static void Delete(void* ptr) {
64 | free(ptr);
65 | }
66 |
67 | ngeRefHandle ngeCreateNormalHandle(void* ptr) {
68 | return ngeRefHandleCreate(Delete, ptr);
69 | }
70 |
--------------------------------------------------------------------------------
/src/nge_sys_compatible.c:
--------------------------------------------------------------------------------
1 | #include "nge_common.h"
2 | #include "nge_debug_log.h"
3 | #include "nge_sys_compatible.h"
4 | #include
5 | #include
6 |
7 | static int cpu_type = CPU_TYPE_222MHZ;
8 |
9 | #ifdef NGE_PSP
10 | #include
11 | //psp
12 | int sys_localtime(sys_time_p stm)
13 | {
14 | if(stm)
15 | return sceRtcGetCurrentClockLocalTime(stm);
16 | else
17 | return 0;
18 | }
19 |
20 | char* sys_get_idstorage()
21 | {
22 | static char ret[32] = {0};
23 | unsigned char buffer[0x1e]; /* Buffer */
24 | /*sceIdStorageLookup(0x050, 0x0, buffer, 0x1e);
25 | sprintf(ret,"%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",
26 | buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5],
27 | buffer[6], buffer[7], buffer[8], buffer[9], buffer[10], buffer[11],
28 | buffer[12], buffer[13], buffer[14], buffer[15], buffer[16], buffer[17],
29 | buffer[18], buffer[19], buffer[20], buffer[21], buffer[22], buffer[23],
30 | buffer[24], buffer[25], buffer[26], buffer[27], buffer[28], buffer[29]);*/
31 | return ret;
32 | }
33 |
34 | char* sys_get_mac()
35 | {
36 | static char ret[24]={0};
37 | unsigned char sVal[8]= {0};
38 | int retVal;
39 | //retVal = sceWlanGetEtherAddr(sVal);
40 | if (retVal == 0)
41 | sprintf(ret,"%02X:%02X:%02X:%02X:%02X:%02X", sVal[0], sVal[1], sVal[2], sVal[3], sVal[4], sVal[5]);
42 | return ret;
43 | }
44 |
45 | char* sys_get_nickname()
46 | {
47 | static char ret[64]={0};
48 | /*if(sceUtilityGetSystemParamString(PSP_SYSTEMPARAM_ID_STRING_NICKNAME, ret, 64) == PSP_SYSTEMPARAM_RETVAL_FAIL)
49 | strncpy(ret,"NGE2",4);*/
50 | return ret;
51 | }
52 |
53 | int sys_set_frequency_type(int type)
54 | {
55 | int ret = -1;
56 | switch(type)
57 | {
58 | case CPU_TYPE_333MHZ:
59 | ret = scePowerSetClockFrequency(333, 333, 166);
60 | break;
61 | case CPU_TYPE_222MHZ:
62 | ret = scePowerSetClockFrequency(222, 222, 111);
63 | break;
64 | case CPU_TYPE_111MHZ:
65 | ret = scePowerSetClockFrequency(111, 111, 66);
66 | break;
67 | default:
68 | break;
69 | }
70 | if(ret == 0){
71 | cpu_type = type;
72 | return 1;
73 | }
74 | return 0;
75 | }
76 |
77 | int sys_get_frequency_type()
78 | {
79 | return cpu_type;
80 | }
81 | #else
82 | #include
83 | int sys_localtime(sys_time_p stm)
84 | {
85 | time_t t = time(NULL);
86 | struct tm *pt = localtime(&t);
87 | if(stm){
88 | stm->year = pt->tm_year+1900;
89 | stm->month = pt->tm_mon+1;
90 | stm->day = pt->tm_mday;
91 | stm->hour = pt->tm_hour;
92 | stm->minutes = pt->tm_min;
93 | stm->seconds = pt->tm_sec;
94 | stm->microseconds = 0;
95 | return 1;
96 | }
97 | return 0;
98 | }
99 |
100 | //set 'F'
101 | char* sys_get_idstorage()
102 | {
103 | static char ret[32] = {0};
104 | memset(ret,'F',30);
105 | return ret;
106 | }
107 |
108 | char* sys_get_mac()
109 | {
110 | static char ret[24]={0};
111 | unsigned char sVal[8]= {0};
112 | memset(sVal,0xff,8);
113 | sprintf(ret,"%02X:%02X:%02X:%02X:%02X:%02X", sVal[0], sVal[1], sVal[2], sVal[3], sVal[4], sVal[5]);
114 | return ret;
115 | }
116 |
117 | char* sys_get_nickname()
118 | {
119 | static char ret[64]={"NGE2"};
120 | return ret;
121 | }
122 |
123 | int sys_set_frequency_type(int type)
124 | {
125 | printf("switch cpu to %d mhz\n",type);
126 | cpu_type = type;
127 | return 1;
128 | }
129 |
130 | int sys_get_frequency_type()
131 | {
132 | return cpu_type;
133 | }
134 | #endif
135 |
--------------------------------------------------------------------------------
/src/nge_tex_cache.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/src/nge_tex_cache.c
--------------------------------------------------------------------------------
/src/nge_timer.c:
--------------------------------------------------------------------------------
1 | #include "nge_platform.h"
2 | #include "nge_debug_log.h"
3 | #include "nge_timer.h"
4 | #include
5 | #include
6 |
7 | #if defined NGE_LINUX || defined NGE_IPHONE || defined NGE_ANDROID
8 | #define NGE_UNIX
9 | #endif
10 |
11 | static uint32_t TM_get_ticks(nge_timer* timer);
12 | static uint32_t TM_is_started(nge_timer* timer);
13 | static uint32_t TM_is_paused(nge_timer* timer);
14 | static void TM_start(nge_timer* timer);
15 | static void TM_stop(nge_timer* timer);
16 | static void TM_pause(nge_timer* timer);
17 | static void TM_unpause(nge_timer* timer);
18 |
19 | nge_timer* nge_timer_create()
20 | {
21 | nge_timer* timer = (nge_timer*)malloc(sizeof(nge_timer));
22 | memset(timer,0,sizeof(nge_timer));
23 | timer->get_ticks = TM_get_ticks;
24 | timer->is_started = TM_is_started;
25 | timer->is_paused = TM_is_paused;
26 | timer->start = TM_start;
27 | timer->stop = TM_stop;
28 | timer->pause = TM_pause;
29 | timer->unpause = TM_unpause;
30 | return timer;
31 | }
32 |
33 | void nge_timer_free(nge_timer* timer)
34 | {
35 | SAFE_FREE(timer);
36 | }
37 |
38 | static uint32_t TM_get_ticks(nge_timer* timer)
39 | {
40 | //If the timer is running
41 | if( timer->started == 1 )
42 | {
43 | //If the timer is paused
44 | if( timer->paused == 1 )
45 | {
46 | //Return the number of ticks when the the timer was paused
47 | return timer->pausedTicks;
48 | }
49 | else
50 | {
51 | //Return the current time minus the start time
52 | return nge_get_tick() - timer->startTicks;
53 | }
54 | }
55 | return 0;
56 | }
57 | static uint32_t TM_is_started(nge_timer* timer)
58 | {
59 | return timer->started;
60 | }
61 | static uint32_t TM_is_paused(nge_timer* timer)
62 | {
63 | return timer->paused;
64 | }
65 | static void TM_start(nge_timer* timer)
66 | {
67 | timer->started = 1;
68 | timer->paused = 0;
69 | timer->startTicks = nge_get_tick();
70 | }
71 | static void TM_stop(nge_timer* timer)
72 | {
73 | timer->started = 0;
74 | timer->paused = 0;
75 | }
76 | static void TM_pause(nge_timer* timer)
77 | {
78 | //If the timer is running and isn't already paused
79 | if( ( timer->started == 1 ) && ( timer->paused == 0 ) )
80 | {
81 | //Pause the timer
82 | timer->paused = 1;
83 | //Calculate the paused ticks
84 | timer->pausedTicks = nge_get_tick() - timer->startTicks;
85 | }
86 | }
87 | static void TM_unpause(nge_timer* timer)
88 | {
89 | //If the timer is paused
90 | if( timer->paused == 1 )
91 | {
92 | //Unpause the timer
93 | timer->paused = 0;
94 |
95 | //Reset the starting ticks
96 | timer->startTicks = nge_get_tick() - timer->pausedTicks;
97 |
98 | //Reset the paused ticks
99 | timer->pausedTicks = 0;
100 | }
101 | }
102 |
103 | #if defined NGE_PSP
104 | #include
105 | #include
106 | #include
107 | static u64 mTickFrequency = 0;
108 | #elif defined NGE_WIN
109 | #define WIN32_LEAN_AND_MEAN
110 | #include
111 | /*
112 | * Structure used in select() call, taken from the BSD file sys/time.h.
113 | */
114 | struct timeval {
115 | long tv_sec; /* seconds */
116 | long tv_usec; /* and microseconds */
117 | };
118 |
119 | int gettimeofday(struct timeval * val, struct timezone * zone)
120 | {
121 | if (val)
122 | {
123 | LARGE_INTEGER liTime, liFreq;
124 | QueryPerformanceFrequency( &liFreq );
125 | QueryPerformanceCounter( &liTime );
126 | val->tv_sec = (long)( liTime.QuadPart / liFreq.QuadPart );
127 | val->tv_usec = (long)( liTime.QuadPart * 1000000.0 / liFreq.QuadPart - val->tv_sec * 1000000.0 );
128 | }
129 | return 0;
130 | }
131 |
132 | #elif defined NGE_UNIX
133 | #include
134 | #endif
135 |
136 | uint32_t nge_get_tick()
137 | {
138 | #if defined NGE_UNIX || defined NGE_WIN
139 | static struct timeval start;
140 | static uint8_t uninited = 1;
141 | uint32_t ticks;
142 | struct timeval now;
143 | if (uninited) {
144 | uninited = 0;
145 | gettimeofday(&start, NULL);
146 | }
147 |
148 | gettimeofday(&now, NULL);
149 | ticks=(now.tv_sec-start.tv_sec)*1000+(now.tv_usec-start.tv_usec)/1000;
150 | return(ticks);
151 | #elif defined NGE_PSP
152 | u64 ticks;
153 | uint32_t tick32;
154 |
155 | if(mTickFrequency == 0)
156 | mTickFrequency = sceRtcGetTickResolution();
157 | sceRtcGetCurrentTick(&ticks);
158 | tick32 = ticks/1000;
159 | return tick32;
160 | #endif
161 | }
162 |
--------------------------------------------------------------------------------
/src/psp/nge_graphics.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nomadalex/libnge2/d8de1a8fba3b7c0d1b98ca4cf9c32333856b485f/src/psp/nge_graphics.c
--------------------------------------------------------------------------------
/src/psp/vram.c:
--------------------------------------------------------------------------------
1 | #include "nge_vram.h"
2 |
3 | #include
4 | #include
5 |
6 | static unsigned int staticOffset = 0;
7 |
8 | static unsigned int getMemorySize(unsigned int width, unsigned int height, unsigned int psm)
9 | {
10 | switch (psm)
11 | {
12 | case GU_PSM_T4:
13 | return (width * height) >> 1;
14 |
15 | case GU_PSM_T8:
16 | return width * height;
17 |
18 | case GU_PSM_5650:
19 | case GU_PSM_5551:
20 | case GU_PSM_4444:
21 | case GU_PSM_T16:
22 | return 2 * width * height;
23 |
24 | case GU_PSM_8888:
25 | case GU_PSM_T32:
26 | return 4 * width * height;
27 |
28 | default:
29 | return 0;
30 | }
31 | }
32 |
33 | unsigned int getStaticVramOffset()
34 | {
35 | return staticOffset;
36 | }
37 |
38 | void* getStaticVramBuffer(unsigned int width, unsigned int height, unsigned int psm)
39 | {
40 | unsigned int memSize = getMemorySize(width,height,psm);
41 | void* result = (void*)staticOffset;
42 | staticOffset += memSize;
43 |
44 | return result;
45 | }
46 |
47 | void* getStaticVramTexture(unsigned int width, unsigned int height, unsigned int psm)
48 | {
49 | void* result = getStaticVramBuffer(width,height,psm);
50 | return (void*)(((unsigned int)result) + ((unsigned int)sceGeEdramGetAddr()));
51 | }
52 |
--------------------------------------------------------------------------------