home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Archive Magazine 1996
/
ARCHIVE_96.iso
/
discs
/
mag_discs
/
volume_9
/
issue_02
/
weather
/
afax
next >
Wrap
Text File
|
1995-07-13
|
4KB
|
144 lines
; > a.afax
;
; use with faxdisp as the calling program
; Assembly language module for fax plotting program
; gets own data one pixel at a time
.INCLUDE "A.SWINAMES" ; converts swi names to numbers
.INCLUDE "A.REGNAMES" ; converts register names to numbers
.INCLUDE "A.ADR"
;
; External functions
;
.EXTERN _printf, x$stack_overflow, color
.AREA A$$code
;
; Constant definitions
;
porta = 0x01 ; these will have more significance
portb = 0x00 ; if you are familiar with the 6522
ifr = 0x0d ; versatile interface adapter, but
pcr = 0x0c ; do not worry about them!
modread = 0x80941
modwrite = 0x80940
block = 0x00
slot = 0x00
rlo = 0xec
rhi = 0xee
threshold = 100
linegap = 100
coloradr: .ADDRESS color ; look up table address
;
; screen data
;
VDU_Input: .LONG 149
.LONG -1
displaystart: .BLKL 1
;
;
s2: .ASCIZ "value is %x\n " ; C format for printing values in hex
.ALIGN ; ensure that succeeding instructions
; will be on a word boundary
;
;
; Registers a1 to a4, v1 to v6 are corrupted
;
;
; Function header (for run-time diagnostics)
;
cplot_name:
.ASCIZ "fax plot"
.ALIGN
.LONG 0xFF000000 + $ - cplot_name
;
; afax is the entry point
;
afax::
MOV ip, sp
mov v2,sp
STMFD sp!, {a1-a4,v1-v6,fp,ip,lr,pc} ; save some registers
SUB fp, ip, #4
;
; Check stack space
CMP sp, sl
BLCC x$stack_overflow
;
mov a1,#15 ; use mode 15
swi OS_WriteI+22
swi OS_WriteC
ADR R0,VDU_Input
ADR R1,displaystart
SWI OS_ReadVduVariables
;
; displaystart in v1 , xptr in v2 , data in v3, v6 = look up table addr
; line ctr in v5
;
ldr v1,displaystart ; screen address in v1
add v1, v1, #1280
mov v2,#0 ; xctr = 0
ldr v6, coloradr ; color address in v6
mov v5, #0 ; set line counter to 0
; ensure ca1/ifr is reset by reading porta
mov a1, #slot
mov a2, #block
mov a3, #porta
swi modread
mov a1, #slot
mov a2, #block
mov a3, #portb
swi modread
;
; read ifr until data ready
ifrloop:
mov a1, #slot
mov a2, #block
mov a3, #ifr
swi modread
and a4, a4, #0x02
; ADR a1, s2 ; diagnostic printing
; mov a2, a4 ; see article
; bl _printf
cmp a4, #0x02
bne ifrloop ; data not ready loop again
;
; data ready, send rlo to pcr, read data, send rhi to pcr
mov a1, #slot
mov a2, #block
mov a3, #pcr
mov a4, #rlo
swi modwrite ; transfer data to A/D o/p
mov a1, #slot
mov a2, #block
mov a3, #porta
swi modread ; read data into a4
mov v3, a4 ; save data byte in v3
mov a1, #slot
mov a2, #block
mov a3, #pcr
mov a4, #rhi
swi modwrite
; ADR a1, s2 ; more diagnostics
; mov a2, v3
; bl _printf
display:
mov v3, v3, lsr #4 ; div by 16, for 16 levels
ldrb v3, [v6, v3] ; get correct tone
strb v3,[v1,v2] ; store color in screen address
add v2,v2,#1 ; inc x counter, single points
mov v3,#640 ; points per line
cmp v2,v3 ; done 1 line of 640 points ?
addge v1,v1,#640 ; inc screen base address 1 lines
movge v2,#0 ; reset horiz. pixel counter
addge v5,v5,#1 ; inc line counter
cmp v5,#252 ; for 256 lines
blt ifrloop ; more lines to come, loop again
;
;
stop: LDMEA fp,{v1-v5,fp,sp,pc}^ ; return to caller