Deja Vu #09
13 ноября 1999

Coding - Error Handling TR-DOS when working through # 3D13.

<b>Coding</b> - Error Handling TR-DOS when working through # 3D13.
(C) Rezonance group
__________________________________________



    Handling Errors TR-DOS when working

               through # 3D13.



   The key point is to change
system variables TR-DOS at
23749, which is usually located team
RET, is used to refer to the BASIC ROM routines 48. After 
intercepting the call determines which subprogram required a 
TR-DOS, and a decision about whether to go in BASIC or use an 
alternate routine, written by us. 

   On error reading sector and the protection of
records are accessed in BASIC at the following addresses: # 
0D6B - clearing the screen and the opening flux 0; # 0010 - 
Print symbol; # 028E, # 031E, # 0333 - all this poll the 
keyboard; # 1F54 - poll BREAK; # 1B7B - RST8 (error handler). 
It is these routines we have to substitute your own. In 
addition to the above, TR-DOS uses a few routines: # 1F1A, # 
1F05, # 0030, # 19E5, and etc. to adjust the memory, but it is 
better do not touch it, let them work as work.

All remaining errors are returned to the system variable and 
processed 23,823 special procedure. We now turn to

the program itself.


   An example of a procedure call download the file.
In case 'A' - a way to download.


      ORG # 8000,0

      DI

      LD A, # FF

      LD HL, NAME

      LD DE, 0

      CALL Load_file


In the case of a fatal error control is transferred here. "

ABORT NOP

      NOP

      NOP

      RET



   File name and extension.

NAME DEFM "screen2"

      DEFM "C"



   Variables: the type of load, the address name
file and the load address, file length, address
on the screen.

DOStyp DEFB 0
DOSnam DEFW 0
DOSadr DEFW 0
DOSlen DEFW 0
DOSscr DEFW 0
;------------------------------;| DOWNLOADS |
;------------------------------; IN:
; A - TYPE OF LOAD
; 0 - address and the length of the directory
, 1,2 - address of 'DE', the length of
; Directory
3 - the address of the 'DE', the length of the 'BC'
; HL - FILE NAME ADDRESS
; DE - Load address
; BC - LENGTH OF FILE
Load_file

      DI


Save the contents of the registers in memory.


      LD (DOStyp), A

      LD (DOSnam), HL

      LD (DOSadr), DE

      LD (DOSlen), BC


Copy the file name in the domain of variables
TR-DOS.


      CALL DOS_move_name


These variables are required to install for
normal operation.


      LD A, 0

      LD (23801), A

      LD (23824), A


Preparation of the remaining variables to work.


      CALL DOS_instal


In the absence of a file or similar
error message displayed on the screen and
Request Retry, Abort. This cycle is necessary
to repeat the operation in case the answer
Retry.


Lfile01

      LD A, (DOStyp)

      LD HL, (DOSadr)

      LD DE, (DOSlen)

      LD BC, 14

      CALL # 3D13

      CALL DOS_disk_error

      JR NZ, Lfile01


Restore the original values ​​of variables
and return.


    JP DOS_uninstal


;------------------------------;| SHIPPING FILE |
;------------------------------; IN:
; HL - FILE NAME ADDRESS
; DE - ADDRESS FILE
; BC - LENGTH OF FILE
Here, everything is similar to the procedure for downloading
file.

Save_file

      DI

      LD (DOSnam), HL

      LD (DOSadr), DE

      LD (DOSlen), BC

      CALL DOS_move_name

      LD A, 0

      LD (23801), A

      LD (23824), A

      CALL DOS_instal
Sfile01

      LD HL, (DOSadr)

      LD DE, (DOSlen)

      LD BC, 11

      CALL # 3D13

      CALL DOS_disk_error

      JR NZ, Sfile01

      JP DOS_uninstal
;------------------------------
Set the number of characters for which
looking for a file, change the variable ERR_SP,
to easily go back and do not
forget about the team JP.


