Clicks 0.76 (optimizations)

git-svn-id: svn://kolibrios.org@1006 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2009-01-28 15:20:29 +00:00
parent 9166e950b4
commit ba74256d24
2 changed files with 68 additions and 89 deletions

View File

@ -1,5 +1,5 @@
/* /*
Just Clicks v0.75 Just Clicks v0.76
Copyright (C) 2008 Leency Copyright (C) 2008 Leency
Clickomania v0.3 Clickomania v0.3
Copyright (C) 2005 <20><><EFBFBD><EFBFBD><EFBFBD> <20>竏┴<E7AB8F> aka Olaf Copyright (C) 2005 <20><><EFBFBD><EFBFBD><EFBFBD> <20>竏┴<E7AB8F> aka Olaf
@ -25,35 +25,30 @@ struct
}matrix[64]; }matrix[64];
void check_n_destroy(byte ID, ID1)
{
IF (matrix[ID1].color == matrix[ID].color) && (matrix[ID1].mark!=1)
{
matrix[ID1].mark=1;
destroy_button(ID1);
}
}
void destroy_button(byte ID) void destroy_button(byte ID)
{ {
IF (matrix[ID-8].color == matrix[ID].color) && (matrix[ID-8].mark!=1) check_n_destroy(ID, ID-8);
{ check_n_destroy(ID, ID+8);
matrix[ID-8].mark=1; IF (ID!=0)&&(ID!=8)&&(ID!=16)&&(ID!=24)&&(ID!=32)&&(ID!=40)&&(ID!=48)&&(ID!=56)
destroy_button(ID-8); check_n_destroy(ID, ID-1);
} IF (ID!=7)&&(ID!=15)&&(ID!=23)&&(ID!=31)&&(ID!=39)&&(ID!=47)&&(ID!=55)&&(ID!=63)
IF (matrix[ID+8].color == matrix[ID].color) && (matrix[ID+8].mark!=1) check_n_destroy(ID, ID+1);
{
matrix[ID+8].mark=1;
destroy_button(ID+8);
}
IF (ID!=0)&&(ID!=8)&&(ID!=16)&&(ID!=24)&&(ID!=32)&&(ID!=40)&&(ID!=48)&&(ID!=56)
&& (matrix[ID-1].color == matrix[ID].color) && (matrix[ID-1].mark!=1)
{
matrix[ID-1].mark=1;
destroy_button(ID-1);
}
IF (ID!=7)&&(ID!=15)&&(ID!=23)&&(ID!=31)&&(ID!=39)&&(ID!=47)&&(ID!=55)&&(ID!=63)
&& (matrix[ID+1].color == matrix[ID].color) && (matrix[ID+1].mark!=1)
{
matrix[ID+1].mark=1;
destroy_button(ID+1);
}
IF (matrix[ID].x<XX) {XX=matrix[ID].x; IF (matrix[ID].y>YY) YY=matrix[ID].y;} IF (matrix[ID].x<XX) {XX=matrix[ID].x; IF (matrix[ID].y>YY) YY=matrix[ID].y;}
IF (matrix[ID].y>YY) {YY=matrix[ID].y; IF (matrix[ID].x<XX) XX=matrix[ID].x;} IF (matrix[ID].y>YY) {YY=matrix[ID].y; IF (matrix[ID].x<XX) XX=matrix[ID].x;}
} }
void shift_bars(byte AA, BB) void shift_bars(byte AA, BB)
byte id_curr,id_next,bz; byte id_curr,id_next,bz;
{ {
@ -128,22 +123,22 @@ void ReDraw_Blocks(byte newgame)
matrix[num].y=i; matrix[num].y=i;
IF (matrix[num].mark==0) IF (matrix[num].mark==0)
{ {
DefineButton(j*21+5,y-22, 20, 20, num+BT_HIDE, 0); DefineButton(j*21,y-22, 20, 20, num+BT_HIDE, 0);
PutImage(matrix[num].color-1*1323+#img,21,21,j*21+5,y-22); PutImage(matrix[num].color-1*1323+#img,21,21,j*21,y-22);
} ELSE DrawBar(j*21+5,y-22,21,21, 0xB2B4BF); } ELSE DrawBar(j*21,y-22,21,21, 0xB2B4BF);
num++; num++;
} }
y=y+21; y=y+21;
} }
DrawBar(95,178,71,8,0xE4DFE1); DrawBar(90,178,71,8,0xE4DFE1);
IF (check_for_end()==1) WriteText(95,178,0x80,0,"<22>¥§ã«ìâ â:",10); IF (check_for_end()==1) WriteText(90,178,0x80,0,"<22>¥§ã«ìâ â:",10);
ELSE WriteText(101,178,0x80,0,"Žáâ «®áì:",10); ELSE WriteText(96,178,0x80,0,"Žáâ «®áì:",10);
FOR (i=0;i<8;i++) FOR (j=0;j<8;j++) IF (matrix[j*8+i].mark==0) count_blocks++; FOR (i=0;i<8;i++) FOR (j=0;j<8;j++) IF (matrix[j*8+i].mark==0) count_blocks++;
WriteText(155,178,0x80,0,IntToStr(count_blocks),0); WriteNumber(150,178,0x80,0,count_blocks);
// //
if (check_for_end()==1) && (count_blocks<8) if (check_for_end()==1) && (count_blocks<8)
{ {
DrawFlatButton(26,42,125,62,0,0xE4DFE1,""); DrawFlatButton(21,42,125,62,0,0xE4DFE1,"");
IF (count_blocks==0) copystr(" <20>竍茱 ≡ュ!", #temp); IF (count_blocks==0) copystr(" <20>竍茱 ≡ュ!", #temp);
IF (count_blocks==1) copystr(" 踳<><E8B8B3><EFBFBD>", #temp); IF (count_blocks==1) copystr(" 踳<><E8B8B3><EFBFBD>", #temp);
IF (count_blocks==2) copystr("<22><EFBFBD> 絎牀莅!", #temp); IF (count_blocks==2) copystr("<22><EFBFBD> 絎牀莅!", #temp);
@ -152,46 +147,48 @@ void ReDraw_Blocks(byte newgame)
copystr(" <20><EFBFBD>絎", #temp); copystr(" <20><EFBFBD>絎", #temp);
count_blocks=3; count_blocks=3;
} }
PutImage(count_blocks*42*37*3+#cups,42,37,68,48); PutImage(count_blocks*42*37*3+#cups,42,37,63,48);
WriteText(51,91,0x80,0x0,#temp,0); WriteText(46,91,0x80,0x0,#temp,0);
} }
} }
void main() void main()
{ byte id; { byte id, skin_width;
randomize(); randomize();
ReDraw_Blocks(1); ReDraw_Blocks(1);
loop() loop()
{ {
switch(WaitEvent()) switch(WaitEvent())
{ {
CASE evKey: IF (GetKey()==051) ReDraw_Blocks(1); break; //New game CASE evKey:
IF (GetKey()==051) ReDraw_Blocks(1); //New game
break;
CASE evButton: CASE evButton:
id=GetButtonID(); id=GetButtonID();
IF (id==255) ExitProcess(); IF (id==255) ExitProcess();
IF (id==254) {ReDraw_Blocks(1); break;} //New game IF (id==254) ReDraw_Blocks(1); //New game
IF (id<65) IF (check_for_end()<>1) IF (id<65) //Color Button
{ //if Button {
destroy_button(id); destroy_button(id);
IF (XX!=9) IF (XX!=9)
{ {
shift_bars(XX,YY); shift_bars(XX,YY);
IF (YY == 7) {move_it();move_it();} IF (YY==7) {move_it();move_it();}
XX=9; XX=9;
YY=0; YY=0;
ReDraw_Blocks(0); ReDraw_Blocks(0);
}
break;
} }
}
break;
case evReDraw: case evReDraw:
WindowRedrawStatus(1); WindowRedrawStatus(1);
skin_width = GetSkinWidth(); skin_width = GetSkinWidth();
DefineAndDrawWindow(400,276,177,201+skin_width,0x44,0x10B2B4BF,0,0,"Just Clicks v0.75"); DefineAndDrawWindow(400,276,177,201+skin_width,0x74,0x10B2B4BF,0,0,"Just Clicks v0.76");
//DefineButton(155,2-skin_width,18,18,255+BT_HIDE+BT_NOFRAME,0x0866CC00); DefineButton(150,2-skin_width,18,18,255+BT_HIDE+BT_NOFRAME,0x0866CC00);
DrawBar(5,168,168,29,0xE4DFE1); DrawBar(0,168,168,29,0xE4DFE1);
//DrawFlatButton(9,172,84,19,254,0xE4DFE1,"New game (F2)"); //DrawFlatButton(9,172,84,19,254,0xE4DFE1,"New game (F2)");
DrawFlatButton(9,172,80,19,254,0xE4DFE1,"‡ ­®¢® (F2)"); DrawFlatButton(4,172,80,19,254,0xE4DFE1,"‡ ­®¢® (F2)");
ReDraw_Blocks(0); ReDraw_Blocks(0);
WindowRedrawStatus(2); WindowRedrawStatus(2);
} }

View File

@ -8,12 +8,10 @@ dword alloc_mem = 0x00100000;
dword x86esp_reg = 0x0007fff0; dword x86esp_reg = 0x0007fff0;
dword I_Param = 0x0; dword I_Param = 0x0;
dword I_Icon = 0x0; dword I_Icon = 0x0;
dword skin_width;
#define evButton 3 #define evButton 3
#define evKey 2 #define evKey 2
#define evReDraw 1 #define evReDraw 1
#define evNet 8
#define BT_DEL 0x80000000 #define BT_DEL 0x80000000
#define BT_HIDE 0x40000000 #define BT_HIDE 0x40000000
@ -86,14 +84,14 @@ void DefineButton(dword x,y,w,h,EDX,ESI)
{ {
EAX = 8; EAX = 8;
EBX = x<<16+w; EBX = x<<16+w;
ECX = skin_width+y<<16+h; ECX = y<<16+h;
$int 0x40 $int 0x40
} }
void WriteText(dword x,y,byte fontType, dword color, EDX, ESI) void WriteText(dword x,y,byte fontType, dword color, EDX, ESI)
{ {
EAX = 4; EAX = 4;
EBX = x<<16+skin_width+y; EBX = x<<16+y;
ECX = fontType<<24+color; ECX = fontType<<24+color;
$int 0x40; $int 0x40;
} }
@ -103,7 +101,7 @@ void DrawBar(dword x,y,w,h,EDX)
{ {
EAX = 13; EAX = 13;
EBX = x<<16+w; EBX = x<<16+w;
ECX = skin_width+y<<16+h; ECX = y<<16+h;
$int 0x40 $int 0x40
} }
@ -129,13 +127,11 @@ void DrawFlatButton(dword x,y,width,height,id,color,text)
} }
void PutImage(dword buf,w,h,x,y) void PutImage(dword EBX,w,h,x,y)
{ {
EDI=buf;
EAX = 7; EAX = 7;
EBX = buf;
ECX = w<<16+h; ECX = w<<16+h;
EDX = x<<16+y+skin_width; EDX = x<<16+y;
$int 0x40 $int 0x40
} }
@ -152,31 +148,17 @@ l1:
$jnz l1 $jnz l1
} }
void WriteNumber(dword x,y,byte fontType, ESI, ECX)
char buffer[11]="";
inline fastcall dword IntToStr(dword ESI)
{ {
$mov edi, #buffer EAX = 47;
$mov ecx, 10 EBX = 2<<16;
$test esi, esi /*ecx = 0
$jns f1 while(eax>10)
$mov al, '-' {
$stosb ecx ++;
$neg esi eax /= 10;
f1: }*/
$mov eax, esi EDX = x<<16+y;
$push -'0' ESI = fontType<<24+ESI;
f2: $int 0x40;
$xor edx, edx
$div ecx
$push edx
$test eax, eax
$jnz f2
f3:
$pop eax
$add al, '0'
$stosb
$jnz f3
$mov eax, #buffer
$ret
} }