?login_element?

Subversion Repositories NedoOS

Rev

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

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;
  3. ;A lot of the code in this file has been hand-crafted from the
  4. ;C routines in JZIP 2.0.1g
  5. ;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7. ;
  8. obj_addr:
  9.         defw    0       ;Object table address
  10. objlen: defw    0       ;Length of 1 object
  11. ptlen:  defw    0       ;Length of default property table
  12.  
  13. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  14. ;
  15. ;Get address of object DE into HL.
  16. ;
  17. objadd: push    de      ;get_object_address()
  18.         push    bc
  19.         push    af
  20.         ld      a,d     ;<< v1.01 Check for Vile 0 Error. It should have been
  21.         or      e       ;        caught earlier but this is the last defence.
  22.         call    z,v0efh ;>> v1.01
  23.         ld      hl,(obj_addr)
  24.         ld      bc,(ptlen)      ;Default property table length
  25.         add     hl,bc           ;HL -> start of objects
  26.         push    hl
  27.         ld      bc,(objlen)     ;BC = object length, DE = object number
  28.         dec     de              ;DE was 1 based
  29.         call    umult16         ;DE:= offset to object
  30.         pop     hl
  31.         add     hl,de
  32.         pop     af
  33.         pop     bc
  34.         pop     de
  35.         ret
  36. ;
  37. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  38. ;
  39. ;Locate attribute BC in object DE.
  40. ;
  41. attradd:
  42.         push    bc
  43.         call    objadd  ;HL:=object address
  44.         pop     bc
  45.         ld      a,c     ;A=attribute number
  46.         rrca
  47.         rrca
  48.         rrca            ;Divide by 8, giving offset in bytes
  49.         and     7       ;Remove the bits which went round to the top
  50.         ld      e,a
  51.         ld      d,0
  52.         add     hl,de
  53. ;
  54. ;CREATE a bitmask
  55. ;
  56. mkmask: ld      a,c
  57.         and     7       ;Attribute number
  58.         ld      b,80h
  59. mkms1:  ret     z
  60.         srl     b
  61.         dec     a
  62.         jr      mkms1
  63. ;
  64. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  65. ;
  66. ;For HL->object, read/write its parent, child, siblings
  67. ;
  68. read_child:
  69.         push    bc
  70.         ld      bc,060Ah        ;B=offset for v1-v3; C=offset for v4-v8
  71.         jr      oread
  72. ;
  73. write_child:
  74.         push    bc
  75.         ld      bc,060Ah
  76.         jr      owrite
  77. ;
  78. read_sibling:
  79.         push    bc
  80.         ld      bc,0508h
  81.         jr      oread
  82. ;
  83. write_sibling:
  84.         push    bc
  85.         ld      bc,0508h
  86.         jr      owrite
  87. ;
  88. read_parent:
  89.         push    bc
  90.         ld      bc,0406h
  91. oread:  ld      a,(zver)
  92.         cp      4
  93.         jr      c,oreadb
  94.         ld      b,0
  95.         add     hl,bc
  96.         ld      e,0
  97.         call    ZXPKWI
  98.         ld      d,b
  99.         ld      e,c
  100.         pop     bc
  101.         ret
  102. ;
  103. oreadb: ld      c,b
  104.         ld      b,0
  105.         add     hl,bc
  106.         call    peek64
  107.         ld      e,a
  108.         ld      d,0
  109.         pop     bc
  110.         ret
  111. ;
  112. write_parent:
  113.         push    bc
  114.         ld      bc,0406h
  115. owrite: ld      a,(zver)
  116.         cp      4
  117.         jr      c,owriteb
  118.         ld      b,0
  119.         add     hl,bc
  120.         ld      a,d
  121.         call    ZXPOKE
  122.         inc     hl
  123.         jr      owritee
  124. ;
  125. owriteb:
  126.         ld      c,b
  127.         ld      b,0
  128.         add     hl,bc
  129. owritee:
  130.         ld      a,e
  131.         call    ZXPOKE
  132.         pop     bc
  133.         ret
  134. ;
  135. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  136. ;
  137. ;Remove object DE from its container
  138. ;
  139. obj_remove:
  140.         push    bc
  141.         push    hl
  142.         push    de
  143.         call    objadd
  144.         ld      a,d             ;<< v1.01 Vile 0 Error?
  145.         or      e
  146.         jp      z,remret        ;>> v1.01
  147.  
  148.         ld      (objptr),hl
  149.         call    read_parent
  150.         ld      a,d
  151.         or      e
  152.         jp      z,remret        ;Object already removed
  153.         call    objadd
  154.         ld      (objpar),hl     ;HL -> parent
  155.         call    read_child      ;DE = no. of 1st child
  156.         pop     bc
  157.         push    bc              ;BC = no. to remove
  158.         call    cpdebc          ;Are they the same?
  159.  
  160.         jr      nz,remv1
  161.         ld      hl,(objptr)
  162.         call    read_sibling    ;DE = object's sibling
  163.  
  164.         ld      hl,(objpar)
  165.         call    write_child
  166.         jr      remv2
  167. ;
  168. ;DE = number of current child object. BC = number to delete.
  169. ;
  170. remv1:  call    objadd          ;HL -> current child
  171.         push    hl              ;<< v0.02 bug fix >>
  172.         call    read_sibling    ;DE = sibling of current child
  173.         pop     hl              ;<< v0.02 bug fix >>
  174.  
  175.         call    cpdebc          ;Is this object's sibling the one to remove?
  176.         jr      nz,remv1
  177.         push    hl
  178.         ld      hl,(objptr)
  179.         call    read_sibling
  180.  
  181.         pop     hl
  182.         call    write_sibling
  183. remv2:  ld      hl,(objptr)
  184.         ld      de,0
  185.         push    hl
  186.         call    write_sibling
  187.         pop     hl
  188.         call    write_parent
  189. remret: pop     de
  190.         pop     hl
  191.         pop     bc
  192.         ret
  193.  
  194. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  195. ;
  196. ;INSERT object DE in object HL.
  197. ;
  198. objptr: defw    0       ;Points to object being removed or inserted
  199. objpar: defw    0       ;Parent of object being removed or inserted
  200. objpno: defw    0       ;Number of new parent object
  201.  
  202. obj_insert:
  203.         ld      (objpno),hl     ;Number of new parent
  204.         call    obj_remove      ;Remove object DE from where it was
  205.  
  206.         ld      a,d             ;<< v1.01 Vile 0 Error?
  207.         or      e
  208.         scf
  209.         ret     z               ;>> v1.01
  210.  
  211.         push    de              ;Sets objptr but not objpar
  212.         ex      de,hl
  213.         call    objadd
  214.         ld      (objpar),hl     ;so set objpar here
  215. ;
  216. ;Get number of new parent's 1st child, set it to current object's sibling
  217. ;
  218.         push    hl
  219.         call    read_child      ;New parent's 1st child
  220.         ld      hl,(objptr)
  221.         push    hl
  222.         call    write_sibling
  223.         pop     hl
  224. ;
  225. ;Tell the object about its new parent
  226. ;
  227.         ld      de,(objpno)
  228.         call    write_parent
  229.         pop     hl
  230. ;
  231. ;SET new parent's child to new object
  232. ;
  233.         pop     de
  234.         jp      write_child
  235. ;
  236.  
  237. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  238. ;
  239. ;<< v0.02
  240. ;
  241. ;Print data for object DE (debugging code)
  242. ;
  243. obtree: push    af
  244.         push    bc
  245.         push    de
  246.         push    hl
  247.         call    ilprint
  248.         defb    'Object $'
  249.         call    hexde
  250.  
  251.         call    objadd  ;HL -> the object
  252. obtr0:  push    hl
  253.  
  254.         call    ilprint
  255.         defb    ' @ $'
  256.         call    hexhl
  257.  
  258.         call    ilprint
  259.         defb    13,10,'Siblings: $'
  260.  
  261. siblp:  call    read_sibling
  262.         call    hexde
  263.         ld      a,d
  264.         or      e
  265.         jr      z,obtr1
  266.         call    objadd
  267.         call    ilprint
  268.         defb    '[$'
  269.         call    hexhl
  270.         call    ilprint
  271.         defb    '] $'
  272.         jr      siblp
  273.  
  274. obtr1:  call    ilprint
  275.         defb    13,10,'Children: $'
  276.         pop     hl
  277.         call    read_child
  278. chlp:   call    hexde
  279.         ld      a,d
  280.         or      e
  281.         jr      z,obtr2
  282.         call    objadd
  283.         call    ilprint
  284.         defb    '[$'
  285.         call    hexhl
  286.         call    ilprint
  287.         defb    '] $'
  288.         call    read_sibling
  289.         jr      chlp
  290.  
  291. obtr2:  call    ilprint
  292.         defb    13,10,'$'
  293.         jp      popd
  294. ;
  295. ; >> v0.02
  296. ; << v1.01
  297. ;
  298. v0efh:  nop
  299.         call    ilprint
  300.         defb    'WARNING: This story file has attempted to access object 0.'
  301.         defb    13,10
  302.         defb    'The story file may behave unpredictably, or you may need '
  303.         defb    13,10
  304.         defb    'an updated version of the story file.'
  305.         defb    13,10,'$'
  306.  
  307.         push    af
  308.         push    de
  309.         ld      a,(zpc+2)
  310.         call    hexa
  311.         ld      de,(zpc)
  312.         call    hexde
  313.  
  314.         ld      a,0C9h  ;RET - only show the message once.
  315.         ld      (v0efh),a
  316.         pop     de
  317.         pop     af
  318.         ret
  319. ;
  320. ; >> v1.01
  321. ;
  322.