News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_AMSDOS

BBC BASIC for CPC

Started by AMSDOS, 12:11, 15 August 18

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

AMSDOS

I was flipping through some of the very early BBC Micro User catalogues today from 1983 and was impressed with the graphical abilities from the screenshots they had, they were even testing me out in terms of coding it in Locomotive BASIC. Eventually I managed to get this Multicoloured Diamond working, though I thought it was a good opportunity to dust off my BBC BASIC DSK Image and see how BBC BASIC for CPC handles it.


BBC BASIC for CPC was written back in 1986, it can operate in CP/M 2.2 or CP/M Plus, like Locomotive BASIC it's fully Interpreter with a number of the BBC Commands appearing to be interpreted for program compatibility.


This Example I have needed a few minor tweaks, the most significant alteration the program needed was an additional VDU 19 to generate the Yellow between the Blue and Red, after that I had to modify the PRINT statements to have a semi-colon, this was causing some unusual squares appearing/disappearing along the edges and causing Line 25 to turn blue with the rest of the screen using green paper.


Here's an original screenshot from the Magazine:




And this is what the original program looked like:



10 REM *** PROGRAM FOUR ***
20 MODE 5
30 VDU 19,3,4,0,0,0:VDU 19,0,2,0,0,0
40 COLOUR 128:CLS
50 centre=9:top=7:bottom=25
60 FOR row=1 TO 9
70 start=centre- row +1
80 FOR length = 0 TO 2*(row-1)
90 COLOUR (ABS(start+length-9)+ABS(top+row-16))MOD 3+129
100 PRINT TAB(start+length,  top+row);" "
110 PRINT TAB(start+length,bottom-row);" "
120 NEXT length
130 NEXT row
140 VDU 30



To have that appearing the same with the CPC Version of BBC BASIC, this is the resulting code:




   10 REM *** PROGRAM FOUR ***
   20 MODE 5
   30 VDU 19,2,3,0,0,0:VDU 19,3,4,0,0,0:VDU 19,0,2,0,0,0
   40 COLOUR 128:CLS
   50 centre=9:top=7:bottom=25
   60 FOR row=1 TO 9
   70   start=centre- row +1
   80   FOR length = 0 TO 2*(row-1)
   90     COLOUR(ABS(start+length-9)+ABS(top+row-16))MOD3+129
  100     PRINT TAB(start+length,  top+row);" ";
  110     PRINT TAB(start+length,bottom-row);" ";
  120   NEXT length
  130 NEXT row
  140 VDU 30                                 


With an output looking like this:



I initially had some difficulty saving it onto a DSK image, though the SAVE and LOAD commands appear to be the same as Locomotive BASIC, the code is also Tokenised. I initially tried it out with CP/M Plus and had no problems with it, though in CP/M v2.2, BBC BASIC needs to be in Drive B: (with CP/M v2.2 in A:), and like all things when Disks (or DSKs) are changed CP/M v2.2 needs to be informed about it. In BBCBASIC the command is *RESET with takes you back to Drive A: fortunately you can tell CP/M to *DRIVE B: to view the work-disk, though there's so much less hassle when using it in CP/M Plus.


Anyhow I've attached a DSK image below.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

scruss

Richard Russell did a lot of work to keep his various implementations of BBC BASIC as compatible with each other as possible. He's still maintaining it: BBC BASIC for SDL 2.0 runs on a variety of modern platforms. An independent implementation is stardot/MatrixBrandy: Fork of Brandy BASIC V for Linux. If anything, the test programme you listed looks nicer when run under Brandy than on BBC BASIC for SDL.
You should be able to get the ASCII listing out of BBC BASIC for CPC with:*SPOOL "PROG4TXT.BAS"
LIST
*SPOOL

LambdaMikel

Neat! Didn't know about BBC BASIC for the CPC.
Does it have the [ ... ] inline assembler for Z80 then? 

revaldinho

Quote from: LambdaMikel on 18:21, 15 August 18
Neat! Didn't know about BBC BASIC for the CPC.
Does it have the [ ... ] inline assembler for Z80 then?


Yes is does. I think it's common to all platforms including the ARM based Archimedes and even the little Amstrad NC100s.


Great feature.


http://www.bbcbasic.co.uk/bbcbasic/z80basic.html


R

AMSDOS

