BeebControl>>Interfaces>>Clare software


     Clare home  

How Control Logo works

The BBC Micro version of AUCBE's Control Logo software caters for three different flavours of Logo - from Acornsoft, Logotron and LSL. When the disc is shift/booted, a screen menu prompts the user to specify which of the three is already installed before loading the appropriate combination of machine-code driver and Logo extensions. A check is also made for the presence of B+/Master shadow ram and this is taken advantage of where found.

Using the Clare board with languages other than Logo

Personally I'm not a big fan of Logo and its 'black box' approach, so the first thing I did was to look at how I could use the Clare board from Basic. The key to this is the standard machine-code driver that interfaces with all three sets of Logo extensions. There appear to be three BBC B versions of the driver on the disc (postfixed with '1') and two Master versions (prefixed with an 'M'), but in fact they're identical bar their load/execute addresses. Presumably the load address varies according to which memory areas the corresponding version of Logo is likely to leave free.

Each set of Logo extensions installs a number of new logo commands (the Control Logo set) which correspond to the commands needed to drive the Clare board. The Logo commands peek and poke values into data space in the machine-code driver and then CALL its execution address. By mimicking the action of each of the Logo extension command 'procedures' with versions written in Basic, it should be possible to usurp the driver and run the Clare board via Basic (or any other programming language).

How the driver works

Taking the "LCSI1" driver as an example. The driver is loaded at &1500 and leaves room between &1503 and &1510 for up to fourteen bytes of data to be passed to/from the Logo commands. When the driver is CALLed via &1500 it first JMPs over this data space to &1511, saves the registers to the stack, sets up the parallel port data lines as outputs and the user port data lines as inputs and then checks the byte at &1504 to determine what action it's being asked to perform and which subroutine it should therefore branch to. Once we know the assignment of each of the data space locations, the relevant data can be inserted or retrieved via Basic procedures rather than the Control Logo command routines.

Examination of one of the Control Logo scripts will reveal which data is required in which location to control each function on the board. You will see that SENSORS is the key procedure as it CALLs the driver code once the correct data has been set up by other procedures. (EXAMINE is equivalent to peek and DEPOSIT is equivalent to poke.)

"LSCI" script file from Control Logo disc

(Note that CTRLB is set to &1500 in a previously EXECed "L.BBC" file)

................

TO COUNTDOWN :BIT :TARGET
IF :TARGET < 1 [STOP]
.DEPOSIT :CTRLB + 8 REMAINDER :TARGET 256
.DEPOSIT :CTRLB + 9 INT DIV :TARGET 256
SENSORS 7 :BIT
END

TO COUNTBIT :BIT :START :END
.DEPOSIT :CTRLB + 7 :BIT
.DEPOSIT :CTRLB + 8 :START
IF :END < 0 [.DEPOSIT :CTRLB + 9 0 - :END SENSORS 8 1] [.DEPOSIT :CTRLB + 9 :END SENSORS 8 0]
OP ( .EXAMINE :CTRLB + 13 ) * 256 + .EXAMINE :CTRLB + 12
END

TO HELLOWORLD
.DEPOSIT :CTRLB + 3 0
.DEPOSIT :CTRLB + 15 8
SENDPORT 0
END

TO LASTOUT
SENSORS 2 2
OP .EXAMINE :CTRLB + 6
END

TO TURNONLIST :LST
IF EMPTY? :LST [STOP]
SENSORS 4 FIRST :LST
TURNONLIST BF :LST
END

