Compare commits

..
Author SHA1 Message Date
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
kichikuou 97b8bcb22a Fix argument for SDL_JoystickEventState 2020-10-01 16:46:20 +09:00
kichikuou 862f639e2e Fix ShString.FillString 2020-09-21 18:02:32 +09:00
kichikuou 316a06a168 Refactor string variable functions
This replaces v_str* functions with new svar_* functions.
The new svar_* functions use 1-based string variable index, so that
callers don't have to decrement string numbers from SCO.
2020-09-21 16:17:23 +09:00
kichikuou c9ec20dcc8 Remove no field of agsurface_t 2020-09-21 13:24:12 +09:00
kichikuou 023b8cd455 VSP: Do not use static extraction buffer
Now it's allocated on the stack. Up to 401*8 bytes, should be fine.
2020-09-21 12:01:20 +09:00
kichikuou 335681863c VSP: Appropriately scale 4-bit color to 8-bit
This fixes a bug where VSP image was displayed slightly darker than the
original.
2020-09-21 11:46:48 +09:00
kichikuou ecba592d82 TECH.TXT: Typo fixes and minor corrections 2020-09-21 11:03:13 +09:00
kichikuou dbac18c260 Globally replace "pallet" with "palette" 2020-09-19 22:25:10 +09:00
kichikuou ed8f610f80 Remove unused xpg_basename.c 2020-09-16 18:36:03 +09:00
kichikuou f753cf8670 SDL: Show quit confirmation dialog on SDL_QUIT 2020-09-12 18:59:32 +09:00
kichikuou c3cc4f3e44 menu_sdl.c: Implement menu_msgbox_open() 2020-09-12 18:27:51 +09:00
kichikuou e57913bfc6 Revive menu_null.c
It's used only if graphic backend is X11 and libgtk2 is not available.
2020-09-12 18:18:34 +09:00
kichikuou f941916fb2 CI: Install libgtk2.0-dev in X11 build 2020-09-12 16:56:41 +09:00
kichikuou f5248bda8a Merge sdl_mode.c to sdl_video.c 2020-09-10 15:42:27 +09:00
kichikuou 988a072964 Rename menu_null.c to menu_sdl.c 2020-09-10 15:25:02 +09:00
kichikuou 775b34cf1a SDL: Implement inline text input (for MJ command)
Very few games use it (Mamorigami-sama and Les Chairs Cruelles), but
this could be reused when we add a pure SDL implementation of input
dialogs.
2020-09-07 22:33:31 +09:00
kichikuou 5455bce8d6 Rename sdl_input.c to sdl_keytable.h
And move xsyskey.pl to tools/.
2020-09-06 13:58:09 +09:00
kichikuou 5e5defb6bc Android: Input dialog truncates string that exceeds maximum length 2020-09-06 10:35:35 +09:00
kichikuou 05cca544c6 Text input commands should accept half-width characters
Although its dialog message says "Half-width characters cannot be used",
System3.9 does not prevent users from entering half-width characters.
2020-09-05 22:40:23 +09:00
kichikuou 38758569bb Android: Implement input dialogs 2020-09-04 17:03:01 +09:00
kichikuou e417811a94 emscripten: Implement messagebox and number input dialog 2020-09-04 17:03:01 +09:00
kichikuou b509be2b64 Remove unused menu_widget_reinit() 2020-09-04 11:34:24 +09:00
kichikuou fa845a6439 MIDI: Keep track of current music number in music_midi.c 2020-08-30 17:21:03 +09:00
kichikuou b3cb185a35 Simplify cg_load
Before this, cg_load() skipped loading CG or loaded only palettes,
depending on the flags set by the PC command.

After this, it always loads a CG and populates the cache. Functions for
loading only palettes have been removed. Actually this may be good for
performance, because some games use `PC 0:` to prewarm the cache.
2020-08-30 15:39:42 +09:00
kichikuou 87413d54dc Fix SC command
This fixes a bug where SC command did not return 999/999/999/999 when
CD-DA is not available.
2020-08-30 13:55:20 +09:00
kichikuou 440fb93b08 Fix memory leak in sprite_update.c 2020-08-30 12:17:46 +09:00
kichikuou 6d1ef1ba6f Fix memory leak in cursor_load 2020-08-30 11:20:29 +09:00
kichikuou dd1f0fd230 Fix memory leak in ags_setWorldSize
SetWorldSize() replaces the DIB, so alpha buffer must be freed before
calling it.
2020-08-30 10:33:45 +09:00
kichikuou 15fb122148 Remove agsurface.has_{pixel,alpha} fields 2020-08-30 10:26:55 +09:00
kichikuou 91a6cf7e67 Fix out-of-bounds memory access in font_ttf_get_glyph
FT_GlyphSlot.bitmap_left can be negative.
2020-08-30 09:58:09 +09:00
kichikuou dc8025469a Fix memory leak in msg_openWindow 2020-08-29 22:36:59 +09:00
kichikuou 0bbace898d Fix memory leak in save_saveAll 2020-08-29 22:04:34 +09:00
kichikuou c4e5ef3c36 Fix usage message 2020-08-29 19:10:55 +09:00
kichikuou e039fb3193 Fix memory leak in qnt_extract 2020-08-29 18:47:21 +09:00
kichikuou e547c153fc emscripten: Call sys_getInputInfo() at least once per frame
This fixes Graymerca, which checks input only with IG command.
2020-08-29 12:38:01 +09:00
kichikuou fef74da3dd emscripten: Enable JPEG 2020-08-26 20:23:56 +09:00
kichikuou 7baab6b616 Android CI: Use the system's default JDK 2020-08-23 14:09:37 +09:00
kichikuou 54b219e435 Android: Update build instructions to use commandline-tools
Now it works with JDK 9+.
2020-08-23 13:23:21 +09:00
kichikuou a20363b901 Android: Upgrade build environment
- targetSdkVersion 28
- Android Gradle plugin 4.0.1
- Kotlin 1.3.72
- Gradle 6.1.1
2020-08-23 11:22:05 +09:00
kichikuou bc9fc924ed [experimental] Unicode mode
This adds "Unicode mode", in which scenarios can be written in any
language. xsys35c 1.2.0 and later can produce Unicode scenarios.

- nact->encoding represents the current scenario encoding. The initial
  value is SJIS, and ZU command changes it to UTF8.

- Use conversion macros that switch the behavior by the scenario
  encoding. For example, toUTF8() calls sjis2utf() if the scenario
  encoding is SJIS, and calls strdup() if it is UTF8.

- Fix various string processing functions to work with UTF8.
2020-08-09 21:24:56 +09:00
kichikuou d8fbf9a8b1 Cleanup 2020-08-09 13:41:26 +09:00
kichikuou 077e4d32e0 Fix emscripten build 2020-08-08 23:07:53 +09:00
kichikuou 652e4b9111 Simplify ags_drawStringToSurface() 2020-08-08 22:57:22 +09:00
kichikuou 3cecc58607 Narrow dependency on font.h
This removes font.h dependency from header files such as ags.h and
nact.h. After this, font.h must be explicitly included in order to use
font functions.
2020-08-08 22:52:47 +09:00
kichikuou f31742a503 Font functions only handle utf-8 strings
Conversion from Shift_JIS is done in ags.c.
2020-08-08 22:03:58 +09:00
kichikuou e830190537 Add ags_drawStringToSurface() 2020-08-08 21:28:01 +09:00
kichikuou 7d8458c86d Emscripten: Remove getMemory from EXTRA_EXPORTED_RUNTIME_METHODS 2020-08-08 14:29:44 +09:00
kichikuou dfc10a7f34 Update emscripten to 1.40.1 2020-08-08 10:35:23 +09:00
kichikuou a5684cffa4 Switch README.md to English, and add a link to the releases page 2020-08-06 19:28:15 +09:00
kichikuou cfa9dc3502 Make BGM setup easy
This changes the default value of cdrom_device to "playlist.txt" so that
users can prepare BGM simply by putting a file named "playlist.txt" in
the game directory.

Also, if the playlist file is not found but there is a "_inmm.ini" file
in the game directory, load it as a playlist (but unlike the normal
playlist format, the first line corresponds to track 2). This makes some
archived games work without any configuration.
2020-08-06 17:20:27 +09:00
kichikuou f978c43ee1 Move mmap-related code to mmap.{h,c}
And add Windows implementation.
2020-08-06 15:09:51 +09:00
kichikuou 7871bb9328 Fix DEBUG_COMMAND macro 2020-08-06 14:59:33 +09:00
kichikuou ab32b1792f Do not display message argument of System 3.9 H/HH/X commands
This matches the behavior of System39.exe.
2020-08-02 15:38:12 +09:00
kichikuou 98d0a13a20 Change the underlying type of boolean to C99 _Bool 2020-08-02 14:07:51 +09:00
kichikuou 5456ac4219 Remove unused ERROR constant 2020-08-02 13:46:44 +09:00
kichikuou f258ae42b1 Windows: Remember last selected game folder in registry 2020-08-02 13:41:34 +09:00
kichikuou 6a459260e4 Fix font filename in xsystem35.nsi 2020-08-02 13:41:34 +09:00
kichikuou 6580b864c0 Windows: Localize game-folder chooser dialog 2020-08-02 13:41:34 +09:00
kichikuou bfd8e3e55a Windows: Add app icon 2020-08-02 13:41:34 +09:00
kichikuou 05cacb170f Windows CI: Generate installer as build artifact 2020-08-01 23:23:51 +09:00
kichikuou d2c861ad53 Windows: Let the user select a game folder when launched without arguments 2020-08-01 21:43:20 +09:00
kichikuou 8a395a57e4 Windows: Load profile from registry
This allows xsystem35 to use the font paths written to the registry by
the installer.
2020-08-01 21:43:20 +09:00
kichikuou 6706348c11 Make DWORD definition not to conflict with windows.h 2020-08-01 21:43:20 +09:00
kichikuou c66714bab6 Add NSIS script for generating Windows installer 2020-08-01 21:43:15 +09:00
kichikuou 730b15dfca Refactor debug output macros 2020-07-25 22:01:21 +09:00
kichikuou ad6c84db4d Clean up xsys35rc.sample 2020-07-25 17:57:49 +09:00
kichikuou 9053583517 Do UTF-8 conversion for filenames in cmd*.c 2020-07-25 17:09:08 +09:00
kichikuou 07f8f8a5f8 initGameResourceFromDir: Stop prepending CWD to filenames 2020-07-25 14:48:41 +09:00
kichikuou 9f244c3dee Fix filecheck.c issues
- Use _wfopen on Windows, to avoid garbled filenames.
- The -savekanji option is removed. Now character encoding of file paths
  is assumed to be UTF-8 on non-windows.
- On all platforms, data files are also searched for in current
  directory.
2020-07-25 13:17:03 +09:00
kichikuou 2e895ed3ae Fix a compiler warning 2020-07-24 20:09:29 +09:00
kichikuou b5010df10d Add helper functions for number formatting
And use it from H, HH, MH, and MHH commands.
2020-07-24 17:06:30 +09:00
kichikuou fc5f89912e Fix zen2han
To match the behavior of "ZH 1" in System 3.9.
2020-07-24 16:30:03 +09:00
kichikuou 70ea305ca9 Refactor hankaku.c 2020-07-24 16:17:18 +09:00
kichikuou b4eb18c938 Add test for hankaku.c 2020-07-24 15:42:48 +09:00
kichikuou b9e0d97156 Fix utf2sjis() for KATAKANA MIDDLE DOT character 2020-07-24 14:53:59 +09:00
kichikuou 350d8bb367 Remove unused sys_getConvString() 2020-07-24 13:21:48 +09:00
kichikuou fb10cbc52d Add unittest.h with some assertion macros 2020-07-24 12:46:14 +09:00
kichikuou 55976a5816 Merge hankana2sjis.c into hankaku.c 2020-07-24 11:30:07 +09:00
kichikuou 827f98d24a Remove ttfont_{gothic,mincho}_code .xys35rc parameters
These are no longer effective as we have dropped SJIS charmap support.
This also removes the codeconv field from FONT struct.
2020-07-24 10:00:43 +09:00
kichikuou ce67aa7028 Eliminate SJIS string constants 2020-07-24 08:54:45 +09:00
kichikuou 50b3812364 Convert gametitle.h to utf-8 2020-07-23 22:50:43 +09:00
kichikuou 616534621e Fix ShString.ExchangeString
And add a test.
2020-07-23 18:08:58 +09:00
kichikuou 1f5ec7a9a9 Simplify string functions 2020-07-23 17:04:37 +09:00
kichikuou 06223ea727 Add more tests for string variables 2020-07-23 16:57:31 +09:00
kichikuou d15c770b4b Fix strGetCharType and strGetLengthASCII 2020-07-23 16:55:49 +09:00
kichikuou 60bb70c456 Fix strCheckASCII and strCheckSJIS
They were referencing wrong string variables.
2020-07-23 16:36:03 +09:00
kichikuou 52322345b5 Fix MG7 command
This fixes a regression bug introduced by 86470e5.
2020-07-23 16:31:35 +09:00
kichikuou 66693ad39a font_freetype2: Drop support for SJIS character map
Nowadays, it's safe to assume that fonts have a Unicode character map.
2020-07-23 15:01:46 +09:00
kichikuou 73fab9b628 Remove unused functions in utfsjis.c 2020-07-23 13:53:25 +09:00
kichikuou bdfe0e8077 Remove sjis2lang and lang2sjis macros
There's no plan to use any other "native" character encodings than
UTF-8.
2020-07-23 13:53:08 +09:00
kichikuou 03f8af2241 Simplify registerGameFiles() 2020-07-12 14:25:34 +09:00
kichikuou c03b6cf6b5 Embed GameResource in NACTINFO 2020-07-12 14:17:31 +09:00
kichikuou 1a3b779ace Use const strings for file names 2020-07-12 13:41:57 +09:00
kichikuou 4c58510a37 CMake: Introduce src_lib library
To avoid compiling test targets twice.
2020-07-12 13:01:31 +09:00
kichikuou b4c729a1f6 initGameResourceFromDir: Detect non-{ald,ain} files too
Now BGI, WAI and other files can be used without writing a .gr file.
2020-07-12 12:09:01 +09:00
kichikuou daf5098530 Add test for initGameResourceFromDir 2020-07-12 11:46:39 +09:00
kichikuou 4223284781 CI: Update GitHub Actions
- mymindstorm/setup-emsdk@v6
- actions/cache@v2
- actions/upload-artifact@v2
2020-07-12 11:27:45 +09:00
kichikuou 3d70d00bce Add unit test for gameresource.c 2020-07-11 19:12:45 +09:00
kichikuou f2fbf54c32 Move registerGameFiles to xsystem35.c 2020-07-11 18:34:27 +09:00
kichikuou b4d2c0832e Clean up gameresource.c 2020-07-11 18:34:24 +09:00
kichikuou d777b18b55 Game Resource: Allow file names containing spaces 2020-07-11 18:23:39 +09:00
kichikuou 7b3efd9aaa Move *.gr reader code to gameresource.c 2020-07-11 18:22:05 +09:00
kichikuou 90eb139994 Merge pull request #17 from nunuhara/missing_font_fix
Fix segfault when non-existent font specified
2020-07-11 16:15:13 +09:00
Nunuhara Cabbage aa87e3e8c0 Fix segfault when non-existent font specified 2020-07-10 23:43:46 -07:00
kichikuou 1cd949f597 CMake: Fix X11 + SDL_mixer build
Stop using SDL2_FOUND to determine if SDL2 should be used or not,
because it may be defined as a side effect of
pkg_check_modules(SDL2_mixer).
2020-06-27 15:05:56 +09:00
kichikuou 426cdaa836 Fix compatibility issues around maximum index of array variables
The second argument of DC command specifies the maximum index of the new
array. That means, `DC _,n,_:` allocates an array of size n+1 (a[0] to
a[n]).

This patch makes sure various D commands work with a[n], and a[n] is
correctly saved and loaded.

Now loadSysVar() does not shrink array variables using the data count in
the save file, so that files saved by old xsystem35 binary can be safely
loaded. This also matches the behavior of System3.9.
2020-06-27 13:16:22 +09:00
kichikuou 8db5a9cd65 Implement text decoration type 4 and 10 2020-06-21 11:10:19 +09:00
kichikuou 47f82e87c5 Add guards against incomplete SJIS bytes 2020-06-21 09:49:13 +09:00
kichikuou 86470e543a Rework string variables
- strVar is now allocated as a vector of indefinite length buffers
  rather than a single contiguous buffer.
- Strings can be any length, but truncated to (strvar_len * 2) bytes
  when saved to a file, for backward compatibility.
- Now string commands treat 1-byte characters in the same way as System
  3.9. This potentially fixes bugs in English translated games.