@scruss - Spool option worked, thanks.


I have a very brief txt file which comes with the CPC version of BBC BASIC, which is pretty much saying that if I want a detail manual, then the "Torch Version 2.3" is the manual to follow, along with the text file that comes with the CPC version, which outlines the differences. Guessing I'll have to download the Torch version to get the rest of the manual.


Tried out another Graphical example from the BBC Micro User which draws a series of Triangles. Once again had to make some alterations so the largest Triangle was onscreen. MODE 5 appears to have a resolution of 1000x1000 on the BBC, I reduced the size of largest triangle to 750, in order to prevent drawing offscreen. Otherwise, everything else worked, though I had to add an additional VDU to get Yellow. The BBC seems to have a slightly different colour set when set by default, has the BBC manual got any information about those defaults colours?


Here's the original program:



10 REM PROGRAM TEN
20 MODE 5
30 VDU 19,3,4,0,0,0
40 TALLY=0
50 SIZE=1000
60 HEIGHT=1.732*SIZE/2
70 REPEAT
80 BASE=SIZE - TALLY*250
90 UP=HEIGHT*TALLY/4
100 XPOS=100 + 250*TALLY/2
110 YPOS=UP/2  + 100
120 PROCtriangle(XPOS,YPOS,BASE,TALLY MOD 3+1)
130 TALLY=TALLY+1
140 UNTIL TALLY > 3
150 END
160 DEFPROCtriangle(x,y,length,colour)
170 LOCAL height
180 GCOL0,colour
190 height=length*1.732/2
200 MOVE x,y
210 DRAW x+length,y
220 DRAW x+length/2,y+height
230 DRAW x,y
240 ENDPROC



And the CPC version:




   10 REM PROGRAM TEN
   20 MODE 5
   30 VDU 19,2,3,0,0,0:VDU 19,3,4,0,0,0
   40 TALLY=0
   50 SIZE=750
   60 HEIGHT=1.732*SIZE/2
   70 REPEAT
   80   BASE=SIZE - TALLY*187.5
   90   UP=HEIGHT*TALLY/4
  100   XPOS=320 + 187.5*TALLY/2
  110   YPOS=UP/2
  120   PROCtriangle(XPOS,YPOS,BASE,TALLY MOD 3+1)
  130   TALLY=TALLY+1
  140 UNTIL TALLY > 3
  150 END
  160 DEFPROCtriangle(x,y,length,colour)
  170 LOCAL height
  180 GCOL0,colour
  190 height=length*1.732/2
  200 MOVE x,y
  210 DRAW x+length,y
  220 DRAW x+length/2,y+height
  230 DRAW x,y
  240 ENDPROC                                     



And screenshot:



* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS


I was testing out a simple game called Bouncing Bug from the Usborne Computer Graphics since there seem to be a BBC version, however I've encountered problems in translating some of the dialect for the CPC version.


There seems to be some problems going on with the INKEY() routine. I decided to use it as opposed to INKEY$(), which was used in the original, the controls seem to work, though if I decide to not hold down any keys, the Bug decides to move Up (maybe it's meant to be like that). I had a look in the Torch Manual, which is what this version of BBC BASIC is based around and it seems like INKEY() on the BBC works in the same manners as the Locomotive BASIC, however when I tested it (using the key numbers as suggested from the Amstrad manual with a minus sign at the start), I got a result of 0 instead of -1. The main problem seems to be the 'Press Space to Play' keypress on line 880. I replaced 870 & 880 with an INKEY(-47) and tried variations of IF and even REPEAT UNTIL, without any luck, so the routine simply skips through and goes immediately to the game after drawing a couple of screens.


The other bug (which I don't understand why it's occurring), is a series of Cursor Character(s) are being Printed onscreen, I found some problems which related to how large the BBC Text Screen and made adjustments to accomodate that along with areas where the Text was being printed across the screen (more than 20 characters), though after adjusting that so everything could fit onscreen, the Cursor Characters remain.


The only good thing I can take out of this, is being able to get the idea of the game and rewrite for Locomotive BASIC.


Though here's the code if anyone was interested.



    5 MODE 5
   10 WI%=19
   20 HI%=20
   30 V%=1
   40 W%=0
   50 G%=15:Z=1
   60 TS%=0
   70 NB%=3
   80 DIM X%(G%):DIM Y%(G%)
   85 GOSUB 900
   90 GOSUB 830
  100 GOSUB 550
  110 GOSUB 800
  120 GOTO 270
  140 IF INKEY(-0) THEN W%=-1:V%=0
  150 IF INKEY(-2) THEN W%=1:V%=0
  160 IF INKEY(-8) THEN V%=-1:W%=0
  170 IF INKEY(-1) THEN V%=1:W%=0
  180 GOSUB 440
  190 PRINT TAB(X%,Y%);" "
  200 X%=X%+V%
  210 Y%=Y%+W%
  220 IF X%<1 THEN X%=1:V%=-V%
  230 IF Y%<4 THEN Y%=4:W%=-W%
  240 IF X%>WI%-1 THEN X%=WI%-1:V%=-V%
  250 IF Y%>HI%-2 THEN Y%=HI%-2:W%=-W%
  260 PRINT TAB(X%,Y%);CHR$(D%)
  270 FOR I%=1 TO G%
  280   IF X%=X%(I%) AND Y%=Y%(I%) THEN GOSUB 490
  290 NEXT I%
  300 IF X%=P% AND Y%=Q% THEN T%=1
  310 PRINT TAB(X%,Y%);CHR$(224);
  320 T%=T%-1
  330 PRINT TAB(0,2);"SCORE ";TS%;
  331 PRINT TAB(0,24);"TIME ";T%;"  ";
  340 IF T%>0 THEN GOTO 140
  350 IF B%>0 THEN PRINT TAB(5,5);"BONUS ";B%
  360 FOR C%=1 TO 5000:NEXT C%
  370 TS%=TS%+B%
  380 IF B%=0 THEN NB%=NB%-1
  390 IF NB%>0 THEN GOTO 100
  400 PRINT TAB(5,5);"PLAY AGAIN ? (Y/N)"
  410 INPUT Q$
  420 IF Q$="Y" THEN RUN
  430 STOP
  440 IF W%=1 THEN D%=225
  450 IF W%=-1 THEN D%=226
  460 IF V%=-1 THEN D%=227
  470 IF V%=1 THEN D%=228
  480 RETURN
  490 S%=S%+1
  500 TS%=TS%+5
  510 X%(I%)=0
  520 Y%(I%)=0
  530 IF S%=G% THEN B%=T%/3:T%=1
  540 RETURN
  550 CLS
  560 COLOUR 3
  570 PRINT TAB(3,1);"BOUNCING BUG";
  571 PRINT TAB(0,23);"BUGS ";NB%;
  580 S%=0
  590 B%=0
  600 Z=Z+0.3
  610 T%=1000/Z
  620 FOR I%=1 TO G%
  630   COLOUR INT(RND(1)*2+1)
  640   GOSUB 800
  650   X%(I%)=X%:Y%(I%)=Y%
  660   PRINT TAB(X%(I%),Y%(I%));CHR$(229)
  670 NEXT I%
  680 GOSUB 800
  690 P%=X%:Q%=Y%
  700 COLOUR INT(RND(1)*2+1)
  710 FOR I%=1 TO WI%
  720   PRINT TAB(I%,3);"*";
  730   PRINT TAB(I%,HI%-1);"*";
  740 NEXT I%
  750 FOR I%=3 TO HI%-1
  760   PRINT TAB(0,I%);"*";
  770   PRINT TAB(WI%,I%);"*";
  780 NEXT I%
  790 RETURN
  800 X%=RND(1)*(WI%-1)+1
  810 Y%=RND(1)*(HI%-5)+4
  820 RETURN
  830 GOSUB 550
  840 GOSUB 620
  850 COLOUR 3
  860 PRINT TAB(0,2);"PRESS SPACE TO START"
  880 IF INKEY(-47) THEN GOTO 840
  890 RETURN
  900 VDU 23,224,0,90,60,126,126,60,90,0
  910 VDU 23,225,129,90,60,126,102,36,66,129
  920 VDU 23,226,129,66,36,102,126,60,90,129
  930 VDU 23,227,129,90,60,14,14,60,90,129
  940 VDU 23,228,129,90,60,112,112,60,90,129
  950 VDU 23,229,28,62,62,28,8,42,28,8
  960 RETURN                                                                 



And Screenshot with Cursor Character beside my bug character.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

chinnyhill10

Anyone benchmarked how fast this runs against a real BBC?
--
ChinnyVision - Reviews Of Classic Games Using Original Hardware
chinnyhill10 - YouTube

AMSDOS

Quote from: chinnyhill10 on 12:08, 08 September 18
Anyone benchmarked how fast this runs against a real BBC?


I don't know how fast a real BBC runs (guessing it's 1 or 2 Mhz), though the purpose of this language seems to be more about having a counterpart across a number of systems. This particular one was written for the CPC and operates though CP/M Plus or CP/M 2.2 back in 1986. Some of the things it tries to do, may simulate commands from the BBC, though it won't try to emulate what a BBC would allow. The game I posted above for example can be setup to play in an area 19x30 in size in MODE 5 on the BBC, though the CPC doesn't have that, so issuing a MODE 5 will setup MODE 0 screen instead.


