Author Topic: libbbc.dll - C BASIC  (Read 10383 times)

0 Members and 1 Guest are viewing this topic.

JRS

  • Guest
libbbc.dll - C BASIC
« on: February 08, 2014, 09:39:00 PM »
If anyone would like to give the BBC Graphics libbbc.dll a try with O2, the DLL and source are attached. I have tried it with SB & DLLC and it works great. Direct calls to SDL are also permitted. The libbbc fork of the Brandy BASIC V SDL graphics library was rewritten using C BASIC.

Note: SDL 1.2 needs to be installed for libbbc.dll to work.






.
« Last Edit: February 09, 2014, 03:02:53 AM by John »

Charles Pegge

  • Guest
Re: libbbc.dll - C BASIC
« Reply #1 on: February 09, 2014, 02:40:36 AM »
Thanks John,  is it just SDL.DLL that is required?

JRS

  • Guest
Re: libbbc.dll - C BASIC
« Reply #2 on: February 09, 2014, 02:49:07 AM »
I think so. Take a peek at the SB / DLLC version I posted on All BASIC.


JRS

  • Guest
Re: libbbc.dll - C BASIC
« Reply #3 on: February 11, 2014, 01:36:59 AM »
Charles,

Are you able to use the libbbc5.h file with O2? It has everything in the header and only functions / subs in the libbbc5.c source file.

John

Charles Pegge

  • Guest
Re: libbbc.dll - C BASIC
« Reply #4 on: February 11, 2014, 09:53:27 AM »

Hi John,
A few more header problems to solve. It's keeping me very busy, but I can get it to accept the header now.

JRS

  • Guest
Re: libbbc.dll - C BASIC
« Reply #5 on: February 11, 2014, 07:13:17 PM »
Sounds great! Here is the C BASIC libbbc5.dll and polygon.c example running on Windows XP. The attached zip includes binaries and source for both.



Code: [Select]
// C BASIC Polygon

#include <stdio.h>
#include <math.h>
#include <SDL.h>
#include "libbbc5.h"
#include "cbasic.h"

#define PI 3.14159265358979323846

MAIN
BEGIN_FUNCTION
  DIM AS float64 angle, radius, x[10], y[10];
  DIM AS int32 c, t, d, side, sides, xorigin, yorigin, i, l;
  DIM AS Uint32 t1, t2, t3;
  DIM AS char strbuff[15];
  BBC_OPEN();
  BBC_MODE(32);
  t1 = SDL_GetTicks();
  SDL_WM_SetCaption("C BASIC BBC5 - polygon", 0);
  BBC_VDU(26);
  DEF_FOR (i = 1 TO i <= 1000 STEP INCR i)
  BEGIN_FOR
    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, 0);
    BBC_GCOL(0, c, t);
    DEF_FOR (side = 1 TO side <= sides STEP INCR side)
    BEGIN_FOR
      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);
    DO
      d = BBC_RND(64) - 1;
    WHILE ((d & 63) != (c & 6));
    BBC_GCOL(0, d, t);
    DEF_FOR (side = 1 TO side <= sides STEP INCR side)
    BEGIN_FOR
      DEF_FOR (l = side TO l <= sides STEP INCR l)
      BEGIN_FOR
        BBC_MOVE(x[side], y[side]);
        BBC_DRAW(x[l], y[l]);
      NEXT
    NEXT
  NEXT
  t2 = SDL_GetTicks();
  t3 = (t2 - t1) / 1000;
  sprintf(strbuff, "%d.4 Seconds.", t3);
  BBC_OFF();
  BBC_VDUSTR(strbuff, 0);
  DEF_WHILE (BBC_GETKEY() != SDLK_ESCAPE)
  BEGIN_WHILE
  WEND
//  BBC_WAITKEY();
  BBC_CLOSE();
  RETURN_FUNCTION(0);
END_FUNCTION

Code: [Select]
F:\libbbc>gcc polygon.c -o polygon.exe -I C:/MinGW32/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -DHAVE_OPENGL -lmingw32 lSDLmain -lSDL -mwindows libbbc5.dll -lm

Here is the Android version of the above. The same (untouched) code ran on 64 bit Linux, 32 bit Windows and on ARM. (Android 32 bit Linux)





.
« Last Edit: February 11, 2014, 11:41:08 PM by John »

Emil_halim

  • Guest
Re: libbbc.dll - C BASIC
« Reply #6 on: February 12, 2014, 08:33:48 AM »
Hi John,

I liked the idea of C BASIC itself, the great point that it does not need any exe to translate the Basic style to C code.

where can i fine it's site.

thanks.

Charles Pegge

  • Guest
Re: libbbc.dll - C BASIC
« Reply #7 on: February 12, 2014, 08:41:28 AM »

Hi Emil,

Our board for C Basic is here:

http://www.allbasic.info/forum/index.php?board=18.0

Emil_halim

  • Guest
Re: libbbc.dll - C BASIC
« Reply #8 on: February 12, 2014, 08:54:52 AM »
Hi Charles,

thank you for your reply.

i will check it.

 

JRS

  • Guest
Re: libbbc.dll - C BASIC
« Reply #9 on: February 12, 2014, 09:27:43 AM »
The C preprocessor is a nice feature to help make C easier to read and use. The ScriptBasic API is a good example of this concept in use. C BASIC is still in it's early conceptual state but is useful for making existing C code more readable. It's still missing many of the BASIC language features that would allow it to be used for development. A fun project no less.

« Last Edit: February 12, 2014, 10:40:24 AM by John »

Emil_halim

  • Guest
Re: libbbc.dll - C BASIC
« Reply #10 on: February 12, 2014, 11:32:32 AM »


I think i will use cbasic.h and i will add some stuff that fit my needs.

thanks.

JRS

  • Guest
Re: libbbc.dll - C BASIC
« Reply #11 on: February 12, 2014, 12:07:22 PM »
Please share whatever you add to cbasic.h.


Emil_halim

  • Guest
Re: libbbc.dll - C BASIC
« Reply #12 on: February 12, 2014, 12:11:10 PM »

 ofcourse i will. 

Kuron

  • Guest
Re: libbbc.dll - C BASIC
« Reply #13 on: February 12, 2014, 12:55:29 PM »
where can i fine it's site.

There is not a site/forums open to the public (which is intentionally keeping people from participating and preventing a community from growing around it), but I am going to put a section on the forums I am setting up.  It does deserve some promotions and being opened to others.

JRS

  • Guest
Re: libbbc.dll - C BASIC
« Reply #14 on: February 12, 2014, 01:09:22 PM »
The project site for C BASIC is HERE. It has a git based file repository, wiki and incident tracking feature. It's open to the public and allows for making requests and commenting on direction.