2020-06-20 22:29:22 +09:00
kichikuou a23ce19433 Add tests for string variables (M commands)
xsystem35 does not pass yet.
2020-06-20 13:00:32 +09:00
kichikuou 1cf197513c Use const strings in message related functions 2020-06-20 10:53:38 +09:00
kichikuou 64c3c28336 CI: Run SDL2 and X11 builds on Linux 2020-06-20 10:52:35 +09:00
kichikuou 7309ed012f Make DspDeviceSync no-op in SDL graphics 2020-06-18 21:49:51 +09:00
kichikuou 515a92544b getCaliValue: Recover from out-of-bounds index access
Before this, array access caused stack underflow if the index was out of
range. After this, such index access will be evaluated to zero.
2020-06-14 22:43:17 +09:00
kichikuou 725b0ee6ab Prevent buffer overrun by DF command 2020-06-14 22:09:14 +09:00
kichikuou e17b447e73 Cleanup variable lookup code
No behavior changes.
2020-06-14 21:54:11 +09:00
kichikuou 6dbd31cdbc Add tests for array access 2020-06-14 21:48:52 +09:00
kichikuou a217df39b1 Fix compiler warnings on Windows
On Windows, jpeglib.h includes windows.h which defines several macros
that conflict with ours.
2020-06-14 14:23:40 +09:00
kichikuou 80266d6454 Support JPEG image format
JPEG images are not used in AliceSoft games, but supported since System3.6
version 3.23 and used in some third-party games (e.g. Graymerca).
2020-06-14 14:16:19 +09:00
kichikuou 2e17188f2b Fix DI command and add tests 2020-06-13 15:46:45 +09:00
kichikuou 37f4d847e5 Fix Windows build 2020-06-07 21:29:53 +09:00
kichikuou 43c6688ce7 CI updates
- Add Windows build
- Run Debug and Release builds on Linux
- Run CI against pull requests
2020-06-07 15:16:39 +09:00
kichikuou 09e89e794d Android: Version 0.2.1 2020-06-07 14:31:31 +09:00
kichikuou 3fd7a58544 Android: Use filtered scaling
This improves text readability, especially for the Mincho font.
2020-06-07 12:55:16 +09:00
kichikuou f0ccdcf40a Android: Use arhive filename as alternate launcher item name
The title.txt file is written when the MT command is used, however some
games (Daiakuji, AmbivalenZ, Ikenai Katsumi sensei) does not use the MT
command. As a result, these titles did not appear in the launcher.

