Exchange of experience - Error Handling TR DOS.

Adventurer #07
     (C) REAL SOFTWARE / NHG '1997, Brest

     (C) Music: Andrew Fer / PhF



    Handling disk errors TR-DOS



     If your program does not require
to do more error handling throw out the menu with a choice of 
RIA, but you want to avoid clearing the screen and the 
appearance of vile inscriptions TR-DOS "disk error", then

This will help developed my short protsedurka, which blocks all
attempts to TR-DOS print message
error, it is, in this case, without any
effects return control to the program with
error code in register A (a copy of the system variable # 5D0F 
(23823)). If you need to handle RIA, then at this protsedurku 
without any problems, you can hang a driver error handling, for 
example, such as published in the newspaper ECHO 3

(Author VfNG). In case you have not
there is this newspaper, I cite this
driver, once connected to my program that I it was made only
determine the type of error DISK ERROR or
READ ONLY.


     Instead, # 3D13 call TR-DOS obrabotka errors without menus 
RIA: TRDOS PUSH HL


       LD HL, (23613) Save. ERR_SP

       LD (ERR +1), HL

       LD HL, ERR

       EX (SP), HL

       LD (23613), SP

       EX AF, AF '

       XOR A

       LD (23823), A

       LD (23824), A

       LD (23570), A

       EX AF, AF '

       JP 15635
ERR LD HL, 0

       LD (23613), HL; Restore. ERR_SP

       LD A, 6

       LD (23570), A

       LD A, (23823)

       AND A
TRD1 RET Z

       PUSH AF

       LD IX, W1; box ERROR!

       CALL OPWIN; open

       POP AF

       RET


     Note: if you use beysikovskie channels to print characters 
or for any other purposes, then insert

in the error handling procedure before opening the window with 
an error initializing the desired channel. For example: LD A, 
2: CALL 5633.


     By the way, one way to fast
hacking programs, it is opening the latch
drive during startup, and maintenance
by MAGIC 'in or entering the monitor, and then
just need to find LOADER. So, if
you want to properly protect the program,
then hang a particular procedure for handling errors.


     Processing of RIA:
TRDOS PUSH HL

       LD HL, (23613) Save. ERR_SP

       LD (ERR +1), HL

       LD HL, DDRIV; Const. Drive.

       LD (# 5CC3), HL

       LD HL, ERR

       EX (SP), HL

       LD (23613), SP

       EX AF, AF '

       LD A, # C3

       LD (# 5CC2), A

       XOR A

       LD (23823), A

       LD (23824), A

       EX AF, AF '

       JP 15635
ERR LD HL, 0

       LD (23613), HL; Restore. ERR_SP

       LD A, # C9; Restore. RET

       LD (# 5CC2), A

       LD A, (23823)

       AND A
TRD1 RET Z

       CP 6

       PUSH AF

       LD IX, W1; box NO DISK

       JR Z, NODISK

       LD IX, W2; window BREAK
NODISK CALL OPWIN; open

       POP AF

       RET


     Processing RIA


DDRIV EX (SP), HL

       PUSH AF

       LD A, H

       CP 1913

       JR Z, ERROR

       POP AF

       EX (SP), HL

       RET
ERROR; in the system variable

       ; # 5CF4 (23796) Current dor / sects

       LD IX, W3; table window

       CALL OPWIN; open

       ............ ; Print

       ............ ; Current dor / sects

       POP HL

       POP HL

       LD A, L

       POP HL

       POP HL

       POP HL

       CP # D8

       LD HL, TX23; DISK ERROR

       JR NZ, ERROR0

       LD HL, TX24; READ ONLY
ERROR0 CALL WRITE; Print

       XOR A

       LD (23560), A

       LD IX, GORM2; table menu

       CALL GRMNU; choice item

       LD A, (IX +2); item number

       DEC A

       LD C, "R"

       JR Z, ERROR1

       DEC A

       LD C, "A"

       JR Z, ERROR1

       LD C, "I"
ERROR1 LD A, C

       LD HL, # 3F7E

       EX (SP), HL

       JP # 3D2F