Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 5, 2014 18:06:49 GMT 1
The example maxes out one of my cores running this demo. I think the WAIT_KEY function needs a different approach. HERE is the same thing in Brandy BASIC V. Thanks guys for your continued efforts. P.S. I passed the 1/2 way mark in converting the libbbc.c to C BASIC. I even fixed a couple errors. (falling through CASEs with a forgotten break, ...)
|
|
|
Post by vovchik on Feb 5, 2014 18:28:16 GMT 1
Dear John,
WAIT_KEY could be fixed in a number of ways, but this is a really simple and dumb fix (SLEEP 200) designed to lower the CPU activity:
' ------------------ SUB KEY_WAIT() ' ------------------ LOCAL event TYPE SDL_Event WHILE TRUE DO WHILE BBC_GETKEY(&event) DO SELECT event.type CASE SDL_KEYUP ' If return is pressed, quit ' see http://www.libsdl.org/release/SDL-1.2.15/docs/html/sdlkey.html IF event.key.keysym.sym = SDLK_RETURN THEN OFF() ENDSCREEN() END 0 END IF CASE SDL_QUIT END 0 END SELECT WEND SLEEP 200 WEND END SUB
With kind regards, vovchik
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 5, 2014 18:56:16 GMT 1
Much better. 5-7%
FYI The emulate_vdustr (GPRINT) accepts a zero for the length and sizes the string within the function. I see no reason for the length argument and it will be eliminated in the C BASIC version.
|
|
|
Post by bigbass on Feb 6, 2014 6:24:40 GMT 1
Hey vovchik I added a little to your key wait KeywaitJoe
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 6, 2014 7:40:08 GMT 1
Looks good Joe. Using BaCon to map out the functionality for libbbc.so will make this much easier filling in the holes. That may change when I release the C BASIC version of the library. Take a peek at what I already posted to start getting the flow of using C BASIC masking of C. It doesn't take long before it feels like home. The next chapter in this project is sprites. There are multiple ways to approach this. Currently my approach has been to use SDL_image and I'm thinking of using RTB (Return to BASIC) sprite routines. The simplicy flows well with the syntax of the BBC method of graphics. I'm open to all suggestions, existing libraries or whatever else you guys might come up with.
|
|
|
Post by vovchik on Feb 6, 2014 13:05:19 GMT 1
Dear Joe and all, Great job on the enhance KEYWAIT. Thanks. I have fixed up some demos now using your sub and have attached them. With kind regards, vovchik Attachments:bbc_fixed.tar.gz (3.31 KB)
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 6, 2014 18:17:09 GMT 1
vovchik,
Nice job on the cleanup for the existing examples. Keyboard and mouse seem to working great. I like the ufo01-good.bac example with the return of status info from libbbc.
I hope to have a the new C BASIC version compiling today and if I can get the the other things I want to add in done, I might be able to get it posted. I'm shooting for a release by this weekend at the latest.
jrs@laptop:~/BaCon/V251$ ./ufo01-good MODE: 32 DEPTH: 255 Width: 800 Height: 600 OriginX: 0 OriginY: 0 FGcolor: 63 BGcolor: 0 OriginX: 0 OriginY: 0 FGcolor: 2 BGcolor: 0 RETURN jrs@laptop:~/BaCon/V251$
|
|
|
Post by vovchik on Feb 6, 2014 18:42:35 GMT 1
Dear John, Thanks. The annotationa t the botton where it says "left click" should say "right click". I honestly cannot tell the difference between right and left without first looking at my hands, so I often make such mistakes. With kind regards, vovchik
|
|
|
Post by vovchik on Feb 6, 2014 23:18:27 GMT 1
Dear all,
I am trying to understand how BBC BASIC handles RGB. Alex has explaind it to me, and here is a sample bit he gave me, which I implemented in Bacon:
' Rectangle Fill - Alex bits
' *********************** ' COMPILER DIRECTIVES ' ***********************
PRAGMA INCLUDE SDL.h PRAGMA OPTIONS -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -DHAVE_OPENGL PRAGMA LDFLAGS m SDL bbc
' *********************** ' END COMPILER DIRECTIVES ' ***********************
' *********************** ' EXTERNAL FUNCTIONS ' ***********************
PROTO init_screen ALIAS SCREEN PROTO emulate_modefn ALIAS GETMODE PROTO emulate_vdufn ALIAS GETVDU PROTO emulate_mode ALIAS MODE PROTO emulate_origin ALIAS ORIGIN PROTO emulate_off ALIAS OFF PROTO emulate_gcol ALIAS GCOLOR PROTO emulate_move ALIAS MOVE PROTO emulate_vdustr ALIAS GPRINT PROTO end_screen ALIAS ENDSCREEN PROTO emulate_vdu ALIAS VDU PROTO emulate_drawrect ALIAS RECTANGLE PROTO SDL_WM_SetCaption ALIAS TITLE PROTO SDL_PollEvent ALIAS BBC_GETKEY PROTO SDL_GL_SetAttribute ALIAS SDL_ATTRIBUTE PROTO printf ALIAS PRINTF 'emulate_drawrect(int32, int32, int32, int32, boolean) RECTANGLE
' *********************** ' END EXTERNAL FUNCTIONS ' ***********************
' *********************** ' SUBS & FUNCTIONS ' ***********************
' ------------------ SUB KEY_WAIT() ' ------------------ LOCAL event TYPE SDL_Event WHILE TRUE DO WHILE BBC_GETKEY(&event) DO SELECT event.type CASE SDL_KEYUP ' If return is pressed, quit ' see http://www.libsdl.org/release/SDL-1.2.15/docs/html/sdlkey.html IF event.key.keysym.sym = SDLK_RETURN THEN OFF() ENDSCREEN() END 0 END IF IF event.key.keysym.sym = SDLK_RIGHT THEN PRINT "RIGHT" END IF IF event.key.keysym.sym = SDLK_LEFT THEN PRINT "LEFT" END IF IF event.key.keysym.sym = SDLK_UP THEN PRINT "UP" END IF IF event.key.keysym.sym = SDLK_DOWN THEN PRINT "DOWN" END IF CASE SDL_MOUSEMOTION PRINTF("Current mouse position is : %d,%d \n", event.motion.x,event.motion.y ) CASE SDL_MOUSEBUTTONDOWN ' If left mouse button is clicked, quit IF event.button.button == SDL_BUTTON_LEFT THEN PRINT "LEFT BUTTON" OFF() ENDSCREEN() END 0 END IF IF event.button.button == SDL_BUTTON_RIGHT THEN PRINT "RIGHT BUTTON" END IF IF event.button.button == SDL_BUTTON_MIDDLE THEN PRINT "MIDDLE BUTTON" END IF CASE SDL_QUIT END 0 END SELECT WEND SLEEP 200 WEND END SUB
' ------------------ SUB ANTIALIAS() ' ------------------ SDL_ATTRIBUTE(SDL_GL_MULTISAMPLEBUFFERS, 1) SDL_ATTRIBUTE(SDL_GL_MULTISAMPLESAMPLES, 4) END SUB
' ------------------ SUB MK_DRAWING() ' ------------------ ' initializatopm LOCAL x, y TYPE int LOCAL T1$, T2$, T3$ TYPE STRING T1$ = "BaCon BBC RECTANGLE FILL" T2$ = "BBC Graphics" T3$ = "Right click to quit" LOCAL rotation TYPE double ' screen prep SCREEN() TITLE(T1$, 0) ANTIALIAS() MODE(10) VDU(5) OFF() ' terminal output PRINT "MODE: ", GETMODE() PRINT "DEPTH: ", GETVDU(3) PRINT "Width: ", GETVDU(11) + 1, " Height: ", GETVDU(12) + 1 PRINT "OriginX: ", GETVDU(136), " OriginY: ", GETVDU(137) PRINT "FGcolor: ", GETVDU(153), " BGcolor: ", GETVDU(154) PRINT "OriginX: ", GETVDU(136), " OriginY: ", GETVDU(137) ORIGIN(0, 200) FOR col = 0 TO 63 FOR tint = 0 TO 192 STEP 64 GCOLOR(0, col, tint) RECTANGLE(tint * 4, col * 16, 256, 16, 1) NEXT tint NEXT col PRINT "OriginX: ", GETVDU(136), " OriginY: ", GETVDU(137) PRINT "FGcolor: ", GETVDU(153), " BGcolor: ", GETVDU(154) ORIGIN(0, 0) MOVE(0, 80) GCOLOR(0, 2, 3) PRINT "OriginX: ", GETVDU(136), " OriginY: ", GETVDU(137) PRINT "FGcolor: ", GETVDU(153), " BGcolor: ", GETVDU(154) GPRINT(T2$, 0) GCOLOR(0, 2, 4) MOVE(0, 40) GPRINT(T3$, 0) END SUB
' *********************** ' END SUBS & FUNCTIONS ' ***********************
' *********************** ' MAIN ' ***********************
MK_DRAWING() KEY_WAIT()
' *********************** ' END MAIN ' ***********************
With kind regards, vovchik
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 6, 2014 23:36:35 GMT 1
Hint To recover the formatting of a code block someone posts, select the message Quote button and a copy will be brought into the editor with full formatting glory. jrs@laptop:~/BaCon/V251$ ./rectfill MODE: 10 DEPTH: 255 Width: 160 Height: 256 OriginX: 0 OriginY: 0 FGcolor: 63 BGcolor: 0 OriginX: 0 OriginY: 0 OriginX: 0 OriginY: 200 FGcolor: 63 BGcolor: 0 OriginX: 0 OriginY: 0 FGcolor: 2 BGcolor: 0 jrs@laptop:~/BaCon/V251$
With vovchik, right is a state of mind not a mouse button.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 8, 2014 9:09:48 GMT 1
I posted the first cut of the C BASIC version of libbbc.so on the Bitbucket site / repository if you would like to give it a try. This version should be functionally compatible with the prior version I posted. The Brandy BASIC V distribution is no longer required to build the C BASIC BBC graphics library.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 8, 2014 22:03:17 GMT 1
I have updated the libbbc.c and header files on Bitbucket. So far everything I recompiled with the new library works fine. HERE is a new version of the libbbc.c in its native C form. If I don't hear back from anyone I'll assume things are working fine for you as well.
|
|
|
Post by vovchik on Feb 8, 2014 22:53:52 GMT 1
Dear John,
Most things work fine with the new lib. However, this thing does not (I get rectangles and not circles).
With kind regards, vovchik
' Circles/Colours BBC BASIC
' *********************** ' COMPILER DIRECTIVES ' ***********************
PRAGMA INCLUDE SDL.h PRAGMA OPTIONS -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -DHAVE_OPENGL PRAGMA LDFLAGS m SDL bbc
' *********************** ' END COMPILER DIRECTIVES ' ***********************
' *********************** ' EXTERNAL FUNCTIONS ' ***********************
PROTO init_screen ALIAS SCREEN PROTO emulate_modefn ALIAS GETMODE PROTO emulate_vdufn ALIAS GETVDU PROTO emulate_mode ALIAS MODE PROTO emulate_origin ALIAS ORIGIN PROTO emulate_off ALIAS OFF PROTO emulate_gcol ALIAS GCOLOR PROTO emulate_move ALIAS MOVE PROTO emulate_vdustr ALIAS GPRINT PROTO end_screen ALIAS ENDSCREEN PROTO emulate_vdu ALIAS VDU PROTO emulate_point ALIAS POINT PROTO emulate_line ALIAS LINE PROTO emulate_circle ALIAS CIRCLE PROTO SDL_WM_SetCaption ALIAS TITLE PROTO SDL_PollEvent ALIAS BBC_GETKEY PROTO SDL_GL_SetAttribute ALIAS SDL_ATTRIBUTE PROTO printf ALIAS PRINTF
' *********************** ' END EXTERNAL FUNCTIONS ' ***********************
' *********************** ' SUBS & FUNCTIONS ' ***********************
' ------------------ SUB FLOOD(int X, int Y, int C) ' ------------------ LOCAL L, R TYPE int ' PRINT POINT(X, Y) IF POINT(X, Y) <> C THEN GOTO SKIP END IF L = X R = X WHILE POINT(L - 2, Y) = C DO DECR L, 2 WEND WHILE POINT(R + 2, Y) = C DO INCR R, 2 WEND LINE(L, Y, R, Y) FOR X = L TO R STEP 2 CALL FLOOD(X, Y + 2, C) CALL FLOOD(X, Y - 2, C) NEXT LABEL SKIP END SUB
' ------------------ SUB KEY_WAIT() ' ------------------ LOCAL event TYPE SDL_Event WHILE TRUE DO WHILE BBC_GETKEY(&event) DO SELECT event.type CASE SDL_KEYUP ' If return is pressed, quit ' see http://www.libsdl.org/release/SDL-1.2.15/docs/html/sdlkey.html IF event.key.keysym.sym = SDLK_RETURN THEN OFF() ENDSCREEN() END 0 END IF IF event.key.keysym.sym = SDLK_RIGHT THEN PRINT "RIGHT" END IF IF event.key.keysym.sym = SDLK_LEFT THEN PRINT "LEFT" END IF IF event.key.keysym.sym = SDLK_UP THEN PRINT "UP" END IF IF event.key.keysym.sym = SDLK_DOWN THEN PRINT "DOWN" END IF CASE SDL_MOUSEMOTION PRINTF("Current mouse position is : %d,%d \n", event.motion.x,event.motion.y ) CASE SDL_MOUSEBUTTONDOWN ' If left mouse button is clicked, quit IF event.button.button == SDL_BUTTON_LEFT THEN PRINT "LEFT BUTTON" OFF() ENDSCREEN() END 0 END IF IF event.button.button == SDL_BUTTON_RIGHT THEN PRINT "RIGHT BUTTON" END IF IF event.button.button == SDL_BUTTON_MIDDLE THEN PRINT "MIDDLE BUTTON" END IF CASE SDL_QUIT END 0 END SELECT WEND SLEEP 200 WEND END SUB
' ------------------ SUB ANTIALIAS() ' ------------------ SDL_ATTRIBUTE(SDL_GL_MULTISAMPLEBUFFERS, 1) SDL_ATTRIBUTE(SDL_GL_MULTISAMPLESAMPLES, 4) END SUB
' ------------------ SUB MK_DRAWING() ' ------------------ LOCAL x, y, i, j TYPE int LOCAL T1$, T2$, T3$ TYPE STRING T1$ = "BaCon BBC FLOOD FILL" T2$ = "BBC Old School Graphics" T3$ = "Press <RETURN> or Left Click to quit" SCREEN() TITLE(T1$, 0) ANTIALIAS() MODE(32) VDU(5) OFF() PRINT "MODE: ", GETMODE() PRINT "DEPTH: ", GETVDU(3) PRINT "Width: ", GETVDU(11) + 1, " Height: ", GETVDU(12) + 1 PRINT "OriginX: ", GETVDU(136), " OriginY: ", GETVDU(137) PRINT "FGcolor: ", GETVDU(153), " BGcolor: ", GETVDU(154) GCOLOR(0, 10, 5) FOR i = 0 TO 127 GCOLOR(0, i, 5) ORIGIN(100, 120) PRINT "OriginX: ", GETVDU(136), " OriginY: ", GETVDU(137) PRINT "FGcolor: ", GETVDU(153), " BGcolor: ", GETVDU(154) CIRCLE(640, 512, 500, 1) FOR j = 0 TO 255 MOVE(1100, 100) GCOLOR(0, 47, 200) GPRINT("i = " & RIGHT$(" " & STR$(i), 3), 0) MOVE(1100, 70) GPRINT("j = " & RIGHT$(" " & STR$(j), 3), 0) GCOLOR(0, i, j) CIRCLE(500, 600, 200, 1) ' SLEEP 1 NEXT j NEXT i GCOLOR(0, 5, 6) FLOOD(600, 200, 15) ORIGIN(0, 0) MOVE(580, 100) GCOLOR(0, 2, 3) PRINT "OriginX: ", GETVDU(136), " OriginY: ", GETVDU(137) PRINT "FGcolor: ", GETVDU(153), " BGcolor: ", GETVDU(154) GPRINT(T2$, 0) GCOLOR(0, 2, 4) MOVE(470, 70) GPRINT(T3$, 0) END SUB
' *********************** ' END SUBS & FUNCTIONS ' ***********************
' *********************** ' MAIN ' ***********************
MK_DRAWING() KEY_WAIT()
' *********************** ' END MAIN ' ***********************
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 9, 2014 0:18:09 GMT 1
Good catch!
I screwed up and used INCR instead of DECR on a couple of variables in the filled_ellipse routine. Please get the latest from Bitbucket, recompile and give it another try.
Thanks again for testing, I REALLY appreciate it!
Note: The C BASIC version is the only copy being maintained on Bitbucket. If you wish to create your own native C version of the library, do the following and start at the end of the redirected file and work your way up to the first function in the library. Add the header and includes (- cbasic.h) and that's all there is to it.
gcc -E -I/usr/include/SDL libbbc.c > libbbc.expanded
|
|
|
Post by vovchik on Feb 9, 2014 0:59:55 GMT 1
Dear John,
It works nicely now...Thanks.
With kind regards, vovchik
|
|