MODIFYING BBC MICRO PROGRAMS FOR RISCOS ON THE RASPBERRY PI

PROGRAM REQUIREMENTS
Not all BBC micro programs will run natively under RISCOS on the Raspberry Pi. Any programs which use machine code are generally not going to be suitable though there might be some exceptions, which will be discussed later.

Programs written wholly in BASIC 2 or BASIC 4 will be good candidates for running on the Raspberry Pi.

 

PROBLEMS WITH BASIC PROGRAMS FROM THE BBC MICRO
Very few programs for the BBC micro have been well written. Programmers often will have had to be very creative to get programs to work in the limited amount of memory available on the BBC micro and may have used 'short cuts' to get things working.

 

PAGE
PAGE is a system variable in the BBC micro which holds the memory address of the start of the current BASIC program. A basic Tape machine has PAGE at &E00 and a basic Disc machine has its PAGE at &1900. Disc machines have less memory available than Tape machines and many programs will load at &1900 from disc and then switch the file system to Tape, set PAGE to &E00 and move the program down in memory to the new PAGE and then run it.

Other programs will change the value of PAGE as they run, sometimes having two or more working programs in memory at once, switching between them by changing the value in PAGE.

On a Raspberry Pi the value of PAGE will be completely different and if it is set to match a BBC micro value the Pi's memory will be corrupted.

Thankfully the Raspberry Pi has much more RAM available than on a BBC micro, which means that changing PAGE to make a program work will not be needed. There will be no need to move a program down in memory. All references to PAGE can usefully be removed and the program will still work on the Pi.

 

DIRECT MEMORY ACCESS
BBC micro programmers very frequently use direct memory access for storage of data, pointers, etc. In the BBC micro memory locations at &900, &A00, &C00 and in the range &70 to &8F can generally be used safely, if user defined characters are not being used (these use memory at &C00).

These locations are not available in RISCOS.

This memory access can be accommodated in RISCOS by the following method, assuming the area at &900 is being referenced. At the start of the program add the line

xxxx DIM M900 256

where xxxx is the program line number. This line reserves 256 bytes of memory and the start address of this is stored in the variable M900. To reference this memory change all occurrences of ?&9xx to M900?xx, $&900="..." to $M900="..." and so on.

 

USER DEFINED CHARACTERS
BBC programs which have user defined characters are sometimes written badly and must be changed. Programmers often load character definitions directly into &C00 to avoid having to use lots of VDU23 ... commands to define them, thus saving memory. This is bad practice and only works on a BBC micro models A, B or B+. Under RISCOS a procedure must be written to read the character definitions from the file that would be loaded and issuing the appropriate VDU23 ... commands to define the graphics.

Another 'trick' used by some programmers was to use VDU128 to display the user character 224. This worked on a BBC micro because its operating system would treat characters in the range 128 to 159 as characters 224 to 255. Characters 128 to 159 could be obtained by pressing the appropriate function key when entering the program and this saved memory. When converting such a program to run in RISCOS all references to characters in the range 128 to 159 could be changed to be in the range 224 to 255. This is tedious. A quicker method is sometimes possible and that is to define characters 128 to 159 to be the same as characters 224 to 255.

 

TIMING
When moving BBC micro programs to the Raspberry Pi there is a massive increase in speed. The effect of this is that some programs may run too quickly to be usable, especially those which move things on screen. If the program is written correctly and uses timing loops derived from the system clock then the program should run as intended. Sometimes programmers used FOR ... NEXT loops to time events. These will not work and will need to be changed.

For RISCOS only use the keyword WAIT could be used for delays but for backwards compatibility a delay procedure should be written or the INKEY() keyword used.

 

CURSOR
Many programs disable the cursor unless input is required. The usual way to do this is to use a VDU23 command to program the video processor. This does not work on RISCOS and the keywords OFF and ON used instead.

 

COLOURS
The BBC micro has 8 screen modes available each with a different colour set. MODE7 is different in the way it uses colour and an excellent MODE7 emulator has been built into RISCOS. This works just as expected.

All the other BBC modes on the Raspberry Pi are 64 colour modes. This means that the colour numbers for BBC programs will be different when run on the Pi. There is no way around this but to change the colour numbers. Generally 8 variables are defined to hold the colour numbers and used where necessary. When red is needed, which is colour number 1 on the BBC micro, the variable Red% is used instead; this is actually colour number 3 on the Pi.

VDU19 commands to change the colour shown for a particular logical colour in a mode will not work. The actual colour must be used in its place.

Programs which rely on the effects of GCOL3,x may not work correctly. There is no work around for this problem as RISCOS does not use colours from a pallette as does the BBC micro.

 

FX COMMANDS
Many of the most common FX commands work as expected. The ones that do not are usually linked to the BBC micro's hardware. Sometimes a RISCOS SYS call can perform the same task as an FX call. FX calls that are not implemented on the Pi are just ignored.

 

OPERATING SYSTEM CALLS
Some of these are implemented by RISCOS but most are not. There are, however, equivalent SYS calls to accomplish the same effect.

 

6502 MACHINE CODE
Some BASIC programs on the BBC use small machine code routines to achieve an effect. In general these will not work under RISCOS. It may be possible to translate the 6502 programs into ARM programs, rewrite the assembler routines and use them that way.

Any programs that *LOAD machine code to a particular memory address will not work on RISCOS.

In many cases, due to the speed of the Raspberry Pi, converting the machine code routine to BASIC will prove to be satisfactory.

 

   
   
Home
   
© 2018 - 2024 flaxcottage.com