home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
332.lha
/
AmigaAsmPreprocessor_v0.2
/
test.p
< prev
Wrap
Text File
|
1990-01-06
|
4KB
|
228 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
{
rndseed(vr) d0 rndseed(vr) = #31421 * #6927 + = .
d0 #320 / % .
}
rts
; code (a0),(a2) -> d0 -- calculate visibility code for clip
code moveq #0,d0
{
d0 X(a0) = XL(a2) == .
iflt d0 #16 <1 . else
d0 XR(a2) == . ifgt d0 #17 <1 . then then
d0 Y(a0) = YB(a2) == .
iflt d0 #18 <1 . else
d0 YT(a2) == . ifgt d0 #19 <1 . then then
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
{
begin
d3 d0 = d1 & .
}
bne exclip
{
d0 0= . ifeq a0 a1 :=: . d0 d1 :=: . then
d0 0= .
while
d0 #0 <? . ifne
Y(a0) d3 Y(a1) = Y(a0) -
d4 XL(a2) = X(a0) -
d5 X(a1) = X(a0) - */ + .
X(a0) XL(a2) = .
else d0 #1 <? . ifne
Y(a0) d3 Y(a1) = Y(a0) -
d4 XR(a2) = X(a0) -
d5 X(a1) = X(a0) - */ + .
X(a0) XR(a2) = .
else d0 #2 <? . ifne
X(a0) d3 X(a1) = X(a0) -
d4 YB(a2) = Y(a0) -
d5 Y(a1) = Y(a0) - */ + .
Y(a0) YB(a2) = .
else d0 #3 <? . ifne
X(a0) d3 X(a1) = X(a0) -
d4 YT(a2) = Y(a0) -
d5 Y(a1) = Y(a0) - */ + .
Y(a0) YT(a2) = .
then then then then
}
bsr code
{
repeat
}
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