Subversion Repositories Kolibri OS

Rev

Rev 836 | Rev 853 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 836 Rev 852
Line 1... Line 1...
1
; ”㭪樨 à ¡®âë á ª®­á®«ìî ¤«ï ¯à®£à ¬¬ Š®«¨¡à¨Ž‘
1
; ”㭪樨 à ¡®âë á ª®­á®«ìî ¤«ï ¯à®£à ¬¬ Š®«¨¡à¨Ž‘
2
; diamond, 2006, 2007
2
; diamond, 2006-2008
Line 3... Line 3...
3
 
3
 
Line 4... Line 4...
4
 
4
 
Line 1137... Line 1137...
1137
        xchg    ax, [con.entered_char]
1137
        xchg    ax, [con.entered_char]
1138
        ret
1138
        ret
Line 1139... Line 1139...
1139
 
1139
 
1140
; void __stdcall con_gets(char* str, int n);
1140
; void __stdcall con_gets(char* str, int n);
-
 
1141
con_gets:
-
 
1142
        pop     eax
-
 
1143
        push    0
-
 
1144
        push    eax
-
 
1145
; void __stdcall con_gets2(con_gets2_callback callback, char* str, int n);
1141
con_gets:
1146
con_gets2:
1142
        pushad
1147
        pushad
1143
        mov     esi, [esp+20h+4]        ; str
1148
        mov     esi, [esp+20h+8]        ; str
1144
        mov     ebx, [esp+20h+8]        ; n
1149
        mov     ebx, [esp+20h+12]       ; n
1145
        sub     ebx, 1
1150
        sub     ebx, 1
1146
        jle     .ret
1151
        jle     .ret
1147
        mov     byte [esi], 0
1152
        mov     byte [esi], 0
1148
        xor     ecx, ecx                ; ¤«¨­  㦥 ¢¢¥¤ñ­­®© áâப¨
1153
        xor     ecx, ecx                ; ¤«¨­  㦥 ¢¢¥¤ñ­­®© áâப¨
1149
        call    con.get_data_ptr
1154
        call    con.get_data_ptr
1150
.loop:
1155
.loop:
1151
        call    con_getch
1156
        call    con_getch2
1152
        test    al, al
1157
        test    al, al
1153
        jz      .extended
1158
        jz      .extended
1154
        cmp     al, 8
1159
        cmp     al, 8
1155
        jz      .backspace
1160
        jz      .backspace
1156
        cmp     al, 27
1161
        cmp     al, 27
1157
        jz      .esc
1162
        jz      .esc
1158
        cmp     al, 13
1163
        cmp     al, 13
-
 
1164
        jz      .enter
-
 
1165
        cmp     al, 9
1159
        jz      .enter
1166
        jz      .tab
1160
        inc     ecx
1167
        inc     ecx
1161
        mov     dl, al
1168
        mov     dl, al
1162
        call    con.write_char_ex
1169
        call    con.write_char_ex
1163
        push    [con.cur_x]
1170
        push    [con.cur_x]
Line 1181... Line 1188...
1181
        pop     [con.cur_x]
1188
        pop     [con.cur_x]
1182
.update_screen_and_loop:
1189
.update_screen_and_loop:
1183
        call    con.update_screen
1190
        call    con.update_screen
1184
        cmp     ecx, ebx
1191
        cmp     ecx, ebx
1185
        jb      .loop
1192
        jb      .loop
-
 
1193
.ret_us:
1186
        mov     edx, [con.cur_x]
1194
        mov     edx, [con.cur_x]
1187
@@:
1195
@@:
1188
        lodsb
1196
        lodsb
1189
        test    al, al
1197
        test    al, al
1190
        jz      @f
1198
        jz      @f
Line 1216... Line 1224...
1216
        call    con.get_data_ptr
1224
        call    con.get_data_ptr
1217
        dec     esi
1225
        dec     esi
1218
        xor     ecx, ecx
1226
        xor     ecx, ecx
1219
@@:
1227
@@:
1220
        mov     byte [esi], 0
1228
        mov     byte [esi], 0
1221
        cmp     esi, [esp+20h+4]
1229
        cmp     esi, [esp+20h+8]
1222
        jbe     .update_screen_and_loop
1230
        jbe     .update_screen_and_loop
1223
        mov     al, 8
1231
        mov     al, 8
1224
        call    con.write_special_char
1232
        call    con.write_special_char
1225
        mov     al, ' '
1233
        mov     al, ' '
1226
        call    con.write_char
1234
        call    con.write_char
Line 1232... Line 1240...
1232
        cmp     byte [esi], 0
1240
        cmp     byte [esi], 0
1233
        jz      .loop
1241
        jz      .loop
1234
        lodsb
1242
        lodsb
1235
        call    con.write_char_ex
1243
        call    con.write_char_ex
1236
.backspace:
1244
.backspace:
1237
        cmp     esi, [esp+20h+4]
1245
        cmp     esi, [esp+20h+8]
1238
        jbe     .loop
1246
        jbe     .loop
1239
        push    esi
1247
        push    esi
1240
        mov     edx, [con.cur_x]
1248
        mov     edx, [con.cur_x]
1241
@@:
1249
@@:
1242
        lodsb
1250
        lodsb
Line 1296... Line 1304...
1296
        mov     [esi-1], al
1304
        mov     [esi-1], al
1297
        mov     byte [esi], 0
1305
        mov     byte [esi], 0
1298
        call    con.write_special_char
1306
        call    con.write_special_char
1299
        call    con.update_screen
1307
        call    con.update_screen
1300
        jmp     .ret
1308
        jmp     .ret
-
 
1309
.tab:
-
 
1310
        mov     al, 0
-
 
1311
        mov     ah, 0xF
1301
.extended:
1312
.extended:
1302
        call    con_getch
1313
        xchg    al, ah
1303
        cmp     al, 0x4B
1314
        cmp     al, 0x4B
1304
        jz      .left
1315
        jz      .left
1305
        cmp     al, 0x4D
1316
        cmp     al, 0x4D
1306
        jz      .right
1317
        jz      .right
1307
        cmp     al, 0x47
1318
        cmp     al, 0x47
1308
        jz      .home
1319
        jz      .home
1309
        cmp     al, 0x4F
1320
        cmp     al, 0x4F
1310
        jz      .end
1321
        jz      .end
1311
        cmp     al, 0x53
1322
        cmp     al, 0x53
1312
        jz      .delete
1323
        jz      .delete
-
 
1324
; give control to callback function
-
 
1325
        cmp     dword [esp+20h+4], 0
-
 
1326
        jz      .loop
-
 
1327
; remember length of text before and length of text after
-
 
1328
; and advance cursor to the end of line
-
 
1329
        push    ecx
-
 
1330
        push    eax
-
 
1331
        lea     edx, [esi+1]
-
 
1332
@@:
-
 
1333
        lodsb
-
 
1334
        test    al, al
-
 
1335
        jz      @f
-
 
1336
        call    con.write_char_ex
-
 
1337
        jmp     @b
-
 
1338
@@:
-
 
1339
        sub     esi, edx
-
 
1340
        pop     eax
-
 
1341
        push    esi
-
 
1342
        dec     edx
-
 
1343
        sub     edx, [esp+28h+8]
-
 
1344
        push    edx
-
 
1345
        push    esp             ; ppos
-
 
1346
        mov     ecx, [esp+30h+4]
-
 
1347
        lea     edx, [esp+30h+12]
-
 
1348
        push    edx             ; pn
-
 
1349
        lea     edx, [esp+34h+8]
-
 
1350
        push    edx             ; pstr
-
 
1351
        push    eax             ; keycode
-
 
1352
        call    ecx
-
 
1353
        call    con.get_data_ptr
-
 
1354
        dec     eax
