Skip to content

Commit

Permalink
v1.38a 2023/11/12: New release
Browse files Browse the repository at this point in the history
  • Loading branch information
rtrussell committed Nov 12, 2023
1 parent d9e2455 commit b501c78
Show file tree
Hide file tree
Showing 29 changed files with 82 additions and 26 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# BBCSDL
BBC BASIC for SDL 2.0 is a cross-platform implementation of the BBC BASIC programming language for
BBC BASIC for SDL 2.0 (BBCSDL) is a cross-platform implementation of the BBC BASIC programming language for
Windows, Linux (x86), MacOS, Raspbian (Raspberry Pi OS), Android, iOS and Emscripten / WebAssembly.
It is highly compatible with BBC BASIC for Windows and has the same language extensions, but uses
SDL 2.0 as an OS abstraction layer to achieve cross-platform compatibility.

The BBC BASIC Console Mode editions are lightweight implementations for Windows, Linux (x86),
The BBC BASIC Console Mode editions (BBCTTY) are lightweight implementations for Windows, Linux (x86),
MacOS and Raspbian (Raspberry Pi OS) which do not support graphics or sound but are otherwise
compatible with the desktop, mobile and web editions. They take their input from stdin and
send their output to stdout, so may be used for scripting, CGI and remote terminal applications.
Expand Down
Binary file modified bin/android/autorun.bbc
Binary file not shown.
Binary file modified bin/wasm/autorun.bbc
Binary file not shown.
2 changes: 1 addition & 1 deletion bin/wasm/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ VPATH = ../BBCSDL/src ../BBCSDL/include
CXX = emcc -s USE_PTHREADS=1 -s USE_SDL=2 -s USE_SDL_TTF=2 -s USE_SDL_NET=2 \
-I . -I ../BBCSDL/include -Wall -Wno-pthreads-mem-growth

LXX = emcc -s USE_PTHREADS=1 -s USE_SDL=2 -s USE_SDL_TTF=2 -s USE_SDL_NET=2 \
LXX = emcc -s USE_PTHREADS=1 -s USE_SDL=2 -s USE_SDL_TTF=2 -s USE_SDL_NET=2 -s MAXIMUM_MEMORY=1gb \
-s PTHREAD_POOL_SIZE=2 -s ALLOW_MEMORY_GROWTH=1 -s WASM=1 -s ASSERTIONS=0 -s STACK_SIZE=5MB \
-I . -I ../BBCSDL/include -Wall -Wno-pthreads-mem-growth

Expand Down
Binary file modified examples/games/jigsaw.bbc
Binary file not shown.
Binary file modified examples/general/textedit.bbc
Binary file not shown.
Binary file added examples/general/timerdem.bbc
Binary file not shown.
Binary file modified examples/general/video.bbc
Binary file not shown.
Binary file modified examples/tools/SDLIDE.bbc
Binary file not shown.
Binary file modified examples/tools/addconst.bbc
Binary file not shown.
Binary file modified examples/tools/compiler.bbc
Binary file not shown.
Binary file modified examples/tools/crossref.bbc
Binary file not shown.
Binary file modified examples/tools/macrorec.bbc
Binary file not shown.
Binary file modified examples/tools/memmon.bbc
Binary file not shown.
Binary file modified examples/tools/searchin.bbc
Binary file not shown.
Binary file added examples/tools/settab.bbc
Binary file not shown.
Binary file modified examples/tools/touchide.bbc
Binary file not shown.
4 changes: 2 additions & 2 deletions include/version.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define YEAR "2023" // Copyright year
#define VERSION "1.37a" // Version string
#define VER_RES 1,37,1,00 // For VERSIONINFO resource
#define VERSION "1.38a" // Version string
#define VER_RES 1,38,1,00 // For VERSIONINFO resource
#define DEFAULT_RAM PAGE_OFFSET+0x200000 // Initial amount of RAM to allocate
#ifdef __EMSCRIPTEN__
#define MAXIMUM_RAM 0x1000000 // Maximum amount of RAM to allocate
Expand Down
Binary file modified lib/dlglib.bbc
Binary file not shown.
Binary file modified lib/editbox.bbc
Binary file not shown.
Binary file modified lib/menulib.bbc
Binary file not shown.
Binary file modified lib/msgbox.bbc
Binary file not shown.
34 changes: 32 additions & 2 deletions src/bbasmb_wasm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Broadcasting Corporation and used with their permission *
* *
* bbasmb.c: API Wrappers to satisfy function signatures *
* Version 1.36a, 30-Jul-2023 *
* Version 1.38a, 09-Sep-2023 *
\*****************************************************************/

