mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-09-22 22:48:08 +03:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5bd4622031 | ||
|
|
c7c0f69ec4 | ||
|
|
f38a3eda5c | ||
|
|
dc17b78365 | ||
|
|
b9f68eedd3 | ||
|
|
adf362ea57 | ||
|
|
b5bf439b8e | ||
|
|
9a01d28075 | ||
|
|
945dbd7722 | ||
|
|
1c54487041 | ||
|
|
92389289da | ||
|
|
4de03cc77f | ||
|
|
5a81ac6fc8 | ||
|
|
d7bac22059 | ||
|
|
8d4424061d |
@@ -42,7 +42,7 @@ jobs:
|
||||
ls /${{ matrix.sys }}/share/licenses
|
||||
mkdir dist
|
||||
cp -r /${{ matrix.sys }}/share/licenses dist/
|
||||
cp fonts/*.license dist/licenses/
|
||||
cp licenses/* dist/licenses/
|
||||
|
||||
- name: Install dev dependencies
|
||||
run: pacboy --noconfirm -S --needed gcc:p cmake:p ninja:p asciidoctor:p
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## 2.16.0 - 2024-06-13
|
||||
- Fixed map tile color issue in Graymerca (#67)
|
||||
- Windows: Implemented number input dialog for the `NI` command (#68)
|
||||
- Android: Added "Clear Save Files" launcher menu command
|
||||
|
||||
## 2.15.1 - 2024-05-14
|
||||
- Fixed a text rendering issue in Rance 5D (#66)
|
||||
|
||||
|
||||
+2
-7
@@ -1,16 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
# Rebuild external projects when download URL changes
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
|
||||
cmake_policy(SET CMP0135 NEW)
|
||||
endif()
|
||||
cmake_minimum_required(VERSION 3.13...4.0)
|
||||
|
||||
project(xsystem35 LANGUAGES C)
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
enable_testing()
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
|
||||
|
||||
set(XSYSTEM35_VERSION "2.15.1")
|
||||
set(XSYSTEM35_VERSION "2.16.0")
|
||||
|
||||
include(CheckSymbolExists)
|
||||
include(FetchContent)
|
||||
|
||||
@@ -16,8 +16,8 @@ android {
|
||||
defaultConfig {
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 34
|
||||
versionCode 34
|
||||
versionName "2.15.1" + gitRevision()
|
||||
versionCode 35
|
||||
versionName "2.16.0" + gitRevision()
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments "-DANDROID_APP_PLATFORM=android-19", "-DANDROID_STL=c++_static"
|
||||
|
||||
@@ -44,8 +44,9 @@ file(MAKE_DIRECTORY ${ASSETS_DIR}/licenses)
|
||||
file(COPY_FILE ${PROJECT_ROOT_DIR}/fonts/MTLc3m.ttf ${ASSETS_DIR}/MTLc3m.ttf)
|
||||
file(COPY_FILE ${PROJECT_ROOT_DIR}/fonts/mincho.otf ${ASSETS_DIR}/mincho.otf)
|
||||
file(COPY_FILE ${PROJECT_ROOT_DIR}/COPYING ${ASSETS_DIR}/licenses/xsystem35)
|
||||
file(COPY_FILE ${PROJECT_ROOT_DIR}/fonts/MTLc3m.ttf.license ${ASSETS_DIR}/licenses/MTLc3m)
|
||||
file(COPY_FILE ${PROJECT_ROOT_DIR}/fonts/mincho.otf.license ${ASSETS_DIR}/licenses/mincho)
|
||||
file(COPY_FILE ${PROJECT_ROOT_DIR}/licenses/MTLc3m.txt ${ASSETS_DIR}/licenses/MTLc3m)
|
||||
file(COPY_FILE ${PROJECT_ROOT_DIR}/licenses/mincho.txt ${ASSETS_DIR}/licenses/mincho)
|
||||
file(COPY_FILE ${PROJECT_ROOT_DIR}/licenses/nanojpeg.txt ${ASSETS_DIR}/licenses/nanojpeg)
|
||||
file(COPY_FILE ${sdl_SOURCE_DIR}/LICENSE.txt ${ASSETS_DIR}/licenses/SDL)
|
||||
file(COPY_FILE ${sdl_ttf_SOURCE_DIR}/LICENSE.txt ${ASSETS_DIR}/licenses/SDL_ttf)
|
||||
file(COPY_FILE ${sdl_ttf_SOURCE_DIR}/external/freetype/docs/GPLv2.TXT ${ASSETS_DIR}/licenses/freetype)
|
||||
|
||||
@@ -253,6 +253,14 @@ class Launcher private constructor(private val rootDir: File) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun clearSaveData(): Boolean {
|
||||
var success = true
|
||||
File(rootDir, SAVE_DIR).listFiles()?.forEach { file ->
|
||||
if (!file.deleteRecursively()) success = false
|
||||
}
|
||||
return success
|
||||
}
|
||||
}
|
||||
|
||||
private fun forEachZipEntry(input: InputStream, action: (ZipEntry, ZipInputStream) -> Unit): Boolean {
|
||||
|
||||
@@ -82,7 +82,7 @@ class LauncherActivity : Activity(), LauncherObserver {
|
||||
}
|
||||
|
||||
private fun onItemLongClick(position: Int): Boolean {
|
||||
AlertDialog.Builder(this).setTitle(R.string.uninstall_dialog_title)
|
||||
AlertDialog.Builder(this).setTitle(R.string.confirm)
|
||||
.setMessage(getString(R.string.uninstall_dialog_message, launcher.games[position].title))
|
||||
.setPositiveButton(R.string.ok) {_, _ -> uninstall(position)}
|
||||
.setNegativeButton(R.string.cancel) {_, _ -> }
|
||||
@@ -117,6 +117,21 @@ class LauncherActivity : Activity(), LauncherObserver {
|
||||
SAVEDATA_IMPORT_REQUEST)
|
||||
true
|
||||
}
|
||||
R.id.clear_savedata -> {
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle(R.string.confirm)
|
||||
.setMessage(R.string.clear_save_data_confirm)
|
||||
.setPositiveButton(R.string.ok) { _, _ ->
|
||||
if (launcher.clearSaveData()) {
|
||||
Toast.makeText(this, R.string.save_data_clear_success, Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
errorDialog(R.string.save_data_clear_error)
|
||||
}
|
||||
}
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show()
|
||||
true
|
||||
}
|
||||
R.id.help -> {
|
||||
AlertDialog.Builder(this)
|
||||
.setMessage(Html.fromHtml(getString(R.string.usage)))
|
||||
|
||||
@@ -13,6 +13,7 @@ class LicensesMenuActivity : Activity() {
|
||||
Entry("SDL", "SDL", "https://www.libsdl.org/"),
|
||||
Entry("SDL_mixer", "SDL_mixer", "https://github.com/libsdl-org/SDL_mixer"),
|
||||
Entry("SDL_ttf", "SDL_ttf", "https://github.com/libsdl-org/SDL_ttf"),
|
||||
Entry("NanoJPEG", "nanojpeg", "https://keyj.emphy.de/nanojpeg/"),
|
||||
Entry("FreeType", "freetype", "https://freetype.org/"),
|
||||
Entry("HarfBuzz", "harfbuzz", "https://harfbuzz.github.io/"),
|
||||
Entry("MotoyaLCedar W3 mono", "MTLc3m", "https://github.com/aosp-mirror/platform_frameworks_base/tree/lollipop-release/data/fonts"),
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
<item
|
||||
android:id="@+id/import_savedata"
|
||||
android:title="@string/action_import_save_data" />
|
||||
<item
|
||||
android:id="@+id/clear_savedata"
|
||||
android:title="@string/action_clear_save_data" />
|
||||
<item
|
||||
android:id="@+id/help"
|
||||
android:title="@string/action_help" />
|
||||
|
||||
@@ -6,9 +6,12 @@
|
||||
<string name="action_import_save_data">セーブデータをインポート</string>
|
||||
<string name="action_install_from_zip">ZIPからインストール</string>
|
||||
<string name="action_licenses">オープンソースライセンス</string>
|
||||
<string name="action_clear_save_data">セーブデータをクリア</string>
|
||||
<string name="cancel">キャンセル</string>
|
||||
<string name="cannot_find_ald">System 3.x のファイル (*.ald) が見つかりません。</string>
|
||||
<string name="choose_a_file">ファイルを選択</string>
|
||||
<string name="clear_save_data_confirm">セーブデータをすべて削除します。元には戻せません。本当によろしいですか?</string>
|
||||
<string name="confirm">確認</string>
|
||||
<string name="error_dialog_title">エラー</string>
|
||||
<string name="install_dialog_title">インストール中…</string>
|
||||
<string name="install_progress">%s を展開中</string>
|
||||
@@ -16,8 +19,9 @@
|
||||
<string name="save_data_export_error">セーブデータのエクスポートに失敗しました。</string>
|
||||
<string name="save_data_export_success">エクスポートに成功しました。</string>
|
||||
<string name="save_data_import_success">インポートに成功しました。</string>
|
||||
<string name="save_data_clear_success">セーブデータをクリアしました。</string>
|
||||
<string name="save_data_clear_error">セーブデータのクリアに失敗しました。</string>
|
||||
<string name="uninstall_dialog_message">「%s」をアンインストールしますか?</string>
|
||||
<string name="uninstall_dialog_title">確認</string>
|
||||
<string name="unsupported_zip">この形式の ZIP はサポートしていません。</string>
|
||||
<string name="zip_extraction_error">ZIP の展開に失敗しました。</string>
|
||||
<string name="usage">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<resources>
|
||||
<string name="app_name">xsystem35</string>
|
||||
<string name="action_clear_save_data">Clear Save Files</string>
|
||||
<string name="action_export_save_data">Export Save Files</string>
|
||||
<string name="action_help">Help</string>
|
||||
<string name="action_import_save_data">Import Save Files</string>
|
||||
@@ -8,16 +9,19 @@
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="cannot_find_ald">Cannot find System 3.x game files (*.ald).</string>
|
||||
<string name="choose_a_file">Choose a file</string>
|
||||
<string name="clear_save_data_confirm">Are you sure you want to clear all save files? This cannot be undone.</string>
|
||||
<string name="confirm">Confirm</string>
|
||||
<string name="error_dialog_title">Error</string>
|
||||
<string name="install_dialog_title">Installing…</string>
|
||||
<string name="install_progress">Extracting %s</string>
|
||||
<string name="no_data_to_import">No save/ folder in the ZIP archive.</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="save_data_clear_error">Failed to clear save files.</string>
|
||||
<string name="save_data_clear_success">Save files cleared.</string>
|
||||
<string name="save_data_export_error">Failed to export save files.</string>
|
||||
<string name="save_data_import_success">Imported successfully.</string>
|
||||
<string name="save_data_export_success">Exported successfully.</string>
|
||||
<string name="uninstall_dialog_message">Uninstall \"%s\"?</string>
|
||||
<string name="uninstall_dialog_title">Confirm</string>
|
||||
<string name="unsupported_zip">This type of ZIP is not supported.</string>
|
||||
<string name="zip_extraction_error">Failed to extract ZIP.</string>
|
||||
<string name="usage">
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
install(FILES
|
||||
MTLc3m.ttf
|
||||
MTLc3m.ttf.license
|
||||
mincho.otf
|
||||
mincho.otf.license
|
||||
DESTINATION share/xsystem35/fonts)
|
||||
|
||||
# pyftsubset is included in fonttools.
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// NanoJPEG -- KeyJ's Tiny Baseline JPEG Decoder
|
||||
// version 1.3.5 (2016-11-14)
|
||||
// Copyright (c) 2009-2016 Martin J. Fiedler <martin.fiedler@gmx.net>
|
||||
// published under the terms of the MIT license
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
+4
-4
@@ -33,7 +33,7 @@
|
||||
#include "ags.h"
|
||||
#include "pms.h"
|
||||
#include "qnt.h"
|
||||
#include "sdl_core.h"
|
||||
#include "gfx.h"
|
||||
#include "ngraph.h"
|
||||
#include "dri.h"
|
||||
#include "ald_manager.h"
|
||||
@@ -73,21 +73,21 @@ static surface_t *sf_getcg(void *b, size_t size) {
|
||||
cg->alpha = cg->pic;
|
||||
cg->pic = NULL;
|
||||
sf = sf_create_alpha(cg->width, cg->height);
|
||||
sdl_drawImageAlphaMap(cg, sf, 0, 0);
|
||||
gfx_drawImageAlphaMap(cg, sf, 0, 0);
|
||||
break;
|
||||
case ALCG_PMS16:
|
||||
cg = pms64k_extract(b);
|
||||
sf = cg->alpha
|
||||
? sf_create_surface(cg->width, cg->height)
|
||||
: sf_create_pixel(cg->width, cg->height);
|
||||
sdl_drawImage16(cg, sf, 0, 0, 255, false);
|
||||
gfx_drawImage16(cg, sf, 0, 0, 255, false);
|
||||
break;
|
||||
case ALCG_QNT:
|
||||
cg = qnt_extract(b);
|
||||
sf = cg->alpha
|
||||
? sf_create_surface(cg->width, cg->height)
|
||||
: sf_create_pixel(cg->width, cg->height);
|
||||
sdl_drawImage24(cg, sf, 0, 0, 255);
|
||||
gfx_drawImage24(cg, sf, 0, 0, 255);
|
||||
break;
|
||||
default:
|
||||
WARNING("Unknown Cg Type");
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "surface.h"
|
||||
#include "sdl_core.h"
|
||||
#include "effect.h"
|
||||
#include "ags.h"
|
||||
#include "input.h"
|
||||
#include "graph.h"
|
||||
@@ -24,17 +24,17 @@ void gpx_effect(int no,
|
||||
|
||||
*endtype = 0;
|
||||
|
||||
enum sdl_effect_type type = from_sact_effect(no);
|
||||
enum effect_type type = from_sact_effect(no);
|
||||
if (type == EFFECT_INVALID) {
|
||||
WARNING("Unimplemented effect %d", no);
|
||||
type = EFFECT_CROSSFADE;
|
||||
}
|
||||
SDL_Rect rect = { wx, wy, width, height };
|
||||
struct sdl_effect *eff = sdl_effect_init(&rect, dst, dx, dy, src, sx, sy, type);
|
||||
struct effect *eff = effect_init(&rect, dst, dx, dy, src, sx, sy, type);
|
||||
if (!time)
|
||||
time = (no == SACT_EFFECT_CROSSFADE_DOWN || no == SACT_EFFECT_CROSSFADE_UP) ? 1150 : 2700;
|
||||
ags_runEffect(time, false, (ags_EffectStepFunc)sdl_effect_step, eff);
|
||||
sdl_effect_finish(eff);
|
||||
ags_runEffect(time, false, (ags_EffectStepFunc)effect_step, eff);
|
||||
effect_finish(eff);
|
||||
|
||||
switch (no) {
|
||||
case SACT_EFFECT_FADEOUT:
|
||||
|
||||
+4
-4
@@ -11,7 +11,7 @@
|
||||
#include "graph.h"
|
||||
#include "ngraph.h"
|
||||
#include "ags.h"
|
||||
#include "sdl_core.h"
|
||||
#include "gfx.h"
|
||||
|
||||
/**
|
||||
* surface から surface にコピーなどをする際に、転送元と転送先のsurface
|
||||
@@ -33,8 +33,8 @@
|
||||
*/
|
||||
bool gr_clip(surface_t *ss, int *sx, int *sy, int *sw, int *sh, surface_t *ds, int *dx, int *dy) {
|
||||
if (!ss || !ds) return false;
|
||||
MyRectangle src_window = { 0, 0, ss->width, ss->height };
|
||||
MyRectangle dst_window = { 0, 0, ds->width, ds->height };
|
||||
SDL_Rect src_window = { 0, 0, ss->width, ss->height };
|
||||
SDL_Rect dst_window = { 0, 0, ds->width, ds->height };
|
||||
return ags_clipCopyRect(&src_window, &dst_window, sx, sy, dx, dy, sw, sh);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ void gr_copy(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int
|
||||
if (dst == src) {
|
||||
SDL_Rect r;
|
||||
if (SDL_IntersectRect(&src_rect, &dst_rect, &r)) {
|
||||
SDL_Surface *view = sdl_createSurfaceView(src->sdl_surface, sx, sy, sw, sh);
|
||||
SDL_Surface *view = gfx_createSurfaceView(src->sdl_surface, sx, sy, sw, sh);
|
||||
SDL_Surface *tmp = SDL_ConvertSurface(view, dst->sdl_surface->format, 0);
|
||||
src_rect.x = 0;
|
||||
src_rect.y = 0;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "portab.h"
|
||||
#include "graphics.h"
|
||||
#include "ags.h"
|
||||
#include "sprite.h"
|
||||
|
||||
@@ -42,7 +41,7 @@ struct _night {
|
||||
// graph
|
||||
// cginfo_t *cg[CGMAX];
|
||||
|
||||
MyRectangle updaterect;
|
||||
SDL_Rect updaterect;
|
||||
|
||||
FontType fonttype;
|
||||
int fontsize;
|
||||
|
||||
@@ -53,8 +53,8 @@ void nt_gr_set_wallpaper(int no) {
|
||||
sp = nt_sp_new(SPNO_WALL, no, 0, 0, SPRITE_WP);
|
||||
nt_sp_add_updatelist(sp);
|
||||
if (no == 0) {
|
||||
sp->cursize.width = main_surface->w;
|
||||
sp->cursize.height = main_surface->h;
|
||||
sp->width = main_surface->w;
|
||||
sp->height = main_surface->h;
|
||||
sp->update = nt_sp_draw_wall;
|
||||
}
|
||||
|
||||
|
||||
+13
-14
@@ -7,7 +7,6 @@
|
||||
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "sdl_core.h"
|
||||
#include "utfsjis.h"
|
||||
#include "ags.h"
|
||||
#include "nact.h"
|
||||
@@ -217,7 +216,7 @@ static void ntmsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB
|
||||
char *msg;
|
||||
sprite_t *sp;
|
||||
bool needupdate = false;
|
||||
MyRectangle uparea = {0,0,0,0};
|
||||
SDL_Rect uparea = {0,0,0,0};
|
||||
int savex;
|
||||
|
||||
if (night.msgbuf[0] == '\0') return;
|
||||
@@ -236,7 +235,7 @@ static void ntmsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB
|
||||
char mbuf[20];
|
||||
int cw, delta, wcnt;
|
||||
|
||||
wcnt = sdl_getTicks();
|
||||
wcnt = sys_get_ticks();
|
||||
|
||||
mbuf[0] = '\0';
|
||||
msg = get_char(msg, mbuf, sizeof(mbuf) -1);
|
||||
@@ -267,7 +266,7 @@ static void ntmsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB
|
||||
needupdate = false;
|
||||
|
||||
// keywait
|
||||
delta = sdl_getTicks() - wcnt;
|
||||
delta = sys_get_ticks() - wcnt;
|
||||
if (delta < wSpeed) {
|
||||
if (sys_keywait(wSpeed - delta, KEYWAIT_NONCANCELABLE)) {
|
||||
|
||||
@@ -284,8 +283,8 @@ static void ntmsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB
|
||||
|
||||
// Waitなしの出力は最後にupdate
|
||||
if (needupdate) {
|
||||
uparea.w = sp->cursize.width;
|
||||
uparea.h = min(sp->cursize.height, uparea.y - sp->u.msg.dspcur.y + wLineSpace + wLineSpace);
|
||||
uparea.w = sp->width;
|
||||
uparea.h = min(sp->height, uparea.y - sp->u.msg.dspcur.y + wLineSpace + wLineSpace);
|
||||
nt_sp_updateme_part(sp, uparea.x, uparea.y, uparea.w, uparea.h);
|
||||
}
|
||||
|
||||
@@ -311,14 +310,14 @@ static int ntmsg_keywait() {
|
||||
night.waitkey = -1;
|
||||
|
||||
while (night.waitkey == -1 && !nact->is_quit) {
|
||||
int st = sdl_getTicks();
|
||||
int st = sys_get_ticks();
|
||||
int interval = 25;
|
||||
|
||||
if (!night.zhiding) {
|
||||
interval = night.sp[SPNO_MSG_KEYANIM]->u.anime.interval;
|
||||
hakanim(i++);
|
||||
}
|
||||
sys_keywait(interval - (sdl_getTicks() - st), KEYWAIT_NONCANCELABLE);
|
||||
sys_keywait(interval - (sys_get_ticks() - st), KEYWAIT_NONCANCELABLE);
|
||||
}
|
||||
|
||||
night.waittype = KEYWAIT_NONE;
|
||||
@@ -355,8 +354,8 @@ static void set_align(char *msg, sprite_t *sp, int wSize) {
|
||||
|
||||
maxchar = max(maxchar, c);
|
||||
line++;
|
||||
sp->u.msg.dspcur.x = (sp->cursize.width - (maxchar * wSize/2)) /2;
|
||||
sp->u.msg.dspcur.y = (sp->cursize.height - (line * (wSize+2))) /2;
|
||||
sp->u.msg.dspcur.x = (sp->width - (maxchar * wSize/2)) /2;
|
||||
sp->u.msg.dspcur.y = (sp->height - (line * (wSize+2))) /2;
|
||||
break;
|
||||
case 2:
|
||||
sp->u.msg.dspcur.x = msgframe_2.x;
|
||||
@@ -436,14 +435,14 @@ static void hakanim(int i) {
|
||||
sp->show = show;
|
||||
}
|
||||
|
||||
void ntmsg_update(sprite_t *sp, MyRectangle *r) {
|
||||
SDL_Rect sp_rect = {0, 0, sp->cursize.width, sp->cursize.height};
|
||||
void ntmsg_update(sprite_t *sp, SDL_Rect *r) {
|
||||
SDL_Rect sp_rect = {0, 0, sp->width, sp->height};
|
||||
int sx = 0;
|
||||
int sy = 0;
|
||||
int dx = sp->cur.x;
|
||||
int dy = sp->cur.y;
|
||||
int w = sp->cursize.width;
|
||||
int h = sp->cursize.height;
|
||||
int w = sp->width;
|
||||
int h = sp->height;
|
||||
if (!ags_clipCopyRect(&sp_rect, r, &sx, &sy, &dx, &dy, &w, &h)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,6 @@ void ntmsg_set_place(int type);
|
||||
void ntmsg_newline();
|
||||
void ntmsg_add(const char *msg);
|
||||
int ntmsg_ana(void);
|
||||
void ntmsg_update(sprite_t *sp, MyRectangle *r);
|
||||
void ntmsg_update(sprite_t *sp, SDL_Rect *r);
|
||||
|
||||
#endif /* __NT_MSG_H__ */
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "input.h"
|
||||
#include "sdl_core.h"
|
||||
#include "scheduler.h"
|
||||
#include "xsystem35.h"
|
||||
#include "nact.h"
|
||||
|
||||
+10
-10
@@ -28,11 +28,11 @@ sprite_t *nt_sp_new(int no, int cg1, int cg2, int cg3, int type) {
|
||||
sp->cur = sp->loc;
|
||||
|
||||
if (sp->curcg == NULL) {
|
||||
sp->cursize.width = 0;
|
||||
sp->cursize.height = 0;
|
||||
sp->width = 0;
|
||||
sp->height = 0;
|
||||
} else {
|
||||
sp->cursize.width = sp->curcg->sf->w;
|
||||
sp->cursize.height = sp->curcg->sf->h;
|
||||
sp->width = sp->curcg->sf->w;
|
||||
sp->height = sp->curcg->sf->h;
|
||||
}
|
||||
sp->update = DEFAULT_UPDATE;
|
||||
|
||||
@@ -58,8 +58,8 @@ sprite_t *nt_sp_msg_new(int no, int x, int y, int width, int height) {
|
||||
sp->loc.x = x;
|
||||
sp->loc.y = y;
|
||||
sp->cur = sp->loc;
|
||||
sp->cursize.width = width;
|
||||
sp->cursize.height = height;
|
||||
sp->width = width;
|
||||
sp->height = height;
|
||||
sp->u.msg.dspcur.x = 0;
|
||||
sp->u.msg.dspcur.y = 0;
|
||||
sp->u.msg.canvas = SDL_CreateRGBSurfaceWithFormat(0, width, height, 32, SDL_PIXELFORMAT_ARGB8888);
|
||||
@@ -107,11 +107,11 @@ void nt_sp_set_cg(sprite_t *sp, int no) {
|
||||
cg = no ? nt_scg_addref(no) : NULL;
|
||||
|
||||
if (cg == NULL) {
|
||||
sp->cursize.width = 0;
|
||||
sp->cursize.height = 0;
|
||||
sp->width = 0;
|
||||
sp->height = 0;
|
||||
} else {
|
||||
sp->cursize.width = cg->sf->w;
|
||||
sp->cursize.height = cg->sf->h;
|
||||
sp->width = cg->sf->w;
|
||||
sp->height = cg->sf->h;
|
||||
}
|
||||
|
||||
sp->curcg = cg;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#define __SPRITE_H__
|
||||
|
||||
#include "portab.h"
|
||||
#include "graphics.h"
|
||||
#include <SDL_rect.h>
|
||||
|
||||
#define DEFAULT_UPDATE nt_sp_draw
|
||||
|
||||
@@ -72,7 +72,8 @@ struct _sprite {
|
||||
|
||||
int no;
|
||||
|
||||
MyDimension cursize;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
cginfo_t *curcg;
|
||||
cginfo_t *cg1, *cg2, *cg3;
|
||||
@@ -81,11 +82,11 @@ struct _sprite {
|
||||
|
||||
int blendrate;
|
||||
|
||||
MyPoint loc;
|
||||
SDL_Point loc;
|
||||
|
||||
MyPoint cur;
|
||||
SDL_Point cur;
|
||||
|
||||
void (* update)(struct _sprite *sp, MyRectangle *updatearea);
|
||||
void (* update)(struct _sprite *sp, SDL_Rect *updatearea);
|
||||
|
||||
union {
|
||||
struct {
|
||||
@@ -97,7 +98,7 @@ struct _sprite {
|
||||
|
||||
struct {
|
||||
struct SDL_Surface *canvas;
|
||||
MyPoint dspcur;
|
||||
SDL_Point dspcur;
|
||||
} msg;
|
||||
} u;
|
||||
};
|
||||
@@ -120,12 +121,12 @@ void nt_sp_updateme(sprite_t *sp);
|
||||
void nt_sp_updateme_part(sprite_t *sp, int x, int y, int w, int h);
|
||||
void nt_sp_add_updatelist(sprite_t *sp);
|
||||
void nt_sp_remove_updatelist(sprite_t *sp);
|
||||
void nt_sp_draw_wall(sprite_t *sp, MyRectangle *r);
|
||||
void nt_sp_draw_wall(sprite_t *sp, SDL_Rect *r);
|
||||
void nt_sp_clear_updatelist(void);
|
||||
|
||||
/* in nt_sprite_draw.c */
|
||||
void nt_sp_draw(sprite_t *sp, MyRectangle *r);
|
||||
void nt_sp_draw_scg(sprite_t *sp, MyRectangle *r);
|
||||
void nt_sp_draw(sprite_t *sp, SDL_Rect *r);
|
||||
void nt_sp_draw_scg(sprite_t *sp, SDL_Rect *r);
|
||||
|
||||
/* in nt_sprite_eupdate.c */
|
||||
void nt_sp_eupdate(int type, int time, int cancel);
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "ags.h"
|
||||
#include "graphics.h"
|
||||
#include "sprite.h"
|
||||
|
||||
/*
|
||||
@@ -37,7 +36,7 @@
|
||||
@param sp: 描画するスプライト
|
||||
@param r : 再描画する領域
|
||||
*/
|
||||
void nt_sp_draw(sprite_t *sp, MyRectangle *r) {
|
||||
void nt_sp_draw(sprite_t *sp, SDL_Rect *r) {
|
||||
if (sp == NULL) return;
|
||||
cginfo_t *cg = sp->curcg;
|
||||
if (cg == NULL) return;
|
||||
@@ -69,7 +68,7 @@ void nt_sp_draw(sprite_t *sp, MyRectangle *r) {
|
||||
}
|
||||
|
||||
// BlendScreenによる描画
|
||||
void nt_sp_draw_scg(sprite_t *sp, MyRectangle *r) {
|
||||
void nt_sp_draw_scg(sprite_t *sp, SDL_Rect *r) {
|
||||
if (sp == NULL) return;
|
||||
cginfo_t *cg = sp->curcg;
|
||||
if (cg == NULL) return;
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
#include "ags.h"
|
||||
#include "input.h"
|
||||
#include "sprite.h"
|
||||
#include "sdl_core.h"
|
||||
#include "gfx.h"
|
||||
#include "effect.h"
|
||||
|
||||
/*
|
||||
効果つき画面更新
|
||||
@@ -44,25 +45,25 @@ void nt_sp_eupdate(int no, int time, int cancel) {
|
||||
|
||||
nt_sp_update_all(false);
|
||||
|
||||
enum sdl_effect_type type = from_sact_effect(no - 100);
|
||||
enum effect_type type = from_sact_effect(no - 100);
|
||||
if (type == EFFECT_INVALID) {
|
||||
WARNING("Unimplemented effect %d", no);
|
||||
type = EFFECT_CROSSFADE;
|
||||
}
|
||||
SDL_Rect rect = { 0, 0, main_surface->w, main_surface->h };
|
||||
struct sdl_effect *eff = sdl_effect_init(&rect, NULL, 0, 0, sdl_getDIB(), 0, 0, type);
|
||||
struct effect *eff = effect_init(&rect, NULL, 0, 0, gfx_getDIB(), 0, 0, type);
|
||||
|
||||
int sttime, curtime;
|
||||
sttime = curtime = sdl_getTicks();
|
||||
sttime = curtime = sys_get_ticks();
|
||||
int edtime = curtime + time;
|
||||
|
||||
while ((curtime = sdl_getTicks()) < edtime) {
|
||||
sdl_effect_step(eff, (float)(curtime - sttime) / (edtime - sttime));
|
||||
int rest = 16 - (sdl_getTicks() - curtime);
|
||||
while ((curtime = sys_get_ticks()) < edtime) {
|
||||
effect_step(eff, (float)(curtime - sttime) / (edtime - sttime));
|
||||
int rest = 16 - (sys_get_ticks() - curtime);
|
||||
int key = sys_keywait(rest, cancel ? KEYWAIT_CANCELABLE : KEYWAIT_NONCANCELABLE);
|
||||
if (cancel && key)
|
||||
break;
|
||||
}
|
||||
sdl_effect_finish(eff);
|
||||
effect_finish(eff);
|
||||
ags_updateFull();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "system.h"
|
||||
#include "list.h"
|
||||
#include "ags.h"
|
||||
#include "graphics.h"
|
||||
#include "sprite.h"
|
||||
|
||||
// スプライト再描画間の間に変更のあったスプライトの領域の和
|
||||
@@ -41,22 +40,22 @@ static SList *updatearea;
|
||||
static SList *updatelist;
|
||||
|
||||
static void disjunction(void* region, void* data);
|
||||
static MyRectangle get_updatearea();
|
||||
static SDL_Rect get_updatearea();
|
||||
static void do_update_each(void* data, void* userdata);
|
||||
|
||||
// 領域1と領域2をすべて含む矩形領域を計算
|
||||
static void disjunction(void* region, void* data) {
|
||||
MyRectangle *r1 = (MyRectangle *)region;
|
||||
MyRectangle *r2 = (MyRectangle *)data;
|
||||
SDL_Rect *r1 = (SDL_Rect *)region;
|
||||
SDL_Rect *r2 = (SDL_Rect *)data;
|
||||
SDL_UnionRect(r1, r2, r2);
|
||||
free(r1);
|
||||
}
|
||||
|
||||
// 更新の必要なスプライトの領域の和をとってクリッピングする
|
||||
static MyRectangle get_updatearea() {
|
||||
MyRectangle clip = {0, 0, 0, 0};
|
||||
MyRectangle screen = {0, 0, main_surface->w, main_surface->h};
|
||||
MyRectangle result;
|
||||
static SDL_Rect get_updatearea() {
|
||||
SDL_Rect clip = {0, 0, 0, 0};
|
||||
SDL_Rect screen = {0, 0, main_surface->w, main_surface->h};
|
||||
SDL_Rect result;
|
||||
|
||||
slist_foreach(updatearea, disjunction, &clip);
|
||||
|
||||
@@ -75,7 +74,7 @@ static MyRectangle get_updatearea() {
|
||||
// updatelist に登録してあるすべてのスプライトを更新
|
||||
static void do_update_each(void* data, void* userdata) {
|
||||
sprite_t *sp = (sprite_t *)data;
|
||||
MyRectangle *r = (MyRectangle *)userdata;
|
||||
SDL_Rect *r = (SDL_Rect *)userdata;
|
||||
|
||||
// 非表示の場合はなにもしない
|
||||
if (!sp->show) return;
|
||||
@@ -92,7 +91,7 @@ static void do_update_each(void* data, void* userdata) {
|
||||
*/
|
||||
void nt_sp_update_all(bool syncscreen) {
|
||||
// 画面全体を更新領域に
|
||||
MyRectangle r = {0, 0, main_surface->w, main_surface->h };
|
||||
SDL_Rect r = {0, 0, main_surface->w, main_surface->h };
|
||||
|
||||
// updatelistに登録してあるスプライトを再描画
|
||||
// updatelistはスプライトの番号順に並んでいる
|
||||
@@ -111,7 +110,7 @@ void nt_sp_update_all(bool syncscreen) {
|
||||
updateme(_part)で登録した更新が必要なspriteの和の領域をupdate
|
||||
*/
|
||||
void nt_sp_update_clipped() {
|
||||
MyRectangle r;
|
||||
SDL_Rect r;
|
||||
|
||||
// 更新領域の確定
|
||||
r = get_updatearea();
|
||||
@@ -131,16 +130,16 @@ void nt_sp_update_clipped() {
|
||||
@param sp: 更新するスプライト
|
||||
*/
|
||||
void nt_sp_updateme(sprite_t *sp) {
|
||||
MyRectangle *r;
|
||||
SDL_Rect *r;
|
||||
|
||||
if (sp == NULL) return;
|
||||
if (sp->cursize.width == 0 || sp->cursize.height == 0) return;
|
||||
if (sp->width == 0 || sp->height == 0) return;
|
||||
|
||||
r = malloc(sizeof(MyRectangle));
|
||||
r = malloc(sizeof(SDL_Rect));
|
||||
r->x = sp->cur.x;
|
||||
r->y = sp->cur.y;
|
||||
r->w = sp->cursize.width;
|
||||
r->h = sp->cursize.height;
|
||||
r->w = sp->width;
|
||||
r->h = sp->height;
|
||||
|
||||
updatearea = slist_append(updatearea, r);
|
||||
|
||||
@@ -157,12 +156,12 @@ void nt_sp_updateme(sprite_t *sp) {
|
||||
@param h: 更新領域高さ
|
||||
*/
|
||||
void nt_sp_updateme_part(sprite_t *sp, int x, int y, int w, int h) {
|
||||
MyRectangle *r;
|
||||
SDL_Rect *r;
|
||||
|
||||
if (sp == NULL) return;
|
||||
if (w == 0 || h == 0) return;
|
||||
|
||||
r = malloc(sizeof(MyRectangle));
|
||||
r = malloc(sizeof(SDL_Rect));
|
||||
r->x = sp->cur.x + x;
|
||||
r->y = sp->cur.y + y;
|
||||
r->w = w;
|
||||
@@ -204,6 +203,6 @@ void nt_sp_clear_updatelist(void) {
|
||||
}
|
||||
|
||||
// デフォルトの壁紙update
|
||||
void nt_sp_draw_wall(sprite_t *sp, MyRectangle *area) {
|
||||
void nt_sp_draw_wall(sprite_t *sp, SDL_Rect *area) {
|
||||
SDL_FillRect(main_surface, area, SDL_MapRGB(main_surface->format, 0, 0, 0));
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "nact.h"
|
||||
#include "alk.h"
|
||||
#include "music.h"
|
||||
#include "sdl_core.h"
|
||||
#include "gfx.h"
|
||||
#include "input.h"
|
||||
#include "cg.h"
|
||||
#include "jpeg.h"
|
||||
@@ -52,9 +52,9 @@ static void ndd_run(int demonum) {
|
||||
if (mus)
|
||||
musbgm_play(mus, 0, 100, 0);
|
||||
|
||||
uint32_t start = sdl_getTicks();
|
||||
uint32_t start = sys_get_ticks();
|
||||
while (!nact->is_quit) {
|
||||
int i = (sdl_getTicks() - start) / (1000 / FPS);
|
||||
int i = (sys_get_ticks() - start) / (1000 / FPS);
|
||||
if (i >= alk->datanum)
|
||||
break;
|
||||
|
||||
@@ -69,12 +69,12 @@ static void ndd_run(int demonum) {
|
||||
WARNING("Cannot decode CG %d in %s", i, alk_path);
|
||||
}
|
||||
|
||||
int wait_ms = (i + 1) * (1000 / FPS) - (sdl_getTicks() - start);
|
||||
int wait_ms = (i + 1) * (1000 / FPS) - (sys_get_ticks() - start);
|
||||
if (wait_ms > 0) {
|
||||
if (sys_keywait(wait_ms, KEYWAIT_CANCELABLE))
|
||||
break;
|
||||
} else {
|
||||
sdl_updateScreen();
|
||||
gfx_updateScreen();
|
||||
if (sys_getInputInfo())
|
||||
break;
|
||||
}
|
||||
|
||||
+11
-11
@@ -25,10 +25,9 @@
|
||||
#define __SACT_H__
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <SDL_rect.h>
|
||||
#include "portab.h"
|
||||
#include "list.h"
|
||||
#include "graphics.h"
|
||||
#include "ags.h"
|
||||
#include "sacttimer.h"
|
||||
#include "variable.h"
|
||||
@@ -107,7 +106,8 @@ struct _sprite {
|
||||
int numsound1, numsound2, numsound3;
|
||||
|
||||
// 初期 sprite の大きさ(cg1の大きさ)
|
||||
MyDimension cursize;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
// それぞれの状態で表示する CG
|
||||
cginfo_t *cg1, *cg2, *cg3;
|
||||
@@ -126,10 +126,10 @@ struct _sprite {
|
||||
int freezed_state;
|
||||
|
||||
// 表示位置 (SetPos)
|
||||
MyPoint loc;
|
||||
SDL_Point loc;
|
||||
|
||||
// 現在のスプライトの表示位置
|
||||
MyPoint cur;
|
||||
SDL_Point cur;
|
||||
|
||||
// event callback
|
||||
int (* eventcb)(struct _sprite *sp, agsevent_t *e); // for key/mouse
|
||||
@@ -146,7 +146,7 @@ struct _sprite {
|
||||
|
||||
// move command 用パラメータ
|
||||
struct {
|
||||
MyPoint to; // 移動先
|
||||
SDL_Point to; // 移動先
|
||||
int time; // 移動完了時間
|
||||
int speed; // 移動速度
|
||||
int starttime; // 移動開始時刻
|
||||
@@ -157,7 +157,7 @@ struct _sprite {
|
||||
// SACT.Numeral用パラメータ
|
||||
struct {
|
||||
int cg[10];
|
||||
MyPoint pos;
|
||||
SDL_Point pos;
|
||||
int span;
|
||||
} numeral;
|
||||
|
||||
@@ -171,7 +171,7 @@ struct _sprite {
|
||||
// ゲットスプライト
|
||||
struct {
|
||||
bool dragging; // ドラッグ中
|
||||
MyPoint dragstart; // ドラッグ開始位置
|
||||
SDL_Point dragstart; // ドラッグ開始位置
|
||||
} get;
|
||||
|
||||
// プットスプライト
|
||||
@@ -191,7 +191,7 @@ struct _sprite {
|
||||
struct {
|
||||
SList *buf; // 表示する文字のリスト
|
||||
struct SDL_Surface *canvas;
|
||||
MyPoint dspcur; // 現在の表示位置
|
||||
SDL_Point dspcur; // 現在の表示位置
|
||||
} msg;
|
||||
} u;
|
||||
};
|
||||
@@ -213,7 +213,7 @@ struct _sact {
|
||||
cginfo_t *cg[CGMAX]; // cgまたはCG_xxで作った CG
|
||||
|
||||
// 座標系の原点
|
||||
MyPoint origin;
|
||||
SDL_Point origin;
|
||||
|
||||
// 文字列 replce 用
|
||||
SList *strreplace;
|
||||
@@ -247,7 +247,7 @@ struct _sact {
|
||||
int movestarttime; // 一斉に移動を開始するための開始時間
|
||||
int movecurtime;
|
||||
|
||||
MyRectangle updaterect; // 更新が必要なspriteの領域の和
|
||||
SDL_Rect updaterect; // 更新が必要なspriteの領域の和
|
||||
|
||||
// sact timer
|
||||
stimer_t timer[65536];
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "sact.h"
|
||||
#include "pms.h"
|
||||
#include "sprite.h"
|
||||
#include "sdl_core.h"
|
||||
#include "effect.h"
|
||||
#include "mmap.h"
|
||||
|
||||
// SACTEFAM を使ったマスク
|
||||
@@ -91,10 +91,10 @@ void sp_eupdate_amap(int index, int time, int cancel) {
|
||||
return;
|
||||
}
|
||||
SDL_Surface *mask_sf = SDL_CreateRGBSurfaceFrom(mask->pic, mask->width, mask->height, 8, mask->width, 0, 0, 0, 0);
|
||||
sp_update_all(false); // old = sdl_texture, new = main_surface
|
||||
struct sdl_effect *eff = sdl_effect_sactamask_init(mask_sf);
|
||||
ags_runEffect(time * 10, cancel, (ags_EffectStepFunc)sdl_effect_step, eff);
|
||||
sdl_effect_finish(eff);
|
||||
sp_update_all(false); // old = gfx_texture, new = main_surface
|
||||
struct effect *eff = effect_sactamask_init(mask_sf);
|
||||
ags_runEffect(time * 10, cancel, (ags_EffectStepFunc)effect_step, eff);
|
||||
effect_finish(eff);
|
||||
ags_updateFull();
|
||||
|
||||
SDL_FreeSurface(mask_sf);
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "sact.h"
|
||||
#include "sactcg.h"
|
||||
#include "cg.h"
|
||||
#include "sdl_core.h"
|
||||
#include "gfx.h"
|
||||
|
||||
#define SPCG_ASSERT_NO(no) \
|
||||
if ((no) > (CGMAX -1)) { \
|
||||
@@ -118,9 +118,9 @@ void scg_create_reverse(int wNumCG, int wNumSrcCG, int wReverseX, int wReverseY)
|
||||
|
||||
SDL_Surface *sf = SDL_ConvertSurface(src->sf, src->sf->format, 0);
|
||||
if (wReverseX)
|
||||
sdl_FlipSurfaceHorizontal(sf);
|
||||
gfx_FlipSurfaceHorizontal(sf);
|
||||
if (wReverseY)
|
||||
sdl_FlipSurfaceVertical(sf);
|
||||
gfx_FlipSurfaceVertical(sf);
|
||||
scg_new(CG_REVERSE, wNumCG, sf);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include "input.h"
|
||||
#include "sact.h"
|
||||
#include "sprite.h"
|
||||
#include "sdl_core.h"
|
||||
#include "randMT.h"
|
||||
|
||||
#define M_PIf ((float)M_PI)
|
||||
@@ -78,9 +77,9 @@ void sp_quake_screen(int type, int p1, int p2, int time, int cancel) {
|
||||
|
||||
if (type > 1) return;
|
||||
|
||||
sttime = sdl_getTicks();
|
||||
sttime = sys_get_ticks();
|
||||
edtime = time * 10 + sttime;
|
||||
while ((curtime = sdl_getTicks()) < edtime) {
|
||||
while ((curtime = sys_get_ticks()) < edtime) {
|
||||
int adjx, adjy;
|
||||
|
||||
cb[type]((float)(curtime - sttime)/(edtime - sttime), p1, p2, &adjx, &adjy);
|
||||
|
||||
+11
-11
@@ -145,11 +145,11 @@ void sp_new(int no, int cg1, int cg2, int cg3, int type) {
|
||||
|
||||
// cg1の大きさをスプライトの大きさとする
|
||||
if (sp->curcg == NULL) {
|
||||
sp->cursize.width = 0;
|
||||
sp->cursize.height = 0;
|
||||
sp->width = 0;
|
||||
sp->height = 0;
|
||||
} else {
|
||||
sp->cursize.width = sp->curcg->sf->w;
|
||||
sp->cursize.height = sp->curcg->sf->h;
|
||||
sp->width = sp->curcg->sf->w;
|
||||
sp->height = sp->curcg->sf->h;
|
||||
}
|
||||
|
||||
sp->freezed_state = 0; // 状態固定は無し
|
||||
@@ -201,8 +201,8 @@ void sp_new_msg(int no, int x, int y, int width, int height) {
|
||||
sp->loc.y = y - sact.origin.y;
|
||||
sp->u.msg.dspcur.x = 0; // 文字描画開始位置
|
||||
sp->u.msg.dspcur.y = 0;
|
||||
sp->cursize.width = width; // スプライトの大きさ
|
||||
sp->cursize.height = height;
|
||||
sp->width = width; // スプライトの大きさ
|
||||
sp->height = height;
|
||||
sp->cur = sp->loc;
|
||||
sp->u.msg.buf = NULL;
|
||||
|
||||
@@ -224,10 +224,10 @@ void sp_set_wall_paper(int no) {
|
||||
|
||||
if (sp->curcg) { // display specified CG
|
||||
sp->update = DEFAULT_UPDATE;
|
||||
sp->cursize.width = sp->curcg->sf->w;
|
||||
sp->cursize.height = sp->curcg->sf->h;
|
||||
sp->width = sp->curcg->sf->w;
|
||||
sp->height = sp->curcg->sf->h;
|
||||
} else { // Black
|
||||
sp->cursize.height = main_surface->h;
|
||||
sp->height = main_surface->h;
|
||||
sp->curcg = NULL;
|
||||
sp->update = sp_draw_wall;
|
||||
}
|
||||
@@ -516,8 +516,8 @@ bool sp_query_size(int wNum, int *vw, int *vh) {
|
||||
|
||||
if (sp->type == SPRITE_NONE) goto errexit;
|
||||
|
||||
*vw = sp->cursize.width;
|
||||
*vh = sp->cursize.height;
|
||||
*vw = sp->width;
|
||||
*vh = sp->height;
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "ags.h"
|
||||
#include "sdl_core.h"
|
||||
#include "sact.h"
|
||||
#include "sprite.h"
|
||||
|
||||
@@ -44,7 +43,7 @@ static int eventCB_ANIM(sprite_t *sp, agsevent_t *e) {
|
||||
if (e->type != AGSEVENT_TIMER) return 0;
|
||||
|
||||
// 現在時刻の取得
|
||||
now = sdl_getTicks();
|
||||
now = sys_get_ticks();
|
||||
|
||||
// 指定時間までスキップ
|
||||
if ((now - sp->u.anime.starttime) < sp->u.anime.interval) return 0;
|
||||
@@ -85,7 +84,7 @@ void sp_anime_setup(sprite_t *sp) {
|
||||
int n = 0;
|
||||
|
||||
sp->u.anime.interval = 500; // デフォルトの間隔 0.5秒
|
||||
sp->u.anime.starttime = sdl_getTicks(); // 開始時刻
|
||||
sp->u.anime.starttime = sys_get_ticks(); // 開始時刻
|
||||
sp->u.anime.tick = 0; // カウンタ初期化
|
||||
|
||||
// アニメパターンはいくつあるか
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "ags.h"
|
||||
#include "graphics.h"
|
||||
#include "sact.h"
|
||||
#include "sprite.h"
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
#include "input.h"
|
||||
#include "sact.h"
|
||||
#include "sprite.h"
|
||||
#include "sdl_core.h"
|
||||
#include "gfx.h"
|
||||
#include "effect.h"
|
||||
|
||||
/*
|
||||
効果つき画面更新
|
||||
@@ -45,25 +46,25 @@ void sp_eupdate(int type, int time, int cancel) {
|
||||
|
||||
sp_update_all(false);
|
||||
|
||||
enum sdl_effect_type sdl_effect = from_sact_effect(type);
|
||||
if (sdl_effect == EFFECT_INVALID) {
|
||||
enum effect_type effect = from_sact_effect(type);
|
||||
if (effect == EFFECT_INVALID) {
|
||||
WARNING("Unimplemented effect %d", type);
|
||||
type = EFFECT_CROSSFADE;
|
||||
}
|
||||
SDL_Rect rect = { 0, 0, main_surface->w, main_surface->h };
|
||||
struct sdl_effect *eff = sdl_effect_init(&rect, NULL, 0, 0, sdl_getDIB(), 0, 0, sdl_effect);
|
||||
struct effect *eff = effect_init(&rect, NULL, 0, 0, gfx_getDIB(), 0, 0, effect);
|
||||
|
||||
int sttime, curtime;
|
||||
sttime = curtime = sdl_getTicks();
|
||||
sttime = curtime = sys_get_ticks();
|
||||
int edtime = curtime + time * 10;
|
||||
|
||||
while ((curtime = sdl_getTicks()) < edtime) {
|
||||
sdl_effect_step(eff, (float)(curtime - sttime) / (edtime - sttime));
|
||||
int rest = 16 - (sdl_getTicks() - curtime);
|
||||
while ((curtime = sys_get_ticks()) < edtime) {
|
||||
effect_step(eff, (float)(curtime - sttime) / (edtime - sttime));
|
||||
int rest = 16 - (sys_get_ticks() - curtime);
|
||||
int key = sys_keywait(rest, cancel ? KEYWAIT_CANCELABLE : KEYWAIT_NONCANCELABLE);
|
||||
if (cancel && key)
|
||||
break;
|
||||
}
|
||||
sdl_effect_finish(eff);
|
||||
effect_finish(eff);
|
||||
ags_updateFull();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "sdl_core.h"
|
||||
#include "menu.h"
|
||||
#include "input.h"
|
||||
#include "nact.h"
|
||||
@@ -213,7 +212,7 @@ static void cb_waitkey_simple(agsevent_t *e) {
|
||||
switch (e->type) {
|
||||
case AGSEVENT_KEY_PRESS:
|
||||
if (e->code == KEY_Z) {
|
||||
cur = sdl_getTicks();
|
||||
cur = sys_get_ticks();
|
||||
if (!sact.zhiding) {
|
||||
slist_foreach(sact.sp_zhide, cb_defocused_zkey, &update);
|
||||
sact.zhiding = true;
|
||||
@@ -243,7 +242,7 @@ static void cb_waitkey_simple(agsevent_t *e) {
|
||||
case AGSEVENT_KEY_RELEASE:
|
||||
switch(e->code) {
|
||||
case KEY_Z:
|
||||
cur = sdl_getTicks();
|
||||
cur = sys_get_ticks();
|
||||
if (500 < (cur - sact.zofftime) || !sact.zdooff) {
|
||||
slist_foreach(sact.sp_zhide, cb_focused_zkey, &update);
|
||||
sact.zhiding = false;
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "list.h"
|
||||
#include "sdl_core.h"
|
||||
#include "ags.h"
|
||||
#include "nact.h"
|
||||
#include "input.h"
|
||||
@@ -67,7 +66,7 @@ static void hidesprite(sprite_t *sp) {
|
||||
スプライトがドロップされた時の各種処理を含む
|
||||
*/
|
||||
static bool waitcond(int endtime) {
|
||||
int curtime = sdl_getTicks();
|
||||
int curtime = sys_get_ticks();
|
||||
if (curtime >= endtime) return true;
|
||||
|
||||
if (sact.dropped) {
|
||||
@@ -133,7 +132,7 @@ void sp_keywait(int *vOK, int *vRND, int *vD01, int *vD02, int *vD03, int timeou
|
||||
{
|
||||
// とりあえず、現在のマウス位置を送って、switch sprite の
|
||||
// 状態を更新しておく
|
||||
MyPoint p;
|
||||
SDL_Point p;
|
||||
sys_getMouseInfo(&p, false);
|
||||
agsevent_t agse = {
|
||||
.type = AGSEVENT_MOUSE_MOTION,
|
||||
@@ -144,7 +143,7 @@ void sp_keywait(int *vOK, int *vRND, int *vD01, int *vD02, int *vD03, int timeou
|
||||
}
|
||||
|
||||
// 終了時間の計算
|
||||
curtime = sdl_getTicks();
|
||||
curtime = sys_get_ticks();
|
||||
endtime = timeout < 0 ? INT_MAX : (curtime + timeout * 10);
|
||||
|
||||
// スプライトキー待ちメイン
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "nact.h"
|
||||
#include "sact.h"
|
||||
#include "sprite.h"
|
||||
#include "sdl_core.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -161,14 +160,14 @@ void spev_move_waitend(sprite_t *sp, int dx, int dy, int time) {
|
||||
sp->move.time = 0;
|
||||
|
||||
sact.movelist = slist_append(sact.movelist, sp);
|
||||
sact.movestarttime = sdl_getTicks();
|
||||
sact.movestarttime = sys_get_ticks();
|
||||
slist_foreach(sact.movelist, spev_move_setup, NULL);
|
||||
slist_free(sact.movelist);
|
||||
sact.movelist = NULL;
|
||||
|
||||
while (sp->move.moving) {
|
||||
nact->callback();
|
||||
sdl_wait_vsync();
|
||||
sys_wait_vsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +186,7 @@ void spev_wait4moving_sp() {
|
||||
|
||||
while (sp->move.moving) {
|
||||
nact->callback();
|
||||
sdl_wait_vsync();
|
||||
sys_wait_vsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-13
@@ -29,7 +29,6 @@
|
||||
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "sdl_core.h"
|
||||
#include "ags.h"
|
||||
#include "nact.h"
|
||||
#include "input.h"
|
||||
@@ -241,7 +240,7 @@ void smsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB, int wF
|
||||
sprite_t *sp;
|
||||
int len = 0; // 処理した文字数?
|
||||
bool needupdate = false;
|
||||
MyRectangle uparea = {0,0,0,0};
|
||||
SDL_Rect uparea = {0,0,0,0};
|
||||
|
||||
// wRSize == 0 -> ルビ無し(SACT.MessageOutputからの呼出)
|
||||
|
||||
@@ -268,7 +267,7 @@ void smsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB, int wF
|
||||
char mbuf[20], rbuf[20];
|
||||
int cw, delta, wcnt;
|
||||
|
||||
wcnt = sdl_getTicks();
|
||||
wcnt = sys_get_ticks();
|
||||
|
||||
mbuf[0] = rbuf[0] = '\0';
|
||||
msg = get_char(msg, mbuf, rbuf, sizeof(mbuf) -1);
|
||||
@@ -316,7 +315,7 @@ void smsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB, int wF
|
||||
needupdate = false;
|
||||
|
||||
// keywait
|
||||
delta = sdl_getTicks() - wcnt;
|
||||
delta = sys_get_ticks() - wcnt;
|
||||
if (delta < wSpeed) {
|
||||
if (sys_keywait(wSpeed - delta, KEYWAIT_NONCANCELABLE)) {
|
||||
|
||||
@@ -335,8 +334,8 @@ void smsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB, int wF
|
||||
|
||||
// Waitなしの出力は最後にupdate
|
||||
if (needupdate) {
|
||||
uparea.w = sp->cursize.width;
|
||||
uparea.h = min(sp->cursize.height, uparea.y - sp->u.msg.dspcur.y + wLineSpace + wLineSpace + wRSize);
|
||||
uparea.w = sp->width;
|
||||
uparea.h = min(sp->height, uparea.y - sp->u.msg.dspcur.y + wLineSpace + wLineSpace + wRSize);
|
||||
sp_updateme_part(sp, uparea.x, uparea.y, uparea.w, uparea.h);
|
||||
}
|
||||
|
||||
@@ -420,7 +419,7 @@ int smsg_keywait(int wNum1, int wNum2, int msglen) {
|
||||
sact.waitkey = -1;
|
||||
|
||||
while (sact.waitkey == -1 && !nact->is_quit) {
|
||||
int st = sdl_getTicks();
|
||||
int st = sys_get_ticks();
|
||||
int interval = 25;
|
||||
|
||||
// アニメパターンがある場合、その更新
|
||||
@@ -434,7 +433,7 @@ int smsg_keywait(int wNum1, int wNum2, int msglen) {
|
||||
update_mark(minfo[j].sp, minfo[j].cg);
|
||||
i++;
|
||||
}
|
||||
sys_keywait(interval - (sdl_getTicks() - st), KEYWAIT_NONCANCELABLE);
|
||||
sys_keywait(interval - (sys_get_ticks() - st), KEYWAIT_NONCANCELABLE);
|
||||
}
|
||||
|
||||
sact.waittype = KEYWAIT_NONE;
|
||||
@@ -447,13 +446,13 @@ int smsg_keywait(int wNum1, int wNum2, int msglen) {
|
||||
@param sp: 再描画するスプライト
|
||||
*/
|
||||
void smsg_update(sprite_t *sp) {
|
||||
SDL_Rect sp_rect = {0, 0, sp->cursize.width, sp->cursize.height};
|
||||
SDL_Rect sp_rect = {0, 0, sp->width, sp->height};
|
||||
int sx = 0;
|
||||
int sy = 0;
|
||||
int dx = sp->cur.x;
|
||||
int dy = sp->cur.y;
|
||||
int w = sp->cursize.width;
|
||||
int h = sp->cursize.height;
|
||||
int w = sp->width;
|
||||
int h = sp->height;
|
||||
if (!ags_clipCopyRect(&sp_rect, &sact.updaterect, &sx, &sy, &dx, &dy, &w, &h)) {
|
||||
return;
|
||||
}
|
||||
@@ -547,10 +546,10 @@ static void set_align(char *msg, sprite_t *sp, int wSize, int wAlign) {
|
||||
|
||||
switch (wAlign) {
|
||||
case 1: // センタリング
|
||||
adjx = (sp->cursize.width - mlen) / 2;
|
||||
adjx = (sp->width - mlen) / 2;
|
||||
break;
|
||||
case 2: // 右寄せ
|
||||
adjx = (sp->cursize.width - mlen);
|
||||
adjx = (sp->width - mlen);
|
||||
break;
|
||||
}
|
||||
sp->u.msg.dspcur.x = max(0, adjx);
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "input.h"
|
||||
#include "sact.h"
|
||||
#include "sprite.h"
|
||||
#include "sdl_core.h"
|
||||
#include "randMT.h"
|
||||
|
||||
/*
|
||||
@@ -49,9 +48,9 @@ void sp_quake_sprite(int wType, int wAmplitudeX, int wAmplitudeY, int wCount, in
|
||||
int i = 0, key;
|
||||
SList *node;
|
||||
|
||||
edtime = wCount * 10 + sdl_getTicks();
|
||||
edtime = wCount * 10 + sys_get_ticks();
|
||||
|
||||
while ((curtime = sdl_getTicks()) < edtime) {
|
||||
while ((curtime = sys_get_ticks()) < edtime) {
|
||||
if (wType == 0) { // 全てのスプライトを同じように動かす
|
||||
int adjx = (int)(genrand() * wAmplitudeX/2);
|
||||
int adjy = (int)(genrand() * wAmplitudeY/2);
|
||||
|
||||
@@ -60,8 +60,8 @@ static int sel_main();
|
||||
* マージン内はsprite内部とは判断しない
|
||||
*/
|
||||
static bool sp_is_insprite2(sprite_t *sp, int x, int y, int margin) {
|
||||
MyPoint p = {x, y};
|
||||
MyRectangle r = {
|
||||
SDL_Point p = {x, y};
|
||||
SDL_Rect r = {
|
||||
sp->cur.x + margin,
|
||||
sp->cur.y + margin,
|
||||
sp->curcg->sf->w - 2 * margin,
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "nact.h"
|
||||
#include "sact.h"
|
||||
#include "sprite.h"
|
||||
#include "sdl_core.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -63,7 +62,7 @@ static void tevent_callback(agsevent_t *e) {
|
||||
int update = 0;
|
||||
|
||||
// SP_MOVE の同期移動のためのカウンタの読み込み
|
||||
sact.movecurtime = sdl_getTicks();
|
||||
sact.movecurtime = sys_get_ticks();
|
||||
|
||||
for (node = sact.teventlisteners; node; node = node->next) {
|
||||
sprite_t *sp = (sprite_t *)node->data;
|
||||
|
||||
@@ -28,9 +28,7 @@
|
||||
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "sdl_core.h"
|
||||
#include "ags.h"
|
||||
#include "graphics.h"
|
||||
#include "sact.h"
|
||||
#include "sprite.h"
|
||||
|
||||
@@ -43,16 +41,16 @@ static void do_update_each(void* data, void* userdata);
|
||||
|
||||
// 領域1と領域2をすべて含む矩形領域を計算
|
||||
static void disjunction(void* region, void* data) {
|
||||
MyRectangle *r1 = (MyRectangle *)region;
|
||||
MyRectangle *r2 = (MyRectangle *)data;
|
||||
SDL_Rect *r1 = (SDL_Rect *)region;
|
||||
SDL_Rect *r2 = (SDL_Rect *)data;
|
||||
SDL_UnionRect(r1, r2, r2);
|
||||
free(r1);
|
||||
}
|
||||
|
||||
// 更新の必要なスプライトの領域の和をとってクリッピングする
|
||||
static void get_updatearea() {
|
||||
MyRectangle clip = {0, 0, 0, 0};
|
||||
MyRectangle screen = {0, 0, main_surface->w, main_surface->h};
|
||||
SDL_Rect clip = {0, 0, 0, 0};
|
||||
SDL_Rect screen = {0, 0, main_surface->w, main_surface->h};
|
||||
|
||||
slist_foreach(updatearea, disjunction, &clip);
|
||||
|
||||
@@ -93,7 +91,7 @@ void sp_update_all(bool syncscreen) {
|
||||
// スプライト移動がある場合は移動開始
|
||||
if (sact.movelist) {
|
||||
// 移動開始時間を合わせる
|
||||
sact.movestarttime = sdl_getTicks();
|
||||
sact.movestarttime = sys_get_ticks();
|
||||
slist_foreach(sact.movelist, spev_move_setup, NULL);
|
||||
slist_free(sact.movelist);
|
||||
sact.movelist = NULL;
|
||||
@@ -149,16 +147,16 @@ void sp_update_clipped() {
|
||||
@param sp: 更新するスプライト
|
||||
*/
|
||||
void sp_updateme(sprite_t *sp) {
|
||||
MyRectangle *r;
|
||||
SDL_Rect *r;
|
||||
|
||||
if (sp == NULL) return;
|
||||
if (sp->cursize.width == 0 || sp->cursize.height == 0) return;
|
||||
if (sp->width == 0 || sp->height == 0) return;
|
||||
|
||||
r = malloc(sizeof(MyRectangle));
|
||||
r = malloc(sizeof(SDL_Rect));
|
||||
r->x = sp->cur.x;
|
||||
r->y = sp->cur.y;
|
||||
r->w = sp->cursize.width;
|
||||
r->h = sp->cursize.height;
|
||||
r->w = sp->width;
|
||||
r->h = sp->height;
|
||||
|
||||
updatearea = slist_append(updatearea, r);
|
||||
|
||||
@@ -175,12 +173,12 @@ void sp_updateme(sprite_t *sp) {
|
||||
@param h: 更新領域高さ
|
||||
*/
|
||||
void sp_updateme_part(sprite_t *sp, int x, int y, int w, int h) {
|
||||
MyRectangle *r;
|
||||
SDL_Rect *r;
|
||||
|
||||
if (sp == NULL) return;
|
||||
if (w == 0 || h == 0) return;
|
||||
|
||||
r = malloc(sizeof(MyRectangle));
|
||||
r = malloc(sizeof(SDL_Rect));
|
||||
r->x = sp->cur.x + x;
|
||||
r->y = sp->cur.y + y;
|
||||
r->w = w;
|
||||
|
||||
@@ -36,13 +36,12 @@
|
||||
#include "nact.h"
|
||||
#include "ags.h"
|
||||
#include "music.h"
|
||||
#include "sdl_core.h"
|
||||
#include "hacks.h"
|
||||
|
||||
#define SLOT 40
|
||||
|
||||
static MyRectangle maprect; /* アニメーション表示領域 */
|
||||
static MyRectangle mapback; /* 背景セーブ領域 */
|
||||
static SDL_Rect maprect; /* アニメーション表示領域 */
|
||||
static SDL_Rect mapback; /* 背景セーブ領域 */
|
||||
static int mapback_p5; /* 背景転送先 X */
|
||||
static int mapback_p6; /* 背景転送先 Y */
|
||||
|
||||
@@ -451,7 +450,7 @@ static void PlayAnimeData() {
|
||||
dib = ags_getDIB();
|
||||
|
||||
for (loop = 0; loop < p1; loop++) {
|
||||
int cnt = sdl_getTicks();
|
||||
int cnt = sys_get_ticks();
|
||||
is_backcopied = false;
|
||||
|
||||
for (i = 0; i < SLOT; i++) {
|
||||
@@ -528,9 +527,9 @@ static void PlayAnimeData() {
|
||||
if (is_backcopied && !SDL_RectEmpty(&maprect))
|
||||
ags_updateArea(maprect.x, maprect.y, maprect.w, maprect.h);
|
||||
|
||||
int now = sdl_getTicks();
|
||||
int now = sys_get_ticks();
|
||||
if (now - cnt < interval) {
|
||||
sdl_sleep(interval - (now-cnt));
|
||||
sys_sleep(interval - (now-cnt));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "system.h"
|
||||
#include "xsystem35.h"
|
||||
#include "modules.h"
|
||||
#include "sdl_core.h"
|
||||
#include "input.h"
|
||||
#include "menu.h"
|
||||
|
||||
@@ -54,7 +53,7 @@ static void OutputMessageBox(void) { /* 0 */
|
||||
char *title_utf8 = toUTF8(svar_get(title));
|
||||
char *msg_utf8 = toUTF8(svar_get(msg));
|
||||
|
||||
sdl_showMessageBox(MESSAGEBOX_INFO, title_utf8, msg_utf8);
|
||||
sys_show_message_box(MESSAGEBOX_INFO, title_utf8, msg_utf8);
|
||||
|
||||
free(title_utf8);
|
||||
free(msg_utf8);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#ifndef __DRAWTEXT_H__
|
||||
#define __DRAWTEXT_H__
|
||||
|
||||
#include "graphics.h"
|
||||
#include "font.h"
|
||||
|
||||
struct SDL_Surface;
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ static void gre_BlendUseAMap(surface_t *dst, int dx, int dy, surface_t *src, int
|
||||
|
||||
void gr_blend_alpha_map(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int sw, int sh) {
|
||||
if (src == NULL || dst == NULL) return;
|
||||
MyRectangle src_window = { 0, 0, src->width, src->height };
|
||||
MyRectangle dst_window = { 0, 0, dst->width, dst->height };
|
||||
SDL_Rect src_window = { 0, 0, src->width, src->height };
|
||||
SDL_Rect dst_window = { 0, 0, dst->width, dst->height };
|
||||
if (!ags_clipCopyRect(&src_window, &dst_window, &sx, &sy, &dx, &dy, &sw, &sh)) return;
|
||||
|
||||
if (src->alpha == NULL) {
|
||||
|
||||
@@ -22,7 +22,7 @@ typedef struct {
|
||||
|
||||
static void *mapdata[NUM_MAPS];
|
||||
static int setChipParam_index;
|
||||
static MyRectangle chip_params[NUM_LAYERS];
|
||||
static SDL_Rect chip_params[NUM_LAYERS];
|
||||
static int window_width;
|
||||
static int window_height;
|
||||
static int map_width;
|
||||
@@ -68,7 +68,7 @@ static void MakeMapSetChipParam() {
|
||||
WARNING("unexpected MakeMapSeChipParam call");
|
||||
return;
|
||||
}
|
||||
MyRectangle *r = &chip_params[setChipParam_index++];
|
||||
SDL_Rect *r = &chip_params[setChipParam_index++];
|
||||
r->x = p1;
|
||||
r->y = p2;
|
||||
r->w = p3;
|
||||
@@ -93,9 +93,9 @@ static void MakeMapDraw() {
|
||||
int c1 = a1[index];
|
||||
int c2 = a2[index];
|
||||
int c3 = a3[index];
|
||||
MyRectangle *r1 = &chip_params[0];
|
||||
MyRectangle *r2 = &chip_params[1];
|
||||
MyRectangle *r3 = &chip_params[2];
|
||||
SDL_Rect *r1 = &chip_params[0];
|
||||
SDL_Rect *r2 = &chip_params[1];
|
||||
SDL_Rect *r3 = &chip_params[2];
|
||||
surface_t *dib = ags_getDIB();
|
||||
if (c3) {
|
||||
ags_copyArea(r3->x + c3 * r3->w, r3->y, r3->w, r3->h, dstX + x * r3->w, dstY + y * r3->h);
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "alk.h"
|
||||
#include "input.h"
|
||||
#include "bgm.h"
|
||||
#include "sdl_core.h"
|
||||
#include "gfx.h"
|
||||
#include "cg.h"
|
||||
#include "jpeg.h"
|
||||
|
||||
@@ -72,9 +72,9 @@ static void Run() {
|
||||
|
||||
musbgm_play(TDEMO_MUSIC_NO, 0, 100, 0);
|
||||
|
||||
uint32_t start = sdl_getTicks();
|
||||
uint32_t start = sys_get_ticks();
|
||||
while (!nact->is_quit) {
|
||||
int i = (sdl_getTicks() - start) / (1000 / FPS);
|
||||
int i = (sys_get_ticks() - start) / (1000 / FPS);
|
||||
if (i >= alk->datanum)
|
||||
break;
|
||||
|
||||
@@ -89,12 +89,12 @@ static void Run() {
|
||||
WARNING("Cannot decode CG %d", i);
|
||||
}
|
||||
|
||||
int wait_ms = (i + 1) * (1000 / FPS) - (sdl_getTicks() - start);
|
||||
int wait_ms = (i + 1) * (1000 / FPS) - (sys_get_ticks() - start);
|
||||
if (wait_ms > 0) {
|
||||
if (sys_keywait(wait_ms, KEYWAIT_CANCELABLE))
|
||||
break;
|
||||
} else {
|
||||
sdl_updateScreen();
|
||||
gfx_updateScreen();
|
||||
if (sys_getInputInfo())
|
||||
break;
|
||||
}
|
||||
|
||||
+7
-7
@@ -59,9 +59,14 @@ target_sources(xsystem35 PRIVATE
|
||||
cursor.c
|
||||
dri.c
|
||||
ecopy.c
|
||||
effect.c
|
||||
event.c
|
||||
filecheck.c
|
||||
font.c
|
||||
hacks.c
|
||||
gfx_draw.c
|
||||
gfx_image.c
|
||||
gfx_video.c
|
||||
image.c
|
||||
input.c
|
||||
jpeg.c
|
||||
@@ -82,13 +87,8 @@ target_sources(xsystem35 PRIVATE
|
||||
savedata.c
|
||||
scenario.c
|
||||
scheduler.c
|
||||
sdl_cursor.c
|
||||
sdl_draw.c
|
||||
sdl_effect.c
|
||||
sdl_event.c
|
||||
sdl_image.c
|
||||
sdl_video.c
|
||||
selection.c
|
||||
system.c
|
||||
texthook.c
|
||||
variable.c
|
||||
vsp.c
|
||||
@@ -125,7 +125,7 @@ elseif (ANDROID)
|
||||
elseif (ENABLE_GTK)
|
||||
target_sources(xsystem35 PRIVATE menu.c menu_callback.c menu_gui.c s39init.c)
|
||||
else ()
|
||||
target_sources(xsystem35 PRIVATE menu_sdl.c sdl_input.c)
|
||||
target_sources(xsystem35 PRIVATE menu_sdl.c editor.c)
|
||||
endif()
|
||||
|
||||
if (HAVE_WEBP)
|
||||
|
||||
@@ -35,7 +35,9 @@
|
||||
#include "xsystem35.h"
|
||||
#include "scenario.h"
|
||||
#include "ags.h"
|
||||
#include "sdl_core.h"
|
||||
#include "gfx.h"
|
||||
#include "effect.h"
|
||||
#include "event.h"
|
||||
#include "alpha_plane.h"
|
||||
#include "utfsjis.h"
|
||||
#include "input.h"
|
||||
@@ -81,25 +83,25 @@ static void initPal(void) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
nact->ags.pal[i].a = 255;
|
||||
}
|
||||
sdl_setPalette(nact->ags.pal, 0, 256);
|
||||
gfx_setPalette(nact->ags.pal, 0, 256);
|
||||
palette_changed();
|
||||
}
|
||||
|
||||
bool ags_check_param(int *x, int *y, int *w, int *h) {
|
||||
if (*x >= nact->ags.world_size.width) {
|
||||
WARNING("Illegal Param x = %d (max=%d)(@%03x:%05x)", *x, nact->ags.world_size.width, sl_getPage(), sl_getIndex());
|
||||
if (*x >= nact->ags.world_width) {
|
||||
WARNING("Illegal Param x = %d (max=%d)(@%03x:%05x)", *x, nact->ags.world_width, sl_getPage(), sl_getIndex());
|
||||
return false;
|
||||
}
|
||||
if (*y >= nact->ags.world_size.height) {
|
||||
WARNING("Illegal Param y = %d (max=%d)", *y, nact->ags.world_size.height);
|
||||
if (*y >= nact->ags.world_height) {
|
||||
WARNING("Illegal Param y = %d (max=%d)", *y, nact->ags.world_height);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*x < 0) { *w += *x; *x = 0; }
|
||||
if (*y < 0) { *h += *y; *y = 0; }
|
||||
|
||||
if ((*x + *w) > nact->ags.world_size.width) { *w = nact->ags.world_size.width - *x;}
|
||||
if ((*y + *h) > nact->ags.world_size.height) { *h = nact->ags.world_size.height - *y;}
|
||||
if ((*x + *w) > nact->ags.world_width) { *w = nact->ags.world_width - *x;}
|
||||
if ((*y + *h) > nact->ags.world_height) { *h = nact->ags.world_height - *y;}
|
||||
|
||||
if (*w <= 0) return false;
|
||||
if (*h <= 0) return false;
|
||||
@@ -108,11 +110,11 @@ bool ags_check_param(int *x, int *y, int *w, int *h) {
|
||||
}
|
||||
|
||||
bool ags_check_param_xy(int *x, int *y) {
|
||||
if (*x >= nact->ags.world_size.width) {
|
||||
if (*x >= nact->ags.world_width) {
|
||||
WARNING("Illegal Param x = %d", *x);
|
||||
return false;
|
||||
}
|
||||
if (*y >= nact->ags.world_size.height) {
|
||||
if (*y >= nact->ags.world_height) {
|
||||
WARNING("Illegal Param y = %d", *y);
|
||||
return false;
|
||||
}
|
||||
@@ -125,8 +127,8 @@ bool ags_check_param_xy(int *x, int *y) {
|
||||
|
||||
void ags_init(const char *render_driver, bool enable_zb) {
|
||||
nact->ags.mouse_warp_enabled = true;
|
||||
nact->ags.world_size.width = SYS35_DEFAULT_WIDTH;
|
||||
nact->ags.world_size.height = SYS35_DEFAULT_HEIGHT;
|
||||
nact->ags.world_width = SYS35_DEFAULT_WIDTH;
|
||||
nact->ags.world_height = SYS35_DEFAULT_HEIGHT;
|
||||
nact->ags.world_depth = SYS35_DEFAULT_DEPTH;
|
||||
nact->ags.view_area.x = 0;
|
||||
nact->ags.view_area.y = 0;
|
||||
@@ -139,7 +141,9 @@ void ags_init(const char *render_driver, bool enable_zb) {
|
||||
nact->ags.enable_zb = enable_zb;
|
||||
nact->ags.font_weight = enable_zb ? FONT_WEIGHT_BOLD : FONT_WEIGHT_NORMAL;
|
||||
|
||||
sdl_Initialize(render_driver);
|
||||
gfx_Initialize(render_driver);
|
||||
event_init();
|
||||
cursor_init();
|
||||
font_init();
|
||||
|
||||
initPal();
|
||||
@@ -148,7 +152,8 @@ void ags_init(const char *render_driver, bool enable_zb) {
|
||||
|
||||
void ags_remove(void) {
|
||||
ags_autorepeat(true);
|
||||
sdl_Remove();
|
||||
event_remove();
|
||||
gfx_Remove();
|
||||
}
|
||||
|
||||
void ags_reset(void) {
|
||||
@@ -159,8 +164,8 @@ void ags_reset(void) {
|
||||
}
|
||||
|
||||
void ags_setWorldSize(int width, int height, int depth) {
|
||||
nact->ags.world_size.width = width;
|
||||
nact->ags.world_size.height = height;
|
||||
nact->ags.world_width = width;
|
||||
nact->ags.world_height = height;
|
||||
nact->ags.world_depth = depth;
|
||||
|
||||
if (nact->ags.dib && nact->ags.dib->alpha) {
|
||||
@@ -168,9 +173,9 @@ void ags_setWorldSize(int width, int height, int depth) {
|
||||
nact->ags.dib->alpha = NULL;
|
||||
}
|
||||
|
||||
sdl_setWorldSize(width, height, depth);
|
||||
gfx_setWorldSize(width, height, depth);
|
||||
|
||||
nact->ags.dib = sdl_getDIB();
|
||||
nact->ags.dib = gfx_getDIB();
|
||||
|
||||
/* DIBが8以上の場合は、alpha plane を用意 */
|
||||
if (depth > 8) {
|
||||
@@ -188,29 +193,29 @@ void ags_setViewArea(int x, int y, int width, int height) {
|
||||
nact->ags.view_area.y = y;
|
||||
nact->ags.view_area.w = width;
|
||||
nact->ags.view_area.h = height;
|
||||
sdl_setWindowSize(width, height);
|
||||
gfx_setWindowSize(width, height);
|
||||
}
|
||||
|
||||
void ags_setWindowTitle(const char *title_utf8) {
|
||||
char buf[256];
|
||||
snprintf(buf, sizeof(buf), "XSystem35 Version %s: %s", VERSION, title_utf8);
|
||||
sdl_setWindowTitle(buf);
|
||||
gfx_setWindowTitle(buf);
|
||||
}
|
||||
|
||||
void ags_getDIBInfo(DispInfo *info) {
|
||||
info->width = nact->ags.world_size.width;
|
||||
info->height = nact->ags.world_size.height;
|
||||
info->width = nact->ags.world_width;
|
||||
info->height = nact->ags.world_height;
|
||||
info->depth = nact->ags.world_depth;
|
||||
}
|
||||
|
||||
void ags_getViewAreaInfo(DispInfo *info) {
|
||||
sdl_getWindowInfo(info);
|
||||
gfx_getWindowInfo(NULL, NULL, &info->depth);
|
||||
info->width = nact->ags.view_area.w;
|
||||
info->height = nact->ags.view_area.h;
|
||||
}
|
||||
|
||||
void ags_getWindowInfo(DispInfo *info) {
|
||||
sdl_getWindowInfo(info);
|
||||
gfx_getWindowInfo(&info->width, &info->height, &info->depth);
|
||||
}
|
||||
|
||||
void ags_setExposeSwitch(bool expose) {
|
||||
@@ -221,13 +226,13 @@ void ags_updateArea(int x, int y, int w, int h) {
|
||||
if (fade_outed || !need_update)
|
||||
return;
|
||||
|
||||
MyRectangle r = {x, y, w, h}, update;
|
||||
SDL_Rect r = {x, y, w, h}, update;
|
||||
if (SDL_IntersectRect(&nact->ags.view_area, &r, &update)) {
|
||||
MyPoint p = {
|
||||
SDL_Point p = {
|
||||
update.x - nact->ags.view_area.x,
|
||||
update.y - nact->ags.view_area.y
|
||||
};
|
||||
sdl_updateArea(&update, &p);
|
||||
gfx_updateArea(&update, &p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,14 +240,14 @@ void ags_updateFull() {
|
||||
if (fade_outed || !need_update)
|
||||
return;
|
||||
|
||||
MyRectangle r = {
|
||||
SDL_Rect r = {
|
||||
nact->ags.view_area.x,
|
||||
nact->ags.view_area.y,
|
||||
min(nact->ags.view_area.w, nact->ags.world_size.width),
|
||||
min(nact->ags.view_area.h, nact->ags.world_size.height)
|
||||
min(nact->ags.view_area.w, nact->ags.world_width),
|
||||
min(nact->ags.view_area.h, nact->ags.world_height)
|
||||
};
|
||||
MyPoint p = {0, 0};
|
||||
sdl_updateArea(&r, &p);
|
||||
SDL_Point p = {0, 0};
|
||||
gfx_updateArea(&r, &p);
|
||||
}
|
||||
|
||||
void ags_setPalettes(SDL_Color *src, int dst, int cnt) {
|
||||
@@ -261,47 +266,47 @@ void ags_setPalette(int no, int red, int green, int blue) {
|
||||
|
||||
void ags_setPaletteToSystem(int src, int cnt) {
|
||||
if (!fade_outed)
|
||||
sdl_setPalette(nact->ags.pal, src, cnt);
|
||||
gfx_setPalette(nact->ags.pal, src, cnt);
|
||||
}
|
||||
|
||||
void ags_drawRectangle(int x, int y, int w, int h, int col) {
|
||||
if (!ags_check_param(&x, &y, &w, &h)) return;
|
||||
|
||||
sdl_drawRectangle(x, y, w, h, col);
|
||||
gfx_drawRectangle(x, y, w, h, col);
|
||||
}
|
||||
|
||||
void ags_fillRectangle(int x, int y, int w, int h, int col) {
|
||||
if (!ags_check_param(&x, &y, &w, &h)) return;
|
||||
|
||||
sdl_fillRectangle(x, y, w, h, col);
|
||||
gfx_fillRectangle(x, y, w, h, col);
|
||||
}
|
||||
|
||||
void ags_drawLine(int x0, int y0, int x1, int y1, int col) {
|
||||
if (!ags_check_param_xy(&x0, &y0)) return;
|
||||
if (!ags_check_param_xy(&x1, &y1)) return;
|
||||
|
||||
sdl_drawLine(x0, y0, x1, y1, col);
|
||||
gfx_drawLine(x0, y0, x1, y1, col);
|
||||
}
|
||||
|
||||
void ags_copyArea(int sx, int sy, int w, int h, int dx, int dy) {
|
||||
if (!ags_check_param(&sx, &sy, &w, &h)) return;
|
||||
if (!ags_check_param(&dx, &dy, &w, &h)) return;
|
||||
|
||||
sdl_copyArea(sx, sy, w, h, dx, dy);
|
||||
gfx_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 (!ags_check_param(&sx, &sy, &sw, &sh)) return;
|
||||
if (!ags_check_param(&dx, &dy, &dw, &dh)) return;
|
||||
|
||||
sdl_scaledCopyArea(sx, sy, sw, sh, dx, dy, dw, dh, mirror_sw);
|
||||
gfx_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 (!ags_check_param(&sx, &sy, &w, &h)) return;
|
||||
if (!ags_check_param(&dx, &dy, &w, &h)) return;
|
||||
|
||||
sdl_copyAreaSP(sx, sy, w, h, dx, dy, col);
|
||||
gfx_copyAreaSP(sx, sy, w, h, dx, dy, col);
|
||||
}
|
||||
|
||||
void ags_wrapColor(int x, int y, int w, int h, int p1, int p2) {
|
||||
@@ -309,13 +314,18 @@ void ags_wrapColor(int x, int y, int w, int h, int p1, int p2) {
|
||||
|
||||
if (!ags_check_param(&x, &y, &w, &h)) return;
|
||||
|
||||
sdl_wrapColor(x, y, w, h, p1, p2);
|
||||
gfx_wrapColor(x, y, w, h, p1, p2);
|
||||
}
|
||||
|
||||
void ags_getPixel(int x, int y, Palette *cell) {
|
||||
void ags_getPixel(int x, int y, PixelColor *cell) {
|
||||
if (!ags_check_param_xy(&x, &y)) return;
|
||||
|
||||
sdl_getPixel(x, y, cell);
|
||||
uint32_t pixel = gfx_getPixel(x, y);
|
||||
if (main_surface->format->BitsPerPixel == 8) {
|
||||
cell->index = pixel;
|
||||
} else {
|
||||
SDL_GetRGB(pixel, main_surface->format, &cell->r, &cell->g, &cell->b);
|
||||
}
|
||||
}
|
||||
|
||||
void ags_copyPaletteShift(int sx, int sy, int w, int h, int dx, int dy, uint8_t sprite) {
|
||||
@@ -357,7 +367,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 (!ags_check_param(&x, &y, &w, &h)) return NULL;
|
||||
|
||||
return (void *)sdl_saveRegion(x, y, w, h);
|
||||
return (void *)gfx_saveRegion(x, y, w, h);
|
||||
}
|
||||
|
||||
void ags_restoreRegion(void *region, int x, int y) {
|
||||
@@ -365,7 +375,7 @@ void ags_restoreRegion(void *region, int x, int y) {
|
||||
|
||||
if (!ags_check_param_xy(&x, &y)) return;
|
||||
|
||||
sdl_restoreRegion(region, x, y);
|
||||
gfx_restoreRegion(region, x, y);
|
||||
}
|
||||
|
||||
void ags_putRegion(void *region, int x, int y) {
|
||||
@@ -373,16 +383,16 @@ void ags_putRegion(void *region, int x, int y) {
|
||||
|
||||
if (!ags_check_param_xy(&x, &y)) return;
|
||||
|
||||
sdl_putRegion(region, x, y);
|
||||
gfx_putRegion(region, x, y);
|
||||
}
|
||||
|
||||
void ags_delRegion(void *region) {
|
||||
if (region == NULL) return;
|
||||
|
||||
sdl_delRegion(region);
|
||||
gfx_delRegion(region);
|
||||
}
|
||||
|
||||
int ags_drawString(int x, int y, const char *src, int col, MyRectangle *rect_out) {
|
||||
int ags_drawString(int x, int y, const char *src, int col, SDL_Rect *rect_out) {
|
||||
if (!ags_check_param_xy(&x, &y)) {
|
||||
if (rect_out) {
|
||||
rect_out->x = x;
|
||||
@@ -393,7 +403,7 @@ int ags_drawString(int x, int y, const char *src, int col, MyRectangle *rect_out
|
||||
return 0;
|
||||
}
|
||||
|
||||
MyRectangle adj;
|
||||
SDL_Rect adj;
|
||||
char *utf8 = toUTF8(src);
|
||||
switch(nact->ags.text_decoration_type) {
|
||||
case TEXT_DECORATION_NONE:
|
||||
@@ -401,46 +411,46 @@ int ags_drawString(int x, int y, const char *src, int col, MyRectangle *rect_out
|
||||
adj.x = 0; adj.y = 0; adj.w = 0; adj.h = 0;
|
||||
break;
|
||||
case TEXT_DECORATION_DROP_SHADOW_BOTTOM:
|
||||
sdl_drawString(x, y +1, utf8, nact->ags.text_decoration_color);
|
||||
gfx_drawString(x, y +1, utf8, nact->ags.text_decoration_color);
|
||||
adj.x = 0; adj.y = 0; adj.w = 0; adj.h = 1;
|
||||
break;
|
||||
case TEXT_DECORATION_DROP_SHADOW_RIGHT:
|
||||
sdl_drawString(x +1, y, utf8, nact->ags.text_decoration_color);
|
||||
gfx_drawString(x +1, y, utf8, nact->ags.text_decoration_color);
|
||||
adj.x = 0; adj.y = 0; adj.w = 1; adj.h = 0;
|
||||
break;
|
||||
case TEXT_DECORATION_DROP_SHADOW_BOTTOM_RIGHT:
|
||||
sdl_drawString(x +1, y +1, utf8, nact->ags.text_decoration_color);
|
||||
gfx_drawString(x +1, y +1, utf8, nact->ags.text_decoration_color);
|
||||
adj.x = 0; adj.y = 0; adj.w = 1; adj.h = 1;
|
||||
break;
|
||||
case TEXT_DECORATION_OUTLINE:
|
||||
sdl_drawString(x -1, y, utf8, nact->ags.text_decoration_color);
|
||||
sdl_drawString(x +1, y, utf8, nact->ags.text_decoration_color);
|
||||
sdl_drawString(x, y -1, utf8, nact->ags.text_decoration_color);
|
||||
sdl_drawString(x, y +1, utf8, nact->ags.text_decoration_color);
|
||||
gfx_drawString(x -1, y, utf8, nact->ags.text_decoration_color);
|
||||
gfx_drawString(x +1, y, utf8, nact->ags.text_decoration_color);
|
||||
gfx_drawString(x, y -1, utf8, nact->ags.text_decoration_color);
|
||||
gfx_drawString(x, y +1, utf8, nact->ags.text_decoration_color);
|
||||
adj.x = -1; adj.y = -1; adj.w = 2; adj.h = 2;
|
||||
break;
|
||||
case TEXT_DECORATION_BOLD_HORIZONTAL:
|
||||
sdl_drawString(x +1, y, utf8, col);
|
||||
gfx_drawString(x +1, y, utf8, col);
|
||||
adj.x = 0; adj.y = 0; adj.w = 1; adj.h = 0;
|
||||
break;
|
||||
case TEXT_DECORATION_BOLD_VERTICAL:
|
||||
sdl_drawString(x, y +1, utf8, col);
|
||||
gfx_drawString(x, y +1, utf8, col);
|
||||
adj.x = 0; adj.y = 0; adj.w = 0; adj.h = 1;
|
||||
break;
|
||||
case TEXT_DECORATION_BOLD_HORIZONTAL_VERTICAL:
|
||||
sdl_drawString(x +1, y +1, utf8, col);
|
||||
gfx_drawString(x +1, y +1, utf8, col);
|
||||
adj.x = 0; adj.y = 0; adj.w = 1; adj.h = 1;
|
||||
break;
|
||||
case TEXT_DECORATION_DROP_SHADOW_OUTLINE:
|
||||
sdl_drawString(x -1, y , utf8, nact->ags.text_decoration_color);
|
||||
sdl_drawString(x +1, y , utf8, nact->ags.text_decoration_color);
|
||||
sdl_drawString(x , y -1, utf8, nact->ags.text_decoration_color);
|
||||
sdl_drawString(x , y +1, utf8, nact->ags.text_decoration_color);
|
||||
sdl_drawString(x +2, y +2, utf8, nact->ags.text_decoration_color);
|
||||
gfx_drawString(x -1, y , utf8, nact->ags.text_decoration_color);
|
||||
gfx_drawString(x +1, y , utf8, nact->ags.text_decoration_color);
|
||||
gfx_drawString(x , y -1, utf8, nact->ags.text_decoration_color);
|
||||
gfx_drawString(x , y +1, utf8, nact->ags.text_decoration_color);
|
||||
gfx_drawString(x +2, y +2, utf8, nact->ags.text_decoration_color);
|
||||
adj.x = -1; adj.y = -1; adj.w = 3; adj.h = 3;
|
||||
break;
|
||||
}
|
||||
SDL_Rect r = sdl_drawString(x, y, utf8, col);
|
||||
SDL_Rect r = gfx_drawString(x, y, utf8, col);
|
||||
if (rect_out) {
|
||||
rect_out->x = r.x + adj.x;
|
||||
rect_out->y = r.y + adj.y;
|
||||
@@ -461,13 +471,13 @@ SDL_Surface *ags_drawStringToSurface(const char *str, int r, int g, int b) {
|
||||
void ags_drawCg(cgdata *cg, int x, int y, int brightness, int sprite_color, bool alpha_blend) {
|
||||
switch (cg->depth) {
|
||||
case 8:
|
||||
sdl_drawImage8(cg, x, y, sprite_color);
|
||||
gfx_drawImage8(cg, x, y, sprite_color);
|
||||
break;
|
||||
case 16:
|
||||
sdl_drawImage16(cg, nact->ags.dib, x, y, brightness, alpha_blend);
|
||||
gfx_drawImage16(cg, nact->ags.dib, x, y, brightness, alpha_blend);
|
||||
break;
|
||||
case 24:
|
||||
sdl_drawImage24(cg, nact->ags.dib, x, y, brightness);
|
||||
gfx_drawImage24(cg, nact->ags.dib, x, y, brightness);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -478,7 +488,7 @@ void ags_copyArea_shadow(int sx, int sy, int w, int h, int dx, int dy) {
|
||||
if (!ags_check_param(&sx, &sy, &w, &h)) return;
|
||||
if (!ags_check_param(&dx, &dy, &w, &h)) return;
|
||||
|
||||
sdl_copyAreaSP16_shadow(sx, sy, w, h, dx, dy, 255);
|
||||
gfx_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) {
|
||||
@@ -487,7 +497,7 @@ void ags_copyArea_transparent(int sx, int sy, int w, int h, int dx, int dy, int
|
||||
if (!ags_check_param(&sx, &sy, &w, &h)) return;
|
||||
if (!ags_check_param(&dx, &dy, &w, &h)) return;
|
||||
|
||||
sdl_copyAreaSP(sx, sy, w, h, dx, dy, col);
|
||||
gfx_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) {
|
||||
@@ -496,7 +506,7 @@ void ags_copyArea_alphaLevel(int sx, int sy, int w, int h, int dx, int dy, int l
|
||||
if (!ags_check_param(&sx, &sy, &w, &h)) return;
|
||||
if (!ags_check_param(&dx, &dy, &w, &h)) return;
|
||||
|
||||
sdl_copyAreaSP16_alphaLevel(sx, sy, w, h, dx, dy, lv);
|
||||
gfx_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) {
|
||||
@@ -505,14 +515,14 @@ void ags_copyArea_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, int l
|
||||
if (!ags_check_param(&sx, &sy, &w, &h)) return;
|
||||
if (!ags_check_param(&dx, &dy, &w, &h)) return;
|
||||
|
||||
sdl_copyAreaSP16_alphaBlend(sx, sy, w, h, dx, dy, lv);
|
||||
gfx_copyAreaSP16_alphaBlend(sx, sy, w, h, dx, dy, lv);
|
||||
}
|
||||
|
||||
MyRectangle ags_floodFill(int x, int y, int col) {
|
||||
SDL_Rect ags_floodFill(int x, int y, int col) {
|
||||
if (!ags_check_param_xy(&x, &y))
|
||||
return (MyRectangle){};
|
||||
return (SDL_Rect){};
|
||||
|
||||
return sdl_floodFill(x, y, col);
|
||||
return gfx_floodFill(x, y, col);
|
||||
}
|
||||
|
||||
void ags_copyFromAlpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flg) {
|
||||
@@ -521,7 +531,7 @@ void ags_copyFromAlpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_C
|
||||
if (!ags_check_param(&sx, &sy, &w, &h)) return;
|
||||
if (!ags_check_param(&dx, &dy, &w, &h)) return;
|
||||
|
||||
sdl_copy_from_alpha(sx, sy, w, h, dx, dy, flg);
|
||||
gfx_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) {
|
||||
@@ -530,7 +540,7 @@ void ags_copyToAlpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COP
|
||||
if (!ags_check_param(&sx, &sy, &w, &h)) return;
|
||||
if (!ags_check_param(&dx, &dy, &w, &h)) return;
|
||||
|
||||
sdl_copy_to_alpha(sx, sy, w, h, dx, dy, flg);
|
||||
gfx_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) {
|
||||
@@ -592,10 +602,10 @@ void ags_alpha_setPixel(int x, int y, int w, int h, uint8_t *b) {
|
||||
|
||||
void ags_runEffect(int duration_ms, bool cancelable, ags_EffectStepFunc step, void *arg) {
|
||||
unsigned wflags = cancelable ? KEYWAIT_CANCELABLE : KEYWAIT_NONCANCELABLE;
|
||||
int start = sdl_getTicks();
|
||||
for (int t = 0; t < duration_ms; t = sdl_getTicks() - start) {
|
||||
int start = sys_get_ticks();
|
||||
for (int t = 0; t < duration_ms; t = sys_get_ticks() - start) {
|
||||
step(arg, (float)t / duration_ms);
|
||||
int key = sys_keywait(start + t + 16 - sdl_getTicks(), wflags);
|
||||
int key = sys_keywait(start + t + 16 - sys_get_ticks(), wflags);
|
||||
if (cancelable && key) {
|
||||
nact->waitcancel_key = key;
|
||||
break;
|
||||
@@ -604,22 +614,22 @@ void ags_runEffect(int duration_ms, bool cancelable, ags_EffectStepFunc step, vo
|
||||
step(arg, 1.0);
|
||||
}
|
||||
|
||||
static void fade(int duration, bool cancelable, enum sdl_effect_type type) {
|
||||
static void fade(int duration, bool cancelable, enum effect_type type) {
|
||||
nact->waitcancel_key = 0;
|
||||
|
||||
SDL_Rect rect = {0, 0, nact->ags.view_area.w, nact->ags.view_area.h};
|
||||
struct sdl_effect *eff = sdl_effect_init(
|
||||
struct effect *eff = effect_init(
|
||||
&rect, NULL, 0, 0,
|
||||
sdl_getDIB(), nact->ags.view_area.x, nact->ags.view_area.y,
|
||||
gfx_getDIB(), nact->ags.view_area.x, nact->ags.view_area.y,
|
||||
type);
|
||||
ags_runEffect(duration, cancelable, (ags_EffectStepFunc)sdl_effect_step, eff);
|
||||
sdl_effect_finish(eff);
|
||||
ags_runEffect(duration, cancelable, (ags_EffectStepFunc)effect_step, eff);
|
||||
effect_finish(eff);
|
||||
}
|
||||
|
||||
void ags_fadeIn(int rate, bool flag) {
|
||||
fade_outed = false;
|
||||
if (nact->ags.world_depth == 8)
|
||||
sdl_setPalette(nact->ags.pal, 0, 256);
|
||||
gfx_setPalette(nact->ags.pal, 0, 256);
|
||||
|
||||
if (!need_update)
|
||||
return;
|
||||
@@ -627,7 +637,7 @@ void ags_fadeIn(int rate, bool flag) {
|
||||
int duration = rate * 16 * 1000 / 60;
|
||||
fade(duration, flag, nact->ags.world_depth == 8 ? EFFECT_FADEIN : EFFECT_DITHERING_FADEIN);
|
||||
|
||||
sdl_updateAll(&nact->ags.view_area);
|
||||
gfx_updateAll(&nact->ags.view_area);
|
||||
}
|
||||
|
||||
void ags_fadeOut(int rate, bool flag) {
|
||||
@@ -642,14 +652,14 @@ void ags_fadeOut(int rate, bool flag) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
pal[i] = (SDL_Color){0, 0, 0, 255};
|
||||
}
|
||||
sdl_setPalette(pal, 0, 256);
|
||||
gfx_setPalette(pal, 0, 256);
|
||||
}
|
||||
}
|
||||
|
||||
void ags_whiteIn(int rate, bool flag) {
|
||||
fade_outed = false;
|
||||
if (nact->ags.world_depth == 8)
|
||||
sdl_setPalette(nact->ags.pal, 0, 256);
|
||||
gfx_setPalette(nact->ags.pal, 0, 256);
|
||||
|
||||
if (!need_update)
|
||||
return;
|
||||
@@ -657,7 +667,7 @@ void ags_whiteIn(int rate, bool flag) {
|
||||
int duration = rate * 16 * 1000 / 60;
|
||||
fade(duration, flag, nact->ags.world_depth == 8 ? EFFECT_WHITEIN : EFFECT_DITHERING_WHITEIN);
|
||||
|
||||
sdl_updateAll(&nact->ags.view_area);
|
||||
gfx_updateAll(&nact->ags.view_area);
|
||||
}
|
||||
|
||||
void ags_whiteOut(int rate, bool flag) {
|
||||
@@ -670,7 +680,7 @@ void ags_whiteOut(int rate, bool flag) {
|
||||
if (nact->ags.world_depth == 8) {
|
||||
SDL_Color pal[256];
|
||||
memset(&pal, 255, sizeof(pal));
|
||||
sdl_setPalette(pal, 0, 256);
|
||||
gfx_setPalette(pal, 0, 256);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -692,7 +702,7 @@ void ags_setTextDecorationColor(int col) {
|
||||
|
||||
void ags_setCursorType(int type) {
|
||||
if (nact->ags.noimagecursor && type >= 100) return;
|
||||
sdl_setCursorType(type);
|
||||
cursor_set_type(type);
|
||||
}
|
||||
|
||||
void ags_loadCursor(int p1,int p2) {
|
||||
@@ -715,26 +725,26 @@ void ags_setCursorLocation(int x, int y, bool is_dibgeo, bool for_selection) {
|
||||
// We can't move the actual cursor in the browser, but can change the
|
||||
// internal mouse coordinates. This can help with keyboard/gamepad
|
||||
// navigation.
|
||||
sdl_setCursorInternalLocation(x, y);
|
||||
event_set_mouse_internal_location(x, y);
|
||||
EM_ASM({ xsystem35.shell.showMouseMoveEffect($0, $1); }, x, y);
|
||||
sdl_sleep(cursor_move_time);
|
||||
sys_sleep(cursor_move_time);
|
||||
}
|
||||
#else
|
||||
if (nact->ags.mouse_warp_enabled) {
|
||||
MyPoint p;
|
||||
SDL_Point p;
|
||||
sys_getMouseInfo(&p, is_dibgeo);
|
||||
int dx = x - p.x;
|
||||
int dy = y - p.y;
|
||||
for (int i = 1; i < 8; i++) {
|
||||
int xi = ((dx*i*i*i) >> 9) - ((3*dx*i*i)>> 6) + ((3*dx*i) >> 3) + p.x;
|
||||
int yi = ((dy*i*i*i) >> 9) - ((3*dy*i*i)>> 6) + ((3*dy*i) >> 3) + p.y;
|
||||
sdl_setCursorLocation(xi, yi);
|
||||
sdl_sleep(cursor_move_time / 7);
|
||||
event_set_mouse_location(xi, yi);
|
||||
sys_sleep(cursor_move_time / 7);
|
||||
}
|
||||
sdl_setCursorLocation(x, y);
|
||||
event_set_mouse_location(x, y);
|
||||
} else if (!for_selection) {
|
||||
sdl_setCursorInternalLocation(x, y);
|
||||
sdl_sleep(cursor_move_time);
|
||||
event_set_mouse_internal_location(x, y);
|
||||
sys_sleep(cursor_move_time);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -758,7 +768,7 @@ void ags_copyArea_shadow_withrate(int sx, int sy, int w, int h, int dx, int dy,
|
||||
if (!ags_check_param(&sx, &sy, &w, &h)) return;
|
||||
if (!ags_check_param(&dx, &dy, &w, &h)) return;
|
||||
|
||||
sdl_copyAreaSP16_shadow(sx, sy, w, h, dx, dy, lv);
|
||||
gfx_copyAreaSP16_shadow(sx, sy, w, h, dx, dy, lv);
|
||||
}
|
||||
|
||||
void ags_setCursorMoveTime(int msec) {
|
||||
@@ -774,10 +784,14 @@ surface_t *ags_getDIB() {
|
||||
}
|
||||
|
||||
void ags_autorepeat(bool enable) {
|
||||
sdl_setAutoRepeat(enable);
|
||||
if (enable) {
|
||||
// SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
} else {
|
||||
// SDL_EnableKeyRepeat(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
bool ags_clipCopyRect(const MyRectangle *sw, const MyRectangle *dw, int *sx, int *sy, int *dx, int *dy, int *w, int *h) {
|
||||
bool ags_clipCopyRect(const SDL_Rect *sw, const SDL_Rect *dw, int *sx, int *sy, int *dx, int *dy, int *w, int *h) {
|
||||
// Clip source rectangle to source window
|
||||
SDL_Rect sr = {*sx, *sy, *w, *h};
|
||||
if (!SDL_IntersectRect(&sr, sw, &sr))
|
||||
|
||||
@@ -29,22 +29,7 @@
|
||||
#include <SDL_surface.h>
|
||||
#include "portab.h"
|
||||
#include "cg.h"
|
||||
#include "graphics.h"
|
||||
|
||||
/* マウスカーソルの種類 */
|
||||
#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
|
||||
#include "font.h"
|
||||
|
||||
/* RGB <-> alpha plane copy type */
|
||||
typedef enum {
|
||||
@@ -111,13 +96,26 @@ typedef enum {
|
||||
TEXT_DECORATION_DROP_SHADOW_OUTLINE = 10,
|
||||
} TextDecorationType;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t r, g, b;
|
||||
uint32_t index;
|
||||
} PixelColor;
|
||||
|
||||
typedef struct {
|
||||
int width;
|
||||
int height;
|
||||
int depth;
|
||||
} DispInfo;
|
||||
|
||||
struct _ags {
|
||||
SDL_Color pal[256]; /* system palette */
|
||||
bool pal_changed; /* system palette has changed */
|
||||
|
||||
MyDimension world_size; /* size of off-screen */
|
||||
|
||||
MyRectangle view_area; /* view region in off-screen */
|
||||
int world_width;
|
||||
int world_height;
|
||||
|
||||
SDL_Rect view_area; /* view region in off-screen */
|
||||
|
||||
int world_depth; /* depth of off-screen (bits per pixel) */
|
||||
|
||||
@@ -174,7 +172,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, Palette *cell);
|
||||
extern void ags_getPixel(int x, int y, PixelColor *cell);
|
||||
extern void ags_copyPaletteShift(int sx, int sy, int w, int h, int dx, int dy, uint8_t sprite);
|
||||
extern void ags_changeColorArea(int x, int y, int w, int h, int dst, int src, int cnt);
|
||||
|
||||
@@ -183,14 +181,14 @@ extern void ags_restoreRegion(void *region, int x, int y);
|
||||
extern void ags_putRegion(void *region, int x, int y);
|
||||
extern void ags_delRegion(void *region);
|
||||
|
||||
extern int ags_drawString(int x, int y, const char *src, int col, MyRectangle *rect_out);
|
||||
extern int ags_drawString(int x, int y, const char *src, int col, SDL_Rect *rect_out);
|
||||
extern void ags_drawCg(cgdata *cg, int x, int y, int brightness, int sprite_color, bool alpha_blend);
|
||||
|
||||
extern void ags_copyArea_shadow(int sx, int sy, int w, int h, int dx, int dy);
|
||||
extern void ags_copyArea_transparent(int sx, int sy, int w, int h, int dx, int dy, int col);
|
||||
extern void ags_copyArea_alphaLevel(int sx, int sy, int w, int h, int dx, int dy, int lv);
|
||||
extern void ags_copyArea_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, int lv);
|
||||
extern MyRectangle ags_floodFill(int x, int y, int col);
|
||||
extern SDL_Rect ags_floodFill(int x, int y, int col);
|
||||
extern void ags_eCopyArea(int sx, int sy, int w, int h, int dx, int dy, int sw, int opt, bool cancel);
|
||||
extern void ags_eSpriteCopyArea(int sx, int sy, int w, int h, int dx, int dy, int sw, int opt, bool cancel, int spCol);
|
||||
|
||||
@@ -228,7 +226,7 @@ extern int ags_getCursorMoveTime();
|
||||
extern void ags_setAntialiasedStringMode(bool mode);
|
||||
extern bool ags_getAntialiasedStringMode();
|
||||
extern void ags_autorepeat(bool enable);
|
||||
extern bool ags_clipCopyRect(const MyRectangle *sr, const MyRectangle *dr, int *sx, int *sy, int *dx, int *dy, int *w, int *h);
|
||||
extern bool ags_clipCopyRect(const SDL_Rect *sr, const SDL_Rect *dr, int *sx, int *sy, int *dx, int *dy, int *w, int *h);
|
||||
|
||||
typedef void (*ags_EffectStepFunc)(void *, float);
|
||||
void ags_runEffect(int duration_ms, bool cancelable, ags_EffectStepFunc step, void *arg);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "nact.h"
|
||||
#include "bgm.h"
|
||||
#include "bgi.h"
|
||||
#include "sdl_core.h"
|
||||
#include "system.h"
|
||||
|
||||
bool musbgm_init(DRIFILETYPE type, int base_no) {
|
||||
if (type == DRIFILE_BGM)
|
||||
@@ -84,6 +84,6 @@ void musbgm_wait(int no, int timeout) {
|
||||
for (int i = 0; i * 16 < timeout * 10; i++) {
|
||||
if (!musbgm_isplaying(no))
|
||||
break;
|
||||
sdl_wait_vsync();
|
||||
sys_wait_vsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <stdlib.h>
|
||||
#include "portab.h"
|
||||
#include "LittleEndian.h"
|
||||
#include "graphics.h"
|
||||
#include "cg.h"
|
||||
#include "bmp.h"
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "portab.h"
|
||||
#include "cdrom.h"
|
||||
#include "scheduler.h"
|
||||
#include "system.h"
|
||||
|
||||
static bool cdrom_init(char *playlist) {
|
||||
return true;
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <SDL.h>
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "graphics.h"
|
||||
#include "nact.h"
|
||||
#include "ags.h"
|
||||
#include "cg.h"
|
||||
@@ -57,7 +56,7 @@ int cg_brightness;
|
||||
|
||||
/* CG表示位置に関する情報 */
|
||||
static CG_WHERETODISP loc_policy, loc_policy0;
|
||||
static MyPoint loc_where, loc_where0;
|
||||
static SDL_Point loc_where, loc_where0;
|
||||
|
||||
/* extracted cg data cache control object */
|
||||
static cacher *cacheid;
|
||||
@@ -65,7 +64,7 @@ static cacher *cacheid;
|
||||
/* static methods */
|
||||
static CG_TYPE check_cgformat(uint8_t *data);
|
||||
static void set_vspbank(uint8_t *pic, int bank, int width, int height);
|
||||
static MyPoint set_display_loc(cgdata *cg);
|
||||
static SDL_Point set_display_loc(cgdata *cg);
|
||||
static void clear_display_loc();
|
||||
static void display_cg(cgdata *cg, int x, int y, int sprite_color, bool alpha_blend);
|
||||
static cgdata *loader(int no);
|
||||
@@ -131,8 +130,8 @@ void cgdata_free(cgdata *cg) {
|
||||
* cg: cg information
|
||||
* return: x and y for display location
|
||||
*/
|
||||
static MyPoint set_display_loc(cgdata *cg) {
|
||||
MyPoint p;
|
||||
static SDL_Point set_display_loc(cgdata *cg) {
|
||||
SDL_Point p;
|
||||
|
||||
switch(loc_policy) {
|
||||
case OFFSET_ABSOLUTE_GC:
|
||||
@@ -288,7 +287,7 @@ void cg_set_display_location(int x, int y, CG_WHERETODISP policy) {
|
||||
*/
|
||||
void cg_load(int no, int flg) {
|
||||
cgdata *cg;
|
||||
MyPoint p;
|
||||
SDL_Point p;
|
||||
int i, bank = cg_vspPB;
|
||||
|
||||
/* load and extract cg */
|
||||
@@ -361,7 +360,7 @@ void cg_load(int no, int flg) {
|
||||
*/
|
||||
void cg_load_with_alpha(int cgno, int shadowno) {
|
||||
cgdata *cg = NULL, *scg;
|
||||
MyPoint p;
|
||||
SDL_Point p;
|
||||
|
||||
/* load pixel */
|
||||
if (cgno >= 0) {
|
||||
@@ -441,7 +440,7 @@ int cg_load_with_filename(char *fname_utf8, int x, int y) {
|
||||
long filesize;
|
||||
uint8_t *data;
|
||||
cgdata *cg = NULL;
|
||||
MyPoint p;
|
||||
SDL_Point p;
|
||||
|
||||
data = load_cg_from_file(fname_utf8, &status, &filesize);
|
||||
if (data == NULL) return status;
|
||||
@@ -490,9 +489,9 @@ int cg_load_with_filename(char *fname_utf8, int x, int y) {
|
||||
* no : file no for cg ( >= 0 )
|
||||
* info: information to be retored
|
||||
*/
|
||||
void cg_get_info(int no, MyRectangle *info) {
|
||||
void cg_get_info(int no, SDL_Rect *info) {
|
||||
cgdata *cg = loader(no);
|
||||
MyPoint p;
|
||||
SDL_Point p;
|
||||
|
||||
if (cg == NULL) {
|
||||
info->x = info->y = info->w = info->h = 0;
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
#ifndef __CG__
|
||||
#define __CG__
|
||||
|
||||
#include <SDL_rect.h>
|
||||
#include "portab.h"
|
||||
#include "graphics.h"
|
||||
|
||||
struct SDL_Surface;
|
||||
|
||||
@@ -80,7 +80,7 @@ extern void cg_set_display_location(int x, int y, CG_WHERETODISP policy);
|
||||
extern void cg_load(int no, int flg);
|
||||
extern void cg_load_with_alpha(int cgno, int shadowno);
|
||||
extern int cg_load_with_filename(char *fname_utf8, int x, int y);
|
||||
extern void cg_get_info(int no, MyRectangle *info);
|
||||
extern void cg_get_info(int no, SDL_Rect *info);
|
||||
extern void cg_clear_display_loc();
|
||||
extern void cgdata_free(cgdata *cg);
|
||||
extern struct SDL_Surface *cg_load_as_sdlsurface(int no);
|
||||
|
||||
+8
-8
@@ -38,7 +38,7 @@
|
||||
#include "utfsjis.h"
|
||||
#include "hankaku.h"
|
||||
#include "ags.h"
|
||||
#include "sdl_core.h"
|
||||
#include "gfx.h"
|
||||
#include "ald_manager.h"
|
||||
#include "LittleEndian.h"
|
||||
#include "hacks.h"
|
||||
@@ -107,7 +107,7 @@ void commands2F04() {
|
||||
|
||||
void commands2F05() {
|
||||
/* 現在のテキスト表示位置をスタックにプッシュする */
|
||||
MyPoint loc;
|
||||
SDL_Point loc;
|
||||
msg_getMessageLocation(&loc);
|
||||
sl_pushTextLoc(loc.x, loc.y);
|
||||
TRACE("TPP:");
|
||||
@@ -706,7 +706,7 @@ void commands2F43() {
|
||||
int eLength = getCaliValue();
|
||||
int eColor = getCaliValue();
|
||||
|
||||
sdl_fillCircle(eX, eY, eLength, eColor);
|
||||
gfx_fillCircle(eX, eY, eLength, eColor);
|
||||
ags_updateArea(eX, eY, eLength, eLength);
|
||||
|
||||
TRACE("grDrawFillCircle %d, %d, %d, %d:", eX, eY, eLength, eColor);
|
||||
@@ -781,10 +781,10 @@ void commands2F4C() {
|
||||
int eWidth = getCaliValue();
|
||||
int eHeight = getCaliValue();
|
||||
|
||||
MyRectangle r = {eSrcX, eSrcY, eWidth, eHeight};
|
||||
MyPoint p = {eX, eY};
|
||||
SDL_Rect r = {eSrcX, eSrcY, eWidth, eHeight};
|
||||
SDL_Point p = {eX, eY};
|
||||
|
||||
sdl_updateArea(&r, &p);
|
||||
gfx_updateArea(&r, &p);
|
||||
|
||||
TRACE("grBlt %d, %d, %d, %d, %d, %d:",
|
||||
eX, eY, eSrcX, eSrcY, eWidth, eHeight);
|
||||
@@ -943,7 +943,7 @@ void commands2F5A() {
|
||||
char *t1;
|
||||
|
||||
t1 = toUTF8(sText);
|
||||
sdl_showMessageBox(MESSAGEBOX_INFO, nact->game_title_utf8, t1);
|
||||
sys_show_message_box(MESSAGEBOX_INFO, nact->game_title_utf8, t1);
|
||||
free(t1);
|
||||
|
||||
TRACE("strMessageBox %s:", sText);
|
||||
@@ -954,7 +954,7 @@ void commands2F5B() {
|
||||
char *t1;
|
||||
|
||||
t1 = toUTF8(svar_get(eNum));
|
||||
sdl_showMessageBox(MESSAGEBOX_INFO, nact->game_title_utf8, t1);
|
||||
sys_show_message_box(MESSAGEBOX_INFO, nact->game_title_utf8, t1);
|
||||
free(t1);
|
||||
|
||||
TRACE("strMessageBoxStr %d:", eNum);
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@
|
||||
#include "selection.h"
|
||||
#include "message.h"
|
||||
#include "input.h"
|
||||
#include "sdl_core.h"
|
||||
#include "gfx.h"
|
||||
|
||||
static void undeferr();
|
||||
|
||||
@@ -181,7 +181,7 @@ void exec_command(void) {
|
||||
int c0 = sl_getc();
|
||||
|
||||
if (c0 == BREAKPOINT) {
|
||||
sdl_updateScreen();
|
||||
gfx_updateScreen();
|
||||
c0 = dbg_handle_breakpoint(sl_getPage(), sl_getIndex() - 1);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@ void commandB4() {
|
||||
}
|
||||
|
||||
void commandB10() {
|
||||
MyPoint p;
|
||||
SDL_Point p;
|
||||
int *x_var = getCaliVariable();
|
||||
int *y_var = getCaliVariable();
|
||||
|
||||
|
||||
+1
-1
@@ -265,7 +265,7 @@ void commandCP() {
|
||||
int y = getCaliValue();
|
||||
int color = getCaliValue();
|
||||
|
||||
MyRectangle rec = ags_floodFill(x, y, color);
|
||||
SDL_Rect rec = ags_floodFill(x, y, color);
|
||||
if (!SDL_RectEmpty(&rec))
|
||||
ags_updateArea(rec.x, rec.y, rec.w, rec.h);
|
||||
|
||||
|
||||
+6
-7
@@ -26,10 +26,9 @@
|
||||
#include "xsystem35.h"
|
||||
#include "scenario.h"
|
||||
#include "ags.h"
|
||||
#include "graphics.h"
|
||||
|
||||
typedef struct {
|
||||
MyRectangle r;
|
||||
SDL_Rect r;
|
||||
int pal;
|
||||
} Ecomtbl;
|
||||
|
||||
@@ -55,7 +54,7 @@ void commandES() {
|
||||
void commandEC() {
|
||||
int num = getCaliValue();
|
||||
Ecomtbl *e;
|
||||
MyRectangle *r;
|
||||
SDL_Rect *r;
|
||||
|
||||
if (num == 0) {
|
||||
r = &nact->ags.view_area;
|
||||
@@ -91,8 +90,8 @@ void commandEM() {
|
||||
int x = getCaliValue();
|
||||
int y = getCaliValue();
|
||||
|
||||
MyPoint p = {x, y};
|
||||
MyRectangle r = tbl[num - 1].r;
|
||||
SDL_Point p = {x, y};
|
||||
SDL_Rect r = tbl[num - 1].r;
|
||||
if (nact->patch_emen == 0) {
|
||||
r.w -= 1;
|
||||
r.h -= 1;
|
||||
@@ -108,11 +107,11 @@ void commandEN() {
|
||||
int x = getCaliValue();
|
||||
int y = getCaliValue();
|
||||
|
||||
MyPoint p = {x, y};
|
||||
SDL_Point p = {x, y};
|
||||
*var = 0;
|
||||
|
||||
for (int i = min; i <= max; i++) {
|
||||
MyRectangle r = tbl[i - 1].r;
|
||||
SDL_Rect r = tbl[i - 1].r;
|
||||
if (nact->patch_emen == 0) {
|
||||
r.w -= 1;
|
||||
r.h -= 1;
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ void commandG1() {
|
||||
|
||||
void commandGS() {
|
||||
/* num 番にリンクされているCGの座標とサイズを取得する */
|
||||
MyRectangle r;
|
||||
SDL_Rect r;
|
||||
int num = getCaliValue();
|
||||
int *var = getCaliVariable();
|
||||
|
||||
|
||||
+1
-2
@@ -28,7 +28,6 @@
|
||||
#include "xsystem35.h"
|
||||
#include "scenario.h"
|
||||
#include "ags.h"
|
||||
#include "sdl_core.h"
|
||||
#include "input.h"
|
||||
#include "msgskip.h"
|
||||
|
||||
@@ -102,7 +101,7 @@ void commandIM() {
|
||||
/* マウスカーソルの座標取得 */
|
||||
int *x_var = getCaliVariable();
|
||||
int *y_var = getCaliVariable();
|
||||
MyPoint p;
|
||||
SDL_Point p;
|
||||
|
||||
sysVar[0] = sys_getMouseInfo(&p, false);
|
||||
*x_var = p.x;
|
||||
|
||||
+4
-4
@@ -156,10 +156,10 @@ void commandPT0() {
|
||||
int *var = getCaliVariable();
|
||||
int x = getCaliValue();
|
||||
int y = getCaliValue();
|
||||
Palette cell;
|
||||
PixelColor cell;
|
||||
|
||||
ags_getPixel(x, y, &cell);
|
||||
*var = cell.pixel;
|
||||
*var = cell.index;
|
||||
|
||||
TRACE("PT0 %p,%d,%d:", var, x, y);
|
||||
}
|
||||
@@ -171,7 +171,7 @@ void commandPT1() {
|
||||
int *b_var = getCaliVariable();
|
||||
int x = getCaliValue();
|
||||
int y = getCaliValue();
|
||||
Palette cell;
|
||||
PixelColor cell;
|
||||
|
||||
ags_getPixel(x, y, &cell);
|
||||
*r_var = cell.r;
|
||||
@@ -187,7 +187,7 @@ void commandPT2() {
|
||||
int *low_var = getCaliVariable();
|
||||
int x = getCaliValue();
|
||||
int y = getCaliValue();
|
||||
Palette cell;
|
||||
PixelColor cell;
|
||||
int r, g, b, pic;
|
||||
|
||||
ags_getPixel(x, y, &cell);
|
||||
|
||||
+4
-5
@@ -27,7 +27,6 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include "portab.h"
|
||||
#include "sdl_core.h"
|
||||
#include "scheduler.h"
|
||||
#include "xsystem35.h"
|
||||
#include "scenario.h"
|
||||
@@ -760,7 +759,7 @@ void commandVA() { /* from Panyo */
|
||||
/* 開始 (p3=コマ数,0:無限(開始位置==終了位置のとき))*/
|
||||
inAnimation = true;
|
||||
VAcmd[p1].elaspCut = 0;
|
||||
VAcmd[p1].startTime = sdl_getTicks();
|
||||
VAcmd[p1].startTime = sys_get_ticks();
|
||||
VAcmd[p1].totalCut = p3;
|
||||
|
||||
if (p3 == 0) {
|
||||
@@ -784,7 +783,7 @@ void commandVA() { /* from Panyo */
|
||||
/* キー抜け無し ,p3=0は指定不可 */
|
||||
while(VAcmd[p1].state == VA_RUNNING) {
|
||||
va_animationAlone(p1);
|
||||
sdl_sleep(10);
|
||||
sys_sleep(10);
|
||||
}
|
||||
va_drawUnit(p1);
|
||||
va_updateUnit(p1);
|
||||
@@ -794,7 +793,7 @@ void commandVA() { /* from Panyo */
|
||||
VAcmd[p1].rewrite = true;
|
||||
while(VAcmd[p1].state == VA_RUNNING) {
|
||||
va_animationAlone(p1);
|
||||
sdl_sleep(10);
|
||||
sys_sleep(10);
|
||||
key = sys_getInputInfo();
|
||||
if (key != 0) {
|
||||
sysVar[0] = key;
|
||||
@@ -1003,7 +1002,7 @@ static void va_animationAlone(int i) {
|
||||
static void va_update() {
|
||||
bool proceeding = false;
|
||||
int i;
|
||||
int curTime = sdl_getTicks();
|
||||
int curTime = sys_get_ticks();
|
||||
|
||||
for (i = 0; i < VACMD_MAX; i++) {
|
||||
if (VAcmd[i].state == VA_RUNNING) {
|
||||
|
||||
+2
-3
@@ -31,7 +31,6 @@
|
||||
#include "input.h"
|
||||
#include "scenario.h"
|
||||
#include "cmd_check.h"
|
||||
#include "sdl_core.h"
|
||||
#include "scheduler.h"
|
||||
#include "music_cdrom.h"
|
||||
#include "hacks.h"
|
||||
@@ -68,14 +67,14 @@ unsigned Y3waitFlags = KEYWAIT_CANCELABLE;
|
||||
* delay, when a button is pressed.
|
||||
*
|
||||
* For Rance4 v2, this does not work because the UI loop also checks keyboard
|
||||
* status, so we use a different hack. See rance4v2_hack() in sdl_event.c.
|
||||
* status, so we use a different hack. See rance4v2_hack() in event.c.
|
||||
*/
|
||||
static void rance4_Y3_IM_hack() {
|
||||
static int count;
|
||||
|
||||
int button_pressed = sys_getInputInfo();
|
||||
if (!button_pressed) {
|
||||
sdl_wait_vsync();
|
||||
sys_wait_vsync();
|
||||
count = 0;
|
||||
}
|
||||
commandIM();
|
||||
|
||||
+4
-4
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "portab.h"
|
||||
#include "xsystem35.h"
|
||||
#include "sdl_core.h"
|
||||
#include "gfx.h"
|
||||
#include "scheduler.h"
|
||||
#include "ags.h"
|
||||
#include "scenario.h"
|
||||
@@ -44,13 +44,13 @@ static struct {
|
||||
} counters[257]; // [0] for ZT 1-5, [1..256] for ZT 10-11
|
||||
|
||||
static void reset_counter(int num, int divisor, int offset) {
|
||||
counters[num].base = sdl_getTicks() - offset;
|
||||
counters[num].base = sys_get_ticks() - offset;
|
||||
counters[num].divisor = divisor;
|
||||
}
|
||||
|
||||
static uint32_t get_counter(int num) {
|
||||
scheduler_on_event(SCHEDULER_EVENT_TIMER_CHECK);
|
||||
return sdl_getTicks() - counters[num].base;
|
||||
return sys_get_ticks() - counters[num].base;
|
||||
}
|
||||
|
||||
void commandZC() {
|
||||
@@ -462,7 +462,7 @@ void commandZZ10() {
|
||||
/* スクリーンモードを取得する */
|
||||
int *var = getCaliVariable();
|
||||
|
||||
*var = sdl_isFullscreen() ? 1 : 0;
|
||||
*var = gfx_isFullscreen() ? 1 : 0;
|
||||
|
||||
TRACE("ZZ10 %d:",*var);
|
||||
}
|
||||
|
||||
+206
-2
@@ -23,13 +23,217 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <SDL.h>
|
||||
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "cursor.h"
|
||||
#include "LittleEndian.h"
|
||||
#include "ald_manager.h"
|
||||
#include "sdl_core.h"
|
||||
|
||||
#include "bitmaps/cursor_uparrow.xpm"
|
||||
|
||||
#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
|
||||
|
||||
typedef struct {
|
||||
short idReserved; /* always set to 0 */
|
||||
short idType; /* always set to 1 */
|
||||
short idCount; /* number of cursor images,always set to 1 */
|
||||
/* immediately followed by idCount TCursorDirEntries */
|
||||
} CursorHeader;
|
||||
|
||||
typedef struct {
|
||||
unsigned char bWidth; /* Width */
|
||||
unsigned char bHeight; /* Height */
|
||||
unsigned char bColorCount;
|
||||
unsigned char bReserved;
|
||||
unsigned short wxHotspot;
|
||||
unsigned short wyHotspot;
|
||||
unsigned long dwBytesInRes; /* total number of bytes in image */
|
||||
unsigned long dwImageOffset;
|
||||
} TCursorDirEntry;
|
||||
|
||||
typedef struct {
|
||||
long biSize; /* sizeof(TBitmapInfoHeader) */
|
||||
long biWidth; /* width of bitmap */
|
||||
long biHeight; /* height of bitmap, see notes */
|
||||
short biPlanes; /* planes, always 1 */
|
||||
short biBitCount; /* number of color bits */
|
||||
long biCompression; /* compression used, 0 */
|
||||
long biSizeImage; /* size of the pixel data, see notes */
|
||||
long biXPelsPerMeter; /* not used, 0 */
|
||||
long biYPelsPerMeter; /* not used, 0 */
|
||||
long biClrUsed; /* # of colors used, set to 0 */
|
||||
long biClrImportant; /* important colors, set to 0 */
|
||||
short hotX;
|
||||
short hotY;
|
||||
} TBitmapInfoHeader;
|
||||
|
||||
/*
|
||||
biHeight=2*TIconDirEntry.bHeight;
|
||||
biSizeImage=ANDmask + XORmask;
|
||||
|
||||
XORmask=(TIconDirEntry.bWidth * TIconDirEntry.bHeight * biBitCount)/8;
|
||||
ANDmask=(TIconDirEntry.bWidth * TIconDirEntry.bHeight)/8;
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
unsigned char rgbBlue; /* blue component of color */
|
||||
unsigned char rgbGreen; /* green component of color */
|
||||
unsigned char rgbRed; /* red component of color */
|
||||
unsigned char rgbReserved; /* reserved, 0 */
|
||||
} TRGBQuad;
|
||||
|
||||
typedef struct {
|
||||
TBitmapInfoHeader icHeader; /* image header info */
|
||||
TRGBQuad *icColors; /* image palette */
|
||||
int xormasklen;
|
||||
int andmasklen;
|
||||
} CursorImage;
|
||||
|
||||
typedef struct {
|
||||
int cbSizeof;
|
||||
int cFrames;
|
||||
int cSteps;
|
||||
int cx;
|
||||
int cy;
|
||||
int cBitCount;
|
||||
int cPlanes;
|
||||
int jiffRate;
|
||||
int fl;
|
||||
|
||||
int *rate;
|
||||
int *seq;
|
||||
} AnimationCursorHeader ;
|
||||
|
||||
typedef struct {
|
||||
AnimationCursorHeader *header;
|
||||
CursorImage *images;
|
||||
} AniCursorImage;
|
||||
|
||||
static SDL_Cursor *cursor[256];
|
||||
|
||||
/* Stolen from the SDL mailing list */
|
||||
/* Creates a new mouse cursor from an XPM */
|
||||
|
||||
static SDL_Cursor *init_system_cursor(const char *image[]) {
|
||||
int i, row, col;
|
||||
Uint8 data[4*32];
|
||||
Uint8 mask[4*32];
|
||||
int hot_x, hot_y;
|
||||
|
||||
i = -1;
|
||||
for (row = 0; row < 32; row++) {
|
||||
for (col = 0; col < 32; col++) {
|
||||
if (col % 8) {
|
||||
data[i] <<= 1;
|
||||
mask[i] <<= 1;
|
||||
} else {
|
||||
i++;
|
||||
data[i] = mask[i] = 0;
|
||||
}
|
||||
switch (image[4 + row][col]) {
|
||||
case 'X':
|
||||
data[i] |= 0x01;
|
||||
mask[i] |= 0x01;
|
||||
break;
|
||||
case '.':
|
||||
mask[i] |= 0x01;
|
||||
break;
|
||||
case ' ':
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
sscanf(image[4 + row], "%d,%d", &hot_x, &hot_y);
|
||||
return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y);
|
||||
}
|
||||
|
||||
void cursor_init(void) {
|
||||
cursor[CURSOR_ARROW] = SDL_GetDefaultCursor();
|
||||
cursor[CURSOR_CROSS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_CROSSHAIR);
|
||||
cursor[CURSOR_IBEAM] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
|
||||
cursor[CURSOR_ICON] = SDL_GetDefaultCursor();
|
||||
cursor[CURSOR_NO] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO);
|
||||
cursor[CURSOR_SIZE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
|
||||
cursor[CURSOR_SIZEALL] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
|
||||
cursor[CURSOR_SIZENESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
|
||||
cursor[CURSOR_SIZENS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
|
||||
cursor[CURSOR_SIZENWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
|
||||
cursor[CURSOR_SIZEWE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
|
||||
cursor[CURSOR_UPARROW] = init_system_cursor(cursor_uparrow);
|
||||
cursor[CURSOR_WAIT] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT);
|
||||
}
|
||||
|
||||
static bool cursor_new(uint8_t* data, int no, CursorImage *cursorImage, TCursorDirEntry *cursordirentry) {
|
||||
int xormasklen, andmasklen, xornum;
|
||||
int i, j;
|
||||
int h = 0;
|
||||
|
||||
uint8_t *buf1, *buf2, *buf3, *buf4;
|
||||
|
||||
xornum = (cursordirentry->bWidth * cursordirentry->bHeight);
|
||||
xormasklen = (xornum * cursorImage->icHeader.biBitCount) / 8;
|
||||
NOTICE("Cursor: xormasklen==%d, xornum==%d", xormasklen, xornum);
|
||||
|
||||
andmasklen = xornum / 8;
|
||||
cursorImage->xormasklen = xormasklen;
|
||||
cursorImage->andmasklen = andmasklen;
|
||||
|
||||
buf1 = malloc(sizeof(uint8_t) * xornum);
|
||||
buf2 = malloc(sizeof(uint8_t) * xornum);
|
||||
buf3 = malloc(sizeof(uint8_t) * xornum);
|
||||
buf4 = malloc(sizeof(uint8_t) * xornum);
|
||||
|
||||
memcpy(buf1, data, min(xormasklen, xornum));
|
||||
data += xormasklen;
|
||||
|
||||
memcpy(buf2, data, min(andmasklen, xornum));
|
||||
data += andmasklen;
|
||||
|
||||
#define height cursordirentry->bHeight
|
||||
#define width cursordirentry->bWidth
|
||||
|
||||
for (j = 0; j < height; j++) {
|
||||
for (i = 0; i < width * cursorImage->icHeader.biBitCount /8; i++) {
|
||||
buf3[h] = buf1[(height-j-1)*height*cursorImage->icHeader.biBitCount/8+i];
|
||||
buf4[h] = 0xff ^ buf2[(height-j-1)*height*cursorImage->icHeader.biBitCount/8+i];
|
||||
h++;
|
||||
}
|
||||
}
|
||||
|
||||
if (cursor[no])
|
||||
SDL_FreeCursor(cursor[no]);
|
||||
cursor[no] = SDL_CreateCursor(buf3, buf4, 32, 32, cursordirentry->wxHotspot, cursordirentry->wyHotspot);
|
||||
|
||||
free(buf1);
|
||||
free(buf2);
|
||||
free(buf3);
|
||||
free(buf4);
|
||||
|
||||
#undef height
|
||||
#undef width
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void cursor_set_type(int type) {
|
||||
if (cursor[type] != NULL) {
|
||||
SDL_SetCursor(cursor[type]);
|
||||
}
|
||||
}
|
||||
|
||||
static CursorHeader cursorHeader;
|
||||
static TCursorDirEntry cursordirentry;
|
||||
@@ -293,7 +497,7 @@ static bool cursor_load_mono(uint8_t *d, int no) {
|
||||
pos += p1;
|
||||
|
||||
/* read pixedl data */
|
||||
if (!sdl_cursorNew(d + pos, no, &cursorImage, &cursordirentry)) {
|
||||
if (!cursor_new(d + pos, no, &cursorImage, &cursordirentry)) {
|
||||
WARNING("unable to read pixel data");
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
-79
@@ -23,84 +23,8 @@
|
||||
#ifndef __CURSOR_H__
|
||||
#define __CURSOR_H__
|
||||
|
||||
#define BitSet(byte, bit) (((byte) & (bit)) == (bit))
|
||||
|
||||
typedef struct {
|
||||
short idReserved; /* always set to 0 */
|
||||
short idType; /* always set to 1 */
|
||||
short idCount; /* number of cursor images,always set to 1 */
|
||||
/* immediately followed by idCount TCursorDirEntries */
|
||||
} CursorHeader;
|
||||
|
||||
typedef struct {
|
||||
unsigned char bWidth; /* Width */
|
||||
unsigned char bHeight; /* Height */
|
||||
unsigned char bColorCount;
|
||||
unsigned char bReserved;
|
||||
unsigned short wxHotspot;
|
||||
unsigned short wyHotspot;
|
||||
unsigned long dwBytesInRes; /* total number of bytes in image */
|
||||
unsigned long dwImageOffset;
|
||||
} TCursorDirEntry;
|
||||
|
||||
typedef struct {
|
||||
long biSize; /* sizeof(TBitmapInfoHeader) */
|
||||
long biWidth; /* width of bitmap */
|
||||
long biHeight; /* height of bitmap, see notes */
|
||||
short biPlanes; /* planes, always 1 */
|
||||
short biBitCount; /* number of color bits */
|
||||
long biCompression; /* compression used, 0 */
|
||||
long biSizeImage; /* size of the pixel data, see notes */
|
||||
long biXPelsPerMeter; /* not used, 0 */
|
||||
long biYPelsPerMeter; /* not used, 0 */
|
||||
long biClrUsed; /* # of colors used, set to 0 */
|
||||
long biClrImportant; /* important colors, set to 0 */
|
||||
short hotX;
|
||||
short hotY;
|
||||
} TBitmapInfoHeader;
|
||||
|
||||
/*
|
||||
biHeight=2*TIconDirEntry.bHeight;
|
||||
biSizeImage=ANDmask + XORmask;
|
||||
|
||||
XORmask=(TIconDirEntry.bWidth * TIconDirEntry.bHeight * biBitCount)/8;
|
||||
ANDmask=(TIconDirEntry.bWidth * TIconDirEntry.bHeight)/8;
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
unsigned char rgbBlue; /* blue component of color */
|
||||
unsigned char rgbGreen; /* green component of color */
|
||||
unsigned char rgbRed; /* red component of color */
|
||||
unsigned char rgbReserved; /* reserved, 0 */
|
||||
} TRGBQuad;
|
||||
|
||||
typedef struct {
|
||||
TBitmapInfoHeader icHeader; /* image header info */
|
||||
TRGBQuad *icColors; /* image palette */
|
||||
int xormasklen;
|
||||
int andmasklen;
|
||||
} CursorImage;
|
||||
|
||||
typedef struct {
|
||||
int cbSizeof;
|
||||
int cFrames;
|
||||
int cSteps;
|
||||
int cx;
|
||||
int cy;
|
||||
int cBitCount;
|
||||
int cPlanes;
|
||||
int jiffRate;
|
||||
int fl;
|
||||
|
||||
int *rate;
|
||||
int *seq;
|
||||
} AnimationCursorHeader ;
|
||||
|
||||
typedef struct {
|
||||
AnimationCursorHeader *header;
|
||||
CursorImage *images;
|
||||
} AniCursorImage;
|
||||
|
||||
extern void cursor_load(int no, int linkno);
|
||||
void cursor_init(void);
|
||||
void cursor_load(int no, int linkno);
|
||||
void cursor_set_type(int type);
|
||||
|
||||
#endif /* __CURSOR_H__ */
|
||||
|
||||
+7
-6
@@ -31,7 +31,8 @@
|
||||
#include "debugger_private.h"
|
||||
#include "debug_symbol.h"
|
||||
#include "msgqueue.h"
|
||||
#include "sdl_core.h"
|
||||
#include "gfx.h"
|
||||
#include "event.h"
|
||||
#include "system.h"
|
||||
#include "nact.h"
|
||||
#include "variable.h"
|
||||
@@ -296,7 +297,7 @@ static void cmd_evaluate(cJSON *args, cJSON *resp) {
|
||||
}
|
||||
|
||||
static void cmd_continue(cJSON *args, cJSON *resp) {
|
||||
sdl_raiseWindow();
|
||||
gfx_raiseWindow();
|
||||
cJSON_AddBoolToObject(resp, "success", true);
|
||||
}
|
||||
|
||||
@@ -593,13 +594,13 @@ static int read_command_thread(void *data) {
|
||||
free(buf);
|
||||
break;
|
||||
}
|
||||
sdl_post_debugger_command(buf);
|
||||
event_post_debugger_command(buf);
|
||||
content_length = -1;
|
||||
} else {
|
||||
fprintf(stderr, "Unknown Debug Adapter Protocol header: %s", header);
|
||||
}
|
||||
}
|
||||
sdl_post_debugger_command(NULL); // end of messages
|
||||
event_post_debugger_command(NULL); // end of messages
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -617,7 +618,7 @@ static void dbg_dap_init(const char *path) {
|
||||
while (!initialized && !nact->is_quit) {
|
||||
SDL_Event e;
|
||||
SDL_WaitEvent(&e);
|
||||
sdl_handle_event(&e);
|
||||
event_handle_event(&e);
|
||||
while (!msgq_isempty(queue)) {
|
||||
char *msg = msgq_dequeue(queue);
|
||||
if (!msg)
|
||||
@@ -639,7 +640,7 @@ static void dbg_dap_repl(int bp_no) {
|
||||
while (continue_repl && !nact->is_quit) {
|
||||
SDL_Event e;
|
||||
SDL_WaitEvent(&e);
|
||||
sdl_handle_event(&e);
|
||||
event_handle_event(&e);
|
||||
while (!msgq_isempty(queue)) {
|
||||
char *msg = msgq_dequeue(queue);
|
||||
if (!msg)
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "system.h"
|
||||
#include "LittleEndian.h"
|
||||
#include "dri.h"
|
||||
#include "sdl_core.h"
|
||||
|
||||
static bool read_index(int volume, drifiles *d, FILE *fp) {
|
||||
fseek(fp, 0L, SEEK_END);
|
||||
@@ -142,7 +141,7 @@ static void warn_missing_ald(drifiles *d, int no) {
|
||||
} else {
|
||||
snprintf(msgbuf, sizeof(msgbuf), "Cannot read resource #%d.", no);
|
||||
}
|
||||
sdl_showMessageBox(MESSAGEBOX_WARNING, "xsystem35", msgbuf);
|
||||
sys_show_message_box(MESSAGEBOX_WARNING, "xsystem35", msgbuf);
|
||||
}
|
||||
|
||||
dridata *dri_getdata(drifiles *d, int no) {
|
||||
|
||||
+33
-33
@@ -27,7 +27,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "portab.h"
|
||||
#include "sdl_core.h"
|
||||
#include "gfx.h"
|
||||
#include "input.h"
|
||||
#include "ags.h"
|
||||
#include "system.h"
|
||||
@@ -39,19 +39,19 @@ static bool ecp_cancel;
|
||||
#define EC_WAIT \
|
||||
if ((key |= sys_getInputInfo()) && ecp_cancel) break; \
|
||||
do { \
|
||||
int wait_ms = cnt - sdl_getTicks(); \
|
||||
int wait_ms = cnt - sys_get_ticks(); \
|
||||
if (wait_ms >= 16) \
|
||||
key = sys_keywait(wait_ms, ecp_cancel ? KEYWAIT_CANCELABLE : KEYWAIT_NONCANCELABLE); \
|
||||
} while (0)
|
||||
|
||||
|
||||
static void eCopyUpdateArea(int sx, int sy, int w, int h, int dx, int dy) {
|
||||
MyRectangle src = {sx, sy, w, h};
|
||||
MyPoint dst = {
|
||||
SDL_Rect src = {sx, sy, w, h};
|
||||
SDL_Point dst = {
|
||||
dx - nact->ags.view_area.x,
|
||||
dy - nact->ags.view_area.y
|
||||
};
|
||||
sdl_updateArea(&src, &dst);
|
||||
gfx_updateArea(&src, &dst);
|
||||
}
|
||||
|
||||
static int eCopyArea5(int sx, int sy, int w, int h, int dx, int dy, int opt) {
|
||||
@@ -60,7 +60,7 @@ static int eCopyArea5(int sx, int sy, int w, int h, int dx, int dy, int opt) {
|
||||
static int hx[16]={ 0,32,16,48, 0,32,16,48,16,48, 0,32,16,48, 0,32};
|
||||
static int hy[16]={ 0, 0,16,16,32,32,48,48, 0, 0,16,16,32,32,48,48};
|
||||
|
||||
cnt = sdl_getTicks();
|
||||
cnt = sys_get_ticks();
|
||||
for (i = 0; i < 16; i++) {
|
||||
cnt += waitcnt;
|
||||
for (y = 0; y < (h -63); y += 64) {
|
||||
@@ -81,7 +81,7 @@ static int eCopyArea6(int dx, int dy, int w, int h, int opt) {
|
||||
int i, x, y, key = 0, cnt;
|
||||
int waitcnt = opt == 0 ? 30 : opt;
|
||||
|
||||
cnt = sdl_getTicks();
|
||||
cnt = sys_get_ticks();
|
||||
for (i = 0; i < 7; i++) {
|
||||
cnt += waitcnt;
|
||||
for (x = 0; x < (w -63); x += 64) {
|
||||
@@ -105,18 +105,18 @@ static int eCopyArea9(int sx, int sy, int w, int h, int dx, int dy, int opt) {
|
||||
static int hintY[4] = {0,8,8,0};
|
||||
|
||||
|
||||
cnt = sdl_getTicks();
|
||||
cnt = sys_get_ticks();
|
||||
for (i = 0; i < 4; i++) {
|
||||
cnt+=waitcnt;
|
||||
for (y = 0; y < h -15; y+=16) {
|
||||
for (x = 0; x < (w -7); x+=16) {
|
||||
sdl_copyArea(sx + x + hintX[i],sy + y + hintY[i], 8, 8, dx + x + hintX[i], dy + y + hintY[i]);
|
||||
gfx_copyArea(sx + x + hintX[i],sy + y + hintY[i], 8, 8, dx + x + hintX[i], dy + y + hintY[i]);
|
||||
}
|
||||
}
|
||||
ags_updateArea(dx, dy, w, h);
|
||||
EC_WAIT;
|
||||
}
|
||||
sdl_copyArea(sx, sy, w, h, dx, dy);
|
||||
gfx_copyArea(sx, sy, w, h, dx, dy);
|
||||
ags_updateArea(dx, dy, w, h);
|
||||
return key;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ static int eCopyArea16(int dx, int dy, int w, int h, int opt) {
|
||||
int i, x, key = 0, cnt;
|
||||
int waitcnt = opt == 0 ? 30 : opt;
|
||||
|
||||
cnt = sdl_getTicks();
|
||||
cnt = sys_get_ticks();
|
||||
for (i = 0; i < 8; i++) {
|
||||
cnt += waitcnt;
|
||||
for (x = 0; x < (w -15); x += 16) {
|
||||
@@ -143,7 +143,7 @@ static int eCopyArea17(int dx, int dy, int w, int h, int opt) {
|
||||
int waitcnt = opt == 0 ? 30 : opt;
|
||||
|
||||
#define E17X 18
|
||||
cnt = sdl_getTicks();
|
||||
cnt = sys_get_ticks();
|
||||
for (i = 0; i < E17X; i++) {
|
||||
cnt += waitcnt;
|
||||
for (y = 0; y < (h - E17X + 1); y += E17X) {
|
||||
@@ -159,7 +159,7 @@ static int eCopyArea22(int sx, int sy, int w, int h, int dx, int dy, int opt) {
|
||||
int i, x, y, key = 0, cnt;
|
||||
int waitcnt = opt == 0 ? 80 : opt;
|
||||
|
||||
cnt = sdl_getTicks();
|
||||
cnt = sys_get_ticks();
|
||||
for (i = 0; i < 2; i++) {
|
||||
cnt += waitcnt;
|
||||
for (y = 0; y < (h -3); y+=4) {
|
||||
@@ -184,12 +184,12 @@ static int eCopyArea23(int sx, int sy, int w, int h, int dx, int dy, int opt) {
|
||||
static int hintX[4] = {0,2,2,0};
|
||||
static int hintY[4] = {0,2,0,2};
|
||||
|
||||
cnt = sdl_getTicks();
|
||||
cnt = sys_get_ticks();
|
||||
for (i = 0; i < 4; i++) {
|
||||
cnt += waitcnt;
|
||||
for (y = 0; y < (h -3); y+=4) {
|
||||
for (x = 0; x < (w -3); x+=4) {
|
||||
sdl_copyArea(sx + x + hintX[i], sy + y + hintY[i], 2, 2,
|
||||
gfx_copyArea(sx + x + hintX[i], sy + y + hintY[i], 2, 2,
|
||||
dx + x + hintX[i], dy + y + hintY[i]);
|
||||
}
|
||||
}
|
||||
@@ -207,7 +207,7 @@ static int eCopyArea1000(int sx, int sy, int w, int h, int dx, int dy, int opt)
|
||||
}
|
||||
|
||||
static int eCopyArea2000(int sx, int sy, int w, int h, int dx, int dy, int opt) {
|
||||
sdl_fillRectangleRGB(dx, dy, w, h, 0, 0, 0);
|
||||
gfx_fillRectangleRGB(dx, dy, w, h, 0, 0, 0);
|
||||
ags_copyArea_alphaLevel(sx, sy, w, h, dx, dy, opt);
|
||||
ags_updateArea(dx, dy, w, h);
|
||||
return sys_getInputInfo();
|
||||
@@ -315,9 +315,9 @@ void ags_eCopyArea(int sx, int sy, int w, int h, int dx, int dy, int sw, int opt
|
||||
|
||||
if (sw == NACT_EFFECT_MAGNIFY) {
|
||||
SDL_Rect target_rect = { sx, sy, w, h };
|
||||
struct sdl_effect *eff = sdl_effect_magnify_init(sdl_getDIB(), &nact->ags.view_area, &target_rect);
|
||||
ags_runEffect(duration(sw, opt, NULL), cancel, (ags_EffectStepFunc)sdl_effect_step, eff);
|
||||
sdl_effect_finish(eff);
|
||||
struct effect *eff = effect_magnify_init(gfx_getDIB(), &nact->ags.view_area, &target_rect);
|
||||
ags_runEffect(duration(sw, opt, NULL), cancel, (ags_EffectStepFunc)effect_step, eff);
|
||||
effect_finish(eff);
|
||||
// Actual copy.
|
||||
ags_scaledCopyArea(
|
||||
sx, sy, w, h,
|
||||
@@ -326,24 +326,24 @@ void ags_eCopyArea(int sx, int sy, int w, int h, int dx, int dy, int sw, int opt
|
||||
return;
|
||||
}
|
||||
|
||||
enum sdl_effect_type sdl_effect = from_nact_effect(sw);
|
||||
if (sdl_effect != EFFECT_INVALID) {
|
||||
enum effect_type effect = from_nact_effect(sw);
|
||||
if (effect != EFFECT_INVALID) {
|
||||
SDL_Rect rect = { dx - nact->ags.view_area.x, dy - nact->ags.view_area.y, w, h };
|
||||
// Note that we specify NULL (which means sdl_texture) for the old
|
||||
// surface rather than sdl_getDIB(). This is to use the current display
|
||||
// Note that we specify NULL (which means gfx_texture) for the old
|
||||
// surface rather than gfx_getDIB(). This is to use the current display
|
||||
// contents, not reflecting uncommitted palette changes.
|
||||
struct sdl_effect *eff = sdl_effect_init(&rect, NULL, rect.x, rect.y, sdl_getDIB(), sx, sy, sdl_effect);
|
||||
ags_runEffect(duration(sw, opt, &rect), cancel, (ags_EffectStepFunc)sdl_effect_step, eff);
|
||||
sdl_effect_finish(eff);
|
||||
struct effect *eff = effect_init(&rect, NULL, rect.x, rect.y, gfx_getDIB(), sx, sy, effect);
|
||||
ags_runEffect(duration(sw, opt, &rect), cancel, (ags_EffectStepFunc)effect_step, eff);
|
||||
effect_finish(eff);
|
||||
|
||||
// Actual copy.
|
||||
switch (sw) {
|
||||
case NACT_EFFECT_FADEOUT:
|
||||
sdl_fillRectangleRGB(dx, dy, w, h, 0, 0, 0);
|
||||
gfx_fillRectangleRGB(dx, dy, w, h, 0, 0, 0);
|
||||
ags_updateArea(dx, dy, w, h);
|
||||
break;
|
||||
case NACT_EFFECT_WHITEOUT:
|
||||
sdl_fillRectangleRGB(dx, dy, w, h, 255, 255, 255);
|
||||
gfx_fillRectangleRGB(dx, dy, w, h, 255, 255, 255);
|
||||
ags_updateArea(dx, dy, w, h);
|
||||
break;
|
||||
default:
|
||||
@@ -363,7 +363,7 @@ void ags_eCopyArea(int sx, int sy, int w, int h, int dx, int dy, int sw, int opt
|
||||
case 54:
|
||||
ags_copyArea(sx, sy, w, h, dx, dy);
|
||||
{
|
||||
MyRectangle r = {dx, dy, w, h}, update;
|
||||
SDL_Rect r = {dx, dy, w, h}, update;
|
||||
SDL_IntersectRect(&nact->ags.view_area, &r, &update);
|
||||
w = update.w;
|
||||
h = update.h;
|
||||
@@ -431,15 +431,15 @@ void ags_eSpriteCopyArea(int sx, int sy, int w, int h, int dx, int dy, int sw, i
|
||||
return;
|
||||
}
|
||||
|
||||
enum sdl_effect_type type = from_nact_sprite_effect(sw);
|
||||
enum effect_type type = from_nact_sprite_effect(sw);
|
||||
if (type == EFFECT_INVALID) {
|
||||
WARNING("Invalid effect: %d", sw);
|
||||
return;
|
||||
}
|
||||
SDL_Rect rect = { dx - nact->ags.view_area.x, dy - nact->ags.view_area.y, w, h };
|
||||
struct sdl_effect *eff = sdl_sprite_effect_init(&rect, dx, dy, sx, sy, spCol, type);
|
||||
ags_runEffect(duration(sw, opt, &rect), cancel, (ags_EffectStepFunc)sdl_effect_step, eff);
|
||||
sdl_effect_finish(eff);
|
||||
struct effect *eff = sprite_effect_init(&rect, dx, dy, sx, sy, spCol, type);
|
||||
ags_runEffect(duration(sw, opt, &rect), cancel, (ags_EffectStepFunc)effect_step, eff);
|
||||
effect_finish(eff);
|
||||
// Actual copy.
|
||||
if (sw == 5) {
|
||||
ags_copyArea_shadow(sx, sy, w, h, dx, dy);
|
||||
|
||||
@@ -21,10 +21,12 @@
|
||||
#include <string.h>
|
||||
#include <SDL.h>
|
||||
|
||||
#include "sdl_core.h"
|
||||
#include "sdl_private.h"
|
||||
#include "editor.h"
|
||||
#include "event.h"
|
||||
#include "gfx.h"
|
||||
#include "menu.h"
|
||||
#include "nact.h"
|
||||
#include "system.h"
|
||||
|
||||
#define XMARGIN 3
|
||||
#define YMARGIN 2
|
||||
@@ -53,13 +55,13 @@ static void redraw() {
|
||||
};
|
||||
|
||||
if (*input->text) {
|
||||
int w = sdl_drawString(r.x, r.y, input->text, fgcolor).w;
|
||||
int w = gfx_drawString(r.x, r.y, input->text, fgcolor).w;
|
||||
r.x += w;
|
||||
r.w -= w;
|
||||
}
|
||||
|
||||
if (*input->composingText) {
|
||||
int w = sdl_drawString(r.x, r.y, input->composingText, fgcolor).w;
|
||||
int w = gfx_drawString(r.x, r.y, input->composingText, fgcolor).w;
|
||||
ags_fillRectangle(r.x, r.y + r.h, w, 2, fgcolor); // underline
|
||||
}
|
||||
|
||||
@@ -129,7 +131,7 @@ static bool handle_event(const SDL_Event *e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool sdl_inputString(INPUTSTRING_PARAM *p) {
|
||||
bool edit_string(INPUTSTRING_PARAM *p) {
|
||||
static char *buf;
|
||||
free(buf);
|
||||
buf = malloc(p->max * MAX_UTF8_BYTES_PAR_CHAR + 1);
|
||||
@@ -153,14 +155,14 @@ bool sdl_inputString(INPUTSTRING_PARAM *p) {
|
||||
ags_setFont(FONT_GOTHIC, p->h);
|
||||
redraw();
|
||||
|
||||
sdl_custom_event_handler = handle_event;
|
||||
event_custom_handler = handle_event;
|
||||
while (!input->done) {
|
||||
sdl_getKeyInfo(); // message pump
|
||||
event_get_key(); // message pump
|
||||
nact->callback();
|
||||
sdl_wait_vsync();
|
||||
sys_wait_vsync();
|
||||
}
|
||||
SDL_StopTextInput();
|
||||
sdl_custom_event_handler = NULL;
|
||||
event_custom_handler = NULL;
|
||||
|
||||
ags_restoreRegion(saved_region, s.rect.x, s.rect.y);
|
||||
ags_updateArea(s.rect.x, s.rect.y, s.rect.w, s.rect.h);
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2025 kichikuou <KichikuouChrome@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef __EDITOR_H__
|
||||
#define __EDITOR_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct inputstring_param;
|
||||
|
||||
bool edit_string(struct inputstring_param *);
|
||||
|
||||
#endif // __EDITOR_H__
|
||||
+275
-274
File diff suppressed because it is too large
Load Diff
+15
-4
@@ -20,6 +20,9 @@
|
||||
#ifndef __EFFECT_H__
|
||||
#define __EFFECT_H__
|
||||
|
||||
#include <SDL_surface.h>
|
||||
#include "ags.h"
|
||||
|
||||
// Effect types of the CE/CD command.
|
||||
enum nact_effect {
|
||||
NACT_EFFECT_PAN_IN_DOWN = 1,
|
||||
@@ -116,7 +119,7 @@ enum sact_effect {
|
||||
};
|
||||
|
||||
// Internal effect numbers.
|
||||
enum sdl_effect_type {
|
||||
enum effect_type {
|
||||
EFFECT_INVALID,
|
||||
EFFECT_CROSSFADE,
|
||||
EFFECT_FADEOUT,
|
||||
@@ -186,8 +189,16 @@ enum sdl_effect_type {
|
||||
EFFECT_SACTAMASK,
|
||||
};
|
||||
|
||||
enum sdl_effect_type from_nact_effect(enum nact_effect effect);
|
||||
enum sdl_effect_type from_nact_sprite_effect(enum nact_effect effect);
|
||||
enum sdl_effect_type from_sact_effect(enum sact_effect effect);
|
||||
enum effect_type from_nact_effect(enum nact_effect effect);
|
||||
enum effect_type from_nact_sprite_effect(enum nact_effect effect);
|
||||
enum effect_type from_sact_effect(enum sact_effect effect);
|
||||
|
||||
struct effect;
|
||||
struct effect *effect_init(SDL_Rect *rect, surface_t *old, int ox, int oy, surface_t *new, int nx, int ny, enum effect_type effect);
|
||||
struct effect *sprite_effect_init(SDL_Rect *rect, int dx, int dy, int sx, int sy, int col, enum effect_type type);
|
||||
struct effect *effect_magnify_init(surface_t *surface, SDL_Rect *view_rect, SDL_Rect *target_rect);
|
||||
struct effect *effect_sactamask_init(SDL_Surface *mask);
|
||||
void effect_step(struct effect *eff, float progress);
|
||||
void effect_finish(struct effect *eff);
|
||||
|
||||
#endif /* __EFFECT_H__ */
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
* sdl_darw.c SDL event handler
|
||||
*
|
||||
* Copyright (C) 2000- Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -18,7 +16,6 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: sdl_event.c,v 1.5 2001/12/16 17:12:56 chikama Exp $ */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@@ -31,21 +28,24 @@
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
#include "event.h"
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "debugger.h"
|
||||
#include "nact.h"
|
||||
#include "sdl_core.h"
|
||||
#include "sdl_private.h"
|
||||
#include "gfx.h"
|
||||
#include "gfx_private.h"
|
||||
#include "scheduler.h"
|
||||
#include "menu.h"
|
||||
#include "input.h"
|
||||
#include "msgskip.h"
|
||||
#include "hacks.h"
|
||||
|
||||
static void sdl_getEvent(void);
|
||||
static void get_event(void);
|
||||
static void keyEventProsess(SDL_KeyboardEvent *e, bool pressed);
|
||||
|
||||
bool (*event_custom_handler)(const SDL_Event *);
|
||||
|
||||
static uint32_t custom_event_type = (uint32_t)-1;
|
||||
|
||||
enum CustomEventCode {
|
||||
@@ -61,7 +61,7 @@ bool RawKeyInfo[256];
|
||||
/* SDL Joystick */
|
||||
static int joyinfo=0;
|
||||
|
||||
static int sdl_keytable[SDL_NUM_SCANCODES] = {
|
||||
static int keytable[SDL_NUM_SCANCODES] = {
|
||||
[SDL_SCANCODE_A] = KEY_A,
|
||||
[SDL_SCANCODE_B] = KEY_B,
|
||||
[SDL_SCANCODE_C] = KEY_C,
|
||||
@@ -183,9 +183,53 @@ static int sdl_keytable[SDL_NUM_SCANCODES] = {
|
||||
[SDL_SCANCODE_RALT] = KEY_ALT,
|
||||
};
|
||||
|
||||
void sdl_event_init(void) {
|
||||
static int joy_device_index = -1;
|
||||
static SDL_Joystick *js;
|
||||
|
||||
static bool joy_open(int index) {
|
||||
if (js)
|
||||
return false;
|
||||
|
||||
js = SDL_JoystickOpen(index);
|
||||
if (!js)
|
||||
return false;
|
||||
|
||||
const char *name = SDL_JoystickName(js);
|
||||
int axes = SDL_JoystickNumAxes(js);
|
||||
int buttons = SDL_JoystickNumButtons(js);
|
||||
SDL_JoystickEventState(SDL_ENABLE);
|
||||
NOTICE("SDL joystick '%s' %d axes %d buttons", name, axes, buttons);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool joy_init(void) {
|
||||
SDL_Init(SDL_INIT_JOYSTICK);
|
||||
|
||||
if (joy_device_index >= 0)
|
||||
return joy_open(joy_device_index);
|
||||
|
||||
for (int i = 0; i < SDL_NumJoysticks(); i++) {
|
||||
if (joy_open(i))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void event_init(void) {
|
||||
if (custom_event_type == (uint32_t)-1)
|
||||
custom_event_type = SDL_RegisterEvents(1);
|
||||
joy_init();
|
||||
}
|
||||
|
||||
void event_remove(void) {
|
||||
if (js) {
|
||||
SDL_JoystickClose(js);
|
||||
js = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void event_set_joy_device_index(int index) {
|
||||
joy_device_index = index;
|
||||
}
|
||||
|
||||
static int mouse_to_rawkey(int button) {
|
||||
@@ -232,7 +276,34 @@ void send_agsevent(enum agsevent_type type, int code) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void sdl_setCursorInternalLocation(int x, int y) {
|
||||
void event_set_mouse_location(int x, int y) {
|
||||
// scale mouse x and y
|
||||
float scalex, scaley;
|
||||
SDL_RenderGetScale(gfx_renderer, &scalex, &scaley);
|
||||
x *= scalex;
|
||||
y *= scaley;
|
||||
|
||||
// calculate window borders
|
||||
int logw, logh;
|
||||
SDL_RenderGetLogicalSize(gfx_renderer, &logw, &logh);
|
||||
|
||||
float scalew, scaleh;
|
||||
scalew = logw * scalex;
|
||||
scaleh = logh * scaley;
|
||||
|
||||
int winw, winh;
|
||||
SDL_GetWindowSize(gfx_window, &winw, &winh);
|
||||
|
||||
float border_left = (winw - scalew) / 2;
|
||||
float border_top = (winh - scaleh) / 2;
|
||||
|
||||
// offset x and y by window borders
|
||||
x += border_left;
|
||||
y += border_top;
|
||||
SDL_WarpMouseInWindow(gfx_window, x, y);
|
||||
}
|
||||
|
||||
void event_set_mouse_internal_location(int x, int y) {
|
||||
mousex = x;
|
||||
mousey = y;
|
||||
send_agsevent(AGSEVENT_MOUSE_MOTION, 0);
|
||||
@@ -281,8 +352,8 @@ static void rance4v2_hack(void) {
|
||||
cancel_yield();
|
||||
}
|
||||
|
||||
void sdl_handle_event(SDL_Event *e) {
|
||||
if (sdl_custom_event_handler && sdl_custom_event_handler(e))
|
||||
void event_handle_event(SDL_Event *e) {
|
||||
if (event_custom_handler && event_custom_handler(e))
|
||||
return;
|
||||
|
||||
switch (e->type) {
|
||||
@@ -293,7 +364,7 @@ void sdl_handle_event(SDL_Event *e) {
|
||||
case SDL_WINDOWEVENT:
|
||||
switch (e->window.event) {
|
||||
case SDL_WINDOWEVENT_EXPOSED:
|
||||
sdl_dirty = true;
|
||||
gfx_dirty = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -303,7 +374,7 @@ void sdl_handle_event(SDL_Event *e) {
|
||||
break;
|
||||
#endif
|
||||
case SDL_APP_DIDENTERFOREGROUND:
|
||||
sdl_dirty = true;
|
||||
gfx_dirty = true;
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
keyEventProsess(&e->key, true);
|
||||
@@ -315,7 +386,7 @@ void sdl_handle_event(SDL_Event *e) {
|
||||
msgskip_activate(!msgskip_isActivated());
|
||||
break;
|
||||
case SDLK_F4:
|
||||
sdl_setFullscreen(!sdl_fs_on);
|
||||
gfx_setFullscreen(!gfx_fullscreen);
|
||||
break;
|
||||
}
|
||||
#ifdef __ANDROID__
|
||||
@@ -325,7 +396,7 @@ void sdl_handle_event(SDL_Event *e) {
|
||||
#endif
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
sdl_setCursorInternalLocation(e->motion.x, e->motion.y);
|
||||
event_set_mouse_internal_location(e->motion.x, e->motion.y);
|
||||
#ifdef _WIN32
|
||||
win_menu_onMouseMotion(e->motion.x, e->motion.y);
|
||||
#endif
|
||||
@@ -400,7 +471,7 @@ void sdl_handle_event(SDL_Event *e) {
|
||||
break;
|
||||
|
||||
case SDL_JOYDEVICEADDED:
|
||||
sdl_joy_open(e->jdevice.which);
|
||||
joy_open(e->jdevice.which);
|
||||
break;
|
||||
|
||||
case SDL_JOYAXISMOTION:
|
||||
@@ -479,7 +550,7 @@ void sdl_handle_event(SDL_Event *e) {
|
||||
}
|
||||
|
||||
/* Event処理 */
|
||||
static void sdl_getEvent(void) {
|
||||
static void get_event(void) {
|
||||
enum scheduler_event scheduler_event = SCHEDULER_EVENT_INPUT_CHECK_MISS;
|
||||
|
||||
fire_deferred_touch_event();
|
||||
@@ -487,7 +558,7 @@ static void sdl_getEvent(void) {
|
||||
SDL_Event e;
|
||||
while (SDL_PollEvent(&e)) {
|
||||
scheduler_event = SCHEDULER_EVENT_INPUT_CHECK_HIT;
|
||||
sdl_handle_event(&e);
|
||||
event_handle_event(&e);
|
||||
}
|
||||
scheduler_on_event(scheduler_event);
|
||||
if (game_id == GAME_RANCE4_V2)
|
||||
@@ -496,15 +567,15 @@ static void sdl_getEvent(void) {
|
||||
|
||||
/* キー情報の取得 */
|
||||
static void keyEventProsess(SDL_KeyboardEvent *e, bool pressed) {
|
||||
int code = sdl_keytable[e->keysym.scancode];
|
||||
int code = keytable[e->keysym.scancode];
|
||||
RawKeyInfo[code] = pressed;
|
||||
send_agsevent(pressed ? AGSEVENT_KEY_PRESS : AGSEVENT_KEY_RELEASE, code);
|
||||
}
|
||||
|
||||
int sdl_getKeyInfo() {
|
||||
int event_get_key(void) {
|
||||
int rt;
|
||||
|
||||
sdl_getEvent();
|
||||
get_event();
|
||||
|
||||
rt = ((RawKeyInfo[KEY_UP] || RawKeyInfo[KEY_PAD_8]) |
|
||||
((RawKeyInfo[KEY_DOWN] || RawKeyInfo[KEY_PAD_2]) << 1) |
|
||||
@@ -518,8 +589,8 @@ int sdl_getKeyInfo() {
|
||||
return rt;
|
||||
}
|
||||
|
||||
int sdl_getMouseInfo(MyPoint *p) {
|
||||
sdl_getEvent();
|
||||
int event_get_mouse(SDL_Point *p) {
|
||||
get_event();
|
||||
|
||||
if (p) {
|
||||
p->x = mousex;
|
||||
@@ -531,7 +602,7 @@ int sdl_getMouseInfo(MyPoint *p) {
|
||||
return m1 | m2;
|
||||
}
|
||||
|
||||
void sdl_getWheelInfo(int *forward, int *back) {
|
||||
void event_get_wheel(int *forward, int *back) {
|
||||
*forward = mouse_wheel_up;
|
||||
*back = mouse_wheel_down;
|
||||
|
||||
@@ -540,16 +611,16 @@ void sdl_getWheelInfo(int *forward, int *back) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void sdl_clearWheelInfo(void) {
|
||||
void event_clear_wheel(void) {
|
||||
mouse_wheel_up = mouse_wheel_down = 0;
|
||||
}
|
||||
|
||||
int sdl_getJoyInfo(void) {
|
||||
sdl_getEvent();
|
||||
int event_get_joy(void) {
|
||||
get_event();
|
||||
return joyinfo;
|
||||
}
|
||||
|
||||
void sdl_post_debugger_command(void *data) {
|
||||
void event_post_debugger_command(void *data) {
|
||||
SDL_Event event = {
|
||||
.user = {
|
||||
.type = custom_event_type,
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2000- Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __EVENT_H__
|
||||
#define __EVENT_H__
|
||||
|
||||
#include "config.h"
|
||||
#include <SDL_events.h>
|
||||
#include "portab.h"
|
||||
|
||||
extern bool (*event_custom_handler)(const SDL_Event *);
|
||||
|
||||
void event_init(void);
|
||||
void event_remove(void);
|
||||
void event_set_joy_device_index(int index);
|
||||
void event_set_mouse_location(int x, int y);
|
||||
void event_set_mouse_internal_location(int x, int y);
|
||||
int event_get_key(void);
|
||||
int event_get_mouse(SDL_Point *p);
|
||||
void event_get_wheel(int *forward, int *back);
|
||||
void event_clear_wheel(void);
|
||||
int event_get_joy(void);
|
||||
void event_post_debugger_command(void *data);
|
||||
void event_handle_event(SDL_Event *e);
|
||||
|
||||
#endif // __EVENT_H__
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
#define CONCATENATE(x, y) x ## y
|
||||
#define CONCAT(x, y) CONCATENATE(x, y)
|
||||
|
||||
static SDL_Rect CONCAT(sdl_floodFill_, TYPE)(int x, int y, Uint32 col) {
|
||||
static SDL_Rect CONCAT(gfx_floodFill_, TYPE)(int x, int y, Uint32 col) {
|
||||
int old_color = *(TYPE *)PIXEL_AT(main_surface, x, y);
|
||||
if (old_color == col)
|
||||
return (SDL_Rect){};
|
||||
|
||||
+7
-7
@@ -35,7 +35,7 @@
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "font.h"
|
||||
#include "sdl_private.h"
|
||||
#include "gfx_private.h"
|
||||
#include "hacks.h"
|
||||
|
||||
typedef struct {
|
||||
@@ -130,9 +130,9 @@ SDL_Surface *font_get_glyph(const char *str_utf8, int r, int g, int b) {
|
||||
}
|
||||
|
||||
// SDL can't blit ARGB to an indexed bitmap properly, so we do it ourselves.
|
||||
static void sdl_drawAntiAlias_8bpp(int dstx, int dsty, SDL_Surface *src, uint8_t col)
|
||||
static void gfx_drawAntiAlias_8bpp(int dstx, int dsty, SDL_Surface *src, uint8_t col)
|
||||
{
|
||||
const SDL_Color* palette = sdl_palette->colors;
|
||||
const SDL_Color* palette = gfx_palette->colors;
|
||||
Uint8 cache[256*7];
|
||||
memset(cache, 0, 256);
|
||||
|
||||
@@ -154,7 +154,7 @@ static void sdl_drawAntiAlias_8bpp(int dstx, int dsty, SDL_Surface *src, uint8_t
|
||||
} else {
|
||||
// find nearest color in palette
|
||||
cache[*dp] |= 1 << alpha;
|
||||
int c = sdl_nearest_color(
|
||||
int c = gfx_nearest_color(
|
||||
(palette[col].r * alpha + palette[*dp].r * (7 - alpha)) / 7,
|
||||
(palette[col].g * alpha + palette[*dp].g * (7 - alpha)) / 7,
|
||||
(palette[col].b * alpha + palette[*dp].b * (7 - alpha)) / 7);
|
||||
@@ -186,9 +186,9 @@ SDL_Rect font_draw_glyph(int x, int y, const char *str_utf8, uint8_t cl) {
|
||||
antialias = false;
|
||||
|
||||
if (antialias) {
|
||||
fs = TTF_RenderUTF8_Blended(fontset->id, str_utf8, sdl_palette->colors[cl]);
|
||||
fs = TTF_RenderUTF8_Blended(fontset->id, str_utf8, gfx_palette->colors[cl]);
|
||||
} else {
|
||||
fs = TTF_RenderUTF8_Solid(fontset->id, str_utf8, sdl_palette->colors[cl]);
|
||||
fs = TTF_RenderUTF8_Solid(fontset->id, str_utf8, gfx_palette->colors[cl]);
|
||||
}
|
||||
if (!fs) {
|
||||
WARNING("Text rendering failed: %s", TTF_GetError());
|
||||
@@ -201,7 +201,7 @@ SDL_Rect font_draw_glyph(int x, int y, const char *str_utf8, uint8_t cl) {
|
||||
r_dst = (SDL_Rect){x, y, w, h};
|
||||
|
||||
if (main_surface->format->BitsPerPixel == 8 && antialias) {
|
||||
sdl_drawAntiAlias_8bpp(x, y, fs, cl);
|
||||
gfx_drawAntiAlias_8bpp(x, y, fs, cl);
|
||||
} else {
|
||||
r_src = (SDL_Rect){0, 0, w, h};
|
||||
SDL_BlitSurface(fs, &r_src, main_surface, &r_dst);
|
||||
|
||||
+6
-1
@@ -27,7 +27,12 @@
|
||||
#include <SDL_surface.h>
|
||||
#include "config.h"
|
||||
#include "portab.h"
|
||||
#include "graphics.h"
|
||||
|
||||
typedef enum {
|
||||
FONT_GOTHIC,
|
||||
FONT_MINCHO,
|
||||
} FontType;
|
||||
#define FONTTYPEMAX 2
|
||||
|
||||
#define FONT_WEIGHT_NORMAL 4
|
||||
#define FONT_WEIGHT_BOLD 7
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2000- Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
|
||||
* 2025 kichikuou <KichikuouChrome@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#ifndef __GFX_H__
|
||||
#define __GFX_H__
|
||||
|
||||
#include "config.h"
|
||||
#include <SDL_surface.h>
|
||||
#include "portab.h"
|
||||
#include "ags.h"
|
||||
|
||||
/* 初期化関係 */
|
||||
int gfx_Initialize(const char *render_driver);
|
||||
void gfx_Remove(void);
|
||||
|
||||
/* ウィンド関係 */
|
||||
void gfx_setWorldSize(int width, int height, int depth);
|
||||
void gfx_setWindowSize(int w, int h);
|
||||
void gfx_setWindowTitle(char *name);
|
||||
void gfx_getWindowInfo(int *width, int *height, int *depth);
|
||||
void gfx_setFullscreen(bool on);
|
||||
bool gfx_isFullscreen(void);
|
||||
void gfx_raiseWindow(void);
|
||||
surface_t *gfx_getDIB(void);
|
||||
void gfx_setIntegerScaling(bool enable);
|
||||
SDL_Surface *gfx_createSurfaceView(SDL_Surface *sf, int x, int y, int w, int h);
|
||||
|
||||
/* 画面更新 */
|
||||
void gfx_updateArea(SDL_Rect *src, SDL_Point *dst);
|
||||
void gfx_updateAll(SDL_Rect *view_rect);
|
||||
void gfx_updateScreen(void);
|
||||
|
||||
/* パレット関係 */
|
||||
void gfx_setPalette(SDL_Color *pal, int first, int count);
|
||||
|
||||
/* 描画関係 */
|
||||
void gfx_drawRectangle(int x, int y, int w, int h, uint8_t c);
|
||||
void gfx_fillRectangle(int x, int y, int w, int h, uint8_t c);
|
||||
void gfx_fillRectangleRGB(int x, int y, int w, int h, uint8_t r, uint8_t g, uint8_t b);
|
||||
void gfx_fillCircle(int left, int top, int diameter, uint8_t c);
|
||||
void gfx_drawLine(int x1, int y1, int x2, int y2, uint8_t c);
|
||||
SDL_Rect gfx_floodFill(int x, int y, int col);
|
||||
SDL_Rect gfx_drawString(int x, int y, const char *str_utf8, uint8_t col);
|
||||
void gfx_copyArea(int sx,int sy, int w, int h, int dx, int dy);
|
||||
void gfx_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, uint8_t sp);
|
||||
void gfx_wrapColor(int sx, int sy, int w, int h, uint8_t cl, int rate);
|
||||
void gfx_scaledCopyArea(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int mirror);
|
||||
void gfx_drawImage8(cgdata *cg, int x, int y, int sprite_color);
|
||||
void gfx_drawImage16(cgdata *cg, surface_t *sf, int x, int y, int brightness, bool alpha_blend);
|
||||
void gfx_drawImage24(cgdata *cg, surface_t *sf, int x, int y, int brightness);
|
||||
void gfx_drawImageAlphaMap(cgdata *cg, surface_t *sf, int x, int y);
|
||||
void gfx_copyAreaSP16_shadow(int sx, int sy, int w, int h, int dx, int dy, int lv);
|
||||
void gfx_copyAreaSP16_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, int lv);
|
||||
void gfx_copyAreaSP16_alphaLevel(int sx, int sy, int w, int h, int dx, int dy, int lv);
|
||||
void gfx_copy_from_alpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag);
|
||||
void gfx_copy_to_alpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag);
|
||||
uint32_t gfx_getPixel(int x, int y);
|
||||
void gfx_putRegion(void *src, int x, int y);
|
||||
void gfx_restoreRegion(void *src, int x, int y);
|
||||
void* gfx_saveRegion(int x, int y, int w, int h);
|
||||
void gfx_delRegion(void *src);
|
||||
void gfx_FlipSurfaceHorizontal(SDL_Surface *s);
|
||||
void gfx_FlipSurfaceVertical(SDL_Surface *s);
|
||||
|
||||
bool save_screenshot(const char* path);
|
||||
|
||||
#endif /* __GFX_H__ */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* sdl_darw.c SDL draw to surface
|
||||
* gfx_draw.c SDL draw to surface
|
||||
*
|
||||
* Copyright (C) 2000- Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
|
||||
*
|
||||
@@ -18,7 +18,7 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: sdl_draw.c,v 1.13 2003/01/25 01:34:50 chikama Exp $ */
|
||||
/* $Id: gfx_draw.c,v 1.13 2003/01/25 01:34:50 chikama Exp $ */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@@ -34,76 +34,38 @@
|
||||
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "sdl_core.h"
|
||||
#include "sdl_private.h"
|
||||
#include "scheduler.h"
|
||||
#include "gfx.h"
|
||||
#include "gfx_private.h"
|
||||
#include "font.h"
|
||||
#include "ags.h"
|
||||
#include "image.h"
|
||||
#include "nact.h"
|
||||
#include "debugger.h"
|
||||
|
||||
static void sdl_pal_check(void) {
|
||||
static void gfx_pal_check(void) {
|
||||
if (nact->ags.pal_changed) {
|
||||
nact->ags.pal_changed = false;
|
||||
sdl_setPalette(nact->ags.pal, 0, 256);
|
||||
gfx_setPalette(nact->ags.pal, 0, 256);
|
||||
}
|
||||
}
|
||||
|
||||
static Uint32 palette_color(uint8_t c) {
|
||||
if (main_surface->format->BitsPerPixel == 8)
|
||||
return c;
|
||||
return SDL_MapRGB(main_surface->format, sdl_palette->colors[c].r, sdl_palette->colors[c].g, sdl_palette->colors[c].b);
|
||||
return SDL_MapRGB(main_surface->format, gfx_palette->colors[c].r, gfx_palette->colors[c].g, gfx_palette->colors[c].b);
|
||||
}
|
||||
|
||||
void sdl_updateScreen(void) {
|
||||
if (!sdl_dirty)
|
||||
void gfx_updateScreen(void) {
|
||||
if (!gfx_dirty)
|
||||
return;
|
||||
SDL_RenderClear(sdl_renderer);
|
||||
SDL_RenderCopy(sdl_renderer, sdl_texture, NULL, NULL);
|
||||
SDL_RenderPresent(sdl_renderer);
|
||||
sdl_dirty = false;
|
||||
}
|
||||
|
||||
uint32_t sdl_getTicks(void) {
|
||||
return SDL_GetTicks();
|
||||
}
|
||||
|
||||
void sdl_sleep(int msec) {
|
||||
sdl_updateScreen();
|
||||
dbg_onsleep();
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_sleep(msec);
|
||||
#else
|
||||
SDL_Delay(msec);
|
||||
#endif
|
||||
scheduler_on_event(SCHEDULER_EVENT_SLEEP);
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
EM_JS(void, wait_vsync, (void), {
|
||||
// We need a `return` here for JSPI support (ASYNCIFY=2).
|
||||
return Asyncify.handleSleep(function(wakeUp) {
|
||||
window.requestAnimationFrame(function() {
|
||||
wakeUp();
|
||||
});
|
||||
});
|
||||
});
|
||||
#endif
|
||||
|
||||
void sdl_wait_vsync() {
|
||||
sdl_updateScreen();
|
||||
dbg_onsleep();
|
||||
#ifdef __EMSCRIPTEN__
|
||||
wait_vsync();
|
||||
#else
|
||||
SDL_Delay(16);
|
||||
#endif
|
||||
scheduler_on_event(SCHEDULER_EVENT_SLEEP);
|
||||
SDL_RenderClear(gfx_renderer);
|
||||
SDL_RenderCopy(gfx_renderer, gfx_texture, NULL, NULL);
|
||||
SDL_RenderPresent(gfx_renderer);
|
||||
gfx_dirty = false;
|
||||
}
|
||||
|
||||
/* off-screen の指定領域を Main Window へ転送 */
|
||||
void sdl_updateArea(MyRectangle *rect, MyPoint *dst) {
|
||||
void gfx_updateArea(SDL_Rect *rect, SDL_Point *dst) {
|
||||
SDL_Rect sw = {0, 0, main_surface->w, main_surface->h};
|
||||
SDL_Rect dw = {0, 0, view_w, view_h};
|
||||
SDL_Rect sr = {rect->x, rect->y, rect->w, rect->h};
|
||||
@@ -114,26 +76,26 @@ void sdl_updateArea(MyRectangle *rect, MyPoint *dst) {
|
||||
dr.h = sr.h;
|
||||
|
||||
SDL_Surface *sf;
|
||||
SDL_LockTextureToSurface(sdl_texture, &dr, &sf);
|
||||
SDL_LockTextureToSurface(gfx_texture, &dr, &sf);
|
||||
SDL_BlitSurface(main_surface, &sr, sf, NULL);
|
||||
SDL_UnlockTexture(sdl_texture);
|
||||
SDL_UnlockTexture(gfx_texture);
|
||||
|
||||
sdl_dirty = true;
|
||||
gfx_dirty = true;
|
||||
}
|
||||
|
||||
/* 全画面更新 */
|
||||
void sdl_updateAll(MyRectangle *view_rect) {
|
||||
sdl_updateArea(view_rect, &(MyPoint){0, 0});
|
||||
void gfx_updateAll(SDL_Rect *view_rect) {
|
||||
gfx_updateArea(view_rect, &(SDL_Point){0, 0});
|
||||
}
|
||||
|
||||
/* Color の複数個指定 */
|
||||
void sdl_setPalette(SDL_Color *pal, int first, int count) {
|
||||
SDL_SetPaletteColors(sdl_palette, pal + first, first, count);
|
||||
void gfx_setPalette(SDL_Color *pal, int first, int count) {
|
||||
SDL_SetPaletteColors(gfx_palette, pal + first, first, count);
|
||||
}
|
||||
|
||||
/* 矩形の描画 */
|
||||
void sdl_drawRectangle(int x, int y, int w, int h, uint8_t c) {
|
||||
sdl_pal_check();
|
||||
void gfx_drawRectangle(int x, int y, int w, int h, uint8_t c) {
|
||||
gfx_pal_check();
|
||||
Uint32 col = palette_color(c);
|
||||
|
||||
SDL_Rect rect = {x, y, w, 1};
|
||||
@@ -150,14 +112,14 @@ void sdl_drawRectangle(int x, int y, int w, int h, uint8_t c) {
|
||||
}
|
||||
|
||||
/* 矩形塗りつぶし */
|
||||
void sdl_fillRectangle(int x, int y, int w, int h, uint8_t c) {
|
||||
sdl_pal_check();
|
||||
void gfx_fillRectangle(int x, int y, int w, int h, uint8_t c) {
|
||||
gfx_pal_check();
|
||||
|
||||
SDL_Rect rect = {x, y, w, h};
|
||||
SDL_FillRect(main_surface, &rect, palette_color(c));
|
||||
}
|
||||
|
||||
void sdl_fillRectangleRGB(int x, int y, int w, int h, uint8_t r, uint8_t g, uint8_t b) {
|
||||
void gfx_fillRectangleRGB(int x, int y, int w, int h, uint8_t r, uint8_t g, uint8_t b) {
|
||||
if (main_surface->format->BitsPerPixel == 8)
|
||||
return;
|
||||
|
||||
@@ -165,7 +127,7 @@ void sdl_fillRectangleRGB(int x, int y, int w, int h, uint8_t r, uint8_t g, uint
|
||||
SDL_FillRect(main_surface, &rect, SDL_MapRGB(main_surface->format, r, g, b));
|
||||
}
|
||||
|
||||
void sdl_fillCircle(int left, int top, int diameter, uint8_t c) {
|
||||
void gfx_fillCircle(int left, int top, int diameter, uint8_t c) {
|
||||
diameter &= ~1;
|
||||
if (diameter <= 0)
|
||||
return;
|
||||
@@ -188,7 +150,7 @@ void sdl_fillCircle(int left, int top, int diameter, uint8_t c) {
|
||||
}
|
||||
|
||||
/* 領域コピー */
|
||||
void sdl_copyArea(int sx, int sy, int w, int h, int dx, int dy) {
|
||||
void gfx_copyArea(int sx, int sy, int w, int h, int dx, int dy) {
|
||||
if (sx == dx && sy == dy)
|
||||
return;
|
||||
|
||||
@@ -197,15 +159,15 @@ void sdl_copyArea(int sx, int sy, int w, int h, int dx, int dy) {
|
||||
|
||||
SDL_Rect intersect;
|
||||
if (SDL_IntersectRect(&r_src, &r_dst, &intersect)) {
|
||||
void* region = sdl_saveRegion(sx, sy, w, h);
|
||||
sdl_restoreRegion(region, dx, dy);
|
||||
void* region = gfx_saveRegion(sx, sy, w, h);
|
||||
gfx_restoreRegion(region, dx, dy);
|
||||
} else {
|
||||
SDL_BlitSurface(main_surface, &r_src, main_surface, &r_dst);
|
||||
}
|
||||
}
|
||||
|
||||
static void sdl_dib_sprite_copy(SDL_Surface *dst, int sx, int sy, int w, int h, int dx, int dy, uint8_t sp) {
|
||||
sdl_pal_check();
|
||||
static void gfx_dib_sprite_copy(SDL_Surface *dst, int sx, int sy, int w, int h, int dx, int dy, uint8_t sp) {
|
||||
gfx_pal_check();
|
||||
|
||||
Uint32 col = palette_color(sp);
|
||||
SDL_SetColorKey(main_surface, SDL_TRUE, col);
|
||||
@@ -220,29 +182,29 @@ static void sdl_dib_sprite_copy(SDL_Surface *dst, int sx, int sy, int w, int h,
|
||||
/*
|
||||
* dib に指定のパレット sp を抜いてコピー
|
||||
*/
|
||||
void sdl_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, uint8_t sp) {
|
||||
sdl_dib_sprite_copy(main_surface, sx, sy, w, h, dx, dy, sp);
|
||||
void gfx_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, uint8_t sp) {
|
||||
gfx_dib_sprite_copy(main_surface, sx, sy, w, h, dx, dy, sp);
|
||||
}
|
||||
|
||||
SDL_Surface *sdl_dib_to_surface_colorkey(int x, int y, int w, int h, int sp) {
|
||||
SDL_Surface *gfx_dib_to_surface_colorkey(int x, int y, int w, int h, int sp) {
|
||||
SDL_Surface *s = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, SDL_PIXELFORMAT_ARGB8888);
|
||||
SDL_FillRect(s, NULL, 0);
|
||||
sdl_dib_sprite_copy(s, x, y, w, h, 0, 0, sp);
|
||||
gfx_dib_sprite_copy(s, x, y, w, h, 0, 0, sp);
|
||||
return s;
|
||||
}
|
||||
|
||||
void sdl_drawImage8(cgdata *cg, int dx, int dy, int sprite_color) {
|
||||
void gfx_drawImage8(cgdata *cg, int dx, int dy, int sprite_color) {
|
||||
int w = cg->width;
|
||||
int h = cg->height;
|
||||
SDL_Surface *s = SDL_CreateRGBSurfaceWithFormatFrom(
|
||||
cg->pic, w, h, 8, w, SDL_PIXELFORMAT_INDEX8);
|
||||
|
||||
sdl_pal_check();
|
||||
gfx_pal_check();
|
||||
|
||||
if (main_surface->format->BitsPerPixel > 8 && cg->pal) {
|
||||
SDL_SetPaletteColors(s->format->palette, cg->pal, 0, 256);
|
||||
} else {
|
||||
SDL_SetSurfacePalette(s, sdl_palette);
|
||||
SDL_SetSurfacePalette(s, gfx_palette);
|
||||
}
|
||||
|
||||
if (sprite_color != -1)
|
||||
@@ -255,11 +217,11 @@ void sdl_drawImage8(cgdata *cg, int dx, int dy, int sprite_color) {
|
||||
}
|
||||
|
||||
/* 直線描画 */
|
||||
void sdl_drawLine(int x1, int y1, int x2, int y2, uint8_t c) {
|
||||
sdl_pal_check();
|
||||
void gfx_drawLine(int x1, int y1, int x2, int y2, uint8_t c) {
|
||||
gfx_pal_check();
|
||||
|
||||
SDL_Renderer *renderer = SDL_CreateSoftwareRenderer(main_surface);
|
||||
SDL_SetRenderDrawColor(renderer, sdl_palette->colors[c].r, sdl_palette->colors[c].g, sdl_palette->colors[c].b, SDL_ALPHA_OPAQUE);
|
||||
SDL_SetRenderDrawColor(renderer, gfx_palette->colors[c].r, gfx_palette->colors[c].g, gfx_palette->colors[c].b, SDL_ALPHA_OPAQUE);
|
||||
SDL_RenderDrawLine(renderer, x1, y1, x2, y2);
|
||||
SDL_DestroyRenderer(renderer);
|
||||
}
|
||||
@@ -274,28 +236,28 @@ void sdl_drawLine(int x1, int y1, int x2, int y2, uint8_t c) {
|
||||
#include "flood.h"
|
||||
#undef TYPE
|
||||
|
||||
SDL_Rect sdl_floodFill(int x, int y, int c) {
|
||||
SDL_Rect gfx_floodFill(int x, int y, int c) {
|
||||
Uint32 col = palette_color(c);
|
||||
|
||||
switch (main_surface->format->BytesPerPixel) {
|
||||
case 1:
|
||||
return sdl_floodFill_uint8_t(x, y, col);
|
||||
return gfx_floodFill_uint8_t(x, y, col);
|
||||
case 2:
|
||||
return sdl_floodFill_uint16_t(x, y, col);
|
||||
return gfx_floodFill_uint16_t(x, y, col);
|
||||
case 4:
|
||||
return sdl_floodFill_uint32_t(x, y, col);
|
||||
return gfx_floodFill_uint32_t(x, y, col);
|
||||
default:
|
||||
WARNING("sdl_floodFill: unsupported DIB format");
|
||||
WARNING("gfx_floodFill: unsupported DIB format");
|
||||
return (SDL_Rect){};
|
||||
}
|
||||
}
|
||||
|
||||
int sdl_nearest_color(int r, int g, int b) {
|
||||
int gfx_nearest_color(int r, int g, int b) {
|
||||
int i, col, mind = INT_MAX;
|
||||
for (i = 0; i < 256; i++) {
|
||||
int dr = r - sdl_palette->colors[i].r;
|
||||
int dg = g - sdl_palette->colors[i].g;
|
||||
int db = b - sdl_palette->colors[i].b;
|
||||
int dr = r - gfx_palette->colors[i].r;
|
||||
int dg = g - gfx_palette->colors[i].g;
|
||||
int db = b - gfx_palette->colors[i].b;
|
||||
int d = dr*dr*30 + dg*dg*59 + db*db*11;
|
||||
if (d < mind) {
|
||||
mind = d;
|
||||
@@ -305,15 +267,15 @@ int sdl_nearest_color(int r, int g, int b) {
|
||||
return col;
|
||||
}
|
||||
|
||||
SDL_Rect sdl_drawString(int x, int y, const char *str_utf8, uint8_t col) {
|
||||
sdl_pal_check();
|
||||
SDL_Rect gfx_drawString(int x, int y, const char *str_utf8, uint8_t col) {
|
||||
gfx_pal_check();
|
||||
return font_draw_glyph(x, y, str_utf8, col);
|
||||
}
|
||||
|
||||
/*
|
||||
* 指定範囲にパレット col を rate の割合で重ねる CK1
|
||||
*/
|
||||
void sdl_wrapColor(int sx, int sy, int w, int h, uint8_t c, int rate) {
|
||||
void gfx_wrapColor(int sx, int sy, int w, int h, uint8_t c, int rate) {
|
||||
SDL_Surface *s = SDL_CreateRGBSurfaceWithFormat(0, w, h, main_surface->format->BitsPerPixel, main_surface->format->format);
|
||||
assert(s->format->BitsPerPixel > 8);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* sdl_image.c image操作 for SDL
|
||||
* gfx_image.c image操作 for SDL
|
||||
*
|
||||
* Copyright (C) 2000- Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
|
||||
*
|
||||
@@ -18,7 +18,7 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: sdl_image.c,v 1.23 2003/07/20 19:30:16 chikama Exp $ */
|
||||
/* $Id: gfx_image.c,v 1.23 2003/07/20 19:30:16 chikama Exp $ */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@@ -28,14 +28,14 @@
|
||||
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "sdl_core.h"
|
||||
#include "sdl_private.h"
|
||||
#include "gfx.h"
|
||||
#include "gfx_private.h"
|
||||
#include "cg.h"
|
||||
#include "nact.h"
|
||||
#include "alpha_plane.h"
|
||||
#include "image.h"
|
||||
|
||||
void sdl_FlipSurfaceHorizontal(SDL_Surface *s) {
|
||||
void gfx_FlipSurfaceHorizontal(SDL_Surface *s) {
|
||||
#if SDL_VERSION_ATLEAST(3, 2, 0)
|
||||
SDL_FlipSurface(s, SDL_FLIP_HORIZONTAL);
|
||||
#else
|
||||
@@ -57,7 +57,7 @@ void sdl_FlipSurfaceHorizontal(SDL_Surface *s) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void sdl_FlipSurfaceVertical(SDL_Surface *s) {
|
||||
void gfx_FlipSurfaceVertical(SDL_Surface *s) {
|
||||
#if SDL_VERSION_ATLEAST(3, 2, 0)
|
||||
SDL_FlipSurface(s, SDL_FLIP_VERTICAL);
|
||||
#else
|
||||
@@ -76,28 +76,28 @@ void sdl_FlipSurfaceVertical(SDL_Surface *s) {
|
||||
}
|
||||
|
||||
// Scaled copy in main_surface
|
||||
void sdl_scaledCopyArea(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int mirror) {
|
||||
void gfx_scaledCopyArea(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int mirror) {
|
||||
SDL_Rect src_rect = {sx, sy, sw, sh};
|
||||
SDL_Rect dst_rect = {dx, dy, dw, dh};
|
||||
// NOTE: SDL_BlitScaled() does not support 8-bit surfaces.
|
||||
SDL_SoftStretch(main_surface, &src_rect, main_surface, &dst_rect);
|
||||
if (mirror) {
|
||||
SDL_IntersectRect(&dst_rect, &(SDL_Rect){0, 0, main_surface->w, main_surface->h}, &dst_rect);
|
||||
SDL_Surface *view = sdl_createSurfaceView(main_surface, dst_rect.x, dst_rect.y, dst_rect.w, dst_rect.h);
|
||||
SDL_Surface *view = gfx_createSurfaceView(main_surface, dst_rect.x, dst_rect.y, dst_rect.w, dst_rect.h);
|
||||
if (mirror & 1)
|
||||
sdl_FlipSurfaceVertical(view);
|
||||
gfx_FlipSurfaceVertical(view);
|
||||
if (mirror & 2)
|
||||
sdl_FlipSurfaceHorizontal(view);
|
||||
gfx_FlipSurfaceHorizontal(view);
|
||||
SDL_FreeSurface(view);
|
||||
}
|
||||
}
|
||||
|
||||
void sdl_drawImage16(cgdata *cg, surface_t *sf, int dx, int dy, int brightness, bool alpha_blend) {
|
||||
void gfx_drawImage16(cgdata *cg, surface_t *sf, int dx, int dy, int brightness, bool alpha_blend) {
|
||||
int w = cg->width;
|
||||
int h = cg->height;
|
||||
|
||||
if (cg->alpha && !alpha_blend) {
|
||||
sdl_drawImageAlphaMap(cg, sf, dx, dy);
|
||||
gfx_drawImageAlphaMap(cg, sf, dx, dy);
|
||||
}
|
||||
|
||||
SDL_Surface *s;
|
||||
@@ -136,9 +136,9 @@ void sdl_drawImage16(cgdata *cg, surface_t *sf, int dx, int dy, int brightness,
|
||||
SDL_FreeSurface(s);
|
||||
}
|
||||
|
||||
void sdl_drawImage24(cgdata *cg, surface_t *sf, int x, int y, int brightness) {
|
||||
void gfx_drawImage24(cgdata *cg, surface_t *sf, int x, int y, int brightness) {
|
||||
if (cg->alpha) {
|
||||
sdl_drawImageAlphaMap(cg, sf, x, y);
|
||||
gfx_drawImageAlphaMap(cg, sf, x, y);
|
||||
}
|
||||
|
||||
SDL_Surface *s = SDL_CreateRGBSurfaceWithFormatFrom(
|
||||
@@ -151,7 +151,7 @@ void sdl_drawImage24(cgdata *cg, surface_t *sf, int x, int y, int brightness) {
|
||||
SDL_FreeSurface(s);
|
||||
}
|
||||
|
||||
void sdl_drawImageAlphaMap(cgdata *cg, surface_t *sf, int x, int y) {
|
||||
void gfx_drawImageAlphaMap(cgdata *cg, surface_t *sf, int x, int y) {
|
||||
if (!cg->alpha || !sf->alpha) return;
|
||||
|
||||
uint8_t *a_src = cg->alpha;
|
||||
@@ -164,14 +164,14 @@ void sdl_drawImageAlphaMap(cgdata *cg, surface_t *sf, int x, int y) {
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Surface *sdl_dib_to_surface_with_alpha(int x, int y, int w, int h) {
|
||||
SDL_Surface *gfx_dib_to_surface_with_alpha(int x, int y, int w, int h) {
|
||||
SDL_Surface *s = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, SDL_PIXELFORMAT_ARGB8888);
|
||||
|
||||
SDL_Rect r_src = {x, y, w, h};
|
||||
SDL_BlitSurface(main_surface, &r_src, s, NULL);
|
||||
|
||||
uint8_t *p_ds = ALPHA_AT(s, 0, 0);
|
||||
uint8_t *adata = GETOFFSET_ALPHA(sdl_dibinfo, x, y);
|
||||
uint8_t *adata = GETOFFSET_ALPHA(gfx_dibinfo, x, y);
|
||||
for (int y = 0; y < h; y++) {
|
||||
uint8_t *p_src = adata;
|
||||
uint8_t *p_dst = p_ds;
|
||||
@@ -179,14 +179,14 @@ SDL_Surface *sdl_dib_to_surface_with_alpha(int x, int y, int w, int h) {
|
||||
*p_dst = *(p_src++);
|
||||
p_dst += 4;
|
||||
}
|
||||
adata += sdl_dibinfo->width;
|
||||
adata += gfx_dibinfo->width;
|
||||
p_ds += s->pitch;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
void sdl_copyAreaSP16_shadow(int sx, int sy, int w, int h, int dx, int dy, int lv) {
|
||||
SDL_Surface *s = sdl_dib_to_surface_with_alpha(sx, sy, w, h);
|
||||
void gfx_copyAreaSP16_shadow(int sx, int sy, int w, int h, int dx, int dy, int lv) {
|
||||
SDL_Surface *s = gfx_dib_to_surface_with_alpha(sx, sy, w, h);
|
||||
if (lv < 255)
|
||||
SDL_SetSurfaceAlphaMod(s, lv);
|
||||
|
||||
@@ -195,7 +195,7 @@ void sdl_copyAreaSP16_shadow(int sx, int sy, int w, int h, int dx, int dy, int l
|
||||
SDL_FreeSurface(s);
|
||||
}
|
||||
|
||||
void sdl_copyAreaSP16_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, int lv) {
|
||||
void gfx_copyAreaSP16_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, int lv) {
|
||||
SDL_Rect r_src = {sx, sy, w, h};
|
||||
SDL_Rect r_dst = {dx, dy, w, h};
|
||||
SDL_SetSurfaceBlendMode(main_surface, SDL_BLENDMODE_BLEND);
|
||||
@@ -205,7 +205,7 @@ void sdl_copyAreaSP16_alphaBlend(int sx, int sy, int w, int h, int dx, int dy, i
|
||||
SDL_SetSurfaceBlendMode(main_surface, SDL_BLENDMODE_NONE);
|
||||
}
|
||||
|
||||
void sdl_copyAreaSP16_alphaLevel(int sx, int sy, int w, int h, int dx, int dy, int lv) {
|
||||
void gfx_copyAreaSP16_alphaLevel(int sx, int sy, int w, int h, int dx, int dy, int lv) {
|
||||
SDL_Rect r_src = {sx, sy, w, h};
|
||||
SDL_Rect r_dst = {dx, dy, w, h};
|
||||
SDL_SetSurfaceBlendMode(main_surface, SDL_BLENDMODE_BLEND);
|
||||
@@ -216,53 +216,42 @@ void sdl_copyAreaSP16_alphaLevel(int sx, int sy, int w, int h, int dx, int dy, i
|
||||
SDL_SetSurfaceBlendMode(main_surface, SDL_BLENDMODE_NONE);
|
||||
}
|
||||
|
||||
void sdl_copy_from_alpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag) {
|
||||
void gfx_copy_from_alpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag) {
|
||||
image_copy_from_alpha(nact->ags.dib, sx, sy, w, h, dx, dy, flag);
|
||||
}
|
||||
|
||||
void sdl_copy_to_alpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag) {
|
||||
void gfx_copy_to_alpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag) {
|
||||
image_copy_to_alpha(nact->ags.dib, sx, sy, w, h, dx, dy, flag);
|
||||
}
|
||||
|
||||
/*
|
||||
* dib のピクセル情報を取得
|
||||
*/
|
||||
void sdl_getPixel(int x, int y, Palette *cell) {
|
||||
uint32_t gfx_getPixel(int x, int y) {
|
||||
uint8_t *p = PIXEL_AT(main_surface, x, y);
|
||||
if (main_surface->format->BitsPerPixel == 8) {
|
||||
cell->pixel = *p;
|
||||
} else {
|
||||
Uint32 cl=0;
|
||||
|
||||
switch (main_surface->format->BytesPerPixel) {
|
||||
case 2:
|
||||
{
|
||||
unsigned short *pp = (unsigned short *)p;
|
||||
cl = *pp;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
|
||||
switch (main_surface->format->BytesPerPixel) {
|
||||
case 1:
|
||||
return *p;
|
||||
case 2:
|
||||
return *(unsigned short *)p;
|
||||
case 3:
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
cl = (p[2]<<16)+(p[1]<<8) + p[0];
|
||||
return (p[2]<<16)+(p[1]<<8) + p[0];
|
||||
#else
|
||||
cl = (p[0]<<16)+(p[1]<<8) + p[2];
|
||||
return (p[0]<<16)+(p[1]<<8) + p[2];
|
||||
#endif
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
Uint32 *pp = (Uint32 *)p;
|
||||
cl = *pp;
|
||||
}
|
||||
break;
|
||||
}
|
||||
SDL_GetRGB(cl, main_surface->format, &cell->r, &cell->g, &cell->b);
|
||||
case 4:
|
||||
return *(Uint32 *)p;
|
||||
default:
|
||||
return 0; // cannot happen
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* dib から領域の切り出し
|
||||
*/
|
||||
void* sdl_saveRegion(int x, int y, int w, int h) {
|
||||
void* gfx_saveRegion(int x, int y, int w, int h) {
|
||||
SDL_Surface *s = SDL_CreateRGBSurfaceWithFormat(0, w, h, main_surface->format->BitsPerPixel, main_surface->format->format);
|
||||
if (main_surface->format->BitsPerPixel == 8)
|
||||
memcpy(s->format->palette->colors, main_surface->format->palette->colors,
|
||||
@@ -276,14 +265,14 @@ void* sdl_saveRegion(int x, int y, int w, int h) {
|
||||
/*
|
||||
* セーブした領域を破棄
|
||||
*/
|
||||
void sdl_delRegion(void *psrc) {
|
||||
void gfx_delRegion(void *psrc) {
|
||||
SDL_FreeSurface((SDL_Surface *)psrc);
|
||||
}
|
||||
|
||||
/*
|
||||
* dib にセーブした領域を回復
|
||||
*/
|
||||
void sdl_putRegion(void *psrc, int x, int y) {
|
||||
void gfx_putRegion(void *psrc, int x, int y) {
|
||||
SDL_Surface *src = (SDL_Surface *)psrc;
|
||||
|
||||
SDL_Rect r_src = {0, 0, src->w, src->h};
|
||||
@@ -295,8 +284,8 @@ void sdl_putRegion(void *psrc, int x, int y) {
|
||||
/*
|
||||
* dib に dstを描画後、後始末
|
||||
*/
|
||||
void sdl_restoreRegion(void *psrc, int x, int y) {
|
||||
void gfx_restoreRegion(void *psrc, int x, int y) {
|
||||
SDL_Surface *src = (SDL_Surface *)psrc;
|
||||
sdl_putRegion(src, x ,y);
|
||||
gfx_putRegion(src, x ,y);
|
||||
SDL_FreeSurface(src);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* sdl_private.h SDL only private data
|
||||
* gfx_private.h SDL only private data
|
||||
*
|
||||
* Copyright (C) 2000- Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
|
||||
*
|
||||
@@ -18,7 +18,7 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: sdl_private.h,v 1.4 2002/04/29 05:48:21 chikama Exp $ */
|
||||
/* $Id: gfx_private.h,v 1.4 2002/04/29 05:48:21 chikama Exp $ */
|
||||
|
||||
#ifndef __SDL_PRIVATE_H__
|
||||
#define __SDL_PRIVATE_H__
|
||||
@@ -30,22 +30,18 @@
|
||||
#include "portab.h"
|
||||
#include "ags.h"
|
||||
|
||||
extern SDL_Window *sdl_window;
|
||||
extern SDL_Renderer *sdl_renderer;
|
||||
extern SDL_Texture *sdl_texture;
|
||||
extern SDL_Palette *sdl_palette;
|
||||
extern surface_t *sdl_dibinfo;
|
||||
extern SDL_Window *gfx_window;
|
||||
extern SDL_Renderer *gfx_renderer;
|
||||
extern SDL_Texture *gfx_texture;
|
||||
extern SDL_Palette *gfx_palette;
|
||||
extern surface_t *gfx_dibinfo;
|
||||
extern int view_w;
|
||||
extern int view_h;
|
||||
extern bool sdl_dirty;
|
||||
extern bool sdl_fs_on;
|
||||
extern bool (*sdl_custom_event_handler)(const SDL_Event *);
|
||||
extern bool gfx_dirty;
|
||||
extern bool gfx_fullscreen;
|
||||
|
||||
void sdl_event_init(void);
|
||||
void sdl_cursor_init(void);
|
||||
int sdl_nearest_color(int r, int g, int b);
|
||||
bool sdl_joy_open(int index);
|
||||
SDL_Surface *sdl_dib_to_surface_with_alpha(int x, int y, int w, int h);
|
||||
SDL_Surface *sdl_dib_to_surface_colorkey(int x, int y, int w, int h, int col);
|
||||
int gfx_nearest_color(int r, int g, int b);
|
||||
SDL_Surface *gfx_dib_to_surface_with_alpha(int x, int y, int w, int h);
|
||||
SDL_Surface *gfx_dib_to_surface_colorkey(int x, int y, int w, int h, int col);
|
||||
|
||||
#endif /* __SDL_PRIVATE_H__ */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* sdl_video.c SDL video init
|
||||
* gfx_video.c SDL video init
|
||||
*
|
||||
* Copyright (C) 2000- Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
|
||||
*
|
||||
@@ -18,7 +18,7 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: sdl_video.c,v 1.11 2003/01/04 17:01:02 chikama Exp $ */
|
||||
/* $Id: gfx_video.c,v 1.11 2003/01/04 17:01:02 chikama Exp $ */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@@ -31,98 +31,60 @@
|
||||
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "sdl_core.h"
|
||||
#include "sdl_private.h"
|
||||
#include "gfx.h"
|
||||
#include "gfx_private.h"
|
||||
#include "xsystem35.h"
|
||||
#include "image.h"
|
||||
|
||||
SDL_Window *sdl_window;
|
||||
SDL_Renderer *sdl_renderer;
|
||||
SDL_Texture *sdl_texture;
|
||||
SDL_Window *gfx_window;
|
||||
SDL_Renderer *gfx_renderer;
|
||||
SDL_Texture *gfx_texture;
|
||||
SDL_Surface *main_surface; // offscreen surface
|
||||
SDL_Palette *sdl_palette;
|
||||
surface_t *sdl_dibinfo;
|
||||
SDL_Palette *gfx_palette;
|
||||
surface_t *gfx_dibinfo;
|
||||
int view_w;
|
||||
int view_h;
|
||||
bool sdl_dirty;
|
||||
bool sdl_fs_on;
|
||||
bool (*sdl_custom_event_handler)(const SDL_Event *);
|
||||
bool gfx_dirty;
|
||||
bool gfx_fullscreen;
|
||||
|
||||
static void window_init(const char *render_driver);
|
||||
static void makeDIB(int width, int height, int depth);
|
||||
|
||||
static int joy_device_index = -1;
|
||||
|
||||
static SDL_Joystick *js;
|
||||
|
||||
bool sdl_joy_open(int index) {
|
||||
if (js)
|
||||
return false;
|
||||
|
||||
js = SDL_JoystickOpen(index);
|
||||
if (!js)
|
||||
return false;
|
||||
|
||||
const char *name = SDL_JoystickName(js);
|
||||
int axes = SDL_JoystickNumAxes(js);
|
||||
int buttons = SDL_JoystickNumButtons(js);
|
||||
SDL_JoystickEventState(SDL_ENABLE);
|
||||
NOTICE("SDL joystick '%s' %d axes %d buttons", name, axes, buttons);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool joy_open(void) {
|
||||
if (joy_device_index >= 0)
|
||||
return sdl_joy_open(joy_device_index);
|
||||
|
||||
for (int i = 0; i < SDL_NumJoysticks(); i++) {
|
||||
if (sdl_joy_open(i))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* SDL の初期化 */
|
||||
int sdl_Initialize(const char *render_driver) {
|
||||
int gfx_Initialize(const char *render_driver) {
|
||||
window_init(render_driver);
|
||||
|
||||
/* offscreen Pixmap */
|
||||
makeDIB(SYS35_DEFAULT_WIDTH, SYS35_DEFAULT_HEIGHT, SYS35_DEFAULT_DEPTH);
|
||||
|
||||
sdl_event_init();
|
||||
sdl_cursor_init();
|
||||
|
||||
sdl_setWindowSize(SYS35_DEFAULT_WIDTH, SYS35_DEFAULT_HEIGHT);
|
||||
|
||||
gfx_setWindowSize(SYS35_DEFAULT_WIDTH, SYS35_DEFAULT_HEIGHT);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
// Prevent SDL from calling emscripten_exit_fullscreen on visibilitychange
|
||||
emscripten_set_visibilitychange_callback(NULL, 0, NULL);
|
||||
#endif
|
||||
|
||||
joy_open();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sdl_Remove(void) {
|
||||
if (sdl_palette)
|
||||
SDL_FreePalette(sdl_palette);
|
||||
void gfx_Remove(void) {
|
||||
if (gfx_palette)
|
||||
SDL_FreePalette(gfx_palette);
|
||||
if (main_surface)
|
||||
SDL_FreeSurface(main_surface);
|
||||
if (sdl_renderer)
|
||||
SDL_DestroyRenderer(sdl_renderer);
|
||||
if (js)
|
||||
SDL_JoystickClose(js);
|
||||
if (gfx_renderer)
|
||||
SDL_DestroyRenderer(gfx_renderer);
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
/* name is UTF-8 */
|
||||
#ifdef __EMSCRIPTEN__
|
||||
EM_JS(void, sdl_setWindowTitle, (char *name), {
|
||||
EM_JS(void, gfx_setWindowTitle, (char *name), {
|
||||
xsystem35.shell.setWindowTitle(UTF8ToString(name));
|
||||
});
|
||||
#else
|
||||
void sdl_setWindowTitle(char *name) {
|
||||
SDL_SetWindowTitle(sdl_window, name);
|
||||
void gfx_setWindowTitle(char *name) {
|
||||
SDL_SetWindowTitle(gfx_window, name);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -132,7 +94,7 @@ static void window_init(const char *render_driver) {
|
||||
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
|
||||
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
|
||||
|
||||
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
// Stop SDL from calling emscripten_sleep() in functions that are called
|
||||
@@ -153,12 +115,12 @@ static void window_init(const char *render_driver) {
|
||||
#else
|
||||
Uint32 flags = SDL_WINDOW_RESIZABLE;
|
||||
#endif
|
||||
sdl_window = SDL_CreateWindow(
|
||||
gfx_window = SDL_CreateWindow(
|
||||
title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||
SYS35_DEFAULT_WIDTH, SYS35_DEFAULT_HEIGHT, flags);
|
||||
sdl_renderer = SDL_CreateRenderer(sdl_window, -1, 0);
|
||||
SDL_SetRenderDrawColor(sdl_renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
|
||||
sdl_palette = SDL_AllocPalette(256);
|
||||
gfx_renderer = SDL_CreateRenderer(gfx_window, -1, 0);
|
||||
SDL_SetRenderDrawColor(gfx_renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
|
||||
gfx_palette = SDL_AllocPalette(256);
|
||||
}
|
||||
|
||||
static void makeDIB(int width, int height, int depth) {
|
||||
@@ -187,43 +149,43 @@ static void makeDIB(int width, int height, int depth) {
|
||||
main_surface = SDL_CreateRGBSurfaceWithFormat(0, width, height, depth, format);
|
||||
|
||||
if (main_surface->format->BitsPerPixel == 8) {
|
||||
SDL_SetSurfacePalette(main_surface, sdl_palette);
|
||||
SDL_SetSurfacePalette(main_surface, gfx_palette);
|
||||
}
|
||||
|
||||
if (sdl_dibinfo) {
|
||||
free(sdl_dibinfo);
|
||||
if (gfx_dibinfo) {
|
||||
free(gfx_dibinfo);
|
||||
}
|
||||
|
||||
sdl_dibinfo = calloc(1, sizeof(surface_t));
|
||||
sdl_dibinfo->width = width;
|
||||
sdl_dibinfo->height = height;
|
||||
sdl_dibinfo->alpha = NULL;
|
||||
sdl_dibinfo->sdl_surface = main_surface;
|
||||
gfx_dibinfo = calloc(1, sizeof(surface_t));
|
||||
gfx_dibinfo->width = width;
|
||||
gfx_dibinfo->height = height;
|
||||
gfx_dibinfo->alpha = NULL;
|
||||
gfx_dibinfo->sdl_surface = main_surface;
|
||||
|
||||
image_setdepth(main_surface->format->BitsPerPixel);
|
||||
}
|
||||
|
||||
/* offscreen の設定 */
|
||||
void sdl_setWorldSize(int width, int height, int depth) {
|
||||
void gfx_setWorldSize(int width, int height, int depth) {
|
||||
makeDIB(width, height, depth);
|
||||
SDL_FillRect(main_surface, NULL, 0);
|
||||
}
|
||||
|
||||
/* display の size と depth の取得 */
|
||||
void sdl_getWindowInfo(DispInfo *info) {
|
||||
void gfx_getWindowInfo(int *width, int *height, int *depth) {
|
||||
SDL_DisplayMode dm;
|
||||
SDL_GetCurrentDisplayMode(0, &dm);
|
||||
info->width = dm.w;
|
||||
info->height = dm.h;
|
||||
info->depth = SDL_BITSPERPIXEL(dm.format);
|
||||
if (width) *width = dm.w;
|
||||
if (height) *height = dm.h;
|
||||
if (depth) *depth = SDL_BITSPERPIXEL(dm.format);
|
||||
}
|
||||
|
||||
/* DIBの取得 */
|
||||
surface_t *sdl_getDIB(void) {
|
||||
return sdl_dibinfo;
|
||||
surface_t *gfx_getDIB(void) {
|
||||
return gfx_dibinfo;
|
||||
}
|
||||
|
||||
SDL_Surface *sdl_createSurfaceView(SDL_Surface *sf, int x, int y, int w, int h) {
|
||||
SDL_Surface *gfx_createSurfaceView(SDL_Surface *sf, int x, int y, int w, int h) {
|
||||
uint8_t *pixels = sf->pixels;
|
||||
pixels += y * sf->pitch + x * sf->format->BytesPerPixel;
|
||||
SDL_Surface *view = SDL_CreateRGBSurfaceWithFormatFrom(
|
||||
@@ -233,73 +195,50 @@ SDL_Surface *sdl_createSurfaceView(SDL_Surface *sf, int x, int y, int w, int h)
|
||||
return view;
|
||||
}
|
||||
|
||||
/* AutoRepeat の設定 */
|
||||
void sdl_setAutoRepeat(bool enable) {
|
||||
if (enable) {
|
||||
// SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
} else {
|
||||
// SDL_EnableKeyRepeat(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void sdl_setFullscreen(bool on) {
|
||||
void gfx_setFullscreen(bool on) {
|
||||
#ifndef __EMSCRIPTEN__
|
||||
if (on == sdl_fs_on)
|
||||
if (on == gfx_fullscreen)
|
||||
return;
|
||||
SDL_SetWindowFullscreen(sdl_window, on ? SDL_WINDOW_FULLSCREEN_DESKTOP: 0);
|
||||
sdl_fs_on = on;
|
||||
SDL_SetWindowFullscreen(gfx_window, on ? SDL_WINDOW_FULLSCREEN_DESKTOP: 0);
|
||||
gfx_fullscreen = on;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool sdl_isFullscreen(void) {
|
||||
return sdl_fs_on;
|
||||
bool gfx_isFullscreen(void) {
|
||||
return gfx_fullscreen;
|
||||
}
|
||||
|
||||
void sdl_raiseWindow(void) {
|
||||
SDL_RaiseWindow(sdl_window);
|
||||
void gfx_raiseWindow(void) {
|
||||
SDL_RaiseWindow(gfx_window);
|
||||
}
|
||||
|
||||
void sdl_setWindowSize(int w, int h) {
|
||||
void gfx_setWindowSize(int w, int h) {
|
||||
if (w == view_w && h == view_h) return;
|
||||
|
||||
view_w = w;
|
||||
view_h = h;
|
||||
|
||||
#ifndef __ANDROID__
|
||||
SDL_SetWindowSize(sdl_window, w, h);
|
||||
SDL_SetWindowSize(gfx_window, w, h);
|
||||
#endif
|
||||
SDL_RenderSetLogicalSize(sdl_renderer, w, h);
|
||||
if (sdl_texture)
|
||||
SDL_DestroyTexture(sdl_texture);
|
||||
sdl_texture = SDL_CreateTexture(
|
||||
sdl_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING, w, h);
|
||||
SDL_RenderSetLogicalSize(gfx_renderer, w, h);
|
||||
if (gfx_texture)
|
||||
SDL_DestroyTexture(gfx_texture);
|
||||
gfx_texture = SDL_CreateTexture(
|
||||
gfx_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING, w, h);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
EM_ASM( xsystem35.shell.windowSizeChanged(); );
|
||||
#endif
|
||||
}
|
||||
|
||||
void sdl_showMessageBox(enum messagebox_type type, const char* title_utf8, const char* message_utf8) {
|
||||
uint32_t flags = 0;
|
||||
switch (type) {
|
||||
case MESSAGEBOX_ERROR: flags = SDL_MESSAGEBOX_ERROR; break;
|
||||
case MESSAGEBOX_WARNING: flags = SDL_MESSAGEBOX_WARNING; break;
|
||||
case MESSAGEBOX_INFO: flags = SDL_MESSAGEBOX_INFORMATION; break;
|
||||
}
|
||||
SDL_ShowSimpleMessageBox(flags, title_utf8, message_utf8, sdl_window);
|
||||
}
|
||||
|
||||
void sdl_setJoyDeviceIndex(int index) {
|
||||
joy_device_index = index;
|
||||
}
|
||||
|
||||
void sdl_setIntegerScaling(bool enable) {
|
||||
SDL_RenderSetIntegerScale(sdl_renderer, enable);
|
||||
void gfx_setIntegerScaling(bool enable) {
|
||||
SDL_RenderSetIntegerScale(gfx_renderer, enable);
|
||||
}
|
||||
|
||||
bool EMSCRIPTEN_KEEPALIVE save_screenshot(const char* path) {
|
||||
SDL_Rect *r = &nact->ags.view_area;
|
||||
SDL_Surface *view = sdl_createSurfaceView(main_surface, r->x, r->y, r->w, r->h);
|
||||
SDL_Surface *view = gfx_createSurfaceView(main_surface, r->x, r->y, r->w, r->h);
|
||||
bool ok = SDL_SaveBMP(view, path) == 0;
|
||||
SDL_FreeSurface(view);
|
||||
return ok;
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* graphics.h graphics related definition
|
||||
*
|
||||
* Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
|
||||
* 1998- <masaki-c@is.aist-nara.ac.jp>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: graphics.h,v 1.24 2000/11/25 13:09:04 chikama Exp $ */
|
||||
|
||||
#ifndef __GRAPHICS__
|
||||
#define __GRAPHICS__
|
||||
|
||||
#include "portab.h"
|
||||
#include <SDL_rect.h>
|
||||
#include <SDL_pixels.h>
|
||||
|
||||
typedef struct {
|
||||
uint8_t r,g,b;
|
||||
uint32_t pixel;
|
||||
} Palette;
|
||||
|
||||
typedef SDL_Point MyPoint;
|
||||
|
||||
typedef struct {
|
||||
int width;
|
||||
int height;
|
||||
} MyDimension;
|
||||
|
||||
typedef SDL_Rect MyRectangle;
|
||||
|
||||
typedef struct {
|
||||
int width;
|
||||
int height;
|
||||
int depth;
|
||||
} DispInfo;
|
||||
|
||||
typedef enum {
|
||||
FONT_GOTHIC,
|
||||
FONT_MINCHO,
|
||||
} FontType;
|
||||
#define FONTTYPEMAX 2
|
||||
|
||||
#endif /* !__GRAPHICS__ */
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "cg.h"
|
||||
#include "config.h"
|
||||
#include "nact.h"
|
||||
#include "sdl_core.h"
|
||||
#include "alpha_plane.h"
|
||||
#include "ags.h"
|
||||
|
||||
|
||||
+14
-14
@@ -25,7 +25,7 @@
|
||||
#include <limits.h>
|
||||
#include "config.h"
|
||||
#include "input.h"
|
||||
#include "sdl_core.h"
|
||||
#include "event.h"
|
||||
#include "scheduler.h"
|
||||
#include "xsystem35.h"
|
||||
#include "message.h"
|
||||
@@ -51,9 +51,9 @@ void set_hak_keymode(int key, int mode) {
|
||||
}
|
||||
}
|
||||
|
||||
int sys_getMouseInfo(MyPoint *p, bool is_dibgeo) {
|
||||
MyPoint _p;
|
||||
int key = sdl_getMouseInfo(&_p);
|
||||
int sys_getMouseInfo(SDL_Point *p, bool is_dibgeo) {
|
||||
SDL_Point _p;
|
||||
int key = event_get_mouse(&_p);
|
||||
|
||||
if (p) {
|
||||
p->x = _p.x;
|
||||
@@ -67,23 +67,23 @@ int sys_getMouseInfo(MyPoint *p, bool is_dibgeo) {
|
||||
}
|
||||
|
||||
void sys_getWheelInfo(int *forward, int *back) {
|
||||
sdl_getWheelInfo(forward, back);
|
||||
event_get_wheel(forward, back);
|
||||
}
|
||||
|
||||
void sys_clearWheelInfo(void) {
|
||||
sdl_clearWheelInfo();
|
||||
event_clear_wheel();
|
||||
}
|
||||
|
||||
int sys_getKeyInfo() {
|
||||
return sdl_getKeyInfo();
|
||||
return event_get_key();
|
||||
}
|
||||
|
||||
int sys_getJoyInfo() {
|
||||
return sdl_getJoyInfo();
|
||||
return event_get_joy();
|
||||
}
|
||||
|
||||
int sys_getInputInfo() {
|
||||
return sdl_getMouseInfo(NULL) | sdl_getKeyInfo() | sdl_getJoyInfo();
|
||||
return event_get_mouse(NULL) | event_get_key() | event_get_joy();
|
||||
}
|
||||
|
||||
int sys_keywait(int msec, unsigned flags) {
|
||||
@@ -100,14 +100,14 @@ int sys_keywait(int msec, unsigned flags) {
|
||||
}
|
||||
|
||||
int key=0, n;
|
||||
int end = msec == INT_MAX ? INT_MAX : sdl_getTicks() + msec;
|
||||
int end = msec == INT_MAX ? INT_MAX : sys_get_ticks() + msec;
|
||||
while (!nact->is_quit &&
|
||||
!((flags & KEYWAIT_SKIPPABLE) && msgskip_isSkipping()) &&
|
||||
(n = end - sdl_getTicks()) > 0) {
|
||||
(n = end - sys_get_ticks()) > 0) {
|
||||
if (n <= 16)
|
||||
sdl_sleep(n);
|
||||
sys_sleep(n);
|
||||
else
|
||||
sdl_wait_vsync();
|
||||
sys_wait_vsync();
|
||||
nact->callback();
|
||||
key = sys_getInputInfo();
|
||||
cancel_yield(); // We just yielded!
|
||||
@@ -122,7 +122,7 @@ void sys_hit_any_key() {
|
||||
if (msgskip_isSkipping()) {
|
||||
if (msgskip_getFlags() & MSGSKIP_STOP_ON_CLICK && sys_getInputInfo())
|
||||
msgskip_activate(false);
|
||||
sdl_sleep(30);
|
||||
sys_sleep(30);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -25,7 +25,8 @@
|
||||
#define __INPUT__
|
||||
|
||||
#include "portab.h"
|
||||
#include "graphics.h"
|
||||
|
||||
struct SDL_Point;
|
||||
|
||||
#define SYS35KEY_NULL 0
|
||||
#define SYS35KEY_UP 1
|
||||
@@ -159,7 +160,7 @@ enum keycode {
|
||||
extern bool RawKeyInfo[NUM_KEYCODES];
|
||||
|
||||
extern int sys_keywait(int msec, unsigned flags);
|
||||
extern int sys_getMouseInfo(MyPoint *p, bool is_dibgeo);
|
||||
extern int sys_getMouseInfo(struct SDL_Point *p, bool is_dibgeo);
|
||||
extern int sys_getInputInfo(void);
|
||||
extern int sys_getKeyInfo(void);
|
||||
extern int sys_getJoyInfo(void);
|
||||
|
||||
+18
-17
@@ -18,38 +18,39 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <SDL_cpuinfo.h>
|
||||
|
||||
#if defined(__ARM_NEON)
|
||||
#define STBI_NEON
|
||||
#endif
|
||||
#define STBI_NO_STDIO
|
||||
#define STBI_ONLY_JPEG
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "system.h"
|
||||
#include "jpeg.h"
|
||||
|
||||
// Disable the bicubic chroma filter to avoid color bleeding in Graymerca.
|
||||
#define NJ_CHROMA_FILTER 0
|
||||
#include "nanojpeg.c"
|
||||
|
||||
bool jpeg_checkfmt(uint8_t *data) {
|
||||
return data[0] == 0xff && data[1] == 0xd8;
|
||||
}
|
||||
|
||||
cgdata *jpeg_extract(uint8_t *data, size_t size) {
|
||||
int width, height, channels;
|
||||
uint8_t *pixels = stbi_load_from_memory(data, size, &width, &height, &channels, 3);
|
||||
if (!pixels) {
|
||||
WARNING("cannot decode jpeg: %s", stbi_failure_reason());
|
||||
njInit();
|
||||
nj_result_t err = njDecode(data, size);
|
||||
if (err != NJ_OK) {
|
||||
WARNING("cannot decode jpeg: %d", err);
|
||||
return NULL;
|
||||
}
|
||||
if (!njIsColor()) {
|
||||
WARNING("grayscale jpeg is not supported:");
|
||||
njDone();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cgdata *cg = calloc(1, sizeof(cgdata));
|
||||
cg->type = ALCG_JPEG;
|
||||
cg->width = width;
|
||||
cg->height = height;
|
||||
cg->width = njGetWidth();
|
||||
cg->height = njGetHeight();
|
||||
cg->depth = 24;
|
||||
cg->pic = pixels;
|
||||
cg->pic = nj.rgb; // steal the buffer from nj_context_t
|
||||
nj.rgb = NULL;
|
||||
njDone();
|
||||
return cg;
|
||||
}
|
||||
|
||||
+5
-5
@@ -27,8 +27,8 @@
|
||||
#include "system.h"
|
||||
#include "nact.h"
|
||||
#include "menu.h"
|
||||
#include "sdl_core.h"
|
||||
#include "sdl_private.h"
|
||||
#include "editor.h"
|
||||
#include "gfx_private.h"
|
||||
#ifdef _WIN32
|
||||
#include "win/dialog.h"
|
||||
#endif
|
||||
@@ -44,7 +44,7 @@ void menu_quitmenu_open(void) {
|
||||
};
|
||||
const SDL_MessageBoxData messagebox_data = {
|
||||
.flags = SDL_MESSAGEBOX_INFORMATION,
|
||||
.window = sdl_window,
|
||||
.window = gfx_window,
|
||||
.title = "Confirm",
|
||||
.message = "Quit xsystem35?",
|
||||
.numbuttons = SDL_arraysize(buttons),
|
||||
@@ -67,7 +67,7 @@ void menu_resetmenu_open(void) {
|
||||
};
|
||||
const SDL_MessageBoxData messagebox_data = {
|
||||
.flags = SDL_MESSAGEBOX_INFORMATION,
|
||||
.window = sdl_window,
|
||||
.window = gfx_window,
|
||||
.title = "Confirm",
|
||||
.message = "Restart the game?",
|
||||
.numbuttons = SDL_arraysize(buttons),
|
||||
@@ -93,7 +93,7 @@ bool menu_inputstring(INPUTSTRING_PARAM *p) {
|
||||
}
|
||||
|
||||
bool menu_inputstring2(INPUTSTRING_PARAM *p) {
|
||||
return sdl_inputString(p);
|
||||
return edit_string(p);
|
||||
}
|
||||
|
||||
bool menu_inputnumber(INPUTNUM_PARAM *p) {
|
||||
|
||||
+5
-6
@@ -29,7 +29,6 @@
|
||||
|
||||
#include "portab.h"
|
||||
#include "windowframe.h"
|
||||
#include "sdl_core.h"
|
||||
#include "xsystem35.h"
|
||||
#include "message.h"
|
||||
#include "variable.h"
|
||||
@@ -49,7 +48,7 @@
|
||||
static int frameType;
|
||||
static int frameDot;
|
||||
/* 現在の文字表示位置 */
|
||||
static MyPoint msgcur;
|
||||
static SDL_Point msgcur;
|
||||
static bool nextLineIsAfterKaigyou = false;
|
||||
|
||||
/* Private Methods */
|
||||
@@ -126,7 +125,7 @@ void msg_putMessage(const char *m) {
|
||||
|
||||
ags_setFontWithWeight(nact->ags.font_type, msg.MsgFontSize, nact->ags.font_weight);
|
||||
|
||||
MyRectangle drawn;
|
||||
SDL_Rect drawn;
|
||||
msgcur.x += ags_drawString(msgcur.x, msgcur.y, m, msg.MsgFontColor, &drawn);
|
||||
|
||||
if (nact->messagewait_enable && nact->messagewait_time > 0 &&
|
||||
@@ -140,7 +139,7 @@ void msg_putMessage(const char *m) {
|
||||
ags_updateArea(drawn.x, drawn.y, drawn.w, drawn.h);
|
||||
break;
|
||||
}
|
||||
sdl_sleep(nact->messagewait_time * 10);
|
||||
sys_sleep(nact->messagewait_time * 10);
|
||||
nact->callback();
|
||||
}
|
||||
} else {
|
||||
@@ -265,7 +264,7 @@ void msg_setMessageLocation(int x, int y) {
|
||||
nextLineIsAfterKaigyou = false;
|
||||
}
|
||||
|
||||
void msg_getMessageLocation(MyPoint *loc) {
|
||||
void msg_getMessageLocation(SDL_Point *loc) {
|
||||
loc->x = msgcur.x;
|
||||
loc->y = msgcur.y;
|
||||
}
|
||||
@@ -276,7 +275,7 @@ void msg_hitAnyKey() {
|
||||
[UTF8] = "▼",
|
||||
};
|
||||
|
||||
MyRectangle r;
|
||||
SDL_Rect r;
|
||||
int x = msg.win->x + msg.win->width - msg.MsgFontSize;
|
||||
int y = msg.win->y + msg.win->height - msg.MsgFontSize;
|
||||
ags_drawString(x, y, prompt[nact->encoding], msg.HitAnyKeyMsgColor, &r);
|
||||
|
||||
+3
-2
@@ -26,7 +26,8 @@
|
||||
|
||||
#include "portab.h"
|
||||
#include "windowframe.h"
|
||||
#include "graphics.h"
|
||||
|
||||
struct SDL_Point;
|
||||
|
||||
extern void msg_init();
|
||||
extern void msg_setFontSize(int size);
|
||||
@@ -36,7 +37,7 @@ extern void msg_nextPage(bool clear);
|
||||
extern void msg_hitAnyKey();
|
||||
extern void msg_openWindow(int W, int C1, int C2, int N, int M);
|
||||
extern void msg_setMessageLocation(int x, int y);
|
||||
extern void msg_getMessageLocation(MyPoint *loc);
|
||||
extern void msg_getMessageLocation(struct SDL_Point *loc);
|
||||
extern void msg_mg6_command(int cmd);
|
||||
|
||||
struct __message {
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@
|
||||
#include "portab.h"
|
||||
#include "scenario.h"
|
||||
#include "xsystem35.h"
|
||||
#include "sdl_core.h"
|
||||
#include "gfx.h"
|
||||
#include "scheduler.h"
|
||||
#include "ags.h"
|
||||
#include "nact.h"
|
||||
@@ -112,7 +112,7 @@ void nact_main() {
|
||||
nact->current_page = sl_getPage();
|
||||
nact->current_addr = sl_getIndex();
|
||||
if (dbg_trapped()) {
|
||||
sdl_updateScreen();
|
||||
gfx_updateScreen();
|
||||
dbg_main(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#define __NACT_H__
|
||||
|
||||
#include "portab.h"
|
||||
#include "graphics.h"
|
||||
#include "s39ain.h"
|
||||
#include "gameresource.h"
|
||||
#include "selection.h"
|
||||
|
||||
+916
@@ -0,0 +1,916 @@
|
||||
// NanoJPEG -- KeyJ's Tiny Baseline JPEG Decoder
|
||||
// version 1.3.5 (2016-11-14)
|
||||
// Copyright (c) 2009-2016 Martin J. Fiedler <martin.fiedler@gmx.net>
|
||||
// published under the terms of the MIT license
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// DOCUMENTATION SECTION //
|
||||
// read this if you want to know what this is all about //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// INTRODUCTION
|
||||
// ============
|
||||
//
|
||||
// This is a minimal decoder for baseline JPEG images. It accepts memory dumps
|
||||
// of JPEG files as input and generates either 8-bit grayscale or packed 24-bit
|
||||
// RGB images as output. It does not parse JFIF or Exif headers; all JPEG files
|
||||
// are assumed to be either grayscale or YCbCr. CMYK or other color spaces are
|
||||
// not supported. All YCbCr subsampling schemes with power-of-two ratios are
|
||||
// supported, as are restart intervals. Progressive or lossless JPEG is not
|
||||
// supported.
|
||||
// Summed up, NanoJPEG should be able to decode all images from digital cameras
|
||||
// and most common forms of other non-progressive JPEG images.
|
||||
// The decoder is not optimized for speed, it's optimized for simplicity and
|
||||
// small code. Image quality should be at a reasonable level. A bicubic chroma
|
||||
// upsampling filter ensures that subsampled YCbCr images are rendered in
|
||||
// decent quality. The decoder is not meant to deal with broken JPEG files in
|
||||
// a graceful manner; if anything is wrong with the bitstream, decoding will
|
||||
// simply fail.
|
||||
// The code should work with every modern C compiler without problems and
|
||||
// should not emit any warnings. It uses only (at least) 32-bit integer
|
||||
// arithmetic and is supposed to be endianness independent and 64-bit clean.
|
||||
// However, it is not thread-safe.
|
||||
|
||||
|
||||
// COMPILE-TIME CONFIGURATION
|
||||
// ==========================
|
||||
//
|
||||
// The following aspects of NanoJPEG can be controlled with preprocessor
|
||||
// defines:
|
||||
//
|
||||
// _NJ_EXAMPLE_PROGRAM = Compile a main() function with an example
|
||||
// program.
|
||||
// _NJ_INCLUDE_HEADER_ONLY = Don't compile anything, just act as a header
|
||||
// file for NanoJPEG. Example:
|
||||
// #define _NJ_INCLUDE_HEADER_ONLY
|
||||
// #include "nanojpeg.c"
|
||||
// int main(void) {
|
||||
// njInit();
|
||||
// // your code here
|
||||
// njDone();
|
||||
// }
|
||||
// NJ_USE_LIBC=1 = Use the malloc(), free(), memset() and memcpy()
|
||||
// functions from the standard C library (default).
|
||||
// NJ_USE_LIBC=0 = Don't use the standard C library. In this mode,
|
||||
// external functions njAlloc(), njFreeMem(),
|
||||
// njFillMem() and njCopyMem() need to be defined
|
||||
// and implemented somewhere.
|
||||
// NJ_USE_WIN32=0 = Normal mode (default).
|
||||
// NJ_USE_WIN32=1 = If compiling with MSVC for Win32 and
|
||||
// NJ_USE_LIBC=0, NanoJPEG will use its own
|
||||
// implementations of the required C library
|
||||
// functions (default if compiling with MSVC and
|
||||
// NJ_USE_LIBC=0).
|
||||
// NJ_CHROMA_FILTER=1 = Use the bicubic chroma upsampling filter
|
||||
// (default).
|
||||
// NJ_CHROMA_FILTER=0 = Use simple pixel repetition for chroma upsampling
|
||||
// (bad quality, but faster and less code).
|
||||
|
||||
|
||||
// API
|
||||
// ===
|
||||
//
|
||||
// For API documentation, read the "header section" below.
|
||||
|
||||
|
||||
// EXAMPLE
|
||||
// =======
|
||||
//
|
||||
// A few pages below, you can find an example program that uses NanoJPEG to
|
||||
// convert JPEG files into PGM or PPM. To compile it, use something like
|
||||
// gcc -O3 -D_NJ_EXAMPLE_PROGRAM -o nanojpeg nanojpeg.c
|
||||
// You may also add -std=c99 -Wall -Wextra -pedantic -Werror, if you want :)
|
||||
// The only thing you might need is -Wno-shift-negative-value, because this
|
||||
// code relies on the target machine using two's complement arithmetic, but
|
||||
// the C standard does not, even though *any* practically useful machine
|
||||
// nowadays uses two's complement.
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// HEADER SECTION //
|
||||
// copy and pase this into nanojpeg.h if you want //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _NANOJPEG_H
|
||||
#define _NANOJPEG_H
|
||||
|
||||
// nj_result_t: Result codes for njDecode().
|
||||
typedef enum _nj_result {
|
||||
NJ_OK = 0, // no error, decoding successful
|
||||
NJ_NO_JPEG, // not a JPEG file
|
||||
NJ_UNSUPPORTED, // unsupported format
|
||||
NJ_OUT_OF_MEM, // out of memory
|
||||
NJ_INTERNAL_ERR, // internal error
|
||||
NJ_SYNTAX_ERROR, // syntax error
|
||||
__NJ_FINISHED, // used internally, will never be reported
|
||||
} nj_result_t;
|
||||
|
||||
// njInit: Initialize NanoJPEG.
|
||||
// For safety reasons, this should be called at least one time before using
|
||||
// using any of the other NanoJPEG functions.
|
||||
void njInit(void);
|
||||
|
||||
// njDecode: Decode a JPEG image.
|
||||
// Decodes a memory dump of a JPEG file into internal buffers.
|
||||
// Parameters:
|
||||
// jpeg = The pointer to the memory dump.
|
||||
// size = The size of the JPEG file.
|
||||
// Return value: The error code in case of failure, or NJ_OK (zero) on success.
|
||||
nj_result_t njDecode(const void* jpeg, const int size);
|
||||
|
||||
// njGetWidth: Return the width (in pixels) of the most recently decoded
|
||||
// image. If njDecode() failed, the result of njGetWidth() is undefined.
|
||||
int njGetWidth(void);
|
||||
|
||||
// njGetHeight: Return the height (in pixels) of the most recently decoded
|
||||
// image. If njDecode() failed, the result of njGetHeight() is undefined.
|
||||
int njGetHeight(void);
|
||||
|
||||
// njIsColor: Return 1 if the most recently decoded image is a color image
|
||||
// (RGB) or 0 if it is a grayscale image. If njDecode() failed, the result
|
||||
// of njGetWidth() is undefined.
|
||||
int njIsColor(void);
|
||||
|
||||
// njGetImage: Returns the decoded image data.
|
||||
// Returns a pointer to the most recently image. The memory layout it byte-
|
||||
// oriented, top-down, without any padding between lines. Pixels of color
|
||||
// images will be stored as three consecutive bytes for the red, green and
|
||||
// blue channels. This data format is thus compatible with the PGM or PPM
|
||||
// file formats and the OpenGL texture formats GL_LUMINANCE8 or GL_RGB8.
|
||||
// If njDecode() failed, the result of njGetImage() is undefined.
|
||||
unsigned char* njGetImage(void);
|
||||
|
||||
// njGetImageSize: Returns the size (in bytes) of the image data returned
|
||||
// by njGetImage(). If njDecode() failed, the result of njGetImageSize() is
|
||||
// undefined.
|
||||
int njGetImageSize(void);
|
||||
|
||||
// njDone: Uninitialize NanoJPEG.
|
||||
// Resets NanoJPEG's internal state and frees all memory that has been
|
||||
// allocated at run-time by NanoJPEG. It is still possible to decode another
|
||||
// image after a njDone() call.
|
||||
void njDone(void);
|
||||
|
||||
#endif//_NANOJPEG_H
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// CONFIGURATION SECTION //
|
||||
// adjust the default settings for the NJ_ defines here //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef NJ_USE_LIBC
|
||||
#define NJ_USE_LIBC 1
|
||||
#endif
|
||||
|
||||
#ifndef NJ_USE_WIN32
|
||||
#ifdef _MSC_VER
|
||||
#define NJ_USE_WIN32 (!NJ_USE_LIBC)
|
||||
#else
|
||||
#define NJ_USE_WIN32 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef NJ_CHROMA_FILTER
|
||||
#define NJ_CHROMA_FILTER 1
|
||||
#endif
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// EXAMPLE PROGRAM //
|
||||
// just define _NJ_EXAMPLE_PROGRAM to compile this (requires NJ_USE_LIBC) //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef _NJ_EXAMPLE_PROGRAM
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int size;
|
||||
char *buf;
|
||||
FILE *f;
|
||||
|
||||
if (argc < 2) {
|
||||
printf("Usage: %s <input.jpg> [<output.ppm>]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
f = fopen(argv[1], "rb");
|
||||
if (!f) {
|
||||
printf("Error opening the input file.\n");
|
||||
return 1;
|
||||
}
|
||||
fseek(f, 0, SEEK_END);
|
||||
size = (int) ftell(f);
|
||||
buf = (char*) malloc(size);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
size = (int) fread(buf, 1, size, f);
|
||||
fclose(f);
|
||||
|
||||
njInit();
|
||||
if (njDecode(buf, size)) {
|
||||
free((void*)buf);
|
||||
printf("Error decoding the input file.\n");
|
||||
return 1;
|
||||
}
|
||||
free((void*)buf);
|
||||
|
||||
f = fopen((argc > 2) ? argv[2] : (njIsColor() ? "nanojpeg_out.ppm" : "nanojpeg_out.pgm"), "wb");
|
||||
if (!f) {
|
||||
printf("Error opening the output file.\n");
|
||||
return 1;
|
||||
}
|
||||
fprintf(f, "P%d\n%d %d\n255\n", njIsColor() ? 6 : 5, njGetWidth(), njGetHeight());
|
||||
fwrite(njGetImage(), 1, njGetImageSize(), f);
|
||||
fclose(f);
|
||||
njDone();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// IMPLEMENTATION SECTION //
|
||||
// you may stop reading here //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _NJ_INCLUDE_HEADER_ONLY
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define NJ_INLINE static __inline
|
||||
#define NJ_FORCE_INLINE static __forceinline
|
||||
#else
|
||||
#define NJ_INLINE static inline
|
||||
#define NJ_FORCE_INLINE static inline
|
||||
#endif
|
||||
|
||||
#if NJ_USE_LIBC
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#define njAllocMem malloc
|
||||
#define njFreeMem free
|
||||
#define njFillMem memset
|
||||
#define njCopyMem memcpy
|
||||
#elif NJ_USE_WIN32
|
||||
#include <windows.h>
|
||||
#define njAllocMem(size) ((void*) LocalAlloc(LMEM_FIXED, (SIZE_T)(size)))
|
||||
#define njFreeMem(block) ((void) LocalFree((HLOCAL) block))
|
||||
NJ_INLINE void njFillMem(void* block, unsigned char value, int count) { __asm {
|
||||
mov edi, block
|
||||
mov al, value
|
||||
mov ecx, count
|
||||
rep stosb
|
||||
} }
|
||||
NJ_INLINE void njCopyMem(void* dest, const void* src, int count) { __asm {
|
||||
mov edi, dest
|
||||
mov esi, src
|
||||
mov ecx, count
|
||||
rep movsb
|
||||
} }
|
||||
#else
|
||||
extern void* njAllocMem(int size);
|
||||
extern void njFreeMem(void* block);
|
||||
extern void njFillMem(void* block, unsigned char byte, int size);
|
||||
extern void njCopyMem(void* dest, const void* src, int size);
|
||||
#endif
|
||||
|
||||
typedef struct _nj_code {
|
||||
unsigned char bits, code;
|
||||
} nj_vlc_code_t;
|
||||
|
||||
typedef struct _nj_cmp {
|
||||
int cid;
|
||||
int ssx, ssy;
|
||||
int width, height;
|
||||
int stride;
|
||||
int qtsel;
|
||||
int actabsel, dctabsel;
|
||||
int dcpred;
|
||||
unsigned char *pixels;
|
||||
} nj_component_t;
|
||||
|
||||
typedef struct _nj_ctx {
|
||||
nj_result_t error;
|
||||
const unsigned char *pos;
|
||||
int size;
|
||||
int length;
|
||||
int width, height;
|
||||
int mbwidth, mbheight;
|
||||
int mbsizex, mbsizey;
|
||||
int ncomp;
|
||||
nj_component_t comp[3];
|
||||
int qtused, qtavail;
|
||||
unsigned char qtab[4][64];
|
||||
nj_vlc_code_t vlctab[4][65536];
|
||||
int buf, bufbits;
|
||||
int block[64];
|
||||
int rstinterval;
|
||||
unsigned char *rgb;
|
||||
} nj_context_t;
|
||||
|
||||
static nj_context_t nj;
|
||||
|
||||
static const char njZZ[64] = { 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18,
|
||||
11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35,
|
||||
42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45,
|
||||
38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63 };
|
||||
|
||||
NJ_FORCE_INLINE unsigned char njClip(const int x) {
|
||||
return (x < 0) ? 0 : ((x > 0xFF) ? 0xFF : (unsigned char) x);
|
||||
}
|
||||
|
||||
#define W1 2841
|
||||
#define W2 2676
|
||||
#define W3 2408
|
||||
#define W5 1609
|
||||
#define W6 1108
|
||||
#define W7 565
|
||||
|
||||
NJ_INLINE void njRowIDCT(int* blk) {
|
||||
int x0, x1, x2, x3, x4, x5, x6, x7, x8;
|
||||
if (!((x1 = blk[4] << 11)
|
||||
| (x2 = blk[6])
|
||||
| (x3 = blk[2])
|
||||
| (x4 = blk[1])
|
||||
| (x5 = blk[7])
|
||||
| (x6 = blk[5])
|
||||
| (x7 = blk[3])))
|
||||
{
|
||||
blk[0] = blk[1] = blk[2] = blk[3] = blk[4] = blk[5] = blk[6] = blk[7] = blk[0] << 3;
|
||||
return;
|
||||
}
|
||||
x0 = (blk[0] << 11) + 128;
|
||||
x8 = W7 * (x4 + x5);
|
||||
x4 = x8 + (W1 - W7) * x4;
|
||||
x5 = x8 - (W1 + W7) * x5;
|
||||
x8 = W3 * (x6 + x7);
|
||||
x6 = x8 - (W3 - W5) * x6;
|
||||
x7 = x8 - (W3 + W5) * x7;
|
||||
x8 = x0 + x1;
|
||||
x0 -= x1;
|
||||
x1 = W6 * (x3 + x2);
|
||||
x2 = x1 - (W2 + W6) * x2;
|
||||
x3 = x1 + (W2 - W6) * x3;
|
||||
x1 = x4 + x6;
|
||||
x4 -= x6;
|
||||
x6 = x5 + x7;
|
||||
x5 -= x7;
|
||||
x7 = x8 + x3;
|
||||
x8 -= x3;
|
||||
x3 = x0 + x2;
|
||||
x0 -= x2;
|
||||
x2 = (181 * (x4 + x5) + 128) >> 8;
|
||||
x4 = (181 * (x4 - x5) + 128) >> 8;
|
||||
blk[0] = (x7 + x1) >> 8;
|
||||
blk[1] = (x3 + x2) >> 8;
|
||||
blk[2] = (x0 + x4) >> 8;
|
||||
blk[3] = (x8 + x6) >> 8;
|
||||
blk[4] = (x8 - x6) >> 8;
|
||||
blk[5] = (x0 - x4) >> 8;
|
||||
blk[6] = (x3 - x2) >> 8;
|
||||
blk[7] = (x7 - x1) >> 8;
|
||||
}
|
||||
|
||||
NJ_INLINE void njColIDCT(const int* blk, unsigned char *out, int stride) {
|
||||
int x0, x1, x2, x3, x4, x5, x6, x7, x8;
|
||||
if (!((x1 = blk[8*4] << 8)
|
||||
| (x2 = blk[8*6])
|
||||
| (x3 = blk[8*2])
|
||||
| (x4 = blk[8*1])
|
||||
| (x5 = blk[8*7])
|
||||
| (x6 = blk[8*5])
|
||||
| (x7 = blk[8*3])))
|
||||
{
|
||||
x1 = njClip(((blk[0] + 32) >> 6) + 128);
|
||||
for (x0 = 8; x0; --x0) {
|
||||
*out = (unsigned char) x1;
|
||||
out += stride;
|
||||
}
|
||||
return;
|
||||
}
|
||||
x0 = (blk[0] << 8) + 8192;
|
||||
x8 = W7 * (x4 + x5) + 4;
|
||||
x4 = (x8 + (W1 - W7) * x4) >> 3;
|
||||
x5 = (x8 - (W1 + W7) * x5) >> 3;
|
||||
x8 = W3 * (x6 + x7) + 4;
|
||||
x6 = (x8 - (W3 - W5) * x6) >> 3;
|
||||
x7 = (x8 - (W3 + W5) * x7) >> 3;
|
||||
x8 = x0 + x1;
|
||||
x0 -= x1;
|
||||
x1 = W6 * (x3 + x2) + 4;
|
||||
x2 = (x1 - (W2 + W6) * x2) >> 3;
|
||||
x3 = (x1 + (W2 - W6) * x3) >> 3;
|
||||
x1 = x4 + x6;
|
||||
x4 -= x6;
|
||||
x6 = x5 + x7;
|
||||
x5 -= x7;
|
||||
x7 = x8 + x3;
|
||||
x8 -= x3;
|
||||
x3 = x0 + x2;
|
||||
x0 -= x2;
|
||||
x2 = (181 * (x4 + x5) + 128) >> 8;
|
||||
x4 = (181 * (x4 - x5) + 128) >> 8;
|
||||
*out = njClip(((x7 + x1) >> 14) + 128); out += stride;
|
||||
*out = njClip(((x3 + x2) >> 14) + 128); out += stride;
|
||||
*out = njClip(((x0 + x4) >> 14) + 128); out += stride;
|
||||
*out = njClip(((x8 + x6) >> 14) + 128); out += stride;
|
||||
*out = njClip(((x8 - x6) >> 14) + 128); out += stride;
|
||||
*out = njClip(((x0 - x4) >> 14) + 128); out += stride;
|
||||
*out = njClip(((x3 - x2) >> 14) + 128); out += stride;
|
||||
*out = njClip(((x7 - x1) >> 14) + 128);
|
||||
}
|
||||
|
||||
#define njThrow(e) do { nj.error = e; return; } while (0)
|
||||
#define njCheckError() do { if (nj.error) return; } while (0)
|
||||
|
||||
static int njShowBits(int bits) {
|
||||
unsigned char newbyte;
|
||||
if (!bits) return 0;
|
||||
while (nj.bufbits < bits) {
|
||||
if (nj.size <= 0) {
|
||||
nj.buf = (nj.buf << 8) | 0xFF;
|
||||
nj.bufbits += 8;
|
||||
continue;
|
||||
}
|
||||
newbyte = *nj.pos++;
|
||||
nj.size--;
|
||||
nj.bufbits += 8;
|
||||
nj.buf = (nj.buf << 8) | newbyte;
|
||||
if (newbyte == 0xFF) {
|
||||
if (nj.size) {
|
||||
unsigned char marker = *nj.pos++;
|
||||
nj.size--;
|
||||
switch (marker) {
|
||||
case 0x00:
|
||||
case 0xFF:
|
||||
break;
|
||||
case 0xD9: nj.size = 0; break;
|
||||
default:
|
||||
if ((marker & 0xF8) != 0xD0)
|
||||
nj.error = NJ_SYNTAX_ERROR;
|
||||
else {
|
||||
nj.buf = (nj.buf << 8) | marker;
|
||||
nj.bufbits += 8;
|
||||
}
|
||||
}
|
||||
} else
|
||||
nj.error = NJ_SYNTAX_ERROR;
|
||||
}
|
||||
}
|
||||
return (nj.buf >> (nj.bufbits - bits)) & ((1 << bits) - 1);
|
||||
}
|
||||
|
||||
NJ_INLINE void njSkipBits(int bits) {
|
||||
if (nj.bufbits < bits)
|
||||
(void) njShowBits(bits);
|
||||
nj.bufbits -= bits;
|
||||
}
|
||||
|
||||
NJ_INLINE int njGetBits(int bits) {
|
||||
int res = njShowBits(bits);
|
||||
njSkipBits(bits);
|
||||
return res;
|
||||
}
|
||||
|
||||
NJ_INLINE void njByteAlign(void) {
|
||||
nj.bufbits &= 0xF8;
|
||||
}
|
||||
|
||||
static void njSkip(int count) {
|
||||
nj.pos += count;
|
||||
nj.size -= count;
|
||||
nj.length -= count;
|
||||
if (nj.size < 0) nj.error = NJ_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
NJ_INLINE unsigned short njDecode16(const unsigned char *pos) {
|
||||
return (pos[0] << 8) | pos[1];
|
||||
}
|
||||
|
||||
static void njDecodeLength(void) {
|
||||
if (nj.size < 2) njThrow(NJ_SYNTAX_ERROR);
|
||||
nj.length = njDecode16(nj.pos);
|
||||
if (nj.length > nj.size) njThrow(NJ_SYNTAX_ERROR);
|
||||
njSkip(2);
|
||||
}
|
||||
|
||||
NJ_INLINE void njSkipMarker(void) {
|
||||
njDecodeLength();
|
||||
njSkip(nj.length);
|
||||
}
|
||||
|
||||
NJ_INLINE void njDecodeSOF(void) {
|
||||
int i, ssxmax = 0, ssymax = 0;
|
||||
nj_component_t* c;
|
||||
njDecodeLength();
|
||||
njCheckError();
|
||||
if (nj.length < 9) njThrow(NJ_SYNTAX_ERROR);
|
||||
if (nj.pos[0] != 8) njThrow(NJ_UNSUPPORTED);
|
||||
nj.height = njDecode16(nj.pos+1);
|
||||
nj.width = njDecode16(nj.pos+3);
|
||||
if (!nj.width || !nj.height) njThrow(NJ_SYNTAX_ERROR);
|
||||
nj.ncomp = nj.pos[5];
|
||||
njSkip(6);
|
||||
switch (nj.ncomp) {
|
||||
case 1:
|
||||
case 3:
|
||||
break;
|
||||
default:
|
||||
njThrow(NJ_UNSUPPORTED);
|
||||
}
|
||||
if (nj.length < (nj.ncomp * 3)) njThrow(NJ_SYNTAX_ERROR);
|
||||
for (i = 0, c = nj.comp; i < nj.ncomp; ++i, ++c) {
|
||||
c->cid = nj.pos[0];
|
||||
if (!(c->ssx = nj.pos[1] >> 4)) njThrow(NJ_SYNTAX_ERROR);
|
||||
if (c->ssx & (c->ssx - 1)) njThrow(NJ_UNSUPPORTED); // non-power of two
|
||||
if (!(c->ssy = nj.pos[1] & 15)) njThrow(NJ_SYNTAX_ERROR);
|
||||
if (c->ssy & (c->ssy - 1)) njThrow(NJ_UNSUPPORTED); // non-power of two
|
||||
if ((c->qtsel = nj.pos[2]) & 0xFC) njThrow(NJ_SYNTAX_ERROR);
|
||||
njSkip(3);
|
||||
nj.qtused |= 1 << c->qtsel;
|
||||
if (c->ssx > ssxmax) ssxmax = c->ssx;
|
||||
if (c->ssy > ssymax) ssymax = c->ssy;
|
||||
}
|
||||
if (nj.ncomp == 1) {
|
||||
c = nj.comp;
|
||||
c->ssx = c->ssy = ssxmax = ssymax = 1;
|
||||
}
|
||||
nj.mbsizex = ssxmax << 3;
|
||||
nj.mbsizey = ssymax << 3;
|
||||
nj.mbwidth = (nj.width + nj.mbsizex - 1) / nj.mbsizex;
|
||||
nj.mbheight = (nj.height + nj.mbsizey - 1) / nj.mbsizey;
|
||||
for (i = 0, c = nj.comp; i < nj.ncomp; ++i, ++c) {
|
||||
c->width = (nj.width * c->ssx + ssxmax - 1) / ssxmax;
|
||||
c->height = (nj.height * c->ssy + ssymax - 1) / ssymax;
|
||||
c->stride = nj.mbwidth * c->ssx << 3;
|
||||
if (((c->width < 3) && (c->ssx != ssxmax)) || ((c->height < 3) && (c->ssy != ssymax))) njThrow(NJ_UNSUPPORTED);
|
||||
if (!(c->pixels = (unsigned char*) njAllocMem(c->stride * nj.mbheight * c->ssy << 3))) njThrow(NJ_OUT_OF_MEM);
|
||||
}
|
||||
if (nj.ncomp == 3) {
|
||||
nj.rgb = (unsigned char*) njAllocMem(nj.width * nj.height * nj.ncomp);
|
||||
if (!nj.rgb) njThrow(NJ_OUT_OF_MEM);
|
||||
}
|
||||
njSkip(nj.length);
|
||||
}
|
||||
|
||||
NJ_INLINE void njDecodeDHT(void) {
|
||||
int codelen, currcnt, remain, spread, i, j;
|
||||
nj_vlc_code_t *vlc;
|
||||
static unsigned char counts[16];
|
||||
njDecodeLength();
|
||||
njCheckError();
|
||||
while (nj.length >= 17) {
|
||||
i = nj.pos[0];
|
||||
if (i & 0xEC) njThrow(NJ_SYNTAX_ERROR);
|
||||
if (i & 0x02) njThrow(NJ_UNSUPPORTED);
|
||||
i = (i | (i >> 3)) & 3; // combined DC/AC + tableid value
|
||||
for (codelen = 1; codelen <= 16; ++codelen)
|
||||
counts[codelen - 1] = nj.pos[codelen];
|
||||
njSkip(17);
|
||||
vlc = &nj.vlctab[i][0];
|
||||
remain = spread = 65536;
|
||||
for (codelen = 1; codelen <= 16; ++codelen) {
|
||||
spread >>= 1;
|
||||
currcnt = counts[codelen - 1];
|
||||
if (!currcnt) continue;
|
||||
if (nj.length < currcnt) njThrow(NJ_SYNTAX_ERROR);
|
||||
remain -= currcnt << (16 - codelen);
|
||||
if (remain < 0) njThrow(NJ_SYNTAX_ERROR);
|
||||
for (i = 0; i < currcnt; ++i) {
|
||||
register unsigned char code = nj.pos[i];
|
||||
for (j = spread; j; --j) {
|
||||
vlc->bits = (unsigned char) codelen;
|
||||
vlc->code = code;
|
||||
++vlc;
|
||||
}
|
||||
}
|
||||
njSkip(currcnt);
|
||||
}
|
||||
while (remain--) {
|
||||
vlc->bits = 0;
|
||||
++vlc;
|
||||
}
|
||||
}
|
||||
if (nj.length) njThrow(NJ_SYNTAX_ERROR);
|
||||
}
|
||||
|
||||
NJ_INLINE void njDecodeDQT(void) {
|
||||
int i;
|
||||
unsigned char *t;
|
||||
njDecodeLength();
|
||||
njCheckError();
|
||||
while (nj.length >= 65) {
|
||||
i = nj.pos[0];
|
||||
if (i & 0xFC) njThrow(NJ_SYNTAX_ERROR);
|
||||
nj.qtavail |= 1 << i;
|
||||
t = &nj.qtab[i][0];
|
||||
for (i = 0; i < 64; ++i)
|
||||
t[i] = nj.pos[i + 1];
|
||||
njSkip(65);
|
||||
}
|
||||
if (nj.length) njThrow(NJ_SYNTAX_ERROR);
|
||||
}
|
||||
|
||||
NJ_INLINE void njDecodeDRI(void) {
|
||||
njDecodeLength();
|
||||
njCheckError();
|
||||
if (nj.length < 2) njThrow(NJ_SYNTAX_ERROR);
|
||||
nj.rstinterval = njDecode16(nj.pos);
|
||||
njSkip(nj.length);
|
||||
}
|
||||
|
||||
static int njGetVLC(nj_vlc_code_t* vlc, unsigned char* code) {
|
||||
int value = njShowBits(16);
|
||||
int bits = vlc[value].bits;
|
||||
if (!bits) { nj.error = NJ_SYNTAX_ERROR; return 0; }
|
||||
njSkipBits(bits);
|
||||
value = vlc[value].code;
|
||||
if (code) *code = (unsigned char) value;
|
||||
bits = value & 15;
|
||||
if (!bits) return 0;
|
||||
value = njGetBits(bits);
|
||||
if (value < (1 << (bits - 1)))
|
||||
value += ((-1) << bits) + 1;
|
||||
return value;
|
||||
}
|
||||
|
||||
NJ_INLINE void njDecodeBlock(nj_component_t* c, unsigned char* out) {
|
||||
unsigned char code = 0;
|
||||
int value, coef = 0;
|
||||
njFillMem(nj.block, 0, sizeof(nj.block));
|
||||
c->dcpred += njGetVLC(&nj.vlctab[c->dctabsel][0], NULL);
|
||||
nj.block[0] = (c->dcpred) * nj.qtab[c->qtsel][0];
|
||||
do {
|
||||
value = njGetVLC(&nj.vlctab[c->actabsel][0], &code);
|
||||
if (!code) break; // EOB
|
||||
if (!(code & 0x0F) && (code != 0xF0)) njThrow(NJ_SYNTAX_ERROR);
|
||||
coef += (code >> 4) + 1;
|
||||
if (coef > 63) njThrow(NJ_SYNTAX_ERROR);
|
||||
nj.block[(int) njZZ[coef]] = value * nj.qtab[c->qtsel][coef];
|
||||
} while (coef < 63);
|
||||
for (coef = 0; coef < 64; coef += 8)
|
||||
njRowIDCT(&nj.block[coef]);
|
||||
for (coef = 0; coef < 8; ++coef)
|
||||
njColIDCT(&nj.block[coef], &out[coef], c->stride);
|
||||
}
|
||||
|
||||
NJ_INLINE void njDecodeScan(void) {
|
||||
int i, mbx, mby, sbx, sby;
|
||||
int rstcount = nj.rstinterval, nextrst = 0;
|
||||
nj_component_t* c;
|
||||
njDecodeLength();
|
||||
njCheckError();
|
||||
if (nj.length < (4 + 2 * nj.ncomp)) njThrow(NJ_SYNTAX_ERROR);
|
||||
if (nj.pos[0] != nj.ncomp) njThrow(NJ_UNSUPPORTED);
|
||||
njSkip(1);
|
||||
for (i = 0, c = nj.comp; i < nj.ncomp; ++i, ++c) {
|
||||
if (nj.pos[0] != c->cid) njThrow(NJ_SYNTAX_ERROR);
|
||||
if (nj.pos[1] & 0xEE) njThrow(NJ_SYNTAX_ERROR);
|
||||
c->dctabsel = nj.pos[1] >> 4;
|
||||
c->actabsel = (nj.pos[1] & 1) | 2;
|
||||
njSkip(2);
|
||||
}
|
||||
if (nj.pos[0] || (nj.pos[1] != 63) || nj.pos[2]) njThrow(NJ_UNSUPPORTED);
|
||||
njSkip(nj.length);
|
||||
for (mbx = mby = 0;;) {
|
||||
for (i = 0, c = nj.comp; i < nj.ncomp; ++i, ++c)
|
||||
for (sby = 0; sby < c->ssy; ++sby)
|
||||
for (sbx = 0; sbx < c->ssx; ++sbx) {
|
||||
njDecodeBlock(c, &c->pixels[((mby * c->ssy + sby) * c->stride + mbx * c->ssx + sbx) << 3]);
|
||||
njCheckError();
|
||||
}
|
||||
if (++mbx >= nj.mbwidth) {
|
||||
mbx = 0;
|
||||
if (++mby >= nj.mbheight) break;
|
||||
}
|
||||
if (nj.rstinterval && !(--rstcount)) {
|
||||
njByteAlign();
|
||||
i = njGetBits(16);
|
||||
if (((i & 0xFFF8) != 0xFFD0) || ((i & 7) != nextrst)) njThrow(NJ_SYNTAX_ERROR);
|
||||
nextrst = (nextrst + 1) & 7;
|
||||
rstcount = nj.rstinterval;
|
||||
for (i = 0; i < 3; ++i)
|
||||
nj.comp[i].dcpred = 0;
|
||||
}
|
||||
}
|
||||
nj.error = __NJ_FINISHED;
|
||||
}
|
||||
|
||||
#if NJ_CHROMA_FILTER
|
||||
|
||||
#define CF4A (-9)
|
||||
#define CF4B (111)
|
||||
#define CF4C (29)
|
||||
#define CF4D (-3)
|
||||
#define CF3A (28)
|
||||
#define CF3B (109)
|
||||
#define CF3C (-9)
|
||||
#define CF3X (104)
|
||||
#define CF3Y (27)
|
||||
#define CF3Z (-3)
|
||||
#define CF2A (139)
|
||||
#define CF2B (-11)
|
||||
#define CF(x) njClip(((x) + 64) >> 7)
|
||||
|
||||
NJ_INLINE void njUpsampleH(nj_component_t* c) {
|
||||
const int xmax = c->width - 3;
|
||||
unsigned char *out, *lin, *lout;
|
||||
int x, y;
|
||||
out = (unsigned char*) njAllocMem((c->width * c->height) << 1);
|
||||
if (!out) njThrow(NJ_OUT_OF_MEM);
|
||||
lin = c->pixels;
|
||||
lout = out;
|
||||
for (y = c->height; y; --y) {
|
||||
lout[0] = CF(CF2A * lin[0] + CF2B * lin[1]);
|
||||
lout[1] = CF(CF3X * lin[0] + CF3Y * lin[1] + CF3Z * lin[2]);
|
||||
lout[2] = CF(CF3A * lin[0] + CF3B * lin[1] + CF3C * lin[2]);
|
||||
for (x = 0; x < xmax; ++x) {
|
||||
lout[(x << 1) + 3] = CF(CF4A * lin[x] + CF4B * lin[x + 1] + CF4C * lin[x + 2] + CF4D * lin[x + 3]);
|
||||
lout[(x << 1) + 4] = CF(CF4D * lin[x] + CF4C * lin[x + 1] + CF4B * lin[x + 2] + CF4A * lin[x + 3]);
|
||||
}
|
||||
lin += c->stride;
|
||||
lout += c->width << 1;
|
||||
lout[-3] = CF(CF3A * lin[-1] + CF3B * lin[-2] + CF3C * lin[-3]);
|
||||
lout[-2] = CF(CF3X * lin[-1] + CF3Y * lin[-2] + CF3Z * lin[-3]);
|
||||
lout[-1] = CF(CF2A * lin[-1] + CF2B * lin[-2]);
|
||||
}
|
||||
c->width <<= 1;
|
||||
c->stride = c->width;
|
||||
njFreeMem((void*)c->pixels);
|
||||
c->pixels = out;
|
||||
}
|
||||
|
||||
NJ_INLINE void njUpsampleV(nj_component_t* c) {
|
||||
const int w = c->width, s1 = c->stride, s2 = s1 + s1;
|
||||
unsigned char *out, *cin, *cout;
|
||||
int x, y;
|
||||
out = (unsigned char*) njAllocMem((c->width * c->height) << 1);
|
||||
if (!out) njThrow(NJ_OUT_OF_MEM);
|
||||
for (x = 0; x < w; ++x) {
|
||||
cin = &c->pixels[x];
|
||||
cout = &out[x];
|
||||
*cout = CF(CF2A * cin[0] + CF2B * cin[s1]); cout += w;
|
||||
*cout = CF(CF3X * cin[0] + CF3Y * cin[s1] + CF3Z * cin[s2]); cout += w;
|
||||
*cout = CF(CF3A * cin[0] + CF3B * cin[s1] + CF3C * cin[s2]); cout += w;
|
||||
cin += s1;
|
||||
for (y = c->height - 3; y; --y) {
|
||||
*cout = CF(CF4A * cin[-s1] + CF4B * cin[0] + CF4C * cin[s1] + CF4D * cin[s2]); cout += w;
|
||||
*cout = CF(CF4D * cin[-s1] + CF4C * cin[0] + CF4B * cin[s1] + CF4A * cin[s2]); cout += w;
|
||||
cin += s1;
|
||||
}
|
||||
cin += s1;
|
||||
*cout = CF(CF3A * cin[0] + CF3B * cin[-s1] + CF3C * cin[-s2]); cout += w;
|
||||
*cout = CF(CF3X * cin[0] + CF3Y * cin[-s1] + CF3Z * cin[-s2]); cout += w;
|
||||
*cout = CF(CF2A * cin[0] + CF2B * cin[-s1]);
|
||||
}
|
||||
c->height <<= 1;
|
||||
c->stride = c->width;
|
||||
njFreeMem((void*) c->pixels);
|
||||
c->pixels = out;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
NJ_INLINE void njUpsample(nj_component_t* c) {
|
||||
int x, y, xshift = 0, yshift = 0;
|
||||
unsigned char *out, *lin, *lout;
|
||||
while (c->width < nj.width) { c->width <<= 1; ++xshift; }
|
||||
while (c->height < nj.height) { c->height <<= 1; ++yshift; }
|
||||
out = (unsigned char*) njAllocMem(c->width * c->height);
|
||||
if (!out) njThrow(NJ_OUT_OF_MEM);
|
||||
lin = c->pixels;
|
||||
lout = out;
|
||||
for (y = 0; y < c->height; ++y) {
|
||||
lin = &c->pixels[(y >> yshift) * c->stride];
|
||||
for (x = 0; x < c->width; ++x)
|
||||
lout[x] = lin[x >> xshift];
|
||||
lout += c->width;
|
||||
}
|
||||
c->stride = c->width;
|
||||
njFreeMem((void*) c->pixels);
|
||||
c->pixels = out;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
NJ_INLINE void njConvert(void) {
|
||||
int i;
|
||||
nj_component_t* c;
|
||||
for (i = 0, c = nj.comp; i < nj.ncomp; ++i, ++c) {
|
||||
#if NJ_CHROMA_FILTER
|
||||
while ((c->width < nj.width) || (c->height < nj.height)) {
|
||||
if (c->width < nj.width) njUpsampleH(c);
|
||||
njCheckError();
|
||||
if (c->height < nj.height) njUpsampleV(c);
|
||||
njCheckError();
|
||||
}
|
||||
#else
|
||||
if ((c->width < nj.width) || (c->height < nj.height))
|
||||
njUpsample(c);
|
||||
#endif
|
||||
if ((c->width < nj.width) || (c->height < nj.height)) njThrow(NJ_INTERNAL_ERR);
|
||||
}
|
||||
if (nj.ncomp == 3) {
|
||||
// convert to RGB
|
||||
int x, yy;
|
||||
unsigned char *prgb = nj.rgb;
|
||||
const unsigned char *py = nj.comp[0].pixels;
|
||||
const unsigned char *pcb = nj.comp[1].pixels;
|
||||
const unsigned char *pcr = nj.comp[2].pixels;
|
||||
for (yy = nj.height; yy; --yy) {
|
||||
for (x = 0; x < nj.width; ++x) {
|
||||
register int y = py[x] << 8;
|
||||
register int cb = pcb[x] - 128;
|
||||
register int cr = pcr[x] - 128;
|
||||
*prgb++ = njClip((y + 359 * cr + 128) >> 8);
|
||||
*prgb++ = njClip((y - 88 * cb - 183 * cr + 128) >> 8);
|
||||
*prgb++ = njClip((y + 454 * cb + 128) >> 8);
|
||||
}
|
||||
py += nj.comp[0].stride;
|
||||
pcb += nj.comp[1].stride;
|
||||
pcr += nj.comp[2].stride;
|
||||
}
|
||||
} else if (nj.comp[0].width != nj.comp[0].stride) {
|
||||
// grayscale -> only remove stride
|
||||
unsigned char *pin = &nj.comp[0].pixels[nj.comp[0].stride];
|
||||
unsigned char *pout = &nj.comp[0].pixels[nj.comp[0].width];
|
||||
int y;
|
||||
for (y = nj.comp[0].height - 1; y; --y) {
|
||||
njCopyMem(pout, pin, nj.comp[0].width);
|
||||
pin += nj.comp[0].stride;
|
||||
pout += nj.comp[0].width;
|
||||
}
|
||||
nj.comp[0].stride = nj.comp[0].width;
|
||||
}
|
||||
}
|
||||
|
||||
void njInit(void) {
|
||||
njFillMem(&nj, 0, sizeof(nj_context_t));
|
||||
}
|
||||
|
||||
void njDone(void) {
|
||||
int i;
|
||||
for (i = 0; i < 3; ++i)
|
||||
if (nj.comp[i].pixels) njFreeMem((void*) nj.comp[i].pixels);
|
||||
if (nj.rgb) njFreeMem((void*) nj.rgb);
|
||||
njInit();
|
||||
}
|
||||
|
||||
nj_result_t njDecode(const void* jpeg, const int size) {
|
||||
njDone();
|
||||
nj.pos = (const unsigned char*) jpeg;
|
||||
nj.size = size & 0x7FFFFFFF;
|
||||
if (nj.size < 2) return NJ_NO_JPEG;
|
||||
if ((nj.pos[0] ^ 0xFF) | (nj.pos[1] ^ 0xD8)) return NJ_NO_JPEG;
|
||||
njSkip(2);
|
||||
while (!nj.error) {
|
||||
if ((nj.size < 2) || (nj.pos[0] != 0xFF)) return NJ_SYNTAX_ERROR;
|
||||
njSkip(2);
|
||||
switch (nj.pos[-1]) {
|
||||
case 0xC0: njDecodeSOF(); break;
|
||||
case 0xC4: njDecodeDHT(); break;
|
||||
case 0xDB: njDecodeDQT(); break;
|
||||
case 0xDD: njDecodeDRI(); break;
|
||||
case 0xDA: njDecodeScan(); break;
|
||||
case 0xFE: njSkipMarker(); break;
|
||||
default:
|
||||
if ((nj.pos[-1] & 0xF0) == 0xE0)
|
||||
njSkipMarker();
|
||||
else
|
||||
return NJ_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
if (nj.error != __NJ_FINISHED) return nj.error;
|
||||
nj.error = NJ_OK;
|
||||
njConvert();
|
||||
return nj.error;
|
||||
}
|
||||
|
||||
int njGetWidth(void) { return nj.width; }
|
||||
int njGetHeight(void) { return nj.height; }
|
||||
int njIsColor(void) { return (nj.ncomp != 1); }
|
||||
unsigned char* njGetImage(void) { return (nj.ncomp == 1) ? nj.comp[0].pixels : nj.rgb; }
|
||||
int njGetImageSize(void) { return nj.width * nj.height * nj.ncomp; }
|
||||
|
||||
#endif // _NJ_INCLUDE_HEADER_ONLY
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user