Skip to content

Commit 11dc166

Browse files
committed
Merge remote-tracking branch 'jayrm/emscripten' into fbc-1.10
Conflicts: changelog.txt Resolution: keep all changelog entries
2 parents 73b229e + 7ad773d commit 11dc166

31 files changed

+253
-73
lines changed

changelog.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,23 @@ Version 1.10.1
44
- rtlib: printf format specifier, use 'll' instead of 'I64' if building for ucrt or mingw-w64's stdio implementation (for newer gcc versions and c std)
55
- gcc backend: use 'char' types for zstring instead of 'uint8' to avoid warnings in newer gcc 11+
66
- release: update to build libffi 3.4.4 - this is needed to work with newer mingw-w64 based toolchains for gcc 11.x and up
7+
- emscripten/fbc: in debug version of fbc (__FB_DEBUG__<>0) allow wchar conversion on win32 host to allow building and testing of the test-suite
78

89
[added]
910
- release: add recipes for building fbc distros using gcc-11.2 and gcc-12.2 Mingw-w64 project toolchains
1011
- release: add recipe for building fbc distros using winlibs-gcc-11.2/3/4 toolchain
12+
- fbc: '-fbgfx' command line option to link against correct libfbgfx variant, for platforms (emscripten) where it's not automatic due to missing objinfo support
1113

1214
[fixed]
1315
- sf.net #982: Array descriptors emitted incorrectly in gcc backend
1416
- gas64: emit debug information for statics
1517
- gas64: handle #inf's and NaN's in float comparisons
1618
- unable to set opengl scaling to 1 after initial screen mode - previously: logic error in the driver code prevented the scaling from being set to 1
19+
- emscripten: fbc created faulty static libraries (it called ar instead of emar)
20+
- fbc: emscripten: wstring was broken because sizeof(wstring) was 2 rather than 4
21+
- emscripten: non-graphical programs will now run under node.js. Use -x output.js to produce a .js rather than an .html
22+
- rtlib: emscripten: CURDIR and EXEPATH always returned ""
23+
- emscripten/fbc: -sASYNCIFY wasn't passed to emcc at link-time as needed by recent Emscripten
1724

1825

1926
Version 1.10.0

inc/SDL/SDL.bi

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,7 @@ type SDL_Palette
847847
end type
848848

849849
type SDL_PixelFormat
850+
#ifndef __FB_JS__
850851
palette as SDL_Palette ptr
851852
BitsPerPixel as Uint8
852853
BytesPerPixel as Uint8
@@ -864,6 +865,27 @@ type SDL_PixelFormat
864865
Amask as Uint32
865866
colorkey as Uint32
866867
alpha as Uint8
868+
#else
869+
format as Uint32
870+
palette as SDL_Palette ptr
871+
BitsPerPixel as Uint8
872+
BytesPerPixel as Uint8
873+
padding(1) as Uint8
874+
Rmask as Uint32
875+
Gmask as Uint32
876+
Bmask as Uint32
877+
Amask as Uint32
878+
Rloss as Uint8
879+
Gloss as Uint8
880+
Bloss as Uint8
881+
Aloss as Uint8
882+
Rshift as Uint8
883+
Gshift as Uint8
884+
Bshift as Uint8
885+
Ashift as Uint8
886+
refcount as long
887+
next as SDL_PixelFormat ptr
888+
#endif
867889
end type
868890

869891
type private_hwdata as private_hwdata_
@@ -874,6 +896,7 @@ type SDL_Surface
874896
format as SDL_PixelFormat ptr
875897
w as long
876898
h as long
899+
#ifndef __FB_JS__
877900
pitch as Uint16
878901
pixels as any ptr
879902
offset as long
@@ -883,9 +906,19 @@ type SDL_Surface
883906
locked as Uint32
884907
map as SDL_BlitMap ptr
885908
format_version as ulong
909+
#else
910+
pitch as long
911+
pixels as any ptr
912+
userdata as any ptr
913+
locked as long
914+
lock_data as any ptr
915+
clip_rect as SDL_Rect
916+
map as SDL_BlitMap ptr
917+
#endif
886918
refcount as long
887919
end type
888920

