Memotech CIF “Copy” Fix for Hot-Z 11

Author(s): Bill Bell
Publication: SyncWare News
Pub Details: SyncWare News v5 n4 (Volume 5, Issue 4)
Date: March/April 1988
Pages: 12

Many TS-1000/ZX-81 users drive full size printers with the Memotech Centronics interface due to the wide availability and the ease of use with BASIC programming. However, machine code programs designed to operate the Timex printer have compatibility problems when producing screen copies that are longer or shorter than the standard 22 lines. A notable example is the single page copy function in HOT-Z II, which is a 24 line display.

Well, here is the explanation of the incompatibility, and a simple fix for HOT-Z II that allows EITHER printer to work with the changed code. The same trick can be applied to other programs experiencing the problem.

The Memotech CIF, besides having its own coding in the 8-10K region, also overrides and changes some of the original ROM code that controls printing.

Partial code without the interface:

0869 1616      LD D,16        ;22 line COPY
086B 2A0C40 LD HL,(DFIL) ;
086E 23 INC HL ;display file
086F 1805 JR 0876 ;bypass LPRINT
0871 1601 LD D,01 ;1 line LPRINT
0873 213C40 LD HL,PRBF ;printer buffer
0876 CDE702 CALL 02E7 ;call fast mode
0879 C5 PUSH BC ;
087A E5 PUSH HL ;
087B AF XOR A ;clear A register

Partial code with the interface attached:

0869 1616      LD D,16        ;22 line COPY
086B 2A0C40 LD HL,(DFIL) ;
086E 23 INC HL ;display file
086F 1805 JR 0876 ;bypass LPRINT
0871 1601 LD D,01 ;1 line LPRINT
0873 213C40 LD HL,PRBF ;printer buffer
0876 C5 PUSH BC ;
0877 F5 PUSH AF ;saves A reg
0878 7A LD A,D ;get line count
0879 FE16 CP 16 ;is it 22 lines?
087B 2004 JR NZ 0881 ;no,keep old A
087D F1 POP AF ;yes,replace A
087E 3E76 LD A,76 ;with newline
0880 F5 PUSH AF ;and resave

The changed code tests the D register for the number of lines. If it is 22, the routine replaces the A register content with a newline character in order to properly handle a COPY function. If it is not 22, it assumes we are doing an LPRINT and that a newline character was already in the A register from the LPRINT. This lack of newline is what causes our non-22 line COPY to fail. Easy to fix–all we have to do is load the A register with a newline (76 hex) before jumping into the copy routines. Now Memotech works OK, and the Timex ignores the A register.

The original HOT-Z II 64K program has the 24-line copy routine at 63F0 hex (A3F0 in a high RAM version) and looks like this:

63F0 1618      LD D,18        ;set D for
24 lines
63F2 2A0C40 LD HL,(DFIL) ;
63F5 23 INC HL ;display file
63F6 CDE702 CALL 02E7 ;call fast mode
63F9 CD7608 CALL 0876 ;call copy screen
63FC C9 RET ;return

Change (and simplify) the code to look like this:

63F0 1618      LD D,18        ;set D for
24 lines
63F2 3E76 LD A,76 ;put newline in A
63F4 CD6B08 CALL 086B ;set HL and copy
63F7 C9 RET ;return
63F8 00 NOP ;unused
63F9 00 NOP ;unused
63FA 00 NOP ;unused
63FB 00 NOP ;unused
63FC 00 NOP ;unused

To make these changes permanent, use the method described in HOT-Z II documentation for creating a new version tape–the routine that ends up at 63F0 will be found at 4FC0 when loaded, or at 8FC0 if you read the tape into 8009 upwards.

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