Subversion Repositories Spectranet

[/] [trunk/] [test/] [test.asm] - Blame information for rev 117

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 117 winston
        org 0x8000
2
        include "../rom/w5100_defines.asm"
3
        di
4
        ld a, 1
5
        ld bc, 0x80EF   ; port for page in
6
        out (c), a      ; page in
7
        call F_clear
8
 
9
        ; Test the workspace
10
        ld hl, STR_testwkspc
11
        call F_print
12
        ld hl, 0x3000
13
        ld de, 0
14
        ld bc, 0x1000
15
        call F_randfill
16
        ld hl, 0x3000
17
        ld de, 0
18
        ld bc, 0x1000
19
        call F_randreadback
20
        jp nz, J_readfail
21
        ld hl, STR_ok
22
        call F_print
23
 
24
        ; Test RAM paging
25
        ld hl, STR_pageram
26
        call F_print
27
        ld b, 0x1F      ; number of pages
28
.ramloop
29
        ld a, b
30
        or 0xC0         ; RAM = chip 3, upper two bits high
31
        call F_setpageA
32
        call F_printpage
33
        push bc
34
        ld d, 0
35
        ld e, b
36
        ld bc, 0x1000
37
        ld hl, 0x1000
38
        call F_randfill
39
        pop bc
40
        djnz .ramloop
41
 
42
        ld a, '\n'
43
        call F_putc_5by8
44
 
45
        ld b, 0x1F
46
.ramreadloop
47
        ld a, b
48
        or 0xC0         ; RAM = chip 3, upper two bits high
49
        call F_setpageA
50
        call F_printpage
51
        push bc
52
        ld d, 0
53
        ld e, b
54
        ld bc, 0x1000
55
        ld hl, 0x1000
56
        call F_randreadback
57
        pop bc
58
        call nz, F_pagereadfail
59
        djnz .ramreadloop
60
 
61
        ld hl, STR_complete
62
        call F_print
63
 
64
        ld hl, STR_w5100
65
        call F_print
66
 
67
        ld a, REGPAGE
68
        call F_setpageA
69
        ld hl, HWADDR           ; test: set hwaddr and ipaddr registers
70
        ld de, SHAR0
71
        ld bc, 10
72
        ldir
73
        ld b, 10
74
        ld de, HWADDR
75
        ld hl, buffer
76
.regloop
77
        ld a, (de)
78
        call F_itoh8
79
        inc de
80
        djnz .regloop
81
 
82
        ld hl, buffer
83
        call F_print
84
        ld a, '\n'
85
        call F_putc_5by8
86
 
87
EXIT
88
        ld a, 0
89
        ld bc, 0x80EF
90
        out (c), a      ; page out
91
        ei
92
        ret
93
 
94
J_readfail
95
        ex de, hl
96
        ld hl, STR_readfail
97
        call F_print
98
        ld hl, buffer
99
        ld a, d
100
        call F_itoh8
101
        ld a, e
102
        call F_itoh8
103
        ld hl, buffer
104
        call F_print
105
        ld a, '\n'
106
        call F_putc_5by8
107
        jr EXIT
108
 
109
F_printpage
110
        push hl
111
        push de
112
        push bc
113
        push af
114
        ld hl, buffer
115
        call F_itoh8
116
        ld hl, buffer
117
        call F_print
118
        ld hl, STR_dotdotdot
119
        call F_print
120
        pop af
121
        pop bc
122
        pop de
123
        pop hl
124
        ret
125
 
126
F_pagereadfail
127
        push hl
128
        push de
129
        push bc
130
        push af
131
        ex de, hl
132
        ld hl, STR_pfail
133
        call F_print
134
        ld hl, buffer
135
        ld a, d
136
        call F_itoh8
137
        ld a, e
138
        call F_itoh8
139
        ld hl, buffer
140
        call F_print
141
        ld hl, STR_dotdotdot
142
        call F_print
143
        pop af
144
        pop bc
145
        pop de
146
        pop hl
147
        ret
148
 
149
; Fill a block of memory with random values
150
; hl = start address
151
; de = start seed
152
; bc = size
153
F_randfill
154
        ld (v_seed), de         ; set seed to known value
155
.loop
156
        push hl
157
        call F_rand16
158
        ex de, hl               ; random number in DE
159
        pop hl
160
        ld (hl), e
161
        inc hl
162
        ld (hl), d
163
        inc hl
164
        dec bc
165
        dec bc
166
        ld a, b
167
        or c
168
        jr nz, .loop
169
        ret
170
 
171
; Check that the pseudo random memory fill reads back the same values.
172
; hl = start address
173
; de = start seed
174
; bc = number of bytes
175
; zero flag is set if readback is correct
176
F_randreadback
177
        ld (v_seed), de
178
.loop
179
        push hl
180
        call F_rand16
181
        ex de, hl
182
        pop hl
183
        ld a, (hl)              ; compare what's in memory to newly
184
        cp e                    ; generated pseudo random value
185
        ret nz                  ; oops
186
        inc hl
187
        ld a, (hl)
188
        cp d
189
        ret nz
190
        inc hl
191
        dec bc
192
        dec bc
193
        ld a, b
194
        or c
195
        jr nz, .loop
196
        ret
197
 
198
        include "../rom/sysdefs.asm"
199
        include "../rom/pager.asm"
200
        include "../rom/utility.asm"
201
        include "test_output.asm"
202
        include "../rom/ui_charset.asm"
203
        block 0x8700-$,0
204
        include "../rom/ui_lookup.asm"
205
 
206
 
207
STR_pageram defb "Paging RAM...\n",0
208
STR_pagerom defb "Paging ROM...\n",0
209
STR_testwkspc defb "Testing workspace...\n",0
210
STR_pagefail    defb "Readback failure in page ", 0
211
STR_readfail    defb "Readback failed at address ",0
212
STR_ok          defb "Readback OK\n",0
213
STR_dotdotdot   defb "...",0
214
STR_pfail       defb "F=",0
215
STR_complete    defb "\nReadback complete\n",0
216
STR_w5100       defb "Paging W5100\n",0
217
HWADDR          defb 0x01,0x03,0x07,0x0F,0x1F,0x3F
218
IPADDR          defb 0x7F,0xFF,0xAA,0x55
219
 
220
; some variables
221
v_seed  defw 0
222
v_column        defb 0          ; Current column for 42 col print.
223
v_row           defw 0          ; Current row address for print routine
224
v_rowcount      defb 0          ; current row number
225
v_pr_wkspc      defb 0          ; Print routine workspace
226
v_pga           defb 0          ; Current memory page in area A
227
v_pgb           defb 0          ; Current memory page in area B
228
v_hlsave        defw 0
229
v_desave        defw 0
230
v_bcsave        defw 0
231
v_stringptr     defw 0
232
buffer          defb 0,0,0,0,0,0,0,0,0,0,0,0
233
 
234
UNPAGE          equ 0x007C
235