Compare commits
147 Commits
Daverball/
...
master
Author | SHA1 | Date |
---|---|---|
Amaryllis Kulla | 6a875b30d2 | |
Amaryllis Kulla | 998aa9f846 | |
Amaryllis Kulla | b4c439c6eb | |
Amaryllis Kulla | 380b676777 | |
Amaryllis Kulla | a962c158db | |
Jaiden | cf6403ae65 | |
Ancurio | f138731f7c | |
mara | ac8f4b1594 | |
Jari Vetoniemi | 990843a50b | |
Jari Vetoniemi | 66dc9309db | |
Jonas Kulla | 5c117a55bf | |
Jonas Kulla | cb09036c55 | |
Jonas Kulla | 6903f2ab43 | |
Jonas Kulla | 9dc42914de | |
Jonas Kulla | 86194118a3 | |
Jonas Kulla | 98bdfcf758 | |
Jonas Kulla | 6fa5b8c856 | |
Jonas Kulla | d6b477b887 | |
Jonas Kulla | 9dcfb66e86 | |
Jonas Kulla | d4b9adc1d1 | |
Luis Caceres | 43cb318862 | |
Eliza Velasquez | bab22d87be | |
Jonas Kulla | ae59fcd112 | |
ReinUsesLisp | b5e5a26d8b | |
Jonas Kulla | 9f44ee5068 | |
Jonas Kulla | 183ebbed65 | |
Jonas Kulla | 7902d0942d | |
Jonas Kulla | 947974cac6 | |
Jonas Kulla | 2f81fbbf4b | |
Jonas Kulla | 7d9a85dbbd | |
Carsten Teibes | d427df0c2b | |
Carsten Teibes | b1bdf1e445 | |
Carsten Teibes | fde6a92197 | |
Marty Plummer | 01e17ed5c6 | |
Jonas Kulla | f172f58c74 | |
Jonas Kulla | fba20e6294 | |
Marty Plummer | f5c30affaa | |
Jonas Kulla | bd694f9f99 | |
Jonas Kulla | cab453ac3a | |
Jonas Kulla | 006f701fec | |
Jonas Kulla | 1478e1e0f9 | |
Jonas Kulla | 06feafe9ef | |
Jonas Kulla | e4079d5738 | |
Jonas Kulla | 0481f920b0 | |
Jonas Kulla | 3ea24bd757 | |
Marty Plummer | 60e967e3b7 | |
Jonas Kulla | 0f9b5f274a | |
Jonas Kulla | 6349146e01 | |
Jonas Kulla | c4dd3ffaf6 | |
Jonas Kulla | 55cec53911 | |
Jonas Kulla | 541e24f678 | |
Jonas Kulla | 0ec1fce4ac | |
Jonas Kulla | d4e09f55bd | |
Jonas Kulla | e98c2e0535 | |
Jonas Kulla | fdaf6c3611 | |
Jonas Kulla | 47ef36ca19 | |
Jonas Kulla | de74fc1bc3 | |
Jonas Kulla | 5d776319b5 | |
Jonas Kulla | 53b5b923d4 | |
Mook | 8e411cbcfe | |
Jonas Kulla | 7bf6eca362 | |
Jonas Kulla | 4d97a17c44 | |
Jonas Kulla | 7017ca1c53 | |
Jonas Kulla | 30465691ae | |
Jonas Kulla | dd7545fcf2 | |
Jonas Kulla | 5aaeb0206c | |
Jonas Kulla | 9a3dd2d554 | |
Jonas Kulla | 384249c31a | |
Jonas Kulla | d1ee507ec4 | |
Jonas Kulla | 21247b18b5 | |
cremno | 861d261af2 | |
Jonas Kulla | fe6799d00b | |
Jonas Kulla | fe709b6010 | |
Jonas Kulla | 54c1107f19 | |
Jonas Kulla | 533e69275a | |
Jonas Kulla | e4558c9dfb | |
Jonas Kulla | 5382cc11a3 | |
Jonas Kulla | 1e9e24e45c | |
Jonas Kulla | 9acdd206f6 | |
Jonas Kulla | 6e176a454c | |
Jonas Kulla | afab51279e | |
Jonas Kulla | 61849a9158 | |
Jonas Kulla | 2d31d08fa6 | |
Jonas Kulla | e778dc17c5 | |
Jonas Kulla | 6380a93cec | |
Jonas Kulla | 064b7ac80d | |
Jonas Kulla | d5bacf50f5 | |
Jonas Kulla | e4bc08e972 | |
Jonas Kulla | 88eca58268 | |
Jonas Kulla | e72bced0f7 | |
Jonas Kulla | 794e86d0ab | |
Jonas Kulla | 7260c467b8 | |
Jonas Kulla | 8d7166f3d2 | |
Jonas Kulla | 5379511d95 | |
Jonas Kulla | 91c9bfd0f4 | |
Jonas Kulla | 7393f7e951 | |
Jonas Kulla | 531441d4e3 | |
Jonas Kulla | 0f91bdefea | |
Jonas Kulla | 44eaaf5985 | |
Jonas Kulla | 87462fd7b0 | |
Jonas Kulla | a4b1be1da5 | |
Jonas Kulla | c328ebee04 | |
Jonas Kulla | 713ea07558 | |
Jonas Kulla | b2631d4c23 | |
Jonas Kulla | 4864f63c6c | |
Jonas Kulla | e339964076 | |
Jonas Kulla | 64a3ac3769 | |
Jonas Kulla | fa0459ad93 | |
Jonas Kulla | 74f8c91bf4 | |
Jonas Kulla | 7cbe1eef94 | |
Jonas Kulla | f6604a88b8 | |
Jonas Kulla | c92df0ce3a | |
Jonas Kulla | 7c6a2b2c62 | |
Jonas Kulla | 012d87d05a | |
Jonas Kulla | f1da585f33 | |
Jonas Kulla | a05a3deff6 | |
Jonas Kulla | 6f88ddc51c | |
Jonas Kulla | 7003039e56 | |
Jonas Kulla | 146e0294b4 | |
Jonas Kulla | 4fb94aaf10 | |
Jonas Kulla | 3411435138 | |
Jonas Kulla | c63a8947ce | |
Jonas Kulla | b42725ea20 | |
Jonas Kulla | 9122446b23 | |
Jonas Kulla | 7cbf81c83a | |
Jonas Kulla | b4bca7ea3b | |
Jonas Kulla | 725af97e7b | |
Jonas Kulla | 35077793a0 | |
Jonas Kulla | 5974d05380 | |
Jonas Kulla | 3596fc568d | |
Jonas Kulla | 69795be30b | |
Jonas Kulla | 0a484c8a31 | |
Jonas Kulla | 4560589e25 | |
Jonas Kulla | 4b08d82ea4 | |
Jonas Kulla | 88c41bcc62 | |
Jonas Kulla | a112529f53 | |
Jonas Kulla | b963c67339 | |
Jonas Kulla | ee17bb2137 | |
Jonas Kulla | 3fb4108306 | |
Jonas Kulla | fcfa079e7b | |
Jonas Kulla | 03a6c657c4 | |
Jonas Kulla | b39964a49a | |
Jonas Kulla | 2f95c0613a | |
Jonas Kulla | 373b90af00 | |
Jonas Kulla | 3c0a530eba | |
Jonas Kulla | a53163660f | |
Jonas Kulla | a501e4f22f |
|
@ -0,0 +1,5 @@
|
||||||
|
root=true
|
||||||
|
[*]
|
||||||
|
end_of_line = lf
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
|
@ -110,6 +110,7 @@ set(MAIN_HEADERS
|
||||||
src/flashable.h
|
src/flashable.h
|
||||||
src/font.h
|
src/font.h
|
||||||
src/input.h
|
src/input.h
|
||||||
|
src/iniconfig.h
|
||||||
src/plane.h
|
src/plane.h
|
||||||
src/scene.h
|
src/scene.h
|
||||||
src/sprite.h
|
src/sprite.h
|
||||||
|
@ -167,6 +168,7 @@ set(MAIN_SOURCE
|
||||||
src/filesystem.cpp
|
src/filesystem.cpp
|
||||||
src/font.cpp
|
src/font.cpp
|
||||||
src/input.cpp
|
src/input.cpp
|
||||||
|
src/iniconfig.cpp
|
||||||
src/plane.cpp
|
src/plane.cpp
|
||||||
src/scene.cpp
|
src/scene.cpp
|
||||||
src/sprite.cpp
|
src/sprite.cpp
|
||||||
|
@ -205,21 +207,31 @@ set(MAIN_SOURCE
|
||||||
src/fluid-fun.cpp
|
src/fluid-fun.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
list(APPEND MAIN_HEADERS windows/resource.h)
|
||||||
|
list(APPEND MAIN_SOURCE windows/resource.rc)
|
||||||
|
endif()
|
||||||
|
|
||||||
source_group("MKXP Source" FILES ${MAIN_SOURCE} ${MAIN_HEADERS})
|
source_group("MKXP Source" FILES ${MAIN_SOURCE} ${MAIN_HEADERS})
|
||||||
|
|
||||||
## Setup embedded source ##
|
## Setup embedded source ##
|
||||||
|
|
||||||
set(EMBEDDED_INPUT
|
set(EMBEDDED_INPUT
|
||||||
|
shader/common.h
|
||||||
shader/transSimple.frag
|
shader/transSimple.frag
|
||||||
shader/trans.frag
|
shader/trans.frag
|
||||||
shader/hue.frag
|
shader/hue.frag
|
||||||
shader/sprite.frag
|
shader/sprite.frag
|
||||||
shader/plane.frag
|
shader/plane.frag
|
||||||
|
shader/gray.frag
|
||||||
shader/bitmapBlit.frag
|
shader/bitmapBlit.frag
|
||||||
|
shader/flatColor.frag
|
||||||
shader/simple.frag
|
shader/simple.frag
|
||||||
shader/simpleColor.frag
|
shader/simpleColor.frag
|
||||||
shader/simpleAlpha.frag
|
shader/simpleAlpha.frag
|
||||||
|
shader/simpleAlphaUni.frag
|
||||||
shader/flashMap.frag
|
shader/flashMap.frag
|
||||||
|
shader/minimal.vert
|
||||||
shader/simple.vert
|
shader/simple.vert
|
||||||
shader/simpleColor.vert
|
shader/simpleColor.vert
|
||||||
shader/sprite.vert
|
shader/sprite.vert
|
||||||
|
@ -400,10 +412,12 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||||
)
|
)
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||||
src
|
src
|
||||||
|
windows
|
||||||
${SIGCXX_INCLUDE_DIRS}
|
${SIGCXX_INCLUDE_DIRS}
|
||||||
${PIXMAN_INCLUDE_DIRS}
|
${PIXMAN_INCLUDE_DIRS}
|
||||||
${PHYSFS_INCLUDE_DIRS}
|
${PHYSFS_INCLUDE_DIRS}
|
||||||
${SDL2_INCLUDE_DIRS} # Blindly assume other SDL bits are in same directory
|
${SDL2_INCLUDE_DIRS} # Blindly assume other SDL bits are in same directory
|
||||||
|
${SDL_SOUND_INCLUDE_DIRS}
|
||||||
${Boost_INCLUDE_DIR}
|
${Boost_INCLUDE_DIR}
|
||||||
${MRI_INCLUDE_DIRS}
|
${MRI_INCLUDE_DIRS}
|
||||||
${VORBISFILE_INCLUDE_DIRS}
|
${VORBISFILE_INCLUDE_DIRS}
|
||||||
|
|
27
README.md
27
README.md
|
@ -1,13 +1,19 @@
|
||||||
# mkxp
|
# mkxp
|
||||||
|
|
||||||
|
Discord community: https://discord.gg/A8xHE8P
|
||||||
|
Matrix space: https://matrix.to/#/#rpgmaker:mapleshrine.eu
|
||||||
|
Further links: https://mapleshrine.eu
|
||||||
|
|
||||||
mkxp is a project that seeks to provide a fully open source implementation of the Ruby Game Scripting System (RGSS) interface used in the popular game creation software "RPG Maker XP", "RPG Maker VX" and "RPG Maker VX Ace" (trademark by Enterbrain, Inc.), with focus on Linux. The goal is to be able to run games created with the above software natively without changing a single file.
|
mkxp is a project that seeks to provide a fully open source implementation of the Ruby Game Scripting System (RGSS) interface used in the popular game creation software "RPG Maker XP", "RPG Maker VX" and "RPG Maker VX Ace" (trademark by Enterbrain, Inc.), with focus on Linux. The goal is to be able to run games created with the above software natively without changing a single file.
|
||||||
|
|
||||||
It is licensed under the GNU General Public License v2+.
|
It is licensed under the GNU General Public License v2+.
|
||||||
|
|
||||||
## Prebuilt binaries
|
## Prebuilt binaries
|
||||||
[**Linux (32bit/64bit)**](http://ancurio.bplaced.net/mkxp/generic/)
|
[**Linux / Windows**](https://www.mapleshrine.eu/releases/)
|
||||||
[**OSX**](https://app.box.com/mkxpmacbuilds) by Ali
|
[**OSX**](https://app.box.com/mkxpmacbuilds) by Ali
|
||||||
[**Windows (mingw-w64 32bit)**](http://ancurio.bplaced.net/mkxp/mingw32/)
|
|
||||||
|
## Should I use mkxp
|
||||||
|
mkxp primarily targets technically versed users that are comfortable with Ruby / RGSS, and ideally know how to compile the project themselves. The reason for this is that for most games, due to Win32-API usage, mkxp is simply not a plug-and-play solution, but a building block with which a fully cross-platform version can be created in time.
|
||||||
|
|
||||||
## Bindings
|
## Bindings
|
||||||
Bindings provide the glue code for an interpreted language environment to run game scripts in. Currently there are three bindings:
|
Bindings provide the glue code for an interpreted language environment to run game scripts in. Currently there are three bindings:
|
||||||
|
@ -20,6 +26,8 @@ Matz's Ruby Interpreter, also called CRuby, is the most widely deployed version
|
||||||
For a list of differences, see:
|
For a list of differences, see:
|
||||||
http://stackoverflow.com/questions/21574/what-is-the-difference-between-ruby-1-8-and-ruby-1-9
|
http://stackoverflow.com/questions/21574/what-is-the-difference-between-ruby-1-8-and-ruby-1-9
|
||||||
|
|
||||||
|
This binding supports RGSS1, RGSS2 and RGSS3.
|
||||||
|
|
||||||
### mruby (Lightweight Ruby)
|
### mruby (Lightweight Ruby)
|
||||||
Website: https://github.com/mruby/mruby
|
Website: https://github.com/mruby/mruby
|
||||||
|
|
||||||
|
@ -29,6 +37,8 @@ Due to heavy differences between mruby and MRI as well as lacking modules, runni
|
||||||
|
|
||||||
Some extensions to the standard classes/modules are provided, taking the RPG Maker XP helpfile as a quasi "reference". These include Marshal, File, FileTest and Time.
|
Some extensions to the standard classes/modules are provided, taking the RPG Maker XP helpfile as a quasi "reference". These include Marshal, File, FileTest and Time.
|
||||||
|
|
||||||
|
This binding only supports RGSS1.
|
||||||
|
|
||||||
**Important:** If you decide to use [mattn's oniguruma regexp gem](https://github.com/mattn/mruby-onig-regexp), don't forget to add `-lonig` to the linker flags to avoid ugly symbol overlaps with libc.
|
**Important:** If you decide to use [mattn's oniguruma regexp gem](https://github.com/mattn/mruby-onig-regexp), don't forget to add `-lonig` to the linker flags to avoid ugly symbol overlaps with libc.
|
||||||
|
|
||||||
### null
|
### null
|
||||||
|
@ -44,7 +54,7 @@ This binding only exists for testing purposes and does nothing (the engine quits
|
||||||
* SDL2*
|
* SDL2*
|
||||||
* SDL2_image
|
* SDL2_image
|
||||||
* SDL2_ttf
|
* SDL2_ttf
|
||||||
* SDL_sound (latest hg, apply provided patches!)
|
* [my SDL_sound fork](https://github.com/Ancurio/SDL_sound)
|
||||||
* vorbisfile
|
* vorbisfile
|
||||||
* pixman
|
* pixman
|
||||||
* zlib (only ruby bindings)
|
* zlib (only ruby bindings)
|
||||||
|
@ -77,6 +87,10 @@ These depend on the SDL auxiliary libraries. For maximum RGSS compliance, build
|
||||||
|
|
||||||
To run mkxp, you should have a graphics card capable of at least **OpenGL (ES) 2.0** with an up-to-date driver installed.
|
To run mkxp, you should have a graphics card capable of at least **OpenGL (ES) 2.0** with an up-to-date driver installed.
|
||||||
|
|
||||||
|
## Dependency kit
|
||||||
|
|
||||||
|
To facilitate hacking, I have assembled a package containing all dependencies to compile mkxp on a bare-bones Ubuntu 12.04 64bit installation. Compatibility with other distributions has not been tested. You can download it [here](https://mapleshrine.eu/depkits/linux64.tar.xz). Read the "README" for instructions.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
mkxp reads configuration data from the file "mkxp.conf". The format is ini-style. Do *not* use quotes around file paths (spaces won't break). Lines starting with '#' are comments. See 'mkxp.conf.sample' for a list of accepted entries.
|
mkxp reads configuration data from the file "mkxp.conf". The format is ini-style. Do *not* use quotes around file paths (spaces won't break). Lines starting with '#' are comments. See 'mkxp.conf.sample' for a list of accepted entries.
|
||||||
|
@ -87,13 +101,11 @@ The syntax is: `--<option>=<value>`
|
||||||
|
|
||||||
Example: `./mkxp --gameFolder="my game" --vsync=true --fixedFramerate=60`
|
Example: `./mkxp --gameFolder="my game" --vsync=true --fixedFramerate=60`
|
||||||
|
|
||||||
## Midi music (*ALPHA STATUS*)
|
## Midi music
|
||||||
|
|
||||||
mkxp doesn't come with a soundfont by default, so you will have to supply it yourself (set its path in the config). Playback has been tested and should work reasonably well with all RTP assets.
|
mkxp doesn't come with a soundfont by default, so you will have to supply it yourself (set its path in the config). Playback has been tested and should work reasonably well with all RTP assets.
|
||||||
|
|
||||||
Known issues with midi playback:
|
You can use this public domain soundfont: [GMGSx.sf2](https://mapleshrine.eu/unsorted/GMGSx.sf2)
|
||||||
|
|
||||||
* Some songs' instruments become mute after looping
|
|
||||||
|
|
||||||
## Fonts
|
## Fonts
|
||||||
|
|
||||||
|
@ -103,7 +115,6 @@ If a requested font is not found, no error is generated. Instead, a built-in fon
|
||||||
|
|
||||||
## What doesn't work (yet)
|
## What doesn't work (yet)
|
||||||
|
|
||||||
* Text outline
|
|
||||||
* Movie playback
|
* Movie playback
|
||||||
* wma audio files
|
* wma audio files
|
||||||
* The Win32API ruby class (for obvious reasons)
|
* The Win32API ruby class (for obvious reasons)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -97,6 +97,15 @@ DEF_FADE( me )
|
||||||
|
|
||||||
DEF_PLAY_STOP( se )
|
DEF_PLAY_STOP( se )
|
||||||
|
|
||||||
|
RB_METHOD(audioSetupMidi)
|
||||||
|
{
|
||||||
|
RB_UNUSED_PARAM;
|
||||||
|
|
||||||
|
shState->audio().setupMidi();
|
||||||
|
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
RB_METHOD(audioReset)
|
RB_METHOD(audioReset)
|
||||||
{
|
{
|
||||||
RB_UNUSED_PARAM;
|
RB_UNUSED_PARAM;
|
||||||
|
@ -135,6 +144,8 @@ audioBindingInit()
|
||||||
{
|
{
|
||||||
BIND_POS( bgm );
|
BIND_POS( bgm );
|
||||||
BIND_POS( bgs );
|
BIND_POS( bgs );
|
||||||
|
|
||||||
|
_rb_define_module_function(module, "setup_midi", audioSetupMidi);
|
||||||
}
|
}
|
||||||
|
|
||||||
BIND_PLAY_STOP( se )
|
BIND_PLAY_STOP( se )
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -25,6 +25,7 @@
|
||||||
#include "eventthread.h"
|
#include "eventthread.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "sdl-util.h"
|
||||||
#include "debugwriter.h"
|
#include "debugwriter.h"
|
||||||
#include "graphics.h"
|
#include "graphics.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
|
@ -79,6 +80,7 @@ RB_METHOD(mriP);
|
||||||
RB_METHOD(mkxpDataDirectory);
|
RB_METHOD(mkxpDataDirectory);
|
||||||
RB_METHOD(mkxpPuts);
|
RB_METHOD(mkxpPuts);
|
||||||
RB_METHOD(mkxpRawKeyStates);
|
RB_METHOD(mkxpRawKeyStates);
|
||||||
|
RB_METHOD(mkxpMouseInWindow);
|
||||||
|
|
||||||
RB_METHOD(mriRgssMain);
|
RB_METHOD(mriRgssMain);
|
||||||
RB_METHOD(mriRgssStop);
|
RB_METHOD(mriRgssStop);
|
||||||
|
@ -143,8 +145,18 @@ static void mriBindingInit()
|
||||||
_rb_define_module_function(mod, "data_directory", mkxpDataDirectory);
|
_rb_define_module_function(mod, "data_directory", mkxpDataDirectory);
|
||||||
_rb_define_module_function(mod, "puts", mkxpPuts);
|
_rb_define_module_function(mod, "puts", mkxpPuts);
|
||||||
_rb_define_module_function(mod, "raw_key_states", mkxpRawKeyStates);
|
_rb_define_module_function(mod, "raw_key_states", mkxpRawKeyStates);
|
||||||
|
_rb_define_module_function(mod, "mouse_in_window", mkxpMouseInWindow);
|
||||||
|
|
||||||
|
/* Load global constants */
|
||||||
rb_gv_set("MKXP", Qtrue);
|
rb_gv_set("MKXP", Qtrue);
|
||||||
|
|
||||||
|
VALUE debug = rb_bool_new(shState->config().editor.debug);
|
||||||
|
if (rgssVer == 1)
|
||||||
|
rb_gv_set("DEBUG", debug);
|
||||||
|
else if (rgssVer >= 2)
|
||||||
|
rb_gv_set("TEST", debug);
|
||||||
|
|
||||||
|
rb_gv_set("BTEST", rb_bool_new(shState->config().editor.battleTest));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -193,7 +205,10 @@ RB_METHOD(mkxpDataDirectory)
|
||||||
{
|
{
|
||||||
RB_UNUSED_PARAM;
|
RB_UNUSED_PARAM;
|
||||||
|
|
||||||
return rb_str_new_cstr(shState->config().customDataPath.c_str());
|
const std::string &path = shState->config().customDataPath;
|
||||||
|
const char *s = path.empty() ? "." : path.c_str();
|
||||||
|
|
||||||
|
return rb_str_new_cstr(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
RB_METHOD(mkxpPuts)
|
RB_METHOD(mkxpPuts)
|
||||||
|
@ -218,6 +233,13 @@ RB_METHOD(mkxpRawKeyStates)
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RB_METHOD(mkxpMouseInWindow)
|
||||||
|
{
|
||||||
|
RB_UNUSED_PARAM;
|
||||||
|
|
||||||
|
return rb_bool_new(EventThread::mouseState.inWindow);
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE rgssMainCb(VALUE block)
|
static VALUE rgssMainCb(VALUE block)
|
||||||
{
|
{
|
||||||
rb_funcall2(block, rb_intern("call"), 0, 0);
|
rb_funcall2(block, rb_intern("call"), 0, 0);
|
||||||
|
@ -336,7 +358,7 @@ static void runCustomScript(const std::string &filename)
|
||||||
{
|
{
|
||||||
std::string scriptData;
|
std::string scriptData;
|
||||||
|
|
||||||
if (!readFile(filename.c_str(), scriptData))
|
if (!readFileSDL(filename.c_str(), scriptData))
|
||||||
{
|
{
|
||||||
showMsg(std::string("Unable to open '") + filename + "'");
|
showMsg(std::string("Unable to open '") + filename + "'");
|
||||||
return;
|
return;
|
||||||
|
@ -346,7 +368,7 @@ static void runCustomScript(const std::string &filename)
|
||||||
newStringUTF8(filename.c_str(), filename.size()), NULL);
|
newStringUTF8(filename.c_str(), filename.size()), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE kernelLoadDataInt(const char *filename);
|
VALUE kernelLoadDataInt(const char *filename, bool rubyExc);
|
||||||
|
|
||||||
struct BacktraceData
|
struct BacktraceData
|
||||||
{
|
{
|
||||||
|
@ -373,7 +395,19 @@ static void runRMXPScripts(BacktraceData &btData)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE scriptArray = kernelLoadDataInt(scriptPack.c_str());
|
VALUE scriptArray;
|
||||||
|
|
||||||
|
/* We checked if Scripts.rxdata exists, but something might
|
||||||
|
* still go wrong */
|
||||||
|
try
|
||||||
|
{
|
||||||
|
scriptArray = kernelLoadDataInt(scriptPack.c_str(), false);
|
||||||
|
}
|
||||||
|
catch (const Exception &e)
|
||||||
|
{
|
||||||
|
showMsg(std::string("Failed to read script data: ") + e.msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!RB_TYPE_P(scriptArray, RUBY_T_ARRAY))
|
if (!RB_TYPE_P(scriptArray, RUBY_T_ARRAY))
|
||||||
{
|
{
|
||||||
|
@ -436,8 +470,9 @@ static void runRMXPScripts(BacktraceData &btData)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Execute preloaded scripts */
|
/* Execute preloaded scripts */
|
||||||
for (size_t i = 0; i < conf.preloadScripts.size(); ++i)
|
for (std::set<std::string>::iterator i = conf.preloadScripts.begin();
|
||||||
runCustomScript(conf.preloadScripts[i]);
|
i != conf.preloadScripts.end(); ++i)
|
||||||
|
runCustomScript(*i);
|
||||||
|
|
||||||
VALUE exc = rb_gv_get("$!");
|
VALUE exc = rb_gv_get("$!");
|
||||||
if (exc != Qnil)
|
if (exc != Qnil)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -191,7 +191,7 @@ rb_get_args(int argc, VALUE *argv, const char *format, ...)
|
||||||
if (!RB_TYPE_P(tmp, RUBY_T_STRING))
|
if (!RB_TYPE_P(tmp, RUBY_T_STRING))
|
||||||
rb_raise(rb_eTypeError, "Argument %d: Expected string", argI);
|
rb_raise(rb_eTypeError, "Argument %d: Expected string", argI);
|
||||||
|
|
||||||
*s = StringValueCStr(tmp);
|
*s = RSTRING_PTR(tmp);
|
||||||
++argI;
|
++argI;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -67,7 +67,7 @@ raiseRbExc(const Exception &exc);
|
||||||
|
|
||||||
/* 2.1 has added a new field (flags) to rb_data_type_t */
|
/* 2.1 has added a new field (flags) to rb_data_type_t */
|
||||||
#include <ruby/version.h>
|
#include <ruby/version.h>
|
||||||
#if RUBY_API_VERSION_MINOR > 0
|
#if RUBY_API_VERSION_MAJOR >= 2 && RUBY_API_VERSION_MINOR >= 1
|
||||||
/* TODO: can mkxp use RUBY_TYPED_FREE_IMMEDIATELY here? */
|
/* TODO: can mkxp use RUBY_TYPED_FREE_IMMEDIATELY here? */
|
||||||
#define DEF_TYPE_FLAGS 0
|
#define DEF_TYPE_FLAGS 0
|
||||||
#else
|
#else
|
||||||
|
@ -90,7 +90,12 @@ raiseRbExc(const Exception &exc);
|
||||||
template<rb_data_type_t *rbType>
|
template<rb_data_type_t *rbType>
|
||||||
static VALUE classAllocate(VALUE klass)
|
static VALUE classAllocate(VALUE klass)
|
||||||
{
|
{
|
||||||
|
/* 2.3 has changed the name of this function */
|
||||||
|
#if RUBY_API_VERSION_MAJOR >= 2 && RUBY_API_VERSION_MINOR >= 3
|
||||||
|
return rb_data_typed_object_wrap(klass, 0, rbType);
|
||||||
|
#else
|
||||||
return rb_data_typed_object_alloc(klass, 0, rbType);
|
return rb_data_typed_object_alloc(klass, 0, rbType);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class C>
|
template<class C>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -32,7 +32,7 @@ DEF_TYPE(Bitmap);
|
||||||
static const char *objAsStringPtr(VALUE obj)
|
static const char *objAsStringPtr(VALUE obj)
|
||||||
{
|
{
|
||||||
VALUE str = rb_obj_as_string(obj);
|
VALUE str = rb_obj_as_string(obj);
|
||||||
return StringValueCStr(str);
|
return RSTRING_PTR(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bitmapInitProps(Bitmap *b, VALUE self)
|
void bitmapInitProps(Bitmap *b, VALUE self)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -40,18 +40,22 @@ fileIntFreeInstance(void *inst)
|
||||||
DEF_TYPE_CUSTOMFREE(FileInt, fileIntFreeInstance);
|
DEF_TYPE_CUSTOMFREE(FileInt, fileIntFreeInstance);
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
fileIntForPath(const char *path)
|
fileIntForPath(const char *path, bool rubyExc)
|
||||||
{
|
{
|
||||||
SDL_RWops *ops = SDL_AllocRW();
|
SDL_RWops *ops = SDL_AllocRW();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
shState->fileSystem().openRead(*ops, path);
|
shState->fileSystem().openReadRaw(*ops, path);
|
||||||
}
|
}
|
||||||
catch (const Exception &e)
|
catch (const Exception &e)
|
||||||
{
|
{
|
||||||
SDL_FreeRW(ops);
|
SDL_FreeRW(ops);
|
||||||
raiseRbExc(e);
|
|
||||||
|
if (rubyExc)
|
||||||
|
raiseRbExc(e);
|
||||||
|
else
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE klass = rb_const_get(rb_cObject, rb_intern("FileInt"));
|
VALUE klass = rb_const_get(rb_cObject, rb_intern("FileInt"));
|
||||||
|
@ -119,11 +123,11 @@ RB_METHOD(fileIntBinmode)
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
kernelLoadDataInt(const char *filename)
|
kernelLoadDataInt(const char *filename, bool rubyExc)
|
||||||
{
|
{
|
||||||
rb_gc_start();
|
rb_gc_start();
|
||||||
|
|
||||||
VALUE port = fileIntForPath(filename);
|
VALUE port = fileIntForPath(filename, rubyExc);
|
||||||
|
|
||||||
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
|
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
|
||||||
|
|
||||||
|
@ -142,7 +146,7 @@ RB_METHOD(kernelLoadData)
|
||||||
const char *filename;
|
const char *filename;
|
||||||
rb_get_args(argc, argv, "z", &filename RB_ARG_END);
|
rb_get_args(argc, argv, "z", &filename RB_ARG_END);
|
||||||
|
|
||||||
return kernelLoadDataInt(filename);
|
return kernelLoadDataInt(filename, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
RB_METHOD(kernelSaveData)
|
RB_METHOD(kernelSaveData)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -27,6 +27,29 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
collectStrings(VALUE obj, std::vector<std::string> &out)
|
||||||
|
{
|
||||||
|
if (RB_TYPE_P(obj, RUBY_T_STRING))
|
||||||
|
{
|
||||||
|
out.push_back(RSTRING_PTR(obj));
|
||||||
|
}
|
||||||
|
else if (RB_TYPE_P(obj, RUBY_T_ARRAY))
|
||||||
|
{
|
||||||
|
for (long i = 0; i < RARRAY_LEN(obj); ++i)
|
||||||
|
{
|
||||||
|
VALUE str = rb_ary_entry(obj, i);
|
||||||
|
|
||||||
|
/* Non-string objects are tolerated (ignored) */
|
||||||
|
if (!RB_TYPE_P(str, RUBY_T_STRING))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
out.push_back(RSTRING_PTR(str));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DEF_TYPE(Font);
|
DEF_TYPE(Font);
|
||||||
|
|
||||||
RB_METHOD(fontDoesExist)
|
RB_METHOD(fontDoesExist)
|
||||||
|
@ -48,12 +71,30 @@ RB_METHOD(FontSetName);
|
||||||
|
|
||||||
RB_METHOD(fontInitialize)
|
RB_METHOD(fontInitialize)
|
||||||
{
|
{
|
||||||
VALUE name = Qnil;
|
VALUE namesObj = Qnil;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
rb_get_args(argc, argv, "|oi", &name, &size RB_ARG_END);
|
rb_get_args(argc, argv, "|oi", &namesObj, &size RB_ARG_END);
|
||||||
|
|
||||||
Font *f = new Font(0, size);
|
Font *f;
|
||||||
|
|
||||||
|
if (NIL_P(namesObj))
|
||||||
|
{
|
||||||
|
namesObj = rb_iv_get(rb_obj_class(self), "default_name");
|
||||||
|
f = new Font(0, size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::vector<std::string> names;
|
||||||
|
collectStrings(namesObj, names);
|
||||||
|
|
||||||
|
f = new Font(&names, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This is semantically wrong; the new Font object should take
|
||||||
|
* a dup'ed object here in case of an array. Ditto for the setters.
|
||||||
|
* However the same bug/behavior exists in all RM versions. */
|
||||||
|
rb_iv_set(self, "name", namesObj);
|
||||||
|
|
||||||
setPrivateData(self, f);
|
setPrivateData(self, f);
|
||||||
|
|
||||||
|
@ -65,13 +106,6 @@ RB_METHOD(fontInitialize)
|
||||||
if (rgssVer >= 3)
|
if (rgssVer >= 3)
|
||||||
wrapProperty(self, &f->getOutColor(), "out_color", ColorType);
|
wrapProperty(self, &f->getOutColor(), "out_color", ColorType);
|
||||||
|
|
||||||
if (NIL_P(name))
|
|
||||||
name = rb_iv_get(rb_obj_class(self), "default_name");
|
|
||||||
|
|
||||||
/* Going over the 'name=' function automatically causes
|
|
||||||
* a possbile name array to be re-verified for existing fonts */
|
|
||||||
FontSetName(1, &name, self);
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,57 +139,17 @@ RB_METHOD(FontGetName)
|
||||||
return rb_iv_get(self, "name");
|
return rb_iv_get(self, "name");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
fontSetNameHelper(VALUE self, int argc, VALUE *argv,
|
|
||||||
const char *nameIv, char *outBuf, size_t outLen)
|
|
||||||
{
|
|
||||||
rb_check_argc(argc, 1);
|
|
||||||
|
|
||||||
VALUE arg = argv[0];
|
|
||||||
|
|
||||||
// Fixme: in RGSS3, specifying "" (and only that) as font name results in
|
|
||||||
// no text being drawn (everything else is substituted with Arial I think)
|
|
||||||
strncpy(outBuf, "", outLen);
|
|
||||||
|
|
||||||
if (RB_TYPE_P(arg, RUBY_T_STRING))
|
|
||||||
{
|
|
||||||
strncpy(outBuf, RSTRING_PTR(arg), outLen);
|
|
||||||
}
|
|
||||||
else if (RB_TYPE_P(arg, RUBY_T_ARRAY))
|
|
||||||
{
|
|
||||||
for (long i = 0; i < RARRAY_LEN(arg); ++i)
|
|
||||||
{
|
|
||||||
VALUE str = rb_ary_entry(arg, i);
|
|
||||||
|
|
||||||
/* Non-string objects are tolerated (ignored) */
|
|
||||||
if (!RB_TYPE_P(str, RUBY_T_STRING))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const char *family = RSTRING_PTR(str);
|
|
||||||
|
|
||||||
/* We only set the core Font object's name attribute
|
|
||||||
* to the actually existing font name */
|
|
||||||
if (!shState->fontState().fontPresent(family))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
strncpy(outBuf, family, outLen);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* RMXP doesn't even care if the argument type is
|
|
||||||
* something other than string/array. Whatever... */
|
|
||||||
rb_iv_set(self, nameIv, arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
RB_METHOD(FontSetName)
|
RB_METHOD(FontSetName)
|
||||||
{
|
{
|
||||||
Font *f = getPrivateData<Font>(self);
|
Font *f = getPrivateData<Font>(self);
|
||||||
|
|
||||||
char result[256];
|
rb_check_argc(argc, 1);
|
||||||
fontSetNameHelper(self, argc, argv, "default_name",
|
|
||||||
result, sizeof(result));
|
|
||||||
|
|
||||||
f->setName(result);
|
std::vector<std::string> namesObj;
|
||||||
|
collectStrings(argv[0], namesObj);
|
||||||
|
|
||||||
|
f->setName(namesObj);
|
||||||
|
rb_iv_set(self, "name", argv[0]);
|
||||||
|
|
||||||
return argv[0];
|
return argv[0];
|
||||||
}
|
}
|
||||||
|
@ -223,11 +217,15 @@ RB_METHOD(FontGetDefaultName)
|
||||||
|
|
||||||
RB_METHOD(FontSetDefaultName)
|
RB_METHOD(FontSetDefaultName)
|
||||||
{
|
{
|
||||||
char result[256];
|
RB_UNUSED_PARAM;
|
||||||
fontSetNameHelper(self, argc, argv, "default_name",
|
|
||||||
result, sizeof(result));
|
|
||||||
|
|
||||||
Font::setDefaultName(result);
|
rb_check_argc(argc, 1);
|
||||||
|
|
||||||
|
std::vector<std::string> namesObj;
|
||||||
|
collectStrings(argv[0], namesObj);
|
||||||
|
|
||||||
|
Font::setDefaultName(namesObj, shState->fontState());
|
||||||
|
rb_iv_set(self, "default_name", argv[0]);
|
||||||
|
|
||||||
return argv[0];
|
return argv[0];
|
||||||
}
|
}
|
||||||
|
@ -267,7 +265,24 @@ fontBindingInit()
|
||||||
|
|
||||||
Font::initDefaultDynAttribs();
|
Font::initDefaultDynAttribs();
|
||||||
wrapProperty(klass, &Font::getDefaultColor(), "default_color", ColorType);
|
wrapProperty(klass, &Font::getDefaultColor(), "default_color", ColorType);
|
||||||
rb_iv_set(klass, "default_name", rb_str_new_cstr(Font::getDefaultName()));
|
|
||||||
|
/* Initialize default names */
|
||||||
|
const std::vector<std::string> &defNames = Font::getInitialDefaultNames();
|
||||||
|
VALUE defNamesObj;
|
||||||
|
|
||||||
|
if (defNames.size() == 1)
|
||||||
|
{
|
||||||
|
defNamesObj = rb_str_new_cstr(defNames[0].c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
defNamesObj = rb_ary_new2(defNames.size());
|
||||||
|
|
||||||
|
for (size_t i = 0; i < defNames.size(); ++i)
|
||||||
|
rb_ary_push(defNamesObj, rb_str_new_cstr(defNames[i].c_str()));
|
||||||
|
}
|
||||||
|
|
||||||
|
rb_iv_set(klass, "default_name", defNamesObj);
|
||||||
|
|
||||||
if (rgssVer >= 3)
|
if (rgssVer >= 3)
|
||||||
wrapProperty(klass, &Font::getDefaultOutColor(), "default_out_color", ColorType);
|
wrapProperty(klass, &Font::getDefaultOutColor(), "default_out_color", ColorType);
|
||||||
|
@ -310,14 +325,4 @@ fontBindingInit()
|
||||||
INIT_PROP_BIND(Font, Outline, "outline");
|
INIT_PROP_BIND(Font, Outline, "outline");
|
||||||
INIT_PROP_BIND(Font, OutColor, "out_color");
|
INIT_PROP_BIND(Font, OutColor, "out_color");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rgssVer >= 2)
|
|
||||||
{
|
|
||||||
VALUE defNames = rb_ary_new2(3);
|
|
||||||
rb_ary_push(defNames, rb_str_new2("Verdana"));
|
|
||||||
rb_ary_push(defNames, rb_str_new2("Arial"));
|
|
||||||
rb_ary_push(defNames, rb_str_new2("Courier New"));
|
|
||||||
|
|
||||||
FontSetDefaultName(1, &defNames, klass);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -48,7 +48,7 @@ RB_METHOD(graphicsTransition)
|
||||||
RB_UNUSED_PARAM;
|
RB_UNUSED_PARAM;
|
||||||
|
|
||||||
int duration = 8;
|
int duration = 8;
|
||||||
const char *filename = 0;
|
const char *filename = "";
|
||||||
int vague = 40;
|
int vague = 40;
|
||||||
|
|
||||||
rb_get_args(argc, argv, "|izi", &duration, &filename, &vague RB_ARG_END);
|
rb_get_args(argc, argv, "|izi", &duration, &filename, &vague RB_ARG_END);
|
||||||
|
@ -183,6 +183,18 @@ RB_METHOD(graphicsReset)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RB_METHOD(graphicsPlayMovie)
|
||||||
|
{
|
||||||
|
RB_UNUSED_PARAM;
|
||||||
|
|
||||||
|
const char *filename;
|
||||||
|
rb_get_args(argc, argv, "z", &filename RB_ARG_END);
|
||||||
|
|
||||||
|
shState->graphics().playMovie(filename);
|
||||||
|
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
DEF_GRA_PROP_I(FrameRate)
|
DEF_GRA_PROP_I(FrameRate)
|
||||||
DEF_GRA_PROP_I(FrameCount)
|
DEF_GRA_PROP_I(FrameCount)
|
||||||
DEF_GRA_PROP_I(Brightness)
|
DEF_GRA_PROP_I(Brightness)
|
||||||
|
@ -223,6 +235,11 @@ void graphicsBindingInit()
|
||||||
INIT_GRA_PROP_BIND( Brightness, "brightness" );
|
INIT_GRA_PROP_BIND( Brightness, "brightness" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rgssVer >= 3)
|
||||||
|
{
|
||||||
|
_rb_define_module_function(module, "play_movie", graphicsPlayMovie);
|
||||||
|
}
|
||||||
|
|
||||||
INIT_GRA_PROP_BIND( Fullscreen, "fullscreen" );
|
INIT_GRA_PROP_BIND( Fullscreen, "fullscreen" );
|
||||||
INIT_GRA_PROP_BIND( ShowCursor, "show_cursor" );
|
INIT_GRA_PROP_BIND( ShowCursor, "show_cursor" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -56,6 +56,7 @@ DEF_PROP_I(Sprite, Y)
|
||||||
DEF_PROP_I(Sprite, OX)
|
DEF_PROP_I(Sprite, OX)
|
||||||
DEF_PROP_I(Sprite, OY)
|
DEF_PROP_I(Sprite, OY)
|
||||||
DEF_PROP_I(Sprite, BushDepth)
|
DEF_PROP_I(Sprite, BushDepth)
|
||||||
|
DEF_PROP_I(Sprite, BushOpacity)
|
||||||
DEF_PROP_I(Sprite, Opacity)
|
DEF_PROP_I(Sprite, Opacity)
|
||||||
DEF_PROP_I(Sprite, BlendType)
|
DEF_PROP_I(Sprite, BlendType)
|
||||||
DEF_PROP_I(Sprite, WaveAmp)
|
DEF_PROP_I(Sprite, WaveAmp)
|
||||||
|
@ -126,6 +127,8 @@ spriteBindingInit()
|
||||||
_rb_define_method(klass, "width", spriteWidth);
|
_rb_define_method(klass, "width", spriteWidth);
|
||||||
_rb_define_method(klass, "height", spriteHeight);
|
_rb_define_method(klass, "height", spriteHeight);
|
||||||
|
|
||||||
|
INIT_PROP_BIND( Sprite, BushOpacity, "bush_opacity" );
|
||||||
|
|
||||||
INIT_PROP_BIND( Sprite, WaveAmp, "wave_amp" );
|
INIT_PROP_BIND( Sprite, WaveAmp, "wave_amp" );
|
||||||
INIT_PROP_BIND( Sprite, WaveLength, "wave_length" );
|
INIT_PROP_BIND( Sprite, WaveLength, "wave_length" );
|
||||||
INIT_PROP_BIND( Sprite, WaveSpeed, "wave_speed" );
|
INIT_PROP_BIND( Sprite, WaveSpeed, "wave_speed" );
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2014 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -114,8 +114,17 @@ static void mrbBindingInit(mrb_state *mrb)
|
||||||
/* Load RPG module */
|
/* Load RPG module */
|
||||||
mrb_load_irep(mrb, mrbModuleRPG);
|
mrb_load_irep(mrb, mrbModuleRPG);
|
||||||
|
|
||||||
|
/* Load global constants */
|
||||||
mrb_define_global_const(mrb, "MKXP", mrb_true_value());
|
mrb_define_global_const(mrb, "MKXP", mrb_true_value());
|
||||||
|
|
||||||
|
mrb_value debug = rb_bool_new(shState->config().editor.debug);
|
||||||
|
if (rgssVer == 1)
|
||||||
|
mrb_define_global_const(mrb, "DEBUG", debug);
|
||||||
|
else if (rgssVer >= 2)
|
||||||
|
mrb_define_global_const(mrb, "TEST", debug);
|
||||||
|
|
||||||
|
mrb_define_global_const(mrb, "BTEST", mrb_bool_value(shState->config().editor.battleTest));
|
||||||
|
|
||||||
mrb_gc_arena_restore(mrb, arena);
|
mrb_gc_arena_restore(mrb, arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +275,7 @@ runRMXPScripts(mrb_state *mrb, mrbc_context *ctx)
|
||||||
mrb_state *scriptMrb = mrb_open();
|
mrb_state *scriptMrb = mrb_open();
|
||||||
SDL_RWops ops;
|
SDL_RWops ops;
|
||||||
|
|
||||||
shState->fileSystem().openRead(ops, scriptPack.c_str());
|
shState->fileSystem().openReadRaw(ops, scriptPack.c_str());
|
||||||
|
|
||||||
mrb_value scriptArray = mrb_nil_value();
|
mrb_value scriptArray = mrb_nil_value();
|
||||||
std::string readError;
|
std::string readError;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -45,7 +45,7 @@ MRB_FUNCTION(graphicsFreeze)
|
||||||
MRB_FUNCTION(graphicsTransition)
|
MRB_FUNCTION(graphicsTransition)
|
||||||
{
|
{
|
||||||
mrb_int duration = 8;
|
mrb_int duration = 8;
|
||||||
const char *filename = 0;
|
const char *filename = "";
|
||||||
mrb_int vague = 40;
|
mrb_int vague = 40;
|
||||||
|
|
||||||
mrb_get_args(mrb, "|izi", &duration, &filename, &vague);
|
mrb_get_args(mrb, "|izi", &duration, &filename, &vague);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,4 +1,14 @@
|
||||||
# Lines starting with '#' are comments
|
# Lines starting with '#' are comments.
|
||||||
|
#
|
||||||
|
# About filesystem paths specified in this config:
|
||||||
|
# The "gameFolder" path is resolved either relative
|
||||||
|
# to the directory containing the mkxp executable
|
||||||
|
# (the default behavior), or relative to the current
|
||||||
|
# working directory (when compiled with
|
||||||
|
# -DWORKDIR_CURRENT). All other paths are resolved
|
||||||
|
# relative to gameFolder and ignoring both RTPs and
|
||||||
|
# encrypted archives.
|
||||||
|
|
||||||
|
|
||||||
# Specify the RGSS version to run under.
|
# Specify the RGSS version to run under.
|
||||||
# Possible values are 0, 1, 2, 3. If set to 0,
|
# Possible values are 0, 1, 2, 3. If set to 0,
|
||||||
|
@ -17,6 +27,14 @@
|
||||||
# debugMode=false
|
# debugMode=false
|
||||||
|
|
||||||
|
|
||||||
|
# Continuously print average FPS to console.
|
||||||
|
# This setting does not affect the window title
|
||||||
|
# FPS display toggled via F2
|
||||||
|
# (default: disabled)
|
||||||
|
#
|
||||||
|
# printFPS=false
|
||||||
|
|
||||||
|
|
||||||
# Game window is resizable
|
# Game window is resizable
|
||||||
# (default: disabled)
|
# (default: disabled)
|
||||||
#
|
#
|
||||||
|
@ -39,9 +57,9 @@
|
||||||
|
|
||||||
# Apply linear interpolation when game screen
|
# Apply linear interpolation when game screen
|
||||||
# is upscaled
|
# is upscaled
|
||||||
# (default: disabled)
|
# (default: enabled)
|
||||||
#
|
#
|
||||||
# smoothScaling=false
|
# smoothScaling=true
|
||||||
|
|
||||||
|
|
||||||
# Sync screen redraws to the monitor refresh rate
|
# Sync screen redraws to the monitor refresh rate
|
||||||
|
@ -68,6 +86,12 @@
|
||||||
# defScreenH=480
|
# defScreenH=480
|
||||||
|
|
||||||
|
|
||||||
|
# Override the game window title
|
||||||
|
# (default: none)
|
||||||
|
#
|
||||||
|
# windowTitle=Custom Title
|
||||||
|
|
||||||
|
|
||||||
# Enforce a static frame rate
|
# Enforce a static frame rate
|
||||||
# (0 = disabled)
|
# (0 = disabled)
|
||||||
#
|
#
|
||||||
|
@ -80,12 +104,52 @@
|
||||||
# frameSkip=true
|
# frameSkip=true
|
||||||
|
|
||||||
|
|
||||||
|
# Use a fixed framerate that is approx. equal to the
|
||||||
|
# native screen refresh rate. This is different from
|
||||||
|
# "fixedFramerate" because the actual frame rate is
|
||||||
|
# reported back to the game, ensuring correct timers.
|
||||||
|
# If the screen refresh rate cannot be determined,
|
||||||
|
# this option is force-disabled
|
||||||
|
# (default: disabled)
|
||||||
|
#
|
||||||
|
# syncToRefreshrate=false
|
||||||
|
|
||||||
|
|
||||||
# Don't use alpha blending when rendering text
|
# Don't use alpha blending when rendering text
|
||||||
# (default: disabled)
|
# (default: disabled)
|
||||||
#
|
#
|
||||||
# solidFonts=false
|
# solidFonts=false
|
||||||
|
|
||||||
|
|
||||||
|
# Work around buggy graphics drivers which don't
|
||||||
|
# properly synchronize texture access, most
|
||||||
|
# apparent when text doesn't show up or the map
|
||||||
|
# tileset doesn't render at all
|
||||||
|
# (default: disabled)
|
||||||
|
#
|
||||||
|
# subImageFix=false
|
||||||
|
|
||||||
|
|
||||||
|
# Enable framebuffer blitting if the driver is
|
||||||
|
# capable of it. Some drivers carry buggy
|
||||||
|
# implementations of this functionality, so
|
||||||
|
# disabling it can be used as a workaround
|
||||||
|
# (default: enabled)
|
||||||
|
#
|
||||||
|
# enableBlitting=true
|
||||||
|
|
||||||
|
|
||||||
|
# Limit the maximum size (width, height) of
|
||||||
|
# most textures mkxp will create (exceptions are
|
||||||
|
# rendering backbuffers and similar).
|
||||||
|
# If set to 0, the hardware maximum is used.
|
||||||
|
# This is useful for recording traces that can
|
||||||
|
# be played back on machines with lower specs.
|
||||||
|
# (default: 0)
|
||||||
|
#
|
||||||
|
# maxTextureSize=0
|
||||||
|
|
||||||
|
|
||||||
# Set the base path of the game to '/path/to/game'
|
# Set the base path of the game to '/path/to/game'
|
||||||
# (default: executable directory)
|
# (default: executable directory)
|
||||||
#
|
#
|
||||||
|
@ -218,6 +282,19 @@
|
||||||
# SE.sourceCount=6
|
# SE.sourceCount=6
|
||||||
|
|
||||||
|
|
||||||
|
# The Windows game executable name minus ".exe". By default
|
||||||
|
# this is "Game", but some developers manually rename it.
|
||||||
|
# mkxp needs this name because both the .ini (game
|
||||||
|
# configuration) and .rgssad (encrypted data archive) must
|
||||||
|
# carry the same name minus their extension, and we cannot
|
||||||
|
# guess the executable's name.
|
||||||
|
# You could just as well rename them both to "Game.ini" and
|
||||||
|
# "Game.rgssad", but specifying the executable name here
|
||||||
|
# is a tiny bit less intrusive.
|
||||||
|
#
|
||||||
|
# execName=Game
|
||||||
|
|
||||||
|
|
||||||
# Give a hint on which language the game title as
|
# Give a hint on which language the game title as
|
||||||
# specified in the Game.ini is, useful if the encoding
|
# specified in the Game.ini is, useful if the encoding
|
||||||
# is being falsely detected. Relevant only if mkxp was
|
# is being falsely detected. Relevant only if mkxp was
|
||||||
|
|
11
mkxp.pro
11
mkxp.pro
|
@ -8,6 +8,10 @@ INCLUDEPATH += . src
|
||||||
|
|
||||||
CONFIG(release, debug|release): DEFINES += NDEBUG
|
CONFIG(release, debug|release): DEFINES += NDEBUG
|
||||||
|
|
||||||
|
CONFIG += c++11
|
||||||
|
# And for older qmake versions..
|
||||||
|
QMAKE_CXXFLAGS += -std=c++11
|
||||||
|
|
||||||
isEmpty(BINDING) {
|
isEmpty(BINDING) {
|
||||||
BINDING = MRI
|
BINDING = MRI
|
||||||
}
|
}
|
||||||
|
@ -89,6 +93,7 @@ HEADERS += \
|
||||||
src/flashable.h \
|
src/flashable.h \
|
||||||
src/font.h \
|
src/font.h \
|
||||||
src/input.h \
|
src/input.h \
|
||||||
|
src/iniconfig.h \
|
||||||
src/plane.h \
|
src/plane.h \
|
||||||
src/scene.h \
|
src/scene.h \
|
||||||
src/sprite.h \
|
src/sprite.h \
|
||||||
|
@ -145,6 +150,7 @@ SOURCES += \
|
||||||
src/filesystem.cpp \
|
src/filesystem.cpp \
|
||||||
src/font.cpp \
|
src/font.cpp \
|
||||||
src/input.cpp \
|
src/input.cpp \
|
||||||
|
src/iniconfig.cpp \
|
||||||
src/plane.cpp \
|
src/plane.cpp \
|
||||||
src/scene.cpp \
|
src/scene.cpp \
|
||||||
src/sprite.cpp \
|
src/sprite.cpp \
|
||||||
|
@ -183,16 +189,21 @@ SOURCES += \
|
||||||
src/fluid-fun.cpp
|
src/fluid-fun.cpp
|
||||||
|
|
||||||
EMBED = \
|
EMBED = \
|
||||||
|
shader/common.h \
|
||||||
shader/transSimple.frag \
|
shader/transSimple.frag \
|
||||||
shader/trans.frag \
|
shader/trans.frag \
|
||||||
shader/hue.frag \
|
shader/hue.frag \
|
||||||
shader/sprite.frag \
|
shader/sprite.frag \
|
||||||
shader/plane.frag \
|
shader/plane.frag \
|
||||||
|
shader/gray.frag \
|
||||||
shader/bitmapBlit.frag \
|
shader/bitmapBlit.frag \
|
||||||
|
shader/flatColor.frag \
|
||||||
shader/simple.frag \
|
shader/simple.frag \
|
||||||
shader/simpleColor.frag \
|
shader/simpleColor.frag \
|
||||||
shader/simpleAlpha.frag \
|
shader/simpleAlpha.frag \
|
||||||
|
shader/simpleAlphaUni.frag \
|
||||||
shader/flashMap.frag \
|
shader/flashMap.frag \
|
||||||
|
shader/minimal.vert \
|
||||||
shader/simple.vert \
|
shader/simple.vert \
|
||||||
shader/simpleColor.vert \
|
shader/simpleColor.vert \
|
||||||
shader/sprite.vert \
|
shader/sprite.vert \
|
||||||
|
|
|
@ -1,365 +0,0 @@
|
||||||
diff -r 719dade41745 decoders/wav.c
|
|
||||||
--- a/decoders/wav.c Wed Aug 15 23:52:18 2012 -0400
|
|
||||||
+++ b/decoders/wav.c Fri Sep 12 06:50:35 2014 +0200
|
|
||||||
@@ -113,8 +113,9 @@
|
|
||||||
|
|
||||||
#define fmtID 0x20746D66 /* "fmt ", in ascii. */
|
|
||||||
|
|
||||||
-#define FMT_NORMAL 0x0001 /* Uncompressed waveform data. */
|
|
||||||
-#define FMT_ADPCM 0x0002 /* ADPCM compressed waveform data. */
|
|
||||||
+#define FMT_NORMAL 0x0001 /* Uncompressed waveform data. */
|
|
||||||
+#define FMT_ADPCM 0x0002 /* ADPCM compressed waveform data. */
|
|
||||||
+#define FMT_IMA 0x0011 /* IMA ADPCM compressed waveform data. */
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
@@ -130,6 +131,12 @@
|
|
||||||
Sint16 iSamp2;
|
|
||||||
} ADPCMBLOCKHEADER;
|
|
||||||
|
|
||||||
+typedef struct
|
|
||||||
+{
|
|
||||||
+ Sint16 iPrevSamp;
|
|
||||||
+ Uint8 iStepIndex;
|
|
||||||
+} IMAADPCMDATA;
|
|
||||||
+
|
|
||||||
typedef struct S_WAV_FMT_T
|
|
||||||
{
|
|
||||||
Uint32 chunkID;
|
|
||||||
@@ -166,6 +173,25 @@
|
|
||||||
Sint8 nibble;
|
|
||||||
} adpcm;
|
|
||||||
|
|
||||||
+ struct
|
|
||||||
+ {
|
|
||||||
+ /* per channel decoder state */
|
|
||||||
+ IMAADPCMDATA *d;
|
|
||||||
+ /* auxiliary buffer */
|
|
||||||
+ Uint8 *buf;
|
|
||||||
+
|
|
||||||
+ Uint16 block_frames;
|
|
||||||
+ Uint16 block_framesets;
|
|
||||||
+ Uint16 enc_frameset_size;
|
|
||||||
+ Uint16 headerset_size;
|
|
||||||
+ Uint16 dec_frame_size;
|
|
||||||
+ Uint16 dec_frameset_size;
|
|
||||||
+ Uint16 rem_block_framesets;
|
|
||||||
+
|
|
||||||
+ /* whether the next word(s) are the start of a new block */
|
|
||||||
+ int read_header;
|
|
||||||
+ } ima;
|
|
||||||
+
|
|
||||||
/* put other format-specific data here... */
|
|
||||||
} fmt;
|
|
||||||
} fmt_t;
|
|
||||||
@@ -614,6 +640,296 @@
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
+ * IMA ADPCM compression handler... *
|
|
||||||
+ *****************************************************************************/
|
|
||||||
+
|
|
||||||
+static const int ima_index_table[16] =
|
|
||||||
+{
|
|
||||||
+ -1, -1, -1, -1, 2, 4, 6, 8,
|
|
||||||
+ -1, -1, -1, -1, 2, 4, 6, 8
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static const int ima_step_table[89] =
|
|
||||||
+{
|
|
||||||
+ 7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
|
|
||||||
+ 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
|
|
||||||
+ 50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
|
|
||||||
+ 130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
|
|
||||||
+ 337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
|
|
||||||
+ 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
|
|
||||||
+ 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
|
|
||||||
+ 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
|
|
||||||
+ 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+/* 1 frameset = 4 bytes (per channel) = 8 nibbles = 8 frames */
|
|
||||||
+#define FRAMESET_FRAMES 8
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+static int read_ima_block_headers(SDL_RWops *rw, IMAADPCMDATA *d,
|
|
||||||
+ Uint16 chan_count, Sint16 *out)
|
|
||||||
+{
|
|
||||||
+ Uint16 i;
|
|
||||||
+ Uint8 dummy;
|
|
||||||
+
|
|
||||||
+ for (i = 0; i < chan_count; i++)
|
|
||||||
+ {
|
|
||||||
+ BAIL_IF_MACRO(!read_le16(rw, &d[i].iPrevSamp), NULL, 0);
|
|
||||||
+ BAIL_IF_MACRO(!read_uint8(rw, &d[i].iStepIndex), NULL, 0);
|
|
||||||
+ BAIL_IF_MACRO(!read_uint8(rw, &dummy), NULL, 0);
|
|
||||||
+
|
|
||||||
+ out[i] = d[i].iPrevSamp;
|
|
||||||
+ } /* for */
|
|
||||||
+
|
|
||||||
+ return(1);
|
|
||||||
+} /* read_ima_block_headers */
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+static Sint16 decode_ima_nibble(Uint8 nibble, IMAADPCMDATA *state)
|
|
||||||
+{
|
|
||||||
+ int step = ima_step_table[state->iStepIndex];
|
|
||||||
+ int diff = 0;
|
|
||||||
+ int samp, index;
|
|
||||||
+
|
|
||||||
+ if (nibble & 0x4)
|
|
||||||
+ diff += step >> 0;
|
|
||||||
+ if (nibble & 0x2)
|
|
||||||
+ diff += step >> 1;
|
|
||||||
+ if (nibble & 0x1)
|
|
||||||
+ diff += step >> 2;
|
|
||||||
+
|
|
||||||
+ diff += step >> 3;
|
|
||||||
+
|
|
||||||
+ if (nibble & 0x8)
|
|
||||||
+ diff = -diff;
|
|
||||||
+
|
|
||||||
+ samp = state->iPrevSamp + diff;
|
|
||||||
+ samp = SDL_max(SDL_min(samp, 32767), -32768);
|
|
||||||
+ state->iPrevSamp = samp;
|
|
||||||
+
|
|
||||||
+ index = state->iStepIndex + ima_index_table[nibble];
|
|
||||||
+ state->iStepIndex = SDL_max(SDL_min(index, 88), 0);
|
|
||||||
+
|
|
||||||
+ return samp;
|
|
||||||
+} /* decode_ima_nibble */
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+static int read_ima_frameset(SDL_RWops *rw, wav_t *wav, Sint16 *out)
|
|
||||||
+{
|
|
||||||
+ fmt_t *fmt = wav->fmt;
|
|
||||||
+ Uint16 i, j;
|
|
||||||
+ Uint8 *fs_buf = fmt->fmt.ima.buf;
|
|
||||||
+ Uint32 fs_buf_size = fmt->fmt.ima.enc_frameset_size;
|
|
||||||
+ Uint16 chan_count = fmt->wChannels;
|
|
||||||
+ IMAADPCMDATA *data = fmt->fmt.ima.d;
|
|
||||||
+
|
|
||||||
+ /* read encoded frameset into temp buffer */
|
|
||||||
+ BAIL_IF_MACRO(!SDL_RWread(rw, fs_buf, fs_buf_size, 1), NULL, 0);
|
|
||||||
+
|
|
||||||
+ for (i = 0; i < chan_count; i++)
|
|
||||||
+ {
|
|
||||||
+ for (j = 0; j < 4; j++)
|
|
||||||
+ {
|
|
||||||
+ Uint8 byte = fs_buf[i*4+j];
|
|
||||||
+ Sint16 *_out = out + j*chan_count*2+i;
|
|
||||||
+
|
|
||||||
+ /* low nibble */
|
|
||||||
+ *_out = decode_ima_nibble(byte & 0xF, &data[i]);
|
|
||||||
+
|
|
||||||
+ _out += chan_count;
|
|
||||||
+
|
|
||||||
+ /* high nibble */
|
|
||||||
+ *_out = decode_ima_nibble(byte >> 4, &data[i]);
|
|
||||||
+ }
|
|
||||||
+ } /* for */
|
|
||||||
+
|
|
||||||
+ return(1);
|
|
||||||
+} /* read_ima_frameset */
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+static Uint32 read_sample_fmt_ima(Sound_Sample *sample)
|
|
||||||
+{
|
|
||||||
+ Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
|
||||||
+ wav_t *w = (wav_t *) internal->decoder_private;
|
|
||||||
+ fmt_t *fmt = w->fmt;
|
|
||||||
+ void *const out_buf = internal->buffer;
|
|
||||||
+ Uint32 bw = 0;
|
|
||||||
+ int rc;
|
|
||||||
+
|
|
||||||
+ while (1)
|
|
||||||
+ {
|
|
||||||
+ if (fmt->fmt.ima.read_header)
|
|
||||||
+ {
|
|
||||||
+ if (w->bytesLeft < fmt->fmt.ima.headerset_size)
|
|
||||||
+ {
|
|
||||||
+ sample->flags |= SOUND_SAMPLEFLAG_EOF;
|
|
||||||
+ break;
|
|
||||||
+ } /* if */
|
|
||||||
+
|
|
||||||
+ if (bw+fmt->fmt.ima.dec_frame_size > internal->buffer_size)
|
|
||||||
+ break;
|
|
||||||
+
|
|
||||||
+ rc = read_ima_block_headers(internal->rw, fmt->fmt.ima.d,
|
|
||||||
+ fmt->wChannels, (Sint16*) (out_buf+bw));
|
|
||||||
+
|
|
||||||
+ if (!rc)
|
|
||||||
+ {
|
|
||||||
+ sample->flags |= SOUND_SAMPLEFLAG_ERROR;
|
|
||||||
+ return 0;
|
|
||||||
+ } /* if */
|
|
||||||
+
|
|
||||||
+ w->bytesLeft -= fmt->fmt.ima.headerset_size;
|
|
||||||
+ bw += fmt->fmt.ima.dec_frame_size;
|
|
||||||
+
|
|
||||||
+ fmt->fmt.ima.read_header = 0;
|
|
||||||
+ fmt->fmt.ima.rem_block_framesets = fmt->fmt.ima.block_framesets;
|
|
||||||
+ } /* if */
|
|
||||||
+
|
|
||||||
+ if (w->bytesLeft < fmt->fmt.ima.enc_frameset_size)
|
|
||||||
+ {
|
|
||||||
+ sample->flags |= SOUND_SAMPLEFLAG_EOF;
|
|
||||||
+ break;
|
|
||||||
+ } /* if */
|
|
||||||
+
|
|
||||||
+ if (bw+fmt->fmt.ima.dec_frameset_size > internal->buffer_size)
|
|
||||||
+ break;
|
|
||||||
+
|
|
||||||
+ rc = read_ima_frameset(internal->rw, w, (Sint16*) (out_buf+bw));
|
|
||||||
+
|
|
||||||
+ if (!rc)
|
|
||||||
+ {
|
|
||||||
+ sample->flags |= SOUND_SAMPLEFLAG_ERROR;
|
|
||||||
+ return 0;
|
|
||||||
+ } /* if */
|
|
||||||
+
|
|
||||||
+ bw += fmt->fmt.ima.dec_frameset_size;
|
|
||||||
+ w->bytesLeft -= fmt->fmt.ima.enc_frameset_size;
|
|
||||||
+
|
|
||||||
+ if (--fmt->fmt.ima.rem_block_framesets == 0)
|
|
||||||
+ fmt->fmt.ima.read_header = 1;
|
|
||||||
+ } /* while */
|
|
||||||
+
|
|
||||||
+ return(bw);
|
|
||||||
+} /* read_sample_fmt_ima */
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+static void free_fmt_ima(fmt_t *fmt)
|
|
||||||
+{
|
|
||||||
+ free(fmt->fmt.ima.d);
|
|
||||||
+ free(fmt->fmt.ima.buf);
|
|
||||||
+} /* free_fmt_ima */
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+static int rewind_sample_fmt_ima(Sound_Sample *sample)
|
|
||||||
+{
|
|
||||||
+ Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
|
||||||
+ wav_t *w = (wav_t *) internal->decoder_private;
|
|
||||||
+ fmt_t *fmt = w->fmt;
|
|
||||||
+
|
|
||||||
+ fmt->fmt.ima.read_header = 1;
|
|
||||||
+
|
|
||||||
+ return(1);
|
|
||||||
+} /* rewind_sample_fmt_ima */
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+static int seek_sample_fmt_ima(Sound_Sample *sample, Uint32 ms)
|
|
||||||
+{
|
|
||||||
+ Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
|
||||||
+ wav_t *w = (wav_t *) internal->decoder_private;
|
|
||||||
+ fmt_t *fmt = w->fmt;
|
|
||||||
+ Sint16 *dummy_buf = (Sint16*) (fmt->fmt.ima.buf +
|
|
||||||
+ fmt->fmt.ima.enc_frameset_size);
|
|
||||||
+ Uint32 i;
|
|
||||||
+ int rc, pos;
|
|
||||||
+
|
|
||||||
+ Uint32 seek_frames = (fmt->dwSamplesPerSec * ms) / 1000;
|
|
||||||
+ Uint32 seek_blocks = seek_frames / fmt->fmt.ima.block_frames;
|
|
||||||
+ Uint32 seek_framesets;
|
|
||||||
+ seek_frames %= fmt->fmt.ima.block_frames;
|
|
||||||
+
|
|
||||||
+ w->bytesLeft = fmt->total_bytes;
|
|
||||||
+ pos = seek_blocks * fmt->wBlockAlign + fmt->data_starting_offset;
|
|
||||||
+ rc = SDL_RWseek(internal->rw, pos, SEEK_SET);
|
|
||||||
+ BAIL_IF_MACRO(rc != pos, ERR_IO_ERROR, 0);
|
|
||||||
+ w->bytesLeft -= seek_blocks * fmt->wBlockAlign;
|
|
||||||
+
|
|
||||||
+ fmt->fmt.ima.read_header = 0;
|
|
||||||
+
|
|
||||||
+ if (seek_frames == 0)
|
|
||||||
+ {
|
|
||||||
+ fmt->fmt.ima.read_header = 1;
|
|
||||||
+ return(1);
|
|
||||||
+ } /* if */
|
|
||||||
+
|
|
||||||
+ rc = read_ima_block_headers(internal->rw, fmt->fmt.ima.d,
|
|
||||||
+ fmt->wChannels, dummy_buf);
|
|
||||||
+ BAIL_IF_MACRO(!rc, NULL, 0);
|
|
||||||
+ w->bytesLeft -= fmt->fmt.ima.headerset_size;
|
|
||||||
+
|
|
||||||
+ if (w->bytesLeft < fmt->fmt.ima.headerset_size)
|
|
||||||
+ {
|
|
||||||
+ sample->flags |= SOUND_SAMPLEFLAG_EOF;
|
|
||||||
+ return(1);
|
|
||||||
+ } /* if */
|
|
||||||
+
|
|
||||||
+ seek_frames -= 1;
|
|
||||||
+ seek_framesets = seek_frames / FRAMESET_FRAMES;
|
|
||||||
+
|
|
||||||
+ for (i = 0; i < seek_framesets; i++)
|
|
||||||
+ {
|
|
||||||
+ rc = read_ima_frameset(internal->rw, w, dummy_buf);
|
|
||||||
+ BAIL_IF_MACRO(!rc, NULL, 0);
|
|
||||||
+ w->bytesLeft -= fmt->fmt.ima.enc_frameset_size;
|
|
||||||
+ } /* for */
|
|
||||||
+
|
|
||||||
+ fmt->fmt.ima.rem_block_framesets =
|
|
||||||
+ fmt->fmt.ima.block_framesets - seek_framesets;
|
|
||||||
+
|
|
||||||
+ if (w->bytesLeft < fmt->fmt.ima.enc_frameset_size)
|
|
||||||
+ sample->flags |= SOUND_SAMPLEFLAG_EOF;
|
|
||||||
+
|
|
||||||
+ return(1); /* success. */
|
|
||||||
+} /* seek_sample_fmt_ima */
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+static int read_fmt_ima(SDL_RWops *rw, fmt_t *fmt)
|
|
||||||
+{
|
|
||||||
+ Uint16 chan = fmt->wChannels;
|
|
||||||
+ Sint16 extraBytes;
|
|
||||||
+ int rc;
|
|
||||||
+
|
|
||||||
+ /* setup function pointers */
|
|
||||||
+ fmt->free = free_fmt_ima;
|
|
||||||
+ fmt->read_sample = read_sample_fmt_ima;
|
|
||||||
+ fmt->rewind_sample = rewind_sample_fmt_ima;
|
|
||||||
+ fmt->seek_sample = seek_sample_fmt_ima;
|
|
||||||
+
|
|
||||||
+ BAIL_IF_MACRO(!read_le16(rw, &extraBytes), NULL, 0);
|
|
||||||
+ BAIL_IF_MACRO(!read_le16(rw, &fmt->fmt.ima.block_frames), NULL, 0);
|
|
||||||
+
|
|
||||||
+ /* skip to end of fmt chunk */
|
|
||||||
+ rc = SDL_RWseek(rw, extraBytes-2, SEEK_CUR);
|
|
||||||
+ BAIL_IF_MACRO(!rc, NULL, 0);
|
|
||||||
+
|
|
||||||
+ fmt->fmt.ima.block_framesets = (fmt->fmt.ima.block_frames-1) / FRAMESET_FRAMES;
|
|
||||||
+ fmt->fmt.ima.enc_frameset_size = 4 * chan;
|
|
||||||
+ fmt->fmt.ima.headerset_size = 4 * chan;
|
|
||||||
+ fmt->fmt.ima.dec_frame_size = sizeof(Uint16) * chan;
|
|
||||||
+ fmt->fmt.ima.dec_frameset_size = fmt->fmt.ima.dec_frame_size * FRAMESET_FRAMES;
|
|
||||||
+ fmt->fmt.ima.read_header = 1;
|
|
||||||
+
|
|
||||||
+ fmt->fmt.ima.d = malloc(sizeof(IMAADPCMDATA) * chan);
|
|
||||||
+
|
|
||||||
+ size_t buf_size = fmt->fmt.ima.enc_frameset_size +
|
|
||||||
+ fmt->fmt.ima.dec_frameset_size;
|
|
||||||
+ fmt->fmt.ima.buf = malloc(buf_size);
|
|
||||||
+
|
|
||||||
+ return(1);
|
|
||||||
+} /* read_fmt_ima */
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+/*****************************************************************************
|
|
||||||
* Everything else... *
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
@@ -642,6 +958,13 @@
|
|
||||||
SNDDBG(("WAV: Appears to be ADPCM compressed audio.\n"));
|
|
||||||
return(read_fmt_adpcm(rw, fmt));
|
|
||||||
|
|
||||||
+ case FMT_IMA:
|
|
||||||
+ if (fmt->wBitsPerSample == 4)
|
|
||||||
+ {
|
|
||||||
+ SNDDBG(("WAV: Appears to be 4bit IMA ADPCM compressed audio.\n"));
|
|
||||||
+ return(read_fmt_ima(rw, fmt));
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
/* add other types here. */
|
|
||||||
|
|
||||||
default:
|
|
|
@ -1,54 +0,0 @@
|
||||||
diff -r 719dade41745 Makefile.am
|
|
||||||
--- a/Makefile.am Wed Aug 15 23:52:18 2012 -0400
|
|
||||||
+++ b/Makefile.am Thu Nov 28 18:42:40 2013 +0100
|
|
||||||
@@ -1,8 +1,8 @@
|
|
||||||
lib_LTLIBRARIES = libSDL_sound.la
|
|
||||||
|
|
||||||
-SUBDIRS = decoders . playsound
|
|
||||||
+SUBDIRS = decoders .
|
|
||||||
|
|
||||||
-libSDL_soundincludedir = $(includedir)/SDL
|
|
||||||
+libSDL_soundincludedir = $(includedir)/SDL2
|
|
||||||
libSDL_soundinclude_HEADERS = \
|
|
||||||
SDL_sound.h
|
|
||||||
|
|
||||||
@@ -49,3 +49,5 @@
|
|
||||||
echo >> $(distdir)/docs/README
|
|
||||||
rm -rf `find $(distdir) -type d -name ".svn"`
|
|
||||||
|
|
||||||
+pkgconfigdir = $(libdir)/pkgconfig
|
|
||||||
+pkgconfig_DATA = SDL_sound.pc
|
|
||||||
diff -r 719dade41745 SDL_sound.pc.in
|
|
||||||
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
|
||||||
+++ b/SDL_sound.pc.in Thu Nov 28 18:42:40 2013 +0100
|
|
||||||
@@ -0,0 +1,11 @@
|
|
||||||
+prefix=@prefix@
|
|
||||||
+exec_prefix=@exec_prefix@
|
|
||||||
+libdir=@libdir@
|
|
||||||
+includedir=@includedir@
|
|
||||||
+
|
|
||||||
+Name: SDL_sound
|
|
||||||
+Description: audio decoding library for Simple DirectMedia Layer
|
|
||||||
+Version: @VERSION@
|
|
||||||
+Requires: sdl2 >= @SDL_VERSION@
|
|
||||||
+Libs: -L${libdir} -lSDL_sound
|
|
||||||
+Cflags: -I${includedir}/SDL2
|
|
||||||
diff -r 719dade41745 configure.in
|
|
||||||
--- a/configure.in Wed Aug 15 23:52:18 2012 -0400
|
|
||||||
+++ b/configure.in Thu Nov 28 18:42:40 2013 +0100
|
|
||||||
@@ -107,7 +107,8 @@
|
|
||||||
dnl ---------------------------------------------------------------------
|
|
||||||
|
|
||||||
dnl Check for SDL
|
|
||||||
-SDL_VERSION=1.2.0
|
|
||||||
+SDL_VERSION=2.0.0
|
|
||||||
+AC_SUBST(SDL_VERSION)
|
|
||||||
AM_PATH_SDL($SDL_VERSION,
|
|
||||||
:,
|
|
||||||
AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
|
|
||||||
@@ -339,4 +340,5 @@
|
|
||||||
decoders/timidity/Makefile
|
|
||||||
decoders/libmpg123/Makefile
|
|
||||||
playsound/Makefile
|
|
||||||
+SDL_sound.pc
|
|
||||||
])
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
--- a/common.mk
|
||||||
|
+++ b/common.mk
|
||||||
|
@@ -95,6 +95,7 @@ COMMONOBJS = array.$(OBJEXT) \
|
||||||
|
vm_trace.$(OBJEXT) \
|
||||||
|
thread.$(OBJEXT) \
|
||||||
|
cont.$(OBJEXT) \
|
||||||
|
+ ext/zlib/zlib.$(OBJEXT) \
|
||||||
|
$(BUILTIN_ENCOBJS) \
|
||||||
|
$(BUILTIN_TRANSOBJS) \
|
||||||
|
$(MISSING)
|
||||||
|
diff --git a/ruby-2.1.5.orig/configure b/ruby-2.1.5/configure
|
||||||
|
index d0f1f68..45ab642 100755
|
||||||
|
--- a/configure
|
||||||
|
+++ b/configure
|
||||||
|
@@ -2838,6 +2838,8 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
+LIBS="$LIBS -lz"
|
||||||
|
+
|
||||||
|
{ # environment section
|
||||||
|
|
||||||
|
|
||||||
|
--- a/configure.in
|
||||||
|
+++ b/configure.in
|
||||||
|
@@ -31,6 +31,8 @@ rm() {
|
||||||
|
}
|
||||||
|
])])])
|
||||||
|
|
||||||
|
+LIBS="$LIBS -lz"
|
||||||
|
+
|
||||||
|
{ # environment section
|
||||||
|
|
||||||
|
AC_ARG_WITH(baseruby,
|
||||||
|
--- a/inits.c
|
||||||
|
+++ b/inits.c
|
||||||
|
@@ -61,5 +61,6 @@ rb_call_inits(void)
|
||||||
|
CALL(Complex);
|
||||||
|
CALL(version);
|
||||||
|
CALL(vm_trace);
|
||||||
|
+ CALL(zlib);
|
||||||
|
}
|
||||||
|
#undef CALL
|
|
@ -6,7 +6,7 @@ uniform sampler2D destination;
|
||||||
|
|
||||||
uniform vec4 subRect;
|
uniform vec4 subRect;
|
||||||
|
|
||||||
uniform float opacity;
|
uniform lowp float opacity;
|
||||||
|
|
||||||
varying vec2 v_texCoord;
|
varying vec2 v_texCoord;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ varying vec2 v_blurCoord[2];
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 frag = vec4(0, 0, 0, 0);
|
lowp vec4 frag = vec4(0, 0, 0, 0);
|
||||||
|
|
||||||
frag += texture2D(texture, v_texCoord);
|
frag += texture2D(texture, v_texCoord);
|
||||||
frag += texture2D(texture, v_blurCoord[0]);
|
frag += texture2D(texture, v_blurCoord[0]);
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
#ifdef GLSLES
|
||||||
|
|
||||||
|
#ifdef FRAGMENT_SHADER
|
||||||
|
/* Only the fragment shader has no default float precision */
|
||||||
|
precision mediump float;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Desktop GLSL doesn't know about these */
|
||||||
|
#define highp
|
||||||
|
#define mediump
|
||||||
|
#define lowp
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
uniform float alpha;
|
uniform lowp float alpha;
|
||||||
|
|
||||||
varying vec4 v_color;
|
varying lowp vec4 v_color;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
uniform lowp vec4 color;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragColor = color;
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
|
||||||
|
uniform sampler2D texture;
|
||||||
|
uniform lowp float gray;
|
||||||
|
|
||||||
|
varying vec2 v_texCoord;
|
||||||
|
|
||||||
|
const vec3 lumaF = vec3(.299, .587, .114);
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
/* Sample source color */
|
||||||
|
vec4 frag = texture2D(texture, v_texCoord);
|
||||||
|
|
||||||
|
/* Apply gray */
|
||||||
|
float luma = dot(frag.rgb, lumaF);
|
||||||
|
frag.rgb = mix(frag.rgb, vec3(luma), gray);
|
||||||
|
|
||||||
|
gl_FragColor = frag;
|
||||||
|
}
|
|
@ -1,48 +1,40 @@
|
||||||
|
|
||||||
uniform sampler2D inputTexture;
|
uniform sampler2D texture;
|
||||||
uniform float hueAdjust;
|
uniform mediump float hueAdjust;
|
||||||
|
|
||||||
varying vec2 v_texCoord;
|
varying vec2 v_texCoord;
|
||||||
|
|
||||||
|
/* Source: gamedev.stackexchange.com/a/59808/24839 */
|
||||||
|
vec3 rgb2hsv(vec3 c)
|
||||||
|
{
|
||||||
|
const vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||||
|
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||||
|
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||||
|
|
||||||
|
float d = q.x - min(q.w, q.y);
|
||||||
|
|
||||||
|
/* Avoid divide-by-zero situations by adding a very tiny delta.
|
||||||
|
* Since we always deal with underlying 8-Bit color values, this
|
||||||
|
* should never mask a real value */
|
||||||
|
const float eps = 1.0e-10;
|
||||||
|
|
||||||
|
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + eps)), d / (q.x + eps), q.x);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 hsv2rgb(vec3 c)
|
||||||
|
{
|
||||||
|
const vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||||
|
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||||
|
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||||
|
}
|
||||||
|
|
||||||
void main ()
|
void main ()
|
||||||
{
|
{
|
||||||
const vec4 kRGBToYPrime = vec4 (0.299, 0.587, 0.114, 0.0);
|
vec4 color = texture2D (texture, v_texCoord.xy);
|
||||||
const vec4 kRGBToI = vec4 (0.596, -0.275, -0.321, 0.0);
|
vec3 hsv = rgb2hsv(color.rgb);
|
||||||
const vec4 kRGBToQ = vec4 (0.212, -0.523, 0.311, 0.0);
|
|
||||||
|
|
||||||
const vec4 kYIQToR = vec4 (1.0, 0.956, 0.621, 0.0);
|
hsv.x += hueAdjust;
|
||||||
const vec4 kYIQToG = vec4 (1.0, -0.272, -0.647, 0.0);
|
color.rgb = hsv2rgb(hsv);
|
||||||
const vec4 kYIQToB = vec4 (1.0, -1.107, 1.704, 0.0);
|
|
||||||
|
|
||||||
/* Sample the input pixel */
|
gl_FragColor = color;
|
||||||
vec4 color = texture2D (inputTexture, v_texCoord.xy);
|
|
||||||
|
|
||||||
/* Convert to YIQ */
|
|
||||||
float YPrime = dot (color, kRGBToYPrime);
|
|
||||||
float I = dot (color, kRGBToI);
|
|
||||||
float Q = dot (color, kRGBToQ);
|
|
||||||
|
|
||||||
/* Calculate the hue and chroma */
|
|
||||||
float hue = atan (Q, I);
|
|
||||||
float chroma = sqrt (I * I + Q * Q);
|
|
||||||
|
|
||||||
/* Make the user's adjustments */
|
|
||||||
hue += hueAdjust;
|
|
||||||
|
|
||||||
/* Remember old I and color */
|
|
||||||
float IOriginal = I;
|
|
||||||
vec4 coOriginal = color;
|
|
||||||
|
|
||||||
/* Convert back to YIQ */
|
|
||||||
Q = chroma * sin (hue);
|
|
||||||
I = chroma * cos (hue);
|
|
||||||
|
|
||||||
/* Convert back to RGB */
|
|
||||||
vec4 yIQ = vec4 (YPrime, I, Q, 0.0);
|
|
||||||
color.r = dot (yIQ, kYIQToR);
|
|
||||||
color.g = dot (yIQ, kYIQToG);
|
|
||||||
color.b = dot (yIQ, kYIQToB);
|
|
||||||
|
|
||||||
/* Save the result */
|
|
||||||
gl_FragColor = (IOriginal == 0.0) ? coOriginal : color;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
uniform mat4 projMat;
|
||||||
|
attribute vec2 position;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = projMat * vec4(position, 0, 1);
|
||||||
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
|
|
||||||
uniform sampler2D texture;
|
uniform sampler2D texture;
|
||||||
|
|
||||||
uniform vec4 tone;
|
uniform lowp vec4 tone;
|
||||||
|
|
||||||
uniform float opacity;
|
uniform lowp float opacity;
|
||||||
uniform vec4 color;
|
uniform lowp vec4 color;
|
||||||
uniform vec4 flash;
|
uniform lowp vec4 flash;
|
||||||
|
|
||||||
varying vec2 v_texCoord;
|
varying vec2 v_texCoord;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
uniform sampler2D texture;
|
uniform sampler2D texture;
|
||||||
|
|
||||||
varying vec2 v_texCoord;
|
varying vec2 v_texCoord;
|
||||||
varying vec4 v_color;
|
varying lowp vec4 v_color;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
uniform sampler2D texture;
|
||||||
|
uniform lowp float alpha;
|
||||||
|
|
||||||
|
varying vec2 v_texCoord;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragColor = texture2D(texture, v_texCoord);
|
||||||
|
gl_FragColor.a *= alpha;
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
varying vec4 v_color;
|
varying lowp vec4 v_color;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,10 +6,10 @@ uniform vec2 translation;
|
||||||
|
|
||||||
attribute vec2 position;
|
attribute vec2 position;
|
||||||
attribute vec2 texCoord;
|
attribute vec2 texCoord;
|
||||||
attribute vec4 color;
|
attribute lowp vec4 color;
|
||||||
|
|
||||||
varying vec2 v_texCoord;
|
varying vec2 v_texCoord;
|
||||||
varying vec4 v_color;
|
varying lowp vec4 v_color;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,10 +6,10 @@ uniform vec2 texSizeInv;
|
||||||
|
|
||||||
attribute vec2 position;
|
attribute vec2 position;
|
||||||
attribute vec2 texCoord;
|
attribute vec2 texCoord;
|
||||||
attribute vec4 color;
|
attribute lowp vec4 color;
|
||||||
|
|
||||||
varying vec2 v_texCoord;
|
varying vec2 v_texCoord;
|
||||||
varying vec4 v_color;
|
varying lowp vec4 v_color;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
|
|
||||||
uniform sampler2D texture;
|
uniform sampler2D texture;
|
||||||
|
|
||||||
uniform vec4 tone;
|
uniform lowp vec4 tone;
|
||||||
|
|
||||||
uniform float opacity;
|
uniform lowp float opacity;
|
||||||
uniform vec4 color;
|
uniform lowp vec4 color;
|
||||||
|
|
||||||
uniform float bushDepth;
|
uniform float bushDepth;
|
||||||
uniform float bushOpacity;
|
uniform lowp float bushOpacity;
|
||||||
|
|
||||||
varying vec2 v_texCoord;
|
varying vec2 v_texCoord;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ void main()
|
||||||
frag.rgb = mix(frag.rgb, color.rgb, color.a);
|
frag.rgb = mix(frag.rgb, color.rgb, color.a);
|
||||||
|
|
||||||
/* Apply bush alpha by mathematical if */
|
/* Apply bush alpha by mathematical if */
|
||||||
float underBush = float(v_texCoord.y < bushDepth);
|
lowp float underBush = float(v_texCoord.y < bushDepth);
|
||||||
frag.a *= clamp(bushOpacity + underBush, 0.0, 1.0);
|
frag.a *= clamp(bushOpacity + underBush, 0.0, 1.0);
|
||||||
|
|
||||||
gl_FragColor = frag;
|
gl_FragColor = frag;
|
||||||
|
|
|
@ -18,8 +18,9 @@ const float atAniOffset = 32.0*3.0;
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 tex = texCoord;
|
vec2 tex = texCoord;
|
||||||
if (tex.x <= atAreaW && tex.y <= atAreaH)
|
|
||||||
tex.x += aniIndex * atAniOffset;
|
lowp float pred = float(tex.x <= atAreaW && tex.y <= atAreaH);
|
||||||
|
tex.x += aniIndex * atAniOffset * pred;
|
||||||
|
|
||||||
gl_Position = projMat * vec4(position + translation, 0, 1);
|
gl_Position = projMat * vec4(position + translation, 0, 1);
|
||||||
|
|
||||||
|
|
|
@ -18,14 +18,15 @@ const float atAreaCW = 4.0*32.0;
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 tex = texCoord;
|
vec2 tex = texCoord;
|
||||||
|
lowp float pred;
|
||||||
|
|
||||||
/* Type A autotiles shift horizontally */
|
/* Type A autotiles shift horizontally */
|
||||||
if (tex.x <= atAreaA.x && tex.y <= atAreaA.y)
|
pred = float(tex.x <= atAreaA.x && tex.y <= atAreaA.y);
|
||||||
tex.x += aniOffset.x;
|
tex.x += aniOffset.x * pred;
|
||||||
|
|
||||||
/* Type C autotiles shift vertically */
|
/* Type C autotiles shift vertically */
|
||||||
if (tex.x >= atAreaCX && tex.x <= (atAreaCX+atAreaCW) && tex.y <= atAreaA.y)
|
pred = float(tex.x >= atAreaCX && tex.x <= (atAreaCX+atAreaCW) && tex.y <= atAreaA.y);
|
||||||
tex.y += aniOffset.y;
|
tex.y += aniOffset.y * pred;
|
||||||
|
|
||||||
gl_Position = projMat * vec4(position + translation, 0, 1);
|
gl_Position = projMat * vec4(position + translation, 0, 1);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ void main()
|
||||||
{
|
{
|
||||||
float transV = texture2D(transMap, v_texCoord).r;
|
float transV = texture2D(transMap, v_texCoord).r;
|
||||||
float cTransV = clamp(transV, prog, prog+vague);
|
float cTransV = clamp(transV, prog, prog+vague);
|
||||||
float alpha = (cTransV - prog) / vague;
|
lowp float alpha = (cTransV - prog) / vague;
|
||||||
|
|
||||||
vec4 newFrag = texture2D(currentScene, v_texCoord);
|
vec4 newFrag = texture2D(currentScene, v_texCoord);
|
||||||
vec4 oldFrag = texture2D(frozenScene, v_texCoord);
|
vec4 oldFrag = texture2D(frozenScene, v_texCoord);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -238,5 +238,6 @@ inline ALenum chooseALFormat(int sampleSize, int channelCount)
|
||||||
|
|
||||||
#define AUDIO_SLEEP 10
|
#define AUDIO_SLEEP 10
|
||||||
#define STREAM_BUF_SIZE 32768
|
#define STREAM_BUF_SIZE 32768
|
||||||
|
#define GLOBAL_VOLUME 0.8f
|
||||||
|
|
||||||
#endif // ALUTIL_H
|
#endif // ALUTIL_H
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2014 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
105
src/alstream.cpp
105
src/alstream.cpp
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2014 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -23,10 +23,13 @@
|
||||||
|
|
||||||
#include "sharedstate.h"
|
#include "sharedstate.h"
|
||||||
#include "sharedmidistate.h"
|
#include "sharedmidistate.h"
|
||||||
|
#include "eventthread.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
|
#include "exception.h"
|
||||||
#include "aldatasource.h"
|
#include "aldatasource.h"
|
||||||
#include "fluid-fun.h"
|
#include "fluid-fun.h"
|
||||||
#include "sdl-util.h"
|
#include "sdl-util.h"
|
||||||
|
#include "debugwriter.h"
|
||||||
|
|
||||||
#include <SDL_mutex.h>
|
#include <SDL_mutex.h>
|
||||||
#include <SDL_thread.h>
|
#include <SDL_thread.h>
|
||||||
|
@ -39,12 +42,12 @@ ALStream::ALStream(LoopMode loopMode,
|
||||||
source(0),
|
source(0),
|
||||||
thread(0),
|
thread(0),
|
||||||
preemptPause(false),
|
preemptPause(false),
|
||||||
pitch(1.0)
|
pitch(1.0f)
|
||||||
{
|
{
|
||||||
alSrc = AL::Source::gen();
|
alSrc = AL::Source::gen();
|
||||||
|
|
||||||
AL::Source::setVolume(alSrc, 1.0);
|
AL::Source::setVolume(alSrc, 1.0f);
|
||||||
AL::Source::setPitch(alSrc, 1.0);
|
AL::Source::setPitch(alSrc, 1.0f);
|
||||||
AL::Source::detachBuffer(alSrc);
|
AL::Source::detachBuffer(alSrc);
|
||||||
|
|
||||||
for (int i = 0; i < STREAM_BUFS; ++i)
|
for (int i = 0; i < STREAM_BUFS; ++i)
|
||||||
|
@ -122,6 +125,9 @@ void ALStream::stop()
|
||||||
|
|
||||||
void ALStream::play(float offset)
|
void ALStream::play(float offset)
|
||||||
{
|
{
|
||||||
|
if (!source)
|
||||||
|
return;
|
||||||
|
|
||||||
checkStopped();
|
checkStopped();
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
|
@ -166,7 +172,7 @@ void ALStream::setPitch(float value)
|
||||||
/* If the source supports setting pitch natively,
|
/* If the source supports setting pitch natively,
|
||||||
* we don't have to do it via OpenAL */
|
* we don't have to do it via OpenAL */
|
||||||
if (source && source->setPitch(value))
|
if (source && source->setPitch(value))
|
||||||
AL::Source::setPitch(alSrc, 1.0);
|
AL::Source::setPitch(alSrc, 1.0f);
|
||||||
else
|
else
|
||||||
AL::Source::setPitch(alSrc, value);
|
AL::Source::setPitch(alSrc, value);
|
||||||
}
|
}
|
||||||
|
@ -193,35 +199,76 @@ void ALStream::closeSource()
|
||||||
delete source;
|
delete source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ALStreamOpenHandler : FileSystem::OpenHandler
|
||||||
|
{
|
||||||
|
SDL_RWops *srcOps;
|
||||||
|
bool looped;
|
||||||
|
ALDataSource *source;
|
||||||
|
std::string errorMsg;
|
||||||
|
|
||||||
|
ALStreamOpenHandler(SDL_RWops &srcOps, bool looped)
|
||||||
|
: srcOps(&srcOps), looped(looped), source(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool tryRead(SDL_RWops &ops, const char *ext)
|
||||||
|
{
|
||||||
|
/* Copy this because we need to keep it around,
|
||||||
|
* as we will continue reading data from it later */
|
||||||
|
*srcOps = ops;
|
||||||
|
|
||||||
|
/* Try to read ogg file signature */
|
||||||
|
char sig[5] = { 0 };
|
||||||
|
SDL_RWread(srcOps, sig, 1, 4);
|
||||||
|
SDL_RWseek(srcOps, 0, RW_SEEK_SET);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!strcmp(sig, "OggS"))
|
||||||
|
{
|
||||||
|
source = createVorbisSource(*srcOps, looped);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(sig, "MThd"))
|
||||||
|
{
|
||||||
|
shState->midiState().initIfNeeded(shState->config());
|
||||||
|
|
||||||
|
if (HAVE_FLUID)
|
||||||
|
{
|
||||||
|
source = createMidiSource(*srcOps, looped);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
source = createSDLSource(*srcOps, ext, STREAM_BUF_SIZE, looped);
|
||||||
|
}
|
||||||
|
catch (const Exception &e)
|
||||||
|
{
|
||||||
|
/* All source constructors will close the passed ops
|
||||||
|
* before throwing errors */
|
||||||
|
errorMsg = e.msg;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void ALStream::openSource(const std::string &filename)
|
void ALStream::openSource(const std::string &filename)
|
||||||
{
|
{
|
||||||
const char *ext;
|
ALStreamOpenHandler handler(srcOps, looped);
|
||||||
shState->fileSystem().openRead(srcOps, filename.c_str(), FileSystem::Audio, false, &ext);
|
shState->fileSystem().openRead(handler, filename.c_str());
|
||||||
|
source = handler.source;
|
||||||
needsRewind.clear();
|
needsRewind.clear();
|
||||||
|
|
||||||
/* Try to read ogg file signature */
|
if (!source)
|
||||||
char sig[5] = { 0 };
|
|
||||||
SDL_RWread(&srcOps, sig, 1, 4);
|
|
||||||
SDL_RWseek(&srcOps, 0, RW_SEEK_SET);
|
|
||||||
|
|
||||||
if (!strcmp(sig, "OggS"))
|
|
||||||
{
|
{
|
||||||
source = createVorbisSource(srcOps, looped);
|
char buf[512];
|
||||||
return;
|
snprintf(buf, sizeof(buf), "Unable to decode audio stream: %s: %s",
|
||||||
|
filename.c_str(), handler.errorMsg.c_str());
|
||||||
|
|
||||||
|
Debug() << buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(sig, "MThd"))
|
|
||||||
{
|
|
||||||
shState->midiState().initIfNeeded(shState->config());
|
|
||||||
|
|
||||||
if (HAVE_FLUID)
|
|
||||||
{
|
|
||||||
source = createMidiSource(srcOps, looped);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
source = createSDLSource(srcOps, ext, STREAM_BUF_SIZE, looped);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ALStream::stopStream()
|
void ALStream::stopStream()
|
||||||
|
@ -361,6 +408,8 @@ void ALStream::streamData()
|
||||||
* refill and queue them up again */
|
* refill and queue them up again */
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
shState->rtData().syncPoint.passSecondarySync();
|
||||||
|
|
||||||
ALint procBufs = AL::Source::getProcBufferCount(alSrc);
|
ALint procBufs = AL::Source::getProcBufferCount(alSrc);
|
||||||
|
|
||||||
while (procBufs--)
|
while (procBufs--)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2014 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -25,6 +25,7 @@
|
||||||
#include "soundemitter.h"
|
#include "soundemitter.h"
|
||||||
#include "sharedstate.h"
|
#include "sharedstate.h"
|
||||||
#include "sharedmidistate.h"
|
#include "sharedmidistate.h"
|
||||||
|
#include "eventthread.h"
|
||||||
#include "sdl-util.h"
|
#include "sdl-util.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -40,6 +41,8 @@ struct AudioPrivate
|
||||||
|
|
||||||
SoundEmitter se;
|
SoundEmitter se;
|
||||||
|
|
||||||
|
SyncPoint &syncPoint;
|
||||||
|
|
||||||
/* The 'MeWatch' is responsible for detecting
|
/* The 'MeWatch' is responsible for detecting
|
||||||
* a playing ME, quickly fading out the BGM and
|
* a playing ME, quickly fading out the BGM and
|
||||||
* keeping it paused/stopped while the ME plays,
|
* keeping it paused/stopped while the ME plays,
|
||||||
|
@ -60,11 +63,12 @@ struct AudioPrivate
|
||||||
MeWatchState state;
|
MeWatchState state;
|
||||||
} meWatch;
|
} meWatch;
|
||||||
|
|
||||||
AudioPrivate(const Config &conf)
|
AudioPrivate(RGSSThreadData &rtData)
|
||||||
: bgm(ALStream::Looped, "bgm"),
|
: bgm(ALStream::Looped, "bgm"),
|
||||||
bgs(ALStream::Looped, "bgs"),
|
bgs(ALStream::Looped, "bgs"),
|
||||||
me(ALStream::NotLooped, "me"),
|
me(ALStream::NotLooped, "me"),
|
||||||
se(conf)
|
se(rtData.config),
|
||||||
|
syncPoint(rtData.syncPoint)
|
||||||
{
|
{
|
||||||
meWatch.state = MeNotPlaying;
|
meWatch.state = MeNotPlaying;
|
||||||
meWatch.thread = createSDLThread
|
meWatch.thread = createSDLThread
|
||||||
|
@ -84,6 +88,8 @@ struct AudioPrivate
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
syncPoint.passSecondarySync();
|
||||||
|
|
||||||
if (meWatch.termReq)
|
if (meWatch.termReq)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -164,7 +170,7 @@ struct AudioPrivate
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* BGM is stopped. -> MeNotPlaying */
|
/* BGM is stopped. -> MeNotPlaying */
|
||||||
bgm.setVolume(AudioStream::External, 1.0);
|
bgm.setVolume(AudioStream::External, 1.0f);
|
||||||
|
|
||||||
if (!bgm.noResumeStop)
|
if (!bgm.noResumeStop)
|
||||||
bgm.stream.play();
|
bgm.stream.play();
|
||||||
|
@ -187,7 +193,7 @@ struct AudioPrivate
|
||||||
if (bgm.stream.queryState() == ALStream::Stopped)
|
if (bgm.stream.queryState() == ALStream::Stopped)
|
||||||
{
|
{
|
||||||
/* BGM stopped midway fade in. -> MeNotPlaying */
|
/* BGM stopped midway fade in. -> MeNotPlaying */
|
||||||
bgm.setVolume(AudioStream::External, 1.0);
|
bgm.setVolume(AudioStream::External, 1.0f);
|
||||||
meWatch.state = MeNotPlaying;
|
meWatch.state = MeNotPlaying;
|
||||||
bgm.unlockStream();
|
bgm.unlockStream();
|
||||||
|
|
||||||
|
@ -213,7 +219,7 @@ struct AudioPrivate
|
||||||
if (vol >= 1)
|
if (vol >= 1)
|
||||||
{
|
{
|
||||||
/* BGM fully faded in. -> MeNotPlaying */
|
/* BGM fully faded in. -> MeNotPlaying */
|
||||||
vol = 1.0;
|
vol = 1.0f;
|
||||||
meWatch.state = MeNotPlaying;
|
meWatch.state = MeNotPlaying;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,8 +237,8 @@ struct AudioPrivate
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Audio::Audio(const Config &conf)
|
Audio::Audio(RGSSThreadData &rtData)
|
||||||
: p(new AudioPrivate(conf))
|
: p(new AudioPrivate(rtData))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
* quite make out their meaning yet) */
|
* quite make out their meaning yet) */
|
||||||
|
|
||||||
struct AudioPrivate;
|
struct AudioPrivate;
|
||||||
struct Config;
|
struct RGSSThreadData;
|
||||||
|
|
||||||
class Audio
|
class Audio
|
||||||
{
|
{
|
||||||
|
@ -70,7 +70,7 @@ public:
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Audio(const Config &conf);
|
Audio(RGSSThreadData &rtData);
|
||||||
~Audio();
|
~Audio();
|
||||||
|
|
||||||
friend struct SharedStatePrivate;
|
friend struct SharedStatePrivate;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2014 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -34,11 +34,11 @@ AudioStream::AudioStream(ALStream::LoopMode loopMode,
|
||||||
noResumeStop(false),
|
noResumeStop(false),
|
||||||
stream(loopMode, threadId)
|
stream(loopMode, threadId)
|
||||||
{
|
{
|
||||||
current.volume = 1.0;
|
current.volume = 1.0f;
|
||||||
current.pitch = 1.0;
|
current.pitch = 1.0f;
|
||||||
|
|
||||||
for (size_t i = 0; i < VolumeTypeCount; ++i)
|
for (size_t i = 0; i < VolumeTypeCount; ++i)
|
||||||
volumes[i] = 1.0;
|
volumes[i] = 1.0f;
|
||||||
|
|
||||||
fade.thread = 0;
|
fade.thread = 0;
|
||||||
fade.threadName = std::string("audio_fadeout (") + threadId + ")";
|
fade.threadName = std::string("audio_fadeout (") + threadId + ")";
|
||||||
|
@ -82,8 +82,8 @@ void AudioStream::play(const std::string &filename,
|
||||||
|
|
||||||
lockStream();
|
lockStream();
|
||||||
|
|
||||||
float _volume = clamp<int>(volume, 0, 100) / 100.f;
|
float _volume = clamp<int>(volume, 0, 100) / 100.0f;
|
||||||
float _pitch = clamp<int>(pitch, 50, 150) / 100.f;
|
float _pitch = clamp<int>(pitch, 50, 150) / 100.0f;
|
||||||
|
|
||||||
ALStream::State sState = stream.queryState();
|
ALStream::State sState = stream.queryState();
|
||||||
|
|
||||||
|
@ -179,6 +179,7 @@ void AudioStream::fadeOut(int duration)
|
||||||
lockStream();
|
lockStream();
|
||||||
|
|
||||||
ALStream::State sState = stream.queryState();
|
ALStream::State sState = stream.queryState();
|
||||||
|
noResumeStop = true;
|
||||||
|
|
||||||
if (fade.active)
|
if (fade.active)
|
||||||
{
|
{
|
||||||
|
@ -210,7 +211,7 @@ void AudioStream::fadeOut(int duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
fade.active.set();
|
fade.active.set();
|
||||||
fade.msStep = (1.0) / duration;
|
fade.msStep = 1.0f / duration;
|
||||||
fade.reqFini.clear();
|
fade.reqFini.clear();
|
||||||
fade.reqTerm.clear();
|
fade.reqTerm.clear();
|
||||||
fade.startTicks = SDL_GetTicks();
|
fade.startTicks = SDL_GetTicks();
|
||||||
|
@ -252,7 +253,7 @@ float AudioStream::playingOffset()
|
||||||
|
|
||||||
void AudioStream::updateVolume()
|
void AudioStream::updateVolume()
|
||||||
{
|
{
|
||||||
float vol = 1.0;
|
float vol = GLOBAL_VOLUME;
|
||||||
|
|
||||||
for (size_t i = 0; i < VolumeTypeCount; ++i)
|
for (size_t i = 0; i < VolumeTypeCount; ++i)
|
||||||
vol *= volumes[i];
|
vol *= volumes[i];
|
||||||
|
@ -301,7 +302,7 @@ void AudioStream::fadeOutThread()
|
||||||
lockStream();
|
lockStream();
|
||||||
|
|
||||||
uint32_t curDur = SDL_GetTicks() - fade.startTicks;
|
uint32_t curDur = SDL_GetTicks() - fade.startTicks;
|
||||||
float resVol = 1.0 - (curDur*fade.msStep);
|
float resVol = 1.0f - (curDur*fade.msStep);
|
||||||
|
|
||||||
ALStream::State state = stream.queryState();
|
ALStream::State state = stream.queryState();
|
||||||
|
|
||||||
|
@ -312,7 +313,7 @@ void AudioStream::fadeOutThread()
|
||||||
if (state != ALStream::Paused)
|
if (state != ALStream::Paused)
|
||||||
stream.stop();
|
stream.stop();
|
||||||
|
|
||||||
setVolume(FadeOut, 1.0);
|
setVolume(FadeOut, 1.0f);
|
||||||
unlockStream();
|
unlockStream();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -339,15 +340,15 @@ void AudioStream::fadeInThread()
|
||||||
|
|
||||||
/* Fade in duration is always 1 second */
|
/* Fade in duration is always 1 second */
|
||||||
uint32_t cur = SDL_GetTicks() - fadeIn.startTicks;
|
uint32_t cur = SDL_GetTicks() - fadeIn.startTicks;
|
||||||
float prog = cur / 1000.0;
|
float prog = cur / 1000.0f;
|
||||||
|
|
||||||
ALStream::State state = stream.queryState();
|
ALStream::State state = stream.queryState();
|
||||||
|
|
||||||
if (state != ALStream::Playing
|
if (state != ALStream::Playing
|
||||||
|| prog >= 1.0
|
|| prog >= 1.0f
|
||||||
|| fadeIn.rqFini)
|
|| fadeIn.rqFini)
|
||||||
{
|
{
|
||||||
setVolume(FadeIn, 1.0);
|
setVolume(FadeIn, 1.0f);
|
||||||
unlockStream();
|
unlockStream();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2014 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -55,7 +55,10 @@ struct AudioStream
|
||||||
|
|
||||||
/* Note that 'extPaused' and 'noResumeStop' are
|
/* Note that 'extPaused' and 'noResumeStop' are
|
||||||
* effectively only used with the AudioStream
|
* effectively only used with the AudioStream
|
||||||
* instance representing the BGM */
|
* instance representing the BGM.
|
||||||
|
* They are not AtomicFlags because they're regarded
|
||||||
|
* as part of the underlying stream state, and
|
||||||
|
* always accessed with the stream lock held */
|
||||||
|
|
||||||
/* Flag indicating that the MeWatch paused this
|
/* Flag indicating that the MeWatch paused this
|
||||||
* (BGM) stream because a ME started playing.
|
* (BGM) stream because a ME started playing.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
136
src/bitmap.cpp
136
src/bitmap.cpp
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -221,9 +221,9 @@ struct BitmapPrivate
|
||||||
surf = surfConv;
|
surf = surfConv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onModified()
|
void onModified(bool freeSurface = true)
|
||||||
{
|
{
|
||||||
if (surface)
|
if (surface && freeSurface)
|
||||||
{
|
{
|
||||||
SDL_FreeSurface(surface);
|
SDL_FreeSurface(surface);
|
||||||
surface = 0;
|
surface = 0;
|
||||||
|
@ -233,12 +233,26 @@ struct BitmapPrivate
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct BitmapOpenHandler : FileSystem::OpenHandler
|
||||||
|
{
|
||||||
|
SDL_Surface *surf;
|
||||||
|
|
||||||
|
BitmapOpenHandler()
|
||||||
|
: surf(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool tryRead(SDL_RWops &ops, const char *ext)
|
||||||
|
{
|
||||||
|
surf = IMG_LoadTyped_RW(&ops, 1, ext);
|
||||||
|
return surf != 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Bitmap::Bitmap(const char *filename)
|
Bitmap::Bitmap(const char *filename)
|
||||||
{
|
{
|
||||||
SDL_RWops ops;
|
BitmapOpenHandler handler;
|
||||||
const char *extension;
|
shState->fileSystem().openRead(handler, filename);
|
||||||
shState->fileSystem().openRead(ops, filename, FileSystem::Image, false, &extension);
|
SDL_Surface *imgSurf = handler.surf;
|
||||||
SDL_Surface *imgSurf = IMG_LoadTyped_RW(&ops, 1, extension);
|
|
||||||
|
|
||||||
if (!imgSurf)
|
if (!imgSurf)
|
||||||
throw Exception(Exception::SDLError, "Error loading image '%s': %s",
|
throw Exception(Exception::SDLError, "Error loading image '%s': %s",
|
||||||
|
@ -251,6 +265,7 @@ Bitmap::Bitmap(const char *filename)
|
||||||
/* Mega surface */
|
/* Mega surface */
|
||||||
p = new BitmapPrivate(this);
|
p = new BitmapPrivate(this);
|
||||||
p->megaSurface = imgSurf;
|
p->megaSurface = imgSurf;
|
||||||
|
SDL_SetSurfaceBlendMode(p->megaSurface, SDL_BLENDMODE_NONE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -374,14 +389,46 @@ void Bitmap::stretchBlt(const IntRect &destRect,
|
||||||
if (opacity == 0)
|
if (opacity == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (source.megaSurface())
|
SDL_Surface *srcSurf = source.megaSurface();
|
||||||
|
|
||||||
|
if (srcSurf && shState->config().subImageFix)
|
||||||
{
|
{
|
||||||
|
/* Blit from software surface, for broken GL drivers */
|
||||||
|
Vec2i gpTexSize;
|
||||||
|
shState->ensureTexSize(sourceRect.w, sourceRect.h, gpTexSize);
|
||||||
|
shState->bindTex();
|
||||||
|
|
||||||
|
GLMeta::subRectImageUpload(srcSurf->w, sourceRect.x, sourceRect.y, 0, 0,
|
||||||
|
sourceRect.w, sourceRect.h, srcSurf, GL_RGBA);
|
||||||
|
GLMeta::subRectImageEnd();
|
||||||
|
|
||||||
|
SimpleShader &shader = shState->shaders().simple;
|
||||||
|
shader.bind();
|
||||||
|
shader.setTranslation(Vec2i());
|
||||||
|
shader.setTexSize(gpTexSize);
|
||||||
|
|
||||||
|
p->pushSetViewport(shader);
|
||||||
|
p->bindFBO();
|
||||||
|
|
||||||
|
Quad &quad = shState->gpQuad();
|
||||||
|
quad.setTexRect(FloatRect(0, 0, sourceRect.w, sourceRect.h));
|
||||||
|
quad.setPosRect(destRect);
|
||||||
|
|
||||||
|
p->blitQuad(quad);
|
||||||
|
p->popViewport();
|
||||||
|
|
||||||
|
p->addTaintedArea(destRect);
|
||||||
|
p->onModified();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (srcSurf)
|
||||||
|
{
|
||||||
|
/* Blit from software surface */
|
||||||
/* Don't do transparent blits for now */
|
/* Don't do transparent blits for now */
|
||||||
if (opacity < 255)
|
if (opacity < 255)
|
||||||
source.ensureNonMega();
|
source.ensureNonMega();
|
||||||
|
|
||||||
SDL_Surface *srcSurf = source.megaSurface();
|
|
||||||
|
|
||||||
SDL_Rect srcRect = sourceRect;
|
SDL_Rect srcRect = sourceRect;
|
||||||
SDL_Rect dstRect = destRect;
|
SDL_Rect dstRect = destRect;
|
||||||
SDL_Rect btmRect = { 0, 0, width(), height() };
|
SDL_Rect btmRect = { 0, 0, width(), height() };
|
||||||
|
@ -397,26 +444,25 @@ void Bitmap::stretchBlt(const IntRect &destRect,
|
||||||
SDL_Surface *blitTemp =
|
SDL_Surface *blitTemp =
|
||||||
SDL_CreateRGBSurface(0, destRect.w, destRect.h, bpp, rMask, gMask, bMask, aMask);
|
SDL_CreateRGBSurface(0, destRect.w, destRect.h, bpp, rMask, gMask, bMask, aMask);
|
||||||
|
|
||||||
// FXIME: This is supposed to be a scaled blit, put SDL2 for some reason
|
SDL_BlitScaled(srcSurf, &srcRect, blitTemp, 0);
|
||||||
// makes the source surface unusable after BlitScaled() is called. Investigate!
|
|
||||||
SDL_BlitSurface(srcSurf, &srcRect, blitTemp, 0);
|
|
||||||
|
|
||||||
TEX::bind(p->gl.tex);
|
TEX::bind(p->gl.tex);
|
||||||
|
|
||||||
if (bltRect.w == dstRect.w && bltRect.h == dstRect.h)
|
if (bltRect.w == dstRect.w && bltRect.h == dstRect.h)
|
||||||
{
|
{
|
||||||
|
/* Dest rectangle lies within bounding box */
|
||||||
TEX::uploadSubImage(destRect.x, destRect.y,
|
TEX::uploadSubImage(destRect.x, destRect.y,
|
||||||
destRect.w, destRect.h,
|
destRect.w, destRect.h,
|
||||||
blitTemp->pixels, GL_RGBA);
|
blitTemp->pixels, GL_RGBA);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* Clipped blit */
|
||||||
GLMeta::subRectImageUpload(blitTemp->w, bltRect.x - dstRect.x, bltRect.y - dstRect.y,
|
GLMeta::subRectImageUpload(blitTemp->w, bltRect.x - dstRect.x, bltRect.y - dstRect.y,
|
||||||
bltRect.x, bltRect.y, bltRect.w, bltRect.h, blitTemp, GL_RGBA);
|
bltRect.x, bltRect.y, bltRect.w, bltRect.h, blitTemp, GL_RGBA);
|
||||||
GLMeta::subRectImageEnd();
|
GLMeta::subRectImageEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SDL_FreeSurface(blitTemp);
|
SDL_FreeSurface(blitTemp);
|
||||||
|
|
||||||
p->onModified();
|
p->onModified();
|
||||||
|
@ -468,7 +514,6 @@ void Bitmap::stretchBlt(const IntRect &destRect,
|
||||||
}
|
}
|
||||||
|
|
||||||
p->addTaintedArea(destRect);
|
p->addTaintedArea(destRect);
|
||||||
|
|
||||||
p->onModified();
|
p->onModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,6 +768,14 @@ void Bitmap::clear()
|
||||||
p->onModified();
|
p->onModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t &getPixelAt(SDL_Surface *surf, SDL_PixelFormat *form, int x, int y)
|
||||||
|
{
|
||||||
|
size_t offset = x*form->BytesPerPixel + y*surf->pitch;
|
||||||
|
uint8_t *bytes = (uint8_t*) surf->pixels + offset;
|
||||||
|
|
||||||
|
return *((uint32_t*) bytes);
|
||||||
|
}
|
||||||
|
|
||||||
Color Bitmap::getPixel(int x, int y) const
|
Color Bitmap::getPixel(int x, int y) const
|
||||||
{
|
{
|
||||||
guardDisposed();
|
guardDisposed();
|
||||||
|
@ -745,9 +798,7 @@ Color Bitmap::getPixel(int x, int y) const
|
||||||
glState.viewport.pop();
|
glState.viewport.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t offset = x*p->format->BytesPerPixel + y*p->surface->pitch;
|
uint32_t pixel = getPixelAt(p->surface, p->format, x, y);
|
||||||
uint8_t *bytes = (uint8_t*) p->surface->pixels + offset;
|
|
||||||
uint32_t pixel = *((uint32_t*) bytes);
|
|
||||||
|
|
||||||
return Color((pixel >> p->format->Rshift) & 0xFF,
|
return Color((pixel >> p->format->Rshift) & 0xFF,
|
||||||
(pixel >> p->format->Gshift) & 0xFF,
|
(pixel >> p->format->Gshift) & 0xFF,
|
||||||
|
@ -774,7 +825,16 @@ void Bitmap::setPixel(int x, int y, const Color &color)
|
||||||
|
|
||||||
p->addTaintedArea(IntRect(x, y, 1, 1));
|
p->addTaintedArea(IntRect(x, y, 1, 1));
|
||||||
|
|
||||||
p->onModified();
|
/* Setting just a single pixel is no reason to throw away the
|
||||||
|
* whole cached surface; we can just apply the same change */
|
||||||
|
|
||||||
|
if (p->surface)
|
||||||
|
{
|
||||||
|
uint32_t &surfPixel = getPixelAt(p->surface, p->format, x, y);
|
||||||
|
surfPixel = SDL_MapRGBA(p->format, pixel[0], pixel[1], pixel[2], pixel[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
p->onModified(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bitmap::hueChange(int hue)
|
void Bitmap::hueChange(int hue)
|
||||||
|
@ -794,13 +854,10 @@ void Bitmap::hueChange(int hue)
|
||||||
quad.setTexPosRect(texRect, texRect);
|
quad.setTexPosRect(texRect, texRect);
|
||||||
quad.setColor(Vec4(1, 1, 1, 1));
|
quad.setColor(Vec4(1, 1, 1, 1));
|
||||||
|
|
||||||
/* Calculate hue parameter */
|
|
||||||
hue = wrapRange(hue, 0, 359);
|
|
||||||
float hueAdj = -((M_PI * 2) / 360) * hue;
|
|
||||||
|
|
||||||
HueShader &shader = shState->shaders().hue;
|
HueShader &shader = shState->shaders().hue;
|
||||||
shader.bind();
|
shader.bind();
|
||||||
shader.setHueAdjust(hueAdj);
|
/* Shader expects normalized value */
|
||||||
|
shader.setHueAdjust(wrapRange(hue, 0, 359) / 360.0f);
|
||||||
|
|
||||||
FBO::bind(newTex.fbo);
|
FBO::bind(newTex.fbo);
|
||||||
p->pushSetViewport(shader);
|
p->pushSetViewport(shader);
|
||||||
|
@ -845,9 +902,9 @@ static void applyShadow(SDL_Surface *&in, const SDL_PixelFormat &fm, const SDL_C
|
||||||
SDL_Surface *out = SDL_CreateRGBSurface
|
SDL_Surface *out = SDL_CreateRGBSurface
|
||||||
(0, in->w+1, in->h+1, fm.BitsPerPixel, fm.Rmask, fm.Gmask, fm.Bmask, fm.Amask);
|
(0, in->w+1, in->h+1, fm.BitsPerPixel, fm.Rmask, fm.Gmask, fm.Bmask, fm.Amask);
|
||||||
|
|
||||||
float fr = c.r / 255.0;
|
float fr = c.r / 255.0f;
|
||||||
float fg = c.g / 255.0;
|
float fg = c.g / 255.0f;
|
||||||
float fb = c.b / 255.0;
|
float fb = c.b / 255.0f;
|
||||||
|
|
||||||
/* We allocate an output surface one pixel wider and higher than the input,
|
/* We allocate an output surface one pixel wider and higher than the input,
|
||||||
* (implicitly) blit a copy of the input with RGB values set to black into
|
* (implicitly) blit a copy of the input with RGB values set to black into
|
||||||
|
@ -901,11 +958,11 @@ static void applyShadow(SDL_Surface *&in, const SDL_PixelFormat &fm, const SDL_C
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
float fSrcA = srcA / 255.0;
|
float fSrcA = srcA / 255.0f;
|
||||||
float fShdA = shdA / 255.0;
|
float fShdA = shdA / 255.0f;
|
||||||
|
|
||||||
/* Because opacity == 1, co1 == fSrcA */
|
/* Because opacity == 1, co1 == fSrcA */
|
||||||
float co2 = fShdA * (1.0 - fSrcA);
|
float co2 = fShdA * (1.0f - fSrcA);
|
||||||
/* Result alpha */
|
/* Result alpha */
|
||||||
float fa = fSrcA + co2;
|
float fa = fSrcA + co2;
|
||||||
/* Temp value to simplify arithmetic below */
|
/* Temp value to simplify arithmetic below */
|
||||||
|
@ -914,10 +971,10 @@ static void applyShadow(SDL_Surface *&in, const SDL_PixelFormat &fm, const SDL_C
|
||||||
/* Result colors */
|
/* Result colors */
|
||||||
uint8_t r, g, b, a;
|
uint8_t r, g, b, a;
|
||||||
|
|
||||||
r = clamp<float>(fr * co3, 0, 1) * 255;
|
r = clamp<float>(fr * co3, 0, 1) * 255.0f;
|
||||||
g = clamp<float>(fg * co3, 0, 1) * 255;
|
g = clamp<float>(fg * co3, 0, 1) * 255.0f;
|
||||||
b = clamp<float>(fb * co3, 0, 1) * 255;
|
b = clamp<float>(fb * co3, 0, 1) * 255.0f;
|
||||||
a = clamp<float>(fa, 0, 1) * 255;
|
a = clamp<float>(fa, 0, 1) * 255.0f;
|
||||||
|
|
||||||
*outP = SDL_MapRGBA(&fm, r, g, b, a);
|
*outP = SDL_MapRGBA(&fm, r, g, b, a);
|
||||||
}
|
}
|
||||||
|
@ -960,12 +1017,15 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
||||||
|
|
||||||
p->ensureFormat(txtSurf, SDL_PIXELFORMAT_ABGR8888);
|
p->ensureFormat(txtSurf, SDL_PIXELFORMAT_ABGR8888);
|
||||||
|
|
||||||
|
int rawTxtSurfH = txtSurf->h;
|
||||||
|
|
||||||
if (p->font->getShadow())
|
if (p->font->getShadow())
|
||||||
applyShadow(txtSurf, *p->format, c);
|
applyShadow(txtSurf, *p->format, c);
|
||||||
|
|
||||||
/* outline using TTF_Outline and blending it together with SDL_BlitSurface
|
/* outline using TTF_Outline and blending it together with SDL_BlitSurface
|
||||||
* FIXME: outline is forced to have the same opacity as the font color */
|
* FIXME: outline is forced to have the same opacity as the font color */
|
||||||
if (p->font->getOutline()) {
|
if (p->font->getOutline())
|
||||||
|
{
|
||||||
SDL_Color co = outColor.toSDLColor();
|
SDL_Color co = outColor.toSDLColor();
|
||||||
co.a = 255;
|
co.a = 255;
|
||||||
SDL_Surface *outline;
|
SDL_Surface *outline;
|
||||||
|
@ -1007,7 +1067,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
||||||
if (alignX < rect.x)
|
if (alignX < rect.x)
|
||||||
alignX = rect.x;
|
alignX = rect.x;
|
||||||
|
|
||||||
int alignY = rect.y + (rect.h - txtSurf->h) / 2;
|
int alignY = rect.y + (rect.h - rawTxtSurfH) / 2;
|
||||||
|
|
||||||
float squeeze = (float) rect.w / txtSurf->w;
|
float squeeze = (float) rect.w / txtSurf->w;
|
||||||
|
|
||||||
|
@ -1019,11 +1079,11 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
||||||
Vec2i gpTexSize;
|
Vec2i gpTexSize;
|
||||||
shState->ensureTexSize(txtSurf->w, txtSurf->h, gpTexSize);
|
shState->ensureTexSize(txtSurf->w, txtSurf->h, gpTexSize);
|
||||||
|
|
||||||
bool fastBlit = !p->touchesTaintedArea(posRect) && txtAlpha == 1.0;
|
bool fastBlit = !p->touchesTaintedArea(posRect) && txtAlpha == 1.0f;
|
||||||
|
|
||||||
if (fastBlit)
|
if (fastBlit)
|
||||||
{
|
{
|
||||||
if (squeeze == 1.0)
|
if (squeeze == 1.0f && !shState->config().subImageFix)
|
||||||
{
|
{
|
||||||
/* Even faster: upload directly to bitmap texture.
|
/* Even faster: upload directly to bitmap texture.
|
||||||
* We have to make sure the posRect lies within the texture
|
* We have to make sure the posRect lies within the texture
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
178
src/config.cpp
178
src/config.cpp
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -32,6 +32,8 @@
|
||||||
|
|
||||||
#include "debugwriter.h"
|
#include "debugwriter.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "sdl-util.h"
|
||||||
|
#include "iniconfig.h"
|
||||||
|
|
||||||
#ifdef INI_ENCODING
|
#ifdef INI_ENCODING
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -123,77 +125,93 @@ static bool validUtf8(const char *string)
|
||||||
static std::string prefPath(const char *org, const char *app)
|
static std::string prefPath(const char *org, const char *app)
|
||||||
{
|
{
|
||||||
char *path = SDL_GetPrefPath(org, app);
|
char *path = SDL_GetPrefPath(org, app);
|
||||||
|
|
||||||
|
if (!path)
|
||||||
|
return std::string();
|
||||||
|
|
||||||
std::string str(path);
|
std::string str(path);
|
||||||
SDL_free(path);
|
SDL_free(path);
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
std::set<T> setFromVec(const std::vector<T> &vec)
|
||||||
|
{
|
||||||
|
return std::set<T>(vec.begin(), vec.end());
|
||||||
|
}
|
||||||
|
|
||||||
typedef std::vector<std::string> StringVec;
|
typedef std::vector<std::string> StringVec;
|
||||||
namespace po = boost::program_options;
|
namespace po = boost::program_options;
|
||||||
|
|
||||||
#define CONF_FILE "mkxp.conf"
|
#define CONF_FILE "mkxp.conf"
|
||||||
|
|
||||||
Config::Config()
|
Config::Config()
|
||||||
: rgssVersion(0),
|
{}
|
||||||
debugMode(false),
|
|
||||||
winResizable(false),
|
|
||||||
fullscreen(false),
|
|
||||||
fixedAspectRatio(true),
|
|
||||||
smoothScaling(false),
|
|
||||||
vsync(false),
|
|
||||||
defScreenW(0),
|
|
||||||
defScreenH(0),
|
|
||||||
fixedFramerate(0),
|
|
||||||
frameSkip(true),
|
|
||||||
solidFonts(false),
|
|
||||||
gameFolder("."),
|
|
||||||
anyAltToggleFS(false),
|
|
||||||
enableReset(true),
|
|
||||||
allowSymlinks(false),
|
|
||||||
pathCache(true),
|
|
||||||
useScriptNames(false)
|
|
||||||
{
|
|
||||||
midi.chorus = false;
|
|
||||||
midi.reverb = false;
|
|
||||||
SE.sourceCount = 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Config::read(int argc, char *argv[])
|
void Config::read(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
#define PO_DESC_ALL \
|
#define PO_DESC_ALL \
|
||||||
PO_DESC(rgssVersion, int) \
|
PO_DESC(rgssVersion, int, 0) \
|
||||||
PO_DESC(debugMode, bool) \
|
PO_DESC(debugMode, bool, false) \
|
||||||
PO_DESC(winResizable, bool) \
|
PO_DESC(printFPS, bool, false) \
|
||||||
PO_DESC(fullscreen, bool) \
|
PO_DESC(winResizable, bool, false) \
|
||||||
PO_DESC(fixedAspectRatio, bool) \
|
PO_DESC(fullscreen, bool, false) \
|
||||||
PO_DESC(smoothScaling, bool) \
|
PO_DESC(fixedAspectRatio, bool, true) \
|
||||||
PO_DESC(vsync, bool) \
|
PO_DESC(smoothScaling, bool, true) \
|
||||||
PO_DESC(defScreenW, int) \
|
PO_DESC(vsync, bool, false) \
|
||||||
PO_DESC(defScreenH, int) \
|
PO_DESC(defScreenW, int, 0) \
|
||||||
PO_DESC(fixedFramerate, int) \
|
PO_DESC(defScreenH, int, 0) \
|
||||||
PO_DESC(frameSkip, bool) \
|
PO_DESC(windowTitle, std::string, "") \
|
||||||
PO_DESC(solidFonts, bool) \
|
PO_DESC(fixedFramerate, int, 0) \
|
||||||
PO_DESC(gameFolder, std::string) \
|
PO_DESC(frameSkip, bool, true) \
|
||||||
PO_DESC(anyAltToggleFS, bool) \
|
PO_DESC(syncToRefreshrate, bool, false) \
|
||||||
PO_DESC(enableReset, bool) \
|
PO_DESC(solidFonts, bool, false) \
|
||||||
PO_DESC(allowSymlinks, bool) \
|
PO_DESC(subImageFix, bool, false) \
|
||||||
PO_DESC(dataPathOrg, std::string) \
|
PO_DESC(enableBlitting, bool, true) \
|
||||||
PO_DESC(dataPathApp, std::string) \
|
PO_DESC(maxTextureSize, int, 0) \
|
||||||
PO_DESC(iconPath, std::string) \
|
PO_DESC(gameFolder, std::string, ".") \
|
||||||
PO_DESC(titleLanguage, std::string) \
|
PO_DESC(anyAltToggleFS, bool, false) \
|
||||||
PO_DESC(midi.soundFont, std::string) \
|
PO_DESC(enableReset, bool, true) \
|
||||||
PO_DESC(midi.chorus, bool) \
|
PO_DESC(allowSymlinks, bool, false) \
|
||||||
PO_DESC(midi.reverb, bool) \
|
PO_DESC(dataPathOrg, std::string, "") \
|
||||||
PO_DESC(SE.sourceCount, int) \
|
PO_DESC(dataPathApp, std::string, "") \
|
||||||
PO_DESC(customScript, std::string) \
|
PO_DESC(iconPath, std::string, "") \
|
||||||
PO_DESC(pathCache, bool) \
|
PO_DESC(execName, std::string, "Game") \
|
||||||
PO_DESC(useScriptNames, bool)
|
PO_DESC(titleLanguage, std::string, "") \
|
||||||
|
PO_DESC(midi.soundFont, std::string, "") \
|
||||||
|
PO_DESC(midi.chorus, bool, false) \
|
||||||
|
PO_DESC(midi.reverb, bool, false) \
|
||||||
|
PO_DESC(SE.sourceCount, int, 6) \
|
||||||
|
PO_DESC(customScript, std::string, "") \
|
||||||
|
PO_DESC(pathCache, bool, true) \
|
||||||
|
PO_DESC(useScriptNames, bool, false)
|
||||||
|
|
||||||
// Not gonna take your shit boost
|
// Not gonna take your shit boost
|
||||||
#define GUARD_ALL( exp ) try { exp } catch(...) {}
|
#define GUARD_ALL( exp ) try { exp } catch(...) {}
|
||||||
|
|
||||||
#define PO_DESC(key, type) (#key, po::value< type >()->default_value(key))
|
editor.debug = false;
|
||||||
|
editor.battleTest = false;
|
||||||
|
|
||||||
|
/* Read arguments sent from the editor */
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
std::string argv1 = argv[1];
|
||||||
|
/* RGSS1 uses "debug", 2 and 3 use "test" */
|
||||||
|
if (argv1 == "debug" || argv1 == "test")
|
||||||
|
editor.debug = true;
|
||||||
|
else if (argv1 == "btest")
|
||||||
|
editor.battleTest = true;
|
||||||
|
|
||||||
|
/* Fix offset */
|
||||||
|
if (editor.debug || editor.battleTest)
|
||||||
|
{
|
||||||
|
argc--;
|
||||||
|
argv++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define PO_DESC(key, type, def) (#key, po::value< type >()->default_value(def))
|
||||||
|
|
||||||
po::options_description podesc;
|
po::options_description podesc;
|
||||||
podesc.add_options()
|
podesc.add_options()
|
||||||
|
@ -219,30 +237,27 @@ void Config::read(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse configuration file */
|
/* Parse configuration file */
|
||||||
std::ifstream confFile;
|
SDLRWStream confFile(CONF_FILE, "r");
|
||||||
confFile.open(CONF_FILE);
|
|
||||||
|
|
||||||
if (confFile)
|
if (confFile)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
po::store(po::parse_config_file(confFile, podesc, true), vm);
|
po::store(po::parse_config_file(confFile.stream(), podesc, true), vm);
|
||||||
po::notify(vm);
|
po::notify(vm);
|
||||||
}
|
}
|
||||||
catch (po::error &error)
|
catch (po::error &error)
|
||||||
{
|
{
|
||||||
Debug() << CONF_FILE":" << error.what();
|
Debug() << CONF_FILE":" << error.what();
|
||||||
}
|
}
|
||||||
|
|
||||||
confFile.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef PO_DESC
|
#undef PO_DESC
|
||||||
#define PO_DESC(key, type) GUARD_ALL( key = vm[#key].as< type >(); )
|
#define PO_DESC(key, type, def) GUARD_ALL( key = vm[#key].as< type >(); )
|
||||||
|
|
||||||
PO_DESC_ALL;
|
PO_DESC_ALL;
|
||||||
|
|
||||||
GUARD_ALL( preloadScripts = vm["preloadScript"].as<StringVec>(); );
|
GUARD_ALL( preloadScripts = setFromVec(vm["preloadScript"].as<StringVec>()); );
|
||||||
|
|
||||||
GUARD_ALL( rtps = vm["RTP"].as<StringVec>(); );
|
GUARD_ALL( rtps = vm["RTP"].as<StringVec>(); );
|
||||||
|
|
||||||
|
@ -296,27 +311,38 @@ void Config::readGameINI()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
po::options_description podesc;
|
std::string iniFilename = execName + ".ini";
|
||||||
podesc.add_options()
|
SDLRWStream iniFile(iniFilename.c_str(), "r");
|
||||||
("Game.Title", po::value<std::string>())
|
|
||||||
("Game.Scripts", po::value<std::string>())
|
|
||||||
;
|
|
||||||
|
|
||||||
std::string iniPath = gameFolder + "/Game.ini";
|
if (iniFile)
|
||||||
|
{
|
||||||
|
INIConfiguration ic;
|
||||||
|
if(ic.load(iniFile.stream()))
|
||||||
|
{
|
||||||
|
GUARD_ALL( game.title = ic.getStringProperty("Game", "Title"); );
|
||||||
|
GUARD_ALL( game.scripts = ic.getStringProperty("Game", "Scripts"); );
|
||||||
|
|
||||||
std::ifstream iniFile;
|
strReplace(game.scripts, '\\', '/');
|
||||||
iniFile.open((iniPath).c_str());
|
|
||||||
|
|
||||||
po::variables_map vm;
|
if (game.title.empty())
|
||||||
po::store(po::parse_config_file(iniFile, podesc, true), vm);
|
{
|
||||||
po::notify(vm);
|
Debug() << iniFilename + ": Could not find Game.Title property";
|
||||||
|
}
|
||||||
|
|
||||||
iniFile.close();
|
if (game.scripts.empty())
|
||||||
|
{
|
||||||
GUARD_ALL( game.title = vm["Game.Title"].as<std::string>(); );
|
Debug() << iniFilename + ": Could not find Game.Scripts property";
|
||||||
GUARD_ALL( game.scripts = vm["Game.Scripts"].as<std::string>(); );
|
}
|
||||||
|
}
|
||||||
strReplace(game.scripts, '\\', '/');
|
else
|
||||||
|
{
|
||||||
|
Debug() << iniFilename + ": Failed to parse ini file";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug() << "FAILED to open" << iniFilename;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef INI_ENCODING
|
#ifdef INI_ENCODING
|
||||||
/* Can add more later */
|
/* Can add more later */
|
||||||
|
|
19
src/config.h
19
src/config.h
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -24,12 +24,14 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
struct Config
|
struct Config
|
||||||
{
|
{
|
||||||
int rgssVersion;
|
int rgssVersion;
|
||||||
|
|
||||||
bool debugMode;
|
bool debugMode;
|
||||||
|
bool printFPS;
|
||||||
|
|
||||||
bool winResizable;
|
bool winResizable;
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
|
@ -39,12 +41,18 @@ struct Config
|
||||||
|
|
||||||
int defScreenW;
|
int defScreenW;
|
||||||
int defScreenH;
|
int defScreenH;
|
||||||
|
std::string windowTitle;
|
||||||
|
|
||||||
int fixedFramerate;
|
int fixedFramerate;
|
||||||
bool frameSkip;
|
bool frameSkip;
|
||||||
|
bool syncToRefreshrate;
|
||||||
|
|
||||||
bool solidFonts;
|
bool solidFonts;
|
||||||
|
|
||||||
|
bool subImageFix;
|
||||||
|
bool enableBlitting;
|
||||||
|
int maxTextureSize;
|
||||||
|
|
||||||
std::string gameFolder;
|
std::string gameFolder;
|
||||||
bool anyAltToggleFS;
|
bool anyAltToggleFS;
|
||||||
bool enableReset;
|
bool enableReset;
|
||||||
|
@ -55,6 +63,7 @@ struct Config
|
||||||
std::string dataPathApp;
|
std::string dataPathApp;
|
||||||
|
|
||||||
std::string iconPath;
|
std::string iconPath;
|
||||||
|
std::string execName;
|
||||||
std::string titleLanguage;
|
std::string titleLanguage;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
|
@ -72,13 +81,19 @@ struct Config
|
||||||
bool useScriptNames;
|
bool useScriptNames;
|
||||||
|
|
||||||
std::string customScript;
|
std::string customScript;
|
||||||
std::vector<std::string> preloadScripts;
|
std::set<std::string> preloadScripts;
|
||||||
std::vector<std::string> rtps;
|
std::vector<std::string> rtps;
|
||||||
|
|
||||||
std::vector<std::string> fontSubs;
|
std::vector<std::string> fontSubs;
|
||||||
|
|
||||||
std::vector<std::string> rubyLoadpaths;
|
std::vector<std::string> rubyLoadpaths;
|
||||||
|
|
||||||
|
/* Editor flags */
|
||||||
|
struct {
|
||||||
|
bool debug;
|
||||||
|
bool battleTest;
|
||||||
|
} editor;
|
||||||
|
|
||||||
/* Game INI contents */
|
/* Game INI contents */
|
||||||
struct {
|
struct {
|
||||||
std::string scripts;
|
std::string scripts;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -26,6 +26,11 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
#include <android/log.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* A cheap replacement for qDebug() */
|
/* A cheap replacement for qDebug() */
|
||||||
|
|
||||||
class Debug
|
class Debug
|
||||||
|
@ -56,7 +61,11 @@ public:
|
||||||
|
|
||||||
~Debug()
|
~Debug()
|
||||||
{
|
{
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
__android_log_write(ANDROID_LOG_DEBUG, "mkxp", buf.str().c_str());
|
||||||
|
#else
|
||||||
std::cerr << buf.str() << std::endl;
|
std::cerr << buf.str() << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -60,6 +60,11 @@ struct Vec4
|
||||||
{
|
{
|
||||||
return (x == other.x && y == other.y && z == other.z && w == other.w);
|
return (x == other.x && y == other.y && z == other.z && w == other.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool xyzNotNull() const
|
||||||
|
{
|
||||||
|
return (x != 0.0f || y != 0.0f || z != 0.0f);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Vec2i
|
struct Vec2i
|
||||||
|
@ -74,19 +79,78 @@ struct Vec2i
|
||||||
: x(x), y(y)
|
: x(x), y(y)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
explicit Vec2i(int xy)
|
||||||
|
: x(xy), y(xy)
|
||||||
|
{}
|
||||||
|
|
||||||
bool operator==(const Vec2i &other) const
|
bool operator==(const Vec2i &other) const
|
||||||
{
|
{
|
||||||
return x == other.x && y == other.y;
|
return x == other.x && y == other.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2i &operator+=(const Vec2i &other)
|
bool operator!=(const Vec2i &other) const
|
||||||
{
|
{
|
||||||
x += other.x;
|
return !(*this == other);
|
||||||
y += other.y;
|
}
|
||||||
|
|
||||||
|
Vec2i &operator+=(const Vec2i &value)
|
||||||
|
{
|
||||||
|
x += value.x;
|
||||||
|
y += value.y;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vec2i &operator-=(const Vec2i &value)
|
||||||
|
{
|
||||||
|
x -= value.x;
|
||||||
|
y -= value.y;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec2i operator+(const Vec2i &value) const
|
||||||
|
{
|
||||||
|
return Vec2i(x + value.x, y + value.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec2i operator-(const Vec2i &value) const
|
||||||
|
{
|
||||||
|
return Vec2i(x - value.x, y - value.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
Vec2i operator*(T value) const
|
||||||
|
{
|
||||||
|
return Vec2i(x * value, y * value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
Vec2i operator/(T value) const
|
||||||
|
{
|
||||||
|
return Vec2i(x / value, y / value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec2i operator%(int value) const
|
||||||
|
{
|
||||||
|
return Vec2i(x % value, y % value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec2i operator&(unsigned value) const
|
||||||
|
{
|
||||||
|
return Vec2i(x & value, y & value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec2i operator-() const
|
||||||
|
{
|
||||||
|
return Vec2i(-x, -y);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec2i operator!() const
|
||||||
|
{
|
||||||
|
return Vec2i(!x, !y);
|
||||||
|
}
|
||||||
|
|
||||||
operator Vec2() const
|
operator Vec2() const
|
||||||
{
|
{
|
||||||
return Vec2(x, y);
|
return Vec2(x, y);
|
||||||
|
@ -108,12 +172,25 @@ struct IntRect : SDL_Rect
|
||||||
this->h = h;
|
this->h = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IntRect(const Vec2i &pos, const Vec2i &size)
|
||||||
|
{
|
||||||
|
x = pos.x;
|
||||||
|
y = pos.y;
|
||||||
|
w = size.x;
|
||||||
|
h = size.y;
|
||||||
|
}
|
||||||
|
|
||||||
bool operator==(const IntRect &other) const
|
bool operator==(const IntRect &other) const
|
||||||
{
|
{
|
||||||
return (x == other.x && y == other.y &&
|
return (x == other.x && y == other.y &&
|
||||||
w == other.w && h == other.h);
|
w == other.w && h == other.h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator!=(const IntRect &other) const
|
||||||
|
{
|
||||||
|
return !(*this == other);
|
||||||
|
}
|
||||||
|
|
||||||
Vec2i pos() const
|
Vec2i pos() const
|
||||||
{
|
{
|
||||||
return Vec2i(x, y);
|
return Vec2i(x, y);
|
||||||
|
@ -124,10 +201,24 @@ struct IntRect : SDL_Rect
|
||||||
return Vec2i(w, h);
|
return Vec2i(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
operator SDL_Rect() const
|
void setPos(const Vec2i &value)
|
||||||
{
|
{
|
||||||
SDL_Rect r = { x, y, w, h };
|
x = value.x;
|
||||||
return r;
|
y = value.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setSize(const Vec2i &value)
|
||||||
|
{
|
||||||
|
w = value.x;
|
||||||
|
h = value.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool encloses(const IntRect &o) const
|
||||||
|
{
|
||||||
|
return (x <= o.x &&
|
||||||
|
y <= o.y &&
|
||||||
|
x+w >= o.x+o.w &&
|
||||||
|
y+h >= o.y+o.h);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -163,35 +254,10 @@ struct FloatRect
|
||||||
Vec2 topRight() const { return Vec2(x+w, y); }
|
Vec2 topRight() const { return Vec2(x+w, y); }
|
||||||
Vec2 bottomRight() const { return Vec2(x+w, y+h); }
|
Vec2 bottomRight() const { return Vec2(x+w, y+h); }
|
||||||
|
|
||||||
void shrinkHalf()
|
|
||||||
{
|
|
||||||
x += 0.5;
|
|
||||||
y += 0.5;
|
|
||||||
w -= 1.0;
|
|
||||||
h -= 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
FloatRect vFlipped() const
|
|
||||||
{
|
|
||||||
return FloatRect(x, y+h, w, -h);
|
|
||||||
}
|
|
||||||
|
|
||||||
FloatRect hFlipped() const
|
FloatRect hFlipped() const
|
||||||
{
|
{
|
||||||
return FloatRect(x+w, y, -w, h);
|
return FloatRect(x+w, y, -w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2 corner(int i) const
|
|
||||||
{
|
|
||||||
switch (i)
|
|
||||||
{
|
|
||||||
case 0 : return topLeft();
|
|
||||||
case 1 : return topRight();
|
|
||||||
case 2 : return bottomRight();
|
|
||||||
case 3 : return bottomLeft();
|
|
||||||
default : return Vec2();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Value between 0 and 255 with internal
|
/* Value between 0 and 255 with internal
|
||||||
|
@ -208,13 +274,13 @@ struct NormValue
|
||||||
|
|
||||||
NormValue(int unNorm)
|
NormValue(int unNorm)
|
||||||
: unNorm(unNorm),
|
: unNorm(unNorm),
|
||||||
norm(unNorm / 255.0)
|
norm(unNorm / 255.0f)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void operator =(int value)
|
void operator =(int value)
|
||||||
{
|
{
|
||||||
unNorm = clamp(value, 0, 255);
|
unNorm = clamp(value, 0, 255);
|
||||||
norm = unNorm / 255.0;
|
norm = unNorm / 255.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator ==(int value) const
|
bool operator ==(int value) const
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
@ -26,25 +26,53 @@
|
||||||
#include <SDL_messagebox.h>
|
#include <SDL_messagebox.h>
|
||||||
#include <SDL_timer.h>
|
#include <SDL_timer.h>
|
||||||
#include <SDL_thread.h>
|
#include <SDL_thread.h>
|
||||||
|
#include <SDL_touch.h>
|
||||||
|
#include <SDL_rect.h>
|
||||||
|
|
||||||
|
#include <al.h>
|
||||||
|
#include <alext.h>
|
||||||
|
|
||||||
#include "sharedstate.h"
|
#include "sharedstate.h"
|
||||||
#include "graphics.h"
|
#include "graphics.h"
|
||||||
#include "settingsmenu.h"
|
#include "settingsmenu.h"
|
||||||
|
#include "al-util.h"
|
||||||
#include "debugwriter.h"
|
#include "debugwriter.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
uint8_t EventThread::keyStates[] = { false };
|
typedef void (ALC_APIENTRY *LPALCDEVICEPAUSESOFT) (ALCdevice *device);
|
||||||
|
typedef void (ALC_APIENTRY *LPALCDEVICERESUMESOFT) (ALCdevice *device);
|
||||||
|
|
||||||
EventThread::JoyState EventThread::joyState =
|
#define AL_DEVICE_PAUSE_FUN \
|
||||||
{
|
AL_FUN(DevicePause, LPALCDEVICEPAUSESOFT) \
|
||||||
{ 0 }, { 0 }, { false }
|
AL_FUN(DeviceResume, LPALCDEVICERESUMESOFT)
|
||||||
};
|
|
||||||
|
|
||||||
EventThread::MouseState EventThread::mouseState =
|
struct ALCFunctions
|
||||||
{
|
{
|
||||||
0, 0, false, { false }
|
#define AL_FUN(name, type) type name;
|
||||||
};
|
AL_DEVICE_PAUSE_FUN
|
||||||
|
#undef AL_FUN
|
||||||
|
} static alc;
|
||||||
|
|
||||||
|
static void
|
||||||
|
initALCFunctions(ALCdevice *alcDev)
|
||||||
|
{
|
||||||
|
if (!strstr(alcGetString(alcDev, ALC_EXTENSIONS), "ALC_SOFT_pause_device"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Debug() << "ALC_SOFT_pause_device present";
|
||||||
|
|
||||||
|
#define AL_FUN(name, type) alc. name = (type) alcGetProcAddress(alcDev, "alc" #name "SOFT");
|
||||||
|
AL_DEVICE_PAUSE_FUN;
|
||||||
|
#undef AL_FUN
|
||||||
|
}
|
||||||
|
|
||||||
|
#define HAVE_ALC_DEVICE_PAUSE alc.DevicePause
|
||||||
|
|
||||||
|
uint8_t EventThread::keyStates[];
|
||||||
|
EventThread::JoyState EventThread::joyState;
|
||||||
|
EventThread::MouseState EventThread::mouseState;
|
||||||
|
EventThread::TouchState EventThread::touchState;
|
||||||
|
|
||||||
/* User event codes */
|
/* User event codes */
|
||||||
enum
|
enum
|
||||||
|
@ -55,6 +83,7 @@ enum
|
||||||
REQUEST_SETCURSORVISIBLE,
|
REQUEST_SETCURSORVISIBLE,
|
||||||
|
|
||||||
UPDATE_FPS,
|
UPDATE_FPS,
|
||||||
|
UPDATE_SCREEN_RECT,
|
||||||
|
|
||||||
EVENT_COUNT
|
EVENT_COUNT
|
||||||
};
|
};
|
||||||
|
@ -80,21 +109,34 @@ void EventThread::process(RGSSThreadData &rtData)
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
SDL_Window *win = rtData.window;
|
SDL_Window *win = rtData.window;
|
||||||
WindowSizeNotify &windowSizeMsg = rtData.windowSizeMsg;
|
UnidirMessage<Vec2i> &windowSizeMsg = rtData.windowSizeMsg;
|
||||||
|
|
||||||
|
initALCFunctions(rtData.alcDev);
|
||||||
|
|
||||||
|
// XXX this function breaks input focus on OSX
|
||||||
|
#ifndef __MACOSX__
|
||||||
|
SDL_SetEventFilter(eventFilter, &rtData);
|
||||||
|
#endif
|
||||||
|
|
||||||
fullscreen = rtData.config.fullscreen;
|
fullscreen = rtData.config.fullscreen;
|
||||||
int toggleFSMod = rtData.config.anyAltToggleFS ? KMOD_ALT : KMOD_LALT;
|
int toggleFSMod = rtData.config.anyAltToggleFS ? KMOD_ALT : KMOD_LALT;
|
||||||
|
|
||||||
fps.lastFrame = SDL_GetPerformanceCounter();
|
fps.lastFrame = SDL_GetPerformanceCounter();
|
||||||
fps.displayCounter = 0;
|
fps.displayCounter = 0;
|
||||||
fps.displaying = false;
|
|
||||||
fps.immInitFlag = false;
|
|
||||||
fps.immFiniFlag = false;
|
|
||||||
fps.acc = 0;
|
fps.acc = 0;
|
||||||
fps.accDiv = 0;
|
fps.accDiv = 0;
|
||||||
|
|
||||||
|
if (rtData.config.printFPS)
|
||||||
|
fps.sendUpdates.set();
|
||||||
|
|
||||||
|
bool displayingFPS = false;
|
||||||
|
|
||||||
bool cursorInWindow = false;
|
bool cursorInWindow = false;
|
||||||
bool windowFocused = false;
|
/* Will be updated eventually */
|
||||||
|
SDL_Rect gameScreen = { 0, 0, 0, 0 };
|
||||||
|
|
||||||
|
/* SDL doesn't send an initial FOCUS_GAINED event */
|
||||||
|
bool windowFocused = true;
|
||||||
|
|
||||||
bool terminate = false;
|
bool terminate = false;
|
||||||
|
|
||||||
|
@ -109,6 +151,11 @@ void EventThread::process(RGSSThreadData &rtData)
|
||||||
|
|
||||||
bool resetting = false;
|
bool resetting = false;
|
||||||
|
|
||||||
|
int winW, winH;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
SDL_GetWindowSize(win, &winW, &winH);
|
||||||
|
|
||||||
SettingsMenu *sMenu = 0;
|
SettingsMenu *sMenu = 0;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
|
@ -126,33 +173,55 @@ void EventThread::process(RGSSThreadData &rtData)
|
||||||
delete sMenu;
|
delete sMenu;
|
||||||
sMenu = 0;
|
sMenu = 0;
|
||||||
|
|
||||||
updateCursorState(cursorInWindow && windowFocused);
|
updateCursorState(cursorInWindow && windowFocused, gameScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Preselect and discard unwanted events here */
|
||||||
|
switch (event.type)
|
||||||
|
{
|
||||||
|
case SDL_MOUSEBUTTONDOWN :
|
||||||
|
case SDL_MOUSEBUTTONUP :
|
||||||
|
case SDL_MOUSEMOTION :
|
||||||
|
if (event.button.which == SDL_TOUCH_MOUSEID)
|
||||||
|
continue;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_FINGERDOWN :
|
||||||
|
case SDL_FINGERUP :
|
||||||
|
case SDL_FINGERMOTION :
|
||||||
|
if (event.tfinger.fingerId >= MAX_FINGERS)
|
||||||
|
continue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now process the rest */
|
||||||
switch (event.type)
|
switch (event.type)
|
||||||
{
|
{
|
||||||
case SDL_WINDOWEVENT :
|
case SDL_WINDOWEVENT :
|
||||||
switch (event.window.event)
|
switch (event.window.event)
|
||||||
{
|
{
|
||||||
case SDL_WINDOWEVENT_SIZE_CHANGED :
|
case SDL_WINDOWEVENT_SIZE_CHANGED :
|
||||||
windowSizeMsg.notifyChange(event.window.data1,
|
winW = event.window.data1;
|
||||||
event.window.data2);
|
winH = event.window.data2;
|
||||||
|
|
||||||
|
windowSizeMsg.post(Vec2i(winW, winH));
|
||||||
|
resetInputStates();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_WINDOWEVENT_ENTER :
|
case SDL_WINDOWEVENT_ENTER :
|
||||||
cursorInWindow = true;
|
cursorInWindow = true;
|
||||||
mouseState.inWindow = true;
|
mouseState.inWindow = true;
|
||||||
updateCursorState(cursorInWindow && windowFocused && !sMenu);
|
updateCursorState(cursorInWindow && windowFocused && !sMenu, gameScreen);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_WINDOWEVENT_LEAVE :
|
case SDL_WINDOWEVENT_LEAVE :
|
||||||
cursorInWindow = false;
|
cursorInWindow = false;
|
||||||
mouseState.inWindow = false;
|
mouseState.inWindow = false;
|
||||||
updateCursorState(cursorInWindow && windowFocused && !sMenu);
|
updateCursorState(cursorInWindow && windowFocused && !sMenu, gameScreen);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -163,13 +232,13 @@ void EventThread::process(RGSSThreadData &rtData)
|
||||||
|
|
||||||
case SDL_WINDOWEVENT_FOCUS_GAINED :
|
case SDL_WINDOWEVENT_FOCUS_GAINED :
|
||||||
windowFocused = true;
|
windowFocused = true;
|
||||||
updateCursorState(cursorInWindow && windowFocused && !sMenu);
|
updateCursorState(cursorInWindow && windowFocused && !sMenu, gameScreen);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_WINDOWEVENT_FOCUS_LOST :
|
case SDL_WINDOWEVENT_FOCUS_LOST :
|
||||||
windowFocused = false;
|
windowFocused = false;
|
||||||
updateCursorState(cursorInWindow && windowFocused && !sMenu);
|
updateCursorState(cursorInWindow && windowFocused && !sMenu, gameScreen);
|
||||||
resetInputStates();
|
resetInputStates();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -202,7 +271,7 @@ void EventThread::process(RGSSThreadData &rtData)
|
||||||
if (!sMenu)
|
if (!sMenu)
|
||||||
{
|
{
|
||||||
sMenu = new SettingsMenu(rtData);
|
sMenu = new SettingsMenu(rtData);
|
||||||
updateCursorState(false);
|
updateCursorState(false, gameScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
sMenu->raise();
|
sMenu->raise();
|
||||||
|
@ -210,26 +279,30 @@ void EventThread::process(RGSSThreadData &rtData)
|
||||||
|
|
||||||
if (event.key.keysym.scancode == SDL_SCANCODE_F2)
|
if (event.key.keysym.scancode == SDL_SCANCODE_F2)
|
||||||
{
|
{
|
||||||
if (!fps.displaying)
|
if (!displayingFPS)
|
||||||
{
|
{
|
||||||
fps.immInitFlag = true;
|
fps.immInitFlag.set();
|
||||||
fps.displaying = true;
|
fps.sendUpdates.set();
|
||||||
|
displayingFPS = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fps.displaying = false;
|
displayingFPS = false;
|
||||||
|
|
||||||
|
if (!rtData.config.printFPS)
|
||||||
|
fps.sendUpdates.clear();
|
||||||
|
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
{
|
{
|
||||||
/* Prevent fullscreen flicker */
|
/* Prevent fullscreen flicker */
|
||||||
strncpy(pendingTitle, rtData.config.game.title.c_str(),
|
strncpy(pendingTitle, rtData.config.windowTitle.c_str(),
|
||||||
sizeof(pendingTitle));
|
sizeof(pendingTitle));
|
||||||
havePendingTitle = true;
|
havePendingTitle = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SetWindowTitle(win, rtData.config.game.title.c_str());
|
SDL_SetWindowTitle(win, rtData.config.windowTitle.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -304,7 +377,22 @@ void EventThread::process(RGSSThreadData &rtData)
|
||||||
case SDL_MOUSEMOTION :
|
case SDL_MOUSEMOTION :
|
||||||
mouseState.x = event.motion.x;
|
mouseState.x = event.motion.x;
|
||||||
mouseState.y = event.motion.y;
|
mouseState.y = event.motion.y;
|
||||||
|
updateCursorState(cursorInWindow, gameScreen);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_FINGERDOWN :
|
||||||
|
i = event.tfinger.fingerId;
|
||||||
|
touchState.fingers[i].down = true;
|
||||||
|
|
||||||
|
case SDL_FINGERMOTION :
|
||||||
|
i = event.tfinger.fingerId;
|
||||||
|
touchState.fingers[i].x = event.tfinger.x * winW;
|
||||||
|
touchState.fingers[i].y = event.tfinger.y * winH;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_FINGERUP :
|
||||||
|
i = event.tfinger.fingerId;
|
||||||
|
memset(&touchState.fingers[i], 0, sizeof(touchState.fingers[0]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
|
@ -321,7 +409,7 @@ void EventThread::process(RGSSThreadData &rtData)
|
||||||
|
|
||||||
case REQUEST_MESSAGEBOX :
|
case REQUEST_MESSAGEBOX :
|
||||||
SDL_ShowSimpleMessageBox(event.user.code,
|
SDL_ShowSimpleMessageBox(event.user.code,
|
||||||
rtData.config.game.title.c_str(),
|
rtData.config.windowTitle.c_str(),
|
||||||
(const char*) event.user.data1, win);
|
(const char*) event.user.data1, win);
|
||||||
free(event.user.data1);
|
free(event.user.data1);
|
||||||
msgBoxDone.set();
|
msgBoxDone.set();
|
||||||
|
@ -329,15 +417,18 @@ void EventThread::process(RGSSThreadData &rtData)
|
||||||
|
|
||||||
case REQUEST_SETCURSORVISIBLE :
|
case REQUEST_SETCURSORVISIBLE :
|
||||||
showCursor = event.user.code;
|
showCursor = event.user.code;
|
||||||
updateCursorState(cursorInWindow);
|
updateCursorState(cursorInWindow, gameScreen);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UPDATE_FPS :
|
case UPDATE_FPS :
|
||||||
if (!fps.displaying)
|
if (rtData.config.printFPS)
|
||||||
|
Debug() << "FPS:" << event.user.code;
|
||||||
|
|
||||||
|
if (!fps.sendUpdates)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
snprintf(buffer, sizeof(buffer), "%s - %d FPS",
|
snprintf(buffer, sizeof(buffer), "%s - %d FPS",
|
||||||
rtData.config.game.title.c_str(), event.user.code);
|
rtData.config.windowTitle.c_str(), event.user.code);
|
||||||
|
|
||||||
/* Updating the window title in fullscreen
|
/* Updating the window title in fullscreen
|
||||||
* mode seems to cause flickering */
|
* mode seems to cause flickering */
|
||||||
|
@ -351,6 +442,15 @@ void EventThread::process(RGSSThreadData &rtData)
|
||||||
|
|
||||||
SDL_SetWindowTitle(win, buffer);
|
SDL_SetWindowTitle(win, buffer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case UPDATE_SCREEN_RECT :
|
||||||
|
gameScreen.x = event.user.windowID;
|
||||||
|
gameScreen.y = event.user.code;
|
||||||
|
gameScreen.w = reinterpret_cast<intptr_t>(event.user.data1);
|
||||||
|
gameScreen.h = reinterpret_cast<intptr_t>(event.user.data2);
|
||||||
|
updateCursorState(cursorInWindow, gameScreen);
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,12 +458,69 @@ void EventThread::process(RGSSThreadData &rtData)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Just in case */
|
||||||
|
rtData.syncPoint.resumeThreads();
|
||||||
|
|
||||||
if (SDL_JoystickGetAttached(js))
|
if (SDL_JoystickGetAttached(js))
|
||||||
SDL_JoystickClose(js);
|
SDL_JoystickClose(js);
|
||||||
|
|
||||||
delete sMenu;
|
delete sMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int EventThread::eventFilter(void *data, SDL_Event *event)
|
||||||
|
{
|
||||||
|
RGSSThreadData &rtData = *static_cast<RGSSThreadData*>(data);
|
||||||
|
|
||||||
|
switch (event->type)
|
||||||
|
{
|
||||||
|
case SDL_APP_WILLENTERBACKGROUND :
|
||||||
|
Debug() << "SDL_APP_WILLENTERBACKGROUND";
|
||||||
|
|
||||||
|
if (HAVE_ALC_DEVICE_PAUSE)
|
||||||
|
alc.DevicePause(rtData.alcDev);
|
||||||
|
|
||||||
|
rtData.syncPoint.haltThreads();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case SDL_APP_DIDENTERBACKGROUND :
|
||||||
|
Debug() << "SDL_APP_DIDENTERBACKGROUND";
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case SDL_APP_WILLENTERFOREGROUND :
|
||||||
|
Debug() << "SDL_APP_WILLENTERFOREGROUND";
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case SDL_APP_DIDENTERFOREGROUND :
|
||||||
|
Debug() << "SDL_APP_DIDENTERFOREGROUND";
|
||||||
|
|
||||||
|
if (HAVE_ALC_DEVICE_PAUSE)
|
||||||
|
alc.DeviceResume(rtData.alcDev);
|
||||||
|
|
||||||
|
rtData.syncPoint.resumeThreads();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case SDL_APP_TERMINATING :
|
||||||
|
Debug() << "SDL_APP_TERMINATING";
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case SDL_APP_LOWMEMORY :
|
||||||
|
Debug() << "SDL_APP_LOWMEMORY";
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// case SDL_RENDER_TARGETS_RESET :
|
||||||
|
// Debug() << "****** SDL_RENDER_TARGETS_RESET";
|
||||||
|
// return 0;
|
||||||
|
|
||||||
|
// case SDL_RENDER_DEVICE_RESET :
|
||||||
|
// Debug() << "****** SDL_RENDER_DEVICE_RESET";
|
||||||
|
// return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void EventThread::cleanup()
|
void EventThread::cleanup()
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
@ -378,6 +535,7 @@ void EventThread::resetInputStates()
|
||||||
memset(&keyStates, 0, sizeof(keyStates));
|
memset(&keyStates, 0, sizeof(keyStates));
|
||||||
memset(&joyState, 0, sizeof(joyState));
|
memset(&joyState, 0, sizeof(joyState));
|
||||||
memset(&mouseState.buttons, 0, sizeof(mouseState.buttons));
|
memset(&mouseState.buttons, 0, sizeof(mouseState.buttons));
|
||||||
|
memset(&touchState, 0, sizeof(touchState));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventThread::setFullscreen(SDL_Window *win, bool mode)
|
void EventThread::setFullscreen(SDL_Window *win, bool mode)
|
||||||
|
@ -387,9 +545,13 @@ void EventThread::setFullscreen(SDL_Window *win, bool mode)
|
||||||
fullscreen = mode;
|
fullscreen = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventThread::updateCursorState(bool inWindow)
|
void EventThread::updateCursorState(bool inWindow,
|
||||||
|
const SDL_Rect &screen)
|
||||||
{
|
{
|
||||||
if (inWindow)
|
SDL_Point pos = { mouseState.x, mouseState.y };
|
||||||
|
bool inScreen = inWindow && SDL_PointInRect(&pos, &screen);
|
||||||
|
|
||||||
|
if (inScreen)
|
||||||
SDL_ShowCursor(showCursor ? SDL_TRUE : SDL_FALSE);
|
SDL_ShowCursor(showCursor ? SDL_TRUE : SDL_FALSE);
|
||||||
else
|
else
|
||||||
SDL_ShowCursor(SDL_TRUE);
|
SDL_ShowCursor(SDL_TRUE);
|
||||||
|
@ -458,7 +620,7 @@ bool EventThread::getShowCursor() const
|
||||||
|
|
||||||
void EventThread::notifyFrame()
|
void EventThread::notifyFrame()
|
||||||
{
|
{
|
||||||
if (!fps.displaying)
|
if (!fps.sendUpdates)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint64_t current = SDL_GetPerformanceCounter();
|
uint64_t current = SDL_GetPerformanceCounter();
|
||||||
|
@ -467,8 +629,8 @@ void EventThread::notifyFrame()
|
||||||
|
|
||||||
if (fps.immInitFlag)
|
if (fps.immInitFlag)
|
||||||
{
|
{
|
||||||
fps.immInitFlag = false;
|
fps.immInitFlag.clear();
|
||||||
fps.immFiniFlag = true;
|
fps.immFiniFlag.set();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -484,7 +646,7 @@ void EventThread::notifyFrame()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fps.displayCounter = 0;
|
fps.displayCounter = 0;
|
||||||
fps.immFiniFlag = false;
|
fps.immFiniFlag.clear();
|
||||||
|
|
||||||
int32_t avgFPS = fps.acc / fps.accDiv;
|
int32_t avgFPS = fps.acc / fps.accDiv;
|
||||||
fps.acc = fps.accDiv = 0;
|
fps.acc = fps.accDiv = 0;
|
||||||
|
@ -494,3 +656,100 @@ void EventThread::notifyFrame()
|
||||||
event.user.type = usrIdStart + UPDATE_FPS;
|
event.user.type = usrIdStart + UPDATE_FPS;
|
||||||
SDL_PushEvent(&event);
|
SDL_PushEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EventThread::notifyGameScreenChange(const SDL_Rect &screen)
|
||||||
|
{
|
||||||
|
/* We have to get a bit hacky here to fit the rectangle
|
||||||
|
* data into the user event struct */
|
||||||
|
SDL_Event event;
|
||||||
|
event.type = usrIdStart + UPDATE_SCREEN_RECT;
|
||||||
|
event.user.windowID = screen.x;
|
||||||
|
event.user.code = screen.y;
|
||||||
|
event.user.data1 = reinterpret_cast<void*>(screen.w);
|
||||||
|
event.user.data2 = reinterpret_cast<void*>(screen.h);
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SyncPoint::haltThreads()
|
||||||
|
{
|
||||||
|
if (mainSync.locked)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Lock the reply sync first to avoid races */
|
||||||
|
reply.lock();
|
||||||
|
|
||||||
|
/* Lock main sync and sleep until RGSS thread
|
||||||
|
* reports back */
|
||||||
|
mainSync.lock();
|
||||||
|
reply.waitForUnlock();
|
||||||
|
|
||||||
|
/* Now that the RGSS thread is asleep, we can
|
||||||
|
* safely put the other threads to sleep as well
|
||||||
|
* without causing deadlocks */
|
||||||
|
secondSync.lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SyncPoint::resumeThreads()
|
||||||
|
{
|
||||||
|
if (!mainSync.locked)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mainSync.unlock(false);
|
||||||
|
secondSync.unlock(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SyncPoint::mainSyncLocked()
|
||||||
|
{
|
||||||
|
return mainSync.locked;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SyncPoint::waitMainSync()
|
||||||
|
{
|
||||||
|
reply.unlock(false);
|
||||||
|
mainSync.waitForUnlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SyncPoint::passSecondarySync()
|
||||||
|
{
|
||||||
|
if (!secondSync.locked)
|
||||||
|
return;
|
||||||
|
|
||||||
|
secondSync.waitForUnlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
SyncPoint::Util::Util()
|
||||||
|
{
|
||||||
|
mut = SDL_CreateMutex();
|
||||||
|
cond = SDL_CreateCond();
|
||||||
|
}
|
||||||
|
|
||||||
|
SyncPoint::Util::~Util()
|
||||||
|
{
|
||||||
|
SDL_DestroyCond(cond);
|
||||||
|
SDL_DestroyMutex(mut);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SyncPoint::Util::lock()
|
||||||
|
{
|
||||||
|
locked.set();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SyncPoint::Util::unlock(bool multi)
|
||||||
|
{
|
||||||
|
locked.clear();
|
||||||
|
|
||||||
|
if (multi)
|
||||||
|
SDL_CondBroadcast(cond);
|
||||||
|
else
|
||||||
|
SDL_CondSignal(cond);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SyncPoint::Util::waitForUnlock()
|
||||||
|
{
|
||||||
|
SDL_LockMutex(mut);
|
||||||
|
|
||||||
|
while (locked)
|
||||||
|
SDL_CondWait(cond, mut);
|
||||||
|
|
||||||
|
SDL_UnlockMutex(mut);
|
||||||
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue