Skip to content

Commit 59a5c7b

Browse files
committed
gfxlib2: Allow long data types with SCREENINFO, IMAGEINFO, SCREENCONTROL
- Add new gfxlib2 API's fb_GfxScreenInfo32() and fb_GfxScreenInfo64() - Change overload to SCREENINFO( byref as long = 0, byref as long = 0, byref as long = 0, byref as long = 0, byref as long = 0, byref as long = 0, byref as string = "" ) - Add overload for SCREENINFO( byref as longint, byref as longint, byref as longint = 0, byref as longint = 0, byref as longint = 0, byref as longint = 0, byref as string = "" ) - Add new gflib2 API's fb_GfxImageInfo32() and fb_GfxImageInfo64() - Change overload to IMAGEINFO( byval as const any ptr, byref as long = 0, byref as long = 0, byref as long = 0, byref as long = 0, byref as any ptr = 0, byref as longint = 0 ) as long - Add overload for IMAGEINFO( byval as const any ptr, byref as longint, byref as longint, byref as longint = 0, byref as longint = 0, byref as any ptr = 0, byref as longint = 0 ) as long - Add new gfxlib2 API's fb_GfxControl_i32() and fb_GfxControl_i64() - Change overload for SCREENCONTROL( byval as const long, byref as long = -2147483648, byref as long = -2147483648, byref as long = -2147483648, byref as long = -2147483648 ) - Add overload for SCREENCONTROL( byval as const long, byref as longint, byref as longint = -2147483648, byref as longint = -2147483648, byref as longint = -2147483648 )
1 parent b9a1800 commit 59a5c7b

File tree

14 files changed

+386
-70
lines changed

14 files changed

+386
-70
lines changed

changelog.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ Version 1.08.0
4747
- optimize byref 'm += s' string concatenations to fb_StrConcatByref() which will check for same string descriptor at run-time which can't be determined at compile time for byref parameters.
4848
- github #298: allow command line options passed to as, gcc, ld to be longer than 128 characters by using string types internally
4949
- sf.net #923: implicitly emit the deleting destructor for extern "c++" mangling for better g++ ABI compatibility
50+
- Add new gfxlib2 API's fb_GfxScreenInfo32() and fb_GfxScreenInfo64()
51+
- Change overload to SCREENINFO( byref as long = 0, byref as long = 0, byref as long = 0, byref as long = 0, byref as long = 0, byref as long = 0, byref as string = "" )
52+
- Add overload for SCREENINFO( byref as longint, byref as longint, byref as longint = 0, byref as longint = 0, byref as longint = 0, byref as longint = 0, byref as string = "" )
53+
- Add new gflib2 API's fb_GfxImageInfo32() and fb_GfxImageInfo64()
54+
- Change overload to IMAGEINFO( byval as const any ptr, byref as long = 0, byref as long = 0, byref as long = 0, byref as long = 0, byref as any ptr = 0, byref as longint = 0 ) as long
55+
- Add overload for IMAGEINFO( byval as const any ptr, byref as longint, byref as longint, byref as longint = 0, byref as longint = 0, byref as any ptr = 0, byref as longint = 0 ) as long
56+
- Add new gfxlib2 API's fb_GfxControl_i32() and fb_GfxControl_i64()
57+
- Change overload for SCREENCONTROL( byval as const long, byref as long = -2147483648, byref as long = -2147483648, byref as long = -2147483648, byref as long = -2147483648 )
58+
- Add overload for SCREENCONTROL( byval as const long, byref as longint, byref as longint = -2147483648, byref as longint = -2147483648, byref as longint = -2147483648 )
5059

5160
[added]
5261
- extern "rtlib": respects the parent namespace, uses default fb calling convention and C style name mangling

src/compiler/rtl-gfx.bas

Lines changed: 108 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -830,28 +830,53 @@ declare function hPorts_cb _
830830
( typeSetIsConst( FB_DATATYPE_LONG ), FB_PARAMMODE_BYVAL, FALSE ) _
831831
} _
832832
), _
833-
/' sub screeninfo _
833+
/' sub screeninfo overload _
834834
( _
835-
byref width as integer = 0, _
836-
byref height as integer = 0, _
837-
byref depth as integer = 0, _
838-
byref bpp as integer = 0, _
839-
byref pitch as integer = 0, _
840-
byref refresh_rate as integer = 0, _
835+
byref width as long = 0, _
836+
byref height as long = 0, _
837+
byref depth as long = 0, _
838+
byref bpp as long = 0, _
839+
byref pitch as long = 0, _
840+
byref refresh_rate as long = 0, _
841841
byref driver as string = byval NULL _
842842
) '/ _
843843
( _
844-
@"screeninfo", @"fb_GfxScreenInfo", _
844+
@"screeninfo", @"fb_GfxScreenInfo32", _
845845
FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
846-
@hGfxlib_cb, FB_RTL_OPT_NOQB, _
846+
@hGfxlib_cb, FB_RTL_OPT_OVER or FB_RTL_OPT_NOQB, _
847847
7, _
848848
{ _
849-
( FB_DATATYPE_INTEGER, FB_PARAMMODE_BYREF, TRUE, 0 ), _
850-
( FB_DATATYPE_INTEGER, FB_PARAMMODE_BYREF, TRUE, 0 ), _
851-
( FB_DATATYPE_INTEGER, FB_PARAMMODE_BYREF, TRUE, 0 ), _
852-
( FB_DATATYPE_INTEGER, FB_PARAMMODE_BYREF, TRUE, 0 ), _
853-
( FB_DATATYPE_INTEGER, FB_PARAMMODE_BYREF, TRUE, 0 ), _
854-
( FB_DATATYPE_INTEGER, FB_PARAMMODE_BYREF, TRUE, 0 ), _
849+
( FB_DATATYPE_LONG, FB_PARAMMODE_BYREF, TRUE, 0 ), _
850+
( FB_DATATYPE_LONG, FB_PARAMMODE_BYREF, TRUE, 0 ), _
851+
( FB_DATATYPE_LONG, FB_PARAMMODE_BYREF, TRUE, 0 ), _
852+
( FB_DATATYPE_LONG, FB_PARAMMODE_BYREF, TRUE, 0 ), _
853+
( FB_DATATYPE_LONG, FB_PARAMMODE_BYREF, TRUE, 0 ), _
854+
( FB_DATATYPE_LONG, FB_PARAMMODE_BYREF, TRUE, 0 ), _
855+
( FB_DATATYPE_STRING, FB_PARAMMODE_BYREF, TRUE, NULL ) _
856+
} _
857+
), _
858+
/' sub screeninfo overload _
859+
( _
860+
byref width as longint, _
861+
byref height as longint, _
862+
byref depth as longint = 0, _
863+
byref bpp as longint = 0, _
864+
byref pitch as longint = 0, _
865+
byref refresh_rate as longint = 0, _
866+
byref driver as string = byval NULL _
867+
) '/ _
868+
( _
869+
@"screeninfo", @"fb_GfxScreenInfo64", _
870+
FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
871+
@hGfxlib_cb, FB_RTL_OPT_OVER or FB_RTL_OPT_NOQB, _
872+
7, _
873+
{ _
874+
( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYREF, FALSE ), _
875+
( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYREF, FALSE ), _
876+
( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYREF, TRUE, 0 ), _
877+
( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYREF, TRUE, 0 ), _
878+
( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYREF, TRUE, 0 ), _
879+
( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYREF, TRUE, 0 ), _
855880
( FB_DATATYPE_STRING, FB_PARAMMODE_BYREF, TRUE, NULL ) _
856881
} _
857882
), _
@@ -917,29 +942,54 @@ declare function hPorts_cb _
917942
( typeAddrOf( typeSetIsConst( FB_DATATYPE_VOID ) ), FB_PARAMMODE_BYVAL, FALSE ) _
918943
} _
919944
), _
920-
/' function imageinfo _
945+
/' function imageinfo overload _
921946
( _
922947
byval img as const any ptr, _
923-
byref width as integer = 0, _
924-
byref height as integer = 0, _
925-
byref bpp as integer = 0, _
926-
byref pitch as integer = 0, _
948+
byref width as long = 0, _
949+
byref height as long = 0, _
950+
byref bpp as long = 0, _
951+
byref pitch as long = 0, _
927952
byref imgdata as any ptr = 0, _
928-
byref size as integer = 0 _
953+
byref size as long = 0 _
929954
) as long '/ _
930955
( _
931-
@"imageinfo", @"fb_GfxImageInfo", _
956+
@"imageinfo", @"fb_GfxImageInfo32", _
932957
FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
933-
@hGfxlib_cb, FB_RTL_OPT_NOQB, _
958+
@hGfxlib_cb, FB_RTL_OPT_OVER or FB_RTL_OPT_NOQB, _
934959
7, _
935960
{ _
936961
( typeAddrOf( typeSetIsConst( FB_DATATYPE_VOID ) ), FB_PARAMMODE_BYVAL, FALSE ), _
937-
( FB_DATATYPE_INTEGER, FB_PARAMMODE_BYREF, TRUE, 0 ), _
938-
( FB_DATATYPE_INTEGER, FB_PARAMMODE_BYREF, TRUE, 0 ), _
939-
( FB_DATATYPE_INTEGER, FB_PARAMMODE_BYREF, TRUE, 0 ), _
940-
( FB_DATATYPE_INTEGER, FB_PARAMMODE_BYREF, TRUE, 0 ), _
962+
( FB_DATATYPE_LONG, FB_PARAMMODE_BYREF, TRUE, 0 ), _
963+
( FB_DATATYPE_LONG, FB_PARAMMODE_BYREF, TRUE, 0 ), _
964+
( FB_DATATYPE_LONG, FB_PARAMMODE_BYREF, TRUE, 0 ), _
965+
( FB_DATATYPE_LONG, FB_PARAMMODE_BYREF, TRUE, 0 ), _
941966
( typeAddrOf( FB_DATATYPE_VOID ), FB_PARAMMODE_BYREF, TRUE, 0 ), _
942-
( FB_DATATYPE_INTEGER, FB_PARAMMODE_BYREF, TRUE, 0 ) _
967+
( FB_DATATYPE_LONG, FB_PARAMMODE_BYREF, TRUE, 0 ) _
968+
} _
969+
), _
970+
/' function imageinfo overload _
971+
( _
972+
byval img as const any ptr, _
973+
byref width as longint, _
974+
byref height as longint, _
975+
byref bpp as longint = 0, _
976+
byref pitch as longint = 0, _
977+
byref imgdata as any ptr = 0, _
978+
byref size as longint = 0 _
979+
) as long '/ _
980+
( _
981+
@"imageinfo", @"fb_GfxImageInfo64", _
982+
FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
983+
@hGfxlib_cb, FB_RTL_OPT_OVER or FB_RTL_OPT_NOQB, _
984+
7, _
985+
{ _
986+
( typeAddrOf( typeSetIsConst( FB_DATATYPE_VOID ) ), FB_PARAMMODE_BYVAL, FALSE ), _
987+
( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYREF, FALSE ), _
988+
( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYREF, FALSE ), _
989+
( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYREF, TRUE, 0 ), _
990+
( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYREF, TRUE, 0 ), _
991+
( typeAddrOf( FB_DATATYPE_VOID ), FB_PARAMMODE_BYREF, TRUE, 0 ), _
992+
( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYREF, TRUE, 0 ) _
943993
} _
944994
), _
945995
/' sub imageconvertrow _
@@ -993,22 +1043,43 @@ declare function hPorts_cb _
9931043
/' sub screencontrol overload _
9941044
( _
9951045
byval what as const long, _
996-
byref param1 as integer = &h80000000, _
997-
byref param2 as integer = &h80000000, _
998-
byref param3 as integer = &h80000000, _
999-
byref param4 as integer = &h80000000 _
1046+
byref param1 as long = &h80000000, _
1047+
byref param2 as long = &h80000000, _
1048+
byref param3 as long = &h80000000, _
1049+
byref param4 as long = &h80000000 _
1050+
) '/ _
1051+
( _
1052+
@"screencontrol", @"fb_GfxControl_i32", _
1053+
FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
1054+
@hGfxlib_cb, FB_RTL_OPT_OVER or FB_RTL_OPT_NOQB, _
1055+
5, _
1056+
{ _
1057+
( typeSetIsConst( FB_DATATYPE_LONG ), FB_PARAMMODE_BYVAL, FALSE ), _
1058+
( FB_DATATYPE_LONG, FB_PARAMMODE_BYREF, TRUE, &h80000000 ), _
1059+
( FB_DATATYPE_LONG, FB_PARAMMODE_BYREF, TRUE, &h80000000 ), _
1060+
( FB_DATATYPE_LONG, FB_PARAMMODE_BYREF, TRUE, &h80000000 ), _
1061+
( FB_DATATYPE_LONG, FB_PARAMMODE_BYREF, TRUE, &h80000000 ) _
1062+
} _
1063+
), _
1064+
/' sub screencontrol overload _
1065+
( _
1066+
byval what as const long, _
1067+
byref param1 as longint, _
1068+
byref param2 as longint = &h80000000, _
1069+
byref param3 as longint = &h80000000, _
1070+
byref param4 as longint = &h80000000 _
10001071
) '/ _
10011072
( _
1002-
@"screencontrol", @"fb_GfxControl_i", _
1073+
@"screencontrol", @"fb_GfxControl_i64", _
10031074
FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
10041075
@hGfxlib_cb, FB_RTL_OPT_OVER or FB_RTL_OPT_NOQB, _
10051076
5, _
10061077
{ _
10071078
( typeSetIsConst( FB_DATATYPE_LONG ), FB_PARAMMODE_BYVAL, FALSE ), _
1008-
( FB_DATATYPE_INTEGER, FB_PARAMMODE_BYREF, TRUE, &h80000000 ), _
1009-
( FB_DATATYPE_INTEGER, FB_PARAMMODE_BYREF, TRUE, &h80000000 ), _
1010-
( FB_DATATYPE_INTEGER, FB_PARAMMODE_BYREF, TRUE, &h80000000 ), _
1011-
( FB_DATATYPE_INTEGER, FB_PARAMMODE_BYREF, TRUE, &h80000000 ) _
1079+
( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYREF, FALSE ), _
1080+
( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYREF, TRUE, &h80000000 ), _
1081+
( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYREF, TRUE, &h80000000 ), _
1082+
( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYREF, TRUE, &h80000000 ) _
10121083
} _
10131084
), _
10141085
/' function screenglproc( byval proc as const zstring ptr ) as any ptr '/ _