This makes the launcher use the name of the ZIP archive when the game
was installed as the alternate item name if the MT command was not used.
2020-06-07 12:23:19 +09:00
kichikuou 1a6b7b33b9 Android: Compile SDL_mixer with ogg support
This enables voice playback in Escalayer.
2020-06-06 23:00:39 +09:00
kichikuou 7240971beb Fix SACT.MessageIsEmpty
This fixes a bug where message wasn't flushed before changing text
attributes.
2020-06-06 18:27:20 +09:00
240 changed files with 4485 additions and 10969 deletions
+2 -7
View File
@@ -1,5 +1,5 @@
name: Android Build
on: [push]
on: [push, pull_request]
jobs:
build:
@@ -11,15 +11,10 @@ jobs:
- name: Install Deps
run: sudo apt install ninja-build
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build
run: |
cd android
./gradlew assembleRelease
ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk-bundle ./gradlew assembleRelease
- name: Upload artifacts
uses: actions/upload-artifact@v1
+5 -13
View File
@@ -1,8 +1,8 @@
name: Emscripten Build
on: [push]
on: [push, pull_request]
env:
emscripten-version: 1.39.16
emscripten-version: 1.40.1
jobs:
build:
@@ -11,25 +11,17 @@ jobs:
- uses: actions/checkout@v2
- name: Cache emsdk
uses: actions/cache@v1
id: cache
with:
path: emsdk-cache
key: ${{ runner.os }}-emsdk-${{ env.emscripten-version }}
- name: Cache .emscripten_cache
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: emscripten-cache
key: emscripten-cache-${{ env.emscripten-version }}
- name: Setup Emscripten toolchain
uses: mymindstorm/setup-emsdk@v3
uses: mymindstorm/setup-emsdk@v7
with:
version: ${{ env.emscripten-version }}
actions-cache-folder: emsdk-cache
no-cache: true
- name: Build
env:
@@ -45,7 +37,7 @@ jobs:
mv src/xsystem35.* xsystem35/
- name: Upload artifacts
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v2
with:
name: xsystem35-wasm
path: out/wasm/xsystem35
+11 -7
View File
@@ -1,25 +1,29 @@
name: Linux Build
on: [push]
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
build-type: ["Debug", "Release"]
name: Linux ${{ matrix.build-type }}
steps:
- uses: actions/checkout@v2
- name: Install Deps
run: |
sudo apt update
sudo apt install libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev
sudo apt install libgtk2.0-dev libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev
- name: Build
run: |
mkdir -p out/debug
cd out/debug
cmake -DCMAKE_BUILD_TYPE=Debug ../../
mkdir -p out/${{ matrix.build-type }}
cd out/${{ matrix.build-type }}
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} ../../
make
- name: Test
run: ctest
working-directory: out/debug
run: ctest --output-on-failure
working-directory: out/${{ matrix.build-type }}
+60
View File
@@ -0,0 +1,60 @@
name: Windows Build
on: [push, pull_request]
jobs:
build:
runs-on: windows-2019
strategy:
matrix:
mingw: ["MINGW32", "MINGW64"]
include:
- mingw: "MINGW32"
package: "mingw-w64-i686"
installer: "xsystem35-32bit"
- mingw: "MINGW64"
package: "mingw-w64-x86_64"
installer: "xsystem35-64bit"
defaults:
run:
shell: bash.exe --login -eo pipefail "{0}"
env:
MSYSTEM: ${{ matrix.mingw }}
CHERE_INVOKING: 1
name: MSYS2 ${{ matrix.mingw }}
steps:
- name: Set up shell
run: echo "C:\msys64\usr\bin\" >> $env:GITHUB_PATH
shell: pwsh
- name: Print system version
run: |
uname
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
- name: Checkout
uses: actions/checkout@v2
- name: Build
run: |
mkdir -p out/release
cd out/release
cmake -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release ../../
make
- name: Test
run: ctest --output-on-failure
working-directory: out/release
- name: Package
working-directory: 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
+14 -65
View File
@@ -36,16 +36,13 @@ 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()
@@ -58,25 +55,20 @@ else()
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)
set(ENABLE_GTK 1)
endif()
optional_find_package(Freetype)
include(FindPkgConfig)
if (NOT X11_FOUND)
optional_pkg_check_modules(SDL2 IMPORTED_TARGET sdl2)
endif()
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)
include(FindJPEG)
if (JPEG_FOUND)
set(HAVE_JPEG 1)
endif()
set(DEFAULT_FONT_PATH ${CMAKE_INSTALL_PREFIX}/share/xsystem35/fonts/)
endif()
@@ -86,6 +78,8 @@ endif()
if (EMSCRIPTEN)
set(SRC_MENU menu_emscripten.c)
elseif (ANDROID)
set(SRC_MENU menu_android.c)
elseif (GTK2_FOUND)
set(SRC_MENU menu.c menu_callback.c menu_gui.c s39init.c)
@@ -98,21 +92,8 @@ elseif (GTK2_FOUND)
include_directories(${Intl_INCLUDE_DIRS})
link_libraries(${Intl_LIBRARIES})
endif()
else()
set(SRC_MENU menu_null.c)
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_mode.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 ***")
else ()
set(SRC_MENU menu_sdl.c sdl_input.c)
endif()
# PCM audio
@@ -155,7 +136,7 @@ if (SDL2MIXER_FOUND AND NOT ANDROID)
list(APPEND SUMMARY_CDROM "SDL_mixer (wav|mp3|ogg...)")
set(ENABLE_CDROM_MP3 1)
endif()
set(CDROM_DEVICE "/dev/cdrom" CACHE STRING "CDROM Device Name")
set(CDROM_DEVICE "playlist.txt" CACHE STRING "CDROM Device Name")
# MIDI
@@ -197,40 +178,10 @@ endif()
if (EMSCRIPTEN OR ANDROID)
set(SRC_JOYSTICK joystick_dmy.c)
elseif (SDL2_FOUND)
else()
set(SRC_JOYSTICK joystick_sdl.c)
set(SUMMARY_JOYSTICK "SDL")
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 cp932tojis0213.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
@@ -246,11 +197,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("------------------")
+12 -14
View File
@@ -1,26 +1,24 @@
# xsytem35-sdl2
アリスソフトのゲームエンジン System3.x のフリー実装である xsystem35 を SDL2 に対応して、emscripten でコンパイルできるようにしたものです。
This is a multi-platform port of xsystem35, a free implementation of AriceSoft's System3.x game engine.
## ビルド方法
### Linux
## Download
Prebuilt binaries for Windows and Android can be downloaded from the [Releases](https://github.com/kichikuou/xsystem35-sdl2/releases) page.
[cmake](https://cmake.org/) が必要です。
## Build
### Linux (Debian / Ubuntu)
$ sudo apt install build-essential cmake libgtk2.0-dev libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev
$ mkdir -p out/debug
$ cd out/debug
$ cmake -DCMAKE_BUILD_TYPE=Debug ../../
$ make && make install
cmake の実行でエラーになる場合は必要なライブラリをインストールしてください。
グラフィックスシステムとして X11 と SDL2 が使用可能です。両方存在する場合は X11 が優先されますが、`cmake` のオプションに `-DENABLE_X11=NO` を指定すると SDL2 が使われます。
### MacOS
[Homebrew](https://brew.sh/index_ja) が必要です。
[Homebrew](https://brew.sh/index_ja) is needed.
$ brew install cmake pkg-config sdl2 sdl2_mixer freetype
$ brew install cmake pkg-config sdl2 sdl2_mixer sdl2_ttf libjpeg
$ mkdir -p out/debug
$ cd out/debug
$ cmake -DCMAKE_BUILD_TYPE=Debug ../../
@@ -28,9 +26,9 @@ cmake の実行でエラーになる場合は必要なライブラリをイン
### Windows
[MSYS2](https://www.msys2.org) が必要です。
[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
$ 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
$ mkdir -p out/debug
$ cd out/debug
$ cmake -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Debug ../../
@@ -43,8 +41,8 @@ cmake の実行でエラーになる場合は必要なライブラリをイン
$ emcmake cmake -DCMAKE_BUILD_TYPE=MinSizeRel ../../
$ make
実行するには、[鬼畜王 on Webのリポジトリ](https://github.com/kichikuou/web)をチェックアウトして、`docs`ディレクトリに `out/xsystem35.*` をすべてコピーしてください。
To use the generated binary, checkout [Kichikuou on Web](https://github.com/kichikuou/web) and copy `out/xsystem35.*` into its `docs` directory.
### Android
[android/README.md](android/) を参照してください。
See [android/README.md](android/).
+10 -11
View File
@@ -6,7 +6,7 @@ Prebuilt APKs are [here](https://github.com/kichikuou/xsystem35-sdl2/releases).
## Build
Prerequisites:
- CMake >=3.13
- Android SDK >=26
- Android SDK >=28
- Android NDK >=r15c
### Using Android Studio
@@ -15,20 +15,19 @@ Open this directory as an Android Studio project.
### Command line build
Configure environment variables and run the `gradlew` script in this folder.
Example build instructions (for Debian Stretch):
Example build instructions (for Debian buster):
```sh
# Install necessary packages
sudo apt install git wget unzip default-jdk-headless ninja-build
sudo apt -t stretch-backports install cmake
sudo apt install git wget unzip default-jdk-headless cmake ninja-build
# Install Android SDK / NDK
export ANDROID_HOME=$HOME/android-sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
unzip sdk-tools-linux-4333796.zip -d $ANDROID_HOME
yes |$ANDROID_HOME/tools/bin/sdkmanager --licenses
$ANDROID_HOME/tools/bin/sdkmanager ndk-bundle
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
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
# Check out and build xsystem35
git clone https://github.com/kichikuou/xsystem35-sdl2.git
+5 -5
View File
@@ -1,4 +1,4 @@
def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY');
def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY')
def buildAsApplication = !buildAsLibrary
if (buildAsApplication) {
apply plugin: 'com.android.application'
@@ -9,15 +9,15 @@ else {
apply plugin: 'kotlin-android'
android {
compileSdkVersion 26
compileSdkVersion 28
defaultConfig {
if (buildAsApplication) {
applicationId "io.github.kichikuou.xsystem35"
}
minSdkVersion 19
targetSdkVersion 26
versionCode 3
versionName "0.2.0"
targetSdkVersion 28
versionCode 5
versionName "0.2.3"
externalNativeBuild {
cmake {
arguments "-DANDROID_APP_PLATFORM=android-16", "-DANDROID_STL=c++_static"
+1
View File
@@ -40,6 +40,7 @@ endif()
FetchContent_GetProperties(SDL_mixer)
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
@@ -17,9 +17,13 @@
*/
package io.github.kichikuou.xsystem35
import android.app.AlertDialog
import android.media.MediaPlayer
import android.os.Bundle
import android.text.InputType
import android.util.Log
import android.widget.EditText
import android.widget.NumberPicker
import org.libsdl.app.SDLActivity
import java.io.File
import java.io.IOException
@@ -29,6 +33,7 @@ import java.io.IOException
class GameActivity : SDLActivity() {
companion object {
const val EXTRA_GAME_ROOT = "GAME_ROOT"
const val EXTRA_ARCHIVE_NAME = "ARCHIVE_NAME"
}
private lateinit var gameRoot: File
@@ -63,20 +68,92 @@ class GameActivity : SDLActivity() {
override fun setTitle(title: CharSequence?) {
super.setTitle(title)
val str = title?.toString()?.substringAfter(':', "")
if (str.isNullOrEmpty())
return
var str = title?.toString()?.substringAfter(':', "")
if (str.isNullOrEmpty()) {
str = intent.getStringExtra(EXTRA_ARCHIVE_NAME)
if (str == null)
return
}
File(gameRoot, Launcher.TITLE_FILE).writeText(str)
Launcher.updateGameList()
}
// These functions are called in the SDL thread by JNI.
private fun textInputDialog(msg: String, oldVal: String, maxLen: Int, result: Array<String?>) {
val input = EditText(this)
input.inputType = InputType.TYPE_CLASS_TEXT
input.setText(oldVal)
AlertDialog.Builder(this)
.setMessage(msg)
.setView(input)
.setPositiveButton(R.string.ok) {_, _ ->
val s = input.text.toString()
result[0] = if (s.length <= maxLen) s else s.substring(0, maxLen)
}
.setNegativeButton(R.string.cancel) {_, _ -> }
.setOnDismissListener {
synchronized(result) {
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") (result as Object).notify()
}
}
.show()
}
private fun numberInputDialog(msg: String, min: Int, max: Int, initial: Int, result: IntArray) {
val input = NumberPicker(this)
input.minValue = min
input.maxValue = max
input.value = initial
AlertDialog.Builder(this)
.setMessage(msg)
.setView(input)
.setPositiveButton(R.string.ok) {_, _ ->
input.clearFocus()
result[0] = input.value
}
.setNegativeButton(R.string.cancel) {_, _ -> }
.setOnDismissListener {
synchronized(result) {
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") (result as Object).notify()
}
}
.show()
}
// The functions below are called in the SDL thread by JNI.
@Suppress("unused") fun cddaStart(track: Int, loop: Boolean) = cdda.start(track, loop)
@Suppress("unused") fun cddaStop() = cdda.stop()
@Suppress("unused") fun cddaCurrentPosition() = cdda.currentPosition()
@Suppress("unused") fun midiStart(path: String, loop: Boolean) = midi.start(path, loop)
@Suppress("unused") fun midiStop() = midi.stop()
@Suppress("unused") fun midiCurrentPosition() = midi.currentPosition()
@Suppress("unused") fun inputString(msg: String, oldVal: String, maxLen: Int): String? {
val result = arrayOfNulls<String?>(1)
runOnUiThread { textInputDialog(msg, oldVal, maxLen, result) }
// Block the calling thread.
synchronized(result) {
try {
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") (result as Object).wait()
} catch (ex: InterruptedException) {
ex.printStackTrace()
}
}
return result[0]
}
@Suppress("unused") fun inputNumber(msg: String, min: Int, max: Int, initial: Int): Int {
val result = intArrayOf(-1)
runOnUiThread { numberInputDialog(msg, min, max, initial, result) }
// Block the calling thread.
synchronized(result) {
try {
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") (result as Object).wait()
} catch (ex: InterruptedException) {
ex.printStackTrace()
}
}
return result[0]
}
}
private class CddaPlayer(private val playlistPath: File) {
@@ -35,7 +35,7 @@ private var gLauncher: Launcher? = null
interface LauncherObserver {
fun onGameListChange()
fun onInstallProgress(path: String)
fun onInstallSuccess(path: File)
fun onInstallSuccess(path: File, archiveName: String?)
fun onInstallFailure(msgId: Int)
}
@@ -73,7 +73,7 @@ class Launcher private constructor(private val rootDir: File) {
updateGameList()
}
fun install(input: InputStream) {
fun install(input: InputStream, archiveName: String?) {
val dir = createDirForGame()
@SuppressLint("HandlerLeak")
val handler = object : Handler() {
@@ -84,7 +84,7 @@ class Launcher private constructor(private val rootDir: File) {
}
SUCCESS -> {
isInstalling = false
observer?.onInstallSuccess(msg.obj as File)
observer?.onInstallSuccess(msg.obj as File, archiveName)
}
FAILURE -> {
isInstalling = false
@@ -19,7 +19,9 @@ package io.github.kichikuou.xsystem35
import android.app.*
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.provider.OpenableColumns
import android.util.Log
import android.view.Menu
import android.view.MenuItem
@@ -60,7 +62,7 @@ class LauncherActivity : ListActivity(), AdapterView.OnItemLongClickListener, La
override fun onListItemClick(l: ListView?, v: View?, position: Int, id: Long) {
super.onListItemClick(l, v, position, id)
if (position < launcher.games.size) {
startGame(launcher.games[position].path)
startGame(launcher.games[position].path, null)
} else {
val i = Intent(Intent.ACTION_GET_CONTENT)
i.type = CONTENT_TYPE_ZIP
@@ -112,7 +114,7 @@ class LauncherActivity : ListActivity(), AdapterView.OnItemLongClickListener, La
INSTALL_REQUEST -> {
val input = contentResolver.openInputStream(uri) ?: return
showProgressDialog()
launcher.install(input)
launcher.install(input, getArchiveName(uri))
}
SAVEDATA_EXPORT_REQUEST -> try {
launcher.exportSaveData(contentResolver.openOutputStream(uri)!!)
@@ -144,9 +146,9 @@ class LauncherActivity : ListActivity(), AdapterView.OnItemLongClickListener, La
progressDialog?.setProgress(getString(R.string.install_progress, path))
}
override fun onInstallSuccess(path: File) {
override fun onInstallSuccess(path: File, archiveName: String?) {
dismissProgressDialog()
startGame(path)
startGame(path, archiveName)
}
override fun onInstallFailure(msgId: Int) {
@@ -154,10 +156,11 @@ class LauncherActivity : ListActivity(), AdapterView.OnItemLongClickListener, La
errorDialog(msgId)
}
private fun startGame(path: File) {
private fun startGame(path: File, archiveName: String?) {
val i = Intent()
i.setClass(applicationContext, GameActivity::class.java)
i.putExtra(GameActivity.EXTRA_GAME_ROOT, path.path)
i.putExtra(GameActivity.EXTRA_ARCHIVE_NAME, archiveName)
startActivity(i)
}
@@ -181,6 +184,17 @@ class LauncherActivity : ListActivity(), AdapterView.OnItemLongClickListener, La
.setPositiveButton(R.string.ok) {_, _ -> }
.show()
}
private fun getArchiveName(uri: Uri): String? {
val cursor = contentResolver.query(uri, null, null, null, null, null)
cursor?.use {
if (it.moveToFirst()) {
val fname = it.getString(it.getColumnIndex(OpenableColumns.DISPLAY_NAME))
return if (fname.endsWith(".zip", true)) fname.dropLast(4) else fname
}
}
return null
}
}
@Suppress("DEPRECATION") // for ProgressDialog
+2 -2
View File
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.61'
ext.kotlin_version = '1.3.72'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.android.tools.build:gradle:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
+2 -2
View File
@@ -1,6 +1,6 @@
#Mon Oct 23 13:51:26 PDT 2017
#Mon Aug 10 12:24:31 JST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
+1 -6
View File
@@ -3,7 +3,6 @@
#cmakedefine CMAKE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@"
#define RGB_ORDER 1
#cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@
#cmakedefine CACHE_TOTALSIZE @CACHE_TOTALSIZE@
@@ -13,17 +12,13 @@
#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_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_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@"
@@ -33,11 +28,11 @@
#cmakedefine QUIET_MIDI @QUIET_MIDI@
#cmakedefine HAVE_GETLOGIN @HAVE_GETLOGIN@
#cmakedefine HAVE_JPEG @HAVE_JPEG@
#cmakedefine HAVE_MMAP @HAVE_MMAP@
#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 -1
View File
@@ -27,7 +27,7 @@
Midi : MIDIデータ
Data : その他データ
Save : セーブデータ
Resouce : リソースファイル(マウスカーソル形状)
Resource : リソースファイル(マウスカーソル形状)
Ain : DLL とその関数の情報のかかれた System39.ain
BGM : BGMデータ(エスカレイヤー以降のBGMデータファイル)
WAI : PCMデータの追加情報 (mixer channel 情報等)
-4
View File
@@ -225,10 +225,6 @@
-devjoy name : joystick のデバイス名を name にします
-savekanji # : ゲーム内でファイル名を指定してセーブデータを記録するとき、
日本語のファイル名を UTF-8 と SJIS のどちらで保存するかを
指定します。(# は 0 または 1 ... 0:utf-8, 1:sjis)
-version : バージョン情報を表示します。
-fullscreen : フルスクリーンでゲームを実行します。
+49 -49
View File
@@ -84,7 +84,7 @@
必要に応じてシナリオ内の変数に読み込みます。
f) リソースファイルは、マウスカーソルの形状とアニメーションマウスカーソルの
データを格納しています。これまで DARCROW でのみ使用されました。
データを格納しています。これまで DARCROWS でのみ使用されました。
g) セーブデータは、システム管理情報と数値変数、文字列変数のすべてを含んだ
全セーブデータ(*.asd)と数値変数・文字列変数の一部を保存したデータの2種類が
@@ -94,17 +94,17 @@
h) その他のデータの範疇に入るものとしては外字ファイルとデータファイルがあり
ます。
外字ファイルは、PC9801の外字領域に16x16ドットのビットマップデータを並べた
もので、オリジナルの外字を表示させるのに加えて、98機種依存文字の吸収も目指
もので、オリジナルの外字を表示させるのに加えて、PC98機種依存文字の吸収も目指
していたのですが、結局外字ファイルは「いけないかつみ先生」で使われたのみで、
SYSTEM35.EXE Version 2.x 以降ではサポートすらされなくなりました。また、機種
依存文字(まる文字やギリシャ数字など)はそれ以降のゲームでも機種存のコードで
依存文字(まる文字やギリシャ数字など)はそれ以降のゲームでも機種依存のコードで
継続して使われています。SYSTEM 3.9 では再び外字のサポートが復活するようです。
データファイルは、基本的には、シナリオ変数を外部に保存したものと考える事
ができます。マップデータのようにあらかじめゲームに附属しているものもあれば、
ゲームの途中経過を記録するために、ファイルに書き出す事もあります。
かえるにょぱにょーんのマップデータ等のように e)のデータファイルで代用できる
ものもあります。
かえるにょ・ぱにょ〜んのマップデータ等のように e)のデータファイルで代用でき
るものもあります。
3. データファイル (.ald) のフォーマット
@@ -143,15 +143,15 @@
data そのものについても、ヘッダと実データに分ける事が出来ます。ヘッダは
32バイト以上の長さで次のようになっています。
int32 prt;
int32 ptr;
int32 size;
int32 time_l;
int32 time_h;
char name[?];
ptr は実際のデータへのヘッダからの相対アドレスです。size はデータの大きさを
表します。 time_l と time_h は Windows 特有(?)の値で、データの作成時間をユリ
ウス歴の最初の日付からの経過時間をナノ秒で表したものです。name はアーカイブ
表します。 time_l と time_h は Windows の FILETIME 型の値で、データの作成時刻
を1601-01-01からの100ナノ秒単位の経過時間で表したものです。name はアーカイブ
する前のデータのファイル名で、16バイト以上の長さがあります。16バイト未満の時
は0でパディングされます。またヘッダとデータを併せて 256バイト単位になるよう
にデータの後ろは0でパディングされます。
@@ -200,26 +200,26 @@
int16 width;
int16 height;
int8 rsv;
int8 pallet_bank;
int8 palette_bank;
int8 pal[3*16];
(x0,y0) は、CGを表示する位置を表します。シナリオから表示位置の指定のない場合
この値を使います。x0 は 8で割った大きさになっていいますので、x0=10 とあった
場合は実際には (80,y0) の位置に表示します。
この値を使います。x0 は 8で割った大きさになっていますので、x0=10 とあった場
合は実際には (80,y0) の位置に表示します。
(width, height) は CG の大きさを表します。widthは実際には8で割った大きさに
なっています。これは、プレーン型のデータが元になっているためです。プレーン型
のデータの場合、1バイトで表されるのは8ピクセル分だったため、width にいれる
値は占めるバイト数を格納した方が有利だったんめと考えられます。よってCGの横の
値は占めるバイト数を格納した方が有利だったためと考えられます。よってCGの横の
サイズは常に8の倍数になります。8の倍数以外にしたい場合は、余る部分を透過
パレット(スプライト)とする事で実現出来ます。
rsv は現在のところ、使われていません。
pallet_bank は、SYSTEM 3 の時代に 256色対応ゲームで、VSPファイルを読み込ませ
palette_bank は、SYSTEM 3 の時代に 256色対応ゲームで、VSPファイルを読み込ませ
るために、256個のパレットのどの場所に 16色分のパレットを置くかを決めます。
bank=0 で 0-15, bank=1 で 16-31 となります。実装方法としては、plane->packed
の変換の際に上位4bitにpalletを置いた場所の bitを立てます。bank=1 なら '| 0x10'
の変換の際に上位4bitにpaletteを置いた場所の bitを立てます。bank=1 なら '| 0x10'
という具合です。シナリオ側からパレットバンクを指定することもできます。しかし、
シナリオ側から1度もパレットバンクの指定が無い場合はこのヘッダ内の情報が使用
されます。(これは実装依存かもしれません)
@@ -234,7 +234,7 @@
です。
00, len;
一つ上のプレーンと(len+1)の長さだけ同じ
同じプレーンの一つ左の列と(len+1)の長さだけ同じ
01, len, pic;
1バイト(pic)の繰り返し。長さは(len+1)
@@ -277,32 +277,32 @@
int8 bpp;
int8 bppS;
int8 trans_pal;
int16 palett_bank;
int32 rsv;
int8 rsv1;
int16 palette_bank;
int32 rsv2;
int32 x0;
int32 y0;
int32 width;
int32 height;
int32 data_ptr;
int32 pallet_ptr;
int32 palette_ptr;
int32 comment_ptr;
sig はデータのマジックナンバーで 'PM' というデータが入っています。
ver はデータのバージョンで、現在は 1 が入っています。
bpp はデータの bit per pixel で 8または16です。256色データの場合は 8、64k色
の場合は 16です。
bpp はデータの bits per pixel で、256色データの場合は 8、64k色の場合は16です。
bppsはαチャンネルの bit per pixel で通常は8です。
bppsはαチャンネルの bits per pixel で通常は8です。
trans_pal は透過するパレットの番号です。通常はシナリオから指定が来るので
使用しません。
pallet_bank は データの中のパレットのどの部分をシステムに転送するかを
palette_bank は データの中のパレットのどの部分をシステムに転送するかを
表します。通常は 256個全部転送するのですが、CGデータがそれ以下しか色を使って
ない場合には、一部のみ転送することができます。pallet_bank は 16bit の情報を
持ち 256個を 16個づつに分割してどの部分を転送するかを指定します。bit-on で
ない場合には、一部のみ転送することができます。palette_bank は 16bit の情報を
持ち 256個を 16個ずつに分割してどの部分を転送するかを指定します。bit-on で
転送です。LSB が0-15, MSB が 240-255 です。
(x0, y0) は CG の表示位置です。VSP と違って8で割った大きさではなく実際の
@@ -312,10 +312,10 @@
data_ptr はデータ先頭からピクセルデータへの相対アドレスが入ります。
pallet_ptr は bppが8の場合にはパレットへの相対アドレスが入りますが、
palette_ptr は bppが8の場合にはパレットへの相対アドレスが入りますが、
16の場合にはαチャンネルデータへの相対アドレスが入ります。
comment_prt はデータにコメントをつける事ができて、そのデータへの相対アドレス
comment_ptr はデータにコメントをつける事ができて、そのデータへの相対アドレス
を指定します。
パレット
@@ -333,31 +333,31 @@
2つ上のラインと同じ。長さは (len+3:8bit, len+2:16bit)
0xfd, len, pic,
1byte の picデータの連続。長さは (len+4:8bit, len+3:16bit)
1ピクセルの picデータの連続。長さは (len+4:8bit, len+3:16bit)
0xfc, len, pic1, pic2
2byte (pic1, pic2) データの連続。長さは ((len+3)*2:8bit, ((len+2)*2):16bit))
2ピクセル (pic1, pic2) データの連続。長さは ((len+3)*2:8bit, (len+2)*2:16bit)
0xfb
左上のデータと同じ。(PMS16専用)
左上のピクセルと同じ。(PMS16専用)
0xfa
右上のデータと同じ。(PMS16専用)
右上のピクセルと同じ。(PMS16専用)
0xf9, len, pic_h, pic_l1, pic_l2, .... (PMS16専用)
ピクセル間の色の差が小さいものの連続。長さは(len+1)
各ピクセルのうち、R の上位 3bit, G の 2bit, B の 2bit が同じで、R の下位
各ピクセルのうち、R の上位 3bit, G の 2bit, B の 3bit が同じで、R の下位
2bit, G の 4bit, B の 2bit が異なるとき、下位の異なる部分のみを pic_l2,
pic_l3... で表す。( RGB は 5bit, 6bit, 5bit で表される)
pic_h, pic_l1 で最初のピクセルを構成し、ここから、RGB の上位が同じで、下位の
異なる部分を pic_l2, pic_l3... で構成する
異なる部分を pic_l2, pic_l3... で構成する。
0xf8, pic
picそのもの。コードと同じピクセル用。8bit では pic は 1byte, 16bit では 2byte.
0xf7-0x00
データそのもの 8bitでは 1byte, 16bit では 00-f7 の次のコードはすべて(00-ff)
使用してピクセルを構成。
データそのもの。 8bitでは 1byte, 16bit では次の 1byte と合わせてピクセルを
構成。
4.3 QNT フォーマット
@@ -380,7 +380,7 @@
int32 width;
int32 height;
int32 bpp;
int32 rsv(?)
int32 rsv; (?)
int32 pixel_size;
int32 alpha_size;
@@ -420,7 +420,7 @@
header_size はヘッダの大きさをバイト数で表しています。Version 0 では 48
バイト固定です。
(x0, y0) は CG の表示位置の指定です
(x0, y0) は CG の表示位置の指定です。
(width, height) は CG の大きさの指定です。
@@ -472,8 +472,8 @@
最新のものでは 'S380' となっています。途中混乱した時期があってこれと異なる
場合もあります。
dat_prt は実際のシナリオデータの先頭への相対アドレスです。また、シナリオ中の
ジャンプ命令のアドレスは、上のヘッダの最初からの相対アドレスを使用します。
data_ptr は実際のシナリオデータの先頭のアドレスです。また、シナリオ中の
ジャンプ命令のアドレスは、上のヘッダの先頭からの相対アドレスを使用します。
size はヘッダを含めたデータのサイズを示しています。
@@ -534,21 +534,21 @@
04h 演算子(>= 以上)
数値は0から65535までの正の整数を扱えます。しかし、計算式上では word 定数は
3FFFh しかあつかえませんので、それ以上の値を扱う場合は演算子を使います。
3FFFh までしかあつかえませんので、それ以上の値を扱う場合は演算子を使います。
65536 以上の数値を扱ったり、浮動小数を扱う場合は、64ビット変数を使用します。
配列を除く変数の最大は論理的には、16384 個ですが、実際には 2000 以下に実装上
の限界があります。1000 以上になる場合は、配列変数を有効に使うと良いでしょう。
配列を除く変数は論理的には最大 16384 個ですが、実際には 2000 以下に実装上の
限界があります。1000 以上になる場合は、配列変数を有効に使うと良いでしょう。
(xsystem35 の場合は 1024, 1.5.1pre1から 8192)
変数には、数値変数と配列変数があります。配列変数は、index 変数を用いた
アクセス方法と、var[]のようなアクセス方法があります。var[]では上の 3.51拡張
コードを使用して C0, 01, base_h, base_l, cali: というコーディングがなされま
コードを使用して C0, 01, base_h, base_l, cali: というエンコードがなされま
す。配列のベースとなる変数が (base_h << 8) + base_l で表され、インデックスは
cali で指定されます。インデックスは配列変数も使用可能です。ex. var10[var20[5]]
cali で指定されます。インデックスは配列参照も使用可能です。ex. var10[var20[5]]
計算式は逆ポーランド記述で格納されますので、基本的な処理はスタックから2つの
数値または変数と1つの演算子を取り出して演算し、結果をスタックに戻します。
計算式は逆ポーランド記述で格納されますので、基本的な処理はスタックから1つの
演算子と2つの数値または変数を取り出して演算し、結果をスタックに戻します。
この操作を 0x7f が出現するまで繰り返します。0x7f が来たら、スタックに残って
いる数値を取り出します。コマンドの引数として変数を要求している場合の計算式
は、変数へのポインタを返します。
@@ -657,8 +657,8 @@
wav** など小文字系のコマンドはすべて 0x2f, 0x??, にエンコードされます。
また引数として文字列を含むもの(ファイル名など)は、従来は ':' で終っていました
が、system 3.8 以降では '\0' で終わるようになり、これらコマンドは新規に 0x2f
コマンドとして新規に割り当てられました。
が、system 3.8 以降では '\0' で終わるようになり、これらのコマンドは新規に
0x2f コマンドとして割り当てられました。
0x2f, 0x0a, cali *2: [wavLoad]
0x2f, 0x0b, cali *2: [wavPlay]
@@ -807,7 +807,7 @@
ここでは、コマンド表に載っていないけど、ゲームに出て来るものを紹介します。
5.8.1 VA
* 機能: ユニットアニメーション (かえるにょ・ぱにょん初出)
* 機能: ユニットアニメーション (かえるにょ・ぱにょ〜ん初出)
* フォーマット: VA getd, cali, cali, cali:
* VA0 : 制御用コマンド
@@ -821,7 +821,7 @@
VA0, no, 1, num:
no番のアニメーション開始。すぐに制御を戻す。
numはコマ数, 0の場合と開始位置と終了位置が同じな時はアニメーションは
動かずにコマ数だけが無限にされるカウント。
動かずにコマ数だけが無限にカウントされる。
VA0, no, 2, num:
no番のアニメーション開始。終るまで制御を戻さない。
+21
View File
@@ -0,0 +1,21 @@
#!/bin/sh
# To use this script in MSYS2 shell, install mingw-w64-x86_64-nsis and
# mingw-w64-x86_64-ntldd-git packages.
if [ $# -ne 2 ]; then
echo 'Usage: make-installer.sh <build-dir> <nsi>'
exit 1
fi
builddir=$1
nsi=$2
echo 'dlls.nsi:'
ntldd -R $builddir/src/xsystem35.exe |perl -ne 'print "File \"$1\"\n" if /=> (.*) \(/' |grep mingw |tee $builddir/dlls.nsi
echo
echo 'dlls-uninstall.nsi:'
sed 's/^File ".*\\/Delete "$INSTDIR\\/' $builddir/dlls.nsi |tee $builddir/dlls-uninstall.nsi
echo
makensis -INPUTCHARSET UTF8 -DBUILDDIR="$builddir" "$nsi"
+5
View File
@@ -0,0 +1,5 @@
Unicode true
Name xsystem35
OutFile xsystem35-32bit.exe
InstallDir $PROGRAMFILES32\xsystem35
!include xsystem35.nsi
+5
View File
@@ -0,0 +1,5 @@
Unicode true
Name xsystem35
OutFile xsystem35-64bit.exe
InstallDir $PROGRAMFILES64\xsystem35
!include xsystem35.nsi
+77
View File
@@ -0,0 +1,77 @@
ManifestDPIAware true
SetCompressor /SOLID lzma
LoadLanguageFile "${NSISDIR}\Contrib\Language files\English.nlf"
LoadLanguageFile "${NSISDIR}\Contrib\Language files\Japanese.nlf"
Page license
Page directory
Page components
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
LicenseData ..\COPYING
!define SHCNE_ASSOCCHANGED 0x08000000
!define SHCNF_IDLIST 0
Function RefreshShellIcons
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v \
(${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
FunctionEnd
Section
SetOutPath $INSTDIR
FILE ${BUILDDIR}\src\xsystem35.exe
!include ${BUILDDIR}\dlls.nsi
SetOutPath $INSTDIR\fonts
FILE /x CMakeLists.txt ..\fonts\*.*
WriteUninstaller $INSTDIR\uninstall.exe
WriteRegStr HKLM "Software\Kichikuou\xsystem35\profile" "ttfont_gothic" "$INSTDIR\fonts\MTLc3m.ttf"
WriteRegStr HKLM "Software\Kichikuou\xsystem35\profile" "ttfont_mincho" "$INSTDIR\fonts\mincho.otf"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\xsystem35" "DisplayName" "xsystem35 (remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\xsystem35" "UninstallString" '"$INSTDIR\uninstall.exe"'
SectionEnd
LangString FileAssociation ${LANG_ENGLISH} "Associate with .ALD file type"
LangString FileAssociation ${LANG_JAPANESE} ".ALD ファイルに関連付け"
Section "$(FileAssociation)"
WriteRegStr HKCR ".ald" "" "System35Archive"
WriteRegStr HKCR "System35Archive" "" "AliceSoft System 3.x archive"
WriteRegStr HKCR "System35Archive\DefaultIcon" "" "$INSTDIR\xsystem35.exe,0"
WriteRegStr HKCR "System35Archive\shell\open\command" "" '"$INSTDIR\xsystem35.exe" "%1"'
Call RefreshShellIcons
SectionEnd
LangString DesktopIcon ${LANG_ENGLISH} "Create Desktop icon"
LangString DesktopIcon ${LANG_JAPANESE} "デスクトップショートカットを作成"
Section "$(DesktopIcon)"
CreateShortcut $DESKTOP\xsystem35.lnk $INSTDIR\xsystem35.exe
SectionEnd
LangString StartMenu ${LANG_ENGLISH} "Create Start menu entry"
LangString StartMenu ${LANG_JAPANESE} "スタートメニューに登録"
Section "$(StartMenu)"
CreateDirectory $SMPROGRAMS\xsystem35
CreateShortcut $SMPROGRAMS\xsystem35\xsystem35.lnk $INSTDIR\xsystem35.exe
CreateShortcut $SMPROGRAMS\xsystem35\uninstall.lnk $INSTDIR\uninstall.exe
SectionEnd
Section "Uninstall"
Delete $DESKTOP\xsystem35.lnk
RMDir /r $SMPROGRAMS\xsystem35
DeleteRegKey HKCR ".ald"
DeleteRegKey HKCR "System35Archive"
DeleteRegKey HKLM "Software\Kichikuou\xsystem35"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\xsystem35"
RMDir /r $INSTDIR\fonts
Delete $INSTDIR\uninstall.exe
Delete $INSTDIR\xsystem35.exe
!include ${BUILDDIR}\dlls-uninstall.nsi
RMDir $INSTDIR
SectionEnd
+32 -8
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,13 @@ add_library(modules STATIC
tDemo/tDemo.c
)
target_include_directories(modules PUBLIC .)
target_include_directories(modules PUBLIC . lib)
target_compile_options(modules PRIVATE -Wno-pointer-sign -Wno-invalid-source-encoding)
target_link_libraries(modules PRIVATE graph alk drawtext list)
add_executable(modules_tests lib/list_test.c)
target_link_libraries(modules_tests PRIVATE modules)
add_test(NAME modules_tests COMMAND modules_tests)
target_compile_options(modules PRIVATE -Wno-pointer-sign)
if (SDL2MIXER_FOUND)
if (ANDROID)
@@ -81,9 +107,7 @@ if (SDL2MIXER_FOUND)
endif()
endif()
include(FindJPEG)
if (JPEG_FOUND)
target_compile_definitions(modules PRIVATE HAVE_JPEG)
if (HAVE_JPEG)
target_sources(modules PRIVATE
NightDemonDemo/ndd.c
NightDemonDemo/jpeg2surface.c
+7 -19
View File
@@ -120,10 +120,9 @@ static int load_cg_main(int no) {
sno = find_null_surface();
sf->no = sno;
suf[sno] = sf;
return sf->no;
return sno;
}
static void Init() {
@@ -165,7 +164,7 @@ static void Create() {
*var = 0;
} else {
int no = find_null_surface();
*var = s->no = no;
*var = no;
suf[no] = s;
}
@@ -193,7 +192,7 @@ static void CreatePixelOnly() {
*var = 0;
} else {
int no = find_null_surface();
*var = s->no = no;
*var = no;
suf[no] = s;
}
@@ -219,7 +218,7 @@ static void CreateAMapOnly() {
*var = 0;
} else {
int no = find_null_surface();
*var = s->no = no;
*var = no;
suf[no] = s;
}
@@ -243,7 +242,7 @@ static void IsSurface() {
if (s == NULL) {
*var = 0;
} else {
*var = (s->has_alpha && s->has_pixel) ? 1 : 0;
*var = (s->alpha && s->pixel) ? 1 : 0;
}
DEBUG_COMMAND("Gpx.IsSurface %d,%p:\n", p1, var);
@@ -265,7 +264,7 @@ static void IsPixel() {
if (s == NULL) {
*var = 0;
} else {
*var = s->has_pixel ? 1 : 0;
*var = s->pixel ? 1 : 0;
}
DEBUG_COMMAND("Gpx.IsPixel %d,%p:\n", p1, var);
@@ -287,7 +286,7 @@ static void IsAlpha() {
if (s == NULL) {
*var = 0;
} else {
*var = s->has_alpha ? 1 : 0;
*var = s->alpha ? 1 : 0;
}
DEBUG_COMMAND("Gpx.IsAlpha %d,%p:\n", p1, var);
@@ -421,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);
@@ -466,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);
@@ -539,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);
@@ -716,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);
}
@@ -735,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);
}
@@ -857,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);
@@ -885,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);
@@ -1005,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);
@@ -1057,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);
@@ -1095,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);
@@ -1162,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;
+1 -1
View File
@@ -26,7 +26,7 @@ static void Start() {
int *p1 = getCaliVariable();
int p2 = getCaliValue();
msgskipfile = strdup(v_str(p2 -1));
msgskipfile = strdup(svar_get(p2));
DEBUG_COMMAND_YET("MsgSkip.Start %p,%d:\n", p1, p2);
}
+1 -1
View File
@@ -39,7 +39,7 @@ static void Init(void) { /* 0 */
}
static void InitGame() { /* 1 */
nact->ags.font->antialiase_on = TRUE;
ags_setAntialiasedStringMode(TRUE);
sys_setHankakuMode(2);
nact->msgout = ntmsg_add;
-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);
+5 -15
View File
@@ -17,12 +17,14 @@
#include "nt_msg.h"
#include "sprite.h"
#include "sactcg.h"
#include "sjisname.h"
#include "sactstring.h"
extern int ntsel_dosel(void);
#define SNAME_RYO "亮    "
#define SNAME_RYO_DEF "亮"
// 通常メッセージ表示位置と大きさ
#define MSGFRAME_0_X 6
#define MSGFRAME_0_Y 347
@@ -102,7 +104,7 @@ void ntmsg_init() {
// 主人公名前
nt_sstr_regist_replace(SNAME_RYO, SNAME_RYO_DEF);
nt_sstr_regist_replace(fromUTF8(SNAME_RYO), fromUTF8(SNAME_RYO_DEF));
night.msg.cbmove = cb_mousemove;
night.msg.cbrelease = cb_keyrelease;
@@ -179,19 +181,13 @@ void ntmsg_newline() {
ntmsg_add(buf);
}
void ntmsg_add(char *msg) {
void ntmsg_add(const char *msg) {
int len;
SACT_DEBUG("len = %d\n", strlen(msg));
if (msg[0] == '\0') return;
if (0) {
char *b = sjis2lang(msg);
fprintf(stderr, "add msg '%s'\n", b);
free(b);
}
len = MSGBUFMAX - (int)strlen(night.msgbuf);
if (len < 0) {
WARNING("buf shortage (%d)\n", len);
@@ -258,12 +254,6 @@ static void ntmsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB
dt_setfont(wFont, wSize);
if (1) {
char *b = sjis2lang(mbuf);
fprintf(stderr, "msg '%s'\n", b);
free(b);
}
cw = dt_drawtext_col(sp->u.msg.canvas,
sp->u.msg.dspcur.x,
sp->u.msg.dspcur.y,
+1 -1
View File
@@ -5,7 +5,7 @@ extern void ntmsg_init();
extern void ntmsg_set_frame(int type);
extern void ntmsg_set_place(int type);
extern void ntmsg_newline();
extern void ntmsg_add(char *msg);
extern void ntmsg_add(const char *msg);
extern int ntmsg_ana(void);
extern int ntmsg_update(sprite_t *sp, MyRectangle *r);
+1 -1
View File
@@ -77,7 +77,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;
}
+11 -25
View File
@@ -30,7 +30,6 @@
#include "portab.h"
#include "nact.h"
#include "system.h"
#include "utfsjis.h"
#include "ags.h"
#include "surface.h"
#include "ngraph.h"
@@ -204,24 +203,14 @@ int nt_scg_create_blend(int wNumDstCG, int wNumBaseCG, int wX, int wY, int wNumB
// 指定の文字列のCGを作成
int nt_scg_create_text(int wNumCG, int wSize, int wR, int wG, int wB, char *cText) {
cginfo_t *i;
agsurface_t *glyph;
FONT *font;
if (0) {
char *b = sjis2lang(cText);
WARNING("str = '%s'\n", b);
free(b);
}
spcg_assert_no(wNumCG);
// 勝手に出ていいのかな?
if (strlen(cText) == 0) return OK;
font = nact->ags.font;
font->sel_font(FONT_GOTHIC, wSize);
glyph = font->get_glyph(cText);
ags_setFont(FONT_GOTHIC, wSize);
agsurface_t *glyph = ags_drawStringToSurface(cText);
i = malloc(sizeof(cginfo_t));
i->type = CG_SET;
i->no = wNumCG;
@@ -242,8 +231,6 @@ int nt_scg_create_text(int wNumCG, int wSize, int wR, int wG, int wB, char *cTex
// 数字文字列のCGを作成
int nt_scg_create_textnum(int wNumCG, int wSize, int wR, int wG, int wB, int wFigs, int wZeroPadding, int wValue) {
cginfo_t *i;
agsurface_t *glyph;
FONT *font;
char s[256], ss[256];
spcg_assert_no(wNumCG);
@@ -257,9 +244,8 @@ int nt_scg_create_textnum(int wNumCG, int wSize, int wR, int wG, int wB, int wFi
}
sprintf(s, ss, wValue);
font = nact->ags.font;
font->sel_font(FONT_GOTHIC, wSize);
glyph = font->get_glyph(s);
ags_setFont(FONT_GOTHIC, wSize);
agsurface_t *glyph = ags_drawStringToSurface(s);
i = malloc(sizeof(cginfo_t));
i->type = CG_SET;
@@ -322,15 +308,15 @@ int nt_scg_cut(int wNumDstCG, int wNumSrcCG, int wX, int wY, int wWidth, int wHe
i->refcnt = 0;
src = srccg->sf;
if (src->has_alpha) {
if (src->alpha) {
dst = sf_create_surface(wWidth, wHeight, src->depth);
} else {
dst = sf_create_pixel(wWidth, wHeight, src->depth);
}
if (src->has_pixel) {
if (src->pixel) {
gr_copy(dst, 0, 0, src, wX, wY, wWidth, wHeight);
}
if (src->has_alpha) {
if (src->alpha) {
gr_copy_alpha_map(dst, 0, 0, src, wX, wY, wWidth, wHeight);
}
@@ -363,17 +349,17 @@ int nt_scg_partcopy(int wNumDstCG, int wNumSrcCG, int wX, int wY, int wWidth, in
i->refcnt = 0;
src = srccg->sf;
if (src->has_alpha) {
if (src->alpha) {
dst = sf_create_surface(src->width, src->height, src->depth);
gr_fill_alpha_map(dst, 0, 0, src->width, src->height, 255);
} else {
dst = sf_create_pixel(src->width, src->height, src->depth);
}
if (src->has_pixel) {
if (src->pixel) {
gr_copy(dst, wX, wY, src, wX, wY, wWidth, wHeight);
}
if (src->has_alpha) {
if (src->alpha) {
gr_copy_alpha_map(dst, wX, wY, src, wX, wY, wWidth, wHeight);
}
@@ -498,7 +484,7 @@ int nt_scg_existalphamap(int wNumCG, int *ret) {
if (cgs[wNumCG] == NULL) goto errexit;
if (cgs[wNumCG]->sf == NULL) goto errexit;
*ret = cgs[wNumCG]->sf->has_alpha ? 1 : 0;
*ret = cgs[wNumCG]->sf->alpha ? 1 : 0;
errexit:
*ret = 0;
+2 -2
View File
@@ -4,7 +4,7 @@ static surface_t *blend(surface_t *base, int x, int y, surface_t *blend, int mod
gr_copy(dst, 0, 0, base, 0, 0, base->width, base->height);
if (base->has_alpha) {
if (base->alpha) {
// ベースに alpha map がある場合はそれをコピー
gr_copy_alpha_map(dst, 0, 0, base, 0, 0, base->width, base->height);
} else {
@@ -12,7 +12,7 @@ static surface_t *blend(surface_t *base, int x, int y, surface_t *blend, int mod
gr_fill_alpha_map(dst, 0, 0, base->width, base->height, 255);
}
if (blend->has_alpha) {
if (blend->alpha) {
// 重ね合わせ先の alpha map があるときはそれを使う
gre_BlendUseAMap(dst, x, y, base, x, y, blend, 0, 0, blend->width, blend->height, blend, 0, 0, 255);
} else {
+3 -6
View File
@@ -12,13 +12,11 @@ static surface_t *stretch(surface_t *src, int dw, int dh, int mirror) {
dst->depth = src->depth;
dst->bytes_per_line = dw * src->bytes_per_pixel;
dst->bytes_per_pixel = src->bytes_per_pixel;
dst->has_pixel = src->has_pixel;
dst->has_alpha = src->has_alpha;
if (src->has_pixel) {
if (src->pixel) {
dst->pixel = malloc(dh * dst->bytes_per_line);
}
if (src->has_alpha) {
if (src->alpha) {
dst->alpha = malloc(dw * dh);
}
@@ -78,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:
@@ -88,7 +85,7 @@ static surface_t *stretch(surface_t *src, int dw, int dh, int mirror) {
break;
}
if (src->has_alpha) {
if (src->alpha) {
int x, y;
BYTE *sl, *dl;
BYTE *_sl, *_dl;
+3 -3
View File
@@ -97,8 +97,8 @@ int nt_sstr_regist_replace(char *sstr, char *dstr) {
if (sstr == dstr) return NG;
ex = malloc(sizeof(strexchange_t));
ex->src = strdup(sstr);
ex->dst = strdup(dstr);
ex->src = sstr;
ex->dst = dstr;
strreplace = slist_append(strreplace, ex);
return OK;
}
@@ -118,7 +118,7 @@ int nt_sstr_num2str(int strno, int fig, int nzeropad, int num) {
}
sprintf(s, ss, num);
v_strcpy(strno -1, s);
svar_set(strno, s);
return OK;
}
-2
View File
@@ -1,2 +0,0 @@
#define SNAME_RYO "亮    "
#define SNAME_RYO_DEF "亮"
+1 -1
View File
@@ -76,7 +76,7 @@ int nt_sp_draw2(sprite_t *sp, cginfo_t *cg, MyRectangle *r) {
dx += r->x;
dy += r->y;
if (cg->sf->has_alpha) {
if (cg->sf->alpha) {
// alpha map がある場合
gre_BlendUseAMap(sf0, dx, dy,
sf0, dx, dy,
+4 -4
View File
@@ -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;
}
+11 -16
View File
@@ -67,28 +67,23 @@ static void disjunction(void* region, void* data) {
MyRectangle *r2 = (MyRectangle *)data;
int x1, x2, y1, y2;
//SACT_DEBUG("r1x=%d,r1y=%d,r1w=%d,r1h=%d\n", r1->x, r1->y, r1->width, r1->height);
//SACT_DEBUG("r2x=%d,r2y=%d,r2w=%d,r2h=%d\n", r2->x, r2->y, r2->width, r2->height);
if (r2->width == 0) {
r2->x = r1->x;
r2->y = r1->y;
r2->width = r1->width;
r2->height = r1->height;
return;
} 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;
}
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;
//SACT_DEBUG("res:r2x=%d,r2y=%d,r2w=%d,r2h=%d\n", r2->x, r2->y, r2->width, r2->height);
free(r1);
}
// 更新の必要なスプライトの領域の和をとってクリッピングする
+1 -1
View File
@@ -31,7 +31,7 @@
#include "modules.h"
#include "nact.h"
extern void ndd_init(char *files[], int n);
extern void ndd_init(const char *files[], int n);
extern void ndd_run(int demonum);
static void Init() {
+4 -12
View File
@@ -21,10 +21,12 @@
*/
/* $Id: jpeg2surface.c,v 1.2 2003/11/09 15:06:12 chikama Exp $ */
#include "config.h"
#include <stdio.h>
#include <jpeglib.h>
#undef max
#undef min
#include "config.h"
#include "portab.h"
#include "ags.h"
@@ -35,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;
+2 -2
View File
@@ -39,7 +39,7 @@
// 2: Meteo
struct nddemo {
char **fn;
const char **fn;
alk_t *alk;
surface_t *sf[10];
};
@@ -52,7 +52,7 @@ static int ndemo_nums[3] = {150, 603, 467};
extern surface_t *jpeg2surface(FILE *fp, int offset);
// ALKファイルの登録
void ndd_init(char *files[], int n) {
void ndd_init(const char *files[], int n) {
int i;
ndd.fn = malloc(sizeof(char *) * n);
+3 -3
View File
@@ -103,9 +103,9 @@ static void Init() {
int p1 = getCaliValue(); /* ISys3x */
// ゲームタイトルによるバージョン設定
if (0 == strcmp(nact->game_title_name, GT_ESUKA)) {
if (0 == strcmp(nact->game_title_utf8, GT_ESUKA)) {
sact.version = 100;
} else if (0 == strcmp(nact->game_title_name, GT_RANCE5D)){
} else if (0 == strcmp(nact->game_title_utf8, GT_RANCE5D)){
sact.version = 110;
} else {
sact.version = 120;
@@ -132,7 +132,7 @@ static void Init() {
sact.dmap = sf_create_pixel(sf0->width, sf0->height, 16);
// その他 System35 のデフォルト動作の変更
nact->ags.font->antialiase_on = TRUE;
ags_setAntialiasedStringMode(TRUE);
sys_setHankakuMode(2); // 全角半角変換無し
ags_autorepeat(FALSE); // key auto repeat off
+2 -4
View File
@@ -32,7 +32,7 @@
#include "surface.h"
#include "sacttimer.h"
#include "variable.h"
#include "mmap.h"
// スプライトの最大数
#define SPRITEMAX 21845
@@ -63,9 +63,7 @@ typedef struct {
// SACTEFAM を使ったマスク
typedef struct {
int fd; // SACTEFAM.KLD のファイルディスクプリタ
char *mapadr; // mmap された最初のアドレス
off_t size; // mmap した大きさ
mmap_t *mmap;
int datanum; // SACTEFAM.KLD 中のマスクファイルの数
int *no; // シナリオ側での番号
int *offset; // データへのオフセット
+8 -32
View File
@@ -27,11 +27,6 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "portab.h"
#include "system.h"
@@ -60,40 +55,21 @@ static ecopyparam_t ecp;
// SACTEFAM.KLD の読み込み
int smask_init(char *path) {
struct stat sbuf;
int i, fd;
char *adr;
int i;
SACTEFAM_t *am;
if (0 > (fd = open(path, O_RDONLY))) {
WARNING("open: %s\n", strerror(errno));
mmap_t *m = map_file(path);
if (!m)
return NG;
}
if (0 > fstat(fd, &sbuf)) {
WARNING("fstat: %s\n", strerror(errno));
close(fd);
return NG;
}
if (MAP_FAILED == (adr = mmap(0, sbuf.st_size, PROT_READ, MAP_SHARED, fd, 0))) {
WARNING("mmap: %s\n", strerror(errno));
close(fd);
return NG;
}
am = &sact.am;
am->mapadr = adr;
am->size = sbuf.st_size;
am->fd = fd;
am->datanum = LittleEndian_getDW(adr, 0);
am->mmap = m;
am->datanum = LittleEndian_getDW(m->addr, 0);
am->no = malloc(sizeof(int) * am->datanum);
am->offset = malloc(sizeof(int) * am->datanum);
for (i = 0; i < am->datanum; i++) {
am->no[i] = LittleEndian_getDW(adr, 16 + i * 16);
am->offset[i] = LittleEndian_getDW(adr, 16 + i * 16 + 8);
am->no[i] = LittleEndian_getDW(m->addr, 16 + i * 16);
am->offset[i] = LittleEndian_getDW(m->addr, 16 + i * 16 + 8);
}
return OK;
@@ -110,7 +86,7 @@ static surface_t *smask_get(int no) {
if (i == am->datanum) return NULL;
return sf_getcg(am->mapadr + am->offset[i]);
return sf_getcg(am->mmap->addr + am->offset[i]);
}
// ベースになるマスクの alpha 値を拡大して取り出す
+1 -1
View File
@@ -24,6 +24,6 @@
#ifndef __SACTAMASK_H__
#define __SACTAMASK_H__
extern int smask_init(char *path);
extern int smask_init(const char *path);
#endif
+15 -29
View File
@@ -35,7 +35,6 @@
#include "sactcg.h"
#include "surface.h"
#include "ngraph.h"
#include "utfsjis.h"
#include "sactcg_stretch.c"
#include "sactcg_blend.c"
@@ -202,24 +201,14 @@ int scg_create_blend(int wNumDstCG, int wNumBaseCG, int wX, int wY, int wNumBlen
// 指定の文字列のCGを作成
int scg_create_text(int wNumCG, int wSize, int wR, int wG, int wB, int wText) {
cginfo_t *i;
agsurface_t *glyph;
FONT *font;
if (0) {
char *b = sjis2lang(v_str(wText-1));
WARNING("str = '%s'\n", b);
free(b);
}
spcg_assert_no(wNumCG);
// 勝手に出ていいのかな?
if (v_strlen(wText -1) == 0) return OK;
font = nact->ags.font;
font->sel_font(FONT_GOTHIC, wSize);
glyph = font->get_glyph(v_str(wText -1));
if (svar_length(wText) == 0) return OK;
ags_setFont(FONT_GOTHIC, wSize);
agsurface_t *glyph = ags_drawStringToSurface(svar_get(wText));
i = malloc(sizeof(cginfo_t));
i->type = CG_SET;
i->no = wNumCG;
@@ -240,8 +229,6 @@ int scg_create_text(int wNumCG, int wSize, int wR, int wG, int wB, int wText) {
// 数字文字列のCGを作成
int scg_create_textnum(int wNumCG, int wSize, int wR, int wG, int wB, int wFigs, int wZeroPadding, int wValue) {
cginfo_t *i;
agsurface_t *glyph;
FONT *font;
char s[256], ss[256];
spcg_assert_no(wNumCG);
@@ -254,11 +241,10 @@ int scg_create_textnum(int wNumCG, int wSize, int wR, int wG, int wB, int wFigs,
sprintf(ss, sss, wFigs);
}
sprintf(s, ss, wValue);
font = nact->ags.font;
font->sel_font(FONT_GOTHIC, wSize);
glyph = font->get_glyph(s);
ags_setFont(FONT_GOTHIC, wSize);
agsurface_t *glyph = ags_drawStringToSurface(s);
i = malloc(sizeof(cginfo_t));
i->type = CG_SET;
i->no = wNumCG;
@@ -320,15 +306,15 @@ int scg_cut(int wNumDstCG, int wNumSrcCG, int wX, int wY, int wWidth, int wHeigh
i->refcnt = 0;
src = srccg->sf;
if (src->has_alpha) {
if (src->alpha) {
dst = sf_create_surface(wWidth, wHeight, src->depth);
} else {
dst = sf_create_pixel(wWidth, wHeight, src->depth);
}
if (src->has_pixel) {
if (src->pixel) {
gr_copy(dst, 0, 0, src, wX, wY, wWidth, wHeight);
}
if (src->has_alpha) {
if (src->alpha) {
gr_copy_alpha_map(dst, 0, 0, src, wX, wY, wWidth, wHeight);
}
@@ -361,17 +347,17 @@ int scg_partcopy(int wNumDstCG, int wNumSrcCG, int wX, int wY, int wWidth, int w
i->refcnt = 0;
src = srccg->sf;
if (src->has_alpha) {
if (src->alpha) {
dst = sf_create_surface(src->width, src->height, src->depth);
gr_fill_alpha_map(dst, 0, 0, src->width, src->height, 255);
} else {
dst = sf_create_pixel(src->width, src->height, src->depth);
}
if (src->has_pixel) {
if (src->pixel) {
gr_copy(dst, wX, wY, src, wX, wY, wWidth, wHeight);
}
if (src->has_alpha) {
if (src->alpha) {
gr_copy_alpha_map(dst, wX, wY, src, wX, wY, wWidth, wHeight);
}
@@ -496,7 +482,7 @@ int scg_existalphamap(int wNumCG, int *ret) {
if (sact.cg[wNumCG] == NULL) goto errexit;
if (sact.cg[wNumCG]->sf == NULL) goto errexit;
*ret = sact.cg[wNumCG]->sf->has_alpha ? 1 : 0;
*ret = sact.cg[wNumCG]->sf->alpha ? 1 : 0;
errexit:
*ret = 0;
+2 -2
View File
@@ -4,7 +4,7 @@ static surface_t *blend(surface_t *base, int x, int y, surface_t *blend, int mod
gr_copy(dst, 0, 0, base, 0, 0, base->width, base->height);
if (base->has_alpha) {
if (base->alpha) {
// ベースに alpha map がある場合はそれをコピー
gr_copy_alpha_map(dst, 0, 0, base, 0, 0, base->width, base->height);
} else {
@@ -12,7 +12,7 @@ static surface_t *blend(surface_t *base, int x, int y, surface_t *blend, int mod
gr_fill_alpha_map(dst, 0, 0, base->width, base->height, 255);
}
if (blend->has_alpha) {
if (blend->alpha) {
// 重ね合わせ先の alpha map があるときはそれを使う
gre_BlendUseAMap(dst, x, y, base, x, y, blend, 0, 0, blend->width, blend->height, blend, 0, 0, 255);
} else {
+3 -6
View File
@@ -12,13 +12,11 @@ static surface_t *stretch(surface_t *src, int dw, int dh, int mirror) {
dst->depth = src->depth;
dst->bytes_per_line = dw * src->bytes_per_pixel;
dst->bytes_per_pixel = src->bytes_per_pixel;
dst->has_pixel = src->has_pixel;
dst->has_alpha = src->has_alpha;
if (src->has_pixel) {
if (src->pixel) {
dst->pixel = malloc(dh * dst->bytes_per_line);
}
if (src->has_alpha) {
if (src->alpha) {
dst->alpha = malloc(dw * dh);
}
@@ -78,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:
@@ -88,7 +85,7 @@ static surface_t *stretch(surface_t *src, int dw, int dh, int mirror) {
break;
}
if (src->has_alpha) {
if (src->alpha) {
int x, y;
BYTE *sl, *dl;
BYTE *_sl, *_dl;
+1 -1
View File
@@ -47,7 +47,7 @@ int scryp_encrypt_str(int strno, int key) {
}
int scryp_decrypt_str(int strno, int key) {
WARNING("str = '%s'\n", v_str(strno -1));
WARNING("str = '%s'\n", svar_get(strno));
WARNING("NOT IMPLEMENTED\n");
return OK;
}
+21 -12
View File
@@ -40,7 +40,17 @@
#include "ngraph.h"
#include "drawtext.h"
#include "utfsjis.h"
#include "sactlog_sjismsg.c"
#define LOGMSG_LINES 6
static const char *logmsg_utf8[LOGMSG_LINES] = {
"\n",
"※バックログ操作方法※",
"[ESC]またはマウス右クリックでゲームに戻る",
"[PageUp][PageDown]でページスクロール",
"[↑][↓]またはマウスホイールで行スクロール",
"\n",
};
/*
ホイールで上下スクロール
@@ -73,21 +83,18 @@ static void draw_log() {
// 表示始め位置
node = list_nth(sact.log, list_length(sact.log) - curline);
for (i = 0; i < LOGLINENUM; i++) {
char *str, *streuc;
if (cur <= 0) continue;
str = (char *)(node->data);
char *str = (char *)(node->data);
if (0 == strcmp(str, "\n")) {
gr_fill(chr, 0, y + FONTSIZE/2, sf0->width, 3, 128, 0, 0);
} else {
streuc = sjis2lang(str);
if (cur < 6) {
dt_setfont(FONT_MINCHO, FONTSIZE);
} else {
dt_setfont(FONT_GOTHIC, FONTSIZE);
}
dt_drawtext(chr, 0, y, str);
free(streuc);
}
y += FONTSIZE;
cur--;
@@ -103,13 +110,15 @@ static void draw_log() {
int sblog_start(void) {
static char *logmsg[LOGMSG_LINES];
if (!logmsg[0]) {
for (int i = 0; i < LOGMSG_LINES; i++)
logmsg[i] = fromUTF8(logmsg_utf8[i]);
}
// 説明文章を追加
sact.log = list_append(sact.log, "\n");
sact.log = list_append(sact.log, LOGMSG1);
sact.log = list_append(sact.log, LOGMSG2);
sact.log = list_append(sact.log, LOGMSG3);
sact.log = list_append(sact.log, LOGMSG4);
sact.log = list_append(sact.log, "\n");
for (int i = 0; i < LOGMSG_LINES; i++)
sact.log = list_append(sact.log, logmsg[i]);
back = sf_dup(sf0);
chr = sf_create_surface(sf0->width, sf0->height, 8);
@@ -129,7 +138,7 @@ int sblog_end(void) {
sf_free(chr);
// 説明文章を削除
for (i = 0; i < 6; i++) {
for (i = 0; i < LOGMSG_LINES; i++) {
node = list_last(sact.log);
sact.log = list_remove(sact.log, node->data);
}
-5
View File
@@ -1,5 +0,0 @@
#define LOGMSG1 "※バックログ操作方法※"
#define LOGMSG2 "[ESC]またはマウス右クリックでゲームに戻る"
#define LOGMSG3 "[PageUp][PageDown]でページスクロール"
#define LOGMSG4 "[↑][↓]またはマウスホイールで行スクロール"
+5 -5
View File
@@ -56,7 +56,7 @@ int sstr_push(int strno) {
idxmax = idx*2;
}
stack[idx++] = strdup(v_str(strno -1));
stack[idx++] = strdup(svar_get(strno));
return OK;
}
@@ -68,7 +68,7 @@ int sstr_push(int strno) {
int sstr_pop(int strno) {
if (idx == 0) return NG;
v_strcpy(strno -1, stack[--idx]);
svar_set(strno, stack[--idx]);
free(stack[idx]);
return OK;
@@ -85,8 +85,8 @@ int sstr_regist_replace(int sstrno, int dstrno) {
if (sstrno == dstrno) return NG;
ex = malloc(sizeof(strexchange_t));
ex->src = strdup(v_str(sstrno -1));
ex->dst = strdup(v_str(dstrno -1));
ex->src = strdup(svar_get(sstrno));
ex->dst = strdup(svar_get(dstrno));
sact.strreplace = slist_append(sact.strreplace, ex);
return OK;
}
@@ -106,7 +106,7 @@ int sstr_num2str(int strno, int fig, int nzeropad, int num) {
}
sprintf(s, ss, num);
v_strcpy(strno -1, s);
svar_set(strno, s);
return OK;
}
+1 -1
View File
@@ -83,7 +83,7 @@ extern void sp_draw_dmap(void* data, void* userdata);
// in sprite_msg.c
extern void smsg_add(char *msg);
extern void smsg_add(const char *msg);
extern void smsg_newline(int wNum, int size);
extern void smsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB, int wFont, int wSpeed, int wLineSpace, int wAlign, int wRSize, int wRFont, int wRLineSpace, int *wLength);
extern void smsg_clear(int wNum);
+2 -2
View File
@@ -117,7 +117,7 @@ int sp_draw2(sprite_t *sp, cginfo_t *cg) {
dx += sact.updaterect.x;
dy += sact.updaterect.y;
if (cg->sf->has_alpha) {
if (cg->sf->alpha) {
// alpha map がある場合
gre_BlendUseAMap(sf0, dx, dy,
sf0, dx, dy,
@@ -175,7 +175,7 @@ void sp_draw_dmap(void* data, void* userdata) {
return;
}
if (cg->sf->has_alpha) {
if (cg->sf->alpha) {
fill_dmap_mask(cg->sf, sx, sy, dx, dy, w, h, sp->no);
} else {
fill_dmap(dx, dy, w, h, sp->no);
+4 -4
View File
@@ -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;
}
-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++) {
+5 -1
View File
@@ -1,3 +1,4 @@
#include <stdlib.h>
#include "ngraph.h"
#include "graph.h"
@@ -42,7 +43,10 @@ static void ec10_cb(surface_t *sfsrc, surface_t *sfdst) {
if (ec10_sf[0] == NULL) {
ec10_sf[0] = sf_dup2(sfsrc, FALSE, FALSE);
sf = ec10_sf[0];
sf->has_alpha = FALSE;
if (sf->alpha) {
free(sf->alpha);
sf->alpha = NULL;
}
gr_copy_stretch(sf, 0, 0, sf->width, sf->height, sfsrc, sx, sy, sw, sh);
gr_bright_dst_only(sf, 0, 0, sf->width, sf->height, 255/6);
return;
+2 -2
View File
@@ -164,7 +164,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 +183,7 @@ void spev_wait4moving_sp() {
while (sp->move.moving) {
nact->callback();
WaitVsync();
sdl_wait_vsync();
}
}
}
+3 -16
View File
@@ -38,7 +38,6 @@
#include "ngraph.h"
#include "drawtext.h"
#include "sactlog.h"
#include "utfsjis.h"
// メッセージキー待ちの時、表示するアニメーションに関する情報
struct markinfo {
@@ -188,17 +187,11 @@ static int setupmark(int wNum1, int wNum2, struct markinfo *minfo) {
@param msg: 追加する文字列
*/
void smsg_add(char *msg) {
void smsg_add(const char *msg) {
int len;
if (msg[0] == '\0') return;
if (0) {
char *b = sjis2lang(msg);
fprintf(stderr, "add msg '%s'\n", b);
free(b);
}
len = MSGBUFMAX - (int)strlen(sact.msgbuf);
if (len < 0) {
WARNING("buf shortage (%d)\n", len);
@@ -304,12 +297,6 @@ void smsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB, int wF
}
dt_setfont(wFont, wSize);
if (0) {
char *b = sjis2lang(mbuf);
fprintf(stderr, "msg '%s'\n", b);
free(b);
}
cw = dt_drawtext_col(sp->u.msg.canvas,
sp->u.msg.dspcur.x,
sp->u.msg.dspcur.y + wRSize + wRLineSpace,
@@ -392,10 +379,10 @@ void smsg_clear(int wNum) {
/*
出力中の文字列があるかチェック
@return: なし(0) , あり(1)
@return: なし(1) , あり(0)
*/
int smsg_is_empty() {
return (sact.msgbuf[0] != '\0');
return (sact.msgbuf[0] == '\0');
}
/*
+1 -1
View File
@@ -284,7 +284,7 @@ void ssel_add(int nString, int wI) {
free(sact.sel.elem[wI]);
}
sact.sel.elem[wI] = strdup(v_str(nString -1));
sact.sel.elem[wI] = strdup(svar_get(nString));
}
/*
+11 -16
View File
@@ -63,28 +63,23 @@ static void disjunction(void* region, void* data) {
MyRectangle *r2 = (MyRectangle *)data;
int x1, x2, y1, y2;
//SACT_DEBUG("r1x=%d,r1y=%d,r1w=%d,r1h=%d\n", r1->x, r1->y, r1->width, r1->height);
//SACT_DEBUG("r2x=%d,r2y=%d,r2w=%d,r2h=%d\n", r2->x, r2->y, r2->width, r2->height);
if (r2->width == 0) {
r2->x = r1->x;
r2->y = r1->y;
r2->width = r1->width;
r2->height = r1->height;
return;
} 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;
}
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;
//SACT_DEBUG("res:r2x=%d,r2y=%d,r2w=%d,r2h=%d\n", r2->x, r2->y, r2->width, r2->height);
free(r1);
}
// 更新の必要なスプライトの領域の和をとってクリッピングする
+2 -2
View File
@@ -67,7 +67,7 @@ int spxm_getnum(int reginum) {
int spxm_gettext(int reginum, int strno) {
if (reginum > SEL_ELEMENT_MAX) return NG;
v_strcpy(strno -1, xmenu.item[reginum]);
svar_set(strno, xmenu.item[reginum]);
return OK;
}
@@ -78,6 +78,6 @@ int spxm_titlereg(void) {
}
int spxm_titleget(int strno) {
v_strcpy(strno -1, xmenu.title);
svar_set(strno, xmenu.title);
return OK;
}
+2 -38
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));
@@ -508,7 +490,6 @@ static void PlayAnimeData() {
ags_copyArea(mapback.x, mapback.y,
mapback.width, mapback.height,
mapback_p5, mapback_p6);
ags_sync();
}
if (wavno != 0) {
@@ -566,7 +547,7 @@ static void PlayAnimeData() {
{
int now = get_high_counter(SYSTEMCOUNTER_MSEC);
if (now - cnt < interval) {
Sleep(interval - (now-cnt));
sdl_sleep(interval - (now-cnt));
}
}
}
@@ -588,23 +569,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);
+1 -1
View File
@@ -35,7 +35,7 @@
#include "system.h"
#include "xsystem35.h"
#include "modules.h"
#include "graphicsdevice.h"
#include "sdl_core.h"
// キー変換テーブル
#define KEYMAP_MAX 8
+5 -23
View File
@@ -45,26 +45,8 @@ static void ExchangeString(void) {
int target = getCaliValue();
int pat = getCaliValue();
int patr = getCaliValue();
char *start = v_str(target -1);
char *next;
char dst[STRVAR_LEN] = "";
svar_replaceAll(target, pat, patr);
DEBUG_COMMAND("ShString.ExchangeString: %d,%d,%d:\n", target, pat, patr);
if (v_strlen(target -1) == 0 || v_strlen(pat -1) == 0) {
return;
}
while(TRUE) {
next = strstr(start, v_str(pat -1));
if (next == NULL) break;
strncat(dst, start, (size_t)(next - start));
strncat(dst, v_str(patr -1), sizeof(dst) - strlen(dst));
start = next + v_strlen(pat -1);
}
strncat(dst, start, sizeof(dst) - strlen(dst));
v_strcpy(target -1, dst);
}
static void SetNum16String(void) { /* 1 */
@@ -107,7 +89,7 @@ static void SetWindowTitle(void) { /* 6 */
int strno = getCaliValue();
int p2 = getCaliValue(); /* ISys3xSystem */
ags_setWindowTitle(v_str(strno - 1));
ags_setWindowTitle(svar_get(strno));
DEBUG_COMMAND("ShString.SetWindowTitle: %d,%d:\n", strno, p2);
}
@@ -127,8 +109,8 @@ static void FillString() {
int i;
for (i = 0; i < cnt; i++) {
if (st - 1 != src)
v_strcpy(st -1, v_str(src));
if (st + i != src)
svar_set(st + i, svar_get(src));
}
DEBUG_COMMAND("ShString.FillString: %d,%d,%d,%d:\n", st, cnt, src, p4);
@@ -144,7 +126,7 @@ static void SetStringNum16(void) {
*/
int st = getCaliValue();
int *var = getCaliVariable();
char *str = v_str(st -1);
const char *str = svar_get(st);
char _dst[100];
char *dst = _dst;
-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)
+11 -39
View File
@@ -27,58 +27,31 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "portab.h"
#include "system.h"
#include "LittleEndian.h"
#include "alk.h"
alk_t *alk_new(char *path) {
alk_t *alk_new(const char *path) {
alk_t *alk;
int i, fd;
char *adr;
struct stat sbuf;
int i;
if (0 > (fd = open(path, O_RDONLY))) {
WARNING("open: %s\n", strerror(errno));
return NULL;
}
if (0 > fstat(fd, &sbuf)) {
WARNING("fstat: %s\n", strerror(errno));
close(fd);
return NULL;
}
mmap_t *m = map_file(path);
if (MAP_FAILED == (adr = mmap(0, sbuf.st_size, PROT_READ, MAP_SHARED, fd, 0))) {
WARNING("mmap: %s\n", strerror(errno));
close(fd);
return NULL;
}
if (0 != strncmp(adr, "ALK0", 4)) {
WARNING("mmap: %s\n", strerror(errno));
munmap(adr, sbuf.st_size);
close(fd);
if (0 != strncmp(m->addr, "ALK0", 4)) {
WARNING("%s: not an ALK file\n", path);
unmap_file(m);
return NULL;
}
alk = calloc(1, sizeof(alk_t));
alk->mapadr = adr;
alk->size = sbuf.st_size;
alk->fd = fd;
alk->datanum = LittleEndian_getDW(adr, 4);
alk->mmap = m;
alk->datanum = LittleEndian_getDW(m->addr, 4);
alk->offset = malloc(sizeof(int) * alk->datanum);
for (i = 0; i < alk->datanum; i++) {
alk->offset[i] = LittleEndian_getDW(adr, 8 + i * 8);
alk->offset[i] = LittleEndian_getDW(m->addr, 8 + i * 8);
}
return alk;
@@ -87,8 +60,7 @@ alk_t *alk_new(char *path) {
int alk_free(alk_t *alk) {
if (alk == NULL) return OK;
munmap(alk->mapadr, alk->size);
close(alk->fd);
unmap_file(alk->mmap);
free(alk->offset);
free(alk);
@@ -98,5 +70,5 @@ int alk_free(alk_t *alk) {
char *alk_get(alk_t *alk, int no) {
if (no >= alk->datanum) return NULL;
return alk->mapadr + alk->offset[no];
return (char *)alk->mmap->addr + alk->offset[no];
}
+3 -4
View File
@@ -27,6 +27,7 @@
#include <unistd.h>
#include <sys/types.h>
#include "mmap.h"
/*
.ALK データ構造
@@ -38,14 +39,12 @@
*/
typedef struct {
int fd; /* .alk ファイルの file discpriter */
char *mapadr; /* mmap したファイルの先頭アドレス */
off_t size; /* mmap したバイト数(ファイルサイズ) */
mmap_t *mmap; /* mmap したファイル */
int datanum; /* .alk ファイル中のファイル数 */
int *offset; /* 各ファイルへのオフセット */
} alk_t;
extern alk_t *alk_new(char *path);
extern alk_t *alk_new(const char *path);
extern int alk_free(alk_t *alk);
extern char *alk_get(alk_t *alk, int no);
+6 -13
View File
@@ -29,7 +29,6 @@
#include "system.h"
#include "nact.h"
#include "ags.h"
#include "font.h"
#include "surface.h"
#include "ngraph.h"
@@ -59,13 +58,10 @@ int dt_setfont(int type, int size) {
* @return: 実際に描画した幅
*/
int dt_drawtext(surface_t *sf, int x, int y, char *buf) {
agsurface_t *glyph;
int sx, sy, sw, sh;
FONT *font = nact->ags.font;
font->sel_font(ftype, fsize);
glyph = font->get_glyph(buf);
ags_setFont(ftype, fsize);
agsurface_t *glyph = ags_drawStringToSurface(buf);
if (glyph == NULL) return 0;
sx = x; sy = y;
@@ -92,13 +88,10 @@ int dt_drawtext(surface_t *sf, int x, int y, char *buf) {
* @return: 実際に描画した幅
*/
int dt_drawtext_col(surface_t *sf, int x, int y, char *buf, int r, int g, int b) {
agsurface_t *glyph;
int sx, sy, sw, sh;
FONT *font = nact->ags.font;
font->sel_font(ftype, fsize);
glyph = font->get_glyph(buf);
ags_setFont(ftype, fsize);
agsurface_t *glyph = ags_drawStringToSurface(buf);
if (glyph == NULL) return 0;
sx = x; sy = y;
-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) {
+44 -45
View File
@@ -16,13 +16,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#undef NDEBUG
#include "list.h"
#include <assert.h>
#include "unittest.h"
#include <stdio.h>
static void list_func(void *data, void *user_data) {
assert(*(int*)data == ++*(int*)user_data);
ASSERT_EQUAL(*(int*)data, ++*(int*)user_data);
}
static int compare_func(const void *a, const void *b) {
@@ -36,18 +35,18 @@ int main() {
// Basic
{
SList* l = NULL;
assert(slist_length(l) == 0);
ASSERT_EQUAL(slist_length(l), 0);
l = slist_append(l, &data1);
assert(slist_length(l) == 1);
assert(l->data == &data1);
assert(slist_next(l) == NULL);
ASSERT_EQUAL(slist_length(l), 1);
ASSERT_EQUAL_PTR(l->data, &data1);
ASSERT_NULL(slist_next(l));
l = slist_append(l, &data2);
assert(slist_length(l) == 2);
assert(l->data == &data1);
assert(slist_next(l)->data == &data2);
assert(slist_next(slist_next(l)) == NULL);
ASSERT_EQUAL(slist_length(l), 2);
ASSERT_EQUAL_PTR(l->data, &data1);
ASSERT_EQUAL_PTR(slist_next(l)->data, &data2);
ASSERT_NULL(slist_next(slist_next(l)));
slist_free(l);
}
@@ -55,20 +54,20 @@ int main() {
// slist_nth, slist_last
{
SList* l = NULL;
assert(slist_nth(l, 0) == NULL);
assert(slist_nth(l, 1) == NULL);
assert(slist_last(l) == NULL);
ASSERT_NULL(slist_nth(l, 0));
ASSERT_NULL(slist_nth(l, 1));
ASSERT_NULL(slist_last(l));
l = slist_append(l, &data1);
assert(slist_nth(l, 0)->data == &data1);
assert(slist_nth(l, 1) == NULL);
assert(slist_last(l) == slist_nth(l, 0));
ASSERT_EQUAL_PTR(slist_nth(l, 0)->data, &data1);
ASSERT_NULL(slist_nth(l, 1));
ASSERT_EQUAL_PTR(slist_last(l), slist_nth(l, 0));
l = slist_append(l, &data2);
assert(slist_nth(l, 0)->data == &data1);
assert(slist_nth(l, 1)->data == &data2);
assert(slist_nth(l, 2) == NULL);
assert(slist_last(l) == slist_nth(l, 1));
ASSERT_EQUAL_PTR(slist_nth(l, 0)->data, &data1);
ASSERT_EQUAL_PTR(slist_nth(l, 1)->data, &data2);
ASSERT_NULL(slist_nth(l, 2));
ASSERT_EQUAL_PTR(slist_last(l), slist_nth(l, 1));
slist_free(l);
}
@@ -76,28 +75,28 @@ int main() {
// slist_remove
{
SList* l = NULL;
assert(slist_remove(l, NULL) == NULL);
assert(slist_remove(l, &data1) == NULL);
ASSERT_NULL(slist_remove(l, NULL));
ASSERT_NULL(slist_remove(l, &data1));
l = slist_append(l, &data1);
assert(slist_remove(l, NULL) == l);
ASSERT_EQUAL_PTR(slist_remove(l, NULL), l);
l = slist_remove(l, &data1);
assert(l == NULL);
ASSERT_NULL(l);
l = slist_append(l, &data1);
l = slist_append(l, &data2);
l = slist_append(l, &data1);
l = slist_append(l, &data2);
assert(slist_length(l) == 4);
ASSERT_EQUAL(slist_length(l), 4);
l = slist_remove(l, &data2);
assert(slist_length(l) == 3);
assert(slist_nth(l, 0)->data == &data1);
assert(slist_nth(l, 1)->data == &data1);
assert(slist_nth(l, 2)->data == &data2);
ASSERT_EQUAL(slist_length(l), 3);
ASSERT_EQUAL_PTR(slist_nth(l, 0)->data, &data1);
ASSERT_EQUAL_PTR(slist_nth(l, 1)->data, &data1);
ASSERT_EQUAL_PTR(slist_nth(l, 2)->data, &data2);
l = slist_remove(l, &data2);
assert(slist_length(l) == 2);
assert(slist_nth(l, 0)->data == &data1);
assert(slist_nth(l, 1)->data == &data1);
ASSERT_EQUAL(slist_length(l), 2);
ASSERT_EQUAL_PTR(slist_nth(l, 0)->data, &data1);
ASSERT_EQUAL_PTR(slist_nth(l, 1)->data, &data1);
slist_free(l);
}
@@ -105,17 +104,17 @@ int main() {
// slist_index
{
SList* l = NULL;
assert(slist_index(l, NULL) == -1);
assert(slist_index(l, &data1) == -1);
ASSERT_EQUAL(slist_index(l, NULL), -1);
ASSERT_EQUAL(slist_index(l, &data1), -1);
l = slist_append(l, &data1);
assert(slist_index(l, NULL) == -1);
assert(slist_index(l, &data1) == 0);
ASSERT_EQUAL(slist_index(l, NULL), -1);
ASSERT_EQUAL(slist_index(l, &data1), 0);
l = slist_append(l, &data1);
l = slist_append(l, &data2);
assert(slist_index(l, &data1) == 0);
assert(slist_index(l, &data2) == 2);
ASSERT_EQUAL(slist_index(l, &data1), 0);
ASSERT_EQUAL(slist_index(l, &data2), 2);
slist_free(l);
}
@@ -127,7 +126,7 @@ int main() {
l = slist_append(l, &data2);
int count = 0;
slist_foreach(l, list_func, &count);
assert(count == 2);
ASSERT_EQUAL(count, 2);
slist_free(l);
}
@@ -140,11 +139,11 @@ int main() {
l = slist_insert_sorted(l, &data3, compare_func);
l = slist_insert_sorted(l, &data0, compare_func);
l = slist_insert_sorted(l, &data2, compare_func);
assert(slist_length(l) == 4);
assert(slist_nth(l, 0)->data == &data0);
assert(slist_nth(l, 1)->data == &data1);
assert(slist_nth(l, 2)->data == &data2);
assert(slist_nth(l, 3)->data == &data3);
ASSERT_EQUAL(slist_length(l), 4);
ASSERT_EQUAL_PTR(slist_nth(l, 0)->data, &data0);
ASSERT_EQUAL_PTR(slist_nth(l, 1)->data, &data1);
ASSERT_EQUAL_PTR(slist_nth(l, 2)->data, &data2);
ASSERT_EQUAL_PTR(slist_nth(l, 3)->data, &data3);
slist_free(l);
}
+10 -15
View File
@@ -13,21 +13,18 @@ static surface_t *create(int width, int height, int depth, boolean has_pixel, bo
s->width = width;
s->height = height;
s->has_alpha = has_alpha;
s->has_pixel = has_pixel;
s->bytes_per_line = width;
s->bytes_per_pixel = 1;
s->depth = depth;
if (s->has_pixel) {
if (has_pixel) {
switch (s->depth) {
case 8:
s->pixel = calloc(width * (height +1), sizeof(BYTE));
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;
@@ -42,11 +39,9 @@ static surface_t *create(int width, int height, int depth, boolean has_pixel, bo
default:
WARNING("depth %d is not supported\n", s->depth);
}
} else {
s->pixel = NULL;
}
if (s->has_alpha) {
if (has_alpha) {
s->alpha = calloc(width * (height +1), sizeof(BYTE));
}
@@ -57,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) {
@@ -78,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) {
@@ -111,13 +106,13 @@ surface_t *sf_dup(surface_t *in) {
sf = malloc(sizeof(surface_t));
memcpy(sf, in, sizeof(surface_t));
if (in->has_pixel) {
if (in->pixel) {
len = sf->bytes_per_line * sf->height;
sf->pixel = malloc(sizeof(BYTE) * (len + sf->bytes_per_line));
memcpy(sf->pixel, in->pixel, len);
}
if (in->has_alpha) {
if (in->alpha) {
len = sf->width * sf->height;
sf->alpha = malloc(sizeof(BYTE) * (len + sf->width));
memcpy(sf->alpha, in->alpha, len);
@@ -143,12 +138,12 @@ void sf_copyall(surface_t *dst, surface_t *src) {
if (src->bytes_per_pixel != dst->bytes_per_pixel) return;
if (src->has_alpha && dst->has_alpha) {
if (src->alpha && dst->alpha) {
len = src->width * src->height;
memcpy(dst->alpha, src->alpha, len);
}
if (src->has_pixel && dst->has_pixel) {
if (src->pixel && dst->pixel) {
len = src->bytes_per_line * src->height;
memcpy(dst->pixel, src->pixel, len);
}
@@ -170,7 +165,7 @@ surface_t *sf_dup2(surface_t *in, boolean copypixel, boolean copyalpha) {
sf = malloc(sizeof(surface_t));
memcpy(sf, in, sizeof(surface_t));
if (in->has_pixel) {
if (in->pixel) {
len = sf->bytes_per_line * sf->height;
sf->pixel = malloc(sizeof(BYTE) * (len + sf->bytes_per_line));
if (copypixel) {
@@ -178,7 +173,7 @@ surface_t *sf_dup2(surface_t *in, boolean copypixel, boolean copyalpha) {
}
}
if (in->has_alpha) {
if (in->alpha) {
len = sf->width * sf->height;
sf->alpha = malloc(sizeof(BYTE) * (len + sf->width));
if (copyalpha) {
+51 -29
View File
@@ -1,10 +1,20 @@
add_library(src_lib STATIC
gameresource.c
hankaku.c
utfsjis.c
)
target_compile_options(src_lib PRIVATE -Wno-pointer-sign -Wall)
target_include_directories(src_lib PRIVATE .)
if (ANDROID)
add_library(xsystem35 SHARED)
else()
add_executable(xsystem35)
endif()
target_compile_options(xsystem35 PRIVATE -Wno-pointer-sign -Wno-invalid-source-encoding)
target_compile_options(xsystem35 PRIVATE -Wno-pointer-sign $<$<CONFIG:Debug>:-Wall>)
target_include_directories(xsystem35 PRIVATE .)
target_link_libraries(xsystem35 PRIVATE src_lib)
target_sources(xsystem35 PRIVATE
xsystem35.c
@@ -14,8 +24,6 @@ target_sources(xsystem35 PRIVATE
${SRC_AUDIO}
${SRC_CDROM}
${SRC_MIDI}
${SRC_GRAPHDEV}
${SRC_FONT}
${SRC_MENU}
${SRC_JOYSTICK})
@@ -25,9 +33,20 @@ 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)
if (HAVE_JPEG)
target_sources(xsystem35 PRIVATE jpeg.c)
if (NOT EMSCRIPTEN)
target_link_libraries(xsystem35 PRIVATE JPEG::JPEG)
endif()
endif()
# Music
target_sources(xsystem35 PRIVATE
@@ -35,25 +54,32 @@ target_sources(xsystem35 PRIVATE
# Misc
target_sources(xsystem35 PRIVATE
LittleEndian.c counter.c input.c profile.c mt19937-1.c utfsjis.c
filecheck.c)
LittleEndian.c counter.c input.c profile.c mt19937-1.c filecheck.c mmap.c)
# Scenario
target_sources(xsystem35 PRIVATE
cali.c scenario.c variable.c cmd_check.c hankana2sjis.c nact.c
selection.c message.c savedata.c hankaku.c s39ain.c texthook.c)
cali.c scenario.c variable.c cmd_check.c nact.c
selection.c message.c savedata.c s39ain.c texthook.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 flood.c cg.c ecopy.c antialiase.c alpha_plane.c cursor.c)
# Network
target_sources(xsystem35 PRIVATE
network.c)
if (WIN32)
target_sources(xsystem35 PRIVATE win/dialog.c win/resources.rc)
endif()
if (EMSCRIPTEN)
set(LIBS "SHELL:-s USE_ZLIB=1 -s USE_FREETYPE=1 -s USE_SDL=2")
set(LIBS
"SHELL:-s USE_ZLIB=1"
"SHELL:-s USE_LIBJPEG=1"
"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)
@@ -68,7 +94,7 @@ if (EMSCRIPTEN)
"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','getMemory','addRunDependency','removeRunDependency']\"")
"SHELL:-s EXTRA_EXPORTED_RUNTIME_METHODS=\"['getValue','addRunDependency','removeRunDependency']\"")
elseif (ANDROID)
@@ -76,35 +102,31 @@ 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()
target_link_libraries(xsystem35 PRIVATE PkgConfig::SDL2)
target_link_libraries(xsystem35 PRIVATE PkgConfig::SDL2TTF)
if (GTK2_FOUND)
target_link_libraries(xsystem35 PRIVATE GTK2::gtk)
endif()
if (FREETYPE_FOUND)
target_link_libraries(xsystem35 PRIVATE Freetype::Freetype)
endif()
if (SDL2_FOUND)
target_link_libraries(xsystem35 PRIVATE PkgConfig::SDL2)
endif()
if (SDL2MIXER_FOUND)
target_link_libraries(xsystem35 PRIVATE PkgConfig::SDL2MIXER)
endif()
if (SDL2TTF_FOUND)
target_link_libraries(xsystem35 PRIVATE PkgConfig::SDL2TTF)
endif()
install(TARGETS xsystem35 RUNTIME DESTINATION bin)
add_executable(src_tests
src_tests.c
gameresource_test.c
hankaku_test.c
)
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)
add_custom_target(sdl_input.c
COMMAND perl xsyskey.pl ${SDL2_INCLUDE_DIRS} > sdl_input.c
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})
endif()
+99 -115
View File
@@ -31,7 +31,7 @@
#include "portab.h"
#include "xsystem35.h"
#include "ags.h"
#include "graphicsdevice.h"
#include "sdl_core.h"
#include "alpha_plane.h"
#include "counter.h"
#include "utfsjis.h"
@@ -45,15 +45,15 @@
#define check_param_xy ags_check_param_xy
#define intersection ags_intersection
static void initPal(Pallet256 *sys_pal);
static void initPal(Palette256 *sys_pal);
static boolean intersects(MyRectangle *r1, MyRectangle *r2);
static Pallet256 pal_256;
static Palette256 pal_256;
static boolean need_update = TRUE;
static boolean fade_outed = FALSE;
static int cursor_move_time = 50; /* カーソル移動にかかる時間(ms) */
static void initPal(Pallet256 *pal) {
static void initPal(Palette256 *pal) {
int i;
for (i = 0; i < 256; i++) {
pal->red[i] = 0; pal->green[i] = 0; pal->blue[i] = 0;
@@ -62,7 +62,7 @@ static void initPal(Pallet256 *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;
SetPallet(pal, 0, 256);
sdl_setPalette(pal, 0, 256);
nact->sys_pal_changed = TRUE;
}
@@ -137,38 +137,35 @@ void ags_init() {
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);
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) {
nact->sys_world_size.width = width;
nact->sys_world_size.height = height;
nact->sys_world_depth = depth;
SetWorldSize(width, height, depth);
if (nact->ags.dib && nact->ags.dib->alpha) {
free(nact->ags.dib->alpha);
nact->ags.dib->alpha = NULL;
}
sdl_setWorldSize(width, height, depth);
nact->ags.dib = GetDIB();
nact->ags.dib->has_alpha = FALSE;
nact->ags.dib->has_pixel = TRUE;
nact->ags.dib = sdl_getDIB();
/* DIBが8以上の場合は、alpha plane を用意 */
if (depth > 8) {
if (nact->ags.dib->alpha != NULL) {
free(nact->ags.dib->alpha);
}
if (depth > 8)
nact->ags.dib->alpha = calloc(width * height, sizeof(BYTE));
nact->ags.dib->has_alpha = TRUE;
}
fade_outed = FALSE; /* thanx tajiri@wizard */
@@ -181,21 +178,21 @@ void ags_setViewArea(int x, int y, int width, int height) {
nact->sys_view_area.width = width;
nact->sys_view_area.height = height;
SetWindowSize(x, y, width, height);
sdl_setWindowSize(x, y, width, height);
}
void ags_setWindowTitle(char *src) {
void ags_setWindowTitle(const char *src) {
#define TITLEHEAD "XSystem35 Version "VERSION":"
BYTE *dst, *d;
BYTE *utf, *d;
dst = sjis2lang(src);
if (NULL == (d = malloc(strlen(dst) + strlen(TITLEHEAD) + 1))) {
utf = toUTF8(src);
if (NULL == (d = malloc(strlen(utf) + strlen(TITLEHEAD) + 1))) {
NOMEMERR();
}
strcpy(d, TITLEHEAD);
strcat(d, dst);
SetWindowTitle(d);
free(dst);
strcat(d, utf);
sdl_setWindowTitle(d);
free(utf);
free(d);
}
@@ -206,13 +203,13 @@ void ags_getDIBInfo(DispInfo *info) {
}
void ags_getViewAreaInfo(DispInfo *info) {
GetWindowInfo(info);
sdl_getWindowInfo(info);
info->width = nact->sys_view_area.width;
info->height = nact->sys_view_area.height;
}
void ags_getWindowInfo(DispInfo *info) {
GetWindowInfo(info);
sdl_getWindowInfo(info);
}
void ags_setExposeSwitch(boolean bool) {
@@ -231,7 +228,7 @@ void ags_updateArea(int x, int y, int w, int h) {
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);
sdl_updateArea(&update, &p);
}
}
}
@@ -247,11 +244,11 @@ void ags_updateFull() {
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_setPallets(Pallet256 *src_pal, int src, int dst, int cnt) {
void ags_setPalettes(Palette256 *src_pal, int src, int dst, int cnt) {
int i;
for (i = 0; i < cnt; i++) {
nact->sys_pal->red [dst + i] = src_pal->red [src + i];
@@ -261,58 +258,56 @@ void ags_setPallets(Pallet256 *src_pal, int src, int dst, int cnt) {
nact->sys_pal_changed = TRUE;
}
void ags_setPallet(int no, int red, int green, int blue) {
void ags_setPalette(int no, int red, int green, int blue) {
nact->sys_pal->red[no] = red;
nact->sys_pal->green[no] = green;
nact->sys_pal->blue[no] = blue;
nact->sys_pal_changed = TRUE;
}
void ags_setPalletToSystem(int src, int cnt) {
void ags_setPaletteToSystem(int src, int cnt) {
if (!fade_outed)
SetPallet(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) {
@@ -320,15 +315,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, Pallet *cell) {
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) {
@@ -336,7 +329,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;
@@ -357,8 +349,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) {
@@ -366,8 +357,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) {
@@ -375,8 +365,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) {
@@ -385,28 +374,48 @@ 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, char *src, int col) {
int ags_drawString(int x, int y, const char *src, int col) {
int w;
if (!check_param_xy(&x, &y)) return 0;
DspDeviceSync();
w = DrawString(x, y, src, col);
char *utf8 = toUTF8(src);
w = sdl_drawString(x, y, utf8, col);
free(utf8);
return w;
}
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);
fs = font_get_glyph(utf8);
free(utf8);
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) {
int sx, sy, w, h;
@@ -418,8 +427,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) {
@@ -433,8 +441,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) {
@@ -443,8 +450,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) {
@@ -453,8 +459,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) {
@@ -463,8 +468,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) {
@@ -473,8 +477,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) {
@@ -483,8 +486,7 @@ 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);
}
@@ -529,8 +531,6 @@ MyRectangle* ags_imageFlood(int x, int y, int c) {
if (!check_param_xy(&x, &y)) return NULL;
DspDeviceSync();
{
agsurface_t *dib = nact->ags.dib;
BYTE *dst = GETOFFSET_PIXEL(dib, x, y);
@@ -564,8 +564,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) {
@@ -574,8 +573,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) {
@@ -622,12 +620,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;
@@ -655,7 +652,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 残り時間 */
@@ -705,7 +702,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);
}
@@ -723,7 +720,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);
}
@@ -740,7 +737,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);
}
@@ -757,18 +754,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) {
@@ -793,7 +790,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;
@@ -806,7 +803,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;
@@ -817,17 +814,17 @@ void ags_setCursorLocation(int x, int y, boolean is_dibgeo) {
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;
return font_get_antialias();
}
void ags_fullscreen(boolean on) {
nact->sys_fullscreen_on = on;
FullScreen(on);
sdl_FullScreen(on);
}
void ags_copyArea_shadow_withrate(int sx, int sy, int w, int h, int dx, int dy, int lv) {
@@ -838,8 +835,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) {
@@ -857,25 +853,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);
}
+48 -125
View File
@@ -29,23 +29,21 @@
#include "portab.h"
#include "cg.h"
#include "graphics.h"
#include "font.h"
/* マウスカーソルの種類 */
#define IDC_ARROW 1
#define IDC_CROSS 2
#define IDC_IBEAM 3
#define IDC_ICON 4
#define IDC_NO 5
#define IDC_SIZE 6
#define IDC_SIZEALL 7
#define IDC_SIZENESW 8
#define IDC_SIZENS 9
#define IDC_SIZENWSE 10
#define IDC_SIZEWE 11
#define IDC_UPARROW 12
#define IDC_WAIT 13
#define CURSOR_ARROW 1
#define CURSOR_CROSS 2
#define CURSOR_IBEAM 3
#define CURSOR_ICON 4
#define CURSOR_NO 5
#define CURSOR_SIZE 6
#define CURSOR_SIZEALL 7
#define CURSOR_SIZENESW 8
#define CURSOR_SIZENS 9
#define CURSOR_SIZENWSE 10
#define CURSOR_SIZEWE 11
#define CURSOR_UPARROW 12
#define CURSOR_WAIT 13
/* RGB <-> alpha plane copy type */
typedef enum {
@@ -62,26 +60,23 @@ typedef enum {
} ALPHA_DIB_COPY_TYPE;
struct agsurface {
int no; /* surface number, primary DIB is 0 */
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 */
BYTE *pixel; /* pointer to pixel data */
BYTE *alpha; /* pointer to alpha pixel data */
boolean has_alpha;
boolean has_pixel;
BYTE *pixel; /* pixel data (can be NULL) */
BYTE *alpha; /* alpha pixel data (can be NULL) */
};
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;
@@ -118,8 +113,8 @@ typedef struct ags_faderinfo ags_faderinfo_t;
struct _ags {
Pallet256 pal; /* system pallet */
boolean pal_changed; /* system pallet has changed */
Palette256 pal; /* system palette */
boolean pal_changed; /* system palette has changed */
MyDimension world_size; /* size of off-screen */
@@ -135,8 +130,6 @@ struct _ags {
boolean fullscree_is_on; /* if full-screen mode then true */
FONT *font; /* font device */
agsurface_t *dib; /* main surface */
void (*eventcb)(agsevent_t *e); /* deliver event */
};
@@ -151,7 +144,7 @@ extern void ags_remove();
/* ウィンド関係 */
extern void ags_setWorldSize(int width, int height, int depth);
extern void ags_setViewArea(int x, int y, int width, int height);
extern void ags_setWindowTitle(char *str);
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);
@@ -161,7 +154,6 @@ 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);
@@ -169,14 +161,13 @@ extern void ags_updateFull(void);
extern void ags_updateArea(int x, int y, int width, int height);
/* パレット関係 */
extern void ags_setPallets(Pallet256 *src_pal, int src, int dst, int cnt);
extern void ags_setPallet(int no, int red, int green, int blue);
extern void ags_setPalletToSystem(int src, int cnt);
extern void ags_setPalettes(Palette256 *src_pal, int src, int dst, int cnt);
extern void ags_setPalette(int no, int red, int green, int blue);
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);
@@ -185,7 +176,7 @@ extern void ags_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, int col
extern void ags_copyArea_shadow_withrate(int sx, int sy, int w, int h, int dx, int dy, int lv);
extern void ags_wrapColor(int x, int y, int w, int h, int p1, int p2);
extern void ags_getPixel(int x, int y, Pallet *cell);
extern void ags_getPixel(int x, int y, Palette *cell);
extern void ags_changeColorArea(int x, int y, int w, int h, int dst, int src, int cnt);
extern void* ags_saveRegion(int x, int y, int w, int h);
@@ -194,7 +185,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, char *src, int col);
extern int 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);
@@ -224,7 +215,12 @@ extern void ags_whiteOut(int rate, boolean flg);
extern void ags_fader_callback();
/* フォント関連 */
enum FontType {
FONT_GOTHIC,
FONT_MINCHO,
};
extern void ags_setFont(int type, int size);
extern agsurface_t *ags_drawStringToSurface(const char *str);
/* カーソル関係 */
extern void ags_setCursorType(int type);
@@ -239,102 +235,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)
@@ -348,7 +272,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)));
+6 -8
View File
@@ -101,14 +101,12 @@ void ald_freedata(dridata *data) {
* type: data type
* file: file name array
* cnt : number in file name array
* mmap: mmap file or not
*/
void ald_init(int type, char **file, int cnt, boolean mmap) {
/* check wrong type */
if (type < DRIFILETYPEMAX) {
dri[type] = dri_init(file, cnt, mmap);
if (!dri[type]->mmapped) {
cacheid = cache_new(ald_free);
}
void ald_init(int type, const char **file, int cnt) {
if (type >= DRIFILETYPEMAX || cnt <= 0)
return;
dri[type] = dri_init(file, cnt);
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, char **file, int cnt, boolean mmap);
extern void ald_init(int type, const char **file, int cnt);
extern dridata *ald_getdata(DRIFILETYPE type, int no);
extern void ald_freedata(dridata *data);
+8 -29
View File
@@ -36,7 +36,7 @@
* static methods
*/
static bmp_header *extract_header(BYTE *b);
static void getpal(Pallet256 *pal, BYTE *b);
static void getpal(Palette256 *pal, BYTE *b);
static void extract_8bit(bmp_header *bmp, BYTE *pic, BYTE *b);
static void extract_24bit(bmp_header *bmp, WORD *pic, BYTE *b);
@@ -64,11 +64,11 @@ static bmp_header *extract_header(BYTE *b) {
}
/*
* Get pallet from raw data
* pal: pallet to be stored
* b : raw data (pointer to pallet)
* Get palette from raw data
* pal: palette to be stored
* b : raw data (pointer to palette)
*/
static void getpal(Pallet256 *pal, BYTE *b) {
static void getpal(Palette256 *pal, BYTE *b) {
int i;
for (i = 0; i < 256; i++) {
@@ -160,7 +160,7 @@ boolean bmp256_checkfmt(BYTE *data) {
}
/*
* Extract 8bit bmp, header, pallet and pixel
* Extract 8bit bmp, header, palette and pixel
* data: raw data (pointer to data top)
* return: extracted image data and information
*/
@@ -168,7 +168,7 @@ cgdata *bmp256_extract(BYTE *data) {
bmp_header *bmp = extract_header(data);
cgdata *cg = calloc(1, sizeof(cgdata));
cg->pal = malloc(sizeof(Pallet256));
cg->pal = malloc(sizeof(Palette256));
getpal(cg->pal, data + bmp->bmpPp);
/* +10: margin for broken cg */
@@ -208,7 +208,7 @@ boolean bmp16m_checkfmt(BYTE *data) {
}
/*
* Extract 24bit bmp, header, pallet and pixel
* Extract 24bit bmp, header, palette and pixel
* data: raw data (pointer to data top)
* return: extracted image data and information
*/
@@ -232,24 +232,3 @@ cgdata *bmp16m_extract(BYTE *data) {
return cg;
}
/*
* Extract bmp pallet only
* data: raw data (pointer to data top)
* return: extracted pallet data
*/
cgdata *bmp_getpal(BYTE *data) {
cgdata *cg = calloc(1, sizeof(cgdata));
bmp_header *bmp = extract_header(data);
cg->pal = malloc(sizeof(Pallet256));
getpal(cg->pal, data + bmp->bmpPp);
cg->type = ALCG_BMP8;
cg->pic = NULL;
cg->alpha = NULL;
free(bmp);
return cg;
}
-1
View File
@@ -50,6 +50,5 @@ extern boolean bmp256_checkfmt(BYTE *data);
extern cgdata *bmp256_extract(BYTE *data);
extern boolean bmp16m_checkfmt(BYTE *data);
extern cgdata *bmp16m_extract(BYTE *data);
extern cgdata *bmp_getpal(BYTE *data);
#endif /* !__BMP__ */
+19 -28
View File
@@ -64,52 +64,44 @@ static int *fixOffset(int base, int offset2) {
int page, offset;
int *index;
preVarPage = (sysVarAttribute + base) -> page;
preVarPage = sysVarAttribute[base].page;
preVarNo = base;
if ((sysVarAttribute + base) -> page == 0) {
if (sysVarAttribute[base].page == 0) {
if (offset2 == -1) {
#ifdef DEBUG_CHECKALING
if (base >= SYSVAR_MAX) {
WARNING("sysVar[no] ArrayIndexOutofException (%d, %d)\n", base, offset2);
WARNING("%03d:%05x: ArrayIndexOutOfBounds (%d, %d)\n", sl_getPage(), sl_getIndex(), base, offset2);
return NULL;
}
#endif
preVarIndex = base;
return sysVar + base;
} else {
#ifdef DEBUG_CHECKALING
if ((base + offset2) >= SYSVAR_MAX) {
WARNING("sysVar[no] ArrayIndexOutofException (%d, %d)\n", base, offset2);
WARNING("%03d:%05x: ArrayIndexOutOfBounds (%d, %d)\n", sl_getPage(), sl_getIndex(), base, offset2);
return NULL;
}
#endif
preVarIndex = base + offset2;
return sysVar + base + offset2;
}
} else {
if (offset2 == -1) {
index = (sysVarAttribute + base) -> pointvar;
page = (sysVarAttribute + base) -> page;
offset = (sysVarAttribute + base) -> offset;
#ifdef DEBUG_CHECKALING
if ((*index) + offset > (arrayVarBuffer + page - 1)->max) {
WARNING("sysVar[no] ArrayIndexOutofException (%d, %d, %d, %d, %d)\n", base, offset2, *index, page, offset);
index = sysVarAttribute[base].pointvar;
page = sysVarAttribute[base].page;
offset = sysVarAttribute[base].offset;
if (*index + offset >= arrayVarBuffer[page - 1].size) {
WARNING("%03d:%05x: ArrayIndexOutOfBounds (%d, %d, %d, %d, %d)\n", sl_getPage(), sl_getIndex(), base, offset2, *index, page, offset);
return NULL;
}
#endif
preVarIndex = offset + (*index);
return ((arrayVarBuffer + page - 1) -> value) + offset + (*index);
preVarIndex = offset + *index;
return arrayVarBuffer[page - 1].value + offset + *index;
} else {
page = (sysVarAttribute + base) -> page;
offset = (sysVarAttribute + base) -> offset;
#ifdef DEBUG_CHECKALING
if (offset + offset2 > (arrayVarBuffer + page - 1)->max) {
WARNING("sysVar[no] ArrayIndexOutofException (%d, %d, %d, %d)\n", base, offset2, page, offset);
page = sysVarAttribute[base].page;
offset = sysVarAttribute[base].offset;
if (offset + offset2 >= arrayVarBuffer[page - 1].size) {
WARNING("%03d:%05x: ArrayIndexOutOfBounds (%d, %d, %d, %d)\n", sl_getPage(), sl_getIndex(), base, offset2, page, offset);
return NULL;
}
#endif
preVarIndex = offset + offset2;
return ((arrayVarBuffer + page - 1) -> value) + offset + offset2;
return arrayVarBuffer[page - 1].value + offset + offset2;
}
}
}
@@ -203,8 +195,7 @@ int getCaliValue() {
}
l_var:
t = getVar(c0);
if (t == NULL) continue;
*cali = *t; cali++;
*cali++ = t ? *t : 0;
} else {
switch(c0) {
case 0x7e: /* != */
@@ -304,12 +295,12 @@ int getCaliValue() {
}
}
c0 = *--cali;
#ifdef DEBUG_CHECKALING
if (cali != bufc) {
WARNING("Something is wrong @ %03d:%05x\n", sl_getPage(), sl_getIndex());
cali = bufc;
return 0;
}
#endif
return c0;
}
+3 -6
View File
@@ -208,7 +208,7 @@ int cdrom_getPlayingInfo (cd_time *info) {
struct cd_sub_channel_info data;
if (!enabled)
goto errexit;
return NG;
memset(&s, 0, sizeof(s));
s.data = &data;
@@ -217,17 +217,14 @@ int cdrom_getPlayingInfo (cd_time *info) {
s.data_format = CD_CURRENT_POSITION;
if (do_ioctl(CDIOCREADSUBCHANNEL, &s) < 0) {
perror("CDIOCREADSUBCHANNEL");
goto errexit;
return NG;
}
if (s.data->header.audio_status != CD_AS_PLAY_IN_PROGRESS) {
goto errexit;
return NG;
}
info->t = s.data->what.position.track_number;
info->m = s.data->what.position.reladdr.msf.minute;
info->s = s.data->what.position.reladdr.msf.second;
info->f = s.data->what.position.reladdr.msf.frame;
return OK;
errexit:
info->t = info->m = info->s = info->f = 999;
return NG;
}
+4 -7
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;
@@ -241,22 +241,19 @@ static int cdrom_getPlayingInfo (cd_time *info) {
struct cdrom_subchnl sc;
if (!enabled)
goto errexit;
return NG;
sc.cdsc_format = CDROM_MSF;
if (do_ioctl(CDROMSUBCHNL, &sc) < 0) {
perror("CDROMSUBCHNL");
goto errexit;
return NG;
}
if (sc.cdsc_audiostatus != CDROM_AUDIO_PLAY) {
goto errexit;
return NG;
}
info->t = sc.cdsc_trk;
info->m = sc.cdsc_reladdr.msf.minute;
info->s = sc.cdsc_reladdr.msf.second;
info->f = sc.cdsc_reladdr.msf.frame;
return OK;
errexit:
info->t = info->m = info->s = info->f = 999;
return NG;
}
+3 -5
View File
@@ -92,18 +92,16 @@ int cd_init(cdromdevice_t *cd) {
memcpy(cd, DEV_PLAY_MODE, sizeof(cdromdevice_t));
ret = cd->init(dev);
}
else {
#ifdef ENABLE_CDROM_MP3
else if (S_ISREG(st.st_mode)) {
/* MP3 MODE */
memcpy(cd, &cdrom_mp3, sizeof(cdromdevice_t));
ret = cd->init(dev);
memcpy(cd, &cdrom_mp3, sizeof(cdromdevice_t));
}
#endif
else {
#else
/* error */
WARNING("no cdrom device available\n");
ret = NG;
#endif
}
return ret;
#endif // ENABLE_CDROM_EMSCRIPTEN || ENABLE_CDROM_ANDROID

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