921+
#ifndef __FB_JS__
889922
const SDL_SWSURFACE = &h00000000
890923
const SDL_HWSURFACE = &h00000001
891924
const SDL_ASYNCBLIT = &h00000004
@@ -903,6 +936,23 @@ const SDL_RLEACCELOK = &h00002000
903936
const SDL_RLEACCEL = &h00004000
904937
const SDL_SRCALPHA = &h00010000
905938
const SDL_PREALLOC = &h01000000
939+
#else
940+
const SDL_SWSURFACE = &h00000000
941+
const SDL_SRCALPHA = &h00010000
942+
const SDL_SRCCOLORKEY = &h00020000
943+
const SDL_ANYFORMAT = &h00100000
944+
const SDL_HWPALETTE = &h00200000
945+
const SDL_DOUBLEBUF = &h00400000
946+
const SDL_FULLSCREEN = &h00800000
947+
const SDL_RESIZABLE = &h01000000
948+
const SDL_NOFRAME = &h02000000
949+
const SDL_OPENGL = &h04000000
950+
const SDL_HWSURFACE = &h08000001
951+
const SDL_ASYNCBLIT = &h08000000
952+
const SDL_RLEACCELOK = &h08000000
953+
const SDL_HWACCEL = &h08000000
954+
#endif
955+
906956
#define SDL_MUSTLOCK(surface) (surface->offset orelse ((surface->flags and ((SDL_HWSURFACE or SDL_ASYNCBLIT) or SDL_RLEACCEL)) <> 0))
907957
type SDL_blit as function(byval src as SDL_Surface ptr, byval srcrect as SDL_Rect ptr, byval dst as SDL_Surface ptr, byval dstrect as SDL_Rect ptr) as long
908958

@@ -1174,6 +1224,9 @@ enum
11741224
SDL_EVENT_COMPAT1 = &h7000
11751225
SDL_EVENT_COMPAT2
11761226
SDL_EVENT_COMPAT3
1227+
SDL_ACTIVEEVENT = SDL_EVENT_COMPAT1
1228+
SDL_VIDEORESIZE = SDL_EVENT_COMPAT2
1229+
SDL_VIDEOEXPOSE = SDL_EVENT_COMPAT3
11771230
SDL_USEREVENT = &h8000
11781231
SDL_LASTEVENT = &hFFFF
11791232
#endif
@@ -1240,17 +1293,19 @@ type SDL_MouseMotionEvent
12401293
state as Uint8
12411294
x as Uint16
12421295
y as Uint16
1296+
xrel as Sint16
1297+
yrel as Sint16
12431298
#else
12441299
as Uint32 type
12451300
timestamp as Uint32
12461301
windowID as Uint32
12471302
which as Uint32
12481303
state as Uint32
1249-
x as Sint16
1250-
y as Sint16
1304+
x as Sint32
1305+
y as Sint32
1306+
xrel as Sint32
1307+
yrel as Sint32
12511308
#endif
1252-
xrel as Sint16
1253-
yrel as Sint16
12541309
end type
12551310

12561311
type SDL_MouseButtonEvent
@@ -1270,8 +1325,8 @@ type SDL_MouseButtonEvent
12701325
state as Uint8
12711326
padding1 as Uint8
12721327
padding2 as Uint8
1273-
x as Sint16
1274-
y as Sint16
1328+
x as Sint32
1329+
y as Sint32
12751330
#endif
12761331
end type
12771332

@@ -1432,7 +1487,11 @@ const SDL_QUERY = -1
14321487
const SDL_IGNORE = 0
14331488
const SDL_DISABLE = 0
14341489
const SDL_ENABLE = 1
1490+
#ifndef __FB_JS__
14351491
declare function SDL_EventState(byval type as Uint8, byval state as long) as Uint8
1492+
#else
1493+
'SDL_EventState doesn't exist
1494+
#endif
14361495
#define _SDL_loadso_h
14371496

