“S” and “Q” Keys with “CAT*” Command

Author(s): Mike Finn
Pub Details: Time Designs Magazine v4 n5 (Volume 4, Issue 5)
Date: July/August 1988
Pages: 25-26

After reading Ronald Havlen‘s FDD Express (Oct. ’87) newsletter about the problem with stopping the scrolling on the CAT* command with keys “S” and “Q”, I began to experiment and I soon discovered that these keys will work occasionally. Here is a small program which shows that an even larger problem exists.

First, make sure you have a disk with a large enough directory to require screen scrolling. One fast way to do this is to run the following program:

10 FOR I = 1 TO 40
20 LET A$ = STR$ I
30 DIM* A$
40 NEXT I

Now delete that program and enter the following:

10 LET I = 0
20 CAT*
30 LET I = I + 1
40 GOTO 20

Run this program and while it is running, press and hold the “S” key. Be patient, as this may take a minute or so. Eventually, the scrolling will freeze and will remain this way until the “Q” key is pressed. Press the “Q” key and the screen will begin scrolling again. Immediately press CAPS SHIFT and BREAK. Enter as a direct command PRINT I. The first time I tried this it took 33 repetitions of the loop from lines 20 to 40 before the scrolling stopped. Other times it took as few as four loops.

This shows that the “S” and “Q” keys do work sometimes…the problem is why don’t they work all of the time.

I’ve also noticed another problem which may be similar to the systems non-response to the “S” key. Let’s clean up our disk’s directory with the following program.

10 FOR I = 1 to 40
20 LET A$ = STR$ I
30 ERASE A$
40 NEXT I

When you run this program, TOS (Timex Operating System) will ask you to confirm that you want to erase each directory entry. Answer “Y” each time and take notice of how long a wait there is between when you press “Y” and when TOS recognizes that you replied. The first six times I answered “Y”, TOS recognized my input immediately, but the following two times, there was noticeable lag. on one occasion, I tapped the “Y” key several times before the system finally responded. I have not had this problem any other time, so I assume the problem is not a defective keyboard. (I would like to know if these things I’ve written about are peculiar only to my setup or if they are universal among all Zebra FDD owners.)

I have been working on a disassembly of the Zebra interface ROM. I believe the I’ve identified the subroutine that deals with the use of the “Q” and “S”. I am still investigating this routine and have nothing final to report, but on my first glance, I see no reason why it shouldn’t work consistently.

My initial review shows that when the Zebra interface ROM sets up a TOS command to the disk controller, it then controls a response using a subroutine which the Zebra Disk Drive Technical Manual (page 28) calls RESPOSTA. This routine lies between 0688 hex and 06DB. If TOS wants a write out of text in the data buffer (2000 to 20FF hex) or from the error message section of the command buffer (210D to 212D), the routine at 03EB to 0423 is called. It is this routine which contains the “S” and “Q” key tests. One noteworthy point about this routine is that it only tests the “S” key at the beginning of the screen printout of text. It can print 256 bytes from the data buffer before it has to return to the original calling routine. If a directory printout contains less than 257 bytes, the “S” key will not stop it in the middle of a transfer since it is only tested prior to the data printout.

Can a long directory be contained in just 256 bytes? If you look at the line by line printout of the previous sample directory, you will notice that it is mostly empty spaces. The TAB function can easily generate all those spaces in just a few bytes of machine code, so pressing “S” may not necessarily stop even a large directory from scrolling.

Zebra ROM subroutines called by the “S” and “Q” key routine:

000A FDCB01AE RES 5,(IY+01)  RESET SYSTEM VARIABLE FLAG WHICH
                             TRACKS KEYHITS
000E FDCB01DE SET 3,(IY+01)  SET CURSOR MODE L
0012 CD3003   CALL 0330      CALL KEYBOARD SCANNER IN
0015 B002     DEFB 020B         HOME ROM
0017 AF       XOR A          CLEAR FLAG REGISTER
0018 FDCB016E BIT 5,(IY+01)  TEST WHETHER KEYHIT FOUND
001C C8       RET Z          IF NOT, RETURN TO CALLING ROUTINE
001D 3A085C   LD A,(5C08)    SYSTEM VARIABLE - LAST KEY
0020 FE61     CP 61          TEST FOR UPPER CASE
0022 D8       RET C          RETURN IF UPPER CASE
0023 E6DF     AND DF         IF LOWER CASE, CONVERT TO
0025 C9       RET               UPPER CASE AND RETURN
0026 3E0D     LD A,0D        CARRIAGE RETURN
0028 CD3003   CALL 0330      CALL RST 10 IN HOME ROM
002B 1000     DEFB 0010         TO TRANSMIT CARRIAGE RETURN
002D C9       RET

printout routine:

03EB E5       PUSH HL        SAVE HL, ADDRESS OF TEXT TO BE
                             PRINTED OUT
03EC 3E02     LD A,02        OPEN CHANNEL # 2; 0330 IS THE
03EE CD3003   CALL 0330        CBAS ROUTINE USED TO CALL HOME
03F1 3012     DEFB 1230        ROM ROUTINES
03F3 3EFF     LD A,FF        POKE SYSTEM VARIABLE WITH FF FOR
03F5 328C5C   LD (5C8C),A      CONTINUOUS SCROLL OF SCREEN
03F8 CD0A00   CALL 000A      KEYBOARD SCANNER ROUTINE
03FB FE53     CP 53          IS IT THE "S" KEY?
03FD 2007     JR NZ,0406     IF NOT,CONTINUE WITH PRINTOUT
03FF CD0A00   CALL 000A      IF IT IS "S", KEEP SCANNING
0402 FE51     CP 51          IS IT THE "Q" KEY?
0404 20F9     JR NZ,03FF     IF NOT, THEN KEEP SCANNING
                             KEYBOARD UNTIL "Q" IS PRESSED
0406 CD2600   CALL 0026      THIS DOES HOME ROM RST 10 TO
                             TRANSMIT A CARRIAGE RETURN
0409 E1       POP HL         RESTORE POINTER TO BUFFER BYTES
040A E5       PUSH HL
040B 7C       LD A,H         THIS TESTS WHETHER HL POINTS TO
                             COMMAND BUFFER 210D HEX OR TO
                             DATA BUFFER 2000 HEX
040C 1F       RRA            CARRY WILL BE SET FOR COMMAND
                             BUFFER, AND RESET FOR DATA
                             BUFFER READOUTS
040D 0600     LD B,00        THIS SETS UP A PRINTOUT OF
                             UP TO 32 BYTES, THE MAXIMUM
                             SIZE OF THE MESSAGE AREA IN THE
                             COMMAND BUFFER
040F 3802     JR C,0413
0411 0621     LD B,21        THIS SETS UP A PRINTOUT OF UP TO
                             256 BYTES, THE MAXIMUM LENGTH OF
                             THE DATA BUFFER, 2000 TO 20FF
0413 E1       POP HL         RESTORE BUFFER TEXT ADDRESS
0414 04       INC B          TESTS THAT WE DON'T EXCEED THE
0415 78       LD A,B           MAXIMUM SIZE OF BUFFER
0416 FE21     CP 21
0418 C8       RET Z          IF SO, RETURN TO CALLING ROUTINE
0419 7E       LD A,(HL)      PICK UP TEXT BYTE POINTED TO BY
                             HL
041A B7       OR A           TESTS TO SEE IF WE REACHED END
                             OF DATA MARKER, 00 HEX
041B C8       RET Z          IF SO, RETURN TO CALLING ROUTINE
041C 23       INC HL         IF NOT END OF DATA OR END OF
041D E5       PUSH HL          BUFFER THEN GET NEXT ADDRESS TO
                               BE PRINTED OUT AND SAVE IT
041E CD3003   CALL 0330      USE CBAS TO RUN HOME ROM RST 10
0421 1000     DEFB 0010        FOR TEXT BYTE IN THE A REGISTER
0423 18EE     JR 0413        REPEAT THE END OF DATA AND END OF
                             BUFFER TESTS

Note that the keyboard is only tested once for the “S” key, then up to 265 bytes are printed out. When this is completed we return to REPOSTA which sends a DONE message to TOS. If TOS has anything else to output to the screen, it repeats the request for data printout and up to 256 bytes can again be printed. So we only get the chance to stop the screen scrolling every 256 bytes.

When you try the program, you will see the scrolling freeze occasionally and will have to press “Q” to restart it. This shows that the routine does work. I see no software bugs to prevent it from working all the time (i.e., every 256 bytes). I don’t know enough about the hardware mechanisms involved in paging in and out the Zebra FDD shadow ROM, but I suspect a timing problem or a keyboard debouncing/reading problem more than a software problem. Does anyone have any suggestions for further study so we can nail down the source of this problem?

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