Spectrofon #03
28 февраля 1994
  TR-DOS  

System - work with TR-DOS in the assembly.

<b>System</b> - work with TR-DOS in the assembly.
            SYSTEM


(C) Pavel Nikitin.


  WORKING WITH TR-DOS in assembler

  ---------------------------

   In this article we will discuss
some techniques use
functions of TR-DOS when programming in assembler.

1. FORMAT TRACK.


   Many programmers consider
formatting operation Tracks
mystery. Between
to format the track in an arbitrary way is not so
difficult. Type the following program in any assembly, and
You'll find this:



        ORG # EA60; Start address (60000 in decimal)

        DI; Disable interrupt

        LD A, # 8; Code Download command VG93

        CALL ZAGR

        LD A, # 3C; side code (equal # 3C and # 2C

                     ; For acc. upper and lower sides)

        LD C, # 00; track number (in this case, the 0th)

        CALL SEARCH; Calling searching for tracks

        CALL FORMAT; procedure call format

        CALL FORMAT; (preferably to call several times)

        EI; Interrupt Enable

        RET; Back to BASIC
ZAGR LD IX, # 2FC3

        JP TO_TRDS
SEARCH LD IX, # 2F4D; address in ROM TR-DOS

                      , Searching for tracks
TO_TRDS PUSH IX; pushes the address of procedure

        JP # 3D2F; Go through the stack in ROM TR-DOS



FORMAT LD HL, FRM_DAT; sequence of procedures

        LD BC, # 007F; directly

        LD A, # F0; producing

        LD IX, # 2F57; formatting

        PUSH IX

        LD IX, # 3FCA

        PUSH IX

        LD IX, # 2FC3

        JP TO_TRDS



   Do not forget that formatting procedure is nothing
otherwise, a record, but not the data (your programs, arrays, 
and etc.), and bytes of system information on the sector.



   FRM_DAT - a list of bytes describing the sector of
track.


FRM_DAT DEFS 50, # 4E; first gap.

        DEFS 12, # 00

        DEFS 03, # F5; recording three bytes # A1

                      , And initialize the checksum.

        DEFB # FE; Address label index data,

                      , Ie # FE "speaks" SH, what's next

                      ; Are traded (on the track, sectors, etc.)

                      ; Data.

        DEFB # NN; Track Number

        DEFB # NN; Number of

        DEFB # NN; Number sector

        DEFB # NN; length of the sector (ranging

                      ; 0,1,2,3 for acc. length in bytes

                      ; 128,256,512,1024)

        DEFB # F7; recording two byte checksum

        DEFS 22, # 4E; second gap

        DEFS 12, # 00

        DEFS 03, # F5; Initializing checksum

        DEFB # FB; (says "SH, that further written

                      ; Data from which and are your files)

        DEFS NNNN, # 00; data (the number depends on the # NNNN

                      ; Sector size - respectively

                      , 128, 256, 512, 1024 bytes)

        DEFB # F7; recording two byte checksum

        DEFS 54, # 4E



   For each track, you need to
make a number of tables FRM_DAT, how many
sectors you want to get in
this track:


        SECTOR1_FRM_DAT 1

        SECTOR2_FRM_DAT 2

         etc.


   But it must be remembered
that one track can be prescribed
approximately (16 * 256 128) bytes
information.



   Next comes a list of basic
procedures ROM TR-DOS, used when formatting.

1) When you sign the register A should
contain a command code. Procedure
provides a check at the end
command and executes the delay.

# 2F57 OUT (# 1F), A; entry in the register commands

                       , And the number 8 from the battery
# 2F59 IN A, (# FF); check at the end of command

        AND # 80

        JR Z, # 2F59

        PUSH BC; Saving BC

        CALL # 3DFD; Call Subroutine Delay

        POP BC; Recovery BC

        RET; Return from procedure



2) are entered into the instruction register VG93
the number of battery

