Customize Your Sign Designer

Author(s): Chia-Chi Chao
Publication: SyncWare News
Pub Details: SyncWare News v5 n1 (Volume 5, Issue 1)
Date: September/October 1987
Pages: 19-21

Most, if not all, of you should have heard about the famous Print Shop program for computers such as Apple and IBM. It is a graphics package which allows you to create cards, signs, and banners for various occasions. Well, how about our Timex Sinclair computers? Zebra Systems came to the rescue by putting out a series of programs similar to the Print Shop: Card Designer, Sign Designer, and Banner Designer. They are priced at $19.95 each, and they all have received good reviews.

I purchased a copy of Sign Designer some time ago, thinking that I could also create “small signs” to make cards. I found out that is not the case. Therefore, I decided to modify the program to shrink those full page signs.

Note: This conversion was written for and tested on Citizen MSP-10 (EPSON compatible) printer, but it should work for most other printers as well. Since I can not test this modification on other printers, you may find the result different from what is described here.

A pixel on the screen is converted to four pixels on the printout, doubled horizontally and vertically. In order to make a card, you don’t need that magnification. By examining the BASIC and machine language parts of Sign Designer, the printing routine was found and deciphered.

C1BE   CALL C20D   ;get bit pattern into register A
C1C1 PUSH AF ;save data on stack
C1C2 CALL C25E ;send to printer
C1C5 POP AF ;get it back
C1C6 PUSH AF ;send to printer again,
C1C7 CALL C25E ; to be
C1CA POP AF ; taken out
C1CB LD HL,BFC9 ;test for single/double density
C1CE BIT 0,(HL) ; bit set if double density
C1D0 JR Z,C1DA ; skip if single density
C1D2 PUSH AF ;send data to printer,
C1D3 CALL C25E ; to be
C1D6 POP AF ; deleted
C1D7 CALL C25E ;send to printer for the last time
C1DA rest of the routine

It is easy to reduce the horizontal pixels because the same data is just sent to the printer twice in a row (four times for double density mode). This can be accomplished by poking some zeros in the printing routine to take out the extra instructions.

XXOOXXOO                    XOXO
XXOOXXOO  -> converted to -> XOXO
OOXXOOXX                    OXOX
OOXXOOXX                    OXOX

For vertical pixels, a MC routine has to be added to process these data. Here is the simplified algorithm:

1. Calculate first pair of coordinates.
2. Get pattern #1.
3. Filter out unnecessary bits.
4. Calculate second pair of coordinates.
5. Get pattern #2.
6. Filter out unnecessary bits.
7. Combine the two patterns.
8. Send data to printer.
   XOXO
#1 XOXO  -> filter ->  XOXO
   OXOX                OXOX
   OXOX                                 XOXO
                          -> combine -> OXOX
   OXOX                                 OXOX
#2 OXOX  -> filter ->  OXOX             XOXO
   XOXO                XOXO
   XOXO

In order to create a card, two pictures should appear at opposite corners of a page, one normal and one upside down so that when the paper is folded, both designs are right-side-up. The above algorithm only shrinks the sign, so a further modification is needed to flip the picture. Suppose we have a 3 by 5 array:

    0 1 2 3 4              4 3 2 1 0

0   A B C D E          2   O N M L K
1   F G H I J    ==>   1   J I H G F
2   K L M N O          0   E D C B A

When the original program wants to print “A” in position (0,0), we actually want to print “O” in position (2,4). So, if (row,column) are the coordinates, we need (2-row,4-column) to reverse the array. In the Sign Designer, there are 356 rows and 216 columns stored in the computer, so we only need to change steps 1 and 4 of the algorithm a little to flip the picture.

Now let’s start modifying the Sign Designer. First, load the machine language part:

CLEAR 45739
LOAD ""CODE 45928,19606

We need to poke some numbers to change and delete some MC instructions.

POKE 49599,173   ;B2AD (CALL ENTRY)
POKE 49600,178 ;branch to our modification

POKE 49656,8 ;(LD BC,0008)

POKE 49601,0 ;delete the extra
POKE 49602,0 ;printing instructions
POKE 49603,0
POKE 49604,0
POKE 49605,0
POKE 49618,0
POKE 49619,0
POKE 49620,0
POKE 49621,0
POKE 49622,0

Then use a BASIC loader or an appropriate editor such as Hot-Z to enter the machine code routines. There are 174 bytes, so be patient.

10 FOR X=45741 TO 45914
20 PRINT X;" ";
30 INPUT A: PRINT A
40 POKE X,A: NEXT X

Values to input using the above loader

