Pablo Pixel-O

A SUPERB HIGH-RESOLUTION GRAPHICS-DESIGN PROGRAM FOR THE ZX-81/TS 1000 PLUS AN EXPANDED AND VERSATILE VERSION FOR THE T/S 2068…

example 1 (crescent moon, stars and clouds)
example 1 (crescent moon, stars and clouds)

I have thoroughly enjoyed my ZX-81 for years. I have added a full-size keyboard, 64k of memory and the Timex/Sinclair 2040 Printer. I’ve always lamented the lack of high-resolution graphics, but have never felt compelled to invest the extra money for the needed hardware or s/w. The following program will allow you to use your ZX-81/TS 1000/1500 and either the Sinclair or Timex Printer to create high-resolution graphics (see examples 1-4). Good-bye “blocky” pictures!

The characters of the ZX-81 are generated using an eight by eight grid. Each line of this grid is stored as a binary number in the ROM (addresses 1E00h to 1EE7h). IF you were to PEEK the eight addresses for the letter “O” in the ROM, you would find the decimal/binary code in Fig. 1. For each “1” in the binary code, a pixel is set on the screen, producing the pattern “O”.

Due to the design of the ZX-81, only codes stored in the actual ROM can be generated onto the screen without the use of extensive machine code programming. By using the routines contained in lines 500-570 and 1000-1090 of listing 1, and a lifted version of the LLIST subroutine from the ROM, any eight by eight character can be generated via your printer.

USING PABLO PIXEL-O

The program is designed for you to draw a picture and create individual characters to produce a high-res copy of it. Graph paper which is ruled in eight by eight grids will help you map out your characters. Draw or trace your picture onto the graph paper. Next, darken each square (pixel) which is a line or solid/shaded element of your picture. (NOTE: if your picture does not contain an empty 8×8 grid, you may wish to define an extra “space” character to help you in formatting later on.) Total up the number of different characters (8×8 pixel grid) you will need to compose your picture. Now count up the number of characters in each line (a max. of 32) and the number of character lines in your picture. You may wish to design your picture sideways and create a long panorama, but it can only be 32 characters high.

You are now ready to LOAD the program and begin creating your own characters. Before LOADing, you will need to lower RAMTOP by entering “POKE 16389,124”, then followed by “NEW”.

fig. 1

dec     binary
  0 /  00000000
 60 /  00111100
 66 /  01000010
 66 /  01000010
 66 /  01000010
 66 /  01000010
 60 /  00111100
  0 /  00000000
fig. 1 pixel grid for the letter O
fig. 1 pixel grid for the letter O

DEFINING CHARACTERS

When the menu appears, choose option 1– “Define Characters” (see fig. 2). This will set up a blank array in which to store your data. Answer the prompt with the total you calculated earlier. You may wish to enter a total slightly higher than the amount of characters you wish to define, allowing for any errors or additions. When prompted, enter each line of the 8×8 grid as a space or an inverted space (GRAPHICS/SPACE…see fig. 3). When this character is produced by the printer, a pixel will be set (black) for each inverted space and unset (blank) for each space. If, after entering all eight lines, you are not satisfied, answer “NO” to the prompt and you will have the option of starting over for that character or changing individual lines. (Keep track of the order in which you define your characters as they are coded and stored in this order. Character code “1” is for the first character defined, code “2” the second defined, ect.) After you have completed your character definition, the screen will go blank for a few seconds while the computer analyzes and stores the data. If you would like to return to the menu during definitions, enter “M” as the first space in any line. This will allow you to check your progress or save your data. NOTE: To continue definitions, choose option 2 “Continue Definitions”, as option 1 will clear all data from memory!

fig. 2

++++     PABLO  PIXEL-O     ++++
 DEFINE CHARACTERS........1
 CONTINUE DEFINITIONS.....2
 PICTURE CODING...........3
 PRINT OUT PICTURE........4
 SAVE.....................5
 RE-DEFINE CHARACTER......6
 CONTINUE PICTURE CODING..7
 BIG-BITS.................8
  ENTER ONE OF THE ABOVE

SEEING IS BELIEVING

You can review a portion of your work with “Big-Bits”–option 8. This option will display up to eight enlarged characters across and six down, using the standard Sinclair graphics. (See example 5) When prompted to enter code numbers, enter the number for the character you wish displayed (remember, character 1 is the first character defined, 2 is the second, ect.). After entering the codes the screen will go blank while the computer stores this information on a “notepad”. You will then see an enlarged version of the characters in the order you specified. By pressing “M”, you can return to the menu, “Z” will make a copy of your enlarged characters on the printer. NOTE: The program uses part of the machine code stored in REM to set up the COPY routine in ROM, copying as many lines as are needed.

HARD EVIDENCE

To print a copy of your picture in high-resolution, choose option 3–“Picture Coding”. Follow the prompts, by inputting the totals you calculated for the width and height of your picture. You will again be asked to enter codes for the newly defined characters in the order to be printed. After entering all of the character codes, you will be returned to the menu. If you only wish to print out a portion of your picture, entering “0” for a character code will return you to the menu. You may return to coding the picture by choosing option 7–“Continue Picture Coding”. Option 4–“Print Out Picture” will produce a high-resolution picture via the printer. The monitor screen will go blank for a few seconds while the computer transfers data to a notepad, after which it will print out one line of your picture. This pattern will continue until all of the picture has been printed. After you have finished “coding” your picture, a copy can be obtained at anytime by going directly to option 4.

fig. 3 PLOT OUT CHARACTER 1
fig. 3 PLOT OUT CHARACTER 1

HOW DID THAT GET THERE?

If you would like to correct or re-define a character, option 6 will allow you to re-define any character you designate. Re-define a character by following the steps for defining, line by line.

PRESERVING THAT MASTERPIECE

Option 5 will save the program and any data already entered. NOTE: if you break the program, do not RUN, as this will erase all of the data entered. Continue by entering GOTO 600, putting you into the menu. When you reload the program, the menu will appear and you may continue from there.

ENTERING THE PROGRAM – TS1000 version

Before entering listing 1, lower RAMTOP by entering POKE 16389, 124 and NEW. Line 1 should contain 113 characters after REM. When you have finished typing in the program, it is prudent to save it to tape before RUNing the program. After you have made a back-up copy, enter FAST mode and enter GOTO 9000. This will load the machine code into the REM statement. This subroutine will check for most typing errors while entering the machine code contained in A$. After the code has been transferred to the REM statement, you may delete lines 9010-9170. To save this completed version to tape, set-up your recorder to record and start the tape, enter as direct commands, CLEAR and GOTO 3000. Remember, you will have to lower RAMTOP by POKEing 16389 with 124 before loading this program into the computer.

example 5 (big-bits)
example 5 (big-bits)

Listing 2 is a disassembled version of the machine code for the 1000 version. Addresses 16514-16529 contain the table holding the different graphic characters used by Big-Bits. The routine starting at 16530, looks at two lines of each character. It first looks at the first two bits in each line and calculates a matching character from the graphics character table, printing this graphic symbol. Then it moves on to the next two bits of each line, calculating and printing until all bits have been translated. This procedure is repeated until all eight lines of the character has been printed and then moves on to the next character. The routine at 16621 copies the screen to the printer. Register D is loaded with the number of screen lines to be copied. The routine then jumps into the ROM’s copy routine.

BY THE NUMBERS

Line 1:  Machine code for option 7 "Big-Bits"
Lines 2-3:  Initializes flags
Lines 5-60:  "Lifts" the LLIST routine from ROM and places it
             above RAMTOP with modifications.
Lines 100-130:  Initializes array to store new character coding.
Lines 180-345:  Accepts data for defined characters as a graphic
                binary code and changes the binary into decimal for storage.
Lines 350-390:  Allows for corrections before storage of data is made.
Lines 400-495:  Sets up picture array and accepts code numbers
                in the order you wish them printed.
Lines 500-565:  Converts and stores character codes for printing of picture.
Lines 600-670: Contains the menu.
Lines 700-740:  Sets up editing of already defined characters.
Lines 800-990:  Subroutine which sets up data for the machine
                code for Big-Bits.
Lines 1000-1090:  Stores the 8 lines of code for each character
                  to be printed for each line of your picture and calls the LLIST
                  routine store above RAMTOP.
Lines 2000-2040:  Saves the program with any data entered.
Lines 9010-9170:  Machine code loader.

Some of the Variables:

D(8):  Holds decimal code for individual lines of character being defined.
D$:  Blank line to mask or clear prompts printed to the screen.
I$(8,8): Accepts "plotted" version of character.
C:  Total amount of characters to be defined.
C$(C,8):  Stores CHR$ for the CODE of each line of defined
          characters. (By storing these codes in a string array we
          conserve memory. To store 100 characters using a numerical
          array would require 4K, opposed to 800 bytes using characters --
          i.e. the number 53 is stored as "P".)
W & L:  Width and Length, in characters, of you planned picture.
P(L,W):  Contains character code numbers in the order to be printed.
L(32,8):  Stores the eight lines of each character for printing
          of one line of the picture.
B(6,8):  Stores the character codes in the order to be displayed
         during Big-Bits option.
