OpenCores
URL https://opencores.org/ocsvn/z80soc/z80soc/trunk

Subversion Repositories z80soc

[/] [z80soc/] [trunk/] [V0.7.1a/] [rom/] [SoCv0.7b.z8a] - Blame information for rev 45

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 41 rrred
;
2
; Z80Soc V0.7 Demo ROM
3
; Ronivon C. Costa
4
; 2010 - 02 - 21
5
;
6
 
7
           ld          sp,BFFEH          ; Put Stack on top of memory
8
inicio:
9
           ld          a,(FFDFH)         ; Verify what is the development board
10
           or          a
11
           jr          z,de1
12
           call        set_lcd           ;is Z80soc-s3e
13
           jr          inic1
14
de1:
15
           ld          a,F0h
16
           out         (01h),a
17
           call        hexDisplay        ;is DE1, test 7 segment display
18
inic1:
19
           ld          a,0Fh
20
           out         (01h),a
21
           call        clear
22
           call        defineNewA
23
           ld          de,4034h
24
           ld          hl,Text1
25
           call        printmsg
26
           ld          de,405Ch
27
           ld          hl,Text2
28
           call        printmsg
29
           call        Border
30
           ld          de,4146h
31
           ld          hl,Text3
32
           call        printmsg
33
           ld          de,4196h
34
           ld          hl,Text4
35
           call        printmsg
36
           ld          de,41E6h
37
           ld          hl,Text5
38
           call        printmsg
39
           ld          de,4236h
40
           ld          hl,Text6
41
           call        printmsg
42
           ld          de,425Eh
43
           ld          hl,Text7
44
           call        printmsg
45
           ; check soz version
46
           ld          hl,DE1_Version
47
           ld          a,(FFDFh)
48
           or          a
49
           jr          z,print_v
50
           ld          hl,S3E_Version
51
print_v:
52
           ld          de,4087h
53
           call        printmsg
54
setprint:
55
           ld          de,42D6h
56
           ld          bc,30
57
loopprint:
58
           push        bc
59
           push        de
60
           call        delay
61
           call        rotate
62
           ld          a,(FFDFh)
63
           or          a
64
           jr          z,looppr2
65
           call        s3e_routine       ; Is Z80-S3E
66
looppr2:
67
           pop         de
68
           pop         bc
69
           call        read_kbd
70
           or          a
71
           jr          z,loopprint
72
           cp          41h
73
           jr          z,go_on
74
           out         (01H),a
75
           ld          l,a
76
           ld          a,(FFDFh)           ; get z80soc version
77
           or          a
78
           jr          nz,looppr3
79
           ld          a,l
80
           out         (11h),a             ; Use HEX display if DE1
81
looppr3:
82
           ld          a,l
83
           ld          (de),a
84
           inc         de
85
           dec         bc
86
           ld          a,b
87
           or          c
88
           jr          z,setprint
89
           jr          loopprint
90
go_on:
91
           ld          hl,6000h          ; RAM Address
92
           ld          a,0               ; Value to store in memory
93
loop1:
94
           ld          (hl),a            ; Store A into Memory (HL)
95
           inc         hl               ; Point to next memory location
96
           inc         a                ; Add 1 to value to store in memory
97
           jr          nz,loop1          ; If A not equal 0 continue loop1
98
                                ; When A=FFh, and we make A=A+1 ...
99
                                ; A becomes 100h
100
                                ; But, A is an 8 bits register, and
101
                                ; can only store the two last hex digits,
102
                                ; that is, 8 bits.
103
           call        read_key0       ; Wait until KEY0 is pressed
104
                                ;
105
           ld          hl,6000h          ; Get back the start RAM address
106
loop2:
107
           ld          a,(FFDFh)           ; get z80soc version
108
           or          a
109
           jr          nz,skip2_de1
110
           ld          a,h
111
           out         (11h),a
112
           ld          a,l
113
           out         (10h),a
114
skip2_de1:
115
           ld          a,(hl)             ; Read back the values stored in loop1
116
           out         (01h),a            ; Send to Green Leds
117
           call        delay              ; Call sub-routine to delay some time
118
           inc         hl                 ; Add 1 to the memory location
119
           ld          a,(hl)             ; Read the value in the memory