There's a number of modern day versions of BBC BASIC, I've played around with BBC BASIC for Mac and there's also BBC BASIC for Windows. While I've been able to play around with code from Rosetta code on BBC BASIC for Mac, there's nothing about it, which simulates the speed of a real BBC and I haven't even been able to run code from BBC BASIC for Windows from things like Dragon Curve or Maze Generation on BBC BASIC for CPC.


So it seems to be a language designed for studying of BBC BASIC code and adjust accordingly to suit CPC specs. It's perhaps handy just to get an idea of what to expect from a program and then code in your own BASIC dialect. I did have a couple of Locomotive BASIC examples I converted earlier from BBC BASIC, all very simple stuff though.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

robcfg

Actually, the Amstrad Notepad (or NC) had a version of BBC Basic. Could it be possible to make it work on a CPC, providing machine specific code?

scruss

The NC BASIC is essentially the same codebase as the BBC BASIC for CPC/CP/M. You could (maybe!) make a native version — the folks over on stardot have ported it to all sorts of systems, including the ancient DEC PDP-11. While I do remember the Z80 BBC BASIC being pretty quick (I had a Z88) I don't think it could compare to the 6502 version. Sophie Wilson apparently put in some highly optimized code that Richard Russell (the author of BBC BASIC for Z80 and later PCs) took a while to pick up on.
The CPC version is supposed to be compatible with the Beeb's graphics commands. Obviously, from AMSDOS's experience, it's not quite.
Curiously, I heard from Vik "The Hairy Hacker" Olliver that one of the Z80 development systems that strongly influenced the CPC (esp after it made the hurried switch to Z80) was a board/system design by Richard Russell when he was at the BBC. Apparently these were widely pirated and used outside the Corporation. Richard himself is not convinced that this could be the case, but Vik seemed pretty sure.

AMSDOS




It's very close with the X-Axis being correctly scaled from 0 to 1279, however the Y-Axis is smaller, so instead of it being 0 to 1023, it's 0 to 799.



The Text Screen is also different, again the Amstrad can handle 40 rows and simulate it as a Beep would from 0 to 39, though the Beep can allow 32 columns (0-31).


Earlier when I was drawing that Multicoloured Diamond, I noticed in the original programme that the PRINT statement didn't have a semicolon at the end either. When I was using BBC BASIC for CPC and had the PRINT statement in that manner, there seemed to be a whole series of Cursor appearing, disappearing onscreen during the drawing cycle. The Semicolon seemed to be the only means of correcting that, though now with that simple game I posted, it seems to be occurring with that as well. I don't know what's going on with that.


After looking at the Manual which comes with the Torch version of BBC BASIC (which is what the CPC Manual refers to), INKEY sounds very similar to the CPC INKEY with -1 being returned on no keypress, though BBC BASIC for the CPC didn't seem to be behaving in this manner, could try testing that with a Test program.

* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

