Compare commits

...
113 Commits
Author SHA1 Message Date
kichikuou 2936212967 Bump version to 2.0.0
Ever since I forked xsystem35, the version number has remained at 1.7.3.
I'm going to resume versioning.
2021-10-23 10:16:10 +09:00
kichikuou e83f4da24f Move installer/ to tools/installer/ 2021-10-23 10:16:07 +09:00
kichikuou 066295df2f Windows: Open folder chooser only if current folder has no ALD files 2021-10-23 09:18:13 +09:00
kichikuou 40a4d8b2f6 debugger_dap: Support variables and setVariable requests 2021-10-23 08:12:13 +09:00
kichikuou 0793b57e3c Debugger: Add finish (step out) command 2021-10-22 11:10:56 +09:00
kichikuou 089520ec55 Add support for Debug Adapter Protocol
If -debug_dap flag is given, xsystem35 speaks the Debug Adapter Protocol
(https://microsoft.github.io/debug-adapter-protocol/) via stdin/stdout.
This enables xsystem35 to work as a backend of VS Code's Debugger (and
possibly other debuggers that support DAP).
2021-10-17 21:05:24 +09:00
kichikuou 4bea33d852 Disable debugger on Android and Emscripten 2021-10-09 11:00:23 +09:00
kichikuou 6930acd3b1 Debugger: Empty input repeats last command 2021-10-03 16:01:06 +09:00
kichikuou f9a3ef8606 Debugger: Add "list" command 2021-10-03 16:01:06 +09:00
kichikuou 841deb6f81 Debugger: Add "help" command 2021-10-03 16:01:06 +09:00
kichikuou d713e1470e Make SACT work with emscripten
- Add some functions to ASYNCIFY_ADD

  A function that calls an asynchronous function via a function pointer
  must be added to ASYNCIFY_ADD, even if it had a direct call to
  another asynchronous function, so that the indirect call itself is
  instrumented.

- Add dummy emscripten_sleep() call to send_agsevent

  Because adding a function to ASYNCIFY_ADD does not make its callers
  instrumented transitively.
2021-09-25 22:54:57 +09:00
kichikuou 6268cb6a9b Add musbgm implementation for emscripten 2021-09-25 22:54:57 +09:00
kichikuou a5aa8d0672 Android: Update SDL2 to 2.0.16 2021-09-19 15:59:33 +09:00
kichikuou f8b7adf3d0 Debugger: Fix crash by breakpoint on message literal 2021-08-15 18:19:37 +09:00
kichikuou 3e46c54ce6 VSP: allocate extraction buffer on heap
This fixes stack overflow in MacOS release build.
2021-08-15 18:19:16 +09:00
kichikuou 0925ee86e0 Move xsys35rc.sample to repository root directory
And describe the PortMidi option.
2021-08-14 17:19:06 +09:00
kichikuou 7a77470a19 Split debugger into two parts
The core (debugger.c) and CUI part (debugger_cui.c).
2021-08-01 22:16:21 +09:00
kichikuou 068a2910b5 Fix texthook in Unicode mode 2021-08-01 13:52:14 +09:00
kichikuou 6ef699e87d Clean up scenario.h dependencies
- nact.h and xsystem35.h no longer include scenario.h
- Removed `sys_*` aliases in nact.h
- sys_getString() and sys_getConstString() are moved to
  scenario.c as sl_getString() and sl_getConstString()
- DEBUG_COMMAND macros are now defined in scenario.h
2021-07-31 15:18:02 +09:00
kichikuou d6dd7d34b7 Refactor scenario.{h,c} 2021-07-31 13:56:47 +09:00
kichikuou a4f0e18d70 Windows: Allocate a console for debugger
Since xsystem35 is built as a GUI executable, we have to create a
console explicitly.
2021-07-31 09:56:43 +09:00
kichikuou 80bd68214b Debugger: Allow interrupts inside sleep functions
This makes it possible to enter a REPL in the middle of command
execution (for example, while waiting for input in the A command).
2021-07-25 21:26:05 +09:00
kichikuou 4143cfc83b Debugger: Add string command
It prints contents of string variables.
2021-07-24 17:52:40 +09:00
kichikuou 541cd22e56 Debugger: Support more ways to specify breakpoint locations
- `break function` sets a breakpoint to the entry of `function`, which
  is either a global function or a local function in current page.
- `break number` sets a breakpoint to the specified line in current
  file.
2021-07-24 17:47:26 +09:00
kichikuou d82175c9f5 Debugger: Add quit command 2021-07-24 17:27:13 +09:00
kichikuou 21e43b5cc7 Debugger: Support FUNC debug information
It is used to print function names in backtrace.
2021-07-24 17:27:10 +09:00
BEN ENGLISCH 5283a0aa5d Left/right select first/last menu items 2021-07-21 08:32:03 +09:00
BEN ENGLISCH 91d30c9b13 Fix mouse warping by translating coords 2021-07-21 08:32:03 +09:00
BEN ENGLISCH f66ebff002 Add integerscale option 2021-07-21 08:32:03 +09:00
BEN ENGLISCH 98e1355461 Fix midi_pause() 2021-07-21 08:32:03 +09:00
kichikuou 35b1b12ab6 Linux CI: Build with PortMidi 2021-07-19 18:59:49 +09:00
BEN ENGLISCH 1e2ea9821c Add PortMidi MIDI implementation 2021-07-19 09:09:23 +09:00
kichikuou e5fab0f198 Add source-level debugger
If -debug option is specified, xsystem35 enables built-in debugger. It
optionally loads debug information from *SA.ALD.symbols file (generated
by xsys35c), and drops into a debugger REPL.

Currently the debugger supports:
- Simple breakpoints
- Backtrace
- Single-step execution (step into / step over)
- Printing variables

Also, when the debugger is enabled SIGINT breaks execution and enters a
REPL.
2021-07-18 22:55:22 +09:00
kichikuou 2e2fbbaa1b Refactor main loop 2021-07-17 22:12:16 +09:00
kichikuou fb44e5b1e3 Add a hack to improve Rance4 map navigation
Fixes #23.

This is quite hacky but I couldn't find any cleaner solutions.
2021-07-16 14:35:00 +09:00
kichikuou 6690687d0f emscripten CI: Use standard setup-emsdk way to cache 2021-07-14 18:01:23 +09:00
kichikuou 26c9f663ca Update emscripten to 2.0.25 2021-07-14 17:46:29 +09:00
kichikuou d5a7040b54 Fix SU command
This fixes a bug in various games where waiting for sound effects to
finish was not working.

`SU var1, var2:` should set var1 to 1 if sound is playing. Before this
fix, it was set to the return value of mus_pcm_get_playposition(), which
is usually 0 (OK).
2021-07-13 21:29:58 +09:00
kichikuou 3280d6073b Android: migrate from jcenter to mavenCentral 2021-06-25 21:14:40 +09:00
kichikuou ca09dc7413 Treat font load failure as a fatal error 2021-06-19 16:29:47 +09:00
kichikuou cc60fdfb7d Android: Allow specifying custom fonts in .xsys35rc
Now custom font files specified in .xsys35rc (as relative paths from the
ZIP root) can be loaded correctly.