#include <stdlib.h>
Expand Down Expand Up @@ -462,6 +462,14 @@ long long BBC_RemoveTimer(st id, st i1, st i2, st i3, st i4, st i5, st i6, st i7

// Miscellaneous:

long long BBC_Delay(st ms, st i1, st i2, st i3, st i4, st i5, st i6, st i7,
st i8, st i9, st i10, st i11, db f0, db f1, db f2, db f3, db f4, db f5, db f6, db f7)
{ SDL_Delay(ms); return 0; }

long long BBC_GetError(st i0, st i1, st i2, st i3, st i4, st i5, st i6, st i7,
st i8, st i9, st i10, st i11, db f0, db f1, db f2, db f3, db f4, db f5, db f6, db f7)
{ return (intptr_t) SDL_GetError(); }

long long BBC_HasIntersection(st recta, st rectb, st i2, st i3, st i4, st i5, st i6, st i7,
st i8, st i9, st i10, st i11, db f0, db f1, db f2, db f3, db f4, db f5, db f6, db f7)
{ return SDL_HasIntersection((const SDL_Rect*) recta, (const SDL_Rect*) rectb); }
Expand All @@ -478,10 +486,18 @@ long long BBC_GetWindowFlags(st window, st i1, st i2, st i3, st i4, st i5, st i6
st i8, st i9, st i10, st i11, db f0, db f1, db f2, db f3, db f4, db f5, db f6, db f7)
{ return SDL_GetWindowFlags((SDL_Window*) window); }

long long BBC_SetWindowPosition(st window, st x, st y, st i3, st i4, st i5, st i6, st i7,
st i8, st i9, st i10, st i11, db f0, db f1, db f2, db f3, db f4, db f5, db f6, db f7)
{ SDL_SetWindowPosition((SDL_Window*) window, x, y); return 0; }

long long BBC_SetWindowResizable(st window, st resizable, st i2, st i3, st i4, st i5, st i6, st i7,
st i8, st i9, st i10, st i11, db f0, db f1, db f2, db f3, db f4, db f5, db f6, db f7)
{ SDL_SetWindowResizable((SDL_Window*) window, resizable); return 0; }

long long BBC_SetWindowSize(st window, st w, st h, st i3, st i4, st i5, st i6, st i7,
st i8, st i9, st i10, st i11, db f0, db f1, db f2, db f3, db f4, db f5, db f6, db f7)
{ SDL_SetWindowSize((SDL_Window*) window, w, h); return 0; }

long long BBC_SetWindowTitle(st window, st title, st i2, st i3, st i4, st i5, st i6, st i7,
st i8, st i9, st i10, st i11, db f0, db f1, db f2, db f3, db f4, db f5, db f6, db f7)
{ SDL_SetWindowTitle((SDL_Window*) window, (const char*) title); return 0; }
Expand Down Expand Up @@ -614,7 +630,11 @@ long long BBC_emscripten_async_wget(st url, st file, st i2, st i3, st i4, st i5,
return 0 ;
}

#define NSYS 128
long long BBC_emscripten_run_script_string(st script, st i1, st i2, st i3, st i4, st i5, st i6, st i7,
st i8, st i9, st i10, st i11, db f0, db f1, db f2, db f3, db f4, db f5, db f6, db f7)
{ return (intptr_t) emscripten_run_script_string((const char*) script); }

#define NSYS 133

static const char *sysname[NSYS] = {
"B2D_GetProcAddress",
Expand Down Expand Up @@ -654,6 +674,7 @@ static const char *sysname[NSYS] = {
"SDL_CreateRGBSurfaceWithFormat",
"SDL_CreateTexture",
"SDL_CreateTextureFromSurface",
"SDL_Delay",
"SDL_DestroyTexture",
"SDL_FillRect",
"SDL_FreeSurface",
Expand All @@ -669,6 +690,7 @@ static const char *sysname[NSYS] = {
"SDL_GL_SetSwapInterval",
"SDL_GL_SwapWindow",
"SDL_GetDisplayUsableBounds",
"SDL_GetError",
"SDL_GetPerformanceCounter",
"SDL_GetPerformanceFrequency",
"SDL_GetQueuedAudioSize",
Expand Down Expand Up @@ -719,7 +741,9 @@ static const char *sysname[NSYS] = {
"SDL_SetTextureAlphaMod",
"SDL_SetTextureBlendMode",
"SDL_SetTextureColorMod",
"SDL_SetWindowPosition",
"SDL_SetWindowResizable",
"SDL_SetWindowSize",
"SDL_SetWindowTitle",
"SDL_ShowSimpleMessageBox",
"SDL_UnlockAudioDevice",
Expand All @@ -738,6 +762,7 @@ static const char *sysname[NSYS] = {
"drmp3_open_file_and_read_f32",
"drmp3dec_f32_to_s16",
"emscripten_async_wget",
"emscripten_run_script_string",
"gmtime",
"localtime",
"mktime",
Expand Down Expand Up @@ -784,6 +809,7 @@ static void *sysfunc[NSYS] = {
BBC_CreateRGBSurfaceWithFormat,
BBC_CreateTexture,
BBC_CreateTextureFromSurface,
BBC_Delay,
BBC_DestroyTexture,
BBC_FillRect,
BBC_FreeSurface,
Expand All @@ -799,6 +825,7 @@ static void *sysfunc[NSYS] = {
BBC_GL_SetSwapInterval,
BBC_GL_SwapWindow,
BBC_GetDisplayUsableBounds,
BBC_GetError,
BBC_GetPerformanceCounter,
BBC_GetPerformanceFrequency,
BBC_GetQueuedAudioSize,
Expand Down Expand Up @@ -849,7 +876,9 @@ static void *sysfunc[NSYS] = {
BBC_SetTextureAlphaMod,
BBC_SetTextureBlendMode,
BBC_SetTextureColorMod,
BBC_SetWindowPosition,
BBC_SetWindowResizable,
BBC_SetWindowSize,
BBC_SetWindowTitle,
BBC_ShowSimpleMessageBox,
BBC_UnlockAudioDevice,
Expand All @@ -868,6 +897,7 @@ static void *sysfunc[NSYS] = {
BBC_drmp3_open_file_and_read_f32,
BBC_drmp3dec_f32_to_s16,
BBC_emscripten_async_wget,
BBC_emscripten_run_script_string,
BBC_gmtime,
BBC_localtime,
BBC_mktime,
Expand Down
11 changes: 7 additions & 4 deletions src/bbccli.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* *
* bbccli.c: Command Line Interface (OS emulation) *
* This module runs in the context of the interpreter thread *
* Version 1.37a, 09-Aug-2023 *
* Version 1.38a, 04-Sep-2023 *
\*****************************************************************/

#include <stdlib.h>
Expand Down Expand Up @@ -74,6 +74,7 @@ static int BBC_RWclose (struct SDL_RWops* context)
char *setup (char *dst, char *src, char *ext, char term, unsigned char *pflag)
{
unsigned char flag = 0 ;
char *limit = dst + 0x100 ;

while (*src == ' ') src++ ; // Skip leading spaces
if ((*src == '"') && (term != '"'))
Expand Down Expand Up @@ -102,6 +103,7 @@ char *setup (char *dst, char *src, char *ext, char term, unsigned char *pflag)
flag |= BIT1 ; // Flag path present
}
*dst++ = ch ;
if (dst >= limit) error (204, "Bad name") ;
}

if (flag & BIT7)
Expand All @@ -111,8 +113,10 @@ char *setup (char *dst, char *src, char *ext, char term, unsigned char *pflag)
}
else if (flag & BIT0)
{
int n = strlen(ext) ;
if (dst + n >= limit) error (204, "Bad name") ;
strcpy (dst, ext) ;
dst += strlen (ext) ;
dst += n ;
}

if (pflag != NULL)
Expand Down Expand Up @@ -238,8 +242,7 @@ void oscli (char *cmd)
return ;

q = memchr (cmd, 0x0D, sizeof(cpy)) ;
if (q == NULL)
error (204, "Bad name") ;
if (q == NULL) return ;
memcpy (cpy, cmd, q - cmd) ;
cpy[q - cmd] = 0 ;
p = cpy ;
Expand Down
26 changes: 15 additions & 11 deletions src/bbcmos.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* *
* bbcmos.c Machine Operating System emulation *
* This module runs in the context of the interpreter thread *
* Version 1.34d, 23-Mar-2023 *
* Version 1.38a, 04-Sep-2023 *
\*****************************************************************/

#define _GNU_SOURCE
Expand Down Expand Up @@ -889,6 +889,11 @@ void reset (void)
{
vduq[10] = 0 ; // Flush VDU queue
keyptr = NULL ; // Cancel *KEY expansion
if (*(keystr + 0))
{
SDL_free (*(keystr + 0)) ; // Clipboard
*(keystr + 0) = NULL ;
}
optval = 0 ; // Cancel I/O redirection
reflag = 0 ; // *REFRESH ON
}
Expand Down Expand Up @@ -1095,7 +1100,14 @@ static int rdkey (unsigned char *pkey)
{
*pkey = *keyptr++ ;
if (*keyptr == 0)
{
keyptr = NULL ;
if (*(keystr + 0))
{
SDL_free (*(keystr + 0)) ; // Clipboard
*(keystr + 0) = NULL ;
}
}
return 1 ;
}

Expand Down Expand Up @@ -1443,16 +1455,8 @@ void osline (char *buffer)
case 22:
if (SDL_HasClipboardText ())
{
char *t = SDL_GetClipboardText () ;
char *s = t ;
while ((*s >= ' ') && (p < (buffer + 255)))
{
oswrch (*s) ;
memmove (p + 1, p, buffer + 255 - p) ;
*p++ = *s++ ;
}
*(buffer + 255) = 0x0D ;
SDL_free (t) ;
*(keystr + 0) = SDL_GetClipboardText () ;
keyptr = (unsigned char *) *(keystr + 0) ;
}
break ;

Expand Down
17 changes: 15 additions & 2 deletions src/bbcsdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Broadcasting Corporation and used with their permission *
* *
* bbcsdl.c Main program: Initialisation, Polling Loop *
* Version 1.37a, 17-Aug-2023 *
* Version 1.38a, 15-Oct-2023 *
\*****************************************************************/

#include <stdlib.h>
Expand Down Expand Up @@ -678,7 +678,7 @@ if (!SDL_RenderTargetSupported(renderer))
return 8;
}

SDL_GL_GetDrawableSize (window, &sizex, &sizey) ; // Window may not be the requested size
SDL_GetRendererOutputSize (renderer, &sizex, &sizey) ; // Window may not be the requested size

#if defined __ANDROID__ || defined __IPHONEOS__
{
Expand Down Expand Up @@ -936,6 +936,7 @@ Mutex = SDL_CreateMutex () ;
#endif

SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
SDL_EventState(SDL_DROPTEXT, SDL_ENABLE);
SDL_PumpEvents () ;
if (SDL_PeepEvents (&ev, 1, SDL_GETEVENT, SDL_DROPFILE, SDL_DROPFILE))
{
Expand Down Expand Up @@ -1609,6 +1610,18 @@ static int maintick (void)
oldy = ev.mgesture.y ;
break ;

case SDL_DROPFILE:
case SDL_DROPTEXT:
if (systrp && (sysflg & 8))
{
int wparam = ((intptr_t) ev.drop.file) & 0x0FFFFFFFFUL ;
int lparam = ((intptr_t) ev.drop.file) / 0x100000000UL ;
putevt (systrp, ev.type, wparam, lparam) ;
flags |= ALERT ;
break ;
}
break ;

case SDL_WINDOWEVENT:
if (clotrp && (ev.window.event == SDL_WINDOWEVENT_CLOSE))
{
Expand Down
7 changes: 6 additions & 1 deletion src/bbexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Broadcasting Corporation and used with their permission *
* *
* bbexec.c: Variable assignment and statement execution *
* Version 1.35a, 04-Apr-2023 *
* Version 1.38a, 10-Oct-2023 *
\*****************************************************************/

#include <string.h>
Expand Down Expand Up @@ -219,6 +219,7 @@ void storen (VAR v, void *ptr, unsigned char type)
v.d.d = v.f ;
if ((v.s.l == 0x7FF00000) || (v.s.l == 0xFFF00000))
error (20, NULL) ; // 'Number too big'
if (v.s.l == 0) v.d.d = 0.0 ;
USTORE(ptr, v.s.p) ;
USTORE((char *)ptr + 4, v.s.l) ;
}
Expand Down Expand Up @@ -1085,6 +1086,7 @@ static void defscan (signed char *edx)
return ;
oldesi = esi ;
esi = edx + 1 ; // Byte after DEF
curlin = esi - (signed char *) zero ;
nxt () ;
if ((*esi == TPROC) || (*esi == TFN))
{
Expand All @@ -1094,6 +1096,7 @@ static void defscan (signed char *edx)
VSTORE(ptr, esi) ;
}
esi = oldesi ;
curlin = esi - (signed char *) zero ;
edx -= 3 ; // point to line-length byte
edx += (int) *(unsigned char *)edx ;
}
Expand Down Expand Up @@ -1483,6 +1486,7 @@ VAR xeq (void)
{
unsigned char type ;
void *ptr ;
volatile int seq ;
int count = 0 ;
signed char *oldesi = esi ;
char *edi = accs ;
Expand Down Expand Up @@ -1527,6 +1531,7 @@ VAR xeq (void)
*--esp = count ;
*--esp = RETCHK ;
esi = oldesi - 1 ;
for (seq=0; seq<1; seq++) ; // GCC bug?
// transfer secret [accs] to formal [esi]
esi = argue ((signed char *)accs - 1, esp + 2, 1) ;
}
Expand Down
3 changes: 2 additions & 1 deletion src/bbmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Broadcasting Corporation and used with their permission *
* *
* bbmain.c: Immediate mode, error handling, variable lookup *
* Version 1.35a, 15-Mar-2023 *
* Version 1.38a, 04-Sep-2023 *
\*****************************************************************/

#include <stdio.h>
Expand Down Expand Up @@ -1583,6 +1583,7 @@ int basic (void *ecx, void *edx, void *prompt)
signed char *tmp = vpage + (signed char *) zero ;
clear () ;
n = strlen (buff) + 3 ;
if (n > 255) error (19, NULL) ; // 'String too long'
while (lino > SLOAD(tmp + 1))
tmp += (int)*(unsigned char *)tmp ;
if (lino == SLOAD(tmp + 1))
Expand Down
Binary file modified tests/errortst.bbc
Binary file not shown.

0 comments on commit b501c78

Please sign in to comment.