#11
After spending some time off from this Language, I decided to go back to it and figure out what was wrong with the Bouncing Bug game. For some reason I thought I wrote a Test Programme to Test the Key Input routine, but like the game, a While Square was appearing alongside the Shape, so I thought perhaps it's a Cursor, the next thing was to determine how to switch it off. Within the Text File included with the CPC version of BBC BASIC it shows a command prompt, I place one at the start of my Test programme to Disable the Cursor (Line 10) and one at the end (Line 100) to Reinstate the Cursor and this was what I got:




   10 MODE 2:VDU 23,1,0;0;0;0;
   20 X=10:Y=10:OX=X:OY=Y
   30 REPEAT
   40   IF INKEY(-67) THEN IF Y>0 THEN Y=Y-1
   50   IF INKEY(-69) THEN IF Y<23 THEN Y=Y+1
   60   IF INKEY(-34) THEN IF X>0 THEN X=X-1
   70   IF INKEY(-27) THEN IF X<19 THEN X=X+1
   80   IF OX<>X OR OY<>Y THEN PRINT TAB(OX,OY);CHR$(32);
   90   PRINT TAB(X,Y);CHR$(79);:OX=X:OY=Y
  100 UNTIL INKEY(-47):VDU 23,1,1;0;0;0;                                                                               



Now when I run it I have a letter 'O' which I can move around the Screen (in 20x25 Mode), Space Exits the Programme and the VDU 23 restores the Cursor.


With that sorted out I can now have the same thing in the Bouncing Bug game and no Cursor Keys appear. I found that this Command exists within the BBC Manual, so I'm not sure if the same thing really happened like that on a BBC Computer, anyway I'm just glad it's resolved now and the game plays a bit better even though I cringe when I look at the coding of it.




    5 MODE 5:VDU 23,1,0;0;0;0;
   10 WI%=19
   20 HI%=20
   30 V%=1
   40 W%=0
   50 G%=15:Z=1
   60 TS%=0
   70 NB%=3
   80 DIM X%(G%):DIM Y%(G%)
   85 GOSUB 900
   90 GOSUB 830
  100 GOSUB 550
  110 GOSUB 800
  120 GOTO 270
  140 IF INKEY(-67) THEN W%=-1:V%=0
  150 IF INKEY(-69) THEN W%=1:V%=0
  160 IF INKEY(-34) THEN V%=-1:W%=0
  170 IF INKEY(-27) THEN V%=1:W%=0
  180 GOSUB 440
  190 PRINT TAB(X%,Y%);" "
  200 X%=X%+V%
  210 Y%=Y%+W%
  220 IF X%<1 THEN X%=1:V%=-V%
  230 IF Y%<4 THEN Y%=4:W%=-W%
  240 IF X%>WI%-1 THEN X%=WI%-1:V%=-V%
  250 IF Y%>HI%-2 THEN Y%=HI%-2:W%=-W%
  260 PRINT TAB(X%,Y%);CHR$(D%)
  270 FOR I%=1 TO G%
  280   IF X%=X%(I%) AND Y%=Y%(I%) THEN GOSUB 490
  290 NEXT I%
  300 IF X%=P% AND Y%=Q% THEN T%=1
  310 PRINT TAB(X%,Y%);CHR$(224);
  320 T%=T%-1
  330 PRINT TAB(0,2);"SCORE ";TS%;
  331 PRINT TAB(0,24);"TIME ";T%;"  ";
  340 IF T%>0 THEN GOTO 140
  350 IF B%>0 THEN PRINT TAB(5,5);"BONUS ";B%
  360 FOR C%=1 TO 5000:NEXT C%
  370 TS%=TS%+B%
  380 IF B%=0 THEN NB%=NB%-1
  390 IF NB%>0 THEN GOTO 100
  400 PRINT TAB(5,5);"PLAY AGAIN ? (Y/N)"
  410 INPUT Q$
  420 IF Q$="Y" THEN RUN
  430 VDU 23,1,1;0;0;0;:STOP
  440 IF W%=1 THEN D%=225
  450 IF W%=-1 THEN D%=226
  460 IF V%=-1 THEN D%=227
  470 IF V%=1 THEN D%=228
  480 RETURN
  490 S%=S%+1
  500 TS%=TS%+5
  510 X%(I%)=0
  520 Y%(I%)=0
  530 IF S%=G% THEN B%=T%/3:T%=1
  540 RETURN
  550 CLS
  560 COLOUR 3
  570 PRINT TAB(3,1);"BOUNCING BUG";
  571 PRINT TAB(0,23);"BUGS ";NB%;
  580 S%=0
  590 B%=0
  600 Z=Z+0.3
  610 T%=1000/Z
  620 FOR I%=1 TO G%
  630   COLOUR INT(RND(1)*2+1)
  640   GOSUB 800
  650   X%(I%)=X%:Y%(I%)=Y%
  660   PRINT TAB(X%(I%),Y%(I%));CHR$(229)
  670 NEXT I%
  680 GOSUB 800
  690 P%=X%:Q%=Y%
  700 COLOUR INT(RND(1)*2+1)
  710 FOR I%=1 TO WI%
  720   PRINT TAB(I%,3);"*";
  730   PRINT TAB(I%,HI%-1);"*";
  740 NEXT I%
  750 FOR I%=3 TO HI%-1
  760   PRINT TAB(0,I%);"*";
  770   PRINT TAB(WI%,I%);"*";
  780 NEXT I%
  790 RETURN
  800 X%=RND(1)*(WI%-1)+1
  810 Y%=RND(1)*(HI%-5)+4
  820 RETURN
  830 GOSUB 550
  840 GOSUB 620
  850 COLOUR 3
  860 PRINT TAB(0,2);"PRESS SPACE TO START"
  880 REPEAT UNTIL INKEY(-47)
  890 RETURN
  900 VDU 23,224,0,90,60,126,126,60,90,0
  910 VDU 23,225,129,90,60,126,102,36,66,129
  920 VDU 23,226,129,66,36,102,126,60,90,129
  930 VDU 23,227,129,90,60,14,14,60,90,129
  940 VDU 23,228,129,90,60,112,112,60,90,129
  950 VDU 23,229,28,62,62,28,8,42,28,8
  960 RETURN