# 2FC3 OUT (# 1F), A

        RET


3) Internal procedure
TR-DOS, performing a delay


         # 3DFD LD A, # 50, two elementary

         # 3DFF LD C, # FF; nested loop

         # 3E01 DEC C; providing

                 JR NZ, # 3E01; delay

                 DEC A

                 JR NZ, # 3DFF

                 RET



4) When you sign the register A contains
number to boot the system
register. Register C contains a number of the first track file. 
The procedure provides a recording of the track number in the 
register data, executing the actuator drive to the right track, 
check for the command and execution delays. 

# 2F4D OUT (# FF), A; Load System Register

                       ; Code of # 3C and # 2C

        LD A, C; transfer of the register C to A

        OUT (# 7F), A; Entering the track number in the 
registration data 

        CALL # 3DFD; Call Subroutine Delay

        LD A, 18

        OUT (# 1F), A
# 2F59 IN A, (# FF); check at the end of command

        AND # 80

        JR Z, # 2F59

        PUSH BC; Saving BC

        CALL # 3DFD; Call Subroutine Delay

        POP BC; Recovery BC

        RET

5) The procedure, output from
information (write to disk).

# 3FCA IN A, (# FF); cycle expectations

        AND # C0

        JR Z, # 3FCA

        RET M

        OUTI; Listing Information

        JR # 3FCA


   Using the procedure described
formatting, you can put
"Tag" on the disk, if you format the track as follows: first 16
sector of the Standard, and one with
number n> 16 128 bytes.



   When copying such a disc
Last track copyist
Sector will not notice and he will not be copied. Track can be 
easily test the reading of his standard procedure TR-DOS:



       LD B, 1; Number of readable sectors.

       LD C, 5; code read command of sectors.

       LD D, TREK; track number.

       LD E, SECTOR; number of sectors.

       LD HL, ADDR; Address accommodate the readout sector.

       CALL # 3D13; Group entry procedures for TR-DOS.

       RET

2. DRIVER read from disk, do NOT
Requires System Variables TR-DOS.


   Many of the toys, especially multi-level, not always well
amenable diskovizatsii using the standard download procedure 
TR-DOS, because at This should restore the system variables 
TR-DOS, to allocate a buffer, etc. 


   Below is a sector driver read the disc, with skilful
the use of which load
the disc will be less
painful for the program, because
driver does not need the system variables and an additional 
buffer for reading, and with no problemma

interrupts.



   Parameters for input:


   HL - the load address in memory;

   DE - the initial track, the sector;

   B - number of sectors.


LOADER DI; disable the interrupts.
NXTT PUSH BC; Saving BC.

        PUSH DE; --//-- DE.

        LD A, D; identify the physical

        OR A; track number and the parties.

        RRA

        LD C, A

        LD A, # 3C; # 3C - code of zero.

        JR NC, SIDE; Go to the installation side.

        LD A, # 2C; # 2C - code of the first part.
SIDE LD IX, # 2F4D; Calling the installation side.

        CALL TO_TRDS

        POP DE; Recovering DE.

        POP BC; --//-- BC.



CONT PUSH BC

        PUSH DE

        LD IX, # 2F1B

        CALL TO_TRDS; Just reading the sector.

        POP DE

        INC H

        INC E

        BIT 4, E; If the sector has passed for 15 th,

        JR Z, NXTS; it becomes a 0-vym and track

        LD E, # 00; incremented.

        INC D

        POP BC

        DJNZ NXTT

        RET
NXTS POP BC

        DJNZ CONT
TO_TRDS PUSH IX; procedure call TR-DOS'a

        JP # 3D2F



EXAMPLE:


        LD HL, # 6000; Reading directory drive

        LD DE, # 0000 at # 6000.

        LD B, # 9

        CALL LOADER

        EI

        RET



   Using this driver, you must
remember that the reading errors with
disk are not processed. If
length of the feed unit is not
multiple of 256, then no special
measures will be teryatsya 1 <= n <= 255 bytes
information. Bytes nn = (256 * count
sectors - the length in bytes) will be
corrupted. They must be preserved
(Useful for multi-block
programs)


EXAMPLE: To be produced by loading # 2000 bytes at address # 
6000 with preservation of "spoiling" bytes

in the display area.


        LD HL, # 6000; Load address

        PUSH HL

        LD DE, # 2000; Number of bytes

        ADD HL, DE

        PUSH HL

        PUSH DE

        LD DE, 16384; Save

        LD BC, 256; "spoiling"

        LDIR; bytes

        POP DE

        LD A, D; Calculation

        QR A; number

        JR Z, M1; downloads

        INC D; sectors
M1 LD B, D

        POP DE

        POP HL

        PUSH DE

        LD DE, START_TR_SEC


        CALL LOADER; Calling bootloader

        POP DE; Recovery

        LD HL, 16384; spoiled

        LDIR; bytes

        EI

        RET



   You may ask how you can load levels from the disk, not 
knowing their primary track and the sector? For

This should highlight the main
(Main) block, process it and
after written one after the other levels:


        main block

        level1

        level2

        level3

        etc.



   After this procedure, let
command MOVE, that the files are placed one after the other not
only in the catalog, and that between
they had no extraneous information. Make a table size (in 
sectors) at all levels. After downloading main_blok record last 
track / sector. Then, choosing the level, take from the table 
length and add to the last track / sector, calculating initial 
track / sector needs level.




   This will help you next
procedure that the initial
track / sector returns track / sector
with a pass to # nn sectors.



DE - beg. track / sector.
A - number of skipped sectors.
According to the exit in DE new track / sector.



        LD B, # 10; number of sectors per track.

        ADD A, E; Skip to start of the track.
M1 CCF

        SUB B; Move to the track.

        JR C, M2; All?

        INC D; No, to increase the track number.

        JR M1
M2 ADD A, B

        LD E, A; new start sector.

        RET



3. FEATURES OF THE BUTTONS
MAGIC.



   Another little thing that you
can be useful - is the protection
from MAGIC'a. Below, we consider
three elementary version of the defense.


a) Pressing MAGIC spoiled two cells, which are stored
survey data keyboard
(LAST_KEY). You will be able to without them
Labor test.