DOS_instal

      LD A, 9

      LD (23814), A

      LD (23613), SP

      LD A, # C3

      LD HL, DOS_error_intercept

      LD (23746), A

      LD (23747), HL

      RET
;------------------------------
Once the procedure is fulfilled, will return to the place of 
RET. Here can also add command to restore ERR_SP.



DOS_uninstal

      LD A, # C9

      LD HL, # FFFF

      LD (23746), A

      LD (23747), HL

      RET
;------------------------------
Transferring a file name in the domain of variables
TR-DOS.

DOS_move_name

      LD DE, 23773

      LD BC, 9

      LDIR

      RET
;------------------------------; PROCESSING ERROR 'RZ-DOSv1' |
;------------------------------ Enjoying the content 23823: if 
there is 0, then file is loaded (shipped) without any problems, 
or discover that it is a mistake. 

DOS_disk_error

      LD A, (23823)

      OR A

      RET Z


Open the on-screen window.


      CALL DOS_window_open


In the 'HL' address error messages.


      LD HL, DOS_mezage


Do not pay attention, not just a string
fit on the screen. In the 'BC' length of all messages.

LD BC, DOS_mezage_error-DOS_mezage


Finding us a message by its code in
case 'A'.


DOS_Derror1

      CPI

      JR Z, DOS_Derror2

      JP PE, DOS_Derror1


If the message is found, then the 'HL' address, if not, then 
the 'HL' address message "* Indiscernible error *", ie 
Unrecognized error. 

DOS_Derror2


Print a message in the window


      CALL DOS_write_line


Print Retry, Abort? (If, for example,
disc does not have the desired file, then you politely
report it and ask, search
again or be enough? And you at this time
insolent view insert another disk and push "R"!).



      LD HL, DOS_mezage_ask

      CALL DOS_write_line


Reset the error so that when you answer "R" and
successful completion of the work mysteriously not
an error message.


      LD A, 0

      LD (23823), A


Poll buttons "R" and "A".


DOS_Derror3

      CALL DOS_RAI_ask

      CP "A"

      JR Z, DOS_abort

      CP "R"

      JR Z, DOS_retry

      JR DOS_Derror3


Close the window, dropping the Z flag and repeat
almost all from the beginning.

DOS_retry

      CALL DOS_window_close

      OR # FF

      RET


Close the window by turning off all that is needed and
go to the caller.

DOS_abort

      CALL DOS_window_close

      CALL DOS_uninstal

      JP ABORT


Error message. Format: error code
newline (why come? so does
DOS), the message 0 - end of message marker.

DOS_mezage

      DEFB 1,13

      DEFM "No file"

      DEFB 0,2,13

      DEFM "File exists"

      DEFB 0,3,13

      DEFM "No space"

      DEFB 0,4,13

      DEFM "Directory full"

      DEFB 0,5,13

      DEFM "Rec O / F"

      DEFM 0,6,13

      DEFM "No disc"

      DEFB 0,12,13

      DEFM "Break into program"

      DEFB 0,20,13

      DEFM "Break-cont repeats"

      DEFB 0
DOS_mezage_error
; NERASPOZNANAYA RZ-DOSom ERROR!

      DEFB 13

      DEFM "* Indiscernible error *"

      DEFB 0
DOS_mezage_ask

      DEFB 13

      DEFM "Retry, Abort?"

      DEFB 0
This is just the author's autograph!

      DEFM "RZ-DOSv1 special for"

      DEFM "magazine DEJA VU!"

      DEFM "Rezonance multimedia"

      DEFM "group"
;------------------------------; INTERCEPTION ERRORS TR-DOS!!! |
; Are looking for intercepting calls to |
; ROM BASIC 1948 (BIOS) |
;------------------------------; Handle errors:
; Disc error Trc XX sec XX
; Read only Trc XX sec XX
; Break-cont repeats

From top of stack address routines and check whether you need 
to replace it. 

