home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / enterprs / c128 / util / sfxsrc.arc / GRAPH.A < prev    next >
Encoding:
Text File  |  1990-02-12  |  2.5 KB  |  108 lines

  1. ; graph.a
  2. ;──────────────────────────────────────────────────────────────────────────────
  3. ; Bar Graph display subroutine for LHSFX
  4. ;──────────────────────────────────────────────────────────────────────────────
  5.  
  6.             INSTXT "sfx.i"
  7.  
  8.             PUBLIC InitGraph
  9.             PUBLIC UpdateGraph
  10.  
  11.             EXT Prt
  12.             EXT Abort
  13.             EXT stop
  14.  
  15. Space       EQU 32
  16. Rev         EQU 18                  ; Reverse video on
  17. RevOff      EQU 146                 ; Reverse video off
  18. Left        EQU 157                 ; Cursor left
  19.  
  20.  
  21. BarChar     fcb RevOff,32           ; 0 bars
  22.             fcb RevOff,180          ; 2 bars
  23.             fcb RevOff,161          ; 4 bars
  24.             fcb 18,170              ; 6 bars
  25.  
  26.             BSS Remainder,1
  27.             BSS BarSize,3
  28.  
  29. ;──────────────────────────────────────────────
  30. ; Initialize. Call with OriginalSize in .a.x.y
  31. ;──────────────────────────────────────────────
  32.  
  33. InitGraph   sta BarSize
  34.             stx BarSize+1
  35.             sty BarSize+2
  36.             and #3
  37.             sta Remainder
  38. Graph0      ldx #2
  39. Graph1      lsr BarSize+2
  40.             ror BarSize+1
  41.             ror BarSize
  42.             dex
  43.             bne Graph1
  44.  
  45. Graph2      lda BarSize
  46.             ora BarSize+1
  47.             beq DoRem
  48.             lda #18
  49.             jsr Prt
  50.             lda #' '
  51.             jsr Prt
  52.             lda BarSize
  53.             bne Graph3
  54.             dec BarSize+1
  55. Graph3      dec BarSize
  56.             jmp Graph2
  57.  
  58. DoRem       lda Remainder
  59.             asl a
  60.             tay
  61.             lda BarChar,y
  62.             jsr Prt
  63.             iny
  64.             lda BarChar,y
  65.             jsr Prt
  66.             dec Remainder
  67.             lda #RevOff
  68.             jmp Prt
  69.  
  70. ;───────────────────────────────────────
  71. ; Update and possibly abort on RUN/STOP
  72. ;───────────────────────────────────────
  73.  
  74. UpdateGraph pha
  75.             txa
  76.             pha
  77.             tya
  78.             pha
  79.  
  80.             jsr stop                ; Check for user abort
  81.             beq gabort
  82.             lda Remainder
  83.             bpl Graph4
  84.             lda #Left
  85.             jsr Prt
  86.             lda #3
  87.             sta Remainder
  88. Graph4      lda #Left
  89.             jsr Prt
  90.             jsr DoRem
  91.  
  92. Graph5      pla
  93.             tay
  94.             pla
  95.             tax
  96.             pla
  97.             rts
  98.  
  99. gabort      ldy #>ErrMssg
  100.             ldx #<ErrMssg
  101.             jmp Abort
  102.  
  103. ErrMssg     fcb 13
  104.             fcc "RUN STOP PRESSED"
  105.             fcb 13,0
  106.  
  107.             END
  108.