BeeGOL - Beeb Game Oriented Language

Got a programming project in mind? Tell everyone about it!
User avatar
sydney
Posts: 1967
Joined: Wed May 18, 2005 9:09 am
Location: Newcastle upon Tyne

BeeGOL - Beeb Game Oriented Language

Postby sydney » Fri Mar 24, 2017 12:49 pm

A while back Tricky posted about a sprite display routine which can be used from BBC Basic. Discussion moved on and AGD on the spectrum was mentioned, even the creator of AGD contributed, and seemed to come to an end with me writing:

sydney wrote:I'd thought about doing something like this last year but decided not to as I'm a bit of a novice myself. However, with some guidance from both Jonathan and Richard maybe it'd be doable.


The idea I had last year was inspired by reading some articles about writing a compiler and I thought I'd be able to follow the articles and produce something for the beeb that would give a subset of BASIC with easy access to some fast sprite plotting routines. In the end I read two or three of the articles then went ahead and started so - as usual with me - its a bit of a bodge job.

I'm writing it in C as, at first, it's going to be a cross compiler where code is written and compiled on a pc then transferred and ran on a beeb. My C skills are pretty limited as I've not touched it in over 15 years and even then my only experience of it was college and Uni courses. Don't expect nice structured tidily formatted code.

How it works
The source code is read a line at a time and converted to beebasm compatible assembly language. Three files are needed at the assembly stage, acornconstants.asm, the .asm file produced by the compiler and the .sub file produced by the compiler. The asm file contains the main program and any variables, strings and other data. The sub file contains subroutines for any commands used in the program. Subroutines will only be added here if the command is used in the program so as to keep the code as small as possible .

What I've done so far:

Not much!
At the moment the following commands can be compilied:

  • byte - a datatype for declaring variables of type byte
  • word - a datatype for declaring variables of type word
  • string - a datatype for declaring variables of type - needs work to include a size
  • let - nothing as yet!
  • print - print text of variables to the screen
  • mode - set screen mode
  • goto - allows program flow to jump to a label
  • label - for use with goto
  • begin - marks the end of the variable declaration section and start of main program
  • end - marks the end of the program
  • rem - comments


What I want to do soon:

  • Add functionality to 'let' to enable arithmetic operations like +,-,*,/,=
  • Add for loop
  • Add while loop
  • Add repeat loop
  • Add keyboard input
  • Add sprite functionality
  • Improve layout of assembler output so that it's more readable
All to be done in that order, hopefully by the time the Wakefield show comes along. A this point it should be possible to write a simple game.

What I want to do later:

  • Procedures/Subroutines/Functions
  • Sound
  • File handling
  • Replace all OS routines with fast custom routines
  • Write a version that will run on a beeb!
  • Lots of other cool stuff!

Example:
The following beegol code...

Code: Select all

rem test program;
rem should loop forever printing hello world in mode two
begin;
mode 2;
label jump;
print "hello there";
goto jump;
end;

...will produce the following .asm file...

Code: Select all

\\  test program;
\\  should loop forever printing hello world in mode two
INCLUDE "acornconstants.asm"
ORG &2000
.start
lda #$16
jsr oswrch
lda #2
jsr oswrch
.jump
\\ print
lda #LO(strings0)
sta printvector
lda #HI(strings0)
sta printvector+1
ldy #0
jsr printstring
jmp jump
rts

INCLUDE "test.sub"


.strings0 equs "hello there"
equb 0

.end
SAVE "MAIN",start,end

...and the following .sub file...

Code: Select all


.printstring
lda (&F6),y
beq printend
jsr osasci
iny
bne printstring
.printend
rts


I'll include all the files needed in a zip except for beebasm - you'll have to get that yourself. The source file must end in a .bgl file extension and the .asm and .sub files will have the same name as the .bgl file.

It is entirely possible that I'm not up to finishing this but it's been a lot of fun so far. Expect lots of questions on assembler and C!

Link to github repository: https://github.com/sydney69/beegol

User avatar
tricky
Posts: 1816
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: BEEGOL - Beeb Game Oriented Language

Postby tricky » Fri Mar 24, 2017 1:46 pm

I've started this type of thing quite a few times, but usually stop when the number of compromises get too many.
I'm happy to chip in with c or ASM.
My usual complaint with myself is that i start out writing a compiler and end up having invented a new language, so staying starting with a new language is probably a good thing, although the error handling/debugging may be a lot of work.
Last edited by tricky on Thu Jun 08, 2017 10:45 pm, edited 1 time in total.

User avatar
sydney
Posts: 1967
Joined: Wed May 18, 2005 9:09 am
Location: Newcastle upon Tyne

Re: BEEGOL - Beeb Game Oriented Language

Postby sydney » Fri Mar 24, 2017 2:11 pm

tricky wrote:I've started this type of thing quite a few times, but usually stop when the number of compromises get too many.
I'm happy to chip in with c or ASM.
My usual complaint with myself is that i start out writing a compiler and end up having invented a new language, so staying with a new language is probably a good thing, although the error handling/debugging may be a lot of work.


Glad to hear you'll chip in with some c and ASM.
I've kind of rushed to get something out there that actually does something. I'm going to take a step back now and get some error checking in before it all becomes too much to take in. I'm also going to try to reorganise the code so that its not just a single long file as I can see it rapidly expanding into something unmanageable.

edit: spotted an error just rereading my first post!

User avatar
lurkio
Posts: 1151
Joined: Tue Apr 09, 2013 11:30 pm
Location: Doomawangara
Contact:

Re: BEEGOL - Beeb Game Oriented Language

Postby lurkio » Fri Mar 24, 2017 6:19 pm

I have no useful skills to help you whatsoever, but I just wanted to say I think this is a great idea!

Good luck!

:)

User avatar
sydney
Posts: 1967
Joined: Wed May 18, 2005 9:09 am
Location: Newcastle upon Tyne

Re: BeeGOL - Beeb Game Oriented Language

Postby sydney » Mon Apr 03, 2017 7:14 pm

I've spent the last week or so doing lots of things but no actual work on beegol! I've been relearning C and altering the code so that it's not one long file (it was already over 500 lines) but instead it has one file per beegol command which will make adding commands a lot easier.

I've also set up a better development environment. I was using Notepad++ and compiling by typing :

Code: Select all

gcc beegol.c -o beegol


Now I've downloaded geany and learned a bit about makefiles so all I need to do is press shift+f9. Much easier.
I've also given myself a crash course in using git and github. Many stardotters have recommended it in the past but I never got round to looking at it until this week.
It's not fully up to date yet but I've started a repository on github and I'm gradually getting the project back to where it was in the first post of this thread.

My plans for the next 3 weeks revolve around getting a simple game working. I used blitz basic bitd on the amiga and a magazine ran a series on it. They published a simple breakout game and I'm going to use this code see just how simple I can make it then implement only the commands needed for it.

User avatar
Elminster
Posts: 1632
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK

Re: BeeGOL - Beeb Game Oriented Language

Postby Elminster » Thu Jun 08, 2017 8:49 pm

sydney wrote: I used blitz basic bitd on the amiga and a magazine ran a series on it. They published a simple breakout game and I'm going to use this code see just how simple I can make it then implement only the commands needed for it.


Was an AMOS person myself. Wrote a bbs chat program in it that talk over a serial link. Which was made harder by a) only have one machine, and b) not having a serial cross over cable.

You kept quiet in my 6502 basic Compiler thread. If someone took on such a project they would save a load of time using your work as a base.

Which c cross Compiler are you using or looking to use?


Return to “projects”

Who is online

Users browsing this forum: No registered users and 1 guest