EasyManuals Logo
Home>Sinclair>Desktop>ZX Spectrum

Sinclair ZX Spectrum User Manual

Sinclair ZX Spectrum
82 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #43 background imageLoading...
Page #43 background image
Chapter 4
41
10 OUT 32735,20
20 DEF FN p(c)=INT (c/8):
DEF FN i(c)=c-8*FN p(c):
DEF FN b(c)=32*FN p(c)+FN i(c)
30 FOR c=0 TO 63
40 OUT 254,FN b(c)
50 PAUSE 25
60 NEXT c
70 GO TO 30
The program cycles through all available colours. DEF FN statements are used to
simplify the process of translating the 64 colour palette into a value to output to I/O
port 254 ($FE).
The multiple screen mechanism can be controlled when in any of the row based
attribute modes that use single byte colour, i.e. 8x8 SB, 8x8 SE, 4x8 SB and 4x8 SE. It
can be used to just store a screen image for display later, or it can be used to
implement a double buffer mechanism. The following program demonstrates this latter
use and displays screens of random numbers one after the other. To see the effect of
screen buffering, uncomment lines 10 and 60. Line 10 selects screen bank 0 for
display and screen bank 1 to shadow the Spectrum's lower 16K RAM bank. Line 60
reverses this to select screen bank 1 for display and screen bank 0 to shadow the
Spectrum's lower 16K RAM bank.
10 REM OUT 32735,64
20 CLS
30 FOR r=0 TO 20
40 PRINT RND
50 NEXT r
60 REM OUT 32735,32
70 CLS
80 FOR r=0 TO 20
90 PRINT RND
100 NEXT r
110 IF INKEY$="" THEN GO TO 10
120 OUT 32735,0
With screen buffering enabled, the process of printing to the screen becomes invisible
to the user. The program still takes the same length of time to output the random
numbers but the visual result can be more pleasing to the eye. To terminate the
program, hold down any key and the program will end by reverting to the standard
display mode.
It may be desirable for a program to adjust its output depending upon whether the
new display modes of the SPECTRA interface are available or not. The following
program demonstrates how this can be achieved from BASIC:
10 OUT 32735,16
20 PRINT "New display modes: ";
30 IF IN 32735<>16 THEN PRINT "not ";
40 PRINT "available"
50 OUT 32735,0

Table of Contents

Other manuals for Sinclair ZX Spectrum

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Sinclair ZX Spectrum and is the answer not in the manual?

Sinclair ZX Spectrum Specifications

General IconGeneral
BrandSinclair
ModelZX Spectrum
CategoryDesktop
LanguageEnglish

Related product manuals