?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;
  3. ;0OPs
  4. ;
  5.  
  6. zero_ops:       ;0OP: 0   1     2      3      4       5       6        7
  7.         defw    rtrue,  rfalse, print, prret, no_op,  d_save, d_restr, restart
  8.         defw    rpop,   catch,  zquit, newln, sstatus,vrfy,   fail,    piracy
  9. ;
  10. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  11. ;
  12. ;0OP returns
  13. ;
  14. rpop:   call    zpop
  15.         jr      z_ret
  16. ;
  17. rfalse: ld      hl,0
  18.         jr      z_ret
  19. ;
  20. rtrue:  ld      hl,1
  21. z_ret:  ex      de,hl   ;DE = returned value
  22.         ld      ix,(zsp)
  23.         ld      l,(ix+0)
  24.         ld      h,(ix+1)
  25.         ld      (zpc),hl
  26.         ld      l,(ix+2)
  27.         ld      h,(ix+3)
  28.         ld      (zpc+2),hl
  29.         ld      l,(ix+36)
  30.         ld      h,(ix+37)       ;Routine stack pointer
  31.         ld      (rsp),hl
  32.         ld      a,(ix+34)       ;CALL type - 0 to return a result in DE
  33.         ld      bc,38           ;1 to return nothing
  34.         add     ix,bc           ;2,3 for timer interrupt returns
  35.         ld      (zsp),ix        ;POP that frame
  36.         cp      3
  37.         jp      z,rchr_iret
  38.         cp      2
  39.         jp      z,timer_iret
  40.         or      a
  41.         scf
  42.         ret     nz
  43.         ex      de,hl           ;HL = returned value
  44.         scf
  45.         jp      ret_hl
  46. ;
  47. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  48. ;
  49. prret:  call    print           ;Print_ret
  50.         call    newln
  51.         jp      rtrue
  52. ;
  53. print:  call    zpcipeek
  54.         ld      b,a
  55.         call    zpcipeek
  56.         ld      c,a             ;BC=packed word
  57.         call    printwrd
  58.         bit     7,b
  59.         jr      z,print
  60.         call    rshift
  61.         scf
  62.         ret
  63. ;
  64. printwrd:
  65.         push    bc
  66.         ld      a,b
  67.         rrca
  68.         rrca
  69.         and     1Fh
  70.         call    op_zchar
  71.         ld      a,b
  72.         rla
  73.         rla
  74.         rla
  75.         and     018h            ;
  76.         ld      b,a
  77.         ld      a,c
  78.         rlca
  79.         rlca
  80.         rlca
  81.         and     7
  82.         or      b
  83.         call    op_zchar
  84.         ld      a,c
  85.         and     1Fh
  86.         call    op_zchar
  87.         pop     bc
  88.         ret
  89. ;
  90. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  91. ;
  92. newln:  ld      hl,0dh
  93.         call    ll_zchr
  94.         scf
  95.         ret
  96. ;
  97. no_op:  scf
  98.         ret
  99. ;
  100. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  101. ;
  102. zquit:  xor     a
  103.         ld      (running),a
  104.         scf
  105.         ret
  106. ;
  107. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  108. ;
  109. piracy: jp      branch  ;Assume genuine
  110.  
  111. vrfy:   ld      hl,1ah
  112.         ld      e,0
  113.         call    ZXPKWD
  114.         ld      l,c
  115.         ld      h,b     ;HL = file length
  116.         ld      e,0
  117.         sla     l
  118.         rl      h
  119.         rl      e
  120.         ld      a,(zver)
  121.         cp      4
  122.         jr      c,vrfy1 ;v1-3: Scale by factor of 2
  123.         sla     l
  124.         rl      h
  125.         rl      e
  126.         cp      6       ;v4-v5: Scale by factor of 4
  127.         jr      c,vrfy1
  128.         sla     l       ;v6: Scale by factor of 8
  129.         rl      h
  130.         rl      e       ;EHL = true file length
  131. vrfy1:  ld      bc,40h  ;<< v0.02 >> This label moved down 3 lines, bug fix
  132.         and     a
  133.         sbc     hl,bc
  134.         jr      nc,vrfy2
  135.         dec     e
  136. vrfy2:  push    hl      ;EHL = no. of bytes to verify
  137.         pop     bc
  138.         ld      d,e     ;DBC = no. of bytes to verify
  139.         call    ZXVRFY
  140.         push    hl      ;Calculated sum
  141.         ld      hl,1ch
  142.         ld      e,0
  143.         call    ZXPKWI  ;BC = checksum
  144.         pop     hl      ;Calculated sum
  145.         and     a
  146.         sbc     hl,bc
  147.         jp      z,branch
  148.         jp      nbranch
  149. ;
  150. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  151. ;
  152. catch:  ld      a,(zver)
  153.         cp      5
  154.         jr      c,v1pop
  155.         ld      hl,(zstop)      ;Top of z-stack
  156.         ld      de,(zsp)
  157.         and     a
  158.         sbc     hl,de           ;HL = stack frame ID, independent of the
  159.                                 ;stack base (necessary for savefile
  160.                                 ;compatability).
  161.         scf
  162.         jp      ret_hl
  163. ;
  164. v1pop:  call    zpop
  165.         scf
  166.         ret
  167. ;
  168. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  169. ;
  170. restart:
  171.         ld      a,2
  172.         ld      (running),a
  173.         scf
  174.         ret
  175. ;
  176. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  177. ;
  178. ;<< v0.04  show_status - draw the status line
  179. ;
  180. sstatus:
  181.         ld      a,(zver)
  182.         cp      3
  183.         scf
  184.         ret     nz
  185.         call    flush_buf
  186.         ld      a,1             ;1 line for status line
  187.         call    ZXSWND
  188.         ld      a,1
  189.         call    ZXUWND
  190.         ld      a,1             ;Reverse on
  191.         call    ZXSTYL
  192.  
  193.         call    ZXGETX          ;A = screen width
  194.         ld      b,a
  195. sblank: push    bc
  196.         ld      hl,' '
  197.         ld      a,1
  198.         call    ZXZCHR
  199.         pop     bc
  200.         djnz    sblank
  201.         ld      bc,0101h
  202.         call    ZXSCUR
  203.  
  204.         ld      a,10h           ;1st global
  205.         call    get_glb         ;HL := object number
  206.         ex      de,hl
  207.         ld      a,d             ;<< v1.01 Guard against object 0 errors
  208.         or      e
  209.         jr      z,noloc         ;>> v1.01
  210.         call    objadd          ;Get address of object into HL
  211.         ld      bc,7
  212.         add     hl,bc
  213.         ld      e,0
  214.         call    ZXPKWI          ;BC = address
  215.         inc     bc              ;skip count byte
  216.         ld      h,b
  217.         ld      l,c
  218.         call    printp1         ;Print location object
  219.         call    flush_buf
  220. noloc:  ld      hl,1            ;<< v1.04 Flags 1 is at address 1 >>
  221.         call    ZXPK64          ;Get Flags 1, bit 1
  222.         bit     1,a
  223.         ld      a,':'
  224.         ld      de,stbuf
  225.         jr      nz,sltime
  226.         ld      a,'/'
  227. sltime:
  228.         ld      (statsep),a
  229. ;
  230. ;Status contains score/turns
  231. ;
  232.         ld      a,11h           ;"Score" global
  233.         push    de
  234.         call    get_glb         ;Score/turns
  235.         pop     de
  236.         bit     7,h
  237.         jr      z,pscore
  238.         ld      a,'-'
  239.         ld      (de),a
  240.         inc     de
  241.         call    neghl
  242. pscore: call    spdec           ;Done score
  243.         ld      a,(statsep)
  244.         ld      (de),a
  245.         inc     de
  246.         ld      a,12h           ;"Turns" global
  247.         push    de
  248.         call    get_glb
  249.         pop     de
  250.         call    spdec
  251.         ld      hl,stbuf
  252.         ex      de,hl
  253.         and     a
  254.         sbc     hl,de           ;L = Length of the score/turns string
  255.         ld      b,l
  256.         push    bc
  257.         ld      bc,0138h        ;8 characters in from the left
  258.         call    ZXSCUR          ;Right-align the score/turns
  259.         pop     bc
  260.         ld      de,stbuf
  261.         jr      ostbuf
  262. ;
  263. ostbuf: push    bc
  264.         push    de
  265.         ld      a,(de)
  266.         ld      l,a
  267.         ld      h,0
  268.         ld      a,1
  269.         call    ZXZCHR
  270.         pop     de
  271.         pop     bc
  272.         inc     de
  273.         djnz    ostbuf
  274. ;
  275.         xor     a
  276.         call    ZXSTYL
  277.         xor     a
  278.         call    ZXUWND
  279.         scf
  280.         ret
  281. ;
  282. statsep:
  283.         defb    '/'
  284. stbuf:  defb    '999/9999        '
  285.