[comp.sys.acorn] 8-bit Graphics screen standards

patrick@sideways.gen.nz (Pat Cain) (01/21/91)

vac122g@monu6.cc.monash.edu.au (Daniel Bowen) writes:

> Otherwise I suppose an option is to work-out the format from the
> original listings, and re-write a program to read/write them,
> but it would be a bit of a pain.

Actually, someone at this site recently disassembled the LDPIC
program and is currently in the process of rewriting it.  Below
is a text file that he initially wrote about it.

Someone else here is writing a reader for other 8bit machines.

I am not sure what changes were made to the program below to
'improve' it.

You can e-mail the author: terros@sideways.gen.nz


Disassembly of *LdPic utility.

Commented (and improved) by D. Sainty
=====================================

JSR openfile

LDA #&01:STA &73
JSR get8:STA &7A
JSR get8:STA &7B

JSR getmode     ; get current mode, leaves mode unchanged if possible to get
                ; the overwrite effect. retun current mode in A.
CMP &7B:BEQ inmode
JSR selectmode  ; MODE A

; mode 0 = 640x256 2 colour
; mode 1 = 320x256 4 colour
; mode 2 = 160x256 16 colour
; mode 3 = text screen, wont be used
; mode 4 = 320x256 2 colour
; mode 5 = 160x256 4 colour
; mode 6 = text screen, wont be used
; mode 7 = teletext screen, unlikely to be used

.inmode JSR screenstart ; A = start page of screen
STA &7D

LDX #&0F
.colours TXA:PHA
LDX #&04:JSR getbits:TAX
PLA
JSR setcolour   ; set colour A to display colur X
; colour 0 = black
; colour 1 = red
; colour 2 = green
; colour 3 = yellow
; colour 4 = blue
; colour 5 = magenta
; colour 6 = cyan
; colour 7 = white
; in modes without 16 physical colours, ignore initial colours, eg in mode 0
; ignore colours 2-15 when set.

TAX:DEX:BPL colours

JSR get8:STA &7E:STA&7F
JSR get8:STA &88

.mainloop LDA &7F:SEC:SBC #&01:STA &70
LDA&7D:STA&71

JSR getc
BCC typeb

LDX &88:JSR getbits:STA &77
LDX &7A:JSR getbits:STA &78
.loop8 LDA &78:STA (&70):JSR add
DEC &77:BNE loop8
BEQcheckend

.typeb LDX &7A:JSR getbits:STA (&70):JSRadd

.checkend LDA &71:CMP#&80:BNE &2EA7

DEC &7F:BEQ end
JMP mainloop

.end JMP closefile

.getc DEC &73:BNE inbyt
JSR getbyte     ; get a byte from file in A.
STA &74
LDA #&08:STA &73
.inbyt ASL &74:RTS

.get8 LDX#8
.getbits STX &79
LDA #&08:SEC:SBC &79:STA &79
LDA #&00:STA &76
.loop JSR getc
ROR &76:DEX:BNE loop
LDX &79:BEQ over
.loop2 LSR &76:DEX:BNE loop2
.over LDA &76:RTS

.add LDA &70:CLC:ADC &7E:STA &70:BCCrts:INC&71
.rts RTS

; BBC screen format

The bbc screen memory is displayed in rows of 8 bytes. the first 8 bytes of the
screen display the first character, in the top left, (in a 2 colour mode).
The second 8 display the next character to the right. The next line starts in
memory where the first row ends. therefore, the first rastor line is made up
of the first byte, the 8th, the 16th, to the end of the character row.

Colours:

in 2 colour modes, a bit with value 0 signifies colour 0, bit value 1 signifies
colour 1. each bit maps onto one pixel.


in 4 colour modes, 2 bits map onto each pixel. each byte is four pixels wide.

pixel 0 = colour (bit 7 * 2 + bit 3)
pixel 1 = colour (bit 6 * 2 + bit 2)
pixel 2 = colour (bit 5 * 2 + bit 1)
pixel 3 = colour (bit 4 * 2 + bit 0)


in 16 colour modes, 4 bits map to each pixel. each byte is 2 pixels wide.

pixel 0 = colour (bit 7 * 8 + bit 5 * 4 + bit 3 * 2 + bit 1)
pixel 1 = colour (bit 6 * 8 + bit 4 * 4 + bit 2 * 2 + bit 0)
---------------------------------------------------------------------------
--
Patrick Cain, Private Box 2060, Wellington, New Zealand.