1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-03 07:41:21 +00:00

Incorporated the User Mods into the parts system.

This way, we only include that code if its commands are called upon.
In order to do this, some other areas had to be changed as well:
  - There is now a libqb.h file, which declares some routines in libqb.cpp,
    in order to allow them to be called from a separately compiled unit, i.e,
    the user mods part.
  - common.cpp now has an #include guard, just to be on the safe side.
  - The library purge routines know about the new part.
  - qb64.bas is modified to handle the new part; this area is just modeled
    off the code for the other parts.
  - Appropriate flags were set in the hash table entires for the commands.
  - The user mods, now being a separate compilation unit, #include common.cpp
    and libqb.h. The former is required for important type declarations and
    access to glut commmands, the latter for access to libqb routines.
  - qbx.cpp #includes the src.cpp file in the user mods part, which declares the
    routines.
Something to ponder: libqb does not include or rely on any of the user mod routines,
so it's probably not necessary to rebuild it like with the other parts. That exploration
is for another day, however.
This commit is contained in:
Luke Ceddia 2014-10-02 17:54:52 +10:00
parent a5b0fc7bd5
commit b9a52e9600
31 changed files with 229 additions and 88 deletions

View file

@ -1,8 +0,0 @@
//***********************************************
//**
//** A main include area so that users can organize their code into folders and such individually
//**
//***********************************************
#include "luke_mods.cpp"
#include "Steves_Main-List.cpp"

View file

@ -1,22 +0,0 @@
//***************************************************************
//**
//** Declarations for routines proved by Steve McNeill
//** Email: smcneill@swva.net
//**
//****************************************************************
//Angle Conversion Formulas
extern double func_deg2rad(double degree);
extern double func_deg2grad(double degree);
extern double func_rad2deg(double degree);
extern double func_rad2grad(double degree);
extern double func_grad2deg(double degree);
extern double func_grad2rad(double degree);
extern double func_pi();
extern int32 func_screenwidth();
extern int32 func_screenheight();
int32 func_windowexists ();
int32 func__controlchr();
int32 func__str_nc_compare(qbs *s1, qbs *s2);
int32 func__str_compare(qbs *s1, qbs *s2);

View file

@ -1,3 +1,5 @@
#ifndef INC_COMMON_CPP
#define INC_COMMON_CPP
#include "os.h"
#ifdef QB64_ANDROID
@ -399,16 +401,4 @@ struct mem_lock{
void *offset;//used by malloc'ed blocks to free them
};
#endif //INC_COMMON_CPP

View file

@ -1,4 +1,5 @@
#include "common.cpp"
#include "libqb.h"
#include "parts/core/glew/src/glew.c"
@ -17066,8 +17067,8 @@ ptrszint func_ubound(ptrszint *array,int32 index,int32 num_indexes){
return array[4*index]+array[4*index+1]-1;
}
static uint8 port60h_event[256];
static int32 port60h_events=0;
uint8 port60h_event[256];
int32 port60h_events=0;
int32 func_inp(int32 port){
@ -34703,4 +34704,3 @@ render_state.cull_mode=CULL_MODE__UNKNOWN;
#endif
}
#include "User Mods/Users Routines-List.cpp"

71
internal/c/libqb.h Normal file
View file

@ -0,0 +1,71 @@
#ifndef INC_LIBQB_H
#define INC_LIBQB_H
#include "common.cpp"
void error(int32 error_number);
extern uint32 new_error;
extern uint32 error_err; //=0;
extern double error_erl; //=0;
extern uint32 error_occurred;
extern uint32 error_goto_line;
extern uint32 error_handling;
extern uint32 error_retry;
void sub_shell4(qbs*,int32);//_DONTWAIT & _HIDE
int32 func__source();
int32 func_pos(int32 ignore);
void sub__printimage(int32 i);
double func_timer(double accuracy,int32 passed);
int32 func__newimage(int32 x,int32 y,int32 bpp,int32 passed);
void display();
void validatepage(int32);
void sub__dest(int32);
void sub__source(int32);
int32 func__printwidth(qbs*,int32,int32);
void sub_cls(int32,uint32,int32);
void qbs_print(qbs*,int32);
int32 func__copyimage(int32 i,int32 mode,int32 passed);
int32 func__dest();
int32 func__display();
void qbg_sub_view_print(int32,int32,int32);
qbs *qbs_new(int32,uint8);
qbs *qbs_new_txt(const char*);
qbs *qbs_add(qbs*,qbs*);
qbs *qbs_set(qbs*,qbs*);
void qbg_sub_window(float,float,float,float,int32);
extern int32 autodisplay;
//GFS forward references
int32 gfs_eof_passed(int32 i);
int32 gfs_eof_reached(int32 i);
int64 gfs_getpos(int32 i);
int32 gfs_fileno_valid(int32 f);
int32 gfs_fileno_freefile();//like FREEFILE
void gfs_fileno_use(int32 f, int32 i);
int32 gfs_open(qbs *filename,int32 access,int32 restrictions, int32 how);
int32 gfs_close(int32 i);
int64 gfs_lof(int32 i);
int32 gfs_setpos(int32 i, int64 position);
int32 gfs_write(int32 i,int64 position,uint8 *data,int64 size);
int32 gfs_read(int32 i,int64 position,uint8 *data,int64 size);
int64 gfs_read_bytes();
extern uint8 cmem[1114099];//16*65535+65535+3 (enough for highest referencable dword in conv memory)
//keyhit cyclic buffer
extern int64 keyhit[8192];
// keyhit specific internal flags: (stored in high 32-bits)
// &4294967296->numpad was used
extern int32 keyhit_nextfree;
extern int32 keyhit_next;
//note: if full, the oldest message is discarded to make way for the new message
extern uint8 port60h_event[256];
extern int32 port60h_events;
extern int32 window_exists;
extern int32 no_control_characters2;
extern qbs *qbs_lcase(qbs *str);
extern qbs *qbs_ucase(qbs *str);
#endif

View file

@ -1,5 +1,5 @@
/* Routines by Luke
* The actual code is in Luke_Main-List.cpp
* The actual code is in luke_mods.cpp
* Write me at <flukiluke@gmail.com> if I broke something
*/
qbs *func__cwd();

View file

@ -0,0 +1,23 @@
//***************************************************************
//**
//** Declarations for routines proved by Steve McNeill
//** Email: smcneill@swva.net
//**
//****************************************************************
//Angle Conversion Formulas
double func_deg2rad(double degree);
double func_deg2grad(double degree);
double func_rad2deg(double degree);
double func_rad2grad(double degree);
double func_grad2deg(double degree);
double func_grad2rad(double degree);
double func_pi();
int32 func_screenwidth();
int32 func_screenheight();
void sub_screenicon();
int32 func_windowexists ();
int32 func__controlchr();
int32 func__str_nc_compare(qbs *s1, qbs *s2);
int32 func__str_compare(qbs *s1, qbs *s2);

View file

@ -0,0 +1,14 @@
#!/bin/sh
gcc -I../../../../ -DFREEGLUT_STATIC -I../../include -c ../../src/luke_mods.cpp -o temp/luke_mods.o
gcc -I../../../../ -DFREEGLUT_STATIC -I../../include -c ../../src/steve_mods.cpp -o temp/steve_mods.o
ar rcs src.a temp/steve_mods.o temp/luke_mods.o
echo "Press any key to continue..."
Pause()
{
OLDCONFIG=`stty -g`
stty -icanon -echo min 1 time 0
dd count=1 2>/dev/null
stty $OLDCONFIG
}
Pause

View file

@ -0,0 +1,15 @@
cd "$(dirname "$0")"
gcc -I../../../../ -I../../include -c ../../src/luke_mods.cpp -o temp/luke_mods.o
gcc -I../../../../ -I../../include -c ../../src/steve_mods.cpp -o temp/steve_mods.o
ar rcs src.a temp/steve_mods.o temp/luke_mods.o
echo "Press any key to continue..."
Pause()
{
OLDCONFIG=`stty -g`
stty -icanon -echo min 1 time 0
dd count=1 2>/dev/null
stty $OLDCONFIG
}
Pause

