mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-07-04 04:50:22 +00:00
Merge branch 'runtime_tidyup' into development
This commit is contained in:
commit
06250fed9f
|
@ -22,23 +22,16 @@
|
||||||
#define QB64_GL1
|
#define QB64_GL1
|
||||||
#define QB64_GLUT
|
#define QB64_GLUT
|
||||||
|
|
||||||
#ifdef QB64_LINUX
|
|
||||||
#ifndef QB64_MACOSX
|
|
||||||
#define QB64_X11
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DEPENDENCY_CONSOLE_ONLY
|
#ifdef DEPENDENCY_CONSOLE_ONLY
|
||||||
#undef QB64_GLUT
|
#undef QB64_GLUT
|
||||||
#else
|
#else
|
||||||
#define QB64_GUI
|
#define QB64_GUI
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NO_S_D_L
|
|
||||||
|
|
||||||
//core
|
//core
|
||||||
#ifdef QB64_GUI
|
#ifdef QB64_GUI
|
||||||
#ifdef QB64_GLUT
|
#ifdef QB64_GLUT
|
||||||
|
//This file only contains header stuff
|
||||||
#include "parts/core/src.c"
|
#include "parts/core/src.c"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -51,7 +44,6 @@
|
||||||
#define int64 __int64
|
#define int64 __int64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#include <Shlobj.h>
|
|
||||||
#include <shfolder.h>
|
#include <shfolder.h>
|
||||||
|
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
@ -132,33 +124,6 @@ struct qbs{
|
||||||
qbs_field *field;
|
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{
|
struct img_struct{
|
||||||
void *lock_offset;
|
void *lock_offset;
|
||||||
int64 lock_id;
|
int64 lock_id;
|
||||||
|
@ -205,125 +170,6 @@ struct img_struct{
|
||||||
#define IMG_SCREEN 2 //img is linked to other screen pages
|
#define IMG_SCREEN 2 //img is linked to other screen pages
|
||||||
#define IMG_FREEMEM 4 //if set, it means memory must be freed
|
#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)
|
//QB64 internal variable type flags (internally referenced by some C functions)
|
||||||
#define ISSTRING 1073741824
|
#define ISSTRING 1073741824
|
||||||
|
@ -409,17 +255,6 @@ struct device_struct{
|
||||||
#define DEVICETYPE_KEYBOARD 2
|
#define DEVICETYPE_KEYBOARD 2
|
||||||
#define DEVICETYPE_MOUSE 3
|
#define DEVICETYPE_MOUSE 3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct mem_block{
|
struct mem_block{
|
||||||
ptrszint offset;
|
ptrszint offset;
|
||||||
ptrszint size;
|
ptrszint size;
|
4696
internal/c/libqb.cpp
4696
internal/c/libqb.cpp
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
||||||
#ifndef INC_LIBQB_H
|
#ifndef INC_LIBQB_H
|
||||||
#define INC_LIBQB_H
|
#define INC_LIBQB_H
|
||||||
#include "common.cpp"
|
#include "common.h"
|
||||||
|
|
||||||
void error(int32 error_number);
|
void error(int32 error_number);
|
||||||
extern uint32 new_error;
|
extern uint32 new_error;
|
||||||
|
|
|
@ -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_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_BACKSLASH_FILESYSTEM: Does this system use \ for file paths (as opposed to /)?
|
||||||
* QB64_MICROSOFT: Are we compiling with Visual Studio?
|
* QB64_MICROSOFT: Are we compiling with Visual Studio?
|
||||||
* QB64_GCC: Are we compiling with gcc?
|
* QB64_GCC: Are we compiling with gcc?
|
||||||
* QB64_MINGW: Are we compiling with MinGW, specifically? (Set in addition to QB64_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_32: A 32bit system (the default)
|
||||||
* QB64_64: A 64bit system (assumes all Macs are 64 bit)
|
* QB64_64: A 64bit system (assumes all Macs are 64 bit)
|
||||||
*/
|
*/
|
||||||
|
@ -13,18 +16,22 @@
|
||||||
#define QB64_WINDOWS
|
#define QB64_WINDOWS
|
||||||
#define QB64_BACKSLASH_FILESYSTEM
|
#define QB64_BACKSLASH_FILESYSTEM
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
//Do we even support non-mingw compilers on Windows?
|
//Do we even support non-mingw compilers on Windows?
|
||||||
#define QB64_MICROSOFT
|
#define QB64_MICROSOFT
|
||||||
#else
|
#else
|
||||||
#define QB64_GCC
|
#define QB64_GCC
|
||||||
#define QB64_MINGW
|
#define QB64_MINGW
|
||||||
#endif
|
#endif
|
||||||
#else
|
#elif defined(__APPLE__)
|
||||||
#define QB64_LINUX
|
#define QB64_MACOSX
|
||||||
|
#define QB64_UNIX
|
||||||
#define QB64_GCC
|
#define QB64_GCC
|
||||||
#ifdef __APPLE__
|
#elif defined(__linux__)
|
||||||
#define QB64_MACOSX
|
#define QB64_LINUX
|
||||||
#endif
|
#define QB64_UNIX
|
||||||
|
#define QB64_GCC
|
||||||
|
#else
|
||||||
|
#error "Unknown system; refusing to build. Edit os.h if needed"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__) || defined(QB64_MACOSX)
|
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__) || defined(QB64_MACOSX)
|
||||||
|
|
|
@ -2,12 +2,6 @@
|
||||||
#include "glew/include/GL/glew.h"
|
#include "glew/include/GL/glew.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef QB64_ANDROID
|
|
||||||
#include <EGL/egl.h>
|
|
||||||
#include <GLES/gl.h>
|
|
||||||
#include <GLES/glext.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef QB64_MACOSX
|
#ifdef QB64_MACOSX
|
||||||
//note: MacOSX uses Apple's GLUT not FreeGLUT
|
//note: MacOSX uses Apple's GLUT not FreeGLUT
|
||||||
#include <OpenGL/gl.h>
|
#include <OpenGL/gl.h>
|
||||||
|
@ -16,14 +10,5 @@
|
||||||
#include <GLUT/glut.h>
|
#include <GLUT/glut.h>
|
||||||
#else
|
#else
|
||||||
#define CORE_FREEGLUT
|
#define CORE_FREEGLUT
|
||||||
#ifdef QB64_ANDROID
|
#include "src/freeglut.h"
|
||||||
#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
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -105,29 +105,6 @@ if (isHardware){
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
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
|
#endif
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "common.cpp"
|
#include "common.h"
|
||||||
|
|
||||||
#ifdef QB64_MACOSX
|
#ifdef QB64_MACOSX
|
||||||
#include <ApplicationServices/ApplicationServices.h>
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
|
@ -604,8 +604,18 @@ extern uint64 string2ui64(qbs*str);
|
||||||
extern float string2s(qbs*str);
|
extern float string2s(qbs*str);
|
||||||
extern double string2d(qbs*str);
|
extern double string2d(qbs*str);
|
||||||
extern long double string2f(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
|
//free images
|
||||||
freeallimages();
|
freeallimages();
|
||||||
//stop & free sounds (note: QB also stops any sound from the PLAY command)
|
//stop & free sounds (note: QB also stops any sound from the PLAY command)
|
||||||
//NO_S_D_L//sndcloseall();
|
|
||||||
//invalidate RETURN location(s)
|
//invalidate RETURN location(s)
|
||||||
next_return_point=0;
|
next_return_point=0;
|
||||||
//reset error goto location to 'unhandled'
|
//reset error goto location to 'unhandled'
|
||||||
|
|
|
@ -9515,7 +9515,6 @@ DO
|
||||||
IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$
|
IF a3$ = "" THEN a3$ = a2$ ELSE a3$ = a3$ + sp + a2$
|
||||||
NEXT
|
NEXT
|
||||||
PRINT #12, "skip" + u$ + ":"
|
PRINT #12, "skip" + u$ + ":"
|
||||||
PRINT #12, "revert_input_check();"
|
|
||||||
IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);"
|
IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);"
|
||||||
layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$
|
layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$
|
||||||
GOTO finishedline
|
GOTO finishedline
|
||||||
|
@ -21865,25 +21864,6 @@ END FUNCTION
|
||||||
|
|
||||||
SUB xend
|
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();"
|
PRINT #12, "sub_end();"
|
||||||
END SUB
|
END SUB
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue