Rev 1453 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log
Rev 1453 | Rev 1458 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | DEVICE ZXSPECTRUM128 |
1 | DEVICE ZXSPECTRUM128 |
2 | include "../_sdk/sys_h.asm" |
2 | include "../_sdk/sys_h.asm" |
3 | 3 | ||
4 | MAXCMDSZ=COMMANDLINE_sz-1;127 ;не считая терминатора |
4 | MAXCMDSZ=COMMANDLINE_sz-1;127 ;не считая терминатора |
- | 5 | filebuf=0xc000 |
|
5 | filebufsz=512 |
6 | filebufsz=0x4000;512 |
6 | TRDSIZE=655360 |
7 | TRDSIZE=655360 |
7 | 8 | ||
8 | org PROGSTART |
9 | org PROGSTART |
9 | cmd_begin |
10 | cmd_begin |
10 | ld sp,0x4000 ;не должен опускаться ниже 0x3b00! иначе возможна порча OS |
11 | ld sp,0x4000 ;не должен опускаться ниже 0x3b00! иначе возможна порча OS |
Line 27... | Line 28... | ||
27 | pop hl |
28 | pop hl |
28 | ld e,l |
29 | ld e,l |
29 | OS_DELPAGE |
30 | OS_DELPAGE |
30 | endif |
31 | endif |
31 | 32 | ||
- | 33 | ld hl,tpgs |
|
- | 34 | ld b,TRDSIZE/0x4000 |
|
- | 35 | getpgs |
|
- | 36 | push bc |
|
- | 37 | push hl |
|
- | 38 | OS_NEWPAGE |
|
- | 39 | pop hl |
|
- | 40 | ld (hl),e |
|
- | 41 | inc hl |
|
- | 42 | pop bc |
|
- | 43 | djnz getpgs |
|
- | 44 | ||
32 | ld hl,COMMANDLINE ;command line |
45 | ld hl,COMMANDLINE ;command line |
33 | ;command line = "print <file>" |
46 | ;command line = "print <file>" |
34 | ld de,wordbuf |
47 | ld de,wordbuf |
35 | call skipword |
48 | call skipword |
36 | ld a,(hl) |
49 | ld a,(hl) |
Line 41... | Line 54... | ||
41 | call getword |
54 | call getword |
42 | nofilename |
55 | nofilename |
43 | ld de,wordbuf |
56 | ld de,wordbuf |
44 | OS_CREATEHANDLE |
57 | OS_CREATEHANDLE |
45 | or a |
58 | or a |
46 | jr nz,errorquit |
59 | jp nz,errorquit |
47 | push bc |
60 | push bc |
48 | ld a,b |
61 | ld a,b |
49 | ld (filehandle),a |
62 | ld (filehandle),a |
50 | 63 | ||
51 | call dosoff |
64 | ;call dosoff |
52 | 65 | ||
53 | ;Пример настройки контроллера на скорость обмена 9600 бод из режима BASIC-48: |
66 | ;Пример настройки контроллера на скорость обмена 9600 бод из режима BASIC-48: |
54 | ;10 LET register = 3: LET value = 128: GO SUB 1000 |
67 | ;10 LET register = 3: LET value = 128: GO SUB 1000 |
55 | ;20 LET register = 0: LET value = 12: GO SUB 1000 |
68 | ;20 LET register = 0: LET value = 12: GO SUB 1000 |
56 | ;30 LET register = 1: LET value =0: GO SUB 1000 |
69 | ;30 LET register = 1: LET value =0: GO SUB 1000 |
Line 58... | Line 71... | ||
58 | ld bc,#fbef ;RS232_LINE_CTRL |
71 | ld bc,#fbef ;RS232_LINE_CTRL |
59 | in a,(c) |
72 | in a,(c) |
60 | or 128 |
73 | or 128 |
61 | out (c),a |
74 | out (c),a |
62 | ld bc,#f8ef ;RS232_DIV_L |
75 | ld bc,#f8ef ;RS232_DIV_L |
63 | ld a,1;12 ;115200 |
76 | ld a,2;12 ;115200/2 (иначе не успеет) |
64 | out (c),a |
77 | out (c),a |
65 | ld bc,#f9ef ;RS232_DIV_H |
78 | ld bc,#f9ef ;RS232_DIV_H |
66 | ld a,0 ;+128 native ZXEvo mode |
79 | ld a,0 ;+128 native ZXEvo mode |
67 | out (c),a |
80 | out (c),a |
68 | ld bc,#fbef ;RS232_LINE_CTRL |
81 | ld bc,#fbef ;RS232_LINE_CTRL |
69 | ld a,7;3 |
82 | ld a,3 |
- | 83 | out (c),a |
|
- | 84 | ld bc,0xFAEF;UART_FCR ;сбрасываем буферы |
|
- | 85 | ld a,7 |
|
70 | out (c),a |
86 | out (c),a |
71 | 87 | ||
72 | call doson |
88 | ;call doson |
73 | 89 | ||
- | 90 | di |
|
74 | ld hl,TRDSIZE&0xffff |
91 | ld hl,TRDSIZE&0xffff |
75 | ld de,TRDSIZE/65536 |
92 | ld de,TRDSIZE/65536 |
76 | readloop0 |
93 | readloop0 |
77 | ;dehl=remaining size |
94 | ;dehl=remaining size |
78 | ld bc,filebufsz |
95 | ld bc,filebufsz |
Line 87... | Line 104... | ||
87 | readloop_fullsize |
104 | readloop_fullsize |
88 | ld h,b |
105 | ld h,b |
89 | ld l,c |
106 | ld l,c |
90 | readloop_tailsize |
107 | readloop_tailsize |
91 | push hl ;size to read |
108 | push hl ;size to read |
92 | call readtofile |
109 | call readtomem;file |
93 | pop bc ;size to read |
110 | pop bc ;size to read |
94 | pop hl ;remaining size |
111 | pop hl ;remaining size |
95 | pop de ;remaining size HSW |
112 | pop de ;remaining size HSW |
96 | or a |
113 | or a |
97 | sbc hl,bc |
114 | sbc hl,bc |
Line 100... | Line 117... | ||
100 | ld a,d |
117 | ld a,d |
101 | or e |
118 | or e |
102 | or h |
119 | or h |
103 | or l |
120 | or l |
104 | jr nz,readloop0 |
121 | jr nz,readloop0 |
- | 122 | ei |
|
- | 123 | ||
- | 124 | ld hl,TRDSIZE&0xffff |
|
- | 125 | ld de,TRDSIZE/65536 |
|
- | 126 | saveloop0 |
|
- | 127 | ;dehl=remaining size |
|
- | 128 | ld bc,filebufsz |
|
- | 129 | push de ;remaining size HSW |
|
- | 130 | push hl ;remaining size |
|
- | 131 | ld a,d |
|
- | 132 | or e |
|
- | 133 | jr nz,saveloop_fullsize |
|
- | 134 | sbc hl,bc |
|
- | 135 | add hl,bc |
|
- | 136 | jr c,saveloop_tailsize ;dehl < bc |
|
- | 137 | saveloop_fullsize |
|
- | 138 | ld h,b |
|
- | 139 | ld l,c |
|
- | 140 | saveloop_tailsize |
|
- | 141 | push hl ;size to read |
|
- | 142 | call savetofile |
|
- | 143 | pop bc ;size to read |
|
- | 144 | pop hl ;remaining size |
|
- | 145 | pop de ;remaining size HSW |
|
- | 146 | or a |
|
- | 147 | sbc hl,bc |
|
- | 148 | jr nc,$+3 |
|
- | 149 | dec de |
|
- | 150 | ld a,d |
|
- | 151 | or e |
|
- | 152 | or h |
|
- | 153 | or l |
|
- | 154 | jr nz,saveloop0 |
|
105 | 155 | ||
106 | pop bc |
156 | pop bc |
107 | OS_CLOSEHANDLE |
157 | OS_CLOSEHANDLE |
108 | ld hl,0 |
158 | ld hl,0 |
109 | QUIT |
159 | QUIT |
110 | errorquit |
160 | errorquit |
111 | ld l,a |
161 | ld l,a |
112 | ld h,0 |
162 | ld h,0 |
113 | QUIT |
163 | QUIT |
114 | 164 | ||
115 | readtofile |
165 | readtomem;file |
116 | ;hl=size |
166 | ;hl=size |
117 | push hl |
167 | push hl |
118 | call dosoff |
168 | ;call dosoff |
- | 169 | ||
- | 170 | readtomem_tpgspointer=$+1 |
|
- | 171 | ld hl,tpgs |
|
- | 172 | ld a,(hl) |
|
- | 173 | SETPGC000 |
|
- | 174 | inc hl |
|
- | 175 | ld (readtomem_tpgspointer),hl |
|
- | 176 | ||
119 | pop hl |
177 | pop hl |
120 | 178 | ||
121 | ld de,filebuf |
179 | ld de,filebuf |
122 | 180 | ||
123 | push hl |
181 | push hl |
Line 140... | Line 198... | ||
140 | dec hl |
198 | dec hl |
141 | ld a,h |
199 | ld a,h |
142 | or l |
200 | or l |
143 | jp nz,readtofile0 |
201 | jp nz,readtofile0 |
144 | 202 | ||
145 | call doson |
203 | ;call doson |
- | 204 | ||
- | 205 | pop hl ;size |
|
- | 206 | ret |
|
146 | 207 | ||
- | 208 | savetofile |
|
- | 209 | push hl ;size |
|
- | 210 | savetofile_tpgspointer=$+1 |
|
- | 211 | ld hl,tpgs |
|
- | 212 | ld a,(hl) |
|
- | 213 | SETPGC000 |
|
- | 214 | inc hl |
|
- | 215 | ld (savetofile_tpgspointer),hl |
|
147 | pop hl ;size |
216 | pop hl ;size |
148 | 217 | ||
149 | ld de,filebuf |
218 | ld de,filebuf |
150 | filehandle=$+1 |
219 | filehandle=$+1 |
151 | ld b,0 |
220 | ld b,0 |
Line 209... | Line 278... | ||
209 | db "file.trd" |
278 | db "file.trd" |
210 | ds MAXCMDSZ+1 -8 |
279 | ds MAXCMDSZ+1 -8 |
211 | 280 | ||
212 | cmd_end |
281 | cmd_end |
213 | 282 | ||
- | 283 | align 256 |
|
- | 284 | tpgs |
|
- | 285 | ds 64 |
|
- | 286 | ||
214 | filebuf |
287 | ;filebuf |
215 | ds filebufsz |
288 | ; ds filebufsz |
216 | 289 | ||
217 | 290 | ||
218 | 291 | ||
219 | savebin "gettrd.com",cmd_begin,cmd_end-cmd_begin |
292 | savebin "gettrd.com",cmd_begin,cmd_end-cmd_begin |
220 | 293 |