PC Graphics on Spectrum

Author(s): Andreas Schraepel
Publication: LISTing Newsletter
Date: March 1996
Pages: 9-10

Submitted by John Pazmino

[From COMP.SYS.SINCLAIR with minor editing by John Pazmino. Mr Schraepel is at [e-mail address omitted]. This conversion utility is designed ONLY for the Z90 Spectrum emulator, which has the facility to attach its Interface serial port to a file.]

I did a simple program to convert PC-pictures to the Spectrum last January [1995]. I just got my copy of Z80-3.02 [Spectrum emulator for the IBM] and wanted to try its features. You have to create some B/W PCX-files for it (256×192 of course). I suggest the wonderful PAINT SHOP PRO for Windows for this. [PCX is one of the standard Windows graphics formats accepted by Paintbrush.]

It’s just a Sinclair BASIC program, but it works fine! And a nice work for you to type in the following BASIC. Fire up the emulator, switch on Interface 1, type in the following listing, save it! Then connect your PCX file to the “RS232 Input”. [That is, assign this port to the PCX filename.] Execute the program.

  0 REM No binaries allowed here. [A reminder to Internet
callers that this is a program for offline use, not
as an approval to post PXC files on COMP.SYS.siINCLAIR.]
1 DEF FN m(z,s,r)=16384+2048*INT(z/8)+32*(z-8*
INT (z/8))+256*r+s:REM [Get this code correct or else!]
2 DEF FN a(x,y)=USR 30000
3 FORMAT "b";19200:CLEAR 29999:CLS #:INPUT
" *PCX to SCREEN converter*"'''"Give
me a name for the"'"outputfile.."'"The
picture will be saved"'"after conversion
"''"Name:"; LINE n$
4 INPUT " *PCX to SCREEN converter*"'''
"Now connect your 256*192*2 PCX- picture
to the RS232/Disk-Input.Then select the
colours for the picture by the following
three INPUTs. Thereafter reading and
conversion will start.."''"Select value
for INK (0-7)";ink'"PAPER (0-7)";pap'"
BRIGHT (0 or 1) ";bri''
5 BRIGHT bri: BORDER 6:PAPER pap: INK ink:
CLS:PRINT #0;AT 0,0;BRIGHT bri; PAPER pap;
INK ink;CHR$ 6;CHR$ 6;CHR$ 6;CHR$ 6:DATA
221,42,11,92,221,126,4,221,166,12,79,221,
126,5,221,166,13,71,201:FOR f=30000 TO 30018:
READ w: POKE f,w:NEXT f
10 CLEAR #: OPEN #4;"b"
20 DIM h(128):FOR f=1 TO 128:LET h(f)=CODE
INKEY$#4:NEXT f:REM This gets the PCX-header in h()

The following two lines are unused.[They can be missed out.]

 30 LET pwidth=h(9)+256*h(10)+h(5)+256*h(6)+1
32 LET phgt=h(11)+256*h(12)+h(7)+256*h(8)+1

89 REM get the bytes If the PCX contains many
informations, the second value (46144) is not big
enough. Try 50000 or more.:
90 FOR f=40000 TO 46144:POKE f,CODE INKEY$#4:NEXT f
[^^^^^\this number]
99 REM Conversion part
100 LET from=40000:LET ct=0
120 FOR k=0 TO 23:FOR i=0 TO 7:FOR j=0 TO 31

150 REM FN a(value1,value2) is an logical AND
160 IF NOT ct AND FN a(192,PEEK from)=192 THEN
LET ct=FN a(63,PEEK from)

165 REM FN m() translate to ZX screen/memory format
170 IF NOT ct THEN POKE FN m(k,j,i),PEEK from:
LET from=from+1:GO TO 190
185 POKE FN m(k,j,i),PEEK (from+1):LET ct=ct-1:
IF NOT ct THEN LET from=from+2
190 NEXT j: NEXT i: NEXT k

199 REM save the work. The "Start Tape" message destroys
the lower two textlines. Use either saving to micro
drive (SAVE *"m";1;n$SCREEN$) or save the result as
a SCR file from the emulator. [That is, save this SCREEN$
by the emulator's special menu selection.]
200 SAVE n$ SCREEN$

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.