EDIT: Sorry I forgot to mention the keys for the game and test programme are in the 'Q','A','O','P' configuration for Up, Down, Left, Right if anyone wants to play with it. Earlier I had it using Cursor Keys, though the game was doing something odd with the character movement, for example if you let go of the 'A' key the Character would Move Up instead of Continuing Down, likewise with 'O' and 'P' as well.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

I've been having a look at some further BBC BASIC games coded for the BBC which are using some unfamiliar Operating System Specific Commands, the main culprit in this case is *FX

I downloaded some pages of the BBC BASIC Manual which documents how *FX works, which follows a series of Numbers and in some cases a Second (or can even include a Third) parameter. The leading number relates to what operation to perform (the same way VDU operates), with the second option selecting a new state, in some of my examples it just has *FX followed by one number, which I suspect just resets back to default state.

One of the options I can perform in BBC BASIC for the CPC is *FX 15,1 which is the BBCs way to CLEAR INPUT.  The Short programme I posted above is a good example where a CLEAR INPUT type command is needed because once you exit the REPEAT...UNTIL loop all the Keyboard Input fills up along the BASIC Prompt. To fix that the following lines can be altered:


100 UNTIL INKEY(-47)
110 REPEAT UNTIL INKEY$(0)=""
120 VDU 23,1,1;0;0;0;


so now line 110 Clears the Keyboard Buffer.

The next function example is rather more complicated, which is "*FX 12,1" and "*FX 12", which handles the Keyboards auto-repeat delay. If I didn't know correctly it sounds very similar to the Amstrads SPEED KEY which reflects how many keystrokes are produced in a time frame. *FX 12 and *FX 12,1 which is used in the Touchdown Game from the Usborne book Computer Spacegames. *FX 12,1 is used at the beginning of the game and when the game Exits back to BASIC *FX 12 is used, which suggests it's returning the Computer back to it's default state.
In the BBC BASIC for CPC Text Document, there's nothing there about *FX and indeed it doesn't appear to be implemented, I'm unsure if BBC BASIC for the CPC is catering in some other way, for instance in the Text Document (just before section 5. The VDU emulator) is a set of OS related operations following a CALL address and some Entry conditions. In there is something called 'OSKEY: CALL &10F ; Time Limit in HL, returns Character in A, carry=0 if timeout occurred'. I was wondering if this could relate? It would be handy if it does because the alternative would be to use Firmware, which I'm not too thrilled about using since I'm in CP/M, the relevant Firmware appears to be KM SET REPEAT &BB39, but I could easily be mistaking that.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

mr.freeze

I was pleased to learn that the BBC Basic source code for CP/M (Z80) was released last month under a permissive license. Of course, none of the graphics/sound instructions are implemented.

