home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / compiler / nasm20b / libinc / demo / resident.s65 < prev    next >
Text File  |  1993-01-19  |  4KB  |  226 lines

  1.    .include #system
  2.    .include #os
  3.    .include #misc
  4.    .include #handler.h65
  5.  
  6. _value   == $E0
  7. _string1 == $E2
  8. _hor     == $E4
  9. _ver     == $E5
  10. _tmp1    == $E6
  11. _tmp2    == $E8
  12. _tmp3    == $EA
  13. _screen  == $EC
  14.  
  15.  
  16.    .macro intro
  17.       sta   :savea
  18.       txa
  19.       pha
  20.       jsr   :intro
  21.       s_print  %$1
  22.    .endm
  23.  
  24.    .macro outro
  25.       .if   %0 = 2
  26.          tsx
  27.          inx
  28.          inx
  29.          inx
  30.          lda   $100,X
  31.          cmp   #$C0
  32.       .endif
  33.       pla
  34.       tax
  35.       lda   #>:outro-1
  36.       pha
  37.       lda   #<:outro-1
  38.       pha
  39.       .if   %0 = 2
  40.          bcc   njet
  41.          lda   osrts+1
  42.          pha
  43.          lda   osrts
  44.          pha
  45. njet
  46.       .endif         
  47.       lda   :savea
  48.       jmp   (%1)
  49.    .endm
  50.  
  51.  
  52. start:
  53.       jmp   install
  54.  
  55. ; --------------------------------------------------------------
  56. ;        The CIO handlers that replace the old handlers
  57. ; --------------------------------------------------------------
  58. :open
  59.       intro    "נסדמ-"        ; load ATARI 8-BIT font
  60.       outro    :xopen
  61. fix1  =  * - 2
  62.  
  63. :close
  64.       intro    "בכנצד-"
  65.       outro    :xclose
  66. fix2  =  * - 2
  67.  
  68.  
  69. :get
  70.       intro    "ודק-"
  71.       jsr      :pr_icbll
  72.       outro    :xget
  73. fix3  =  * - 2
  74.  
  75.  
  76. :put
  77.       intro    "סרק-"
  78.       jsr      :pr_icbll
  79.       outro    :xput,@special
  80. fix4  =  * - 2
  81.  
  82.  
  83. :status
  84.       intro    "צקIJקרצ-"
  85.       outro    :xstatus
  86. fix5  =  * - 2
  87.  
  88.  
  89. :special
  90.       intro    "צסדבחIJכ-Cmd: $"
  91.       poke     _value+1,0
  92.       move     iccomz,_value
  93.       jsr      :utoh
  94.       jsr      :space
  95.       jsr      :pr_icbll
  96.       outro    :xspecial
  97. fix6  =  * - 2
  98.  
  99.  
  100. :intro
  101.       move  :savex,_hor
  102.       move  :savey,_ver
  103.       rts
  104.  
  105. :outro
  106.       php
  107.       pha
  108.       txa
  109.       pha
  110.       tya
  111.       pha
  112.       sta      _value
  113.       .if AFTERBUFFER
  114.          s_print  " Y:$"
  115.       .else
  116.          s_print  " Ret:$"
  117.       .endif
  118.       dpoke    _string1,:buffer
  119.       jsr      :clrbuf
  120.       lda      _value
  121.       jsr      utob
  122.       jsr      s_print
  123.       .if AFTERBUFFER
  124.          s_print  " $"
  125.          jsr   :pr_icbll2
  126.       .endif
  127. ; now do the CONSOL key stuff
  128.  
  129.       jsr      :space
  130.       jsr      s_return
  131.  
  132.       .if CONSOLKEY
  133.          .if BLINKER
  134.             lda   COLOR4
  135.             pha
  136.             eor   #$F4
  137.             sta   COLOR4
  138.          .endif
  139. :wait
  140.          lda   CONSOL
  141.          eor   #7
  142.          beq   :wait
  143.          cmp   #4
  144.          bcc   :over
  145. :until
  146.          lda   CONSOL
  147.          eor   #7
  148.          bne   :until
  149. :over
  150.          .if BLINKER
  151.             pla
  152.             sta   COLOR4
  153.          .endif
  154.          move  _hor,:savex
  155.          move  _ver,:savey
  156.       .endif
  157.       pla
  158.       tay
  159.       pla
  160.       tax
  161.       pla
  162.       plp
  163. :nowhere
  164.       rts
  165.  
  166. ; --------------------------------------------------------------
  167. ;           Print buffer address and length in HEX
  168. ; --------------------------------------------------------------
  169. :pr_icbal
  170.       dmove    ICBALZ,_value
  171.       jmp      :utoh
  172.  
  173. :pr_icbll
  174.       s_print  "Buf:$"
  175. :pr_icbll2
  176.       jsr      :pr_icbal
  177.       s_print  ",$"
  178.       dmove    ICBLLZ,_value
  179.  
  180. :utoh
  181.       dpoke    _string1,:buffer
  182.       jsr      :clrbuf
  183.       jsr      utoh
  184.       dpoke    _string1,:buffer
  185.       jmp      s_print
  186.  
  187.  
  188. :clrbuf
  189.       ldx      #osrts-:buffer-1
  190.       lda      #0
  191. :clr
  192.       sta      :buffer,x
  193.       dex
  194.       bne      :clr
  195.       rts
  196.  
  197. :space
  198.       dpoke    _string1,:strspace
  199.       jmp      s_print
  200.  
  201. :strspace
  202.       .byte    " ",0
  203.  
  204. :savea   .byte 0
  205. :savex   .byte 0
  206. :savey   .byte 0
  207.  
  208. ourtab:   .word :open-1,:close-1,:get-1,:put-1,:status-1,:special-1
  209.          jmp   :nowhere
  210.  
  211. theirtab:
  212. :xopen   .ds   2
  213. :xclose  .ds   2
  214. :xget    .ds   2
  215. :xput    .ds   2
  216. :xstatus .ds   2
  217. :xspecial .ds  2
  218. :xinit   .ds   3
  219.  
  220. othertab .ds   15
  221.  
  222. :buffer  .ds   6
  223. osrts:   .ds   2
  224.  
  225.  
  226.