Subversion Repositories Kolibri OS

Rev

Rev 532 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 532 Rev 551
1
;
1
;
2
;    CHESS CLIENT for CHESSCLUB.COM (VT)
2
;    CHESS CLIENT for CHESSCLUB.COM (VT)
3
;
3
;
4
;    Compile with FASM for Menuet
4
;    Compile with FASM for Menuet
5
;
5
;
6
 
6
 
7
appname equ 'Chess Client for Chessclub.com '
7
appname equ 'Chess Client for Chessclub.com '
8
version equ '0.2'
8
version equ '0.2'
9
 
9
 
10
use32
10
use32
11
 org	0x0
11
 org	0x0
12
 db	'MENUET01'    ; header
12
 db	'MENUET01'    ; header
13
 dd	0x01	      ; header version
13
 dd	0x01	      ; header version
14
 dd	START	      ; entry point
14
 dd	START	      ; entry point
15
 dd	I_END	      ; image size
15
 dd	I_END	      ; image size
16
 dd	0x100000      ; required memory
16
 dd	0x100000      ; required memory
17
 dd	0x100000      ; esp
17
 dd	0x100000      ; esp
18
 dd	0x0 , 0x0     ; I_Param , I_Path
18
 dd	0x0 , 0x0     ; I_Param , I_Path
19
 
19
 
20
include 'lang.inc'
20
include 'lang.inc'
21
include '..\..\..\macros.inc'
21
include '..\..\..\macros.inc'
22
 
22
 
23
pawn_color:
23
pawn_color:
24
 
24
 
25
     dd  0x000000
25
     dd  0x000000
26
     dd  0x222222
26
     dd  0x222222
27
     dd  0x444444
27
     dd  0x444444
28
     dd  0xf0f0f0
28
     dd  0xf0f0f0
29
     dd  0xc0c0c0
29
     dd  0xc0c0c0
30
     dd  0xa0a0a0
30
     dd  0xa0a0a0
31
     dd  0xa0a0a0
31
     dd  0xa0a0a0
32
     dd  0x707070
32
     dd  0x707070
33
     dd  0xb0b0b0
33
     dd  0xb0b0b0
34
     dd  0xc0c0c0
34
     dd  0xc0c0c0
35
     dd  0xd0d0d0
35
     dd  0xd0d0d0
36
     dd  0xd8d8d8
36
     dd  0xd8d8d8
37
     dd  0xe0e0e0
37
     dd  0xe0e0e0
38
     dd  0xe8e8e8
38
     dd  0xe8e8e8
39
     dd  0x00ff00
39
     dd  0x00ff00
40
     dd  0xffffff
40
     dd  0xffffff
41
 
41
 
42
 
42
 
43
 
43
 
44
texts  equ  board_old+80*30
44
texts  equ  board_old+80*30
45
 
45
 
46
text   equ  texts+80*32*4
46
text   equ  texts+80*32*4
47
 
47
 
48
 
48
 
49
START:				; start of execution
49
START:				; start of execution
50
 
50
 
51
    mov  esi,chess_bmp
51
    mov  esi,chess_bmp
52
    mov  edi,0x10000+18*3
52
    mov  edi,0x10000+18*3
53
 
53
 
54
    mov  ebx,0
54
    mov  ebx,0
55
    mov  ecx,0
55
    mov  ecx,0
56
 
56
 
57
  newp:
57
  newp:
58
 
58
 
59
    xor  eax,eax
59
    xor  eax,eax
60
    mov  al,[esi]
60
    mov  al,[esi]
61
    and  al,0xf0
61
    and  al,0xf0
62
    shr  al,4
62
    shr  al,4
63
    shl  eax,2
63
    shl  eax,2
64
    mov  eax,[pawn_color+eax]
64
    mov  eax,[pawn_color+eax]
65
    mov  [edi+0],eax
65
    mov  [edi+0],eax
66
 
66
 
67
    xor  eax,eax
67
    xor  eax,eax
68
    mov  al,[esi]
68
    mov  al,[esi]
69
    and  al,0x0f
69
    and  al,0x0f
70
    shl  eax,2
70
    shl  eax,2
71
    mov  eax,[pawn_color+eax]
71
    mov  eax,[pawn_color+eax]
72
    mov  [edi+3],eax
72
    mov  [edi+3],eax
73
 
73
 
74
    add  edi,6
74
    add  edi,6
75
    add  esi,1
75
    add  esi,1
76
 
76
 
77
    inc  ebx
77
    inc  ebx
78
    cmp  ebx,23
78
    cmp  ebx,23
79
    jbe  newp
79
    jbe  newp
80
 
80
 
81
    sub  edi,12
81
    sub  edi,12
82
 
82
 
83
    mov  ebx,0
83
    mov  ebx,0
84
 
84
 
85
    inc  ecx
85
    inc  ecx
86
    cmp  ecx,279
86
    cmp  ecx,279
87
    jb	 newp
87
    jb	 newp
88
 
88
 
89
    ; Clear the screen memory
89
    ; Clear the screen memory
90
    mov     eax, '    '
90
    mov     eax, '    '
91
    mov     edi,text
91
    mov     edi,text
92
    mov     ecx,80*30 /4
92
    mov     ecx,80*30 /4
93
    cld
93
    cld
94
    rep     stosd
94
    rep     stosd
95
 
95
 
96
 
96
 
97
    call draw_window
97
    call draw_window
98
 
98
 
99
still:
99
still:
100
 
100
 
101
    call  check_for_board
101
    call  check_for_board
102
 
102
 
103
    call  board_changed
103
    call  board_changed
104
 
104
 
105
    call  draw_board
105
    call  draw_board
106
 
106
 
107
    ; check connection status
107
    ; check connection status
108
    mov  eax,53
108
    mov  eax,53
109
    mov  ebx,6
109
    mov  ebx,6
110
    mov  ecx,[socket]
110
    mov  ecx,[socket]
111
    mcall
111
    mcall
112
 
112
 
113
    mov     ebx, [socket_status]
113
    mov     ebx, [socket_status]
114
    mov     [socket_status], eax
114
    mov     [socket_status], eax
115
 
115
 
116
    cmp     eax, ebx
116
    cmp     eax, ebx
117
    je	    waitev
117
    je	    waitev
118
 
118
 
119
    call    display_status
119
    call    display_status
120
 
120
 
121
waitev:
121
waitev:
122
    mov  eax,23 		; wait here for event
122
    mov  eax,23 		; wait here for event
123
    mov  ebx,20
123
    mov  ebx,20
124
    mcall
124
    mcall
125
 
125
 
126
    cmp  eax,1			; redraw request ?
126
    cmp  eax,1			; redraw request ?
127
    je	 red
127
    je	 red
128
    cmp  eax,2			; key in buffer ?
128
    cmp  eax,2			; key in buffer ?
129
    je	 key
129
    je	 key
130
    cmp  eax,3			; button in buffer ?
130
    cmp  eax,3			; button in buffer ?
131
    je	 button
131
    je	 button
132
 
132
 
133
    ; any data from the socket?
133
    ; any data from the socket?
134
 
134
 
135
    mov     eax, 53
135
    mov     eax, 53
136
    mov     ebx, 2
136
    mov     ebx, 2
137
    mov     ecx, [socket]
137
    mov     ecx, [socket]
138
    mcall
138
    mcall
139
    cmp     eax, 0
139
    cmp     eax, 0
140
    jne      read_input
140
    jne      read_input
141
 
141
 
142
    jmp  still
142
    jmp  still
143
 
143
 
144
 
144
 
145
read_input:
145
read_input:
146
 
146
 
147
    push ecx
147
    push ecx
148
    mov     eax, 53
148
    mov     eax, 53
149
    mov     ebx, 3
149
    mov     ebx, 3
150
    mov     ecx, [socket]
150
    mov     ecx, [socket]
151
    mcall
151
    mcall
152
    pop  ecx
152
    pop  ecx
153
 
153
 
154
    call    handle_data
154
    call    handle_data
155
 
155
 
156
    push    ecx
156
    push    ecx
157
    mov     eax, 53
157
    mov     eax, 53
158
    mov     ebx, 2
158
    mov     ebx, 2
159
    mov     ecx, [socket]
159
    mov     ecx, [socket]
160
    mcall
160
    mcall
161
    pop     ecx
161
    pop     ecx
162
    cmp     eax, 0
162
    cmp     eax, 0
163
 
163
 
164
 
164
 
165
    jne   read_input
165
    jne   read_input
166
    call draw_text
166
    call draw_text
167
    jmp  still
167
    jmp  still
168
 
168
 
169
 
169
 
170
 
170
 
171
check_for_board:
171
check_for_board:
172
 
172
 
173
    pusha
173
    pusha
174
 
174
 
175
     mov  esi,text-80
175
     mov  esi,text-80
176
   news:
176
   news:
177
    add  esi,80
177
    add  esi,80
178
    cmp  esi,text+80*10
178
    cmp  esi,text+80*10
179
    je	 board_not_found
179
    je	 board_not_found
180
    cmp  [esi+12],dword '----'
180
    cmp  [esi+12],dword '----'
181
    je	 cfb1
181
    je	 cfb1
182
    jmp  news
182
    jmp  news
183
   cfb1:
183
   cfb1:
184
    cmp  [esi+16*80+12],dword '----'
184
    cmp  [esi+16*80+12],dword '----'
185
    je	 cfb2
185
    je	 cfb2
186
    jmp  news
186
    jmp  news
187
  cfb2:
187
  cfb2:
188
    cmp  [esi+2*80+12],dword '+---'
188
    cmp  [esi+2*80+12],dword '+---'
189
    jne  news
189
    jne  news
190
 
190
 
191
    cmp  [esi+4*80+12],dword '+---'
191
    cmp  [esi+4*80+12],dword '+---'
192
    jne  news
192
    jne  news
193
 
193
 
194
  board_found:
194
  board_found:
195
 
195
 
196
    mov  edi,chess_board
196
    mov  edi,chess_board
197
    mov  ecx,80*18
197
    mov  ecx,80*18
198
    cld
198
    cld
199
    rep  movsb
199
    rep  movsb
200
 
200
 
201
   board_not_found:
201
   board_not_found:
202
 
202
 
203
     popa
203
     popa
204
 
204
 
205
     ret
205
     ret
206
 
206
 
207
 
207
 
208
yst	dd  150
208
yst	dd  150
209
textx	equ 10
209
textx	equ 10
210
ysts	equ 410
210
ysts	equ 410
211
 
211
 
212
boardx	dd 45
212
boardx	dd 45
213
boardy	dd 45
213
boardy	dd 45
214
 
214
 
215
boardxs dd 44
215
boardxs dd 44
216
boardys dd 44
216
boardys dd 44
217
 
217
 
218
conx	equ 420
218
conx	equ 420
219
cony	equ 118
219
cony	equ 118
220
 
220
 
221
dconx	equ 420
221
dconx	equ 420
222
dcony	equ 148
222
dcony	equ 148
223
 
223
 
224
statusx equ 420
224
statusx equ 420
225
statusy equ 178
225
statusy equ 178
226
 
226
 
227
 
227
 
228
drsq:
228
drsq:
229
 
229
 
230
     push eax ebx
230
     push eax ebx
231
 
231
 
232
     mov  ecx,ebx
232
     mov  ecx,ebx
233
     mov  ebx,eax
233
     mov  ebx,eax
234
 
234
 
235
     mov  eax,ebx
235
     mov  eax,ebx
236
     add  eax,ecx
236
     add  eax,ecx
237
 
237
 
238
     imul ebx,[boardxs]
238
     imul ebx,[boardxs]
239
     add  ebx,[boardx]
239
     add  ebx,[boardx]
240
     shl  ebx,16
240
     shl  ebx,16
241
     imul ecx,[boardys]
241
     imul ecx,[boardys]
242
     add  ecx,[boardy]
242
     add  ecx,[boardy]
243
     shl  ecx,16
243
     shl  ecx,16
244
 
244
 
245
     add  ebx,[boardxs]
245
     add  ebx,[boardxs]
246
     add  ecx,[boardys]
246
     add  ecx,[boardys]
247
 
247
 
248
     mov  edx,[sq_black]
248
     mov  edx,[sq_black]
249
     test eax,1
249
     test eax,1
250
     jnz  dbl22
250
     jnz  dbl22
251
     mov  edx,[sq_white]
251
     mov  edx,[sq_white]
252
   dbl22:
252
   dbl22:
253
 
253
 
254
     mov  eax,13
254
     mov  eax,13
255
     mcall
255
     mcall
256
 
256
 
257
     pop  ebx eax
257
     pop  ebx eax
258
 
258
 
259
     ret
259
     ret
260
 
260
 
261
 
261
 
262
 
262
 
263
draw_pawn:
263
draw_pawn:
264
 
264
 
265
;    edi,0  ; white / black
265
;    edi,0  ; white / black
266
;    esi,0  ; from position 2  , 20 square
266
;    esi,0  ; from position 2  , 20 square
267
;    eax,2  ; board x
267
;    eax,2  ; board x
268
;    ebx,0  ; board y
268
;    ebx,0  ; board y
269
 
269
 
270
     pusha
270
     pusha
271
 
271
 
272
     call drsq
272
     call drsq
273
 
273
 
274
     cmp  esi,20
274
     cmp  esi,20
275
     jne  no_sqd
275
     jne  no_sqd
276
 
276
 
277
     popa
277
     popa
278
     ret
278
     ret
279
 
279
 
280
   no_sqd:
280
   no_sqd:
281
 
281
 
282
     imul eax,[boardxs]
282
     imul eax,[boardxs]
283
     imul ebx,[boardys]
283
     imul ebx,[boardys]
284
 
284
 
285
     add  eax,[boardx]
285
     add  eax,[boardx]
286
     add  ebx,[boardy]
286
     add  ebx,[boardy]
287
 
287
 
288
     imul esi,44*45*3
288
     imul esi,44*45*3
289
     add  esi,0x10000+18*3
289
     add  esi,0x10000+18*3
290
 
290
 
291
     mov  ecx,43
291
     mov  ecx,43
292
 
292
 
293
   dp0:
293
   dp0:
294
 
294
 
295
     pusha
295
     pusha
296
 
296
 
297
     mov  ecx,44
297
     mov  ecx,44
298
 
298
 
299
   ldp1:
299
   ldp1:
300
 
300
 
301
     pusha
301
     pusha
302
 
302
 
303
     mov  ecx,ebx
303
     mov  ecx,ebx
304
     mov  ebx,eax
304
     mov  ebx,eax
305
 
305
 
306
     mov  edx,[esi]
306
     mov  edx,[esi]
307
     and  edx,0xffffff
307
     and  edx,0xffffff
308
     mov  eax,1
308
     mov  eax,1
309
     cmp  edx,0x00ff00
309
     cmp  edx,0x00ff00
310
     je   nowp
310
     je   nowp
311
     cmp  edi,1
311
     cmp  edi,1
312
     jne  nobl
312
     jne  nobl
313
     shr  edx,1
313
     shr  edx,1
314
     and  edx,0x7f7f7f
314
     and  edx,0x7f7f7f
315
   nobl:
315
   nobl:
316
     mcall
316
     mcall
317
   nowp:
317
   nowp:
318
 
318
 
319
     popa
319
     popa
320
 
320
 
321
     add  esi,3
321
     add  esi,3
322
     add  eax,1
322
     add  eax,1
323
 
323
 
324
     dec  ecx
324
     dec  ecx
325
     jnz  ldp1
325
     jnz  ldp1
326
 
326
 
327
     popa
327
     popa
328
 
328
 
329
     add  ebx,1
329
     add  ebx,1
330
     add  esi,3*44
330
     add  esi,3*44
331
 
331
 
332
     dec  ecx
332
     dec  ecx
333
     jnz  dp0
333
     jnz  dp0
334
 
334
 
335
     popa
335
     popa
336
 
336
 
337
     ret
337
     ret
338
 
338
 
339
 
339
 
340
board_changed:
340
board_changed:
341
 
341
 
342
    pusha
342
    pusha
343
 
343
 
344
    mov  eax,0
344
    mov  eax,0
345
    mov  esi,chess_board
345
    mov  esi,chess_board
346
  bcl1:
346
  bcl1:
347
    add  eax,[esi]
347
    add  eax,[esi]
348
    add  esi,4
348
    add  esi,4
349
    cmp  esi,chess_board+19*80
349
    cmp  esi,chess_board+19*80
350
    jb	 bcl1
350
    jb	 bcl1
351
 
351
 
352
    cmp  eax,[checksum]
352
    cmp  eax,[checksum]
353
    je	 bcl2
353
    je	 bcl2
354
    mov  [changed],1
354
    mov  [changed],1
355
  bcl2:
355
  bcl2:
356
    mov  [checksum],eax
356
    mov  [checksum],eax
357
 
357
 
358
    popa
358
    popa
359
 
359
 
360
    ret
360
    ret
361
 
361
 
362
 
362
 
363
 
363
 
364
checksum dd 0
364
checksum dd 0
365
 
365
 
366
changed db 1
366
changed db 1
367
 
367
 
368
draw_board:
368
draw_board:
369
 
369
 
370
     pusha
370
     pusha
371
 
371
 
372
     cmp  [changed],1
372
     cmp  [changed],1
373
     jne  no_change_in_board
373
     jne  no_change_in_board
374
 
374
 
375
     mov  [changed],0
375
     mov  [changed],0
376
 
376
 
377
     mov    eax,0
377
     mov    eax,0
378
     mov    ebx,0
378
     mov    ebx,0
379
   scan_board:
379
   scan_board:
380
 
380
 
381
     push   eax ebx
381
     push   eax ebx
382
 
382
 
383
     mov    esi,ebx
383
     mov    esi,ebx
384
     imul   esi,2
384
     imul   esi,2
385
     imul   esi,80
385
     imul   esi,80
386
     add    esi,80
386
     add    esi,80
387
 
387
 
388
     imul   eax,4
388
     imul   eax,4
389
     add    eax,10
389
     add    eax,10
390
 
390
 
391
     add    esi,eax
391
     add    esi,eax
392
 
392
 
393
     movzx  edx,word [chess_board+esi]
393
     movzx  edx,word [chess_board+esi]
394
     cmp    dx,[board_old+esi]
394
     cmp    dx,[board_old+esi]
395
     je     empty_slot
395
     je     empty_slot
396
 
396
 
397
     mov    ecx,13
397
     mov    ecx,13
398
   newseek2:
398
   newseek2:
399
     mov    edi,ecx
399
     mov    edi,ecx
400
     imul   edi,8
400
     imul   edi,8
401
     sub    edi,8
401
     sub    edi,8
402
     cmp    dx,[edi+nappulat]
402
     cmp    dx,[edi+nappulat]
403
     je     foundnappula2
403
     je     foundnappula2
404
     loop   newseek2
404
     loop   newseek2
405
 
405
 
406
     jmp    empty_slot
406
     jmp    empty_slot
407
 
407
 
408
    foundnappula2:
408
    foundnappula2:
409
 
409
 
410
     mov   esi,[edi+nappulat+4]
410
     mov   esi,[edi+nappulat+4]
411
     mov   edi,0
411
     mov   edi,0
412
     cmp   dl,'*'
412
     cmp   dl,'*'
413
     jne   nnbb
413
     jne   nnbb
414
     mov   edi,1
414
     mov   edi,1
415
   nnbb:
415
   nnbb:
416
     mov   eax,[esp+4]
416
     mov   eax,[esp+4]
417
     mov   ebx,[esp]
417
     mov   ebx,[esp]
418
     call  draw_pawn
418
     call  draw_pawn
419
 
419
 
420
    empty_slot:
420
    empty_slot:
421
 
421
 
422
     pop  ebx eax
422
     pop  ebx eax
423
 
423
 
424
     inc  eax
424
     inc  eax
425
     cmp  eax,8
425
     cmp  eax,8
426
     jb   scan_board
426
     jb   scan_board
427
     mov  eax,0
427
     mov  eax,0
428
     inc  ebx
428
     inc  ebx
429
     cmp  ebx,8
429
     cmp  ebx,8
430
     jb   scan_board
430
     jb   scan_board
431
 
431
 
432
     mov  esi,chess_board
432
     mov  esi,chess_board
433
     mov  edi,board_old
433
     mov  edi,board_old
434
     mov  ecx,80*19
434
     mov  ecx,80*19
435
     cld
435
     cld
436
     rep  movsb
436
     rep  movsb
437
 
437
 
438
     mov  eax,13
438
     mov  eax,13
439
     mov  ebx,[boardx]
439
     mov  ebx,[boardx]
440
     sub  ebx,14
440
     sub  ebx,14
441
     shl  ebx,16
441
     shl  ebx,16
442
     add  ebx,8
442
     add  ebx,8
443
     mov  ecx,[boardy]
443
     mov  ecx,[boardy]
444
     shl  ecx,16
444
     shl  ecx,16
445
     add  ecx,46*8
445
     add  ecx,46*8
446
     mov  edx,[wcolor]
446
     mov  edx,[wcolor]
447
     mcall
447
     mcall
448
 
448
 
449
     mov  eax,4 		   ; numbers at left
449
     mov  eax,4 		   ; numbers at left
450
     mov  ebx,[boardx]
450
     mov  ebx,[boardx]
451
     sub  ebx,14
451
     sub  ebx,14
452
     shl  ebx,16
452
     shl  ebx,16
453
     add  ebx,[boardy]
453
     add  ebx,[boardy]
454
     add  ebx,18
454
     add  ebx,18
455
     mov  ecx,[tcolor]
455
     mov  ecx,[tcolor]
456
     mov  edx,chess_board+80+5
456
     mov  edx,chess_board+80+5
457
     mov  esi,3
457
     mov  esi,3
458
    db1:
458
    db1:
459
     mcall
459
     mcall
460
     add  edx,80*2
460
     add  edx,80*2
461
     add  ebx,[boardxs]
461
     add  ebx,[boardxs]
462
     cmp  edx,chess_board+80*16
462
     cmp  edx,chess_board+80*16
463
     jb   db1
463
     jb   db1
464
 
464
 
465
     mov  eax,13
465
     mov  eax,13
466
     mov  ebx,[boardx]
466
     mov  ebx,[boardx]
467
     shl  ebx,16
467
     shl  ebx,16
468
     add  ebx,8*46
468
     add  ebx,8*46
469
     mov  ecx,[boardys]
469
     mov  ecx,[boardys]
470
     imul ecx,8
470
     imul ecx,8
471
     add  ecx,[boardy]
471
     add  ecx,[boardy]
472
     add  ecx,8
472
     add  ecx,8
473
     shl  ecx,16
473
     shl  ecx,16
474
     add  ecx,10
474
     add  ecx,10
475
     mov  edx,[wcolor]
475
     mov  edx,[wcolor]
476
     mcall
476
     mcall
477
 
477
 
478
     mov  eax,4 		   ; letters at bottom
478
     mov  eax,4 		   ; letters at bottom
479
     mov  ebx,[boardx]
479
     mov  ebx,[boardx]
480
     add  ebx,3
480
     add  ebx,3
481
     shl  ebx,16
481
     shl  ebx,16
482
     mov  bx,word [boardys]
482
     mov  bx,word [boardys]
483
     imul bx,8
483
     imul bx,8
484
     add  ebx,[boardy]
484
     add  ebx,[boardy]
485
     add  ebx,8
485
     add  ebx,8
486
     mov  ecx,[tcolor]
486
     mov  ecx,[tcolor]
487
     mov  edx,chess_board+80*17+8
487
     mov  edx,chess_board+80*17+8
488
     mov  esi,4
488
     mov  esi,4
489
   db3:
489
   db3:
490
     mcall
490
     mcall
491
     mov  edi,[boardxs]
491
     mov  edi,[boardxs]
492
     shl  edi,16
492
     shl  edi,16
493
     add  ebx,edi
493
     add  ebx,edi
494
     add  edx,4
494
     add  edx,4
495
     cmp  edx,chess_board+80*17+8+4*8
495
     cmp  edx,chess_board+80*17+8+4*8
496
     jb   db3
496
     jb   db3
497
 
497
 
498
     ; print player times
498
     ; print player times
499
 
499
 
500
     mov  edi,74
500
     mov  edi,74
501
     cmp  [chess_board+80+5],byte '1'
501
     cmp  [chess_board+80+5],byte '1'
502
     jne  nowww2
502
     jne  nowww2
503
     mov  edi,371
503
     mov  edi,371
504
   nowww2:
504
   nowww2:
505
 
505
 
506
     mov  eax,13
506
     mov  eax,13
507
     mov  ebx,(conx)*65536+100
507
     mov  ebx,(conx)*65536+100
508
     mov  ecx,edi
508
     mov  ecx,edi
509
     shl  ecx,16
509
     shl  ecx,16
510
     add  ecx,10
510
     add  ecx,10
511
     mov  edx,[wcolor]
511
     mov  edx,[wcolor]
512
     mcall
512
     mcall
513
 
513
 
514
     mov  eax,4
514
     mov  eax,4
515
     mov  ebx,(conx)*65536
515
     mov  ebx,(conx)*65536
516
     add  ebx,edi
516
     add  ebx,edi
517
     mov  ecx,[tcolor]
517
     mov  ecx,[tcolor]
518
     mov  edx,chess_board+80*7+59-1
518
     mov  edx,chess_board+80*7+59-1
519
     mov  esi,20
519
     mov  esi,20
520
     mcall
520
     mcall
521
 
521
 
522
     mov  edi,74
522
     mov  edi,74
523
     cmp  [chess_board+80+5],byte '1'
523
     cmp  [chess_board+80+5],byte '1'
524
     je   nowww
524
     je   nowww
525
     mov  edi,371
525
     mov  edi,371
526
   nowww:
526
   nowww:
527
 
527
 
528
     mov  eax,13
528
     mov  eax,13
529
     mov  ebx,(conx)*65536+100
529
     mov  ebx,(conx)*65536+100
530
     mov  ecx,edi
530
     mov  ecx,edi
531
     shl  ecx,16
531
     shl  ecx,16
532
     add  ecx,10
532
     add  ecx,10
533
     mov  edx,[wcolor]
533
     mov  edx,[wcolor]
534
     mcall
534
     mcall
535
 
535
 
536
     mov  eax,4
536
     mov  eax,4
537
     mov  ebx,(conx)*65536
537
     mov  ebx,(conx)*65536
538
     add  ebx,edi
538
     add  ebx,edi
539
     mov  ecx,[tcolor]
539
     mov  ecx,[tcolor]
540
     mov  edx,chess_board+80*9+59-1
540
     mov  edx,chess_board+80*9+59-1
541
     mov  esi,20
541
     mov  esi,20
542
     mcall
542
     mcall
543
 
543
 
544
     ; move #
544
     ; move #
545
 
545
 
546
     mov  eax,13
546
     mov  eax,13
547
     mov  ebx,conx*65536+120
547
     mov  ebx,conx*65536+120
548
     mov  ecx,200*65536+10
548
     mov  ecx,200*65536+10
549
     mov  edx,[wcolor]
549
     mov  edx,[wcolor]
550
     mcall
550
     mcall
551
 
551
 
552
     mov  eax,4
552
     mov  eax,4
553
     mov  ebx,conx*65536
553
     mov  ebx,conx*65536
554
     add  ebx,200
554
     add  ebx,200
555
     mov  ecx,[tcolor]
555
     mov  ecx,[tcolor]
556
     mov  edx,chess_board+80*1+46
556
     mov  edx,chess_board+80*1+46
557
     mov  esi,30
557
     mov  esi,30
558
     mcall
558
     mcall
559
 
559
 
560
   no_change_in_board:
560
   no_change_in_board:
561
 
561
 
562
     popa
562
     popa
563
 
563
 
564
     ret
564
     ret
565
 
565
 
566
 
566
 
567
handle_data:
567
handle_data:
568
    ; Telnet servers will want to negotiate options about our terminal window
568
    ; Telnet servers will want to negotiate options about our terminal window
569
    ; just reject them all.
569
    ; just reject them all.
570
    ; Telnet options start with the byte 0xff and are 3 bytes long.
570
    ; Telnet options start with the byte 0xff and are 3 bytes long.
571
 
571
 
572
    mov     al, [telnetstate]
572
    mov     al, [telnetstate]
573
    cmp     al, 0
573
    cmp     al, 0
574
    je	    state0
574
    je	    state0
575
    cmp     al, 1
575
    cmp     al, 1
576
    je	    state1
576
    je	    state1
577
    cmp     al, 2
577
    cmp     al, 2
578
    je	    state2
578
    je	    state2
579
    jmp     hd001
579
    jmp     hd001
580
 
580
 
581
state0:
581
state0:
582
    cmp     bl, 255
582
    cmp     bl, 255
583
    jne     hd001
583
    jne     hd001
584
    mov     al, 1
584
    mov     al, 1
585
    mov     [telnetstate], al
585
    mov     [telnetstate], al
586
    ret
586
    ret
587
 
587
 
588
state1:
588
state1:
589
    mov     al, 2
589
    mov     al, 2
590
    mov     [telnetstate], al
590
    mov     [telnetstate], al
591
    ret
591
    ret
592
 
592
 
593
state2:
593
state2:
594
    mov     al, 0
594
    mov     al, 0
595
    mov     [telnetstate], al
595
    mov     [telnetstate], al
596
    mov     [telnetrep+2], bl
596
    mov     [telnetrep+2], bl
597
 
597
 
598
    mov     edx, 3
598
    mov     edx, 3
599
    mov     eax,53
599
    mov     eax,53
600
    mov     ebx,7
600
    mov     ebx,7
601
    mov     ecx,[socket]
601
    mov     ecx,[socket]
602
    mov     esi, telnetrep
602
    mov     esi, telnetrep
603
    mcall
603
    mcall
604
    ret
604
    ret
605
 
605
 
606
hd001:
606
hd001:
607
    cmp  bl,13				; BEGINNING OF LINE
607
    cmp  bl,13				; BEGINNING OF LINE
608
    jne  nobol
608
    jne  nobol
609
    mov  ecx,[pos]
609
    mov  ecx,[pos]
610
    add  ecx,1
610
    add  ecx,1
611
  boll1:
611
  boll1:
612
    sub  ecx,1
612
    sub  ecx,1
613
    mov  eax,ecx
613
    mov  eax,ecx
614
    xor  edx,edx
614
    xor  edx,edx
615
    mov  ebx,80
615
    mov  ebx,80
616
    div  ebx
616
    div  ebx
617
    cmp  edx,0
617
    cmp  edx,0
618
    jne  boll1
618
    jne  boll1
619
    mov  [pos],ecx
619
    mov  [pos],ecx
620
 
620
 
621
    call check_for_board
621
    call check_for_board
622
 
622
 
623
    jmp  newdata
623
    jmp  newdata
624
  nobol:
624
  nobol:
625
 
625
 
626
    cmp  bl,10				  ; LINE DOWN
626
    cmp  bl,10				  ; LINE DOWN
627
    jne  nolf
627
    jne  nolf
628
   addx1:
628
   addx1:
629
    add  [pos],dword 1
629
    add  [pos],dword 1
630
    mov  eax,[pos]
630
    mov  eax,[pos]
631
    xor  edx,edx
631
    xor  edx,edx
632
    mov  ecx,80
632
    mov  ecx,80
633
    div  ecx
633
    div  ecx
634
    cmp  edx,0
634
    cmp  edx,0
635
    jnz  addx1
635
    jnz  addx1
636
    mov  eax,[pos]
636
    mov  eax,[pos]
637
    jmp  cm1
637
    jmp  cm1
638
  nolf:
638
  nolf:
639
 
639
 
640
     cmp  bl,9				   ; TAB
640
     cmp  bl,9				   ; TAB
641
     jne  notab
641
     jne  notab
642
    add  [pos],dword 8
642
    add  [pos],dword 8
643
    jmp  newdata
643
    jmp  newdata
644
  notab:
644
  notab:
645
 
645
 
646
    cmp  bl,8				 ; BACKSPACE
646
    cmp  bl,8				 ; BACKSPACE
647
    jne  nobasp
647
    jne  nobasp
648
    mov  eax,[pos]
648
    mov  eax,[pos]
649
    dec  eax
649
    dec  eax
650
    mov  [pos],eax
650
    mov  [pos],eax
651
    mov  [eax+text],byte 32
651
    mov  [eax+text],byte 32
652
    mov  [eax+text+60*80],byte 0
652
    mov  [eax+text+60*80],byte 0
653
    jmp  newdata
653
    jmp  newdata
654
   nobasp:
654
   nobasp:
655
 
655
 
656
    cmp  bl,15				 ; CHARACTER
656
    cmp  bl,15				 ; CHARACTER
657
    jbe  newdata
657
    jbe  newdata
658
    mov  eax,[pos]
658
    mov  eax,[pos]
659
    mov  [eax+text],bl
659
    mov  [eax+text],bl
660
    mov  eax,[pos]
660
    mov  eax,[pos]
661
    add  eax,1
661
    add  eax,1
662
  cm1:
662
  cm1:
663
    mov  ebx,[scroll+4]
663
    mov  ebx,[scroll+4]
664
    imul ebx,80
664
    imul ebx,80
665
    cmp  eax,ebx
665
    cmp  eax,ebx
666
    jb	 noeaxz
666
    jb	 noeaxz
667
    mov  esi,text+80
667
    mov  esi,text+80
668
    mov  edi,text
668
    mov  edi,text
669
    mov  ecx,ebx
669
    mov  ecx,ebx
670
    cld
670
    cld
671
    rep  movsb
671
    rep  movsb
672
    mov  eax,ebx
672
    mov  eax,ebx
673
    sub  eax,80
673
    sub  eax,80
674
  noeaxz:
674
  noeaxz:
675
    mov  [pos],eax
675
    mov  [pos],eax
676
  newdata:
676
  newdata:
677
    ret
677
    ret
678
 
678
 
679
 
679
 
680
  red:				; REDRAW WINDOW
680
  red:				; REDRAW WINDOW
681
    call draw_window
681
    call draw_window
682
    jmp  still
682
    jmp  still
683
 
683
 
684
  key:				; KEY
684
  key:				; KEY
685
    mov  eax,2			; send to modem
685
    mov  eax,2			; send to modem
686
    mcall
686
    mcall
687
 
687
 
688
    mov     ebx, [socket_status]
688
    mov     ebx, [socket_status]
689
    cmp     ebx, 4		; connection open?
689
    cmp     ebx, 4		; connection open?
690
    jne     still		; no, so ignore key
690
    jne     still		; no, so ignore key
691
 
691
 
692
    shr  eax,8
692
    shr  eax,8
693
    cmp  eax,178		; ARROW KEYS
693
    cmp  eax,178		; ARROW KEYS
694
    jne  noaup
694
    jne  noaup
695
    mov  al,'A'
695
    mov  al,'A'
696
    call arrow
696
    call arrow
697
    jmp  still
697
    jmp  still
698
  noaup:
698
  noaup:
699
    cmp  eax,177
699
    cmp  eax,177
700
    jne  noadown
700
    jne  noadown
701
    mov  al,'B'
701
    mov  al,'B'
702
    call arrow
702
    call arrow
703
    jmp  still
703
    jmp  still
704
  noadown:
704
  noadown:
705
    cmp  eax,179
705
    cmp  eax,179
706
    jne  noaright
706
    jne  noaright
707
    mov  al,'C'
707
    mov  al,'C'
708
    call arrow
708
    call arrow
709
    jmp  still
709
    jmp  still
710
  noaright:
710
  noaright:
711
    cmp  eax,176
711
    cmp  eax,176
712
    jne  noaleft
712
    jne  noaleft
713
    mov  al,'D'
713
    mov  al,'D'
714
    call arrow
714
    call arrow
715
    jmp  still
715
    jmp  still
716
  noaleft:
716
  noaleft:
717
  modem_out:
717
  modem_out:
718
 
718
 
719
    call    to_modem
719
    call    to_modem
720
 
720
 
721
    jmp  still
721
    jmp  still
722
 
722
 
723
  button:			; BUTTON
723
  button:			; BUTTON
724
    mov  eax,17
724
    mov  eax,17
725
    mcall
725
    mcall
726
    cmp  ah,1			; CLOSE PROGRAM
726
    cmp  ah,1			; CLOSE PROGRAM
727
    jne  noclose
727
    jne  noclose
728
 
728
 
729
    mov  eax,53
729
    mov  eax,53
730
    mov  ebx,8
730
    mov  ebx,8
731
    mov  ecx,[socket]
731
    mov  ecx,[socket]
732
    mcall
732
    mcall
733
 
733
 
734
     mov  eax,-1
734
     mov  eax,-1
735
     mcall
735
     mcall
736
  noclose:
736
  noclose:
737
 
737
 
738
    cmp     ah, 4		; connect
738
    cmp     ah, 4		; connect
739
    jne     notcon
739
    jne     notcon
740
 
740
 
741
    mov     eax, [socket_status]
741
    mov     eax, [socket_status]
742
    cmp     eax, 4
742
    cmp     eax, 4
743
    je	   still
743
    je	   still
744
    call    connect
744
    call    connect
745
 
745
 
746
    jmp     still
746
    jmp     still
747
 
747
 
748
notcon:
748
notcon:
749
    cmp     ah,5		; disconnect
749
    cmp     ah,5		; disconnect
750
    jne     notdiscon
750
    jne     notdiscon
751
 
751
 
752
    call    disconnect
752
    call    disconnect
753
    jmp  still
753
    jmp  still
754
 
754
 
755
 notdiscon:
755
 notdiscon:
756
 
756
 
757
    jmp     still
757
    jmp     still
758
 
758
 
759
arrow:
759
arrow:
760
 
760
 
761
    push eax
761
    push eax
762
    mov  al,27
762
    mov  al,27
763
    call to_modem
763
    call to_modem
764
    mov  al,'['
764
    mov  al,'['
765
    call to_modem
765
    call to_modem
766
    pop  eax
766
    pop  eax
767
    call to_modem
767
    call to_modem
768
 
768
 
769
    ret
769
    ret
770
 
770
 
771
 
771
 
772
to_modem:
772
to_modem:
773
    pusha
773
    pusha
774
    push    ax
774
    push    ax
775
    mov     [tx_buff], al
775
    mov     [tx_buff], al
776
    mov     edx, 1
776
    mov     edx, 1
777
    cmp     al, 13
777
    cmp     al, 13
778
    jne     tm_000
778
    jne     tm_000
779
    mov     edx, 2
779
    mov     edx, 2
780
tm_000:
780
tm_000:
781
    mov     eax,53
781
    mov     eax,53
782
    mov     ebx,7
782
    mov     ebx,7
783
    mov     ecx,[socket]
783
    mov     ecx,[socket]
784
    mov     esi, tx_buff
784
    mov     esi, tx_buff
785
    mcall
785
    mcall
786
    pop     bx
786
    pop     bx
787
    mov     al, [echo]
787
    mov     al, [echo]
788
    cmp     al, 0
788
    cmp     al, 0
789
    je	    tm_001
789
    je	    tm_001
790
 
790
 
791
    push    bx
791
    push    bx
792
    call    handle_data
792
    call    handle_data
793
    pop     bx
793
    pop     bx
794
 
794
 
795
    cmp     bl, 13
795
    cmp     bl, 13
796
    jne     tm_002
796
    jne     tm_002
797
 
797
 
798
    mov     bl, 10
798
    mov     bl, 10
799
    call    handle_data
799
    call    handle_data
800
 
800
 
801
tm_002:
801
tm_002:
802
    call    draw_text
802
    call    draw_text
803
 
803
 
804
tm_001:
804
tm_001:
805
    popa
805
    popa
806
    ret
806
    ret
807
 
807
 
808
 
808
 
809
 
809
 
810
disconnect:
810
disconnect:
811
    mov  eax,53
811
    mov  eax,53
812
    mov  ebx,8
812
    mov  ebx,8
813
    mov  ecx,[socket]
813
    mov  ecx,[socket]
814
    mcall
814
    mcall
815
    ret
815
    ret
816
 
816
 
817
 
817
 
818
 
818
 
819
connect:
819
connect:
820
    pusha
820
    pusha
821
 
821
 
822
 mov	 ecx, 1000  ; local port starting at 1000
822
 mov	 ecx, 1000  ; local port starting at 1000
823
 
823
 
824
getlp:
824
getlp:
825
 inc	 ecx
825
 inc	 ecx
826
 push ecx
826
 push ecx
827
 mov	 eax, 53
827
 mov	 eax, 53
828
 mov	 ebx, 9
828
 mov	 ebx, 9
829
 mcall
829
 mcall
830
 pop	 ecx
830
 pop	 ecx
831
 cmp	 eax, 0   ; is this local port in use?
831
 cmp	 eax, 0   ; is this local port in use?
832
 jz  getlp	; yes - so try next
832
 jz  getlp	; yes - so try next
833
 
833
 
834
    mov     eax,53
834
    mov     eax,53
835
    mov     ebx,5
835
    mov     ebx,5
836
    mov     dl, [ip_address + 3]
836
    mov     dl, [ip_address + 3]
837
    shl     edx, 8
837
    shl     edx, 8
838
    mov     dl, [ip_address + 2]
838
    mov     dl, [ip_address + 2]
839
    shl     edx, 8
839
    shl     edx, 8
840
    mov     dl, [ip_address + 1]
840
    mov     dl, [ip_address + 1]
841
    shl     edx, 8
841
    shl     edx, 8
842
    mov     dl, [ip_address]
842
    mov     dl, [ip_address]
843
    mov     esi, edx
843
    mov     esi, edx
844
    movzx   edx, word [port]	  ; telnet port id
844
    movzx   edx, word [port]	  ; telnet port id
845
    mov     edi,1      ; active open
845
    mov     edi,1      ; active open
846
    mcall
846
    mcall
847
    mov     [socket], eax
847
    mov     [socket], eax
848
 
848
 
849
    popa
849
    popa
850
 
850
 
851
    ret
851
    ret
852
 
852
 
853
 
853
 
854
 
854
 
855
;   *********************************************
855
;   *********************************************
856
;   *******  WINDOW DEFINITIONS AND DRAW ********
856
;   *******  WINDOW DEFINITIONS AND DRAW ********
857
;   *********************************************
857
;   *********************************************
858
 
858
 
859
 
859
 
860
draw_window:
860
draw_window:
861
 
861
 
862
    pusha
862
    pusha
863
 
863
 
864
    mov  eax,12
864
    mov  eax,12
865
    mov  ebx,1
865
    mov  ebx,1
866
    mcall
866
    mcall
867
 
867
 
868
    mov  eax,14
868
    mov  eax,14
869
    mcall
869
    mcall
870
 
870
 
871
    mov  ebx,eax
871
    mov  ebx,eax
872
    mov  ecx,eax
872
    mov  ecx,eax
873
 
873
 
874
    shr  ebx,16
874
    shr  ebx,16
875
    and  ebx,0xffff
875
    and  ebx,0xffff
876
    and  ecx,0xffff
876
    and  ecx,0xffff
877
 
877
 
878
    shr  ebx,1
878
    shr  ebx,1
879
    shr  ecx,1
879
    shr  ecx,1
880
 
880
 
881
    sub  ebx,275
881
    sub  ebx,275
882
    sub  ecx,235
882
    sub  ecx,235
883
 
883
 
884
    shl  ebx,16
884
    shl  ebx,16
885
    shl  ecx,16
885
    shl  ecx,16
886
 
886
 
887
    mov  eax,0 		    ; DRAW WINDOW
887
    mov  eax,0 		    ; DRAW WINDOW
888
    mov  bx,550
888
    mov  bx,550
889
    mov  cx,470
889
    mov  cx,470
890
    mov  edx,[wcolor]
890
    mov  edx,[wcolor]
891
    add  edx,0x13000000
891
    add  edx,0x14000000
892
    mov  edi,title
892
    mov  edi,title
893
    mcall
893
    mcall
894
 
894
 
895
    call display_status
895
    call display_status
896
 
896
 
897
    mov  eax,8			   ; BUTTON 4: Connect
897
    mov  eax,8			   ; BUTTON 4: Connect
898
    mov  ebx,conx*65536+80
898
    mov  ebx,conx*65536+80
899
    mov  ecx,cony*65536+15
899
    mov  ecx,cony*65536+15
900
     mov  esi,[wbutton]
900
     mov  esi,[wbutton]
901
     mov  edx,4
901
     mov  edx,4
902
    mcall
902
    mcall
903
    mov  eax,4			   ; Button text
903
    mov  eax,4			   ; Button text
904
    mov  ebx,(conx+4)*65536+cony+4
904
    mov  ebx,(conx+4)*65536+cony+4
905
    mov  ecx,0xffffff
905
    mov  ecx,0xffffff
906
    mov  edx,cont
906
    mov  edx,cont
907
    mov  esi,conlen-cont
907
    mov  esi,conlen-cont
908
    mcall
908
    mcall
909
 
909
 
910
 
910
 
911
    mov  eax,8			   ; BUTTON 5: disconnect
911
    mov  eax,8			   ; BUTTON 5: disconnect
912
    mov  ebx,dconx*65536+80
912
    mov  ebx,dconx*65536+80
913
    mov  ecx,dcony*65536+15
913
    mov  ecx,dcony*65536+15
914
    mov  edx,5
914
    mov  edx,5
915
     mov  esi,[wbutton]
915
     mov  esi,[wbutton]
916
     mcall
916
     mcall
917
    mov  eax,4			   ; Button text
917
    mov  eax,4			   ; Button text
918
    mov  ebx,(dconx+4)*65536+dcony+4
918
    mov  ebx,(dconx+4)*65536+dcony+4
919
    mov  ecx,0x00ffffff
919
    mov  ecx,0x00ffffff
920
    mov  edx,dist
920
    mov  edx,dist
921
    mov  esi,dislen-dist
921
    mov  esi,dislen-dist
922
    mcall
922
    mcall
923
 
923
 
924
 
924
 
925
    xor  eax,eax
925
    xor  eax,eax
926
    mov  edi,text+80*30
926
    mov  edi,text+80*30
927
    mov  ecx,80*30 /4
927
    mov  ecx,80*30 /4
928
    cld
928
    cld
929
    rep  stosd
929
    rep  stosd
930
 
930
 
931
    call draw_text
931
    call draw_text
932
 
932
 
933
    mov  [changed],1
933
    mov  [changed],1
934
 
934
 
935
    mov  edi,board_old
935
    mov  edi,board_old
936
    mov  ecx,80*19
936
    mov  ecx,80*19
937
    mov  al,0
937
    mov  al,0
938
    cld
938
    cld
939
    rep  stosb
939
    rep  stosb
940
 
940
 
941
    mov  eax,4
941
    mov  eax,4
942
    mov  ebx,conx*65536+52
942
    mov  ebx,conx*65536+52
943
    mov  ecx,[tcolor]
943
    mov  ecx,[tcolor]
944
    mov  edx,quick_start
944
    mov  edx,quick_start
945
    mov  esi,30
945
    mov  esi,30
946
 
946
 
947
  prqs:
947
  prqs:
948
 
948
 
949
    mcall
949
    mcall
950
    add  ebx,10
950
    add  ebx,10
951
    add  edx,30
951
    add  edx,30
952
    cmp  [edx],byte 'x'
952
    cmp  [edx],byte 'x'
953
    jne  prqs
953
    jne  prqs
954
 
954
 
955
    mov  eax,12
955
    mov  eax,12
956
    mov  ebx,2
956
    mov  ebx,2
957
    mcall
957
    mcall
958
 
958
 
959
    popa
959
    popa
960
 
960
 
961
    ret
961
    ret
962
 
962
 
963
 
963
 
964
display_status:
964
display_status:
965
 
965
 
966
    pusha
966
    pusha
967
 
967
 
968
    ; draw status bar
968
    ; draw status bar
969
    mov  eax, 13
969
    mov  eax, 13
970
    mov  ebx, statusx*65536+80
970
    mov  ebx, statusx*65536+80
971
    mov  ecx, statusy*65536 + 16
971
    mov  ecx, statusy*65536 + 16
972
    mov  edx, [wcolor]
972
    mov  edx, [wcolor]
973
    mcall
973
    mcall
974
 
974
 
975
    mov  esi,contlen-contt	    ; display connected status
975
    mov  esi,contlen-contt	    ; display connected status
976
    mov  edx, contt
976
    mov  edx, contt
977
    mov  eax, [socket_status]
977
    mov  eax, [socket_status]
978
    cmp  eax, 4 		 ; 4 is connected
978
    cmp  eax, 4 		 ; 4 is connected
979
    je	 pcon
979
    je	 pcon
980
    mov  esi,discontlen-discontt
980
    mov  esi,discontlen-discontt
981
    mov  edx, discontt
981
    mov  edx, discontt
982
  pcon:
982
  pcon:
983
    mov  eax,4			   ; status text
983
    mov  eax,4			   ; status text
984
    mov  ebx,statusx*65536+statusy+2
984
    mov  ebx,statusx*65536+statusy+2
985
     mov  ecx,[tcolor]
985
     mov  ecx,[tcolor]
986
     mcall
986
     mcall
987
 
987
 
988
    popa
988
    popa
989
    ret
989
    ret
990
 
990
 
991
 
991
 
992
nappulat:
992
nappulat:
993
 
993
 
994
    dd '*P  ',5
994
    dd '*P  ',5
995
    dd '*K  ',3
995
    dd '*K  ',3
996
    dd '*Q  ',4
996
    dd '*Q  ',4
997
    dd '*R  ',0
997
    dd '*R  ',0
998
    dd '*N  ',1
998
    dd '*N  ',1
999
    dd '*B  ',2
999
    dd '*B  ',2
1000
 
1000
 
1001
    dd '    ',20
1001
    dd '    ',20
1002
 
1002
 
1003
    dd 'P   ',5
1003
    dd 'P   ',5
1004
    dd 'K   ',3
1004
    dd 'K   ',3
1005
    dd 'Q   ',4
1005
    dd 'Q   ',4
1006
    dd 'R   ',0
1006
    dd 'R   ',0
1007
    dd 'N   ',1
1007
    dd 'N   ',1
1008
    dd 'B   ',2
1008
    dd 'B   ',2
1009
 
1009
 
1010
 
1010
 
1011
row   dd  0x0
1011
row   dd  0x0
1012
col   dd  0x0
1012
col   dd  0x0
1013
 
1013
 
1014
 
1014
 
1015
 
1015
 
1016
draw_text:
1016
draw_text:
1017
 
1017
 
1018
    mov  esi,text+80*24
1018
    mov  esi,text+80*24
1019
    mov  edi,texts+80*3
1019
    mov  edi,texts+80*3
1020
 
1020
 
1021
  dtl1:
1021
  dtl1:
1022
 
1022
 
1023
    cmp  [esi],dword 'logi'
1023
    cmp  [esi],dword 'logi'
1024
    je	 add_text
1024
    je	 add_text
1025
    cmp  [esi],dword 'aics'
1025
    cmp  [esi],dword 'aics'
1026
    je	 add_text
1026
    je	 add_text
1027
    cmp  [esi],dword 'You '
1027
    cmp  [esi],dword 'You '
1028
    je	 add_text
1028
    je	 add_text
1029
    cmp  [esi],dword 'Your'
1029
    cmp  [esi],dword 'Your'
1030
    je	 add_text
1030
    je	 add_text
1031
    cmp  [esi],dword 'Game'
1031
    cmp  [esi],dword 'Game'
1032
    je	 add_text
1032
    je	 add_text
1033
    cmp  [esi],dword 'Ille'
1033
    cmp  [esi],dword 'Ille'
1034
    je	 add_text
1034
    je	 add_text
1035
    cmp  [esi],dword 'No s'
1035
    cmp  [esi],dword 'No s'
1036
    je	 add_text
1036
    je	 add_text
1037
 
1037
 
1038
    sub  esi,80
1038
    sub  esi,80
1039
    cmp  esi,text
1039
    cmp  esi,text
1040
    jge  dtl1
1040
    jge  dtl1
1041
 
1041
 
1042
  dtl2:
1042
  dtl2:
1043
 
1043
 
1044
    mov  eax,13
1044
    mov  eax,13
1045
    mov  ebx,10*65536+532
1045
    mov  ebx,10*65536+532
1046
    mov  ecx,420*65536+40
1046
    mov  ecx,420*65536+40
1047
     mov  edx,[wtcom]
1047
     mov  edx,[wtcom]
1048
     mcall
1048
     mcall
1049
 
1049
 
1050
    mov  eax,4
1050
    mov  eax,4
1051
    mov  ebx,10*65536+420
1051
    mov  ebx,10*65536+420
1052
     mov  ecx,[wtxt]
1052
     mov  ecx,[wtxt]
1053
     mov  edx,texts
1053
     mov  edx,texts
1054
    mov  esi,80
1054
    mov  esi,80
1055
 
1055
 
1056
  dtl3:
1056
  dtl3:
1057
 
1057
 
1058
    mcall
1058
    mcall
1059
    add  edx,80
1059
    add  edx,80
1060
    add  ebx,10
1060
    add  ebx,10
1061
    cmp  edx,texts+4*80
1061
    cmp  edx,texts+4*80
1062
    jb	 dtl3
1062
    jb	 dtl3
1063
 
1063
 
1064
    ret
1064
    ret
1065
 
1065
 
1066
  add_text:
1066
  add_text:
1067
 
1067
 
1068
    pusha
1068
    pusha
1069
 
1069
 
1070
    cld
1070
    cld
1071
    mov  ecx,80
1071
    mov  ecx,80
1072
    rep  movsb
1072
    rep  movsb
1073
 
1073
 
1074
    popa
1074
    popa
1075
 
1075
 
1076
 
1076
 
1077
    sub  esi,80
1077
    sub  esi,80
1078
    sub  edi,80
1078
    sub  edi,80
1079
 
1079
 
1080
    cmp  edi,texts
1080
    cmp  edi,texts
1081
    jb	 dtl2
1081
    jb	 dtl2
1082
 
1082
 
1083
    jmp  dtl1
1083
    jmp  dtl1
1084
 
1084
 
1085
 
1085
 
1086
read_string:
1086
read_string:
1087
 
1087
 
1088
    mov  edi,string
1088
    mov  edi,string
1089
    mov  eax,'_'
1089
    mov  eax,'_'
1090
    mov  ecx,[string_length]
1090
    mov  ecx,[string_length]
1091
    inc     ecx
1091
    inc     ecx
1092
    cld
1092
    cld
1093
    rep  stosb
1093
    rep  stosb
1094
    call print_text
1094
    call print_text
1095
 
1095
 
1096
    mov  edi,string
1096
    mov  edi,string
1097
  f11:
1097
  f11:
1098
    mov  eax,10
1098
    mov  eax,10
1099
    mcall
1099
    mcall
1100
    cmp  eax,2
1100
    cmp  eax,2
1101
    jne  read_done
1101
    jne  read_done
1102
    mov  eax,2
1102
    mov  eax,2
1103
    mcall
1103
    mcall
1104
    shr  eax,8
1104
    shr  eax,8
1105
    cmp  eax,13
1105
    cmp  eax,13
1106
    je	 read_done
1106
    je	 read_done
1107
    cmp  eax,8
1107
    cmp  eax,8
1108
    jnz  nobsl
1108
    jnz  nobsl
1109
    cmp  edi,string
1109
    cmp  edi,string
1110
    jz	 f11
1110
    jz	 f11
1111
    sub  edi,1
1111
    sub  edi,1
1112
    mov  [edi],byte '_'
1112
    mov  [edi],byte '_'
1113
    call print_text
1113
    call print_text
1114
    jmp  f11
1114
    jmp  f11
1115
  nobsl:
1115
  nobsl:
1116
    cmp  eax,dword 31
1116
    cmp  eax,dword 31
1117
    jbe  f11
1117
    jbe  f11
1118
    cmp  eax,dword 95
1118
    cmp  eax,dword 95
1119
    jb	 keyok
1119
    jb	 keyok
1120
    sub  eax,32
1120
    sub  eax,32
1121
  keyok:
1121
  keyok:
1122
    mov  [edi],al
1122
    mov  [edi],al
1123
    call print_text
1123
    call print_text
1124
 
1124
 
1125
    inc  edi
1125
    inc  edi
1126
    mov  esi,string
1126
    mov  esi,string
1127
    add  esi,[string_length]
1127
    add  esi,[string_length]
1128
    cmp  esi,edi
1128
    cmp  esi,edi
1129
    jnz  f11
1129
    jnz  f11
1130
 
1130
 
1131
  read_done:
1131
  read_done:
1132
 
1132
 
1133
    call print_text
1133
    call print_text
1134
 
1134
 
1135
    ret
1135
    ret
1136
 
1136
 
1137
 
1137
 
1138
print_text:
1138
print_text:
1139
 
1139
 
1140
    pusha
1140
    pusha
1141
 
1141
 
1142
    mov  eax,13
1142
    mov  eax,13
1143
    mov  ebx,[string_x]
1143
    mov  ebx,[string_x]
1144
    shl  ebx,16
1144
    shl  ebx,16
1145
    add  ebx,[string_length]
1145
    add  ebx,[string_length]
1146
    imul bx,6
1146
    imul bx,6
1147
    mov  ecx,[string_y]
1147
    mov  ecx,[string_y]
1148
    shl  ecx,16
1148
    shl  ecx,16
1149
    mov  cx,8
1149
    mov  cx,8
1150
    mov  edx,[wcolor]
1150
    mov  edx,[wcolor]
1151
    mcall
1151
    mcall
1152
 
1152
 
1153
    mov  eax,4
1153
    mov  eax,4
1154
    mov  ebx,[string_x]
1154
    mov  ebx,[string_x]
1155
    shl  ebx,16
1155
    shl  ebx,16
1156
    add  ebx,[string_y]
1156
    add  ebx,[string_y]
1157
    mov  ecx,[tcolor]
1157
    mov  ecx,[tcolor]
1158
    mov  edx,string
1158
    mov  edx,string
1159
    mov  esi,[string_length]
1159
    mov  esi,[string_length]
1160
    mcall
1160
    mcall
1161
 
1161
 
1162
    popa
1162
    popa
1163
    ret
1163
    ret
1164
 
1164
 
1165
 
1165
 
1166
 
1166
 
1167
 
1167
 
1168
; DATA AREA
1168
; DATA AREA
1169
 
1169
 
1170
telnetrep	db 0xff,0xfc,0x00
1170
telnetrep	db 0xff,0xfc,0x00
1171
telnetstate	db 0
1171
telnetstate	db 0
1172
 
1172
 
1173
string_length  dd    16
1173
string_length  dd    16
1174
string_x       dd    200
1174
string_x       dd    200
1175
string_y       dd    60
1175
string_y       dd    60
1176
 
1176
 
1177
string	       db    '________________'
1177
string	       db    '________________'
1178
 
1178
 
1179
tx_buff 	db  0, 10
1179
tx_buff 	db  0, 10
1180
ip_address	db  204,178,125,65
1180
ip_address	db  204,178,125,65
1181
port		dw  5051 ;  0,0
1181
port		dw  5051 ;  0,0
1182
echo		db  1
1182
echo		db  1
1183
socket		dd  0x0
1183
socket		dd  0x0
1184
socket_status	dd  0x0
1184
socket_status	dd  0x0
1185
pos		dd  80 * 22
1185
pos		dd  80 * 22
1186
scroll		dd  1
1186
scroll		dd  1
1187
		dd  24
1187
		dd  24
1188
 
1188
 
1189
wbutton 	dd  0x336688
1189
wbutton 	dd  0x336688
1190
 
1190
 
1191
wtcom		dd  0x336688 ; 0x666666
1191
wtcom		dd  0x336688 ; 0x666666
1192
wtxt		dd  0xffffff
1192
wtxt		dd  0xffffff
1193
 
1193
 
1194
wcolor		dd  0xe0e0e0
1194
wcolor		dd  0xe0e0e0
1195
tcolor		dd  0x000000
1195
tcolor		dd  0x000000
1196
 
1196
 
1197
sq_black	dd  0x336688 ; 666666
1197
sq_black	dd  0x336688 ; 666666
1198
sq_white	dd  0xffffff
1198
sq_white	dd  0xffffff
1199
 
1199
 
1200
title		db  appname,version,0
1200
title		db  appname,version,0
1201
 
1201
 
1202
setipt		db  '               .   .   .'
1202
setipt		db  '               .   .   .'
1203
setiplen:
1203
setiplen:
1204
setportt	db  '     '
1204
setportt	db  '     '
1205
setportlen:
1205
setportlen:
1206
cont		db  'Connect'
1206
cont		db  'Connect'
1207
conlen:
1207
conlen:
1208
dist		db  'Disconnect'
1208
dist		db  'Disconnect'
1209
dislen:
1209
dislen:
1210
contt		db  'Connected'
1210
contt		db  'Connected'
1211
contlen:
1211
contlen:
1212
discontt	db  'Disconnected'
1212
discontt	db  'Disconnected'
1213
discontlen:
1213
discontlen:
1214
echot	     db  'Echo On'
1214
echot	     db  'Echo On'
1215
echolen:
1215
echolen:
1216
echoot	      db  'Echo Off'
1216
echoot	      db  'Echo Off'
1217
echoolen:
1217
echoolen:
1218
 
1218
 
1219
quick_start:
1219
quick_start:
1220
 
1220
 
1221
    db	'( OPPONENT )                  '
1221
    db	'( OPPONENT )                  '
1222
 
1222
 
1223
   times 16  db  '                             1'
1223
   times 16  db  '                             1'
1224
 
1224
 
1225
    db	'Quick start:                  '
1225
    db	'Quick start:                  '
1226
    db	'                              '
1226
    db	'                              '
1227
    db	'1 Connect                     '
1227
    db	'1 Connect                     '
1228
    db	'2 login: "guest"              '
1228
    db	'2 login: "guest"              '
1229
    db	'3 aics% "seek 10 0"           '
1229
    db	'3 aics% "seek 10 0"           '
1230
    db	'  (for a player)              '
1230
    db	'  (for a player)              '
1231
    db	'  (wait)                      '
1231
    db	'  (wait)                      '
1232
    db	'4 Play eg. "e7e5"             '
1232
    db	'4 Play eg. "e7e5"             '
1233
    db	'  or  "d2d4"                  '
1233
    db	'  or  "d2d4"                  '
1234
    db	'5 aics% "resign"              '
1234
    db	'5 aics% "resign"              '
1235
    db	'  (quit game)                 '
1235
    db	'  (quit game)                 '
1236
    db	'6 Disconnect                  '
1236
    db	'6 Disconnect                  '
1237
 
1237
 
1238
  times 5  db  '                              '
1238
  times 5  db  '                              '
1239
 
1239
 
1240
    db	'( YOU )                       '
1240
    db	'( YOU )                       '
1241
 
1241
 
1242
    db	'x'
1242
    db	'x'
1243
 
1243
 
1244
 
1244
 
1245
chess_board:
1245
chess_board:
1246
 
1246
 
1247
    times  80	 db 0
1247
    times  80	 db 0
1248
 
1248
 
1249
 db '     8    *R  *N  *B  *Q  *K  *B  *N  *R'
1249
 db '     8    *R  *N  *B  *Q  *K  *B  *N  *R'
1250
 db '                                        '
1250
 db '                                        '
1251
 
1251
 
1252
     times  80	db 0
1252
     times  80	db 0
1253
 
1253
 
1254
 db '     7    *P  *P  *P  *P  *P  *P  *P  *P'
1254
 db '     7    *P  *P  *P  *P  *P  *P  *P  *P'
1255
 db '                                        '
1255
 db '                                        '
1256
 
1256
 
1257
     times  80	db 0
1257
     times  80	db 0
1258
 
1258
 
1259
 db '     6                                  '
1259
 db '     6                                  '
1260
 db '                                        '
1260
 db '                                        '
1261
 
1261
 
1262
     times  80	db 0
1262
     times  80	db 0
1263
 
1263
 
1264
 db '     5                                  '
1264
 db '     5                                  '
1265
 db '                                        '
1265
 db '                                        '
1266
 
1266
 
1267
     times  80	db 0
1267
     times  80	db 0
1268
 
1268
 
1269
 db '     4                                  '
1269
 db '     4                                  '
1270
 db '                                        '
1270
 db '                                        '
1271
 
1271
 
1272
     times  80	db 0
1272
     times  80	db 0
1273
 
1273
 
1274
 db '     3                                  '
1274
 db '     3                                  '
1275
 db '                                        '
1275
 db '                                        '
1276
 
1276
 
1277
     times  80	db 0
1277
     times  80	db 0
1278
 
1278
 
1279
 db '     2    P   P   P   P   P   P   P   P '
1279
 db '     2    P   P   P   P   P   P   P   P '
1280
 db '                                        '
1280
 db '                                        '
1281
 
1281
 
1282
    times  80	   db 0
1282
    times  80	   db 0
1283
 
1283
 
1284
 db '     1    R   N   B   Q   K   B   N   R '
1284
 db '     1    R   N   B   Q   K   B   N   R '
1285
 db '                                        '
1285
 db '                                        '
1286
 
1286
 
1287
    times  80	   db 0
1287
    times  80	   db 0
1288
 
1288
 
1289
 db '          a   b   c   d   e   f   g   h '
1289
 db '          a   b   c   d   e   f   g   h '
1290
 db '                                        '
1290
 db '                                        '
1291
 
1291
 
1292
 
1292
 
1293
    times  80*20 db 0
1293
    times  80*20 db 0
1294
 
1294
 
1295
chess_bmp:
1295
chess_bmp:
1296
        file    'chess.bmp':22*3+4+24*2
1296
        file    'chess.bmp':22*3+4+24*2
1297
 
1297
 
1298
board_old:
1298
board_old:
1299
 
1299
 
1300
 
1300
 
1301
I_END:
1301
I_END: