?login_element?

Subversion Repositories NedoOS

Rev

Rev 1424 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;+3DOS function addresses
  2. DOS_OPEN EQU #0106 ;Open file
  3. DOS_CLOSE EQU #0109 ;Close file
  4. DOS_ABAND EQU #010C ;Abandon file (force it closed)
  5. DOS_READ EQU #0112 ;Read data
  6. DOS_WRITE EQU #0115 ;Write data
  7. GETBYT   EQU #0118 ;Read one byte
  8. PUTBYT   EQU #011B ;Write one byte
  9. SETPOS   EQU #0136 ;Seek
  10. GET_1346 EQU #013C ;Get memory allocation in 1,3,4,6
  11. SET_1346 EQU #013F ;SET memory allocation in 1,3,4,6
  12. DOS_MAPB EQU #0154
  13. ;<< v1.03 >> Map drive B: to unit 0 or unit 1
  14.  
  15. FILENO  EQU #0C
  16. ;Arbitrary number from 0 to 15 for
  17. ;Z-code file. +3 BASIC uses 0-2
  18.  
  19. SAVENO  EQU #0B ;File number for save file
  20.  
  21. TRANSNO EQU #0A ;Transcript file number
  22.  
  23. FLAGS3  EQU 23398
  24. ;<< v1.03 >> System variable holding no. of drives
  25.  
  26. ;;;;;;;;;;;;;;;;;;;;;
  27. ;Transcript functions
  28.        IF p3dos
  29. ts_open
  30.         LD      A,1
  31. ;"Save as". This doesn't actually
  32. ;have any effect in the ZXIO version.
  33.         CALL    ZXNAME
  34. ;Returns filename
  35.         LD      A,H
  36.         OR      L
  37.         SCF
  38.         RET     Z
  39.         LD      B,TRANSNO
  40.         LD      C,2 ;Open to write
  41.         LD      DE,#0204
  42.         CALL    dodos
  43.         DEFW    DOS_OPEN
  44.         RET     NC
  45.         LD      A,1
  46.         LD      (tsflag),A
  47.         RET
  48.        ENDIF
  49.  
  50.        IF p3dos
  51. ts_close
  52.         LD      HL,#1A
  53.         CALL    ts_char
  54.         RET     NC
  55.         LD      B,TRANSNO
  56.         CALL    dodos
  57.         DEFW    DOS_CLOSE
  58.         RET     NC
  59.         LD      A,0
  60.         LD      (tsflag),A
  61.         RET
  62.        ENDIF
  63.  
  64.        IF p3dos
  65. ts_char
  66.         LD      A,(tsflag)
  67.         OR      A
  68.         SCF
  69.         RET     Z
  70.         LD      A,(cwin)
  71.         OR      A
  72.         SCF
  73.         RET     Z
  74.         LD      B,TRANSNO
  75.         LD      C,L
  76.         CALL    dodos
  77.         DEFW    PUTBYT
  78.         RET
  79.        ENDIF
  80.  
  81. ;;;;
  82. ;Verify the game file
  83. p3vrfy
  84.        IF p3dos
  85.         XOR     A
  86. ;<< v0.02 - border colour cycling
  87.         LD      (activea),A ;>> v0.02
  88.  
  89.         PUSH    DE
  90.         PUSH    BC
  91.         LD      B,FILENO
  92.         LD      HL,#40
  93.         LD      E,H
  94. ;SET position just after header
  95.         CALL    dodos
  96.         DEFW    SETPOS
  97.         LD      HL,0
  98.         POP     BC
  99.         POP     DE
  100. vloop
  101.         PUSH    BC
  102.         PUSH    DE
  103.         PUSH    HL
  104.         LD      B,FILENO
  105.         CALL    dodos
  106.         DEFW    GETBYT
  107.         LD      E,A
  108.         LD      D,0 ;DE = byte just read
  109.         POP     HL
  110.         ADD     HL,DE
  111.         POP     DE
  112.         POP     BC
  113.         DEC     BC
  114.         CALL    activity
  115.         LD      A,B
  116.         OR      C
  117.         JR      NZ,vloop
  118.         DEC     D
  119.         LD      A,D
  120.         CP      #FF
  121.         JR      NZ,vloop
  122.  
  123.         LD      A,(BORDCR)
  124. ; << v0.02 - remove traces of the
  125.         RRCA ;activity checker
  126.         RRCA
  127.         RRCA
  128.         AND     7
  129.         OUT     (254),A
  130.  
  131.         SCF
  132.         RET
  133. ;
  134. ;DEBUG
  135.        ELSE ;~p3dos
  136.         SCF
  137.         RET
  138.        ENDIF
  139. hbuf
  140.         DEFB "000000",13,10,"$"
  141.  
  142. ;
  143. ;<< v0.02 - cycle the border while
  144. ;verify is happening.
  145. ;
  146. activity
  147.                 ;Do something every 1k
  148.         LD      A,C
  149.         OR      A
  150.         RET     NZ
  151.         LD      A,B
  152.         AND     3
  153.         RET     NZ
  154.  
  155.         LD      A,(activea)
  156.         OUT     (254),A
  157.         INC     A
  158.         CP      8
  159.         JR      C,activ1
  160.         XOR     A
  161. activ1
  162.         LD      (activea),A
  163.         RET
  164. ;
  165. activea
  166.  
  167.         DEFB 0       ;>> v0.02
  168.  
  169. ;;;;;;;;;;;;;;;;;;
  170.  
  171.        IF p3dos
  172. ;;;;;;;;;;;;
  173. ;Numeric data
  174. chgdsk
  175.         DEFW 0
  176. ;Original CHANGE DISK routine
  177.  
  178. unit_b
  179.         DEFB 0
  180. ;Drive B is unit 0 or 1?
  181.  
  182. old_1346
  183.         DEFW 0
  184. ;Original cache and RAMdisc settings
  185.         DEFW 0
  186.  
  187. p3dver
  188.         DEFW 0
  189. ;The version of +3DOS we are using
  190.  
  191. dosde
  192.         DEFW 0
  193. ;Used to store DE while entering +3DOS
  194.  
  195. tsflag
  196.         DEFB 0
  197. ;Transcripting on or off?
  198.  
  199. ;One message (not really very informative)
  200. p3der
  201.         DEFB "+3DOS error "
  202. p3eno
  203.         DEFB "00000"
  204.  
  205.  
  206. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  207. ;Utility function to call +3DOS, and
  208. ;expand any error returned to text.
  209. ;This takes an inline word parameter,
  210. ;the address within +3DOS that should
  211. ;be called.
  212. dodos
  213.         LD      (dosde),DE
  214.         EX      (SP),HL
  215.         LD      E,(HL)
  216.         INC     HL
  217.         LD      D,(HL)
  218.         INC     HL
  219.         EX      (SP),HL
  220.         LD      (dosjmp + 1),DE
  221.         LD      DE,(dosde)
  222.         CALL    seldos
  223. dosjmp
  224.         CALL    0
  225.         CALL    sel48
  226.         RET     C
  227.         PUSH    AF      ;Error no.
  228.         LD      L,A
  229.         LD      H,0
  230.         LD      DE,p3eno
  231.         CALL    spdec2  ;2-digit
  232.         EX      DE,HL
  233.         DEC     HL
  234.         SET     7,(HL)
  235. ;SET bit 7 on last character, since
  236. ;this is a fatal error message
  237.         LD      HL,p3der
  238.         POP     AF
  239.         RET
  240.        ENDIF
  241.  
  242.        if p3dos
  243. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  244. ;Bank-switching code to take us to/from
  245. ;the +3DOS environment
  246. seldos
  247.         PUSH    AF
  248.         PUSH    BC
  249.         LD      A,(BANKM)
  250.        ;RES     4,A
  251.        ;OR      7
  252.        SET 4,A
  253.        AND #38
  254.         DI
  255.         LD      (BANKM),A
  256.         LD      BC,BANKIO
  257.         OUT     (C),A
  258.         EI
  259.         POP     BC
  260.         POP     AF
  261.         RET
  262.        endif
  263.  
  264.        IF p3dos
  265. sel48
  266.         PUSH    AF
  267.         PUSH    BC
  268.         LD      A,(BANKM)
  269.         SET     4,A
  270.         AND     USED
  271.         LD      BC,BANKIO
  272.         DI
  273.         LD      (BANKM),A
  274.         OUT     (C),A
  275.         EI
  276.         POP     BC
  277.         POP     AF
  278.         RET
  279.        ENDIF