t_edit can open kpack-ed files

git-svn-id: svn://kolibrios.org@9485 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2021-12-27 14:55:00 +00:00
parent 493083429e
commit 8be74c2de6
5 changed files with 230 additions and 34 deletions

View File

@ -0,0 +1,115 @@
// block name, color, step, coord: x,y,z, rotation: x,y,z
const m1 = 0xff0000; //red
const m2 = 0xff; //blue
const m3 = 0x808080; //gray
const m4 = 0xffff00; //yellow
const m5 = 0x080808; //black
const m6 = 0xffffff; //white
model_list=[
['b10x10x1', m3, 0,-20, -20, 0, 0,0,0],
['b2x3x1', m1, 1, 0, 4, 39, 0,0,90],
['b1x1x1', m1, 1, 0, 0, 39, 0,0,0],
['b1x1x1', m1, 1, -8, 0, 39, 0,0,0],
['b1x3x1', m2, 1, 0, 12, 39, 0,0,90],
['b1x4x1', m2, 1, 4, 8, 39, 0,0,0],
['b1x4x1', m2, 1,-12, 8, 39, 0,0,0],
['b1x4x1', m2, 2,-12, 4, 42, 0,0,0],
['b1x4x1', m2, 2, 4, 4, 42, 0,0,0],
['b1x4x1', m1, 2, -8, -4, 42, 0,0,0],
['b1x4x1', m1, 2, 0, -4, 42, 0,0,0],
['b1x3x1', m2, 2, 0, 12, 42, 0,0,90],
['b2x4x1', m2, 3,-12, 0, 45, 0,0,0],
['b2x4x1', m2, 3, 0, 0, 45, 0,0,0],
['b1x2x1', m4, 3, -4, 8, 45, 0,0,0],
['b2x3x1', m1, 3, 0, -8, 45, 0,0,90],
['b2x3x1', m1, 4, 0,-12, 48, 0,0,90],
['b2x4x1', m2, 4, 0, -4, 48, 0,0,0],
['b2x4x1', m2, 4,-12, -4, 48, 0,0,0],
['b1x3x1', m4, 4, 0, 12, 48, 0,0,90],
['b1x3x1', m4, 5, 0, 12, 51, 0,0,90],
['b2x2x1', m4, 5,-12, 4, 51, 0,0,0],
['b2x2x1', m4, 5, 0, 4, 51, 0,0,0],
['b2x3x1', m2, 5,-12, -8, 51, 0,0,0],
['b2x3x1', m2, 5, 0, -8, 51, 0,0,0],
['b1x3x1', m1, 5, 0,-12, 51, 0,0,90],
['b2x3x1', m1, 6, 0,-16, 54, 0,0,90],
['b2x3x1', m1, 6, 0, 8, 54, 0,0,90],
['b1x2x1', m2, 6,-12,-12, 54, 0,0,0],
['b1x2x1', m2, 6, 4,-12, 54, 0,0,0],
['b1x4x1', m4, 6,-12, -4, 54, 0,0,0],
['b1x4x1', m4, 6, 4, -4, 54, 0,0,0],
['b2x3x1', m1, 7, 0,-16, 57, 0,0,90],
['b2x3x1', m1, 7, 0, 4, 57, 0,0,90],
['b1x1x1', m2, 7,-12,-12, 57, 0,0,0],
['b1x1x1', m2, 7, 4,-12, 57, 0,0,0],
['b1x4x1', m4, 7,-12, -8, 57, 0,0,0],
['b1x4x1', m4, 7, 4, -8, 57, 0,0,0],
['b1x2x1', m4, 8,-12,-12, 60, 0,0,0],
['b1x2x1', m4, 8, 4,-12, 60, 0,0,0],
['b2x3x1', m1, 8, 0,-16, 60, 0,0,90],
['b2x3x1', m1, 8,-12, -4, 60, 0,0,0],
['b2x3x1', m1, 8, 0, -4, 60, 0,0,0],
['b1x3x1', m1, 8, 0, 8, 60, 0,0,90],
['b2x3x1', m1, 9, 0,-12, 63, 0,0,90],
['b2x3x1', m1, 9, 0, 0, 63, 0,0,90],
['b1x4x1', m1, 9,-12,-12, 63, 0,0,0],
['b1x4x1', m1, 9, 4,-12, 63, 0,0,0],
['b2x3x1', m1, 10,-12, -8, 66, 0,0,0],
['b1x3x1', m1, 10, -4, -8, 66, 0,0,0],
['b2x3x1', m1, 10, 0, -8, 66, 0,0,0],
['b1x3x1', m6, 10, 0,-12, 66, 0,0,90],
['b1x3x1', m5, 10, 0,-16, 66, 0,0,90],
['b1x3x1', m5, 10, 0,-20, 66, 0,0,90],
['b1x1x1', m5, 10, -4,-32, 66, 0,0,0],
['b1x1x1', m6, 11, -4,-32, 69, 0,0,0],
['b2x3x1', m6, 11, 0,-16, 69, 0,0,90],
['b1x3x1', m5, 11, -4,-28, 69, 0,0,0],
['b1x1x1', m5, 11, -8,-20, 69, 0,0,0],
['b1x1x1', m5, 11, 0,-20, 69, 0,0,0],
['b1x3x1', m1, 11, 0, 0, 69, 0,0,90],
['b2x3x1', m1, 11, 0, -8, 69, 0,0,90],
['b1x3x1', m6, 12, -4,-32, 72, 0,0,0],
['b2x3x1', m6, 12, 0,-20, 72, 0,0,90],
['b1x3x1', m6, 12, 0,-12, 72, 0,0,90],
['b2x3x1', m1, 12, 0, -8, 72, 0,0,90],
['b1x3x1', m6, 13, -4,-28, 75, 0,0,0],
['b1x3x1', m6, 13, 0,-12, 75, 0,0,90],
['c1x1x1', m5, 13, -8,-16, 75, 0,0,0],
['c1x1x1', m5, 13, 0,-16, 75, 0,0,0],
['b2x3x1', m1, 13, 0, -8, 75, 0,0,90],
['b2x3x1', m6, 14, 0,-20, 78, 0,0,90],
['b1x1x1', m6, 14, -4,-24, 78, 0,0,0],
['b2x3x1', m1, 14, 0,-12, 78, 0,0,90],
['b2x3x1', m1, 15, 0,-16, 81, 0,0,90],
['b1x3x1', m1, 15, 0,-20, 81, 0,0,90],
['b2x2x1', m3, 16, 8, -4, 3, 0,0,0],
['b2x2x1', m3, 17, 8, -4, 6, 0,0,0],
['b2x2x1', m3, 18, 8, -4, 9, 0,0,0],
['b2x2x1', m3, 19, 8, -4, 12, 0,0,0],
['b2x2x1', m3, 20, 8, -4, 15, 0,0,0],
['b2x2x1', m3, 21, 8, -4, 18, 0,0,0],
['b2x2x1', m3, 22, 8, -4, 21, 0,0,0],
['b2x2x1', m3, 23, 8, -4, 24, 0,0,0],
['b2x2x1', m3, 24, 8, -4, 27, 0,0,0],
['b2x2x1', m3, 25, 8, -4, 30, 0,0,0],
['b2x8x1', m3, 25, 4, -4, 30, 0,0,90],
['b2x8x1', m3, 26, 16, -4, 33, 0,0,90],
['c1x1x1', m5, 26, -8, -8, 33, 0,0,0],
['c1x1x1', m5, 26, 0, -8, 33, 0,0,0],
['b1x3x1', m6, 27, -8, -8, 36, 0,0,0],
['b1x3x1', m6, 27, 0, -8, 36, 0,0,0],
['b1x1x1', m2, 28, -4, 12, 9, 0,0,90],
['b1x1x1', m2, 29, -4, 12, 12, 0,0,90],
['b1x2x1', m2, 30, -2, 12, 15, 0,0,90],
['b1x2x1', m2, 31, -2, 12, 18, 0,0,90],
['b1x2x1', m1, 32, -2, 12, 21, 0,0,90],
['b1x3x1', m1, 33, 0, 12, 24, 0,0,90],
['b1x3x1', m1, 34, 0, 12, 27, 0,0,90],
['b1x1x1', m1, 35, -4, 12, 30, 0,0,0],
['b1x1x1', m2, 36, -8, 12, 30, 0,0,0],
['b1x1x1', m2, 37, 0, 12, 30, 0,0,0],
['b2x3x1', m2, 38, 0, 8, 33, 0,0,90],
['b2x3x1', m2, 39, 0, 8, 36, 0,0,90],
];

View File

@ -1,8 +1,13 @@
#ifndef __KOS_LIB_H_INCLUDED_
#define __KOS_LIB_H_INCLUDED_
int memcmp(const void *buf1, const void *buf2, long int count);
void *memcpy(void *dest, const void *src, unsigned int n);
void *memset(void *s, char c, unsigned int n);
unsigned int strlen(const char *str); unsigned int strlen(const char *str);
char *strcpy(char *dest, const char *src); char *strcpy(char *dest, const char *src);
void *memcpy(void *dest, const void *src, unsigned int n); char *strncpy(char *dest, const char *src, long int n);
void *memset(void *s, char c, unsigned int n);
int strcmp(const char *str1, const char *str2); int strcmp(const char *str1, const char *str2);
char *strchr(const char *str, int ch); char *strchr(const char *str, int ch);
char *strstr(const char *str1, const char *str2); char *strstr(const char *str1, const char *str2);
@ -13,3 +18,5 @@ double StrToDouble(char *str);
long StrToInt(char *str); long StrToInt(char *str);
void MessageBox(char *str); void MessageBox(char *str);
#endif

View File

@ -142,6 +142,41 @@ proc @strcpy$qpcpxc uses esi edi
ret ret
endp endp
align 4
proc @strncpy$qpcpxcl uses esi edi
cld
mov edi,[esp+16]
mov ecx,[esp+20]
jecxz @f
mov esi,edi
xor al,al
repnz scasb
not ecx
mov edi,[esp+12]
mov edx,ecx
mov eax,edi
shr ecx,2
rep movsd
mov ecx,edx
and ecx,3
rep movsb
@@:
ret
endp
align 4
proc @memcmp$qpxvt1l uses esi edi
cld
mov ecx,[esp+20]
mov edi,[esp+16]
mov esi,[esp+12]
repe cmpsb
movzx eax,byte[esi-1]
movzx edx,byte[edi-1]
sub eax,edx
ret
endp
align 4 align 4
proc @memcpy$qpvpxvui uses esi edi proc @memcpy$qpvpxvui uses esi edi
cld cld
@ -246,7 +281,7 @@ align 4
lea eax,[esi-1] lea eax,[esi-1]
.not_f: .not_f:
ret ret
endp endp
align 4 align 4