b) If you put a stack of screen
(SP <= # 4038), then when you save
register stack "climb" into the ROM and
in this work MAGIC'a end.



a) "RESET" VG93:


         CALL RESET

         EI

         RET
RESET LD HL, # 1FF3

         XOR A

         PUSH HL

         DI

         JP # 3D2F



   Use this technique should be after all the downloads, because
VG93 if not restore, then
read it will not.


P. Thanks in advance for all
additions and corrections. You
should be noted that this
article does not purport to be complete
coverage of the issues. If everything goes perfectly
plain and simple, you, dear readers, have forgotten how to think
and lose your cravings for comprehension
incomprehensible.





Other articles:

Expertise - parsing the game "Genghis Khan". You could repeat conquest of the Tatar-Mongol.

Debut - the passage of "ZZZZ" - original adventyurnaya humorous game.

Debut - the passage of "Castle Master" - a game that features a three-dimensional shaded graphics and an abundance of puzzles.

Exam - the task of playing Castle Master.

Review - Monologue Spectrum died and the funeral was not? ". Game news: SWIV, Dizzy 7, Steg, Cisco Heat, Battle Command. Hitparad with Mitinskoe market.

From the world of bat - an overview of mail. Answers questions from readers of the magazine.

Archive - the game is considered "Great Britain Ltd", which you can try as prime minister.

System - work with TR-DOS in the assembly.

Advertising - Free offers and ads.


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

Similar articles:
Entry - the contents of rooms.
Game room - SNAKE-HELP1. Tips for playing Snake.
Aperativchik - On the new shell magazine.

В этот день...   29 April