forked from aburguera/YAP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UTIL.X68
155 lines (146 loc) · 5.77 KB
/
UTIL.X68
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
; =============================================================================
; UTILITY MACROS
; =============================================================================
; -----------------------------------------------------------------------------
UTLSPEN MACRO
; WRAPPER FOR SET PEN TRAP 15 TASK.
; INPUT - \1 COLOR IN FORMAT $00BBGGRR
; OUTPUT - NONE
; MODIFIES - D0,D1
; -----------------------------------------------------------------------------
MOVE.B #80,D0
MOVE.L \1,D1
TRAP #15
ENDM
; -----------------------------------------------------------------------------
UTLSFIL MACRO
; WRAPPER FOR SET FIL TRAP 15 TASK.
; INPUT - \1 COLOR IN FORMAT $00BBGGRR
; OUTPUT - NONE
; MODIFIES - D0,D1
; -----------------------------------------------------------------------------
MOVE.B #81,D0
MOVE.L \1,D1
TRAP #15
ENDM
; -----------------------------------------------------------------------------
UTLLOCT MACRO
; WRAPPER TO TEXT POSITIONNING FROM TRAP 15
; INPUT - \1 X, \2 Y
; OUTPUT - NONE
; MODIFIES - D0,D1
; -----------------------------------------------------------------------------
MOVE.W #\1<<8|\2, D1
MOVE.B #11,D0
TRAP #15
ENDM
; =============================================================================
; UTILITY SUBROUTINES
; =============================================================================
; -----------------------------------------------------------------------------
UTLINIT
; INITIALIZES UTILITY CODE
; INPUT - NONE
; OUTPUT - NONE
; MODIFIES - NONE
; -----------------------------------------------------------------------------
CLR.B (UTLRNDIX)
RTS
; -----------------------------------------------------------------------------
UTLCHCOL
; CHECKS COLLISION
; INPUT - D0.W X0 COORDINATE
; D1.W Y0 COORDINATE
; D2.W X1 COORDINATE
; D3.W Y1 COORDINATE
; D4.W WIDTH 0
; D5.W WIDTH 1
; D6.W HEIGHT 0
; D7.W HEIGHT 1
; OUTPUT - D0.B=FF - COLLISION, =0 - NO COLLISION
; MODIFIES - NONE
; -----------------------------------------------------------------------------
MOVEM.W D4-D7,-(A7)
ADD.W D0,D4
CMP.W D2,D4
BLE .NOCOL
ADD.W D2,D5
CMP.W D0,D5
BLE .NOCOL
ADD.W D1,D6
CMP.W D3,D6
BLE .NOCOL
ADD.W D3,D7
CMP.W D1,D7
BLE .NOCOL
MOVE.B #$FF,D0
BRA .END
.NOCOL CLR.B D0
.END MOVEM.W (A7)+,D4-D7
RTS
; -----------------------------------------------------------------------------
UTLRAND
; PROVIDES A PSEUDO-RANDOM BYTE
; INPUT - NONE
; OUTPUT - D0.L RANDOM VALUE (ONLY BYTE)
; MODIFIES - NONE (ASIDE OF OUTPUT)
; -----------------------------------------------------------------------------
MOVE.L A0,-(A7)
LEA .RANDVEC,A0
CLR.L D0
MOVE.B (UTLRNDIX),D0
MOVE.B (A0,D0.L),D0
ADDQ.B #1,(UTLRNDIX)
MOVE.L (A7)+,A0
RTS
.RANDVEC DC.B 162, 238, 154, 12 , 245, 36 , 32 , 103
DC.B 42 , 163, 81 , 38 , 224, 172, 19 , 69
DC.B 117, 81 , 202, 253, 51 , 235, 108, 154
DC.B 96 , 204, 231, 184, 154, 235, 34 , 203
DC.B 29 , 118, 181, 149, 176, 137, 62 , 108
DC.B 57 , 21 , 72 , 201, 110, 202, 159, 41
DC.B 67 , 231, 226, 124, 55 , 37 , 84 , 62
DC.B 233, 148, 206, 233, 228, 82 , 243, 78
DC.B 55 , 109, 154, 132, 162, 40 , 30 , 39
DC.B 25 , 226, 198, 119, 128, 212, 232, 225
DC.B 10 , 90 , 50 , 103, 51 , 194, 222, 40
DC.B 89 , 128, 220, 14 , 87 , 252, 243, 252
DC.B 138, 171, 188, 247, 7 , 77 , 29 , 234
DC.B 239, 213, 119, 110, 30 , 187, 131, 23
DC.B 214, 224, 42 , 143, 189, 40 , 212, 130
DC.B 19 , 79 , 102, 236, 10 , 100, 122, 188
DC.B 86 , 82 , 154, 22 , 155, 144, 7 , 199
DC.B 6 , 138, 164, 247, 1 , 218, 166, 82
DC.B 242, 231, 119, 40 , 177, 118, 220, 102
DC.B 164, 66 , 227, 129, 177, 103, 165, 108
DC.B 191, 206, 250, 22 , 191, 56 , 30 , 161
DC.B 209, 139, 80 , 12 , 95 , 73 , 168, 56
DC.B 222, 76 , 20 , 162, 64 , 220, 93 , 12
DC.B 182, 155, 10 , 56 , 93 , 171, 89 , 6
DC.B 226, 27 , 221, 117, 21 , 130, 101, 18
DC.B 138, 38 , 81 , 48 , 159, 71 , 57 , 21
DC.B 30 , 138, 187, 113, 198, 110, 185, 152
DC.B 159, 71 , 229, 52 , 148, 39 , 77 , 6
DC.B 125, 6 , 214, 186, 48 , 15 , 212, 22
DC.B 236, 127, 126, 3 , 207, 45 , 193, 2
DC.B 148, 91 , 35 , 242, 139, 205, 248, 237
DC.B 116, 51 , 236, 185, 15 , 213, 221, 6
; -----------------------------------------------------------------------------
UTLSTRLN
; COMPUTES THE LENGTH OF A ZERO-TERMINATED STRING
; INPUT - A1 POINTER TO THE STRING
; OUTPUT - D0.W STRING LENGTH
; MODIFIES - NONE
; -----------------------------------------------------------------------------
MOVE.L A1,-(A7)
CLR.W D0
.LOOP TST.B (A1)+
BEQ .END
ADDQ.W #1,D0
BRA .LOOP
.END MOVE.L (A7)+,A1
RTS
*~Font name~Courier New~
*~Font size~10~
*~Tab type~0~
*~Tab size~4~