runtime/lib: C++ify
This commit is contained in:
@@ -34,9 +34,6 @@ add_library(${PROJECT_NAME} STATIC
|
|||||||
# "multiplay_setup.hpp"
|
# "multiplay_setup.hpp"
|
||||||
# "multiplay_setup.rc"
|
# "multiplay_setup.rc"
|
||||||
"resource.hpp"
|
"resource.hpp"
|
||||||
"runtime.cpp"
|
|
||||||
"std.cpp"
|
|
||||||
"std.hpp"
|
|
||||||
# "userlib.cpp"
|
# "userlib.cpp"
|
||||||
# "userlib.hpp"
|
# "userlib.hpp"
|
||||||
"userlibs.cpp"
|
"userlibs.cpp"
|
||||||
@@ -44,13 +41,12 @@ add_library(${PROJECT_NAME} STATIC
|
|||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
PUBLIC
|
|
||||||
stdutil
|
stdutil
|
||||||
runtime_gfx
|
runtime_gfx
|
||||||
ddraw
|
ddraw
|
||||||
dsound
|
dsound
|
||||||
dxguid
|
dxguid
|
||||||
mswsock
|
wsock32
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME}
|
target_include_directories(${PROJECT_NAME}
|
||||||
|
|||||||
+16
-14
@@ -1,5 +1,7 @@
|
|||||||
#include "bbsys.hpp"
|
#include "bbsys.hpp"
|
||||||
#include "std.hpp"
|
#include <map>
|
||||||
|
|
||||||
|
#include <stdutil.hpp>
|
||||||
|
|
||||||
//how many strings allocated
|
//how many strings allocated
|
||||||
static int stringCnt;
|
static int stringCnt;
|
||||||
@@ -29,8 +31,8 @@ static BBStr usedStrs, freeStrs;
|
|||||||
static int next_handle;
|
static int next_handle;
|
||||||
|
|
||||||
//object<->handle maps
|
//object<->handle maps
|
||||||
static map<int, BBObj*> handle_map;
|
static std::map<int, BBObj*> handle_map;
|
||||||
static map<BBObj*, int> object_map;
|
static std::map<BBObj*, int> object_map;
|
||||||
|
|
||||||
static BBType _bbIntType(BBTYPE_INT);
|
static BBType _bbIntType(BBTYPE_INT);
|
||||||
static BBType _bbFltType(BBTYPE_FLT);
|
static BBType _bbFltType(BBTYPE_FLT);
|
||||||
@@ -99,41 +101,41 @@ BBStr::BBStr()
|
|||||||
++stringCnt;
|
++stringCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
BBStr::BBStr(const char* s) : string(s)
|
BBStr::BBStr(const char* s) : std::string(s)
|
||||||
{
|
{
|
||||||
++stringCnt;
|
++stringCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
BBStr::BBStr(const char* s, int n) : string(s, n)
|
BBStr::BBStr(const char* s, int n) : std::string(s, n)
|
||||||
{
|
{
|
||||||
++stringCnt;
|
++stringCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
BBStr::BBStr(const BBStr& s) : string(s)
|
BBStr::BBStr(const BBStr& s) : std::string(s)
|
||||||
{
|
{
|
||||||
++stringCnt;
|
++stringCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
BBStr::BBStr(const string& s) : string(s)
|
BBStr::BBStr(const std::string& s) : std::string(s)
|
||||||
{
|
{
|
||||||
++stringCnt;
|
++stringCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
BBStr& BBStr::operator=(const char* s)
|
BBStr& BBStr::operator=(const char* s)
|
||||||
{
|
{
|
||||||
string::operator=(s);
|
std::string::operator=(s);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
BBStr& BBStr::operator=(const BBStr& s)
|
BBStr& BBStr::operator=(const BBStr& s)
|
||||||
{
|
{
|
||||||
string::operator=(s);
|
std::string::operator=(s);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
BBStr& BBStr::operator=(const string& s)
|
BBStr& BBStr::operator=(const std::string& s)
|
||||||
{
|
{
|
||||||
string::operator=(s);
|
std::string::operator=(s);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,7 +340,7 @@ void _bbObjDelete(BBObj* obj)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
map<BBObj*, int>::iterator it = object_map.find(obj);
|
std::map<BBObj*, int>::iterator it = object_map.find(obj);
|
||||||
if (it != object_map.end()) {
|
if (it != object_map.end()) {
|
||||||
handle_map.erase(it->second);
|
handle_map.erase(it->second);
|
||||||
object_map.erase(it);
|
object_map.erase(it);
|
||||||
@@ -514,7 +516,7 @@ int _bbObjToHandle(BBObj* obj)
|
|||||||
{
|
{
|
||||||
if (!obj || !obj->fields)
|
if (!obj || !obj->fields)
|
||||||
return 0;
|
return 0;
|
||||||
map<BBObj*, int>::const_iterator it = object_map.find(obj);
|
std::map<BBObj*, int>::const_iterator it = object_map.find(obj);
|
||||||
if (it != object_map.end())
|
if (it != object_map.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
++next_handle;
|
++next_handle;
|
||||||
@@ -525,7 +527,7 @@ int _bbObjToHandle(BBObj* obj)
|
|||||||
|
|
||||||
BBObj* _bbObjFromHandle(int handle, BBObjType* type)
|
BBObj* _bbObjFromHandle(int handle, BBObjType* type)
|
||||||
{
|
{
|
||||||
map<int, BBObj*>::const_iterator it = handle_map.find(handle);
|
std::map<int, BBObj*>::const_iterator it = handle_map.find(handle);
|
||||||
if (it == handle_map.end())
|
if (it == handle_map.end())
|
||||||
return 0;
|
return 0;
|
||||||
BBObj* obj = it->second;
|
BBObj* obj = it->second;
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
#ifndef BASIC_H
|
|
||||||
#define BASIC_H
|
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -155,5 +152,3 @@ float _bbFMod(float x, float y);
|
|||||||
float _bbFPow(float x, float y);
|
float _bbFPow(float x, float y);
|
||||||
|
|
||||||
void bbRuntimeStats();
|
void bbRuntimeStats();
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
BBTYPE_END = 0,
|
BBTYPE_END = 0,
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
|
|
||||||
#include "bbaudio.hpp"
|
#include "bbaudio.hpp"
|
||||||
#include "std.hpp"
|
|
||||||
|
#include <gxchannel.hpp>
|
||||||
|
#include <gxsound.hpp>
|
||||||
|
|
||||||
gxAudio* gx_audio;
|
gxAudio* gx_audio;
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
static inline void debugSound(gxSound* s)
|
static inline void debugSound(gxSound* s)
|
||||||
{
|
{
|
||||||
if (debug) {
|
if (debug) {
|
||||||
@@ -11,17 +13,20 @@ static inline void debugSound(gxSound* s)
|
|||||||
ThrowRuntimeException("Sound does not exist");
|
ThrowRuntimeException("Sound does not exist");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#define debugSound
|
||||||
|
#endif
|
||||||
|
|
||||||
static gxSound* loadSound(BBStr* f, bool use_3d)
|
static gxSound* loadSound(BBStr* f, bool use_3d)
|
||||||
{
|
{
|
||||||
string t = *f;
|
std::string t = *f;
|
||||||
delete f;
|
delete f;
|
||||||
return gx_audio ? gx_audio->loadSound(t, use_3d) : 0;
|
return gx_audio ? gx_audio->loadSound(t, use_3d) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gxChannel* playMusic(BBStr* f, bool use_3d)
|
static gxChannel* playMusic(BBStr* f, bool use_3d)
|
||||||
{
|
{
|
||||||
string t = *f;
|
std::string t = *f;
|
||||||
delete f;
|
delete f;
|
||||||
return gx_audio ? gx_audio->playFile(t, use_3d) : 0;
|
return gx_audio ? gx_audio->playFile(t, use_3d) : 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
#ifndef BBAUDIO_H
|
|
||||||
#define BBAUDIO_H
|
|
||||||
|
|
||||||
#include "bbsys.hpp"
|
#include "bbsys.hpp"
|
||||||
#include "gxaudio.hpp"
|
|
||||||
|
#include <gxaudio.hpp>
|
||||||
|
|
||||||
extern gxAudio* gx_audio;
|
extern gxAudio* gx_audio;
|
||||||
|
|
||||||
@@ -23,5 +21,3 @@ void bbChannelPitch(gxChannel* channel, int pitch);
|
|||||||
void bbChannelVolume(gxChannel* channel, float volume);
|
void bbChannelVolume(gxChannel* channel, float volume);
|
||||||
void bbChannelPan(gxChannel* channel, float pan);
|
void bbChannelPan(gxChannel* channel, float pan);
|
||||||
int bbChannelPlaying(gxChannel* channel);
|
int bbChannelPlaying(gxChannel* channel);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
#include "bbbank.hpp"
|
#include "bbbank.hpp"
|
||||||
|
#include <set>
|
||||||
#include "bbstream.hpp"
|
#include "bbstream.hpp"
|
||||||
#include "std.hpp"
|
|
||||||
|
|
||||||
struct bbBank {
|
struct bbBank {
|
||||||
char* data;
|
char* data;
|
||||||
@@ -36,8 +35,9 @@ struct bbBank {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static set<bbBank*> bank_set;
|
static std::set<bbBank*> bank_set;
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
static inline void debugBank(bbBank* b)
|
static inline void debugBank(bbBank* b)
|
||||||
{
|
{
|
||||||
if (debug) {
|
if (debug) {
|
||||||
@@ -54,6 +54,9 @@ static inline void debugBank(bbBank* b, int offset)
|
|||||||
ThrowRuntimeException("Offset out of range");
|
ThrowRuntimeException("Offset out of range");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#define debugBank
|
||||||
|
#endif
|
||||||
|
|
||||||
bbBank* bbCreateBank(int size)
|
bbBank* bbCreateBank(int size)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,2 @@
|
|||||||
|
#pragma once
|
||||||
#ifndef BBBANK_H
|
|
||||||
#define BBBANK_H
|
|
||||||
|
|
||||||
#include "bbsys.hpp"
|
#include "bbsys.hpp"
|
||||||
|
|
||||||
#endif
|
|
||||||
+24
-25
@@ -1,26 +1,25 @@
|
|||||||
|
|
||||||
#include "std.hpp"
|
|
||||||
|
|
||||||
#include "../blitz3d/blitz3d.hpp"
|
|
||||||
#include "../blitz3d/brush.hpp"
|
|
||||||
#include "../blitz3d/camera.hpp"
|
|
||||||
#include "../blitz3d/meshmodel.hpp"
|
|
||||||
#include "../blitz3d/sprite.hpp"
|
|
||||||
#include "../blitz3d/texture.hpp"
|
|
||||||
#include "../blitz3d/world.hpp"
|
|
||||||
#include "bbblitz3d.hpp"
|
#include "bbblitz3d.hpp"
|
||||||
#include "bbgraphics.hpp"
|
#include <set>
|
||||||
//#include "../blitz3d/loader_x.hpp"
|
#include "../blitz3d/animator.hpp"
|
||||||
|
#include "../blitz3d/brush.hpp"
|
||||||
#include "../blitz3d/cachedtexture.hpp"
|
#include "../blitz3d/cachedtexture.hpp"
|
||||||
|
#include "../blitz3d/camera.hpp"
|
||||||
#include "../blitz3d/listener.hpp"
|
#include "../blitz3d/listener.hpp"
|
||||||
#include "../blitz3d/loader_3ds.hpp"
|
#include "../blitz3d/loader_3ds.hpp"
|
||||||
#include "../blitz3d/loader_b3d.hpp"
|
#include "../blitz3d/loader_b3d.hpp"
|
||||||
#include "../blitz3d/md2model.hpp"
|
#include "../blitz3d/md2model.hpp"
|
||||||
|
#include "../blitz3d/meshmodel.hpp"
|
||||||
#include "../blitz3d/meshutil.hpp"
|
#include "../blitz3d/meshutil.hpp"
|
||||||
#include "../blitz3d/pivot.hpp"
|
#include "../blitz3d/pivot.hpp"
|
||||||
#include "../blitz3d/planemodel.hpp"
|
#include "../blitz3d/planemodel.hpp"
|
||||||
#include "../blitz3d/q3bspmodel.hpp"
|
#include "../blitz3d/q3bspmodel.hpp"
|
||||||
|
#include "../blitz3d/sprite.hpp"
|
||||||
#include "../blitz3d/terrain.hpp"
|
#include "../blitz3d/terrain.hpp"
|
||||||
|
#include "../blitz3d/texture.hpp"
|
||||||
|
#include "../blitz3d/world.hpp"
|
||||||
|
#include "bbgraphics.hpp"
|
||||||
|
|
||||||
|
#include <stdutil.hpp>
|
||||||
|
|
||||||
gxScene* gx_scene;
|
gxScene* gx_scene;
|
||||||
extern gxFileSystem* gx_filesys;
|
extern gxFileSystem* gx_filesys;
|
||||||
@@ -28,9 +27,9 @@ extern gxFileSystem* gx_filesys;
|
|||||||
static int tri_count;
|
static int tri_count;
|
||||||
static World* world;
|
static World* world;
|
||||||
|
|
||||||
static set<Brush*> brush_set;
|
static std::set<Brush*> brush_set;
|
||||||
static set<Texture*> texture_set;
|
static std::set<Texture*> texture_set;
|
||||||
static set<Entity*> entity_set;
|
static std::set<Entity*> entity_set;
|
||||||
|
|
||||||
static Listener* listener;
|
static Listener* listener;
|
||||||
|
|
||||||
@@ -53,7 +52,7 @@ extern float stats3d[10];
|
|||||||
static Loader_3DS loader_3ds;
|
static Loader_3DS loader_3ds;
|
||||||
static Loader_B3D loader_b3d;
|
static Loader_B3D loader_b3d;
|
||||||
|
|
||||||
static map<string, Transform> loader_mat_map;
|
static std::map<std::string, Transform> loader_mat_map;
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
static inline void debug3d()
|
static inline void debug3d()
|
||||||
@@ -192,13 +191,13 @@ static inline void debugVertex(Surface* s, int n, int t)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Entity* loadEntity(string t, int hint)
|
static Entity* loadEntity(std::string t, int hint)
|
||||||
{
|
{
|
||||||
t = tolower(t);
|
t = tolower(t);
|
||||||
int n = t.rfind(".");
|
int n = t.rfind(".");
|
||||||
if (n == string::npos)
|
if (n == std::string::npos)
|
||||||
return 0;
|
return 0;
|
||||||
string ext = t.substr(n + 1);
|
std::string ext = t.substr(n + 1);
|
||||||
MeshLoader* l;
|
MeshLoader* l;
|
||||||
|
|
||||||
if (ext == "x") {
|
if (ext == "x") {
|
||||||
@@ -213,9 +212,9 @@ static Entity* loadEntity(string t, int hint)
|
|||||||
|
|
||||||
const Transform& conv = loader_mat_map[ext];
|
const Transform& conv = loader_mat_map[ext];
|
||||||
|
|
||||||
CachedTextureFactory::setPath(filenamepath(t));
|
CachedTexture::setPath(filenamepath(t));
|
||||||
Entity* e = l->load(t, conv, hint);
|
Entity* e = l->load(t, conv, hint);
|
||||||
CachedTextureFactory::setPath("");
|
CachedTexture::setPath("");
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,7 +266,7 @@ static void erase(Entity* e)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static Entity* findChild(Entity* e, const string& t)
|
static Entity* findChild(Entity* e, const std::string& t)
|
||||||
{
|
{
|
||||||
if (e->getName() == t)
|
if (e->getName() == t)
|
||||||
return e;
|
return e;
|
||||||
@@ -586,7 +585,7 @@ BBStr* bbTextureName(Texture* t)
|
|||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
debugTexture(t);
|
debugTexture(t);
|
||||||
#endif
|
#endif
|
||||||
CachedTextureFactory* c = t->getCachedTexture();
|
CachedTexture* c = t->getCachedTexture();
|
||||||
return c ? new BBStr(c->getName().c_str()) : new BBStr("");
|
return c ? new BBStr(c->getName().c_str()) : new BBStr("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1722,10 +1721,10 @@ Entity* bbLoadBSP(BBStr* file, float gam, Entity* p)
|
|||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
debugParent(p);
|
debugParent(p);
|
||||||
#endif
|
#endif
|
||||||
CachedTextureFactory::setPath(filenamepath(*file));
|
CachedTexture::setPath(filenamepath(*file));
|
||||||
Q3BSPModel* t = new Q3BSPModel(*file, gam);
|
Q3BSPModel* t = new Q3BSPModel(*file, gam);
|
||||||
delete file;
|
delete file;
|
||||||
CachedTextureFactory::setPath("");
|
CachedTexture::setPath("");
|
||||||
|
|
||||||
if (!t->isValid()) {
|
if (!t->isValid()) {
|
||||||
delete t;
|
delete t;
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
#ifndef BBBLITZ3D_H
|
|
||||||
#define BBBLITZ3D_H
|
|
||||||
|
|
||||||
#include "bbsys.hpp"
|
#include "bbsys.hpp"
|
||||||
#include "gxscene.hpp"
|
#include <gxscene.hpp>
|
||||||
|
|
||||||
extern gxScene* gx_scene;
|
extern gxScene* gx_scene;
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
|
|
||||||
#include "bbfilesystem.hpp"
|
#include "bbfilesystem.hpp"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <set>
|
||||||
#include "bbstream.hpp"
|
#include "bbstream.hpp"
|
||||||
#include "std.hpp"
|
|
||||||
|
|
||||||
gxFileSystem* gx_filesys;
|
gxFileSystem* gx_filesys;
|
||||||
|
|
||||||
struct bbFile : public bbStream {
|
struct bbFile : public bbStream {
|
||||||
filebuf* buf;
|
std::filebuf* buf;
|
||||||
bbFile(filebuf* f) : buf(f) {}
|
bbFile(std::filebuf* f) : buf(f) {}
|
||||||
~bbFile()
|
~bbFile()
|
||||||
{
|
{
|
||||||
delete buf;
|
delete buf;
|
||||||
@@ -31,7 +30,7 @@ struct bbFile : public bbStream {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static set<bbFile*> file_set;
|
static std::set<bbFile*> file_set;
|
||||||
|
|
||||||
static inline void debugFile(bbFile* f)
|
static inline void debugFile(bbFile* f)
|
||||||
{
|
{
|
||||||
@@ -51,9 +50,9 @@ static inline void debugDir(gxDir* d)
|
|||||||
|
|
||||||
static bbFile* open(BBStr* file_path, int flags)
|
static bbFile* open(BBStr* file_path, int flags)
|
||||||
{
|
{
|
||||||
string t = *file_path;
|
std::string t = *file_path;
|
||||||
filebuf* buf = new filebuf();
|
std::filebuf* buf = new std::filebuf();
|
||||||
if (buf->open(t.c_str(), flags | ios_base::binary)) {
|
if (buf->open(t.c_str(), flags | std::ios_base::binary)) {
|
||||||
bbFile* file = new bbFile(buf);
|
bbFile* file = new bbFile(buf);
|
||||||
file_set.insert(file);
|
file_set.insert(file);
|
||||||
return file;
|
return file;
|
||||||
@@ -64,17 +63,17 @@ static bbFile* open(BBStr* file_path, int flags)
|
|||||||
|
|
||||||
bbFile* bbReadFile(BBStr* f)
|
bbFile* bbReadFile(BBStr* f)
|
||||||
{
|
{
|
||||||
return open(f, ios_base::in);
|
return open(f, std::ios_base::in);
|
||||||
}
|
}
|
||||||
|
|
||||||
bbFile* bbWriteFile(BBStr* f)
|
bbFile* bbWriteFile(BBStr* f)
|
||||||
{
|
{
|
||||||
return open(f, ios_base::out | ios_base::trunc);
|
return open(f, std::ios_base::out | std::ios_base::trunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bbFile* bbOpenFile(BBStr* f)
|
bbFile* bbOpenFile(BBStr* f)
|
||||||
{
|
{
|
||||||
return open(f, ios_base::in | ios_base::out);
|
return open(f, std::ios_base::in | std::ios_base::out);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bbCloseFile(bbFile* f)
|
void bbCloseFile(bbFile* f)
|
||||||
@@ -86,17 +85,17 @@ void bbCloseFile(bbFile* f)
|
|||||||
|
|
||||||
int bbFilePos(bbFile* f)
|
int bbFilePos(bbFile* f)
|
||||||
{
|
{
|
||||||
return f->buf->pubseekoff(0, ios_base::cur);
|
return f->buf->pubseekoff(0, std::ios_base::cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bbSeekFile(bbFile* f, int pos)
|
int bbSeekFile(bbFile* f, int pos)
|
||||||
{
|
{
|
||||||
return f->buf->pubseekoff(pos, ios_base::beg);
|
return f->buf->pubseekoff(pos, std::ios_base::beg);
|
||||||
}
|
}
|
||||||
|
|
||||||
gxDir* bbReadDir(BBStr* d)
|
gxDir* bbReadDir(BBStr* d)
|
||||||
{
|
{
|
||||||
string t = *d;
|
std::string t = *d;
|
||||||
delete d;
|
delete d;
|
||||||
return gx_filesys->openDir(t, 0);
|
return gx_filesys->openDir(t, 0);
|
||||||
}
|
}
|
||||||
@@ -137,7 +136,7 @@ void bbDeleteDir(BBStr* d)
|
|||||||
|
|
||||||
int bbFileType(BBStr* f)
|
int bbFileType(BBStr* f)
|
||||||
{
|
{
|
||||||
string t = *f;
|
std::string t = *f;
|
||||||
delete f;
|
delete f;
|
||||||
int n = gx_filesys->getFileType(t);
|
int n = gx_filesys->getFileType(t);
|
||||||
return n == gxFileSystem::FILE_TYPE_FILE ? 1 : (n == gxFileSystem::FILE_TYPE_DIR ? 2 : 0);
|
return n == gxFileSystem::FILE_TYPE_FILE ? 1 : (n == gxFileSystem::FILE_TYPE_DIR ? 2 : 0);
|
||||||
@@ -145,14 +144,14 @@ int bbFileType(BBStr* f)
|
|||||||
|
|
||||||
int bbFileSize(BBStr* f)
|
int bbFileSize(BBStr* f)
|
||||||
{
|
{
|
||||||
string t = *f;
|
std::string t = *f;
|
||||||
delete f;
|
delete f;
|
||||||
return gx_filesys->getFileSize(t);
|
return gx_filesys->getFileSize(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bbCopyFile(BBStr* f, BBStr* to)
|
void bbCopyFile(BBStr* f, BBStr* to)
|
||||||
{
|
{
|
||||||
string src = *f, dest = *to;
|
std::string src = *f, dest = *to;
|
||||||
delete f;
|
delete f;
|
||||||
delete to;
|
delete to;
|
||||||
gx_filesys->copyFile(src, dest);
|
gx_filesys->copyFile(src, dest);
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
#ifndef BBFILESYSTEM_H
|
|
||||||
#define BBFILESYSTEM_H
|
|
||||||
|
|
||||||
#include "bbsys.hpp"
|
#include "bbsys.hpp"
|
||||||
#include "gxfilesystem.hpp"
|
|
||||||
|
#include <gxfilesystem.hpp>
|
||||||
|
|
||||||
extern gxFileSystem* gx_filesys;
|
extern gxFileSystem* gx_filesys;
|
||||||
|
|
||||||
#endif
|
|
||||||
+30
-29
@@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
#include "bbgraphics.hpp"
|
#include "bbgraphics.hpp"
|
||||||
#include "bbinput.hpp"
|
#include "bbinput.hpp"
|
||||||
#include "std.hpp"
|
#include <fstream>
|
||||||
|
|
||||||
|
#include <gxmovie.hpp>
|
||||||
|
|
||||||
gxGraphics* gx_graphics;
|
gxGraphics* gx_graphics;
|
||||||
gxCanvas* gx_canvas;
|
gxCanvas* gx_canvas;
|
||||||
@@ -12,14 +13,14 @@ struct GfxMode {
|
|||||||
|
|
||||||
class bbImage {
|
class bbImage {
|
||||||
public:
|
public:
|
||||||
bbImage(const vector<gxCanvas*>& f) : frames(f) {}
|
bbImage(const std::vector<gxCanvas*>& f) : frames(f) {}
|
||||||
~bbImage()
|
~bbImage()
|
||||||
{
|
{
|
||||||
for (int k = 0; k < frames.size(); ++k) {
|
for (int k = 0; k < frames.size(); ++k) {
|
||||||
gx_graphics->freeCanvas(frames[k]);
|
gx_graphics->freeCanvas(frames[k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const vector<gxCanvas*>& getFrames() const
|
const std::vector<gxCanvas*>& getFrames() const
|
||||||
{
|
{
|
||||||
return frames;
|
return frames;
|
||||||
}
|
}
|
||||||
@@ -30,7 +31,7 @@ class bbImage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vector<gxCanvas*> frames;
|
std::vector<gxCanvas*> frames;
|
||||||
};
|
};
|
||||||
|
|
||||||
//degrees to radians
|
//degrees to radians
|
||||||
@@ -41,7 +42,7 @@ static int gx_driver; //current graphics driver
|
|||||||
static bool filter;
|
static bool filter;
|
||||||
static bool auto_dirty;
|
static bool auto_dirty;
|
||||||
static bool auto_midhandle;
|
static bool auto_midhandle;
|
||||||
static set<bbImage*> image_set;
|
static std::set<bbImage*> image_set;
|
||||||
static int curs_x, curs_y;
|
static int curs_x, curs_y;
|
||||||
static gxCanvas* p_canvas;
|
static gxCanvas* p_canvas;
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@ static gxFont* curr_font;
|
|||||||
static unsigned curr_color;
|
static unsigned curr_color;
|
||||||
static unsigned curr_clsColor;
|
static unsigned curr_clsColor;
|
||||||
|
|
||||||
static vector<GfxMode> gfx_modes;
|
static std::vector<GfxMode> gfx_modes;
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
static inline void debugImage(bbImage* i, int frame = 0)
|
static inline void debugImage(bbImage* i, int frame = 0)
|
||||||
@@ -234,9 +235,9 @@ static gxCanvas* tformCanvas(gxCanvas* c, float m[2][2], int x_handle, int y_han
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool saveCanvas(gxCanvas* c, const string& f)
|
static bool saveCanvas(gxCanvas* c, const std::string& f)
|
||||||
{
|
{
|
||||||
ofstream out(f.c_str(), ios::binary);
|
std::ofstream out(f.c_str(), std::ios::binary);
|
||||||
if (!out.good())
|
if (!out.good())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -286,7 +287,7 @@ int bbCountGfxDrivers()
|
|||||||
BBStr* bbGfxDriverName(int n)
|
BBStr* bbGfxDriverName(int n)
|
||||||
{
|
{
|
||||||
debugDriver(n);
|
debugDriver(n);
|
||||||
string t;
|
std::string t;
|
||||||
int caps;
|
int caps;
|
||||||
gx_runtime->graphicsDriverInfo(n - 1, &t, &caps);
|
gx_runtime->graphicsDriverInfo(n - 1, &t, &caps);
|
||||||
return new BBStr(t);
|
return new BBStr(t);
|
||||||
@@ -351,7 +352,7 @@ int bbGfxModeExists(int w, int h, int d)
|
|||||||
int bbGfxDriver3D(int n)
|
int bbGfxDriver3D(int n)
|
||||||
{
|
{
|
||||||
debugDriver(n);
|
debugDriver(n);
|
||||||
string t;
|
std::string t;
|
||||||
int caps;
|
int caps;
|
||||||
gx_runtime->graphicsDriverInfo(n - 1, &t, &caps);
|
gx_runtime->graphicsDriverInfo(n - 1, &t, &caps);
|
||||||
return (caps & gxRuntime::GFXMODECAPS_3D) ? 1 : 0;
|
return (caps & gxRuntime::GFXMODECAPS_3D) ? 1 : 0;
|
||||||
@@ -441,7 +442,7 @@ gxCanvas* bbGraphicsBuffer()
|
|||||||
int bbLoadBuffer(gxCanvas* c, BBStr* str)
|
int bbLoadBuffer(gxCanvas* c, BBStr* str)
|
||||||
{
|
{
|
||||||
debugCanvas(c);
|
debugCanvas(c);
|
||||||
string s = *str;
|
std::string s = *str;
|
||||||
delete str;
|
delete str;
|
||||||
gxCanvas* t = gx_graphics->loadCanvas(s, 0);
|
gxCanvas* t = gx_graphics->loadCanvas(s, 0);
|
||||||
if (!t)
|
if (!t)
|
||||||
@@ -463,7 +464,7 @@ int bbLoadBuffer(gxCanvas* c, BBStr* str)
|
|||||||
int bbSaveBuffer(gxCanvas* c, BBStr* str)
|
int bbSaveBuffer(gxCanvas* c, BBStr* str)
|
||||||
{
|
{
|
||||||
debugCanvas(c);
|
debugCanvas(c);
|
||||||
string t = *str;
|
std::string t = *str;
|
||||||
delete str;
|
delete str;
|
||||||
return saveCanvas(c, t) ? 1 : 0;
|
return saveCanvas(c, t) ? 1 : 0;
|
||||||
}
|
}
|
||||||
@@ -827,7 +828,7 @@ int bbFontHeight()
|
|||||||
|
|
||||||
int bbStringWidth(BBStr* str)
|
int bbStringWidth(BBStr* str)
|
||||||
{
|
{
|
||||||
string t = *str;
|
std::string t = *str;
|
||||||
delete str;
|
delete str;
|
||||||
return curr_font->getWidth(t);
|
return curr_font->getWidth(t);
|
||||||
}
|
}
|
||||||
@@ -879,7 +880,7 @@ void bbCloseMovie(gxMovie* movie)
|
|||||||
|
|
||||||
bbImage* bbLoadImage(BBStr* s)
|
bbImage* bbLoadImage(BBStr* s)
|
||||||
{
|
{
|
||||||
string t = *s;
|
std::string t = *s;
|
||||||
delete s;
|
delete s;
|
||||||
gxCanvas* c = gx_graphics->loadCanvas(t, 0);
|
gxCanvas* c = gx_graphics->loadCanvas(t, 0);
|
||||||
if (!c)
|
if (!c)
|
||||||
@@ -888,7 +889,7 @@ bbImage* bbLoadImage(BBStr* s)
|
|||||||
c->backup();
|
c->backup();
|
||||||
if (auto_midhandle)
|
if (auto_midhandle)
|
||||||
c->setHandle(c->getWidth() / 2, c->getHeight() / 2);
|
c->setHandle(c->getWidth() / 2, c->getHeight() / 2);
|
||||||
vector<gxCanvas*> frames;
|
std::vector<gxCanvas*> frames;
|
||||||
frames.push_back(c);
|
frames.push_back(c);
|
||||||
bbImage* i = new bbImage(frames);
|
bbImage* i = new bbImage(frames);
|
||||||
image_set.insert(i);
|
image_set.insert(i);
|
||||||
@@ -897,7 +898,7 @@ bbImage* bbLoadImage(BBStr* s)
|
|||||||
|
|
||||||
bbImage* bbLoadAnimImage(BBStr* s, int w, int h, int first, int cnt)
|
bbImage* bbLoadAnimImage(BBStr* s, int w, int h, int first, int cnt)
|
||||||
{
|
{
|
||||||
string t = *s;
|
std::string t = *s;
|
||||||
delete s;
|
delete s;
|
||||||
|
|
||||||
if (cnt < 1)
|
if (cnt < 1)
|
||||||
@@ -918,7 +919,7 @@ bbImage* bbLoadAnimImage(BBStr* s, int w, int h, int first, int cnt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//x,y of first frame...
|
//x,y of first frame...
|
||||||
vector<gxCanvas*> frames;
|
std::vector<gxCanvas*> frames;
|
||||||
int src_x = first % fpr * w, src_y = first / fpr * h;
|
int src_x = first % fpr * w, src_y = first / fpr * h;
|
||||||
|
|
||||||
for (int k = 0; k < cnt; ++k) {
|
for (int k = 0; k < cnt; ++k) {
|
||||||
@@ -950,8 +951,8 @@ bbImage* bbLoadAnimImage(BBStr* s, int w, int h, int first, int cnt)
|
|||||||
bbImage* bbCopyImage(bbImage* i)
|
bbImage* bbCopyImage(bbImage* i)
|
||||||
{
|
{
|
||||||
debugImage(i);
|
debugImage(i);
|
||||||
vector<gxCanvas*> frames;
|
std::vector<gxCanvas*> frames;
|
||||||
const vector<gxCanvas*>& f = i->getFrames();
|
const std::vector<gxCanvas*>& f = i->getFrames();
|
||||||
for (int k = 0; k < f.size(); ++k) {
|
for (int k = 0; k < f.size(); ++k) {
|
||||||
gxCanvas* t = f[k];
|
gxCanvas* t = f[k];
|
||||||
gxCanvas* c = gx_graphics->createCanvas(t->getWidth(), t->getHeight(), 0);
|
gxCanvas* c = gx_graphics->createCanvas(t->getWidth(), t->getHeight(), 0);
|
||||||
@@ -978,7 +979,7 @@ bbImage* bbCopyImage(bbImage* i)
|
|||||||
|
|
||||||
bbImage* bbCreateImage(int w, int h, int n)
|
bbImage* bbCreateImage(int w, int h, int n)
|
||||||
{
|
{
|
||||||
vector<gxCanvas*> frames;
|
std::vector<gxCanvas*> frames;
|
||||||
for (int k = 0; k < n; ++k) {
|
for (int k = 0; k < n; ++k) {
|
||||||
gxCanvas* c = gx_graphics->createCanvas(w, h, 0);
|
gxCanvas* c = gx_graphics->createCanvas(w, h, 0);
|
||||||
if (!c) {
|
if (!c) {
|
||||||
@@ -1001,7 +1002,7 @@ void bbFreeImage(bbImage* i)
|
|||||||
{
|
{
|
||||||
if (!image_set.erase(i))
|
if (!image_set.erase(i))
|
||||||
return;
|
return;
|
||||||
const vector<gxCanvas*>& f = i->getFrames();
|
const std::vector<gxCanvas*>& f = i->getFrames();
|
||||||
for (int k = 0; k < f.size(); ++k) {
|
for (int k = 0; k < f.size(); ++k) {
|
||||||
if (f[k] == gx_canvas) {
|
if (f[k] == gx_canvas) {
|
||||||
bbSetBuffer(gx_graphics->getFrontCanvas());
|
bbSetBuffer(gx_graphics->getFrontCanvas());
|
||||||
@@ -1014,7 +1015,7 @@ void bbFreeImage(bbImage* i)
|
|||||||
int bbSaveImage(bbImage* i, BBStr* str, int n)
|
int bbSaveImage(bbImage* i, BBStr* str, int n)
|
||||||
{
|
{
|
||||||
debugImage(i, n);
|
debugImage(i, n);
|
||||||
string t = *str;
|
std::string t = *str;
|
||||||
delete str;
|
delete str;
|
||||||
gxCanvas* c = i->getFrames()[n];
|
gxCanvas* c = i->getFrames()[n];
|
||||||
return saveCanvas(c, t) ? 1 : 0;
|
return saveCanvas(c, t) ? 1 : 0;
|
||||||
@@ -1110,7 +1111,7 @@ void bbMaskImage(bbImage* i, int r, int g, int b)
|
|||||||
{
|
{
|
||||||
debugImage(i);
|
debugImage(i);
|
||||||
unsigned argb = (r << 16) | (g << 8) | b;
|
unsigned argb = (r << 16) | (g << 8) | b;
|
||||||
const vector<gxCanvas*>& f = i->getFrames();
|
const std::vector<gxCanvas*>& f = i->getFrames();
|
||||||
for (int k = 0; k < f.size(); ++k)
|
for (int k = 0; k < f.size(); ++k)
|
||||||
f[k]->setMask(argb);
|
f[k]->setMask(argb);
|
||||||
}
|
}
|
||||||
@@ -1118,7 +1119,7 @@ void bbMaskImage(bbImage* i, int r, int g, int b)
|
|||||||
void bbHandleImage(bbImage* i, int x, int y)
|
void bbHandleImage(bbImage* i, int x, int y)
|
||||||
{
|
{
|
||||||
debugImage(i);
|
debugImage(i);
|
||||||
const vector<gxCanvas*>& f = i->getFrames();
|
const std::vector<gxCanvas*>& f = i->getFrames();
|
||||||
for (int k = 0; k < f.size(); ++k)
|
for (int k = 0; k < f.size(); ++k)
|
||||||
f[k]->setHandle(x, y);
|
f[k]->setHandle(x, y);
|
||||||
}
|
}
|
||||||
@@ -1126,7 +1127,7 @@ void bbHandleImage(bbImage* i, int x, int y)
|
|||||||
void bbMidHandle(bbImage* i)
|
void bbMidHandle(bbImage* i)
|
||||||
{
|
{
|
||||||
debugImage(i);
|
debugImage(i);
|
||||||
const vector<gxCanvas*>& f = i->getFrames();
|
const std::vector<gxCanvas*>& f = i->getFrames();
|
||||||
for (int k = 0; k < f.size(); ++k)
|
for (int k = 0; k < f.size(); ++k)
|
||||||
f[k]->setHandle(f[k]->getWidth() / 2, f[k]->getHeight() / 2);
|
f[k]->setHandle(f[k]->getWidth() / 2, f[k]->getHeight() / 2);
|
||||||
}
|
}
|
||||||
@@ -1206,7 +1207,7 @@ int bbImageRectCollide(bbImage* i, int x, int y, int f, int x2, int y2, int w2,
|
|||||||
void bbTFormImage(bbImage* i, float a, float b, float c, float d)
|
void bbTFormImage(bbImage* i, float a, float b, float c, float d)
|
||||||
{
|
{
|
||||||
debugImage(i);
|
debugImage(i);
|
||||||
const vector<gxCanvas*>& f = i->getFrames();
|
const std::vector<gxCanvas*>& f = i->getFrames();
|
||||||
int k;
|
int k;
|
||||||
for (k = 0; k < f.size(); ++k) {
|
for (k = 0; k < f.size(); ++k) {
|
||||||
if (f[k] == gx_canvas) {
|
if (f[k] == gx_canvas) {
|
||||||
@@ -1319,7 +1320,7 @@ void bbPrint(BBStr* str)
|
|||||||
BBStr* bbInput(BBStr* prompt)
|
BBStr* bbInput(BBStr* prompt)
|
||||||
{
|
{
|
||||||
gxCanvas* c = startPrinting();
|
gxCanvas* c = startPrinting();
|
||||||
string t = *prompt;
|
std::string t = *prompt;
|
||||||
delete prompt;
|
delete prompt;
|
||||||
|
|
||||||
//get temp canvas
|
//get temp canvas
|
||||||
@@ -1340,7 +1341,7 @@ BBStr* bbInput(BBStr* prompt)
|
|||||||
p_canvas->setColor(curr_color);
|
p_canvas->setColor(curr_color);
|
||||||
p_canvas->blit(0, 0, c, 0, curs_y, c->getWidth(), curr_font->getHeight(), true);
|
p_canvas->blit(0, 0, c, 0, curs_y, c->getWidth(), curr_font->getHeight(), true);
|
||||||
|
|
||||||
string str;
|
std::string str;
|
||||||
bool go = true;
|
bool go = true;
|
||||||
int curs = 0, last_key = 0, last_time, rep_delay;
|
int curs = 0, last_key = 0, last_time, rep_delay;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
#ifndef BBGRAPHICS_H
|
|
||||||
#define BBGRAPHICS_H
|
|
||||||
|
|
||||||
#include "bbsys.hpp"
|
#include "bbsys.hpp"
|
||||||
#include "gxgraphics.hpp"
|
|
||||||
|
#include <gxgraphics.hpp>
|
||||||
|
#include <gxcanvas.hpp>
|
||||||
|
#include <gxscene.hpp>
|
||||||
|
#include <gxfont.hpp>
|
||||||
|
|
||||||
extern gxGraphics* gx_graphics;
|
extern gxGraphics* gx_graphics;
|
||||||
extern gxCanvas* gx_canvas;
|
extern gxCanvas* gx_canvas;
|
||||||
@@ -115,5 +116,3 @@ void bbWrite(BBStr* str);
|
|||||||
void bbPrint(BBStr* str);
|
void bbPrint(BBStr* str);
|
||||||
BBStr* bbInput(BBStr* prompt);
|
BBStr* bbInput(BBStr* prompt);
|
||||||
void bbLocate(int x, int y);
|
void bbLocate(int x, int y);
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
|
|
||||||
#include "bbsys.hpp"
|
#include "bbsys.hpp"
|
||||||
#include "std.hpp"
|
#include <vector>
|
||||||
|
|
||||||
|
#include <gxinput.hpp>
|
||||||
|
#include <gxdevice.hpp>
|
||||||
|
|
||||||
gxInput* gx_input;
|
gxInput* gx_input;
|
||||||
gxDevice* gx_mouse;
|
gxDevice* gx_mouse;
|
||||||
gxDevice* gx_keyboard;
|
gxDevice* gx_keyboard;
|
||||||
vector<gxDevice*> gx_joysticks;
|
std::vector<gxDevice*> gx_joysticks;
|
||||||
|
|
||||||
static int mouse_x, mouse_y, mouse_z;
|
static int mouse_x, mouse_y, mouse_z;
|
||||||
static const float JLT = -1.0f / 3.0f;
|
static const float JLT = -1.0f / 3.0f;
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
#ifndef BBINPUT_H
|
|
||||||
#define BBINPUT_H
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "bbsys.hpp"
|
#include "bbsys.hpp"
|
||||||
#include "gxinput.hpp"
|
|
||||||
|
#include <gxinput.hpp>
|
||||||
|
#include <gxdevice.hpp>
|
||||||
|
|
||||||
extern gxInput* gx_input;
|
extern gxInput* gx_input;
|
||||||
extern gxDevice* gx_mouse;
|
extern gxDevice* gx_mouse;
|
||||||
@@ -51,5 +49,3 @@ int bbJoyZDir(int port);
|
|||||||
int bbJoyUDir(int port);
|
int bbJoyUDir(int port);
|
||||||
int bbJoyVDir(int port);
|
int bbJoyVDir(int port);
|
||||||
void bbFlushJoy();
|
void bbFlushJoy();
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
#include "bbmath.hpp"
|
#include "bbmath.hpp"
|
||||||
#include "std.hpp"
|
#include <cmath>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
static int rnd_state;
|
static int rnd_state;
|
||||||
static const int RND_A = 48271;
|
static const int RND_A = 48271;
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
#ifndef BBMATH_H
|
|
||||||
#define BBMATH_H
|
|
||||||
|
|
||||||
float bbSin(float n);
|
float bbSin(float n);
|
||||||
float bbCos(float n);
|
float bbCos(float n);
|
||||||
@@ -20,5 +18,3 @@ float bbLog(float n);
|
|||||||
float bbLog10(float n);
|
float bbLog10(float n);
|
||||||
float bbRnd(float from, float to);
|
float bbRnd(float from, float to);
|
||||||
void bbSeedRnd(int seed);
|
void bbSeedRnd(int seed);
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
#include "bbruntime.hpp"
|
#include "bbruntime.hpp"
|
||||||
#include "bbsys.hpp"
|
#include "bbsys.hpp"
|
||||||
#include "std.hpp"
|
#include <string>
|
||||||
|
|
||||||
|
#include <gxtimer.hpp>
|
||||||
|
|
||||||
void bbEnd()
|
void bbEnd()
|
||||||
{
|
{
|
||||||
@@ -23,7 +24,7 @@ void bbAppTitle(BBStr* ti, BBStr* cp)
|
|||||||
|
|
||||||
void bbRuntimeError(BBStr* str)
|
void bbRuntimeError(BBStr* str)
|
||||||
{
|
{
|
||||||
string t = *str;
|
std::string t = *str;
|
||||||
delete str;
|
delete str;
|
||||||
if (t.size() > 255)
|
if (t.size() > 255)
|
||||||
t[255] = 0;
|
t[255] = 0;
|
||||||
@@ -34,7 +35,7 @@ void bbRuntimeError(BBStr* str)
|
|||||||
|
|
||||||
int bbExecFile(BBStr* f)
|
int bbExecFile(BBStr* f)
|
||||||
{
|
{
|
||||||
string t = *f;
|
std::string t = *f;
|
||||||
delete f;
|
delete f;
|
||||||
int n = gx_runtime->execute(t);
|
int n = gx_runtime->execute(t);
|
||||||
if (!gx_runtime->idle())
|
if (!gx_runtime->idle())
|
||||||
@@ -60,7 +61,7 @@ BBStr* bbCommandLine()
|
|||||||
|
|
||||||
BBStr* bbSystemProperty(BBStr* p)
|
BBStr* bbSystemProperty(BBStr* p)
|
||||||
{
|
{
|
||||||
string t = gx_runtime->systemProperty(*p);
|
std::string t = gx_runtime->systemProperty(*p);
|
||||||
delete p;
|
delete p;
|
||||||
return new BBStr(t);
|
return new BBStr(t);
|
||||||
}
|
}
|
||||||
@@ -75,7 +76,7 @@ BBStr* bbGetEnv(BBStr* env_var)
|
|||||||
|
|
||||||
void bbSetEnv(BBStr* env_var, BBStr* val)
|
void bbSetEnv(BBStr* env_var, BBStr* val)
|
||||||
{
|
{
|
||||||
string t = *env_var + "=" + *val;
|
std::string t = *env_var + "=" + *val;
|
||||||
_putenv(t.c_str());
|
_putenv(t.c_str());
|
||||||
delete env_var;
|
delete env_var;
|
||||||
delete val;
|
delete val;
|
||||||
@@ -204,7 +205,7 @@ void bbruntime_link(void (*rtSym)(const char* sym, void* pc))
|
|||||||
//start up error
|
//start up error
|
||||||
static void sue(const char* t)
|
static void sue(const char* t)
|
||||||
{
|
{
|
||||||
string p = string("Startup Error: ") + t;
|
std::string p = std::string("Startup Error: ") + t;
|
||||||
gx_runtime->debugInfo(p.c_str());
|
gx_runtime->debugInfo(p.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Platform neutral runtime library.
|
Platform neutral runtime library.
|
||||||
@@ -7,15 +6,11 @@ To be statically linked with an appropriate gxruntime driver.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BBRUNTIME_H
|
#pragma once
|
||||||
#define BBRUNTIME_H
|
#include <gxruntime.hpp>
|
||||||
|
|
||||||
#include "gxruntime.hpp"
|
|
||||||
|
|
||||||
void bbruntime_link(void (*rtSym)(const char* sym, void* pc));
|
void bbruntime_link(void (*rtSym)(const char* sym, void* pc));
|
||||||
|
|
||||||
const char* bbruntime_run(gxRuntime* runtime, void (*pc)(), bool debug);
|
const char* bbruntime_run(gxRuntime* runtime, void (*pc)(), bool debug);
|
||||||
|
|
||||||
void bbruntime_panic(const char* err);
|
void bbruntime_panic(const char* err);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
|
||||||
#include "bbsockets.hpp"
|
#include "bbsockets.hpp"
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
#include <stdutil.hpp>
|
||||||
|
|
||||||
#include <WinSock2.h>
|
#include <WinSock2.h>
|
||||||
#include "std.hpp"
|
|
||||||
|
|
||||||
static bool socks_ok;
|
static bool socks_ok;
|
||||||
static WSADATA wsadata;
|
static WSADATA wsadata;
|
||||||
@@ -22,9 +24,9 @@ class UDPStream;
|
|||||||
class TCPStream;
|
class TCPStream;
|
||||||
class TCPServer;
|
class TCPServer;
|
||||||
|
|
||||||
static set<UDPStream*> udp_set;
|
static std::set<UDPStream*> udp_set;
|
||||||
static set<TCPStream*> tcp_set;
|
static std::set<TCPStream*> tcp_set;
|
||||||
static set<TCPServer*> server_set;
|
static std::set<TCPServer*> server_set;
|
||||||
|
|
||||||
class UDPStream : public bbStream {
|
class UDPStream : public bbStream {
|
||||||
public:
|
public:
|
||||||
@@ -45,7 +47,7 @@ class UDPStream : public bbStream {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
SOCKET sock;
|
SOCKET sock;
|
||||||
vector<char> in_buf, out_buf;
|
std::vector<char> in_buf, out_buf;
|
||||||
sockaddr_in addr, in_addr, out_addr;
|
sockaddr_in addr, in_addr, out_addr;
|
||||||
int in_get, e;
|
int in_get, e;
|
||||||
};
|
};
|
||||||
@@ -201,7 +203,7 @@ class TCPServer {
|
|||||||
private:
|
private:
|
||||||
int e;
|
int e;
|
||||||
SOCKET sock;
|
SOCKET sock;
|
||||||
set<TCPStream*> accepted_set;
|
std::set<TCPStream*> accepted_set;
|
||||||
};
|
};
|
||||||
|
|
||||||
TCPStream::TCPStream(SOCKET s, TCPServer* t) : sock(s), server(t), e(0)
|
TCPStream::TCPStream(SOCKET s, TCPServer* t) : sock(s), server(t), e(0)
|
||||||
@@ -348,6 +350,7 @@ void TCPServer::remove(TCPStream* s)
|
|||||||
accepted_set.erase(s);
|
accepted_set.erase(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
static inline void debugUDPStream(UDPStream* p)
|
static inline void debugUDPStream(UDPStream* p)
|
||||||
{
|
{
|
||||||
if (debug && !udp_set.count(p)) {
|
if (debug && !udp_set.count(p)) {
|
||||||
@@ -368,8 +371,13 @@ static inline void debugTCPServer(TCPServer* p)
|
|||||||
ThrowRuntimeException("TCP Server does not exist");
|
ThrowRuntimeException("TCP Server does not exist");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#define debugUPDStream
|
||||||
|
#define debugTCPStream
|
||||||
|
#define debugTCPServer
|
||||||
|
#endif
|
||||||
|
|
||||||
static vector<int> host_ips;
|
static std::vector<int> host_ips;
|
||||||
|
|
||||||
int bbCountHostIPs(BBStr* host)
|
int bbCountHostIPs(BBStr* host)
|
||||||
{
|
{
|
||||||
@@ -467,7 +475,7 @@ BBStr* bbDottedIP(int ip)
|
|||||||
+ itoa(ip & 255));
|
+ itoa(ip & 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int findHostIP(const string& t)
|
static int findHostIP(const std::string& t)
|
||||||
{
|
{
|
||||||
int ip = inet_addr(t.c_str());
|
int ip = inet_addr(t.c_str());
|
||||||
if (ip != INADDR_NONE)
|
if (ip != INADDR_NONE)
|
||||||
|
|||||||
@@ -1,7 +1,2 @@
|
|||||||
|
#pragma once
|
||||||
#ifndef BBSOCKETS_H
|
|
||||||
#define BBSOCKETS_H
|
|
||||||
|
|
||||||
#include "bbstream.hpp"
|
#include "bbstream.hpp"
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
|
|
||||||
#include "bbstream.hpp"
|
#include "bbstream.hpp"
|
||||||
#include "std.hpp"
|
#include <set>
|
||||||
|
|
||||||
static set<bbStream*> stream_set;
|
static std::set<bbStream*> stream_set;
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
void debugStream(bbStream* s)
|
void debugStream(bbStream* s)
|
||||||
{
|
{
|
||||||
if (stream_set.count(s))
|
if (stream_set.count(s))
|
||||||
return;
|
return;
|
||||||
ThrowRuntimeException("Stream does not exist");
|
ThrowRuntimeException("Stream does not exist");
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#define debugStream
|
||||||
|
#endif
|
||||||
|
|
||||||
bbStream::bbStream()
|
bbStream::bbStream()
|
||||||
{
|
{
|
||||||
@@ -80,7 +83,7 @@ BBStr* bbReadString(bbStream* s)
|
|||||||
if (s->read((char*)&len, 4)) {
|
if (s->read((char*)&len, 4)) {
|
||||||
char* buff = new char[len];
|
char* buff = new char[len];
|
||||||
if (s->read(buff, len)) {
|
if (s->read(buff, len)) {
|
||||||
*str = string(buff, len);
|
*str = std::string(buff, len);
|
||||||
}
|
}
|
||||||
delete[] buff;
|
delete[] buff;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
#ifndef BBSTREAM_H
|
|
||||||
#define BBSTREAM_H
|
|
||||||
|
|
||||||
#include "bbsys.hpp"
|
#include "bbsys.hpp"
|
||||||
|
|
||||||
class bbStream {
|
class bbStream {
|
||||||
@@ -25,5 +22,3 @@ class bbStream {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void debugStream(bbStream* s);
|
void debugStream(bbStream* s);
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
|
#include "bbsys.hpp"
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "bbsys.hpp"
|
|
||||||
|
|
||||||
#define CHKPOS(x) \
|
#define CHKPOS(x) \
|
||||||
if ((x) < 0) \
|
if ((x) < 0) \
|
||||||
@@ -39,7 +38,7 @@ BBStr* bbRight(BBStr* s, int n)
|
|||||||
BBStr* bbReplace(BBStr* s, BBStr* from, BBStr* to)
|
BBStr* bbReplace(BBStr* s, BBStr* from, BBStr* to)
|
||||||
{
|
{
|
||||||
int n = 0, from_sz = from->size(), to_sz = to->size();
|
int n = 0, from_sz = from->size(), to_sz = to->size();
|
||||||
while (n < s->size() && (n = s->find(*from, n)) != string::npos) {
|
while (n < s->size() && (n = s->find(*from, n)) != std::string::npos) {
|
||||||
s->replace(n, from_sz, *to);
|
s->replace(n, from_sz, *to);
|
||||||
n += to_sz;
|
n += to_sz;
|
||||||
}
|
}
|
||||||
@@ -55,7 +54,7 @@ int bbInstr(BBStr* s, BBStr* t, int from)
|
|||||||
int n = s->find(*t, from);
|
int n = s->find(*t, from);
|
||||||
delete s;
|
delete s;
|
||||||
delete t;
|
delete t;
|
||||||
return n == string::npos ? 0 : n + 1;
|
return n == std::string::npos ? 0 : n + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
BBStr* bbMid(BBStr* s, int o, int n)
|
BBStr* bbMid(BBStr* s, int o, int n)
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
#ifndef BBSTRING_H
|
#include "basic.hpp"
|
||||||
#define BBSTRING_H
|
|
||||||
|
|
||||||
#include "basic.h"
|
|
||||||
|
|
||||||
BBStr* bbString(BBStr* s, int n);
|
BBStr* bbString(BBStr* s, int n);
|
||||||
BBStr* bbLeft(BBStr* s, int n);
|
BBStr* bbLeft(BBStr* s, int n);
|
||||||
@@ -22,5 +19,3 @@ BBStr* bbHex(int n);
|
|||||||
BBStr* bbBin(int n);
|
BBStr* bbBin(int n);
|
||||||
BBStr* bbCurrentDate();
|
BBStr* bbCurrentDate();
|
||||||
BBStr* bbCurrentTime();
|
BBStr* bbCurrentTime();
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
#include "bbsys.hpp"
|
#include "bbsys.hpp"
|
||||||
#include "std.hpp"
|
|
||||||
|
#include <gxruntime.hpp>
|
||||||
|
|
||||||
bool debug;
|
bool debug;
|
||||||
gxRuntime* gx_runtime;
|
gxRuntime* gx_runtime;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
#ifndef BBSYS_H
|
|
||||||
#define BBSYS_H
|
|
||||||
|
|
||||||
#include "basic.hpp"
|
#include "basic.hpp"
|
||||||
#include "gxruntime.hpp"
|
|
||||||
|
#include <gxruntime.hpp>
|
||||||
|
|
||||||
extern bool debug;
|
extern bool debug;
|
||||||
extern gxRuntime* gx_runtime;
|
extern gxRuntime* gx_runtime;
|
||||||
@@ -18,5 +16,3 @@ struct bbEx {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define ThrowRuntimeException(_X_) throw bbEx(_X_);
|
#define ThrowRuntimeException(_X_) throw bbEx(_X_);
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
|
|
||||||
#include "std.hpp"
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
|
|
||||||
#ifndef STD_H
|
|
||||||
#define STD_H
|
|
||||||
|
|
||||||
//#ifndef _WINSOCKAPI_
|
|
||||||
//#define _WINSOCKAPI_ /* Prevent inclusion of winsock.h in windows.h */
|
|
||||||
//#endif
|
|
||||||
#include <windows.h>
|
|
||||||
//#include <winsock2.h>
|
|
||||||
|
|
||||||
#include "../stdutil/stdutil.hpp"
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <list>
|
|
||||||
#include <map>
|
|
||||||
#include <set>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
|
|
||||||
#include "userlibs.hpp"
|
#include "userlibs.hpp"
|
||||||
#include "bbsys.hpp"
|
#include "bbsys.hpp"
|
||||||
#include "std.hpp"
|
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
static vector<HMODULE> _mods;
|
static std::vector<HMODULE> _mods;
|
||||||
|
|
||||||
struct Str {
|
struct Str {
|
||||||
char* p;
|
char* p;
|
||||||
@@ -27,7 +25,7 @@ static void procNotFound()
|
|||||||
|
|
||||||
void _bbLoadLibs(char* p)
|
void _bbLoadLibs(char* p)
|
||||||
{
|
{
|
||||||
string home;
|
std::string home;
|
||||||
|
|
||||||
if (const char* t = getenv("blitzpath"))
|
if (const char* t = getenv("blitzpath"))
|
||||||
home = t;
|
home = t;
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
#ifndef USERLIBS_H
|
|
||||||
#define USERLIBS_H
|
|
||||||
|
|
||||||
#include "basic.hpp"
|
#include "basic.hpp"
|
||||||
|
|
||||||
void _bbLoadLibs(char* p);
|
void _bbLoadLibs(char* p);
|
||||||
|
|
||||||
const char* _bbStrToCStr(BBStr* str);
|
const char* _bbStrToCStr(BBStr* str);
|
||||||
BBStr* _bbCStrToStr(const char* str);
|
BBStr* _bbCStrToStr(const char* str);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
Reference in New Issue
Block a user