home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / compiler / nasm20b / nasm_src / lib / src / screen.s65 < prev    next >
Text File  |  1993-01-19  |  4KB  |  177 lines

  1.    .include #system
  2.    .include #macros
  3.    .include #misc
  4.  
  5.    .if .not .def __RUN
  6.       .vfl_bochum _string1
  7.       .vfl_bochum _hor
  8.       .vfl_bochum _ver
  9.       .vfl_bochum _screen
  10.    .else
  11.  
  12.       *     = $3000
  13.  
  14. _string1 = $F0
  15. _hor     = $F2
  16. _ver     = $F3
  17. _screen  = $F4
  18.  
  19.  
  20.  
  21.       poke     _hor,0
  22.       sta      _ver
  23.       s_print  "This is a first test",@s1+@special
  24. :wait
  25.       lda      consol
  26.       cmp      #6
  27.       bne      :wait
  28.       lda      #50
  29. :more:
  30.       pha      
  31.       s_print  "And this the second."
  32.       pla
  33.       sbc      #1
  34.       bcs      :more
  35.       rts
  36.    .endif
  37.  
  38. ; --------------------------------------------------------------
  39. ;      Just advance one line, doesn't do anything visibly
  40. ; --------------------------------------------------------------
  41. s_return:
  42.    lda      #0
  43.    sta      _hor
  44.    inc      _ver
  45.    ldy      _ver
  46.    cpy      #25
  47.    bcc      :finish
  48.    sta      _ver
  49. :finish
  50.    rts
  51.  
  52. ; --------------------------------------------------------------
  53. ; Pokes a string directly into screen memory, computes actual
  54. ; screen address from SAVMSC (OS). This could be a bit more
  55. ; general for 32 and 48 byte modes, but then why not lift this
  56. ; code and modify it ??
  57. ; This is intended as a coding shortcut. For any efficiency do
  58. ; it yourself.
  59. ; with hor/ver (user supplied)
  60. ; Returns:
  61. ;   X : #characters left in line
  62. ;   Y : #length of printed string
  63. ;   Carry set, Zero set
  64. ; ---------------------------------------------------------------
  65. s_print:
  66.    jsr      _calc_screen      ; calculate _screen address from _hor/_ver
  67.    lda      #40               ; bytes to go until we hit the next line
  68.    sec                        ; only works for 40 cols
  69.    sbc      _hor
  70.    tax                        ; counter in X
  71. :onemore
  72.    lda      (_string1),y      ; get character
  73.    beq      :finish           ; 0 ? then done ->
  74.    cmp      #155              ; RETURN ?
  75.    beq      :iscrlf           ; -> yes
  76.    jsr      scrbyte
  77.    sta      (_screen),y
  78.    inc      _hor
  79. :skip1
  80.    iny                        ; next character
  81.    bne      :skip
  82.    inc      _screen+1
  83.    inc      _string1+1
  84. :skip
  85.    dex                        ; --bytes to go this line
  86.    bne      :onemore          ; still positive then up
  87.  
  88.    jsr      :scroll
  89.    bne      :onemore
  90.  
  91. :scroll
  92.    inc      _ver
  93.    lda      _ver              ; check if we went too low
  94.    cmp      #25               ; too low ?
  95.    bcc      :njet             ; no ->
  96.    lda      #0
  97.    sta      _ver              ; yes wrap to top
  98.    dmove    SAVMSC,_screen    ; set _screen to top
  99.    tya                        ; don't forget to sub Y
  100.    sbc      _screen           ; from _screen cause we are keeping
  101.    sta      _screen           ; Y for the _string1
  102.    bcs      :njet
  103.    dec      _screen+1
  104. :njet:
  105.    poke     _hor,0
  106.    ldx      #40
  107.    rts
  108.  
  109. :iscrlf
  110.    dex                        ; screen remains the same for next INY
  111.    txa                        ; in skip1. 
  112.    adc      _screen           ; Calc new _screen address
  113.    sta      _screen
  114.    jsr      :scroll
  115.    inx                        ; set counter to 41
  116.    bne      :skip1
  117.  
  118. ; --------------------------------------------------------------
  119. ; Calc_screen, computes actual screen address from SAVMSC (OS)
  120. ; and hor/ver (user supplied)
  121. ; Returns:
  122. ; SCREEN : actual screen address
  123. ;      A : LSB of screen address
  124. ;      Y : 0
  125. ;      X : <unchanged>
  126. ; ---------------------------------------------------------------
  127. _calc_screen:
  128.    lda      SAVMSC+1
  129.    sta      _screen+1
  130.    lda      SAVMSC
  131.  
  132.    clc
  133.    ldy      _ver
  134.    beq      :done
  135.  
  136. :loop
  137.    adc      #40
  138.    bcc      :next
  139.    inc      _screen+1
  140.    clc
  141. :next
  142.    dey
  143.    bne      :loop
  144.  
  145. :done
  146.    adc      _hor
  147.    sta      _screen
  148.    bcc      :fine
  149.    inc      _screen+1
  150. :fine
  151.    rts
  152.  
  153. ; --------------------------------------------------------------
  154. ;        Converts a byte into it's screen representation
  155. ; there are probably better ways...
  156. ; --------------------------------------------------------------
  157. scrbyte:
  158.    pha
  159.    and      #$7F
  160.    cmp      #$20
  161.    bcc      :case1
  162.    cmp      #$60
  163.    bcs      :case3
  164.    pla
  165.    sbc      #$1F
  166.    rts
  167.    
  168. :case1
  169.    pla
  170.    adc      #$40
  171.    rts
  172.    
  173. :case3
  174.    pla
  175.    rts
  176.  
  177.