120
           cp          FFh               ; check if equal 255
121
           jr          nz,skip2_de1       ; If not equal 255, continue loop2
122
           ; end of First execution
123
           call         read_key0       ; Wait until KEY0 is pressed
124
           jP           inicio            ; Restart program
125
read_key0:
126
loop3:
127
           call         delay
128
           in           a,(30h)           ; Read KEYs (all 4 KEYs)
129
           cp           1               ; check if returns "00001110"
130
           jr           nz,loop3          ; KEY0 not pressed, continue checking
131
           ret
132
iodelay:
133
           in           a,(20h)           ; Read SW(7-0)
134
           or           a
135
           jr           nz,loop4
136
           ld           a,1       ; Read the number of times to loop
137
loop4:
138
           dec          a                ; Start counting backwards
139
           jr           nz,loop4          ; If A greather than 0, continue loop
140
           ret                  ; return to calling program
141
delay:
142
           in           a,(20h)           ; Read SW(7-0)
143
           or           a
144
           jr           nz,loop5
145
           ld           a,1
146
loop5:
147
           push  af
148
           ld    bc,5000             ; Every delay has at least 255 loops
149
loop6:
150
           dec   bc                ; Start counting backwards
151
           ld    a,b
152
           or    c
153
           jr    nz,loop6          ; If A greather than 0, continue loop
154
           pop   af               ; Get multiplier back
155
           dec   a                ;
156
           jr    nz,loop5
157
           ret                  ; return to calling program
158
clear:
159
        ld      a,0
160
        out     (91h),a      ; video cursor x = 0
161
        out     (92h),a      ; video cursor y = 0
162
        ld      bc,1200
163
clean_loop:
164
        ld      a,20h
165
        out     (90h),a      ; print character to video
166
                             ; cursor x,y is automatically updated
167
                             ; by hardware
168
        dec     bc
169
        ld      a,b
170
        or      c
171
        jr      nz,clean_loop
172
        ret
173
printmsg:
174
 
175
ploop:
176
 
177
           ld          a,(hl)
178
           or          a
179
           ret         z
180
           ld          (de),a
181
           inc         hl
182
           inc         de
183
           jr          ploop
184
read_kbd:
185
           in          a,(80h)
186
           ret
187
Border:
188
           ld          hl,Lineu
189
           ld          de,40F5H
190
           call        printmsg
191
           ld          de,411DH
192
           ld          a,10
193
brdloop:
194
           ld          hl,Column
195
           push        hl
196
           push        af
197
           push        de
198
           call        printmsg
199
           pop         de
200
           pop         af
201
           ld          hl,40
202
           add         hl,de
203
           ld          d,h
204
           ld          e,l
205
           pop         hl
206
           dec         a
207
           jr          nz,brdloop
208
           ld          hl,Lined
209
           call        printmsg
210
           ret
211
rotate:
212
           ; save first line of box
213
           ld          hl,411Eh
214
           ld          de,B000h
215
           ld          bc,30
216
           ldir
217
           ; move all lines up
218
           ld          hl,4146h ; this is second line of box
219
           ld          de,411Eh ; this is first line of box
220
           ld          b,9
221
loop_rotate:
222
           push        bc
223
           push        hl
224
           push        de
225
           ld          bc,30
226
           ldir
227
           pop         de
228
           ld          hl,40
229
           add         hl,de
230
           ld          d,h
231
           ld          e,l
232
           pop         hl
233
           ld          bc,40
234
           add         hl,bc
235
           pop         bc
236
           djnz        loop_rotate
237
           ; now get back the first line saved in 9000h
238
           ; and put on the last line of box
239
           ld          hl,B000h
240
           ld          bc,30
241
           ldir
242
           ret
243
s3e_routine:
244
           ; print message in LCD display
245
           ; Check of Rotary Knob is moving
246
           call        read_rot
247
           ; Is it rotating to the right ?
248
           cp          1
249
           jr          nz,check_left
250
           call        roll_lcd_right
251
           ld          a,1
252
           jr          printlcd
253
 
254
check_left:
255
           ; Is it rotating to the left?
256
           cp          2
257
           jr          nz,dec_jump
258
           call        roll_lcd_left
259
           ld          a,128
260
printlcd:
261
           out         (01h),a
