|
Post by bigbass on Dec 12, 2017 23:49:16 GMT 1
Hey Alex Congratulations! You got it to compile Getting the "magical combination" With typedef struct when using a pointer can be a punishing experience (porting code) I spent a lot of time With the same problem today Joe Here I was working on something Doing this example and the pointer was not working basic-converter.proboards.com/post/10590
|
|
|
Post by alexfish on Dec 13, 2017 0:29:45 GMT 1
Hi Joe Well not the easiest of tasks when trying to do code that will compile in c* gcc versions & c++ versions You do not find these oddities until it Hits You:: yet think Peter may look at this struct in function problem + allow casting a struct without a USEC this works void GetIterAtCursor(struct gapbuf * buffer,char * iters) { if (buffer->gap == 0) { iters[0]='\0' }else{ iters[0]=buffer->buf[buffer->gap-1] iters[1]='\0' } } this does not : since Bacon Rejects Struct in Sub SUB GetIterAtCursor(struct gapbuf * buffer,char * iters) if (buffer->gap == 0) { iters[0]='\0' }else{ iters[0]=buffer->buf[buffer->gap-1] iters[1]='\0' } END SUB BR Alex
|
|
|
Post by alexfish on Dec 13, 2017 1:00:27 GMT 1
Hi All
Laugh of the day :: Re my comments ' Basic with those squiggly things
{};
Here is a result of a Google Search of
whats is a {
Top of the List
Well Well.
What does Your squiggly Thing Do.. Ha Ha..
BR Alex
|
|
|
Post by vovchik on Dec 13, 2017 17:53:41 GMT 1
Dear Alex and Joe, Here is that thing somewhat BaConised: ' PRAGMA OPTIONS -w OPTION PARSE FALSE
CONST BUFFERSIZE = 32768000 DECLARE t = 0, n TYPE int DECLARE curpos = 0 TYPE int DECLARE ip="END" TYPE const char* DECLARE tmp[1025] TYPE char
RECORD gapbuf LOCAL buf TYPE char* LOCAL total TYPE size_t LOCAL front TYPE size_t LOCAL end TYPE size_t LOCAL gap TYPE size_t LOCAL markstart TYPE size_t LOCAL markend TYPE size_t END RECORD
DECLARE buf TYPE gapbuf_type
' ------------------ SUB INIT_BUFFER(gapbuf_type* buffer) ' ------------------ buffer->buf = (char*)malloc(BUFFERSIZE) buffer->buf[0] = '\0' buffer->total = 1 buffer->front = 0 buffer->gap = 0 buffer->markstart = 0 buffer->markend = 1 END SUB
' ------------------ SUB INIT_CHAR(gapbuf_type* buffer, char txt) ' ------------------ IF buffer->total <= BUFFERSIZE THEN memmove(buffer->buf + buffer->gap + 1, buffer->buf + buffer->gap, \ strlen(buffer->buf) - buffer->gap) buffer->buf[buffer->gap] = txt buffer->gap = buffer->gap + 1 buffer->total = buffer->total + 1 buffer->end = buffer->total - 1 ELSE puts("overflow") END IF END SUB
' ------------------ SUB INSERT_CHARS(gapbuf_type* buffer, char* txt) ' ------------------ LOCAL i = 0 TYPE int FOR i = 0 TO strlen(txt) - 1 INIT_CHAR(buffer, txt[i]) NEXT i END SUB
' ------------------ SUB CH_SEEK_END(gapbuf_type* buffer) ' ------------------ buffer->gap = buffer->end END SUB
' ------------------ SUB CH_SEEK_START(gapbuf_type* buffer) ' ------------------ buffer->gap = buffer->front END SUB
' ------------------ SUB SET_CURSOR_POS(gapbuf_type* buffer, int curs) ' ------------------ IF curs <= buffer->front THEN curs = buffer->front END IF IF curs >= buffer->end THEN curs = buffer->end END IF buffer->gap = curs END SUB
' ------------------ SUB DELETE_CHAR(gapbuf_type* buffer) ' ------------------ IF buffer->gap >= 1 THEN memmove(buffer->buf + buffer->gap - 1, buffer->buf + buffer->gap, \ strlen(buffer->buf) - buffer->gap) buffer->gap = buffer->gap - 1 buffer->total = buffer->total - 1 buffer->buf[buffer->end - 1] = '\0' buffer->end = buffer->total - 1 END IF END SUB
' ------------------ SUB CURSOR_FORWARD(gapbuf_type* buffer) ' ------------------ buffer->gap = buffer->gap + 1 IF buffer->gap >= buffer->end THEN buffer->gap = buffer->end END IF END SUB
' ------------------ SUB SET_ITER_START(gapbuf_type* buffer, int ptr) ' ------------------ buffer->markstart = ptr END SUB
' ------------------ SUB GET_ITER_START(gapbuf_type* buffer, int* ptr) ' ------------------ *ptr = buffer->markstart END SUB
' ------------------ SUB SET_ITER_END(gapbuf_type* buffer, int ptr) ' ------------------ buffer->markend = ptr END SUB
' ------------------ SUB GET_ITER_END(gapbuf_type* buffer, int* ptr) ' ------------------ *ptr = buffer->markend END SUB
' ------------------ SUB GET_CURSOR(gapbuf_type* buffer, int* ptr) ' ------------------ *ptr = buffer->gap END SUB
' ------------------ SUB FREE_BUFFER(gapbuf_type* buffer) ' ------------------ free(buffer->buf) END SUB
' ------------------ SUB CLEAR_BUFFER(gapbuf_type* buffer) ' ------------------ FREE_BUFFER(buffer) INIT_BUFFER(buffer) END SUB
' ------------------ SUB GET_ITERS_AT_MARK(gapbuf_type* buffer, char* iters) ' ------------------ LOCAL ptr1 TYPE int LOCAL iterptr TYPE int IF buffer->markend >= BUFFERSIZE - 1 THEN buffer->markend = BUFFERSIZE - 1 END IF IF buffer->markend <= 0 THEN buffer->markend = 0 END IF IF buffer->markstart >= BUFFERSIZE - 1 THEN buffer->markstart = BUFFERSIZE - 1 END IF IF buffer->markstart <= 0 THEN buffer->markstart = 0 END IF FOR ptr1 = buffer->markstart TO buffer->markend iters[iterptr] = buffer->buf[ptr1] iterptr = iterptr + 1 NEXT ptr1 iterptr = iterptr + 1 iters[iterptr] = '\0' END SUB
PRINT " Hi ALL > buffer testing \n" INIT_BUFFER(&buf) INSERT_CHARS(&buf, (char*)"START ") puts(buf.buf) INIT_CHAR(&buf,'A') INIT_CHAR(&buf,'B') INIT_CHAR(&buf,'C') puts(buf.buf) SET_CURSOR_POS(&buf, 1) INIT_CHAR(&buf, 'D') INIT_CHAR(&buf, 'F') puts(buf.buf) CH_SEEK_END(&buf) INIT_CHAR(&buf, 'Z') INIT_CHAR(&buf, '9') puts( buf.buf) CH_SEEK_START(&buf) INIT_CHAR(&buf, '1') puts( buf.buf) CH_SEEK_END(&buf) GET_CURSOR(&buf, &curpos) PRINT "CursorPos Now at : ", curpos
INSERT_CHARS(&buf, (char*)ip) INSERT_CHARS(&buf, (char*)ip) INIT_CHAR(&buf, '1') puts( buf.buf) CH_SEEK_START(&buf) INIT_CHAR(&buf, 'X') puts( buf.buf) SET_CURSOR_POS(&buf, 1) DELETE_CHAR(&buf) puts( buf.buf) CH_SEEK_END(&buf) DELETE_CHAR(&buf) puts( buf.buf) INSERT_CHARS(&buf, (char*)"\nTest tab\t and New Line\n") INIT_CHAR(&buf, 'Z') puts( buf.buf) GET_CURSOR(&buf, &curpos) PRINT "CursorPos Now at : ", curpos SET_ITER_START(&buf, 0) SET_ITER_END(&buf, 7) GET_ITERS_AT_MARK(&buf, tmp) PRINT " get chars : "; puts(tmp) ' delete buffer CLEAR_BUFFER(&buf) INSERT_CHARS(&buf, " Buffer Cleared.\n END ALL THAT...\n Bye For Now.\n\t\tBYE") puts(buf.buf) FREE_BUFFER(&buf) With kind regards, vovchik UPDATED: The GET_ pointers were not working properly, and when they were, I was getting an error message (no-implicit -Wno-deprecated -Wno-pointer-to-int-cast), which can be suppressed by a real kluge (PRAGMA OPTIIONS -w). Not satisfied with that, but it seems to work. UPDATED: With Peter's latest beta (14 Dec 17), no PRAGMA OPTIONS -w needed. Pointers work fine. Thanks, Peter.
|
|
|
Post by alexfish on Dec 13, 2017 22:50:18 GMT 1
Hi Vovchik
on BaCon 3.6 I be getting a compile error
line 160:
IF buffer->markstart <= 0 THEN
Cause: expected expression before ')' token
then sub is
SUB GET_ITERS_AT_MARK(gapbuf_type* buffer, char* iters)
then line
IF buffer->markstart <= 0 THEN
The Although the Code looks Respectable
BR Alex
|
|
|
Post by vovchik on Dec 13, 2017 23:10:04 GMT 1
Dear Alex,
Please try Peter's latest beta. I used today's version and got no errors. Nice that we can use that record definition in subs and functions by prepending the record varname to "_type" and passing that as argument. I tested in Mint and in PI3, where I also have the latest BaCon beta:)
With kind regards, vovchik
|
|
|
Post by alexfish on Dec 14, 2017 0:07:35 GMT 1
Hi Vovchik
the code now compiles on the RPI with
BaCon version 3.7 beta on Linux armv7l - (c) Peter van Eerten - MIT License.
Now looking at how To Delete N chars as in opposite to to insertchars , and then can get a Paste over Type function
BR Alex
|
|
|
Post by Pjot on Dec 14, 2017 7:45:29 GMT 1
Hi Alex,
The construct 'IF buffer->markstart <= 0 THEN' works in BaCon 3.7, this is one of the improvements in accepting C++ syntax.
BR Peter
|
|
|
Post by vovchik on Dec 14, 2017 10:29:36 GMT 1
Dear Alex, The GET_ subs were not working properly, so I updated the code above with a real kluge. We still need a better solution. With kind regards, vovchik
|
|
|
Post by vovchik on Dec 14, 2017 18:47:55 GMT 1
Dear all, That was all yesterday's news. Today, Peter added an invisible casting enhancement - so get the latest beta - and the pointer problem goes away. You can comment out the PRAGMA OPTIONS -w bit in my code above since it is no longer needed. Everything works and no errors with pointers. Thanks, Peter. With kind regards, vovchik
|
|
|
Post by alexfish on Dec 14, 2017 22:17:44 GMT 1
Hi All & @ Peter
new beta working fine here on PI esp the buffer code as by Vovchik , thanks again to Peter & Vovchik
BR Alex
|
|
|
Post by alexfish on Dec 20, 2017 21:10:30 GMT 1
Hi All Whilst working on the openvg toolkit , came across a problem RE images. Not an easy one to resolve, but the results now looking good. Now added Cursors as a result. also the image buffer can be used for compositing etc etc. making gaming more attractive live mode updating on widgets and images now 25% faster. can see in the next demo. as a comparison GLXGEARS demo fullscreen 17 frames per second .. although the following demo is 2D, it is a full on live mode redraw all including a Desktop Image. this = 32/33 frames per second whilst at same time saving all buffers through -127 to 128 Hence ensure the graphics mem = 256. Also keyboard driver now in use , whilst on this found a way to get the Upper keys without resorting to the key map hence still a work in progress , if this works out as expected then looking to add UTF8 to the key maps. hence have yet another demo. First. need to ensure the system is Rasberry PI3 ,Debian Raspbarian/Pixel , and that the Desktop art is in the "/usr/share/rpd-wallpaper/" & the Wallpaper "aurora.jpg" exists. need to put all of the following in one folder "BaConEyes.png" "cursornormal.png" "cursordiag.png" "cursormove.png" "cursortextblack.png" "MyGBkeysMap.inc" Then "demoall2" Purpose of Demo Prevent Alpha Chanel's Penetraing through the Backing Buffer Esp if run on top of X11 and That the Alpha Blending Works on the user surface. + Blending in Particle mode not that this demo is using all buffering IE buffers are not deleted on Swap. Also note that there no other libs in use Exception .. X11 Dumb Window to blank callbacks on the Desktop IE the Demo Assumes X and the Desktop is running. and that is in the /opt/vc/ BR Alex
|
|
|
Post by alexfish on Dec 20, 2017 21:12:22 GMT 1
|
|
|
Post by alexfish on Dec 20, 2017 21:14:04 GMT 1
The demo Remember to play the particles Demo , Place the window Top left and Drag bottom right to full screen. BR Alex Attachments:demoall2.bz2 (98.37 KB)
|
|
|
Post by vovchik on Dec 21, 2017 0:20:00 GMT 1
Dear Alex, Fab. All working in my RPI3. With thanks and kind regards, vovchik
|
|