home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
332.lha
/
AmigaAsmPreprocessor_v0.2
/
test.a
< prev
next >
Wrap
Text File
|
1990-01-06
|
4KB
|
280 lines
;
; test.p -- test
;
include 'include.i'
include 'offsets.i'
include 'macro.i'
SysBase equ 4
; point
X equ 0
Y equ 2
; window
XL equ 0
YB equ 2
XR equ 4
YT equ 6
; vars
lastvar set 0
var.l IntuitionBase
var.l GfxBase
var.l screen
var.l rp
var.w line,4
var.w rndseed
;
start link vr,#lastvar ; alloc & clear vars
move.w #-lastvar/2,d0
lea lastvar(vr),a0
bra.s 001$
000$ clr.w (a0)+
001$ dbra d0,000$
lea GfxName(pc),a1 ; open graphics
moveq #0,d0
call SysBase,OpenLibrary
move.l d0,GfxBase(vr)
beq exit
lea IntuitionName(pc),a1 ; open intuition
moveq #0,d0
call OpenLibrary
move.l d0,IntuitionBase(vr)
beq exit
move.l d0,a6 ; open screen
lea newscr(pc),a0
call OpenScreen
move.l d0,screen(vr)
beq exit
move.l d0,a0 ; get RastPort address
lea sc_RastPort(a0),a0
move.l a0,rp(vr)
move.w #7051,rndseed(vr) ; init rndseed
lea wind(pc),a2 ; load window ptr
move.l GfxBase(vr),a6
moveq #1,d0
move.l rp(vr),a1
call SetAPen
move.l #RP_COMPLEMENT,d0
move.l rp(vr),a1
call SetDrMd
move.w #319,d2 ; draw 10000 lines
yyy move.w d2,line(vr)
move.w #0,line+2(vr)
move.w #319,line+4(vr)
sub.w d2,line+4(vr)
move.w #255,line+6(vr)
lea line(vr),a0
lea line+4(vr),a1
bsr clip
dbra d2,yyy
move.w #255,d2
aaa move.w #0,line(vr)
move.w d2,line+2(vr)
move.w #319,line+4(vr)
move.w #255,line+6(vr)
sub.w d2,line+6(vr)
lea line(vr),a0
lea line+4(vr),a1
bsr clip
bbb dbra d2,aaa
moveq #100,d2 ; wait 2 seconds
zzz call WaitTOF
dbra d2,zzz
exit tst.l IntuitionBase(vr) ; test intuition
beq.s 000$
tst.l screen(vr) ; test screen
beq.s 001$
move.l screen(vr),a0 ; close screen
call IntuitionBase(vr),CloseScreen
001$ move.l IntuitionBase(vr),a1 ; close intuition
call SysBase,CloseLibrary
000$ tst.l GfxBase(vr) ; test graphics
beq.s 002$
move.l GfxBase(vr),a1 ; close graphics
call SysBase,CloseLibrary
unlk vr ; restore stack
moveq #0,d0 ; exit(0)
002$ rts
rnd
move.w rndseed(vr),d0
muls.w #31421,d0
add.w #6927,d0
move.w d0,rndseed(vr)
ext.l d0
divs.w #320,d0
swap d0
rts
; code (a0),(a2) -> d0 -- calculate visibility code for clip
code moveq #0,d0
move.w X(a0),d0
cmp.w XL(a2),d0
bge if.000
bset #16,d0
bra if.001
if.000
cmp.w XR(a2),d0
ble if.002
bset #17,d0
if.002
if.001
move.w Y(a0),d0
cmp.w YB(a2),d0
bge if.003
bset #18,d0
bra if.004
if.003
cmp.w YT(a2),d0
ble if.005
bset #19,d0
if.005
if.004
swap d0
rts
; clip (a0)-(a1),(a2) ->d0 -- clip line (a0)-(a1) to window (a2), d0=0 if succ
clip movem.l d2-d5,-(sp)
bsr code
exg.l a1,a0
move.w d0,d1
bsr code
beg.006
move.w d0,d3
and.w d1,d3
bne exclip
tst.w d0
bne if.007
exg.w a1,a0
exg.w d1,d0
if.007
tst.w d0
beq whl.008
btst #0,d0
beq if.009
move.w Y(a1),d3
sub.w Y(a0),d3
move.w XL(a2),d4
sub.w X(a0),d4
move.w X(a1),d5
sub.w X(a0),d5
muls.w d4,d3
divs.w d5,d3
add.w d3,Y(a0)
move.w XL(a2),X(a0)
bra if.010
if.009
btst #1,d0
beq if.011
move.w Y(a1),d3
sub.w Y(a0),d3
move.w XR(a2),d4
sub.w X(a0),d4
move.w X(a1),d5
sub.w X(a0),d5
muls.w d4,d3
divs.w d5,d3
add.w d3,Y(a0)
move.w XR(a2),X(a0)
bra if.012
if.011
btst #2,d0
beq if.013
move.w X(a1),d3
sub.w X(a0),d3
move.w YB(a2),d4
sub.w Y(a0),d4
move.w Y(a1),d5
sub.w Y(a0),d5
muls.w d4,d3
divs.w d5,d3
add.w d3,X(a0)
move.w YB(a2),Y(a0)
bra if.014
if.013
btst #3,d0
beq if.015
move.w X(a1),d3
sub.w X(a0),d3
move.w YT(a2),d4
sub.w Y(a0),d4
move.w Y(a1),d5
sub.w Y(a0),d5
muls.w d4,d3
divs.w d5,d3
add.w d3,X(a0)
move.w YT(a2),Y(a0)
if.015
if.014
if.012
if.010
bsr code
bra beg.006
whl.008
move.l a1,-(sp) ; draw line
movem.w (a0),d0-d1
move.l rp(vr),a1
call Move
move.l (sp)+,a0
movem.w (a0),d0-d1
move.l rp(vr),a1
call Draw
exclip movem.l (sp)+,d2-d5
rts
; data
newscr dc.w 0,0,320,256, ; left top widht height
dc.w 2, ; depth
dc.b 0,1, ; detailpen blockpen
dc.w 0,CUSTOMSCREEN, ; wiewmodes type
dc.l font, ; font
dc.l title, ; title
dc.l 0,0 ; gadgets custombitmap
font dc.l fontnam,
dc.w TOPAZ_EIGHTY,
dc.b FS_NORMAL,FPF_ROMFONT
wind dc.w 50,50,270,205
IntuitionName
dc.b 'intuition.library',0
GfxName dc.b 'graphics.library',0
title dc.b 'Test screen',0
fontnam dc.b 'topaz.font',0
ds.w 0
end