src/gfxlib2/fb_gfx.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,15 @@ extern FBCALL int fb_GfxScreen(int mode, int depth, int num_pages, int flags, in
434434
extern FBCALL int fb_GfxScreenQB(int mode, int visible, int active);
435435
extern FBCALL int fb_GfxScreenRes(int width, int height, int depth, int num_pages, int flags, int refresh_rate);
436436
extern FBCALL void fb_GfxScreenInfo(ssize_t *width, ssize_t *height, ssize_t *depth, ssize_t *bpp, ssize_t *pitch, ssize_t *refresh_rate, FBSTRING *driver);
437+
extern FBCALL void fb_GfxScreenInfo32(int *width, int *height, int *depth, int *bpp, int *pitch, int *refresh_rate, FBSTRING *driver);
438+
extern FBCALL void fb_GfxScreenInfo64(long long *width, long long *height, long long *depth, long long *bpp, long long *pitch, long long *refresh_rate, FBSTRING *driver);
437439
extern FBCALL int fb_GfxScreenList(int depth);
438440
extern FBCALL void *fb_GfxImageCreate(int width, int height, unsigned int color, int depth, int flags);
439441
extern FBCALL void *fb_GfxImageCreateQB(int width, int height, unsigned int color, int depth, int flags);
440442
extern FBCALL void fb_GfxImageDestroy(void *image);
441443
extern FBCALL int fb_GfxImageInfo(void *img, ssize_t *width, ssize_t *height, ssize_t *bpp, ssize_t *pitch, void **imgdata, ssize_t *size);
444+
extern FBCALL int fb_GfxImageInfo32(void *img, int *width, int *height, int *bpp, int *pitch, void **imgdata, int *size);
445+
extern FBCALL int fb_GfxImageInfo64(void *img, long long *width, long long *height, long long *bpp, long long *pitch, void **imgdata, long long *size);
442446
extern FBCALL void fb_GfxPalette(int index, int r, int g, int b);
443447
extern FBCALL void fb_GfxPaletteUsing(int *data);
444448
extern FBCALL void fb_GfxPaletteUsing64(long long *data);
@@ -470,6 +474,8 @@ extern FBCALL int fb_GfxGetJoystick(int id, ssize_t *buttons, float *a1, float *
470474
extern FBCALL int fb_GfxEvent(EVENT *event);
471475
extern FBCALL void fb_GfxControl_s(int what, FBSTRING *param);
472476
extern FBCALL void fb_GfxControl_i(int what, ssize_t *param1, ssize_t *param2, ssize_t *param3, ssize_t *param4);
477+
extern FBCALL void fb_GfxControl_i32(int what, int *param1, int *param2, int *param3, int *param4);
478+
extern FBCALL void fb_GfxControl_i64(int what, long long *param1, long long *param2, long long *param3, long long *param4);
473479
extern FBCALL int fb_GfxBload(FBSTRING *filename, void *dest, void *pal);
474480
extern FBCALL int fb_GfxBloadQB(FBSTRING *filename, void *dest, void *pal);
475481
extern FBCALL int fb_GfxBsave(FBSTRING *filename, void *src, unsigned int size, void *pal);

src/gfxlib2/gfx_control.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,23 @@ FBCALL void fb_GfxControl_i( int what, ssize_t *param1, ssize_t *param2, ssize_t
267267
*param4 = res4;
268268
}
269269
}
270+
271+
FBCALL void fb_GfxControl_i32( int what, int *param1, int *param2, int *param3, int *param4 )
272+
{
273+
ssize_t p1, p2, p3, p4;
274+
fb_GfxControl_i( what, &p1, &p2, &p3, &p4 );
275+
*param1 = (int)p1;
276+
*param2 = (int)p2;
277+
*param3 = (int)p3;
278+
*param4 = (int)p4;
279+
}
280+
281+
FBCALL void fb_GfxControl_i64( int what, long long *param1, long long *param2, long long *param3, long long *param4 )
282+
{
283+
ssize_t p1, p2, p3, p4;
284+
fb_GfxControl_i( what, &p1, &p2, &p3, &p4 );
285+
*param1 = (long long)p1;
286+
*param2 = (long long)p2;
287+
*param3 = (long long)p3;
288+
*param4 = (long long)p4;
289+
}

src/gfxlib2/gfx_image_info.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,45 @@ FBCALL int fb_GfxImageInfo
4848

4949
return fb_ErrorSetNum( FB_RTERROR_OK );
5050
}
51+
52+
FBCALL int fb_GfxImageInfo32
53+
(
54+
void *img,
55+
int *width,
56+
int *height,
57+
int *bpp,
58+
int *pitch,
59+
void **imgdata,
60+
int *size
61+
)
62+
{
63+
ssize_t w, h, b, p, s;
64+
int ret = fb_GfxImageInfo( img, &w, &h, &b, &p, imgdata, &s );
65+
*width = (int)w;
66+
*height = (int)h;
67+
*bpp = (int)b;
68+
*pitch = (int)p;
69+
*size = (int)s;
70+
return ret;
71+
}
72+
73+
FBCALL int fb_GfxImageInfo64
74+
(
75+
void *img,
76+
long long *width,
77+
long long *height,
78+
long long *bpp,
79+
long long *pitch,
80+
void **imgdata,
81+
long long *size
82+
)
83+
{
84+
ssize_t w, h, b, p, s;
85+
int ret = fb_GfxImageInfo( img, &w, &h, &b, &p, imgdata, &s );
86+
*width = (long long)w;
87+
*height = (long long)h;
88+
*bpp = (long long)b;
89+
*pitch = (long long)p;
90+
*size = (long long)s;
91+
return ret;
92+
}

