MADMOUSE v0.2 - some optimizations.

git-svn-id: svn://kolibrios.org@2726 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Marat Zakiyanov (Mario79) 2012-06-03 13:55:55 +00:00
parent f6aaf4294f
commit 5b05341aae
4 changed files with 151 additions and 140 deletions

View File

@ -1,140 +0,0 @@
;
; Mad Mouse
; €¢â®à í⮣® 㦠᭮ áâ६­®£® ª®¤ : Sourcerer, 23.04.2010
; popovpa (29.05.2012)
; 1. ˆ§¬¥­¥­¨¥ «®£¨ª¨ à ¡®âë ¯à®£à ¬¬ë.
; 2. „®¡ ¢«¥­® "¯¥à¥áª ª¨¢ ­¨¥" ᢥàåã ¨ ­¨§ã :)
; 3. Ž¯â¨¬¨§ æ¨ï ª®¤ .
;
use32 ; âà ­á«ïâ®à, ¨á¯®«ì§ãî騩 32-å à §àï¤­ë¥ ª®¬ ­¤ë
org 0x0 ; ¡ §®¢ë©  ¤à¥á ª®¤ , ¢á¥£¤  0x0
db 'MENUET01' ; 1. ¨¤¥­â¨ä¨ª â®à ¨á¯®«­ï¥¬®£® ä ©«  (8 ¡ ©â)
dd 0x01 ; 2. ¢¥àá¨ï ä®à¬ â  § £®«®¢ª  ¨á¯®«­ï¥¬®£® ä ©« 
dd START ; 3.  ¤à¥á, ­  ª®â®àë© á¨á⥬  ¯¥à¥¤ ñâ ã¯à ¢«¥­¨¥
; ¯®á«¥ § £à㧪¨ ¯à¨«®¦¥­¨ï ¢ ¯ ¬ïâì
dd I_END ; 4. à §¬¥à ¯à¨«®¦¥­¨ï
dd 0x100000 ; 5. ®¡êñ¬ ­¥®¡å®¤¨¬®© ¯à¨«®¦¥­¨î ¯ ¬ïâ¨
; ¬®¦­® ®¡à é âìáï ª ¯ ¬ï⨠¢ ¤¨ ¯ §®­¥ ®â 0x0
; ¤® §­ ç¥­¨ï, ®¯à¥¤¥«ñ­­®£® §¤¥áì
dd 0x100000 ; 6. ¢¥à設  á⥪  ¢ ¤¨ ¯ §®­¥ ¯ ¬ïâ¨, 㪠§ ­­®¬ ¢ëè¥
dd 0x0 ; 7. 㪠§ â¥«ì ­  áâபã á ¯ à ¬¥âà ¬¨.
; ¥á«¨ ¯®á«¥ § ¯ã᪠ ­¥à ¢­® ­ã«î, ¯à¨«®¦¥­¨¥ ¡ë«®
; § ¯ã饭® á ¯ à ¬¥âà ¬¨ ¨§ ª®¬ ­¤­®© áâப¨
dd 0x0 ; 8. 㪠§ â¥«ì ­  áâபã, ¢ ª®â®àãî § ¯¨á ­ ¯ãâì,
; ®âªã¤  § ¯ã饭® ¯à¨«®¦¥­¨¥
;---------------------------------------------------------------------
;--- <20>€—€Ž <20><>Žƒ<C5BD>€ŒŒ ----------------------------------------------
;---------------------------------------------------------------------
START: ; ¤à¥á ­ ç «  ¯à®£à ¬¬ë
mov eax,14 ;äã­ªæ¨ï 14 - ¯®«ãç¨âì à §¬¥à íªà ­ 
int 0x40
mov ebx,eax
shl ebx,16
shr ebx,16
mov edi,ebx ;á®åà ­¨¬ ã
shr eax,16 ;ᤢ¨£ ¥¬ eax ¢¯à ¢® ­  16 - ¯®«ãç ¥¬ x
mov esi,eax ;á®åà ­¨¬ x
;---------------------------------------------------------------------
;--- –ˆŠ‹ Ž<><C5BD><EFBFBD>ŽŠˆ Ž<E28098>ˆ‰ ----------------------------------------
;---------------------------------------------------------------------
still:
;®à£ ­¨§ã¥¬ ¯ ã§ã ¢ 100 ¬á
mov eax,5 ;äã­ªæ¨ï 5 - ¯ ã§ , ¢ ebx ¢à¥¬ï ¢ ¬á
mov ebx,1 ;§ ¤¥à¦ª  100 ¬á
int 0x40
;¯®«ãç ¥¬ ª®®à¤¨­ âë ªãàá®à 
mov eax,37 ;äã­ªæ¨ï 37 - à ¡®â  á ¬ëèìî
xor ebx,ebx ;¯®¤äãªæ¨ï 0 - ª®®à¤¨­ âë ¬ëè¨
;®â­®á¨â¥«ì­® íªà ­ 
int 0x40
mov ebx,eax ;§ ¯®¬¨­ ¥¬ ª®®à¤¨­ âë
shr eax,16 ;⥯¥àì ã ­ á ⮫쪮 x. ­ã¦¥­ ¨ y
mov ecx,eax ;§ ¯®¬¨­ ¥¬ x
shl ebx,16 ;ᤢ¨­¥¬ ¢«¥® ­  16
shr ebx,16 ;ᤢ¨­¥¬¢ ¯à ¢® ­  16, ã ­ á ¥áâì ã
;------------------------------------------------------------------------------
;¢ esi ¨ edi ª®®à¤¨­ âë à §¬¥à  íªà ­  X ¨ Y ᮮ⢥âᢥ­­®
;¢ ecx ¨ ebx ª®®à¤¨­ âë ªãàá®à  X ¨ Y ᮮ⢥⢥­­®
;------------------------------------------------------------------------------
;áà ¢­¥­¨¥ ª®®à¤¨­ â x
test ecx,ecx ;à ¢­  0?
jz left_border ;¯¥à¥å®¤ ª ®¡à ¡®âª¥ ã «¥¢®£® ªà ï
cmp ecx,esi ;à ¢­  è¨à¨­¥ íªà ­ ?
jz right_border ;¯¥à¥å®¤¨¬ ª ®¡à ¡®âª¥ 㠯ࠢ®£® ªà ï
;áà ¢­¥­¨¥ ª®®à¤¨­ â y
test ebx,ebx ;à ¢­  0?
jz top_border ;¥á«¨ ¤  §­ ç¨â ªãàá®à ¢¢¥àåã
cmp ebx,edi ;à ¢­  ¢ëá®â¥ íªà ­ ?
jz bottom_border ;¯¥à¥å®¤ ª ®¡à ¡®âª¥ ã ­¨¦­¥£® ªà ï
jmp still ;¨­ ç¥ ­¨ç¥£® ¤¥« âì ­¥ ­ã¦­®
left_border:
mov edx,esi ;¢ edx ¨¬¥¥¬ è¨à¨­ã íªà ­ 
dec edx ;㬥­ì訬 ­  1
shl edx,16 ;⥯¥àì edx=(x-1)*65536
add edx,ebx ;  ⥯¥àì edx=(x-1)*65536+y
mov eax,18 ;äã­ªæ¨ï 18: ãáâ ­®¢¨âì ­ áâனª¨ ¬ëè¨
mov ebx,19 ;¯®¤äã­ªæ¨ï 19
mov ecx,4 ;¯®¤¯®¤äã­ªæ¨ï 4: ãáâ ­®¢¨âì ¯®«®¦¥­¨¥
;ªãàá®à 
int 0x40
jmp still ;®â¤ëå ¥¬
right_border: ;ªãàá®à 㠯ࠢ®£® ªà ï
xor edx,edx
inc edx ;edx=1
shl edx,16 ;edx = 1*65536
add edx,ebx ;edx=1*65536+y
mov eax,18 ;äã­ªæ¨ï 18: ãáâ ­®¢¨âì ­ áâனª¨ ¬ëè¨
mov ebx,19 ;¯®¤äã­ªæ¨ï 19
mov ecx,4 ;¯®¤¯®¤äã­ªæ¨ï 4: ãáâ ­®¢¨âì ¯®«®¦¥­¨¥
;ªãàá®à 
int 0x40
jmp still ;®â¤ëå ¥¬
top_border: ;ªãàá®à ã ¢¥àå­¥£® ªà ï
mov edx,ecx ;• ª®®à¤¨­ â  ªãàá®à 
shl edx,16 ;⥯¥àì edx=(x)*65536
add edx,edi ;  ⥯¥àì edx=(x)*65536+y
dec edx ;  ⥯¥àì edx=(x)*65536+(ã-1)
mov eax,18 ;äã­ªæ¨ï 18: ãáâ ­®¢¨âì ­ áâனª¨ ¬ëè¨
mov ebx,19 ;¯®¤äã­ªæ¨ï 19
mov ecx,4 ;¯®¤¯®¤äã­ªæ¨ï 4: ãáâ ­®¢¨âì ¯®«®¦¥­¨¥
;ªãàá®à 
int 0x40
jmp still ;¨ ®â¤ëå ¥¬
bottom_border: ;ªãàá®à ã ­¨¦­¥£® ªà ï
mov edx,ecx ;edx=ecx x ª®®à¤¨­ â  ªãàá®à 
shl edx,16 ;edx = å*65536
;ã ª®®à¤¨­ â  à ¢­  0
mov eax,18 ;äã­ªæ¨ï 18: ãáâ ­®¢¨âì ­ áâனª¨ ¬ëè¨
mov ebx,19 ;¯®¤äã­ªæ¨ï 19
mov ecx,4 ;¯®¤¯®¤äã­ªæ¨ï 4: ãáâ ­®¢¨âì ¯®«®¦¥­¨¥
;ªãàá®à 
int 0x40
jmp still ;¨ ®â¤ëå ¥¬
I_END: ; ¬¥âª  ª®­æ  ¯à®£à ¬¬ë

