home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine 1996 / ARCHIVE_96.iso / discs / mag_discs / volume_9 / issue_02 / weather / afax next >
Text File  |  1995-07-13  |  4KB  |  144 lines

  1. ;     > a.afax
  2. ;       
  3. ;   use with faxdisp as the calling program
  4. ;       Assembly language module for fax plotting program
  5. ;   gets own data one pixel at a time  
  6.  
  7. .INCLUDE "A.SWINAMES"     ; converts swi names to numbers
  8. .INCLUDE "A.REGNAMES"     ; converts register names to numbers
  9. .INCLUDE "A.ADR"
  10.  
  11. ;
  12. ;       External functions
  13. ;
  14.         .EXTERN _printf, x$stack_overflow, color
  15.  
  16.         .AREA A$$code
  17.  
  18. ;
  19. ;       Constant definitions
  20. ;
  21. porta  = 0x01              ; these will have more significance
  22. portb  = 0x00              ; if you are familiar with the 6522
  23. ifr    = 0x0d              ; versatile interface adapter, but
  24. pcr    = 0x0c              ; do not worry about them!
  25. modread = 0x80941
  26. modwrite = 0x80940
  27. block  = 0x00
  28. slot   = 0x00
  29. rlo    =  0xec
  30. rhi    =  0xee 
  31. threshold   =  100 
  32. linegap     =  100
  33.  
  34. coloradr:  .ADDRESS  color   ; look up table address
  35. ;
  36. ;  screen data
  37. ;
  38. VDU_Input:    .LONG 149
  39.               .LONG -1
  40. displaystart:   .BLKL 1
  41. ;                               
  42. ;
  43. s2:     .ASCIZ  "value is %x\n "  ; C format for printing values in hex
  44.  
  45. .ALIGN                            ; ensure that succeeding instructions
  46.                                   ; will be on a word boundary
  47. ;
  48. ;
  49. ;               Registers a1 to a4, v1 to v6 are corrupted
  50. ;
  51. ;
  52. ;       Function header (for run-time diagnostics)
  53. ;
  54. cplot_name:
  55.  
  56.         .ASCIZ  "fax plot"
  57.         .ALIGN
  58.         .LONG   0xFF000000 + $ - cplot_name
  59. ;
  60. ;       afax is the entry point
  61. ;
  62. afax::
  63.         MOV     ip, sp
  64.         mov     v2,sp
  65.         STMFD   sp!, {a1-a4,v1-v6,fp,ip,lr,pc}  ; save some registers
  66.         SUB     fp, ip, #4
  67. ;
  68. ;       Check stack space
  69.         CMP     sp, sl
  70.         BLCC    x$stack_overflow 
  71. ;
  72.         mov   a1,#15                   ; use mode 15
  73.         swi   OS_WriteI+22
  74.         swi   OS_WriteC
  75.         ADR   R0,VDU_Input
  76.         ADR   R1,displaystart
  77.         SWI   OS_ReadVduVariables
  78. ;
  79. ;    displaystart in v1 , xptr in v2 , data in v3, v6 = look up table addr 
  80. ;                 line ctr in v5
  81. ;
  82.         ldr     v1,displaystart        ; screen address in v1
  83.         add     v1, v1, #1280
  84.         mov     v2,#0                  ; xctr = 0
  85.         ldr     v6, coloradr           ; color address in v6
  86.         mov     v5, #0                 ; set line counter to 0
  87. ;    ensure ca1/ifr is reset by reading porta
  88.         mov   a1, #slot
  89.         mov   a2, #block
  90.         mov   a3, #porta
  91.         swi   modread
  92.         mov   a1, #slot
  93.         mov   a2, #block
  94.         mov   a3, #portb
  95.         swi   modread
  96. ;
  97. ;    read ifr until data ready
  98. ifrloop:
  99.         mov   a1, #slot
  100.         mov   a2, #block
  101.         mov   a3, #ifr
  102.         swi   modread
  103.         and   a4, a4, #0x02
  104. ;  ADR    a1, s2                       ; diagnostic printing
  105. ;  mov    a2, a4                       ; see article
  106. ;  bl   _printf
  107.         cmp   a4, #0x02
  108.         bne   ifrloop                  ; data not ready loop again
  109. ;
  110. ;    data ready, send rlo to pcr, read data, send rhi to pcr
  111.         mov   a1, #slot
  112.         mov   a2, #block
  113.         mov   a3, #pcr
  114.         mov   a4, #rlo
  115.         swi   modwrite                 ; transfer data to A/D o/p
  116.         mov   a1, #slot
  117.         mov   a2, #block
  118.         mov   a3, #porta               
  119.         swi   modread                  ; read data into a4
  120.         mov   v3, a4                   ; save data byte in v3
  121.         mov   a1, #slot      
  122.         mov   a2, #block
  123.         mov   a3, #pcr
  124.         mov   a4, #rhi
  125.         swi   modwrite
  126. ;  ADR   a1, s2                      ; more diagnostics
  127. ;  mov   a2, v3                      
  128. ;  bl   _printf                      
  129. display:
  130.          mov    v3, v3, lsr #4        ; div by 16, for 16 levels
  131.          ldrb   v3, [v6, v3]          ; get correct tone
  132.          strb   v3,[v1,v2]            ; store color in screen address
  133.          add    v2,v2,#1              ; inc x counter, single points
  134.          mov    v3,#640               ; points per line
  135.          cmp    v2,v3                 ; done 1 line of 640  points ?
  136.          addge  v1,v1,#640            ; inc screen base address 1 lines
  137.          movge  v2,#0                 ; reset horiz. pixel counter
  138.          addge  v5,v5,#1              ; inc line counter
  139.          cmp    v5,#252               ; for 256 lines
  140.          blt    ifrloop               ; more lines to come, loop again
  141. ;
  142. ;
  143. stop:    LDMEA  fp,{v1-v5,fp,sp,pc}^  ; return to caller
  144.