14381497
declare function SDL_LoadObject(byval sofile as const zstring ptr) as any ptr

lib/fb_rtlib.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@ var __fb_rtlib =
5353
{
5454
if( this.term === null )
5555
{
56-
console.log(text);
56+
// Under node.js write to stdout. console.log adds an extra newline
57+
if( typeof process !== 'undefined' )
58+
process.stdout.write(text);
59+
else
60+
console.log(text);
5761
return;
5862
}
59-
6063
this.term.write('%c(' + this.fg_color + ',' + this.bg_color + ')' + text.replace('%(', '%%('));
6164
},
6265

lib/termlib_min.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ _makeTerm: function(rebuild) {
14341434
tr=document.createElement('tr');
14351435
td=document.createElement('td');
14361436
td.id=divPrefix+r;
1437-
td.style.height=td.style.minHeight=td.style.maxHeight=this.conf.rowHeight;
1437+
td.style.height=td.style.minHeight=td.style.maxHeight=this.conf.rowHeight+'px';
14381438
td.style.whiteSpace='nowrap';
14391439
td.className=this.conf.fontClass;
14401440
td.innerHTML=rstr;
@@ -2760,4 +2760,4 @@ var TermGlobals = Terminal.prototype.globals;
27602760
var termKey = Terminal.prototype.globals.termKey;
27612761
var termDomKeyRef = Terminal.prototype.globals.termDomKeyRef;
27622762

2763-
// eof
2763+
// eof

src/compiler/ast-node-bop.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ function astNewBOP _
869869
if( litsym <> NULL ) then
870870
'' ok to convert at compile-time?
871871
if( (typeGetDtAndPtrOnly( ldtype ) = typeGetDtAndPtrOnly( rdtype )) or _
872-
env.wchar_doconv ) then
872+
(env.wcharconv <> FB_WCHARCONV_NEVER) ) then
873873
return hWstrLiteralConcat( l, r )
874874
end if
875875
end if