-
 
1355
        js      .callback_nochange
-
 
1356
        jz      .callback_del
-
 
1357
        dec     eax
-
 
1358
        jz      .callback_output
-
 
1359
; callback returned 2 - exit
-
 
1360
        add     esp, 12
-
 
1361
        jmp     .ret
-
 
1362
.callback_nochange:
-
 
1363
; callback returned 0 - string was not changed, only restore cursor position
-
 
1364
        pop     esi
-
 
1365
        pop     ecx
-
 
1366
        test    ecx, ecx
-
 
1367
        jz      .cncs
-
 
1368
@@:
-
 
1369
        mov     al, 8
-
 
1370
        call    con.write_special_char
-
 
1371
        loop    @b
-
 
1372
.cncs:
-
 
1373
        pop     ecx
-
 
1374
        add     esi, [esp+20h+8]
-
 
1375
        jmp     .callback_done
-
 
1376
.callback_del:
-
 
1377
; callback returned 1 - string was changed, delete old string and output new
-
 
1378
        mov     ecx, [esp+8]
-
 
1379
        test    ecx, ecx
-
 
1380
        jz      .cds
-
 
1381
@@:
-
 
1382
        mov     al, 8
-
 
1383
        call    con.write_special_char
-
 
1384
        mov     al, ' '
-
 
1385
        call    con.write_char_ex
-
 
1386
        mov     al, 8
-
 
1387
        call    con.write_special_char
-
 
1388
        loop    @b
-
 
1389
.cds:
-
 
1390
.callback_output:
-
 
1391
; callback returned 2 - string was changed, output new string
-
 
1392
        pop     edx
-
 
1393
        pop     esi
-
 
1394
        pop     ecx
-
 
1395
        mov     esi, [esp+20h+8]
-
 
1396
        xor     ecx, ecx
-
 
1397
@@:
-
 
1398
        lodsb
-
 
1399
        test    al, al
-
 
1400
        jz      @f
-
 
1401
        call    con.write_char_ex
-
 
1402
        inc     ecx
-
 
1403
        jmp     @b
-
 
1404
@@:
-
 
1405
        dec     esi
-
 
1406
        push    ecx
-
 
1407
        sub     ecx, edx
-
 
1408
        jz      .cos
-
 
1409
@@:
-
 
1410
        mov     al, 8
-
 
1411
        call    con.write_special_char
-
 
1412
        dec     esi
-
 
1413
        loop    @b
-
 
1414
.cos:
-
 
1415
        pop     ecx
-
 
1416
.callback_done:
-
 
1417
        call    con.update_screen
-
 
1418
        mov     ebx, [esp+20h+12]
-
 
1419
        dec     ebx
-
 
1420
        cmp     ecx, ebx
-
 
1421
        jae     .ret_us
1313
        jmp     .loop
1422
        jmp     .loop
1314
.left:
1423
.left:
1315
        cmp     esi, [esp+20h+4]
1424
        cmp     esi, [esp+20h+8]
1316
        jbe     .loop
1425
        jbe     .loop
1317
        dec     esi
1426
        dec     esi
1318
        mov     al, 8
1427
        mov     al, 8
1319
        call    con.write_special_char
1428
        call    con.write_special_char
1320
        jmp     .update_screen_and_loop
1429
        jmp     .update_screen_and_loop
Line 1323... Line 1432...
1323
        jz      .loop
1432
        jz      .loop
1324
        lodsb
1433
        lodsb
1325
        call    con.write_char_ex
1434
        call    con.write_char_ex
1326
        jmp     .update_screen_and_loop
1435
        jmp     .update_screen_and_loop
1327
.home:
1436
.home:
1328
        cmp     esi, [esp+20h+4]
1437
        cmp     esi, [esp+20h+8]
1329
        jz      .update_screen_and_loop
1438
        jz      .update_screen_and_loop
1330
        dec     esi
1439
        dec     esi
1331
        mov     al, 8