src/gfxlib2/gfx_screeninfo.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,45 @@ FBCALL void fb_GfxScreenInfo
3838

3939
FB_GRAPHICS_UNLOCK( );
4040
}
41+
42+
FBCALL void fb_GfxScreenInfo32
43+
(
44+
int *width,
45+
int *height,
46+
int *depth,
47+
int *bpp,
48+
int *pitch,
49+
int *refresh,
50+
FBSTRING *driver
51+
)
52+
{
53+
ssize_t w, h, d, b, p, r;
54+
fb_GfxScreenInfo( &w, &h, &d, &b, &p, &r, driver );
55+
*width = (int)w;
56+
*height = (int)h;
57+
*depth = (int)d;
58+
*bpp = (int)b;
59+
*pitch = (int)p;
60+
*refresh = (int)r;
61+
}
62+
63+
FBCALL void fb_GfxScreenInfo64
64+
(
65+
long long *width,
66+
long long *height,
67+
long long *depth,
68+
long long *bpp,
69+
long long *pitch,
70+
long long *refresh,
71+
FBSTRING *driver
72+
)
73+
{
74+
ssize_t w, h, d, b, p, r;
75+
fb_GfxScreenInfo( &w, &h, &d, &b, &p, &r, driver );
76+
*width = (long long)w;
77+
*height = (long long)h;
78+
*depth = (long long)d;
79+
*bpp = (long long)b;
80+
*pitch = (long long)p;
81+
*refresh = (long long)r;
82+
}

0 commit comments

Comments
 (0)