See https://cowlark.com/2019-06-14-bbcbasic-opensource/index.html
Direct link to the source: https://github.com/davidgiven/cpmish/tree/master/third_party/bbcbasic

AMSDOS

This game comes from the 1982 Usborne Book Computer Spacegames which has 6 BASIC versions to it depending on which Computer you had, due to its use of Graphics. The BBC version is on page 34 of the book and upon inspection it's quite well written making use of BBC BASICs System Commands, Procedures and Graphical Commands. Because the CPC is different from a BBC and has BBC BASIC available, I wanted to see how this game would go when ported to the CPC Version of BBC BASIC, if anyone is interested in viewing the original game, the book can be downloaded from Usbornes website or viewed through Archive.org


Most of the changes I made for the CPC version were graphical and even after typing in this game I had to alter where the text was placed as well as the Procedure Bar which handles drawing 4 Bars along the Left Side of the Screen. This is because on a BBC it's Low-Res Mode is 20 characters by 32 Lines, and CPC only has a Max of 25 Lines. In addition this BBC game has some System Commands in the form of ¨*FX 12,1¨,¨*FX 12¨ and ¨*FX 15,1¨. The first 2 related to the Auto Repeat Sequence when a key is being pressed and the 3rd flushes the Keyboard Buffer which is the equivalent of CLEAR INPUT in Locomotive BASIC 1.1. I wasn't sure how FX function 12 would go, so I decided to leave those codes out and decide while playing the game to determine if they are warranted or not. Having played the game, I've decided they aren't important to try and translate, however I have included a routine to flush the keyboard.


Playing The Game


The original game used keys 'A' and 'D' to Accelerate or Decelerate Thrust, which is what I chose here, the best way I can describe playing the game is to use the Velocity as close to 0 in the Yellow a Fuel Indicator Line is present as well as Space Shuttle Height and the Last bar is how much Thrust. When the Velocity Line gets lower reduce Thrust (but not too much), if the Velocity Line goes below 0 it the Line Turns Green (this is bad) and your Space Shuttle Lifts. If you run out of Fuel it's not exactly Game Over, but you won't be able to use Thrust either and if Velocity gets to high, you Land with All Dead on Board. In the original game in Line 690 if V+v1 are over 8 then it's ALL DEAD otherwise it's considered a Safe Landing, in my version I've increased slightly to 10 and found that even that can be tricky, otherwise a fun little game.


Loading the Game

BBC BASIC for the CPC runs in CP/M, so CP/M needs to be booted, either CP/M will work, but found CP/M Plus removes the hassle of Telling the Computer to Change disks all the time.
-> Once CP/M Plus has loaded that disc can be removed and the BBC BASIC for CPC can be Inserted.
-> BBCBASIC will load BBC BASIC, then that disk can be removed and my attached DSK can be Inserted  ???
-> The game can be loaded with LOAD"TCHDOWN.BBC", type RUN to play, the game starts Immediately.