1440
        mov     al, 8
1332
        call    con.write_special_char
1441
        call    con.write_special_char
1333
        jmp     .home
1442
        jmp     .home
Line 1340... Line 1449...
1340
@@:
1449
@@:
1341
        dec     esi
1450
        dec     esi
1342
        jmp     .update_screen_and_loop
1451
        jmp     .update_screen_and_loop
1343
.ret:
1452
.ret:
1344
        popad
1453
        popad
1345
        ret     8
1454
        ret     12
Line 1346... Line 1455...
1346
 
1455
 
1347
con.update_screen:
1456
con.update_screen:
1348
        push    eax
1457
        push    eax
1349
        mov     eax, [con.cur_y]
1458
        mov     eax, [con.cur_y]
Line 2016... Line 2125...
2016
con.vscroll_pt      dd    -1
2125
con.vscroll_pt      dd    -1
Line 2017... Line 2126...
2017
 
2126
 
2018
align 16
2127
align 16
2019
EXPORTS:
2128
EXPORTS:
2020
        dd      szStart,                START
2129
        dd      szStart,                START
2021
        dd      szVersion,              0x00020003
2130
        dd      szVersion,              0x00020004
2022
        dd      szcon_init,             con_init
2131
        dd      szcon_init,             con_init
2023
        dd      szcon_write_asciiz,     con_write_asciiz
2132
        dd      szcon_write_asciiz,     con_write_asciiz
2024
        dd      szcon_printf,           con_printf
2133
        dd      szcon_printf,           con_printf
2025
        dd      szcon_exit,             con_exit
2134
        dd      szcon_exit,             con_exit
2026
        dd      szcon_get_flags,        con_get_flags
2135
        dd      szcon_get_flags,        con_get_flags
2027
        dd      szcon_set_flags,        con_set_flags
2136
        dd      szcon_set_flags,        con_set_flags
2028
        dd      szcon_kbhit,            con_kbhit
2137
        dd      szcon_kbhit,            con_kbhit
2029
        dd      szcon_getch,            con_getch
2138
        dd      szcon_getch,            con_getch
2030
        dd      szcon_getch2,           con_getch2
2139
        dd      szcon_getch2,           con_getch2
-
 
2140
        dd      szcon_gets,             con_gets
2031
        dd      szcon_gets,             con_gets
2141
        dd      szcon_gets2,            con_gets2
2032
        dd      szcon_get_font_height,  con_get_font_height
2142
        dd      szcon_get_font_height,  con_get_font_height
2033
        dd      szcon_get_cursor_height,con_get_cursor_height
2143
        dd      szcon_get_cursor_height,con_get_cursor_height
2034
        dd      szcon_set_cursor_height,con_set_cursor_height
2144
        dd      szcon_set_cursor_height,con_set_cursor_height
Line 2059... Line 2169...
2059
szcon_set_flags         db 'con_set_flags',0
2169
szcon_set_flags         db 'con_set_flags',0
2060
szcon_kbhit             db 'con_kbhit',0
2170
szcon_kbhit             db 'con_kbhit',0
2061
szcon_getch             db 'con_getch',0
2171
szcon_getch             db 'con_getch',0
2062
szcon_getch2            db 'con_getch2',0
2172
szcon_getch2            db 'con_getch2',0
2063
szcon_gets              db 'con_gets',0
2173
szcon_gets              db 'con_gets',0
-
 
2174
szcon_gets2             db 'con_gets2',0
2064
szcon_get_font_height   db 'con_get_font_height',0
2175
szcon_get_font_height   db 'con_get_font_height',0
2065
szcon_get_cursor_height db 'con_get_cursor_height',0
2176
szcon_get_cursor_height db 'con_get_cursor_height',0
2066
szcon_set_cursor_height db 'con_set_cursor_height',0
2177
szcon_set_cursor_height db 'con_set_cursor_height',0
Line 2067... Line 2178...
2067
 
2178