/[projet1]/users/chema/skooldaze/auxiliar.s
Defence Force logotype

Contents of /users/chema/skooldaze/auxiliar.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 610 - (show annotations)
Sat Sep 10 23:40:26 2011 UTC (8 years, 6 months ago) by Chema
File size: 3294 byte(s)
More bug hunting (Symoon's) and some of the ideas from Dbug included.
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;; -----------------------------------
3 ;; Skool Daze
4 ;; The Oric Version
5 ;; -----------------------------------
6 ;; (c) Chema 2011
7 ;; enguita@gmail.com
8 ;; -----------------------------------
9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10
11 ;; Auxiliary functions
12 ;; --------------------
13
14 #include "params.h"
15 #include "text.h"
16
17
18 _GenerateTables
19 .(
20 ; Generate screen offset data
21 #ifdef CENTER_PLAY_AREA
22 lda #<$a000+160
23 sta tmp0+0
24 lda #>$a000+160
25 sta tmp0+1
26 #else
27 lda #<$a000
28 sta tmp0+0
29 lda #>$a000
30 sta tmp0+1
31 #endif
32
33 ldx #0
34 loop
35 ; generate two bytes screen address
36 clc
37 lda tmp0+0
38 sta _HiresAddrLow,x
39 adc #40
40 sta tmp0+0
41 lda tmp0+1
42 sta _HiresAddrHigh,x
43 adc #0
44 sta tmp0+1
45
46 inx
47 cpx #200
48 bne loop
49 rts
50 .)
51
52
53
54 ; A real random generator... trying to enhance this...
55 randgen
56 .(
57 ;php ; INTERRUPTS MUST BE ENABLED! We store the state of flags.
58 ;cli
59 lda randseed ; get old lsb of seed.
60 ora $308 ; lsb of VIA T2L-L/T2C-L.
61 rol ; this is even, but the carry fixes this.
62 adc $304 ; lsb of VIA TK-L/T1C-L. This is taken mod 256.
63 sta randseed ; random enough yet.
64 sbc randseed+1 ; minus the hsb of seed...
65 rol ; same comment than before. Carry is fairly random.
66 sta randseed+1 ; we are set.
67 ;plp
68 rts ; see you later alligator.
69 .)
70
71 utoa
72 .(
73 ldy#0
74 sty bufconv
75 itoaloop
76 jsr udiv10
77 pha
78 iny
79 lda op2
80 ora op2+1
81 bne itoaloop
82
83 ldx #0
84 lda bufconv
85 beq poploop
86 inx
87 poploop
88 pla
89 clc
90 adc #$30
91 sta bufconv,x
92 inx
93 dey
94 bne poploop
95 lda #0
96 sta bufconv,x
97 rts
98
99 ;
100 ; udiv10 op2= op2 / 10 and A= op2 % 10
101 ;
102 udiv10
103 lda #0
104 ldx #16
105 clc
106 udiv10lp
107 rol op2
108 rol op2+1
109 rol
110 cmp #10
111 bcc contdiv
112 sbc #10
113 contdiv
114 dex
115 bne udiv10lp
116 rol op2
117 rol op2+1
118 rts
119 .)
120
121 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
122 ; Multiplies 2 8-bit numbers
123 ; in tmp0 and tmp0+1 and gets a 16-bit
124 ; result in tmp0,tmp1 using the
125 ; classical shift&add method
126 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
127
128 mul8
129 .(
130 sta tmp1
131 ldx #9
132 _m8_loop
133 lsr tmp1
134 ror tmp0
135 bcc _m8_deccnt
136 clc
137 lda tmp0+1
138 adc tmp1
139 sta tmp1
140 _m8_deccnt
141 dex
142 bne _m8_loop
143 rts
144 .)
145
146 ; Adds 40 to tmp
147 add40tmp
148 .(
149 lda tmp
150 clc
151 adc #40
152 sta tmp
153 bcc nocarry
154 inc tmp+1
155 nocarry
156 rts
157 .)
158
159 /*
160
161 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
162 ;; Compares two 16-bit numbers in op1 and op2
163 ;; Performs signed and unsigned comparisions at the same time.
164 ;; If the N flag is 1, then op1 (signed) < op2 (signed) and BMI will branch
165 ;; If the N flag is 0, then op1 (signed) >= op2 (signed) and BPL will branch
166 ;; For unsigned comparisions ,the behaviour is the usual with the carry flag
167 ;; If the C flag is 0, then op1 (unsigned) < op2 (unsigned) and BCC will branch
168 ;; If the C flag is 1, then op1 (unsigned) >= op2 (unsigned) and BCS will branch
169 ;; The Z flag DOES NOT indicate equality...
170 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
171
172 cmp16
173 .(
174 lda op1 ; op1-op2
175 cmp op2
176 lda op1+1
177 sbc op2+1
178 bvc ret ; N eor V
179 eor #$80
180 ret
181 rts
182 .)
183 */

  ViewVC Help
Powered by ViewVC 1.1.26