262
           ld          de,FFE0h
263
           ld          hl,9100h
264
           call        printmsg
265
dec_jump:
266
           ret
267
set_lcd:
268
           ld          de,9100h
269
           ld          hl,lcdtxt
270
           ld          bc,33
271
           ldir
272
           ld          de,FFE0h
273
           ld          hl,9100h
274
           ld          bc,32
275
           ldir
276
           ret
277
read_rot:
278
           ;CALL        DELAY_MULT
279
           ;LD          A,0
280
           ;RET         NZ
281
           IN          A,(70H)
282
           RET
283
 
284
DELAY_ROT:
285
           LD          A,(9200H)
286
           DEC         A
287
           LD          (9200H),A
288
           RET
289
DELAY_MULT:
290
           LD          A,(9201H)
291
           DEC         A
292
           JR          NZ,DLY_M1
293
           LD          A,10H
294
DLY_M1:
295
           LD          (9201H),A
296
           RET
297
 
298
roll_lcd_left:
299
           ; save the first char on the left, for every line
300
           ld        a,(9100h)
301
           ld        (9202H),a
302
           ld        a,(9110h)
303
           ld        (9203H),a
304
           ld        HL,9101H
305
           ld        de,9100h
306
           ld        bc,31
307
           ldir
308
           ld        a,(9202h)
309
           ld        (910Fh),a
310
           ld        a,(9203h)
311
           ld        (911Fh),a
312
           ret
313
roll_lcd_right:
314
           ; save the first char on the left, for every line
315
           ld        a,(910Fh)
316
           ld        (9202H),a
317
           ld        a,(911Fh)
318
           ld        (9203H),a
319
           ld        HL,911EH
320
           ld        de,911Fh
321
           ld        bc,31
322
           lddr
323
           ld        a,(9202h)
324
           ld        (9100h),a
325
           ld        a,(9203h)
326
           ld        (9110h),a
327
           ret
328
defineNewA:
329
           ld        hl,newCharA
330
           ld        de,4E88h   ; this is the char ram addres of "A"
331
                                ; which is "4C80h + 65 * 8"
332
                                ; 4C80h = initial char ram address
333
                                ; 65 = ASCCII of "A"
334
                                ; 8  = 8 bytes for each char
335
           ld        bc,8
336
           ldir
337
           ret
338
hexDisplay:
339
           ld        a,20h
340
           out       (10h),a
341
           ld        a,10h
342
           out       (11h),a
343
           ret
344
           ;                    character set: lat9-08
345
Text1:
346
           db                   "Z80 SYSTEM ON CHIP"
347
           db                   0
348
Text2:
349
           db                   "RONIVON COSTA 2010"
350
           db                   0
351
Text3:
352
           db                   "  |!#$%&/()=?*`+´ç~^,.;:\<>"
353
           db                   0
354
Text4:
355
           db                   "  ABCDEFGHIJKLMNOPQRSTUVWXYZ"
356
           db                   0
357
Text5:
358
           db                   "  abcdefghijklmnopqrstuvwxyz"
359
           db                   0
360
Text6:
361
           db                   "         0123456789"
362
           db                   0
363
Text7:
364
           db                   2,3,4,11,12,13,14,18,24,25,26,27,232,233,235,187,188,138,134,135,129,128,1,6,7,8,9,10,29,31
365
           db                   0
366
Lineu:
367
           db                   150,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,156
368
           db                   0
369
Lined:
370
           db                   147,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,153
371
           db                   0
372
 
373
Column:
374
           db                   149
375
           db                   "                              "
376
           db                   149
377
           db                   0
378
lcdtxt:
379
           db                   "   Z80 SYSTEM   "
380
           db                   " RONIVON  COSTA "
381
           db                   0
382
DE1_Version:
383
           db                   "DE1 Version"
384
           db                   0
385
S3E_Version:
386
           db                   "S3E Version"
387
           db                   0
388
newCharA:
389
           db                   FFh  ;11111111
390
           db                   81h  ;10000001
391
           db                   99h  ;10011001
392
           db                   A5h  ;10100101
393
           db                   BDh  ;10111101
394
           db                   A5h  ;10100101
395
           db                   81h  ;10000001
396
           db                   FFh  ;11111111

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.