Address Dec Hex  Address Dec Hex  Address Dec Hex
45741 71  47    45806 197 C5    45871 246 F6
45742 58  3A    45807 213 D5    45872 4   04
45743 172 AC    45808 229 E5    45873 203 CB
45744 178 B2    45809 237 ED    45874 99  63
45745 254 FE    45810 91  5B    45875 40  28
45746 0   00    45811 116 74    45876 2   02
45747 120 78    45812 191 BF    45877 246 F6
45748 40  28    45813 33  21    45878 2   02
45749 56  38    45814 215 D7    45879 203 CB
45750 205 CD    45815 0   00    45880 115 73
45751 13  0D    45816 167 A7    45881 40  28
45752 194 C2    45817 237 ED    45882 2   02
45753 197 C5    45818 82  52    45883 246 F6
45754 213 D5    45819 34  22    45884 1   01
45755 229 E5    45820 91  5B    45885 201 C9
45756 205 CD    45821 179 B3    45886 14  0E
45757 225 E1    45822 237 ED    45887 0   00
45758 178 B2    45823 91  5B    45888 205 CD
45759 245 F5    45824 118 76    45889 98  62
45760 237 ED    45825 191 BF    45890 192 C0
45761 91  5B    45826 33  21    45891 237 ED
45762 118 76    45827 100 64    45892 75  4B
45763 191 BF    45828 1   01    45893 91  5B
45764 19  13    45829 167 A7    45894 179 B3
45765 19  13    45830 237 ED    45895 121 79
45766 19  13    45831 82  52    45896 203 CB
45767 19  13    45832 34  22    45897 56  38
45768 237 ED    45833 93  5D    45898 203 CB
45769 75  4B    45834 179 B3    45899 25  19
45770 116 74    45835 235 EB    45900 203 CB
45771 191 BF    45836 205 CD    45901 56  38
45772 237 ED    45837 62  3E    45902 203 CB
45773 67  43    45838 179 B3    45903 25  19
45774 91  5B    45839 205 CD    45904 203 CB
45775 179 B3    45840 35  23    45905 56  38
45776 205 CD    45841 179 B3    45906 203 CB
45777 62  3E    45842 245 F5    45907 25  19
45778 179 B3    45843 237 ED    45908 9   09
45779 205 CD    45844 91  5B    45909 230 E6
45780 225 E1    45845 93  5D    45910 7   07
45781 178 B2    45846 179 B3    45911 205 CD
45782 79  4F    45847 27  1B    45912 13  0D
45783 241 F1    45848 27  1B    45913 194 C2
45784 7   07    45849 27  1B    45914 201 C9
45785 7   07    45850 27  1B
45786 7   07    45851 205 CD
45787 7   07    45852 62  3E
45788 177 B1    45853 179 B3
45789 225 E1    45854 205 CD
45790 209 D1    45855 35  23
45791 193 C1    45856 179 B3
45792 201 C9    45857 24  18
45793 87  57    45858 179 B3
45794 230 E6    45859 95  5F
45795 96  60    45860 175 AF
45796 15  0F    45861 203 CB
45797 15  0F    45862 67  43
45798 15  0F    45863 40  28
45799 95  5F    45864 2   02
45800 122 7A    45865 246 F6
45801 230 E6    45866 8   08
45802 6   06    45867 203 CB
45803 15  0F    45868 83  53
45804 179 B3    45869 40  28
45805 201 C9    45870 2   02

After you are done, save the MC portion on tape:

SAVE "CardDesign"CODE 45740,19794.

For more information on the MC routines, please see the commented disassembly listing. Now load the BASIC part of Sign Designer: LOAD “”. You can BREAK it after the MC part starts to load. Warning! Do NOT use RUN, or you will erase lots of important data. Certain lines have to be added/deleted to support our added features:

2114 [ENTER]
2202 [ENTER]

12 LOAD "CardDesign"CODE 45740,19794
2006 OVER 0:PRINT AT 9,0;" (64 spaces) ":OVER 1
2120 INPUT "T)op or B)ottom ? ";k$
2125 IF k$="t" OR k$="T" THEN POKE 45740,0: POKE 49133,1: GO TO 2140
2130 IF k$="b" OR k$="B" THEN POKE 45740,1: POKE 49133,43: GO TO 2140
2135 GO TO 2120
2140 POKE 49109,176: POKE 49110,1: POKE 49149.18
2150 RANDOMIZE USR 49535
9990 SAVE "CardDesign" LINE 12
9992 SAVE "CardDesign"CODE 45740,19794

After you finish changing the BASIC portion, load the MC part back: LOAD “”CODE. Then use GOTO 9990 to save the complete program (BASIC and MC).

You may also want to add this line to your regular Sign Designer: 2113 POKE 49149,36. Location 49149 controls the top and bottom margins, in 1/72 of an inch. The original value is 32, but the value I calculated is 36, at least for my printers. If you find that the second sign you print consecutively is higher on the page than the first one, then you need to change that value. For our modification to print cards, that value is 18 (half of 36), as done in line 2140.

Location 49133 (in lines 2125 and 2130) controls the left margin, in characters. The values of 1 and 43 are for EPSON (or compatible) printers, assuming the paper is centered correctly. You may need to adjust these values to get the best result on your printer.

You can go through the BASIC program and change every “Sign” in PRINT statements to “Card”, but it does take a lot of work. You use the “Card” Designer as usual. Just pick Top and Bottom portions correctly when printing your creations. Top is upside-down at upper left corner, and bottom is normal at lower right corner. If you have any questions about this conversion, please send SASE to: Chia-Chi Chao, 73 Sullivan Drive, Moraga, CA. 94556-1209. Enjoy!