View File

@ -0,0 +1,3 @@
@fasm -m 16384 madmouse.asm madmouse
@kpack madmouse
@pause

View File

@ -0,0 +1,11 @@
#!/bin/bash
# This script does for linux the same as build.bat for DOS,
# it compiles the KoOS program, hopefully ;-)
fasm -m 16384 madmouse.asm madmouse
kpack madmouse
exit 0

View File

@ -0,0 +1,137 @@
;------------------------------------------------------------------------------
; Mad Mouse
;---------------------------------------------------------------------
; version: 0.2
; last update: 03/06/2012
; changed by: Marat Zakiyanov aka Mario79, aka Mario
; changes: Some optimizations.
;---------------------------------------------------------------------
; €¢â®à í⮣® 㦠᭮ áâ६­®£® ª®¤ : Sourcerer, 23.04.2010
; popovpa (29.05.2012)
; 1. ˆ§¬¥­¥­¨¥ «®£¨ª¨ à ¡®âë ¯à®£à ¬¬ë.
; 2. „®¡ ¢«¥­® "¯¥à¥áª ª¨¢ ­¨¥" ᢥàåã ¨ ­¨§ã :)
; 3. Ž¯â¨¬¨§ æ¨ï ª®¤ .
;------------------------------------------------------------------------------
use32 ; âà ­á«ïâ®à, ¨á¯®«ì§ãî騩 32-å à §àï¤­ë¥ ª®¬ ­¤ë
org 0x0 ; ¡ §®¢ë©  ¤à¥á ª®¤ , ¢á¥£¤  0x0
db 'MENUET01' ; 1. ¨¤¥­â¨ä¨ª â®à ¨á¯®«­ï¥¬®£® ä ©«  (8 ¡ ©â)
dd 0x01 ; 2. ¢¥àá¨ï ä®à¬ â  § £®«®¢ª  ¨á¯®«­ï¥¬®£® ä ©« 
dd START ; 3.  ¤à¥á, ­  ª®â®àë© á¨á⥬  ¯¥à¥¤ ñâ ã¯à ¢«¥­¨¥
; ¯®á«¥ § £à㧪¨ ¯à¨«®¦¥­¨ï ¢ ¯ ¬ïâì
dd IM_END ; 4. à §¬¥à ¯à¨«®¦¥­¨ï
dd I_END ; 5. ®¡êñ¬ ­¥®¡å®¤¨¬®© ¯à¨«®¦¥­¨î ¯ ¬ïâ¨
; ¬®¦­® ®¡à é âìáï ª ¯ ¬ï⨠¢ ¤¨ ¯ §®­¥ ®â 0x0
; ¤® §­ ç¥­¨ï, ®¯à¥¤¥«ñ­­®£® §¤¥áì
dd stack_area ; 6. ¢¥à設  á⥪  ¢ ¤¨ ¯ §®­¥ ¯ ¬ïâ¨, 㪠§ ­­®¬ ¢ëè¥
dd 0x0 ; 7. 㪠§ â¥«ì ­  áâபã á ¯ à ¬¥âà ¬¨.
; ¥á«¨ ¯®á«¥ § ¯ã᪠ ­¥à ¢­® ­ã«î, ¯à¨«®¦¥­¨¥ ¡ë«®
; § ¯ã饭® á ¯ à ¬¥âà ¬¨ ¨§ ª®¬ ­¤­®© áâப¨
dd 0x0 ; 8. 㪠§ â¥«ì ­  áâபã, ¢ ª®â®àãî § ¯¨á ­ ¯ãâì,
; ®âªã¤  § ¯ã饭® ¯à¨«®¦¥­¨¥
;------------------------------------------------------------------------------
; ¬ ªà®áë ®¡«¥£ç îâ ¦¨§­ì ¯à®£à ¬¬¨áâ 
include '../../macros.inc'
;------------------------------------------------------------------------------
;--- <20>€—€Ž <20><>Žƒ<C5BD>€ŒŒ ----------------------------------------------
;------------------------------------------------------------------------------
START: ; ¤à¥á ­ ç «  ¯à®£à ¬¬ë
mov eax,40 ;ãáâ ­®¢¨âì ¬ áªã ¤«ï ®¦¨¤ ¥¬ëå ᮡë⨩.
mov ebx,100000b ;­ã¦­® ⮫쪮 ᮡë⨥ ¬ëè¨
int 0x40
;------------------------------------------------------------------------------
;--- –ˆŠ‹ Ž<><C5BD><EFBFBD>ŽŠˆ Ž<E28098>ˆ‰ ----------------------------------------
;------------------------------------------------------------------------------
align 4
still:
mov eax,10 ;®¦¨¤ âì ᮡë⨩
int 0x40
mov eax,14 ;äã­ªæ¨ï 14 - ¯®«ãç¨âì à §¬¥à íªà ­ 
int 0x40 ;¢ë§®¢ ä.14 ¢ 横«¥ ¯®â®¬ã çâ® ¬®¦¥â
;¯®¬¥­ïâìáï à §à¥è¥­¨¥ íªà ­ 
mov ebx,eax
shl ebx,16
shr ebx,16
mov edi,ebx ;á®åà ­¨¬ ã
shr eax,16 ;ᤢ¨£ ¥¬ eax ¢¯à ¢® ­  16 - ¯®«ãç ¥¬ x
mov esi,eax ;á®åà ­¨¬ x
;¯®«ãç ¥¬ ª®®à¤¨­ âë ªãàá®à 
mov eax,37 ;äã­ªæ¨ï 37 - à ¡®â  á ¬ëèìî
xor ebx,ebx ;¯®¤äãªæ¨ï 0 - ª®®à¤¨­ âë ¬ëè¨
;®â­®á¨â¥«ì­® íªà ­ 
int 0x40
mov ebx,eax ;§ ¯®¬¨­ ¥¬ ª®®à¤¨­ âë
shr eax,16 ;⥯¥àì ã ­ á ⮫쪮 x. ­ã¦¥­ ¨ y
mov ecx,eax ;§ ¯®¬¨­ ¥¬ x
shl ebx,16 ;ᤢ¨­¥¬ ¢«¥® ­  16
shr ebx,16 ;ᤢ¨­¥¬¢ ¯à ¢® ­  16, ã ­ á ¥áâì ã
;------------------------------------------------------------------------------
;¢ esi ¨ edi ª®®à¤¨­ âë à §¬¥à  íªà ­  X ¨ Y ᮮ⢥âᢥ­­®
;¢ ecx ¨ ebx ª®®à¤¨­ âë ªãàá®à  X ¨ Y ᮮ⢥⢥­­®
;------------------------------------------------------------------------------
;áà ¢­¥­¨¥ ª®®à¤¨­ â x
test ecx,ecx ;à ¢­  0?
jz left_border ;¯¥à¥å®¤ ª ®¡à ¡®âª¥ ã «¥¢®£® ªà ï
cmp ecx,esi ;à ¢­  è¨à¨­¥ íªà ­ ?
jz right_border ;¯¥à¥å®¤¨¬ ª ®¡à ¡®âª¥ 㠯ࠢ®£® ªà ï
;áà ¢­¥­¨¥ ª®®à¤¨­ â y
test ebx,ebx ;à ¢­  0?
jz top_border ;¥á«¨ ¤  §­ ç¨â ªãàá®à ¢¢¥àåã
cmp ebx,edi ;à ¢­  ¢ëá®â¥ íªà ­ ?
jz bottom_border ;¯¥à¥å®¤ ª ®¡à ¡®âª¥ ã ­¨¦­¥£® ªà ï
jmp still ;¨­ ç¥ ­¨ç¥£® ¤¥« âì ­¥ ­ã¦­®
;------------------------------------------------------------------------------
align 4
left_border:
mov edx,esi ;¢ edx ¨¬¥¥¬ è¨à¨­ã íªà ­ 
dec edx ;㬥­ì訬 ­  1
shl edx,16 ;⥯¥àì edx=(x-1)*65536
add edx,ebx ;  ⥯¥àì edx=(x-1)*65536+y
;------------------------------------------------------------------------------
align 4
set_mouse_position:
mov eax,18 ;äã­ªæ¨ï 18: ãáâ ­®¢¨âì ­ áâனª¨ ¬ëè¨
mov ebx,19 ;¯®¤äã­ªæ¨ï 19
mov ecx,4 ;¯®¤¯®¤äã­ªæ¨ï 4: ãáâ ­®¢¨âì ¯®«®¦¥­¨¥
;ªãàá®à 
int 0x40
jmp still ;®â¤ëå ¥¬
;------------------------------------------------------------------------------
align 4
right_border: ;ªãàá®à 㠯ࠢ®£® ªà ï
xor edx,edx
inc edx ;edx=1
shl edx,16 ;edx = 1*65536
add edx,ebx ;edx=1*65536+y
jmp set_mouse_position
;------------------------------------------------------------------------------
align 4
top_border: ;ªãàá®à ã ¢¥àå­¥£® ªà ï
mov edx,ecx ;• ª®®à¤¨­ â  ªãàá®à 
shl edx,16 ;⥯¥àì edx=(x)*65536
add edx,edi ;  ⥯¥àì edx=(x)*65536+y
dec edx ;  ⥯¥àì edx=(x)*65536+(ã-1)
jmp set_mouse_position
;------------------------------------------------------------------------------
align 4
bottom_border: ;ªãàá®à ã ­¨¦­¥£® ªà ï
mov edx,ecx ;edx=ecx x ª®®à¤¨­ â  ªãàá®à 
shl edx,16 ;edx = å*65536
;ã ª®®à¤¨­ â  à ¢­  0
jmp set_mouse_position
;------------------------------------------------------------------------------
IM_END: ; ¬¥âª  ª®­æ  ª®¤ 
;------------------------------------------------------------------------------
align 4
rb 1024
stack_area:
;------------------------------------------------------------------------------
I_END: ; ¬¥âª  ª®­æ  ¯à®£à ¬¬ë
;------------------------------------------------------------------------------