TO TURNON :LST
IF NUMBER? :LST [SENSORS 4 :LST STOP]
IF LIST? :LST [TURNONLIST :LST STOP]
PRINT ( SE [TURNON DOESN'T LIKE] :LST [AS INPUT] )
END

TO TURNOFFLIST :LST
IF EMPTY? :LST [STOP]
SENSORS 5 FIRST :LST
TURNOFFLIST BF :LST
END

TO TURNOFF :LST
IF NUMBER? :LST [SENSORS 5 :LST STOP]
IF LIST? :LST [TURNOFFLIST :LST STOP]
PRINT ( SE [TURNOFF DOESN'T LIKE] :LST [AS INPUT] )
END

TO STATELIST :LST :RESULT
IF EMPTY? :LST [OP :RESULT]
SENSORS 6 FIRST :LST
MAKE "RESULT SE :RESULT .EXAMINE :CTRLB + 6
OP STATELIST BF :LST :RESULT
END

TO STATE :LST
IF NUMBER? :LST [SENSORS 6 :LST OP .EXAMINE :CTRLB + 6]
IF LIST? :LST [MAKE "RESULT [] OP STATELIST :LST :RESULT]
PRINT ( SE [STATE DOES NOT LIKE] :LST [AS INPUT] )
END

TO HELLOCLARE
.DEPOSIT :CTRLB + 3 1
MAKE "X 15
REPEAT 8 [SENSORS 0 :X SENSORS 3 0 MAKE "X :X - 1]
SELECT [SWITCHES BARS]
END

TO SENSORS :DEV :VAL
.DEPOSIT :CTRLB + 4 :DEV
.DEPOSIT :CTRLB + 5 :VAL
.CALL :CTRLB
END

TO READPORT
SENSORS 1 1
OP .EXAMINE :CTRLB + 6
END

TO SENDPORT :X
IF NOT NUMBER? :X [PRINT [INPUT TO SENDPORT SHOULD BE A NUMBER] STOP]
SENSORS 3 :X
END

TO ECHO
SENDPORT READPORT
ECHO
END

TO SELECT :X
IF LIST? :X [SELECTLIST :X STOP]
IF EQUAL? :X "INBUS [SENSORS 0 0 STOP]
IF EQUAL? :X "SWITCHES [SENSORS 0 1 STOP]
IF EQUAL? :X "HEAT [SENSORS 0 6 STOP]
IF EQUAL? :X "HEAT2 [SENSORS 0 4 STOP]
IF EQUAL? :X "LIGHT [SENSORS 0 7 STOP]
IF EQUAL? :X "LIGHT2 [SENSORS 0 5 STOP]
IF EQUAL? :X "OUTBUS [SENSORS 0 8 STOP]
IF EQUAL? :X "BARS [SENSORS 0 9 STOP]
IF EQUAL? :X "SOUND [SENSORS 0 13 STOP]
IF EQUAL? :X "BULB [SENSORS 0 12 STOP]
IF EQUAL? :X "SEG7 [SENSORS 0 10 STOP]
IF EQUAL? :X "MOTORS [SENSORS 0 11 STOP]
PRINT SE :X [IS NOT A DEVICE]
END

TO SELECTLIST :X
IF EMPTY? :X [STOP]
SELECT FIRST :X
SELECTLIST BF :X
END

MAKE "CTRLB 54016

................

Greg Cook has kindly posted a copy of the LCSI Logotron reference guide so you can use it to analyse the syntax above if your Logo is as rusty as mine. (Ain't the Web wonderful?)

Finally, the following section from the Clare Technical Manual may help further:

"Some of you will want to know how the board works. You will have realised that the micro has 8 input lines and 8 output lines, so how do we manage to send out 8 bits of data and also select the correct device?

When the command SENDPORT is used, the current output device is sent the parameter value, which is latched into it so that it will remain even if other values are sent to other devices.

This is achieved by splitting the data into two pieces (nibbles) and combining them into bytes with the code representing the address of the required device.

These two bytes are then sent out one after the other. On arrival at the board, the data nibble is stored in a latch whilst the device address is used to activate the required destination device.

When the procedure READPORT is used, the device address is first sent out to the board. This allows the data from the selected device through to where it can be read by the READPORT operation."


Using a Clare board with other micros

If you have a version of Control Logo for a different micro (e.g. Nimbus, RM 380Z/480Z, Spectrum), the chances are a similar code interaction mechanism will be at work if you examine the driver and script files on your disc closely. You can then program equivalent procedures in a language to suit your micro, letting you control your Clare board independently of Logo.




<< Clare home
All content on this website is Neil Fazakerley or its originators