home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / club100 / ref / trgins.asm < prev    next >
Assembly Source File  |  2006-10-19  |  2KB  |  110 lines

  1. ;------
  2. TRGINS:
  3. ;------
  4. ;Installs a 6 OR LESS character name as a ROM trigger file on the
  5. ;Model 100 directory.
  6. ;Entry: HL points to 6 OR LESS null TERMINATED
  7. ;    character string to use for the name.
  8. ;Exit:  None
  9.  
  10. ;==============================================================
  11. ;Model 100 addresses and routines used.
  12.  
  13. ;Retrieve next directory entry of an active file
  14. ;Entry:    HL should point to one directory entry less than the
  15. ;    point at which to begin the search. The search routine
  16. ;    starts by incrementing to the next entry
  17. ;Exit:    Z set = no more entries
  18. ;        else
  19. ;    HL points to the next directory entry with an
  20. ;        active file.
  21. NXTDIR:     EQU      020D5H
  22. ;------
  23.  
  24. ;Locate an empty directory slot.
  25. ;Entry:    none
  26. ;Exit:    HL points to a free slot
  27. FREDIR: EQU      020ECH
  28. ;------
  29.  
  30. ;Beginning of the User Directory Area
  31. USRDIR:        EQU    0F9BAH
  32. ;------
  33.  
  34.  
  35.  
  36. ;1.    Test if a Trigger file exists
  37.  
  38.     PUSH    H        ;Save New File name.
  39.     CALL    FOTRG        ;Find an old trigger file
  40.     POP    D        ;File Name
  41.  
  42. ;2.    If so then install over it
  43.  
  44.     JNZ    TRGINS1        ;If found install over it.
  45.  
  46. ;3.    Otherwise locate a free directory
  47.  
  48.     PUSH    D        ;else
  49.     RST    6        ;Call Std ROM to
  50.     DW    FREDIR        ;Find an empty Slot.
  51.     POP    D        ;and install
  52.  
  53. ;4.    Copy in 0F0H file type and 0FFFFH start
  54.  
  55. TRGINS1:
  56.     MVI    M,0F0H        ;Trigger File type
  57.     INX    H        ;Step past start
  58.     MVI    M,0FFH        ;Set start to 0FFFFH
  59.     INX    H
  60.     MVI    M,0FFH
  61.     INX    H
  62.  
  63. ;5.    Copy the name to the first null and then
  64. ;    nulls to the rest of the name.
  65.     MVI    C,8        ;and copy in the name
  66.  
  67. TRGINS2:
  68.     LDAX    D
  69.     MOV    M,A
  70.     INX    H        ;Fill the rest of the
  71.     ORA    A        ;name with nulls when we
  72.     JZ    TRGINS3        ;hit the null terminator
  73.     INX    D
  74. TRGINS3:
  75.     DCR    C        ;directory name with nulls
  76.     JNZ    TRGINS2
  77.     RET
  78.  
  79. ;------
  80. FOTRG:
  81. ;------
  82. ;Searches the directory for an already existing trigger
  83. ;file and returns a pointer to it in HL if found.
  84. ;Entry:    None
  85. ;Exit:    Z set if none found
  86. ;        else
  87. ;    HL points to the directory entry
  88.  
  89.  
  90. ;1.    Starting behind the free directory
  91.     LXI    H,USRDIR-11    ;Free dir - 1 entry
  92.  
  93. ;2.    Get the next in use File
  94.  
  95. FOTRG1:
  96.     RST    6        ;Call Std ROM to
  97.     DW    NXTDIR        ;get Next Live File
  98.     RZ            ;no file found
  99.  
  100. ;3.    Return Pointing to it if it is a ROM
  101. ;    trigger file.
  102.  
  103.     MOV    A,M        ;is it a ROM Trigger
  104.     CPI    0F0H        ;Type
  105.     JNZ    FOTRG1        ;No - Go again
  106.     ANA    A        ;Clear Z flag
  107.     RET
  108.  
  109.     END
  110.