From 24788185aa64b081fb4e2e7371add1c1f6b47752 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Fri, 18 Jan 2019 15:55:06 +0100 Subject: [PATCH] runtime: CMake-ify --- Runtime/CMakeLists.txt | 72 + Runtime/bbruntime_dll.cpp | 6 +- .../{bbruntime_dll.h => bbruntime_dll.hpp} | 2 +- Runtime/bbruntime_dll.rc | 6 +- Runtime/blitz3d/CMakeLists.txt | 138 + {blitz3d => Runtime/blitz3d}/animation.cpp | 4 +- .../blitz3d/animation.hpp | 2 +- {blitz3d => Runtime/blitz3d}/animator.cpp | 6 +- .../blitz3d/animator.hpp | 2 +- {blitz3d => Runtime/blitz3d}/bd2model.cpp | 2 +- .../blitz3d/bd2model.hpp | 0 .../blitz3d.h => Runtime/blitz3d/blitz3d.hpp | 0 {blitz3d => Runtime/blitz3d}/boxvis.cpp | 5 +- {blitz3d => Runtime/blitz3d}/brush.cpp | 6 +- blitz3d/brush.h => Runtime/blitz3d/brush.hpp | 4 +- .../blitz3d}/cachedtexture.cpp | 4 +- .../blitz3d/cachedtexture.hpp | 2 +- {blitz3d => Runtime/blitz3d}/camera.cpp | 4 +- .../camera.h => Runtime/blitz3d/camera.hpp | 6 +- {blitz3d => Runtime/blitz3d}/collision.cpp | 4 +- .../blitz3d/collision.hpp | 2 +- {blitz3d => Runtime/blitz3d}/emitter.cpp | 4 +- .../emitter.h => Runtime/blitz3d/emitter.hpp | 2 +- {blitz3d => Runtime/blitz3d}/entity.cpp | 6 +- .../entity.h => Runtime/blitz3d/entity.hpp | 2 +- .../blitz3d/entityutil.hpp | 0 {blitz3d => Runtime/blitz3d}/frustum.cpp | 4 +- .../frustum.h => Runtime/blitz3d/frustum.hpp | 2 +- {blitz3d => Runtime/blitz3d}/geom.cpp | 4 +- blitz3d/geom.h => Runtime/blitz3d/geom.hpp | 0 blitz3d/group.h => Runtime/blitz3d/group.hpp | 0 {blitz3d => Runtime/blitz3d}/light.cpp | 6 +- blitz3d/light.h => Runtime/blitz3d/light.hpp | 6 +- {blitz3d => Runtime/blitz3d}/listener.cpp | 4 +- .../blitz3d/listener.hpp | 2 +- {blitz3d => Runtime/blitz3d}/loader.cpp | 6 +- .../blitz3d/loader.hpp | 0 {blitz3d => Runtime/blitz3d}/loader_3ds.cpp | 8 +- .../blitz3d/loader_3ds.hpp | 2 +- {blitz3d => Runtime/blitz3d}/loader_b3d.cpp | 10 +- .../blitz3d/loader_b3d.hpp | 2 +- {blitz3d => Runtime/blitz3d}/loader_x.cpp | 12 +- .../blitz3d/loader_x.hpp | 2 +- {blitz3d => Runtime/blitz3d}/md2model.cpp | 6 +- .../blitz3d/md2model.hpp | 4 +- {blitz3d => Runtime/blitz3d}/md2model_bak.cpp | 0 {blitz3d => Runtime/blitz3d}/md2norms.cpp | 4 +- .../blitz3d/md2norms.hpp | 0 {blitz3d => Runtime/blitz3d}/md2rep.cpp | 6 +- .../md2rep.h => Runtime/blitz3d/md2rep.hpp | 2 +- blitz3d/mesh.h => Runtime/blitz3d/mesh.hpp | 0 {blitz3d => Runtime/blitz3d}/meshcollider.cpp | 4 +- .../blitz3d/meshcollider.hpp | 2 +- {blitz3d => Runtime/blitz3d}/meshloader.cpp | 6 +- .../blitz3d/meshloader.hpp | 4 +- {blitz3d => Runtime/blitz3d}/meshmodel.cpp | 6 +- .../blitz3d/meshmodel.hpp | 4 +- .../blitz3d/meshrenderer.hpp | 4 +- {blitz3d => Runtime/blitz3d}/meshutil.cpp | 4 +- .../blitz3d/meshutil.hpp | 2 +- {blitz3d => Runtime/blitz3d}/mirror.cpp | 4 +- .../mirror.h => Runtime/blitz3d/mirror.hpp | 2 +- {blitz3d => Runtime/blitz3d}/model.cpp | 4 +- blitz3d/model.h => Runtime/blitz3d/model.hpp | 6 +- {blitz3d => Runtime/blitz3d}/ms3drep.cpp | 0 .../loader.h => Runtime/blitz3d/ms3drep.hpp | 0 {blitz3d => Runtime/blitz3d}/object.cpp | 4 +- .../object.h => Runtime/blitz3d/object.hpp | 6 +- {blitz3d => Runtime/blitz3d}/pivot.cpp | 4 +- blitz3d/pivot.h => Runtime/blitz3d/pivot.hpp | 2 +- {blitz3d => Runtime/blitz3d}/planemodel.cpp | 8 +- .../blitz3d/planemodel.hpp | 4 +- {blitz3d => Runtime/blitz3d}/q3bspmodel.cpp | 6 +- .../blitz3d/q3bspmodel.hpp | 2 +- {blitz3d => Runtime/blitz3d}/q3bsprep.cpp | 4 +- .../blitz3d/q3bsprep.hpp | 4 +- .../blitz3d/rendercontext.hpp | 2 +- {blitz3d => Runtime/blitz3d}/skinmodel.cpp | 4 +- .../blitz3d/skinmodel.hpp | 2 +- {blitz3d => Runtime/blitz3d}/sprite.cpp | 4 +- .../sprite.h => Runtime/blitz3d/sprite.hpp | 6 +- Runtime/blitz3d/std.cpp | 2 + blitz3d/std.h => Runtime/blitz3d/std.hpp | 6 +- {blitz3d => Runtime/blitz3d}/surface.cpp | 4 +- .../surface.h => Runtime/blitz3d/surface.hpp | 2 +- {blitz3d => Runtime/blitz3d}/terrain.cpp | 6 +- .../terrain.h => Runtime/blitz3d/terrain.hpp | 2 +- .../blitz3d/terrainmodel.hpp | 0 {blitz3d => Runtime/blitz3d}/terrainrep.cpp | 4 +- .../blitz3d/terrainrep.hpp | 2 +- {blitz3d => Runtime/blitz3d}/texture.cpp | 10 +- .../texture.h => Runtime/blitz3d/texture.hpp | 4 +- .../blitz3d/texturecache.hpp | 0 {blitz3d => Runtime/blitz3d}/users_guide.txt | 0 {blitz3d => Runtime/blitz3d}/world.cpp | 4 +- blitz3d/world.h => Runtime/blitz3d/world.hpp | 10 +- Runtime/lib/CMakeLists.txt | 104 + {RuntimeLib => Runtime/lib}/basic.cpp | 1184 +++---- RuntimeLib/basic.h => Runtime/lib/basic.hpp | 298 +- .../bb_basic.h => Runtime/lib/bb_basic.hpp | 0 {RuntimeLib => Runtime/lib}/bbaudio.cpp | 4 +- .../bbaudio.h => Runtime/lib/bbaudio.hpp | 4 +- {RuntimeLib => Runtime/lib}/bbbank.cpp | 6 +- RuntimeLib/bbbank.h => Runtime/lib/bbbank.hpp | 2 +- {RuntimeLib => Runtime/lib}/bbblitz3d.cpp | 42 +- .../bbblitz3d.h => Runtime/lib/bbblitz3d.hpp | 4 +- {RuntimeLib => Runtime/lib}/bbfilesystem.cpp | 6 +- .../lib/bbfilesystem.hpp | 4 +- {RuntimeLib => Runtime/lib}/bbgraphics.cpp | 2750 ++++++++--------- .../lib/bbgraphics.hpp | 4 +- {RuntimeLib => Runtime/lib}/bbinput.cpp | 4 +- .../bbinput.h => Runtime/lib/bbinput.hpp | 4 +- {RuntimeLib => Runtime/lib}/bbmath.cpp | 4 +- RuntimeLib/bbmath.h => Runtime/lib/bbmath.hpp | 0 {RuntimeLib => Runtime/lib}/bbruntime.cpp | 6 +- .../bbruntime.h => Runtime/lib/bbruntime.hpp | 2 +- {RuntimeLib => Runtime/lib}/bbsockets.cpp | 0 .../bbsockets.h => Runtime/lib/bbsockets.hpp | 0 {RuntimeLib => Runtime/lib}/bbstream.cpp | 0 .../bbstream.h => Runtime/lib/bbstream.hpp | 2 +- {RuntimeLib => Runtime/lib}/bbstring.cpp | 4 +- .../bbstring.h => Runtime/lib/bbstring.hpp | 0 Runtime/lib/bbsys.cpp | 6 + RuntimeLib/bbsys.h => Runtime/lib/bbsys.hpp | 4 +- {RuntimeLib => Runtime/lib}/multiplay.cpp | 6 +- .../multiplay.h => Runtime/lib/multiplay.hpp | 2 +- .../lib}/multiplay_setup.cpp | 8 +- .../lib/multiplay_setup.hpp | 0 .../lib}/multiplay_setup.rc | 4 +- .../resource.h => Runtime/lib/resource.hpp | 0 .../texturecache.h => Runtime/lib/runtime.cpp | 0 Runtime/lib/std.cpp | 2 + RuntimeLib/std.h => Runtime/lib/std.hpp | 4 +- {RuntimeLib => Runtime/lib}/userlib.cpp | 6 +- .../userlib.h => Runtime/lib/userlib.hpp | 0 {RuntimeLib => Runtime/lib}/userlibs.cpp | 6 +- .../userlibs.h => Runtime/lib/userlibs.hpp | 2 +- Runtime/{resource.h => resource.hpp} | 0 RuntimeLib/bbsys.cpp | 6 - RuntimeLib/std.cpp | 2 - blitz3d/std.cpp | 2 - gxruntime/CMakeLists.txt | 113 + gxruntime/asmcoder.cpp | 2 +- gxruntime/{asmcoder.h => asmcoder.hpp} | 0 gxruntime/ddutil.cpp | 14 +- gxruntime/{ddutil.h => ddutil.hpp} | 2 +- ...{GraphicsRuntime.h => graphicsruntime.hpp} | 94 +- gxruntime/gxaudio.cpp | 5 +- gxruntime/{gxaudio.h => gxaudio.hpp} | 2 +- gxruntime/gxcanvas.cpp | 10 +- gxruntime/{gxcanvas.h => gxcanvas.hpp} | 2 +- gxruntime/gxchannel.cpp | 4 +- gxruntime/{gxchannel.h => gxchannel.hpp} | 0 gxruntime/gxdevice.cpp | 6 +- gxruntime/{gxdevice.h => gxdevice.hpp} | 0 gxruntime/gxdir.cpp | 4 +- gxruntime/{gxdir.h => gxdir.hpp} | 0 gxruntime/gxfilesys_h.txt | 0 gxruntime/gxfilesystem.cpp | 4 +- .../{gxfilesystem.h => gxfilesystem.hpp} | 2 +- gxruntime/gxfont.cpp | 8 +- gxruntime/{gxfont.h => gxfont.hpp} | 0 gxruntime/gxgraphics.cpp | 6 +- gxruntime/{gxgraphics.h => gxgraphics.hpp} | 14 +- gxruntime/gxinput.cpp | 6 +- gxruntime/{gxinput.h => gxinput.hpp} | 6 +- gxruntime/gxlight.cpp | 8 +- gxruntime/{gxlight.h => gxlight.hpp} | 2 +- gxruntime/gxmesh.cpp | 8 +- gxruntime/{gxmesh.h => gxmesh.hpp} | 2 +- gxruntime/gxmovie.cpp | 6 +- gxruntime/{gxmovie.h => gxmovie.hpp} | 2 +- gxruntime/gxmusic.cpp | 5 +- gxruntime/{gxmusic.h => gxmusic.hpp} | 0 gxruntime/gxruntime.cpp | 44 +- gxruntime/{gxruntime.h => gxruntime.hpp} | 14 +- gxruntime/gxscene.cpp | 8 +- gxruntime/{gxscene.h => gxscene.hpp} | 4 +- gxruntime/gxsound.cpp | 7 +- gxruntime/{gxsound.h => gxsound.hpp} | 2 +- gxruntime/gxtimer.cpp | 6 +- gxruntime/{gxtimer.h => gxtimer.hpp} | 2 + gxruntime/std.cpp | 2 +- gxruntime/{std.h => std.hpp} | 7 +- 184 files changed, 2957 insertions(+), 2527 deletions(-) create mode 100644 Runtime/CMakeLists.txt rename Runtime/{bbruntime_dll.h => bbruntime_dll.hpp} (94%) create mode 100644 Runtime/blitz3d/CMakeLists.txt rename {blitz3d => Runtime/blitz3d}/animation.cpp (99%) rename blitz3d/animation.h => Runtime/blitz3d/animation.hpp (97%) rename {blitz3d => Runtime/blitz3d}/animator.cpp (98%) rename blitz3d/animator.h => Runtime/blitz3d/animator.hpp (98%) rename {blitz3d => Runtime/blitz3d}/bd2model.cpp (93%) rename blitz3d/bd2model.h => Runtime/blitz3d/bd2model.hpp (100%) rename blitz3d/blitz3d.h => Runtime/blitz3d/blitz3d.hpp (100%) rename {blitz3d => Runtime/blitz3d}/boxvis.cpp (98%) rename {blitz3d => Runtime/blitz3d}/brush.cpp (98%) rename blitz3d/brush.h => Runtime/blitz3d/brush.hpp (94%) rename {blitz3d => Runtime/blitz3d}/cachedtexture.cpp (98%) rename blitz3d/cachedtexture.h => Runtime/blitz3d/cachedtexture.hpp (95%) rename {blitz3d => Runtime/blitz3d}/camera.cpp (98%) rename blitz3d/camera.h => Runtime/blitz3d/camera.hpp (94%) rename {blitz3d => Runtime/blitz3d}/collision.cpp (99%) rename blitz3d/collision.h => Runtime/blitz3d/collision.hpp (97%) rename {blitz3d => Runtime/blitz3d}/emitter.cpp (94%) rename blitz3d/emitter.h => Runtime/blitz3d/emitter.hpp (95%) rename {blitz3d => Runtime/blitz3d}/entity.cpp (98%) rename blitz3d/entity.h => Runtime/blitz3d/entity.hpp (99%) rename RuntimeLib/runtime.cpp => Runtime/blitz3d/entityutil.hpp (100%) rename {blitz3d => Runtime/blitz3d}/frustum.cpp (97%) rename blitz3d/frustum.h => Runtime/blitz3d/frustum.hpp (97%) rename {blitz3d => Runtime/blitz3d}/geom.cpp (92%) rename blitz3d/geom.h => Runtime/blitz3d/geom.hpp (100%) rename blitz3d/group.h => Runtime/blitz3d/group.hpp (100%) rename {blitz3d => Runtime/blitz3d}/light.cpp (88%) rename blitz3d/light.h => Runtime/blitz3d/light.hpp (83%) rename {blitz3d => Runtime/blitz3d}/listener.cpp (94%) rename blitz3d/listener.h => Runtime/blitz3d/listener.hpp (94%) rename {blitz3d => Runtime/blitz3d}/loader.cpp (96%) rename blitz3d/entityutil.h => Runtime/blitz3d/loader.hpp (100%) rename {blitz3d => Runtime/blitz3d}/loader_3ds.cpp (99%) rename blitz3d/loader_3ds.h => Runtime/blitz3d/loader_3ds.hpp (86%) rename {blitz3d => Runtime/blitz3d}/loader_b3d.cpp (98%) rename blitz3d/loader_b3d.h => Runtime/blitz3d/loader_b3d.hpp (86%) rename {blitz3d => Runtime/blitz3d}/loader_x.cpp (98%) rename blitz3d/loader_x.h => Runtime/blitz3d/loader_x.hpp (86%) rename {blitz3d => Runtime/blitz3d}/md2model.cpp (97%) rename blitz3d/md2model.h => Runtime/blitz3d/md2model.hpp (95%) rename {blitz3d => Runtime/blitz3d}/md2model_bak.cpp (100%) rename {blitz3d => Runtime/blitz3d}/md2norms.cpp (99%) rename blitz3d/md2norms.h => Runtime/blitz3d/md2norms.hpp (100%) rename {blitz3d => Runtime/blitz3d}/md2rep.cpp (99%) rename blitz3d/md2rep.h => Runtime/blitz3d/md2rep.hpp (97%) rename blitz3d/mesh.h => Runtime/blitz3d/mesh.hpp (100%) rename {blitz3d => Runtime/blitz3d}/meshcollider.cpp (99%) rename blitz3d/meshcollider.h => Runtime/blitz3d/meshcollider.hpp (97%) rename {blitz3d => Runtime/blitz3d}/meshloader.cpp (97%) rename blitz3d/meshloader.h => Runtime/blitz3d/meshloader.hpp (94%) rename {blitz3d => Runtime/blitz3d}/meshmodel.cpp (99%) rename blitz3d/meshmodel.h => Runtime/blitz3d/meshmodel.hpp (96%) rename blitz3d/meshrenderer.h => Runtime/blitz3d/meshrenderer.hpp (88%) rename {blitz3d => Runtime/blitz3d}/meshutil.cpp (99%) rename blitz3d/meshutil.h => Runtime/blitz3d/meshutil.hpp (97%) rename {blitz3d => Runtime/blitz3d}/mirror.cpp (69%) rename blitz3d/mirror.h => Runtime/blitz3d/mirror.hpp (91%) rename {blitz3d => Runtime/blitz3d}/model.cpp (98%) rename blitz3d/model.h => Runtime/blitz3d/model.hpp (96%) rename {blitz3d => Runtime/blitz3d}/ms3drep.cpp (100%) rename blitz3d/loader.h => Runtime/blitz3d/ms3drep.hpp (100%) rename {blitz3d => Runtime/blitz3d}/object.cpp (98%) rename blitz3d/object.h => Runtime/blitz3d/object.hpp (96%) rename {blitz3d => Runtime/blitz3d}/pivot.cpp (62%) rename blitz3d/pivot.h => Runtime/blitz3d/pivot.hpp (89%) rename {blitz3d => Runtime/blitz3d}/planemodel.cpp (97%) rename blitz3d/planemodel.h => Runtime/blitz3d/planemodel.hpp (92%) rename {blitz3d => Runtime/blitz3d}/q3bspmodel.cpp (92%) rename blitz3d/q3bspmodel.h => Runtime/blitz3d/q3bspmodel.hpp (96%) rename {blitz3d => Runtime/blitz3d}/q3bsprep.cpp (99%) rename blitz3d/q3bsprep.h => Runtime/blitz3d/q3bsprep.hpp (95%) rename blitz3d/rendercontext.h => Runtime/blitz3d/rendercontext.hpp (96%) rename {blitz3d => Runtime/blitz3d}/skinmodel.cpp (93%) rename blitz3d/skinmodel.h => Runtime/blitz3d/skinmodel.hpp (92%) rename {blitz3d => Runtime/blitz3d}/sprite.cpp (98%) rename blitz3d/sprite.h => Runtime/blitz3d/sprite.hpp (91%) create mode 100644 Runtime/blitz3d/std.cpp rename blitz3d/std.h => Runtime/blitz3d/std.hpp (66%) rename {blitz3d => Runtime/blitz3d}/surface.cpp (99%) rename blitz3d/surface.h => Runtime/blitz3d/surface.hpp (99%) rename {blitz3d => Runtime/blitz3d}/terrain.cpp (92%) rename blitz3d/terrain.h => Runtime/blitz3d/terrain.hpp (96%) rename blitz3d/ms3drep.h => Runtime/blitz3d/terrainmodel.hpp (100%) rename {blitz3d => Runtime/blitz3d}/terrainrep.cpp (99%) rename blitz3d/terrainrep.h => Runtime/blitz3d/terrainrep.hpp (98%) rename {blitz3d => Runtime/blitz3d}/texture.cpp (97%) rename blitz3d/texture.h => Runtime/blitz3d/texture.hpp (93%) rename blitz3d/terrainmodel.h => Runtime/blitz3d/texturecache.hpp (100%) rename {blitz3d => Runtime/blitz3d}/users_guide.txt (100%) rename {blitz3d => Runtime/blitz3d}/world.cpp (99%) rename blitz3d/world.h => Runtime/blitz3d/world.hpp (91%) create mode 100644 Runtime/lib/CMakeLists.txt rename {RuntimeLib => Runtime/lib}/basic.cpp (95%) rename RuntimeLib/basic.h => Runtime/lib/basic.hpp (95%) rename RuntimeLib/bb_basic.h => Runtime/lib/bb_basic.hpp (100%) rename {RuntimeLib => Runtime/lib}/bbaudio.cpp (98%) rename RuntimeLib/bbaudio.h => Runtime/lib/bbaudio.hpp (93%) rename {RuntimeLib => Runtime/lib}/bbbank.cpp (98%) rename RuntimeLib/bbbank.h => Runtime/lib/bbbank.hpp (67%) rename {RuntimeLib => Runtime/lib}/bbblitz3d.cpp (98%) rename RuntimeLib/bbblitz3d.h => Runtime/lib/bbblitz3d.hpp (57%) rename {RuntimeLib => Runtime/lib}/bbfilesystem.cpp (98%) rename RuntimeLib/bbfilesystem.h => Runtime/lib/bbfilesystem.hpp (58%) rename {RuntimeLib => Runtime/lib}/bbgraphics.cpp (96%) rename RuntimeLib/bbgraphics.h => Runtime/lib/bbgraphics.hpp (98%) rename {RuntimeLib => Runtime/lib}/bbinput.cpp (99%) rename RuntimeLib/bbinput.h => Runtime/lib/bbinput.hpp (95%) rename {RuntimeLib => Runtime/lib}/bbmath.cpp (98%) rename RuntimeLib/bbmath.h => Runtime/lib/bbmath.hpp (100%) rename {RuntimeLib => Runtime/lib}/bbruntime.cpp (98%) rename RuntimeLib/bbruntime.h => Runtime/lib/bbruntime.hpp (90%) rename {RuntimeLib => Runtime/lib}/bbsockets.cpp (100%) rename RuntimeLib/bbsockets.h => Runtime/lib/bbsockets.hpp (100%) rename {RuntimeLib => Runtime/lib}/bbstream.cpp (100%) rename RuntimeLib/bbstream.h => Runtime/lib/bbstream.hpp (95%) rename {RuntimeLib => Runtime/lib}/bbstring.cpp (98%) rename RuntimeLib/bbstring.h => Runtime/lib/bbstring.hpp (100%) create mode 100644 Runtime/lib/bbsys.cpp rename RuntimeLib/bbsys.h => Runtime/lib/bbsys.hpp (81%) rename {RuntimeLib => Runtime/lib}/multiplay.cpp (98%) rename RuntimeLib/multiplay.h => Runtime/lib/multiplay.hpp (96%) rename {RuntimeLib => Runtime/lib}/multiplay_setup.cpp (99%) rename RuntimeLib/multiplay_setup.h => Runtime/lib/multiplay_setup.hpp (100%) rename {RuntimeLib => Runtime/lib}/multiplay_setup.rc (97%) rename RuntimeLib/resource.h => Runtime/lib/resource.hpp (100%) rename blitz3d/texturecache.h => Runtime/lib/runtime.cpp (100%) create mode 100644 Runtime/lib/std.cpp rename RuntimeLib/std.h => Runtime/lib/std.hpp (85%) rename {RuntimeLib => Runtime/lib}/userlib.cpp (83%) rename RuntimeLib/userlib.h => Runtime/lib/userlib.hpp (100%) rename {RuntimeLib => Runtime/lib}/userlibs.cpp (95%) rename RuntimeLib/userlibs.h => Runtime/lib/userlibs.hpp (88%) rename Runtime/{resource.h => resource.hpp} (100%) delete mode 100644 RuntimeLib/bbsys.cpp delete mode 100644 RuntimeLib/std.cpp delete mode 100644 blitz3d/std.cpp create mode 100644 gxruntime/CMakeLists.txt rename gxruntime/{asmcoder.h => asmcoder.hpp} (100%) rename gxruntime/{ddutil.h => ddutil.hpp} (97%) rename gxruntime/{GraphicsRuntime.h => graphicsruntime.hpp} (98%) rename gxruntime/{gxaudio.h => gxaudio.hpp} (97%) rename gxruntime/{gxcanvas.h => gxcanvas.hpp} (99%) rename gxruntime/{gxchannel.h => gxchannel.hpp} (100%) rename gxruntime/{gxdevice.h => gxdevice.hpp} (100%) rename gxruntime/{gxdir.h => gxdir.hpp} (100%) delete mode 100644 gxruntime/gxfilesys_h.txt rename gxruntime/{gxfilesystem.h => gxfilesystem.hpp} (97%) rename gxruntime/{gxfont.h => gxfont.hpp} (100%) rename gxruntime/{gxgraphics.h => gxgraphics.hpp} (94%) rename gxruntime/{gxinput.h => gxinput.hpp} (91%) rename gxruntime/{gxlight.h => gxlight.hpp} (95%) rename gxruntime/{gxmesh.h => gxmesh.hpp} (98%) rename gxruntime/{gxmovie.h => gxmovie.hpp} (97%) rename gxruntime/{gxmusic.h => gxmusic.hpp} (100%) rename gxruntime/{gxruntime.h => gxruntime.hpp} (94%) rename gxruntime/{gxscene.h => gxscene.hpp} (98%) rename gxruntime/{gxsound.h => gxsound.hpp} (95%) rename gxruntime/{gxtimer.h => gxtimer.hpp} (94%) rename gxruntime/{std.h => std.hpp} (66%) diff --git a/Runtime/CMakeLists.txt b/Runtime/CMakeLists.txt new file mode 100644 index 0000000..c8a323c --- /dev/null +++ b/Runtime/CMakeLists.txt @@ -0,0 +1,72 @@ +project(runtime) + +add_subdirectory(lib) +add_subdirectory(blitz3d) + +add_library(${PROJECT_NAME} MODULE + "bbruntime_dll.hpp" + "bbruntime_dll.cpp" + "resource.hpp" + "bbruntime_dll.rc" +) + +target_link_libraries(${PROJECT_NAME} + PRIVATE + runtime_lib + gxruntime + stdutil +) + +#target_include_directories(${PROJECT_NAME} +# +#) + +if (WIN32) + target_compile_definitions(${PROJECT_NAME} + PRIVATE + _CRT_SECURE_NO_WARNINGS + # windows.h + WIN32_LEAN_AND_MEAN + NOGPICAPMASKS + NOVIRTUALKEYCODES + NOWINMESSAGES + NOWINSTYLES + NOSYSMETRICS + NOMENUS + NOICONS + NOKEYSTATES + NOSYSCOMMANDS + NORASTEROPS + NOSHOWWINDOW + NOATOM + NOCLIPBOARD + NOCOLOR + NOCTLMGR + NODRAWTEXT + #NOGDI + NOKERNEL + #NOUSER + NONLS + #NOMB + NOMEMMGR + NOMETAFILE + NOMINMAX + #NOMSG + NOOPENFILE + NOSCROLL + NOSERVICE + NOSOUND + NOTEXTMETRIC + NOWH + NOWINOFFSETS + NOCOMM + NOKANJI + NOHELP + NOPROFILER + NODEFERWINDOWPOS + NOMCX + NOIME + NOMDI + NOINOUT + ) +endif() diff --git a/Runtime/bbruntime_dll.cpp b/Runtime/bbruntime_dll.cpp index 4ddfce4..1b47a7f 100644 --- a/Runtime/bbruntime_dll.cpp +++ b/Runtime/bbruntime_dll.cpp @@ -1,8 +1,8 @@ #pragma warning( disable:4786 ) -#include "bbruntime_dll.h" -#include "../debugger/debugger.h" +#include "bbruntime_dll.hpp" +#include "../debugger/debugger.hpp" using namespace std; @@ -11,7 +11,7 @@ using namespace std; #include #include -#include "../RuntimeLib/bbruntime.h" +#include "bbruntime.hpp" class DummyDebugger : public Debugger{ public: diff --git a/Runtime/bbruntime_dll.h b/Runtime/bbruntime_dll.hpp similarity index 94% rename from Runtime/bbruntime_dll.h rename to Runtime/bbruntime_dll.hpp index 402d59e..bcf3e74 100644 --- a/Runtime/bbruntime_dll.h +++ b/Runtime/bbruntime_dll.hpp @@ -6,7 +6,7 @@ #include -#include "../stdutil/stdutil.h" +#include "stdutil.hpp" class Debugger; diff --git a/Runtime/bbruntime_dll.rc b/Runtime/bbruntime_dll.rc index d31b91b..705b97c 100644 --- a/Runtime/bbruntime_dll.rc +++ b/Runtime/bbruntime_dll.rc @@ -1,13 +1,13 @@ //Microsoft Developer Studio generated resource script. // -#include "resource.h" +#include "resource.hpp" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // -#include "afxres.h" +#include "afxres.hpp" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -34,7 +34,7 @@ END 2 TEXTINCLUDE DISCARDABLE BEGIN - "#include ""afxres.h""\r\n" + "#include ""afxres.hpp""\r\n" "\0" END diff --git a/Runtime/blitz3d/CMakeLists.txt b/Runtime/blitz3d/CMakeLists.txt new file mode 100644 index 0000000..f8b25de --- /dev/null +++ b/Runtime/blitz3d/CMakeLists.txt @@ -0,0 +1,138 @@ +project(runtime_blitz3d) + +add_library(${PROJECT_NAME} STATIC + "animation.cpp" + "animation.hpp" + "animator.cpp" + "animator.hpp" + "blitz3d.hpp" + "brush.cpp" + "brush.hpp" + "cachedtexture.cpp" + "cachedtexture.hpp" + "camera.cpp" + "camera.hpp" + "collision.cpp" + "collision.hpp" + "entity.cpp" + "entity.hpp" + "frustum.cpp" + "frustum.hpp" + "geom.cpp" + "geom.hpp" + "light.cpp" + "light.hpp" + "listener.cpp" + "listener.hpp" + "loader_3ds.cpp" + "loader_3ds.hpp" + "loader_b3d.cpp" + "loader_b3d.hpp" +# "loader_x.cpp" +# "loader_x.hpp" + "md2model.cpp" + "md2model.hpp" + "md2norms.cpp" + "md2norms.hpp" + "md2rep.cpp" + "md2rep.hpp" + "meshcollider.cpp" + "meshcollider.hpp" + "meshloader.cpp" + "meshloader.hpp" + "meshmodel.cpp" + "meshmodel.hpp" + "meshutil.cpp" + "meshutil.hpp" + "mirror.cpp" + "mirror.hpp" + "model.cpp" + "model.hpp" + "object.cpp" + "object.hpp" + "pivot.cpp" + "pivot.hpp" + "planemodel.cpp" + "planemodel.hpp" + "q3bspmodel.cpp" + "q3bspmodel.hpp" + "q3bsprep.cpp" + "q3bsprep.hpp" + "rendercontext.hpp" + "sprite.cpp" + "sprite.hpp" + "std.cpp" + "std.hpp" + "surface.cpp" + "surface.hpp" + "terrain.cpp" + "terrain.hpp" + "terrainrep.cpp" + "terrainrep.hpp" + "texture.cpp" + "texture.hpp" + "world.cpp" + "world.hpp" +) + +target_link_libraries(${PROJECT_NAME} + PRIVATE + config + gxruntime + stdutil + PUBLIC +) + +target_include_directories(${PROJECT_NAME} + PUBLIC ${PROJECT_SOURCE_DIR} +) + +if (WIN32) + target_compile_definitions(${PROJECT_NAME} + PRIVATE + _CRT_SECURE_NO_WARNINGS + # windows.h + WIN32_LEAN_AND_MEAN + NOGPICAPMASKS + NOVIRTUALKEYCODES + NOWINMESSAGES + NOWINSTYLES + NOSYSMETRICS + NOMENUS + NOICONS + NOKEYSTATES + NOSYSCOMMANDS + NORASTEROPS + NOSHOWWINDOW + NOATOM + NOCLIPBOARD + NOCOLOR + NOCTLMGR + NODRAWTEXT + #NOGDI + NOKERNEL + #NOUSER + NONLS + NOMB + NOMEMMGR + NOMETAFILE + NOMINMAX + #NOMSG + NOOPENFILE + NOSCROLL + NOSERVICE + NOSOUND + NOTEXTMETRIC + NOWH + NOWINOFFSETS + NOCOMM + NOKANJI + NOHELP + NOPROFILER + NODEFERWINDOWPOS + NOMCX + NOIME + NOMDI + NOINOUT + ) +endif() diff --git a/blitz3d/animation.cpp b/Runtime/blitz3d/animation.cpp similarity index 99% rename from blitz3d/animation.cpp rename to Runtime/blitz3d/animation.cpp index 4c761db..959f69b 100644 --- a/blitz3d/animation.cpp +++ b/Runtime/blitz3d/animation.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "animation.h" +#include "std.hpp" +#include "animation.hpp" struct Animation::Rep{ diff --git a/blitz3d/animation.h b/Runtime/blitz3d/animation.hpp similarity index 97% rename from blitz3d/animation.h rename to Runtime/blitz3d/animation.hpp index 8f2319b..39d61d6 100644 --- a/blitz3d/animation.h +++ b/Runtime/blitz3d/animation.hpp @@ -4,7 +4,7 @@ #include -#include "geom.h" +#include "geom.hpp" class Animation{ public: diff --git a/blitz3d/animator.cpp b/Runtime/blitz3d/animator.cpp similarity index 98% rename from blitz3d/animator.cpp rename to Runtime/blitz3d/animator.cpp index 0990f25..97db3ba 100644 --- a/blitz3d/animator.cpp +++ b/Runtime/blitz3d/animator.cpp @@ -1,7 +1,7 @@ -#include "std.h" -#include "animator.h" -#include "object.h" +#include "std.hpp" +#include "animator.hpp" +#include "object.hpp" Animator::Animator( Animator *t ):_seqs( t->_seqs ){ diff --git a/blitz3d/animator.h b/Runtime/blitz3d/animator.hpp similarity index 98% rename from blitz3d/animator.h rename to Runtime/blitz3d/animator.hpp index 3c23997..83a2df9 100644 --- a/blitz3d/animator.h +++ b/Runtime/blitz3d/animator.hpp @@ -2,7 +2,7 @@ #ifndef ANIMATOR_H #define ANIMATOR_H -#include "animation.h" +#include "animation.hpp" class Object; diff --git a/blitz3d/bd2model.cpp b/Runtime/blitz3d/bd2model.cpp similarity index 93% rename from blitz3d/bd2model.cpp rename to Runtime/blitz3d/bd2model.cpp index a322dbc..1598079 100644 --- a/blitz3d/bd2model.cpp +++ b/Runtime/blitz3d/bd2model.cpp @@ -1,5 +1,5 @@ -#include "bd2model.h" +#include "bd2model.hpp" struct BD2Vert{ unsigned char x,y,z,n,u,v; diff --git a/blitz3d/bd2model.h b/Runtime/blitz3d/bd2model.hpp similarity index 100% rename from blitz3d/bd2model.h rename to Runtime/blitz3d/bd2model.hpp diff --git a/blitz3d/blitz3d.h b/Runtime/blitz3d/blitz3d.hpp similarity index 100% rename from blitz3d/blitz3d.h rename to Runtime/blitz3d/blitz3d.hpp diff --git a/blitz3d/boxvis.cpp b/Runtime/blitz3d/boxvis.cpp similarity index 98% rename from blitz3d/boxvis.cpp rename to Runtime/blitz3d/boxvis.cpp index 29b6ece..9d384c2 100644 --- a/blitz3d/boxvis.cpp +++ b/Runtime/blitz3d/boxvis.cpp @@ -1,6 +1,7 @@ -#include "std.h" -#include "world.h" +#include "std.hpp" +#include "world.hpp" +#include static World *w; diff --git a/blitz3d/brush.cpp b/Runtime/blitz3d/brush.cpp similarity index 98% rename from blitz3d/brush.cpp rename to Runtime/blitz3d/brush.cpp index 27647e7..25418ea 100644 --- a/blitz3d/brush.cpp +++ b/Runtime/blitz3d/brush.cpp @@ -1,8 +1,8 @@ -#include "std.h" -#include "brush.h" +#include "std.hpp" +#include "brush.hpp" -#include "../gxruntime/gxgraphics.h" +#include "../gxruntime/gxgraphics.hpp" struct Brush::Rep{ union{ int ref_cnt;Rep *next; }; diff --git a/blitz3d/brush.h b/Runtime/blitz3d/brush.hpp similarity index 94% rename from blitz3d/brush.h rename to Runtime/blitz3d/brush.hpp index 7bbd6cc..b08c432 100644 --- a/blitz3d/brush.h +++ b/Runtime/blitz3d/brush.hpp @@ -2,8 +2,8 @@ #ifndef BRUSH_H #define BRUSH_H -#include "geom.h" -#include "texture.h" +#include "geom.hpp" +#include "texture.hpp" class Brush{ public: diff --git a/blitz3d/cachedtexture.cpp b/Runtime/blitz3d/cachedtexture.cpp similarity index 98% rename from blitz3d/cachedtexture.cpp rename to Runtime/blitz3d/cachedtexture.cpp index 88e02b3..6321545 100644 --- a/blitz3d/cachedtexture.cpp +++ b/Runtime/blitz3d/cachedtexture.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "cachedtexture.h" +#include "std.hpp" +#include "cachedtexture.hpp" int active_texs; diff --git a/blitz3d/cachedtexture.h b/Runtime/blitz3d/cachedtexture.hpp similarity index 95% rename from blitz3d/cachedtexture.h rename to Runtime/blitz3d/cachedtexture.hpp index 2241867..c111294 100644 --- a/blitz3d/cachedtexture.h +++ b/Runtime/blitz3d/cachedtexture.hpp @@ -2,7 +2,7 @@ #ifndef CACHEDTEXTURE_H #define CACHEDTEXTURE_H -#include "../gxruntime/gxcanvas.h" +#include "../gxruntime/gxcanvas.hpp" class CachedTextureFactory{ public: diff --git a/blitz3d/camera.cpp b/Runtime/blitz3d/camera.cpp similarity index 98% rename from blitz3d/camera.cpp rename to Runtime/blitz3d/camera.cpp index 672923c..19960d2 100644 --- a/blitz3d/camera.cpp +++ b/Runtime/blitz3d/camera.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "camera.h" +#include "std.hpp" +#include "camera.hpp" extern gxScene *gx_scene; diff --git a/blitz3d/camera.h b/Runtime/blitz3d/camera.hpp similarity index 94% rename from blitz3d/camera.h rename to Runtime/blitz3d/camera.hpp index 4da42fd..f4479a3 100644 --- a/blitz3d/camera.h +++ b/Runtime/blitz3d/camera.hpp @@ -2,9 +2,9 @@ #ifndef CAMERA_H #define CAMERA_H -#include "model.h" -#include "frustum.h" -#include "mirror.h" +#include "model.hpp" +#include "frustum.hpp" +#include "mirror.hpp" class Camera : public Object{ public: diff --git a/blitz3d/collision.cpp b/Runtime/blitz3d/collision.cpp similarity index 99% rename from blitz3d/collision.cpp rename to Runtime/blitz3d/collision.cpp index db48723..1d4a4ee 100644 --- a/blitz3d/collision.cpp +++ b/Runtime/blitz3d/collision.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "collision.h" +#include "std.hpp" +#include "collision.hpp" const float COLLISION_FLT_EPSILON=.001f; diff --git a/blitz3d/collision.h b/Runtime/blitz3d/collision.hpp similarity index 97% rename from blitz3d/collision.h rename to Runtime/blitz3d/collision.hpp index 36219f5..940e4b0 100644 --- a/blitz3d/collision.h +++ b/Runtime/blitz3d/collision.hpp @@ -2,7 +2,7 @@ #ifndef COLLISION_H #define COLLISION_H -#include "geom.h" +#include "geom.hpp" extern const float COLLISION_FLT_EPSILON; diff --git a/blitz3d/emitter.cpp b/Runtime/blitz3d/emitter.cpp similarity index 94% rename from blitz3d/emitter.cpp rename to Runtime/blitz3d/emitter.cpp index fc01f13..d9e72ff 100644 --- a/blitz3d/emitter.cpp +++ b/Runtime/blitz3d/emitter.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "emitter.h" +#include "std.hpp" +#include "emitter.hpp" Emitter::Emitter(){ } diff --git a/blitz3d/emitter.h b/Runtime/blitz3d/emitter.hpp similarity index 95% rename from blitz3d/emitter.h rename to Runtime/blitz3d/emitter.hpp index 87e02e3..0143a8e 100644 --- a/blitz3d/emitter.h +++ b/Runtime/blitz3d/emitter.hpp @@ -2,7 +2,7 @@ #ifndef EMITTER_H #define EMITTER_H -#include "object.h" +#include "object.hpp" class gxSound; class gxChannel; diff --git a/blitz3d/entity.cpp b/Runtime/blitz3d/entity.cpp similarity index 98% rename from blitz3d/entity.cpp rename to Runtime/blitz3d/entity.cpp index c28add9..fa64955 100644 --- a/blitz3d/entity.cpp +++ b/Runtime/blitz3d/entity.cpp @@ -1,8 +1,8 @@ -#include "std.h" -#include "entity.h" +#include "std.hpp" +#include "entity.hpp" -//#include "stats.h" +//#include "stats.hpp" Entity *Entity::_orphans, *Entity::_last_orphan; diff --git a/blitz3d/entity.h b/Runtime/blitz3d/entity.hpp similarity index 99% rename from blitz3d/entity.h rename to Runtime/blitz3d/entity.hpp index 2ea741f..08893da 100644 --- a/blitz3d/entity.h +++ b/Runtime/blitz3d/entity.hpp @@ -4,7 +4,7 @@ #include -#include "geom.h" +#include "geom.hpp" class Entity; class Object; diff --git a/RuntimeLib/runtime.cpp b/Runtime/blitz3d/entityutil.hpp similarity index 100% rename from RuntimeLib/runtime.cpp rename to Runtime/blitz3d/entityutil.hpp diff --git a/blitz3d/frustum.cpp b/Runtime/blitz3d/frustum.cpp similarity index 97% rename from blitz3d/frustum.cpp rename to Runtime/blitz3d/frustum.cpp index 5c33ace..0c8f44e 100644 --- a/blitz3d/frustum.cpp +++ b/Runtime/blitz3d/frustum.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "frustum.h" +#include "std.hpp" +#include "frustum.hpp" Frustum::Frustum(){ } diff --git a/blitz3d/frustum.h b/Runtime/blitz3d/frustum.hpp similarity index 97% rename from blitz3d/frustum.h rename to Runtime/blitz3d/frustum.hpp index 0ad808a..de98ed1 100644 --- a/blitz3d/frustum.h +++ b/Runtime/blitz3d/frustum.hpp @@ -2,7 +2,7 @@ #ifndef FRUSTUM_H #define FRUSTUM_H -#include "geom.h" +#include "geom.hpp" class Frustum{ public: diff --git a/blitz3d/geom.cpp b/Runtime/blitz3d/geom.cpp similarity index 92% rename from blitz3d/geom.cpp rename to Runtime/blitz3d/geom.cpp index 31b0049..9240dcd 100644 --- a/blitz3d/geom.cpp +++ b/Runtime/blitz3d/geom.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "geom.h" +#include "std.hpp" +#include "geom.hpp" Matrix Matrix::tmps[64]; Transform Transform::tmps[64]; diff --git a/blitz3d/geom.h b/Runtime/blitz3d/geom.hpp similarity index 100% rename from blitz3d/geom.h rename to Runtime/blitz3d/geom.hpp diff --git a/blitz3d/group.h b/Runtime/blitz3d/group.hpp similarity index 100% rename from blitz3d/group.h rename to Runtime/blitz3d/group.hpp diff --git a/blitz3d/light.cpp b/Runtime/blitz3d/light.cpp similarity index 88% rename from blitz3d/light.cpp rename to Runtime/blitz3d/light.cpp index 322849e..5f013d1 100644 --- a/blitz3d/light.cpp +++ b/Runtime/blitz3d/light.cpp @@ -1,7 +1,7 @@ -#include "std.h" -#include "light.h" -#include "../gxruntime/gxscene.h" +#include "std.hpp" +#include "light.hpp" +#include "../gxruntime/gxscene.hpp" extern gxScene *gx_scene; diff --git a/blitz3d/light.h b/Runtime/blitz3d/light.hpp similarity index 83% rename from blitz3d/light.h rename to Runtime/blitz3d/light.hpp index cf732ce..77f1f22 100644 --- a/blitz3d/light.h +++ b/Runtime/blitz3d/light.hpp @@ -2,9 +2,9 @@ #ifndef LIGHT_H #define LIGHT_H -#include "geom.h" -#include "object.h" -#include "../gxruntime/gxlight.h" +#include "geom.hpp" +#include "object.hpp" +#include "../gxruntime/gxlight.hpp" class World; diff --git a/blitz3d/listener.cpp b/Runtime/blitz3d/listener.cpp similarity index 94% rename from blitz3d/listener.cpp rename to Runtime/blitz3d/listener.cpp index c1a1000..1eca5c0 100644 --- a/blitz3d/listener.cpp +++ b/Runtime/blitz3d/listener.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "listener.h" +#include "std.hpp" +#include "listener.hpp" extern gxAudio *gx_audio; diff --git a/blitz3d/listener.h b/Runtime/blitz3d/listener.hpp similarity index 94% rename from blitz3d/listener.h rename to Runtime/blitz3d/listener.hpp index ec3b698..1562ac6 100644 --- a/blitz3d/listener.h +++ b/Runtime/blitz3d/listener.hpp @@ -2,7 +2,7 @@ #ifndef LISTENER_H #define LISTENER_H -#include "object.h" +#include "object.hpp" class Listener : public Object{ public: diff --git a/blitz3d/loader.cpp b/Runtime/blitz3d/loader.cpp similarity index 96% rename from blitz3d/loader.cpp rename to Runtime/blitz3d/loader.cpp index 849e51e..6f5e9f4 100644 --- a/blitz3d/loader.cpp +++ b/Runtime/blitz3d/loader.cpp @@ -1,7 +1,7 @@ -#include "std.h" -#include "meshloader.h" -#include "meshmodel.h" +#include "std.hpp" +#include "meshloader.hpp" +#include "meshmodel.hpp" struct Surf{ vector tris; diff --git a/blitz3d/entityutil.h b/Runtime/blitz3d/loader.hpp similarity index 100% rename from blitz3d/entityutil.h rename to Runtime/blitz3d/loader.hpp diff --git a/blitz3d/loader_3ds.cpp b/Runtime/blitz3d/loader_3ds.cpp similarity index 99% rename from blitz3d/loader_3ds.cpp rename to Runtime/blitz3d/loader_3ds.cpp index ad89fd9..88f7898 100644 --- a/blitz3d/loader_3ds.cpp +++ b/Runtime/blitz3d/loader_3ds.cpp @@ -1,8 +1,8 @@ -#include "std.h" -#include "loader_3ds.h" -#include "meshmodel.h" -#include "animation.h" +#include "std.hpp" +#include "loader_3ds.hpp" +#include "meshmodel.hpp" +#include "animation.hpp" extern gxRuntime *gx_runtime; diff --git a/blitz3d/loader_3ds.h b/Runtime/blitz3d/loader_3ds.hpp similarity index 86% rename from blitz3d/loader_3ds.h rename to Runtime/blitz3d/loader_3ds.hpp index 91e617f..4307c22 100644 --- a/blitz3d/loader_3ds.h +++ b/Runtime/blitz3d/loader_3ds.hpp @@ -2,7 +2,7 @@ #ifndef LOADER_3DS_H #define LOADER_3DS_H -#include "meshloader.h" +#include "meshloader.hpp" class Loader_3DS : public MeshLoader{ public: diff --git a/blitz3d/loader_b3d.cpp b/Runtime/blitz3d/loader_b3d.cpp similarity index 98% rename from blitz3d/loader_b3d.cpp rename to Runtime/blitz3d/loader_b3d.cpp index 39ca961..bdcd426 100644 --- a/blitz3d/loader_b3d.cpp +++ b/Runtime/blitz3d/loader_b3d.cpp @@ -1,9 +1,9 @@ -#include "std.h" -#include "loader_b3d.h" -#include "meshmodel.h" -#include "pivot.h" -#include "meshutil.h" +#include "std.hpp" +#include "loader_b3d.hpp" +#include "meshmodel.hpp" +#include "pivot.hpp" +#include "meshutil.hpp" //#define SHOW_BONES diff --git a/blitz3d/loader_b3d.h b/Runtime/blitz3d/loader_b3d.hpp similarity index 86% rename from blitz3d/loader_b3d.h rename to Runtime/blitz3d/loader_b3d.hpp index 65675c7..564bd34 100644 --- a/blitz3d/loader_b3d.h +++ b/Runtime/blitz3d/loader_b3d.hpp @@ -2,7 +2,7 @@ #ifndef LOADER_B3D_H #define LOADER_B3D_H -#include "meshloader.h" +#include "meshloader.hpp" class Loader_B3D : public MeshLoader{ public: diff --git a/blitz3d/loader_x.cpp b/Runtime/blitz3d/loader_x.cpp similarity index 98% rename from blitz3d/loader_x.cpp rename to Runtime/blitz3d/loader_x.cpp index f0ef651..d4647e0 100644 --- a/blitz3d/loader_x.cpp +++ b/Runtime/blitz3d/loader_x.cpp @@ -1,13 +1,13 @@ -#include "std.h" -#include "loader_x.h" -#include "meshmodel.h" -#include "animation.h" -#include "pivot.h" +#include "std.hpp" +#include "loader_x.hpp" +#include "meshmodel.hpp" +#include "animation.hpp" +#include "pivot.hpp" #include //#include -#include "../gxruntime/GraphicsRuntime.h" +#include "../gxruntime/GraphicsRuntime.hpp" #include #include #include diff --git a/blitz3d/loader_x.h b/Runtime/blitz3d/loader_x.hpp similarity index 86% rename from blitz3d/loader_x.h rename to Runtime/blitz3d/loader_x.hpp index 11a212b..9e8dfed 100644 --- a/blitz3d/loader_x.h +++ b/Runtime/blitz3d/loader_x.hpp @@ -2,7 +2,7 @@ #ifndef LOADER_X_H #define LOADER_X_H -#include "meshloader.h" +#include "meshloader.hpp" class Loader_X : public MeshLoader{ public: diff --git a/blitz3d/md2model.cpp b/Runtime/blitz3d/md2model.cpp similarity index 97% rename from blitz3d/md2model.cpp rename to Runtime/blitz3d/md2model.cpp index 72bc148..a73b275 100644 --- a/blitz3d/md2model.cpp +++ b/Runtime/blitz3d/md2model.cpp @@ -1,7 +1,7 @@ -#include "std.h" -#include "md2rep.h" -#include "md2model.h" +#include "std.hpp" +#include "md2rep.hpp" +#include "md2model.hpp" struct MD2Model::Rep : public MD2Rep{ int ref_cnt; diff --git a/blitz3d/md2model.h b/Runtime/blitz3d/md2model.hpp similarity index 95% rename from blitz3d/md2model.h rename to Runtime/blitz3d/md2model.hpp index 7f3b158..6e5621c 100644 --- a/blitz3d/md2model.h +++ b/Runtime/blitz3d/md2model.hpp @@ -2,8 +2,8 @@ #ifndef MD2MODEL_H #define MD2MODEL_H -#include "model.h" -#include "md2rep.h" +#include "model.hpp" +#include "md2rep.hpp" class MD2Model : public Model{ public: diff --git a/blitz3d/md2model_bak.cpp b/Runtime/blitz3d/md2model_bak.cpp similarity index 100% rename from blitz3d/md2model_bak.cpp rename to Runtime/blitz3d/md2model_bak.cpp diff --git a/blitz3d/md2norms.cpp b/Runtime/blitz3d/md2norms.cpp similarity index 99% rename from blitz3d/md2norms.cpp rename to Runtime/blitz3d/md2norms.cpp index ec36ce3..f81e493 100644 --- a/blitz3d/md2norms.cpp +++ b/Runtime/blitz3d/md2norms.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "md2norms.h" +#include "std.hpp" +#include "md2norms.hpp" float md2norms[162][3]={ {-0.525731f, 0.000000f, 0.850651f}, diff --git a/blitz3d/md2norms.h b/Runtime/blitz3d/md2norms.hpp similarity index 100% rename from blitz3d/md2norms.h rename to Runtime/blitz3d/md2norms.hpp diff --git a/blitz3d/md2rep.cpp b/Runtime/blitz3d/md2rep.cpp similarity index 99% rename from blitz3d/md2rep.cpp rename to Runtime/blitz3d/md2rep.cpp index 1cd8255..f623b58 100644 --- a/blitz3d/md2rep.cpp +++ b/Runtime/blitz3d/md2rep.cpp @@ -1,7 +1,7 @@ -#include "std.h" -#include "md2rep.h" -#include "md2norms.h" +#include "std.hpp" +#include "md2rep.hpp" +#include "md2norms.hpp" extern gxRuntime *gx_runtime; extern gxGraphics *gx_graphics; diff --git a/blitz3d/md2rep.h b/Runtime/blitz3d/md2rep.hpp similarity index 97% rename from blitz3d/md2rep.h rename to Runtime/blitz3d/md2rep.hpp index 9de334c..128671f 100644 --- a/blitz3d/md2rep.h +++ b/Runtime/blitz3d/md2rep.hpp @@ -2,7 +2,7 @@ #ifndef MD2REP_H #define MD2REP_H -#include "model.h" +#include "model.hpp" class MD2Rep{ public: diff --git a/blitz3d/mesh.h b/Runtime/blitz3d/mesh.hpp similarity index 100% rename from blitz3d/mesh.h rename to Runtime/blitz3d/mesh.hpp diff --git a/blitz3d/meshcollider.cpp b/Runtime/blitz3d/meshcollider.cpp similarity index 99% rename from blitz3d/meshcollider.cpp rename to Runtime/blitz3d/meshcollider.cpp index df39c8e..431a56d 100644 --- a/blitz3d/meshcollider.cpp +++ b/Runtime/blitz3d/meshcollider.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "meshcollider.h" +#include "std.hpp" +#include "meshcollider.hpp" static const int MAX_COLL_TRIS=16; static vector tri_centres; diff --git a/blitz3d/meshcollider.h b/Runtime/blitz3d/meshcollider.hpp similarity index 97% rename from blitz3d/meshcollider.h rename to Runtime/blitz3d/meshcollider.hpp index 349700c..9cf3912 100644 --- a/blitz3d/meshcollider.h +++ b/Runtime/blitz3d/meshcollider.hpp @@ -2,7 +2,7 @@ #ifndef MESHCOLLIDER_H #define MESHCOLLIDER_H -#include "collision.h" +#include "collision.hpp" class MeshCollider{ public: diff --git a/blitz3d/meshloader.cpp b/Runtime/blitz3d/meshloader.cpp similarity index 97% rename from blitz3d/meshloader.cpp rename to Runtime/blitz3d/meshloader.cpp index 9c90b31..aa14f16 100644 --- a/blitz3d/meshloader.cpp +++ b/Runtime/blitz3d/meshloader.cpp @@ -1,7 +1,7 @@ -#include "std.h" -#include "meshloader.h" -#include "meshmodel.h" +#include "std.hpp" +#include "meshloader.hpp" +#include "meshmodel.hpp" struct Tri{ int verts[3]; diff --git a/blitz3d/meshloader.h b/Runtime/blitz3d/meshloader.hpp similarity index 94% rename from blitz3d/meshloader.h rename to Runtime/blitz3d/meshloader.hpp index 35ea429..1a4423b 100644 --- a/blitz3d/meshloader.h +++ b/Runtime/blitz3d/meshloader.hpp @@ -2,8 +2,8 @@ #ifndef MESHLOADER_H #define MESHLOADER_H -#include "model.h" -#include "surface.h" +#include "model.hpp" +#include "surface.hpp" class MeshLoader{ public: diff --git a/blitz3d/meshmodel.cpp b/Runtime/blitz3d/meshmodel.cpp similarity index 99% rename from blitz3d/meshmodel.cpp rename to Runtime/blitz3d/meshmodel.cpp index a1b4112..89e6c92 100644 --- a/blitz3d/meshmodel.cpp +++ b/Runtime/blitz3d/meshmodel.cpp @@ -1,7 +1,7 @@ -#include "std.h" -#include "meshmodel.h" -#include "meshcollider.h" +#include "std.hpp" +#include "meshmodel.hpp" +#include "meshcollider.hpp" extern gxGraphics *gx_graphics; diff --git a/blitz3d/meshmodel.h b/Runtime/blitz3d/meshmodel.hpp similarity index 96% rename from blitz3d/meshmodel.h rename to Runtime/blitz3d/meshmodel.hpp index b064d3b..a4ba775 100644 --- a/blitz3d/meshmodel.h +++ b/Runtime/blitz3d/meshmodel.hpp @@ -2,8 +2,8 @@ #ifndef MESHMODEL_H #define MESHMODEL_H -#include "model.h" -#include "surface.h" +#include "model.hpp" +#include "surface.hpp" class MeshCollider; diff --git a/blitz3d/meshrenderer.h b/Runtime/blitz3d/meshrenderer.hpp similarity index 88% rename from blitz3d/meshrenderer.h rename to Runtime/blitz3d/meshrenderer.hpp index f2ebdd8..8dbc58b 100644 --- a/blitz3d/meshrenderer.h +++ b/Runtime/blitz3d/meshrenderer.hpp @@ -2,8 +2,8 @@ #ifndef MESHRENDERER_H #define MESHRENDERER_H -#include "mesh.h" -#include "model.h" +#include "mesh.hpp" +#include "model.hpp" class MeshRenderer{ public: diff --git a/blitz3d/meshutil.cpp b/Runtime/blitz3d/meshutil.cpp similarity index 99% rename from blitz3d/meshutil.cpp rename to Runtime/blitz3d/meshutil.cpp index 7a1686f..c7dc4f1 100644 --- a/blitz3d/meshutil.cpp +++ b/Runtime/blitz3d/meshutil.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "meshutil.h" +#include "std.hpp" +#include "meshutil.hpp" MeshModel *MeshUtil::createCube( const Brush &b ){ static Vector norms[]={ diff --git a/blitz3d/meshutil.h b/Runtime/blitz3d/meshutil.hpp similarity index 97% rename from blitz3d/meshutil.h rename to Runtime/blitz3d/meshutil.hpp index 48bec5f..0ebda71 100644 --- a/blitz3d/meshutil.h +++ b/Runtime/blitz3d/meshutil.hpp @@ -2,7 +2,7 @@ #ifndef MESHUTIL_H #define MESHUTIL_H -#include "meshmodel.h" +#include "meshmodel.hpp" struct MeshUtil{ diff --git a/blitz3d/mirror.cpp b/Runtime/blitz3d/mirror.cpp similarity index 69% rename from blitz3d/mirror.cpp rename to Runtime/blitz3d/mirror.cpp index 9b9f2b4..9aa46b0 100644 --- a/blitz3d/mirror.cpp +++ b/Runtime/blitz3d/mirror.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "mirror.h" +#include "std.hpp" +#include "mirror.hpp" Mirror::Mirror(){ } diff --git a/blitz3d/mirror.h b/Runtime/blitz3d/mirror.hpp similarity index 91% rename from blitz3d/mirror.h rename to Runtime/blitz3d/mirror.hpp index ce876a2..cc3f06d 100644 --- a/blitz3d/mirror.h +++ b/Runtime/blitz3d/mirror.hpp @@ -2,7 +2,7 @@ #ifndef MIRROR_H #define MIRROR_H -#include "object.h" +#include "object.hpp" class Mirror : public Object{ public: diff --git a/blitz3d/model.cpp b/Runtime/blitz3d/model.cpp similarity index 98% rename from blitz3d/model.cpp rename to Runtime/blitz3d/model.cpp index ce0305a..74fe4bd 100644 --- a/blitz3d/model.cpp +++ b/Runtime/blitz3d/model.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "model.h" +#include "std.hpp" +#include "model.hpp" extern gxScene *gx_scene; diff --git a/blitz3d/model.h b/Runtime/blitz3d/model.hpp similarity index 96% rename from blitz3d/model.h rename to Runtime/blitz3d/model.hpp index 904e4a5..bff3a08 100644 --- a/blitz3d/model.h +++ b/Runtime/blitz3d/model.hpp @@ -2,9 +2,9 @@ #ifndef MODEL_H #define MODEL_H -#include "brush.h" -#include "object.h" -#include "rendercontext.h" +#include "brush.hpp" +#include "object.hpp" +#include "rendercontext.hpp" class Sprite; class Terrain; diff --git a/blitz3d/ms3drep.cpp b/Runtime/blitz3d/ms3drep.cpp similarity index 100% rename from blitz3d/ms3drep.cpp rename to Runtime/blitz3d/ms3drep.cpp diff --git a/blitz3d/loader.h b/Runtime/blitz3d/ms3drep.hpp similarity index 100% rename from blitz3d/loader.h rename to Runtime/blitz3d/ms3drep.hpp diff --git a/blitz3d/object.cpp b/Runtime/blitz3d/object.cpp similarity index 98% rename from blitz3d/object.cpp rename to Runtime/blitz3d/object.cpp index 6b4c526..d99e8f2 100644 --- a/blitz3d/object.cpp +++ b/Runtime/blitz3d/object.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "object.h" +#include "std.hpp" +#include "object.hpp" extern gxRuntime *gx_runtime; diff --git a/blitz3d/object.h b/Runtime/blitz3d/object.hpp similarity index 96% rename from blitz3d/object.h rename to Runtime/blitz3d/object.hpp index a6d58f6..5840b55 100644 --- a/blitz3d/object.h +++ b/Runtime/blitz3d/object.hpp @@ -4,9 +4,9 @@ #include -#include "entity.h" -#include "animator.h" -#include "collision.h" +#include "entity.hpp" +#include "animator.hpp" +#include "collision.hpp" class gxSound; diff --git a/blitz3d/pivot.cpp b/Runtime/blitz3d/pivot.cpp similarity index 62% rename from blitz3d/pivot.cpp rename to Runtime/blitz3d/pivot.cpp index 5cd7834..77e5497 100644 --- a/blitz3d/pivot.cpp +++ b/Runtime/blitz3d/pivot.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "pivot.h" +#include "std.hpp" +#include "pivot.hpp" Pivot::Pivot(){ } diff --git a/blitz3d/pivot.h b/Runtime/blitz3d/pivot.hpp similarity index 89% rename from blitz3d/pivot.h rename to Runtime/blitz3d/pivot.hpp index e4f8fa5..c464e01 100644 --- a/blitz3d/pivot.h +++ b/Runtime/blitz3d/pivot.hpp @@ -2,7 +2,7 @@ #ifndef PIVOT_H #define PIVOT_H -#include "object.h" +#include "object.hpp" class Pivot : public Object{ public: diff --git a/blitz3d/planemodel.cpp b/Runtime/blitz3d/planemodel.cpp similarity index 97% rename from blitz3d/planemodel.cpp rename to Runtime/blitz3d/planemodel.cpp index 78f8b06..d2fd451 100644 --- a/blitz3d/planemodel.cpp +++ b/Runtime/blitz3d/planemodel.cpp @@ -1,8 +1,8 @@ -#include "std.h" -#include "planemodel.h" -#include "frustum.h" -#include "camera.h" +#include "std.hpp" +#include "planemodel.hpp" +#include "frustum.hpp" +#include "camera.hpp" static Vector vts[17][17]; diff --git a/blitz3d/planemodel.h b/Runtime/blitz3d/planemodel.hpp similarity index 92% rename from blitz3d/planemodel.h rename to Runtime/blitz3d/planemodel.hpp index 73f6485..3e37843 100644 --- a/blitz3d/planemodel.h +++ b/Runtime/blitz3d/planemodel.hpp @@ -2,8 +2,8 @@ #ifndef PLANEMODEL_H #define PLANEMODEL_H -#include "model.h" -#include "brush.h" +#include "model.hpp" +#include "brush.hpp" class PlaneModel : public Model{ public: diff --git a/blitz3d/q3bspmodel.cpp b/Runtime/blitz3d/q3bspmodel.cpp similarity index 92% rename from blitz3d/q3bspmodel.cpp rename to Runtime/blitz3d/q3bspmodel.cpp index e36bc84..3e6fe77 100644 --- a/blitz3d/q3bspmodel.cpp +++ b/Runtime/blitz3d/q3bspmodel.cpp @@ -1,7 +1,7 @@ -#include "std.h" -#include "q3bspmodel.h" -#include "q3bsprep.h" +#include "std.hpp" +#include "q3bspmodel.hpp" +#include "q3bsprep.hpp" struct Q3BSPModel::Rep : public Q3BSPRep{ int ref_cnt; diff --git a/blitz3d/q3bspmodel.h b/Runtime/blitz3d/q3bspmodel.hpp similarity index 96% rename from blitz3d/q3bspmodel.h rename to Runtime/blitz3d/q3bspmodel.hpp index 7b85d96..d77e1cf 100644 --- a/blitz3d/q3bspmodel.h +++ b/Runtime/blitz3d/q3bspmodel.hpp @@ -2,7 +2,7 @@ #ifndef Q3BSPMODEL_H #define Q3BSPMODEL_H -#include "model.h" +#include "model.hpp" class Q3BSPModel : public Model{ public: diff --git a/blitz3d/q3bsprep.cpp b/Runtime/blitz3d/q3bsprep.cpp similarity index 99% rename from blitz3d/q3bsprep.cpp rename to Runtime/blitz3d/q3bsprep.cpp index f1ba436..becc207 100644 --- a/blitz3d/q3bsprep.cpp +++ b/Runtime/blitz3d/q3bsprep.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "q3bsprep.h" +#include "std.hpp" +#include "q3bsprep.hpp" /* Quake3 File format types */ diff --git a/blitz3d/q3bsprep.h b/Runtime/blitz3d/q3bsprep.hpp similarity index 95% rename from blitz3d/q3bsprep.h rename to Runtime/blitz3d/q3bsprep.hpp index 7d58abe..dbf06b3 100644 --- a/blitz3d/q3bsprep.h +++ b/Runtime/blitz3d/q3bsprep.hpp @@ -2,8 +2,8 @@ #ifndef Q3BSPREP_H #define Q3BSPREP_H -#include "model.h" -#include "meshcollider.h" +#include "model.hpp" +#include "meshcollider.hpp" struct Q3BSPSurf; struct Q3BSPFace; diff --git a/blitz3d/rendercontext.h b/Runtime/blitz3d/rendercontext.hpp similarity index 96% rename from blitz3d/rendercontext.h rename to Runtime/blitz3d/rendercontext.hpp index d821549..080ee64 100644 --- a/blitz3d/rendercontext.h +++ b/Runtime/blitz3d/rendercontext.hpp @@ -2,7 +2,7 @@ #ifndef RENDERCONTEXT_H #define RENDERCONTEXT_H -#include "frustum.h" +#include "frustum.hpp" class RenderContext{ public: diff --git a/blitz3d/skinmodel.cpp b/Runtime/blitz3d/skinmodel.cpp similarity index 93% rename from blitz3d/skinmodel.cpp rename to Runtime/blitz3d/skinmodel.cpp index 93f30c8..9f980e0 100644 --- a/blitz3d/skinmodel.cpp +++ b/Runtime/blitz3d/skinmodel.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "skinmodel.h" +#include "std.hpp" +#include "skinmodel.hpp" SkinModel::SkinModel(){ setRenderSpace( RENDER_SPACE_WORLD ); diff --git a/blitz3d/skinmodel.h b/Runtime/blitz3d/skinmodel.hpp similarity index 92% rename from blitz3d/skinmodel.h rename to Runtime/blitz3d/skinmodel.hpp index c52f58f..4f4c915 100644 --- a/blitz3d/skinmodel.h +++ b/Runtime/blitz3d/skinmodel.hpp @@ -2,7 +2,7 @@ #ifndef SKINMODEL_H #define SKINMODEL_H -#include "meshmodel.h" +#include "meshmodel.hpp" class SkinModel : public MeshModel{ vector _bones; diff --git a/blitz3d/sprite.cpp b/Runtime/blitz3d/sprite.cpp similarity index 98% rename from blitz3d/sprite.cpp rename to Runtime/blitz3d/sprite.cpp index 0cc1c5f..51738c8 100644 --- a/blitz3d/sprite.cpp +++ b/Runtime/blitz3d/sprite.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "sprite.h" +#include "std.hpp" +#include "sprite.hpp" extern float stats3d[]; diff --git a/blitz3d/sprite.h b/Runtime/blitz3d/sprite.hpp similarity index 91% rename from blitz3d/sprite.h rename to Runtime/blitz3d/sprite.hpp index 879ec9f..a424df5 100644 --- a/blitz3d/sprite.h +++ b/Runtime/blitz3d/sprite.hpp @@ -2,9 +2,9 @@ #ifndef SPRITE_H #define SPRITE_H -#include "model.h" -#include "brush.h" -#include "../gxruntime/gxmesh.h" +#include "model.hpp" +#include "brush.hpp" +#include "../gxruntime/gxmesh.hpp" class Sprite : public Model{ public: diff --git a/Runtime/blitz3d/std.cpp b/Runtime/blitz3d/std.cpp new file mode 100644 index 0000000..d5f561b --- /dev/null +++ b/Runtime/blitz3d/std.cpp @@ -0,0 +1,2 @@ + +#include "std.hpp" diff --git a/blitz3d/std.h b/Runtime/blitz3d/std.hpp similarity index 66% rename from blitz3d/std.h rename to Runtime/blitz3d/std.hpp index f744f4c..bf52761 100644 --- a/blitz3d/std.h +++ b/Runtime/blitz3d/std.hpp @@ -4,9 +4,9 @@ #pragma warning( disable:4786 ) -#include "../config/config.h" -#include "../stdutil/stdutil.h" -#include "../gxruntime/gxruntime.h" +#include "config.hpp" +#include "stdutil.hpp" +#include "gxruntime.hpp" #include #include diff --git a/blitz3d/surface.cpp b/Runtime/blitz3d/surface.cpp similarity index 99% rename from blitz3d/surface.cpp rename to Runtime/blitz3d/surface.cpp index 292f127..0a3434b 100644 --- a/blitz3d/surface.cpp +++ b/Runtime/blitz3d/surface.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "surface.h" +#include "std.hpp" +#include "surface.hpp" extern gxGraphics *gx_graphics; diff --git a/blitz3d/surface.h b/Runtime/blitz3d/surface.hpp similarity index 99% rename from blitz3d/surface.h rename to Runtime/blitz3d/surface.hpp index c7197f0..43a5804 100644 --- a/blitz3d/surface.h +++ b/Runtime/blitz3d/surface.hpp @@ -2,7 +2,7 @@ #ifndef SURFACE_H #define SURFACE_H -#include "model.h" +#include "model.hpp" #define MAX_SURFACE_BONES 4 diff --git a/blitz3d/terrain.cpp b/Runtime/blitz3d/terrain.cpp similarity index 92% rename from blitz3d/terrain.cpp rename to Runtime/blitz3d/terrain.cpp index a77f64c..23b7285 100644 --- a/blitz3d/terrain.cpp +++ b/Runtime/blitz3d/terrain.cpp @@ -1,7 +1,7 @@ -#include "std.h" -#include "terrain.h" -#include "terrainrep.h" +#include "std.hpp" +#include "terrain.hpp" +#include "terrainrep.hpp" Terrain::Terrain( int size_shift ): rep( new TerrainRep( size_shift ) ){ diff --git a/blitz3d/terrain.h b/Runtime/blitz3d/terrain.hpp similarity index 96% rename from blitz3d/terrain.h rename to Runtime/blitz3d/terrain.hpp index 4b194d1..7838b70 100644 --- a/blitz3d/terrain.h +++ b/Runtime/blitz3d/terrain.hpp @@ -2,7 +2,7 @@ #ifndef TERRAIN_H #define TERRAIN_H -#include "model.h" +#include "model.hpp" struct TerrainRep; diff --git a/blitz3d/ms3drep.h b/Runtime/blitz3d/terrainmodel.hpp similarity index 100% rename from blitz3d/ms3drep.h rename to Runtime/blitz3d/terrainmodel.hpp diff --git a/blitz3d/terrainrep.cpp b/Runtime/blitz3d/terrainrep.cpp similarity index 99% rename from blitz3d/terrainrep.cpp rename to Runtime/blitz3d/terrainrep.cpp index f2a8840..7603414 100644 --- a/blitz3d/terrainrep.cpp +++ b/Runtime/blitz3d/terrainrep.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "terrainrep.h" +#include "std.hpp" +#include "terrainrep.hpp" #include extern gxRuntime *gx_runtime; diff --git a/blitz3d/terrainrep.h b/Runtime/blitz3d/terrainrep.hpp similarity index 98% rename from blitz3d/terrainrep.h rename to Runtime/blitz3d/terrainrep.hpp index 01b261b..2e89777 100644 --- a/blitz3d/terrainrep.h +++ b/Runtime/blitz3d/terrainrep.hpp @@ -4,7 +4,7 @@ #include -#include "model.h" +#include "model.hpp" struct TerrainRep{ public: diff --git a/blitz3d/texture.cpp b/Runtime/blitz3d/texture.cpp similarity index 97% rename from blitz3d/texture.cpp rename to Runtime/blitz3d/texture.cpp index 2ba1c7b..46b1eac 100644 --- a/blitz3d/texture.cpp +++ b/Runtime/blitz3d/texture.cpp @@ -1,10 +1,10 @@ -#include "std.h" -#include "geom.h" -#include "texture.h" -#include "cachedtexture.h" +#include "std.hpp" +#include "geom.hpp" +#include "texture.hpp" +#include "cachedtexture.hpp" -#include "../gxruntime/gxgraphics.h" +#include "../gxruntime/gxgraphics.hpp" extern gxScene *gx_scene; extern gxGraphics *gx_graphics; diff --git a/blitz3d/texture.h b/Runtime/blitz3d/texture.hpp similarity index 93% rename from blitz3d/texture.h rename to Runtime/blitz3d/texture.hpp index 8aeed77..2c67941 100644 --- a/blitz3d/texture.h +++ b/Runtime/blitz3d/texture.hpp @@ -4,9 +4,9 @@ #include -#include "cachedtexture.h" +#include "cachedtexture.hpp" -#include "../gxruntime/gxcanvas.h" +#include "../gxruntime/gxcanvas.hpp" class Texture{ public: diff --git a/blitz3d/terrainmodel.h b/Runtime/blitz3d/texturecache.hpp similarity index 100% rename from blitz3d/terrainmodel.h rename to Runtime/blitz3d/texturecache.hpp diff --git a/blitz3d/users_guide.txt b/Runtime/blitz3d/users_guide.txt similarity index 100% rename from blitz3d/users_guide.txt rename to Runtime/blitz3d/users_guide.txt diff --git a/blitz3d/world.cpp b/Runtime/blitz3d/world.cpp similarity index 99% rename from blitz3d/world.cpp rename to Runtime/blitz3d/world.cpp index 24ca42d..194a297 100644 --- a/blitz3d/world.cpp +++ b/Runtime/blitz3d/world.cpp @@ -1,7 +1,7 @@ -#include "std.h" +#include "std.hpp" #include -#include "world.h" +#include "world.hpp" //0=tris compared for collision //1=max proj err of terrain diff --git a/blitz3d/world.h b/Runtime/blitz3d/world.hpp similarity index 91% rename from blitz3d/world.h rename to Runtime/blitz3d/world.hpp index 4236c0f..996a9a9 100644 --- a/blitz3d/world.h +++ b/Runtime/blitz3d/world.hpp @@ -4,11 +4,11 @@ #include -#include "model.h" -#include "camera.h" -#include "light.h" -#include "mirror.h" -#include "listener.h" +#include "model.hpp" +#include "camera.hpp" +#include "light.hpp" +#include "mirror.hpp" +#include "listener.hpp" #define WORLD_COLLISION_TYPES 16 #define WORLD_COLLISION_HITS 4 diff --git a/Runtime/lib/CMakeLists.txt b/Runtime/lib/CMakeLists.txt new file mode 100644 index 0000000..49d4175 --- /dev/null +++ b/Runtime/lib/CMakeLists.txt @@ -0,0 +1,104 @@ +project(runtime_lib) + +add_library(${PROJECT_NAME} STATIC + "basic.cpp" + "basic.hpp" + "bb_basic.hpp" + "bbaudio.cpp" + "bbaudio.hpp" + "bbbank.cpp" + "bbbank.hpp" + "bbblitz3d.cpp" + "bbblitz3d.hpp" + "bbfilesystem.cpp" + "bbfilesystem.hpp" + "bbgraphics.cpp" + "bbgraphics.hpp" + "bbinput.cpp" + "bbinput.hpp" + "bbmath.cpp" + "bbmath.hpp" + "bbruntime.cpp" + "bbruntime.hpp" + "bbstring.cpp" + "bbstring.hpp" + "bbsys.cpp" + "bbsys.hpp" +# "multiplay.cpp" +# "multiplay.hpp" +# "multiplay_setup.cpp" +# "multiplay_setup.hpp" +# "multiplay_setup.rc" + "resource.hpp" + "runtime.cpp" + "std.cpp" + "std.hpp" + "userlib.cpp" + "userlib.hpp" + "userlibs.cpp" + "userlibs.hpp" +) + +target_link_libraries(${PROJECT_NAME} + PUBLIC + stdutil + gxruntime + ddraw + dsound + dxguid +) + +target_include_directories(${PROJECT_NAME} + PUBLIC ${PROJECT_SOURCE_DIR} +) + + +if (WIN32) + target_compile_definitions(${PROJECT_NAME} + PRIVATE + _CRT_SECURE_NO_WARNINGS + # windows.h + WIN32_LEAN_AND_MEAN + NOGPICAPMASKS + NOVIRTUALKEYCODES + #NOWINMESSAGES + NOWINSTYLES + NOSYSMETRICS + NOMENUS + NOICONS + NOKEYSTATES + NOSYSCOMMANDS + NORASTEROPS + NOSHOWWINDOW + NOATOM + NOCLIPBOARD + NOCOLOR + NOCTLMGR + NODRAWTEXT + #NOGDI + NOKERNEL + #NOUSER + #NONLS + NOMB + NOMEMMGR + NOMETAFILE + NOMINMAX + #NOMSG + NOOPENFILE + NOSCROLL + NOSERVICE + NOSOUND + #NOTEXTMETRIC + NOWH + NOWINOFFSETS + NOCOMM + NOKANJI + NOHELP + NOPROFILER + NODEFERWINDOWPOS + NOMCX + NOIME + NOMDI + NOINOUT + ) +endif() diff --git a/RuntimeLib/basic.cpp b/Runtime/lib/basic.cpp similarity index 95% rename from RuntimeLib/basic.cpp rename to Runtime/lib/basic.cpp index 6bd79f9..270f566 100644 --- a/RuntimeLib/basic.cpp +++ b/Runtime/lib/basic.cpp @@ -1,593 +1,593 @@ -#include "std.h" -#include "bbsys.h" - -//how many strings allocated -static int stringCnt; - -//how many objects new'd but not deleted -static int objCnt; - -//how many objects deleted but not released -static int unrelObjCnt; - -//how many objects to alloc per block -static const int OBJ_NEW_INC = 512; - -//how many strings to alloc per block -static const int STR_NEW_INC = 512; - -//current data ptr -static BBData *dataPtr; - -//chunks of mem - WHAT THE FUCK WAS I ON?!?!?!? -//static list memBlks; - -//strings -static BBStr usedStrs, freeStrs; - -//object handle number -static int next_handle; - -//object<->handle maps -static map handle_map; -static map object_map; - -static BBType _bbIntType(BBTYPE_INT); -static BBType _bbFltType(BBTYPE_FLT); -static BBType _bbStrType(BBTYPE_STR); -static BBType _bbCStrType(BBTYPE_CSTR); - -static void *bbMalloc(int size) { - return malloc(size); - /* - char *c=new char[ size ]; - memBlks.push_back( c ); - return c; - */ -} - -static void bbFree(void *q) { - free(q); - /* - if( !q ) return; - char *c=(char*)q; - memBlks.remove( c ); - delete [] c; - */ -} - -static void removeStr(BBStr *str) { - str->next->prev = str->prev; - str->prev->next = str->next; -} - -static void insertStr(BBStr *str, BBStr *next) { - str->next = next; - str->prev = next->prev; - str->prev->next = str; - next->prev = str; -} - -void *BBStr::operator new(size_t size) { - if (freeStrs.next == &freeStrs) { - BBStr *t = (BBStr*)bbMalloc(sizeof(BBStr)*STR_NEW_INC); - for (int k = 0; k < STR_NEW_INC; ++k) insertStr(t++, &freeStrs); - } - BBStr *t = freeStrs.next; - removeStr(t); insertStr(t, &usedStrs); - return t; -} - -void BBStr::operator delete(void *q) { - if (!q) return; - BBStr *t = (BBStr*)q; - removeStr(t); insertStr(t, &freeStrs); -} - -BBStr::BBStr() { - ++stringCnt; -} - -BBStr::BBStr(const char *s) :string(s) { - ++stringCnt; -} - -BBStr::BBStr(const char *s, int n) : string(s, n) { - ++stringCnt; -} - -BBStr::BBStr(const BBStr &s) : string(s) { - ++stringCnt; -} - -BBStr::BBStr(const string &s) : string(s) { - ++stringCnt; -} - -BBStr &BBStr::operator=(const char *s) { - string::operator=(s); return *this; -} - -BBStr &BBStr::operator=(const BBStr &s) { - string::operator=(s); return *this; -} - -BBStr &BBStr::operator=(const string &s) { - string::operator=(s); return *this; -} - -BBStr::~BBStr() { - --stringCnt; -} - -BBStr *_bbStrLoad(BBStr **var) { - return *var ? new BBStr(**var) : new BBStr(); -} - -void _bbStrRelease(BBStr *str) { - delete str; -} - -void _bbStrStore(BBStr **var, BBStr *str) { - _bbStrRelease(*var); *var = str; -} - -BBStr *_bbStrConcat(BBStr *s1, BBStr *s2) { - *s1 += *s2; delete s2; return s1; -} - -int _bbStrCompare(BBStr *lhs, BBStr *rhs) { - int n = lhs->compare(*rhs); - delete lhs; delete rhs; return n; -} - -int _bbStrToInt(BBStr *s) { - int n = atoi(*s); - delete s; return n; -} - -BBStr *_bbStrFromInt(int n) { - return new BBStr(itoa(n)); -} - -float _bbStrToFloat(BBStr *s) { - float n = (float)atof(*s); - delete s; return n; -} - -BBStr *_bbStrFromFloat(float n) { - return new BBStr(ftoa(n)); -} - -BBStr *_bbStrConst(const char *s) { - return new BBStr(s); -} - -void * _bbVecAlloc(BBVecType *type) { - void *vec = bbMalloc(type->size * 4); - memset(vec, 0, type->size * 4); - return vec; -} - -void _bbVecFree(void *vec, BBVecType *type) { - if (type->elementType->type == BBTYPE_STR) { - BBStr **p = (BBStr**)vec; - for (int k = 0; k < type->size; ++p, ++k) { - if (*p) _bbStrRelease(*p); - } - } else if (type->elementType->type == BBTYPE_OBJ) { - BBObj **p = (BBObj**)vec; - for (int k = 0; k < type->size; ++p, ++k) { - if (*p) _bbObjRelease(*p); - } - } - bbFree(vec); -} - -void _bbVecBoundsEx() { - ThrowRuntimeException("Blitz array index out of bounds"); -} - -void _bbUndimArray(BBArray *array) { - if (void *t = array->data) { - if (array->elementType == BBTYPE_STR) { - BBStr **p = (BBStr**)t; - int size = array->scales[array->dims - 1]; - for (int k = 0; k < size; ++p, ++k) { - if (*p) _bbStrRelease(*p); - } - } else if (array->elementType == BBTYPE_OBJ) { - BBObj **p = (BBObj**)t; - int size = array->scales[array->dims - 1]; - for (int k = 0; k < size; ++p, ++k) { - if (*p) _bbObjRelease(*p); - } - } - bbFree(t); - array->data = 0; - } -} - -void _bbDimArray(BBArray *array) { - int k; - for (k = 0; k < array->dims; ++k) ++array->scales[k]; - for (k = 1; k < array->dims; ++k) { - array->scales[k] *= array->scales[k - 1]; - } - int size = array->scales[array->dims - 1]; - array->data = bbMalloc(size * 4); - memset(array->data, 0, size * 4); -} - -void _bbArrayBoundsEx() { - ThrowRuntimeException("Array index out of bounds"); -} - -static void unlinkObj(BBObj *obj) { - obj->next->prev = obj->prev; - obj->prev->next = obj->next; -} - -static void insertObj(BBObj *obj, BBObj *next) { - obj->next = next; - obj->prev = next->prev; - next->prev->next = obj; - next->prev = obj; -} - -BBObj *_bbObjNew(BBObjType *type) { - if (type->free.next == &type->free) { - int obj_size = sizeof(BBObj) + type->fieldCnt * 4; - BBObj *o = (BBObj*)bbMalloc(obj_size*OBJ_NEW_INC); - for (int k = 0; k < OBJ_NEW_INC; ++k) { - insertObj(o, &type->free); - o = (BBObj*)((char*)o + obj_size); - } - } - BBObj *o = type->free.next; - unlinkObj(o); - o->type = type; - o->ref_cnt = 1; - o->fields = (BBField*)(o + 1); - for (int k = 0; k < type->fieldCnt; ++k) { - switch (type->fieldTypes[k]->type) { - case BBTYPE_VEC: - o->fields[k].VEC = _bbVecAlloc((BBVecType*)type->fieldTypes[k]); - break; - default: - o->fields[k].INT = 0; - } - } - insertObj(o, &type->used); - ++unrelObjCnt; - ++objCnt; - return o; -} - -void _bbObjDelete(BBObj *obj) { - if (!obj) return; - BBField *fields = obj->fields; - if (!fields) return; - BBObjType *type = obj->type; - for (int k = 0; k < type->fieldCnt; ++k) { - switch (type->fieldTypes[k]->type) { - case BBTYPE_STR: - _bbStrRelease(fields[k].STR); - break; - case BBTYPE_OBJ: - _bbObjRelease(fields[k].OBJ); - break; - case BBTYPE_VEC: - _bbVecFree(fields[k].VEC, (BBVecType*)type->fieldTypes[k]); - break; - } - } - map::iterator it = object_map.find(obj); - if (it != object_map.end()) { - handle_map.erase(it->second); - object_map.erase(it); - } - obj->fields = 0; - _bbObjRelease(obj); - --objCnt; -} - -void _bbObjDeleteEach(BBObjType *type) { - BBObj *obj = type->used.next; - while (obj->type) { - BBObj *next = obj->next; - if (obj->fields) _bbObjDelete(obj); - obj = next; - } -} - -extern void bbDebugLog(BBStr *t); -extern void bbStop(); - -void _bbObjRelease(BBObj *obj) { - if (!obj || --obj->ref_cnt) return; - unlinkObj(obj); - insertObj(obj, &obj->type->free); - --unrelObjCnt; -} - -void _bbObjStore(BBObj **var, BBObj *obj) { - if (obj) ++obj->ref_cnt; //do this first incase of self-assignment - _bbObjRelease(*var); - *var = obj; -} - -int _bbObjCompare(BBObj *o1, BBObj *o2) { - return (o1 ? o1->fields : 0) != (o2 ? o2->fields : 0); -} - -BBObj *_bbObjNext(BBObj *obj) { - do { - obj = obj->next; - if (!obj->type) return 0; - } while (!obj->fields); - return obj; -} - -BBObj *_bbObjPrev(BBObj *obj) { - do { - obj = obj->prev; - if (!obj->type) return 0; - } while (!obj->fields); - return obj; -} - -BBObj *_bbObjFirst(BBObjType *type) { - return _bbObjNext(&type->used); -} - -BBObj *_bbObjLast(BBObjType *type) { - return _bbObjPrev(&type->used); -} - -void _bbObjInsBefore(BBObj *o1, BBObj *o2) { - if (o1 == o2) return; - unlinkObj(o1); - insertObj(o1, o2); -} - -void _bbObjInsAfter(BBObj *o1, BBObj *o2) { - if (o1 == o2) return; - unlinkObj(o1); - insertObj(o1, o2->next); -} - -int _bbObjEachFirst(BBObj **var, BBObjType *type) { - _bbObjStore(var, _bbObjFirst(type)); - return *var != 0; -} - -int _bbObjEachNext(BBObj **var) { - _bbObjStore(var, _bbObjNext(*var)); - return *var != 0; -} - -int _bbObjEachFirst2(BBObj **var, BBObjType *type) { - *var = _bbObjFirst(type); - return *var != 0; -} - -int _bbObjEachNext2(BBObj **var) { - *var = _bbObjNext(*var); - return *var != 0; -} - -BBStr *_bbObjToStr(BBObj *obj) { - if (!obj || !obj->fields) return new BBStr("[NULL]"); - - static BBObj *root; - static int recurs_cnt; - - if (obj == root) return new BBStr("[ROOT]"); - if (recurs_cnt == 8) return new BBStr("...."); - - ++recurs_cnt; - BBObj *oldRoot = root; - if (!root) root = obj; - - BBObjType *type = obj->type; - BBField *fields = obj->fields; - BBStr *s = new BBStr("["), *t; - for (int k = 0; k < type->fieldCnt; ++k) { - if (k) *s += ','; - switch (type->fieldTypes[k]->type) { - case BBTYPE_INT: - t = _bbStrFromInt(fields[k].INT); *s += *t; delete t; - break; - case BBTYPE_FLT: - t = _bbStrFromFloat(fields[k].FLT); *s += *t; delete t; - break; - case BBTYPE_STR: - if (fields[k].STR) *s += '\"' + *fields[k].STR + '\"'; - else *s += "\"\""; - break; - case BBTYPE_OBJ: - t = _bbObjToStr(fields[k].OBJ); *s += *t; delete t; - break; - default: - *s += "???"; - } - } - *s += ']'; - root = oldRoot; - --recurs_cnt; - return s; -} - -int _bbObjToHandle(BBObj *obj) { - if (!obj || !obj->fields) return 0; - map::const_iterator it = object_map.find(obj); - if (it != object_map.end()) return it->second; - ++next_handle; - object_map[obj] = next_handle; - handle_map[next_handle] = obj; - return next_handle; -} - -BBObj *_bbObjFromHandle(int handle, BBObjType *type) { - map::const_iterator it = handle_map.find(handle); - if (it == handle_map.end()) return 0; - BBObj *obj = it->second; - return obj->type == type ? obj : 0; -} - -void _bbNullObjEx() { - ThrowRuntimeException("Object does not exist"); -} - -void _bbRestore(BBData *data) { - dataPtr = data; -} - -int _bbReadInt() { - switch (dataPtr->fieldType) { - case BBTYPE_END:ThrowRuntimeException("Out of data"); return 0; - case BBTYPE_INT:return dataPtr++->field.INT; - case BBTYPE_FLT:return dataPtr++->field.FLT; - case BBTYPE_CSTR:return atoi(dataPtr++->field.CSTR); - default:ThrowRuntimeException("Bad data type"); return 0; - } -} - -float _bbReadFloat() { - switch (dataPtr->fieldType) { - case BBTYPE_END:ThrowRuntimeException("Out of data"); return 0; - case BBTYPE_INT:return dataPtr++->field.INT; - case BBTYPE_FLT:return dataPtr++->field.FLT; - case BBTYPE_CSTR:return atof(dataPtr++->field.CSTR); - default:ThrowRuntimeException("Bad data type"); return 0; - } -} - -BBStr *_bbReadStr() { - switch (dataPtr->fieldType) { - case BBTYPE_END:ThrowRuntimeException("Out of data"); return 0; - case BBTYPE_INT:return new BBStr(itoa(dataPtr++->field.INT)); - case BBTYPE_FLT:return new BBStr(ftoa(dataPtr++->field.FLT)); - case BBTYPE_CSTR:return new BBStr(dataPtr++->field.CSTR); - default:ThrowRuntimeException("Bad data type"); return 0; - } -} - -int _bbAbs(int n) { - return n >= 0 ? n : -n; -} - -int _bbSgn(int n) { - return n > 0 ? 1 : (n < 0 ? -1 : 0); -} - -int _bbMod(int x, int y) { - return x%y; -} - -float _bbFAbs(float n) { - return n >= 0 ? n : -n; -} - -float _bbFSgn(float n) { - return n > 0 ? 1 : (n < 0 ? -1 : 0); -} - -float _bbFMod(float x, float y) { - return (float)fmod(x, y); -} - -float _bbFPow(float x, float y) { - return (float)pow(x, y); -} - -void bbRuntimeStats() { - gx_runtime->debugLog(("Active strings :" + itoa(stringCnt)).c_str()); - gx_runtime->debugLog(("Active objects :" + itoa(objCnt)).c_str()); - gx_runtime->debugLog(("Unreleased objs:" + itoa(unrelObjCnt)).c_str()); - /* - clog<<"Active strings:"<next ){ - clog<<"string@"<<(void*)t< memBlks; + +//strings +static BBStr usedStrs, freeStrs; + +//object handle number +static int next_handle; + +//object<->handle maps +static map handle_map; +static map object_map; + +static BBType _bbIntType(BBTYPE_INT); +static BBType _bbFltType(BBTYPE_FLT); +static BBType _bbStrType(BBTYPE_STR); +static BBType _bbCStrType(BBTYPE_CSTR); + +static void *bbMalloc(int size) { + return malloc(size); + /* + char *c=new char[ size ]; + memBlks.push_back( c ); + return c; + */ +} + +static void bbFree(void *q) { + free(q); + /* + if( !q ) return; + char *c=(char*)q; + memBlks.remove( c ); + delete [] c; + */ +} + +static void removeStr(BBStr *str) { + str->next->prev = str->prev; + str->prev->next = str->next; +} + +static void insertStr(BBStr *str, BBStr *next) { + str->next = next; + str->prev = next->prev; + str->prev->next = str; + next->prev = str; +} + +void *BBStr::operator new(size_t size) { + if (freeStrs.next == &freeStrs) { + BBStr *t = (BBStr*)bbMalloc(sizeof(BBStr)*STR_NEW_INC); + for (int k = 0; k < STR_NEW_INC; ++k) insertStr(t++, &freeStrs); + } + BBStr *t = freeStrs.next; + removeStr(t); insertStr(t, &usedStrs); + return t; +} + +void BBStr::operator delete(void *q) { + if (!q) return; + BBStr *t = (BBStr*)q; + removeStr(t); insertStr(t, &freeStrs); +} + +BBStr::BBStr() { + ++stringCnt; +} + +BBStr::BBStr(const char *s) :string(s) { + ++stringCnt; +} + +BBStr::BBStr(const char *s, int n) : string(s, n) { + ++stringCnt; +} + +BBStr::BBStr(const BBStr &s) : string(s) { + ++stringCnt; +} + +BBStr::BBStr(const string &s) : string(s) { + ++stringCnt; +} + +BBStr &BBStr::operator=(const char *s) { + string::operator=(s); return *this; +} + +BBStr &BBStr::operator=(const BBStr &s) { + string::operator=(s); return *this; +} + +BBStr &BBStr::operator=(const string &s) { + string::operator=(s); return *this; +} + +BBStr::~BBStr() { + --stringCnt; +} + +BBStr *_bbStrLoad(BBStr **var) { + return *var ? new BBStr(**var) : new BBStr(); +} + +void _bbStrRelease(BBStr *str) { + delete str; +} + +void _bbStrStore(BBStr **var, BBStr *str) { + _bbStrRelease(*var); *var = str; +} + +BBStr *_bbStrConcat(BBStr *s1, BBStr *s2) { + *s1 += *s2; delete s2; return s1; +} + +int _bbStrCompare(BBStr *lhs, BBStr *rhs) { + int n = lhs->compare(*rhs); + delete lhs; delete rhs; return n; +} + +int _bbStrToInt(BBStr *s) { + int n = atoi(*s); + delete s; return n; +} + +BBStr *_bbStrFromInt(int n) { + return new BBStr(itoa(n)); +} + +float _bbStrToFloat(BBStr *s) { + float n = (float)atof(*s); + delete s; return n; +} + +BBStr *_bbStrFromFloat(float n) { + return new BBStr(ftoa(n)); +} + +BBStr *_bbStrConst(const char *s) { + return new BBStr(s); +} + +void * _bbVecAlloc(BBVecType *type) { + void *vec = bbMalloc(type->size * 4); + memset(vec, 0, type->size * 4); + return vec; +} + +void _bbVecFree(void *vec, BBVecType *type) { + if (type->elementType->type == BBTYPE_STR) { + BBStr **p = (BBStr**)vec; + for (int k = 0; k < type->size; ++p, ++k) { + if (*p) _bbStrRelease(*p); + } + } else if (type->elementType->type == BBTYPE_OBJ) { + BBObj **p = (BBObj**)vec; + for (int k = 0; k < type->size; ++p, ++k) { + if (*p) _bbObjRelease(*p); + } + } + bbFree(vec); +} + +void _bbVecBoundsEx() { + ThrowRuntimeException("Blitz array index out of bounds"); +} + +void _bbUndimArray(BBArray *array) { + if (void *t = array->data) { + if (array->elementType == BBTYPE_STR) { + BBStr **p = (BBStr**)t; + int size = array->scales[array->dims - 1]; + for (int k = 0; k < size; ++p, ++k) { + if (*p) _bbStrRelease(*p); + } + } else if (array->elementType == BBTYPE_OBJ) { + BBObj **p = (BBObj**)t; + int size = array->scales[array->dims - 1]; + for (int k = 0; k < size; ++p, ++k) { + if (*p) _bbObjRelease(*p); + } + } + bbFree(t); + array->data = 0; + } +} + +void _bbDimArray(BBArray *array) { + int k; + for (k = 0; k < array->dims; ++k) ++array->scales[k]; + for (k = 1; k < array->dims; ++k) { + array->scales[k] *= array->scales[k - 1]; + } + int size = array->scales[array->dims - 1]; + array->data = bbMalloc(size * 4); + memset(array->data, 0, size * 4); +} + +void _bbArrayBoundsEx() { + ThrowRuntimeException("Array index out of bounds"); +} + +static void unlinkObj(BBObj *obj) { + obj->next->prev = obj->prev; + obj->prev->next = obj->next; +} + +static void insertObj(BBObj *obj, BBObj *next) { + obj->next = next; + obj->prev = next->prev; + next->prev->next = obj; + next->prev = obj; +} + +BBObj *_bbObjNew(BBObjType *type) { + if (type->free.next == &type->free) { + int obj_size = sizeof(BBObj) + type->fieldCnt * 4; + BBObj *o = (BBObj*)bbMalloc(obj_size*OBJ_NEW_INC); + for (int k = 0; k < OBJ_NEW_INC; ++k) { + insertObj(o, &type->free); + o = (BBObj*)((char*)o + obj_size); + } + } + BBObj *o = type->free.next; + unlinkObj(o); + o->type = type; + o->ref_cnt = 1; + o->fields = (BBField*)(o + 1); + for (int k = 0; k < type->fieldCnt; ++k) { + switch (type->fieldTypes[k]->type) { + case BBTYPE_VEC: + o->fields[k].VEC = _bbVecAlloc((BBVecType*)type->fieldTypes[k]); + break; + default: + o->fields[k].INT = 0; + } + } + insertObj(o, &type->used); + ++unrelObjCnt; + ++objCnt; + return o; +} + +void _bbObjDelete(BBObj *obj) { + if (!obj) return; + BBField *fields = obj->fields; + if (!fields) return; + BBObjType *type = obj->type; + for (int k = 0; k < type->fieldCnt; ++k) { + switch (type->fieldTypes[k]->type) { + case BBTYPE_STR: + _bbStrRelease(fields[k].STR); + break; + case BBTYPE_OBJ: + _bbObjRelease(fields[k].OBJ); + break; + case BBTYPE_VEC: + _bbVecFree(fields[k].VEC, (BBVecType*)type->fieldTypes[k]); + break; + } + } + map::iterator it = object_map.find(obj); + if (it != object_map.end()) { + handle_map.erase(it->second); + object_map.erase(it); + } + obj->fields = 0; + _bbObjRelease(obj); + --objCnt; +} + +void _bbObjDeleteEach(BBObjType *type) { + BBObj *obj = type->used.next; + while (obj->type) { + BBObj *next = obj->next; + if (obj->fields) _bbObjDelete(obj); + obj = next; + } +} + +extern void bbDebugLog(BBStr *t); +extern void bbStop(); + +void _bbObjRelease(BBObj *obj) { + if (!obj || --obj->ref_cnt) return; + unlinkObj(obj); + insertObj(obj, &obj->type->free); + --unrelObjCnt; +} + +void _bbObjStore(BBObj **var, BBObj *obj) { + if (obj) ++obj->ref_cnt; //do this first incase of self-assignment + _bbObjRelease(*var); + *var = obj; +} + +int _bbObjCompare(BBObj *o1, BBObj *o2) { + return (o1 ? o1->fields : 0) != (o2 ? o2->fields : 0); +} + +BBObj *_bbObjNext(BBObj *obj) { + do { + obj = obj->next; + if (!obj->type) return 0; + } while (!obj->fields); + return obj; +} + +BBObj *_bbObjPrev(BBObj *obj) { + do { + obj = obj->prev; + if (!obj->type) return 0; + } while (!obj->fields); + return obj; +} + +BBObj *_bbObjFirst(BBObjType *type) { + return _bbObjNext(&type->used); +} + +BBObj *_bbObjLast(BBObjType *type) { + return _bbObjPrev(&type->used); +} + +void _bbObjInsBefore(BBObj *o1, BBObj *o2) { + if (o1 == o2) return; + unlinkObj(o1); + insertObj(o1, o2); +} + +void _bbObjInsAfter(BBObj *o1, BBObj *o2) { + if (o1 == o2) return; + unlinkObj(o1); + insertObj(o1, o2->next); +} + +int _bbObjEachFirst(BBObj **var, BBObjType *type) { + _bbObjStore(var, _bbObjFirst(type)); + return *var != 0; +} + +int _bbObjEachNext(BBObj **var) { + _bbObjStore(var, _bbObjNext(*var)); + return *var != 0; +} + +int _bbObjEachFirst2(BBObj **var, BBObjType *type) { + *var = _bbObjFirst(type); + return *var != 0; +} + +int _bbObjEachNext2(BBObj **var) { + *var = _bbObjNext(*var); + return *var != 0; +} + +BBStr *_bbObjToStr(BBObj *obj) { + if (!obj || !obj->fields) return new BBStr("[NULL]"); + + static BBObj *root; + static int recurs_cnt; + + if (obj == root) return new BBStr("[ROOT]"); + if (recurs_cnt == 8) return new BBStr("...."); + + ++recurs_cnt; + BBObj *oldRoot = root; + if (!root) root = obj; + + BBObjType *type = obj->type; + BBField *fields = obj->fields; + BBStr *s = new BBStr("["), *t; + for (int k = 0; k < type->fieldCnt; ++k) { + if (k) *s += ','; + switch (type->fieldTypes[k]->type) { + case BBTYPE_INT: + t = _bbStrFromInt(fields[k].INT); *s += *t; delete t; + break; + case BBTYPE_FLT: + t = _bbStrFromFloat(fields[k].FLT); *s += *t; delete t; + break; + case BBTYPE_STR: + if (fields[k].STR) *s += '\"' + *fields[k].STR + '\"'; + else *s += "\"\""; + break; + case BBTYPE_OBJ: + t = _bbObjToStr(fields[k].OBJ); *s += *t; delete t; + break; + default: + *s += "???"; + } + } + *s += ']'; + root = oldRoot; + --recurs_cnt; + return s; +} + +int _bbObjToHandle(BBObj *obj) { + if (!obj || !obj->fields) return 0; + map::const_iterator it = object_map.find(obj); + if (it != object_map.end()) return it->second; + ++next_handle; + object_map[obj] = next_handle; + handle_map[next_handle] = obj; + return next_handle; +} + +BBObj *_bbObjFromHandle(int handle, BBObjType *type) { + map::const_iterator it = handle_map.find(handle); + if (it == handle_map.end()) return 0; + BBObj *obj = it->second; + return obj->type == type ? obj : 0; +} + +void _bbNullObjEx() { + ThrowRuntimeException("Object does not exist"); +} + +void _bbRestore(BBData *data) { + dataPtr = data; +} + +int _bbReadInt() { + switch (dataPtr->fieldType) { + case BBTYPE_END:ThrowRuntimeException("Out of data"); return 0; + case BBTYPE_INT:return dataPtr++->field.INT; + case BBTYPE_FLT:return dataPtr++->field.FLT; + case BBTYPE_CSTR:return atoi(dataPtr++->field.CSTR); + default:ThrowRuntimeException("Bad data type"); return 0; + } +} + +float _bbReadFloat() { + switch (dataPtr->fieldType) { + case BBTYPE_END:ThrowRuntimeException("Out of data"); return 0; + case BBTYPE_INT:return dataPtr++->field.INT; + case BBTYPE_FLT:return dataPtr++->field.FLT; + case BBTYPE_CSTR:return atof(dataPtr++->field.CSTR); + default:ThrowRuntimeException("Bad data type"); return 0; + } +} + +BBStr *_bbReadStr() { + switch (dataPtr->fieldType) { + case BBTYPE_END:ThrowRuntimeException("Out of data"); return 0; + case BBTYPE_INT:return new BBStr(itoa(dataPtr++->field.INT)); + case BBTYPE_FLT:return new BBStr(ftoa(dataPtr++->field.FLT)); + case BBTYPE_CSTR:return new BBStr(dataPtr++->field.CSTR); + default:ThrowRuntimeException("Bad data type"); return 0; + } +} + +int _bbAbs(int n) { + return n >= 0 ? n : -n; +} + +int _bbSgn(int n) { + return n > 0 ? 1 : (n < 0 ? -1 : 0); +} + +int _bbMod(int x, int y) { + return x%y; +} + +float _bbFAbs(float n) { + return n >= 0 ? n : -n; +} + +float _bbFSgn(float n) { + return n > 0 ? 1 : (n < 0 ? -1 : 0); +} + +float _bbFMod(float x, float y) { + return (float)fmod(x, y); +} + +float _bbFPow(float x, float y) { + return (float)pow(x, y); +} + +void bbRuntimeStats() { + gx_runtime->debugLog(("Active strings :" + itoa(stringCnt)).c_str()); + gx_runtime->debugLog(("Active objects :" + itoa(objCnt)).c_str()); + gx_runtime->debugLog(("Unreleased objs:" + itoa(unrelObjCnt)).c_str()); + /* + clog<<"Active strings:"<next ){ + clog<<"string@"<<(void*)t< -#include - -enum { - BBTYPE_END = 0, - BBTYPE_INT = 1, BBTYPE_FLT = 2, - BBTYPE_STR = 3, BBTYPE_CSTR = 4, - BBTYPE_OBJ = 5, BBTYPE_VEC = 6 -}; - -#pragma pack( push,1 ) - -struct BBObj; -struct BBStr; -struct BBType; -struct BBObjType; -struct BBVecType; -union BBField; -struct BBArray; - -struct BBObj { - BBField *fields; - BBObj *next, *prev; - BBObjType *type; - int ref_cnt; -}; - -struct BBType { - int type; - BBType(int n) :type(n) {} -}; - -struct BBObjType : public BBType { - BBObj used, free; - int fieldCnt; - BBType *fieldTypes[1]; -}; - -struct BBVecType : public BBType { - int size; - BBType *elementType; -}; - -union BBField { - int INT; - float FLT; - BBStr *STR; - char *CSTR; - BBObj *OBJ; - void *VEC; -}; - -struct BBArray { - void *data; - int elementType, dims, scales[1]; -}; - -struct BBStr : public std::string { - BBStr *next, *prev; - - BBStr(); - BBStr(const char *s); - BBStr(const char *s, int n); - BBStr(const BBStr &s); - BBStr(const std::string &s); - BBStr &operator=(const char *s); - BBStr &operator=(const BBStr &s); - BBStr &operator=(const std::string &s); - ~BBStr(); - - void *operator new(size_t size); - void operator delete(void *q); - - void *operator new(size_t size, const char *file, int line) { return operator new(size); } - void operator delete(void *q, const char *file, int line) { operator delete(q); } -}; - -struct BBData { - int fieldType; - BBField field; -}; - -#pragma pack( pop ) - -void basic_link(); - -extern BBType _bbIntType; -extern BBType _bbFltType; -extern BBType _bbStrType; -extern BBType _bbCStrType; - -BBStr * _bbStrLoad(BBStr **var); -void _bbStrRelease(BBStr *str); -void _bbStrStore(BBStr **var, BBStr *str); -int _bbStrCompare(BBStr *lhs, BBStr *rhs); - -BBStr * _bbStrConcat(BBStr *s1, BBStr *s2); -int _bbStrToInt(BBStr *s); -BBStr * _bbStrFromInt(int n); -float _bbStrToFloat(BBStr *s); -BBStr * _bbStrFromFloat(float n); -BBStr * _bbStrConst(const char *s); - -void _bbDimArray(BBArray *array); -void _bbUndimArray(BBArray *array); -void _bbArrayBoundsEx(); - -void * _bbVecAlloc(BBVecType *type); -void _bbVecFree(void *vec, BBVecType *type); -void _bbVecBoundsEx(); - -BBObj * _bbObjNew(BBObjType *t); -void _bbObjDelete(BBObj *obj); -void _bbObjDeleteEach(BBObjType *type); -void _bbObjRelease(BBObj *obj); -void _bbObjStore(BBObj **var, BBObj *obj); -BBObj * _bbObjNext(BBObj *obj); -BBObj * _bbObjPrev(BBObj *obj); -BBObj * _bbObjFirst(BBObjType *t); -BBObj * _bbObjLast(BBObjType *t); -void _bbObjInsBefore(BBObj *o1, BBObj *o2); -void _bbObjInsAfter(BBObj *o1, BBObj *o2); -int _bbObjEachFirst(BBObj **var, BBObjType *type); -int _bbObjEachNext(BBObj **var); -int _bbObjCompare(BBObj *o1, BBObj *o2); -BBStr * _bbObjToStr(BBObj *obj); -int _bbObjToHandle(BBObj *obj); -BBObj * _bbObjFromHandle(int handle, BBObjType *type); -void _bbNullObjEx(); - -void _bbRestore(BBData *data); -int _bbReadInt(); -float _bbReadFloat(); -BBStr * _bbReadStr(); - -int _bbAbs(int n); -int _bbSgn(int n); -int _bbMod(int x, int y); -float _bbFAbs(float n); -float _bbFSgn(float n); -float _bbFMod(float x, float y); -float _bbFPow(float x, float y); - -void bbRuntimeStats(); - + +#ifndef BASIC_H +#define BASIC_H + +#include +#include + +enum { + BBTYPE_END = 0, + BBTYPE_INT = 1, BBTYPE_FLT = 2, + BBTYPE_STR = 3, BBTYPE_CSTR = 4, + BBTYPE_OBJ = 5, BBTYPE_VEC = 6 +}; + +#pragma pack( push,1 ) + +struct BBObj; +struct BBStr; +struct BBType; +struct BBObjType; +struct BBVecType; +union BBField; +struct BBArray; + +struct BBObj { + BBField *fields; + BBObj *next, *prev; + BBObjType *type; + int ref_cnt; +}; + +struct BBType { + int type; + BBType(int n) :type(n) {} +}; + +struct BBObjType : public BBType { + BBObj used, free; + int fieldCnt; + BBType *fieldTypes[1]; +}; + +struct BBVecType : public BBType { + int size; + BBType *elementType; +}; + +union BBField { + int INT; + float FLT; + BBStr *STR; + char *CSTR; + BBObj *OBJ; + void *VEC; +}; + +struct BBArray { + void *data; + int elementType, dims, scales[1]; +}; + +struct BBStr : public std::string { + BBStr *next, *prev; + + BBStr(); + BBStr(const char *s); + BBStr(const char *s, int n); + BBStr(const BBStr &s); + BBStr(const std::string &s); + BBStr &operator=(const char *s); + BBStr &operator=(const BBStr &s); + BBStr &operator=(const std::string &s); + ~BBStr(); + + void *operator new(size_t size); + void operator delete(void *q); + + void *operator new(size_t size, const char *file, int line) { return operator new(size); } + void operator delete(void *q, const char *file, int line) { operator delete(q); } +}; + +struct BBData { + int fieldType; + BBField field; +}; + +#pragma pack( pop ) + +void basic_link(); + +extern BBType _bbIntType; +extern BBType _bbFltType; +extern BBType _bbStrType; +extern BBType _bbCStrType; + +BBStr * _bbStrLoad(BBStr **var); +void _bbStrRelease(BBStr *str); +void _bbStrStore(BBStr **var, BBStr *str); +int _bbStrCompare(BBStr *lhs, BBStr *rhs); + +BBStr * _bbStrConcat(BBStr *s1, BBStr *s2); +int _bbStrToInt(BBStr *s); +BBStr * _bbStrFromInt(int n); +float _bbStrToFloat(BBStr *s); +BBStr * _bbStrFromFloat(float n); +BBStr * _bbStrConst(const char *s); + +void _bbDimArray(BBArray *array); +void _bbUndimArray(BBArray *array); +void _bbArrayBoundsEx(); + +void * _bbVecAlloc(BBVecType *type); +void _bbVecFree(void *vec, BBVecType *type); +void _bbVecBoundsEx(); + +BBObj * _bbObjNew(BBObjType *t); +void _bbObjDelete(BBObj *obj); +void _bbObjDeleteEach(BBObjType *type); +void _bbObjRelease(BBObj *obj); +void _bbObjStore(BBObj **var, BBObj *obj); +BBObj * _bbObjNext(BBObj *obj); +BBObj * _bbObjPrev(BBObj *obj); +BBObj * _bbObjFirst(BBObjType *t); +BBObj * _bbObjLast(BBObjType *t); +void _bbObjInsBefore(BBObj *o1, BBObj *o2); +void _bbObjInsAfter(BBObj *o1, BBObj *o2); +int _bbObjEachFirst(BBObj **var, BBObjType *type); +int _bbObjEachNext(BBObj **var); +int _bbObjCompare(BBObj *o1, BBObj *o2); +BBStr * _bbObjToStr(BBObj *obj); +int _bbObjToHandle(BBObj *obj); +BBObj * _bbObjFromHandle(int handle, BBObjType *type); +void _bbNullObjEx(); + +void _bbRestore(BBData *data); +int _bbReadInt(); +float _bbReadFloat(); +BBStr * _bbReadStr(); + +int _bbAbs(int n); +int _bbSgn(int n); +int _bbMod(int x, int y); +float _bbFAbs(float n); +float _bbFSgn(float n); +float _bbFMod(float x, float y); +float _bbFPow(float x, float y); + +void bbRuntimeStats(); + #endif \ No newline at end of file diff --git a/RuntimeLib/bb_basic.h b/Runtime/lib/bb_basic.hpp similarity index 100% rename from RuntimeLib/bb_basic.h rename to Runtime/lib/bb_basic.hpp diff --git a/RuntimeLib/bbaudio.cpp b/Runtime/lib/bbaudio.cpp similarity index 98% rename from RuntimeLib/bbaudio.cpp rename to Runtime/lib/bbaudio.cpp index 82199e7..0df7256 100644 --- a/RuntimeLib/bbaudio.cpp +++ b/Runtime/lib/bbaudio.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "bbaudio.h" +#include "std.hpp" +#include "bbaudio.hpp" gxAudio *gx_audio; diff --git a/RuntimeLib/bbaudio.h b/Runtime/lib/bbaudio.hpp similarity index 93% rename from RuntimeLib/bbaudio.h rename to Runtime/lib/bbaudio.hpp index 600fd96..fe1f993 100644 --- a/RuntimeLib/bbaudio.h +++ b/Runtime/lib/bbaudio.hpp @@ -2,8 +2,8 @@ #ifndef BBAUDIO_H #define BBAUDIO_H -#include "bbsys.h" -#include "../gxruntime/gxaudio.h" +#include "bbsys.hpp" +#include "../gxruntime/gxaudio.hpp" extern gxAudio *gx_audio; diff --git a/RuntimeLib/bbbank.cpp b/Runtime/lib/bbbank.cpp similarity index 98% rename from RuntimeLib/bbbank.cpp rename to Runtime/lib/bbbank.cpp index 627a7ee..83a909b 100644 --- a/RuntimeLib/bbbank.cpp +++ b/Runtime/lib/bbbank.cpp @@ -1,7 +1,7 @@ -#include "std.h" -#include "bbbank.h" -#include "bbstream.h" +#include "std.hpp" +#include "bbbank.hpp" +#include "bbstream.hpp" struct bbBank{ char *data; diff --git a/RuntimeLib/bbbank.h b/Runtime/lib/bbbank.hpp similarity index 67% rename from RuntimeLib/bbbank.h rename to Runtime/lib/bbbank.hpp index 4c64442..63f9d08 100644 --- a/RuntimeLib/bbbank.h +++ b/Runtime/lib/bbbank.hpp @@ -2,6 +2,6 @@ #ifndef BBBANK_H #define BBBANK_H -#include "bbsys.h" +#include "bbsys.hpp" #endif \ No newline at end of file diff --git a/RuntimeLib/bbblitz3d.cpp b/Runtime/lib/bbblitz3d.cpp similarity index 98% rename from RuntimeLib/bbblitz3d.cpp rename to Runtime/lib/bbblitz3d.cpp index 59d2f2e..f11f283 100644 --- a/RuntimeLib/bbblitz3d.cpp +++ b/Runtime/lib/bbblitz3d.cpp @@ -1,26 +1,26 @@ -#include "std.h" +#include "std.hpp" -#include "bbblitz3d.h" -#include "bbgraphics.h" -#include "../blitz3d/blitz3d.h" -#include "../blitz3d/world.h" -#include "../blitz3d/texture.h" -#include "../blitz3d/brush.h" -#include "../blitz3d/camera.h" -#include "../blitz3d/sprite.h" -#include "../blitz3d/meshmodel.h" -//#include "../blitz3d/loader_x.h" -#include "../blitz3d/loader_3ds.h" -#include "../blitz3d/loader_b3d.h" -#include "../blitz3d/md2model.h" -#include "../blitz3d/q3bspmodel.h" -#include "../blitz3d/meshutil.h" -#include "../blitz3d/pivot.h" -#include "../blitz3d/planemodel.h" -#include "../blitz3d/terrain.h" -#include "../blitz3d/listener.h" -#include "../blitz3d/cachedtexture.h" +#include "bbblitz3d.hpp" +#include "bbgraphics.hpp" +#include "../blitz3d/blitz3d.hpp" +#include "../blitz3d/world.hpp" +#include "../blitz3d/texture.hpp" +#include "../blitz3d/brush.hpp" +#include "../blitz3d/camera.hpp" +#include "../blitz3d/sprite.hpp" +#include "../blitz3d/meshmodel.hpp" +//#include "../blitz3d/loader_x.hpp" +#include "../blitz3d/loader_3ds.hpp" +#include "../blitz3d/loader_b3d.hpp" +#include "../blitz3d/md2model.hpp" +#include "../blitz3d/q3bspmodel.hpp" +#include "../blitz3d/meshutil.hpp" +#include "../blitz3d/pivot.hpp" +#include "../blitz3d/planemodel.hpp" +#include "../blitz3d/terrain.hpp" +#include "../blitz3d/listener.hpp" +#include "../blitz3d/cachedtexture.hpp" gxScene *gx_scene; extern gxFileSystem *gx_filesys; diff --git a/RuntimeLib/bbblitz3d.h b/Runtime/lib/bbblitz3d.hpp similarity index 57% rename from RuntimeLib/bbblitz3d.h rename to Runtime/lib/bbblitz3d.hpp index b4197e0..259c34e 100644 --- a/RuntimeLib/bbblitz3d.h +++ b/Runtime/lib/bbblitz3d.hpp @@ -2,8 +2,8 @@ #ifndef BBBLITZ3D_H #define BBBLITZ3D_H -#include "bbsys.h" -#include "../gxruntime/gxscene.h" +#include "bbsys.hpp" +#include "../gxruntime/gxscene.hpp" extern gxScene *gx_scene; diff --git a/RuntimeLib/bbfilesystem.cpp b/Runtime/lib/bbfilesystem.cpp similarity index 98% rename from RuntimeLib/bbfilesystem.cpp rename to Runtime/lib/bbfilesystem.cpp index d800eb6..ad308d8 100644 --- a/RuntimeLib/bbfilesystem.cpp +++ b/Runtime/lib/bbfilesystem.cpp @@ -1,7 +1,7 @@ -#include "std.h" -#include "bbfilesystem.h" -#include "bbstream.h" +#include "std.hpp" +#include "bbfilesystem.hpp" +#include "bbstream.hpp" #include gxFileSystem *gx_filesys; diff --git a/RuntimeLib/bbfilesystem.h b/Runtime/lib/bbfilesystem.hpp similarity index 58% rename from RuntimeLib/bbfilesystem.h rename to Runtime/lib/bbfilesystem.hpp index 39b8763..3bf31f4 100644 --- a/RuntimeLib/bbfilesystem.h +++ b/Runtime/lib/bbfilesystem.hpp @@ -2,8 +2,8 @@ #ifndef BBFILESYSTEM_H #define BBFILESYSTEM_H -#include "bbsys.h" -#include "../gxruntime/gxfilesystem.h" +#include "bbsys.hpp" +#include "../gxruntime/gxfilesystem.hpp" extern gxFileSystem *gx_filesys; diff --git a/RuntimeLib/bbgraphics.cpp b/Runtime/lib/bbgraphics.cpp similarity index 96% rename from RuntimeLib/bbgraphics.cpp rename to Runtime/lib/bbgraphics.cpp index 7073b79..dedce9a 100644 --- a/RuntimeLib/bbgraphics.cpp +++ b/Runtime/lib/bbgraphics.cpp @@ -1,1376 +1,1376 @@ - -#include "std.h" -#include "bbgraphics.h" -#include "bbinput.h" - -gxGraphics *gx_graphics; -gxCanvas *gx_canvas; - -struct GfxMode { - int w, h, d, caps; -}; - -class bbImage { -public: - bbImage(const vector &f) :frames(f) { - } - ~bbImage() { - for (int k = 0; k < frames.size(); ++k) { - gx_graphics->freeCanvas(frames[k]); - } - } - const vector &getFrames()const { - return frames; - } - void replaceFrame(int n, gxCanvas *c) { - gx_graphics->freeCanvas(frames[n]); - frames[n] = c; - } -private: - vector frames; -}; - -//degrees to radians -static const float s_degreesToRadians = 0.0174532925199432957692369076848861f; - -static int gx_driver; //current graphics driver - -static bool filter; -static bool auto_dirty; -static bool auto_midhandle; -static set image_set; -static int curs_x, curs_y; -static gxCanvas *p_canvas; - -static gxFont *curr_font; -static unsigned curr_color; -static unsigned curr_clsColor; - -static vector gfx_modes; - -#ifdef _DEBUG -static inline void debugImage(bbImage *i, int frame = 0) { - if (debug) { - if (!image_set.count(i)) ThrowRuntimeException("Image does not exist"); - if (frame >= i->getFrames().size()) ThrowRuntimeException("Image frame out of range"); - } -} - -static inline void debugFont(gxFont *f) { - if (debug) { - if (!gx_graphics->verifyFont(f)) ThrowRuntimeException("Font does not exist"); - } -} - -static inline void debugCanvas(gxCanvas *c) { - if (debug) { - if (!gx_graphics->verifyCanvas(c)) ThrowRuntimeException("Buffer does not exist"); - } -} - -static inline void debugDriver(int n) { - if (debug) { - if (n<1 || n>gx_runtime->enumerateGraphicsDrivers()) { - ThrowRuntimeException("Illegal graphics driver index"); - } - } -} - -static inline void debugMode(int n) { - if (debug) { - if (n<1 || n>gfx_modes.size()) { - ThrowRuntimeException("Illegal graphics mode index"); - } - } -} -#else -#define debugImage -#define debugFont -#define debugCanvas -#define debugDriver -#define debugMode -#endif - -void bbFreeImage(bbImage *i); - -static void freeGraphics() { - extern void blitz3d_close(); - blitz3d_close(); - while (image_set.size()) bbFreeImage(*image_set.begin()); - if (p_canvas) { - gx_graphics->freeCanvas(p_canvas); - p_canvas = 0; - } -} - -#define RED(_X_) ( ((_X_)>>16) & 0xff ) -#define GRN(_X_) ( ((_X_)>>8) & 0xff ) -#define BLU(_X_) ( (_X_) & 0xff ) - -static int getPixel(gxCanvas *c, float x, float y) { - debugCanvas(c); - - x -= .5f; y -= .5f; - float fx = floor(x), fy = floor(y); - int ix = fx, iy = fy; fx = x - fx; fy = y - fy; - - int tl = c->getPixel(ix, iy); - int tr = c->getPixel(ix + 1, iy); - int br = c->getPixel(ix + 1, iy + 1); - int bl = c->getPixel(ix, iy + 1); - - float w1 = (1 - fx)*(1 - fy), w2 = fx*(1 - fy), w3 = (1 - fx)*fy, w4 = fx*fy; - - float r = RED(tl)*w1 + RED(tr)*w2 + RED(bl)*w3 + RED(br)*w4; - float g = GRN(tl)*w1 + GRN(tr)*w2 + GRN(bl)*w3 + GRN(br)*w4; - float b = BLU(tl)*w1 + BLU(tr)*w2 + BLU(bl)*w3 + BLU(br)*w4; - - return (int(r + .5f) << 16) | (int(g + .5f) << 8) | int(b + .5f); -} - -struct vec2 { float x, y; }; - -static vec2 vrot(float m[2][2], const vec2 &v) { - vec2 t; t.x = m[0][0] * v.x + m[0][1] * v.y; t.y = m[1][0] * v.x + m[1][1] * v.y; - return t; -} - -static float vmin(float a, float b, float c, float d) { - float t = a; if (b < t) t = b; if (c < t) t = c; if (d < t) t = d; return t; -} - -static float vmax(float a, float b, float c, float d) { - float t = a; if (b > t) t = b; if (c > t) t = c; if (d > t) t = d; return t; -} - -static gxCanvas *tformCanvas(gxCanvas *c, float m[2][2], int x_handle, int y_handle) { - - vec2 v, v0, v1, v2, v3; - float i[2][2]; - float dt = 1.0f / (m[0][0] * m[1][1] - m[1][0] * m[0][1]); - i[0][0] = dt*m[1][1]; i[1][0] = -dt*m[1][0]; - i[0][1] = -dt*m[0][1]; i[1][1] = dt*m[0][0]; - - float ox = x_handle, oy = y_handle; - v0.x = -ox; v0.y = -oy; //tl - v1.x = c->getWidth() - ox; v1.y = -oy; //tr - v2.x = c->getWidth() - ox; v2.y = c->getHeight() - oy; //br - v3.x = -ox; v3.y = c->getHeight() - oy; //bl - v0 = vrot(m, v0); v1 = vrot(m, v1); v2 = vrot(m, v2); v3 = vrot(m, v3); - float minx = floor(vmin(v0.x, v1.x, v2.x, v3.x)); - float miny = floor(vmin(v0.y, v1.y, v2.y, v3.y)); - float maxx = ceil(vmax(v0.x, v1.x, v2.x, v3.x)); - float maxy = ceil(vmax(v0.y, v1.y, v2.y, v3.y)); - int iw = maxx - minx, ih = maxy - miny; - - gxCanvas *t = gx_graphics->createCanvas(iw, ih, 0); - t->setHandle(-minx, -miny); - t->setMask(c->getMask()); - - c->lock(); - t->lock(); - - v.y = miny + .5f; - for (int y = 0; y < ih; ++v.y, ++y) { - v.x = minx + .5f; - for (int x = 0; x < iw; ++v.x, ++x) { - vec2 q = vrot(i, v); - unsigned rgb = filter ? getPixel(c, q.x + ox, q.y + oy) : c->getPixel(floor(q.x + ox), floor(q.y + oy)); - t->setPixel(x, y, rgb); - } - } - - t->unlock(); - c->unlock(); - - return t; -} - -static bool saveCanvas(gxCanvas *c, const string &f) { - - ofstream out(f.c_str(), ios::binary); - if (!out.good()) return false; - - int tempsize = (c->getWidth() * 3 + 3)&~3; - - BITMAPFILEHEADER bf; - memset(&bf, 0, sizeof(bf)); - bf.bfType = 'MB'; - bf.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + tempsize*c->getHeight(); - bf.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); - BITMAPINFOHEADER bi; memset(&bi, 0, sizeof(bi)); - bi.biSize = sizeof(bi); - bi.biWidth = c->getWidth(); - bi.biHeight = c->getHeight(); - bi.biPlanes = 1; - bi.biBitCount = 24; - out.write((char*)&bf, sizeof(bf)); - out.write((char*)&bi, sizeof(bi)); - - unsigned char *temp = new unsigned char[tempsize]; - memset(temp, 0, tempsize); - - c->lock(); - for (int y = c->getHeight() - 1; y >= 0; --y) { - unsigned char *dest = temp; - for (int x = 0; x < c->getWidth(); ++x) { - unsigned rgb = c->getPixelFast(x, y); - *dest++ = rgb & 0xff; - *dest++ = (rgb >> 8) & 0xff; - *dest++ = (rgb >> 16) & 0xff; - } - out.write((char*)temp, tempsize); - } - c->unlock(); - - delete[] temp; - - return out.good(); -} - -int bbCountGfxDrivers() { - return gx_runtime->enumerateGraphicsDrivers(); -} - -BBStr * bbGfxDriverName(int n) { - debugDriver(n); - string t; int caps; - gx_runtime->graphicsDriverInfo(n - 1, &t, &caps); - return new BBStr(t); -} - -void bbSetGfxDriver(int n) { - debugDriver(n); - gfx_modes.clear(); - gx_driver = n - 1; -} - -int bbCountGfxModes() { - gfx_modes.clear(); - int n = gx_runtime->countGraphicsModes(gx_driver); - for (int k = 0; k < n; ++k) { - GfxMode m; - gx_runtime->graphicsModeInfo(gx_driver, k, &m.w, &m.h, &m.d, &m.caps); - gfx_modes.push_back(m); - } - return gfx_modes.size(); -} - -int bbGfxModeWidth(int n) { - debugMode(n); - return gfx_modes[n - 1].w; -} - -int bbGfxModeHeight(int n) { - debugMode(n); - return gfx_modes[n - 1].h; -} - -int bbGfxModeDepth(int n) { - debugMode(n); - return gfx_modes[n - 1].d; -} - -static int modeExists(int w, int h, int d, bool bb3d) { - int cnt = gx_runtime->countGraphicsModes(gx_driver); - for (int k = 0; k < cnt; ++k) { - int tw, th, td, tc; - gx_runtime->graphicsModeInfo(gx_driver, k, &tw, &th, &td, &tc); - if (bb3d && !(tc&gxRuntime::GFXMODECAPS_3D)) continue; - if (w == tw && h == th && d == td) return 1; - } - return 0; -} - -int bbGfxModeExists(int w, int h, int d) { - return modeExists(w, h, d, false); -} - -int bbGfxDriver3D(int n) { - debugDriver(n); - string t; int caps; - gx_runtime->graphicsDriverInfo(n - 1, &t, &caps); - return (caps & gxRuntime::GFXMODECAPS_3D) ? 1 : 0; -} - -int bbCountGfxModes3D() { - gfx_modes.clear(); - int n = gx_runtime->countGraphicsModes(gx_driver); - for (int k = 0; k < n; ++k) { - GfxMode m; - gx_runtime->graphicsModeInfo(gx_driver, k, &m.w, &m.h, &m.d, &m.caps); - if (m.caps & gxRuntime::GFXMODECAPS_3D) gfx_modes.push_back(m); - } - return gfx_modes.size(); -} - -int bbGfxMode3DExists(int w, int h, int d) { - return modeExists(w, h, d, true); -} - -int bbGfxMode3D(int n) { - debugMode(n); - return gfx_modes[n - 1].caps & gxRuntime::GFXMODECAPS_3D ? 1 : 0; -} - -int bbWindowed3D() { - int tc; - gx_runtime->windowedModeInfo(&tc); - return (tc & gxRuntime::GFXMODECAPS_3D) ? 1 : 0; -} - -int bbTotalVidMem() { - return gx_graphics->getTotalVidmem(); -} - -int bbAvailVidMem() { - return gx_graphics->getAvailVidmem(); -} - -void bbSetBuffer(gxCanvas *buff) { - debugCanvas(buff); - gx_canvas = buff; - curs_x = curs_y = 0; - gx_canvas->setOrigin(0, 0); - gx_canvas->setViewport(0, 0, gx_canvas->getWidth(), gx_canvas->getHeight()); - gx_canvas->setColor(curr_color); - gx_canvas->setClsColor(curr_clsColor); - gx_canvas->setFont(curr_font); - - // Switch Render Target - //if (gx_graphics != nullptr) { - // if (gx_graphics->dir3dDev != nullptr) { - // LPDIRECTDRAWSURFACE7 pddsOldRenderTarget = NULL, pddsNewRenderTarget = gx_canvas->getSurface(); - // gx_graphics->dir3dDev->GetRenderTarget(&pddsOldRenderTarget); - - // if (pddsOldRenderTarget) { - // LPDIRECTDRAWSURFACE7 pddsZBuffer = NULL; - // DDSCAPS2 ddscaps = { DDSCAPS_ZBUFFER, 0, 0, 0 }; - // pddsOldRenderTarget->GetAttachedSurface(&ddscaps, &pddsZBuffer); - - // if (pddsZBuffer) { - // pddsOldRenderTarget->DeleteAttachedSurface(0, pddsZBuffer); - // pddsNewRenderTarget->AddAttachedSurface(pddsZBuffer); - // //pddsZBuffer->Release(); - // } - // //pddsOldRenderTarget->Release(); - // } - - // gx_graphics->dir3dDev->SetRenderTarget(pddsNewRenderTarget, 0); - // } - //} -} - -gxCanvas *bbGraphicsBuffer() { - return gx_canvas; -} - -int bbLoadBuffer(gxCanvas *c, BBStr *str) { - debugCanvas(c); - string s = *str; delete str; - gxCanvas *t = gx_graphics->loadCanvas(s, 0); - if (!t) return 0; - float m[2][2]; - m[0][0] = (float)c->getWidth() / (float)t->getWidth(); - m[1][1] = (float)c->getHeight() / (float)t->getHeight(); - m[1][0] = m[0][1] = 0; - gxCanvas *p = tformCanvas(t, m, 0, 0); - gx_graphics->freeCanvas(t); - int ox, oy; - c->getOrigin(&ox, &oy); c->setOrigin(0, 0); - c->blit(0, 0, p, 0, 0, p->getWidth(), p->getHeight(), true); - gx_graphics->freeCanvas(p); - return 1; -} - -int bbSaveBuffer(gxCanvas *c, BBStr *str) { - debugCanvas(c); - string t = *str; delete str; - return saveCanvas(c, t) ? 1 : 0; -} - -void bbBufferDirty(gxCanvas *c) { - debugCanvas(c); - c->backup(); -} - -static void graphics(int w, int h, int d, int flags) { - freeGraphics(); - gx_runtime->closeGraphics(gx_graphics); - gx_graphics = gx_runtime->openGraphics(w, h, d, gx_driver, flags); - if (!gx_runtime->idle()) ThrowRuntimeException(0); - if (!gx_graphics) { - ThrowRuntimeException("Unable to set graphics mode"); - } - curr_clsColor = 0; - curr_color = 0xffffffff; - curr_font = gx_graphics->getDefaultFont(); - gxCanvas *buff = (flags & gxGraphics::GRAPHICS_3D) ? - gx_graphics->getBackCanvas() : gx_graphics->getFrontCanvas(); - bbSetBuffer(buff); -} - -void bbGraphics(int w, int h, int d, int mode) { - int flags = 0; - switch (mode) { - case 0:flags |= debug ? gxGraphics::GRAPHICS_WINDOWED : 0; break; - case 1:break; - case 2:flags |= gxGraphics::GRAPHICS_WINDOWED; break; - case 3:flags |= gxGraphics::GRAPHICS_WINDOWED | gxGraphics::GRAPHICS_SCALED; break; - case 6:flags |= gxGraphics::GRAPHICS_WINDOWED | gxGraphics::GRAPHICS_AUTOSUSPEND; break; - case 7:flags |= gxGraphics::GRAPHICS_WINDOWED | gxGraphics::GRAPHICS_SCALED | gxGraphics::GRAPHICS_AUTOSUSPEND; break; - default:ThrowRuntimeException("Illegal Graphics mode"); - } - graphics(w, h, d, flags); -} - -void bbGraphics3D(int w, int h, int d, int mode) { - int flags = gxGraphics::GRAPHICS_3D; - switch (mode) { - case 0:flags |= (debug && bbWindowed3D()) ? gxGraphics::GRAPHICS_WINDOWED : 0; break; - case 1:break; - case 2:flags |= gxGraphics::GRAPHICS_WINDOWED; break; - case 3:flags |= gxGraphics::GRAPHICS_WINDOWED | gxGraphics::GRAPHICS_SCALED; break; - case 6:flags |= gxGraphics::GRAPHICS_WINDOWED | gxGraphics::GRAPHICS_AUTOSUSPEND; break; - case 7:flags |= gxGraphics::GRAPHICS_WINDOWED | gxGraphics::GRAPHICS_SCALED | gxGraphics::GRAPHICS_AUTOSUSPEND; break; - default:ThrowRuntimeException("Illegal Graphics3D mode"); - } - graphics(w, h, d, flags); - extern void blitz3d_open(); - blitz3d_open(); -} - -void bbEndGraphics() { - freeGraphics(); - gx_runtime->closeGraphics(gx_graphics); - gx_graphics = gx_runtime->openGraphics(400, 300, 0, 0, gxGraphics::GRAPHICS_WINDOWED); - if (!gx_runtime->idle()) ThrowRuntimeException(0); - if (gx_graphics) { - curr_clsColor = 0; - curr_color = 0xffffffff; - curr_font = gx_graphics->getDefaultFont(); - bbSetBuffer(gx_graphics->getFrontCanvas()); - return; - } - ThrowRuntimeException("Unable to set graphics mode"); -} - -int bbGraphicsLost() { - return gx_runtime->graphicsLost(); -} - -void bbSetGamma(int r, int g, int b, float dr, float dg, float db) { - if (dr < 0) dr = 0; - else if (dr > 255.0f) dr = 255.0f; - if (dg < 0) dg = 0; - else if (dg > 255.0f) dg = 255.0f; - if (db < 0) db = 0; - else if (db > 255.0f) db = 255.0f; - gx_graphics->setGamma(r, g, b, dr, dg, db); -} - -void bbUpdateGamma(int calibrate) { - gx_graphics->updateGamma(!!calibrate); -} - -float bbGammaRed(int n) { - float dr, dg, db; - gx_graphics->getGamma(n, n, n, &dr, &dg, &db); - return dr; -} - -float bbGammaGreen(int n) { - float dr, dg, db; - gx_graphics->getGamma(n, n, n, &dr, &dg, &db); - return dg; -} - -float bbGammaBlue(int n) { - float dr, dg, db; - gx_graphics->getGamma(n, n, n, &dr, &dg, &db); - return db; -} - -gxCanvas *bbFrontBuffer() { - return gx_graphics->getFrontCanvas(); -} - -gxCanvas *bbBackBuffer() { - return gx_graphics->getBackCanvas(); -} - -void bbLockBuffer(gxCanvas *buff) { - if (buff) debugCanvas(buff); - (buff ? buff : gx_canvas)->lock(); -} - -void bbUnlockBuffer(gxCanvas *buff) { - if (buff) debugCanvas(buff); - (buff ? buff : gx_canvas)->unlock(); -} - -int bbReadPixel(int x, int y, gxCanvas *buff) { - if (buff) debugCanvas(buff); - return (buff ? buff : gx_canvas)->getPixel(x, y); -} - -void bbWritePixel(int x, int y, int argb, gxCanvas *buff) { - if (buff) debugCanvas(buff); - (buff ? buff : gx_canvas)->setPixel(x, y, argb); -} - -int bbReadPixelFast(int x, int y, gxCanvas *buff) { - return (buff ? buff : gx_canvas)->getPixelFast(x, y); -} - -void bbWritePixelFast(int x, int y, int argb, gxCanvas *buff) { - (buff ? buff : gx_canvas)->setPixelFast(x, y, argb); -} - -void bbCopyPixel(int src_x, int src_y, gxCanvas *src, int dest_x, int dest_y, gxCanvas *buff) { - (buff ? buff : gx_canvas)->copyPixel(dest_x, dest_y, src ? src : gx_canvas, src_x, src_y); -} - -void bbCopyPixelFast(int src_x, int src_y, gxCanvas *src, int dest_x, int dest_y, gxCanvas *buff) { - (buff ? buff : gx_canvas)->copyPixelFast(dest_x, dest_y, src ? src : gx_canvas, src_x, src_y); -} - -int bbScanLine() { - return gx_graphics->getScanLine(); -} - -void bbVWait(int n) { - gx_graphics->vwait(); - if (!gx_runtime->idle()) ThrowRuntimeException(0); -} - -void bbFlip(int vwait) { - gx_graphics->flip(vwait ? true : false); - if (!gx_runtime->idle()) ThrowRuntimeException(0); -} - -int bbGraphicsWidth() { - return gx_graphics->getWidth(); -} - -int bbGraphicsHeight() { - return gx_graphics->getHeight(); -} - -int bbGraphicsDepth() { - return gx_graphics->getDepth(); -} - -void bbOrigin(int x, int y) { - gx_canvas->setOrigin(x, y); -} - -void bbViewport(int x, int y, int w, int h) { - gx_canvas->setViewport(x, y, w, h); -} - -void bbColor(int r, int g, int b) { - gx_canvas->setColor(curr_color = (r << 16) | (g << 8) | b); -} - -void bbGetColor(int x, int y) { - gx_canvas->setColor(curr_color = gx_canvas->getPixel(x, y)); -} - -int bbColorRed() { - return (gx_canvas->getColor() >> 16) & 0xff; -} - -int bbColorGreen() { - return (gx_canvas->getColor() >> 8) & 0xff; -} - -int bbColorBlue() { - return gx_canvas->getColor() & 0xff; -} - -void bbClsColor(int r, int g, int b) { - gx_canvas->setClsColor(curr_clsColor = (r << 16) | (g << 8) | b); -} - -void bbSetFont(gxFont *f) { - debugFont(f); - gx_canvas->setFont(curr_font = f); -} - -void bbCls() { - gx_canvas->cls(); -} - -void bbPlot(int x, int y) { - gx_canvas->plot(x, y); -} - -void bbLine(int x1, int y1, int x2, int y2) { - gx_canvas->line(x1, y1, x2, y2); -} - -void bbRect(int x, int y, int w, int h, int solid) { - gx_canvas->rect(x, y, w, h, solid ? true : false); -} - -void bbOval(int x, int y, int w, int h, int solid) { - gx_canvas->oval(x, y, w, h, solid ? true : false); -} - -void bbText(int x, int y, BBStr *str, int centre_x, int centre_y) { - if (centre_x) x -= curr_font->getWidth(*str) / 2; - if (centre_y) y -= curr_font->getHeight() / 2; - gx_canvas->text(x, y, *str); - delete str; -} - -void bbCopyRect(int sx, int sy, int w, int h, int dx, int dy, gxCanvas *src, gxCanvas *dest) { - if (src) debugCanvas(src); - else src = gx_canvas; - if (dest) debugCanvas(dest); - else dest = gx_canvas; - dest->blit(dx, dy, src, sx, sy, w, h, true); -} - -gxFont *bbLoadFont(BBStr *name, int height, int bold, int italic, int underline) { - int flags = - (bold ? gxFont::FONT_BOLD : 0) | - (italic ? gxFont::FONT_ITALIC : 0) | - (underline ? gxFont::FONT_UNDERLINE : 0); - gxFont *font = gx_graphics->loadFont(*name, height, flags); - delete name; - return font; -} - -void bbFreeFont(gxFont *f) { - debugFont(f); - if (f == curr_font) bbSetFont(gx_graphics->getDefaultFont()); - gx_graphics->freeFont(f); -} - -int bbFontWidth() { - return curr_font->getWidth(); -} - -int bbFontHeight() { - return curr_font->getHeight(); -} - -int bbStringWidth(BBStr *str) { - string t = *str; delete str; - return curr_font->getWidth(t); -} - -int bbStringHeight(BBStr *str) { - delete str; - return curr_font->getHeight(); -} - -gxMovie *bbOpenMovie(BBStr *s) { - gxMovie *movie = gx_graphics->openMovie(*s, 0); delete s; - return movie; -} - -int bbDrawMovie(gxMovie *movie, int x, int y, int w, int h) { - if (w < 0) w = movie->getWidth(); - if (h < 0) h = movie->getHeight(); - int playing = movie->draw(gx_canvas, x, y, w, h); - if (!gx_runtime->idle()) ThrowRuntimeException(0); - return playing; -} - -int bbMovieWidth(gxMovie *movie) { - return movie->getWidth(); -} - -int bbMovieHeight(gxMovie *movie) { - return movie->getHeight(); -} - -int bbMoviePlaying(gxMovie *movie) { - return movie->isPlaying(); -} - -void bbCloseMovie(gxMovie *movie) { - gx_graphics->closeMovie(movie); -} - -bbImage *bbLoadImage(BBStr *s) { - string t = *s; delete s; - gxCanvas *c = gx_graphics->loadCanvas(t, 0); - if (!c) return 0; - if (auto_dirty) c->backup(); - if (auto_midhandle) c->setHandle(c->getWidth() / 2, c->getHeight() / 2); - vector frames; - frames.push_back(c); - bbImage *i = new bbImage(frames); - image_set.insert(i); - return i; -} - -bbImage *bbLoadAnimImage(BBStr *s, int w, int h, int first, int cnt) { - - string t = *s; delete s; - - if (cnt < 1) ThrowRuntimeException("Illegal frame count"); - if (first < 0) ThrowRuntimeException("Illegal first frame"); - - gxCanvas *pic = gx_graphics->loadCanvas(t, gxCanvas::CANVAS_NONDISPLAY); - if (!pic) return 0; - - //frames per row, per picture - int fpr = pic->getWidth() / w; - int fpp = pic->getHeight() / h*fpr; - if (first + cnt > fpp) { - gx_graphics->freeCanvas(pic); - ThrowRuntimeException("Not enough frames in bitmap"); - } - - //x,y of first frame... - vector frames; - int src_x = first%fpr*w, src_y = first / fpr*h; - - for (int k = 0; k < cnt; ++k) { - gxCanvas *c = gx_graphics->createCanvas(w, h, 0); - if (!c) { - for (--k; k >= 0; --k) gx_graphics->freeCanvas(frames[k]); - gx_graphics->freeCanvas(pic); return 0; - } - c->blit(0, 0, pic, src_x, src_y, w, h, true); - if (auto_dirty) c->backup(); - if (auto_midhandle) c->setHandle(c->getWidth() / 2, c->getHeight() / 2); - frames.push_back(c); - src_x += w; if (src_x + w > pic->getWidth()) { src_x = 0; src_y += h; } - } - gx_graphics->freeCanvas(pic); - bbImage *i = new bbImage(frames); - image_set.insert(i); - return i; -} - -bbImage *bbCopyImage(bbImage *i) { - debugImage(i); - vector frames; - const vector &f = i->getFrames(); - for (int k = 0; k < f.size(); ++k) { - gxCanvas *t = f[k]; - gxCanvas *c = gx_graphics->createCanvas(t->getWidth(), t->getHeight(), 0); - if (!c) { - for (--k; k >= 0; --k) gx_graphics->freeCanvas(frames[k]); - return 0; - } - int x, y; - t->getHandle(&x, &y); - t->setHandle(0, 0); - c->blit(0, 0, t, 0, 0, t->getWidth(), t->getHeight(), true); - if (auto_dirty) c->backup(); - t->setHandle(x, y); - c->setHandle(x, y); - c->setMask(t->getMask()); - frames.push_back(c); - } - bbImage *t = new bbImage(frames); - image_set.insert(t); - return t; -} - -bbImage *bbCreateImage(int w, int h, int n) { - vector frames; - for (int k = 0; k < n; ++k) { - gxCanvas *c = gx_graphics->createCanvas(w, h, 0); - if (!c) { - for (--k; k >= 0; --k) gx_graphics->freeCanvas(frames[k]); - return 0; - } - if (auto_dirty) c->backup(); - if (auto_midhandle) c->setHandle(c->getWidth() / 2, c->getHeight() / 2); - frames.push_back(c); - } - bbImage *i = new bbImage(frames); - image_set.insert(i); - return i; -} - -void bbFreeImage(bbImage *i) { - if (!image_set.erase(i)) return; - const vector &f = i->getFrames(); - for (int k = 0; k < f.size(); ++k) { - if (f[k] == gx_canvas) { - bbSetBuffer(gx_graphics->getFrontCanvas()); - break; - } - } - delete i; -} - -int bbSaveImage(bbImage *i, BBStr *str, int n) { - debugImage(i, n); - string t = *str; delete str; - gxCanvas *c = i->getFrames()[n]; - return saveCanvas(c, t) ? 1 : 0; -} - -void bbGrabImage(bbImage *i, int x, int y, int n) { - debugImage(i, n); - gxCanvas *c = i->getFrames()[n]; - int src_ox, src_oy, dst_hx, dst_hy; - gx_canvas->getOrigin(&src_ox, &src_oy); - c->getHandle(&dst_hx, &dst_hy); - x += src_ox - dst_hx; y += src_oy - dst_hy; - c->setViewport(0, 0, c->getWidth(), c->getHeight()); - c->blit(0, 0, gx_canvas, x, y, c->getWidth(), c->getHeight(), true); - if (auto_dirty) c->backup(); -} - -gxCanvas *bbImageBuffer(bbImage *i, int n) { - debugImage(i, n); - return i->getFrames()[n]; -} - -void bbDrawImage(bbImage *i, int x, int y, int frame) { - debugImage(i, frame); - gxCanvas *c = i->getFrames()[frame]; - gx_canvas->blit(x, y, c, 0, 0, c->getWidth(), c->getHeight(), false); -} - -void bbDrawBlock(bbImage *i, int x, int y, int frame) { - debugImage(i, frame); - gxCanvas *c = i->getFrames()[frame]; - gx_canvas->blit(x, y, c, 0, 0, c->getWidth(), c->getHeight(), true); -} - -static void tile(bbImage *i, int x, int y, int frame, bool solid) { - gxCanvas *c = i->getFrames()[frame]; - - int hx, hy; - c->getHandle(&hx, &hy); - int w = c->getWidth(), h = c->getHeight(); - - int ox, oy, vp_x, vp_y, vp_w, vp_h; - gx_canvas->getOrigin(&ox, &oy); - gx_canvas->getViewport(&vp_x, &vp_y, &vp_w, &vp_h); - int dx = vp_x - ox + hx; - int dy = vp_y - oy + hy; - x -= dx; - y -= dy; - dx += (x >= 0 ? x%w : w - (-x%w)); - dy += (y >= 0 ? y%h : h - (-y%h)); - - for (y = -h; y < vp_h; y += h) { - for (x = -w; x < vp_w; x += w) { - gx_canvas->blit(x + dx, y + dy, c, 0, 0, w, h, solid); - } - } -} - -void bbTileImage(bbImage *i, int x, int y, int frame) { - debugImage(i, frame); - tile(i, x, y, frame, false); -} - -void bbTileBlock(bbImage *i, int x, int y, int frame) { - debugImage(i, frame); - tile(i, x, y, frame, true); -} - -void bbDrawImageRect(bbImage *i, int x, int y, int r_x, int r_y, int r_w, int r_h, int frame) { - debugImage(i, frame); - gxCanvas *c = i->getFrames()[frame]; - gx_canvas->blit(x, y, c, r_x, r_y, r_w, r_h, false); -} - -void bbDrawBlockRect(bbImage *i, int x, int y, int r_x, int r_y, int r_w, int r_h, int frame) { - debugImage(i, frame); - gxCanvas *c = i->getFrames()[frame]; - gx_canvas->blit(x, y, c, r_x, r_y, r_w, r_h, true); -} - -void bbMaskImage(bbImage *i, int r, int g, int b) { - debugImage(i); - unsigned argb = (r << 16) | (g << 8) | b; - const vector &f = i->getFrames(); - for (int k = 0; k < f.size(); ++k) f[k]->setMask(argb); -} - -void bbHandleImage(bbImage *i, int x, int y) { - debugImage(i); - const vector &f = i->getFrames(); - for (int k = 0; k < f.size(); ++k) f[k]->setHandle(x, y); -} - -void bbMidHandle(bbImage *i) { - debugImage(i); - const vector &f = i->getFrames(); - for (int k = 0; k < f.size(); ++k) f[k]->setHandle(f[k]->getWidth() / 2, f[k]->getHeight() / 2); -} - -void bbAutoMidHandle(int enable) { - auto_midhandle = enable ? true : false; -} - -int bbImageWidth(bbImage *i) { - debugImage(i); - return i->getFrames()[0]->getWidth(); -} - -int bbImageHeight(bbImage *i) { - debugImage(i); - return i->getFrames()[0]->getHeight(); -} - -int bbImageXHandle(bbImage *i) { - debugImage(i); - int x, y; - i->getFrames()[0]->getHandle(&x, &y); - return x; -} - -int bbImageYHandle(bbImage *i) { - debugImage(i); - int x, y; - i->getFrames()[0]->getHandle(&x, &y); - return y; -} - -int bbImagesOverlap(bbImage *i1, int x1, int y1, bbImage *i2, int x2, int y2) { - debugImage(i1); - debugImage(i2); - gxCanvas *c1 = i1->getFrames()[0]; - gxCanvas *c2 = i2->getFrames()[0]; - return c1->collide(x1, y1, c2, x2, y2, true); -} - -int bbImagesCollide(bbImage *i1, int x1, int y1, int f1, bbImage *i2, int x2, int y2, int f2) { - debugImage(i1, f1); - debugImage(i2, f2); - gxCanvas *c1 = i1->getFrames()[f1]; - gxCanvas *c2 = i2->getFrames()[f2]; - return c1->collide(x1, y1, c2, x2, y2, false); -} - -int bbRectsOverlap(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2) { - if (x1 + w1 <= x2 || x1 >= x2 + w2 || y1 + h1 <= y2 || y1 >= y2 + h2) return 0; - return 1; -} - -int bbImageRectOverlap(bbImage *i, int x, int y, int x2, int y2, int w2, int h2) { - debugImage(i); - gxCanvas *c = i->getFrames()[0]; - return c->rect_collide(x, y, x2, y2, w2, h2, true); -} - -int bbImageRectCollide(bbImage *i, int x, int y, int f, int x2, int y2, int w2, int h2) { - debugImage(i, f); - gxCanvas *c = i->getFrames()[f]; - return c->rect_collide(x, y, x2, y2, w2, h2, false); -} - -void bbTFormImage(bbImage *i, float a, float b, float c, float d) { - debugImage(i); - const vector &f = i->getFrames(); - int k; - for (k = 0; k < f.size(); ++k) { - if (f[k] == gx_canvas) { - bbSetBuffer(gx_graphics->getFrontCanvas()); - break; - } - } - float m[2][2]; - m[0][0] = a; m[1][0] = b; m[0][1] = c; m[1][1] = d; - for (k = 0; k < f.size(); ++k) { - gxCanvas *c = f[k]; - int hx, hy; c->getHandle(&hx, &hy); - gxCanvas *t = tformCanvas(c, m, hx, hy); - i->replaceFrame(k, t); - t->backup(); - } -} - -void bbScaleImage(bbImage *i, float w, float h) { - debugImage(i); - bbTFormImage(i, w, 0, 0, h); -} - -void bbResizeImage(bbImage *i, float w, float h) { - debugImage(i); - gxCanvas *c = i->getFrames()[0]; - bbTFormImage(i, w / (float)c->getWidth(), 0, 0, h / (float)c->getHeight()); -} - -void bbRotateImage(bbImage *i, float d) { - debugImage(i); - d *= -s_degreesToRadians; - bbTFormImage(i, cos(d), -sin(d), sin(d), cos(d)); -} - -void bbTFormFilter(int enable) { - filter = enable ? true : false; -} - -static int p_ox, p_oy, p_hx, p_hy, p_vpx, p_vpy, p_vpw, p_vph; - -static gxCanvas *startPrinting() { - - gxCanvas *c = gx_graphics->getFrontCanvas(); - - c->lock(); - c->unlock(); - - c->getOrigin(&p_ox, &p_oy); - c->getHandle(&p_hx, &p_hy); - c->getViewport(&p_vpx, &p_vpy, &p_vpw, &p_vph); - - c->setOrigin(0, 0); - c->setHandle(0, 0); - c->setViewport(0, 0, c->getWidth(), c->getHeight()); - if (c != gx_canvas) { - c->setFont(curr_font); - c->setColor(curr_color); - } - - int dy = curs_y + curr_font->getHeight() - c->getHeight(); - if (dy > 0) { - curs_y = c->getHeight() - curr_font->getHeight(); - c->blit(0, 0, c, 0, dy, c->getWidth(), c->getHeight() - dy, true); - c->setColor(curr_clsColor); - c->rect(0, c->getHeight() - dy, c->getWidth(), dy, true); - c->setColor(curr_color); - } - return c; -} - -static void endPrinting(gxCanvas *c) { - c->setViewport(p_vpx, p_vpy, p_vpw, p_vph); - c->setHandle(p_hx, p_hy); - c->setOrigin(p_ox, p_oy); - if (c == gx_canvas) c->setColor(curr_color); - if (!gx_runtime->idle()) ThrowRuntimeException(0); -} - -void bbWrite(BBStr *str) { - gxCanvas *c = startPrinting(); - c->text(curs_x, curs_y, *str); - curs_x += curr_font->getWidth(*str); - endPrinting(c); - delete str; -} - -void bbPrint(BBStr *str) { - gxCanvas *c = startPrinting(); - c->text(curs_x, curs_y, *str); - curs_x = 0; - curs_y += curr_font->getHeight(); - endPrinting(c); - delete str; -} - -BBStr *bbInput(BBStr *prompt) { - gxCanvas *c = startPrinting(); - string t = *prompt; delete prompt; - - //get temp canvas - if (!p_canvas || p_canvas->getWidth() < c->getWidth() || p_canvas->getHeight() < curr_font->getHeight() * 2) { - if (p_canvas) gx_graphics->freeCanvas(p_canvas); - p_canvas = gx_graphics->createCanvas(c->getWidth(), curr_font->getHeight() * 2, 0); - if (!p_canvas) { - endPrinting(c); - return new BBStr(); - } - } - //draw prompt - c->text(curs_x, curs_y, t); - curs_x += curr_font->getWidth(t); - - p_canvas->setFont(curr_font); - p_canvas->setColor(curr_color); - p_canvas->blit(0, 0, c, 0, curs_y, c->getWidth(), curr_font->getHeight(), true); - - string str; - bool go = true; - int curs = 0, last_key = 0, last_time, rep_delay; - - while (go) { - - //render all text - //calc curs x and width - int cx = curs_x + curr_font->getWidth(str.substr(0, curs)); - int cw = curr_font->getWidth(curs < str.size() ? str.substr(curs, 1) : "X"); - - //wait for a key - int key = 0, st = gx_runtime->getMilliSecs(), tc = -1; - - while (gx_runtime->idle()) { - int t = gx_runtime->getMilliSecs(); - int n = (t - st) / 320; - if (n != tc) { - tc = n; - if (!(tc & 1)) { //cursor ON - c->setColor(curr_clsColor ^ 0xffffff); - c->rect(cx, curs_y, cw, curr_font->getHeight(), true); - c->setColor(curr_clsColor); - } else { //cursor OFF - c->blit(cx, curs_y, p_canvas, cx, 0, cw, curr_font->getHeight(), true); - c->setColor(curr_color); - } - c->text(cx, curs_y, str.substr(curs, 1)); - } - if (key = gx_keyboard->getKey()) { - if (int asc = gx_input->toAscii(key)) { - rep_delay = 280; - last_key = key; - last_time = t; - key = asc; - break; - } - } - if (last_key && gx_keyboard->keyDown(last_key)) { - if (t - last_time > rep_delay) { - if (key = gx_input->toAscii(last_key)) { - last_time += rep_delay; - rep_delay = 40; - break; - } - } - } else last_key = 0; - gx_runtime->delay(20); - } - - //check the key - switch (key) { - case 0: - go = false; - str = ""; - break; - case 8: - if (curs) { - str = str.substr(0, curs - 1) + str.substr(curs); - --curs; - } - break; - case 27: - curs = 0; str = ""; - break; - case gxInput::ASC_DELETE: - if (curs < str.size()) str = str.substr(0, curs) + str.substr(curs + 1); - break; - case gxInput::ASC_HOME: - curs = 0; - break; - case gxInput::ASC_END: - curs = str.size(); - break; - case gxInput::ASC_LEFT: - if (curs) --curs; - break; - case gxInput::ASC_RIGHT: - if (curs < str.size()) ++curs; - break; - case '\r': - go = false; - break; - default: - if (curr_font->isPrintable(key)) { - str = str.substr(0, curs) + char(key) + str.substr(curs); - ++curs; - } - } - - //render text - p_canvas->blit(0, curr_font->getHeight(), p_canvas, 0, 0, c->getWidth(), curr_font->getHeight(), true); - p_canvas->text(curs_x, curr_font->getHeight(), str); - c->blit(0, curs_y, p_canvas, 0, curr_font->getHeight(), c->getWidth(), curr_font->getHeight(), true); - } - - curs_x = 0; - curs_y += curr_font->getHeight(); - endPrinting(c); - return new BBStr(str); -} - -void bbLocate(int x, int y) { - gxCanvas *c = gx_graphics->getFrontCanvas(); - curs_x = x < 0 ? 0 : (x > c->getWidth() ? c->getWidth() : x); - curs_y = y < 0 ? 0 : (y > c->getHeight() ? c->getHeight() : y); -} - -void bbShowPointer() { - gx_runtime->setPointerVisible(true); -} - -void bbHidePointer() { - gx_runtime->setPointerVisible(false); -} - -bool graphics_create() { - p_canvas = 0; - filter = true; - gx_driver = 0; - freeGraphics(); - auto_dirty = true; - auto_midhandle = false; - gx_graphics = gx_runtime->openGraphics(400, 300, 0, 0, gxGraphics::GRAPHICS_WINDOWED); - if (gx_graphics) { - curr_clsColor = 0; - curr_color = 0xffffffff; - curr_font = gx_graphics->getDefaultFont(); - bbSetBuffer(bbFrontBuffer()); - return true; - } - return false; -} - -bool graphics_destroy() { - freeGraphics(); - gfx_modes.clear(); - if (gx_graphics) { - gx_runtime->closeGraphics(gx_graphics); - gx_graphics = 0; - } - return true; -} - -void graphics_link(void(*rtSym)(const char *sym, void *pc)) { - - //gfx driver info - rtSym("%CountGfxDrivers", bbCountGfxDrivers); - rtSym("$GfxDriverName%driver", bbGfxDriverName); - rtSym("SetGfxDriver%driver", bbSetGfxDriver); - - //gfx mode info - rtSym("%CountGfxModes", bbCountGfxModes); - rtSym("%GfxModeExists%width%height%depth", bbGfxModeExists); - - rtSym("%GfxModeWidth%mode", bbGfxModeWidth); - rtSym("%GfxModeHeight%mode", bbGfxModeHeight); - rtSym("%GfxModeDepth%mode", bbGfxModeDepth); - rtSym("%AvailVidMem", bbAvailVidMem); - rtSym("%TotalVidMem", bbTotalVidMem); - - rtSym("%GfxDriver3D%driver", bbGfxDriver3D); - rtSym("%CountGfxModes3D", bbCountGfxModes3D); - rtSym("%GfxMode3DExists%width%height%depth", bbGfxMode3DExists); - rtSym("%GfxMode3D%mode", bbGfxMode3D); - rtSym("%Windowed3D", bbWindowed3D); - - //display mode -// rtSym( "Graphics%width%height%depth=0%mode=0",bbGraphics ); - rtSym("Graphics3D%width%height%depth=0%mode=0", bbGraphics3D); - rtSym("EndGraphics", bbEndGraphics); - rtSym("%GraphicsLost", bbGraphicsLost); - - rtSym("SetGamma%src_red%src_green%src_blue#dest_red#dest_green#dest_blue", bbSetGamma); - rtSym("UpdateGamma%calibrate=0", bbUpdateGamma); - rtSym("#GammaRed%red", bbGammaRed); - rtSym("#GammaGreen%green", bbGammaGreen); - rtSym("#GammaBlue%blue", bbGammaBlue); - - rtSym("%FrontBuffer", bbFrontBuffer); - rtSym("%BackBuffer", bbBackBuffer); - rtSym("%ScanLine", bbScanLine); - rtSym("VWait%frames=1", bbVWait); - rtSym("Flip%vwait=1", bbFlip); - rtSym("%GraphicsWidth", bbGraphicsWidth); - rtSym("%GraphicsHeight", bbGraphicsHeight); - rtSym("%GraphicsDepth", bbGraphicsDepth); - - //buffer management - rtSym("SetBuffer%buffer", bbSetBuffer); - rtSym("%GraphicsBuffer", bbGraphicsBuffer); - rtSym("%LoadBuffer%buffer$bmpfile", bbLoadBuffer); - rtSym("%SaveBuffer%buffer$bmpfile", bbSaveBuffer); - rtSym("BufferDirty%buffer", bbBufferDirty); - - //fast pixel reads/write - rtSym("LockBuffer%buffer=0", bbLockBuffer); - rtSym("UnlockBuffer%buffer=0", bbUnlockBuffer); - rtSym("%ReadPixel%x%y%buffer=0", bbReadPixel); - rtSym("WritePixel%x%y%argb%buffer=0", bbWritePixel); - rtSym("%ReadPixelFast%x%y%buffer=0", bbReadPixelFast); - rtSym("WritePixelFast%x%y%argb%buffer=0", bbWritePixelFast); - rtSym("CopyPixel%src_x%src_y%src_buffer%dest_x%dest_y%dest_buffer=0", bbCopyPixel); - rtSym("CopyPixelFast%src_x%src_y%src_buffer%dest_x%dest_y%dest_buffer=0", bbCopyPixelFast); - - //rendering - rtSym("Origin%x%y", bbOrigin); - rtSym("Viewport%x%y%width%height", bbViewport); - rtSym("Color%red%green%blue", bbColor); - rtSym("GetColor%x%y", bbGetColor); - rtSym("%ColorRed", bbColorRed); - rtSym("%ColorGreen", bbColorGreen); - rtSym("%ColorBlue", bbColorBlue); - rtSym("ClsColor%red%green%blue", bbClsColor); - rtSym("SetFont%font", bbSetFont); - rtSym("Cls", bbCls); - rtSym("Plot%x%y", bbPlot); - rtSym("Rect%x%y%width%height%solid=1", bbRect); - rtSym("Oval%x%y%width%height%solid=1", bbOval); - rtSym("Line%x1%y1%x2%y2", bbLine); - rtSym("Text%x%y$text%centre_x=0%centre_y=0", bbText); - rtSym("CopyRect%source_x%source_y%width%height%dest_x%dest_y%src_buffer=0%dest_buffer=0", bbCopyRect); - - //fonts - rtSym("%LoadFont$fontname%height=12%bold=0%italic=0%underline=0", bbLoadFont); - rtSym("FreeFont%font", bbFreeFont); - rtSym("%FontWidth", bbFontWidth); - rtSym("%FontHeight", bbFontHeight); - rtSym("%StringWidth$string", bbStringWidth); - rtSym("%StringHeight$string", bbStringHeight); - - //movies - rtSym("%OpenMovie$file", bbOpenMovie); - rtSym("%DrawMovie%movie%x=0%y=0%w=-1%h=-1", bbDrawMovie); - rtSym("%MovieWidth%movie", bbMovieWidth); - rtSym("%MovieHeight%movie", bbMovieHeight); - rtSym("%MoviePlaying%movie", bbMoviePlaying); - rtSym("CloseMovie%movie", bbCloseMovie); - - rtSym("%LoadImage$bmpfile", bbLoadImage); - rtSym("%LoadAnimImage$bmpfile%cellwidth%cellheight%first%count", bbLoadAnimImage); - rtSym("%CopyImage%image", bbCopyImage); - rtSym("%CreateImage%width%height%frames=1", bbCreateImage); - rtSym("FreeImage%image", bbFreeImage); - rtSym("%SaveImage%image$bmpfile%frame=0", bbSaveImage); - - rtSym("GrabImage%image%x%y%frame=0", bbGrabImage); - rtSym("%ImageBuffer%image%frame=0", bbImageBuffer); - rtSym("DrawImage%image%x%y%frame=0", bbDrawImage); - rtSym("DrawBlock%image%x%y%frame=0", bbDrawBlock); - rtSym("TileImage%image%x=0%y=0%frame=0", bbTileImage); - rtSym("TileBlock%image%x=0%y=0%frame=0", bbTileBlock); - rtSym("DrawImageRect%image%x%y%rect_x%rect_y%rect_width%rect_height%frame=0", bbDrawImageRect); - rtSym("DrawBlockRect%image%x%y%rect_x%rect_y%rect_width%rect_height%frame=0", bbDrawBlockRect); - rtSym("MaskImage%image%red%green%blue", bbMaskImage); - rtSym("HandleImage%image%x%y", bbHandleImage); - rtSym("MidHandle%image", bbMidHandle); - rtSym("AutoMidHandle%enable", bbAutoMidHandle); - rtSym("%ImageWidth%image", bbImageWidth); - rtSym("%ImageHeight%image", bbImageHeight); - rtSym("%ImageXHandle%image", bbImageXHandle); - rtSym("%ImageYHandle%image", bbImageYHandle); - - rtSym("ScaleImage%image#xscale#yscale", bbScaleImage); - rtSym("ResizeImage%image#width#height", bbResizeImage); - rtSym("RotateImage%image#angle", bbRotateImage); - rtSym("TFormImage%image#a#b#c#d", bbTFormImage); - rtSym("TFormFilter%enable", bbTFormFilter); - - rtSym("%ImagesOverlap%image1%x1%y1%image2%x2%y2", bbImagesOverlap); - rtSym("%ImagesCollide%image1%x1%y1%frame1%image2%x2%y2%frame2", bbImagesCollide); - rtSym("%RectsOverlap%x1%y1%width1%height1%x2%y2%width2%height2", bbRectsOverlap); - rtSym("%ImageRectOverlap%image%x%y%rect_x%rect_y%rect_width%rect_height", bbImageRectOverlap); - rtSym("%ImageRectCollide%image%x%y%frame%rect_x%rect_y%rect_width%rect_height", bbImageRectCollide); - - rtSym("Write$string", bbWrite); - rtSym("Print$string=\"\"", bbPrint); - rtSym("$Input$prompt=\"\"", bbInput); - rtSym("Locate%x%y", bbLocate); - - rtSym("ShowPointer", bbShowPointer); - rtSym("HidePointer", bbHidePointer); -} - -// NVidia Optimus -extern "C" { - _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; + +#include "std.hpp" +#include "bbgraphics.hpp" +#include "bbinput.hpp" + +gxGraphics *gx_graphics; +gxCanvas *gx_canvas; + +struct GfxMode { + int w, h, d, caps; +}; + +class bbImage { +public: + bbImage(const vector &f) :frames(f) { + } + ~bbImage() { + for (int k = 0; k < frames.size(); ++k) { + gx_graphics->freeCanvas(frames[k]); + } + } + const vector &getFrames()const { + return frames; + } + void replaceFrame(int n, gxCanvas *c) { + gx_graphics->freeCanvas(frames[n]); + frames[n] = c; + } +private: + vector frames; +}; + +//degrees to radians +static const float s_degreesToRadians = 0.0174532925199432957692369076848861f; + +static int gx_driver; //current graphics driver + +static bool filter; +static bool auto_dirty; +static bool auto_midhandle; +static set image_set; +static int curs_x, curs_y; +static gxCanvas *p_canvas; + +static gxFont *curr_font; +static unsigned curr_color; +static unsigned curr_clsColor; + +static vector gfx_modes; + +#ifdef _DEBUG +static inline void debugImage(bbImage *i, int frame = 0) { + if (debug) { + if (!image_set.count(i)) ThrowRuntimeException("Image does not exist"); + if (frame >= i->getFrames().size()) ThrowRuntimeException("Image frame out of range"); + } +} + +static inline void debugFont(gxFont *f) { + if (debug) { + if (!gx_graphics->verifyFont(f)) ThrowRuntimeException("Font does not exist"); + } +} + +static inline void debugCanvas(gxCanvas *c) { + if (debug) { + if (!gx_graphics->verifyCanvas(c)) ThrowRuntimeException("Buffer does not exist"); + } +} + +static inline void debugDriver(int n) { + if (debug) { + if (n<1 || n>gx_runtime->enumerateGraphicsDrivers()) { + ThrowRuntimeException("Illegal graphics driver index"); + } + } +} + +static inline void debugMode(int n) { + if (debug) { + if (n<1 || n>gfx_modes.size()) { + ThrowRuntimeException("Illegal graphics mode index"); + } + } +} +#else +#define debugImage +#define debugFont +#define debugCanvas +#define debugDriver +#define debugMode +#endif + +void bbFreeImage(bbImage *i); + +static void freeGraphics() { + extern void blitz3d_close(); + blitz3d_close(); + while (image_set.size()) bbFreeImage(*image_set.begin()); + if (p_canvas) { + gx_graphics->freeCanvas(p_canvas); + p_canvas = 0; + } +} + +#define RED(_X_) ( ((_X_)>>16) & 0xff ) +#define GRN(_X_) ( ((_X_)>>8) & 0xff ) +#define BLU(_X_) ( (_X_) & 0xff ) + +static int getPixel(gxCanvas *c, float x, float y) { + debugCanvas(c); + + x -= .5f; y -= .5f; + float fx = floor(x), fy = floor(y); + int ix = fx, iy = fy; fx = x - fx; fy = y - fy; + + int tl = c->getPixel(ix, iy); + int tr = c->getPixel(ix + 1, iy); + int br = c->getPixel(ix + 1, iy + 1); + int bl = c->getPixel(ix, iy + 1); + + float w1 = (1 - fx)*(1 - fy), w2 = fx*(1 - fy), w3 = (1 - fx)*fy, w4 = fx*fy; + + float r = RED(tl)*w1 + RED(tr)*w2 + RED(bl)*w3 + RED(br)*w4; + float g = GRN(tl)*w1 + GRN(tr)*w2 + GRN(bl)*w3 + GRN(br)*w4; + float b = BLU(tl)*w1 + BLU(tr)*w2 + BLU(bl)*w3 + BLU(br)*w4; + + return (int(r + .5f) << 16) | (int(g + .5f) << 8) | int(b + .5f); +} + +struct vec2 { float x, y; }; + +static vec2 vrot(float m[2][2], const vec2 &v) { + vec2 t; t.x = m[0][0] * v.x + m[0][1] * v.y; t.y = m[1][0] * v.x + m[1][1] * v.y; + return t; +} + +static float vmin(float a, float b, float c, float d) { + float t = a; if (b < t) t = b; if (c < t) t = c; if (d < t) t = d; return t; +} + +static float vmax(float a, float b, float c, float d) { + float t = a; if (b > t) t = b; if (c > t) t = c; if (d > t) t = d; return t; +} + +static gxCanvas *tformCanvas(gxCanvas *c, float m[2][2], int x_handle, int y_handle) { + + vec2 v, v0, v1, v2, v3; + float i[2][2]; + float dt = 1.0f / (m[0][0] * m[1][1] - m[1][0] * m[0][1]); + i[0][0] = dt*m[1][1]; i[1][0] = -dt*m[1][0]; + i[0][1] = -dt*m[0][1]; i[1][1] = dt*m[0][0]; + + float ox = x_handle, oy = y_handle; + v0.x = -ox; v0.y = -oy; //tl + v1.x = c->getWidth() - ox; v1.y = -oy; //tr + v2.x = c->getWidth() - ox; v2.y = c->getHeight() - oy; //br + v3.x = -ox; v3.y = c->getHeight() - oy; //bl + v0 = vrot(m, v0); v1 = vrot(m, v1); v2 = vrot(m, v2); v3 = vrot(m, v3); + float minx = floor(vmin(v0.x, v1.x, v2.x, v3.x)); + float miny = floor(vmin(v0.y, v1.y, v2.y, v3.y)); + float maxx = ceil(vmax(v0.x, v1.x, v2.x, v3.x)); + float maxy = ceil(vmax(v0.y, v1.y, v2.y, v3.y)); + int iw = maxx - minx, ih = maxy - miny; + + gxCanvas *t = gx_graphics->createCanvas(iw, ih, 0); + t->setHandle(-minx, -miny); + t->setMask(c->getMask()); + + c->lock(); + t->lock(); + + v.y = miny + .5f; + for (int y = 0; y < ih; ++v.y, ++y) { + v.x = minx + .5f; + for (int x = 0; x < iw; ++v.x, ++x) { + vec2 q = vrot(i, v); + unsigned rgb = filter ? getPixel(c, q.x + ox, q.y + oy) : c->getPixel(floor(q.x + ox), floor(q.y + oy)); + t->setPixel(x, y, rgb); + } + } + + t->unlock(); + c->unlock(); + + return t; +} + +static bool saveCanvas(gxCanvas *c, const string &f) { + + ofstream out(f.c_str(), ios::binary); + if (!out.good()) return false; + + int tempsize = (c->getWidth() * 3 + 3)&~3; + + BITMAPFILEHEADER bf; + memset(&bf, 0, sizeof(bf)); + bf.bfType = 'MB'; + bf.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + tempsize*c->getHeight(); + bf.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); + BITMAPINFOHEADER bi; memset(&bi, 0, sizeof(bi)); + bi.biSize = sizeof(bi); + bi.biWidth = c->getWidth(); + bi.biHeight = c->getHeight(); + bi.biPlanes = 1; + bi.biBitCount = 24; + out.write((char*)&bf, sizeof(bf)); + out.write((char*)&bi, sizeof(bi)); + + unsigned char *temp = new unsigned char[tempsize]; + memset(temp, 0, tempsize); + + c->lock(); + for (int y = c->getHeight() - 1; y >= 0; --y) { + unsigned char *dest = temp; + for (int x = 0; x < c->getWidth(); ++x) { + unsigned rgb = c->getPixelFast(x, y); + *dest++ = rgb & 0xff; + *dest++ = (rgb >> 8) & 0xff; + *dest++ = (rgb >> 16) & 0xff; + } + out.write((char*)temp, tempsize); + } + c->unlock(); + + delete[] temp; + + return out.good(); +} + +int bbCountGfxDrivers() { + return gx_runtime->enumerateGraphicsDrivers(); +} + +BBStr * bbGfxDriverName(int n) { + debugDriver(n); + string t; int caps; + gx_runtime->graphicsDriverInfo(n - 1, &t, &caps); + return new BBStr(t); +} + +void bbSetGfxDriver(int n) { + debugDriver(n); + gfx_modes.clear(); + gx_driver = n - 1; +} + +int bbCountGfxModes() { + gfx_modes.clear(); + int n = gx_runtime->countGraphicsModes(gx_driver); + for (int k = 0; k < n; ++k) { + GfxMode m; + gx_runtime->graphicsModeInfo(gx_driver, k, &m.w, &m.h, &m.d, &m.caps); + gfx_modes.push_back(m); + } + return gfx_modes.size(); +} + +int bbGfxModeWidth(int n) { + debugMode(n); + return gfx_modes[n - 1].w; +} + +int bbGfxModeHeight(int n) { + debugMode(n); + return gfx_modes[n - 1].h; +} + +int bbGfxModeDepth(int n) { + debugMode(n); + return gfx_modes[n - 1].d; +} + +static int modeExists(int w, int h, int d, bool bb3d) { + int cnt = gx_runtime->countGraphicsModes(gx_driver); + for (int k = 0; k < cnt; ++k) { + int tw, th, td, tc; + gx_runtime->graphicsModeInfo(gx_driver, k, &tw, &th, &td, &tc); + if (bb3d && !(tc&gxRuntime::GFXMODECAPS_3D)) continue; + if (w == tw && h == th && d == td) return 1; + } + return 0; +} + +int bbGfxModeExists(int w, int h, int d) { + return modeExists(w, h, d, false); +} + +int bbGfxDriver3D(int n) { + debugDriver(n); + string t; int caps; + gx_runtime->graphicsDriverInfo(n - 1, &t, &caps); + return (caps & gxRuntime::GFXMODECAPS_3D) ? 1 : 0; +} + +int bbCountGfxModes3D() { + gfx_modes.clear(); + int n = gx_runtime->countGraphicsModes(gx_driver); + for (int k = 0; k < n; ++k) { + GfxMode m; + gx_runtime->graphicsModeInfo(gx_driver, k, &m.w, &m.h, &m.d, &m.caps); + if (m.caps & gxRuntime::GFXMODECAPS_3D) gfx_modes.push_back(m); + } + return gfx_modes.size(); +} + +int bbGfxMode3DExists(int w, int h, int d) { + return modeExists(w, h, d, true); +} + +int bbGfxMode3D(int n) { + debugMode(n); + return gfx_modes[n - 1].caps & gxRuntime::GFXMODECAPS_3D ? 1 : 0; +} + +int bbWindowed3D() { + int tc; + gx_runtime->windowedModeInfo(&tc); + return (tc & gxRuntime::GFXMODECAPS_3D) ? 1 : 0; +} + +int bbTotalVidMem() { + return gx_graphics->getTotalVidmem(); +} + +int bbAvailVidMem() { + return gx_graphics->getAvailVidmem(); +} + +void bbSetBuffer(gxCanvas *buff) { + debugCanvas(buff); + gx_canvas = buff; + curs_x = curs_y = 0; + gx_canvas->setOrigin(0, 0); + gx_canvas->setViewport(0, 0, gx_canvas->getWidth(), gx_canvas->getHeight()); + gx_canvas->setColor(curr_color); + gx_canvas->setClsColor(curr_clsColor); + gx_canvas->setFont(curr_font); + + // Switch Render Target + //if (gx_graphics != nullptr) { + // if (gx_graphics->dir3dDev != nullptr) { + // LPDIRECTDRAWSURFACE7 pddsOldRenderTarget = NULL, pddsNewRenderTarget = gx_canvas->getSurface(); + // gx_graphics->dir3dDev->GetRenderTarget(&pddsOldRenderTarget); + + // if (pddsOldRenderTarget) { + // LPDIRECTDRAWSURFACE7 pddsZBuffer = NULL; + // DDSCAPS2 ddscaps = { DDSCAPS_ZBUFFER, 0, 0, 0 }; + // pddsOldRenderTarget->GetAttachedSurface(&ddscaps, &pddsZBuffer); + + // if (pddsZBuffer) { + // pddsOldRenderTarget->DeleteAttachedSurface(0, pddsZBuffer); + // pddsNewRenderTarget->AddAttachedSurface(pddsZBuffer); + // //pddsZBuffer->Release(); + // } + // //pddsOldRenderTarget->Release(); + // } + + // gx_graphics->dir3dDev->SetRenderTarget(pddsNewRenderTarget, 0); + // } + //} +} + +gxCanvas *bbGraphicsBuffer() { + return gx_canvas; +} + +int bbLoadBuffer(gxCanvas *c, BBStr *str) { + debugCanvas(c); + string s = *str; delete str; + gxCanvas *t = gx_graphics->loadCanvas(s, 0); + if (!t) return 0; + float m[2][2]; + m[0][0] = (float)c->getWidth() / (float)t->getWidth(); + m[1][1] = (float)c->getHeight() / (float)t->getHeight(); + m[1][0] = m[0][1] = 0; + gxCanvas *p = tformCanvas(t, m, 0, 0); + gx_graphics->freeCanvas(t); + int ox, oy; + c->getOrigin(&ox, &oy); c->setOrigin(0, 0); + c->blit(0, 0, p, 0, 0, p->getWidth(), p->getHeight(), true); + gx_graphics->freeCanvas(p); + return 1; +} + +int bbSaveBuffer(gxCanvas *c, BBStr *str) { + debugCanvas(c); + string t = *str; delete str; + return saveCanvas(c, t) ? 1 : 0; +} + +void bbBufferDirty(gxCanvas *c) { + debugCanvas(c); + c->backup(); +} + +static void graphics(int w, int h, int d, int flags) { + freeGraphics(); + gx_runtime->closeGraphics(gx_graphics); + gx_graphics = gx_runtime->openGraphics(w, h, d, gx_driver, flags); + if (!gx_runtime->idle()) ThrowRuntimeException(0); + if (!gx_graphics) { + ThrowRuntimeException("Unable to set graphics mode"); + } + curr_clsColor = 0; + curr_color = 0xffffffff; + curr_font = gx_graphics->getDefaultFont(); + gxCanvas *buff = (flags & gxGraphics::GRAPHICS_3D) ? + gx_graphics->getBackCanvas() : gx_graphics->getFrontCanvas(); + bbSetBuffer(buff); +} + +void bbGraphics(int w, int h, int d, int mode) { + int flags = 0; + switch (mode) { + case 0:flags |= debug ? gxGraphics::GRAPHICS_WINDOWED : 0; break; + case 1:break; + case 2:flags |= gxGraphics::GRAPHICS_WINDOWED; break; + case 3:flags |= gxGraphics::GRAPHICS_WINDOWED | gxGraphics::GRAPHICS_SCALED; break; + case 6:flags |= gxGraphics::GRAPHICS_WINDOWED | gxGraphics::GRAPHICS_AUTOSUSPEND; break; + case 7:flags |= gxGraphics::GRAPHICS_WINDOWED | gxGraphics::GRAPHICS_SCALED | gxGraphics::GRAPHICS_AUTOSUSPEND; break; + default:ThrowRuntimeException("Illegal Graphics mode"); + } + graphics(w, h, d, flags); +} + +void bbGraphics3D(int w, int h, int d, int mode) { + int flags = gxGraphics::GRAPHICS_3D; + switch (mode) { + case 0:flags |= (debug && bbWindowed3D()) ? gxGraphics::GRAPHICS_WINDOWED : 0; break; + case 1:break; + case 2:flags |= gxGraphics::GRAPHICS_WINDOWED; break; + case 3:flags |= gxGraphics::GRAPHICS_WINDOWED | gxGraphics::GRAPHICS_SCALED; break; + case 6:flags |= gxGraphics::GRAPHICS_WINDOWED | gxGraphics::GRAPHICS_AUTOSUSPEND; break; + case 7:flags |= gxGraphics::GRAPHICS_WINDOWED | gxGraphics::GRAPHICS_SCALED | gxGraphics::GRAPHICS_AUTOSUSPEND; break; + default:ThrowRuntimeException("Illegal Graphics3D mode"); + } + graphics(w, h, d, flags); + extern void blitz3d_open(); + blitz3d_open(); +} + +void bbEndGraphics() { + freeGraphics(); + gx_runtime->closeGraphics(gx_graphics); + gx_graphics = gx_runtime->openGraphics(400, 300, 0, 0, gxGraphics::GRAPHICS_WINDOWED); + if (!gx_runtime->idle()) ThrowRuntimeException(0); + if (gx_graphics) { + curr_clsColor = 0; + curr_color = 0xffffffff; + curr_font = gx_graphics->getDefaultFont(); + bbSetBuffer(gx_graphics->getFrontCanvas()); + return; + } + ThrowRuntimeException("Unable to set graphics mode"); +} + +int bbGraphicsLost() { + return gx_runtime->graphicsLost(); +} + +void bbSetGamma(int r, int g, int b, float dr, float dg, float db) { + if (dr < 0) dr = 0; + else if (dr > 255.0f) dr = 255.0f; + if (dg < 0) dg = 0; + else if (dg > 255.0f) dg = 255.0f; + if (db < 0) db = 0; + else if (db > 255.0f) db = 255.0f; + gx_graphics->setGamma(r, g, b, dr, dg, db); +} + +void bbUpdateGamma(int calibrate) { + gx_graphics->updateGamma(!!calibrate); +} + +float bbGammaRed(int n) { + float dr, dg, db; + gx_graphics->getGamma(n, n, n, &dr, &dg, &db); + return dr; +} + +float bbGammaGreen(int n) { + float dr, dg, db; + gx_graphics->getGamma(n, n, n, &dr, &dg, &db); + return dg; +} + +float bbGammaBlue(int n) { + float dr, dg, db; + gx_graphics->getGamma(n, n, n, &dr, &dg, &db); + return db; +} + +gxCanvas *bbFrontBuffer() { + return gx_graphics->getFrontCanvas(); +} + +gxCanvas *bbBackBuffer() { + return gx_graphics->getBackCanvas(); +} + +void bbLockBuffer(gxCanvas *buff) { + if (buff) debugCanvas(buff); + (buff ? buff : gx_canvas)->lock(); +} + +void bbUnlockBuffer(gxCanvas *buff) { + if (buff) debugCanvas(buff); + (buff ? buff : gx_canvas)->unlock(); +} + +int bbReadPixel(int x, int y, gxCanvas *buff) { + if (buff) debugCanvas(buff); + return (buff ? buff : gx_canvas)->getPixel(x, y); +} + +void bbWritePixel(int x, int y, int argb, gxCanvas *buff) { + if (buff) debugCanvas(buff); + (buff ? buff : gx_canvas)->setPixel(x, y, argb); +} + +int bbReadPixelFast(int x, int y, gxCanvas *buff) { + return (buff ? buff : gx_canvas)->getPixelFast(x, y); +} + +void bbWritePixelFast(int x, int y, int argb, gxCanvas *buff) { + (buff ? buff : gx_canvas)->setPixelFast(x, y, argb); +} + +void bbCopyPixel(int src_x, int src_y, gxCanvas *src, int dest_x, int dest_y, gxCanvas *buff) { + (buff ? buff : gx_canvas)->copyPixel(dest_x, dest_y, src ? src : gx_canvas, src_x, src_y); +} + +void bbCopyPixelFast(int src_x, int src_y, gxCanvas *src, int dest_x, int dest_y, gxCanvas *buff) { + (buff ? buff : gx_canvas)->copyPixelFast(dest_x, dest_y, src ? src : gx_canvas, src_x, src_y); +} + +int bbScanLine() { + return gx_graphics->getScanLine(); +} + +void bbVWait(int n) { + gx_graphics->vwait(); + if (!gx_runtime->idle()) ThrowRuntimeException(0); +} + +void bbFlip(int vwait) { + gx_graphics->flip(vwait ? true : false); + if (!gx_runtime->idle()) ThrowRuntimeException(0); +} + +int bbGraphicsWidth() { + return gx_graphics->getWidth(); +} + +int bbGraphicsHeight() { + return gx_graphics->getHeight(); +} + +int bbGraphicsDepth() { + return gx_graphics->getDepth(); +} + +void bbOrigin(int x, int y) { + gx_canvas->setOrigin(x, y); +} + +void bbViewport(int x, int y, int w, int h) { + gx_canvas->setViewport(x, y, w, h); +} + +void bbColor(int r, int g, int b) { + gx_canvas->setColor(curr_color = (r << 16) | (g << 8) | b); +} + +void bbGetColor(int x, int y) { + gx_canvas->setColor(curr_color = gx_canvas->getPixel(x, y)); +} + +int bbColorRed() { + return (gx_canvas->getColor() >> 16) & 0xff; +} + +int bbColorGreen() { + return (gx_canvas->getColor() >> 8) & 0xff; +} + +int bbColorBlue() { + return gx_canvas->getColor() & 0xff; +} + +void bbClsColor(int r, int g, int b) { + gx_canvas->setClsColor(curr_clsColor = (r << 16) | (g << 8) | b); +} + +void bbSetFont(gxFont *f) { + debugFont(f); + gx_canvas->setFont(curr_font = f); +} + +void bbCls() { + gx_canvas->cls(); +} + +void bbPlot(int x, int y) { + gx_canvas->plot(x, y); +} + +void bbLine(int x1, int y1, int x2, int y2) { + gx_canvas->line(x1, y1, x2, y2); +} + +void bbRect(int x, int y, int w, int h, int solid) { + gx_canvas->rect(x, y, w, h, solid ? true : false); +} + +void bbOval(int x, int y, int w, int h, int solid) { + gx_canvas->oval(x, y, w, h, solid ? true : false); +} + +void bbText(int x, int y, BBStr *str, int centre_x, int centre_y) { + if (centre_x) x -= curr_font->getWidth(*str) / 2; + if (centre_y) y -= curr_font->getHeight() / 2; + gx_canvas->text(x, y, *str); + delete str; +} + +void bbCopyRect(int sx, int sy, int w, int h, int dx, int dy, gxCanvas *src, gxCanvas *dest) { + if (src) debugCanvas(src); + else src = gx_canvas; + if (dest) debugCanvas(dest); + else dest = gx_canvas; + dest->blit(dx, dy, src, sx, sy, w, h, true); +} + +gxFont *bbLoadFont(BBStr *name, int height, int bold, int italic, int underline) { + int flags = + (bold ? gxFont::FONT_BOLD : 0) | + (italic ? gxFont::FONT_ITALIC : 0) | + (underline ? gxFont::FONT_UNDERLINE : 0); + gxFont *font = gx_graphics->loadFont(*name, height, flags); + delete name; + return font; +} + +void bbFreeFont(gxFont *f) { + debugFont(f); + if (f == curr_font) bbSetFont(gx_graphics->getDefaultFont()); + gx_graphics->freeFont(f); +} + +int bbFontWidth() { + return curr_font->getWidth(); +} + +int bbFontHeight() { + return curr_font->getHeight(); +} + +int bbStringWidth(BBStr *str) { + string t = *str; delete str; + return curr_font->getWidth(t); +} + +int bbStringHeight(BBStr *str) { + delete str; + return curr_font->getHeight(); +} + +gxMovie *bbOpenMovie(BBStr *s) { + gxMovie *movie = gx_graphics->openMovie(*s, 0); delete s; + return movie; +} + +int bbDrawMovie(gxMovie *movie, int x, int y, int w, int h) { + if (w < 0) w = movie->getWidth(); + if (h < 0) h = movie->getHeight(); + int playing = movie->draw(gx_canvas, x, y, w, h); + if (!gx_runtime->idle()) ThrowRuntimeException(0); + return playing; +} + +int bbMovieWidth(gxMovie *movie) { + return movie->getWidth(); +} + +int bbMovieHeight(gxMovie *movie) { + return movie->getHeight(); +} + +int bbMoviePlaying(gxMovie *movie) { + return movie->isPlaying(); +} + +void bbCloseMovie(gxMovie *movie) { + gx_graphics->closeMovie(movie); +} + +bbImage *bbLoadImage(BBStr *s) { + string t = *s; delete s; + gxCanvas *c = gx_graphics->loadCanvas(t, 0); + if (!c) return 0; + if (auto_dirty) c->backup(); + if (auto_midhandle) c->setHandle(c->getWidth() / 2, c->getHeight() / 2); + vector frames; + frames.push_back(c); + bbImage *i = new bbImage(frames); + image_set.insert(i); + return i; +} + +bbImage *bbLoadAnimImage(BBStr *s, int w, int h, int first, int cnt) { + + string t = *s; delete s; + + if (cnt < 1) ThrowRuntimeException("Illegal frame count"); + if (first < 0) ThrowRuntimeException("Illegal first frame"); + + gxCanvas *pic = gx_graphics->loadCanvas(t, gxCanvas::CANVAS_NONDISPLAY); + if (!pic) return 0; + + //frames per row, per picture + int fpr = pic->getWidth() / w; + int fpp = pic->getHeight() / h*fpr; + if (first + cnt > fpp) { + gx_graphics->freeCanvas(pic); + ThrowRuntimeException("Not enough frames in bitmap"); + } + + //x,y of first frame... + vector frames; + int src_x = first%fpr*w, src_y = first / fpr*h; + + for (int k = 0; k < cnt; ++k) { + gxCanvas *c = gx_graphics->createCanvas(w, h, 0); + if (!c) { + for (--k; k >= 0; --k) gx_graphics->freeCanvas(frames[k]); + gx_graphics->freeCanvas(pic); return 0; + } + c->blit(0, 0, pic, src_x, src_y, w, h, true); + if (auto_dirty) c->backup(); + if (auto_midhandle) c->setHandle(c->getWidth() / 2, c->getHeight() / 2); + frames.push_back(c); + src_x += w; if (src_x + w > pic->getWidth()) { src_x = 0; src_y += h; } + } + gx_graphics->freeCanvas(pic); + bbImage *i = new bbImage(frames); + image_set.insert(i); + return i; +} + +bbImage *bbCopyImage(bbImage *i) { + debugImage(i); + vector frames; + const vector &f = i->getFrames(); + for (int k = 0; k < f.size(); ++k) { + gxCanvas *t = f[k]; + gxCanvas *c = gx_graphics->createCanvas(t->getWidth(), t->getHeight(), 0); + if (!c) { + for (--k; k >= 0; --k) gx_graphics->freeCanvas(frames[k]); + return 0; + } + int x, y; + t->getHandle(&x, &y); + t->setHandle(0, 0); + c->blit(0, 0, t, 0, 0, t->getWidth(), t->getHeight(), true); + if (auto_dirty) c->backup(); + t->setHandle(x, y); + c->setHandle(x, y); + c->setMask(t->getMask()); + frames.push_back(c); + } + bbImage *t = new bbImage(frames); + image_set.insert(t); + return t; +} + +bbImage *bbCreateImage(int w, int h, int n) { + vector frames; + for (int k = 0; k < n; ++k) { + gxCanvas *c = gx_graphics->createCanvas(w, h, 0); + if (!c) { + for (--k; k >= 0; --k) gx_graphics->freeCanvas(frames[k]); + return 0; + } + if (auto_dirty) c->backup(); + if (auto_midhandle) c->setHandle(c->getWidth() / 2, c->getHeight() / 2); + frames.push_back(c); + } + bbImage *i = new bbImage(frames); + image_set.insert(i); + return i; +} + +void bbFreeImage(bbImage *i) { + if (!image_set.erase(i)) return; + const vector &f = i->getFrames(); + for (int k = 0; k < f.size(); ++k) { + if (f[k] == gx_canvas) { + bbSetBuffer(gx_graphics->getFrontCanvas()); + break; + } + } + delete i; +} + +int bbSaveImage(bbImage *i, BBStr *str, int n) { + debugImage(i, n); + string t = *str; delete str; + gxCanvas *c = i->getFrames()[n]; + return saveCanvas(c, t) ? 1 : 0; +} + +void bbGrabImage(bbImage *i, int x, int y, int n) { + debugImage(i, n); + gxCanvas *c = i->getFrames()[n]; + int src_ox, src_oy, dst_hx, dst_hy; + gx_canvas->getOrigin(&src_ox, &src_oy); + c->getHandle(&dst_hx, &dst_hy); + x += src_ox - dst_hx; y += src_oy - dst_hy; + c->setViewport(0, 0, c->getWidth(), c->getHeight()); + c->blit(0, 0, gx_canvas, x, y, c->getWidth(), c->getHeight(), true); + if (auto_dirty) c->backup(); +} + +gxCanvas *bbImageBuffer(bbImage *i, int n) { + debugImage(i, n); + return i->getFrames()[n]; +} + +void bbDrawImage(bbImage *i, int x, int y, int frame) { + debugImage(i, frame); + gxCanvas *c = i->getFrames()[frame]; + gx_canvas->blit(x, y, c, 0, 0, c->getWidth(), c->getHeight(), false); +} + +void bbDrawBlock(bbImage *i, int x, int y, int frame) { + debugImage(i, frame); + gxCanvas *c = i->getFrames()[frame]; + gx_canvas->blit(x, y, c, 0, 0, c->getWidth(), c->getHeight(), true); +} + +static void tile(bbImage *i, int x, int y, int frame, bool solid) { + gxCanvas *c = i->getFrames()[frame]; + + int hx, hy; + c->getHandle(&hx, &hy); + int w = c->getWidth(), h = c->getHeight(); + + int ox, oy, vp_x, vp_y, vp_w, vp_h; + gx_canvas->getOrigin(&ox, &oy); + gx_canvas->getViewport(&vp_x, &vp_y, &vp_w, &vp_h); + int dx = vp_x - ox + hx; + int dy = vp_y - oy + hy; + x -= dx; + y -= dy; + dx += (x >= 0 ? x%w : w - (-x%w)); + dy += (y >= 0 ? y%h : h - (-y%h)); + + for (y = -h; y < vp_h; y += h) { + for (x = -w; x < vp_w; x += w) { + gx_canvas->blit(x + dx, y + dy, c, 0, 0, w, h, solid); + } + } +} + +void bbTileImage(bbImage *i, int x, int y, int frame) { + debugImage(i, frame); + tile(i, x, y, frame, false); +} + +void bbTileBlock(bbImage *i, int x, int y, int frame) { + debugImage(i, frame); + tile(i, x, y, frame, true); +} + +void bbDrawImageRect(bbImage *i, int x, int y, int r_x, int r_y, int r_w, int r_h, int frame) { + debugImage(i, frame); + gxCanvas *c = i->getFrames()[frame]; + gx_canvas->blit(x, y, c, r_x, r_y, r_w, r_h, false); +} + +void bbDrawBlockRect(bbImage *i, int x, int y, int r_x, int r_y, int r_w, int r_h, int frame) { + debugImage(i, frame); + gxCanvas *c = i->getFrames()[frame]; + gx_canvas->blit(x, y, c, r_x, r_y, r_w, r_h, true); +} + +void bbMaskImage(bbImage *i, int r, int g, int b) { + debugImage(i); + unsigned argb = (r << 16) | (g << 8) | b; + const vector &f = i->getFrames(); + for (int k = 0; k < f.size(); ++k) f[k]->setMask(argb); +} + +void bbHandleImage(bbImage *i, int x, int y) { + debugImage(i); + const vector &f = i->getFrames(); + for (int k = 0; k < f.size(); ++k) f[k]->setHandle(x, y); +} + +void bbMidHandle(bbImage *i) { + debugImage(i); + const vector &f = i->getFrames(); + for (int k = 0; k < f.size(); ++k) f[k]->setHandle(f[k]->getWidth() / 2, f[k]->getHeight() / 2); +} + +void bbAutoMidHandle(int enable) { + auto_midhandle = enable ? true : false; +} + +int bbImageWidth(bbImage *i) { + debugImage(i); + return i->getFrames()[0]->getWidth(); +} + +int bbImageHeight(bbImage *i) { + debugImage(i); + return i->getFrames()[0]->getHeight(); +} + +int bbImageXHandle(bbImage *i) { + debugImage(i); + int x, y; + i->getFrames()[0]->getHandle(&x, &y); + return x; +} + +int bbImageYHandle(bbImage *i) { + debugImage(i); + int x, y; + i->getFrames()[0]->getHandle(&x, &y); + return y; +} + +int bbImagesOverlap(bbImage *i1, int x1, int y1, bbImage *i2, int x2, int y2) { + debugImage(i1); + debugImage(i2); + gxCanvas *c1 = i1->getFrames()[0]; + gxCanvas *c2 = i2->getFrames()[0]; + return c1->collide(x1, y1, c2, x2, y2, true); +} + +int bbImagesCollide(bbImage *i1, int x1, int y1, int f1, bbImage *i2, int x2, int y2, int f2) { + debugImage(i1, f1); + debugImage(i2, f2); + gxCanvas *c1 = i1->getFrames()[f1]; + gxCanvas *c2 = i2->getFrames()[f2]; + return c1->collide(x1, y1, c2, x2, y2, false); +} + +int bbRectsOverlap(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2) { + if (x1 + w1 <= x2 || x1 >= x2 + w2 || y1 + h1 <= y2 || y1 >= y2 + h2) return 0; + return 1; +} + +int bbImageRectOverlap(bbImage *i, int x, int y, int x2, int y2, int w2, int h2) { + debugImage(i); + gxCanvas *c = i->getFrames()[0]; + return c->rect_collide(x, y, x2, y2, w2, h2, true); +} + +int bbImageRectCollide(bbImage *i, int x, int y, int f, int x2, int y2, int w2, int h2) { + debugImage(i, f); + gxCanvas *c = i->getFrames()[f]; + return c->rect_collide(x, y, x2, y2, w2, h2, false); +} + +void bbTFormImage(bbImage *i, float a, float b, float c, float d) { + debugImage(i); + const vector &f = i->getFrames(); + int k; + for (k = 0; k < f.size(); ++k) { + if (f[k] == gx_canvas) { + bbSetBuffer(gx_graphics->getFrontCanvas()); + break; + } + } + float m[2][2]; + m[0][0] = a; m[1][0] = b; m[0][1] = c; m[1][1] = d; + for (k = 0; k < f.size(); ++k) { + gxCanvas *c = f[k]; + int hx, hy; c->getHandle(&hx, &hy); + gxCanvas *t = tformCanvas(c, m, hx, hy); + i->replaceFrame(k, t); + t->backup(); + } +} + +void bbScaleImage(bbImage *i, float w, float h) { + debugImage(i); + bbTFormImage(i, w, 0, 0, h); +} + +void bbResizeImage(bbImage *i, float w, float h) { + debugImage(i); + gxCanvas *c = i->getFrames()[0]; + bbTFormImage(i, w / (float)c->getWidth(), 0, 0, h / (float)c->getHeight()); +} + +void bbRotateImage(bbImage *i, float d) { + debugImage(i); + d *= -s_degreesToRadians; + bbTFormImage(i, cos(d), -sin(d), sin(d), cos(d)); +} + +void bbTFormFilter(int enable) { + filter = enable ? true : false; +} + +static int p_ox, p_oy, p_hx, p_hy, p_vpx, p_vpy, p_vpw, p_vph; + +static gxCanvas *startPrinting() { + + gxCanvas *c = gx_graphics->getFrontCanvas(); + + c->lock(); + c->unlock(); + + c->getOrigin(&p_ox, &p_oy); + c->getHandle(&p_hx, &p_hy); + c->getViewport(&p_vpx, &p_vpy, &p_vpw, &p_vph); + + c->setOrigin(0, 0); + c->setHandle(0, 0); + c->setViewport(0, 0, c->getWidth(), c->getHeight()); + if (c != gx_canvas) { + c->setFont(curr_font); + c->setColor(curr_color); + } + + int dy = curs_y + curr_font->getHeight() - c->getHeight(); + if (dy > 0) { + curs_y = c->getHeight() - curr_font->getHeight(); + c->blit(0, 0, c, 0, dy, c->getWidth(), c->getHeight() - dy, true); + c->setColor(curr_clsColor); + c->rect(0, c->getHeight() - dy, c->getWidth(), dy, true); + c->setColor(curr_color); + } + return c; +} + +static void endPrinting(gxCanvas *c) { + c->setViewport(p_vpx, p_vpy, p_vpw, p_vph); + c->setHandle(p_hx, p_hy); + c->setOrigin(p_ox, p_oy); + if (c == gx_canvas) c->setColor(curr_color); + if (!gx_runtime->idle()) ThrowRuntimeException(0); +} + +void bbWrite(BBStr *str) { + gxCanvas *c = startPrinting(); + c->text(curs_x, curs_y, *str); + curs_x += curr_font->getWidth(*str); + endPrinting(c); + delete str; +} + +void bbPrint(BBStr *str) { + gxCanvas *c = startPrinting(); + c->text(curs_x, curs_y, *str); + curs_x = 0; + curs_y += curr_font->getHeight(); + endPrinting(c); + delete str; +} + +BBStr *bbInput(BBStr *prompt) { + gxCanvas *c = startPrinting(); + string t = *prompt; delete prompt; + + //get temp canvas + if (!p_canvas || p_canvas->getWidth() < c->getWidth() || p_canvas->getHeight() < curr_font->getHeight() * 2) { + if (p_canvas) gx_graphics->freeCanvas(p_canvas); + p_canvas = gx_graphics->createCanvas(c->getWidth(), curr_font->getHeight() * 2, 0); + if (!p_canvas) { + endPrinting(c); + return new BBStr(); + } + } + //draw prompt + c->text(curs_x, curs_y, t); + curs_x += curr_font->getWidth(t); + + p_canvas->setFont(curr_font); + p_canvas->setColor(curr_color); + p_canvas->blit(0, 0, c, 0, curs_y, c->getWidth(), curr_font->getHeight(), true); + + string str; + bool go = true; + int curs = 0, last_key = 0, last_time, rep_delay; + + while (go) { + + //render all text + //calc curs x and width + int cx = curs_x + curr_font->getWidth(str.substr(0, curs)); + int cw = curr_font->getWidth(curs < str.size() ? str.substr(curs, 1) : "X"); + + //wait for a key + int key = 0, st = gx_runtime->getMilliSecs(), tc = -1; + + while (gx_runtime->idle()) { + int t = gx_runtime->getMilliSecs(); + int n = (t - st) / 320; + if (n != tc) { + tc = n; + if (!(tc & 1)) { //cursor ON + c->setColor(curr_clsColor ^ 0xffffff); + c->rect(cx, curs_y, cw, curr_font->getHeight(), true); + c->setColor(curr_clsColor); + } else { //cursor OFF + c->blit(cx, curs_y, p_canvas, cx, 0, cw, curr_font->getHeight(), true); + c->setColor(curr_color); + } + c->text(cx, curs_y, str.substr(curs, 1)); + } + if (key = gx_keyboard->getKey()) { + if (int asc = gx_input->toAscii(key)) { + rep_delay = 280; + last_key = key; + last_time = t; + key = asc; + break; + } + } + if (last_key && gx_keyboard->keyDown(last_key)) { + if (t - last_time > rep_delay) { + if (key = gx_input->toAscii(last_key)) { + last_time += rep_delay; + rep_delay = 40; + break; + } + } + } else last_key = 0; + gx_runtime->delay(20); + } + + //check the key + switch (key) { + case 0: + go = false; + str = ""; + break; + case 8: + if (curs) { + str = str.substr(0, curs - 1) + str.substr(curs); + --curs; + } + break; + case 27: + curs = 0; str = ""; + break; + case gxInput::ASC_DELETE: + if (curs < str.size()) str = str.substr(0, curs) + str.substr(curs + 1); + break; + case gxInput::ASC_HOME: + curs = 0; + break; + case gxInput::ASC_END: + curs = str.size(); + break; + case gxInput::ASC_LEFT: + if (curs) --curs; + break; + case gxInput::ASC_RIGHT: + if (curs < str.size()) ++curs; + break; + case '\r': + go = false; + break; + default: + if (curr_font->isPrintable(key)) { + str = str.substr(0, curs) + char(key) + str.substr(curs); + ++curs; + } + } + + //render text + p_canvas->blit(0, curr_font->getHeight(), p_canvas, 0, 0, c->getWidth(), curr_font->getHeight(), true); + p_canvas->text(curs_x, curr_font->getHeight(), str); + c->blit(0, curs_y, p_canvas, 0, curr_font->getHeight(), c->getWidth(), curr_font->getHeight(), true); + } + + curs_x = 0; + curs_y += curr_font->getHeight(); + endPrinting(c); + return new BBStr(str); +} + +void bbLocate(int x, int y) { + gxCanvas *c = gx_graphics->getFrontCanvas(); + curs_x = x < 0 ? 0 : (x > c->getWidth() ? c->getWidth() : x); + curs_y = y < 0 ? 0 : (y > c->getHeight() ? c->getHeight() : y); +} + +void bbShowPointer() { + gx_runtime->setPointerVisible(true); +} + +void bbHidePointer() { + gx_runtime->setPointerVisible(false); +} + +bool graphics_create() { + p_canvas = 0; + filter = true; + gx_driver = 0; + freeGraphics(); + auto_dirty = true; + auto_midhandle = false; + gx_graphics = gx_runtime->openGraphics(400, 300, 0, 0, gxGraphics::GRAPHICS_WINDOWED); + if (gx_graphics) { + curr_clsColor = 0; + curr_color = 0xffffffff; + curr_font = gx_graphics->getDefaultFont(); + bbSetBuffer(bbFrontBuffer()); + return true; + } + return false; +} + +bool graphics_destroy() { + freeGraphics(); + gfx_modes.clear(); + if (gx_graphics) { + gx_runtime->closeGraphics(gx_graphics); + gx_graphics = 0; + } + return true; +} + +void graphics_link(void(*rtSym)(const char *sym, void *pc)) { + + //gfx driver info + rtSym("%CountGfxDrivers", bbCountGfxDrivers); + rtSym("$GfxDriverName%driver", bbGfxDriverName); + rtSym("SetGfxDriver%driver", bbSetGfxDriver); + + //gfx mode info + rtSym("%CountGfxModes", bbCountGfxModes); + rtSym("%GfxModeExists%width%height%depth", bbGfxModeExists); + + rtSym("%GfxModeWidth%mode", bbGfxModeWidth); + rtSym("%GfxModeHeight%mode", bbGfxModeHeight); + rtSym("%GfxModeDepth%mode", bbGfxModeDepth); + rtSym("%AvailVidMem", bbAvailVidMem); + rtSym("%TotalVidMem", bbTotalVidMem); + + rtSym("%GfxDriver3D%driver", bbGfxDriver3D); + rtSym("%CountGfxModes3D", bbCountGfxModes3D); + rtSym("%GfxMode3DExists%width%height%depth", bbGfxMode3DExists); + rtSym("%GfxMode3D%mode", bbGfxMode3D); + rtSym("%Windowed3D", bbWindowed3D); + + //display mode +// rtSym( "Graphics%width%height%depth=0%mode=0",bbGraphics ); + rtSym("Graphics3D%width%height%depth=0%mode=0", bbGraphics3D); + rtSym("EndGraphics", bbEndGraphics); + rtSym("%GraphicsLost", bbGraphicsLost); + + rtSym("SetGamma%src_red%src_green%src_blue#dest_red#dest_green#dest_blue", bbSetGamma); + rtSym("UpdateGamma%calibrate=0", bbUpdateGamma); + rtSym("#GammaRed%red", bbGammaRed); + rtSym("#GammaGreen%green", bbGammaGreen); + rtSym("#GammaBlue%blue", bbGammaBlue); + + rtSym("%FrontBuffer", bbFrontBuffer); + rtSym("%BackBuffer", bbBackBuffer); + rtSym("%ScanLine", bbScanLine); + rtSym("VWait%frames=1", bbVWait); + rtSym("Flip%vwait=1", bbFlip); + rtSym("%GraphicsWidth", bbGraphicsWidth); + rtSym("%GraphicsHeight", bbGraphicsHeight); + rtSym("%GraphicsDepth", bbGraphicsDepth); + + //buffer management + rtSym("SetBuffer%buffer", bbSetBuffer); + rtSym("%GraphicsBuffer", bbGraphicsBuffer); + rtSym("%LoadBuffer%buffer$bmpfile", bbLoadBuffer); + rtSym("%SaveBuffer%buffer$bmpfile", bbSaveBuffer); + rtSym("BufferDirty%buffer", bbBufferDirty); + + //fast pixel reads/write + rtSym("LockBuffer%buffer=0", bbLockBuffer); + rtSym("UnlockBuffer%buffer=0", bbUnlockBuffer); + rtSym("%ReadPixel%x%y%buffer=0", bbReadPixel); + rtSym("WritePixel%x%y%argb%buffer=0", bbWritePixel); + rtSym("%ReadPixelFast%x%y%buffer=0", bbReadPixelFast); + rtSym("WritePixelFast%x%y%argb%buffer=0", bbWritePixelFast); + rtSym("CopyPixel%src_x%src_y%src_buffer%dest_x%dest_y%dest_buffer=0", bbCopyPixel); + rtSym("CopyPixelFast%src_x%src_y%src_buffer%dest_x%dest_y%dest_buffer=0", bbCopyPixelFast); + + //rendering + rtSym("Origin%x%y", bbOrigin); + rtSym("Viewport%x%y%width%height", bbViewport); + rtSym("Color%red%green%blue", bbColor); + rtSym("GetColor%x%y", bbGetColor); + rtSym("%ColorRed", bbColorRed); + rtSym("%ColorGreen", bbColorGreen); + rtSym("%ColorBlue", bbColorBlue); + rtSym("ClsColor%red%green%blue", bbClsColor); + rtSym("SetFont%font", bbSetFont); + rtSym("Cls", bbCls); + rtSym("Plot%x%y", bbPlot); + rtSym("Rect%x%y%width%height%solid=1", bbRect); + rtSym("Oval%x%y%width%height%solid=1", bbOval); + rtSym("Line%x1%y1%x2%y2", bbLine); + rtSym("Text%x%y$text%centre_x=0%centre_y=0", bbText); + rtSym("CopyRect%source_x%source_y%width%height%dest_x%dest_y%src_buffer=0%dest_buffer=0", bbCopyRect); + + //fonts + rtSym("%LoadFont$fontname%height=12%bold=0%italic=0%underline=0", bbLoadFont); + rtSym("FreeFont%font", bbFreeFont); + rtSym("%FontWidth", bbFontWidth); + rtSym("%FontHeight", bbFontHeight); + rtSym("%StringWidth$string", bbStringWidth); + rtSym("%StringHeight$string", bbStringHeight); + + //movies + rtSym("%OpenMovie$file", bbOpenMovie); + rtSym("%DrawMovie%movie%x=0%y=0%w=-1%h=-1", bbDrawMovie); + rtSym("%MovieWidth%movie", bbMovieWidth); + rtSym("%MovieHeight%movie", bbMovieHeight); + rtSym("%MoviePlaying%movie", bbMoviePlaying); + rtSym("CloseMovie%movie", bbCloseMovie); + + rtSym("%LoadImage$bmpfile", bbLoadImage); + rtSym("%LoadAnimImage$bmpfile%cellwidth%cellheight%first%count", bbLoadAnimImage); + rtSym("%CopyImage%image", bbCopyImage); + rtSym("%CreateImage%width%height%frames=1", bbCreateImage); + rtSym("FreeImage%image", bbFreeImage); + rtSym("%SaveImage%image$bmpfile%frame=0", bbSaveImage); + + rtSym("GrabImage%image%x%y%frame=0", bbGrabImage); + rtSym("%ImageBuffer%image%frame=0", bbImageBuffer); + rtSym("DrawImage%image%x%y%frame=0", bbDrawImage); + rtSym("DrawBlock%image%x%y%frame=0", bbDrawBlock); + rtSym("TileImage%image%x=0%y=0%frame=0", bbTileImage); + rtSym("TileBlock%image%x=0%y=0%frame=0", bbTileBlock); + rtSym("DrawImageRect%image%x%y%rect_x%rect_y%rect_width%rect_height%frame=0", bbDrawImageRect); + rtSym("DrawBlockRect%image%x%y%rect_x%rect_y%rect_width%rect_height%frame=0", bbDrawBlockRect); + rtSym("MaskImage%image%red%green%blue", bbMaskImage); + rtSym("HandleImage%image%x%y", bbHandleImage); + rtSym("MidHandle%image", bbMidHandle); + rtSym("AutoMidHandle%enable", bbAutoMidHandle); + rtSym("%ImageWidth%image", bbImageWidth); + rtSym("%ImageHeight%image", bbImageHeight); + rtSym("%ImageXHandle%image", bbImageXHandle); + rtSym("%ImageYHandle%image", bbImageYHandle); + + rtSym("ScaleImage%image#xscale#yscale", bbScaleImage); + rtSym("ResizeImage%image#width#height", bbResizeImage); + rtSym("RotateImage%image#angle", bbRotateImage); + rtSym("TFormImage%image#a#b#c#d", bbTFormImage); + rtSym("TFormFilter%enable", bbTFormFilter); + + rtSym("%ImagesOverlap%image1%x1%y1%image2%x2%y2", bbImagesOverlap); + rtSym("%ImagesCollide%image1%x1%y1%frame1%image2%x2%y2%frame2", bbImagesCollide); + rtSym("%RectsOverlap%x1%y1%width1%height1%x2%y2%width2%height2", bbRectsOverlap); + rtSym("%ImageRectOverlap%image%x%y%rect_x%rect_y%rect_width%rect_height", bbImageRectOverlap); + rtSym("%ImageRectCollide%image%x%y%frame%rect_x%rect_y%rect_width%rect_height", bbImageRectCollide); + + rtSym("Write$string", bbWrite); + rtSym("Print$string=\"\"", bbPrint); + rtSym("$Input$prompt=\"\"", bbInput); + rtSym("Locate%x%y", bbLocate); + + rtSym("ShowPointer", bbShowPointer); + rtSym("HidePointer", bbHidePointer); +} + +// NVidia Optimus +extern "C" { + _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; } \ No newline at end of file diff --git a/RuntimeLib/bbgraphics.h b/Runtime/lib/bbgraphics.hpp similarity index 98% rename from RuntimeLib/bbgraphics.h rename to Runtime/lib/bbgraphics.hpp index f97728f..f393686 100644 --- a/RuntimeLib/bbgraphics.h +++ b/Runtime/lib/bbgraphics.hpp @@ -2,8 +2,8 @@ #ifndef BBGRAPHICS_H #define BBGRAPHICS_H -#include "bbsys.h" -#include "../gxruntime/gxgraphics.h" +#include "bbsys.hpp" +#include "../gxruntime/gxgraphics.hpp" extern gxGraphics *gx_graphics; extern gxCanvas *gx_canvas; diff --git a/RuntimeLib/bbinput.cpp b/Runtime/lib/bbinput.cpp similarity index 99% rename from RuntimeLib/bbinput.cpp rename to Runtime/lib/bbinput.cpp index b626fad..7896bac 100644 --- a/RuntimeLib/bbinput.cpp +++ b/Runtime/lib/bbinput.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "bbsys.h" +#include "std.hpp" +#include "bbsys.hpp" gxInput *gx_input; gxDevice *gx_mouse; diff --git a/RuntimeLib/bbinput.h b/Runtime/lib/bbinput.hpp similarity index 95% rename from RuntimeLib/bbinput.h rename to Runtime/lib/bbinput.hpp index 0942478..4bd986d 100644 --- a/RuntimeLib/bbinput.h +++ b/Runtime/lib/bbinput.hpp @@ -4,8 +4,8 @@ #include -#include "bbsys.h" -#include "../gxruntime/gxinput.h" +#include "bbsys.hpp" +#include "../gxruntime/gxinput.hpp" extern gxInput *gx_input; extern gxDevice *gx_mouse; diff --git a/RuntimeLib/bbmath.cpp b/Runtime/lib/bbmath.cpp similarity index 98% rename from RuntimeLib/bbmath.cpp rename to Runtime/lib/bbmath.cpp index 8ad32d6..1124d69 100644 --- a/RuntimeLib/bbmath.cpp +++ b/Runtime/lib/bbmath.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "bbmath.h" +#include "std.hpp" +#include "bbmath.hpp" static int rnd_state; static const int RND_A=48271; diff --git a/RuntimeLib/bbmath.h b/Runtime/lib/bbmath.hpp similarity index 100% rename from RuntimeLib/bbmath.h rename to Runtime/lib/bbmath.hpp diff --git a/RuntimeLib/bbruntime.cpp b/Runtime/lib/bbruntime.cpp similarity index 98% rename from RuntimeLib/bbruntime.cpp rename to Runtime/lib/bbruntime.cpp index b7df9bc..e0aa628 100644 --- a/RuntimeLib/bbruntime.cpp +++ b/Runtime/lib/bbruntime.cpp @@ -1,7 +1,7 @@ -#include "std.h" -#include "bbsys.h" -#include "bbruntime.h" +#include "std.hpp" +#include "bbsys.hpp" +#include "bbruntime.hpp" void bbEnd() { ThrowRuntimeException(0); diff --git a/RuntimeLib/bbruntime.h b/Runtime/lib/bbruntime.hpp similarity index 90% rename from RuntimeLib/bbruntime.h rename to Runtime/lib/bbruntime.hpp index b9c237e..8bff663 100644 --- a/RuntimeLib/bbruntime.h +++ b/Runtime/lib/bbruntime.hpp @@ -10,7 +10,7 @@ To be statically linked with an appropriate gxruntime driver. #ifndef BBRUNTIME_H #define BBRUNTIME_H -#include "../gxruntime/gxruntime.h" +#include "gxruntime.hpp" void bbruntime_link( void (*rtSym)( const char *sym,void *pc ) ); diff --git a/RuntimeLib/bbsockets.cpp b/Runtime/lib/bbsockets.cpp similarity index 100% rename from RuntimeLib/bbsockets.cpp rename to Runtime/lib/bbsockets.cpp diff --git a/RuntimeLib/bbsockets.h b/Runtime/lib/bbsockets.hpp similarity index 100% rename from RuntimeLib/bbsockets.h rename to Runtime/lib/bbsockets.hpp diff --git a/RuntimeLib/bbstream.cpp b/Runtime/lib/bbstream.cpp similarity index 100% rename from RuntimeLib/bbstream.cpp rename to Runtime/lib/bbstream.cpp diff --git a/RuntimeLib/bbstream.h b/Runtime/lib/bbstream.hpp similarity index 95% rename from RuntimeLib/bbstream.h rename to Runtime/lib/bbstream.hpp index 9ea2946..6867b2d 100644 --- a/RuntimeLib/bbstream.h +++ b/Runtime/lib/bbstream.hpp @@ -2,7 +2,7 @@ #ifndef BBSTREAM_H #define BBSTREAM_H -#include "bbsys.h" +#include "bbsys.hpp" class bbStream{ public: diff --git a/RuntimeLib/bbstring.cpp b/Runtime/lib/bbstring.cpp similarity index 98% rename from RuntimeLib/bbstring.cpp rename to Runtime/lib/bbstring.cpp index 67b8d3d..3bd33bd 100644 --- a/RuntimeLib/bbstring.cpp +++ b/Runtime/lib/bbstring.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "bbsys.h" + +#include "bbsys.hpp" #include #define CHKPOS(x) if( (x)<0 ) ThrowRuntimeException( "parameter must be positive" ); diff --git a/RuntimeLib/bbstring.h b/Runtime/lib/bbstring.hpp similarity index 100% rename from RuntimeLib/bbstring.h rename to Runtime/lib/bbstring.hpp diff --git a/Runtime/lib/bbsys.cpp b/Runtime/lib/bbsys.cpp new file mode 100644 index 0000000..6567b41 --- /dev/null +++ b/Runtime/lib/bbsys.cpp @@ -0,0 +1,6 @@ + +#include "std.hpp" +#include "bbsys.hpp" + +bool debug; +gxRuntime *gx_runtime; diff --git a/RuntimeLib/bbsys.h b/Runtime/lib/bbsys.hpp similarity index 81% rename from RuntimeLib/bbsys.h rename to Runtime/lib/bbsys.hpp index c5bf0f5..bedf253 100644 --- a/RuntimeLib/bbsys.h +++ b/Runtime/lib/bbsys.hpp @@ -2,8 +2,8 @@ #ifndef BBSYS_H #define BBSYS_H -#include "basic.h" -#include "../gxruntime/gxruntime.h" +#include "basic.hpp" +#include "../gxruntime/gxruntime.hpp" extern bool debug; extern gxRuntime *gx_runtime; diff --git a/RuntimeLib/multiplay.cpp b/Runtime/lib/multiplay.cpp similarity index 98% rename from RuntimeLib/multiplay.cpp rename to Runtime/lib/multiplay.cpp index dfdd105..0d78755 100644 --- a/RuntimeLib/multiplay.cpp +++ b/Runtime/lib/multiplay.cpp @@ -5,9 +5,9 @@ */ -#include "std.h" -#include "multiplay.h" -#include "multiplay_setup.h" +#include "std.hpp" +#include "multiplay.hpp" +#include "multiplay_setup.hpp" //struct Player; // diff --git a/RuntimeLib/multiplay.h b/Runtime/lib/multiplay.hpp similarity index 96% rename from RuntimeLib/multiplay.h rename to Runtime/lib/multiplay.hpp index 839d726..6078cd6 100644 --- a/RuntimeLib/multiplay.h +++ b/Runtime/lib/multiplay.hpp @@ -2,7 +2,7 @@ #ifndef MULTIPLAY_H #define MULTIPLAY_H -#include "bbsys.h" +#include "bbsys.hpp" //#include //void multiplay_link(); diff --git a/RuntimeLib/multiplay_setup.cpp b/Runtime/lib/multiplay_setup.cpp similarity index 99% rename from RuntimeLib/multiplay_setup.cpp rename to Runtime/lib/multiplay_setup.cpp index 619bdf3..2079f2a 100644 --- a/RuntimeLib/multiplay_setup.cpp +++ b/Runtime/lib/multiplay_setup.cpp @@ -1,8 +1,8 @@ -#include "std.h" -#include "bbsys.h" -#include "resource.h" -#include "multiplay_setup.h" +#include "std.hpp" +#include "bbsys.hpp" +#include "resource.hpp" +#include "multiplay_setup.hpp" //IDirectPlay4 *dirPlay; // diff --git a/RuntimeLib/multiplay_setup.h b/Runtime/lib/multiplay_setup.hpp similarity index 100% rename from RuntimeLib/multiplay_setup.h rename to Runtime/lib/multiplay_setup.hpp diff --git a/RuntimeLib/multiplay_setup.rc b/Runtime/lib/multiplay_setup.rc similarity index 97% rename from RuntimeLib/multiplay_setup.rc rename to Runtime/lib/multiplay_setup.rc index 57d1d1c..4749d18 100644 --- a/RuntimeLib/multiplay_setup.rc +++ b/Runtime/lib/multiplay_setup.rc @@ -1,6 +1,6 @@ //Microsoft Developer Studio generated resource script. // -#include "resource.h" +#include "resource.hpp" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// @@ -34,7 +34,7 @@ END 2 TEXTINCLUDE DISCARDABLE BEGIN - "#include ""afxres.h""\r\n" + "#include ""afxres.hpp""\r\n" "\0" END diff --git a/RuntimeLib/resource.h b/Runtime/lib/resource.hpp similarity index 100% rename from RuntimeLib/resource.h rename to Runtime/lib/resource.hpp diff --git a/blitz3d/texturecache.h b/Runtime/lib/runtime.cpp similarity index 100% rename from blitz3d/texturecache.h rename to Runtime/lib/runtime.cpp diff --git a/Runtime/lib/std.cpp b/Runtime/lib/std.cpp new file mode 100644 index 0000000..d5f561b --- /dev/null +++ b/Runtime/lib/std.cpp @@ -0,0 +1,2 @@ + +#include "std.hpp" diff --git a/RuntimeLib/std.h b/Runtime/lib/std.hpp similarity index 85% rename from RuntimeLib/std.h rename to Runtime/lib/std.hpp index 3e2a642..ae192be 100644 --- a/RuntimeLib/std.h +++ b/Runtime/lib/std.hpp @@ -8,8 +8,8 @@ #include //#include -#include "../config/config.h" -#include "../stdutil/stdutil.h" + +#include "../stdutil/stdutil.hpp" #include #include diff --git a/RuntimeLib/userlib.cpp b/Runtime/lib/userlib.cpp similarity index 83% rename from RuntimeLib/userlib.cpp rename to Runtime/lib/userlib.cpp index 47d6bcc..e5711e2 100644 --- a/RuntimeLib/userlib.cpp +++ b/Runtime/lib/userlib.cpp @@ -1,13 +1,13 @@ -#include "std.h" -#include "bbsys.h" +#include "std.hpp" +#include "bbsys.hpp" #include static vector _mods; static void procNotFound(){ - RTEX( "User lib function not found" ); + ThrowRuntimeException( "User lib function not found" ); } void _bbLoadLibs( char *p ){ diff --git a/RuntimeLib/userlib.h b/Runtime/lib/userlib.hpp similarity index 100% rename from RuntimeLib/userlib.h rename to Runtime/lib/userlib.hpp diff --git a/RuntimeLib/userlibs.cpp b/Runtime/lib/userlibs.cpp similarity index 95% rename from RuntimeLib/userlibs.cpp rename to Runtime/lib/userlibs.cpp index fdf1807..b3aa42e 100644 --- a/RuntimeLib/userlibs.cpp +++ b/Runtime/lib/userlibs.cpp @@ -1,7 +1,7 @@ -#include "std.h" -#include "bbsys.h" -#include "userlibs.h" +#include "std.hpp" +#include "bbsys.hpp" +#include "userlibs.hpp" #include diff --git a/RuntimeLib/userlibs.h b/Runtime/lib/userlibs.hpp similarity index 88% rename from RuntimeLib/userlibs.h rename to Runtime/lib/userlibs.hpp index ff2b9f0..7a23b89 100644 --- a/RuntimeLib/userlibs.h +++ b/Runtime/lib/userlibs.hpp @@ -2,7 +2,7 @@ #ifndef USERLIBS_H #define USERLIBS_H -#include "basic.h" +#include "basic.hpp" void _bbLoadLibs( char *p ); diff --git a/Runtime/resource.h b/Runtime/resource.hpp similarity index 100% rename from Runtime/resource.h rename to Runtime/resource.hpp diff --git a/RuntimeLib/bbsys.cpp b/RuntimeLib/bbsys.cpp deleted file mode 100644 index 1cc6bff..0000000 --- a/RuntimeLib/bbsys.cpp +++ /dev/null @@ -1,6 +0,0 @@ - -#include "std.h" -#include "bbsys.h" - -bool debug; -gxRuntime *gx_runtime; diff --git a/RuntimeLib/std.cpp b/RuntimeLib/std.cpp deleted file mode 100644 index 97e3d0d..0000000 --- a/RuntimeLib/std.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -#include "std.h" \ No newline at end of file diff --git a/blitz3d/std.cpp b/blitz3d/std.cpp deleted file mode 100644 index 7bc955d..0000000 --- a/blitz3d/std.cpp +++ /dev/null @@ -1,2 +0,0 @@ - -#include "std.h" diff --git a/gxruntime/CMakeLists.txt b/gxruntime/CMakeLists.txt new file mode 100644 index 0000000..3f27a0c --- /dev/null +++ b/gxruntime/CMakeLists.txt @@ -0,0 +1,113 @@ +project(gxruntime) + +add_library(${PROJECT_NAME} STATIC + "asmcoder.hpp" + "asmcoder.cpp" + "ddutil.hpp" + "ddutil.cpp" + "graphicsruntime.hpp" + "gxaudio.hpp" + "gxaudio.cpp" + "gxcanvas.hpp" + "gxcanvas.cpp" + "gxchannel.hpp" + "gxchannel.cpp" + "gxdevice.hpp" + "gxdevice.cpp" + "gxdir.hpp" + "gxdir.cpp" + "gxfilesystem.hpp" + "gxfilesystem.cpp" + "gxfont.hpp" + "gxfont.cpp" + "gxgraphics.hpp" + "gxgraphics.cpp" + "gxinput.hpp" + "gxinput.cpp" + "gxlight.hpp" + "gxlight.cpp" + "gxmesh.hpp" + "gxmesh.cpp" + "gxmovie.hpp" + "gxmovie.cpp" + "gxmusic.hpp" + "gxmusic.cpp" + "gxruntime.hpp" + "gxruntime.cpp" + "gxscene.hpp" + "gxscene.cpp" + "gxsound.hpp" + "gxsound.cpp" + "gxtimer.hpp" + "gxtimer.cpp" + "std.hpp" + "std.cpp" +) + +target_link_libraries(${PROJECT_NAME} + PRIVATE + stdutil + PUBLIC + shell32 + winmm + ${fmod_LIBRARIES} + ${FreeImage_LIBRARIES} +) + +target_include_directories(${PROJECT_NAME} + PRIVATE + "${fmod_INCLUDE_DIRS}" + "${FreeImage_INCLUDE_DIRS}" + PUBLIC + ${PROJECT_SOURCE_DIR} +) + +if (WIN32) + target_compile_definitions(${PROJECT_NAME} + PRIVATE + _CRT_SECURE_NO_WARNINGS + # windows.hpp + WIN32_LEAN_AND_MEAN + NOGPICAPMASKS + #NOVIRTUALKEYCODES + #NOWINMESSAGES + #NOWINSTYLES + #NOSYSMETRICS + NOMENUS + NOICONS + #NOKEYSTATES + NOSYSCOMMANDS + NORASTEROPS + #NOSHOWWINDOW + NOATOM + NOCLIPBOARD + NOCOLOR + NOCTLMGR + NODRAWTEXT + #NOGDI + NOKERNEL + #NOUSER + NONLS + #NOMB + NOMEMMGR + NOMETAFILE + #NOMSG + NOOPENFILE + NOSCROLL + NOSERVICE + NOSOUND + #NOTEXTMETRIC + NOWH + #NOWINOFFSETS + NOCOMM + NOKANJI + NOHELP + NOPROFILER + NODEFERWINDOWPOS + NOMCX + NOIME + NOMDI + NOMINMAX + NOINOUT + ) +endif() diff --git a/gxruntime/asmcoder.cpp b/gxruntime/asmcoder.cpp index 2ceac4f..ffc75a4 100644 --- a/gxruntime/asmcoder.cpp +++ b/gxruntime/asmcoder.cpp @@ -10,7 +10,7 @@ #include #include -#include "asmcoder.h" +#include "asmcoder.hpp" void (__fastcall *plot)(void *s,int argb); int (__fastcall *point)(void*s); diff --git a/gxruntime/asmcoder.h b/gxruntime/asmcoder.hpp similarity index 100% rename from gxruntime/asmcoder.h rename to gxruntime/asmcoder.hpp diff --git a/gxruntime/ddutil.cpp b/gxruntime/ddutil.cpp index 3480fc2..f25948a 100644 --- a/gxruntime/ddutil.cpp +++ b/gxruntime/ddutil.cpp @@ -1,13 +1,13 @@ -#include "GraphicsRuntime.h" -#include "std.h" -#include "ddutil.h" -#include "asmcoder.h" -#include "gxcanvas.h" -#include "gxruntime.h" +#include "GraphicsRuntime.hpp" +#include "std.hpp" +#include "ddutil.hpp" +#include "asmcoder.hpp" +#include "gxcanvas.hpp" +#include "gxruntime.hpp" #define FREEIMAGE_LIB -#include "..\#ThirdParty\FreeImage\Dist\x32\freeimage.h" +#include extern gxRuntime *gx_runtime; static AsmCoder asm_coder; diff --git a/gxruntime/ddutil.h b/gxruntime/ddutil.hpp similarity index 97% rename from gxruntime/ddutil.h rename to gxruntime/ddutil.hpp index b0f7fb0..735eb3e 100644 --- a/gxruntime/ddutil.h +++ b/gxruntime/ddutil.hpp @@ -2,7 +2,7 @@ #ifndef DDUTIL_H #define DDUTIL_H -#include "GraphicsRuntime.h" +#include "GraphicsRuntime.hpp" class gxGraphics; diff --git a/gxruntime/GraphicsRuntime.h b/gxruntime/graphicsruntime.hpp similarity index 98% rename from gxruntime/GraphicsRuntime.h rename to gxruntime/graphicsruntime.hpp index 0eb5a0f..5d60851 100644 --- a/gxruntime/GraphicsRuntime.h +++ b/gxruntime/graphicsruntime.hpp @@ -1,47 +1,47 @@ -#pragma once -#include - -// Direct Draw -#define DIRECTDRAW_VERSION 0x0700 -#include - -// Direct3D -#define DIRECT3D_VERSION 0x0700 -#include - -// Direct Input -#define DIRECTINPUT_VERSION 0x0800 -#include - -// Redefine GUIDs -DEFINE_GUID(CLSID_DirectDraw, 0xD7B70EE0, 0x4340, 0x11CF, 0xB0, 0x63, 0x00, 0x20, 0xAF, 0xC2, 0xCD, 0x35); -DEFINE_GUID(CLSID_DirectDraw7, 0x3c305196, 0x50db, 0x11d3, 0x9c, 0xfe, 0x00, 0xc0, 0x4f, 0xd9, 0x30, 0xc5); -DEFINE_GUID(CLSID_DirectDrawClipper, 0x593817A0, 0x7DB3, 0x11CF, 0xA2, 0xDE, 0x00, 0xAA, 0x00, 0xb9, 0x33, 0x56); -DEFINE_GUID(IID_IDirectDraw, 0x6C14DB80, 0xA733, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); -DEFINE_GUID(IID_IDirectDraw2, 0xB3A6F3E0, 0x2B43, 0x11CF, 0xA2, 0xDE, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56); -DEFINE_GUID(IID_IDirectDraw4, 0x9c59509a, 0x39bd, 0x11d1, 0x8c, 0x4a, 0x00, 0xc0, 0x4f, 0xd9, 0x30, 0xc5); -DEFINE_GUID(IID_IDirectDraw7, 0x15e65ec0, 0x3b9c, 0x11d2, 0xb9, 0x2f, 0x00, 0x60, 0x97, 0x97, 0xea, 0x5b); -DEFINE_GUID(IID_IDirectDrawSurface, 0x6C14DB81, 0xA733, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); -DEFINE_GUID(IID_IDirectDrawSurface2, 0x57805885, 0x6eec, 0x11cf, 0x94, 0x41, 0xa8, 0x23, 0x03, 0xc1, 0x0e, 0x27); -DEFINE_GUID(IID_IDirectDrawSurface3, 0xDA044E00, 0x69B2, 0x11D0, 0xA1, 0xD5, 0x00, 0xAA, 0x00, 0xB8, 0xDF, 0xBB); -DEFINE_GUID(IID_IDirectDrawSurface4, 0x0B2B8630, 0xAD35, 0x11D0, 0x8E, 0xA6, 0x00, 0x60, 0x97, 0x97, 0xEA, 0x5B); -DEFINE_GUID(IID_IDirectDrawSurface7, 0x06675a80, 0x3b9b, 0x11d2, 0xb9, 0x2f, 0x00, 0x60, 0x97, 0x97, 0xea, 0x5b); -DEFINE_GUID(IID_IDirectDrawPalette, 0x6C14DB84, 0xA733, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); -DEFINE_GUID(IID_IDirectDrawClipper, 0x6C14DB85, 0xA733, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); -DEFINE_GUID(IID_IDirectDrawColorControl, 0x4B9F0EE0, 0x0D7E, 0x11D0, 0x9B, 0x06, 0x00, 0xA0, 0xC9, 0x03, 0xA3, 0xB8); -DEFINE_GUID(IID_IDirectDrawGammaControl, 0x69C11C3E, 0xB46B, 0x11D1, 0xAD, 0x7A, 0x00, 0xC0, 0x4F, 0xC2, 0x9B, 0x4E); -DEFINE_GUID(CLSID_AMMultiMediaStream, 0x49c47ce5, 0x9ba4, 0x11d0, 0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45); -DEFINE_GUID(CLSID_AMDirectDrawStream, 0x49c47ce4, 0x9ba4, 0x11d0, 0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45); -DEFINE_GUID(CLSID_AMAudioStream, 0x8496e040, 0xaf4c, 0x11d0, 0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45); -DEFINE_GUID(CLSID_AMAudioData, 0xf2468580, 0xaf8a, 0x11d0, 0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45); -DEFINE_GUID(CLSID_AMMediaTypeStream, 0xcf0f2f7c, 0xf7bf, 0x11d0, 0x90, 0xd, 0x0, 0xc0, 0x4f, 0xd9, 0x18, 0x9d); -DEFINE_GUID(MSPID_PrimaryVideo, 0xa35ff56a, 0x9fda, 0x11d0, 0x8f, 0xdf, 0x0, 0xc0, 0x4f, 0xd9, 0x18, 0x9d); -DEFINE_GUID(MSPID_PrimaryAudio, 0xa35ff56b, 0x9fda, 0x11d0, 0x8f, 0xdf, 0x0, 0xc0, 0x4f, 0xd9, 0x18, 0x9d); -DEFINE_GUID(IID_IDirect3D7, 0xf5049e77, 0x4861, 0x11d2, 0xa4, 0x7, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); -DEFINE_GUID(IID_IDirect3DRampDevice, 0xF2086B20, 0x259F, 0x11CF, 0xA3, 0x1A, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56); -DEFINE_GUID(IID_IDirect3DRGBDevice, 0xA4665C60, 0x2673, 0x11CF, 0xA3, 0x1A, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56); -DEFINE_GUID(IID_IDirect3DHALDevice, 0x84E63dE0, 0x46AA, 0x11CF, 0x81, 0x6F, 0x00, 0x00, 0xC0, 0x20, 0x15, 0x6E); -DEFINE_GUID(IID_IDirect3DMMXDevice, 0x881949a1, 0xd6f3, 0x11d0, 0x89, 0xab, 0x00, 0xa0, 0xc9, 0x05, 0x41, 0x29); -DEFINE_GUID(IID_IDirect3DRefDevice, 0x50936643, 0x13e9, 0x11d1, 0x89, 0xaa, 0x0, 0xa0, 0xc9, 0x5, 0x41, 0x29); -DEFINE_GUID(IID_IDirect3DNullDevice, 0x8767df22, 0xbacc, 0x11d1, 0x89, 0x69, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); -DEFINE_GUID(IID_IDirect3DTnLHalDevice, 0xf5049e78, 0x4861, 0x11d2, 0xa4, 0x7, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); +#pragma once +#include + +// Direct Draw +#define DIRECTDRAW_VERSION 0x0700 +#include + +// Direct3D +#define DIRECT3D_VERSION 0x0700 +#include + +// Direct Input +#define DIRECTINPUT_VERSION 0x0800 +#include + +// Redefine GUIDs +DEFINE_GUID(CLSID_DirectDraw, 0xD7B70EE0, 0x4340, 0x11CF, 0xB0, 0x63, 0x00, 0x20, 0xAF, 0xC2, 0xCD, 0x35); +DEFINE_GUID(CLSID_DirectDraw7, 0x3c305196, 0x50db, 0x11d3, 0x9c, 0xfe, 0x00, 0xc0, 0x4f, 0xd9, 0x30, 0xc5); +DEFINE_GUID(CLSID_DirectDrawClipper, 0x593817A0, 0x7DB3, 0x11CF, 0xA2, 0xDE, 0x00, 0xAA, 0x00, 0xb9, 0x33, 0x56); +DEFINE_GUID(IID_IDirectDraw, 0x6C14DB80, 0xA733, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); +DEFINE_GUID(IID_IDirectDraw2, 0xB3A6F3E0, 0x2B43, 0x11CF, 0xA2, 0xDE, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56); +DEFINE_GUID(IID_IDirectDraw4, 0x9c59509a, 0x39bd, 0x11d1, 0x8c, 0x4a, 0x00, 0xc0, 0x4f, 0xd9, 0x30, 0xc5); +DEFINE_GUID(IID_IDirectDraw7, 0x15e65ec0, 0x3b9c, 0x11d2, 0xb9, 0x2f, 0x00, 0x60, 0x97, 0x97, 0xea, 0x5b); +DEFINE_GUID(IID_IDirectDrawSurface, 0x6C14DB81, 0xA733, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); +DEFINE_GUID(IID_IDirectDrawSurface2, 0x57805885, 0x6eec, 0x11cf, 0x94, 0x41, 0xa8, 0x23, 0x03, 0xc1, 0x0e, 0x27); +DEFINE_GUID(IID_IDirectDrawSurface3, 0xDA044E00, 0x69B2, 0x11D0, 0xA1, 0xD5, 0x00, 0xAA, 0x00, 0xB8, 0xDF, 0xBB); +DEFINE_GUID(IID_IDirectDrawSurface4, 0x0B2B8630, 0xAD35, 0x11D0, 0x8E, 0xA6, 0x00, 0x60, 0x97, 0x97, 0xEA, 0x5B); +DEFINE_GUID(IID_IDirectDrawSurface7, 0x06675a80, 0x3b9b, 0x11d2, 0xb9, 0x2f, 0x00, 0x60, 0x97, 0x97, 0xea, 0x5b); +DEFINE_GUID(IID_IDirectDrawPalette, 0x6C14DB84, 0xA733, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); +DEFINE_GUID(IID_IDirectDrawClipper, 0x6C14DB85, 0xA733, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); +DEFINE_GUID(IID_IDirectDrawColorControl, 0x4B9F0EE0, 0x0D7E, 0x11D0, 0x9B, 0x06, 0x00, 0xA0, 0xC9, 0x03, 0xA3, 0xB8); +DEFINE_GUID(IID_IDirectDrawGammaControl, 0x69C11C3E, 0xB46B, 0x11D1, 0xAD, 0x7A, 0x00, 0xC0, 0x4F, 0xC2, 0x9B, 0x4E); +DEFINE_GUID(CLSID_AMMultiMediaStream, 0x49c47ce5, 0x9ba4, 0x11d0, 0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45); +DEFINE_GUID(CLSID_AMDirectDrawStream, 0x49c47ce4, 0x9ba4, 0x11d0, 0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45); +DEFINE_GUID(CLSID_AMAudioStream, 0x8496e040, 0xaf4c, 0x11d0, 0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45); +DEFINE_GUID(CLSID_AMAudioData, 0xf2468580, 0xaf8a, 0x11d0, 0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45); +DEFINE_GUID(CLSID_AMMediaTypeStream, 0xcf0f2f7c, 0xf7bf, 0x11d0, 0x90, 0xd, 0x0, 0xc0, 0x4f, 0xd9, 0x18, 0x9d); +DEFINE_GUID(MSPID_PrimaryVideo, 0xa35ff56a, 0x9fda, 0x11d0, 0x8f, 0xdf, 0x0, 0xc0, 0x4f, 0xd9, 0x18, 0x9d); +DEFINE_GUID(MSPID_PrimaryAudio, 0xa35ff56b, 0x9fda, 0x11d0, 0x8f, 0xdf, 0x0, 0xc0, 0x4f, 0xd9, 0x18, 0x9d); +DEFINE_GUID(IID_IDirect3D7, 0xf5049e77, 0x4861, 0x11d2, 0xa4, 0x7, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); +DEFINE_GUID(IID_IDirect3DRampDevice, 0xF2086B20, 0x259F, 0x11CF, 0xA3, 0x1A, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56); +DEFINE_GUID(IID_IDirect3DRGBDevice, 0xA4665C60, 0x2673, 0x11CF, 0xA3, 0x1A, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56); +DEFINE_GUID(IID_IDirect3DHALDevice, 0x84E63dE0, 0x46AA, 0x11CF, 0x81, 0x6F, 0x00, 0x00, 0xC0, 0x20, 0x15, 0x6E); +DEFINE_GUID(IID_IDirect3DMMXDevice, 0x881949a1, 0xd6f3, 0x11d0, 0x89, 0xab, 0x00, 0xa0, 0xc9, 0x05, 0x41, 0x29); +DEFINE_GUID(IID_IDirect3DRefDevice, 0x50936643, 0x13e9, 0x11d1, 0x89, 0xaa, 0x0, 0xa0, 0xc9, 0x5, 0x41, 0x29); +DEFINE_GUID(IID_IDirect3DNullDevice, 0x8767df22, 0xbacc, 0x11d1, 0x89, 0x69, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); +DEFINE_GUID(IID_IDirect3DTnLHalDevice, 0xf5049e78, 0x4861, 0x11d2, 0xa4, 0x7, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); diff --git a/gxruntime/gxaudio.cpp b/gxruntime/gxaudio.cpp index b8f9983..9d9ca3b 100644 --- a/gxruntime/gxaudio.cpp +++ b/gxruntime/gxaudio.cpp @@ -1,6 +1,7 @@ -#include "std.h" -#include "gxaudio.h" +#include "std.hpp" +#include "gxaudio.hpp" +#include struct StaticChannel : public gxChannel{ virtual void play()=0; diff --git a/gxruntime/gxaudio.h b/gxruntime/gxaudio.hpp similarity index 97% rename from gxruntime/gxaudio.h rename to gxruntime/gxaudio.hpp index 9fa15ab..a58f027 100644 --- a/gxruntime/gxaudio.h +++ b/gxruntime/gxaudio.hpp @@ -4,7 +4,7 @@ #include -#include "gxsound.h" +#include "gxsound.hpp" class gxRuntime; struct FSOUND_SAMPLE; diff --git a/gxruntime/gxcanvas.cpp b/gxruntime/gxcanvas.cpp index 70740c4..3549ad8 100644 --- a/gxruntime/gxcanvas.cpp +++ b/gxruntime/gxcanvas.cpp @@ -1,9 +1,9 @@ -#include "std.h" -#include "gxcanvas.h" -#include "gxgraphics.h" -#include "gxruntime.h" -#include "asmcoder.h" +#include "std.hpp" +#include "gxcanvas.hpp" +#include "gxgraphics.hpp" +#include "gxruntime.hpp" +#include "asmcoder.hpp" #define DEBUG_BITMASK diff --git a/gxruntime/gxcanvas.h b/gxruntime/gxcanvas.hpp similarity index 99% rename from gxruntime/gxcanvas.h rename to gxruntime/gxcanvas.hpp index 9d444cd..b3dea32 100644 --- a/gxruntime/gxcanvas.h +++ b/gxruntime/gxcanvas.hpp @@ -2,7 +2,7 @@ #ifndef GXCANVAS_H #define GXCANVAS_H -#include "ddutil.h" +#include "ddutil.hpp" class gxFont; class gxGraphics; diff --git a/gxruntime/gxchannel.cpp b/gxruntime/gxchannel.cpp index 1306187..bb680ff 100644 --- a/gxruntime/gxchannel.cpp +++ b/gxruntime/gxchannel.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "gxchannel.h" +#include "std.hpp" +#include "gxchannel.hpp" gxChannel::~gxChannel(){ } diff --git a/gxruntime/gxchannel.h b/gxruntime/gxchannel.hpp similarity index 100% rename from gxruntime/gxchannel.h rename to gxruntime/gxchannel.hpp diff --git a/gxruntime/gxdevice.cpp b/gxruntime/gxdevice.cpp index c696cc3..6d5db9a 100644 --- a/gxruntime/gxdevice.cpp +++ b/gxruntime/gxdevice.cpp @@ -1,7 +1,7 @@ -#include "std.h" -#include "gxdevice.h" -#include "gxruntime.h" +#include "std.hpp" +#include "gxdevice.hpp" +#include "gxruntime.hpp" gxDevice::gxDevice(){ reset(); diff --git a/gxruntime/gxdevice.h b/gxruntime/gxdevice.hpp similarity index 100% rename from gxruntime/gxdevice.h rename to gxruntime/gxdevice.hpp diff --git a/gxruntime/gxdir.cpp b/gxruntime/gxdir.cpp index 56dfa47..6c9103b 100644 --- a/gxruntime/gxdir.cpp +++ b/gxruntime/gxdir.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "gxdir.h" +#include "std.hpp" +#include "gxdir.hpp" gxDir::gxDir( HANDLE h,const WIN32_FIND_DATA &f ):handle(h),findData(f){ } diff --git a/gxruntime/gxdir.h b/gxruntime/gxdir.hpp similarity index 100% rename from gxruntime/gxdir.h rename to gxruntime/gxdir.hpp diff --git a/gxruntime/gxfilesys_h.txt b/gxruntime/gxfilesys_h.txt deleted file mode 100644 index e69de29..0000000 diff --git a/gxruntime/gxfilesystem.cpp b/gxruntime/gxfilesystem.cpp index 0eaf580..a9af978 100644 --- a/gxruntime/gxfilesystem.cpp +++ b/gxruntime/gxfilesystem.cpp @@ -1,6 +1,6 @@ -#include "std.h" -#include "gxfilesystem.h" +#include "std.hpp" +#include "gxfilesystem.hpp" static set dir_set; diff --git a/gxruntime/gxfilesystem.h b/gxruntime/gxfilesystem.hpp similarity index 97% rename from gxruntime/gxfilesystem.h rename to gxruntime/gxfilesystem.hpp index aa4378b..7fed3f0 100644 --- a/gxruntime/gxfilesystem.h +++ b/gxruntime/gxfilesystem.hpp @@ -4,7 +4,7 @@ #include -#include "gxdir.h" +#include "gxdir.hpp" class gxFileSystem{ public: diff --git a/gxruntime/gxfont.cpp b/gxruntime/gxfont.cpp index 5364482..0fd0c34 100644 --- a/gxruntime/gxfont.cpp +++ b/gxruntime/gxfont.cpp @@ -1,8 +1,8 @@ -#include "std.h" -#include "gxfont.h" -#include "gxcanvas.h" -#include "gxgraphics.h" +#include "std.hpp" +#include "gxfont.hpp" +#include "gxcanvas.hpp" +#include "gxgraphics.hpp" gxFont::gxFont( gxGraphics *g,gxCanvas *c,int w,int h,int b,int e,int d,int *os,int *ws ): graphics(g),canvas(c), diff --git a/gxruntime/gxfont.h b/gxruntime/gxfont.hpp similarity index 100% rename from gxruntime/gxfont.h rename to gxruntime/gxfont.hpp diff --git a/gxruntime/gxgraphics.cpp b/gxruntime/gxgraphics.cpp index a4b57c8..ba37cf4 100644 --- a/gxruntime/gxgraphics.cpp +++ b/gxruntime/gxgraphics.cpp @@ -1,7 +1,7 @@ -#include "std.h" -#include "gxgraphics.h" -#include "gxruntime.h" +#include "std.hpp" +#include "gxgraphics.hpp" +#include "gxruntime.hpp" extern gxRuntime *gx_runtime; diff --git a/gxruntime/gxgraphics.h b/gxruntime/gxgraphics.hpp similarity index 94% rename from gxruntime/gxgraphics.h rename to gxruntime/gxgraphics.hpp index 060797c..84e2710 100644 --- a/gxruntime/gxgraphics.h +++ b/gxruntime/gxgraphics.hpp @@ -5,17 +5,17 @@ #include #include -#include "GraphicsRuntime.h" +#include "GraphicsRuntime.hpp" #include #include -#include "ddutil.h" +#include "ddutil.hpp" -#include "gxfont.h" -#include "gxcanvas.h" -#include "gxscene.h" -#include "gxmesh.h" -#include "gxmovie.h" +#include "gxfont.hpp" +#include "gxcanvas.hpp" +#include "gxscene.hpp" +#include "gxmesh.hpp" +#include "gxmovie.hpp" class gxRuntime; diff --git a/gxruntime/gxinput.cpp b/gxruntime/gxinput.cpp index 219a349..1f0745d 100644 --- a/gxruntime/gxinput.cpp +++ b/gxruntime/gxinput.cpp @@ -1,8 +1,8 @@ #pragma once -#include "std.h" -#include "gxinput.h" -#include "gxruntime.h" +#include "std.hpp" +#include "gxinput.hpp" +#include "gxruntime.hpp" static const int QUE_SIZE = 32; diff --git a/gxruntime/gxinput.h b/gxruntime/gxinput.hpp similarity index 91% rename from gxruntime/gxinput.h rename to gxruntime/gxinput.hpp index 4f0d87b..6c1ffde 100644 --- a/gxruntime/gxinput.h +++ b/gxruntime/gxinput.hpp @@ -1,8 +1,8 @@ #pragma once -#include "std.h" -#include "gxdevice.h" -#include "GraphicsRuntime.h" +#include "std.hpp" +#include "gxdevice.hpp" +#include "GraphicsRuntime.hpp" class gxRuntime; diff --git a/gxruntime/gxlight.cpp b/gxruntime/gxlight.cpp index b215648..febf27e 100644 --- a/gxruntime/gxlight.cpp +++ b/gxruntime/gxlight.cpp @@ -1,8 +1,8 @@ -#include "std.h" -#include "gxlight.h" -#include "gxscene.h" -#include "gxgraphics.h" +#include "std.hpp" +#include "gxlight.hpp" +#include "gxscene.hpp" +#include "gxgraphics.hpp" const float PI=3.14159265359f; //180 degrees const float TWOPI=PI*2.0f; //360 degrees diff --git a/gxruntime/gxlight.h b/gxruntime/gxlight.hpp similarity index 95% rename from gxruntime/gxlight.h rename to gxruntime/gxlight.hpp index 522a459..ea298ea 100644 --- a/gxruntime/gxlight.h +++ b/gxruntime/gxlight.hpp @@ -1,5 +1,5 @@ -#include "GraphicsRuntime.h" +#include "GraphicsRuntime.hpp" #ifndef GXLIGHT_H #define GXLIGHT_H diff --git a/gxruntime/gxmesh.cpp b/gxruntime/gxmesh.cpp index e7e4884..839bd8d 100644 --- a/gxruntime/gxmesh.cpp +++ b/gxruntime/gxmesh.cpp @@ -1,9 +1,9 @@ -#include "std.h" -#include "gxmesh.h" -#include "gxgraphics.h" +#include "std.hpp" +#include "gxmesh.hpp" +#include "gxgraphics.hpp" -#include "gxruntime.h" +#include "gxruntime.hpp" extern gxRuntime *gx_runtime; diff --git a/gxruntime/gxmesh.h b/gxruntime/gxmesh.hpp similarity index 98% rename from gxruntime/gxmesh.h rename to gxruntime/gxmesh.hpp index 3530af7..f0aacf6 100644 --- a/gxruntime/gxmesh.h +++ b/gxruntime/gxmesh.hpp @@ -3,7 +3,7 @@ #define GXMESH_H #include -#include "GraphicsRuntime.h" +#include "GraphicsRuntime.hpp" #include class gxGraphics; diff --git a/gxruntime/gxmovie.cpp b/gxruntime/gxmovie.cpp index 539a7bf..a72b0d4 100644 --- a/gxruntime/gxmovie.cpp +++ b/gxruntime/gxmovie.cpp @@ -1,7 +1,7 @@ -#include "std.h" -#include "gxmovie.h" -#include "gxgraphics.h" +#include "std.hpp" +#include "gxmovie.hpp" +#include "gxgraphics.hpp" gxMovie::gxMovie(gxGraphics *g, IMultiMediaStream *mm) :gfx(g), mm_stream(mm), playing(true) { diff --git a/gxruntime/gxmovie.h b/gxruntime/gxmovie.hpp similarity index 97% rename from gxruntime/gxmovie.h rename to gxruntime/gxmovie.hpp index e6f4a15..a6d09f8 100644 --- a/gxruntime/gxmovie.h +++ b/gxruntime/gxmovie.hpp @@ -6,7 +6,7 @@ #include "amstream.h" // DirectShow multimedia stream interfaces #include "ddstream.h" // DirectDraw multimedia stream interfaces -#include "gxcanvas.h" +#include "gxcanvas.hpp" class gxGraphics; diff --git a/gxruntime/gxmusic.cpp b/gxruntime/gxmusic.cpp index b520f23..c921e3b 100644 --- a/gxruntime/gxmusic.cpp +++ b/gxruntime/gxmusic.cpp @@ -1,6 +1,7 @@ -#include "std.h" -#include "gxmusic.h" +#include "std.hpp" +#include "gxmusic.hpp" +#include gxMusic::gxMusic( gxAudio *a,FMUSIC_MODULE *m,FSOUND_STREAM *s ): audio(a),module(m),stream(s),stream_channel(-1){ diff --git a/gxruntime/gxmusic.h b/gxruntime/gxmusic.hpp similarity index 100% rename from gxruntime/gxmusic.h rename to gxruntime/gxmusic.hpp diff --git a/gxruntime/gxruntime.cpp b/gxruntime/gxruntime.cpp index 5236d8e..8442296 100644 --- a/gxruntime/gxruntime.cpp +++ b/gxruntime/gxruntime.cpp @@ -1,10 +1,12 @@ #pragma once -#include "GraphicsRuntime.h" -#include "std.h" -#include "gxruntime.h" -#include "zmouse.h" -#include "windows.h" +#include "GraphicsRuntime.hpp" +#include "std.hpp" +#include "gxruntime.hpp" +#include +#include +#include +#include struct gxRuntime::GfxMode { DDSURFACEDESC2 desc; @@ -53,7 +55,7 @@ static int mod_cnt; static MMRESULT timerID; static IDirectDrawClipper *clipper; static IDirectDrawSurface7 *primSurf; -static Debugger *debugger; +//static Debugger *debugger; static set timers; @@ -64,11 +66,11 @@ enum { //////////////////// // STATIC STARTUP // //////////////////// -gxRuntime *gxRuntime::openRuntime(HINSTANCE hinst, const string &cmd_line, Debugger *d) { +gxRuntime *gxRuntime::openRuntime(HINSTANCE hinst, const string &cmd_line, void* d) { if (runtime) return 0; //create debugger - debugger = d; + //debugger = d; //create WNDCLASS WNDCLASS wndclass; @@ -204,7 +206,7 @@ void gxRuntime::suspend() { if (gfx_mode == 3) ShowCursor(1); - if (debugger) debugger->debugStop(); + //if (debugger) debugger->debugStop(); } //////////// @@ -219,7 +221,7 @@ void gxRuntime::resume() { suspended = false; busy = false; - if (debugger) debugger->debugRun(); + //if (debugger) debugger->debugRun(); } /////////////////// @@ -505,7 +507,7 @@ bool gxRuntime::idle() { if (suspended) forceResume(); break; case WM_END: - debugger = 0; + //debugger = 0; run_flag = false; break; default: @@ -533,61 +535,61 @@ bool gxRuntime::delay(int ms) { // DEBUGSTMT // /////////////// void gxRuntime::debugStmt(int pos, const char *file) { - if (debugger) debugger->debugStmt(pos, file); + //if (debugger) debugger->debugStmt(pos, file); } /////////////// // DEBUGSTOP // /////////////// void gxRuntime::debugStop() { - if (!suspended) forceSuspend(); + //if (!suspended) forceSuspend(); } //////////////// // DEBUGENTER // //////////////// void gxRuntime::debugEnter(void *frame, void *env, const char *func) { - if (debugger) debugger->debugEnter(frame, env, func); + //if (debugger) debugger->debugEnter(frame, env, func); } //////////////// // DEBUGLEAVE // //////////////// void gxRuntime::debugLeave() { - if (debugger) debugger->debugLeave(); + //if (debugger) debugger->debugLeave(); } //////////////// // DEBUGERROR // //////////////// void gxRuntime::debugError(const char *t) { - if (!debugger) return; - Debugger *d = debugger; + /*if (!debugger) return; + void*d = debugger; asyncEnd(); if (!suspended) { forceSuspend(); } - d->debugMsg(t, true); + d->debugMsg(t, true);*/ } /////////////// // DEBUGINFO // /////////////// void gxRuntime::debugInfo(const char *t) { - if (!debugger) return; + /*if (!debugger) return; Debugger *d = debugger; asyncEnd(); if (!suspended) { forceSuspend(); } - d->debugMsg(t, false); + d->debugMsg(t, false);*/ } ////////////// // DEBUGLOG // ////////////// void gxRuntime::debugLog(const char *t) { - if (debugger) debugger->debugLog(t); + //if (debugger) debugger->debugLog(t); } ///////////////////////// diff --git a/gxruntime/gxruntime.h b/gxruntime/gxruntime.hpp similarity index 94% rename from gxruntime/gxruntime.h rename to gxruntime/gxruntime.hpp index 0a1e0b1..eefd617 100644 --- a/gxruntime/gxruntime.h +++ b/gxruntime/gxruntime.hpp @@ -6,13 +6,11 @@ #include #include -#include "gxaudio.h" -#include "gxinput.h" -#include "gxgraphics.h" -#include "gxfilesystem.h" -#include "gxtimer.h" - -#include "../debugger/debugger.h" +#include "gxaudio.hpp" +#include "gxinput.hpp" +#include "gxgraphics.hpp" +#include "gxfilesystem.hpp" +#include "gxtimer.hpp" class gxRuntime{ /***** INTERNAL INTERFACE *****/ @@ -75,7 +73,7 @@ private: /***** APP INTERFACE *****/ public: - static gxRuntime *openRuntime( HINSTANCE hinst,const std::string &cmd_line,Debugger *debugger ); + static gxRuntime *openRuntime( HINSTANCE hinst,const std::string &cmd_line, void* d ); static void closeRuntime( gxRuntime *runtime ); void asyncStop(); diff --git a/gxruntime/gxscene.cpp b/gxruntime/gxscene.cpp index f48b919..dbb3758 100644 --- a/gxruntime/gxscene.cpp +++ b/gxruntime/gxscene.cpp @@ -1,8 +1,8 @@ -#include "std.h" -#include "gxscene.h" -#include "gxgraphics.h" -#include "gxruntime.h" +#include "std.hpp" +#include "gxscene.hpp" +#include "gxgraphics.hpp" +#include "gxruntime.hpp" static bool can_wb; static int hw_tex_stages,tex_stages; diff --git a/gxruntime/gxscene.h b/gxruntime/gxscene.hpp similarity index 98% rename from gxruntime/gxscene.h rename to gxruntime/gxscene.hpp index d125880..1a27389 100644 --- a/gxruntime/gxscene.h +++ b/gxruntime/gxscene.hpp @@ -4,11 +4,11 @@ #define GXSCENE_H #include -#include "GraphicsRuntime.h" +#include "GraphicsRuntime.hpp" #include #include -#include "gxlight.h" +#include "gxlight.hpp" class gxCanvas; diff --git a/gxruntime/gxsound.cpp b/gxruntime/gxsound.cpp index cc2faf1..5b1b7dc 100644 --- a/gxruntime/gxsound.cpp +++ b/gxruntime/gxsound.cpp @@ -1,7 +1,8 @@ -#include "std.h" -#include "gxsound.h" -#include "gxaudio.h" +#include "std.hpp" +#include "gxsound.hpp" +#include "gxaudio.hpp" +#include gxSound::gxSound( gxAudio *a,FSOUND_SAMPLE *s ): audio(a),sample(s),defs_valid(true){ diff --git a/gxruntime/gxsound.h b/gxruntime/gxsound.hpp similarity index 95% rename from gxruntime/gxsound.h rename to gxruntime/gxsound.hpp index efdd256..964b931 100644 --- a/gxruntime/gxsound.h +++ b/gxruntime/gxsound.hpp @@ -2,7 +2,7 @@ #ifndef GXSOUND_H #define GXSOUND_H -#include "gxchannel.h" +#include "gxchannel.hpp" class gxAudio; struct FSOUND_SAMPLE; diff --git a/gxruntime/gxtimer.cpp b/gxruntime/gxtimer.cpp index 2baba58..5eddc09 100644 --- a/gxruntime/gxtimer.cpp +++ b/gxruntime/gxtimer.cpp @@ -1,7 +1,7 @@ -#include "std.h" -#include "gxtimer.h" -#include "gxruntime.h" +#include "std.hpp" +#include "gxtimer.hpp" +#include "gxruntime.hpp" gxTimer::gxTimer( gxRuntime *rt,int hertz ): runtime(rt),ticks_get(0),ticks_put(0){ diff --git a/gxruntime/gxtimer.h b/gxruntime/gxtimer.hpp similarity index 94% rename from gxruntime/gxtimer.h rename to gxruntime/gxtimer.hpp index dbc00a1..b08f5e1 100644 --- a/gxruntime/gxtimer.h +++ b/gxruntime/gxtimer.hpp @@ -2,6 +2,8 @@ #ifndef GXTIMER_H #define GXTIMER_H +#include + class gxRuntime; class gxTimer{ diff --git a/gxruntime/std.cpp b/gxruntime/std.cpp index 7bc955d..d5f561b 100644 --- a/gxruntime/std.cpp +++ b/gxruntime/std.cpp @@ -1,2 +1,2 @@ -#include "std.h" +#include "std.hpp" diff --git a/gxruntime/std.h b/gxruntime/std.hpp similarity index 66% rename from gxruntime/std.h rename to gxruntime/std.hpp index 224dd1c..6665837 100644 --- a/gxruntime/std.h +++ b/gxruntime/std.hpp @@ -2,10 +2,7 @@ #ifndef STD_H #define STD_H -#include "../#ThirdParty/fmodapi375win/api/inc/fmod.h" - -#include "../config/config.h" -#include "../stdutil/stdutil.h" +#include "stdutil.hpp" #pragma warning( disable:4786 ) @@ -21,7 +18,7 @@ #include #include -#include "GraphicsRuntime.h" +#include "GraphicsRuntime.hpp" using namespace std;