src/compiler/fb.bas

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ dim shared as FBTARGET targetinfo(0 to FB_COMPTARGETS-1) = _
217217
), _
218218
( _
219219
@"js", _
220-
FB_DATATYPE_USHORT, _ '' wchar
220+
FB_DATATYPE_ULONG, _ '' wchar
221221
FB_FUNCMODE_CDECL, _
222222
FB_FUNCMODE_STDCALL_MS, _
223223
0 or FB_TARGETOPT_UNIX _
@@ -474,7 +474,22 @@ sub fbInit _
474474
irInit( )
475475

476476
'' After symbInit(), we can use typeGetSize()
477-
env.wchar_doconv = (sizeof( wstring ) = typeGetSize( env.target.wchar ))
477+
if( sizeof( wstring ) = typeGetSize( env.target.wchar ) ) then
478+
env.wcharconv = FB_WCHARCONV_ALWAYS
479+
else
480+
env.wcharconv = FB_WCHARCONV_NEVER
481+
end if
482+
483+
#if ( __FB_DEBUG__ <> 0 ) andalso defined( __FB_WIN32__ )
484+
select case( env.clopt.target )
485+
case FB_COMPTARGET_JS
486+
'' !!!TODO!!! - FB_WCHARCONV_WARNING needs to show warnings on conversions
487+
'' !!!TODO!!! - FB_WCHARCONV_WARNING probably not correct to force a value
488+
'' but setting it helps with development and testing
489+
'' where sizeof(host-wstring) <> sizeof(target-wstring)
490+
env.wcharconv = FB_WCHARCONV_WARNING
491+
end select
492+
#endif
478493

479494
hashInit( @env.filenamehash, FB_INITINCFILES )
480495
hashInit( @env.incfilehash, FB_INITINCFILES, FALSE )
@@ -564,7 +579,7 @@ sub fbGlobalInit()
564579
env.clopt.gosubsetjmp = FALSE
565580
env.clopt.export = FALSE
566581
env.clopt.multithreaded = FALSE
567-
env.clopt.gfx = FALSE
582+
env.clopt.fbgfx = FALSE
568583
env.clopt.pic = FALSE
569584
env.clopt.msbitfields = FALSE
570585
env.clopt.stacksize = 0 '' default will be set by fbSetOption() called from hParseArgs()
@@ -679,8 +694,8 @@ sub fbSetOption( byval opt as integer, byval value as integer )
679694
env.clopt.msbitfields = value
680695
case FB_COMPOPT_MULTITHREADED
681696
env.clopt.multithreaded = value
682-
case FB_COMPOPT_GFX
683-
env.clopt.gfx = value
697+
case FB_COMPOPT_FBGFX
698+
env.clopt.fbgfx = value
684699
case FB_COMPOPT_PIC
685700
env.clopt.pic = value
686701
case FB_COMPOPT_STACKSIZE
@@ -790,8 +805,8 @@ function fbGetOption( byval opt as integer ) as integer
790805
function = env.clopt.msbitfields
791806
case FB_COMPOPT_MULTITHREADED
792807
function = env.clopt.multithreaded
793-
case FB_COMPOPT_GFX
794-
function = env.clopt.gfx
808+
case FB_COMPOPT_FBGFX
809+
function = env.clopt.fbgfx
795810
case FB_COMPOPT_PIC
796811
function = env.clopt.pic
797812
case FB_COMPOPT_STACKSIZE
@@ -1100,13 +1115,13 @@ sub fbAddLib(byval libname as zstring ptr)
11001115
'' multithreading may have been set after fbgfx.bi was
11011116
'' included, and we can't have both libs passed to the
11021117
'' linker. We can end up linking to the non-threaded
1103-
'' version of fbgfx when we would expect the mt versoin
1118+
'' version of fbgfx when we would expect the mt version,
11041119
'' and the linker won't complain even when both versions
11051120
'' are passed.
11061121

1107-
'' Set the -gfx option to link to the gfx library
1122+
'' Set the -fbgfx option to link to the gfx library
11081123
'' and the lib will be added in hAddDefaultLibs()
1109-
fbSetOption( FB_COMPOPT_GFX, TRUE )
1124+
fbSetOption( FB_COMPOPT_FBGFX, TRUE )
11101125

11111126
exit sub
11121127
end if
@@ -1195,8 +1210,8 @@ private sub hEmitObjinfo( )
11951210
hAppendFbctinf( objinfoEncode( OBJINFO_MT ) )
11961211
end if
11971212

1198-
'' -gfx
1199-
if( env.clopt.gfx ) then
1213+
'' -fbgfx
1214+
if( env.clopt.fbgfx ) then
12001215
hAppendFbctinf( objinfoEncode( OBJINFO_GFX ) )
12011216
end if
12021217

src/compiler/fb.bi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ enum FB_COMPOPT
104104
FB_COMPOPT_EXPORT '' boolean: export all symbols declared as EXPORT?
105105
FB_COMPOPT_MSBITFIELDS '' boolean: use M$'s bitfields packing?
106106
FB_COMPOPT_MULTITHREADED '' boolean: -mt
107-
FB_COMPOPT_GFX '' boolean: -gfx (whether gfxlib should be linked)
107+
FB_COMPOPT_FBGFX '' boolean: -fbgfx (whether libfbgfx should be linked)
108108
FB_COMPOPT_PIC '' boolean: -pic (whether to use position-independent code)
109109
FB_COMPOPT_STACKSIZE '' integer
110110
FB_COMPOPT_OBJINFO '' boolean: write/read .fbctinf sections etc.?
@@ -313,7 +313,7 @@ type FBCMMLINEOPT
313313
export as integer '' export all symbols declared as EXPORT (default = true)
314314
msbitfields as integer '' use M$'s bitfields packing
315315
multithreaded as integer '' link against thread-safe runtime library (default = false)
316-
gfx as integer '' Link against gfx library (default = false)
316+
fbgfx as integer '' Link against gfx library (default = false)
317317
pic as integer '' Whether to use position-independent code (default = false)
318318
stacksize as integer
319319
objinfo as integer

0 commit comments

Comments
 (0)