DOS_error_intercept

      POP DE

      AND A

      LD HL, # 0D6B

      SBC HL, DE


Discovery channel 0. Instead, the channel open
window.


      JP Z, DOS_window_open

      AND A

      LD HL, # 0010

      SBC HL, DE
Print a character.

      JP Z, DOS_write

      AND A

      LD HL, # 1A1B

      SBC HL, DE
Print numbers from the register of 'BC'.

      JP Z, DOS_hex_sumbol

      AND A

      LD HL, # 028E

      SBC HL, DE


Just go back to DOS with the established
flags.


      JP Z, DOS_return

      AND A

      LD HL, # 031E

      SBC HL, DE
Same as the previous one.

      JP Z, DOS_return

      AND A

      LD HL, # 0333

      SBC HL, DE
Poll keys "R", "A", "I".

      JP Z, DOS_ask_and_close

      AND A

      LD HL, # 1B7B

      SBC HL, DE
Subroutine call RST8

      JP Z, DOS_rst8


Restore the 'HL', 'DE', and procedure calls
from BASIC 48.


      PUSH DE


In these variables DOS copies the registers before calling the 
procedure. 


      LD HL, (23810)

      LD DE, (23812)

      RET
;------------------------------; PRINT NUMBER FROM REGISTER 'BC'
, (NUMBER OF TRACK AND SECTOR)
DOS_hex_sumbol
Print '#' character, since sector number
or track is displayed in hexadecimal
format.


      LD A, "#"

      CALL DOS_write


Find and print high-order nibble.


      LD HL, DOS_fex_sumbol1

      LD D, 0

      LD E, C

      SRL E

      SRL E

      SRL E

      SRL E

      ADD HL, DE

      LD A, (HL)

      CALL DOS_write
Now the younger nibble.

      LD A, C

      AND # 0F

      LD HL, DOS_fex_sumbol1

      LD D, 0

      LD E, A

      ADD HL, DE

      LD A, (HL)

      CALL DOS_write

      RET
DOS_hex_sumbol1

      DEFM "0123456789ABCDF"
;------------------------------; POLL KEYBOARD AND CLOSE WINDOW
DOS_ask_and_close

      CALL DOS_RAI_ask

      CALL DOS_window_close

      RET
;------------------------------; RETURN TO DOS WITH INCLUDED
, The Z flag, and C (INSTEAD OF INTERVIEW)
DOS_return

      LD A, # 01

      ADD A, # FF

      RET
;------------------------------; POLL KEYBOARD
DOS_RAI_ask

      LD A, # FB

      IN A, (# FE)

      BIT 3, A

      LD A, "R"

      RET Z

      LD A, # FD

      IN A, (# FE)

      BIT 0, A

      LD A, "A"

      RET Z

      LD A, # DF

      IN A, (# FE)

      BIT 2, A

      LD A, "I"

      RET Z

      JR DOS_RAI_ask
;------------------------------; If pressed "BREAK", TO DOS
, Calls the procedure RST8
Substitute sub RST 8. Restore the stack in the 'BC' and (23823) 
error code "Break-cont repeats"



DOS_rst8

      LD SP, (23827)

      LD BC, 20

      LD A, C

      LD (23823), A

      RET
;------------------------------; OPENING DOORS
The window is formed in the middle third of the screen,
height of the four familiarity. DOS_window_open
Save the registers.


      PUSH AF

      PUSH HL

      PUSH DE

      PUSH BC


Address of the screen to the routine.


      LD HL, # 4802

      LD (DOSscr), HL


Copy the contents of the screen to the clipboard and clear the 
window. 


      LD HL, # 4820

      LD DE, DOS_bufer
DOS_Wopen1

      LD BC, 32 * 3
DOS_Wopen2

      LD A, (HL)

      LD (HL), 0

      LD (DE), A

      INC HL

      INC DE

      DEC BC

      LD A, B

      OR C

      JR NZ, DOS_Wopen2

      INC H

      LD A, # 20

      LD L, A

      LD A, 7

      AND H

      JR NZ, DOS_Wopen1
Same for the field attributes.

      LD HL, # 5920

      LD BC, 32 * 3
DOS_Wopen3

      LD A, (HL)

      LD (HL), # 16

      LD (DE), A

      INC HL

      INC DE

      DEC BC

      LD A, B

      OR C

      JR NZ, DOS_Wopen3
Restore registers and return.

      POP BC

      POP DE

      POP HL

      POP AF

      RET
;------------------------------; CLOSE WINDOW
DOS_window_close
Save registers

      PUSH AF

      PUSH HL

      PUSH DE

      PUSH BC
Restore the contents of the screen under the window.

      LD HL, DOS_bufer

      LD DE, # 4820
DOS_Wclose1

      LD BC, 32 * 3

      LDIR

      INC D

      LD A, # 20

      LD E, A

      LD A, 7

      AND D

      JR NZ, DOS_Wclose1
Same for the field attributes.

      LD DE, # 5920

      LD BC, 32 * 3

      LDIR
Restore registers and return.

      POP BC

      POP DE

      POP HL

      POP AF

      RET
;------------------------------; PROCEDURE printed characters
; Designed specifically for
; RZ-DOSv1, AND LETS PRINT
; Characters inside third of the screen!
Print a line of text.

DOS_write_line

      LD A, (HL)

      INC HL

      AND A

      RET Z

      CALL DOS_write

      JR DOS_write_line


Print a character. The procedure is simplified and therefore 
only prints characters within a third of the screen, because if 
there transition to the next one third, then familiarity will 
address incorrectly calculated. DOS_write

Save the registers.

      PUSH HL

      PUSH DE

      PUSH BC
Transfer code line?

      CP # 0D

      JR NZ, DOS_write1
Yes. Put in the 'HL' address familiarity.

      LD HL, (DOSscr)
Zeroing the lowest 5 register.
Now the current left-most column.

      LD A, L

      AND # E0
Add 32 and thus move on to the next line.

      ADD A, # 20
Back from the edge of two familiarity.

      OR 2

      LD L, A
Stored in the variable.

      LD (DOSscr), HL

      JP DOS_write3
DOS_write1
In the 'HL' character code.

      LD L, A

      LD H, 0
Multiply by 8.

      ADD HL, HL

      ADD HL, HL

      ADD HL, HL
Add to the character generator address in ROM.

      LD DE, # 3C00

      ADD HL, DE
We place a 'DE' address familiarity.

      LD DE, (DOSscr)
Copy the screen from the ROM 8 lines.

      LD B, 8
DOS_write2

      LD A, (HL)

      LD (DE), A

      INC HL

      INC D

      DJNZ DOS_write2
Go to the next print position.

      LD DE, (DOSscr)

      INC DE

      LD (DOSscr), DE
Restore registers and return.
DOS_write3

      POP BC

      POP DE

      POP HL

      RET
;------------------------------; Buffer for SCREEN
DOS_bufer

      DEFS 1024,0



   The article was written under an informational support of 
the book Fedin Pavel Yurevich Complete description + full 
disassembler ROM TR-DOS 5.04T (5.03) ". One can only thank him 
for his work and recommend the readers of this wonderful book 
as a guide to explore the features of the TR-DOS. 


            Until next time!
-----------------------------------------





Other articles:

Apperativchik - the entry of the authors.

Apperativchik - On the control of Deja Vu.

Apperativchik - Freebie number 2: pirates and hacked versions of the magazine.

Apperativchik - Dejavu Info: How to buy the magazine Deja Vu.

Topic - Swap: "From letters to parcels" as found in the city Spektrumistov.

Topic - Tusovka: CSP'99 - interview with Slack Den.

Topic - Tusovka: CSP'99 - an interview with the main coder'om young Novosibirsk group AREASoft

Topic - Tusovka: CSP'99 - interview with one of the publishers 'electronic journal Deja Vu' Daniel / Playgear Co. / Binary Dimension.

Topic - Tusovka: CSP'99 - interview with one of Rybinsk of Cav / Auryn.

Topic - Tusovka: CSP'99 - an interview with the father of Playgear cool uncle Ze Pagan.

Topic - Tusovka: CSP'99 - an interview with the main coder'om Flash and concurrently one of the founders of the group - Alex Rider.

Topic - Tusovka: CSP'99 - poll as the party was held in a nutshell, the general impression.

Topic - Tusovka: Legend of the way passed Crazy Siberian Party 1999.

drop of solder - HD discs: Finalization of the drive controller to work with HD-disks.

drop of solder - The decision PROBLEMS 1.2MB drive.

drop of solder - increase the amount of RAM up to 1024K on SPECCY option Taganrog 128K!

drop of solder - circuit programmer for chip-only memory (ROM).

drop of solder - a dot-matrix printers.

drop of solder - ISA-Spectrum: card inserted into the ISA slot is IBM, which is part or a complete computer ZX-Spectrum.

Software - demoscene: Obzor'ing demozov: 63 bit III, Jam, Anamnesis, 7 Up, 63 bit IV, DemoDyin, Napalm, Crapmo 2, Bunch of Arce, Devotion, WorkStop, Energy , Yes.

Software - Game Review: MIST: Monstrland Part Two, Bomb Lakes, Marbles, KluXer, 4x4 Puzzle, Soldiers, Boats.

Software - Gun Commander: User's Guide.

Coding - coding for Dummies: civilized way in TR-DOS.

Coding - coding for Dummies: More about one of the ways to survey the keyboard.

Coding - coding for Dummies: How does the "Boot" from the inside.

Coding - coding for Dummies: refine MINI BOOT V3.0.

Coding - how to print 42 characters per line (with trabutami), the procedure is quick print sprites with pixel precision.

Coding - Bystrai printing 64 characters per line.

Coding - Conversion of numbers from the stack calculator in the character string.

Coding - fast print 2x2 sprite familiarity, up to familiarity.

Coding - Hrust Library svobodnopasppostpanyaemaya library window procedure by means of eccentricity can be packaged and paspakovyvat VARIOUS data.

Coding - Error Handling TR-DOS when working through # 3D13.

Coding - a set of procedures for constructing the user interface.

Coding - pishim virus invisible to TR-DOS.

Another world - The illusion of safety: Terrifying tales of Windows security and the Internet (Part One).

Hall of Fame - 3 methods to distinguish pealny ZX Spectrum from emulyatopov.

Hall of Fame - the charter of the National Fund of the Spectrum (HFSP).

Hall of Fame - Reserves: an attempt to present the perfect ZX Spectrum.

Hall of Fame - boiling: "And there still alive Speccy, sympathy Boxing?" Reflections in hearing.

Hall of Fame - schA say number 1: optimization of procedures, the announcement of the magazine and the new arcade toy.

Hall of Fame - schA say number 1: disassembly and Serg'a Playgear, hacking calling card, the announcement Crazy Siberian Party '2000.

Hall of Fame - A brief history of the Kemerovo group Digital Life Group.

Seven and 1 / 2 - Student mythology.

Seven and 1 / 2 - April Fools' Day 2 (end).

Seven and 1 / 2 - fairy tales for children.

Seven and 1 / 2 - Features a national ruleza or pure Siberian project (the story of Crazy Siberian Party 1999).

Samples pen - memory: story of the game "Black Crow".

Samples pen - story, "Elixir of the Beast."

Samples pen - "Last Warrior".

Advertising - text ads and announcements.

Advertising - a graphical advertising and announcements.


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
History - A small review of each issue of the newspaper.
Around the World - News from the MacWorld Expo.
Nemo open letters № 5.4

В этот день...   5 May