Optimized FIRE2 program: code size 684->511, now it fits in one sector;

memory requirements 1Mb -> 200Kb.


git-svn-id: svn://kolibrios.org@80 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Evgeny Grechnikov (Diamond) 2006-05-17 13:43:20 +00:00
parent 65a732dc5a
commit cb6852bc2c

View File

@ -1,185 +1,166 @@
use32 use32
org 0x0 org 0x0
db 'MENUET01' db 'MENUET01'
dd 0x01 dd 0x01
dd START dd START
dd I_END dd I_END
dd 0x100000 dd mem_end
dd 0x7fff0 dd mem_end
dd 0x0, 0x0 dd 0x0, 0x0
include 'lang.inc' ;include 'lang.inc'
START: START:
call draw_window mov edi, my_img
mov ecx, 64001*3/4+1
xor eax, eax
rep stosd
mov edi,my_img mov al, 3
mov ecx,64001*3/4 int 0x40
xor eax,eax mov [curtime], eax
rep stosd
mov esi,my_img red:
mov [count1],esi push 12
pop eax
push 1
pop ebx
int 0x40
mov eax,3 xor eax, eax
int 0x40 mov ebx, 200*65536+325
mov [curtime],eax mov ecx, 150*65536+225
xor edx, edx
xor esi, esi
mov edi, 0x00100000
int 0x40
mov al, 8
mov ebx, (325-19)*65536+12
mov ecx, 5*65536+12
inc edx
mov esi, 0x00400000
int 0x40
mov al, 4
mov ebx, 8*65536+8
mov ecx, 0x00FFFFFF;0x00402020
mov edx, fire_label
push len00
pop esi
int 0x40
mov al, 12
push 2
pop ebx
int 0x40
still: still:
mov eax,11 push 11
int 0x40 pop eax
int 0x40
cmp eax,1 dec eax
je red jz red
cmp eax,2 dec eax
je key jz key
cmp eax,3 dec eax
je button jz button
call image
mov eax,3
int 0x40
mov ebx,[curtime]
cmp eax,ebx
jz still
mov [curtime],eax
call print_fps
jmp still
red: call image
call draw_window push 3
jmp still pop eax
int 0x40
cmp eax, [curtime]
jz still
mov [curtime], eax
print_fps:
push 13
pop eax
mov ebx, (8+27*6)*65536+18
mov ecx, 8*65536+8
xor edx, edx
int 0x40
lea edx, [ebx-10]
mov al, 47
mov ebx, 30000h
xor ecx, ecx
xchg ecx, [fps]
mov esi, 0x00FFFFFF ;0x00400000
int 0x40
jmp still
key: key:
mov eax,2 mov al, 2
int 0x40 int 0x40
cmp ah,1 cmp ah, 1Bh ;<Esc>
jne still jne still
mov eax,0xffffffff
int 0x40
jmp still
button: button:
mov eax,17 ; we have only one button, close
int 0x40 or eax, -1
int 0x40
cmp ah,1 image:
jne still
mov eax,-1
int 0x40
retn
;Window
draw_window:
mov eax,12
mov ebx,1
int 0x40
mov eax,0
mov ebx,200*65536+325
mov ecx,150*65536+225
mov edx,0x00000000
mov esi,edx
mov edi,0x00100000
int 0x40
mov eax,4
mov ebx,8*65536+8
mov ecx,0x00402020
mov edx,fire_label
mov esi,len00
int 0x40
mov eax,8
mov ebx,(325-19)*65536+12
mov ecx,5*65536+12
mov edx,1
mov esi,0x00400000
int 0x40
mov eax,12
mov ebx,2
int 0x40
retn
penta:
; <20>¨á㥬 ¯¥­â £p ¬¬ã ; <20>¨á㥬 ¯¥­â £p ¬¬ã
penta:
mov edi,my_img mov edi,my_img+0x540*3
mov ebx,(320)*3 mov ebx,(320)*3
DrawP: mov eax,0x00fc0000 mov eax,0x00fc0000
add edi,0x540*3
push edi push edi
mov ecx,0x78 push 0x78
ll_3: mov [edi],eax pop ecx
mov [edi+3],eax ll_3:
mov [edi-3],eax call put_big_point
mov [edi+ebx],eax lea edi, [edi+ebx+6]
add edi,6 loop ll_3
add edi,ebx
loop ll_3
pop edi pop edi
mov ecx,0x60 mov cl, 0x60
ll_4: mov [ebx+edi],eax ll_4:
mov [edi],eax call put_big_point
mov [edi+3],eax lea edi, [edi+ebx*2+3]
mov [edi-3],eax
add edi,3
add edi,ebx
add edi,ebx
loop ll_4 loop ll_4
mov ecx,0x61 mov cl, 0x61
ll_5: mov [ebx+edi],eax ll_5:
mov [edi],eax call put_big_point
mov [edi+3],eax sub edi, 2*320*3-3
mov [edi-3],eax
add edi,3
sub edi,ebx
sub edi,ebx
loop ll_5 loop ll_5
add edi,0x98D1*3 mov edi, my_img+0x1D4F6
push edi push edi
mov ecx,0x78 mov cl, 0x78
ll_6: mov [edi],eax ll_6:
mov [edi+ebx],eax call put_big_point
mov [edi+3],eax
mov [edi-3],eax
add edi,6 add edi,6
sub edi,ebx sub edi,ebx
loop ll_6 loop ll_6
pop edi pop edi
mov ecx,0x8F*2 mov ecx,0x8F*2
ll_7: mov [edi],eax ll_7: stosd
mov [edi+ebx],eax mov [edi+ebx-4],eax
add edi,3 dec edi
loop ll_7 loop ll_7
retn
fire: fire:
; _HˆŒ€Hˆ…_! ‡¤¥áì á ¬®¥ ¨­â¥p¥á­®¥. ; _HˆŒ€Hˆ…_! ‡¤¥áì á ¬®¥ ¨­â¥p¥á­®¥.
; €«£®p¨â¬ £®p¥­¨ï. ; €«£®p¨â¬ £®p¥­¨ï.
mov esi,[count1] mov esi,[count1]
mov edx,[count2] mov edx,[count2]
mov ebx,320*3 mov ecx, 10000h
mov ecx,0xffff
Flame: cmp esi,0xFA00*3+my_img ; <20>ᥢ¤®á«ãç ©­ ï â®çª  ¢ ¯p¥¤ « å íªp Flame: cmp esi,0xFA00*3+my_img ; <20>ᥢ¤®á«ãç ©­ ï â®çª  ¢ ¯p¥¤ « å íªp
jae NxtP ; ¥á«¨ H… - ¡¥p¥¬ á«¥¤ãîéãî. jae NxtP ; ¥á«¨ H… - ¡¥p¥¬ á«¥¤ãîéãî.
lodsd lodsd
dec esi ; ‘ç¨â뢠¥¬ ¥¥ 梥â. dec esi ; ‘ç¨â뢠¥¬ ¥¥ 梥â.
and eax,0x00ff0000 ; and eax,0x00ff0000
test eax, eax
; ’®çª  ç¥p­ ï? (£®p¥âì ­¥ç¥¬ã?) ; ’®çª  ç¥p­ ï? (£®p¥âì ­¥ç¥¬ã?)
jz NxtP ; ¥á«¨ „€ - ¡¥p¥¬ á«¥¤ãîéãî. jz NxtP ; ¥á«¨ „€ - ¡¥p¥¬ á«¥¤ãîéãî.
sub eax,0x00040000 sub eax,0x00040000
; –¢¥â®¬ ­  ¥¤¨­¨æã ¬¥­ì訬 ; –¢¥â®¬ ­  ¥¤¨­¨æã ¬¥­ì訬
mov [esi-2*3],eax ; áâ ¢¨¬ â®çªã á«¥¢ , mov [esi-2*3],eax ; áâ ¢¨¬ â®çªã á«¥¢ ,
mov [esi],eax ; á¯p ¢ , mov [esi],eax ; á¯p ¢ ,
mov [ebx+esi-1*3],eax ; á­¨§ã mov [320*3+esi-1*3],eax ; á­¨§ã
mov [esi-0x141*3],eax ; ¨ ᢥpåã. mov [esi-0x141*3],eax ; ¨ ᢥpåã.
NxtP: NxtP:
add esi,edx add esi,edx
@ -187,7 +168,7 @@ NxtP:
jbe loc_cont jbe loc_cont
sub esi,0xfffe*3 sub esi,0xfffe*3
loc_cont: loc_cont:
; <20>¥p¥¬ á«¥¤ãîéãî ; <20>¥p¥¬ á«¥¤ãîéãî
add edx,3 add edx,3
cmp edx,0x10000*3 cmp edx,0x10000*3
jbe loc_cont2 jbe loc_cont2
@ -197,50 +178,42 @@ loc_cont2:
;jnz Flame ; ˆ â ª 65536 p §. ;jnz Flame ; ˆ â ª 65536 p §.
loop Flame loop Flame
mov [count1],esi mov [count1],esi
mov [count2],edx mov [count2],edx
retn
image:
call penta
call fire
mov ebx,my_img mov ebx,my_img
mov ecx,320*65536+200 mov ecx,320*65536+200
mov edx,2*65536+23 mov edx,2*65536+23
mov eax,7 push 7
pop eax
int 0x40 int 0x40
inc [fps] inc [fps]
retn retn
print_fps: put_big_point:
mov eax,13 mov [edi], eax
mov ebx,(8+27*6)*65536+18 mov [edi+3], eax
mov ecx,8*65536+8 mov [edi-3], eax
mov edx,0x00000000 mov [edi+ebx], eax
int 0x40 ret
mov eax,47
xor ebx,ebx
mov bx,3
shl ebx,16
mov ecx,[fps]
mov edx,(8+27*6)*65536+8
mov esi,0x00400000
int 0x40
xor eax,eax
mov [fps],eax
retn
;DATA ;DATA
align 4
count1 dd 0 count1 dd my_img
count2 dd 0 count2 dd 0
curtime dd 0 curtime dd 0
fps dd 0 fps dd 0
fire_label db 'Pentagramm in FIRE FPS:' fire_label db 'Pentagramm in FIRE FPS:'
len00=$-fire_label len00=$-fire_label
org 320*3*2
my_img:
I_END: I_END:
align 16
rb 320*3
my_img rb 320*200*3
rb 320*3
; stack
align 256
rb 256
mem_end: