Previous Next Contents Index
Miscalleneous routines II

THE 'FLASH BORDER' SUBROUTINE
When DISCiPLE system variable RBCC (address @0) doesn't hold zero, this subroutine
flashes the border. The border colour is then obtained by masking the E register
(holds sectornumber) with RBCC.

3B17 FLASH_BORD LD   A,(#0298)           Fetch RBCC.
3B1A            AND  E                   Incorporate sectornumber.
3B1B            RET  Z                   Return if 'no flashing'.
3B1C            AND  #07                 Keep border colour only.
3B1E            OUT  (254),A             Set the border and finished.
3B20            RET

THE 'BORDER COLOUR RESTORE' SUBROUTINE
This subroutine is used whenever the border colour was changed during an I/O operation,
and needs to be restored to its original state.

3B21 BORD_REST  PUSH AF
3B22            LD   A,(23624)           Fetch lower screen attribute (BORDCR).
3B25            AND  #38                 Only the border bits.
3B27            RRCA                     Move the bits to 0-2.
3B28            RRCA
3B29            RRCA
3B2A            OUT  (254),A             Restore colour.
3B2C            POP  AF
3B2D            RET

THE 'PRINT DIRECTORY DESCR.' SUBROUTINE
This subroutine is used to print the directory description of a file during an
'extended CAT' command. On entry the A register holds the directory description.

3B2E PRT_TYPE   PUSH AF
3B2F            LD   HL,#3B7C,TYPE_TABLE Start of messages table.
3B32            LD   BC,85               Length of table excluding 'WHAT?'.
3B35            CPIR                     Make HL point to right message. HL
                                         points to 'WHAT?' with unknown types.
3B37            CALL #3D47,PRT_MSG_HL    Print the message.
3B3A            POP  AF                  Restore file type.
3B3B            CP   1
3B3D            JR   NZ,#3B54,PRT_NOBAS  Jump with no 'BASIC' files.
3B3F            LD   (IX+13),219         Make RPT point to autostart line high.
3B43            CALL #37D4,RPT_HL1       HL points to it now.
3B46            LD   A,(HL)
3B47            AND  192
3B49            JR   NZ,#3B77,PRT_EXIT   Jump if no autostart line present.
3B4B            LD   D,(HL)              Otherwise fetch it.
3B4C            DEC  HL
3B4D            LD   E,(HL)
3B4E            EX   DE,HL
3B4F            CALL #3BD7,PRT_NUM       Print it.
3B52            JR   #3B77,PRT_EXIT

Now the other directory descriptions are handled.

3B54 PRT_NOBAS  CP   4
3B56            JR   NZ,#3B77,PRT_EXIT   Jump with no 'CODE' files.
3B58            LD   (IX+13),215         RPT points to file address high byte.
3B5C            CALL #37D4,RPT_HL1       Make HL hold RPT.
3B5F            LD   D,(HL)              Fetch file address.
3B60            DEC  HL
3B61            LD   E,(HL)
3B62            EX   DE,HL
3B63            PUSH DE
3B64            CALL #3BD7,PRT_NUM       Print file address.
3B67            LD   A,","               Print a ','.
3B69            CALL #3C2C,PRT_A
3B6C            POP  HL
3B6D            DEC  HL
3B6E            LD   D,(HL)              Fetch file length.
3B6F            DEC  HL
3B70            LD   E,(HL)
3B71            EX   DE,HL
3B72            LD   A,0                 Ignore leading zero's.
3B74            CALL #3BD9,PRT_N10000    Print the length.
3B77 PRT_EXIT   LD   A,13                Print a NEWLINE and exit.
3B79            JP   #3C2C,PRT_A

THE 'DIRECTORY DESCRIPTION' TABLE
This table contains the directory description messages as printed with an 'extended
CAT'. Each message is preceeded by is description value.

3B7C TYPE_TABLE DEFB 1
3B7D            DEFM "BAS "
3B81            DEFB 2
3B82            DEFM "D.ARRAY"
3B89            DEFB 3
3B8A            DEFM "$.ARRAY"
3B91            DEFB 4
3B92            DEFM "CDE "
3B96            DEFB 5
3B97            DEFM "SNP 48k"
3B9E            DEFB 6
3B9F            DEFM "MD.FILE"
3BA6            DEFB 7
3BA7            DEFM "SCREEN$"
3BAE            DEFB 8
3BAF            DEFM "SPECIAL"
3BB6            DEFB 9
3BB7            DEFM "SNP 128k"
3BBF            DEFB 10
3BC0            DEFM "OPENTYPE"
3BC8            DEFB 11
3BC9            DEFM "EXECUTE"
3BD0            DEFB 12
3BD1            DEFM "WHAT?"
3BD6            DEFB 0

THE 'PRINT NUMBER' SUBROUTINE
This subroutine prints the number held in the HL register. Entering the routine at
#3BD7 prints leading spaces, while the other entry points prints the character held in
the A register in place of leading zero's. A value of 0 means don't print anything.

3BD7 PRT_NUM    LD   A,32                Spaces are printed in place of leading
                                         zero's.
3BD9 PRT_N10000 LD   DE,10000            Start printing with tens-of-thousands.
3BDC            CALL #3BF6,PRT_DIGIT
3BDF PRT_N1000  LD   DE,1000             Start printing with thousands.
3BE2            CALL #3BF6,PRT_DIGIT
3BE5 PRT_N100   LD   DE,100              Start printing with hundreds.
3BE8            CALL #3BF6,PRT_DIGIT
3BEB PRT_N10    LD   DE,10               Start printing with tens.
3BEE            CALL #3BF6,PRT_DIGIT
3BF1            LD   A,L                 Print units.
3BF2            ADD  A,"0"               Add ASCII offset for digits.
3BF4            JR   #3C2C,PRT_A

THE 'PRINT DIGIT' SUBROUTINE
This subroutine is used to print a digit, the HL register holds the number and the
DE register the value for 'repeated subtraction'.

3BF6 PRT_DIGIT  PUSH AF                  Preserve leading character.
3BF7            XOR  A                   Clear Carry and counter.
3BF8 PRT_DIG1   SBC  HL,DE               The 'trial' subtraction.
3BFA            JR   C,#3BFF,PRT_DIG2    Jump if exhausted.
3BFC            INC  A                   Count each trial.
3BFD            JR   #3BF8,PRT_DIG1      Jump back for next try.

The A register now holds the digit to be printed.

3BFF PRT_DIG2   ADD  HL,DE               Restore last subtraction.
3C00            AND  A
3C01            JR   NZ,#3C08,PRT_DIG3   Jump if a non zero value is to be
                                         printed.
3C03            POP  DE                  Retrieve the leading character into D.
3C04            ADD  A,D                 Add it to zero.
3C05            RET  Z                   Return if nothing has to be printed.
3C06            JR   #3C2C,PRT_A         Otherwise print the leading character.

Now print the digit.

3C08 PRT_DIG3   ADD  A,"0"               Add ASCII offset for digits.
3C0A            CALL #3C2C,PRT_A         Print the digit.
3C0D            POP  DE                  Balance the stack.
3C0E            LD   A,"0"               All zeroes after any non zero digit will
3C10            RET                      be printed as '0'.

THE 'PRINT OUT MESSAGE' SUBROUTINE
This subroutine handles the printing of messages directly following the 'CALL'
instruction to this routine. When the DISCiPLE's own error stack pointer (D_ERR_SP)
holds a non-zero value, i.e. during hook and command codes, no printing has to take
place. The carry flag is set and the A register then holds 32, signalling 'error
during hook/command code execution' as usual.

3C11 PO_MSG     LD   HL,(#0296)          Fetch (D_ERR_SP).
3C14            LD   A,H
3C15            OR   L
3C16            JR   Z,#3C1D,PO_MSG1     Jump if it isn't used.
3C18            LD   SP,HL               Clear machine stack.
3C19            LD   A,32                Signal 'error 32'.
3C1B            SCF
3C1C            RET                      Exit.

Now the message can be printed.

3C1D PO_MSG1    POP  HL                  HL points to the message to be printed.
3C1E PO_MSG2    LD   A,(HL)              Fetch a character.
3C1F            AND  #7F
3C21            CALL #3C2C,PRT_A         Print it.
3C24            BIT  7,(HL)              Bit 7 set signals 'End of message'.
3C26            RET  NZ
3C27            INC  HL
3C28            JR   #3C1E,PO_MSG2       Repeat for all characters.

THE 'PRINT A SPACE' SUBROUTINE
This subroutine prints a space to the current stream.

3C2A PRT_SPACE  LD   A,32                Continue in the 'PRT_A' routine.

THE 'PRINT CHARACTER' SUBROUTINE
This subroutine prints the character held in the A register to the current stream.

3C2C PRT_A      PUSH AF
3C2D            PUSH BC
3C2E            PUSH DE
3C2F            PUSH HL
3C30            RST  #10,CALBAS          Print the character in the A register
3C31            DEFW #0010,PRINT_A_1     by calling the 'main' ROM routine.
3C33            POP  HL
3C34            POP  DE
3C35            POP  BC
3C36            POP  AF
3C37            RET

THE 'ROM' MESSAGES
Now follow some messages used in the ROM.

3C38 MESG_0     CALL #3C11,PO_MSG
3C3B            DEFM #0D,#0D,#0D
3C3E            DEFB #0D,#0D,#0D
3C41            DEFM "        "SYSTEM" LOADING"
3C59            DEFB #0D,#0D
3C5B            DEFM "          PLEASE  WAIT"
3C71            DEFB #0D,#0D
3C73            DEFM "        (ROM  ISSUE 3.0)"
3C8B            DEFB #0D,#8D

3C8D MESG_1     CALL #3C11,PO_MSG
3C90            DEFM "OVERWRITE "
3C9A            DEFB """+128

3C9B SURE_MSG   CALL #3C11,PO_MSG
3C9E            DEFM "Are you SURE ? (y/n"
3CB1            DEFB ")"+128

3CB2 MESG_3     CALL #3C11,PO_MSG
3CB5            DEFM "" (y/n"
3CBB            DEFB ")"+128
Previous Next Contents Index