View file

@ -0,0 +1,4 @@
..\..\..\..\c_compiler\bin\gcc -DFREEGLUT_STATIC -I..\..\..\..\ -I..\..\include -c ..\..\src\luke_mods.cpp -o temp\luke_mods.o
..\..\..\..\c_compiler\bin\gcc -DFREEGLUT_STATIC -I..\..\..\..\ -I..\..\include -c ..\..\src\steve_mods.cpp -o temp\steve_mods.o
..\..\..\..\c_compiler\bin\ar rcs src.a temp\steve_mods.o temp\luke_mods.o
pause

View file

@ -0,0 +1,5 @@
#ifndef DEPENDENCY_USER_MODS
//No stubs required
#else
#include "include/user_mods.h"
#endif

View file

@ -10,7 +10,7 @@ int32 func_screenheight () {
void sub_screenicon () {
while (!window_exists){Sleep(100);}
glutIconifyWindow;
glutIconifyWindow();
return;
}
@ -20,4 +20,4 @@ int32 func_windowexists () {
int32 func__controlchr () {
return -no_control_characters2;
}
}

View file

@ -1,3 +1,6 @@
#include <stdlib.h>
#include <string.h>
#ifdef QB64_WINDOWS
#define SNCMP(x,y,z) _memicmp((char *)x, (char *)y, z)
#else
@ -19,7 +22,7 @@ int32 func__str_nc_compare(qbs *s1, qbs *s2) {
if (i<0) return -1;
if (i>0) return 1;
if (l1<l2) return -1;
if (l2>l1) return 1;
if (l1>l2) return 1;
return 0;
}
c1++;
@ -52,4 +55,4 @@ int32 func__str_compare(qbs *s1, qbs *s2) {
if (l1<l2) return -1;
if (l1>l2) return 1;
return 0;
}
}

View file