BBC BASIC for the CPC Source Code



   20 MODE 5
   30 VDU 23,1,0;0;0;0;
   40 PROCSETVAR
   50 PROCDISPLAY
   60 PROCMODULE(H,3)
   70 PROCBAR(1,F,3+2*(F<25))
   80 PROCBAR(2,ABS(V),3+(V<0))
   90 PROCBAR(3,H,3+2*(H<25))
  100 PROCBAR(4,T,3)
  110 PROCTHRUST
  120 V1=V-T/20+G : F=F-T/10
  130 H1=H-(V+V1)/10
  140 PROCMODULE(H,0)
  150 IF H1<0 THEN 200
  160 H=H1:V=V1
  170 IF H<=75 THEN 60
  180 PROCLOST
  190 GOTO 220
  200 PROCMODULE(0,2)
  210 PROCLANDED
  220 VDU 23,1,1;0;0;0;
  230 END
  240 DEF PROCSETVAR
  250 H=75:F=100:T=0
  260 V=5+RND(10)
  270 G=(RND(40)+40)/100
  280 ENDPROC
  290 DEF PROCDISPLAY
  300 MOVE 800,30
  310 FOR X=800 TO 1280 STEP 16
  320   DRAW X,10+RND(40)
  330 NEXT
  340 PRINT "GRAVITY=";G
  350 PRINT "FUEL:"'''"VEL:"
  360 PRINT ''"HEIGHT:"'''"THRUST:"''
  370 ENDPROC
  380 DEF PROCMODULE(H,C)
  390 GCOL 0,C
  400 Y=H*8.5+150
  410 MOVE 1040,Y : PLOT 1,-40,-40
  420 PLOT 1,-8,-60 : PLOT 1,96,0
  430 PLOT 1,-8,60 : PLOT 1,-40,40
  440 ENDPROC
  450 DEF PROCBAR(N,V,C)
  460 Y=808-96*N
  470 GCOL 0,C
  480 MOVE 0,Y : MOVE 0,Y-16
  490 PLOT 85,V*4,Y : PLOT 85,V*4,Y-16
  500 PLOT 87,400,Y : PLOT 87,400,Y-16
  510 ENDPROC
  520 DEF PROCTHRUST
  530 REPEAT UNTIL INKEY$(0)=""
  540 IF INKEY(-69) THEN T=T+4 : IF T>100 THEN T=100
  550 IF INKEY(-61) THEN T=T-4 : IF T<0 THEN T=0
  560 IF T>F THEN T=F
  570 ENDPROC
  580 DEF PROCLOST
  590 CLS
  600 FOR I=1 TO 20
  610   VDU 31,RND(19),RND(25),42
  620 NEXT
  630 PRINT TAB(4,13)"LOST IN SPACE!!"
  640 ENDPROC
  650 DEF PROCLANDED
  660 VDU 28,0,31,11,0,12
  670 PRINT '"LANDED"
  680 PRINT '"AT VEL ";INT((V+V1)*5)/10
  690 IF (V+V1)<10 THEN PRINT '"SAFELY" ELSE PRINT '"ALL DEAD"
  700 ENDPROC
                                                     



Screenshot followed by Attached DSK Image
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

ComSoft6128

#15
Hi,

I made this video last weekend and thought to delete it but having read this thread it occurs to me that if the original BBC BASIC listing can be located it might be interesting to compare the two files.

The top of the globe is not visible in the video, I think this is because normally you would have to RUN "DISC.SDM" first. That program increases the size of the CPC screen in the vertical axis in a similar fashion to the "Mission Genocide" game, but unfortunately it causes the OSSC to lose sync which means no recording is possible.

https://www.youtube.com/watch?v=ZpA0B4iveR4&feature=youtu.be

AMSDOS

Quote from: ComSoft6128 on 18:11, 06 July 19
Hi,

I made this video last weekend and thought to delete it but having read this thread it occurs to me that if the original BBC BASIC listing can be located it might be interesting to compare the two files.

The top of the globe is not visible in the video, I think this is because normally you would have to RUN "DISC.SDM" first. That program increases the size of the CPC screen in the vertical axis in a similar fashion to the "Mission Genocide" game, but unfortunately it causes the OSSC to lose sync which means no recording is possible.

https://www.youtube.com/watch?v=ZpA0B4iveR4&feature=youtu.be


Thanks to the programme I was able to locate the original which is from Beebug January/February 1986 (vol 4. no 8) issue as shown on the Front Cover. The Magazine is in PDF format, I'm not sure how they would take it if I started Copying and Pasting Images, but at least it can be Downloaded if you want to check the source. I took a Snapshot from the original and as shown more of the globe is visible, I think with that it would be possible to stretch the CPCs screen which from memory would reduce the width of the screen in order to increase the height of it.
In the Touchdown game above I decided to leave the screen as is and merely adjust the game to fit within the 25 columns, eventually I'll get around writing a Locomotive BASIC version unless someone beats me to it, at this stage I juggling with other programmes which I would like to Improve.



* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Fessor

@AMSDOS:I dont think, that a port is needed; maybe only a translation to english:
http://cpc-power.com/index.php?page=detail&num=4135

AMSDOS

Quote from: Fessor on 07:47, 07 July 19
@AMSDOS:I dont think, that a port is needed; maybe only a translation to english:
http://cpc-power.com/index.php?page=detail&num=4135


I'm familiar with the Digiglobe programme, unfortunately it appears to be a different programme from the one shown in @ComSoft6128 video :(
Just thought a port of the Touchdown game to Locomotive BASIC would save the hassle of booting CPM/BBC BASIC to load and play the game.  ;D
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Powered by SMFPacks Menu Editor Mod