View File

@ -22,6 +22,8 @@ include '../../../../KOSfuncs.inc'
include 'box_lib.mac' ;macro which should make life easier :) include 'box_lib.mac' ;macro which should make life easier :)
;include '../../../../debug.inc' ;include '../../../../debug.inc'
include 'keys.inc' include 'keys.inc'
include '../../../../system/skincfg/trunk/kglobals.inc'
include '../../../../system/skincfg/trunk/unpacker.inc'
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
mem.alloc dd ? ;ôóíêöèÿ äëÿ âûäåëåíèÿ ïàìÿòè mem.alloc dd ? ;ôóíêöèÿ äëÿ âûäåëåíèÿ ïàìÿòè
@ -170,6 +172,10 @@ proc draw_edge uses eax ebx ecx edx edi esi, box_l:dword, box_t:dword, box_w:dwo
endp endp
;äëÿ ðàáîòû ñ KPCK
IncludeIGlobals
IncludeUGlobals
align 16 align 16
EXPORTS: EXPORTS:

View File

@ -1263,20 +1263,12 @@ proc ted_memory_increase
cmp ted_increase_size,0 cmp ted_increase_size,0
je @f je @f
push eax ebx ecx push eax ebx ecx
mov ecx,ted_increase_size
add ecx,ted_max_chars
mov ted_max_chars,ecx
imul ecx,sizeof.symbol
invoke mem.realloc, ted_tex,ecx
mov ebx,ted_tex mov ebx,ted_tex
mov ted_tex,eax mov ecx,ted_max_chars
mov ted_tex_1,eax call ted_mem_resize.no_2
add ted_tex_1,sizeof.symbol sub edx,ebx
sub edx,ebx add edx,ted_tex
add edx,eax mov ted_ptr_free_symb,edx
mov ted_ptr_free_symb,edx
add eax,ecx
mov ted_tex_end,eax
pop ecx ebx eax pop ecx ebx eax
@@: @@:
ret ret
@ -2546,11 +2538,39 @@ proc ted_find_help_id uses ebx ecx, end_pos:dword
ret ret
endp endp
;description:
; ¨§¬¥­ï¥¬ à §¬¥à ¯ ¬ï⨠¤«ï ⥪áâ  (ãáâ ­®¢ª  ted_ptr_free_symb ­  1 ᨬ¢®«)
;input:
; ecx - ç¨á«® ᨬ¢®«®¢ ¢ ä ©«¥
; edi - pointer to tedit struct
;output:
; eax, ecx - à §àãè îâáï
align 16
ted_mem_resize:
add ecx,2 ;¯ ¬ïâì ¤«ï ⥪áâ  + á«ã¦¥¡­ë¥ ­ ç «ì­ë© ¨ ª®­¥ç­ë© ᨬ¢®«ë
.no_2:
add ecx,ted_increase_size ;¯ ¬ïâì ¤«ï । ªâ¨à®¢ ­¨ï ä ©« 
mov ted_max_chars,ecx
imul ecx,sizeof.symbol
invoke mem.realloc, ted_tex,ecx
mov ted_tex,eax
mov ted_tex_1,eax
add ted_tex_1,sizeof.symbol
add eax,ecx
mov ted_tex_end,eax
mov ecx,ted_tex_1
add ecx,sizeof.symbol
mov ted_ptr_free_symb,ecx
ret
;output: ;output:
; eax = ª®¤ ®è¨¡ª¨ ; eax = ª®¤ ®è¨¡ª¨
; ebx = ª®««¨ç¥á⢮ ¯à®ç¨â ­­ëå ¡ ©â ; ebx = ª®««¨ç¥á⢮ ¯à®ç¨â ­­ëå ¡ ©â
align 16 align 16
proc ted_open_file uses ecx edx edi, edit:dword, file:dword, f_name:dword ;äã­ªæ¨ï ®âªàëâ¨ï ä ©«  proc ted_open_file uses ecx edx edi esi, edit:dword, file:dword, f_name:dword ;äã­ªæ¨ï ®âªàëâ¨ï ä ©« 
locals
unpac_mem dd ?
endl
mov edi,[edit] mov edi,[edit]
; *** ¯à®¢¥à塞 à §¬¥à ¯ ¬ï⨠¨ ¥á«¨ ­¥ 墠⠥â ⮠㢥«¨ç¨¢ ¥¬ *** ; *** ¯à®¢¥à塞 à §¬¥à ¯ ¬ï⨠¨ ¥á«¨ ­¥ 墠⠥â ⮠㢥«¨ç¨¢ ¥¬ ***
@ -2580,21 +2600,8 @@ align 4
mov edx,[edx+32] ;+32 = +0x20: qword: à §¬¥à ä ©«  ¢ ¡ ©â å mov edx,[edx+32] ;+32 = +0x20: qword: à §¬¥à ä ©«  ¢ ¡ ©â å
cmp edx,ecx cmp edx,ecx
jl @f jl @f
;㢥«¨ç¨¢ ¥¬ ¯ ¬ïâì ¥á«¨ ­¥ 墠⨫® mov ecx,edx
mov ecx,edx ;¯ ¬ïâì ­¥®¡å®¤¨¬ ï ¤«ï ®âªàëâ¨ï ä ©«  call ted_mem_resize
add ecx,2 ;¯ ¬ïâì ¤«ï á«ã¦¥¡­ëå ­ ç «ì­®£® ¨ ª®­¥ç­®£® ᨬ¢®«®¢
add ecx,ted_increase_size ;¯ ¬ïâì ¤«ï । ªâ¨à®¢ ­¨ï ä ©« 
mov ted_max_chars,ecx
imul ecx,sizeof.symbol
invoke mem.realloc, ted_tex,ecx
mov ted_tex,eax
mov ted_tex_1,eax
add ted_tex_1,sizeof.symbol
add eax,ecx
mov ted_tex_end,eax
mov ecx,ted_tex_1
add ecx,sizeof.symbol
mov ted_ptr_free_symb,ecx
@@: @@:
; *** ¯à®¡ã¥¬ ®âªàëâì ä ©« *** ; *** ¯à®¡ã¥¬ ®âªàëâì ä ©« ***
@ -2617,6 +2624,32 @@ align 4
cmp ebx,-1 cmp ebx,-1
je .ret_f je .ret_f
;if open file ;if open file
push eax
mov eax,ted_tex
cmp dword[eax],'KPCK'
jne .end_unpack
;¢ë¤¥«¥­¨¥ ¯ ¬ï⨠¤«ï à á¯ ª®¢ª¨ ä ©« 
invoke mem.alloc,[eax+4]
mov [unpac_mem],eax
stdcall unpack,ted_tex,[unpac_mem]
mov ecx,ted_max_chars
sub ecx,2 ;ecx = ¬ ªá¨¬ «ì­®¥ ç¨á«® ¡ ©â, ¤«ï ª®â®àëå ¡ë«  ¢ë¤¥«¥­  ¯ ¬ïâì
mov eax,ted_tex
mov ebx,[eax+4]
cmp ebx,ecx
jl @f ;¥á«¨ ¤«ï à á¯ ª®¢ ­®£® ä ©«  ­¥ 墠⠥⠢뤥«¥­­®© ¯ ¬ïâ¨
mov ecx,ebx
call ted_mem_resize
@@:
mov edi,ted_tex
mov esi,[unpac_mem]
mov ecx,ebx
cld
rep movsb
mov edi,[edit]
invoke mem.free,[unpac_mem]
.end_unpack:
pop eax
call ted_on_open_file call ted_on_open_file
.ret_f: .ret_f:
ret ret