@ -1,3 +1,9 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "libqb.h"
#include "luke_mods.h"
//Get Current Working Directory
qbs *func__cwd(){
qbs *final, *tqbs;

View file

@ -1,4 +1,7 @@
#include "libqb.h"
#include "steve_mods.h"
#include "Steve Stuff/convert_angle.cpp"
#include "Steve Stuff/pi.cpp"
#include "Steve Stuff/screeninfo.cpp"
#include "Steve Stuff/stringcomp.cpp"
#include "Steve Stuff/stringcomp.cpp"

View file

@ -29,3 +29,7 @@ del parts\audio\out\os\lnx\temp\*.o
del parts\video\font\ttf\os\win\src.o
del parts\video\font\ttf\os\lnx\src.o
del parts\user_mods\os\win\src.a
del parts\user_mods\os\lnx\src.a
del parts\user_mods\os\win\temp\*.o
del parts\user_mods\os\lnx\temp\*.o

View file

@ -31,3 +31,7 @@ rm parts/audio/out/os/lnx/temp/*.o
rm parts/video/font/ttf/os/win/src.o
rm parts/video/font/ttf/os/lnx/src.o
rm parts/user_mods/os/win/src.a
rm parts/user_mods/os/lnx/src.a
rm parts/user_mods/os/win/temp/*.o
rm parts/user_mods/os/lnx/temp/*.o

View file

@ -31,3 +31,7 @@ rm parts/audio/out/os/lnx/temp/*.o
rm parts/video/font/ttf/os/win/src.o
rm parts/video/font/ttf/os/lnx/src.o
rm parts/user_mods/os/win/src.a
rm parts/user_mods/os/lnx/src.a
rm parts/user_mods/os/win/temp/*.o
rm parts/user_mods/os/lnx/temp/*.o

View file

@ -31,3 +31,8 @@ rm parts/audio/out/os/lnx/temp/*.o
rm parts/video/font/ttf/os/win/src.o
rm parts/video/font/ttf/os/lnx/src.o
rm parts/user_mods/os/win/src.a
rm parts/user_mods/os/lnx/src.a
rm parts/user_mods/os/win/temp/*.o
rm parts/user_mods/os/lnx/temp/*.o

View file

@ -31,3 +31,8 @@ rm parts/audio/out/os/lnx/temp/*.o
rm parts/video/font/ttf/os/win/src.o
rm parts/video/font/ttf/os/lnx/src.o
rm parts/user_mods/os/win/src.a
rm parts/user_mods/os/lnx/src.a
rm parts/user_mods/os/win/temp/*.o
rm parts/user_mods/os/lnx/temp/*.o

View file

@ -29,3 +29,7 @@ del parts\audio\out\os\lnx\temp\*.o
del parts\video\font\ttf\os\win\src.o
del parts\video\font\ttf\os\lnx\src.o
del parts\user_mods\os\win\src.a
del parts\user_mods\os\lnx\src.a
del parts\user_mods\os\win\temp\*.o
del parts\user_mods\os\lnx\temp\*.o

View file

@ -9,6 +9,8 @@
#include <cmath>
#endif
#include "parts/user_mods/src.cpp"
/* testing only
#ifdef QB64_WINDOWS
@ -94,24 +96,6 @@ struct stat statbuf;
//*******************************************************
//
// Change to make user-defined additions easier to track inside their own headers
//
//********************************************************
#ifdef QB64_BACKSLASH_FILESYSTEM
#include "User Mods\user_list.h"
#else
#include "User Mods/user_list.h"
#endif
/*

View file

@ -59,7 +59,7 @@ CONST DEPENDENCY_AUDIO_DECODE = 3: DEPENDENCY_LAST = DEPENDENCY_LAST + 1
CONST DEPENDENCY_AUDIO_OUT = 4: DEPENDENCY_LAST = DEPENDENCY_LAST + 1
CONST DEPENDENCY_GL = 5: DEPENDENCY_LAST = DEPENDENCY_LAST + 1
CONST DEPENDENCY_IMAGE_CODEC = 6: DEPENDENCY_LAST = DEPENDENCY_LAST + 1
CONST DEPENDENCY_USER_MODS = 7: DEPENDENCY_LAST = DEPENDENCY_LAST + 1
DIM SHARED DEPENDENCY(1 TO DEPENDENCY_LAST)
@ -10831,6 +10831,17 @@ IF DEPENDENCY(DEPENDENCY_AUDIO_OUT) THEN
libs$ = libs$ + " " + d2$ + "\src.a"
END IF
IF DEPENDENCY(DEPENDENCY_USER_MODS) THEN
defines$ = defines$ + defines_header$ + "DEPENDENCY_USER_MODS"
d1$ = "parts\user_mods"
d2$ = d1$ + "\os\" + o$
d3$ = "internal\c\" + d2$
IF _FILEEXISTS(d3$ + "\src.a") = 0 THEN
Build d3$
END IF
libs$ = libs$ + " " + d2$ + "\src.a"
END IF
'finalize libs$ and defines$ strings
IF LEN(libs$) THEN libs$ = libs$ + " "
PATH_SLASH_CORRECT libs$

View file

@ -1,17 +1,19 @@
'Get Current Working Directory
clearid
id.n = "_CWD"
id.musthave = "$"
id.subfunc = 1
id.callname = "func__cwd"
id.ret = STRINGTYPE - ISPOINTER
regid
clearid
id.n = "_KEYCLEAR"
id.subfunc = 2
id.args = 1
id.arg = MKL$(LONGTYPE - ISPOINTER)
id.specialformat = "[?]"
id.callname = "sub__keyclear"
regid
'Get Current Working Directory
clearid
id.n = "_CWD"
id.musthave = "$"
id.subfunc = 1
id.callname = "func__cwd"
id.ret = STRINGTYPE - ISPOINTER
id.Dependency = DEPENDENCY_USER_MODS
regid
clearid
id.n = "_KEYCLEAR"
id.subfunc = 2
id.args = 1
id.arg = MKL$(LONGTYPE - ISPOINTER)
id.specialformat = "[?]"
id.callname = "sub__keyclear"
id.Dependency = DEPENDENCY_USER_MODS
regid

View file

@ -5,6 +5,7 @@ id.callname = "func_deg2rad"
id.args = 1
id.arg = MKL$(FLOATTYPE - ISPOINTER)
id.ret = FLOATTYPE - ISPOINTER
id.Dependency = DEPENDENCY_USER_MODS
regid
clearid
@ -14,6 +15,7 @@ id.callname = "func_deg2grad"
id.args = 1
id.arg = MKL$(FLOATTYPE - ISPOINTER)
id.ret = FLOATTYPE - ISPOINTER
id.Dependency = DEPENDENCY_USER_MODS
regid
clearid
@ -23,6 +25,7 @@ id.callname = "func_rad2deg"
id.args = 1
id.arg = MKL$(FLOATTYPE - ISPOINTER)
id.ret = FLOATTYPE - ISPOINTER
id.Dependency = DEPENDENCY_USER_MODS
regid
clearid
@ -32,6 +35,7 @@ id.callname = "func_rad2grad"
id.args = 1
id.arg = MKL$(FLOATTYPE - ISPOINTER)
id.ret = FLOATTYPE - ISPOINTER
id.Dependency = DEPENDENCY_USER_MODS
regid
clearid
@ -41,6 +45,7 @@ id.callname = "func_grad2deg"
id.args = 1
id.arg = MKL$(FLOATTYPE - ISPOINTER)
id.ret = FLOATTYPE - ISPOINTER
id.Dependency = DEPENDENCY_USER_MODS
regid
clearid
@ -50,6 +55,7 @@ id.callname = "func_grad2rad"
id.args = 1
id.arg = MKL$(FLOATTYPE - ISPOINTER)
id.ret = FLOATTYPE - ISPOINTER
id.Dependency = DEPENDENCY_USER_MODS
regid
clearid 'Clear the old id info so we set the slate for a new one
@ -157,6 +163,7 @@ id.subfunc = 1
id.callname = "func_pi"
id.args = 0
id.ret = DOUBLETYPE - ISPOINTER
id.Dependency = DEPENDENCY_USER_MODS
regid
clearid
@ -165,6 +172,7 @@ id.subfunc = 1
id.callname = "func_screenheight"
id.args = 0
id.ret = LONGTYPE - ISPOINTER
id.Dependency = DEPENDENCY_USER_MODS
regid
clearid
@ -173,18 +181,21 @@ id.subfunc = 1
id.callname = "func_screenwidth"
id.args = 0
id.ret = LONGTYPE - ISPOINTER
id.Dependency = DEPENDENCY_USER_MODS
regid
clearid
id.n = "_SCREENICON" 'name change to from _ICONIFYWINDOW to _SCREENICON to match the screenshow and screenhide
id.subfunc = 2
id.callname = "sub_screenicon"
id.Dependency = DEPENDENCY_USER_MODS
regid
clearid
id.n = "_SCREENEXISTS"
id.subfunc = 1
id.callname = "func_windowexists"
id.Dependency = DEPENDENCY_USER_MODS
regid
clearid
@ -193,6 +204,7 @@ id.subfunc = 1
id.callname = "func__controlchr"
id.args = 0
id.ret = LONGTYPE - ISPOINTER
id.Dependency = DEPENDENCY_USER_MODS
regid
clearid
@ -202,6 +214,7 @@ id.callname = "func__str_nc_compare"
id.args = 2
id.arg = MKL$(STRINGTYPE - ISPOINTER) + MKL$(STRINGTYPE - ISPOINTER)
id.ret = LONGTYPE - ISPOINTER
id.Dependency = DEPENDENCY_USER_MODS
regid
clearid
@ -211,5 +224,6 @@ id.callname = "func__str_compare"
id.args = 2
id.arg = MKL$(STRINGTYPE - ISPOINTER) + MKL$(STRINGTYPE - ISPOINTER)
id.ret = LONGTYPE - ISPOINTER
id.Dependency = DEPENDENCY_USER_MODS
regid