Echo #03
31 марта 1997 |
|
Tricks-2 - On the correct handling Retry / Abort / Ignore in the TR-DOS.
On the correct processing of R / I / A VfNG / NEW In many programs, people may want to grab a standard message DOS Error reading / writing sector to Lovely open its window, do Request Retry / Abort / Ignore, get an answer and the right to continue or terminate the program. Not all are able to do it. I will try to illuminate this issue. At # 3F0A DOS is a procedure that provides a record of the sector, and by # 3F0E-reading. Is precisely because of these procedures and is read / write standard features. Consider these procedures carefully: # 3F0A LD A, # A0; code write command ; Sector JR # 3F10 # 3F0E LD A, # 80; code read command ; Sector # 3F10 LD (# 5CFE), A LD D, # 0A; number of attempts ; Reading / writing # 3F15 PUSH DE DI LD A, (# 5CFF) INC A OUT (# 5F), A; sector number LD HL, (# 5D00); buffer LD C, # 7F; data port LD A, (# 5CFE); command code OUT (# 1F), A; invoking CP # A0; entry? PUSH AF CALL Z, # 3FBA; call recording ; Sector POP AF CALL NZ, # 3FD5; reading challenge ; Sector POP DE EI IN A, (# 1F); reading register ; State LD B, A AND # 7F RET Z; out if there is no ; Error LD HL, # 29D8; address labels ; "Read Only" AND # 40; write protection? JR NZ, # 3F4B; yes LD A, B AND 4, loss of data? JR Z, # 3FA0; not. re ; Attempt to read. DEC D; last attempt? JR NZ, # 3F15; not, another LD HL, # 29E2; address labels ; "Disk error" LD A, # D0 OUT # 1F, A; cease to ; Mande, if it , Continues to be executed LD A, B AND 1 JP NZ, # 3EE7; treatment ; "No disk" IN A, # 3F; reading register ; Track OR A; zero? JR NZ, # 3F5F; yes IN A, # 5F; reading register ; Sector CP # 0A; ten? RET Z; output, if so # 3F5F PUSH HL # 3F60 CALL # 1D97; call clearing ; Screen POP HL RST # 18 LD HL, # 2A13; address labels ; "Trk." RST # 18; output IN A, # 3F; reading register ; Track CALL # 1DA3; withdrawal rates ; Track LD HL, # 2A18; address labels ; "Sec." RST # 18; output IN A, # 5F; reading register ; Sector CALL # 1DA3; withdrawal rates ; Sector LD HL, # 29FE; address labels ; "Retry / Abort / Ignore?" RST # 18; output labels # 3F7B CALL # 1052, # 1052 procedure And returns to the A ASCII-code pressed on the keyboard # 3F7E CP "I"; Ignore? RET Z; refund if Yea CP "R"; Retry? JR Z, # 3F94; yes, access to ; The next cycle ; Attempts CP "A"; Abort? JR NZ, # 3F7B; not, go to , Reading the keyboard ; Tours # 3F89; Abort The main thing that can be extracted from the drawn above, is that as a result of error, we find ourselves either in the # 3F60, or # 3EE7. # 3F60 Poprubuem examine more closely. # 3F60 CALL # 1D97 # 1D97 RST # 20 DEFB # 6B DEFB # 0D # 0020 JP # 2F72 # 2F72 LD (# 5D02), HL LD (# 5D04), DE POP HL LD E, (HL) INC HL LD D, (HL) INC HL PUSH HL LD HL, # 3D2F PUSH HL PUSH DE LD HL, # 5CC2 PUSH HL LD HL, (# 5D02) LD DE, (# 5D04) RET Thus, when a disk error is different from "No disk", we fly to # 5CC2. In # 5CC2 standard sticks RET. This point used to call subroutines ROM BASIC. Two bytes in # 5CC3 and # 5CC4 not used, then we are legally able to enter in the # 5CC2 team of 3 bytes: JP kudanibud, such as driver of treatment. Note that after this most at JP stack will protrude number # 0D6B. Hence, make the following veshchichki: DRIVER EX (SP), HL PUSH AF LD A, H CP # 0D JR Z, ERROR POP AF EX (SP), HL RET Guess for yourself what happened then. Well and now ERROR POP HL POP HL POP HL POP HL POP HL CALL PROC; call their own ; RIA procedure return-to A "R", "I", "A" , Respectively. LD HL, # 3F7E EX (SP), HL JP # 3D2F; return to DOS ; Answer! In the simplest case CALL PROC replaced by LD A, "R" / "I" / "A", if the answer to error is defined odnaznachno. Similarly, although somewhat more complicated is the case with the processing of "No disk" (# 3EE7). In this, as well as to depart on "Abort", sort it out themselves, it is not difficult do.
Other articles:
Similar articles:
В этот день... 3 December