kolibrios-fun/programs/games/klavisha/trunk/klavisha.asm
Marat Zakiyanov (Mario79) 6c8b52f01e Klavisha v.0.95
1) Checking for "rolled up" window
2) Code optimization
3) Clearing source

git-svn-id: svn://kolibrios.org@2076 a494cfbc-eb01-0410-851d-a64ba20cac60
2011-08-19 10:52:19 +00:00

663 lines
17 KiB
NASM
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

; --------------------------------------------------------
; KJ|ABuIIIA - ª« ¢¨ âãà­ë© â७ ¦ñà ¤«ï ®¯¥à æ¨®­­®© á¨áâ¥¬ë Š®«¨¡à¨.
;---------------------------------------------------------------------
; version: 0.95
; last update: 19/08/2011
; changed by: Marat Zakiyanov aka Mario79, aka Mario
; changes: 1) Checking for "rolled up" window
; 2) Code optimization
; 3) Clearing source
;---------------------------------------------------------------------
; version: 0.90
; last update: 24/07/2010
; changed by: €­¤à¥© Œ¨å ©«®¢¨ç (Dron2004)
;
; <20>®á«¥¤­¨¥ ¨§¬¥­¥­¨ï ¢ ¨á室­®¬ ª®¤¥: 24.07.2010 21:15 GMT+6
;---------------------------------------------------------------------
use32
org 0x0
;‡ £®«®¢®ª
db 'MENUET01'
dd 0x01
dd START
dd IM_END
dd I_END
dd stacktop
dd params
dd 0x0
;---------------------------------------------------------------------
include 'lang.inc'
include '../../../macros.inc'
;---------------------------------------------------------------------
;Š®¤ ¯à®£à ¬¬ë
START:
;ˆ­¨æ¨ «¨§¨à㥬 ªãçã
mcall 68,11
; call get_screen_params
; mov eax,0x0000001C
; cmp eax,0x0
; je start_with_internal_text ; <20> à ¬¥âàë ­¥ § ¤ ­ë
; <20> à ¬¥âà § ¤ ­! <20>ëâ ¥¬áï í⨬ ¢®á¯®«ì§®¢ âìáï
; <20>¥®¡å®¤¨¬® ®¯à¥¤¥«¨âì à §¬¥à ä ©« ... ‚¯¥àñ¤!!!
mov eax,5
mov [arg1],eax
xor eax,eax
mov [arg2],eax
mov [arg3],eax
mov [arg4],eax
mov eax,filedatastruct
mov [arg5],eax
mov eax,[0x0000001C]
mov [arg7],eax
mcall 70,filestruct
test eax,eax
jne start_with_internal_text ;Žè¨¡ª 
mov eax, dword [size]
mov [filesize], eax ;⥯¥àì à §¬¥à ä ©«  ã ­ á ¢ filesize
;‚뤥«ï¥¬ ¡«®ª ¯ ¬ï⨠¯®¤ ä ©«
mov ecx, [filesize]
inc ecx ;‚뤥«¨¬ ¤®¯®«­¨â¥«ì­® ®¤¨­ ¡ ©â ¤«ï ⮣®, çâ®¡ë ¤®¡ ¢¨âì 0xFF
;§ é¨â  ®â "¡¨âëå" KLA-ä ©«®¢
mcall 68,12
mov [datastart], eax ; ¯¥à¥¬¥­­®© „ â ‘â àâ ⥯¥àì ­ å®¤¨âáï 㪠§ â¥«ì
add eax, [filesize]
mov bh, 0xFF
mov [eax], bh
;‘®¡á⢥­­®, áç¨â뢠¥¬ ä ©« ¢ ¯ ¬ïâì
xor eax,eax
mov [arg1],eax ;<3B>®¬¥à ¯®¤ä㭪樨
mov [arg2],eax ;‘¬¥é¥­¨¥ ¢ ä ©«¥
mov [arg3],eax ;‘â à訩 dword ᬥ饭¨ï
mov eax,[filesize]
mov [arg4],eax ;<3B> §¬¥à ä ©« 
mov eax,[datastart]
mov [arg5],eax ;“ª § â¥«ì ­  ¤ ­­ë¥
mov eax,par
mov [arg7],eax ;“ª § â¥«ì ­  ASCIIZ-áâபã
mcall 70,filestruct
test eax,eax
je initialize_variables
start_with_internal_text:
mov edx, string
mov [datastart], edx
; mov edx, string ; ˆá¯®«ì§ã¥¬ ¢áâ஥­­ë© ⥪áâ
initialize_variables:
mov edx,[datastart]
mov [currentsymb],edx ; <20> ç «ì­ ï ¨­¨æ¨ «¨§ æ¨ï ¯¥à¥¬¥­­ëå
mov [startline],edx
mov [lastsymb],edx
mov [lessonstart],edx
xor eax,eax
inc eax
mov [currentline], eax
call count_lines
;---------------------------------------------------------------------
redraw:
call draw_window
;---------------------------------------------------------------------
;Žá­®¢­®© 横«
event_wait:
mcall 10
cmp eax, 1 ;<3B>¥à¥à¨á®¢ª  ®ª­  ­ã¦­ 
je redraw
cmp eax, 2 ;Š« ¢¨è  ­ ¦ â 
je key
cmp eax, 3 ;<3B>® ª­®¯ª¥ ¦¬ å­ã«¨
je button
jmp event_wait
;---------------------------------------------------------------------
key:
mcall 2 ;’¥¯¥àì ª®¤ ­ ¦ â®© ª« ¢¨è¨ ¢ ah
push eax
;‡ ¯ã᪠¥¬ áçñâ稪 ¢à¥¬¥­¨ ¤«ï ¯®á«¥¤ãî饣®
; ®¯à¥¤¥«¥­¨ï ᪮à®á⨠­ ¡®à 
mov eax, [currentsymb]
cmp eax, [lessonstart]
jne not_first_symbol
mov eax,[mistakes]
test eax,eax
jne not_first_symbol
mcall 26,9
mov [typestarttime], eax
not_first_symbol:
pop eax
;<3B>஢¥à塞, ­¥ § ª®­ç¨«áï «¨ ⥪áâ
mov esi, [currentsymb]
mov al, byte [esi]
cmp al, 0xFF
je text_end
cmp al, 0xFE
je text_end
push ebx
mov ebx, [currentsymb]
mov al, byte [ebx]
pop ebx
test al,al
jne not_new_line
cmp ah, 0x0D
je correct_key_nl
cmp ah, 0x20
je correct_key_nl
jmp not_this_key
;---------------------------------------------------------------------
correct_key_nl:
mov eax, [currentsymb]
inc eax
mov [startline], eax
mov eax, [currentsymb]
inc eax
mov [currentsymb], eax
mov [lastsymb], eax
mov eax, [currentline]
inc eax
mov [currentline], eax
mov eax, [symbtyped] ;“¢¥«¨ç¨¬ ç¨á«® ¢¢¥¤ñ­­ëå ᨬ¢®«®¢ ­  1
inc eax
mov [symbtyped], eax
call count_speed
; call draw_speed
jmp redraw
;---------------------------------------------------------------------
not_new_line:
cmp ah, al
jne not_this_key
correct_key:
mov eax, [currentsymb]
inc eax
mov [currentsymb], eax
mov [lastsymb], eax
mov eax, [symbtyped] ;“¢¥«¨ç¨¬ ç¨á«® ¢¢¥¤ñ­­ëå ᨬ¢®«®¢ ­  1
inc eax
mov [symbtyped], eax
call count_speed
; call draw_speed
call redraw_2_symbols
jmp event_wait
;---------------------------------------------------------------------
not_this_key:
mov esi, [mistakes]
inc esi
mov [mistakes], esi
call redraw_mistakes
jmp event_wait
;---------------------------------------------------------------------
text_end:
; /// <20>९ïâáâ¢ã¥â ¬¨£ ­¨î ®ª­  ¯® ®ª®­ç ­¨¨ ãப 
; ¯à¨ ­ ¦ â¨¨ ª« ¢¨è
mov esi, [startline]
cmp esi, lessoncomplete
je text_end_already_shown
; ///////////////////////////
call speed_to_string
mov esi, lessoncomplete
mov [startline], esi
mov esi, lessoncompleteend
dec esi
mov [currentsymb], esi
call draw_window
text_end_already_shown:
jmp event_wait
;---------------------------------------------------------------------
button:
mcall 17 ;ˆ¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨ ¢®§¢à éñ­ ¢ ah
cmp ah, 1 ;íâ® ª­®¯ª  § ªàëâ¨ï
jne no_close
mcall -1
no_close:
;<3B>஢¥à塞 ®áâ «ì­ë¥ ª­®¯ª¨
cmp ah, 0x02
jne no_button_2
;<3B> ¦ â  ª­®¯ª  2
;---------------------------------------------------------------------
; Ž—…<E28094>œ <E28098>˜<E282AC>‰ ŠŽ„
;---------------------------------------------------------------------
xor eax, eax
mov [mistakes], 0x0
mov esi, [lastsymb]
mov al, [esi]
;<3B>㦭® ¯à®¢¥à¨âì, çâ® §  ᨬ¢®« ¡ë« ¯®á«¥¤­¨¬. …᫨ 0xFF -
;’¥ªáâ ª®­ç¨«áï, ­ã¦­® ­ ç âì ¢áñ á­ ç « 
cmp al, 0xFF
je start_1st_lesson
cmp al, 0xFE ; Œë ¯à®è«¨ ¯à®è«ë© ãப?
jne not_completed_previous
init_level_after_fe:
;…¦¥«¨ ¤ , â® ¯à®¢¥à¨¬, ­¥ ¯®¯ « «¨ á«ãç ©­® á«¥¤ãî騬 ᨬ¢®«®¬ 0xFF
inc esi
mov al, [esi]
cmp al, 0xFF
;…¦¥«¨ ­¥â - íâ® ¨ ¥áâì á«¥¤ãî騩 ãப
jne set_lesson_start_from_esi
start_1st_lesson:
mov esi, [datastart]
set_lesson_start_from_esi:
mov [startline], esi
mov [currentsymb], esi
mov [lastsymb], esi
mov [lessonstart], esi
xor eax,eax
jmp no_button_3.2
; inc eax
; mov [currentline], eax
; call count_lines
; call reset_speed_counters
; jmp redraw
;---------------------------------------------------------------------
not_completed_previous:
inc esi
mov al, [esi]
cmp al, 0xFF
je start_1st_lesson
cmp al, 0xFE
je init_level_after_fe
jmp not_completed_previous
;---------------------------------------------------------------------
; ŠŽ<C5A0> <E28098>˜<E282AC>ŽƒŽ ŠŽ„€
;---------------------------------------------------------------------
no_button_2:
cmp ah,0x03
jne no_button_3
;<3B>¥à¥§ ¯ã᪠ã஢­ï
mov edx,[lessonstart]
jmp no_button_3.1
; mov [currentsymb],edx
; mov [startline],edx
; mov [lastsymb],edx
; xor eax,eax
; mov [mistakes],eax
; inc eax
; mov [currentline],eax
; call reset_speed_counters
; call count_lines
; jmp redraw
;---------------------------------------------------------------------
no_button_3:
cmp ah,0x04
jne event_wait
;<3B>¥à¥§ ¯ã᪠ªãàá  ã¯à ¦­¥­¨©
mov edx,[datastart]
mov [lessonstart],edx
.1:
mov [currentsymb],edx
mov [startline],edx
mov [lastsymb],edx
xor eax,eax
mov [mistakes],eax
.2:
inc eax
mov [currentline],eax
call reset_speed_counters
call count_lines
jmp redraw
;---------------------------------------------------------------------
;<3B>®«ã稬 ⥪ã騥 ¯ à ¬¥âàë ®ª­ 
get_window_param:
mcall 9,procinfo,-1
ret
;---------------------------------------------------------------------
;"‘¥à¤æ¥" ¯à®£à ¬¬ë - äã­ªæ¨ï à¨á®¢ ­¨ï ®ª­  (¢áñ ®áâ «ì­®¥ - âã«®¢¨é¥ †-)) )
draw_window:
mcall 12,1
mov ax,[areawidth] ;<3B>â® ¯¥à¢ë© ¢ë§®¢ draw_window?
test ax,ax
jne .dw_not_first_call
call get_screen_params ;<3B>®«ãç ¥¬ ¯ à ¬¥âàë íªà ­  - è¨à¨­ã ¨ ¢ëá®âã
.dw_not_first_call:
;¢ ebx - X ¨ è¨à¨­ 
mov bx,[windowx]
shl ebx,16
mov bx,780
; mov ebx,10*65536+780
;¢ ecx - Y ¨ ¢ëá®â 
mov cx, [windowy]
shl ecx,16
mov cx,580
; mov ecx,10*65536+580
xor esi,esi
;Ž¯à¥¤¥«¨âì ¨ ¢ë¢¥á⨠®ª­®
mcall 0,,,0x33CCCCCC,,text
call get_window_param
mov eax,[procinfo+70] ;status of window
test eax,100b
jne .end
;<3B> à¨á㥬 ª­®¯ªã ‘‹…„“ž™ˆ‰ “<>ŽŠ ¨ ⥪áâ ­  ­¥©
mcall 8,<295,145>,<8,18>,2,0x0099CC99
;<3B> à¨á㥬 ª­®¯ªã <20>ŽŽ<E28099>ˆœ “<><E2809C>€†<E282AC><EFBFBD>ˆ
mcall ,<450,145>,,3,0x00CC9999
;<3B> à¨á㥬 ª­®¯ªã <20>€—€œ Š“<C5A0> ‡€<E280A1>ŽŽ
mcall ,<605,145>,,4,0x00DD7777
;‚뢮¤¨¬ ⥪áâ ­  ª­®¯ª å
mcall 4,<310,14>,0x80000000,buttontext
mcall ,<465,14>,,retrybuttontext
mcall ,<626,14>,,restartbuttontext
; <20> à¨á㥬 «®£®â¨¯
xor ebp,ebp
mcall 65,logo,<32,12>,<12,12>,1,green_text
;<3B>®«ã稬 ⥪ã騥 ¯ à ¬¥âàë ®ª­ 
call get_window_param
add ebx,0x2A
mov eax,[ebx]
mov [windowwidth], eax
mov ebx,procinfo
add ebx,0x2E
mov eax,[ebx]
mov [windowheight], eax
;draw_error_count:
; <20> à¨á㥬 ­ ¤¯¨áì "Ž˜ˆ<CB9C>ŽŠ"
mcall 4,<60,15>,0x80AA0000,mistakestext
; ‚뢥¤¥¬ ç¨á«® ®è¨¡®ª
mcall 47,0x80040000,[mistakes],<105,15>,0x00AA0000
;draw_line_number:
; <20> à¨á㥬 ­ ¤¯¨áì "‘âப  ¨§"
mcall 4,<140,15>,0x8000AA00,lineistext
;‚뢥¤¥¬ ­®¬¥à ⥪ã饩 áâப¨
mcall 47,80040000,[currentline],<195,15>,0x0000AA00
;‚뢥¤¥¬ ⥪ãéãî áâபã
mcall ,,[linecount],<252,15>,
;‚뢥á⨠ࠡ®ç¨© ⥪áâ
call draw_text
.end:
mcall 12,2
ret
;---------------------------------------------------------------------
draw_text:
;<3B>®¤£®â®¢ª  ª ¢ë¢®¤ã ⥪áâ 
mov edx,40 ;<3B> ç «ì­®¥ ¯®«®¦¥­¨¥ ¢ë¢®¤¨¬®£® ⥪áâ  ¯® ¢¥à⨪ «¨
mov esi,[startline]
dec esi ;’ ª ­ ¤® (á¬. *1 ­¨¦¥)!
mov ebx,esi ;’¥¯¥àì ¢ edx - ­ ç «® ¢ë¢®¤¨¬®© áâப¨
.start:
;<3B> à é¨¢ ¥¬ 㪠§ â¥«ì ­  ⥪ã騩 ᨬ¢®« ­  ¥¤¨­¨æã
inc ebx ;(*1)
.draw_text_without_inc:
;<3B>®á¬®âਬ,­¥ ¢ë室¨â «¨ ⥪áâ §  £à ­¨æã ®ª­ 
mov esi,[windowheight] ;’¥¯¥àì ¢ esi à §¬¥à ®ª­ 
mov eax,edx
and eax,0x0000FFFF
add eax,64
cmp eax,esi
ja end_draw_text ;Œë ¢ë室¨¬ §  ¯à¥¤¥«ë ®ª­ . <20>¥à¥áâ ñ¬ à¨á®¢ âì.
;ãáâ ­®¢¨¬ ¯®«®¦¥­¨¥ ¯® £®à¨§®­â «¨ (+18 ª ⥪ã饩 ¯®§¨æ¨¨)
mov esi,18*65536
add edx,esi
; ¯®á¬®âਬ, ­¥ ¢ë襫 «¨ ⥪áâ §  £à ­¨æã ¯® £®à¨§®­â «¨
; ¥á«¨ ¢ë襫 - ­¥ à¨á㥬 íâ®â ªã᮪
mov esi,[windowwidth] ;’¥¯¥àì ¢ esi à §¬¥à ®ª­ 
shl esi,16
mov eax,edx
and eax,0xFFFF0000
add eax,40*65536
cmp eax,esi
jna .horizontal_check_ok ;…᫨ eax>est, â® ¬ë ¢ë室¨¬ §  ¯à¥¤¥«ë ®ª­ .
.skip_line_end_step:
mov ah,byte [ebx]
cmp ah,0x00
je .end_line_to_next_line
cmp ah,0xFE
je end_draw_text
cmp ah,0xFF
je end_draw_text
inc ebx
jmp .skip_line_end_step
;-------------------------------------------
.end_line_to_next_line:
and edx,0x0000FFFF
jmp .draw_text_without_inc
;-------------------------------------------
.horizontal_check_ok:
;<3B>஢¥à¨¬, ­¥ § ª®­ç¨«áï «¨ ãப
mov esi, [startline]
cmp esi, lessoncomplete
jne .in_process
;…᫨ § ª®­ç¨«áï, ⥪á⠢뢮¤¨âì ­ã¦­® ‡…<E280B9>Œ –‚…’ŽŒ
mov edi, green_text
jmp .color_set_sucessful
;--------------------------------------------
.in_process:
cmp ebx, [currentsymb] ; <20>¨áã¥âáï ⥪ã騩 ­ ¡¨à ¥¬ë© ᨬ¢®«?
je .red ; ’ ª â®ç­®!
ja .black ; <20>¥â, <20>¨áã¥âáï â®, çâ® ¬ë ¥éñ ­¥ ­ ¡à «¨
mov edi, gray_text ; <20>¥â, à¨áã¥âáï â®, çâ® ¬ë 㦥 ­ ¡à «¨
jmp .color_set_sucessful
;--------------------------------------------
.red:
mov edi, red_text
jmp .color_set_sucessful
;---------------------------------------------
.black:
mov edi, black_text ;˜à¨äâ ¨ 梥â
.color_set_sucessful:
xor esi,esi
movzx si, byte [ebx]
cmp si, 0x0000
jne .continue_drawing
; call increase_y;
; “¢¥«¨ç¨¬ ¢¥à⨪ «ì­ãî ª®®à¤¨­ â㠢뢮¤  ¡ãª¢,
; ¥á«¨ ª®­ç¨« áì áâப  (¢áâà¥â¨«áï ¡ ©â 0x00)
and edx,0x0000FFFF
add edx, 33
jmp .continue_text_proc
;----------------------------------------------
.continue_drawing:
cmp si, 0x00FF
je end_draw_text
cmp si, 0x00FE
je end_draw_text
;<3B>¨á㥬 ¡ãª¢ã á ¯®¬®éìî <20>Žœ˜ŽƒŽ èà¨äâ 
push ebx
push edx
movzx eax, byte [ebx]
shl eax,6
add eax, big_font
mov ebx, eax
pop edx
mov ecx, 16*65536+32
; edx «¥¦¨â ª®®à¤¨­ â 
mov esi, 1
; edi «¥¦¨â 㪠§ â¥«ì ­  ¯ «¨âàã (梥â èà¨äâ )
xor ebp,ebp
mcall 65
pop ebx
;<3B>  í⮬ ®âà¨á®¢ª  ¡ãª¢ë § ¢¥à襭 
.continue_text_proc:
; inc edi
jmp .start
end_draw_text:
ret
;---------------------------------------------------------------------
;<3B><>Ž…„“<E2809E><20><EFBFBD><EFBFBD>ˆŽŠˆ „‚“• ‘ˆŒ‚Ž‹Ž‚ („€<E2809E> Œˆ<C592>ˆŒˆˆ<E280A1>Žœ Œˆƒ€<C692>ˆ…)
redraw_2_symbols:
;<3B>஢¥à¨¬, ­¥ ¢ë©¤¥¬ «¨ ¬ë ¯à¨ à¨á®¢ ­ ¨¨ §  £à ­¨æã ¤®¯ãá⨬®©
;®¡« á⨠¢­ãâਠ®ª­ . …᫨ ¢ë©¤¥¬ - áªà®««¨¬ áâப㠯® £®à¨§®­â «¨
mov esi, [windowwidth] ;’¥¯¥àì ¢ esi à §¬¥à ®ª­ 
mov eax, [currentsymb]
sub eax, [startline]
mov ecx, 18
mul ecx
add eax, 20
add eax, 20
add eax, 40
cmp eax, esi
jna r2s_horizontal_check_ok ;…᫨ eax>est, â® ¬ë ¢ë室¨¬ §  ¯à¥¤¥«ë ®ª­ .
;ˆâ ª, ¬ë ¢ë室¨¬ §  £à ­¨æë ®ª­ ... <20>â® ¯«®å®...
;‘âப㠯ਤñâáï áªà®««¨âì...
mov eax, [currentsymb]
dec eax
mov [startline], eax
call draw_window
jmp return_from_redraw_2_symbols
;---------------------------------------------------------------------
r2s_horizontal_check_ok:
;<3B>¨á㥬 <20><>…„„“™“ž <E28098>“ž ¡ãª¢ã á ¯®¬®éìî <20>Žœ˜ŽƒŽ èà¨äâ 
mov ebx, [currentsymb]
dec ebx
movzx eax, byte [ebx]
shl eax,6
add eax, big_font
mov ebx, eax
mov ecx, 16*65536+32
mov eax, [currentsymb]
sub eax, [startline]
dec eax
imul eax,18
add eax, 18
shl eax,16
add eax, 40
mov edx, eax
xor ebp,ebp
mcall 65,,,,1,gray_text
;<3B>¨á㥬 ’…Š“™“ž <20>“Š
mov ebx, [currentsymb]
movzx eax, byte [ebx]
shl eax,6
add eax, big_font
mov ebx, eax
mov ecx, 16*65536+32
mov eax, [currentsymb]
sub eax, [startline]
imul eax,18
add eax, 18
shl eax,16
add eax, 40
mov edx, eax
mcall 65,,,,1,red_text
return_from_redraw_2_symbols:
ret
;---------------------------------------------------------------------
redraw_mistakes:
;‡ ªà á¨¬ ¯àאַ㣮«ì­¨ª
mcall 13,<59,75>,<14,10>,0x00CCCCCC
; <20> à¨á㥬 ­ ¤¯¨áì "Ž˜ˆ<CB9C>ŽŠ"
mcall 4,<60,15>,0x80AA0000,mistakestext
; ‚뢥¤¥¬ ç¨á«® ®è¨¡®ª
mcall 47,0x80040000,[mistakes],<105,15>,0x00AA0000
ret
;---------------------------------------------------------------------
count_lines:
xor ecx, ecx ; ecx - áçñâ稪 áâப
inc ecx ; “ ­ á 1 áâப 
; <20> ç¨­ ¥¬ à §¡®à...
mov eax, [startline]
dec eax
cl_next_step:
inc eax
mov bh, [eax]
cmp bh, 0x00
jne cl_not_new_line
inc ecx
jmp cl_next_step
;---------------------------------------------------------------------
cl_not_new_line:
cmp bh, 0xFE
je cl_end
cmp bh, 0xFF
je cl_end
jmp cl_next_step
;---------------------------------------------------------------------
cl_end:
mov [linecount],ecx
ret
;---------------------------------------------------------------------
reset_speed_counters:
xor eax,eax
mov [symbtyped],eax
mov [typestarttime],eax
mov [currenttime],eax
mov [typingspeed],eax
ret
;---------------------------------------------------------------------
count_speed:
mcall 26,9
mov [currenttime], eax
mov ebx, [typestarttime]
sub eax, ebx ;’¥¯¥àì ¢ eax - ç¨á«® ¯à®è¥¤è¨å ¤®«¥© ᥪ㭤
mov ecx, [symbtyped]
cmp ecx, 0x00
jne cs_all_ok
inc ecx
cs_all_ok:
xor edx, edx;
div ecx ;’¥¯¥àì ¢ eax - á।­ïï ¯ ã§  ¬¥¦¤ã ᨬ¢®« ¬¨
mov ecx, eax
cmp ecx, 0x00
jne cs_all_ok_2
inc ecx
cs_all_ok_2:
xor edx, edx
mov eax, 6000
div ecx
mov [typingspeed], eax ;‚®â ¨ ¢áñ. [typingspeed] - á।­ïï ᪮à®áâì ­ ¡®à 
ret
;---------------------------------------------------------------------
speed_to_string:
; <20>८¡à §ã¥â ç¨á«® ¢ áâப㠨 § ¯¨á뢠¥â ¯®  ¤à¥¬ã ¯¥à¥¬¥­­®© speedbytes § ¤®¬ ­ ¯¥àñ¤
xor edx, edx
mov eax, [typingspeed]
mov ecx, 10
div ecx
add dl, 30h
mov [speedbytes + 3], dl
xor edx, edx
div ecx
add dl, 30h
mov [speedbytes + 2], dl
xor edx, edx
div ecx
add dl, 30h
mov [speedbytes + 1], dl
xor edx, edx
div ecx
cmp dl, 0x00
je sts_move_space
add dl, 30h
mov [speedbytes], dl
jmp sts_end
;---------------------------------------------------------------------
sts_move_space:
mov [speedbytes], 0x20
sts_end:
ret
;---------------------------------------------------------------------
get_screen_params:
mcall 14
mov [areaheight], ax
push ax
shr eax, 16
mov [areawidth],ax
; ax ¯® ¯à¥¦­¥¬ã ­ å®¤¨âáï è¨à¨­  ®ª­ . ‚®á¯®«ì§ã¥¬áï í⨬
sub ax, 780 ;‚ëç⥬ ­ ç «ì­ë© à §¬¥à ®ª­ 
shr ax, 1
mov [windowx], ax
; <20>¥à¥å®¤¨¬ ª ¢ëá®â¥
xor ax, ax
pop ax ; ‚ë⮫ª­¥¬ ¨§ á⥪  §­ ç¥­¨¥ ¢ëá®âë
sub ax, 580
shr ax, 1
mov [windowy], ax
ret
;---------------------------------------------------------------------
;draw_speed:
;‡ ªà á¨¬ ¯àאַ㣮«ì­¨ª
; mcall 13,<59,340>,<29,10>,0x00CCCCCC
; <20> à¨á㥬 ­ ¤¯¨áì "‘ª®à®áâì ­ ¡®à  (§­ ª®¢ ¢ ¬¨­ãâã):"
; mcall 4,<60,30>,0x80008800,speedtext
; ‚뢥¤¥¬ ç¨á«®
; mcall 47,0x80040000,[typingspeed],<305,30>,0x00008800
; ret
;---------------------------------------------------------------------
include 'data.inc'
;---------------------------------------------------------------------
IM_END:
;---------------------------------------------------------------------
par:
params:
rb 1024
;---------------------------------------------------------------------
procinfo:
rb 1024
;---------------------------------------------------------------------
rb 1024
stacktop:
;---------------------------------------------------------------------
I_END: