Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 13, 2014 23:47:20 GMT 1
Can you try your idea in libbbc5.so and call it from your BaCon code? (using the new BBC_KEYNAME function)
Too much BaCon magic going on under the covers which doesn't help me with the libbbc5 issue I'm having. I think I'm close, just need the data not the pointer to it returned.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 14, 2014 6:06:17 GMT 1
I moved on and created a ScriptBasic BBC extension module. The BBC_KEYNAME function works great in SB. The SB version only has BBC_RND as SB can return multiple types from it's extension module functions. The following has been added to the Brandy BASIC V graphics API in the ScriptBasic BBC extension module. - BBC_OPEN - optional window title string as an argument
- BBC_TIME - millisecond timer that is initialized when the SDL window is opened
- BBC_RND - the Brandy RND function seems to work best with BBC based code so it was added to the library
- BBC_SHIFT - Charles Pegge's bit/arithmetic shifting function
- BBC_ROTATE - Charles Pegge's bit rotating function
- BBC_MOUSE(0) - Waits for mouse movement and returns X position.
- BBC_MOUSE(1) - Waits for mouse movement and returns Y position.
- BBC_MOUSE(2) - Polls for a mouse button press event and returns.
- BBC_MOUSE(3) - Waits for a mouse button to be pressed then returns.
- BBC_GETKEY(0) - Polls for a key press event and returns.
- BBC_GETKEY(1) - Waits for a key to be pressed then returns.
- BBC_KEYNAME(0) - Polls for key up/down events and returns the key name
- BBC_KEYNAME(1) - Waits for a key up/down event and returns the key name
' UFO
DECLARE SUB BBC_OPEN ALIAS "BBC_OPEN" LIB "bbc" DECLARE SUB BBC_MODE ALIAS "BBC_MODE" LIB "bbc" DECLARE SUB BBC_ORIGIN ALIAS "BBC_ORIGIN" LIB "bbc" DECLARE SUB BBC_GCOL ALIAS "BBC_GCOL" LIB "bbc" DECLARE SUB BBC_OFF ALIAS "BBC_OFF" LIB "bbc" DECLARE SUB BBC_PLOT ALIAS "BBC_PLOT" LIB "bbc" DECLARE SUB BBC_VDUSTR ALIAS "BBC_VDUSTR" LIB "bbc" DECLARE SUB BBC_CLOSE ALIAS "BBC_CLOSE" LIB "bbc" DECLARE SUB BBC_TIME ALIAS "BBC_TIME" LIB "bbc" DECLARE SUB BBC_GETKEY ALIAS "BBC_GETKEY" LIB "bbc" DECLARE SUB BBC_WAITKEY ALIAS "BBC_WAIT" LIB "bbc" DECLARE SUB BBC_KEYNAME ALIAS "BBC_KEYNAME" LIB "bbc"
BBC_OPEN "ScriptBasic BBC UFO" t1 = BBC_TIME() BBC_MODE 31 BBC_ORIGIN 800, 600 xs = 2 ys = 2 BBC_GCOL 0, 14 BBC_OFF a = 700 b = A * A c = 600 FOR x = 0 TO a STEP xs s = x * x p = SQR(b - s) FOR i = -p TO p STEP 6 * ys r = SQR(s + i * i) / a q = (r - 1) * SIN(24 * r) y = INT(i / 3 + q * c) IF i = -p THEN m = y n = y END IF IF y > m THEN m = y IF y < n THEN n = y IF m = y OR n = y THEN BBC_PLOT 69, NOT(x), y BBC_PLOT 69, x, y END IF NEXT NEXT t2 = BBC_TIME() t3 = (t2 - t1) / 1000 BBC_OFF BBC_VDUSTR "Time: " & FORMAT("%.4f", t3) & " seconds." WHILE BBC_KEYNAME(1) <> "-escape" WEND BBC_CLOSE
' Fern
DECLARE SUB BBC_OPEN ALIAS "BBC_OPEN" LIB "bbc" DECLARE SUB BBC_MODE ALIAS "BBC_MODE" LIB "bbc" DECLARE SUB BBC_ORIGIN ALIAS "BBC_ORIGIN" LIB "bbc" DECLARE SUB BBC_GCOL ALIAS "BBC_GCOL" LIB "bbc" DECLARE SUB BBC_OFF ALIAS "BBC_OFF" LIB "bbc" DECLARE SUB BBC_DRAW ALIAS "BBC_DRAW" LIB "bbc" DECLARE SUB BBC_MOVE ALIAS "BBC_MOVE" LIB "bbc" DECLARE SUB BBC_VDUSTR ALIAS "BBC_VDUSTR" LIB "bbc" DECLARE SUB BBC_CLOSE ALIAS "BBC_CLOSE" LIB "bbc" DECLARE SUB BBC_TIME ALIAS "BBC_TIME" LIB "bbc" DECLARE SUB BBC_RND ALIAS "BBC_RND" LIB "bbc" DECLARE SUB BBC_WAITKEY ALIAS "BBC_WAITKEY" LIB "bbc"
BBC_OPEN "ScriptBasic BBC fern" t1 = BBC_TIME() BBC_MODE 31 BBC_ORIGIN 200, 100 BBC_OFF BBC_GCOL 0, 10 x = 0 y = 0 FOR i = 1 TO 80000 r = BBC_RND(1) IF r <= 0.1 THEN a = 0 b = 0 c = 0 d = 0.16 e = 0 f = 0 END IF IF r > 0.1 AND r <= 0.86 THEN a = .85 b = .04 c = -.04 d = .85 e = 0 f = 1.6 END IF IF r > 0.86 AND r <= 0.93 THEN a = .2 b = -.26 c = .23 d = .22 e = 0 f = 1.6 END IF IF r > 0.93 THEN a = -.15 b = .28 c = .26 d = .24 e = 0 f = .44 END IF newx = a * x + b * y + e newy = c * x + d * y + f x = newx y = newy BBC_MOVE 600 + 96 * x, 32 + 96 * y BBC_DRAW 600 + 96 * x, 32 + 96 * y NEXT t2 = BBC_TIME() t3 = (t2-t1)/1000 BBC_VDUSTR "Time: " & FORMAT("%.4f",t3) & " seconds" BBC_WAITKEY BBC_CLOSE
' Graph Demo
DECLARE SUB BBC_OPEN ALIAS "BBC_OPEN" LIB "bbc" DECLARE SUB BBC_TIME ALIAS "BBC_TIME" LIB "bbc" DECLARE SUB BBC_MODE ALIAS "BBC_MODE" LIB "bbc" DECLARE SUB BBC_ORIGIN ALIAS "BBC_ORIGIN" LIB "bbc" DECLARE SUB BBC_DRAW ALIAS "BBC_DRAW" LIB "bbc" DECLARE SUB BBC_MOVE ALIAS "BBC_MOVE" LIB "bbc" DECLARE SUB BBC_OFF ALIAS "BBC_OFF" LIB "bbc" DECLARE SUB BBC_GETKEY ALIAS "BBC_GETKEY" LIB "bbc" DECLARE SUB BBC_VDUSTR ALIAS "BBC_VDUSTR" LIB "bbc" DECLARE SUB BBC_CLOSE ALIAS "BBC_CLOSE" LIB "bbc"
CONST SDLK_ESCAPE = 27
BBC_OPEN "ScriptBasic BBC graphdemo" t1 = BBC_TIME() BBC_MODE 31 BBC_ORIGIN 800, 600 xlow = -10 xhigh = 10 ylow = -10 yhigh = 10 depth = 10 xscale = 30 yscale = 12 c = -4000
FOR x = xlow TO xhigh BBC_MOVE xscale * (x + ylow), yscale * (ylow - x) + c / (x * x + ylow * ylow + depth) FOR y = ylow TO yhigh BBC_DRAW xscale * (x + y), yscale * (y - x) + c / (x * x + y * y + depth) NEXT NEXT FOR y = ylow TO yhigh BBC_MOVE xscale * (xlow + y), yscale * (y - xlow) + c / (xlow * xlow + y * y + depth) FOR x = xlow TO xhigh BBC_DRAW xscale * (x + y), yscale * (y - x) + c / (x * x + y * y + depth) NEXT NEXT t2 = BBC_TIME() t3 = (t2 - t1) / 1000 BBC_OFF BBC_VDUSTR "Time: " & FORMAT("%.4f", t3) & " seconds." WHILE BBC_GETKEY(1) <> SDLK_ESCAPE WEND BBC_CLOSE
' Polygon
DECLARE SUB BBC_OPEN ALIAS "BBC_OPEN" LIB "bbc" DECLARE SUB BBC_MODE ALIAS "BBC_MODE" LIB "bbc" DECLARE SUB BBC_ORIGIN ALIAS "BBC_ORIGIN" LIB "bbc" DECLARE SUB BBC_GCOL ALIAS "BBC_GCOL" LIB "bbc" DECLARE SUB BBC_OFF ALIAS "BBC_OFF" LIB "bbc" DECLARE SUB BBC_PLOT ALIAS "BBC_PLOT" LIB "bbc" DECLARE SUB BBC_DRAW ALIAS "BBC_DRAW" LIB "bbc" DECLARE SUB BBC_MOVE ALIAS "BBC_MOVE" LIB "bbc" DECLARE SUB BBC_VDUSTR ALIAS "BBC_VDUSTR" LIB "bbc" DECLARE SUB BBC_CLOSE ALIAS "BBC_CLOSE" LIB "bbc" DECLARE SUB BBC_TIME ALIAS "BBC_TIME" LIB "bbc" DECLARE SUB BBC_RND ALIAS "BBC_RND" LIB "bbc" DECLARE SUB BBC_WAITKEY ALIAS "BBC_WAITKEY" LIB "bbc" DECLARE SUB BBC_SHIFT ALIAS "BBC_SHIFT" LIB "bbc" DECLARE SUB BBC_VDU ALIAS "BBC_VDU" LIB "bbc"
BBC_OPEN "ScriptBasic BBC polygon" t1 = BBC_TIME() BBC_MODE 32 BBC_VDU 26 SPLITA STRING(11, "0") BY "" TO x SPLITA STRING(11, "0") BY "" TO y FOR i = 1 TO 1000 xorigin = BBC_RND(1250) yorigin = BBC_RND(840) radius = BBC_RND(300) + 50 BBC_ORIGIN xorigin, yorigin sides = BBC_RND(8) + 2 BBC_MOVE radius, 0 BBC_MOVE 10, 10 c = BBC_RND(64) - 1 t = BBC_SHIFT((BBC_RND(4) - 1), 6) BBC_GCOL 0, c, t FOR side = 1 TO sides angle = (side - 1) * 2 * PI / sides x[side] = radius * COS(angle) y[side] = radius * SIN(angle) BBC_MOVE 0, 0 BBC_PLOT 85, X[side], y[side] NEXT BBC_MOVE 0, 0 BBC_PLOT 85, radius, 0 REPEAT d = BBC_RND(64) - 1 UNTIL (d AND 63) <> (c AND 6) BBC_GCOL 0,d, t FOR side = 1 TO sides FOR ln = side TO sides BBC_MOVE x[side], y[side] BBC_DRAW x[ln], y[ln] NEXT NEXT NEXT t2 = BBC_TIME() t3 = (t2 - t1) / 1000 BBC_VDUSTR "Time: " & FORMAT("%.4f",t3) & " seconds." BBC_WAITKEY BBC_CLOSE
|
|
|
Post by vovchik on Feb 14, 2014 11:30:38 GMT 1
Dear John, Looks very good. With kind regards, vovchik
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 14, 2014 11:47:50 GMT 1
It's the target I hope the BaCon project can achive. You have everything you need with libbbc5.so to make BaCon as easy to use as ScriptBasic. I leave it in your hands to put on the final coat of paint.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 14, 2014 21:40:59 GMT 1
Here is your BBC colours example in SB. ' ScriptBasic BBC COLOURS Demo - original by vovchik
IMPORT bbc.inc
t1 = "ScriptBasic BBC colours" t2 = "BBC MODE 32" t3 = "Any key to quit"
BBC::OPEN t1 BBC::MODE 32 BBC::VDU 5 BBC::OFF PRINT "Mode: ", BBC::MODEFN(),"\n" PRINT "Depth: ", BBC::VDUFN(3),"\n" PRINT "Width: ", BBC::VDUFN(11) + 1, " Height: ", BBC::VDUFN(12) + 1,"\n" PRINT "OriginX: ", BBC::VDUFN(136), " OriginY: ", BBC::VDUFN(137),"\n" PRINT "FGcolor: ", BBC::VDUFN(153), " BGcolor: ", BBC::VDUFN(154),"\n" PRINT "OriginX: ", BBC::VDUFN(136), " OriginY: ", BBC::VDUFN(137),"\n" BBC::GCOL 0, 63, 192 BBC::MOVE 400, 1160 BBC::VDUSTR "0" BBC::MOVE 400 + 256 - 5, 1160 BBC::VDUSTR "64" BBC::MOVE 400 + (2 * 256) - 15, 1160 BBC::VDUSTR "128" BBC::MOVE 400 + (3 * 256) - 20, 1160 BBC::VDUSTR "192" BBC::ORIGIN 200, 100 FOR col = 0 TO 63 BBC::MOVE 10, (col * 16) + 16 BBC::VDUSTR FORMAT("%~## ~", col) NEXT BBC::ORIGIN 270, 100 FOR col = 0 TO 63 FOR tint = 0 TO 192 STEP 64 BBC::GCOL 0, col, tint BBC::DRAWRECT tint * 4, col * 16, 256, 16, 1 PRINT RIGHT(" " & col, 3), ". BBC::GCOL(0, ", col, ", ", tint, ")\n" NEXT NEXT PRINT "OriginX: ", BBC::VDUFN(136), " OriginY: ", BBC::VDUFN(137),"\n" PRINT "FGcolor: ", BBC::VDUFN(153), " BGcolor: ", BBC::VDUFN(154),"\n" BBC::ORIGIN 0, 0 BBC::MOVE 685, 80 BBC::GCOL 0, 2, 3 PRINT "OriginX: ", BBC::VDUFN(136), " OriginY: ", BBC::VDUFN(137),"\n" PRINT "FGcolor: ", BBC::VDUFN(153), " BGcolor: ", BBC::VDUFN(154) BBC::VDUSTR t2 BBC::GCOL 0, 63, 192 BBC::MOVE 655, 40 BBC::VDUSTR t3 BBC::WAITKEY BBC::CLOSE
colors_con.txt (6.54 KB) bbc.inc MODULE BBC
DECLARE SUB ::OPEN ALIAS "BBC_OPEN" LIB "bbc" DECLARE SUB ::CLOSE ALIAS "BBC_CLOSE" LIB "bbc" DECLARE SUB ::MODE ALIAS "BBC_MODE" LIB "bbc" DECLARE SUB ::MODESTR ALIAS "BBC_MODESTR" LIB "bbc" DECLARE SUB ::NEWMODE ALIAS "BBC_NEWMODE" LIB "bbc" DECLARE SUB ::MODEFN ALIAS "BBC_MODEFN" LIB "bbc" DECLARE SUB ::ORIGIN ALIAS "BBC_ORIGIN" LIB "bbc" DECLARE SUB ::GCOL ALIAS "BBC_GCOL" LIB "bbc" DECLARE SUB ::GCOLRGB ALIAS "BBC_GCOLRGB" LIB "bbc" DECLARE SUB ::GCOLNUM ALIAS "BBC_GCOLNUM" LIB "bbc" DECLARE SUB ::COLOURFN ALIAS "BBC_COLOURFN" LIB "bbc" DECLARE SUB ::MAPCOLOUR ALIAS "BBC_MAPCOLOUR" LIB "bbc" DECLARE SUB ::SETCOLOUR ALIAS "BBC_SETCOLOUR" LIB "bbc" DECLARE SUB ::SETCOLNUM ALIAS "BBC_SETCOLNUM" LIB "bbc" DECLARE SUB ::DEFCOLOUR ALIAS "BBC_DEFCOLOUR" LIB "bbc" DECLARE SUB ::COLOURTINT ALIAS "BBC_COLOURTINT" LIB "bbc" DECLARE SUB ::TINT ALIAS "BBC_TINT" LIB "bbc" DECLARE SUB ::TINTFN ALIAS "BBC_TINTFN" LIB "bbc" DECLARE SUB ::PLOT ALIAS "BBC_PLOT" LIB "bbc" DECLARE SUB ::POINTFN ALIAS "BBC_POINTFN" LIB "bbc" DECLARE SUB ::MOVE ALIAS "BBC_MOVE" LIB "bbc" DECLARE SUB ::MOVEBY ALIAS "BBC_MOVEBY" LIB "bbc" DECLARE SUB ::DRAWBY ALIAS "BBC_DRAWBY" LIB "bbc" DECLARE SUB ::DRAW ALIAS "BBC_DRAW" LIB "bbc" DECLARE SUB ::POINT ALIAS "BBC_POINT" LIB "bbc" DECLARE SUB ::POINTBY ALIAS "BBC_POINTBY" LIB "bbc" DECLARE SUB ::POINTTO ALIAS "BBC_POINTTO" LIB "bbc" DECLARE SUB ::LINE ALIAS "BBC_LINE" LIB "bbc" DECLARE SUB ::CIRCLE ALIAS "BBC_CIRCLE" LIB "bbc" DECLARE SUB ::ELLIPSE ALIAS "BBC_ELLIPSE" LIB "bbc" DECLARE SUB ::DRAWRECT ALIAS "BBC_DRAWRECT" LIB "bbc" DECLARE SUB ::MOVERECT ALIAS "BBC_MOVERECT" LIB "bbc" DECLARE SUB ::FILL ALIAS "BBC_FILL" LIB "bbc" DECLARE SUB ::FILLBY ALIAS "BBC_FILLBY" LIB "bbc" DECLARE SUB ::OFF ALIAS "BBC_OFF" LIB "bbc" DECLARE SUB ::ON ALIAS "BBC_ON" LIB "bbc" DECLARE SUB ::SETCURSOR ALIAS "BBC_SETCURSOR" LIB "bbc" DECLARE SUB ::VDU ALIAS "BBC_VDU" LIB "bbc" DECLARE SUB ::VDUSTR ALIAS "BBC_VDUSTR" LIB "bbc" DECLARE SUB ::VDUFN ALIAS "BBC_VDUFN" LIB "bbc" DECLARE SUB ::NEWLINE ALIAS "BBC_NEWLINE" LIB "bbc" DECLARE SUB ::POS ALIAS "BBC_POS" LIB "bbc" DECLARE SUB ::VPOS ALIAS "BBC_VPOS" LIB "bbc" DECLARE SUB ::TAB ALIAS "BBC_TAB" LIB "bbc" DECLARE SUB ::RND ALIAS "BBC_RND" LIB "bbc" DECLARE SUB ::SHIFT ALIAS "BBC_SHIFT" LIB "bbc" DECLARE SUB ::ROTATE ALIAS "BBC_ROTATE" LIB "bbc" DECLARE SUB ::GETKEY ALIAS "BBC_GETKEY" LIB "bbc" DECLARE SUB ::WAITKEY ALIAS "BBC_WAITKEY" LIB "bbc" DECLARE SUB ::KEYNAME ALIAS "BBC_KEYNAME" LIB "bbc" DECLARE SUB ::MOUSE ALIAS "BBC_MOUSE" LIB "bbc" DECLARE SUB ::TIME ALIAS "BBC_TIME" LIB "bbc"
END MODULE
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 15, 2014 3:34:34 GMT 1
I think I have the keyboard and mouse interface syntax defined and working. You can either poll SDL for events or wait within SDL for an event. We have four ways to return key values. - UNICODE
- KeyCode
- ScanCode
- SDL Key Name
The BBC_GETKEY function has been enhanced to return one of the three possibilities. BBC_GETKEY(0) - unicode poll BBC_GETKEY(1) - unicode wait BBC_GETKEY(2) - keycode poll BBC_GETKEY(3) - keycode wait BBC_GETKEY(4) - scancode poll BBC_GETKEY(5) - scancode wait BBC_KEYNAME(0) - keyname poll BBC_KEYNAME(1) - keyname wait ScriptBasic keyboard test program DECLARE SUB BBC_OPEN ALIAS "BBC_OPEN" LIB "bbc" DECLARE SUB BBC_GETKEY ALIAS "BBC_GETKEY" LIB "bbc" DECLARE SUB BBC_KEYNAME ALIAS "BBC_KEYNAME" LIB "bbc" DECLARE SUB BBC_CLOSE ALIAS "BBC_CLOSE" LIB "bbc"
BBC_OPEN "Test BBC_GETKEY" REPEAT ' k = BBC_GETKEY(5) k = BBC_KEYNAME(1) ' PRINT "Unicode: ",k," Character: ",CHR(k),"\n" ' PRINT "Keycode: ",k," Character: ",CHR(k),"\n" ' PRINT "Scancode: ",k," Character: ",CHR(k),"\n" PRINT "Key Name: ",k,"\n" UNTIL k = "-escape" BBC_CLOSE
UNICODEjrs@laptop:~/sb/sb22/sdl$ scriba getkey.sb Unicode: 97 Character: a Unicode: 98 Character: b Unicode: 99 Character: c Unicode: 0 Character: Unicode: 65 Character: A Unicode: 66 Character: B Unicode: 67 Character: C Unicode: 27 Character: jrs@laptop:~/sb/sb22/sdl$ KeyCodejrs@laptop:~/sb/sb22/sdl$ scriba getkey.sb Keycode: 97 Character: a Keycode: 98 Character: b Keycode: 99 Character: c Keycode: 304 Character: 0 Keycode: 97 Character: a Keycode: 98 Character: b Keycode: 99 Character: c Keycode: 27 Character: jrs@laptop:~/sb/sb22/sdl$ ScanCodejrs@laptop:~/sb/sb22/sdl$ scriba getkey.sb Scancode: 38 Character: & Scancode: 56 Character: 8 Scancode: 54 Character: 6 Scancode: 50 Character: 2 Scancode: 38 Character: & Scancode: 56 Character: 8 Scancode: 54 Character: 6 Scancode: 9 Character: jrs@laptop:~/sb/sb22/sdl$ BBC_KEYNAME (SDL_GetKeyName +keydown | -keyup) jrs@laptop:~/sb/sb22/sdl$ scriba getkey.sb Key Name: +a Key Name: -a Key Name: +b Key Name: -b Key Name: +c Key Name: -c Key Name: +left shift Key Name: +a Key Name: -a Key Name: +b Key Name: -b Key Name: +c Key Name: -c Key Name: -left shift Key Name: +escape Key Name: -escape jrs@laptop:~/sb/sb22/sdl$
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 16, 2014 18:21:23 GMT 1
It seems that the BBC library is too simple to use and the interest has faded. I should of guessed anything under 100 lines of code and not peppered with Gtk calls is of little interest on the BaCon forum.
BTW: Whatever happened to the AlexRAD project? Are we to expect a release anytime soon or was that just another example to show that Alex can code using Gtk with no particular purpose in mind?
@peter - can you close this thread? I'm done here.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 17, 2014 2:46:40 GMT 1
For those still interested in BBC BASIC graphics on Linux, I have posted both 32 and 64 bit Ubuntu 12.04 versions if you would to give it a try. I also posted 32 and 64 bit Ubuntu 12.04 versions of the SDL_draw extension module. I have left the libbbc5 library in vovchik's hands if he wants to wrap it in a BaCon offering. I think there has been enough examples posted you shouldn't have any trouble using what has been posted (C BASIC repository site) and go it alone if the interest in this project has pasted.
|
|
|
Post by Pjot on Feb 17, 2014 21:32:36 GMT 1
At your service
|
|