-
Notifications
You must be signed in to change notification settings - Fork 91
/
sub ChkObjectVisible.asm
67 lines (52 loc) · 1.72 KB
/
sub ChkObjectVisible.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
; ---------------------------------------------------------------------------
; Subroutine to check if an object is off screen
; output:
; d0 = flag set if object is off screen
; ---------------------------------------------------------------------------
; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
ChkObjectVisible:
move.w obX(a0),d0 ; get object x-position
sub.w (v_screenposx).w,d0 ; subtract screen x-position
bmi.s .offscreen
cmpi.w #320,d0 ; is object on the screen?
bge.s .offscreen ; if not, branch
move.w obY(a0),d1 ; get object y-position
sub.w (v_screenposy).w,d1 ; subtract screen y-position
bmi.s .offscreen
cmpi.w #224,d1 ; is object on the screen?
bge.s .offscreen ; if not, branch
moveq #0,d0 ; set flag to 0
rts
.offscreen:
moveq #1,d0 ; set flag to 1
rts
; End of function ChkObjectVisible
; ---------------------------------------------------------------------------
; Subroutine to check if an object is off screen
; More precise than above subroutine, taking width into account
; output:
; d0 = flag set if object is off screen
; ---------------------------------------------------------------------------
; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
ChkPartiallyVisible:
moveq #0,d1
move.b obActWid(a0),d1
move.w obX(a0),d0 ; get object x-position
sub.w (v_screenposx).w,d0 ; subtract screen x-position
add.w d1,d0 ; add object width
bmi.s .offscreen2
add.w d1,d1
sub.w d1,d0
cmpi.w #320,d0
bge.s .offscreen2
move.w obY(a0),d1
sub.w (v_screenposy).w,d1
bmi.s .offscreen2
cmpi.w #224,d1
bge.s .offscreen2
moveq #0,d0
rts
.offscreen2:
moveq #1,d0
rts
; End of function ChkPartiallyVisible