Sign Designer filler drawing (creature with tufted hair)
Sign Designer filler drawing (creature with tufted hair)

Machine Code Disassembly

      HORIZN  EQU BF74h       ;horizontal counter
VERTCL EQU BF76h ;vertical counter
HRZMAX EQU 215 ;216 columns (0-215)
VRTMAX EQU 356 ;356 rows (0-355)
TOPFLG EQU 0 ;flag for top portion
BTMFLG EQU 1 ;flag for bottom part

B2AC FORMAT DEFB BTMFLG ;code for top or bottom
B2AD ENTRY LD B,A ;save A in B
B2AE LD A,(FORMAT) ;load A with format
B2B1 CP TOPFLG ;which function?
B2B3 LD A,B ;get original A back
B2B4 JR Z,TOP ;goto proper function

B2B6 BOTTOM CALL C20Dh ;the stolen instruction
B2B9 PUSH BC ;save registers
B2BA PUSH DE ; on stack
B2BB PUSH HL ;
B2BC CALL FILTER ;get the bits wanted
B2BF PUSH AF ;save 1st ptrn on stack
B2C0 SECOND LD DE,(VERTCL) ;get vertical coord.
B2C4 INC DE ;increase 4 to get
B2C5 INC DE ; coordinate for next
B2C6 INC DE ; row
B2C7 INC DE ;
B2C8 LD BC,(HORIZN) ;get horizontal coord.
B2CC LD (NEWHRZ),BC ;save it for later
B2D0 CALL SUB1 ;get bit pattern
B2D3 CALL FILTER ;again, get bits wanted
B2D6 COMBIN LD C,A ;save 2nd pattern in C
B2D7 POP AF ;get first pattern back
B2D8 RLCA ;rotate first pattern
B2D9 RLCA ; 4 times
B2DA RLCA ;
B2DB RLCA ;
B2DC OR C ;combine two patterns
B2DD POP HL ;get the registers back
B2DE POP DE ;
B2DF POP BC ;
B2E0 RET ;return to orig routine

B2E1 FILTER LD D,A ;save orig pattern in D
B2E2 AND 96 ;get the upper two bits
B2E4 RRCA ;rotate right into
B2E5 RRCA ; position
B2E6 RRCA ;
B2E7 LD E,A ;store it in E
B2E8 LD A,D ;get orig pattern back
B2E9 AND 06 ;get the lower two bits
B2EB RRCA ;rotate into position
B2EC OR E ;combine the four bits
B2ED RET ;
B2EE TOP PUSH BC ;save registers
B2EF PUSH DE ; on stack
B2F0 PUSH HL ;
B2F1 INIT LD DE,(HORIZN) ;get horizontal coord.
B2F5 LD HL,HRZMAX ;highest horiz coord.
B2F8 AND A ;clear carry flag
B2F9 SBC HL,DE ;flip horizontal coord.
B2FB LD (NEWHRZ),HL ;save it in memory
B2FE LD DE,(VERTCL) ;get vertical coord.
B302 LD HL,VRTMAX ;highest vert coord.
B305 AND A ;clear carry flag
B306 SBC HL,DE ;flip vertical coord.
B308 LD (NEWVRT),HL ;save it in memory
B30B START EX DE,HL ;put HL (v-coord) in DE
B30C CALL SUB1 ;get first bit pattern
B30F CALL REVERS ;get bits and reverse
B312 PUSH AF ;save 1st ptrn on stack
B313 SECAND LD DE,(NEWVRT) ;get last vert. coord.
B317 DEC DE ;decrease 4 to get
B318 DEC DE ; coordinate for
B319 DEC DE ; next row
B31A DEC DE ;
B31B CALL SUB1 ;get second pattern
B31E CALL REVERS ;reverse and filter it
B321 JR COMBIN ;combine two patterns

B323 REVERS LD E,A ;put bit pattern in E
B324 XOR A ;initialize A=0
B325 BIT 0,E ;test each of the 4
B327 JR Z,NEXT1 ; bits and set
B329 OR 08 ; appropriate bits in A
B32B NEXT1 BIT 2,E ;
B32D JR Z,NEXT2 ;
B32F OR 04 ;
B331 NEXT2 BIT 4,E ;
B333 JR Z,NEXT3 ;
B335 OR 02 ;
B337 NEXT3 BIT 6,E ;
B339 JR Z,DONE ;
B33B OR 01 ;
B33D DONE RET ;

B33E SUB1 LD C,00 ;C has to be zero
B340 CALL C062h ;taken from original
B343 LD BC,(NEWHRZ) ; routine
B347 LD A,C ;
B348 SRL B ;
B34A RR C ;
B34C SRL B ;
B34E RR C ;
B350 SRL B ;
B352 RR C ;
B354 ADD HL,BC ;
B355 AND 07 ;
B357 CALL C20Dh ;
B35A RET ;

B35B NEWHRZ DEFW 0 ;storage for horizontal
B35D NEWVRT DEFW 0 ;and vertical coords

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