This fixes #20 for Android.
2021-06-03 18:58:29 +09:00
kichikuou ac703b3448 Android CI: downgrade CMake to 3.19
To workaround build error with NullPointerException
(https://github.com/actions/virtual-environments/issues/3078).
2021-05-09 22:16:17 +09:00
kichikuou 2c6a66af8f Android: Update build instructions to use CommandLine Tools 4.0 2021-05-09 22:05:54 +09:00
kichikuou fdcc3de352 Add a hack to trick LHG command error check in Diabolique
This fixes the issue where "HDD is full or CD is not inserted" error
message is displayed in Diabolique.
2021-05-09 15:00:16 +09:00
kichikuou dda7d7f077 Update emscripten to 2.0.15 2021-03-18 15:50:05 +09:00
kichikuou a159e7cb24 Show error instead of SEGV when System39.ini is missing
See #18.
2021-03-08 09:38:46 +09:00
kichikuou 785f46be2a Android Build: Update SDL2_ttf and SDL2_mixer 2021-02-22 08:45:46 +09:00
kichikuou 7ca3f2527e GTK: Stop loading custom resource file 2021-01-31 13:03:33 +09:00
kichikuou f6221a04ba GTK: Migrate off of deprecated functions 2021-01-31 13:02:14 +09:00
kichikuou 7069343e57 GTK: Crash fix
It seems SDL2 must be initialized before initializing GTK.
2021-01-31 13:00:48 +09:00
kichikuou 9be7b0ab68 Migrate from GTK 2 to GTK 3 2021-01-31 12:59:05 +09:00
kichikuou 8779763615 GTK: Do not use deprecated symbols 2021-01-31 12:58:21 +09:00
kichikuou 869e2e34dd emscripten: Enable DLL modules
And remove the ENABLE_MODULES build option.
2021-01-24 14:50:06 +09:00
kichikuou c0daba25a5 Implement ShPort.OutputMessageBox 2021-01-24 11:59:40 +09:00
kichikuou 9775c4569d Implement ShPort.InputListNum
This function is used only in hidden contents (map editor of Alice in
Kaeru nyo Land and unit editor of Daiakuji).

This implementation just calls menu_inputnumber(), while the original
ShPort.DLL shows a listbox.
2021-01-24 11:59:39 +09:00
kichikuou 21444ac1c0 NIGHTDLL: Fix a function signature mismatch 2021-01-24 11:59:34 +09:00
kichikuou d61ce9a18e SACT/NIGHTDLL: Check nact->is_quit flag in wait loops 2021-01-24 11:43:23 +09:00
kichikuou 04c3e22339 Remove setRect() and setOffset() macros 2021-01-23 23:07:12 +09:00
kichikuou 92f8120e4a Change the interpretation of color value in drawing commands
Before this, color values above 255 were directly used as the pixel
color. After this, its lower 8 bits are used as the palette index. The
new behavior matches System 3.9.
2021-01-23 23:07:12 +09:00
kichikuou 3613358b7b Fix an endian bug introduced by 4e2d81cf 2021-01-23 23:07:05 +09:00
kichikuou fc6651642d sdl_floodFill: Support 16-bit/32-bit color modes 2021-01-23 16:31:13 +09:00
kichikuou 0b15fa3506 Rewrite flood-fill routine 2021-01-23 14:58:36 +09:00
kichikuou 2f8dd2d6a5 Remove unused antialiase.c 2021-01-17 21:57:49 +09:00
kichikuou 4e2d81cf47 Use SDL byte-swapping macros 2021-01-17 21:35:27 +09:00
kichikuou 29c85aad36 emscripten: Remove EXPORTED_FUNCTIONS build option 2021-01-17 14:16:37 +09:00
kichikuou cd77cbfbf1 Remove ags_regionContains() 2021-01-09 13:43:24 +09:00
kichikuou e18bb6cb75 Make MyRectangle an alias of SDL_Rect 2021-01-09 13:43:21 +09:00
kichikuou 34e2d60ab4 Refactor s39ain_init()
Now strings in S39AIN struct are not copied with strdup(), but just
point inside the buffer where System39.ain is read.
2021-01-03 16:43:59 +09:00
kichikuou 8894dd40fa Windows: Do not let save dialog change working directory 2021-01-03 15:45:24 +09:00
kichikuou 2529a5b61b Android: Update SDL2 to 2.0.14 2021-01-01 12:34:37 +09:00
kichikuou ca41501f6d Improve rendering of fonts with descenders
- ags_drawString() returns a bounding box of the text so that callers
  can update the screen appropriately.
- Use total font height (not only ascent) for vertical positioning.
2020-12-31 12:57:17 +09:00
kichikuou 36a0e01dcd Windows: Add "Save Screenshot" menu command 2020-12-31 10:56:50 +09:00
kichikuou 81906641e1 Disable message wait (teletype effect) when skipping messages 2020-12-29 12:07:40 +09:00
kichikuou da1c136b39 Move message skip status flags from input.c to msgskip.c 2020-12-29 12:07:37 +09:00
kichikuou 9878f5ca74 Support message skip in System3.9 games without MsgSkip.DLL 2020-12-29 11:27:14 +09:00
kichikuou 6da3dfef55 Add flags that control message skip behavior 2020-12-29 10:10:52 +09:00
kichikuou be1f048b33 Tweaks for better message skip experience
- Any key input detected in skippable wait functions will cancel the
  skip mode (regardless of skipModeInterruptable value).
- Space key (right click) in sys_getInputInfo() will no longer cancel
  the skip mode.
- Add 30ms wait in sys_hit_any_key() (used by the 'A' command) so that
  users can see what's going on while skipping.
- Cancel the skip mode when opening a menu, not when closing it.
2020-12-28 22:45:51 +09:00
kichikuou 6d5831c4e8 emscripten: Support message skip 2020-12-28 22:45:47 +09:00
kichikuou 5ec0c0a7be mmap: Keep file descriptor open while mapping is alive
Emscripten expects that file descriptor used for mmap is not closed
until the map is unmapped -- otherwise it may silently break unrelated
file (https://github.com/emscripten-core/emscripten/issues/4352).
2020-12-26 09:20:46 +09:00
kichikuou 4b002c676c Support skip-seen-messages feature in pre-system3.9 games
This adds functionality equivalent to the MsgSkip module, for older
games. It is enabled if "MsgSkip" file is specified in the game resource
file.

Since messages in pre-system3.9 games don't have IDs, it uses a Bloom
filter to test whether a message has been already seen or not.
2020-12-23 14:08:02 +09:00
kichikuou f0bd336da1 Implement MsgSkip module
The format of savefile (msgskip.asd) is compatible with AliceSoft's
MsgSkip.dll; a 4-byte size field followed by a bitmap indexed by message
ID.
2020-12-22 16:35:37 +09:00
kichikuou 704cfda6ef Windows: Implement wmenuEnableMsgSkip command 2020-12-20 10:17:49 +09:00
kichikuou c0de87d0d8 Refactoring: Remove sdl_keywait() 2020-12-13 14:54:15 +09:00
kichikuou 3964a1bc27 Simplify joystick code 2020-12-13 14:28:59 +09:00
kichikuou b765332c27 Enable specifying joystick device
Before this, value of joy_device config parameter (-devjoy in command
line) was ignored. After this, this parameter will take an integer value
and will be used as the device_index argument of SDL_JoystickOpen().

This also removes obsolete doc/README.joystick.
2020-12-13 13:27:42 +09:00
kichikuou 9f9805128f Improve message skip
When message skip is enabled while executing sys_keywait(), skip starts
immediately.
2020-12-13 12:29:09 +09:00
kichikuou ba0d59d5a4 Windows: Add message-skip menu item 2020-12-12 18:09:55 +09:00
kichikuou d531fa3994 Refactor fullscreen code 2020-12-12 16:21:10 +09:00
kichikuou 4d5fd5efca Windows: Add menubar 2020-12-12 16:20:53 +09:00
kichikuou 89a4ba2bd2 Update emscripten to 2.0.7 2020-10-24 14:45:42 +09:00
kichikuou 163c23af81 emscripten: Add SDL_Delay() to ASYNCIFY_REMOVE
This is safe because we use SDL_HINT_EMSCRIPTEN_ASYNCIFY = 0. This
significantly reduces the number of Asyncified functions and reduces the
wasm code size by 80kb.
2020-10-24 14:42:06 +09:00
kichikuou 48d937a0c3 Android: Version 0.2.3 2020-10-18 14:56:32 +09:00
kichikuou 4aff7a1df7 Android: Fix StringIndexOutOfBoundsException in text input dialog 2020-10-18 14:56:32 +09:00
kichikuou 303510e5c0 Windows: Implement text input dialog 2020-10-11 23:02:55 +09:00
kichikuou c7263a3082 CMake: Add -Wall for debug builds 2020-10-11 21:31:32 +09:00
kichikuou aea53c1079 Clean up GTK menu code 2020-10-11 21:31:25 +09:00
kichikuou 32f1e1ef8a CI: Address deprecation of add-path and set-env 2020-10-11 17:37:07 +09:00
kichikuou 500fffaee2 Refactor hankaku.c 2020-10-11 15:07:43 +09:00
kichikuou ebe3762809 Remove SDL_AllocSurface macro
It was for transition from SDL1.
2020-10-04 16:02:10 +09:00
kichikuou 4fd00a9088 CMake: Build modules as a single library 2020-10-04 16:02:10 +09:00
kichikuou 44d0ddcec7 Use SDL renderer to draw lines 2020-10-04 16:02:10 +09:00
kichikuou 9541f3f85a Make image_Mosaic operate on SDL_Surface 2020-10-04 16:02:10 +09:00
kichikuou b5c8b158c6 Make image_fade{In,Out} operate on SDL_Surface instead of agsurface_t 2020-10-04 16:02:10 +09:00
kichikuou 8d91657c14 Do not create agsurface_t in font.c 2020-10-04 16:02:10 +09:00
kichikuou ebb249cd47 Remove 15bpp surface operations
These were used only with X11 backend.
2020-10-04 16:01:48 +09:00
kichikuou 379ca744d5 Remove BGR-order macros 2020-10-04 15:35:51 +09:00
kichikuou b892189f8b Fix selection menu painting
The new behavior matches System 3.9.

- Use sel.WinFrameColor to draw selection cursor in EncloseType=0
- Implement EncloseType=1 (thick selection cursor)
  - It always uses color 255, not WinFrameColor (System 3.9 bug?)
- EncloseType=2 uses MsgFontColor for background, WinBackgroundColor for
  text
2020-10-04 09:14:19 +09:00
kichikuou f1b4c2550b Simplify font code 2020-10-04 09:14:16 +09:00
kichikuou 79c9bfc85a Drop ft2 font device
This makes sdlttf the only font device, and allows code simplification.
2020-10-03 14:54:48 +09:00
kichikuou 042f333564 Remove graphicsdevice.h 2020-10-01 22:19:58 +09:00
kichikuou 417baec290 Remove ags_sync() 2020-10-01 22:16:50 +09:00
kichikuou ec270f2378 Remove X11/SDL abstraction macros 2020-10-01 22:10:12 +09:00
kichikuou 55837e5115 Remove xcore graphics backend
This removes X11 specific code, making SDL2 a hard dependency.
X-based environments are continue to be supported via SDL2.

This also removes joystick_linux.c which was only used if SDL2 was not
available.
2020-10-01 21:27:59 +09:00
216 changed files with 6041 additions and 10277 deletions
+6
View File
@@ -11,6 +11,12 @@ jobs:
- name: Install Deps
run: sudo apt install ninja-build
# Workaround for https://github.com/actions/virtual-environments/issues/3078
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1.9
with:
cmake-version: '3.19.x'
- name: Build
run: |
cd android
+9 -11
View File
@@ -2,7 +2,8 @@ name: Emscripten Build
on: [push, pull_request]
env:
emscripten-version: 1.40.1
EM_VERSION: 2.0.25
EM_CACHE_FOLDER: 'emsdk-cache'
jobs:
build:
@@ -11,24 +12,21 @@ jobs:
- uses: actions/checkout@v2
- name: Cache .emscripten_cache
- name: Setup cache
id: cache-system-libraries
uses: actions/cache@v2
with:
path: emscripten-cache
key: emscripten-cache-${{ env.emscripten-version }}
path: ${{env.EM_CACHE_FOLDER}}
key: ${{env.EM_VERSION}}-${{ runner.os }}
- name: Setup Emscripten toolchain
uses: mymindstorm/setup-emsdk@v6
uses: mymindstorm/setup-emsdk@v10
with:
version: ${{ env.emscripten-version }}
actions-cache-folder: emsdk-cache
version: ${{ env.EM_VERSION }}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
- name: Build
env:
EM_CACHE: ${{ github.workspace }}/emscripten-cache/cache
EM_PORTS: ${{ github.workspace }}/emscripten-cache/ports
run: |
mkdir -p emscripten-cache
mkdir -p out/wasm
cd out/wasm
emcmake cmake -DCMAKE_BUILD_TYPE=MinSizeRel ../../
+2 -25
View File
@@ -15,38 +15,15 @@ jobs:
- name: Install Deps
run: |
sudo apt update
sudo apt install libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev
sudo apt install libgtk-3-dev libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libportmidi-dev libcjson-dev
- name: Build
run: |
mkdir -p out/${{ matrix.build-type }}
cd out/${{ matrix.build-type }}
cmake -DENABLE_X11=NO -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} ../../
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} ../../
make
- name: Test
run: ctest --output-on-failure
working-directory: out/${{ matrix.build-type }}
build-x11:
runs-on: ubuntu-latest
name: Linux X11
steps:
- uses: actions/checkout@v2
- name: Install Deps
run: |
sudo apt update
sudo apt install libgtk2.0-dev
- name: Build
run: |
mkdir -p out
cd out
cmake ../
make
- name: Test
run: ctest --output-on-failure
working-directory: out
+5 -5
View File
@@ -24,7 +24,7 @@ jobs:
steps:
- name: Set up shell
run: echo ::add-path::C:\msys64\usr\bin\
run: echo "C:\msys64\usr\bin\" >> $env:GITHUB_PATH
shell: pwsh
- name: Print system version
@@ -33,7 +33,7 @@ jobs:
echo PATH: $PATH
- name: Install Deps
run: pacman -S --noconfirm ${{ matrix.package }}-SDL2 ${{ matrix.package }}-SDL2_ttf ${{ matrix.package }}-SDL2_mixer ${{ matrix.package }}-libjpeg-turbo ${{ matrix.package }}-nsis ${{ matrix.package }}-ntldd-git
run: pacman -S --noconfirm ${{ matrix.package }}-SDL2 ${{ matrix.package }}-SDL2_ttf ${{ matrix.package }}-SDL2_mixer ${{ matrix.package }}-libjpeg-turbo ${{ matrix.package }}-cjson ${{ matrix.package }}-nsis ${{ matrix.package }}-ntldd-git
- name: Checkout
uses: actions/checkout@v2
@@ -50,11 +50,11 @@ jobs:
working-directory: out/release
- name: Package
working-directory: installer
run: ./make-installer.sh ../out/release ${{ matrix.installer }}.nsi
working-directory: tools/installer
run: ./make-installer.sh ../../out/release ${{ matrix.installer }}.nsi
- name: Upload
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.installer }}
path: installer/${{ matrix.installer }}.exe
path: tools/installer/${{ matrix.installer }}.exe
+4
View File
@@ -3,3 +3,7 @@ android/.gradle
android/app/.externalNativeBuild
android/app/build
android/build
.ccls-cache
.dir-locals.el
compile_commands.json
build
+42 -95
View File
@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.13)
project(xsystem35 LANGUAGES C)
set(CMAKE_C_STANDARD 99)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
enable_testing()
include(CheckIncludeFile)
@@ -14,14 +15,6 @@ if (MSYS)
list(APPEND CMAKE_LIBRARY_PATH $ENV{MINGW_PREFIX}/$ENV{MINGW_CHOST}/lib)
endif ()
# A wrapper around find_package() that skips the check if ENABLE_<package> is false
macro (optional_find_package package)
option(ENABLE_${package} "Use ${package} if available" ON)
if (ENABLE_${package})
find_package(${package} ${ARGN})
endif()
endmacro()
# A wrapper around pkg_check_modules() that skips the check if ENABLE_<prefix> is false
macro (optional_pkg_check_modules prefix)
option(ENABLE_${prefix} "Use ${prefix} if available" ON)
@@ -36,75 +29,62 @@ check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION)
check_symbol_exists(uname "sys/utsname.h" HAVE_UNAME)
if (EMSCRIPTEN)
set(SDL2_FOUND 1)
set(FREETYPE_FOUND 1)
set(HAVE_JPEG 1)
set(DEFAULT_FONT_PATH /fonts/)
elseif (ANDROID)
if (NOT DEFINED ENABLE_MODULES)
set(ENABLE_MODULES 1)
endif()
set(SDL2_FOUND 1)
set(SDL2MIXER_FOUND 1)
set(SDL2TTF_FOUND 1)
find_library(ndk_zlib z)
find_library(ndk_log log)
else()
include(TestBigEndian)
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
if (NOT DEFINED ENABLE_MODULES)
set(ENABLE_MODULES 1)
endif()
find_package(ZLIB REQUIRED)
optional_find_package(X11)
if (X11_xf86vmode_FOUND)
set(HAVE_XF86VMODE 1)
endif()
optional_find_package(GTK2 COMPONENTS gtk)
if (GTK2_FOUND)
include(FindPkgConfig)
optional_pkg_check_modules(GTK3 IMPORTED_TARGET gtk+-3.0)
if (GTK3_FOUND)
set(ENABLE_GTK 1)
endif()
optional_find_package(Freetype)
include(FindPkgConfig)
optional_pkg_check_modules(SDL2 IMPORTED_TARGET sdl2)
pkg_check_modules(SDL2 IMPORTED_TARGET sdl2)
pkg_check_modules(SDL2TTF IMPORTED_TARGET SDL2_ttf)
optional_pkg_check_modules(SDL2MIXER IMPORTED_TARGET SDL2_mixer)
optional_pkg_check_modules(SDL2TTF IMPORTED_TARGET SDL2_ttf)
option(ENABLE_DEBUGGER "Enable built-in debugger" ON)
if (ENABLE_DEBUGGER)
pkg_check_modules(cJSON IMPORTED_TARGET libcjson)
if (NOT cJSON_FOUND)
# libcjson-dev of Debian buster / Ubuntu 20.04 does not install pkgconfig files.
find_library(cJSON cjson)
if (NOT cJSON)
message(FATAL_ERROR "libcjson is required but not found.")
endif()
endif()
endif()
include(FindJPEG)
if (JPEG_FOUND)
set(HAVE_JPEG 1)
endif()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads)
if (CMAKE_USE_PTHREADS_INIT)
find_library(PORTMIDI portmidi)
if (PORTMIDI)
set(HAVE_PORTMIDI 1)
set(ENABLE_MIDI_PORTMIDI 1)
endif()
endif()
set(DEFAULT_FONT_PATH ${CMAKE_INSTALL_PREFIX}/share/xsystem35/fonts/)
endif()
# Graphics
if (X11_FOUND)
set(SRC_GRAPHDEV xcore_draw.c xcore_video.c xcore_mode.c xcore_event.c xcore_cursor.c xcore_maskupdate.c image.c xcore_image.c)
set(SUMMARY_GRAPHDEV "X11")
elseif (SDL2_FOUND)
set(SRC_GRAPHDEV sdl_video.c sdl_draw.c sdl_event.c sdl_image.c sdl_cursor.c image.c)
set(SUMMARY_GRAPHDEV "SDL2")
set(ENABLE_SDL 1)
else()
message(FATAL_ERROR "*** No graphic device available ***")
endif()
# Menu
if (EMSCRIPTEN)
set(SRC_MENU menu_emscripten.c)
elseif (ANDROID)
set(SRC_MENU menu_android.c)
elseif (GTK2_FOUND)
elseif (ENABLE_GTK)
set(SRC_MENU menu.c menu_callback.c menu_gui.c s39init.c)
# i18n support (currently only menus are translated)
@@ -116,20 +96,18 @@ elseif (GTK2_FOUND)
include_directories(${Intl_INCLUDE_DIRS})
link_libraries(${Intl_LIBRARIES})
endif()
elseif (ENABLE_SDL)
set(SRC_MENU menu_sdl.c sdl_input.c)
else ()
set(SRC_MENU menu_null.c)
set(SRC_MENU menu_sdl.c sdl_input.c)
endif()
# PCM audio
if (EMSCRIPTEN)
list(APPEND SRC_AUDIO)
list(APPEND SRC_AUDIO pcm.emscripten.c bgm.dummy.c)
list(APPEND SRC_AUDIO pcm.emscripten.c bgm.emscripten.c bgi.c)
list(APPEND SUMMARY_AUDIO "Emscripten")
elseif (SDL2MIXER_FOUND)
list(APPEND SRC_AUDIO pcm.sdlmixer.c bgm.sdlmixer.c)
list(APPEND SRC_AUDIO pcm.sdlmixer.c bgm.sdlmixer.c bgi.c)
list(APPEND SUMMARY_AUDIO "SDL_mixer")
set(ENABLE_SDLMIXER 1)
else()
@@ -188,6 +166,7 @@ else()
else ()
check_symbol_exists(SNDCTL_SEQ_NRSYNTHS "sys/soundcard.h" ENABLE_MIDI_SEQMIDI)
endif()
if (ENABLE_MIDI_SEQMIDI)
list(APPEND SUMMARY_MIDI "OSS sequencer")
set(SEQ_DEVICE "/dev/sequencer" CACHE STRING "sequencer device")
@@ -198,46 +177,18 @@ else()
list(APPEND SUMMARY_MIDI "SDL_mixer")
set(ENABLE_MIDI_SDLMIXER 1)
endif()
if (HAVE_PORTMIDI AND ENABLE_MIDI_PORTMIDI)
list(APPEND SRC_MIDI midi.portmidi.c)
list(APPEND SUMMARY_MIDI "PortMidi")
link_libraries(${PORTMIDI} Threads::Threads)
endif()
endif()
# Joystick
if (EMSCRIPTEN OR ANDROID)
set(SRC_JOYSTICK joystick_dmy.c)
elseif (ENABLE_SDL)
set(SRC_JOYSTICK joystick_sdl.c)
set(SUMMARY_JOYSTICK "SDL")
if (NOT EMSCRIPTEN AND NOT ANDROID)
set(HAVE_SDLJOY 1)
else()
check_include_file(linux/joystick.h HAVE_LINUX_JOYSTICK_H)
if (HAVE_LINUX_JOYSTICK_H)
set(SRC_JOYSTICK joystick_linux.c)
set(SUMMARY_JOYSTICK "Linux ioctl")
set(JOY_DEVICE "/dev/js0" CACHE STRING "joystick device")
else ()
set(SRC_JOYSTICK joystick_dmy.c)
endif ()
endif()
# Font
if (X11_FOUND)
list(APPEND SRC_FONT font_x11.c)
list(APPEND SUMMARY_FONT "x11")
set(ENABLE_X11FONT 1)
endif()
if (FREETYPE_FOUND)
list(APPEND SRC_FONT font_freetype2.c)
list(APPEND SUMMARY_FONT "freetype2")
set(ENABLE_FT2 1)
endif()
if (NOT X11_FOUND AND SDL2TTF_FOUND)
list(APPEND SRC_FONT font_sdlttf.c)
list(APPEND SUMMARY_FONT "SDL_ttf")
set(ENABLE_SDLTTF 1)
endif()
if (NOT SRC_FONT)
message(FATAL_ERROR "*** No font device available ***")
endif()
# TODO: MMX
@@ -253,11 +204,9 @@ endfunction()
message("xsystem35 summary:")
message("------------------")
print_summary(graphics ${SUMMARY_GRAPHDEV})
print_summary(audio ${SUMMARY_AUDIO})
print_summary(cdrom ${SUMMARY_CDROM})
print_summary(midi ${SUMMARY_MIDI})
print_summary(font ${SUMMARY_FONT})
print_summary(joystick ${SUMMARY_JOYSTICK})
message("------------------")
@@ -274,7 +223,5 @@ if (ENABLE_NLS)
add_subdirectory(po)
endif()
if (ENABLE_MODULES)
add_subdirectory(modules)
target_link_libraries(xsystem35 PRIVATE modules)
endif()
add_subdirectory(modules)
target_link_libraries(xsystem35 PRIVATE modules)
+3 -5
View File
@@ -8,19 +8,17 @@ Prebuilt binaries for Windows and Android can be downloaded from the [Releases](
## Build
### Linux (Debian / Ubuntu)
$ sudo apt install build-essential cmake libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev
$ sudo apt install build-essential cmake libgtk-3-dev libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libcjson-dev
$ mkdir -p out/debug
$ cd out/debug
$ cmake -DCMAKE_BUILD_TYPE=Debug ../../
$ make && make install
You can choose between X11 and SDL2 as the graphics backend. If both libraries are found, X11 is used by default, but if `-DENABLE_X11=NO` flag is given to the `cmake` invocation, then SDL2 will be used.
### MacOS
[Homebrew](https://brew.sh/index_ja) is needed.
$ brew install cmake pkg-config sdl2 sdl2_mixer freetype libjpeg
$ brew install cmake pkg-config sdl2 sdl2_mixer sdl2_ttf libjpeg cjson
$ mkdir -p out/debug
$ cd out/debug
$ cmake -DCMAKE_BUILD_TYPE=Debug ../../
@@ -30,7 +28,7 @@ You can choose between X11 and SDL2 as the graphics backend. If both libraries a
[MSYS2](https://www.msys2.org) is needed.
$ pacman -S cmake mingw-w64-x86_64-cmake mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_ttf mingw-w64-x86_64-SDL2_mixer mingw-w64-x86_64-libjpeg-turbo
$ pacman -S cmake mingw-w64-x86_64-cmake mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_ttf mingw-w64-x86_64-SDL2_mixer mingw-w64-x86_64-libjpeg-turbo mingw-w64-x86_64-cjson
$ mkdir -p out/debug
$ cd out/debug
$ cmake -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Debug ../../
+3 -2
View File
@@ -23,8 +23,9 @@ sudo apt install git wget unzip default-jdk-headless cmake ninja-build
# Install Android SDK / NDK
export ANDROID_SDK_ROOT=$HOME/android-sdk
mkdir -p $ANDROID_SDK_ROOT/cmdline-tools
wget https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip
unzip commandlinetools-linux-6609375_latest.zip -d $ANDROID_SDK_ROOT/cmdline-tools
wget https://dl.google.com/android/repository/commandlinetools-linux-7302050_latest.zip
unzip commandlinetools-linux-7302050_latest.zip -d $ANDROID_SDK_ROOT/cmdline-tools
mv $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/tools
yes |$ANDROID_SDK_ROOT/cmdline-tools/tools/bin/sdkmanager --licenses
$ANDROID_SDK_ROOT/cmdline-tools/tools/bin/sdkmanager ndk-bundle
export ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk-bundle
+2 -2
View File
@@ -16,8 +16,8 @@ android {
}
minSdkVersion 19
targetSdkVersion 28
versionCode 4
versionName "0.2.1"
versionCode 5
versionName "0.2.3"
externalNativeBuild {
cmake {
arguments "-DANDROID_APP_PLATFORM=android-16", "-DANDROID_STL=c++_static"
+6 -10
View File
@@ -9,21 +9,21 @@ project(GAME)
include(FetchContent)
FetchContent_Declare(
SDL
URL http://libsdl.org/release/SDL2-2.0.12.tar.gz
URL_HASH SHA1=e8ba91bf5eb438dbcf1fedf0530a1bcbe30d3bb6
URL https://libsdl.org/release/SDL2-2.0.16.tar.gz
URL_HASH SHA1=57825428174adb2ac947e4014080c262505aa972
PATCH_COMMAND patch -p1 -i ${CMAKE_CURRENT_LIST_DIR}/SDL.patch
)
# TODO: Use SDL2_ttf 2.0.16 once released
FetchContent_Declare(
SDL_ttf
URL https://hg.libsdl.org/SDL_ttf/archive/d56d67db41d8.tar.gz # rev 420
URL_HASH SHA1=143089a2b2973a5baeee0914af43608cfe8e1d87
GIT_REPOSITORY https://github.com/libsdl-org/SDL_ttf.git
GIT_TAG 11722a2bb4335d489d724c08cfdbb45f97d07aa7
)
# TODO: Use SDL2_mixer 2.0.5 once released
FetchContent_Declare(
SDL_mixer
URL https://hg.libsdl.org/SDL_mixer/archive/d2686bcfcba2.tar.gz # rev 1127
URL_HASH SHA1=4e62e29bd5628b262b3ffb6d5d29861c76a1500e
GIT_REPOSITORY https://github.com/libsdl-org/SDL_mixer.git
GIT_TAG 20433729fb318f7b6f773a42ffa410114cb067f2
)
# Compilation of SDL and companion libraries
@@ -42,10 +42,6 @@ if(NOT sdl_mixer_POPULATED)
FetchContent_Populate(SDL_mixer)
SET(SUPPORT_OGG ON CACHE BOOL "Enable OGG support in SDL_mixer" FORCE)
add_subdirectory(${sdl_mixer_SOURCE_DIR} ${sdl_mixer_BINARY_DIR})
# Workaround for CMakeLists.txt bugs of SDL_mixer.
# TODO: Fix these in upstream
add_library(vorbisfile INTERFACE)
target_include_directories(SDL2_mixer PUBLIC ${sdl_mixer_SOURCE_DIR}/include)
target_compile_definitions(SDL2_mixer PRIVATE MUSIC_WAV)
endif()
+1 -1
View File
@@ -74,7 +74,7 @@
<activity android:name=".GameActivity"
android:label="@string/app_name"
android:alwaysRetainTaskState="true"
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
android:configChanges="layoutDirection|locale|orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:hardwareAccelerated="true"
>
@@ -86,7 +86,8 @@ class GameActivity : SDLActivity() {
.setMessage(msg)
.setView(input)
.setPositiveButton(R.string.ok) {_, _ ->
result[0] = input.text.toString().substring(0, maxLen)
val s = input.text.toString()
result[0] = if (s.length <= maxLen) s else s.substring(0, maxLen)
}
.setNegativeButton(R.string.cancel) {_, _ -> }
.setOnDismissListener {
@@ -7,6 +7,7 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothProfile;
import android.os.Build;
import android.util.Log;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -275,6 +276,7 @@ public class HIDDeviceManager {
0x15e4, // Numark
0x162e, // Joytech
0x1689, // Razer Onza
0x1949, // Lab126, Inc.
0x1bad, // Harmonix
0x24c6, // PowerA
};
@@ -353,9 +355,18 @@ public class HIDDeviceManager {
private void connectHIDDeviceUSB(UsbDevice usbDevice) {
synchronized (this) {
int interface_mask = 0;
for (int interface_index = 0; interface_index < usbDevice.getInterfaceCount(); interface_index++) {
UsbInterface usbInterface = usbDevice.getInterface(interface_index);
if (isHIDDeviceInterface(usbDevice, usbInterface)) {
// Check to see if we've already added this interface
// This happens with the Xbox Series X controller which has a duplicate interface 0, which is inactive
int interface_id = usbInterface.getId();
if ((interface_mask & (1 << interface_id)) != 0) {
continue;
}
interface_mask |= (1 << interface_id);
HIDDeviceUSB device = new HIDDeviceUSB(this, usbDevice, interface_index);
int id = device.getId();
mDevicesById.put(id, device);
@@ -373,6 +384,11 @@ public class HIDDeviceManager {
return;
}
if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE) || (Build.VERSION.SDK_INT < 18)) {
Log.d(TAG, "Couldn't initialize Bluetooth, this version of Android does not support Bluetooth LE");
return;
}
// Find bonded bluetooth controllers and create SteamControllers for them
mBluetoothManager = (BluetoothManager)mContext.getSystemService(Context.BLUETOOTH_SERVICE);
if (mBluetoothManager == null) {
@@ -53,7 +53,12 @@ class HIDDeviceUSB implements HIDDevice {
public String getSerialNumber() {
String result = null;
if (Build.VERSION.SDK_INT >= 21) {
result = mDevice.getSerialNumber();
try {
result = mDevice.getSerialNumber();
}
catch (SecurityException exception) {
//Log.w(TAG, "App permissions mean we cannot get serial number for device " + getDeviceName() + " message: " + exception.getMessage());
}
}
if (result == null) {
result = "";
@@ -2,7 +2,8 @@ package org.libsdl.app;
import android.content.Context;
import java.lang.reflect.*;
import java.lang.Class;
import java.lang.reflect.Method;
/**
SDL library initialization
@@ -51,16 +52,16 @@ public class SDL {
// To use ReLinker, just add it as a dependency. For more information, see
// https://github.com/KeepSafe/ReLinker for ReLinker's repository.
//
Class relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker");
Class relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener");
Class contextClass = mContext.getClassLoader().loadClass("android.content.Context");
Class stringClass = mContext.getClassLoader().loadClass("java.lang.String");
Class<?> relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker");
Class<?> relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener");
Class<?> contextClass = mContext.getClassLoader().loadClass("android.content.Context");
Class<?> stringClass = mContext.getClassLoader().loadClass("java.lang.String");
// Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if
// they've changed during updates.
Method forceMethod = relinkClass.getDeclaredMethod("force");
Object relinkInstance = forceMethod.invoke(null);
Class relinkInstanceClass = relinkInstance.getClass();
Class<?> relinkInstanceClass = relinkInstance.getClass();
// Actually load the library!
Method loadMethod = relinkInstanceClass.getDeclaredMethod("loadLibrary", contextClass, stringClass, stringClass, relinkListenerClass);
@@ -77,7 +78,7 @@ public class SDL {
catch (final SecurityException se) {
throw se;
}
}
}
}
protected static Context mContext;
File diff suppressed because it is too large Load Diff
@@ -1,6 +1,10 @@
package org.libsdl.app;
import android.media.*;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
import android.media.AudioTrack;
import android.media.MediaRecorder;
import android.os.Build;
import android.util.Log;
@@ -199,7 +203,6 @@ public class SDLAudioManager
results[0] = mAudioRecord.getSampleRate();
results[1] = mAudioRecord.getAudioFormat();
results[2] = mAudioRecord.getChannelCount();
results[3] = desiredFrames;
} else {
if (mAudioTrack == null) {
@@ -223,8 +226,8 @@ public class SDLAudioManager
results[0] = mAudioTrack.getSampleRate();
results[1] = mAudioTrack.getAudioFormat();
results[2] = mAudioTrack.getChannelCount();
results[3] = desiredFrames;
}
results[3] = desiredFrames;
Log.v(TAG, "Opening " + (isCapture ? "capture" : "playback") + ", got " + results[3] + " frames of " + results[2] + " channel " + getAudioFormatString(results[1]) + " audio at " + results[0] + " Hz");
@@ -6,9 +6,14 @@ import java.util.Comparator;
import java.util.List;
import android.content.Context;
import android.os.*;
import android.view.*;
import android.os.Build;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.util.Log;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
public class SDLControllerManager
@@ -98,7 +103,7 @@ public class SDLControllerManager
int sources = device.getSources();
/* This is called for every button press, so let's not spam the logs */
/**
/*
if ((sources & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
Log.v(TAG, "Input device " + device.getName() + " has class joystick.");
}
@@ -108,7 +113,7 @@ public class SDLControllerManager
if ((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) {
Log.v(TAG, "Input device " + device.getName() + " is a gamepad.");
}
**/
*/
return ((sources & InputDevice.SOURCE_CLASS_JOYSTICK) != 0 ||
((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) ||
@@ -167,7 +172,7 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler {
}
}
private ArrayList<SDLJoystick> mJoysticks;
private final ArrayList<SDLJoystick> mJoysticks;
public SDLJoystickHandler_API16() {
@@ -177,13 +182,14 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler {
@Override
public void pollInputDevices() {
int[] deviceIds = InputDevice.getDeviceIds();
for(int i=0; i < deviceIds.length; ++i) {
SDLJoystick joystick = getJoystick(deviceIds[i]);
if (joystick == null) {
joystick = new SDLJoystick();
InputDevice joystickDevice = InputDevice.getDevice(deviceIds[i]);
if (SDLControllerManager.isDeviceSDLJoystick(deviceIds[i])) {
joystick.device_id = deviceIds[i];
for (int device_id : deviceIds) {
if (SDLControllerManager.isDeviceSDLJoystick(device_id)) {
SDLJoystick joystick = getJoystick(device_id);
if (joystick == null) {
InputDevice joystickDevice = InputDevice.getDevice(device_id);
joystick = new SDLJoystick();
joystick.device_id = device_id;
joystick.name = joystickDevice.getName();
joystick.desc = getJoystickDescriptor(joystickDevice);
joystick.axes = new ArrayList<InputDevice.MotionRange>();
@@ -191,53 +197,57 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler {
List<InputDevice.MotionRange> ranges = joystickDevice.getMotionRanges();
Collections.sort(ranges, new RangeComparator());
for (InputDevice.MotionRange range : ranges ) {
for (InputDevice.MotionRange range : ranges) {
if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
if (range.getAxis() == MotionEvent.AXIS_HAT_X ||
range.getAxis() == MotionEvent.AXIS_HAT_Y) {
if (range.getAxis() == MotionEvent.AXIS_HAT_X || range.getAxis() == MotionEvent.AXIS_HAT_Y) {
joystick.hats.add(range);
}
else {
} else {
joystick.axes.add(range);
}
}
}
mJoysticks.add(joystick);
SDLControllerManager.nativeAddJoystick(joystick.device_id, joystick.name, joystick.desc, getVendorId(joystickDevice), getProductId(joystickDevice), false, getButtonMask(joystickDevice), joystick.axes.size(), joystick.hats.size()/2, 0);
SDLControllerManager.nativeAddJoystick(joystick.device_id, joystick.name, joystick.desc,
getVendorId(joystickDevice), getProductId(joystickDevice), false,
getButtonMask(joystickDevice), joystick.axes.size(), joystick.hats.size()/2, 0);
}
}
}
/* Check removed devices */
ArrayList<Integer> removedDevices = new ArrayList<Integer>();
for(int i=0; i < mJoysticks.size(); i++) {
int device_id = mJoysticks.get(i).device_id;
int j;
for (j=0; j < deviceIds.length; j++) {
if (device_id == deviceIds[j]) break;
ArrayList<Integer> removedDevices = null;
for (SDLJoystick joystick : mJoysticks) {
int device_id = joystick.device_id;
int i;
for (i = 0; i < deviceIds.length; i++) {
if (device_id == deviceIds[i]) break;
}
if (j == deviceIds.length) {
removedDevices.add(Integer.valueOf(device_id));
if (i == deviceIds.length) {
if (removedDevices == null) {
removedDevices = new ArrayList<Integer>();
}
removedDevices.add(device_id);
}
}
for(int i=0; i < removedDevices.size(); i++) {
int device_id = removedDevices.get(i).intValue();
SDLControllerManager.nativeRemoveJoystick(device_id);
for (int j=0; j < mJoysticks.size(); j++) {
if (mJoysticks.get(j).device_id == device_id) {
mJoysticks.remove(j);
break;
if (removedDevices != null) {
for (int device_id : removedDevices) {
SDLControllerManager.nativeRemoveJoystick(device_id);
for (int i = 0; i < mJoysticks.size(); i++) {
if (mJoysticks.get(i).device_id == device_id) {
mJoysticks.remove(i);
break;
}
}
}
}
}
protected SDLJoystick getJoystick(int device_id) {
for(int i=0; i < mJoysticks.size(); i++) {
if (mJoysticks.get(i).device_id == device_id) {
return mJoysticks.get(i);
for (SDLJoystick joystick : mJoysticks) {
if (joystick.device_id == device_id) {
return joystick;
}
}
return null;
@@ -248,25 +258,21 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler {
if ((event.getSource() & InputDevice.SOURCE_JOYSTICK) != 0) {
int actionPointerIndex = event.getActionIndex();
int action = event.getActionMasked();
switch(action) {
case MotionEvent.ACTION_MOVE:
SDLJoystick joystick = getJoystick(event.getDeviceId());
if ( joystick != null ) {
for (int i = 0; i < joystick.axes.size(); i++) {
InputDevice.MotionRange range = joystick.axes.get(i);
/* Normalize the value to -1...1 */
float value = ( event.getAxisValue( range.getAxis(), actionPointerIndex) - range.getMin() ) / range.getRange() * 2.0f - 1.0f;
SDLControllerManager.onNativeJoy(joystick.device_id, i, value );
}
for (int i = 0; i < joystick.hats.size(); i+=2) {
int hatX = Math.round(event.getAxisValue( joystick.hats.get(i).getAxis(), actionPointerIndex ) );
int hatY = Math.round(event.getAxisValue( joystick.hats.get(i+1).getAxis(), actionPointerIndex ) );
SDLControllerManager.onNativeHat(joystick.device_id, i/2, hatX, hatY );
}
if (action == MotionEvent.ACTION_MOVE) {
SDLJoystick joystick = getJoystick(event.getDeviceId());
if (joystick != null) {
for (int i = 0; i < joystick.axes.size(); i++) {
InputDevice.MotionRange range = joystick.axes.get(i);
/* Normalize the value to -1...1 */
float value = (event.getAxisValue(range.getAxis(), actionPointerIndex) - range.getMin()) / range.getRange() * 2.0f - 1.0f;
SDLControllerManager.onNativeJoy(joystick.device_id, i, value);
}
break;
default:
break;
for (int i = 0; i < joystick.hats.size() / 2; i++) {
int hatX = Math.round(event.getAxisValue(joystick.hats.get(2 * i).getAxis(), actionPointerIndex));
int hatY = Math.round(event.getAxisValue(joystick.hats.get(2 * i + 1).getAxis(), actionPointerIndex));
SDLControllerManager.onNativeHat(joystick.device_id, i, hatX, hatY);
}
}
}
}
return true;
@@ -432,13 +438,13 @@ class SDLHapticHandler_API26 extends SDLHapticHandler {
class SDLHapticHandler {
class SDLHaptic {
static class SDLHaptic {
public int device_id;
public String name;
public Vibrator vib;
}
private ArrayList<SDLHaptic> mHaptics;
private final ArrayList<SDLHaptic> mHaptics;
public SDLHapticHandler() {
mHaptics = new ArrayList<SDLHaptic>();
@@ -504,37 +510,41 @@ class SDLHapticHandler {
}
/* Check removed devices */
ArrayList<Integer> removedDevices = new ArrayList<Integer>();
for(int i=0; i < mHaptics.size(); i++) {
int device_id = mHaptics.get(i).device_id;
int j;
for (j=0; j < deviceIds.length; j++) {
if (device_id == deviceIds[j]) break;
ArrayList<Integer> removedDevices = null;
for (SDLHaptic haptic : mHaptics) {
int device_id = haptic.device_id;
int i;
for (i = 0; i < deviceIds.length; i++) {
if (device_id == deviceIds[i]) break;
}
if (device_id == deviceId_VIBRATOR_SERVICE && hasVibratorService) {
// don't remove the vibrator if it is still present
} else if (j == deviceIds.length) {
removedDevices.add(device_id);
}
if (device_id != deviceId_VIBRATOR_SERVICE || !hasVibratorService) {
if (i == deviceIds.length) {
if (removedDevices == null) {
removedDevices = new ArrayList<Integer>();
}
removedDevices.add(device_id);
}
} // else: don't remove the vibrator if it is still present
}
for(int i=0; i < removedDevices.size(); i++) {
int device_id = removedDevices.get(i);
SDLControllerManager.nativeRemoveHaptic(device_id);
for (int j=0; j < mHaptics.size(); j++) {
if (mHaptics.get(j).device_id == device_id) {
mHaptics.remove(j);
break;
if (removedDevices != null) {
for (int device_id : removedDevices) {
SDLControllerManager.nativeRemoveHaptic(device_id);
for (int i = 0; i < mHaptics.size(); i++) {
if (mHaptics.get(i).device_id == device_id) {
mHaptics.remove(i);
break;
}
}
}
}
}
protected SDLHaptic getHaptic(int device_id) {
for(int i=0; i < mHaptics.size(); i++) {
if (mHaptics.get(i).device_id == device_id) {
return mHaptics.get(i);
for (SDLHaptic haptic : mHaptics) {
if (haptic.device_id == device_id) {
return haptic;
}
}
return null;
@@ -655,8 +665,7 @@ class SDLGenericMotionListener_API24 extends SDLGenericMotionListener_API12 {
public float getEventX(MotionEvent event) {
if (mRelativeModeEnabled) {
return event.getAxisValue(MotionEvent.AXIS_RELATIVE_X);
}
else {
} else {
return event.getX(0);
}
}
@@ -665,14 +674,12 @@ class SDLGenericMotionListener_API24 extends SDLGenericMotionListener_API12 {
public float getEventY(MotionEvent event) {
if (mRelativeModeEnabled) {
return event.getAxisValue(MotionEvent.AXIS_RELATIVE_Y);
}
else {
} else {
return event.getY(0);
}
}
}
class SDLGenericMotionListener_API26 extends SDLGenericMotionListener_API24 {
// Generic Motion (mouse hover, joystick...) events go here
private boolean mRelativeModeEnabled;
@@ -753,15 +760,12 @@ class SDLGenericMotionListener_API26 extends SDLGenericMotionListener_API24 {
if (!SDLActivity.isDeXMode() || (Build.VERSION.SDK_INT >= 27)) {
if (enabled) {
SDLActivity.getContentView().requestPointerCapture();
}
else {
} else {
SDLActivity.getContentView().releasePointerCapture();
}
mRelativeModeEnabled = enabled;
return true;
}
else
{
} else {
return false;
}
}
+2 -2
View File
@@ -3,7 +3,7 @@
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
@@ -17,7 +17,7 @@ buildscript {
allprojects {
repositories {
jcenter()
mavenCentral()
google()
}
}
+3 -10
View File
@@ -1,11 +1,8 @@
#cmakedefine PACKAGE "@PACKAGE@"
#define VERSION "1.7.3sdl2"
#define VERSION "2.0.0"
#cmakedefine CMAKE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@"
#define RGB_ORDER 1
#cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@
#cmakedefine CACHE_TOTALSIZE @CACHE_TOTALSIZE@
#cmakedefine ENABLE_CDROM_ANDROID @ENABLE_CDROM_ANDROID@
@@ -13,17 +10,14 @@
#cmakedefine ENABLE_CDROM_EMSCRIPTEN @ENABLE_CDROM_EMSCRIPTEN@
#cmakedefine ENABLE_CDROM_LINUX @ENABLE_CDROM_LINUX@
#cmakedefine ENABLE_CDROM_MP3 @ENABLE_CDROM_MP3@
#cmakedefine ENABLE_FT2 @ENABLE_FT2@
#cmakedefine ENABLE_DEBUGGER @ENABLE_DEBUGGER@
#cmakedefine ENABLE_GTK @ENABLE_GTK@
#cmakedefine ENABLE_MIDI_RAWMIDI @ENABLE_MIDI_RAWMIDI@
#cmakedefine ENABLE_MIDI_SDLMIXER @ENABLE_MIDI_SDLMIXER@
#cmakedefine ENABLE_MIDI_SEQMIDI @ENABLE_MIDI_SEQMIDI@
#cmakedefine ENABLE_MODULES @ENABLE_MODULES@
#cmakedefine ENABLE_MIDI_PORTMIDI @ENABLE_MIDI_PORTMIDI@
#cmakedefine ENABLE_NLS @ENABLE_NLS@
#cmakedefine ENABLE_SDL @ENABLE_SDL@
#cmakedefine ENABLE_SDLMIXER @ENABLE_SDLMIXER@
#cmakedefine ENABLE_SDLTTF @ENABLE_SDLTTF@
#cmakedefine ENABLE_X11FONT @ENABLE_X11FONT@
#cmakedefine CDROM_DEVICE "@CDROM_DEVICE@"
#cmakedefine JOY_DEVICE "@JOY_DEVICE@"
@@ -38,7 +32,6 @@
#cmakedefine HAVE_SDLJOY @HAVE_SDLJOY@
#cmakedefine HAVE_SIGACTION @HAVE_SIGACTION@
#cmakedefine HAVE_UNAME @HAVE_UNAME@
#cmakedefine HAVE_XF86VMODE @HAVE_XF86VMODE@
#define DEFAULT_GOTHIC_TTF "@DEFAULT_FONT_PATH@MTLc3m.ttf"
#define DEFAULT_MINCHO_TTF "@DEFAULT_FONT_PATH@mincho.otf"
-1
View File
@@ -3,7 +3,6 @@
[鬼畜王ランス]
[ランス4(for Win95)]
= マウスのクリック反応が悪い (fixed ?)
[闘神都市2(for Win95)]
+1 -1
View File
@@ -223,7 +223,7 @@
-Ms? : Sequencer device (?:device number)
-M0 : disable midi
-devjoy name : joystick のデバイス名を name にします
-devjoy n : n 番目の joystick のデバイスを使用します
-version : バージョン情報を表示します。
-17
View File
@@ -1,17 +0,0 @@
Joystick の使い方について
現在 linux の kernel 2.2.x 以降の Joystick インターフェイスに対応して
います。対応環境をおもちの方は configure --enable-joy としてコンパイル
コンパイルして下さい。
Joystick のデバイス名はデフォルトでは /dev/js0 で、実行時に -devjoy
オプションで指定するか、.xsys35rc ファイルで joy_device のエントリー
に加えて下さい。
他環境での動作報告、パッチなどお待ちしています。宛先は以下の両方に
お願いします。
chikama (masaki-c@is.aist-nara.ac.jp)
linux 版の作者の村田さん(fmurata@p1.tcnet.ne.jp)
+43 -5
View File
@@ -1,7 +1,5 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src)
add_subdirectory(lib)
add_library(modules STATIC
modules.c
AliceLogo/AliceLogo.c
@@ -61,6 +59,31 @@ add_library(modules STATIC
dDemo/dDemo.c
eDemo/eDemo.c
eeDemo/eeDemo.c
lib/alk.c
lib/drawtext.c
lib/graph.c
lib/list.c
lib/surface.c
lib/cg.c
lib/graph_expandcolor_blend.c
lib/graph_fillrect.c
lib/graph_fillrect_amap.c
lib/graph_fillrect_acolor.c
lib/graph_rect.c
lib/graph_copy.c
lib/graph_copy_amap.c
lib/graph_copy_bright.c
lib/graph_copy_whiteout.c
lib/graph_blend_amap.c
lib/graph_blend_screen.c
lib/graph_saturadd_amap.c
lib/graph_draw_amap.c
lib/graph_stretch.c
lib/graph_cg.c
lib/graph_buller.c
lib/gre_blend_useamap.c
lib/gre_blend.c
lib/gre_blend_screen.c
nDEMO/nDEMO.c
nDEMOE/nDEMOE.c
oDEMO/oDEMO.c
@@ -68,10 +91,23 @@ add_library(modules STATIC
tDemo/tDemo.c
)
target_include_directories(modules PUBLIC .)
target_include_directories(modules PUBLIC . lib)
if (NOT ANDROID AND NOT EMSCRIPTEN)
add_executable(modules_tests lib/list_test.c)
target_link_libraries(modules_tests PRIVATE modules)
add_test(NAME modules_tests COMMAND modules_tests)
endif()
target_compile_options(modules PRIVATE -Wno-pointer-sign)
target_link_libraries(modules PRIVATE graph alk drawtext list)
if (EMSCRIPTEN)
set(LIBS
"SHELL:-s USE_LIBJPEG=1"
"SHELL:-s USE_SDL=2")
target_compile_options(modules PRIVATE ${LIBS})
target_link_options(modules PRIVATE ${LIBS})
endif()
if (SDL2MIXER_FOUND)
if (ANDROID)
@@ -86,5 +122,7 @@ if (HAVE_JPEG)
NightDemonDemo/ndd.c
NightDemonDemo/jpeg2surface.c
)
target_link_libraries(modules PRIVATE JPEG::JPEG)
if (NOT EMSCRIPTEN)
target_link_libraries(modules PRIVATE JPEG::JPEG)
endif()
endif()
+3 -3
View File
@@ -14,7 +14,7 @@ static void Init() {
}
static void ExistKeyFile() {
char *p1 = sys_getString(0);
const char *p1 = sl_getString(0);
int *p2 = getCaliVariable();
int *var = getCaliVariable();
@@ -24,7 +24,7 @@ static void ExistKeyFile() {
}
static void CheckProtectFile() {
char *p1 = sys_getString(0);
const char *p1 = sl_getString(0);
int *p2 = getCaliVariable();
int *var = getCaliVariable();
@@ -34,7 +34,7 @@ static void CheckProtectFile() {
}
static void CreateKeyFile() {
char *p1 = sys_getString(0);
const char *p1 = sl_getString(0);
int *p2 = getCaliVariable();
int *var = getCaliVariable();
-11
View File
@@ -420,7 +420,6 @@ static void Copy() {
DEBUG_COMMAND("Gpx.Copy %d,%d,%d,%d,%d,%d,%d,%d:\n", ds, dx, dy, ss, sx, sy, sw, sh);
ags_sync();
src = sf_get(ss);
dst = sf_get(ds);
gr_copy(dst, dx, dy, src, sx, sy, sw, sh);
@@ -465,7 +464,6 @@ static void CopyAMap() {
DEBUG_COMMAND("Gpx.CopyAMap %d,%d,%d,%d,%d,%d,%d,%d:\n", da, dx, dy, sa, sx, sy, sw, sh);
ags_sync();
src = sf_get(sa);
dst = sf_get(da);
gr_copy_alpha_map(dst, dx, dy, src, sx, sy, sw, sh);
@@ -538,7 +536,6 @@ static void BlendAMap() {
DEBUG_COMMAND("Gpx.BlendAMap %d,%d,%d,%d,%d,%d,%d,%d:\n", ds, dx, dy, ss, sx, sy, sw, sh);
ags_sync();
src = sf_get(ss);
dst = sf_get(ds);
gr_blend_alpha_map(dst, dx, dy, src, sx, sy, sw, sh);
@@ -715,7 +712,6 @@ static void Fill() {
DEBUG_COMMAND("Gpx.Fill %d,%d,%d,%d,%d,%d,%d,%d:\n", ds, dx, dy, dw, dh, r, g, b);
ags_sync();
dst = sf_get(ds);
gr_fill(dst, dx, dy, dw, dh, r, g, b);
}
@@ -734,7 +730,6 @@ static void FillAlphaColor() { /* not used ? */
DEBUG_COMMAND_YET("Gpx.FillAlphaColor %d,%d,%d,%d,%d,%d,%d,%d,%d:\n", ds, dx, dy, dw, dh, r, g, b, lv);
ags_sync();
dst = sf_get(ds);
gr_fill_alpha_color(dst, dx, dy, dw, dh, r, g, b, lv);
}
@@ -856,7 +851,6 @@ static void SpriteCopyAMap() {
DEBUG_COMMAND("Gpx.SpriteCopyAMap %d,%d,%d,%d,%d,%d,%d,%d,%d:\n", da, dx, dy, sa, sx, sy, sw, sh, cl);
ags_sync();
src = sf_get(sa);
dst = sf_get(da);
gr_copy_alpha_map_sprite(dst, dx, dy, src, sx, sy, sw, sh, cl);
@@ -884,7 +878,6 @@ static void BrightDestOnly() {
DEBUG_COMMAND("Gpx.BrightDestOnly %d,%d,%d,%d,%d,%d:\n", ds, dx, dy, dw, dh, r);
ags_sync();
dst = sf_get(ds);
gr_bright_dst_only(dst, dx, dy, dw, dh, r);
@@ -1004,7 +997,6 @@ static void CopyStretchBlendAMap() {
DEBUG_COMMAND("Gpx.CopyStretchBlendAMap %d,%d,%d,%d,%d,%d,%d,%d,%d,%d:\n", ds, dx, dy, dw, dh, ss, sx, sy, sw, sh);
ags_sync();
src = sf_get(ss);
dst = sf_get(ds);
gr_copy_stretch_blend_alpha_map(dst, dx, dy, dw, dh, src, sx, sy, sw, sh);
@@ -1056,7 +1048,6 @@ static void StretchBlendScreen2x2WDS() {
DEBUG_COMMAND("Gpx.StretchBlendScreen2x2WDS %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d:\n", ds, dx, dy, ss1, sx1, sy1, ss2, sx2, sy2, sw, sh);
ags_sync();
src1 = sf_get(ss1);
src2 = sf_get(ss2);
dst = sf_get(ds);
@@ -1094,7 +1085,6 @@ static void BlendScreenWDS() {
DEBUG_COMMAND("Gpx.BlendScreenWDS %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d:\n", ds, dx, dy, ss1, sx1, sy1, ss2, sx2, sy2, sw, sh);
ags_sync();
src1 = sf_get(ss1);
src2 = sf_get(ss2);
dst = sf_get(ds);
@@ -1161,7 +1151,6 @@ static void EffectCopy() {
default:
DEBUG_COMMAND_YET("Gpx.EffectCopy %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%p:\n", no, dx, dy, ss1, sx1, sy1, ss2, sx2, sy2, sw, sh, time, var);
}
ags_sync();
dib = sf_get(0);
dst = sf_get(ss1);
src = sf_get(ss2);
-15
View File
@@ -169,21 +169,6 @@ void sf_blend_white_level(surface_t *dst, int dx, int dy, surface_t *src, int sx
dp = GETOFFSET_PIXEL(dst, dx, dy);
switch(dst->depth) {
case 15:
{
WORD *yls, *yld;
for (y = 0; y < sh; y++) {
yls = (WORD *)(sp + y * src->bytes_per_line);
yld = (WORD *)(dp + y * dst->bytes_per_line);
for (x = 0; x < sw; x++) {
*yld = WHITELEVEL15(*yls, lv);
yls++; yld++;
}
}
break;
}
case 16:
{
WORD *yls, *yld;
+44 -25
View File
@@ -1,69 +1,88 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "portab.h"
#include "system.h"
#include "filecheck.h"
#include "xsystem35.h"
#include "modules.h"
#include "nact.h"
#include "message.h"
#include "msgskip.h"
#include "utfsjis.h"
static char *msgskipfile;
static boolean valid;
static int action;
static void Init() {
int *p1 = getCaliVariable();
int p2 = getCaliValue(); /* ISys3x */
int p3 = getCaliValue();
int p4 = getCaliValue();
int *p1 = getCaliVariable();
int p2 = getCaliValue(); /* ISys3x */
int p3 = getCaliValue();
int p4 = getCaliValue();
DEBUG_COMMAND_YET("MsgSkip.Init %p,%d,%d,%d:\n", p1, p2, p3, p4);
action = p3;
valid = true;
*p1 = 0;
DEBUG_COMMAND("MsgSkip.Init %p,%d,%d,%d:\n", p1, p2, p3, p4);
}
static void Start() {
int *p1 = getCaliVariable();
int p2 = getCaliValue();
int *p1 = getCaliVariable();
int p2 = getCaliValue();
msgskipfile = strdup(svar_get(p2));
DEBUG_COMMAND_YET("MsgSkip.Start %p,%d:\n", p1, p2);
char *fname_utf8 = sjis2utf(svar_get(p2));
char *path = fc_get_path(fname_utf8);
msgskip_init(path);
free(path);
free(fname_utf8);
DEBUG_COMMAND("MsgSkip.Start %p,%d:\n", p1, p2);
}
static void SetValid() {
int p1 = getCaliValue();
int p1 = getCaliValue();
valid = p1;
msgskip_pause(!valid);
DEBUG_COMMAND("MsgSkip.SetValid %d:\n", p1);
}
static void GetValid() {
int *p1 = getCaliVariable();
DEBUG_COMMAND_YET("MsgSkip.GetValid %p:\n", p1);
int *p1 = getCaliVariable();
*p1 = valid;
DEBUG_COMMAND("MsgSkip.GetValid %p:\n", p1);
}
static void SetAction() {
int p1 = getCaliValue();
int p1 = getCaliValue();
action = p1;
DEBUG_COMMAND("MsgSkip.SetAcion %d:\n", p1);
}
static void GetAction() {
int *p1 = getCaliVariable();
DEBUG_COMMAND_YET("MsgSkip.GetAcion %p:\n", p1);
int *p1 = getCaliVariable();
*p1 = action;
DEBUG_COMMAND("MsgSkip.GetAcion %p:\n", p1);
}
static void PushStr() {
int p1 = getCaliValue();
int p1 = getCaliValue();
DEBUG_COMMAND_YET("MsgSkip.PushStr %d:\n", p1);
}
static void PopStr() {
int p1 = getCaliValue();
int p1 = getCaliValue();
DEBUG_COMMAND_YET("MsgSkip.PopStr %d:\n", p1);
}
-2
View File
@@ -193,8 +193,6 @@ void nt_gr_draw(int effectno) {
void nt_gr_screencg(int no, int x, int y) {
surface_t *sf;
ags_sync();
sf = sf_loadcg_no(no -1);
gre_BlendScreen(sf0, x, y, sf0, x, y, sf, 0, 0, sf->width, sf->height);
+8 -8
View File
@@ -274,7 +274,7 @@ static void ntmsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB
// keywait
delta = get_high_counter(SYSTEMCOUNTER_MSEC) - wcnt;
if (delta < wSpeed) {
if (sys_keywait(wSpeed - delta, FALSE)) {
if (sys_keywait(wSpeed - delta, KEYWAIT_NONCANCELABLE)) {
wSpeed = 0;
}
@@ -289,9 +289,9 @@ static void ntmsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB
// Waitなしの出力は最後にupdate
if (needupdate) {
uparea.width = sp->cursize.width;
uparea.height = min(sp->cursize.height, uparea.y - sp->u.msg.dspcur.y + wLineSpace + wLineSpace);
nt_sp_updateme_part(sp, uparea.x, uparea.y, uparea.width, uparea.height);
uparea.w = sp->cursize.width;
uparea.h = min(sp->cursize.height, uparea.y - sp->u.msg.dspcur.y + wLineSpace + wLineSpace);
nt_sp_updateme_part(sp, uparea.x, uparea.y, uparea.w, uparea.h);
}
}
@@ -312,7 +312,7 @@ static int ntmsg_keywait() {
night.waittype = KEYWAIT_MESSAGE;
night.waitkey = -1;
while (night.waitkey == -1) {
while (night.waitkey == -1 && !nact->is_quit) {
int st = get_high_counter(SYSTEMCOUNTER_MSEC);
int interval = 25;
@@ -320,7 +320,7 @@ static int ntmsg_keywait() {
interval = night.sp[SPNO_MSG_KEYANIM]->u.anime.interval;
hakanim(i++);
}
sys_keywait(interval - (get_high_counter(SYSTEMCOUNTER_MSEC) - st), FALSE);
sys_keywait(interval - (get_high_counter(SYSTEMCOUNTER_MSEC) - st), KEYWAIT_NONCANCELABLE);
}
night.waittype = KEYWAIT_NONE;
@@ -459,8 +459,8 @@ int ntmsg_update(sprite_t *sp, MyRectangle *r) {
// -> 説明スプライトのように、SetShowされたときに対応できないからだめ
//if (sact.msgbufempty) return OK;
update.width = r->width;
update.height = r->height;
update.width = r->w;
update.height = r->h;
dx = sp->cur.x - r->x;
dy = sp->cur.y - r->y;
+3 -6
View File
@@ -9,6 +9,7 @@
#include "system.h"
#include "counter.h"
#include "input.h"
#include "sdl_core.h"
#include "xsystem35.h"
#include "nact.h"
#include "scenario.h"
@@ -16,9 +17,6 @@
#include "night.h"
#include "nt_msg.h"
/* defined by cmd_check.c */
extern void check_command(int c0);
#define MAINLOOP_EVENTCHECK_INTERVAL 16 /* 16 msec */
@@ -56,10 +54,9 @@ static void ntmain(struct _scoadr inadr) {
while (!nact->is_quit) {
for (int cnt = 0; !nact->wait_vsync && cnt < 10000; cnt++) {
DEBUG_MESSAGE("%d:%x\n", sl_getPage(), sl_getIndex());
//SACT_DEBUG("%d:%x\n", sl_getPage(), sl_getIndex());
if (!nact->popupmenu_opened) {
check_command(sl_getc());
exec_command();
if (sl_getPage() == inadr.page &&
sl_getIndex() == inadr.index) {
// ~E%05dからの戻り
@@ -77,7 +74,7 @@ static void ntmain(struct _scoadr inadr) {
if (!nact->is_message_locked) {
sys_getInputInfo();
}
WaitVsync();
sdl_wait_vsync();
nact->frame_count++;
nact->wait_vsync = FALSE;
}
+1 -1
View File
@@ -1,4 +1,4 @@
int ntsel_dosel(int mode) {
int ntsel_dosel(void) {
// 選択肢を描画
//
return 0;
-1
View File
@@ -76,7 +76,6 @@ static surface_t *stretch(surface_t *src, int dw, int dh, int mirror) {
switch(dst->depth) {
case 8:
SCALEDCOPYAREA(BYTE); break;
case 15:
case 16:
SCALEDCOPYAREA(WORD); break;
case 24:
+4 -4
View File
@@ -60,8 +60,8 @@ int nt_sp_draw2(sprite_t *sp, cginfo_t *cg, MyRectangle *r) {
if (cg->sf == NULL) return NG;
// 更新領域の確定
update.width = r->width;
update.height = r->height;
update.width = r->w;
update.height = r->h;
sx = 0;
sy = 0;
dx = sp->cur.x - r->x;
@@ -116,8 +116,8 @@ int nt_sp_draw_scg(sprite_t *sp, MyRectangle *r) {
if (cg->sf == NULL) return NG;
// 更新領域の確定
update.width = r->width;
update.height = r->height;
update.width = r->w;
update.height = r->h;
sx = 0;
sy = 0;
dx = sp->cur.x - r->x;
+6 -6
View File
@@ -37,7 +37,7 @@
#include "surface.h"
#include "sactcg.h"
#include "counter.h"
#include "sdl_core.h"
static void ec1_cb(surface_t *, surface_t *);
@@ -255,7 +255,7 @@ static void ec14_cb(surface_t *sfsrc, surface_t *sfdst) {
if (ecp.oldstep == 0) {
sf_copyall(sf0, sfdst);
}
Maskupdate(0, 0, sfsrc->width, sfsrc->height, 0, 0, 44, curstep);
sdl_maskupdate(0, 0, sfsrc->width, sfsrc->height, 0, 0, 44, curstep);
ecp.oldstep = curstep;
}
@@ -268,7 +268,7 @@ static void ec15_cb(surface_t *sfsrc, surface_t *sfdst) {
if (ecp.oldstep == 0) {
sf_copyall(sf0, sfdst);
}
Maskupdate(0, 0, sfsrc->width, sfsrc->height, 0, 0, 45, curstep);
sdl_maskupdate(0, 0, sfsrc->width, sfsrc->height, 0, 0, 45, curstep);
ecp.oldstep = curstep;
}
@@ -281,7 +281,7 @@ static void ec16_cb(surface_t *sfsrc, surface_t *sfdst) {
if (ecp.oldstep == 0) {
sf_copyall(sf0, sfdst);
}
Maskupdate(0, 0, sfsrc->width, sfsrc->height, 0, 0, 46, curstep);
sdl_maskupdate(0, 0, sfsrc->width, sfsrc->height, 0, 0, 46, curstep);
ecp.oldstep = curstep;
}
@@ -294,7 +294,7 @@ static void ec17_cb(surface_t *sfsrc, surface_t *sfdst) {
if (ecp.oldstep == 0) {
sf_copyall(sf0, sfdst);
}
Maskupdate(0, 0, sfsrc->width, sfsrc->height, 0, 0, 47, curstep);
sdl_maskupdate(0, 0, sfsrc->width, sfsrc->height, 0, 0, 47, curstep);
ecp.oldstep = curstep;
}
@@ -428,7 +428,7 @@ int nt_sp_eupdate(int type, int time, int cancel) {
cb(sfsrc, sfdst);
rest = 15 - (get_high_counter(SYSTEMCOUNTER_MSEC) - ecp.curtime);
key = sys_keywait(rest, cancel);
key = sys_keywait(rest, cancel ? KEYWAIT_CANCELABLE : KEYWAIT_NONCANCELABLE);
if (cancel && key) break;
}
+13 -47
View File
@@ -43,46 +43,15 @@ static SList *updatearea;
// 再描画するスプライトのリスト
static SList *updatelist;
static void intersection(MyRectangle *r1, MyRectangle *r2, MyRectangle *rst);
static void disjunction(void* region, void* data);
static MyRectangle get_updatearea();
static void do_update_each(void* data, void* userdata);
// 領域1と領域2の積を計算
static void intersection(MyRectangle *r1, MyRectangle *r2, MyRectangle *rst) {
int x1 = max(r1->x, r2->x);
int x2 = min(r1->x + r1->width, r2->x + r2->width);
int y1 = max(r1->y, r2->y);
int y2 = min(r1->y + r1->height, r2->y + r2->height);
rst->x = x1;
rst->y = y1;
rst->width = x2 - x1;
rst->height = y2 - y1;
}
// 領域1と領域2をすべて含む矩形領域を計算
static void disjunction(void* region, void* data) {
MyRectangle *r1 = (MyRectangle *)region;
MyRectangle *r2 = (MyRectangle *)data;
int x1, x2, y1, y2;
if (r2->width == 0) {
r2->x = r1->x;
r2->y = r1->y;
r2->width = r1->width;
r2->height = r1->height;
} else {
x1 = min(r1->x, r2->x);
x2 = max(r1->x + r1->width, r2->x + r2->width);
y1 = min(r1->y, r2->y);
y2 = max(r1->y + r1->height, r2->y + r2->height);
r2->x = x1;
r2->y = y1;
r2->width = x2 - x1;
r2->height = y2 - y1;
}
SDL_UnionRect(r1, r2, r2);
free(r1);
}
@@ -98,11 +67,10 @@ static MyRectangle get_updatearea() {
updatearea = NULL;
// surface0との領域の積をとる
intersection(&rsf0, &clip, &result);
SDL_IntersectRect(&rsf0, &clip, &result);
SACT_DEBUG("clipped area x=%d y=%d w=%d h=%d\n",
result.x, result.y,
result.width, result.height);
result.x, result.y, result.w, result.h);
return result;
}
@@ -153,16 +121,14 @@ int nt_sp_update_clipped() {
// 更新領域の確定
r = get_updatearea();
// 幅または高さが 0 の時はなにもしない
if (r.width == 0 || r.height == 0) {
if (SDL_RectEmpty(&r))
return OK;
}
// 更新領域に入っているスプライトの再描画
slist_foreach(updatelist, do_update_each, &r);
// 更新領域を Window に転送
ags_updateArea(r.x, r.y, r.width, r.height);
ags_updateArea(r.x, r.y, r.w, r.h);
return OK;
}
@@ -180,13 +146,13 @@ int nt_sp_updateme(sprite_t *sp) {
r = malloc(sizeof(MyRectangle));
r->x = sp->cur.x;
r->y = sp->cur.y;
r->width = sp->cursize.width;
r->height = sp->cursize.height;
r->w = sp->cursize.width;
r->h = sp->cursize.height;
updatearea = slist_append(updatearea, r);
SACT_DEBUG("x = %d, y = %d, spno = %d w=%d,h=%d\n",
r->x, r->y, sp->no, r->width, r->height);
r->x, r->y, sp->no, r->w, r->h);
return OK;
}
@@ -208,13 +174,13 @@ int nt_sp_updateme_part(sprite_t *sp, int x, int y, int w, int h) {
r = malloc(sizeof(MyRectangle));
r->x = sp->cur.x + x;
r->y = sp->cur.y + y;
r->width = w;
r->height = h;
r->w = w;
r->h = h;
updatearea = slist_append(updatearea, r);
SACT_DEBUG("x = %d, y = %d, spno = %d w=%d,h=%d\n",
r->x, r->y, sp->no, r->width, r->height);
r->x, r->y, sp->no, r->w, r->h);
return OK;
}
@@ -247,8 +213,8 @@ int nt_sp_draw_wall(sprite_t *sp, MyRectangle *area) {
sx = area->x;
sy = area->y;
w = area->width;
h = area->height;
w = area->w;
h = area->h;
gr_fill(sf0, sx, sy, w, h, 0, 0, 0);
SACT_DEBUG("do update no=%d, sx=%d, sy=%d, w=%d, h=%d, \n",
-10
View File
@@ -37,16 +37,6 @@ static void ppm2surface(surface_t *sf, int curscanline, unsigned char *src, int
BYTE *dp = GETOFFSET_PIXEL(sf, 0, curscanline);
switch (sf->depth) {
case 15:
{
WORD *dst = (WORD *)dp;
while (width--) {
*dst = PIX15(*src, *(src +1), *(src +2));
dst++; src+= 3;
}
break;
}
case 16:
{
WORD *dst = (WORD *)dp;
+1 -1
View File
@@ -94,7 +94,7 @@ void ndd_run(int demonum) {
cur1 = get_high_counter(SYSTEMCOUNTER_MSEC);
if (cur1 - cur < 33) {
if (sys_keywait(33 - (cur1 - cur), TRUE)) break;
if (sys_keywait(33 - (cur1 - cur), KEYWAIT_CANCELABLE)) break;
} else {
if (sys_getInputInfo()) break;
}
+8 -7
View File
@@ -29,6 +29,7 @@
#include "portab.h"
#include "system.h"
#include "input.h"
#include "msgskip.h"
#include "xsystem35.h"
#include "gametitle.h"
#include "message.h"
@@ -1011,8 +1012,8 @@ static void WaitKeySimple() {
sact.waittype = KEYWAIT_SIMPLE;
sact.waitkey = -1;
while(sact.waitkey == -1) {
sys_keywait(25, TRUE);
while (sact.waitkey == -1 && !nact->is_quit) {
sys_keywait(25, KEYWAIT_CANCELABLE);
}
sact.waittype = KEYWAIT_NONE;
@@ -1101,7 +1102,7 @@ static void WaitKeySimpleTimeOut() {
sact.waittype = KEYWAIT_SIMPLE;
sact.waitkey = -1;
sys_keywait(wTime * 10, TRUE);
sys_keywait(wTime * 10, KEYWAIT_CANCELABLE);
if (sact.waitkey == -1) {
*vD03 = 1;
*vRND = 0;
@@ -1146,7 +1147,7 @@ static void WaitKeySpriteTimeOut() {
static void QueryMessageSkip() {
int *vSkip = getCaliVariable();
*vSkip = get_skipMode() ? 1 : 0;
*vSkip = msgskip_isSkipping() ? 1 : 0;
DEBUG_COMMAND_YET("SACT.QueryMessageSkip %p:\n", vSkip);
}
@@ -1586,8 +1587,8 @@ static void TimerWait() {
int wTimerID = getCaliValue();
int wCount = getCaliValue();
while(wCount > stimer_get(wTimerID)) {
sys_keywait(10, FALSE);
while (wCount > stimer_get(wTimerID) && !nact->is_quit) {
sys_keywait(10, KEYWAIT_NONCANCELABLE);
}
DEBUG_COMMAND("SACT.TimerWait %d,%d:\n", wTimerID, wCount);
@@ -1601,7 +1602,7 @@ static void TimerWait() {
static void Wait() {
int wCount = getCaliValue();
sys_keywait(wCount*10, FALSE);
sys_keywait(wCount*10, KEYWAIT_NONCANCELABLE);
DEBUG_COMMAND_YET("SACT.Wait %d:\n", wCount);
}
+1 -1
View File
@@ -139,7 +139,7 @@ int sp_eupdate_amap(int index, int time, int cancel) {
gre_BlendUseAMap(sf0, 0, 0, sfsrc, 0, 0, sfdst, 0, 0, sfsrc->width, sfsrc->height, mask2, 0, 0, 255);
ags_updateFull();
key = sys_keywait(10, cancel);
key = sys_keywait(10, cancel ? KEYWAIT_CANCELABLE : KEYWAIT_NONCANCELABLE);
if (cancel && key) break;
// 一時マスクを削除
-1
View File
@@ -76,7 +76,6 @@ static surface_t *stretch(surface_t *src, int dw, int dh, int mirror) {
switch(dst->depth) {
case 8:
SCALEDCOPYAREA(BYTE); break;
case 15:
case 16:
SCALEDCOPYAREA(WORD); break;
case 24:
+2 -2
View File
@@ -135,8 +135,8 @@ int ssnd_waitkey(int no, int *res) {
sact.waittype = KEYWAIT_SIMPLE;
sact.waitkey = -1;
while(sact.waitkey == -1 && mus_wav_get_playposition(slot)) {
sys_keywait(25, TRUE);
while (sact.waitkey == -1 && mus_wav_get_playposition(slot) && !nact->is_quit) {
sys_keywait(25, KEYWAIT_CANCELABLE);
}
if (sact.waitkey == -1) {
+1 -1
View File
@@ -87,7 +87,7 @@ int sp_quake_screen(int type, int p1, int p2, int time, int cancel) {
ags_setViewArea(adjx, adjy, sf0->width, sf0->height);
ags_updateFull();
key = sys_keywait(10, cancel);
key = sys_keywait(10, cancel ? KEYWAIT_CANCELABLE : KEYWAIT_NONCANCELABLE);
if (cancel && key) break;
}
+2 -2
View File
@@ -77,8 +77,8 @@ static int sp_draw_wall(sprite_t *sp) {
sx = sact.updaterect.x;
sy = sact.updaterect.y;
w = sact.updaterect.width;
h = sact.updaterect.height;
w = sact.updaterect.w;
h = sact.updaterect.h;
gr_fill(sf0, sx, sy, w, h, 0, 0, 0);
SACT_DEBUG("do update no=%d, sx=%d, sy=%d, w=%d, h=%d, \n",
+2 -2
View File
@@ -101,8 +101,8 @@ int sp_draw2(sprite_t *sp, cginfo_t *cg) {
if (cg->sf == NULL) return NG;
// 更新領域の確定
update.width = sact.updaterect.width;
update.height = sact.updaterect.height;
update.width = sact.updaterect.w;
update.height = sact.updaterect.h;
sx = 0;
sy = 0;
dx = sp->cur.x - sact.updaterect.x;
+6 -6
View File
@@ -38,7 +38,7 @@
#include "surface.h"
#include "sactcg.h"
#include "counter.h"
#include "sdl_core.h"
static void ec1_cb(surface_t *, surface_t *);
@@ -298,7 +298,7 @@ static void ec14_cb(surface_t *sfsrc, surface_t *sfdst) {
if (ecp.oldstep == 0) {
sf_copyall(sf0, sfdst);
}
Maskupdate(0, 0, sfsrc->width, sfsrc->height, 0, 0, 44, curstep);
sdl_maskupdate(0, 0, sfsrc->width, sfsrc->height, 0, 0, 44, curstep);
ecp.oldstep = curstep;
}
@@ -311,7 +311,7 @@ static void ec15_cb(surface_t *sfsrc, surface_t *sfdst) {
if (ecp.oldstep == 0) {
sf_copyall(sf0, sfdst);
}
Maskupdate(0, 0, sfsrc->width, sfsrc->height, 0, 0, 45, curstep);
sdl_maskupdate(0, 0, sfsrc->width, sfsrc->height, 0, 0, 45, curstep);
ecp.oldstep = curstep;
}
@@ -324,7 +324,7 @@ static void ec16_cb(surface_t *sfsrc, surface_t *sfdst) {
if (ecp.oldstep == 0) {
sf_copyall(sf0, sfdst);
}
Maskupdate(0, 0, sfsrc->width, sfsrc->height, 0, 0, 46, curstep);
sdl_maskupdate(0, 0, sfsrc->width, sfsrc->height, 0, 0, 46, curstep);
ecp.oldstep = curstep;
}
@@ -337,7 +337,7 @@ static void ec17_cb(surface_t *sfsrc, surface_t *sfdst) {
if (ecp.oldstep == 0) {
sf_copyall(sf0, sfdst);
}
Maskupdate(0, 0, sfsrc->width, sfsrc->height, 0, 0, 47, curstep);
sdl_maskupdate(0, 0, sfsrc->width, sfsrc->height, 0, 0, 47, curstep);
ecp.oldstep = curstep;
}
@@ -431,7 +431,7 @@ int sp_eupdate(int type, int time, int cancel) {
(*cb[type-1])(sfsrc, sfdst);
rest = 15 - (get_high_counter(SYSTEMCOUNTER_MSEC) - ecp.curtime);
key = sys_keywait(rest, cancel);
key = sys_keywait(rest, cancel ? KEYWAIT_CANCELABLE : KEYWAIT_NONCANCELABLE);
if (cancel && key) break;
}
-1
View File
@@ -10,7 +10,6 @@ static void do_aff(surface_t *in, surface_t *out, int deg, double zx, double zy)
int i, j, m, n;
switch(in->depth) {
case 15:
case 16: {
WORD *src, *dst;
+9 -5
View File
@@ -5,8 +5,8 @@
static void ec6_cb(surface_t *src, surface_t *dst) {
int curstep, maxstep = 32;
surface_t *st, *dt;
static int slices[32]={4,8,12,16,20,28,36,40,44,48,56,64,72,80,88,96,
88,80,72,64,56,48,44,40,36,28,24,20,16,12,8,4};
static int slices[32]={4,8,12,16,20,28,36,40,44,48,56,64,72,80,88,96,
88,80,72,64,56,48,44,40,36,28,24,20,16,12,8,4};
curstep = maxstep * (ecp.curtime - ecp.sttime)/ (ecp.edtime - ecp.sttime);
@@ -17,9 +17,13 @@ static void ec6_cb(surface_t *src, surface_t *dst) {
st = sf_dup(src);
dt = sf_dup(dst);
image_Mosaic(st, 0, 0, st->width, st->height, 0, 0, slices[curstep]);
image_Mosaic(dt, 0, 0, dt->width, dt->height, 0, 0, slices[curstep]);
SDL_Surface *stt = com2surface(st);
SDL_Surface *dtt = com2surface(dt);
image_Mosaic(stt, 0, 0, stt->w, stt->h, 0, 0, slices[curstep]);
image_Mosaic(dtt, 0, 0, dtt->w, dtt->h, 0, 0, slices[curstep]);
SDL_FreeSurface(stt);
SDL_FreeSurface(dtt);
gre_Blend(sf0, 0, 0, st, 0, 0, dt, 0, 0, st->width, st->height, curstep*8);
ags_updateFull();
-1
View File
@@ -44,7 +44,6 @@ static void do_per(surface_t *in, surface_t *out, float *k) {
int ys = in->height /2;
switch(in->depth) {
case 15:
case 16: {
WORD *src, *dst;
-1
View File
@@ -4,7 +4,6 @@ static void uneune(surface_t *in, surface_t *out, int st) {
int x, y, m, n;
switch(in->depth) {
case 15:
case 16: {
WORD *src, *dst;
for (y = 0; y < in->height; y++) {
+3 -2
View File
@@ -270,7 +270,8 @@ static void cb_waitkey_simple(agsevent_t *e) {
/*
WaitKeySpriteのcallback
*/
static void cb_waitkey_sprite(agsevent_t *e) {
EMSCRIPTEN_KEEPALIVE
void cb_waitkey_sprite(agsevent_t *e) {
SList *node;
sprite_t *focused_sp = NULL; // focus を得ている sprite
sprite_t *defocused_sp = NULL; // focus を失った sprite
@@ -285,7 +286,7 @@ static void cb_waitkey_sprite(agsevent_t *e) {
if (sact.draggedsp) {
// 先に drag中のspriteにイベントを送る
update = sact.draggedsp->eventcb(sact.draggedsp, e);
update = sact.draggedsp->eventcb(sact.draggedsp, e); // Async in emscripten
} else {
// 右クリックキャンセル
// drag中でない時のみ、キャンセルを受け付ける
+4 -4
View File
@@ -53,7 +53,7 @@ static void hidesprite(sprite_t *sp) {
sp->blendrate = i;
sp_updateme(sp);
sp_update_clipped();
sys_keywait(10, FALSE);
sys_keywait(10, KEYWAIT_NONCANCELABLE);
}
sp_updateme(sp);
@@ -142,7 +142,7 @@ int sp_keywait(int *vOK, int *vRND, int *vD01, int *vD02, int *vD03, int timeout
agse.d1 = p.x;
agse.d2 = p.y;
agse.d3 = 0;
nact->ags.eventcb(&agse);
spev_callback(&agse);
}
// 終了時間の計算
@@ -150,8 +150,8 @@ int sp_keywait(int *vOK, int *vRND, int *vD01, int *vD02, int *vD03, int timeout
endtime = timeout < 0 ? INT_MAX : (curtime + timeout * 10);
// スプライトキー待ちメイン
while (!waitcond(endtime)) {
sys_keywait(25, TRUE);
while (!waitcond(endtime) && !nact->is_quit) {
sys_keywait(25, KEYWAIT_CANCELABLE);
}
if (sact.waitkey == 0) {
+3 -2
View File
@@ -33,6 +33,7 @@
#include "sact.h"
#include "sprite.h"
#include "counter.h"
#include "sdl_core.h"
/*
@@ -164,7 +165,7 @@ void spev_move_waitend(sprite_t *sp, int dx, int dy, int time) {
while (sp->move.moving) {
nact->callback();
WaitVsync();
sdl_wait_vsync();
}
}
@@ -183,7 +184,7 @@ void spev_wait4moving_sp() {
while (sp->move.moving) {
nact->callback();
WaitVsync();
sdl_wait_vsync();
}
}
}
+8 -8
View File
@@ -319,7 +319,7 @@ void smsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB, int wF
// keywait
delta = get_high_counter(SYSTEMCOUNTER_MSEC) - wcnt;
if (delta < wSpeed) {
if (sys_keywait(wSpeed - delta, FALSE)) {
if (sys_keywait(wSpeed - delta, KEYWAIT_NONCANCELABLE)) {
wSpeed = 0;
}
@@ -336,9 +336,9 @@ void smsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB, int wF
// Waitなしの出力は最後にupdate
if (needupdate) {
uparea.width = sp->cursize.width;
uparea.height = min(sp->cursize.height, uparea.y - sp->u.msg.dspcur.y + wLineSpace + wLineSpace + wRSize);
sp_updateme_part(sp, uparea.x, uparea.y, uparea.width, uparea.height);
uparea.w = sp->cursize.width;
uparea.h = min(sp->cursize.height, uparea.y - sp->u.msg.dspcur.y + wLineSpace + wLineSpace + wRSize);
sp_updateme_part(sp, uparea.x, uparea.y, uparea.w, uparea.h);
}
// ????
@@ -403,7 +403,7 @@ int smsg_keywait(int wNum1, int wNum2, int msglen) {
sact.waittype = KEYWAIT_MESSAGE;
sact.waitkey = -1;
while (sact.waitkey == -1) {
while (sact.waitkey == -1 && !nact->is_quit) {
int st = get_high_counter(SYSTEMCOUNTER_MSEC);
int interval = 25;
@@ -418,7 +418,7 @@ int smsg_keywait(int wNum1, int wNum2, int msglen) {
update_mark(minfo[j].sp, minfo[j].cg);
i++;
}
sys_keywait(interval - (get_high_counter(SYSTEMCOUNTER_MSEC) - st), FALSE);
sys_keywait(interval - (get_high_counter(SYSTEMCOUNTER_MSEC) - st), KEYWAIT_NONCANCELABLE);
}
sact.waittype = KEYWAIT_NONE;
@@ -438,8 +438,8 @@ int smsg_update(sprite_t *sp) {
// -> 説明スプライトのように、SetShowされたときに対応できないからだめ
//if (sact.msgbufempty) return OK;
update.width = sact.updaterect.width;
update.height = sact.updaterect.height;
update.width = sact.updaterect.w;
update.height = sact.updaterect.h;
dx = sp->cur.x - sact.updaterect.x;
dy = sp->cur.y - sact.updaterect.y;
+1 -1
View File
@@ -85,7 +85,7 @@ int sp_quake_sprite(int wType, int wAmplitudeX, int wAmplitudeY, int wCount, int
i++;
// ウェイトとキャンセルチェック
key = sys_keywait(10, cancel);
key = sys_keywait(10, cancel ? KEYWAIT_CANCELABLE : KEYWAIT_NONCANCELABLE);
if (cancel && key != 0) break;
}
+11 -9
View File
@@ -65,14 +65,14 @@ static int sel_main();
* sprite内部とは判断しない
*/
static boolean sp_is_insprite2(sprite_t *sp, int x, int y, int margin) {
MyRectangle r;
cginfo_t *curcg = sp->curcg;
r.x = sp->cur.x + margin;
r.y = sp->cur.y + margin;
r.width = curcg->sf->width - 2 * margin;
r.height = curcg->sf->height - 2 * margin;
return ags_regionContains(&r, x, y);
MyPoint p = {x, y};
MyRectangle r = {
sp->cur.x + margin,
sp->cur.y + margin,
sp->curcg->sf->width - 2 * margin,
sp->curcg->sf->height - 2 * margin
};
return SDL_PointInRect(&p, &r);
}
// マウスが移動したときの callback
@@ -237,7 +237,9 @@ static int sel_main() {
selected_item = -1;
while(selected_item == -1) {
sys_keywait(25, TRUE);
sys_keywait(25, KEYWAIT_CANCELABLE);
if (nact->is_quit)
selected_item = 0;
}
sact.waittype = KEYWAIT_NONE;
+13 -46
View File
@@ -39,46 +39,15 @@
// スプライト再描画間の間に変更のあったスプライトの領域の和
static SList *updatearea;
static void intersection(MyRectangle *r1, MyRectangle *r2, MyRectangle *rst);
static void disjunction(void* region, void* data);
static void get_updatearea();
static void do_update_each(void* data, void* userdata);
// 領域1と領域2の積を計算
static void intersection(MyRectangle *r1, MyRectangle *r2, MyRectangle *rst) {
int x1 = max(r1->x, r2->x);
int x2 = min(r1->x + r1->width, r2->x + r2->width);
int y1 = max(r1->y, r2->y);
int y2 = min(r1->y + r1->height, r2->y + r2->height);
rst->x = x1;
rst->y = y1;
rst->width = x2 - x1;
rst->height = y2 - y1;
}
// 領域1と領域2をすべて含む矩形領域を計算
static void disjunction(void* region, void* data) {
MyRectangle *r1 = (MyRectangle *)region;
MyRectangle *r2 = (MyRectangle *)data;
int x1, x2, y1, y2;
if (r2->width == 0) {
r2->x = r1->x;
r2->y = r1->y;
r2->width = r1->width;
r2->height = r1->height;
} else {
x1 = min(r1->x, r2->x);
x2 = max(r1->x + r1->width, r2->x + r2->width);
y1 = min(r1->y, r2->y);
y2 = max(r1->y + r1->height, r2->y + r2->height);
r2->x = x1;
r2->y = y1;
r2->width = x2 - x1;
r2->height = y2 - y1;
}
SDL_UnionRect(r1, r2, r2);
free(r1);
}
@@ -93,11 +62,11 @@ static void get_updatearea() {
updatearea = NULL;
// surface0との領域の積をとる
intersection(&rsf0, &clip, &sact.updaterect);
SDL_IntersectRect(&rsf0, &clip, &sact.updaterect);
SACT_DEBUG("clipped area x=%d y=%d w=%d h=%d\n",
sact.updaterect.x, sact.updaterect.y,
sact.updaterect.width, sact.updaterect.height);
sact.updaterect.w, sact.updaterect.h);
return;
}
@@ -135,8 +104,8 @@ int sp_update_all(boolean syncscreen) {
// 画面全体を更新領域に
sact.updaterect.x = 0;
sact.updaterect.y = 0;
sact.updaterect.width = sf0->width;
sact.updaterect.height = sf0->height;
sact.updaterect.w = sf0->width;
sact.updaterect.h = sf0->height;
// updatelistに登録してあるスプライトを再描画
// updatelistはスプライトの番号順に並んでいる
@@ -164,10 +133,8 @@ int sp_update_clipped() {
// 更新領域の確定
get_updatearea();
// 幅または高さが 0 の時はなにもしない
if (sact.updaterect.width == 0 || sact.updaterect.height == 0) {
if (SDL_RectEmpty(&sact.updaterect))
return OK;
}
// 更新領域に入っているスプライトの再描画
slist_foreach(sact.updatelist, do_update_each, NULL);
@@ -178,7 +145,7 @@ int sp_update_clipped() {
}
// 更新領域を Window に転送
ags_updateArea(sact.updaterect.x, sact.updaterect.y, sact.updaterect.width, sact.updaterect.height);
ags_updateArea(sact.updaterect.x, sact.updaterect.y, sact.updaterect.w, sact.updaterect.h);
return OK;
}
@@ -196,13 +163,13 @@ int sp_updateme(sprite_t *sp) {
r = malloc(sizeof(MyRectangle));
r->x = sp->cur.x;
r->y = sp->cur.y;
r->width = sp->cursize.width;
r->height = sp->cursize.height;
r->w = sp->cursize.width;
r->h = sp->cursize.height;
updatearea = slist_append(updatearea, r);
SACT_DEBUG("x = %d, y = %d, spno = %d w=%d,h=%d\n",
r->x, r->y, sp->no, r->width, r->height);
r->x, r->y, sp->no, r->w, r->h);
return OK;
}
@@ -224,13 +191,13 @@ int sp_updateme_part(sprite_t *sp, int x, int y, int w, int h) {
r = malloc(sizeof(MyRectangle));
r->x = sp->cur.x + x;
r->y = sp->cur.y + y;
r->width = w;
r->height = h;
r->w = w;
r->h = h;
updatearea = slist_append(updatearea, r);
SACT_DEBUG("x = %d, y = %d, spno = %d w=%d,h=%d\n",
r->x, r->y, sp->no, r->width, r->height);
r->x, r->y, sp->no, r->w, r->h);
return OK;
}
+13 -52
View File
@@ -37,7 +37,7 @@
#include "ags.h"
#include "counter.h"
#include "music.h"
#include "graphicsdevice.h"
#include "sdl_core.h"
#define SLOT 40
@@ -142,29 +142,11 @@ static void ChangeNotColor() {
DEBUG_COMMAND("ShGraph.ChangeNotColor %d,%d,%d,%d,%p,%p,%d:\n", x0, y0, width, height, src, dst, p7);
ags_check_param(&x0, &y0, &width, &height);
ags_sync();
dib = nact->ags.dib;
dp = GETOFFSET_PIXEL(dib, x0, y0);
switch(dib->depth) {
case 15:
{
WORD pic15s = PIX15(*src, *(src+1), *(src+2));
WORD pic15d = PIX15(*dst, *(dst+1), *(dst+2));
WORD *yl;
for (y = 0; y < height; y++) {
yl = (WORD *)(dp + y * dib->bytes_per_line);
for (x = 0; x < width; x++) {
if (*yl != pic15s) {
*yl = pic15d;
}
yl++;
}
}
break;
}
case 16:
{
WORD pic16s = PIX16(*src, *(src+1), *(src+2));
@@ -420,8 +402,8 @@ static void SetAnimeRect() {
maprect.x = x;
maprect.y = y;
maprect.width = w;
maprect.height = h;
maprect.w = w;
maprect.h = h;
}
static void SetAnimeBack() {
@@ -446,8 +428,8 @@ static void SetAnimeBack() {
mapback.x = sx;
mapback.y = sy;
mapback.width = w;
mapback.height = h;
mapback.w = w;
mapback.h = h;
mapback_p5 = p5;
mapback_p6 = p6;
}
@@ -505,10 +487,8 @@ static void PlayAnimeData() {
if (!is_backcopied) {
is_backcopied = TRUE;
ags_copyArea(mapback.x, mapback.y,
mapback.width, mapback.height,
mapback_p5, mapback_p6);
ags_sync();
ags_copyArea(mapback.x, mapback.y, mapback.w, mapback.h,
mapback_p5, mapback_p6);
}
if (wavno != 0) {
@@ -560,14 +540,12 @@ static void PlayAnimeData() {
// printf("wavPlay %d\n", wavno % 256);
}
}
if (is_backcopied && maprect.width != 0 && maprect.height != 0) {
ags_updateArea(maprect.x, maprect.y, maprect.width, maprect.height);
}
{
int now = get_high_counter(SYSTEMCOUNTER_MSEC);
if (now - cnt < interval) {
Sleep(interval - (now-cnt));
}
if (is_backcopied && !SDL_RectEmpty(&maprect))
ags_updateArea(maprect.x, maprect.y, maprect.w, maprect.h);
int now = get_high_counter(SYSTEMCOUNTER_MSEC);
if (now - cnt < interval) {
sdl_sleep(interval - (now-cnt));
}
}
}
@@ -588,23 +566,6 @@ static void copy_sprite(int sx, int sy, int width, int height, int dx, int dy, i
dp = GETOFFSET_PIXEL(dib, dx, dy);
switch(dib->depth) {
case 15:
{
WORD pic15 = PIX15(r, g, b);
WORD *yls, *yld;
for (y = 0; y < height; y++) {
yls = (WORD *)(sp + y * dib->bytes_per_line);
yld = (WORD *)(dp + y * dib->bytes_per_line);
for (x = 0; x < width; x++) {
if (*yls != pic15) {
*yld = *yls;
}
yls++; yld++;
}
}
break;
}
case 16:
{
WORD pic16 = PIX16(r, g, b);
+40 -14
View File
@@ -35,7 +35,9 @@
#include "system.h"
#include "xsystem35.h"
#include "modules.h"
#include "graphicsdevice.h"
#include "sdl_core.h"
#include "sdl_private.h"
#include "menu.h"
// キー変換テーブル
#define KEYMAP_MAX 8
@@ -44,24 +46,48 @@ static BYTE *keymap[KEYMAP_MAX];
static void OutputMessageBox(void) { /* 0 */
int p1 = getCaliValue();
int p2 = getCaliValue();
int p3 = getCaliValue();
int p4 = getCaliValue();
int p5 = getCaliValue();
int p6 = getCaliValue();
int title = getCaliValue();
int msg = getCaliValue();
int *res = getCaliVariable();
int ISys3xSystem = getCaliValue();
DEBUG_COMMAND_YET("ShPort.OutputMessageBox: %d,%d,%d,%d,%d,%d:\n", p1, p2, p3, p3, p4, p5, p6);
char *title_utf8 = toUTF8(svar_get(title));
char *msg_utf8 = toUTF8(svar_get(msg));
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, title_utf8, msg_utf8, sdl_window);
free(title_utf8);
free(msg_utf8);
DEBUG_COMMAND("ShPort.OutputMessageBox: %d,%d,%d,%d,%p,%d:\n", p1, p2, title, msg, res, ISys3xSystem);
}
static void InputListNum(void) { /* 1 */
int p1 = getCaliValue();
int p2 = getCaliValue();
int p3 = getCaliValue();
int p4 = getCaliValue();
int p5 = getCaliValue();
int p6 = getCaliValue();
int p7 = getCaliValue();
int flags = getCaliValue();
int title = getCaliValue();
int *val = getCaliVariable();
int minval = getCaliValue();
int maxval = getCaliValue();
int *res = getCaliVariable();
int ISys3xSystem = getCaliValue();
DEBUG_COMMAND_YET("ShPortInputListNum: %d,%d,%d,%d,%d,%d,%d:\n", p1, p2, p3, p3, p4, p5, p6, p7);
INPUTNUM_PARAM ni_param = {
.def = minval,
.min = minval,
.max = maxval,
.title = toUTF8(svar_get(title)),
};
menu_inputnumber(&ni_param);
if (ni_param.value < 0) {
*res = 0;
} else {
*val = (WORD)ni_param.value;
*res = 1;
}
free(ni_param.title);
DEBUG_COMMAND("ShPort.InputListNum: %d,%d,%p,%d,%d,%p,%d:\n", flags, title, val, minval, maxval, res, ISys3xSystem);
}
/**
-41
View File
@@ -1,41 +0,0 @@
add_library(graph STATIC
graph.c
surface.c
cg.c
graph_expandcolor_blend.c
graph_fillrect.c
graph_fillrect_amap.c
graph_fillrect_acolor.c
graph_rect.c
graph_copy.c
graph_copy_amap.c
graph_copy_bright.c
graph_copy_whiteout.c
graph_blend_amap.c
graph_blend_screen.c
graph_saturadd_amap.c
graph_draw_amap.c
graph_stretch.c
graph_cg.c
graph_buller.c
gre_blend_useamap.c
gre_blend.c
gre_blend_screen.c
)
add_library(alk STATIC alk.c)
target_compile_options(alk PRIVATE -Wno-pointer-sign)
add_library(drawtext STATIC drawtext.c)
target_compile_options(drawtext PRIVATE -Wno-pointer-sign)
add_library(list STATIC list.c)
target_include_directories(graph PUBLIC .)
target_include_directories(alk PUBLIC .)
target_include_directories(drawtext PUBLIC .)
target_include_directories(list PUBLIC .)
add_executable(lib_test list_test.c)
target_link_libraries(lib_test PRIVATE list)
add_test(NAME lib_test COMMAND lib_test)
-22
View File
@@ -272,28 +272,6 @@ void gr_copy_stretch_blend_alpha_map(surface_t *dst, int dx, int dy, int dw, int
}
switch(dst->depth) {
case 15:
{
WORD *yls, *yld;
BYTE *yla;
for (y = 0; y < dh; y++) {
yls = (WORD *)(sp + *(y + col) * src->bytes_per_line);
yld = (WORD *)(dp + y * dst->bytes_per_line);
yla = (BYTE *)(sa + *(y + col) * src->width);
for (x = 0; x < dw; x++) {
*(yld + x) = ALPHABLEND15(*(yls+ *(row + x)), *(yld+x), *(yla+*(row+x)));
}
while(*(col + y) == *(col + y + 1)) {
yld += dst->width;
for (x = 0; x < dw; x++) {
*(yld + x) = ALPHABLEND15(*(yls+ *(row+x)), *(yld+x), *(yla+*(row+x)));
}
y++;
}
}
break;
}
case 16:
{
WORD *yls, *yld;
-18
View File
@@ -94,24 +94,6 @@ void gr_blend_alpha_wds(surface_t *src1, int sx1, int sy1, surface_t *src2, int
dp = GETOFFSET_PIXEL(dst, dx, dy);
switch(dst->depth) {
case 15:
{
WORD *yls1, *yls2, *yld;
BYTE *yla;
for (y = 0; y < sh; y++) {
yls1 = (WORD *)(sp1 + y * src1->bytes_per_line);
yls2 = (WORD *)(sp2 + y * src2->bytes_per_line);
yld = (WORD *)(dp + y * dst->bytes_per_line);
yla = (BYTE *)(sa + y * src1->width);
for (x = 0; x < sw; x++) {
*yld = SUTURADD15(*yls1, ALPHABLEND15(*yls1, *yls2, *yla));
yls1++; yls2++; yld++; yla++;
}
}
break;
}
case 16:
// if (nact->mmx_is_ok) {
if (0) {
-63
View File
@@ -19,39 +19,6 @@ int gr_buller(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, in
sp = GETOFFSET_PIXEL(src, sx, sy);
dp = GETOFFSET_PIXEL(dst, dx, dy);
switch(dst->depth) {
case 15:
{
WORD *yld, *yls;
for (y = 0; y < height; y++) {
yls = (WORD *)(sp + y * src->bytes_per_line);
yld = (WORD *)(dp + y * dst->bytes_per_line);
for (x = 0; x < step; x++) {
*yld = *(yls+step);
yls++; yld++;
}
for (; x < (width - step*2); x++) {
r1 = PIXR15((*(yls+step)));
g1 = PIXG15((*(yls+step)));
b1 = PIXB15((*(yls+step)));
r2 = PIXR15((*(yls-step)));
g2 = PIXG15((*(yls-step)));
b2 = PIXB15((*(yls-step)));
r3 = min(255, (r1+r2) >> 1);
g3 = min(255, (g1+g2) >> 1);
b3 = min(255, (b1+b2) >> 1);
*yld = PIX15(r3, g3, b3);
yld++; yls++;
}
for (; x < width; x++) {
*yld = *(yls-step);
yls++; yld++;
}
}
break;
}
case 16:
{
WORD *yld, *yls;
@@ -137,36 +104,6 @@ int gr_buller_v(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy,
sp = GETOFFSET_PIXEL(src, sx, sy);
dp = GETOFFSET_PIXEL(dst, dx, dy);
switch(dst->depth) {
case 15:
{
WORD *yld, *yls;
for (x = 0; x < width; x++) {
yls = (WORD *)(sp + x * src->bytes_per_pixel);
yld = (WORD *)(dp + x * dst->bytes_per_pixel);
for (y = 0; y < step; y++) {
*(yld+y*dst->width) = *(yls+(y+step)*src->width);
}
for (; y < (height - step*2); y++) {
r1 = PIXR15((*(yls+(y+step)*src->width)));
g1 = PIXG15((*(yls+(y+step)*src->width)));
b1 = PIXB15((*(yls+(y+step)*src->width)));
r2 = PIXR15((*(yls+(y-step)*src->width)));
g2 = PIXG15((*(yls+(y-step)*src->width)));
b2 = PIXB15((*(yls+(y-step)*src->width)));
r3 = min(255, (r1+r2) >> 1);
g3 = min(255, (g1+g2) >> 1);
b3 = min(255, (b1+b2) >> 1);
*(yld+y*dst->width) = PIX15(r3, g3, b3);
}
for (; y < height; y++) {
*(yld+y*dst->width) = *(yls+(y-step)*src->width);
}
}
break;
}
case 16:
{
WORD *yld, *yls;
+1 -33
View File
@@ -57,23 +57,6 @@ void gr_drawimage24(surface_t *ds, cgdata *cg, int x, int y) {
dp = GETOFFSET_PIXEL(ds, dx, dy);
switch(ds->depth) {
case 15:
{
WORD *yl;
for (y = 0; y < dh; y++) {
yl = (WORD *)(dp + y * ds->bytes_per_line);
for (x = 0; x < dw; x++) {
r = *sp;
g = *(sp +1);
b = *(sp +2);
*yl = PIX15(r, g, b);
yl++; sp += 3;
}
sp += ((cg->width - dw) * 3);
}
break;
}
case 16:
{
WORD *yl;
@@ -138,21 +121,6 @@ void gr_drawimage16(surface_t *ds, cgdata *cg, int x, int y) {
dp = GETOFFSET_PIXEL(ds, dx, dy);
switch(ds->depth) {
case 15:
{
WORD *yl;
for (y = 0; y < dh; y++) {
yl = (WORD *)(dp + y * ds->bytes_per_line);
for (x = 0; x < dw; x++) {
pic16 = *sp;
*yl = PIX15(RGB_PIXR16(pic16), RGB_PIXG16(pic16), RGB_PIXB16(pic16));
yl++; sp ++;
}
sp += (cg->width - dw);
}
break;
}
case 16:
{
for (y = 0; y < dh; y++) {
@@ -172,7 +140,7 @@ void gr_drawimage16(surface_t *ds, cgdata *cg, int x, int y) {
yl = (DWORD *)(dp + y * ds->bytes_per_line);
for (x = 0; x < dw; x++) {
pic16 = *sp;
*yl = PIX24(RGB_PIXR16(pic16), RGB_PIXG16(pic16), RGB_PIXB16(pic16));
*yl = PIX24(PIXR16(pic16), PIXG16(pic16), PIXB16(pic16));
yl++; sp++;
}
sp += (cg->width - dw);
-15
View File
@@ -19,21 +19,6 @@ void gr_copy_bright(surface_t *dst, int dx, int dy, surface_t *src, int sx, int
if (sp == NULL || dp == NULL) return;
switch(dst->depth) {
case 15:
{
WORD *yls, *yld;
for (y = 0; y < height; y++) {
yls = (WORD *)(sp + y * src->bytes_per_line);
yld = (WORD *)(dp + y * dst->bytes_per_line);
for (x = 0; x < width; x++) {
*yld = ALPHALEVEL15(*yls, lv);
yls++; yld++;
}
}
break;
}
case 16:
if (nact->mmx_is_ok) {
// if (0) {
-15
View File
@@ -20,21 +20,6 @@ void gr_copy_whiteout(surface_t *dst, int dx, int dy, surface_t *src, int sx, in
if (sp == NULL || dp == NULL) return;
switch(dst->depth) {
case 15:
{
WORD *yls, *yld;
for (y = 0; y < sh; y++) {
yls = (WORD *)(sp + y * src->bytes_per_line);
yld = (WORD *)(dp + y * dst->bytes_per_line);
for (x = 0; x < sw; x++) {
*yld = WHITELEVEL15(*yls, lv);
yls++; yld++;
}
}
break;
}
case 16:
{
WORD *yls, *yld;
-16
View File
@@ -19,22 +19,6 @@ int gr_expandcolor_blend(surface_t *dst, int dx, int dy, surface_t *src, int sx,
dp = GETOFFSET_PIXEL(dst, dx, dy);
switch(dst->depth) {
case 15: {
WORD *yd;
BYTE *ys;
col = PIX15(r, g, b);
for (y = 0; y < sh; y++) {
ys = (BYTE *)(sp + y * src->bytes_per_line);
yd = (WORD *)(dp + y * dst->bytes_per_line);
for (x = 0; x < sw; x++) {
if (*ys) {
*yd = ALPHABLEND15(col, *yd, (BYTE)*ys);
}
ys++; yd++;
}
}
break;
}
case 16:
col = PIX16(r, g, b);
//if (nact->mmx_is_ok) {
-9
View File
@@ -21,15 +21,6 @@ int gr_fill(surface_t *dst, int dx, int dy, int dw, int dh, int r, int g, int b)
memset(dp, r, dw);
break;
case 15:
{
WORD pic15 = PIX15(r, g, b);
for (x = 0; x < dw; x++) {
*((WORD *)dp + x) = pic15;
}
break;
}
case 16:
{
WORD pic16 = PIX16(r, g, b);
-14
View File
@@ -18,20 +18,6 @@ int gr_fill_alpha_color(surface_t *dst, int dx, int dy, int dw, int dh, int r, i
dp = GETOFFSET_PIXEL(dst, dx, dy);
switch(dst->depth) {
case 15:
{
WORD pic15 = PIX15(r, g, b);
WORD *yls;
for (y = 0; y < dh; y++) {
yls = (WORD *)(dp + y * dst->bytes_per_line);
for (x = 0; x < dw; x++) {
*yls = ALPHABLEND15(pic15, *yls, lv);
yls++;
}
}
break;
}
case 16:
if (nact->mmx_is_ok) {
#ifdef ENABLE_MMX
-3
View File
@@ -19,8 +19,6 @@ int gr_drawrect(surface_t *dst, int x, int y, int w, int h, int r, int g, int b)
switch(dst->depth) {
case 8:
col = r; break;
case 15:
col = PIX15(r, g, b); break;
case 16:
col = PIX16(r, g, b); break;
case 24:
@@ -49,7 +47,6 @@ int gr_drawrect(surface_t *dst, int x, int y, int w, int h, int r, int g, int b)
*((BYTE *)dp + i) = col;
}
break;
case 15:
case 16:
/* top */
for (i = 0; i < w; i++) {
-1
View File
@@ -38,7 +38,6 @@ void gr_copy_stretch(surface_t *dst, int dx, int dy, int dw, int dh, surface_t *
}
switch(dst->depth) {
case 15:
case 16:
{
WORD *yls, *yld;
-16
View File
@@ -16,22 +16,6 @@ int gre_Blend(surface_t *write, int wx, int wy, surface_t *dst, int dx, int dy,
dp = GETOFFSET_PIXEL(dst, dx, dy);
switch(dst->depth) {
case 15:
{
WORD *yls, *yld, *ylw;
for (y = 0; y < height; y++) {
yls = (WORD *)(sp + y * src->bytes_per_line);
yld = (WORD *)(dp + y * dst->bytes_per_line);
ylw = (WORD *)(wp + y * write->bytes_per_line);
for (x = 0; x < width; x++) {
*ylw = ALPHABLEND15(*yls, *yld, lv);
yls++; yld++; ylw++;
}
}
break;
}
case 16:
if (nact->mmx_is_ok) {
// if (0) {
-16
View File
@@ -15,22 +15,6 @@ int gre_BlendScreen(surface_t *write, int wx, int wy, surface_t *dst, int dx, in
dp = GETOFFSET_PIXEL(dst, dx, dy);
switch(dst->depth) {
case 15:
{
WORD *yls, *yld, *ylw;
for (y = 0; y < height; y++) {
yls = (WORD *)(sp + y * src->bytes_per_line);
yld = (WORD *)(dp + y * dst->bytes_per_line);
ylw = (WORD *)(wp + y * write->bytes_per_line);
for (x = 0; x < width; x++) {
*ylw = SUTURADD15(*yls, *yld);
yls++; yld++; ylw++;
}
}
break;
}
case 16:
{
WORD *yls, *yld, *ylw;
-36
View File
@@ -19,24 +19,6 @@ int gre_BlendUseAMap(surface_t *write, int wx, int wy, surface_t *dst, int dx, i
if (lv == 255) {
switch(dst->depth) {
case 15:
{
WORD *yls, *yld, *ylw;
BYTE *yla;
for (y = 0; y < height; y++) {
yls = (WORD *)(sp + y * src->bytes_per_line);
yld = (WORD *)(dp + y * dst->bytes_per_line);
ylw = (WORD *)(wp + y * write->bytes_per_line);
yla = (BYTE *)(ap + y * alpha->width);
for (x = 0; x < width; x++) {
*ylw = ALPHABLEND15(*yls, *yld, *yla);
yls++; yld++; ylw++; yla++;
}
}
break;
}
case 16:
if (nact->mmx_is_ok) {
// if (0) {
@@ -88,24 +70,6 @@ int gre_BlendUseAMap(surface_t *write, int wx, int wy, surface_t *dst, int dx, i
} else {
switch(dst->depth) {
case 15:
{
WORD *yls, *yld, *ylw;
BYTE *yla;
for (y = 0; y < height; y++) {
yls = (WORD *)(sp + y * src->bytes_per_line);
yld = (WORD *)(dp + y * dst->bytes_per_line);
ylw = (WORD *)(wp + y * write->bytes_per_line);
yla = (BYTE *)(ap + y * alpha->width);
for (x = 0; x < width; x++) {
*ylw = ALPHABLEND15(*yls, *yld, (*yla * lv) / 255);
yls++; yld++; ylw++; yla++;
}
}
break;
}
case 16:
if (nact->mmx_is_ok) {
// if (0) {
+2 -3
View File
@@ -25,7 +25,6 @@ static surface_t *create(int width, int height, int depth, boolean has_pixel, bo
s->bytes_per_line = width;
s->bytes_per_pixel = 1;
break;
case 15:
case 16:
s->pixel = calloc(width * (height +1) * 2, sizeof(BYTE));
s->bytes_per_line = width * 2;
@@ -53,7 +52,7 @@ static surface_t *create(int width, int height, int depth, boolean has_pixel, bo
* surfaceの生成 (pixel + alpha)
* @param width: surfaceの幅
* @param height: surfaceの高さ
* @param depth: surfaceのpixelのBPP (8|15|16|24|32), alphaは8固定
* @param depth: surfaceのpixelのBPP (8|16|24|32), alphaは8固定
* @return surface
*/
surface_t *sf_create_surface(int width, int height, int depth) {
@@ -74,7 +73,7 @@ surface_t *sf_create_alpha(int width, int height) {
* surfaceの生成 (pixelのみ)
* @param width: surfaceの幅
* @param height: surfaceの高さ
* @param depth: surfaceのBPP(8|15|16|24|32)
* @param depth: surfaceのBPP(8|16|24|32)
* @return surface
*/
surface_t *sf_create_pixel(int width, int height, int depth) {
+2
View File
@@ -20,6 +20,8 @@
#ifndef __MODULES_H__
#define __MODULES_H__
#include "scenario.h"
typedef struct {
const char *name;
void (*entrypoint)(void);
+35 -33
View File
@@ -3,7 +3,7 @@ add_library(src_lib STATIC
hankaku.c
utfsjis.c
)
target_compile_options(src_lib PRIVATE -Wno-pointer-sign)
target_compile_options(src_lib PRIVATE -Wno-pointer-sign -Wall)
target_include_directories(src_lib PRIVATE .)
if (ANDROID)
@@ -12,7 +12,7 @@ else()
add_executable(xsystem35)
endif()
target_compile_options(xsystem35 PRIVATE -Wno-pointer-sign)
target_compile_options(xsystem35 PRIVATE -Wno-pointer-sign $<$<CONFIG:Debug>:-Wall>)
target_include_directories(xsystem35 PRIVATE .)
target_link_libraries(xsystem35 PRIVATE src_lib)
@@ -24,10 +24,7 @@ target_sources(xsystem35 PRIVATE
${SRC_AUDIO}
${SRC_CDROM}
${SRC_MIDI}
${SRC_GRAPHDEV}
${SRC_FONT}
${SRC_MENU}
${SRC_JOYSTICK})
${SRC_MENU})
# System3.x commands
target_sources(xsystem35 PRIVATE
@@ -35,6 +32,11 @@ target_sources(xsystem35 PRIVATE
cmdk.c cmdl.c cmdm.c cmdn.c cmdo.c cmdp.c cmdq.c cmds.c cmdt.c
cmdu.c cmdv.c cmdw.c cmdy.c cmdz.c cmd2F.c cmd2F60.c)
# Graphics
target_sources(xsystem35 PRIVATE
sdl_video.c sdl_draw.c sdl_event.c sdl_image.c sdl_cursor.c image.c font.c)
# CG
target_sources(xsystem35 PRIVATE
pms.c vsp.c bmp.c qnt.c)
@@ -56,18 +58,24 @@ target_sources(xsystem35 PRIVATE
# Scenario
target_sources(xsystem35 PRIVATE
cali.c scenario.c variable.c cmd_check.c nact.c
selection.c message.c savedata.c s39ain.c texthook.c)
selection.c message.c savedata.c s39ain.c texthook.c msgskip.c)
# Graphics
target_sources(xsystem35 PRIVATE
ags.c font.c flood.c cg.c ecopy.c antialiase.c alpha_plane.c cursor.c)
ags.c cg.c ecopy.c alpha_plane.c cursor.c)
# Network
target_sources(xsystem35 PRIVATE
network.c)
# Debugger
if (ENABLE_DEBUGGER)
target_sources(xsystem35 PRIVATE
debug_symbol.c debugger.c debugger_cui.c debugger_dap.c)
endif()
if (WIN32)
target_sources(xsystem35 PRIVATE win/dialog.c win/resources.rc)
target_sources(xsystem35 PRIVATE win/dialog.c win/resources.rc win/menubar.c win/console.c)
endif()
if (EMSCRIPTEN)
@@ -75,8 +83,8 @@ if (EMSCRIPTEN)
set(LIBS
"SHELL:-s USE_ZLIB=1"
"SHELL:-s USE_LIBJPEG=1"
"SHELL:-s USE_FREETYPE=1"
"SHELL:-s USE_SDL=2")
"SHELL:-s USE_SDL=2"
"SHELL:-s USE_SDL_TTF=2")
target_compile_options(xsystem35 PRIVATE ${LIBS})
target_link_options(xsystem35 PRIVATE ${LIBS})
target_link_libraries(xsystem35 PRIVATE idbfs.js)
@@ -87,11 +95,12 @@ if (EMSCRIPTEN)
target_link_options(xsystem35 PRIVATE
"SHELL:-s ENVIRONMENT=web"
"SHELL:-s ASYNCIFY=1 -s ASYNCIFY_IGNORE_INDIRECT=1"
"SHELL:-s ASYNCIFY_IMPORTS=\"['muspcm_load_no','muspcm_load_mixlr','muspcm_waitend','wait_vsync','load_mincho_font']\""
"SHELL:-s ASYNCIFY_REMOVE=SDL_Delay"
"SHELL:-s ASYNCIFY_IMPORTS=muspcm_load_no,muspcm_load_mixlr,muspcm_waitend,wait_vsync,load_mincho_font"
"SHELL:-s ASYNCIFY_ADD=commands2F60,nact_main,send_agsevent,cb_waitkey_sprite"
"SHELL:-s ALLOW_MEMORY_GROWTH=1"
"SHELL:-s NO_EXIT_RUNTIME=1"
"SHELL:-s EXPORTED_FUNCTIONS=\"['_main','_ags_setAntialiasedStringMode', '_ald_getdata', '_ald_freedata']\""
"SHELL:-s EXTRA_EXPORTED_RUNTIME_METHODS=\"['getValue','addRunDependency','removeRunDependency']\"")
"SHELL:-s EXPORTED_RUNTIME_METHODS=getValue,addRunDependency,removeRunDependency")
elseif (ANDROID)
@@ -99,27 +108,20 @@ elseif (ANDROID)
else() # non-emscripten, non-android
target_link_libraries(xsystem35 PRIVATE m ZLIB::ZLIB)
if (X11_FOUND)
target_include_directories(xsystem35 PRIVATE ${X11_INCLUDE_DIR})
target_link_libraries(xsystem35 PRIVATE ${X11_LIBRARIES})
if (X11_xf86vmode_FOUND)
target_link_libraries(xsystem35 PRIVATE ${X11_Xxf86vm_LIB})
endif()
endif()
if (GTK2_FOUND)
target_link_libraries(xsystem35 PRIVATE GTK2::gtk)
endif()
if (FREETYPE_FOUND)
target_link_libraries(xsystem35 PRIVATE Freetype::Freetype)
endif()
if (ENABLE_SDL)
target_link_libraries(xsystem35 PRIVATE PkgConfig::SDL2)
target_link_libraries(xsystem35 PRIVATE PkgConfig::SDL2)
target_link_libraries(xsystem35 PRIVATE PkgConfig::SDL2TTF)
if (GTK3_FOUND)
target_link_libraries(xsystem35 PRIVATE PkgConfig::GTK3)
endif()
if (SDL2MIXER_FOUND)
target_link_libraries(xsystem35 PRIVATE PkgConfig::SDL2MIXER)
endif()
if (SDL2TTF_FOUND)
target_link_libraries(xsystem35 PRIVATE PkgConfig::SDL2TTF)
if (ENABLE_DEBUGGER)
if (cJSON_FOUND)
target_link_libraries(xsystem35 PRIVATE PkgConfig::cJSON)
else()
target_link_libraries(xsystem35 PRIVATE ${cJSON})
endif()
endif()
install(TARGETS xsystem35 RUNTIME DESTINATION bin)
@@ -129,14 +131,14 @@ else() # non-emscripten, non-android
gameresource_test.c
hankaku_test.c
)
target_compile_options(src_tests PRIVATE -Wno-pointer-sign)
target_compile_options(src_tests PRIVATE -Wno-pointer-sign -Wall)
target_link_libraries(src_tests PRIVATE src_lib)
add_test(NAME src_tests COMMAND src_tests)
configure_file(testdata/test.gr ${CMAKE_CURRENT_BINARY_DIR}/testdata/test.gr COPYONLY)
endif()
# FIXME: set up dependency for xsystem35 on this
if (ENABLE_SDL AND NOT EMSCRIPTEN AND NOT ANDROID)
if (NOT EMSCRIPTEN AND NOT ANDROID)
add_custom_target(sdl_keytable.h
COMMAND perl ../tools/xsyskey.pl ${SDL2_INCLUDE_DIRS} > sdl_keytable.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+106 -223
View File
@@ -27,26 +27,27 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
#include "portab.h"
#include "xsystem35.h"
#include "scenario.h"
#include "ags.h"
#include "graphicsdevice.h"
#include "sdl_core.h"
#include "alpha_plane.h"
#include "counter.h"
#include "utfsjis.h"
#include "input.h"
#include "flood.h"
#include "font.h"
#include "cursor.h"
#include "image.h"
#define check_param ags_check_param
#define check_param_xy ags_check_param_xy
#define intersection ags_intersection
static void initPal(Palette256 *sys_pal);
static boolean intersects(MyRectangle *r1, MyRectangle *r2);
static Palette256 pal_256;
static boolean need_update = TRUE;
@@ -62,32 +63,10 @@ static void initPal(Palette256 *pal) {
pal->red[7] = 255; pal->green[7] = 255; pal->blue[7] = 255;
pal->red[15] = 255; pal->green[15] = 255; pal->blue[15] = 255;
pal->red[255] = 255; pal->green[255] = 255; pal->blue[255] = 255;
SetPalette(pal, 0, 256);
sdl_setPalette(pal, 0, 256);
nact->sys_pal_changed = TRUE;
}
boolean ags_regionContains(MyRectangle *r, int x, int y) {
return x >= r->x && x < r->x + r->width && y >= r->y && y < r->y + r->height;
}
static boolean intersects(MyRectangle *r1, MyRectangle *r2) {
return !((r2->x + r2->width <= r1->x) ||
(r2->y + r2->height <= r1->y) ||
(r2->x >= r1->x + r1->width) ||
(r2->y >= r1->y + r1->height));
}
void ags_intersection(MyRectangle *r1, MyRectangle *r2, MyRectangle *rst) {
int x1 = max(r1->x, r2->x);
int x2 = min(r1->x + r1->width, r2->x + r2->width);
int y1 = max(r1->y, r2->y);
int y2 = min(r1->y + r1->height, r2->y + r2->height);
rst->x = x1;
rst->y = y1;
rst->width = x2 - x1;
rst->height = y2 - y1;
}
boolean ags_check_param(int *x, int *y, int *w, int *h) {
if (*x >= nact->sys_world_size.width) {
WARNING("Illegal Param x = %d (max=%d)(@%03x:%05x)\n", *x, nact->sys_world_size.width, sl_getPage(), sl_getIndex());
@@ -134,21 +113,19 @@ void ags_init() {
nact->sys_world_depth = SYS35_DEFAULT_DEPTH;
nact->sys_view_area.x = 0;
nact->sys_view_area.y = 0;
nact->sys_view_area.width = SYS35_DEFAULT_WIDTH;
nact->sys_view_area.height = SYS35_DEFAULT_HEIGHT;
GraphicsInitilize();
font_init(nact->fontdev);
SetFontDevice(nact->ags.font);
nact->sys_view_area.w = SYS35_DEFAULT_WIDTH;
nact->sys_view_area.h = SYS35_DEFAULT_HEIGHT;
sdl_Initilize();
font_init();
initPal(&pal_256);
cg_init();
}
void ags_remove() {
ags_autorepeat(TRUE);
GraphicsRemove();
sdl_Remove();
}
void ags_setWorldSize(int width, int height, int depth) {
@@ -161,9 +138,9 @@ void ags_setWorldSize(int width, int height, int depth) {
nact->ags.dib->alpha = NULL;
}
SetWorldSize(width, height, depth);
sdl_setWorldSize(width, height, depth);
nact->ags.dib = GetDIB();
nact->ags.dib = sdl_getDIB();
/* DIBが8以上の場合は、alpha plane を用意 */
if (depth > 8)
@@ -178,9 +155,9 @@ void ags_setViewArea(int x, int y, int width, int height) {
nact->sys_view_area.x = x;
nact->sys_view_area.y = y;
nact->sys_view_area.width = width;
nact->sys_view_area.height = height;
SetWindowSize(x, y, width, height);
nact->sys_view_area.w = width;
nact->sys_view_area.h = height;
sdl_setWindowSize(x, y, width, height);
}
void ags_setWindowTitle(const char *src) {
@@ -193,7 +170,7 @@ void ags_setWindowTitle(const char *src) {
}
strcpy(d, TITLEHEAD);
strcat(d, utf);
SetWindowTitle(d);
sdl_setWindowTitle(d);
free(utf);
free(d);
}
@@ -205,13 +182,13 @@ void ags_getDIBInfo(DispInfo *info) {
}
void ags_getViewAreaInfo(DispInfo *info) {
GetWindowInfo(info);
info->width = nact->sys_view_area.width;
info->height = nact->sys_view_area.height;
sdl_getWindowInfo(info);
info->width = nact->sys_view_area.w;
info->height = nact->sys_view_area.h;
}
void ags_getWindowInfo(DispInfo *info) {
GetWindowInfo(info);
sdl_getWindowInfo(info);
}
void ags_setExposeSwitch(boolean bool) {
@@ -219,35 +196,31 @@ void ags_setExposeSwitch(boolean bool) {
}
void ags_updateArea(int x, int y, int w, int h) {
MyRectangle r, update;
MyPoint p;
if (fade_outed) return;
if (need_update) {
r.x = x; r.y = y; r.width = w; r.height = h;
if (intersects(&nact->sys_view_area, &r)) {
intersection(&nact->sys_view_area, &r, &update);
p.x = update.x - nact->sys_view_area.x;
p.y = update.y - nact->sys_view_area.y;
UpdateArea(&update, &p);
}
if (fade_outed || !need_update)
return;
MyRectangle r = {x, y, w, h}, update;
if (SDL_IntersectRect(&nact->sys_view_area, &r, &update)) {
MyPoint p = {
update.x - nact->sys_view_area.x,
update.y - nact->sys_view_area.y
};
sdl_updateArea(&update, &p);
}
}
void ags_updateFull() {
if (fade_outed || !need_update)
return;
MyRectangle r = {
nact->sys_view_area.x,
nact->sys_view_area.y,
min(nact->sys_view_area.w, nact->sys_world_size.width),
min(nact->sys_view_area.h, nact->sys_world_size.height)
};
MyPoint p = {0, 0};
MyRectangle r;
if (fade_outed) return;
if (need_update) {
r.x = nact->sys_view_area.x;
r.y = nact->sys_view_area.y;
r.width = min(nact->sys_view_area.width, nact->sys_world_size.width);
r.height = min(nact->sys_view_area.height, nact->sys_world_size.height);
UpdateArea(&r, &p);
}
sdl_updateArea(&r, &p);
}
void ags_setPalettes(Palette256 *src_pal, int src, int dst, int cnt) {
@@ -269,49 +242,47 @@ void ags_setPalette(int no, int red, int green, int blue) {
void ags_setPaletteToSystem(int src, int cnt) {
if (!fade_outed)
SetPalette(nact->sys_pal, src, cnt);
sdl_setPalette(nact->sys_pal, src, cnt);
}
void ags_drawRectangle(int x, int y, int w, int h, int col) {
if (!check_param(&x, &y, &w, &h)) return;
DrawRectangle(x, y, w, h, col);
sdl_drawRectangle(x, y, w, h, col);
}
void ags_fillRectangle(int x, int y, int w, int h, int col) {
if (!check_param(&x, &y, &w, &h)) return;
FillRectangle(x, y, w, h, col);
sdl_fillRectangle(x, y, w, h, col);
}
void ags_drawLine(int x0, int y0, int x1, int y1, int col) {
if (!check_param_xy(&x0, &y0)) return;
if (!check_param_xy(&x1, &y1)) return;
DrawLine(x0, y0, x1, y1, col);
sdl_drawLine(x0, y0, x1, y1, col);
}
void ags_copyArea(int sx, int sy, int w, int h, int dx, int dy) {
if (!check_param(&sx, &sy, &w, &h)) return;
if (!check_param(&dx, &dy, &w, &h)) return;
CopyArea(sx, sy, w, h, dx, dy);
sdl_copyArea(sx, sy, w, h, dx, dy);
}
void ags_scaledCopyArea(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int mirror_sw) {
if (!check_param(&sx, &sy, &sw, &sh)) return;
if (!check_param(&dx, &dy, &dw, &dh)) return;
DspDeviceSync(); /* Device依存の sync (ex. XSync()) */
ScaledCopyArea(sx, sy, sw, sh, dx, dy, dw, dh, mirror_sw);
sdl_scaledCopyArea(sx, sy, sw, sh, dx, dy, dw, dh, mirror_sw);
}
void ags_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, int col) {
if (!check_param(&sx, &sy, &w, &h)) return;
if (!check_param(&dx, &dy, &w, &h)) return;
DspDeviceSync();
CopyAreaSP(sx, sy, w, h, dx, dy, col);
sdl_copyAreaSP(sx, sy, w, h, dx, dy, col);
}
void ags_wrapColor(int x, int y, int w, int h, int p1, int p2) {
@@ -319,15 +290,13 @@ void ags_wrapColor(int x, int y, int w, int h, int p1, int p2) {
if (!check_param(&x, &y, &w, &h)) return;
DspDeviceSync();
WrapColor(x, y, w, h, p1, p2);
sdl_wrapColor(x, y, w, h, p1, p2);
}
void ags_getPixel(int x, int y, Palette *cell) {
if (!check_param_xy(&x, &y)) return;
DspDeviceSync();
GetPixel(x, y, cell);
sdl_getPixel(x, y, cell);
}
void ags_changeColorArea(int sx, int sy, int w, int h, int dst, int src, int cnt) {
@@ -335,7 +304,6 @@ void ags_changeColorArea(int sx, int sy, int w, int h, int dst, int src, int cnt
if (!check_param(&sx, &sy, &w, &h)) return;
DspDeviceSync();
{
agsurface_t *dib = nact->ags.dib;
int x, y;
@@ -356,8 +324,7 @@ void ags_changeColorArea(int sx, int sy, int w, int h, int dst, int src, int cnt
void* ags_saveRegion(int x, int y, int w, int h) {
if (!check_param(&x, &y, &w, &h)) return NULL;
DspDeviceSync();
return (void *)SaveRegion(x, y, w, h);
return (void *)sdl_saveRegion(x, y, w, h);
}
void ags_restoreRegion(void *region, int x, int y) {
@@ -365,8 +332,7 @@ void ags_restoreRegion(void *region, int x, int y) {
if (!check_param_xy(&x, &y)) return;
DspDeviceSync();
RestoreRegion(region, x, y);
sdl_restoreRegion(region, x, y);
}
void ags_putRegion(void *region, int x, int y) {
@@ -374,8 +340,7 @@ void ags_putRegion(void *region, int x, int y) {
if (!check_param_xy(&x, &y)) return;
DspDeviceSync();
PutRegion(region, x, y);
sdl_putRegion(region, x, y);
}
void ags_copyRegion(void *region, int sx, int sy , int w, int h, int dx, int dy) {
@@ -384,35 +349,44 @@ void ags_copyRegion(void *region, int sx, int sy , int w, int h, int dx, int dy)
if (!check_param_xy(&dx, &dy)) return;
if (!check_param(&dx, &dy, &w, &h)) return;
DspDeviceSync();
CopyRegion(region, sx, sy, w, h, dx, dy);
sdl_CopyRegion(region, sx, sy, w, h, dx, dy);
}
void ags_delRegion(void *region) {
if (region == NULL) return;
DspDeviceSync();
DelRegion(region);
sdl_delRegion(region);
}
int ags_drawString(int x, int y, const char *src, int col) {
int w;
MyRectangle ags_drawString(int x, int y, const char *src, int col) {
if (!check_param_xy(&x, &y)) return (MyRectangle){};
if (!check_param_xy(&x, &y)) return 0;
DspDeviceSync();
char *utf8 = toUTF8(src);
w = DrawString(x, y, utf8, col);
SDL_Rect r = sdl_drawString(x, y, utf8, col);
free(utf8);
return w;
return (MyRectangle){r.x, r.y, r.w, r.h};
}
agsurface_t *ags_drawStringToSurface(const char *str) {
static SDL_Surface *fs;
static agsurface_t result;
if (fs) {
SDL_FreeSurface(fs);
fs = NULL;
}
char *utf8 = toUTF8(str);
agsurface_t *sf = nact->ags.font->get_glyph(utf8);
fs = font_get_glyph(utf8);
free(utf8);
return sf;
result.depth = fs->format->BitsPerPixel;
result.bytes_per_pixel = fs->format->BytesPerPixel;
result.bytes_per_line = fs->pitch;
result.pixel = fs->pixels;
result.width = fs->w;
result.height = fs->h;
return &result;
}
void ags_drawCg8bit(cgdata *cg, int x, int y) {
@@ -426,8 +400,7 @@ void ags_drawCg8bit(cgdata *cg, int x, int y) {
if (!check_param(&x, &y, &w, &h)) return;
cg->data_offset = abs(sy - y) * cg->width + abs(sx - x);
DspDeviceSync();
DrawImage8_fromData(cg, x, y, w, h);
sdl_drawImage8_fromData(cg, x, y, w, h);
}
void ags_drawCg16bit(cgdata *cg, int x, int y) {
@@ -441,8 +414,7 @@ void ags_drawCg16bit(cgdata *cg, int x, int y) {
if (!check_param(&x, &y, &w, &h)) return;
cg->data_offset = abs(sy - y) * cg->width + abs(sx - x);
DspDeviceSync();
DrawImage16_fromData(cg, x, y, w, h);
sdl_drawImage16_fromData(cg, x, y, w, h);
}
void ags_copyArea_shadow(int sx, int sy, int w, int h, int dx, int dy) {
@@ -451,8 +423,7 @@ void ags_copyArea_shadow(int sx, int sy, int w, int h, int dx, int dy) {
if (!check_param(&sx, &sy, &w, &h)) return;
if (!check_param(&dx, &dy, &w, &h)) return;
DspDeviceSync();
CopyAreaSP16_shadow(sx, sy, w, h, dx, dy);
sdl_copyAreaSP16_shadow(sx, sy, w, h, dx, dy, 255);
}
void ags_copyArea_transparent(int sx, int sy, int w, int h, int dx, int dy, int col) {
@@ -461,8 +432,7 @@ void ags_copyArea_transparent(int sx, int sy, int w, int h, int dx, int dy, int
if (!check_param(&sx, &sy, &w, &h)) return;
if (!check_param(&dx, &dy, &w, &h)) return;
DspDeviceSync();
CopyAreaSP(sx, sy, w, h, dx, dy, col);
sdl_copyAreaSP(sx, sy, w, h, dx, dy, col);
}
void ags_copyArea_alphaLevel(int sx, int sy, int w, int h, int dx, int dy, int lv) {
@@ -471,8 +441,7 @@ void ags_copyArea_alphaLevel(int sx, int sy, int w, int h, int dx, int dy, int l
if (!check_param(&sx, &sy, &w, &h)) return;
if (!check_param(&dx, &dy, &w, &h)) return;
DspDeviceSync();
CopyAreaSP16_alphaLevel(sx, sy, w, h, dx, dy, lv);
sdl_copyAreaSP16_alphaLevel(sx, sy, w, h, dx, dy, lv);
}
void ags_copyArea_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, int lv) {
@@ -481,8 +450,7 @@ void ags_copyArea_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, int l
if (!check_param(&sx, &sy, &w, &h)) return;
if (!check_param(&dx, &dy, &w, &h)) return;
DspDeviceSync();
CopyAreaSP16_alphaBlend(sx, sy, w, h, dx, dy, lv);
sdl_copyAreaSP16_alphaBlend(sx, sy, w, h, dx, dy, lv);
}
void ags_copyArea_whiteLevel(int sx, int sy, int w, int h, int dx, int dy, int lv) {
@@ -491,79 +459,14 @@ void ags_copyArea_whiteLevel(int sx, int sy, int w, int h, int dx, int dy, int l
if (!check_param(&sx, &sy, &w, &h)) return;
if (!check_param(&dx, &dy, &w, &h)) return;
DspDeviceSync();
CopyAreaSP16_whiteLevel(sx, sy, w, h, dx, dy, lv);
sdl_copyAreaSP16_whiteLevel(sx, sy, w, h, dx, dy, lv);
}
MyRectangle ags_floodFill(int x, int y, int col) {
if (!check_param_xy(&x, &y))
return (MyRectangle){};
/*******************************************************
*
* special thanks to tajiri@wizard.elec.waseda.ac.jpさん
*
*******************************************************/
/* CP コマンドの実装用. 同じ色で出来た領域を指定された
*/
static int floodColor;
static int changeColor;
static agsurface_t *__img;
/*この操作のあとにアップデートする領域
(updatePointTop updatePointEndで囲まれた長方形)
*/
static MyPoint updatePointTop, updatePointEnd;
static int pixcel(int x, int y) {
int pixval;
if ((y >= 0) && (y <= __img->height) && (x >= 0) && (x <= __img->width)) {
BYTE *dst = (BYTE *)(__img->pixel + y * __img->bytes_per_line + x);
pixval = *dst;
if (pixval == floodColor){
/* if(pixval <= floodColor+2 && pixval >= floodColor-2){ */
*dst = changeColor;
if (x < updatePointTop.x) updatePointTop.x = x;
if (x > updatePointEnd.x) updatePointEnd.x = x;
if (y < updatePointTop.y) updatePointTop.y = y;
if (y > updatePointEnd.y) updatePointEnd.y = y;
return TRUE;
}
}
return FALSE;
}
MyRectangle* ags_imageFlood(int x, int y, int c) {
if (nact->sys_world_depth != 8) return NULL;
if (!check_param_xy(&x, &y)) return NULL;
DspDeviceSync();
{
agsurface_t *dib = nact->ags.dib;
BYTE *dst = GETOFFSET_PIXEL(dib, x, y);
static MyRectangle rec;
__img = dib;
updatePointTop.x = x;
updatePointTop.y = y;
updatePointEnd.x = x;
updatePointEnd.y = y;
/*直線はぬりなおしたりしない!!*/
if ((x <= 0 || (*(dst - 1) != *(dst))) && ((x >= dib->width) || (*(dst + 1) != *dst)))
return NULL;
if ((y <= 0 || (*(dst - dib->bytes_per_line) != *(dst)))
&& ((y >= dib->height) || (*(dst + dib->bytes_per_line) != *dst)))
return NULL;
floodColor = *dst;
changeColor = c;
flood(x, y, pixcel);
rec.x = updatePointTop.x;
rec.y = updatePointTop.y;
rec.width = updatePointEnd.x - updatePointTop.x + 1;
rec.height = updatePointEnd.y - updatePointTop.y + 1;
return &rec;
}
return sdl_floodFill(x, y, col);
}
void ags_copyFromAlpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flg) {
@@ -572,8 +475,7 @@ void ags_copyFromAlpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_C
if (!check_param(&sx, &sy, &w, &h)) return;
if (!check_param(&dx, &dy, &w, &h)) return;
DspDeviceSync();
Copy_from_alpha(sx, sy, w, h, dx, dy, flg);
sdl_copy_from_alpha(sx, sy, w, h, dx, dy, flg);
}
void ags_copyToAlpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flg) {
@@ -582,8 +484,7 @@ void ags_copyToAlpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COP
if (!check_param(&sx, &sy, &w, &h)) return;
if (!check_param(&dx, &dy, &w, &h)) return;
DspDeviceSync();
Copy_to_alpha(sx, sy, w, h, dx, dy, flg);
sdl_copy_to_alpha(sx, sy, w, h, dx, dy, flg);
}
void ags_alpha_uppercut(int sx, int sy, int w, int h, int s, int d) {
@@ -630,12 +531,11 @@ void ags_alpha_getPixel(int x, int y, int *pic) {
}
void ags_alpha_setPixel(int x, int y, int w, int h, BYTE *b) {
int savex, savey, savew, saveh, offset;
int savex, savey, savew, offset;
savex = x;
savey = y;
savew = w;
saveh = h;
if (!check_param(&x, &y, &w, &h)) return;
@@ -663,7 +563,7 @@ void ags_fader(ags_faderinfo_t *i) {
i->callback(step);
key = sys_getInputInfo();
/* 実際の fade にかかった時間 */
Sleep(0); /* It's a magic !!! */
sdl_sleep(0); /* It's a magic !!! */
cnt2 = get_high_counter(SYSTEMCOUNTER_MSEC) - cnt1;
lefttime = i->effect_time - (cnt1 + cnt2 - cnt_st); /* fade 残り時間 */
@@ -675,7 +575,7 @@ void ags_fader(ags_faderinfo_t *i) {
mstime = lefttime / leftstep; /* 1stepに許される時間 */
if (mstime > cnt2) {
/* wait をいれる余裕がある場合 */
key = sys_keywait(mstime - cnt2, i->cancel);
key = sys_keywait(mstime - cnt2, i->cancel ? KEYWAIT_CANCELABLE : KEYWAIT_NONCANCELABLE);
step++;
} else if (mstime > 0) {
/* wait をいれる余裕が無い場合 */
@@ -713,7 +613,7 @@ void ags_fadeIn(int rate, boolean flag) {
nact->waitcancel_key = 0;
i.callback = FadeIn;
i.callback = sdl_fadeIn;
i.step_max = 255;
ags_fader(&i);
}
@@ -731,7 +631,7 @@ void ags_fadeOut(int rate, boolean flag) {
nact->waitcancel_key = 0;
i.callback = FadeOut;
i.callback = sdl_fadeOut;
i.step_max = 255;
ags_fader(&i);
}
@@ -748,7 +648,7 @@ void ags_whiteIn(int rate, boolean flag) {
nact->waitcancel_key = 0;
i.callback = WhiteIn;
i.callback = sdl_whiteIn;
i.step_max = 255;
ags_fader(&i);
}
@@ -765,18 +665,18 @@ void ags_whiteOut(int rate, boolean flag) {
nact->waitcancel_key = 0;
i.callback = WhiteOut;
i.callback = sdl_whiteOut;
i.step_max = 255;
ags_fader(&i);
}
void ags_setFont(int type, int size) {
nact->ags.font->sel_font(type, size);
font_select(type, size);
}
void ags_setCursorType(int type) {
if (nact->noimagecursor && type >= 100) return;
SetCursorType(type);
sdl_setCursorType(type);
}
void ags_loadCursor(int p1,int p2) {
@@ -801,7 +701,7 @@ void ags_setCursorLocation(int x, int y, boolean is_dibgeo) {
case 0:
return;
case 1:
SetCursorLocation(x, y); break;
sdl_setCursorLocation(x, y); break;
case 2:
sys_getMouseInfo(&p, is_dibgeo);
delx = x - p.x;
@@ -814,7 +714,7 @@ void ags_setCursorLocation(int x, int y, boolean is_dibgeo) {
dx[7] = x; dy[7] = y;
for (i = 0; i < 8; i++) {
SetCursorLocation(dx[i], dy[i]);
sdl_setCursorLocation(dx[i], dy[i]);
usleep(cursor_move_time * 1000 / 8);
}
break;
@@ -823,19 +723,15 @@ void ags_setCursorLocation(int x, int y, boolean is_dibgeo) {
}
}
EMSCRIPTEN_KEEPALIVE
void ags_setAntialiasedStringMode(boolean on) {
if (!nact->noantialias) {
nact->ags.font->antialiase_on = on;
font_set_antialias(on);
}
}
boolean ags_getAntialiasedStringMode() {
return nact->ags.font->antialiase_on;
}
void ags_fullscreen(boolean on) {
nact->sys_fullscreen_on = on;
FullScreen(on);
return font_get_antialias();
}
void ags_copyArea_shadow_withrate(int sx, int sy, int w, int h, int dx, int dy, int lv) {
@@ -846,8 +742,7 @@ void ags_copyArea_shadow_withrate(int sx, int sy, int w, int h, int dx, int dy,
if (!check_param(&sx, &sy, &w, &h)) return;
if (!check_param(&dx, &dy, &w, &h)) return;
DspDeviceSync();
CopyAreaSP16_shadow_withRate(sx, sy, w, h, dx, dy, lv);
sdl_copyAreaSP16_shadow(sx, sy, w, h, dx, dy, lv);
}
void ags_setCursorMoveTime(int msec) {
@@ -865,25 +760,13 @@ int ags_getCursorMoveTime() {
void ags_zoom(int x, int y, int w, int h) {
if (!check_param(&x, &y, &w, &h)) return;
DspDeviceSync();
Zoom(x, y, w, h);
sdl_zoom(x, y, w, h);
}
agsurface_t *ags_getDIB() {
return nact->ags.dib;
}
void ags_sync() {
DspDeviceSync();
}
void ags_fillRectangleNeg(int x, int y, int w, int h, int col) {
if (!check_param(&x, &y, &w, &h)) return;
DspDeviceSync();
image_fillRectangleNeg(nact->ags.dib, x, y, w, h, col);
}
void ags_autorepeat(boolean bool) {
SetAutoRepeat(bool);
sdl_setAutoRepeat(bool);
}
+22 -107
View File
@@ -30,8 +30,6 @@
#include "cg.h"
#include "graphics.h"
struct _FONT;
/* マウスカーソルの種類 */
#define CURSOR_ARROW 1
#define CURSOR_CROSS 2
@@ -64,7 +62,7 @@ typedef enum {
struct agsurface {
int width; /* width of surface */
int height; /* height of surface */
int depth; /* depth of surface, 8/15/16/24/32 is available */
int depth; /* depth of surface, 8/16/24/32 is available */
int bytes_per_line; /* bytes per line */
int bytes_per_pixel; /* bytes per pixel */
@@ -74,8 +72,11 @@ struct agsurface {
};
typedef struct agsurface agsurface_t;
// for agsurface_t
#define GETOFFSET_PIXEL(suf, x, y) ((suf)->pixel + (y) * (suf)->bytes_per_line + (x) * (suf)->bytes_per_pixel)
#define GETOFFSET_ALPHA(suf, x, y) ((suf)->alpha + (y) * (suf)->width + (x))
// for SDL_surface
#define PIXEL_AT(suf, x, y) ((suf)->pixels + (y) * (suf)->pitch + (x) * (suf)->format->BytesPerPixel)
struct _agsevent {
int type;
@@ -129,8 +130,6 @@ struct _ags {
boolean fullscree_is_on; /* if full-screen mode then true */
struct _FONT *font; /* font device */
agsurface_t *dib; /* main surface */
void (*eventcb)(agsevent_t *e); /* deliver event */
};
@@ -149,13 +148,9 @@ extern void ags_setWindowTitle(const char *str);
extern void ags_getDIBInfo(DispInfo *info);
extern void ags_getWindowInfo(DispInfo *info);
extern void ags_getViewAreaInfo(DispInfo *info);
extern boolean ags_regionContains(MyRectangle *r, int x, int y);
extern void ags_fullscreen(boolean on);
extern boolean ags_check_param(int *x, int *y, int *w, int *h);
extern boolean ags_check_param_xy(int *x, int *y);
extern void ags_intersection(MyRectangle *r1, MyRectangle *r2, MyRectangle *rst);
extern agsurface_t *ags_getDIB();
extern void ags_sync();
/* 画面更新 */
extern void ags_setExposeSwitch(boolean bool);
@@ -170,7 +165,6 @@ extern void ags_setPaletteToSystem(int src, int cnt);
/* 描画関係 */
extern void ags_drawRectangle(int x, int y, int w, int h, int col);
extern void ags_fillRectangle(int x, int y, int w, int h, int col);
extern void ags_fillRectangleNeg(int x, int y, int w, int h, int col);
extern void ags_drawLine(int x0, int y0, int x1, int y1, int col);
extern void ags_copyArea(int sx, int sy, int w, int h, int dx, int dy);
extern void ags_scaledCopyArea(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int mirror_sw);
@@ -188,7 +182,7 @@ extern void ags_putRegion(void *region, int x, int y);
extern void ags_copyRegion(void *region, int sx, int sy, int w,int h,int dx,int dy);
extern void ags_delRegion(void *region);
extern int ags_drawString(int x, int y, const char *src, int col);
extern MyRectangle ags_drawString(int x, int y, const char *src, int col);
extern void ags_drawCg8bit(cgdata *cg, int x, int y);
extern void ags_drawCg16bit(cgdata *cg, int x, int y);
@@ -197,7 +191,7 @@ extern void ags_copyArea_transparent(int sx, int sy, int w, int h, int dx, int d
extern void ags_copyArea_alphaLevel(int sx, int sy, int w, int h, int dx, int dy, int lv);
extern void ags_copyArea_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, int lv);
extern void ags_copyArea_whiteLevel(int sx, int sy, int w, int h, int dx, int dy, int lv);
extern MyRectangle* ags_imageFlood(int x, int y, int c);
extern MyRectangle ags_floodFill(int x, int y, int col);
extern void ags_eCopyArea(int sx, int sy, int w, int h, int dx, int dy, int type, int opt, boolean flg, int spCol);
/* alpha channel 操作 */
@@ -218,12 +212,6 @@ extern void ags_whiteOut(int rate, boolean flg);
extern void ags_fader_callback();
/* フォント関連 */
typedef enum {
FONT_X11,
FONT_FT2,
FONT_SDLTTF
} fontdev_t;
enum FontType {
FONT_GOTHIC,
FONT_MINCHO,
@@ -244,102 +232,30 @@ extern boolean ags_getAntialiasedStringMode();
extern void ags_fader(ags_faderinfo_t *);
extern void ags_autorepeat(boolean bool);
#define RGB_RMASK15 0x7c00
#define RGB_GMASK15 0x03e0
#define RGB_BMASK15 0x001f
#define RGB_RMASK16 0xf800
#define RGB_GMASK16 0x07e0
#define RGB_BMASK16 0x001f
#define RGB_RMASK24 0x00ff0000
#define RGB_GMASK24 0x0000ff00
#define RGB_BMASK24 0x000000ff
#define RMASK16 0xf800
#define GMASK16 0x07e0
#define BMASK16 0x001f
#define RMASK24 0x00ff0000
#define GMASK24 0x0000ff00
#define BMASK24 0x000000ff
#define BGR_RMASK15 0x001f
#define BGR_GMASK15 0x03e0
#define BGR_BMASK15 0x7c00
#define BGR_RMASK16 0x001f
#define BGR_GMASK16 0x07e0
#define BGR_BMASK16 0xf800
#define BGR_RMASK24 0x000000ff
#define BGR_GMASK24 0x0000ff00
#define BGR_BMASK24 0x00ff0000
#define PIXR16(pic) (BYTE)(((pic) & RMASK16) >> 8)
#define PIXG16(pic) (BYTE)(((pic) & GMASK16) >> 3)
#define PIXB16(pic) (BYTE)(((pic) & BMASK16) << 3)
#define PIX16(r,g,b) (WORD)((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | ((b ) >> 3))
#define RGB_PIXR15(pic) (BYTE)(((pic) & RGB_RMASK15) >> 7)
#define RGB_PIXG15(pic) (BYTE)(((pic) & RGB_GMASK15) >> 2)
#define RGB_PIXB15(pic) (BYTE)(((pic) & RGB_BMASK15) << 3)
#define BGR_PIXR15(pic) (BYTE)(((pic) & BGR_RMASK15) << 3)
#define BGR_PIXG15(pic) (BYTE)(((pic) & BGR_GMASK15) >> 2)
#define BGR_PIXB15(pic) (BYTE)(((pic) & BGR_BMASK15) >> 7)
#define RGB_PIX15(r,g,b) (WORD)((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | ((b ) >> 3))
#define BGR_PIX15(r,g,b) (WORD)((((r) ) >> 3) | (((g) & 0xf8) << 2) | ((b & 0xf8) << 7))
#define RGB_PIXR16(pic) (BYTE)(((pic) & RGB_RMASK16) >> 8)
#define RGB_PIXG16(pic) (BYTE)(((pic) & RGB_GMASK16) >> 3)
#define RGB_PIXB16(pic) (BYTE)(((pic) & RGB_BMASK16) << 3)
#define BGR_PIXR16(pic) (BYTE)(((pic) & BGR_RMASK16) << 3)
#define BGR_PIXG16(pic) (BYTE)(((pic) & BGR_GMASK16) >> 3)
#define BGR_PIXB16(pic) (BYTE)(((pic) & BGR_BMASK16) >> 8)
#define RGB_PIX16(r,g,b) (WORD)((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | ((b ) >> 3))
#define BGR_PIX16(r,g,b) (WORD)((((r) ) >> 3) | (((g) & 0xfc) << 3) | ((b & 0xf8) << 8))
#define RGB_PIXR24(pic) (BYTE)(((pic) & RGB_RMASK24) >> 16)
#define RGB_PIXG24(pic) (BYTE)(((pic) & RGB_GMASK24) >> 8)
#define RGB_PIXB24(pic) (BYTE)(((pic) & RGB_BMASK24) )
#define BGR_PIXR24(pic) (BYTE)(((pic) & BGR_RMASK24) )
#define BGR_PIXG24(pic) (BYTE)(((pic) & BGR_GMASK24) >> 8)
#define BGR_PIXB24(pic) (BYTE)(((pic) & BGR_BMASK24) >> 16)
#define RGB_PIX24(r,g,b) (DWORD)((((r) << 16) | ((g) << 8) | (b) ))
#define BGR_PIX24(r,g,b) (DWORD)((((r) ) | ((g) << 8) | (b) << 16))
#ifdef RGB_ORDER
#define PIXR15 RGB_PIXR15
#define PIXG15 RGB_PIXG15
#define PIXB15 RGB_PIXB15
#define PIXR16 RGB_PIXR16
#define PIXG16 RGB_PIXG16
#define PIXB16 RGB_PIXB16
#define PIXR24 RGB_PIXR24
#define PIXG24 RGB_PIXG24
#define PIXB24 RGB_PIXB24
#define PIX15 RGB_PIX15
#define PIX16 RGB_PIX16
#define PIX24 RGB_PIX24
#else
#define PIXR15 BGR_PIXR15
#define PIXG15 BGR_PIXG15
#define PIXB15 BGR_PIXB15
#define PIXR16 BGR_PIXR16
#define PIXG16 BGR_PIXG16
#define PIXB16 BGR_PIXB16
#define PIXR24 BGR_PIXR24
#define PIXG24 BGR_PIXG24
#define PIXB24 BGR_PIXB24
#define PIX15 BGR_PIX15
#define PIX16 BGR_PIX16
#define PIX24 BGR_PIX24
#endif
#define ALPHABLEND15(f, b, a) (PIX15((((PIXR15((f)) - PIXR15((b))) * (a)) >> 8) + PIXR15((b)),\
(((PIXG15((f)) - PIXG15((b))) * (a)) >> 8) + PIXG15((b)),\
(((PIXB15((f)) - PIXB15((b))) * (a)) >> 8) + PIXB15((b))))
#define ALPHALEVEL15(p, lv) (PIX15(((PIXR15(p) * (lv)) >> 8),\
((PIXG15(p) * (lv)) >> 8),\
((PIXB15(p) * (lv)) >> 8)))
#define WHITELEVEL15(p, lv) ALPHABLEND15(0x7fff, p, lv)
#define PIXR24(pic) (BYTE)(((pic) & RMASK24) >> 16)
#define PIXG24(pic) (BYTE)(((pic) & GMASK24) >> 8)
#define PIXB24(pic) (BYTE)(((pic) & BMASK24) )
#define PIX24(r,g,b) (DWORD)((((r) << 16) | ((g) << 8) | (b) ))
#define ALPHABLEND16(f, b, a) (PIX16((((PIXR16((f)) - PIXR16((b))) * (a)) >> 8)+ PIXR16((b)),\
(((PIXG16((f)) - PIXG16((b))) * (a)) >> 8)+ PIXG16((b)),\
(((PIXB16((f)) - PIXB16((b))) * (a)) >> 8)+ PIXB16((b))))
#define ALPHALEVEL16(p, lv) PIX16(((PIXR16(p) * (lv)) >> 8),\
((PIXG16(p) * (lv)) >> 8),\
((PIXB16(p) * (lv)) >> 8))
#define RGB_ALPHALEVEL16(p, lv) PIX16(((RGB_PIXR16(p) * (lv)) >> 8),\
((RGB_PIXG16(p) * (lv)) >> 8),\
((RGB_PIXB16(p) * (lv)) >> 8))
((PIXG16(p) * (lv)) >> 8),\
((PIXB16(p) * (lv)) >> 8))
#define WHITELEVEL16(p, lv) ALPHABLEND16(0xffff,p,lv)
@@ -353,7 +269,6 @@ extern void ags_autorepeat(boolean bool);
#define WHITELEVEL24(p, lv) ALPHABLEND24(0xffffffff, p, lv)
#define SUTURADD15(pa, pb) PIX15(min(255,PIXR15(pa)+PIXR15(pb)), min(255, PIXG15(pa)+PIXG15(pb)), min(255, PIXB15(pa)+PIXB15(pb)));
#define SUTURADD16(pa, pb) PIX16(min(255,PIXR16(pa)+PIXR16(pb)), min(255, PIXG16(pa)+PIXG16(pb)), min(255, PIXB16(pa)+PIXB16(pb)));
//#define SUTURADD16(pa, pb) PIX16(min(255,(int)(PIXR16(pa))+(int)(PIXR16(pb))), min(255, (int)(PIXG16(pa))+(int)(PIXG16(pb))), min(255, (int)(PIXB16(pa))+(int)(PIXB16(pb))));
#define SUTURADD24(pa, pb) PIX24(min(255,PIXR24(pa)+PIXR24(pb)), min(255, PIXG24(pa)+PIXG24(pb)), min(255, PIXB24(pa)+PIXB24(pb)));
+7 -8
View File
@@ -26,6 +26,9 @@
#include "dri.h"
#include "cache.h"
#include "ald_manager.h"
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
/* drifiles object */
static drifiles *dri[DRIFILETYPEMAX];
@@ -53,6 +56,7 @@ static void ald_free(dridata *dfile) {
* no : file no ( >= 0 )
* return: loaded dridata object
*/
EMSCRIPTEN_KEEPALIVE
dridata *ald_getdata(DRIFILETYPE type, int no) {
dridata *ddata;
@@ -86,6 +90,7 @@ dridata *ald_getdata(DRIFILETYPE type, int no) {
* free dri object
* data: object to be free
*/
EMSCRIPTEN_KEEPALIVE
void ald_freedata(dridata *data) {
if (data == NULL) return;
@@ -96,16 +101,10 @@ void ald_freedata(dridata *data) {
}
}
/*
* Initilize ald manager
* type: data type
* file: file name array
* cnt : number in file name array
*/
void ald_init(int type, const char **file, int cnt) {
void ald_init(int type, const char **file, int cnt, boolean use_mmap) {
if (type >= DRIFILETYPEMAX || cnt <= 0)
return;
dri[type] = dri_init(file, cnt);
dri[type] = dri_init(file, cnt, use_mmap);
if (!dri[type]->mmapped) {
cacheid = cache_new(ald_free);
}
+1 -1
View File
@@ -38,7 +38,7 @@ typedef enum {
DRIFILE_BGM =6 /* stream music data */
} DRIFILETYPE;
extern void ald_init(int type, const char **file, int cnt);
extern void ald_init(int type, const char **file, int cnt, boolean use_mmap);
extern dridata *ald_getdata(DRIFILETYPE type, int no);
extern void ald_freedata(dridata *data);
-80
View File
@@ -1,80 +0,0 @@
/*
* antialiase.c make antialiased pattern
*
* Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
* 1998- <masaki-c@is.aist-nara.ac.jp>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/* $Id: antialiase.c,v 1.3 2001/03/19 12:18:39 chikama Exp $ */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "portab.h"
static void memadd(BYTE *s, BYTE *d, int w, int h) {
int x, y;
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
*d += *s;
*(d+1) += *s;
*(d+2) += *s;
*(d+w+2) += *s;
*(d+w+1+2) += (*s * 16);
*(d+w+1+2) += *s;
*(d+w+w+4) += *s;
*(d+w+w+1+4) += *s;
*(d+w+w+2+4) += *s;
d++; s++;
}
d+=2;
}
}
static void memmul(BYTE *s, int mul, int pixel) {
while(pixel--) {
*s = min(255, (*s) * mul); s++;
}
}
void aa_make(BYTE *data, int w, int h, int bytes_per_line) {
int y;
BYTE *b, *_b, *__b;
BYTE *d = data;
b = calloc(w*h, sizeof(BYTE));
_b = calloc((w+2)*(h+2), sizeof(BYTE));
__b = b;
for (y = 0; y < h; y++) {
memcpy(__b, d, w);
__b+=w; d+=bytes_per_line;
}
memadd(b, _b, w, h);
memmul(_b, 16, (w+2)*(h+2));
d = data;
__b = _b;
for (y = 0; y < h+2; y++) {
memcpy(d, __b, w+2);
__b += (w+2); d+=bytes_per_line;
}
free(b);
free(_b);
}
-31
View File
@@ -1,31 +0,0 @@
/*
* antialiase.h make antialiased pattern
*
* Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
* 1998- <masaki-c@is.aist-nara.ac.jp>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/* $Id: antialiase.h,v 1.2 2000/09/10 10:39:46 chikama Exp $ */
#ifndef __ANTIALIASE__
#define __ANTIALIASE__
#include "portab.h"
extern void aa_make(BYTE *b, int w, int h, int bytes_per_line);
#endif /* !__ANTIALIASE__ */
+84
View File
@@ -0,0 +1,84 @@
/*
* bgi.c: BGI (BGM information) parser
*
* Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
* 1998- <masaki-c@is.aist-nara.ac.jp>
* 2021 kichikuou <KichikuouChrome@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "config.h"
#include <stdio.h>
#include "portab.h"
#include "system.h"
#include "bgi.h"
#define BGI_MAX 100
static int bgi_nfile;
static bgi_t bgi_data[BGI_MAX];
static char *bgi_gets(char *buf, int n, FILE *fp) {
char *s = buf;
int c;
while (--n > 0 && (c = fgetc(fp)) != EOF) {
c = c >> 4 | (c & 0xf) << 4; // decrypt
*s++ = c;
if (c == '\n')
break;
}
if (s == buf && c == EOF)
return NULL;
*s = '\0';
return buf;
}
int bgi_read(const char *path) {
if (!path)
return NG;
FILE *fp = fopen(path, "rb");
if (!fp) {
WARNING("Could not open %s\n", path);
return NG;
}
char buf[100];
while (bgi_nfile < BGI_MAX && bgi_gets(buf, sizeof(buf), fp)) {
int terminator;
if (sscanf(buf, " %d, %d, %d, %d, %d",
&bgi_data[bgi_nfile].no,
&bgi_data[bgi_nfile].loopno,
&bgi_data[bgi_nfile].looptop,
&bgi_data[bgi_nfile].len,
&terminator) != 5
|| terminator != -1) {
continue;
}
bgi_nfile++;
}
return OK;
}
bgi_t *bgi_find(int no) {
for (int i = 0; i < bgi_nfile; i++) {
if (bgi_data[i].no == no)
return &bgi_data[i];
}
return NULL;
}
+13 -12
View File
@@ -1,8 +1,9 @@
/*
* graphicdevice.h graphicデバイスのinclude
* bgi.c: BGI (BGM information) parser
*
* Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
* 1998- <masaki-c@is.aist-nara.ac.jp>
* 2021 kichikuou <KichikuouChrome@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,17 +20,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/* $Id: graphicsdevice.h,v 1.6 2006/04/21 16:40:48 chikama Exp $ */
#ifndef _BGI_H__
#define _BGI_H__
#ifndef __GRAPHICDEVICE__
#define __GRAPHICDEVICE__
typedef struct {
int no; // シナリオ上での曲番号
int loopno; // ループ回数 (0の場合は無限)
int looptop; // ループ時先頭戻り位置 (サンプル数)
int len; // 曲長さ (サンプル数)
} bgi_t;
#include "config.h"
extern int bgi_read(const char *path);
extern bgi_t *bgi_find(int no);
#if ENABLE_SDL
#include "sdl_core.h"
#else
#include "xcore.h"
#endif
#endif /* !__GRAPHICDEVICE__ */
#endif /* _BGI_H__ */
+85
View File
@@ -0,0 +1,85 @@
/*
* bgm.emscripten.c BGM (*BA.ALD) emscripten implementation
*
* Copyright (C) 2021 <KichikuouChrome@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <emscripten.h>
#include "portab.h"
#include "nact.h"
#include "bgm.h"
#include "bgi.h"
#include "sdl_core.h"
int musbgm_init() {
return bgi_read(nact->files.bgi);
}
int musbgm_exit() {
musbgm_stopall(0);
return OK;
}
EM_JS(int, musbgm_play, (int no, int time, int vol), {
xsystem35.cdPlayer.fade(time * 10, vol / 100);
xsystem35.cdPlayer.play(no, 1);
return xsystem35.Status.OK;
});
EM_JS(int, musbgm_stop, (int no, int time), {
xsystem35.cdPlayer.stop(time * 10);
return xsystem35.Status.OK;
});
EM_JS(int, musbgm_fade, (int no, int time, int vol), {
xsystem35.cdPlayer.fade(time * 10, vol / 100);
return xsystem35.Status.OK;
});
int musbgm_getpos(int no) {
int t = EM_ASM_INT_V( return xsystem35.cdPlayer.getPosition(); );
if (!t || (t & 0xff) != no)
return NG;
return (t >> 8) * 100 / 75; // frame -> 10ms
}
int musbgm_getlen(int no) {
bgi_t *bgi = bgi_find(no);
if (!bgi) return 0;
// FIXME: This assumes 44.1kHz
return bgi->len / 441;
}
int musbgm_isplaying(int no) {
int t = EM_ASM_INT_V( return xsystem35.cdPlayer.getPosition(); );
return ((t & 0xff) == no);
}
int musbgm_stopall(int time) {
return musbgm_stop(0, time);
}
int musbgm_wait(int no, int timeout) {
for (int i = 0; i * 16 < timeout * 10; i++) {
if (!musbgm_isplaying(no))
break;
sdl_wait_vsync();
}
return OK;
}
+2 -66
View File
@@ -22,7 +22,6 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
@@ -33,76 +32,15 @@
#include "system.h"
#include "nact.h"
#include "bgm.h"
#include "bgi.h"
#include "music_private.h"
#include "ald_manager.h"
#define BGI_MAX 100
typedef struct {
int no; // シナリオ上での曲番号
int loopno; // ループ回数 (0の場合は無限)
int looptop; // ループ時先頭戻り位置 (サンプル数)
int len; // 曲長さ (サンプル数)
} bgi_t;
static int bgi_nfile;
static bgi_t bgi_data[BGI_MAX];
static int current_no;
static Mix_Music *mix_music;
static dridata* dfile;
static Uint32 start_time;
static char *bgi_gets(char *buf, int n, FILE *fp) {
char *s = buf;
int c;
while (--n > 0 && (c = fgetc(fp)) != EOF) {
c = c >> 4 | (c & 0xf) << 4; // decrypt
*s++ = c;
if (c == '\n')
break;
}
if (s == buf && c == EOF)
return NULL;
*s = '\0';
return buf;
}
static void bgi_read() {
if (nact->files.bgi == NULL)
return;
FILE *fp = fopen(nact->files.bgi, "rb");
if (!fp) {
WARNING("Could not open %s\n", nact->files.bgi);
return;
}
char buf[100];
while (bgi_nfile < BGI_MAX && bgi_gets(buf, sizeof(buf), fp)) {
int terminator;
if (sscanf(buf, " %d, %d, %d, %d, %d",
&bgi_data[bgi_nfile].no,
&bgi_data[bgi_nfile].loopno,
&bgi_data[bgi_nfile].looptop,
&bgi_data[bgi_nfile].len,
&terminator) != 5
|| terminator != -1) {
continue;
}
bgi_nfile++;
}
return;
}
static bgi_t *bgi_find(int no) {
for (int i = 0; i < bgi_nfile; i++) {
if (bgi_data[i].no == no)
return &bgi_data[i];
}
return NULL;
}
static void free_music() {
current_no = 0;
if (mix_music) {
@@ -138,9 +76,7 @@ static Mix_Music *bgm_load(int no) {
}
int musbgm_init() {
bgi_read();
if (!bgi_nfile) return NG;
return OK;
return bgi_read(nact->files.bgi);
}
int musbgm_exit() {
+1 -1
View File
@@ -213,7 +213,7 @@ static int cdrom_start(int trk, int loop) {
return OK;
} else {
ti.cdti_trk0 = ti.cdti_trk1 = trk;
ti.cdti_ind0 = ti.cdti_ind0 = 0;
ti.cdti_ind0 = ti.cdti_ind1 = 0;
if (do_ioctl(CDROMPLAYTRKIND, &ti) < 0) {
perror("CDROMPLAYTRKIND");
return NG;
+3 -3
View File
@@ -517,13 +517,13 @@ void cg_get_info(int no, MyRectangle *info) {
MyPoint p;
if (cg == NULL) {
info->x = info->y = info->width = info->height = 0;
info->x = info->y = info->w = info->h = 0;
} else {
p = set_display_loc(cg);
info->x = p.x;
info->y = p.y;
info->width = cg->width;
info->height = cg->height;
info->w = cg->width;
info->h = cg->height;
}
}
+101 -82
View File
@@ -27,15 +27,18 @@
#include <unistd.h>
#include "portab.h"
#include "xsystem35.h"
#include "scenario.h"
#include "savedata.h"
#include "menu.h"
#include "input.h"
#include "msgskip.h"
#include "selection.h"
#include "message.h"
#include "music.h"
#include "utfsjis.h"
#include "hankaku.h"
#include "ags.h"
#include "graphicsdevice.h"
#include "sdl_core.h"
#include "ald_manager.h"
#include "LittleEndian.h"
#include "gametitle.h"
@@ -237,7 +240,7 @@ void commands2F11() {
}
void commands2F12() {
char *sText = sys_getString(0);
const char *sText = sl_getString(0);
DEBUG_COMMAND("trace %s:\n", sText);
@@ -357,7 +360,7 @@ void commands2F20() {
}
void commands2F21() {
char *str = sys_getString(0);
const char *str = sl_getString(0);
sys_addMsg(str);
}
@@ -365,7 +368,7 @@ void commands2F21() {
void commands2F23() {
int x = getCaliValue();
int y = getCaliValue();
char *vFileName = sys_getString(0);
const char *vFileName = sl_getString(0);
char *fname_utf8 = toUTF8(vFileName);
sysVar[0] = cg_load_with_filename(fname_utf8, x, y);
@@ -375,8 +378,8 @@ void commands2F23() {
}
void commands2F24() {
int type = sys_getc();
char *file_name = sys_getString(0);
int type = sl_getc();
const char *file_name = sl_getString(0);
int *var = NULL, _var = 0;
int num = 0;
@@ -400,8 +403,8 @@ void commands2F24() {
void commands2F25() {
int file_name = getCaliValue();
char *title = sys_getString(0);
char *filter = sys_getString(0);
const char *title = sl_getString(0);
const char *filter = sl_getString(0);
DEBUG_COMMAND_YET("LXG %d, %s, %s:\n", file_name, title, filter);
}
@@ -409,7 +412,7 @@ void commands2F25() {
void commands2F26() {
int dst_no = getCaliValue();
int max_len = getCaliValue();
char *title = sys_getString(0);
const char *title = sl_getString(0);
char *t1, *t2, *t3;
t1 = toUTF8(title);
@@ -439,7 +442,7 @@ void commands2F26() {
void commands2F27() {
int num = getCaliValue();
char *string = sys_getString(0);
const char *string = sl_getString(0);
if (num > 0) {
svar_set(num, string);
@@ -451,7 +454,7 @@ void commands2F27() {
}
void commands2F28() {
char *title = sys_getString(0);
const char *title = sl_getString(0);
if (nact->game_title_utf8)
free(nact->game_title_utf8);
@@ -470,7 +473,7 @@ void commands2F28() {
/* defined in cmdn.c */
extern INPUTNUM_PARAM ni_param;
void commands2F29() {
char *title = sys_getString(0);
const char *title = sl_getString(0);
char *t;
if (ni_param.title != NULL) {
@@ -483,8 +486,8 @@ void commands2F29() {
}
void commands2F2A() {
int type = sys_getc();
char *file_name = sys_getString(0);
int type = sl_getc();
const char *file_name = sl_getString(0);
int *var, _var = 0, cnt;
char *fname_utf8 = toUTF8(file_name);
@@ -500,6 +503,8 @@ void commands2F2A() {
sysVar[0] = save_save_str_with_file(fname_utf8, _var, cnt);
break;
default:
_var = getCaliValue();
cnt = getCaliValue();
WARNING("Unknown QE command\n");
break;
}
@@ -509,9 +514,9 @@ void commands2F2A() {
}
void commands2F2B() {
int type = sys_getc();
char *work_dir = sys_getString(0);
char *file_name = sys_getString(0);
int type = sl_getc();
const char *work_dir = sl_getString(0);
const char *file_name = sl_getString(0);
DEBUG_COMMAND_YET("UP(new) %d, %s, %s:\n", type, work_dir, file_name);
}
@@ -555,16 +560,16 @@ void commands2F30() {
}
void commands2F31() {
int fPage = sys_getw();
int fIndex = sys_getaddress();
int fPage = sl_getw();
int fIndex = sl_getaddr();
sel_setCallback(1, fPage, fIndex);
DEBUG_COMMAND("menuSetCbkSelect page=%d, index=%x:\n", fPage, fIndex);
}
void commands2F32() {
int fPage = sys_getw();
int fIndex = sys_getaddress();
int fPage = sl_getw();
int fIndex = sl_getaddr();
sel_setCallback(2, fPage, fIndex);
DEBUG_COMMAND("menuSetCbkCancel page=%d, index=%x:\n", fPage, fIndex);
@@ -750,8 +755,8 @@ void commands2F44() {
}
void commands2F45() {
int fPage = sys_getw();
int fIndex = sys_getaddress();
int fPage = sl_getw();
int fIndex = sl_getaddr();
cb_sel_init_page = fPage;
cb_sel_init_address = fIndex;
@@ -773,14 +778,14 @@ void commands2F47() {
}
void commands2F48() {
char *sText = sys_getString(0);
const char *sText = sl_getString(0);
DEBUG_COMMAND_YET("sysOpenShell %s:\n", sText);
}
void commands2F49() {
char *sTitle = sys_getString(0);
char *sUrl = sys_getString(0);
const char *sTitle = sl_getString(0);
const char *sUrl = sl_getString(0);
DEBUG_COMMAND_YET("sysAddWebMenu %s, %s:\n", sTitle, sUrl);
}
@@ -807,13 +812,10 @@ void commands2F4C() {
int eWidth = getCaliValue();
int eHeight = getCaliValue();
MyRectangle r;
MyPoint p;
r.x = eSrcX; r.y = eSrcY; r.width = eWidth; r.height = eHeight;
p.x = eX, p.y = eY;
MyRectangle r = {eSrcX, eSrcY, eWidth, eHeight};
MyPoint p = {eX, eY};
UpdateArea(&r, &p);
sdl_updateArea(&r, &p);
DEBUG_COMMAND("grBlt %d, %d, %d, %d, %d, %d:\n",
eX, eY, eSrcX, eSrcY, eWidth, eHeight);
@@ -821,7 +823,7 @@ void commands2F4C() {
void commands2F4D() {
int eNum = getCaliValue();
char *sText = sys_getString(0);
const char *sText = sl_getString(0);
DEBUG_COMMAND_YET("LXWT %d, %s:\n", eNum, sText);
}
@@ -842,7 +844,7 @@ void commands2F4F() {
void commands2F50() {
int eFile = getCaliValue();
int nFlg = sys_getc();
int nFlg = sl_getc();
int eNum = getCaliValue();
DEBUG_COMMAND_YET("LXWH %d, %d, %d:\n", eFile, nFlg, eNum);
@@ -850,7 +852,7 @@ void commands2F50() {
void commands2F51() {
int eFile = getCaliValue();
int nFlg = sys_getc();
int nFlg = sl_getc();
int eNum = getCaliValue();
DEBUG_COMMAND_YET("LXWHH %d, %d, %d:\n", eFile, nFlg, eNum);
@@ -907,14 +909,14 @@ void commands2F55() {
void commands2F56() {
int file_name = getCaliValue();
char *title = sys_getString(0);
char *folder = sys_getString(0);
const char *title = sl_getString(0);
const char *folder = sl_getString(0);
DEBUG_COMMAND_YET("LXF %d, %s, %s:\n", file_name, title, folder);
}
void commands2F57() {
char *sTitle = sys_getString(0);
const char *sTitle = sl_getString(0);
int eStrVar = getCaliValue();
int eLength = getCaliValue();
int *vResult = getCaliVariable();
@@ -962,7 +964,7 @@ void commands2F59() {
}
void commands2F5A() {
char *sText = sys_getString(0);
const char *sText = sl_getString(0);
char *t1;
t1 = toUTF8(sText);
@@ -1121,8 +1123,8 @@ void commands2F65() {
void commands2F66() {
int eNum = getCaliValue();
int page = sys_getw();
int index = sys_getdw();
int page = sl_getw();
int index = sl_getdw();
DEBUG_COMMAND("fncSetTable %d, %d,%d:\n", eNum, page, index);
@@ -1245,8 +1247,10 @@ void commands2F70() {
void commands2F71() {
int eFlag = getCaliValue();
DEBUG_COMMAND_YET("wmenuEnableMsgSkip %d:\n", eFlag);
msgskip_enableMenu(eFlag);
DEBUG_COMMAND("wmenuEnableMsgSkip %d:\n", eFlag);
}
void commands2F72() {
@@ -1264,7 +1268,7 @@ void commands2F73() {
}
void commands2F74() {
char *str1 = sys_getString(0);
const char *str1 = sl_getString(0);
int *var = getCaliVariable();
DEBUG_COMMAND_YET("dlgErrorOkCancel %s,%d:\n", str1, *var);
@@ -1323,41 +1327,56 @@ void commands2F7B() {
}
void commands2F7C() {
int index = sys_getdw();
if (!nact->files.ain) {
if (nact->files.gr_fname) {
SYSERROR("System39.ain is needed to run this game. Make sure you have an \"Ain\" line in %s.\n", nact->files.gr_fname);
} else {
SYSERROR("Ain file is needed to run this game. Make sure you have System39.ain file in the game directory.\n");
}
}
int index = sl_getdw();
if (index >= nact->ain.msgnum) {
WARNING("message id out of bounds (%d)\n", index);
return;
}
sys_addMsg(nact->ain.msg[index]);
msgskip_onAinMessage(index);
DEBUG_COMMAND("2F7C %d:\n", index);
}
void commands2F7D() {
int index = sys_getdw();
int index = sl_getdw();
commandH();
msgskip_onAinMessage(index);
DEBUG_COMMAND("2F7D %d:\n", index);
}
void commands2F7E() {
int index = sys_getdw();
int index = sl_getdw();
commandHH();
msgskip_onAinMessage(index);
DEBUG_COMMAND("2F7E %d:\n", index);
}
void commands2F7F() {
int index = sys_getdw();
int p1 = sys_getCaliValue();
int index = sl_getdw();
int p1 = getCaliValue();
sys_addMsg(svar_get(p1));
DEBUG_COMMAND("2F7F %d, %d(%s,%s):\n", index, p1, nact->ain.msg[index], svar_get(p1));
msgskip_onAinMessage(index);
DEBUG_COMMAND("2F7F %d, %d(%s):\n", index, p1, svar_get(p1));
}
void commands2F80() {
int page = sys_getw();
int index = sys_getdw();
int page = sl_getw();
int index = sl_getdw();
if (NULL == (nact->datatbl_addr = sl_setDataTable(page -1, index))) {
WARNING("dataSetPointer set failed\n");
@@ -1367,8 +1386,8 @@ void commands2F80() {
}
void commands2F81() {
int *vData = sys_getCaliVariable();
int eNumof = sys_getCaliValue();
int *vData = getCaliVariable();
int eNumof = getCaliValue();
int i;
WORD *p = (WORD *)nact->datatbl_addr;
@@ -1384,8 +1403,8 @@ void commands2F81() {
}
void commands2F82() {
int eStrNum = sys_getCaliValue();
int eNumof = sys_getCaliValue();
int eStrNum = getCaliValue();
int eNumof = getCaliValue();
int i;
char *p = (char *)nact->datatbl_addr;
@@ -1400,7 +1419,7 @@ void commands2F82() {
}
void commands2F83() {
int eNumof = sys_getCaliValue();
int eNumof = getCaliValue();
WORD *p = (WORD *)nact->datatbl_addr;
p += eNumof;
@@ -1411,7 +1430,7 @@ void commands2F83() {
}
void commands2F84() {
int eNumof = sys_getCaliValue();
int eNumof = getCaliValue();
int i;
char *p = (char *)nact->datatbl_addr;
@@ -1425,7 +1444,7 @@ void commands2F84() {
}
void commands2F85() {
int *vResult = sys_getCaliVariable();
int *vResult = getCaliVariable();
*vResult = SYSVAR_MAX;
@@ -1433,7 +1452,7 @@ void commands2F85() {
}
void commands2F86() {
int eFlag = sys_getCaliValue();
int eFlag = getCaliValue();
nact->patch_g0 = eFlag;
@@ -1441,10 +1460,10 @@ void commands2F86() {
}
void commands2F87() {
int eSubKeyStrNum = sys_getCaliValue();
int eBaneStrNum = sys_getCaliValue();
int eResultStrNum = sys_getCaliValue();
int *vResult = sys_getCaliVariable();
int eSubKeyStrNum = getCaliValue();
int eBaneStrNum = getCaliValue();
int eResultStrNum = getCaliValue();
int *vResult = getCaliVariable();
*vResult = 1;
@@ -1453,8 +1472,8 @@ void commands2F87() {
}
void commands2F88() {
int eFileNameStrNum = sys_getCaliValue();
int *vResult = sys_getCaliVariable();
int eFileNameStrNum = getCaliValue();
int *vResult = getCaliVariable();
*vResult = 1;
@@ -1462,27 +1481,27 @@ void commands2F88() {
}
void commands2F89() {
int eYear = sys_getCaliValue();
int eMonth = sys_getCaliValue();
int eData = sys_getCaliValue();
int *vResult = sys_getCaliVariable();
int eYear = getCaliValue();
int eMonth = getCaliValue();
int eData = getCaliValue();
int *vResult = getCaliVariable();
DEBUG_COMMAND_YET("timeCheckCurDate %d,%d,%d,%p:\n", eYear, eMonth, eData, vResult);
}
void commands2F8A() {
char *s2 = sys_getConstString();
char *s3 = sys_getConstString();
const char *s2 = sl_getConstString();
const char *s3 = sl_getConstString();
DEBUG_COMMAND_YET("dlgManualProtect %s,%s:\n", s2, s3);
}
void commands2F8B() {
char *s2 = sys_getConstString();
int c3 = sys_getCaliValue();
int c4 = sys_getCaliValue();
char *s6 = sys_getConstString();
int *c7 = sys_getCaliVariable();
const char *s2 = sl_getConstString();
int c3 = getCaliValue();
int c4 = getCaliValue();
const char *s6 = sl_getConstString();
int *c7 = getCaliVariable();
*c7 = 1;
+7 -5
View File
@@ -28,17 +28,20 @@
#include "nact.h"
#include "s39ain.h"
#include "xsystem35.h"
#include "scenario.h"
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
#define dll nact->ain.dll
typedef void *entrypoint (void);
EMSCRIPTEN_KEEPALIVE // Prevent inlining, because this function is listed in ASYNCIFY_ADD
void commands2F60() {
int type = sys_getdw(); /* DLL type */
int fnum = sys_getdw(); /* function number */
entrypoint *function = NULL;
int type = sl_getdw(); /* DLL type */
int fnum = sl_getdw(); /* function number */
#ifdef ENABLE_MODULES
if (dll == NULL) {
SYSERROR("No DLL initilized\n");
}
@@ -51,7 +54,6 @@ void commands2F60() {
dll[type].function[fnum].entrypoint();
return;
#endif
eexit:
SYSERROR("Can't continue further scenario.(%d,%d)(%s,%s)\n", type, fnum, dll[type].name, dll[type].function[fnum].name);
+52 -15
View File
@@ -26,6 +26,7 @@
#include "portab.h"
#include "cmd_check.h"
#include "debugger.h"
#include "scenario.h"
#include "xsystem35.h"
#include "selection.h"
@@ -84,8 +85,8 @@ static void letVar(int type) {
/* データテーブルの設定 */
static void getDataTableAdr() {
int index = sys_getaddress();
int offset = sys_getCaliValue();
int index = sl_getaddr();
int offset = getCaliValue();
if (offset) {
index = sl_getdAt(index + 4 * (offset - 1));
@@ -98,18 +99,18 @@ static void getDataTableAdr() {
/* < ループ開始 */
static void loopStart() {
int p1 = sys_getc();
int p1 = sl_getc();
int exitadr, limit, direction, step;
int *var;
if (p1 == 0) {
sys_getc();
sys_getc();
sl_getc();
sl_getc();
} else if (p1 != 1) {
undeferr();
}
exitadr = sys_getaddress();
exitadr = sl_getaddr();
var = getCaliVariable();
limit = getCaliValue();
direction = getCaliValue();
@@ -147,10 +148,46 @@ static void undeferr() {
SYSERROR("Undefined Command:@ %03d,%05x\n", sl_getPage(), sl_getIndex());
}
void check_command(int c0) {
static void message(int c0) {
char buf[512];
char *p = buf;
while (c0 == 0x20 || c0 >= 0x80) {
if (nact->encoding == UTF8) {
*p++ = (char)c0;
} else if (c0 == 0x20) {
*p++ = (char)c0;
} else if (c0 >= 0xe0) {
*p++ = (char)c0; *p++ = (char)sl_getc();
} else if (c0 >= 0xa0) {
*p++ = (char)c0;
} else {
*p++ = (char)c0; *p++ = (char)sl_getc();
}
c0 = sl_getc();
}
sl_ungetc();
if (p != buf) {
*p = '\0';
sys_addMsg(buf);
}
}
void exec_command(void) {
DEBUG_MESSAGE("%d:%x\n", sl_getPage(), sl_getIndex());
int page, index;
int bool;
int c0 = sl_getc();
if (c0 == BREAKPOINT)
c0 = dbg_handle_breakpoint(sl_getPage(), sl_getIndex() - 1);
if (c0 == 0x20 || c0 >= 0x80) {
message(c0);
return;
}
switch(c0) {
case 0:
/* メッセージのゴミ? */
@@ -177,7 +214,7 @@ void check_command(int c0) {
sel_fixElement();
nact->sel.in_setting = FALSE;
} else {
sel_addRetValue(sys_getaddress());
sel_addRetValue(sl_getaddr());
nact->sel.in_setting = TRUE;
}
break;
@@ -196,7 +233,7 @@ void check_command(int c0) {
break;
case '@':
/* puts("ラベルジャンプ") */
sl_jmpNear(sys_getaddress());
sl_jmpNear(sl_getaddr());
break;
case '<':
/* for loop */
@@ -204,7 +241,7 @@ void check_command(int c0) {
break;
case '>':
/* loop end */
sl_jmpNear(sys_getaddress());
sl_jmpNear(sl_getaddr());
break;
case '/':
/* 小文字コマンド */
@@ -1146,7 +1183,7 @@ void check_command(int c0) {
break;
case '\\':
/* label call */
index = sys_getaddress();
index = sl_getaddr();
if (index == 0) {
sl_retNear();
} else {
@@ -1160,14 +1197,14 @@ void check_command(int c0) {
case '{':
/* puts("条件文"); */
bool = getCaliValue();
index = sys_getaddress();
index = sl_getaddr();
if (bool == 0) {
sl_jmpNear(index);
}
break;
case '~':
/* label far call */
page = sys_getw();
page = sl_getw();
if (page == 0x0000) {
// puts("~ cali:");
nact->fnc_return_value = getCaliValue();
@@ -1176,7 +1213,7 @@ void check_command(int c0) {
// puts("~~ cali:");
*getCaliVariable() = nact->fnc_return_value;
} else {
sl_callFar2(page - 1, sys_getaddress());
sl_callFar2(page - 1, sl_getaddr());
}
break;
default:
+2 -1
View File
@@ -24,13 +24,14 @@
#include <stdio.h>
#include "portab.h"
#include "xsystem35.h"
#include "scenario.h"
#include "windowframe.h"
#include "selection.h"
#include "message.h"
#include "selection.h"
/* 選択肢Window情報 */
Bcom_WindowInfo selWinInfo[SELWINMAX] = {{ 464, 80, 160, 160, TRUE}, 0};
Bcom_WindowInfo selWinInfo[SELWINMAX] = {{ 464, 80, 160, 160, TRUE }};
/* 現在の選択肢Window番号 */
static int selWinNo;
/* 現在のMessageWindow番号 */
+5 -6
View File
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include "portab.h"
#include "xsystem35.h"
#include "scenario.h"
#include "ags.h"
void commandCC() {
@@ -185,7 +186,7 @@ void commandCD() {
}
void commandCK() {
int no = sys_getc();
int no = sl_getc();
int x = getCaliValue();
int y = getCaliValue();
int width = getCaliValue();
@@ -253,11 +254,9 @@ void commandCP() {
int y = getCaliValue();
int color = getCaliValue();
MyRectangle* rec = ags_imageFlood(x, y, color);
if (rec != NULL) {
ags_updateArea(rec->x, rec->y, rec->width, rec->height);
}
MyRectangle rec = ags_floodFill(x, y, color);
if (!SDL_RectEmpty(&rec))
ags_updateArea(rec.x, rec.y, rec.w, rec.h);
DEBUG_COMMAND("CP %d,%d,%d:\n", x, y, color);
}
+1
View File
@@ -25,6 +25,7 @@
#include <stdio.h>
#include "portab.h"
#include "xsystem35.h"
#include "scenario.h"
void commandDC() {
int page = getCaliValue();
+24 -22
View File
@@ -24,6 +24,7 @@
#include <stdio.h>
#include "portab.h"
#include "xsystem35.h"
#include "scenario.h"
#include "ags.h"
#include "graphics.h"
@@ -42,11 +43,11 @@ void commandES() {
int width = getCaliValue();
int height = getCaliValue();
tbl[num - 1].r.x = x;
tbl[num - 1].r.y = y;
tbl[num - 1].r.width = width;
tbl[num - 1].r.height = height;
tbl[num - 1].pal = pal;
tbl[num - 1].r.x = x;
tbl[num - 1].r.y = y;
tbl[num - 1].r.w = width;
tbl[num - 1].r.h = height;
tbl[num - 1].pal = pal;
DEBUG_COMMAND("ES %d,%d,%d,%d,%d,%d:\n", num, pal, x, y, width, height);
}
@@ -58,13 +59,13 @@ void commandEC() {
if (num == 0) {
r = &nact->sys_view_area;
ags_fillRectangle(r->x, r->y, r->width, r->height, 0);
ags_updateArea(r->x, r->y, r->width, r->height);
ags_fillRectangle(r->x, r->y, r->w, r->h, 0);
ags_updateArea(r->x, r->y, r->w, r->h);
} else {
int adj = (nact->patch_ec == 0) ? -1 : 0;
e = &tbl[num - 1];
ags_fillRectangle(e->r.x, e->r.y, e->r.width + adj, e->r.height + adj, e->pal);
ags_updateArea(e->r.x, e->r.y, e->r.width + adj, e->r.height + adj);
ags_fillRectangle(e->r.x, e->r.y, e->r.w + adj, e->r.h + adj, e->pal);
ags_updateArea(e->r.x, e->r.y, e->r.w + adj, e->r.h + adj);
}
DEBUG_COMMAND("EC %d:\n", num);
}
@@ -78,8 +79,8 @@ void commandEG() {
*x = tbl[num -1].r.x;
*y = tbl[num -1].r.y;
*width = tbl[num -1].r.width;
*height = tbl[num -1].r.height;
*width = tbl[num -1].r.w;
*height = tbl[num -1].r.h;
DEBUG_COMMAND("EG %d,%d,%d,%d,%d:\n", num, *x, *y, *width, *height);
}
@@ -89,13 +90,14 @@ void commandEM() {
int *var = getCaliVariable();
int x = getCaliValue();
int y = getCaliValue();
MyPoint p = {x, y};
MyRectangle r = tbl[num - 1].r;
if (nact->patch_emen == 0) {
r.width -= 1;
r.height -= 1;
r.w -= 1;
r.h -= 1;
}
*var = ags_regionContains(&r, x, y) ? 1 : 0;
*var = SDL_PointInRect(&p, &r) ? 1 : 0;
DEBUG_COMMAND("EM %d,%d,%d,%d:\n", num, *var, x, y);
}
@@ -105,18 +107,18 @@ void commandEN() {
int max = getCaliValue();
int x = getCaliValue();
int y = getCaliValue();
int i;
MyRectangle r;
MyPoint p = {x, y};
*var = 0;
for (i = min; i <= max; i++) {
r = tbl[i - 1].r;
for (int i = min; i <= max; i++) {
MyRectangle r = tbl[i - 1].r;
if (nact->patch_emen == 0) {
r.width -= 1;
r.height -= 1;
r.w -= 1;
r.h -= 1;
}
if (ags_regionContains(&r, x, y)) *var = i;
if (SDL_PointInRect(&p, &r))
*var = i;
}
DEBUG_COMMAND("EN %d,%d,%d,%d,%d:\n", *var, min, max, x, y);
+23 -23
View File
@@ -46,7 +46,7 @@ static void commandF11();
static int *F6Index[256];
void commandF() {
switch (sys_getc()) {
switch (sl_getc()) {
case 1:
commandF1(); break;
case 2:
@@ -75,8 +75,8 @@ void commandF() {
}
static void commandF1() {
int str_number = sys_getCaliValue();
int skip = sys_getCaliValue();
int str_number = getCaliValue();
int skip = getCaliValue();
int i;
char *p;
@@ -93,8 +93,8 @@ static void commandF1() {
}
static void commandF2() {
int *read_var = sys_getCaliVariable();
int skip = sys_getCaliValue();
int *read_var = getCaliVariable();
int skip = getCaliValue();
WORD *p = (WORD *)nact->datatbl_addr;
p += skip;
@@ -108,8 +108,8 @@ static void commandF2() {
}
static void commandF3() {
int *read_var = sys_getCaliVariable();
int skip = sys_getCaliValue();
int *read_var = getCaliVariable();
int skip = getCaliValue();
*read_var = LittleEndian_getW(nact->datatbl_addr, skip *2);
@@ -117,8 +117,8 @@ static void commandF3() {
}
static void commandF4() {
int *read_var = sys_getCaliVariable();
int count = sys_getCaliValue();
int *read_var = getCaliVariable();
int count = getCaliValue();
int i;
WORD *p = (WORD *)nact->datatbl_addr;
@@ -134,8 +134,8 @@ static void commandF4() {
}
static void commandF5() {
int *read_var = sys_getCaliVariable();
int count = sys_getCaliValue();
int *read_var = getCaliVariable();
int count = getCaliValue();
int i;
for (i = 0; i < count; i++) {
@@ -147,8 +147,8 @@ static void commandF5() {
}
static void commandF6() {
int *var = sys_getCaliVariable();
int index = sys_getCaliValue();
int *var = getCaliVariable();
int index = getCaliValue();
F6Index[index] = var;
@@ -156,8 +156,8 @@ static void commandF6() {
}
static void commandF7() {
int data_width = sys_getCaliValue();
int count = sys_getCaliValue();
int data_width = getCaliValue();
int count = getCaliValue();
int i, j;
WORD *p = (WORD *)nact->datatbl_addr;
@@ -174,25 +174,25 @@ static void commandF7() {
}
static void commandF8() {
int snum = sys_getCaliValue();
int scnt = sys_getCaliValue();
int snum = getCaliValue();
int scnt = getCaliValue();
DEBUG_COMMAND_YET("F8 %d,%d:\n", snum, scnt);
}
static void commandF9() {
int snum = sys_getCaliValue();
int scnt = sys_getCaliValue();
int snum = getCaliValue();
int scnt = getCaliValue();
DEBUG_COMMAND_YET("F9 %d,%d:\n", snum, scnt);
}
static void commandF10() {
int snum = sys_getCaliValue();
int scnt = sys_getCaliValue();
int snum = getCaliValue();
int scnt = getCaliValue();
DEBUG_COMMAND_YET("F10 %d,%d:\n", snum, scnt);
}
static void commandF11() {
int snum = sys_getCaliValue();
int ends = sys_getCaliValue();
int snum = getCaliValue();
int ends = getCaliValue();
DEBUG_COMMAND_YET("F11 %d,%d:\n", snum, ends);
}
+3 -2
View File
@@ -23,6 +23,7 @@
#include "portab.h"
#include "xsystem35.h"
#include "scenario.h"
#include "cg.h"
void commandG0() {
@@ -68,8 +69,8 @@ void commandGS() {
cg_get_info(num - 1, &r);
var[0] = r.x;
var[1] = r.y;
var[2] = r.width;
var[3] = r.height;
var[2] = r.w;
var[3] = r.h;
DEBUG_COMMAND("GS %d,%p:\n",num,var);
}
+3 -2
View File
@@ -26,11 +26,12 @@
#include <string.h>
#include "portab.h"
#include "xsystem35.h"
#include "scenario.h"
#include "utfsjis.h"
#include "hankaku.h"
void commandH() {
int fig = sys_getc();
int fig = sl_getc();
int num = getCaliValue();
char buf[512];
@@ -42,7 +43,7 @@ void commandH() {
}
void commandHH(void) {
int fig = sys_getc();
int fig = sl_getc();
int num = getCaliValue();
char buf[256];
+15 -13
View File
@@ -26,9 +26,11 @@
#include "config.h"
#include "portab.h"
#include "xsystem35.h"
#include "scenario.h"
#include "ags.h"
#include "graphicsdevice.h"
#include "sdl_core.h"
#include "input.h"
#include "msgskip.h"
#define REPEAT_RATE_FAST 60
#define REPEAT_RATE_SLOW 600
@@ -38,7 +40,7 @@ static int ik_key = 0;
void commandIK() {
/* キー入力関連のコマンド */
int num = sys_getc();
int num = sl_getc();
int key;
DEBUG_COMMAND("IK %d:\n",num);
@@ -52,11 +54,11 @@ void commandIK() {
sysVar[0] = 0;
key = sys_getInputInfo();
if (ik_key != key) repeating = 0;
if (get_skipMode()) break;
key = sys_keywait(INT_MAX, TRUE);
key = sys_keywait(INT_MAX, KEYWAIT_CANCELABLE | KEYWAIT_SKIPPABLE);
if (msgskip_isSkipping()) break;
if (repeating == 1) {
sys_keywait(REPEAT_RATE_SLOW, FALSE);
sys_keywait(REPEAT_RATE_SLOW, KEYWAIT_NONCANCELABLE);
}
repeating++;
sys_key_releasewait(key, TRUE);
@@ -66,11 +68,11 @@ void commandIK() {
sysVar[0] = 0;
key = sys_getInputInfo();
if (ik_key != key) repeating = 0;
if (get_skipMode()) break;
key = sys_keywait(INT_MAX, TRUE);
key = sys_keywait(INT_MAX, KEYWAIT_CANCELABLE | KEYWAIT_SKIPPABLE);
if (msgskip_isSkipping()) break;
if (repeating == 1) {
sys_keywait(REPEAT_RATE_FAST, FALSE);
sys_keywait(REPEAT_RATE_FAST, KEYWAIT_NONCANCELABLE);
}
repeating++;
sys_key_releasewait(key, TRUE);
@@ -133,7 +135,7 @@ void commandIX() {
/* 「次の選択肢まで進む」の状態取得 */
int *var = getCaliVariable();
*var = get_skipMode() == TRUE ? 1 : 0;
*var = msgskip_isSkipping() == TRUE ? 1 : 0;
DEBUG_COMMAND("IX %p:\n",var);
}
@@ -141,13 +143,13 @@ void commandIY() {
int p1 = getCaliValue();
if (p1 == 0) {
set_skipMode(FALSE);
msgskip_activate(FALSE);
} else if (p1 == 1) {
set_skipMode(TRUE);
msgskip_activate(TRUE);
} else if (p1 == 2) {
set_skipMode2(TRUE);
msgskip_setFlags(MSGSKIP_STOP_ON_MENU, MSGSKIP_STOP_ON_MENU);
} else if (p1 == 3) {
set_skipMode2(FALSE);
msgskip_setFlags(0, MSGSKIP_STOP_ON_MENU);
}
DEBUG_COMMAND("IY %d:\n",p1);

Some files were not shown because too many files have changed in this diff Show More