Rev 64 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
64 | dimkam | 1 | DEVICE ZXSPECTRUM128 |
2 | |||
3 | ORG 0x8000 |
||
4 | START |
||
5 | ;�������� ���� |
||
6 | WIZ_BASE_ADDR = 0xc000 |
||
7 | W_MR = WIZ_BASE_ADDR+0x0000 |
||
8 | W_SHAR = WIZ_BASE_ADDR+0x0008 |
||
9 | |||
10 | S0_MR = WIZ_BASE_ADDR+0x0201 ;��.���� |
||
11 | S0_CR = WIZ_BASE_ADDR+0x0203 ;��.���� |
||
12 | S0_SSR = WIZ_BASE_ADDR+0x0209 ;��.���� |
||
13 | S0_PORTR = WIZ_BASE_ADDR+0x020a |
||
14 | S0_DPORTR = WIZ_BASE_ADDR+0x0212 |
||
15 | S0_DIPR = WIZ_BASE_ADDR+0x0214 |
||
16 | S0_TX_WRSR = WIZ_BASE_ADDR+0x0222 ;��.����� |
||
17 | S0_RX_RSR = WIZ_BASE_ADDR+0x022a |
||
18 | S0_TX_FAKE = WIZ_BASE_ADDR+0x2000 |
||
19 | S0_RX_FAKE = WIZ_BASE_ADDR+0x3000 |
||
20 | ;/***************************************/ |
||
21 | ;/* The bit of Sn_MR regsiter defintion */ |
||
22 | ;/***************************************/ |
||
23 | Sn_MR_CLOSE = 0x00 ;/**< Protocol bits of Sn_MR. */ |
||
24 | Sn_MR_TCP = 0x01 ;/**< Protocol bits of Sn_MR. */ |
||
25 | Sn_MR_UDP = 0x02 ;/**< Protocol bits of Sn_MR. */ |
||
26 | Sn_MR_IPRAW = 0x03 ;/**< Protocol bits of Sn_MR. */ |
||
27 | Sn_MR_MACRAW = 0x04 ;/**< Protocol bits of Sn_MR. */ |
||
28 | Sn_MR_PPPoE = 0x05 ;/**< Protocol bits of Sn_MR. */ |
||
29 | |||
30 | /******************************/ |
||
31 | /* The values of CR defintion */ |
||
32 | /******************************/ |
||
33 | Sn_CR_OPEN = 0x01 ;/**< OPEN command value of Sn_CR. */ |
||
34 | Sn_CR_LISTEN = 0x02 ;/**< LISTEN command value of Sn_CR. */ |
||
35 | Sn_CR_CONNECT = 0x04 ;/**< CONNECT command value of Sn_CR. */ |
||
36 | Sn_CR_DISCON = 0x08 ;/**< DISCONNECT command value of Sn_CR. */ |
||
37 | Sn_CR_CLOSE = 0x10 ;/**< CLOSE command value of Sn_CR. */ |
||
38 | Sn_CR_SEND = 0x20 ;/**< SEND command value of Sn_CR. */ |
||
39 | Sn_CR_SEND_MAC = 0x21 ;/**< SEND_MAC command value of Sn_CR. */ |
||
40 | Sn_CR_SEND_KEEP = 0x22 ;/**< SEND_KEEP command value of Sn_CR */ |
||
41 | Sn_CR_RECV = 0x40 ;/**< RECV command value of Sn_CR */ |
||
42 | Sn_CR_PCON = 0x23 ;/**< PCON command value of Sn_CR */ |
||
43 | Sn_CR_PDISCON = 0x24 ;/**< PDISCON command value of Sn_CR */ |
||
44 | Sn_CR_PCR = 0x25 ;/**< PCR command value of Sn_CR */ |
||
45 | Sn_CR_PCN = 0x26 ;/**< PCN command value of Sn_CR */ |
||
46 | Sn_CR_PCJ = 0x27 ;/**< PCJ command value of Sn_CR */ |
||
47 | |||
48 | ;/**********************************/ |
||
49 | ;/* The values of Sn_SSR defintion */ |
||
50 | ;/**********************************/ |
||
51 | SOCK_CLOSED = 0x00 ;< SOCKETn is released */ |
||
52 | SOCK_ARP = 0x01 ;< ARP-request is transmitted in order to acquire destination hardware address. */ |
||
53 | SOCK_INIT = 0x13 ;< SOCKETn is open as TCP mode. */ |
||
54 | SOCK_LISTEN = 0x14 ;< SOCKETn operates as "TCP SERVER" and waits for connection-request (SYN packet) from "TCP CLIENT". */ |
||
55 | SOCK_SYNSENT = 0x15 ;< Connect-request(SYN packet) is transmitted to "TCP SERVER". */ |
||
56 | SOCK_SYNRECV = 0x16 ;< Connect-request(SYN packet) is received from "TCP CLIENT". */ |
||
57 | SOCK_ESTABLISHED = 0x17 ;< TCP connection is established. */ |
||
58 | SOCK_FIN_WAIT = 0x18 ;< SOCKETn is closing. */ |
||
59 | SOCK_CLOSING = 0x1A ;< SOCKETn is closing. */ |
||
60 | SOCK_TIME_WAIT = 0x1B ;< SOCKETn is closing. */ |
||
61 | SOCK_CLOSE_WAIT = 0x1C ;< Disconnect-request(FIN packet) is received from the peer. */ |
||
62 | SOCK_LAST_ACK = 0x1D ;< SOCKETn is closing. */ |
||
63 | SOCK_UDP = 0x22 ;< SOCKETn is open as UDP mode. */ |
||
64 | SOCK_IPRAW = 0x32 ;< SOCKETn is open as IPRAW mode. */ |
||
65 | SOCK_MACRAW = 0x42 ;< SOCKET0 is open as MACRAW mode. */ |
||
66 | SOCK_PPPoE = 0x5F ;< SOCKET0 is open as PPPoE mode. */ |
||
67 | |||
68 | di |
||
69 | ld sp,0xc000 |
||
70 | ld hl,0x4000 |
||
71 | ld (hl),0 |
||
72 | ld de,0x4001 |
||
73 | ld bc,192*256/8-1 |
||
74 | ldir |
||
75 | ;������ ��������� ���� |
||
76 | ;��� �������� ��������� �� 50�� |
||
77 | ei |
||
78 | halt |
||
79 | ld bc,0x83ab |
||
80 | in a,(c) |
||
81 | and 0xee |
||
82 | out (c),a ; ����� |
||
83 | halt |
||
84 | or 0x10 |
||
85 | out (c),a ; ������ ������ |
||
86 | halt |
||
87 | |||
88 | ;������������� ��������� � �������� ������������ z80. |
||
89 | ;��� ������� ���������� � ������ 0xc000-0xffff (� �������� ZX-Evo baseconf). |
||
90 | ;������������� ����� ����������� ������ ��� ������������ ��� � �������� �������� ����. |
||
91 | ;�������� ��� �� ����� �������� |
||
92 | ld a,1 |
||
93 | out (0xbf),a |
||
94 | ld bc,0xfff7 |
||
95 | ld a,0x3f |
||
96 | out (c),a |
||
97 | ;������ �������� ������������� |
||
98 | ld bc,0x82ab |
||
99 | ld a,7 |
||
100 | out (c),a |
||
101 | |||
102 | ;����� ��������� ����(������ �������� ��������, �� ����������) |
||
103 | ld a,0x80 |
||
104 | ld (W_MR+1),a |
||
105 | halt |
||
106 | ld a,0x3c |
||
107 | ld (W_MR),a |
||
108 | di |
||
109 | ;���������� MAC, ����, ����� � ��. �������� ��� ����!!! |
||
110 | ld hl,mac |
||
111 | ld de,W_SHAR |
||
112 | ld bc,20 |
||
113 | ldir |
||
114 | ;� ����� ������� ��� ����� ����������� � ��������� ����� ������� ������������. |
||
115 | ;������� ����� �������� ����� � ��������� ������ ���, �� ��� ������� � ����� ����������. |
||
116 | |||
117 | ;---------------------------------------------------------- |
||
118 | ;������ ����������� � TCP(����) ������� � �������� ������� |
||
119 | ;---------------------------------------------------------- |
||
120 | |||
121 | ;�������� ����� |
||
122 | soc_noinit |
||
123 | ld a,Sn_CR_CLOSE ;������� ���������� |
||
124 | ld (S0_CR),a |
||
125 | ld a,Sn_MR_TCP ;����� ������ TCP |
||
126 | ld (S0_MR),a |
||
127 | ld hl,(source_port) ;���������� ���������� ����, ���� � ���������� �� ��������� |
||
128 | inc hl |
||
129 | ld (source_port),hl |
||
130 | ld e,h ;���������, ������ ����� ������� |
||
131 | ld d,l |
||
132 | ld (S0_PORTR),de |
||
133 | ld a,Sn_CR_OPEN ;���� ������� �������� ������ |
||
134 | ld (S0_CR),a |
||
135 | wait_cr0 |
||
136 | ld a,(S0_CR) ;������� ���������� ������� |
||
137 | or a |
||
138 | jr nz,wait_cr0 |
||
139 | ld a,(S0_SSR) ;���� �� �����������������, �� ������ |
||
140 | cp SOCK_INIT |
||
141 | jr nz,soc_noinit |
||
142 | ;-------------------- |
||
143 | ;���������� � ������� |
||
144 | ;-------------------- |
||
145 | ld hl,S0_DPORTR ;���� ������� !���������! |
||
146 | ld (hl),0 |
||
147 | inc hl |
||
148 | ld (hl),80 |
||
149 | ld hl,S0_DIPR ;ip ������� ������1999 217.146.69.13 |
||
150 | ld (hl),217 |
||
151 | inc hl |
||
152 | ld (hl),146 |
||
153 | inc hl |
||
154 | ld (hl),69 |
||
155 | inc hl |
||
156 | ld (hl),13 |
||
157 | ld a,Sn_CR_CONNECT ;���� ������� ������� |
||
158 | ld (S0_CR),a |
||
159 | wait_cr1 |
||
160 | ld a,(S0_CR) ;������� ���������� ������� |
||
161 | or a |
||
162 | jr nz,wait_cr1 |
||
163 | ;������� �������� � �������� |
||
164 | wait_con |
||
165 | ld a,(S0_SSR) |
||
166 | or a |
||
167 | jp z,soc_noinit ;������ ����� ������(��������) ������� |
||
168 | cp SOCK_ESTABLISHED ;������ �� ��� ���� ��������� � ������ ���� ����, � ������ ����� |
||
169 | jr nz,wait_con ;�� �� ������ �� ��� ���� |
||
170 | wait_con_end |
||
171 | |||
172 | ;��������������, ������ GET ������ |
||
173 | ;-------------------- |
||
174 | ;�������� ������ |
||
175 | ;-------------------- |
||
176 | ld hl,get_str ;���������� ���� � ����� ���� |
||
177 | ld de,S0_TX_FAKE |
||
178 | ld bc,get_str_end-get_str |
||
179 | inc bc ;���������� ���� ������ ���������� ���� |
||
180 | res 0,c ;������� �������� �� ������� |
||
181 | ldir ;������ ��������!!! ldir'��� ����� �� ����� 512 ����, ������ �������� ������, |
||
182 | ;�� �� ������� ���� ������, �.�. ������ � ��� ���� ������ |
||
183 | ld a,high (get_str_end-get_str) |
||
184 | ld (S0_TX_WRSR),a ;���������� ������ ����, �� ������� ��� ��������� |
||
185 | ld a,low (get_str_end-get_str) |
||
186 | ld (S0_TX_WRSR+1),a ;� ��� ����� ����� ��������� ������ ���-�� ����, �������� �� ���������� |
||
187 | |||
188 | ld a,Sn_CR_SEND ;���� ������� �������� |
||
189 | ld (S0_CR),a |
||
190 | wait_cr2 |
||
191 | ld a,(S0_CR) ;������� ���������� ������� |
||
192 | or a |
||
193 | jr nz,wait_cr2 |
||
194 | |||
195 | ;-------------------- |
||
196 | ;������� ����� �� ������� |
||
197 | ;-------------------- |
||
198 | ld de,0 |
||
199 | wait_pack0 |
||
200 | ld de,(S0_RX_RSR) ;������ ������ ������ |
||
201 | ld a,d |
||
202 | or e ;���� �������, �� ��� ������ |
||
203 | jr z,wait_pack0 |
||
204 | wait_pack1 |
||
205 | ld hl,(S0_RX_RSR) ;���, ������ |
||
206 | ex de,hl ;������ ��� ������������� ���� |
||
207 | xor a ;�������� ������ � ���� �� ��������, �� ������ ��� ��� ������ |
||
208 | sbc hl,de |
||
209 | ld a,h |
||
210 | or l |
||
211 | jr nz,wait_pack1 |
||
212 | ;����� ������� ����� ���������, ���� ��� �������� |
||
213 | ;�.�. � S0_RX_RSR ������ ������ ����, ��... |
||
214 | |||
215 | ;-------------------- |
||
216 | ;������ ��������� �������� ������, ��� ����� � ������ ���� ������ ������ ������ |
||
217 | ;-------------------- |
||
218 | ld hl,(S0_RX_FAKE) |
||
219 | ld b,l ;��������� ��������� |
||
220 | ld c,h |
||
221 | ;-------------------- |
||
222 | ;������ �����, � de � ��� ����� ������ ������� ����(���������) |
||
223 | ;-------------------- |
||
224 | ;���������� � ������ ������� |
||
225 | ld b,e |
||
226 | ld c,d |
||
227 | dec bc ;� �������� ������ ������ ���� � ������ ���� ������ ����, |
||
228 | dec bc ;������� ������� ��� ������(������ ������ ������) |
||
229 | ld hl,S0_RX_FAKE |
||
230 | ld de,buf_rx |
||
231 | loop_read |
||
232 | ld l,0 |
||
233 | ld a,c |
||
234 | or b |
||
235 | jr z,end_read |
||
236 | ldi |
||
237 | ldi |
||
238 | jr loop_read |
||
239 | end_read |
||
240 | |||
241 | ld a,Sn_CR_RECV ;���� ����� ��� ����� ������� |
||
242 | ld (S0_CR),a |
||
243 | wait_cr3 |
||
244 | ld a,(S0_CR) ;������� ���������� ������� |
||
245 | or a |
||
246 | jr nz,wait_cr3 |
||
247 | |||
248 | ;���� ��, ����� ��������� �����, �������� ���������, ����������. �� ��� ��� ����, � �������� ����������. |
||
249 | |||
250 | ;-------------------- |
||
251 | ;������� ���������� |
||
252 | ;-------------------- |
||
253 | |||
254 | ld a,Sn_CR_CLOSE ;������� ���������� |
||
255 | ld (S0_CR),a |
||
256 | |||
257 | ;-------------------- |
||
258 | ;��, ������ �������. |
||
259 | ;-------------------- |
||
260 | |||
261 | |||
262 | ld bc,768 ;�� ����� �� ����������. |
||
263 | ld hl,buf_rx+478 ;��� ����� �������� ���������(����� ����������, ���� �������� ���� � �������������) |
||
264 | ld de,0x5800 ;� �������� ��� ���� ���������� HTTP ������� |
||
265 | ldir |
||
266 | di |
||
267 | halt |
||
268 | |||
269 | ;������ ����(!!!��� �������� �������� ��� ����������� ����!!!) |
||
270 | mac |
||
271 | db 0x00,0x08,0xDC,0x01,0x02,0x03 ;����� �� ����� ����, �� ���������� ���� |
||
272 | reserved |
||
273 | db 0x00,0x00 ;��� ��� ����, ���� ����� ������ �������� |
||
274 | gateway |
||
275 | db 192,168,0,1 |
||
276 | mask |
||
277 | db 255,255,255,0 |
||
278 | ip |
||
279 | db 192,168,0,77 |
||
280 | |||
281 | ;���������� ���� |
||
282 | source_port dw 0 |
||
283 | |||
284 | ;http://zx.maros.pri.ee/file/id/15733/filename/Yerzmyey_-_Cat_42_%282009%29_%28_International_Vodka_Party_5%2C_4%29.atr |
||
285 | get_str |
||
286 | db "GET /file/id/15733/filename/Yerzmyey_-_Cat_42_%282009%29_%28_International_Vodka_Party_5%2C_4%29.atr HTTP/1.1",13,10 |
||
287 | db "Host: zx.maros.pri.ee",13,10 |
||
288 | db 13,10,0 |
||
289 | get_str_end |
||
290 | buf_rx |
||
291 | |||
292 | ENDPROG |
||
293 | SAVEHOB "s1.$C","s1.C",START,ENDPROG-START |
||
294 | SAVEBIN "s1",START,ENDPROG-START |