example 2 (man's face)
example 2 (man's face)
example 3 (house with FOR SALE sign)
example 3 (house with FOR SALE sign)
example 4 (tree in a circle)
example 4 (tree in a circle)

Listing 1

Listing 1 - TS1000 Pablo Pixel-O BASIC program, lines 1-990 (part 1)
Listing 1 – TS1000 Pablo Pixel-O BASIC program, lines 1-990 (part 1)
Listing 1 - TS1000 Pablo Pixel-O BASIC program, lines 1000-9170 (part 2)
Listing 1 – TS1000 Pablo Pixel-O BASIC program, lines 1000-9170 (part 2)

Listing 2

Address   Op Code (hex)   Mnemonic

16530 21007D LD HL,32000
16533 E5 PUSH HL
16534 E1 POP HL
16535 0E04 LD C,4
16537 0604 LD B,4
16539 56 LD D,(HL)
16540 23 INC HL
16541 5E LD E,(HL)
16542 23 INC HL
16543 E5 PUSH HL
16544 AF XOR A
16545 CB12 RL D
16547 17 RLA
16548 CB12 RL D
16549 17 RLA
16551 CB13 RL E
16553 17 RLA
16554 CB13 RL E
16556 17 RLA
16557 218240 LD HL,16514
16560 85 ADD A,L
16561 6F LD L,A
16562 7E LD A,(HL)
16563 2A0E40 LD HL,(16398)
16566 77 LD (HL),A
16567 23 INC HL
16568 220E40 LD (16398),HL
16571 10E3 DJNZ,16544
16573 D5 PUSH DE
16574 111D00 LD DE,29
16577 19 ADD HL,DE
16578 220E40 LD (16398),HL
16581 D1 POP DE
16582 E1 POP HL
16583 0D DEC C
16584 20CF JR NZ,16537
16586 E5 PUSH HL
16587 1180FF LD DE,65408
16590 2A0E40 LD HL,(16398)
16593 19 ADD HL,DE
16594 220E40 LD (16398),HL
16597 7E LD A,(HL)
16598 FE76 CP 118
16600 20BC JR NZ,16534
16602 116400 LD DE,100
16605 19 ADD HL,DE
16606 220E40 LD (16389),HL
16609 23 INC HL
16610 ED5B1040 LD DE,(16400)
16614 ED52 SBC HL,DE
16616 19 ADD HL,DE
16617 38AB JR C,16534
16619 E1 POP HL
16620 C9 RET
16621 1604 LD D,4
16623 CD6B08 CALL 2155
16626 C9 RET

2068 version

Listing 3 and 4 contain a version of PABLO PIXEL-O for T/S 2068 owners. There are a few enhancements in this version, made possible by the extended powers of the 2068 computer. Instead of storing our new characters in an array, we will store them in a table above RAMTOP and set the system variable pointing to the character table, to point to our new table (see line 125). Of course, we can have a screen display of our high-resolution picture. Also, when entering the codes for your printed picture, you are allowed the option of choosing seperate ink and paper colors for display. The POKE in line 220 sets the system variable controlling the cursor mode into graphics. Your REM statement in line 1 should contain 63 characters after REM. After entering the program, enter as a direct command, GOTO 9000. This will load the MC into the REM statement, checking for typing errors. You may then delete lines 9000-9199. Save the program by entering as direct commands, CLEAR and SAVE “pablo” LINE 10.

The program operates basically the same as the ZX-81 version. There is the added option of saving a copy of the screen after having displayed your picture. It is possible to define a new character set or font and point the system variables to point to this new set. (See the example 6) You may wish to incorporate this font into other programs.

example 6 (sinclair logo font)
example 6 (sinclair logo font)

Listing 3

Listing 3 - T/S 2068 Pablo Pixel-O BASIC program, lines 1-815 (part 1)
Listing 3 – T/S 2068 Pablo Pixel-O BASIC program, lines 1-815 (part 1)
Listing 3 - T/S 2068 Pablo Pixel-O BASIC program, lines 820-9135 (part 2)
Listing 3 – T/S 2068 Pablo Pixel-O BASIC program, lines 820-9135 (part 2)

Listing 4

Address   Op code (hex)   Mnemonics

26731 21D7FD LD HL,64983
26734 06C0 LD B,192
26736 C5 PUSH BC
26737 0604 LD B,4
26739 56 LD D,(HL)
26740 23 INC HL
26741 5E LD E,(HL)
26742 23 INC HL
26743 E5 PUSH HL
26744 AF XOR A
26745 CB12 RL D
26747 17 RLA
26748 CB12 RL D
26750 17 RLA
26751 CB13 RL E
26752 17 RLA
26753 CB13 RL E
26754 17 RLA
26757 215B68 LD HL,26715
26760 85 ADD A,L
26761 6F LD L,A
26762 7E LD A,(HL)
26763 D7 RST 10h
26764 10EA DJNZ,26744
26766 E1 POP HL
26767 C1 POP BC
26768 10DE DJNZ,26736
26770 C9 RET
26771 F3 DI
26772 06C0 LD B,192
26774 CD050A CALL 2565
26777 C9 RET

USE PABLO PIXEL-O AND SEND US YOUR ARTWORK!

Grey-scale pattern samples
Grey-scale pattern samples

TIME DESIGNS will publish examples of computer “art” using the PABLO PIXEL-O program supplied in this issue, in upcoming future issues. We may publish yours! Send artwork from either T/S 1000 or T/S 2068.

send to: TIME DESIGNS
29722 Hult Rd.
Colton, OR 97017

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