James Cat's rough && ready blog

5th A&B computing article > Machine Code Capers #1

Posted in 6502 by zzjames on January 24, 2013

This article explains that doing graphics on the BBC micro consist solely of pushing a byte stream to the VDU controller (built around a Motorola 6845 CRT controller chip) . It takes the same program, one written using basic commands (move, draw, print, colour, gcol) and rewrites it first using the BASIC vdu statements, one for each of the previous commands, then rewrites it again showing the BASIC vdu command used to create the bytestream from a look up table set up by BASIC read/data statements. Finally we see the same BASIC read/data statements used in conjunction with OSACI (the OS routine at &FFE3) to achieve the same effect. Although this features no sprites or image composition it does show data being read from a table and used for graphics.

lc-p132


REM PROGRAM 5

REM bytes to shoot at the VDU controller
DATA22,2,18,0,1,25,4,100,0,144,1,25,4,176,4,144,1
DATA25,85,100,0,88,2,25,85,176,4,88,2,17,132,17,6
DATA31,5,16,32,86,68,85,32,68,69,77,79,32,13,255

P%=&0C00
REPEAT
READI%:?P%=I%:P%=P%+1
UNTIL I%=255

OSASCI=&FFE3 :REM store address of os routine for readability
FOR O = 1 TO 3 STEP 2
P%=&0C80
[
OPT O
.GRAF
\ routine to output vdu sequence
STX&71 \ address high byte (data starts at &0c 00)
LDA#0
STA&70 \ address low byte
.LOOP
LDA(&70),Y \load character
CMP #&FF \ check end of sequence
BEQ RTRN
JSR OSASCI \ output character
INY \ increment the index
BNE LOOP \ check page boundary
INC &71 \ inc page if boundary crossed
JMP LOOP
.RTRN RTS
]
NEXT O

X%=&C:Y%=0:CALL&0C80
END

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: