Subversion Repositories Kolibri OS

Rev

Rev 109 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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