1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-02 03:50:36 +00:00

Merge branch 'runtime_tidyup' into development

This commit is contained in:
Luke Ceddia 2018-01-18 19:12:10 +11:00
commit 06250fed9f
8 changed files with 287 additions and 4678 deletions

View file

@ -22,23 +22,16 @@
#define QB64_GL1
#define QB64_GLUT
#ifdef QB64_LINUX
#ifndef QB64_MACOSX
#define QB64_X11
#endif
#endif
#ifdef DEPENDENCY_CONSOLE_ONLY
#undef QB64_GLUT
#else
#define QB64_GUI
#endif
#define NO_S_D_L
//core
#ifdef QB64_GUI
#ifdef QB64_GLUT
//This file only contains header stuff
#include "parts/core/src.c"
#endif
#endif
@ -51,7 +44,6 @@
#define int64 __int64
#endif
//#include <Shlobj.h>
#include <shfolder.h>
#include <float.h>
@ -132,33 +124,6 @@ struct qbs{
qbs_field *field;
};
//substitute functionality
#ifdef QB64_WINDOWS
inline void SDL_Delay(uint32 milliseconds){//redefine SDL_Delay to call Sleep
Sleep(milliseconds);
}
#else
inline void SDL_Delay(uint32 milliseconds){//redefine SDL_Delay to call Sleep
static uint64 sec,nsec;
sec=milliseconds/1000;
nsec=(milliseconds%1000)*1000000;
static timespec ts;
ts.tv_sec = sec;
ts.tv_nsec = nsec;
nanosleep (&ts, NULL);
}
inline void Sleep(uint32 milliseconds){
SDL_Delay(milliseconds);
}
inline uint32 _lrotl(uint32 word,uint32 shift){
return (word << shift) | (word >> (32 - shift));
}
inline void ZeroMemory(void *ptr,int64 bytes){
memset(ptr,0,bytes);
}
#endif
struct img_struct{
void *lock_offset;
int64 lock_id;
@ -205,125 +170,6 @@ struct img_struct{
#define IMG_SCREEN 2 //img is linked to other screen pages
#define IMG_FREEMEM 4 //if set, it means memory must be freed
#ifdef QB64_NOT_X86
inline int64 qbr(long double f){
int64 i; int temp=0;
if (f>9223372036854775807) {temp=1;f=f-9223372036854775808u;} //if it's too large for a signed int64, make it an unsigned int64 and return that value if possible.
if (f<0) i=f-0.5f; else i=f+0.5f;
if (temp) return i|0x8000000000000000;//+9223372036854775808;
return i;
}
inline uint64 qbr_longdouble_to_uint64(long double f){if (f<0) return(f-0.5f); else return(f+0.5f);}
inline int32 qbr_float_to_long(float f){if (f<0) return(f-0.5f); else return(f+0.5f);}
inline int32 qbr_double_to_long(double f){if (f<0) return(f-0.5f); else return(f+0.5f);}
#else
//QBASIC compatible rounding via FPU:
#ifdef QB64_MICROSOFT
inline int64 qbr(long double f){
int64 i; int temp=0;
if (f>9223372036854775807) {temp=1;f=f-9223372036854775808u;} //if it's too large for a signed int64, make it an unsigned int64 and return that value if possible.
__asm{
fld f
fistp i
}
if (temp) return i|0x8000000000000000;//+9223372036854775808;
return i;
}
inline uint64 qbr_longdouble_to_uint64(long double f){
uint64 i;
__asm{
fld f
fistp i
}
return i;
}
inline int32 qbr_float_to_long(float f){
int32 i;
__asm{
fld f
fistp i
}
return i;
}
inline int32 qbr_double_to_long(double f){
int32 i;
__asm{
fld f
fistp i
}
return i;
}
#else
//FLDS=load single
//FLDL=load double
//FLDT=load long double
inline int64 qbr(long double f){
int64 i; int temp=0;
if (f>9223372036854775807) {temp=1;f=f-9223372036854775808u;} //if it's too large for a signed int64, make it an unsigned int64 and return that value if possible.
__asm__ (
"fldt %1;"
"fistpll %0;"
:"=m" (i)
:"m" (f)
);
if (temp) return i|0x8000000000000000;// if it's an unsigned int64, manually set the bit flag
return i;
}
inline uint64 qbr_longdouble_to_uint64(long double f){
uint64 i;
__asm__ (
"fldt %1;"
"fistpll %0;"
:"=m" (i)
:"m" (f)
);
return i;
}
inline int32 qbr_float_to_long(float f){
int32 i;
__asm__ (
"flds %1;"
"fistpl %0;"
:"=m" (i)
:"m" (f)
);
return i;
}
inline int32 qbr_double_to_long(double f){
int32 i;
__asm__ (
"fldl %1;"
"fistpl %0;"
:"=m" (i)
:"m" (f)
);
return i;
}
#endif
#endif //x86 support
//bit-array access functions (note: used to be included through 'bit.cpp')
static int64 bmask;
static uint64 *bptr64;
static int64 bval64;
inline uint64 getubits(uint32 bsize,uint8 *base,ptrszint i){
bmask=~(-(((int64)1)<<bsize));
i*=bsize;
return ((*(uint64*)(base+(i>>3)))>>(i&7))&bmask;
}
inline int64 getbits(uint32 bsize,uint8 *base,ptrszint i){
bmask=~(-(((int64)1)<<bsize));
i*=bsize;
bval64=((*(uint64*)(base+(i>>3)))>>(i&7))&bmask;
if (bval64&(((int64)1)<<(bsize-1))) return bval64|(~bmask);
return bval64;
}
inline void setbits(uint32 bsize,uint8 *base,ptrszint i,int64 val){
bmask=(((uint64)1)<<bsize)-1;
i*=bsize;
bptr64=(uint64*)(base+(i>>3));
*bptr64=(*bptr64&( ( (bmask<<(i&7)) ^-1) )) | ((val&bmask)<<(i&7));
}
//QB64 internal variable type flags (internally referenced by some C functions)
#define ISSTRING 1073741824
@ -409,17 +255,6 @@ struct device_struct{
#define DEVICETYPE_KEYBOARD 2
#define DEVICETYPE_MOUSE 3
struct mem_block{
ptrszint offset;
ptrszint size;

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
#ifndef INC_LIBQB_H
#define INC_LIBQB_H
#include "common.cpp"
#include "common.h"
void error(int32 error_number);
extern uint32 new_error;

View file

@ -1,11 +1,14 @@
/* Provide some OS/compiler macros. Note that a Mac has QB64_LINUX too
/* Provide some OS/compiler macros.
* QB64_WINDOWS: Is this a Windows system?
* QB64_LINUX: Is this a Linux system?
* QB64_MACOSX: Is this MacOSX, or MacOS or whatever Apple calls it now?
* QB64_UNIX: Is this a Unix-flavoured system?
*
* QB64_BACKSLASH_FILESYSTEM: Does this system use \ for file paths (as opposed to /)?
* QB64_MICROSOFT: Are we compiling with Visual Studio?
* QB64_GCC: Are we compiling with gcc?
* QB64_MINGW: Are we compiling with MinGW, specifically? (Set in addition to QB64_GCC)
* QB64_LINUX: Is this a Unix system? (really should be QB64_UNIX)
* QB64_MACOSX: Is this MacOSX, or MacOS or whatever Apple calls it now?
*
* QB64_32: A 32bit system (the default)
* QB64_64: A 64bit system (assumes all Macs are 64 bit)
*/
@ -13,18 +16,22 @@
#define QB64_WINDOWS
#define QB64_BACKSLASH_FILESYSTEM
#ifdef _MSC_VER
//Do we even support non-mingw compilers on Windows?
//Do we even support non-mingw compilers on Windows?
#define QB64_MICROSOFT
#else
#define QB64_GCC
#define QB64_MINGW
#endif
#else
#define QB64_LINUX
#elif defined(__APPLE__)
#define QB64_MACOSX
#define QB64_UNIX
#define QB64_GCC
#ifdef __APPLE__
#define QB64_MACOSX
#endif
#elif defined(__linux__)
#define QB64_LINUX
#define QB64_UNIX
#define QB64_GCC
#else
#error "Unknown system; refusing to build. Edit os.h if needed"
#endif
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__) || defined(QB64_MACOSX)

View file

@ -2,12 +2,6 @@
#include "glew/include/GL/glew.h"
#endif
#ifdef QB64_ANDROID
#include <EGL/egl.h>
#include <GLES/gl.h>
#include <GLES/glext.h>
#endif
#ifdef QB64_MACOSX
//note: MacOSX uses Apple's GLUT not FreeGLUT
#include <OpenGL/gl.h>
@ -16,14 +10,5 @@
#include <GLUT/glut.h>
#else
#define CORE_FREEGLUT
#ifdef QB64_ANDROID
#include "android_core/include/GL/freeglut.h"
#include "glues/src/glues.h"
#else
#ifdef QB64_BACKSLASH_FILESYSTEM
#include "src\\freeglut.h"
#else
#include "src/freeglut.h"
#endif
#endif
#include "src/freeglut.h"
#endif

View file

@ -105,29 +105,6 @@ if (isHardware){
}
return i;
#ifndef NO_S_D_L
static qbs *tqbs=NULL,*nullt=NULL;
static int32 i;
if (new_error) return 0;
//validate bpp
if (passed){
if ((bpp!=32)&&(bpp!=256)){error(5); return 0;}
}else{
if (write_page->text){error(5); return 0;}
bpp=-1;
}
if (!f->len) return -1;//return invalid handle if null length string
if (!tqbs) tqbs=qbs_new(0,0);
if (!nullt){nullt=qbs_new(1,0); nullt->chr[0]=0;}
qbs_set(tqbs,qbs_add(f,nullt));
i=imgload(fixdir(tqbs),bpp);
if (!i) return -1;//failed
return -i;
return -1;
#endif //NO_S_D_L
}
#endif

View file

@ -1,4 +1,4 @@
#include "common.cpp"
#include "common.h"
#ifdef QB64_MACOSX
#include <ApplicationServices/ApplicationServices.h>
@ -604,8 +604,18 @@ extern uint64 string2ui64(qbs*str);
extern float string2s(qbs*str);
extern double string2d(qbs*str);
extern long double string2f(qbs*str);
#ifndef QB64_WINDOWS
extern void Sleep(uint32 milliseconds);
extern void ZeroMemory(void *ptr,int64 bytes);
#endif
extern int64 qbr(long double f);
extern uint64 qbr_longdouble_to_uint64(long double f);
extern int32 qbr_float_to_long(float f);
extern int32 qbr_double_to_long(double f);
extern uint64 getubits(uint32 bsize,uint8 *base,ptrszint i);
extern int64 getbits(uint32 bsize,uint8 *base,ptrszint i);
extern void setbits(uint32 bsize,uint8 *base,ptrszint i,int64 val);
@ -1011,7 +1021,6 @@ sub_close(NULL,NULL);//closes all open files
//free images
freeallimages();
//stop & free sounds (note: QB also stops any sound from the PLAY command)
//NO_S_D_L//sndcloseall();
//invalidate RETURN location(s)
next_return_point=0;
//reset error goto location to 'unhandled'

View file

@ -9515,7 +9515,6 @@ DO
IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$
NEXT
PRINT #12, "skip" + u$ + ":"
PRINT #12, "revert_input_check();"
IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);"
layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$
GOTO finishedline
@ -21865,25 +21864,6 @@ END FUNCTION
SUB xend
'1. locate bottomline,1
'PRINT #12, "display_page->cursor_y=print_holding_cursor=0; qbg_cursor_x=1; qbg_cursor_y=qbg_height_in_characters;"
'2. print a message in the screen's width
'PRINT #12, "if (qbg_width_in_characters==80){"
'PRINT #12, "qbs_print(qbs_new_txt(" + CHR$(34) + "Press any key to continue" + SPACE$(80 - 25) + CHR$(34) + "),0);"
'PRINT #12, "}else{"
'PRINT #12, "qbs_print(qbs_new_txt(" + CHR$(34) + "Press any key to continue" + SPACE$(40 - 25) + CHR$(34) + "),0);"
'PRINT #12, "}"
'3. wait for a key to be pressed
'PRINT #12, "do{"
'PRINT #12, "SDL_Delay(0);"
'PRINT #12, "if (stop_program) end();"
'PRINT #12, "}while(qbs_cleanup(qbs_tmp_base,qbs_equal(qbs_inkey(),
' qbs_new_txt(" + CHR$(34) + CHR$(34) + "))));"
'4. quit
'PRINT #12, "close_program=1;"
'PRINT #12, "end();"
PRINT #12, "sub_end();"
END SUB