/programs/games/kosilka/KosFile.h |
---|
12,15 → 12,15 |
{ |
public: |
CKosFile(char *fileName); |
virtual ~CKosFile(void); |
virtual int Read(Byte *targetPtr, int readCount); |
virtual int Write(Byte *sourcePtr, int writeCount); |
virtual int Seek(int seekFrom, int seekStep); |
~CKosFile(void); |
int Read(Byte *targetPtr, int readCount); |
int Write(Byte *sourcePtr, int writeCount); |
int Seek(int seekFrom, int seekStep); |
protected: |
int filePointer; |
int bufferPointer; |
bool validBuffer; |
kosFileInfo fileInfo; |
virtual void ValidateBuffer(void); |
virtual void UpdateBuffer(void); |
void ValidateBuffer(void); |
void UpdateBuffer(void); |
}; |
/programs/games/kosilka/compile.bat |
---|
1,5 → 1,3 |
cl /c /O2 /nologo kosilka.cpp kosFile.cpp kosSyst.cpp mcsmemm.cpp |
link /nologo /entry:crtStartUp /subsystem:native /base:0 /fixed /align:16 /nodefaultlib kosilka.obj kosFile.obj kosSyst.obj mcsmemm.obj |
pe2kos kosilka.exe kosilka |
del kosilka.exe |
pause |
cl /c /O2 /Ox /Os /GL /Gr /Oi /nologo /GS- /GR- kosilka.cpp kosFile.cpp kosSyst.cpp mcsmemm.cpp |
link /section:.bss,E /nologo /ltcg /map /entry:crtStartUp /subsystem:native /base:0 /fixed:no /nodefaultlib /merge:.data=.text /merge:.rdata=.text kosilka.obj kosFile.obj kosSyst.obj mcsmemm.obj |
fasm doexe2.asm kosilka |
/programs/games/kosilka/kosSyst.cpp |
---|
1,13 → 1,41 |
#include "kosSyst.h" |
#include <stdarg.h> |
char stack[16384]; |
char kosExePath[257]; |
struct __MENUET_header_t |
{ |
char signature[8]; |
unsigned version; |
void* entry; |
unsigned init_size; |
unsigned memsize; |
void* stackptr; |
void* command_line_ptr; |
void* app_path_ptr; |
}; |
__MENUET_header_t __MENUET_header = |
{ |
{'M','E','N','U','E','T','0','1'}, |
1, |
&crtStartUp, |
-1, |
-1, |
stack + sizeof(stack), |
NULL, |
&kosExePath |
}; |
#if 0 |
#define atexitBufferSize 32 |
#endif |
char pureCallMessage[] = "PURE function call!"; |
char *kosExePath = NULL; |
//char *kosExePath = NULL; |
#if 0 |
// |
void (__cdecl *atExitList[atexitBufferSize])(); |
int atExitFnNum = 0; |
26,8 → 54,8 |
return 1; |
} |
} |
#endif |
// |
Dword RandomSeed = 1; |
// |
341,8 → 369,9 |
// ôóíêöèÿ -1 çàâåðøåíèÿ ïðîöåññà |
void kos_ExitApp() |
void __declspec(noreturn) kos_ExitApp() |
{ |
#if 0 |
int i; |
// |
352,6 → 381,7 |
atExitList[i](); |
} |
// |
#endif |
__asm{ |
mov eax, -1 |
int 0x40 |
433,9 → 463,8 |
return ( result & 0xFF ) == 0; |
} |
// ôóíêöèÿ 3 ïîëó÷èòü âðåìÿ |
Dword kos_GetSystemClock() |
Dword __cdecl kos_GetSystemClock() |
{ |
// Dword result; |
449,7 → 478,7 |
// return result; |
} |
#if 0 |
// ôóíêöèÿ 4 |
void kos_WriteTextToWindow( |
Word x, |
475,10 → 504,29 |
int 0x40 |
} |
} |
#else |
// ôóíêöèÿ 4 |
void kos_WriteTextToWindow_internal( |
Dword pos, |
Dword font, |
const char *textPtr, |
Dword textLen |
) |
{ |
__asm{ |
mov eax, 4 |
mov ebx, pos |
mov ecx, font |
mov edx, textPtr |
mov esi, textLen |
int 0x40 |
} |
} |
#endif |
// ôóíêöèÿ 5 ïàóçà, â ñîòûõ äîëÿõ ñåêóíäû |
void kos_Pause( Dword value ) |
void __cdecl kos_Pause( Dword value ) |
{ |
// |
__asm{ |
548,7 → 596,7 |
// ôóíêöèÿ 10 |
Dword kos_WaitForEvent() |
Dword __cdecl kos_WaitForEvent() |
{ |
// Dword result; |
578,7 → 626,7 |
// ôóíêöèÿ 12 |
void kos_WindowRedrawStatus( Dword status ) |
void __cdecl kos_WindowRedrawStatus( Dword status ) |
{ |
__asm{ |
mov eax, 12 |
606,7 → 654,6 |
} |
} |
// ôóíêöèÿ 17 |
bool kos_GetButtonID( Dword &buttonID ) |
{ |
626,7 → 673,7 |
// ôóíêöèÿ 23 |
Dword kos_WaitForEvent( Dword timeOut ) |
Dword __cdecl kos_WaitForEvent( Dword timeOut ) |
{ |
// Dword result; |
724,7 → 771,7 |
// ôóíêöèÿ 70 äîñòóï ê ôàéëîâîé ñèñòåìå |
Dword kos_FileSystemAccess( kosFileInfo *fileInfo ) |
Dword __fastcall kos_FileSystemAccess( kosFileInfo *fileInfo ) |
{ |
// Dword result; |
731,7 → 778,7 |
// |
__asm{ |
mov eax, 70 |
mov ebx, fileInfo |
mov ebx, ecx //fileInfo |
int 0x40 |
// mov result, eax |
} |
741,13 → 788,13 |
// ôóíêöèÿ 63 âûâîä ñèìâîëÿ â îêíî îòëàäêè |
void kos_DebugOutChar( char ccc ) |
void __fastcall kos_DebugOutChar( char ccc ) |
{ |
// |
__asm{ |
mov eax, 63 |
mov ebx, 1 |
mov cl, ccc |
//mov cl, ccc |
int 0x40 |
} |
} |
827,27 → 874,13 |
// çàîäíî èíèöèàëèçàöèÿ ãåíåðàòîðà ñëó÷àéíûõ ÷èñåë |
//#pragma section(".CRT$XCA",long,read,write) |
//#pragma section(".CRT$XCZ",long,read,write) |
#pragma data_seg(".CRT$XCA") |
#pragma data_seg(".CRT$XCZ") |
typedef void (__cdecl *_PVFV)(void); |
__declspec(allocate(".CRT$XCA")) _PVFV __xc_a[1] = { NULL }; |
__declspec(allocate(".CRT$XCZ")) _PVFV __xc_z[1] = { NULL }; |
// |
#pragma comment(linker, "/merge:.CRT=.rdata") |
// |
void crtStartUp() |
{ |
// âûçûâàåì èíèöèàëèçàòîðû ïî ñïèñêó, NULL'û èãíîðèðóåì |
for ( _PVFV *pbegin = __xc_a; pbegin < __xc_z; pbegin++ ) |
{ |
// |
if ( *pbegin != NULL ) |
(**pbegin)(); |
} |
__MENUET_header.app_path_ptr; |
// èíèöèàëèçèðóåì ãåíåðàòîð ñëó÷àéíûõ ÷èñåë |
rtlSrand( kos_GetSystemClock() ); |
// ïóòü ê ôàéëó ïðîöåññà |
kosExePath = *((char **)0x20); |
//kosExePath = *((char **)0x20); |
// âûçîâ ãëàâíîé ôóíêöèè ïðèëîæåíèÿ |
kos_Main(); |
// âûõîä |
/programs/games/kosilka/kosSyst.h |
---|
99,7 → 99,7 |
}; |
// |
extern char *kosExePath; |
extern char kosExePath[]; |
// |
void crtStartUp(); |
128,7 → 128,7 |
// |
Dword rtlInterlockedExchange( Dword *target, Dword value ); |
// ôóíêöèÿ -1 çàâåðøåíèÿ ïðîöåññà |
void kos_ExitApp(); |
void __declspec(noreturn) kos_ExitApp(); |
// ôóíêöèÿ 0 |
void kos_DefineAndDrawWindow( |
Word x, Word y, |
142,7 → 142,8 |
// ôóíêöèÿ 2 ïîëó÷èòü êîä íàæàòîé êëàâèøè |
bool kos_GetKey( Byte &keyCode ); |
// ôóíêöèÿ 3 ïîëó÷èòü âðåìÿ |
Dword kos_GetSystemClock(); |
Dword __cdecl kos_GetSystemClock(); |
#if 0 |
// ôóíêöèÿ 4 |
void kos_WriteTextToWindow( |
Word x, Word y, |
151,26 → 152,31 |
char *textPtr, |
Dword textLen |
); |
#else |
void kos_WriteTextToWindow_internal(Dword pos, Dword font, const char* textPtr, Dword textLen); |
#define kos_WriteTextToWindow(x, y, fontType, textColour, textPtr, textLen) \ |
kos_WriteTextToWindow_internal(((x)<<16)|(y), ((fontType)<<24)|(textColour), textPtr, textLen) |
#endif |
// ôóíêöèÿ 7 íàðèñîâàòü èçîáðàæåíèå |
void kos_PutImage( RGB * imagePtr, Word sizeX, Word sizeY, Word x, Word y ); |
// ôóíêöèÿ 8 îïðåäåëèòü êíîïêó |
void kos_DefineButton( Word x, Word y, Word sizeX, Word sizeY, Dword buttonID, Dword colour ); |
// ôóíêöèÿ 5 ïàóçà, â ñîòûõ äîëÿõ ñåêóíäû |
void kos_Pause( Dword value ); |
void __cdecl kos_Pause( Dword value ); |
// ôóíêöèÿ 9 - èíôîðìàöèÿ î ïðîöåññå |
Dword kos_ProcessInfo( sProcessInfo *targetPtr, Dword processID = PROCESS_ID_SELF ); |
// ôóíêöèÿ 10 |
Dword kos_WaitForEvent(); |
Dword __cdecl kos_WaitForEvent(); |
// ôóíêöèÿ 11 |
Dword kos_CheckForEvent(); |
// ôóíêöèÿ 12 |
void kos_WindowRedrawStatus( Dword status ); |
void __cdecl kos_WindowRedrawStatus( Dword status ); |
// ôóíêöèÿ 13 íàðèñîâàòü ïîëîñó |
void kos_DrawBar( Word x, Word y, Word sizeX, Word sizeY, Dword colour ); |
// ôóíêöèÿ 17 |
bool kos_GetButtonID( Dword &buttonID ); |
// ôóíêöèÿ 23 |
Dword kos_WaitForEvent( Dword timeOut ); |
Dword __cdecl kos_WaitForEvent( Dword timeOut ); |
// |
enum eNumberBase |
{ |
195,9 → 201,9 |
// ôóíêöèÿ 48.4 ïîëó÷èòü âûñîòó ñêèíà |
Dword kos_GetSkinWidth(); |
// ôóíêöèÿ 58 äîñòóï ê ôàéëîâîé ñèñòåìå |
Dword kos_FileSystemAccess( kosFileInfo *fileInfo ); |
Dword __fastcall kos_FileSystemAccess( kosFileInfo *fileInfo ); |
// ôóíêöèÿ 63 |
void kos_DebugOutChar( char ccc ); |
void __fastcall kos_DebugOutChar( char ccc ); |
// |
void rtlDebugOutString( char *str ); |
// ôóíêöèÿ 64 èçìåíèòü ïàðàìåòðû îêíà, ïàðàìåòð == -1 íå ìåíÿåòñÿ |
/programs/games/kosilka/kosilka.cpp |
---|
323,29 → 323,29 |
void decode_graphics(Byte * source, RGB * target){ |
static RGB palette[] = { |
0x978A31,0x8B7F2E,0x867B2B,0x82762B,0x7F7428,0x79702B,0x766C26,0x90832E, |
0x978A2F,0x9A8C31,0x9B8D32,0x998C31,0x9C8E33,0x9D8F34,0x988B30,0x928531, |
0x887532,0xBAA454,0xA18C3D,0xC6B26A,0xA08E46,0x6B5F26,0xAF9844,0x9C873B, |
0xAB964D,0x988338,0xA89140,0xB49D4C,0xC1AC5C,0x94872F,0x303030,0x343435, |
0x827933,0x806E2F,0x8B8134,0x938632,0x96892F,0x988C33,0x8F873B,0x7E9F39, |
0x8E812D,0x92803F,0x75715C,0x676462,0x6D6A68,0x666260,0x6B6866,0x6A6664, |
0x8E7B35,0x626161,0x797641,0x9B8E33,0x7F7954,0x776A67,0xB29E55,0xBCA75E, |
0x978C3E,0x3E3E3D,0x434245,0x373938,0x3C9737,0x209437,0xB97934,0xE6863E, |
0xF28C41,0xE2833D,0xDD803B,0xD77C3A,0xD17938,0xEA883F,0x605D5B,0x686563, |
0x706D6B,0x5F5F5E,0x656566,0xB56931,0xAC663B,0xC17D36,0xC88338,0x997246, |
0x737271,0xA89546,0x4D4D4E,0x515152,0x565656,0x5A5A59,0x687B41,0x098933, |
0x5B9B38,0x009036,0x069136,0xF18B41,0xC27034,0xCD7737,0xEE8A40,0xA0774B, |
0xF18C41,0x948037,0x988B34,0x49484A,0x5D5D5D,0x039036,0x0E9236,0xB06B7B, |
0x949CF8,0x7C85F6,0x6A74F5,0x5A66F4,0x4653F1,0x5F53B6,0x726462,0x9C7449, |
0xD0C472,0x696969,0x998B32,0x9D6676,0x3B47DD,0x5349A0,0xD8CD77,0x343EC1, |
0x4F438C,0x8E5538,0xC37341,0x895D71,0x483B74,0x433359,0x9C8D34,0x2A329A, |
0x995F49,0x1D236D,0x756E37,0x524819,0x8D8848,0x9B8D34,0x157F2F,0x2D6C28, |
0xAA778B,0x663C15,0x4E5924,0x9D8F31,0xBCAD48 |
static const char palette[] = { |
0x31,0x8A,0x97,0x2E,0x7F,0x8B,0x2B,0x7B,0x86,0x2B,0x76,0x82,0x28,0x74,0x7F,0x2B,0x70,0x79,0x26,0x6C,0x76,0x2E,0x83,0x90, |
0x2F,0x8A,0x97,0x31,0x8C,0x9A,0x32,0x8D,0x9B,0x31,0x8C,0x99,0x33,0x8E,0x9C,0x34,0x8F,0x9D,0x30,0x8B,0x98,0x31,0x85,0x92, |
0x32,0x75,0x88,0x54,0xA4,0xBA,0x3D,0x8C,0xA1,0x6A,0xB2,0xC6,0x46,0x8E,0xA0,0x26,0x5F,0x6B,0x44,0x98,0xAF,0x3B,0x87,0x9C, |
0x4D,0x96,0xAB,0x38,0x83,0x98,0x40,0x91,0xA8,0x4C,0x9D,0xB4,0x5C,0xAC,0xC1,0x2F,0x87,0x94,0x30,0x30,0x30,0x35,0x34,0x34, |
0x33,0x79,0x82,0x2F,0x6E,0x80,0x34,0x81,0x8B,0x32,0x86,0x93,0x2F,0x89,0x96,0x33,0x8C,0x98,0x3B,0x87,0x8F,0x39,0x9F,0x7E, |
0x2D,0x81,0x8E,0x3F,0x80,0x92,0x5C,0x71,0x75,0x62,0x64,0x67,0x68,0x6A,0x6D,0x60,0x62,0x66,0x66,0x68,0x6B,0x64,0x66,0x6A, |
0x35,0x7B,0x8E,0x61,0x61,0x62,0x41,0x76,0x79,0x33,0x8E,0x9B,0x54,0x79,0x7F,0x67,0x6A,0x77,0x55,0x9E,0xB2,0x5E,0xA7,0xBC, |
0x3E,0x8C,0x97,0x3D,0x3E,0x3E,0x45,0x42,0x43,0x38,0x39,0x37,0x37,0x97,0x3C,0x37,0x94,0x20,0x34,0x79,0xB9,0x3E,0x86,0xE6, |
0x41,0x8C,0xF2,0x3D,0x83,0xE2,0x3B,0x80,0xDD,0x3A,0x7C,0xD7,0x38,0x79,0xD1,0x3F,0x88,0xEA,0x5B,0x5D,0x60,0x63,0x65,0x68, |
0x6B,0x6D,0x70,0x5E,0x5F,0x5F,0x66,0x65,0x65,0x31,0x69,0xB5,0x3B,0x66,0xAC,0x36,0x7D,0xC1,0x38,0x83,0xC8,0x46,0x72,0x99, |
0x71,0x72,0x73,0x46,0x95,0xA8,0x4E,0x4D,0x4D,0x52,0x51,0x51,0x56,0x56,0x56,0x59,0x5A,0x5A,0x41,0x7B,0x68,0x33,0x89,0x09, |
0x38,0x9B,0x5B,0x36,0x90,0x00,0x36,0x91,0x06,0x41,0x8B,0xF1,0x34,0x70,0xC2,0x37,0x77,0xCD,0x40,0x8A,0xEE,0x4B,0x77,0xA0, |
0x41,0x8C,0xF1,0x37,0x80,0x94,0x34,0x8B,0x98,0x4A,0x48,0x49,0x5D,0x5D,0x5D,0x36,0x90,0x03,0x36,0x92,0x0E,0x7B,0x6B,0xB0, |
0xF8,0x9C,0x94,0xF6,0x85,0x7C,0xF5,0x74,0x6A,0xF4,0x66,0x5A,0xF1,0x53,0x46,0xB6,0x53,0x5F,0x62,0x64,0x72,0x49,0x74,0x9C, |
0x72,0xC4,0xD0,0x69,0x69,0x69,0x32,0x8B,0x99,0x76,0x66,0x9D,0xDD,0x47,0x3B,0xA0,0x49,0x53,0x77,0xCD,0xD8,0xC1,0x3E,0x34, |
0x8C,0x43,0x4F,0x38,0x55,0x8E,0x41,0x73,0xC3,0x71,0x5D,0x89,0x74,0x3B,0x48,0x59,0x33,0x43,0x34,0x8D,0x9C,0x9A,0x32,0x2A, |
0x49,0x5F,0x99,0x6D,0x23,0x1D,0x37,0x6E,0x75,0x19,0x48,0x52,0x48,0x88,0x8D,0x34,0x8D,0x9B,0x2F,0x7F,0x15,0x28,0x6C,0x2D, |
0x8B,0x77,0xAA,0x15,0x3C,0x66,0x24,0x59,0x4E,0x31,0x8F,0x9D,0x48,0xAD,0xBC |
}; |
for (int lc=0;lc<576;lc++) |
target[lc] = palette[source[lc]]; |
target[lc] = ((RGB*)palette)[source[lc]]; |
} |