/kernel/trunk/drivers/build.bat |
---|
File deleted |
\ No newline at end of file |
/kernel/trunk/video/vesa20.inc |
---|
1033,16 → 1033,18 |
sdp3: ; MAIN LOOP |
cmp [edi+WinMapAddress],byte 1 ; ptrBuffer^<>byte(1) |
jne snbgp |
push eax |
push ebx |
mov eax,dword [WinMapAddress-8] |
imul eax, [esp+4] ;4 |
xor edx,edx |
mov ebx,[ScreenWidth] |
div ebx |
mov cx,dx |
lea esi,[eax+eax*2] |
mov eax,dword [WinMapAddress-4] |
imul eax, [esp+0] ;0 |
1049,47 → 1051,12 |
xor edx,edx |
mov ebx,[ScreenHeight] |
div ebx |
shl ecx,16 |
mov cx,dx |
imul eax, [esp+8] ;8 |
add esi,eax |
mov eax,[esi+0x300000] |
push eax |
ror ecx,16 |
xor eax,eax |
mov ax,cx |
shl eax,1 ; óìíîæåíèå íà 2 |
lea eax,[eax+eax*4] ; óìíîæåíèå íà 5 |
xor edx,edx |
mov ebx,[ScreenWidth] |
div ebx |
cmp eax,5 |
pop eax |
jb @f |
mov ebx,[esi+0x300000+3] |
call overlapping_of_points |
@@: |
push eax |
ror ecx,16 |
xor eax,eax |
mov ax,cx |
shl eax,1 ; óìíîæåíèå íà 2 |
lea eax,[eax+eax*4] ; óìíîæåíèå íà |
xor edx,edx |
mov ebx,[ScreenHeight] |
div ebx |
cmp eax,5 |
pop eax |
jb @f |
mov ebx,[display_data-8] |
shl ebx,1 |
add ebx,[display_data-8] |
add ebx,0x300000 |
add ebx,esi |
mov ebx,[ebx] |
call overlapping_of_points |
@@: |
and eax,0xffffff |
xchg edi, ebp |
stosw |
shr eax,16 |
1099,44 → 1066,12 |
jz @f |
inc ebp ; +1 |
@@: |
pop ebx |
pop eax |
jmp shook1 |
overlapping_of_points: |
push ecx edi |
mov ecx,eax |
mov edx,ebx |
xor eax,eax |
mov al,cl |
xor ebx,ebx |
mov bl,dl |
add eax,ebx |
rcr eax,1 |
xor edi,edi |
mov di,ax |
xor eax,eax |
mov al,ch |
xor ebx,ebx |
mov bl,dh |
add eax,ebx |
rcr eax,1 |
ror edi,8 |
add edi,eax |
ror ecx,8 |
ror edx,8 |
xor eax,eax |
mov al,ch |
xor ebx,ebx |
mov bl,dh |
add eax,ebx |
rcr eax,1 |
ror edi,8 |
add eax,edi |
ror eax,16 |
pop edi ecx |
ret |
snbgp: |
add ebp,3 ; +3 |
cmp [ScreenBPP],byte 24 ; 24 or 32 bpp ? - x size |
/kernel/trunk/skin/build.bat |
---|
File deleted |
\ No newline at end of file |
/programs/network/stackcfg/trunk/stackcfg.asm |
---|
715,15 → 715,11 |
header db 'STACK CONFIGURATION',0 |
;ENTER YOUR SETTINGS HERE: |
ip_address db 010,005,004,175 |
gateway_ip db 010,005,000,001 |
subnet_mask db 255,255,000,000 |
dns_ip db 213,184,238,006 |
com_irq dd 0 ; irq for slip/ppp |
com_add dd 0 ; com port address for slip/ppp |
interface dd 3 ; not active,slip,ppp,packet driver |
/programs/network/md5/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm md5.asm md5 |
@pause |
/programs/network/md5/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm md5.asm md5 |
@pause |
/programs/network/md5/trunk/md5.asm |
---|
0,0 → 1,445 |
; ਬ¥à ॠ«¨§ 樨 £¥¥à â®à MD5 - å¥è |
; |
; MD5 Generator |
; |
; ¢â®à: Hex |
; ©â: www.mestack.narod.ru |
; ¤¥ï, ॠ«¨§ æ¨ï ¨ ®â« ¤ª . |
; |
; ¢â®à: Halyavin |
; ©â: www.shade.msu.ru/~msu-se/home.html |
; ®à ¡®âª , ®â« ¤ª ¨ ®¯â¨¬¨§ æ¨ï. |
; |
; ®¬¯¨«¨àã¥âìáï Fasm'®¬ ¤«ï ¥ãíâ |
include 'lang.inc' |
macro diff16 title,l2 |
{ |
local s,d,l1 |
s = l2 |
display title,': 0x' |
repeat 8 |
d = 48 + s shr ((8-%) shl 2) and $0F |
if d > 57 |
d = d + 65-57-1 |
end if |
display d |
end repeat |
display 13,10 |
} |
use32 |
org 0x0 |
db 'MENUET01' ; 8-¡ ©âë© ¨¤¥â¨ä¨ª â®à MenuetOS |
dd 0x01 ; ¢¥àá¨ï § £®«®¢ª (¢á¥£¤ 1) |
dd START ; ¤à¥á ¯¥à¢®© ª®¬ ¤ë |
dd I_END ; à §¬¥à ¯à®£à ¬¬ë |
dd 0x100000 ; ª®«¨ç¥á⢮ ¯ ¬ï⨠|
dd 0x100000 ; ¤à¥á ¢¥àè¨ë áâíª |
dd 0x0 ; ¤à¥á ¡ãä¥à ¤«ï ¯ à ¬¥â஢ (¥ ¨á¯®«ì§ã¥âáï) |
dd 0x0 ; § १¥à¢¨à®¢ ® |
START: ; ç «® ¢ë¯®«¥¨ï ¯à®£à ¬¬ë |
call draw_window ; ¯¥à¢ ¯¥à¥à¨á㥬 ®ª® |
still: |
mov eax,23 ; ¦¨¤ ¥¬ ᮡë⨩ |
mov ebx,1 |
int 0x40 |
cmp eax,1 ; ¯à®á ¯¥à¥à¨á®¢ªã ? |
jz red |
cmp eax,2 ; ¦ â ª« ¢¨è¨ ? |
jz key |
cmp eax,3 ; ¦ â ª®¯ª ? |
jz button |
jmp still |
red: |
call draw_window |
jmp still |
key: |
mov eax,2 |
int 0x40 |
jmp still |
button: |
mov eax,17 |
int 0x40 |
cmp ah,1 ; id ª®¯ª¨ = 1 ? |
jnz noclose |
mov eax,-1 |
int 0x40 |
noclose: |
cmp ah,2 ; ¥¥à¨à®¢ âì? |
je procMD5hash |
jmp still |
procMD5hash: |
; phase I - padding |
mov edi,ptBuffer |
mov eax,[dtBufferLength] |
inc eax |
add edi,eax |
mov byte [edi-1],0x80 |
xor edx,edx |
mov ebx,64 |
div ebx |
neg edx |
add edx,64 |
cmp edx,8 |
jae @f |
add edx,64 |
@@: mov ecx,edx |
xor al,al |
rep stosb |
mov eax,[dtBufferLength] |
inc edx |
add [dtBufferLength],edx |
xor edx,edx |
mov ebx,8 |
mul ebx |
mov [edi-8],eax |
mov [edi-4],edx |
mov edx,[dtBufferLength] |
mov edi,ptBuffer |
; phase II - chaining variables initialization |
mov dword [dtA],067452301h |
mov dword [dtB],0efcdab89h |
mov dword [dtC],098badcfeh |
mov dword [dtD],010325476h |
mov esi,ptMD5Result |
hashloop: |
;diff16 "hashloop",hashloop |
mov eax,[dtA] |
mov [dta],eax |
mov eax,[dtB] |
mov [dtb],eax |
mov eax,[dtC] |
mov [dtc],eax |
mov eax,[dtD] |
mov [dtd],eax |
macro ff dta,dtb,dtc,dtd,data,shift,cc |
{ |
mov eax,dtb |
mov ebx,dtc |
mov ecx,dtd |
and ebx,eax |
not eax |
and eax,ecx |
or eax,ebx |
add eax,dta |
add eax,data |
add eax,cc |
rol eax,shift |
add eax,dtb |
mov dta,eax |
} |
macro gg dta,dtb,dtc,dtd,data,shift,cc |
{ |
mov eax,dtb |
mov ebx,dtc |
mov ecx,dtd |
and eax,ecx |
not ecx |
and ecx,ebx |
or eax,ecx |
add eax,dta |
add eax,data |
add eax,cc |
rol eax,shift |
add eax,dtb |
mov dta,eax |
} |
macro hh dta,dtb,dtc,dtd,data,shift,cc |
{ |
mov eax,dtb |
mov ebx,dtc |
mov ecx,dtd |
xor eax,ebx |
xor eax,ecx |
add eax,dta |
add eax,data |
add eax,cc |
rol eax,shift |
add eax,dtb |
mov dta,eax |
} |
macro ii dta,dtb,dtc,dtd,data,shift,cc |
{ |
mov eax,dtb |
mov ebx,dtc |
mov ecx,dtd |
not ecx |
or eax,ecx |
xor eax,ebx |
add eax,dta |
add eax,data |
add eax,cc |
rol eax,shift |
add eax,dtb |
mov dta,eax |
} |
; round 1 |
ff [dta],[dtb],[dtc],[dtd],dword [edi+00*4],07,0xd76aa478 |
ff [dtd],[dta],[dtb],[dtc],dword [edi+01*4],12,0xe8c7b756 |
ff [dtc],[dtd],[dta],[dtb],dword [edi+02*4],17,0x242070db |
ff [dtb],[dtc],[dtd],[dta],dword [edi+03*4],22,0xc1bdceee |
ff [dta],[dtb],[dtc],[dtd],dword [edi+04*4],07,0xf57c0faf |
ff [dtd],[dta],[dtb],[dtc],dword [edi+05*4],12,0x4787c62a |
ff [dtc],[dtd],[dta],[dtb],dword [edi+06*4],17,0xa8304613 |
ff [dtb],[dtc],[dtd],[dta],dword [edi+07*4],22,0xfd469501 |
ff [dta],[dtb],[dtc],[dtd],dword [edi+08*4],07,0x698098d8 |
ff [dtd],[dta],[dtb],[dtc],dword [edi+09*4],12,0x8b44f7af |
ff [dtc],[dtd],[dta],[dtb],dword [edi+10*4],17,0xffff5bb1 |
ff [dtb],[dtc],[dtd],[dta],dword [edi+11*4],22,0x895cd7be |
ff [dta],[dtb],[dtc],[dtd],dword [edi+12*4],07,0x6b901122 |
ff [dtd],[dta],[dtb],[dtc],dword [edi+13*4],12,0xfd987193 |
ff [dtc],[dtd],[dta],[dtb],dword [edi+14*4],17,0xa679438e |
ff [dtb],[dtc],[dtd],[dta],dword [edi+15*4],22,0x49b40821 |
; round 2 |
gg [dta],[dtb],[dtc],[dtd],dword [edi+01*4],05,0xf61e2562 |
gg [dtd],[dta],[dtb],[dtc],dword [edi+06*4],09,0xc040b340 |
gg [dtc],[dtd],[dta],[dtb],dword [edi+11*4],14,0x265e5a51 |
gg [dtb],[dtc],[dtd],[dta],dword [edi+00*4],20,0xe9b6c7aa |
gg [dta],[dtb],[dtc],[dtd],dword [edi+05*4],05,0xd62f105d |
gg [dtd],[dta],[dtb],[dtc],dword [edi+10*4],09,0x02441453 |
gg [dtc],[dtd],[dta],[dtb],dword [edi+15*4],14,0xd8a1e681 |
gg [dtb],[dtc],[dtd],[dta],dword [edi+04*4],20,0xe7d3fbc8 |
gg [dta],[dtb],[dtc],[dtd],dword [edi+09*4],05,0x21e1cde6 |
gg [dtd],[dta],[dtb],[dtc],dword [edi+14*4],09,0xc33707d6 |
gg [dtc],[dtd],[dta],[dtb],dword [edi+03*4],14,0xf4d50d87 |
gg [dtb],[dtc],[dtd],[dta],dword [edi+08*4],20,0x455a14ed |
gg [dta],[dtb],[dtc],[dtd],dword [edi+13*4],05,0xa9e3e905 |
gg [dtd],[dta],[dtb],[dtc],dword [edi+02*4],09,0xfcefa3f8 |
gg [dtc],[dtd],[dta],[dtb],dword [edi+07*4],14,0x676f02d9 |
gg [dtb],[dtc],[dtd],[dta],dword [edi+12*4],20,0x8d2a4c8a |
; round 3 |
hh [dta],[dtb],[dtc],[dtd],dword [edi+05*4],04,0xfffa3942 |
hh [dtd],[dta],[dtb],[dtc],dword [edi+08*4],11,0x8771f681 |
hh [dtc],[dtd],[dta],[dtb],dword [edi+11*4],16,0x6d9d6122 |
hh [dtb],[dtc],[dtd],[dta],dword [edi+14*4],23,0xfde5380c |
hh [dta],[dtb],[dtc],[dtd],dword [edi+01*4],04,0xa4beea44 |
hh [dtd],[dta],[dtb],[dtc],dword [edi+04*4],11,0x4bdecfa9 |
hh [dtc],[dtd],[dta],[dtb],dword [edi+07*4],16,0xf6bb4b60 |
hh [dtb],[dtc],[dtd],[dta],dword [edi+10*4],23,0xbebfbc70 |
hh [dta],[dtb],[dtc],[dtd],dword [edi+13*4],04,0x289b7ec6 |
hh [dtd],[dta],[dtb],[dtc],dword [edi+00*4],11,0xeaa127fa |
hh [dtc],[dtd],[dta],[dtb],dword [edi+03*4],16,0xd4ef3085 |
hh [dtb],[dtc],[dtd],[dta],dword [edi+06*4],23,0x04881d05 |
hh [dta],[dtb],[dtc],[dtd],dword [edi+09*4],04,0xd9d4d039 |
hh [dtd],[dta],[dtb],[dtc],dword [edi+12*4],11,0xe6db99e5 |
hh [dtc],[dtd],[dta],[dtb],dword [edi+15*4],16,0x1fa27cf8 |
hh [dtb],[dtc],[dtd],[dta],dword [edi+02*4],23,0xc4ac5665 |
; round 4 |
ii [dta],[dtb],[dtc],[dtd],dword [edi+00*4],06,0xf4292244 |
ii [dtd],[dta],[dtb],[dtc],dword [edi+07*4],10,0x432aff97 |
ii [dtc],[dtd],[dta],[dtb],dword [edi+14*4],15,0xab9423a7 |
ii [dtb],[dtc],[dtd],[dta],dword [edi+05*4],21,0xfc93a039 |
ii [dta],[dtb],[dtc],[dtd],dword [edi+12*4],06,0x655b59c3 |
ii [dtd],[dta],[dtb],[dtc],dword [edi+03*4],10,0x8f0ccc92 |
ii [dtc],[dtd],[dta],[dtb],dword [edi+10*4],15,0xffeff47d |
ii [dtb],[dtc],[dtd],[dta],dword [edi+01*4],21,0x85845dd1 |
ii [dta],[dtb],[dtc],[dtd],dword [edi+08*4],06,0x6fa87e4f |
ii [dtd],[dta],[dtb],[dtc],dword [edi+15*4],10,0xfe2ce6e0 |
ii [dtc],[dtd],[dta],[dtb],dword [edi+06*4],15,0xa3014314 |
ii [dtb],[dtc],[dtd],[dta],dword [edi+13*4],21,0x4e0811a1 |
ii [dta],[dtb],[dtc],[dtd],dword [edi+04*4],06,0xf7537e82 |
ii [dtd],[dta],[dtb],[dtc],dword [edi+11*4],10,0xbd3af235 |
ii [dtc],[dtd],[dta],[dtb],dword [edi+02*4],15,0x2ad7d2bb |
ii [dtb],[dtc],[dtd],[dta],dword [edi+09*4],21,0xeb86d391 |
mov eax,[dta] |
add [dtA],eax |
mov eax,[dtb] |
add [dtB],eax |
mov eax,[dtc] |
add [dtC],eax |
mov eax,[dtd] |
add [dtD],eax |
add edi,64 |
sub edx,64 |
jnz hashloop |
; phase IV - results |
mov ecx,4 |
mov esi,ptMD5Result |
@@: mov eax,[esi] |
xchg al,ah |
rol eax,16 |
xchg al,ah |
mov [esi],eax |
add esi,4 |
loop @b |
translate: |
;diff16 "translate",translate |
mov esi,ptMD5Result-5 |
mov edi,hexresult |
mov ecx,16 |
@@: |
test ecx,3 |
jnz .nojmp |
add esi,8 |
.nojmp: |
xor eax,eax |
mov al,byte [esi] |
mov edx,eax |
shr eax,4 |
mov bl,byte [table+eax] |
mov [edi],bl |
inc edi |
and edx,15 |
mov bl,byte [table+edx] |
mov [edi],bl |
dec esi |
inc edi |
loop @b |
mov esi,hexresult |
mov [text], esi |
mov eax,32 |
mov [textlen], eax |
call draw_window |
jmp still |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+230 ; [x start] *65536 + [x size] |
mov ecx,60*65536+100 ; [y start] *65536 + [y size] |
mov edx,0x03ffffff ; color of work area RRGGBB |
mov esi,0x80aabbcc ; color of grab bar RRGGBB,8->color gl |
mov edi,0x00aabbcc ; color of frames RRGGBB |
int 0x40 |
; WINDOW LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
mov ecx,0x00ffffff ; color of text RRGGBB |
mov edx,labeltext ; pointer to text beginning |
mov esi,lte-labeltext ; text length |
int 0x40 |
; ¨á㥬 ª®¯ªã ¤«ï £¥¥à 樨 |
mov eax,8 ; function 8 : define and draw button |
mov ebx,20*65536+80 ; [x start] *65536 + [x size] |
mov ecx,34*65536+14 ; [y start] *65536 + [y size] |
mov edx,2 ; button id |
mov esi,0x5588dd ; button color RRGGBB |
int 0x40 |
; §¢ ¨¥ ª®¯ªã |
mov eax,4 ; function 4 : write text to window |
mov ebx,23*65536+38 ; [x start] *65536 + [y start] |
mov ecx,0x000000 ; color of text RRGGBB |
mov edx,gen_txt ; pointer to text beginning |
mov esi,gen_len-gen_txt ; text length |
int 0x40 |
mov eax,4 ; draw info text with function 4 |
mov ebx,20*65536+70 |
mov ecx,0x000000 |
mov edx,[text] |
xor eax,eax |
mov al, [textlen] |
mov esi,eax |
mov eax,4 |
int 0x40 |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
;¡« áâì ¤ ëå |
labeltext: db 'MD5 Generator' |
lte: |
text: dd 0 |
textlen: dd 0 |
gen_txt: db '£¥¥à¨à®¢ âì' |
gen_len: |
InputMD5Rez: dd 0 |
InputMD5Rezlen: |
ptBuffer: db '123' ; ¬¥¨âì £¥¥à¨à㥬®¥ á«®¢® |
rb 61 |
dtBufferLength: dd 3 ; §¬¥à ptBuffer |
ptMD5Result: |
dtA: dd 0 |
dtB: dd 0 |
dtC: dd 0 |
dtD: dd 0 |
dta: dd 0 |
dtb: dd 0 |
dtc: dd 0 |
dtd: dd 0 |
x: dd 0 |
s: dd 0 |
t: dd 0 |
table: db '0123456789abcdef' |
hexresult db 32 |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/rtdata/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm rtdata.asm rtdata |
@pause |
/programs/network/rtdata/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm rtdata.asm rtdata |
@pause |
/programs/network/rtdata/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/rtdata/trunk/rtdata.asm |
---|
0,0 → 1,235 |
; |
; COMMUNICATING WITH MODEM: PORTS & IRQ |
; |
; Compile with FASM for Menuet |
; |
include "lang.inc" |
include "macros.inc" |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x1000 ; memory for app |
dd 0x1000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
START: ; start of execution |
mov eax,45 ; reserve irq 4 |
mov ebx,0 |
mov ecx,4 |
int 0x40 |
mov eax,46 ; reserve ports 0x3f8-0x3ff |
mov ebx,0 |
mov ecx,0x3f8 |
mov edx,0x3ff |
int 0x40 |
mov eax,44 ; read these ports at interrupt/irq 4 |
mov ebx,irqtable |
mov ecx,4 |
int 0x40 |
mov eax,40 ; enable event for interrupt/irq 4 |
mov ebx,10000b shl 16 + 111b |
int 0x40 |
call program_com1 |
call draw_window |
still: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
je red |
cmp eax,2 ; key in buffer ? |
je key |
cmp eax,3 ; button in buffer ? |
je button |
cmp eax,16+4 ; data read by interrupt ? |
je irq4 |
jmp still |
red: ; redraw |
call draw_window |
jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
mov al,ah |
mov dx,0x3f8 |
out dx,al |
jmp still |
button: ; button |
or eax,-1 ; close this program |
int 0x40 |
irq4: |
mov eax,42 |
mov ebx,4 |
int 0x40 |
; eax = number of bytes left |
; ecx = 0 success, =1 fail |
; bl = byte |
inc [pos] |
and [pos],31 |
mov eax,[pos] |
mov [string+eax], bl |
call draw_string |
jmp still |
baudrate_9600 equ 12 |
baudrate_57600 equ 2 |
program_com1: |
mov dx,0x3f8+3 |
mov al,0x80 |
out dx,al |
mov dx,0x3f8+1 |
mov al,0x00 |
out dx,al |
mov dx,0x3f8+0 |
mov al,baudrate_9600 |
out dx,al |
mov dx,0x3f8+3 |
mov al,0x3 |
out dx,al |
mov dx,0x3f8+4 |
mov al,0xb |
out dx,al |
mov dx,0x3f8+1 |
mov al,0x1 |
out dx,al |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax, 48 |
mov ebx, 3 |
mov ecx, sc |
mov edx, sizeof.system_colors |
int 0x40 |
mov eax, 12 ; function 12:tell os about windowdraw |
mov ebx, 1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax, 0 ; function 0 : define and draw window |
mov ebx, 100*65536+250 ; [x start] *65536 + [x size] |
mov ecx, 100*65536+85 ; [y start] *65536 + [y size] |
mov edx, [sc.work] |
or edx, 0x03000000 ; color of work area RRGGBB,8->color gl |
int 0x40 |
; WINDOW LABEL |
mov eax, 4 ; function 4 : write text to window |
mov ebx, 8*65536+8 ; [x start] *65536 + [y start] |
mov ecx, [sc.grab_text] |
or ecx, 0x10000000 ; font 1 & color ( 0xF0RRGGBB ) |
mov edx, header ; pointer to text beginning |
mov esi, header.len ; text length |
int 0x40 |
mov eax, 4 ; draw text |
mov ebx, 20*65536+33 |
mov ecx, [sc.work_text] |
mov edx, text+4 |
.nextstr: |
mov esi, [edx-4] |
test esi, 0xFF000000 |
jnz .finstr |
int 0x40 |
add edx, esi |
add edx, 4 |
add ebx, 10 |
jmp .nextstr |
.finstr: |
call draw_string |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
draw_string: |
mov eax, 4 |
mov ebx, 20*65536+65 |
mov ecx, [sc.work_text] |
mov edx, string |
mov esi, 32 |
int 0x40 |
ret |
; DATA AREA |
if lang eq ru |
text mstr " .",\ |
" ",\ |
" IRQ4 ." |
header: |
db ' COM1' |
.len = $ - header |
else |
text mstr "TYPED CHARACTERS ARE SENT TO MODEM.",\ |
"DATA FROM MODEM IS READ BY IRQ4",\ |
"INTERRUPT AND DISPLAYED BELOW." |
header: |
db 'MODEM AT COM1' |
.len = $ - header |
end if |
pos dd 0x0 |
irqtable: |
; port ; 1=byte, 2=word |
dd 0x3f8 +0x01000000 ; read byte from port 0x3f8 at interrupt/irq 4 |
dd 0x0 ; no more ports ( max 15 ) to read |
I_END: |
string rb 32 |
sc system_colors |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/stackinf/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm stackinf.asm stackinf |
@pause |
/programs/network/stackinf/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm stackinf.asm stackinf |
@pause |
/programs/network/stackinf/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/network/stackinf/trunk/stackinf.asm |
---|
0,0 → 1,158 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; |
;; ETHERNET SETUP |
;; |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x100000 ; required amount of memory |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
call draw_window ; at first, draw the window |
still: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
jmp still |
red: ; redraw |
call draw_window |
jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp still |
button: ; button |
mov eax,17 |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jnz noclose |
mov eax,-1 ; close this program |
int 0x40 |
noclose: |
cmp ah,2 |
jne no_details |
mov eax,19 |
mov ebx,file1 |
mov ecx,file2 |
int 0x40 |
jmp still |
no_details: |
jmp still |
; WINDOW DEFINITIONS AND DRAW |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx, 50*65536+370 ; [x start] *65536 + [x size] |
mov ecx,100*65536+230 ; [y start] *65536 + [y size] |
mov edx,0x03ffffff ; color of work area RRGGBB |
mov esi,0x80557799 ; color of grab bar RRGGBB,8->color glide |
mov edi,esi ; color of frames RRGGBB |
and edi,0xffffff |
int 0x40 |
; WINDOW LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
mov ecx,0x00ffffff ; color of text RRGGBB |
mov edx,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
; BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,202*65536+135 ; [x start] *65536 + [x size] |
mov ecx,190*65536+16 ; [y start] *65536 + [y size] |
mov edx,2 ; button id |
mov esi,edi ; button color RRGGBB |
int 0x40 |
mov ebx,6*65536+35 ; draw info text with function 4 |
mov ecx,0;xffffff |
mov edx,text |
mov esi,60 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,10 |
add edx,60 |
cmp [edx],byte 'x' |
jnz newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
; DATA AREA |
text: |
db ' ETHERNET CONNECTION BETWEEN MENUET AND A TFTP SERVER ' |
db ' ' |
db ' 1) CURRENT ETHERNET CODE IS FOR RTL 8029 AND i8255x ' |
db ' BASED PCI CARDS ' |
db ' 2) START STACK CONFIG FROM NET MENU AND PRESS THE ' |
db ' READ BUTTON, ACTIVATE PACKET DRIVER, SET DESIRED ' |
db ' IP ADDRESS & APPLY ' |
db ' 3) SET THE SERVERS IP ADDRESS TO EG. 192.168.1.24 ' |
db ' ' |
db ' THE MENUET MACHINE SHOULD NOW BE ABLE TO RESPOND TO A ' |
db ' PING FROM THE SERVER, TRANSFER FILES USING TFTP AND USE ' |
db ' IRC CLIENT. SEE MENUET PAGES FOR MORE TCP/IP APPLICATIONS.' |
db ' ' |
db ' MOST LINUX DISTRIBUTIONS HAVE A TFTP SERVER INCLUDED ' |
db ' FOR MS YOU CAN DOWNLOAD TFTPD FROM TFTPD32.JOUNIN.NET ' |
db ' ' |
db ' DETAILED DESCRIPTION ' |
db 'x' |
file1: db 'TINYPAD ' |
file2: db 'STACK.TXT',0 |
labelt: |
db 'NETWORK INFO' |
labellen: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/system/rdsave/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/system/rdsave/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/system/rdsave/trunk/macros.inc |
---|
File deleted |
\ No newline at end of file |
/programs/system/rdsave/trunk/rdsave.asm |
---|
File deleted |
/programs/system/gmon/macros.inc |
---|
File deleted |
\ No newline at end of file |
/programs/system/gmon/diag.inc |
---|
File deleted |
/programs/system/gmon/system.inc |
---|
File deleted |
/programs/system/gmon/test_tab.inc |
---|
File deleted |
\ No newline at end of file |
/programs/system/gmon/config.inc |
---|
File deleted |
/programs/system/gmon/hwm_it87.inc |
---|
File deleted |
/programs/system/gmon/gmon.asm |
---|
File deleted |
/programs/system/gmon/hwm.inc |
---|
File deleted |
/programs/system/gmon/conf_tab.inc |
---|
File deleted |
\ No newline at end of file |
/programs/system/gmon/abou_tab.inc |
---|
File deleted |
/programs/system/gmon/build.bat |
---|
File deleted |
\ No newline at end of file |
/programs/system/gmon/info_tab.inc |
---|
File deleted |
/programs/system/gmon/tests.inc |
---|
File deleted |
\ No newline at end of file |
/programs/system/gmon/readme.txt |
---|
File deleted |
\ No newline at end of file |
/programs/system/gmon/hwm_wb.inc |
---|
File deleted |
/programs/system/kbd/trunk/macros.inc |
---|
123,10 → 123,8 |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
macro __mov reg,a { ; mike.dld |
if ~a eq |
mov reg,a |
end if |
} |
143,6 → 141,11 |
; language for programs |
lang fix ru ; ru en fr ge fi |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 177,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 221,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/system/end/trunk/build_ge.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix ge >lang.inc |
@fasm end.asm end |
@erase lang.inc |
@pause |
/programs/system/end/trunk/build_en.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm end.asm end |
@erase lang.inc |
@pause |
/programs/system/end/trunk/build_ru.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm end.asm end |
@erase lang.inc |
@pause |
/programs/system/end/trunk/macros.inc |
---|
143,6 → 143,10 |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 178,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 222,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/system/icon/trunk/macros.inc |
---|
218,13 → 218,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/system/menu/trunk/macros.inc |
---|
143,6 → 143,10 |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 178,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 222,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/system/desktop/trunk/desktop.asm |
---|
15,7 → 15,7 |
dd START ; start address |
dd I_END ; file size |
dd 28000h ; memory |
dd 28000h ; stack pointer (0x10000+ - work area for os) |
dd 10000h ; stack pointer (0x10000+ - work area for os) |
dd 0,0 ; parameters, reserved |
include 'lang.inc' |
108,12 → 108,12 |
key: ; key |
mov al,2 ; just read it and ignore |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp still |
button: ; button |
mov al,17 ; get id |
mov eax,17 ; get id |
int 0x40 |
cmp ah,11 ; read string |
205,7 → 205,7 |
cmp ah,1 ; terminate |
jnz noid1 |
or eax,-1 |
mov eax,-1 |
int 0x40 |
noid1: |
547,7 → 547,7 |
end virtual |
draw_skin: |
mcall 13,<area.x,area.width>,<area.y+2,area.height-2>,0x00FFFFFF |
mcall 13,<area.x,area.width>,<area.y,area.height>,0x00FFFFFF |
mov ebp,0x18000 |
mov edi,[ebp+SKIN_HEADER.params] |
/programs/system/docpack/trunk/macros.inc |
---|
143,6 → 143,11 |
; language for programs |
lang fix ru ; ru en fr ge fi |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 179,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 223,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/system/vrr/trunk/macros.inc |
---|
143,6 → 143,9 |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 177,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 221,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/system/rb/trunk/@RB.ASM |
---|
350,7 → 350,7 |
<"/RD/1/JPEGVIEW",0> ,\ |
<"/RD/1/CPU",0> ,\ |
<"/RD/1/SPANEL",0> ,\ |
<"/RD/1/ICON",0> ,\ |
<"/RD/1/ICON2",0> ,\ |
<"/RD/1/VRR",0> |
; header: ; § £®«®¢®ª |
/programs/system/rb/trunk/macros.inc |
---|
143,6 → 143,10 |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 178,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
/programs/system/rb/trunk/build_en.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm @rb.asm @rb |
@erase lang.inc |
@pause |
/programs/system/rb/trunk/build_ru.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm @rb.asm @rb |
@erase lang.inc |
@pause |
/programs/system/ir/trunk/ir.asm |
---|
0,0 → 1,268 |
; |
; INFRARED |
; |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 1 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x1000 ; required amount of memory |
dd 0x1000 ; esp = 0x7FFF0 |
dd 0, 0 |
include 'macros.inc' |
START: ; start of execution |
set_variables: |
mov eax,46 ; reserve ports 0x3f0 - 0x3ff |
mov ebx,0 |
mov ecx,0x3f0 |
mov edx,0x3ff |
int 0x40 |
mov eax,45 ; reserve irq 4 |
mov ebx,0 |
mov ecx,4 |
int 0x40 |
mov eax,44 ; set read ports for irq 4 |
mov ebx,irqtable |
; mov ecx,4 |
int 0x40 |
mov dh, 3 ; all ports have number 3xx hex |
mov dl, 0xf3+8 |
mov al, 0x80 |
out dx, al |
mov dl, 0xf1+8 |
mov al, 0 |
out dx, al |
mov dl, 0xf0+8 |
mov al, 0x30 / 4 |
out dx, al |
mov dl, 0xf3+8 |
mov al, 3 |
out dx, al |
mov dl, 0xf4+8 |
mov al, 0xB |
out dx, al |
mov dl, 0xf1+8 |
mov al, 1 |
out dx, al |
mov eax,5 |
mov ebx,100 |
int 0x40 |
mov dl, 0xf8 |
mov al, 'I' |
out dx, al |
mov eax,5 |
mov ebx,10 |
int 0x40 |
mov al, 'R' |
out dx, al |
mov eax,40 ; get com 1 data with irq 4 |
mov ebx,0000000000010000b shl 16 + 101b |
int 0x40 |
red: |
call draw_window |
still: |
mov eax,10 ; wait here for event |
int 0x40 |
dec eax |
jz red |
dec eax |
dec eax |
jnz readir |
button: ; button |
mov al,17 ; get id |
int 0x40 |
; we have only one button, close |
mov eax,45 ; free irq |
mov ebx,1 |
mov ecx,4 |
int 0x40 |
mov eax,46 ; free ports 0x3f0-0x3ff |
mov ebx,1 |
mov ecx,0x3f0 |
mov edx,0x3ff |
int 0x40 |
or eax,-1 ; close this program |
int 0x40 |
pos dd 0x0 |
cdplayer: |
dd 7 |
dd 0 |
dd 0 |
dd 0 |
dd 0 |
db '/RD/1/CDP',0 |
readir: |
mov eax,42 |
mov ebx,4 |
int 0x40 |
cmp ebx,80 |
jne nocd |
mov eax,70 |
mov ebx,cdplayer |
int 0x40 |
nocd: |
push ebx |
mov eax,[pos] |
add eax,1 |
cmp eax,10*20+1 |
jb noeaxz |
mov esi,text+10*4 |
mov edi,text |
mov ecx,10*21*4 |
cld |
rep movsb |
mov eax,13 |
mov ebx,20*65536+260 |
mov ecx,22*65536+220 |
mov edx,[wcolor] |
int 0x40 |
mov eax,10*19+1 |
noeaxz: |
mov [pos],eax |
pop ebx |
and ebx,0xff |
call draw_data |
jmp still |
draw_data: |
pusha |
xchg eax,ebx |
mov ecx,10 |
shl ebx,2 |
mov esi,3 |
newnum: |
xor edx,edx |
div ecx |
add edx,48 |
mov [ebx+text-1],dl |
dec ebx |
dec esi |
jnz newnum |
call draw_text |
popa |
ret |
irqtable: |
dd 0x3f8+0x01000000 ; + 01 = read byte, 02 read word |
dd 0 |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+300 ; [x start] *65536 + [x size] |
mov ecx,100*65536+250 ; [y start] *65536 + [y size] |
mov edx,[wcolor] ; color of work area RRGGBB,8->color |
mov edi,labelt ; caption string |
int 0x40 |
; ; WINDOW LABEL |
; mov eax,4 ; function 4 : write text to window |
; mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
; mov ecx,0x00ffffff ; color of text RRGGBB |
; mov edx,labelt ; pointer to text beginning |
; mov esi,labellen-labelt ; text length |
; int 0x40 |
; CLOSE BUTTON |
; mov eax,8 ; function 8 : define and draw button |
; mov ebx,(300-19)*65536+12 ; [x start] *65536 + [x size] |
; mov ecx,5*65536+12 ; [y start] *65536 + [y size] |
; mov edx,1 ; button id |
; mov esi,0x5599cc ; button color RRGGBB |
; int 0x40 |
draw_text: |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0xffffff |
mov edx,text |
mov esi,40 |
mov edi,20 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,10 |
add edx,esi |
dec edi |
jne newline |
mov eax,12 |
mov ebx,2 |
int 0x40 |
ret |
; DATA AREA |
wcolor dd 0x13000000 |
labelt db 'INFRARED RECEIVER FOR IRMAN IN COM 1',0 |
text: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/system/ir/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm ir.asm ir |
@pause |
/programs/system/ir/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm ir.asm ir |
@pause |
/programs/system/ir/trunk/macros.inc |
---|
0,0 → 1,267 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/system/vrr_m/trunk/build.bat |
---|
File deleted |
\ No newline at end of file |
/programs/system/vrr_m/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm vrr_m.asm vrr_m |
@pause |
/programs/system/vrr_m/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm vrr_m.asm vrr_m |
@pause |
/programs/system/vrr_m/trunk/macros.inc |
---|
123,10 → 123,8 |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
macro __mov reg,a { ; mike.dld |
if ~a eq |
mov reg,a |
end if |
} |
143,6 → 141,11 |
; language for programs |
lang fix ru ; ru en fr ge fi |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 177,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 221,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/system/launcher/trunk/macros.inc |
---|
143,6 → 143,10 |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 178,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 222,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/system/board/trunk/debug.inc |
---|
File deleted |
\ No newline at end of file |
/programs/system/board/trunk/board.asm |
---|
290,10 → 290,18 |
mov ebx,[xstart] |
mov ecx,MAXSTRINGS*10+45 ; [y start] *65536 + [y size] |
mov edx,[sc.work] ; color of work area RRGGBB,8->color gl |
or edx,0x13000000 |
mov edi,header ; WINDOW LABEL |
or edx,0x03000000 |
int 0x40 |
; WINDOW LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
mov ecx,[sc.grab_text] ; color of text RRGGBB |
or ecx,0x10000000 |
mov edx,header ; pointer to text beginning |
mov esi,header.len ; text length |
int 0x40 |
mov ecx,4 |
mov esi,[sc.work] |
mov ebx,316 shl 16+5*6 |
514,11 → 522,17 |
; 11,11 > 0,-1 |
; 5,11 > 0,-1 |
if lang eq ru |
header db ' ',0 |
header: |
db ' ' |
.len = $ - header |
else if lang eq en |
header db 'GENERAL DEBUG & MESSAGE BOARD',0 |
header: |
db 'GENERAL DEBUG & MESSAGE BOARD' |
.len = $ - header |
else |
header db 'ALLGEMEINES DEBUG- & NACHRICHTENBOARD',0 |
header: |
db 'ALLGEMEINES DEBUG- & NACHRICHTENBOARD' |
.len = $ - header |
end if |
krnl_cnt dd 0 |
vmode dd 0 |
/programs/system/board/trunk/build_ge.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix ge >lang.inc |
@fasm board.asm board |
@erase lang.inc |
@pause |
/programs/system/board/trunk/build_en.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm board.asm board |
@erase lang.inc |
@pause |
/programs/system/board/trunk/build_ru.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm board.asm board |
@erase lang.inc |
@pause |
/programs/system/board/trunk/macros.inc |
---|
143,6 → 143,10 |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 178,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 222,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/system/calendar/trunk/build_ge.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix de >lang.inc |
@fasm calendar.asm calendar |
@erase lang.inc |
@pause |
/programs/system/calendar/trunk/build_en.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm calendar.asm calendar |
@erase lang.inc |
@pause |
/programs/system/calendar/trunk/build_ru.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm calendar.asm calendar |
@erase lang.inc |
@pause |
/programs/system/calendar/trunk/macros.inc |
---|
143,6 → 143,9 |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 177,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 221,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/system/cpu/trunk/build_ge.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix de >lang.inc |
@fasm cpu.asm cpu |
@erase lang.inc |
@pause |
/programs/system/cpu/trunk/cpu.asm |
---|
103,7 → 103,7 |
;buttons handlers |
pgdn: |
sub [list_start],display_processes |
; cmp [list_start],0 |
cmp [list_start],0 |
jge still_end |
mov [list_start],0 |
jmp still_end |
114,7 → 114,7 |
jmp still_end |
program_start: |
mov eax,70 |
mov eax,58 |
mov ebx,file_start |
int 0x40 |
jmp still_end |
495,7 → 495,7 |
mov ebx,22*65536+35 ; draw info text with function 4 |
xor ecx,ecx |
mov edx,text |
mov esi,text_len |
mov esi,79 |
mov eax,4 |
int 0x40 |
583,8 → 583,8 |
; DATA AREA |
list_start dd 0 |
file_start: dd 7 |
dd 0,0,0,0 |
file_start: dd 16 |
dd 0,0,0,run_process_buffer |
start_application: db '/RD/1/LAUNCHER',0 |
times 60 db 32 |
593,7 → 593,6 |
text: |
db ' NAME/TERMINATE PID CPU-USAGE % ' |
db 'MEMORY START/USAGE W-STACK W-SIZE' |
text_len = $-text |
tbts: db 'PREV PAGE NEXT PAGE REBOOT SYSTEM' |
tbte: |
608,7 → 607,6 |
text: |
db ' NAME/BEENDEN PID CPU-LAST % ' |
db 'SPEICHER START/NUTZUNG W-STACK W-SIZE' |
text_len = $-text |
tbts: db 'SEITE ZURUECK SEITE VOR REBOOT SYSTEM' |
tbte: |
632,5 → 630,7 |
curposy rd 1 |
index rd 1 |
tasklist rd display_processes |
run_process_buffer: |
process_info_buffer process_information |
rb 4096-($-run_process_buffer) ;rest of run_process_buffer |
U_END: |
/programs/system/cpu/trunk/build_en.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm cpu.asm cpu |
@erase lang.inc |
@pause |
/programs/system/cpu/trunk/macros.inc |
---|
141,8 → 141,6 |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 172,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 216,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/system/pcidev/trunk/PCIDEV.ASM |
---|
1,12 → 1,12 |
;*************************************************************** |
; project name: PCI Device Enumeration |
; target platform: KolibriOS and MenuetOS |
; compiler: flat assmebler 1.66 |
; version: 2.0 |
; last update: 30(th) August 2006 |
; maintained by: Jason Delozier and Sergey Kuzmin |
; e-mail: cordata51@hotmail.com and kuzmin_serg@list.ru |
; project site: http://www.coolthemes.narod.ru/pcidev.html |
; compiler: flat assmebler 1.63.2 |
; version: 1.31 |
; last update: 13(th) May 2006 |
; maintained by: Jason Delozier (cordata51) |
; e-mail: cordata51@hotmail.com |
; project site: http://www.asmfreaks.com/menuetos |
;*************************************************************** |
;Summary: This program will attempt to scan the PCI Bus |
; and display basic information about each device |
15,27 → 15,9 |
;HISTORY: |
;keep dates in european format (dd/mm/yyyy), please |
; '!' means big changes |
; |
;to-do: |
; PCI version should be normalized 0210 -> 02.10 (it is BCD number) |
; vendor's website |
; more vendors |
; device IRQ |
; Subsystem id and Subsystem vendor id detection |
; Full device detection (like "ATI Radeon 9200") will increase app |
; size a lot and probably it is function of particular drivers |
;PCI version should be normalized (0210->02.10) |
;---------------------------------------------------------------- |
;2.0: PCIDEV 30/08/2006 |
;(it differs a lot from the version 1.0, which was introduced 19 months ago) |
;Author: Marat Zakiyanov aka Mario79 <mario79@bk.ru> |
; Sergey Kuzmin aka Wildwest <kuzmin_serg@list.ru> |
;Features: |
; added |
; * Detection of Interface by Mario79 |
; * 122 vendor id's by Wildwest |
; * Description is based on Class, SubClass and Interface now (PCI 3.0) by Wildwest |
;---------------------------------------------------------------- |
;1.31: PCIDEV 13/05/2006 |
;Author: Jason Delozier <cordata51@hotmail.com> |
;Features: |
135,7 → 117,8 |
include 'macros.inc' |
include 'VENDORS.INC' |
include 'vendors.inc' |
include 'lang.inc' |
START: ; start of execution |
call draw_window |
226,7 → 209,7 |
mov ebx, 20*65536+25 ;x start, ystart of text |
mov ecx, 0x224466 ;color of text |
mov edx, dword PCIWin ;start of text buffer |
mov esi, 106 ;lenght of line 106 |
mov esi, 106 ;lenght of line |
newline: ; |
mov eax, 4 ;draw text system function |
int 0x40 ;draw the text |
241,8 → 224,8 |
shl ebx, 16 ; |
mov bx,word [Form] ;get width of window |
sub bx, 32 ;bar is 32 pixels shorter then window width |
mov ecx, 119*65536+10 ;set Ystart(109) and Height(10) of bar 109 |
mov edx, 0xC0C0C0 ;set color of bar |
mov ecx, 109*65536+10 ;set Ystart(109) and Height(10) of bar |
mov edx, 0xb6b6b6 ;set color of bar |
again: ;begin draw bar loop |
int 0x40 ;draw bar to window area |
shr ecx, 16 ;move the Ystart position to working area |
288,7 → 271,7 |
;****************************************************** |
;* Gets the PCI Version and Last Bus |
;* Gets the PCI Versioin and Last Bus |
Get_PCI_Info: |
mov eax, 62 |
xor ebx, ebx |
343,12 → 326,6 |
mov cl, 0x0a ;Register to read (Get Subclass) |
int 0x40 ;Read it |
mov byte [PCI_SubClass], al ;Save it |
; from Mario79 august 2006 |
mov eax, 62 ;PCI Sys Function |
mov cl, 0x09 ;Register to read (Get Interface) |
int 0x40 ;Read it |
mov [PCI_Interface], al ;Save it |
; |
inc byte [total] ;one more device found |
call Print_New_Device ;print device info to screen |
nextDev: |
401,15 → 378,9 |
movzx ecx,byte [PCI_Class] ;get PCI_Class |
int 0x40 ;Draw Class to screen |
and edx, 0xFFFF ;***************************************** |
or edx, 250*65536 ;X start becomes 250 |
or edx, 266*65536 ;X start becomes 266 |
movzx ecx,byte [PCI_SubClass];get sub class |
int 0x40 ;Draw Sub Class to screen |
; from Mario79 august 2006 |
and edx, 0xFFFF ;***************************************** |
or edx, 280*65536 ;X start becomes 280 |
movzx ecx, [PCI_Interface] ;get Interface |
int 0x40 |
; |
;Write Names |
movzx ebx, dx ;Set y position |
or ebx, 310*65536 ;set Xposition to 310 |
425,22 → 396,22 |
;first determine which list to find the vendor in |
mov ax, word [PCI_Vendor] |
mov ecx, 255 ;# vendors in most lists |
cmp ax,4540 ;Check if Vendor's value is less than this number (the start of next part) |
cmp ax,4800 ;Check if Vendor's value is less than this number |
jae next1 ;if it is less, let's continue, or jump to next1 |
mov edx, _FIRSTPART ;select this list |
jmp rep1 ;start searching list |
next1: ; |
cmp ax,5120 ;same thing happening here as above^ |
cmp ax,5314 ;same thing happening here as above^ |
jae next2 ; |
mov edx, _SECONDPART ; |
jmp rep1 ; |
next2: ; |
cmp ax,5459 ; |
cmp ax,5574 ; |
jae next3 ; |
mov edx, _THIRDPART ; |
jmp rep1 ; |
next3: ; |
mov ecx, 222 ;only 222 vendors in this list |
mov ecx, 110 ;only 110 vendors in this list |
mov edx, _FOURTHPART ; |
rep1: |
457,6 → 428,7 |
mov eax,4 ;OS CMD |
mov esi,50 ;Length of text |
int 0x40 ;Print the text |
;------------------------------------------------------------------ |
;------------------------------------------------------------------ |
;Get description based on Class/Subclass |
466,556 → 438,14 |
shl eax, 3 ;multiply for jump table |
mov ecx, [ClassList+eax+4] ;number of descriptions for this class |
mov edx, [ClassList+eax] ;start of description list for class |
mov al, byte [PCI_SubClass] ;get subclass |
; mov ah, byte [PCI_Interface] ;get subclass |
movzx eax, byte [PCI_SubClass] ;get subclass |
repu1: |
cmp al,byte[edx+32] ;are subclasses the same? |
je interface_check ;if so jump to print the description to screen |
je endd ;if so jump to print the description to screen |
add edx, 33 ;if not put us at start of next description |
dec ecx ;one less description in list |
jnz repu1 ;was it our last? |
mov edx,_UNKNOWND ;if so its unknown device |
jmp endd |
interface_check: |
cmp [PCI_Class], 00h |
je endd |
;//////////////////////////// |
cmp [PCI_Class], 01h |
je check01 |
jmp nextclass02 |
check01: |
cmp [PCI_SubClass], 05h |
je sc01_05 |
jmp endd |
sc01_05: |
cmp [PCI_Interface], 20h |
je sc01_05_20 |
cmp [PCI_Interface], 30h |
je sc01_05_30 |
jmp endd |
sc01_05_20: |
mov edx,ata1 ; pointer to text beginning |
jmp endd |
sc01_05_30: |
mov edx,ata2 ; pointer to text beginning |
jmp endd |
;//////////////////////////// |
nextclass02: |
cmp [PCI_Class], 02h |
je endd |
;//////////////////////////////// |
cmp [PCI_Class], 03h |
je check03 |
jmp nextclass04 |
check03: |
cmp [PCI_SubClass], 00h |
je sc03_00 |
jmp endd |
sc03_00: |
cmp [PCI_Interface], 00000000b |
je sc03_00_00000000 |
cmp [PCI_Interface], 00000001b |
je sc03_00_00000001 |
;jmp endd |
sc03_00_00000000: |
mov edx,display1 ; pointer to text beginning |
jmp endd |
sc03_00_00000001: |
mov edx,display2 ; pointer to text beginning |
jmp endd |
;/////////////////////////////// |
nextclass04: |
cmp [PCI_Class], 04h |
je endd |
cmp [PCI_Class], 05h |
je endd |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
cmp [PCI_Class], 06h |
je check06 |
jmp nextclass07 |
check06: |
cmp [PCI_SubClass], 04h |
je sc06_04 |
cmp [PCI_SubClass], 09h |
je sc06_09 |
jmp endd |
sc06_04: |
cmp [PCI_Interface], 00h |
je sc06_04_00 |
cmp [PCI_Interface], 01h |
je sc06_04_01 |
jmp endd |
sc06_04_00: |
mov edx,bridge1 ; pointer to text beginning |
jmp endd |
sc06_04_01: |
mov edx,bridge2 ; pointer to text beginning |
jmp endd |
;====================================== |
sc06_09: |
cmp [PCI_Interface], 40h |
je sc06_09_40 |
cmp [PCI_Interface], 80h |
je sc06_09_80 |
jmp endd |
sc06_09_40: |
mov edx,bridge3 ; pointer to text beginning |
jmp endd |
sc06_09_80: |
mov edx,bridge4 ; pointer to text beginning |
jmp endd |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
nextclass07: |
cmp [PCI_Class], 07h |
je check07 |
jmp nextclass08 |
check07: |
cmp [PCI_SubClass], 00h |
je sc07_00 |
cmp [PCI_SubClass], 01h |
je sc07_01 |
cmp [PCI_SubClass], 03h |
je sc07_03 |
jmp endd |
;= |
sc07_00: |
cmp [PCI_Interface], 00h |
je sc07_00_00 |
cmp [PCI_Interface], 01h |
je sc07_00_01 |
cmp [PCI_Interface], 02h |
je sc07_00_02 |
cmp [PCI_Interface], 03h |
je sc07_00_03 |
cmp [PCI_Interface], 04h |
je sc07_00_04 |
cmp [PCI_Interface], 05h |
je sc07_00_05 |
cmp [PCI_Interface], 06h |
je sc07_00_06 |
sc07_00_00: |
mov edx,communication0 ; pointer to text beginning |
jmp endd |
sc07_00_01: |
mov edx,communication1 ; pointer to text beginning |
jmp endd |
sc07_00_02: |
mov edx,communication2 ; pointer to text beginning |
jmp endd |
sc07_00_03: |
mov edx,communication3 ; pointer to text beginning |
jmp endd |
sc07_00_04: |
mov edx,communication4 ; pointer to text beginning |
jmp endd |
sc07_00_05: |
mov edx,communication5 ; pointer to text beginning |
jmp endd |
sc07_00_06: |
mov edx,communication6 ; pointer to text beginning |
jmp endd |
;= |
sc07_01: |
cmp [PCI_Interface], 00h |
je sc07_01_00 |
cmp [PCI_Interface], 01h |
je sc07_01_01 |
cmp [PCI_Interface], 02h |
je sc07_01_02 |
cmp [PCI_Interface], 03h |
je sc07_01_03 |
cmp [PCI_Interface], $FE |
je sc07_01_FE |
sc07_01_00: |
mov edx,communication7 ; pointer to text beginning |
jmp endd |
sc07_01_01: |
mov edx,communication8 ; pointer to text beginning |
jmp endd |
sc07_01_02: |
mov edx,communication9 ; pointer to text beginning |
jmp endd |
sc07_01_03: |
mov edx,communication10 ; pointer to text beginning |
jmp endd |
sc07_01_FE: |
mov edx,communication11 ; pointer to text beginning |
jmp endd |
;= |
sc07_03: |
cmp [PCI_Interface], 00h |
je sc07_03_00 |
cmp [PCI_Interface], 01h |
je sc07_03_01 |
cmp [PCI_Interface], 02h |
je sc07_03_02 |
cmp [PCI_Interface], 03h |
je sc07_03_03 |
cmp [PCI_Interface], 04h |
je sc07_03_04 |
sc07_03_00: |
mov edx,communication12 ; pointer to text beginning |
jmp endd |
sc07_03_01: |
mov edx,communication13 ; pointer to text beginning |
jmp endd |
sc07_03_02: |
mov edx,communication14 ; pointer to text beginning |
jmp endd |
sc07_03_03: |
mov edx,communication15 ; pointer to text beginning |
jmp endd |
sc07_03_04: |
mov edx,communication16 ; pointer to text beginning |
jmp endd |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
nextclass08: |
cmp [PCI_Class], 08h |
je check08 |
jmp nextclass09 |
check08: |
cmp [PCI_SubClass], 00h |
je sc08_00 |
cmp [PCI_SubClass], 01h |
je sc08_01 |
cmp [PCI_SubClass], 02h |
je sc08_02 |
cmp [PCI_SubClass], 03h |
je sc08_03 |
jmp endd |
;-- |
sc08_00: |
cmp [PCI_Interface], 00h |
je sc08_00_00 |
cmp [PCI_Interface], 01h |
je sc08_00_01 |
cmp [PCI_Interface], 02h |
je sc08_00_02 |
cmp [PCI_Interface], 10h |
je sc08_00_10 |
cmp [PCI_Interface], 20h |
je sc08_00_20 |
jmp endd |
sc08_00_00: |
mov edx,system0 ; pointer to text beginning |
jmp endd |
sc08_00_01: |
mov edx,system1 ; pointer to text beginning |
jmp endd |
sc08_00_02: |
mov edx,system2 ; pointer to text beginning |
jmp endd |
sc08_00_10: |
mov edx,system3 ; pointer to text beginning |
jmp endd |
sc08_00_20: |
mov edx,system4 ; pointer to text beginning |
jmp endd |
;-- |
sc08_01: |
cmp [PCI_Interface], 00h |
je sc08_01_00 |
cmp [PCI_Interface], 01h |
je sc08_01_01 |
cmp [PCI_Interface], 02h |
je sc08_01_02 |
jmp endd |
sc08_01_00: |
mov edx,system5 ; pointer to text beginning |
jmp endd |
sc08_01_01: |
mov edx,system6 ; pointer to text beginning |
jmp endd |
sc08_01_02: |
mov edx,system7 ; pointer to text beginning |
jmp endd |
;-- |
sc08_02: |
cmp [PCI_Interface], 00h |
je sc08_02_00 |
cmp [PCI_Interface], 01h |
je sc08_02_01 |
cmp [PCI_Interface], 02h |
je sc08_02_02 |
jmp endd |
sc08_02_00: |
mov edx,system8 ; pointer to text beginning |
jmp endd |
sc08_02_01: |
mov edx,system9 ; pointer to text beginning |
jmp endd |
sc08_02_02: |
mov edx,system10 ; pointer to text beginning |
jmp endd |
;-- |
sc08_03: |
cmp [PCI_Interface], 00h |
je sc08_03_00 |
cmp [PCI_Interface], 01h |
je sc08_03_01 |
jmp endd |
sc08_03_00: |
mov edx,system11 ; pointer to text beginning |
jmp endd |
sc08_03_01: |
mov edx,system12 ; pointer to text beginning |
jmp endd |
;-- |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
nextclass09: |
cmp [PCI_Class], 09h |
je check09 |
jmp nextclass0A |
check09: |
cmp [PCI_SubClass], 04h |
je sc09_04 |
jmp endd |
sc09_04: |
cmp [PCI_Interface], 00h |
je sc09_04_00 |
cmp [PCI_Interface], 10h |
je sc09_04_10 |
jmp endd |
sc09_04_00: |
mov edx,gameport1 ; pointer to text beginning |
jmp endd |
sc09_04_10: |
mov edx,gameport2 ; pointer to text beginning |
jmp endd |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
nextclass0A: |
cmp [PCI_Class], 0Ah |
je endd |
cmp [PCI_Class], 0Bh |
je endd |
;============================================ |
cmp [PCI_Class], 0Ch |
je check0C |
jmp nextclass0D |
check0C: |
cmp [PCI_SubClass], 00h |
je sc0C_00 |
cmp [PCI_SubClass], 03h |
je sc0C_03 |
cmp [PCI_SubClass], 07h |
je sc0C_07 |
jmp endd |
;;;;;;;;;;; |
sc0C_00: |
cmp [PCI_Interface], 00h |
je sc0C_00_00 |
cmp [PCI_Interface], 10h |
je sc0C_00_10 |
sc0C_00_00: |
mov edx,serialbus6 ; pointer to text beginning |
jmp endd |
sc0C_00_10: |
mov edx,serialbus7 ; pointer to text beginning |
jmp endd |
;;;;;;;;;;;;;;;;;;; |
sc0C_03: |
cmp [PCI_Interface], 00h |
je sc0C_03_00 |
cmp [PCI_Interface], 10h |
je sc0C_03_10 |
cmp [PCI_Interface], 20h |
je sc0C_03_20 |
cmp [PCI_Interface], 80h |
je sc0C_03_80 |
cmp [PCI_Interface], $FE |
je sc0C_03_FE |
;jmp endd |
sc0C_03_00: |
mov edx,serialbus1 ; pointer to text beginning |
jmp endd |
sc0C_03_10: |
mov edx,serialbus2 ; pointer to text beginning |
jmp endd |
sc0C_03_20: |
mov edx,serialbus3 ; pointer to text beginning |
jmp endd |
sc0C_03_80: |
mov edx,serialbus4 ; pointer to text beginning |
jmp endd |
sc0C_03_FE: |
mov edx,serialbus5 ; pointer to text beginning |
jmp endd |
;;;;;;;;;;; |
sc0C_07: |
cmp [PCI_Interface], 00h |
je sc0C_07_00 |
cmp [PCI_Interface], 01h |
je sc0C_07_01 |
cmp [PCI_Interface], 02h |
je sc0C_07_02 |
sc0C_07_00: |
mov edx,serialbus8 ; pointer to text beginning |
jmp endd |
sc0C_07_01: |
mov edx,serialbus9 ; pointer to text beginning |
jmp endd |
sc0C_07_02: |
mov edx,serialbus10 ; pointer to text beginning |
jmp endd |
;;;;;;;;;;;;;;;;;;; |
;============================================== |
nextclass0D: |
cmp [PCI_Class], 0Dh |
je endd |
;;;;;;;;;;;;;;;;;;;;;;;;;; |
cmp [PCI_Class], 0Eh |
je check0E |
jmp nextclass0F |
check0E: |
cmp [PCI_SubClass], 00h |
je sc0E_00 |
jmp endd |
sc0E_00: |
cmp [PCI_Interface], 00h |
je sc0E_00_00 |
cmp [PCI_Interface], 00h ;!!! |
ja sc0E_00_xx |
jmp endd |
sc0E_00_00: |
mov edx,i2o1 ; pointer to text beginning |
jmp endd |
sc0E_00_xx: |
mov edx,i2o2 ; pointer to text beginning |
jmp endd |
;//////////////////////////// |
nextclass0F: |
cmp [PCI_Class], 0Fh |
je endd |
cmp [PCI_Class], 10h |
je endd |
cmp [PCI_Class], 11h |
je endd |
endd: |
and ebx, 0x0000FFFF ;clear X position |
or ebx, 0x02300000 ;set X position to 560 pixels |
1041,226 → 471,30 |
; DATA AREA |
labelt: |
db 'PCI Device Enumeration v 2.0 by J. Delozier, S. Kuzmin, V. Hanla, M. Zakiyanov' |
db 'PCI Device Enumeration v 1.31 by J. Delozier, S. Kuzmin and V. Hanla' |
labellen: |
ata1: |
db 'Storage - ATA c. w/ single DMA ' |
ata1len: |
ata2: |
db 'Storage - ATA c. w/ chained DMA ' |
ata2len: |
display1: |
db 'Display - VGA-compatible c. ' |
display1len: |
display2: |
db 'Display - 8514-compatible c. ' |
display2len: |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
serialbus1: |
db 'Serial Bus - USB Universal HC ' |
serialbus1len: |
serialbus2: |
db 'Serial Bus - USB Open HC ' |
serialbus2len: |
serialbus3: |
db 'Serial Bus - USB2 Enhanced HC ' |
serialbus3len: |
serialbus4: |
db 'Serial Bus - USB w/o specific PI' |
serialbus4len: |
serialbus5: |
db 'Serial Bus - USB device (not HC)' |
serialbus5len: |
serialbus6: |
db 'Serial Bus - IEEE 1394(FireWire)' |
serialbus6len: |
serialbus7: |
db 'Serial Bus- IEEE 1394(Open HCI) ' |
serialbus7len: |
serialbus8: |
db 'Serial Bus - IPMI SMIC I. ' |
serialbus8len: |
serialbus9: |
db 'Serial Bus - IPMI Kybd CSI ' |
serialbus9len: |
serialbus10: |
db 'Serial Bus - IPMI BTI ' |
serialbus10len: |
;;;;;;;;;;;;;;;;;;;;;;; |
bridge1: |
db 'Bridge - PCI/PCI ' |
bridge1len: |
bridge2: |
db 'Bridge - Subtract.Decode PCI/PCI' |
bridge2len: |
bridge3: |
db 'Bridge - Semi-transp. PCI/PCI 1 ' |
bridge3len: |
bridge4: |
db 'Bridge - Semi-transp. PCI/PCI 2 ' |
bridge4len: |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
gameport1: |
db 'Input - Gameport c. (generic) ' |
gameport1len: |
gameport2: |
db 'Input - Gameport c. (legacy) ' |
gameport2len: |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
i2o1: |
db 'Intelligent I/O - I/O c. (I2O 1)' |
i2o1len: |
i2o2: |
db 'Intelligent I/O - c.(FIFO @ 40h)' |
i2o2len: |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
communication0: |
db 'Communication - Serial (XT) ' |
communication0len: |
communication1: |
db 'Communication - Serial c.(16450)' |
communication1len: |
communication2: |
db 'Communication - Serial c.(16550)' |
communication2len: |
communication3: |
db 'Communication - Serial c.(16650)' |
communication3len: |
communication4: |
db 'Communication - Serial c.(16750)' |
communication4len: |
communication5: |
db 'Communication - Serial c.(16850)' |
communication5len: |
communication6: |
db 'Communication - Serial c.(16950)' |
communication6len: |
;------------------------------- |
communication7: |
db 'Communication - Parallel port ' |
communication7len: |
communication8: |
db 'Communication - Bi-dir. par.port' |
communication8len: |
communication9: |
db 'Communication - ECP 1.X par.port' |
communication9len: |
communication10: |
db 'Communication - IEEE1284 c. ' |
communication10len: |
communication11: |
db 'Communication - IEEE1284 device ' |
communication11len: |
;------------------------------- |
communication12: |
db 'Communication - Generic modem ' |
communication12len: |
communication13: |
db 'Communication -Hayes modem 16450' |
communication13len: |
communication14: |
db 'Communication -Hayes modem 16550' |
communication14len: |
communication15: |
db 'Communication -Hayes modem 16650' |
communication15len: |
communication16: |
db 'Communication -Hayes modem 16750' |
communication16len: |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
system0: |
db 'System - Generic 8259 PIC ' |
system0len: |
system1: |
db 'System - ISA PIC ' |
system1len: |
system2: |
db 'System - EISA PIC ' |
system2len: |
system3: |
db 'System - I/O APIC interrupt c. ' |
system3len: |
system4: |
db 'System - I/O(x) APIC interrupt c' |
system4len: |
;- |
system5: |
db 'System - Generic 8237 DMA c. ' |
system5len: |
system6: |
db 'System - ISA DMA c. ' |
system6len: |
system7: |
db 'System - EISA DMA c. ' |
system7len: |
;-- |
system8: |
db 'System - 8254 system timer ' |
system8len: |
system9: |
db 'System - ISA system timer ' |
system9len: |
system10: |
db 'System - EISA (2 system timers) ' |
system10len: |
;-- |
system11: |
db 'System - Generic RTC c. ' |
system11len: |
system12: |
db 'System - ISA RTC c. ' |
system12len: |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
if lang eq de |
PCIWin: |
db 'Im Einstellungsmenue muss der PCI Zugriff eingeschaltet sein. ' |
db ' ' |
db ' ' |
db ' ' |
db 'PCI Version = ' |
db ' ' |
db 'Letzter PCI Bus = ' |
db ' ' |
db 'Anzahl von Geraeten = ' |
db ' ' |
db ' ' |
db ' ' |
db 'VenID DevID Bus# Dev# Fnc Rev Class Subclass Herste' |
db 'ller Beschreibung ' |
db '----- ----- ---- ---- --- --- ----- -------- --------------------' |
db '---------------------- ----------------' |
db 'x' |
else |
PCIWin: |
db 'Please remember to enable PCI Access to Applications in Setup Menu.' |
db ' ' |
db ' ' |
1269,19 → 503,17 |
db ' ' |
db 'Last PCI Bus = ' |
db ' ' |
db 'Quantity of devices = ' |
db 'Number of devices = ' |
db ' ' |
db ' ' |
db ' ' |
db 'VenID DevID Bus# Dev# Fnc Rev Class Subclass/ Comp' |
db 'VenID DevID Bus# Dev# Fnc Rev Class Subclass Comp' |
db 'any Description ' |
db ' Interface ' |
db ' ' |
db '----- ----- ---- ---- --- --- ----- -------- --------------------' |
db '---------------------- ----------------' |
db 'x' |
end if |
; |
total db 0 |
V_Bus db 0 |
1295,8 → 527,8 |
PCI_Rev db 0 |
PCI_Class db 0 |
PCI_SubClass db 0 |
PCI_Interface db 0 |
Proc_Info: |
times 1024 db 0 |
/programs/system/pcidev/trunk/vendors.inc |
---|
1,17 → 1,3 |
;WriteTextToWindow |
macro Text xStart,yStart,rgbColor,pText,nTextLen |
{ |
mov ebx,xStart |
shl ebx,16 |
add ebx,yStart |
mov ecx,rgbColor |
mov edx,pText |
mov esi,nTextLen |
mov eax,4 |
int 0x40 |
} |
; AUTHOR: Victor Alberto Gil Hancco Laquita <vhanla@gmail.com> |
; This list might content mistakes, plz report it |
; There are 865 Lists of Vendors' Names |
23,13 → 9,10 |
; changed 11/05/2006: + 3 vendors and no more label 'PREVIOUSVERSIONLIST' |
; so the total quantity of vendors is 875 now (changes by Sergey Kuzmin) |
; changed 16/08/2006: + 122 vendors |
; so the total quantity of vendors is 987 now (changes by Sergey Kuzmin) |
_FIRSTPART: ;lists the 255 Vendor IDs |
db 'PARADYNE CORP. ' |
dw 51 ; 0x0033 |
db 'Lockheed Martin Corp ' |
db 'REAL 3D ' |
dw 61 ; 0x003D |
db 'NCIPHER CORP. LTD ' |
dw 256 ; 0x0100 |
43,31 → 26,19 |
dw 4097 ; 0x1001 |
db 'ATI TECHNOLOGIES INC ' |
dw 4098 ; 0x1002 |
db 'ULSI ' |
dw 4099 ; 0x1003 |
db 'VLSI TECHNOLOGY INC ' |
dw 4100 ; 0x1004 |
db 'NATIONAL SEMICONDUCTOR CORPORATION ' |
dw 4107 ; 0x100B |
db 'Tseng Labs ' |
dw 4108 ; 0x100C |
db 'Weitek ' |
dw 4110 ; 0x100E |
db 'VIDEO LOGIC LTD ' |
dw 4112 ; 0x1010 |
db 'Digital Equipment Corporation ' |
dw 4113 ; 0x1011 |
db 'Cirrus Logic ' |
dw 4115 ; 0x1013 |
db 'IBM ' |
dw 4116 ; 0x1014 |
db 'Spea Software AG ' |
dw 4119 ; 0x1017 |
db 'UNISYS CORPORATION ' |
dw 4120 ; 0x1018 |
db 'ELITEGROUP COMPUTER SYS ' |
dw 4121 ; 0x1019 |
db 'NCR Corporation ' |
db 'NCR ' |
dw 4122 ; 0x101A |
db 'AMERICAN MEGATRENDS ' |
dw 4126 ; 0x101E |
79,8 → 50,6 |
dw 4130 ; 0x1022 |
db 'TRIDENT MICROSYSTEMS ' |
dw 4131 ; 0x1023 |
db 'Acer Incorporated ' |
dw 4133 ; 0x1025 |
db 'DELL COMPUTER CORPORATION ' |
dw 4136 ; 0x1028 |
db 'LSI LOGIC CORPORATION ' |
87,24 → 56,14 |
dw 4138 ; 0x102A |
db 'MATROX GRAPHICS ' |
dw 4139 ; 0x102B |
db 'Asiliant (Chips And Technologies) ' |
dw 4140 ; 0x102C |
db 'Wyse Technologies ' |
dw 4141 ; 0x102D |
db 'TOSHIBA AMERICA ' |
dw 4143 ; 0x102F |
db 'miro Computer Products AG ' |
dw 4145 ; 0x1031 |
db 'NEC CORPORATION ' |
dw 4147 ; 0x1033 |
db 'Future Domain ' |
dw 4150 ; 0x1036 |
db 'AMP ' |
dw 4152 ; 0x1038 |
db 'SILICON INTEGRATED SYSTEMS ' |
dw 4153 ; 0x1039 |
db 'Hewlett-Packard Company ' |
dw 4156 ; 0x103C |
db 'SYNOPSYS/LOGIC MODELING GROUP ' |
dw 4159 ; 0x103F |
db 'Micron Electronics ' |
119,31 → 78,21 |
dw 4168 ; 0x1048 |
db 'FOUNTAIN TECHNOLOGIES ' |
dw 4169 ; 0x1049 |
db 'STMicroelectronics ' |
dw 4170 ; 0x104A |
db 'TEXAS INSTRUMENTS ' |
dw 4172 ; 0x104C |
db 'SONY CORPORATION ' |
dw 4173 ; 0x104D |
db 'Oak Technology ' |
dw 4174 ; 0x104E |
db 'Co-Time Computer Ltd. ' |
dw 4175 ; 0x104F |
db 'WINBOND ELECTRONICS CORP ' |
dw 4176 ; 0x1050 |
db 'Anigma Corp. ' |
dw 4177 ; 0x1051 |
db 'HITACHI ' |
dw 4180 ; 0x1054 |
db 'Standard Microsystems Corp. ' |
dw 4181 ; 0x1055 |
db 'Motorola ' |
dw 4183 ; 0x1057 |
db 'ETRI ' |
dw 4184 ; 0x1058 |
db 'TEKNOR INDUSTRIAL COMPUTERS INC ' |
dw 4185 ; 0x1059 |
db 'PROMISE TECHNOLOGY ' |
db 'PROMISE TECHNOLOGY. ' |
dw 4186 ; 0x105A |
db 'FOXCONN INTERNATIONAL INC ' |
dw 4187 ; 0x105B |
151,18 → 100,10 |
dw 4189 ; 0x105D |
db 'INFOTRONIC AMERICA INC ' |
dw 4191 ; 0x105F |
db 'United Microelectronics ' |
dw 4192 ; 0x1060 |
db '8x8 Inc. ' |
dw 4193 ; 0x1061 |
db 'OCEAN MANUFACTURING LTD ' |
dw 4195 ; 0x1063 |
db 'ALCATEL ' |
dw 4196 ; 0x1064 |
db 'Texas Microsystems ' |
dw 4197 ; 0x1065 |
db 'Picopower Technology ' |
dw 4198 ; 0x1066 |
db 'MITSUBISHI ELECTRIC AMERICA ' |
dw 4199 ; 0x1067 |
db 'DIVERSIFIED TECHNOLOGY ' |
171,8 → 112,6 |
dw 4201 ; 0x1069 |
db 'APPLE COMPUTER INC. ' |
dw 4203 ; 0x106B |
db 'Hyundai Electronics America ' |
dw 4204 ; 0x106C |
db 'SEQUENT COMPUTER SYSTEMS ' |
dw 4205 ; 0x106D |
db 'DAEWOO TELECOM LTD ' |
181,54 → 120,24 |
dw 4209 ; 0x1071 |
db 'YAMAHA CORPORATION ' |
dw 4211 ; 0x1073 |
db 'Nexgen Microsystems ' |
dw 4212 ; 0x1074 |
db 'Chaintech Comp. ' |
dw 4214 ; 0x1076 |
db 'QLOGIC Corporation ' |
db 'QLOGIC ' |
dw 4215 ; 0x1077 |
db 'Cyrix Corporation ' |
dw 4216 ; 0x1078 |
db 'I-BUS ' |
dw 4217 ; 0x1079 |
db 'GATEWAY 2000 ' |
dw 4219 ; 0x107B |
db 'Leadtek Research ' |
dw 4221 ; 0x107D |
db 'INTERPHASE CORPORATION ' |
dw 4222 ; 0x107E |
db 'Data Technology Corporation ' |
dw 4223 ; 0x107F |
db 'Cypress Semiconductor ' |
dw 4224 ; 0x1080 |
db 'Radius Inc. ' |
dw 4225 ; 0x1081 |
db 'Forex Computer Corporation ' |
dw 4227 ; 0x1083 |
db 'Tulip Computers International BV ' |
dw 4229 ; 0x1085 |
db 'Cache Computer ' |
dw 4231 ; 0x1087 |
db 'SBS Operations ' |
dw 4234 ; 0x108A |
db 'OLICOM ' |
dw 4237 ; 0x108D |
db 'Sun Microsystems ' |
dw 4238 ; 0x108E |
db 'Intergraph Corporation ' |
dw 4241 ; 0x1091 |
db 'Diamond Computer Systems ' |
dw 4242 ; 0x1092 |
db 'National Instruments ' |
dw 4243 ; 0x1093 |
db 'SILICON IMAGE (WAS CMD TECHNOLOGY INC) ' |
dw 4245 ; 0x1095 |
db 'ALACRON ' |
dw 4246 ; 0x1096 |
db 'APPIAN Graphics/ETMA ' |
db 'APPIAN/ETMA ' |
dw 4247 ; 0x1097 |
db 'Quantum Designs Ltd. ' |
dw 4248 ; 0x1098 |
db 'PACKARD BELL NEC ' |
dw 4250 ; 0x109A |
db 'BROOKTREE CORPORATION ' |
239,16 → 148,10 |
dw 4256 ; 0x10A0 |
db 'QUANTUM EFFECT DESIGN ' |
dw 4258 ; 0x10A2 |
db 'Globe Manufacturing Sales ' |
dw 4260 ; 0x10A4 |
db 'Sierra Semiconductor ' |
dw 4264 ; 0x10A8 |
db 'SILICON GRAPHICS ' |
dw 4265 ; 0x10A9 |
db 'HONEYWELL IAC ' |
dw 4268 ; 0x10AC |
db 'Winbond Systems Labs ' |
dw 4269 ; 0x10AD |
db 'MICRO COMPUTER SYSTEMS INC ' |
dw 4271 ; 0x10AF |
db 'PLX TECHNOLOGY. ' |
257,20 → 160,12 |
dw 4278 ; 0x10B6 |
db '3COM Corp, Networking Division ' |
dw 4279 ; 0x10B7 |
db 'Standard Microsystems Corporation ' |
dw 4280 ; 0x10B8 |
db 'ACER LABS Incorp. ' |
dw 4281 ; 0x10B9 |
db 'MITSUBISHI ELECTRIC CORP. ' |
dw 4282 ; 0x10BA |
db 'Surecom Technology ' |
dw 4285 ; 0x10BD |
db 'AUSPEX SYSTEMS INC. ' |
dw 4290 ; 0x10C2 |
db 'Samsung Semiconductors ' |
dw 4291 ; 0x10C3 |
db 'Award Software International Inc. ' |
dw 4292 ; 0x10C4 |
db 'NEOMAGIC CORPORATION ' |
dw 4296 ; 0x10C8 |
db 'FUJITSU MICROELECTRONIC ' |
285,12 → 180,8 |
dw 4305 ; 0x10D1 |
db 'MOLEX INCORPORATED ' |
dw 4306 ; 0x10D2 |
db 'Macronix International Co. Ltd. ' |
dw 4313 ; 0x10D9 |
db 'ROHM LSI SYSTEMS ' |
dw 4315 ; 0x10DB |
db 'CERN-European Lab. for Particle Physics ' |
dw 4316 ; 0x10DC |
db 'EVANS & SUTHERLAND ' |
dw 4317 ; 0x10DD |
db 'NVIDIA CORPORATION ' |
303,35 → 194,17 |
dw 4323 ; 0x10E3 |
db 'MICRO INDUSTRIES CORPORATION ' |
dw 4325 ; 0x10E5 |
db 'Applied Micro Circuits Corp. ' |
dw 4328 ; 0x10E8 |
db 'Tvia, Inc. ' |
dw 4330 ; 0x10EA |
db 'Artist Graphics ' |
dw 4331 ; 0x10EB |
db 'REALTEK SEMICONDUCTOR CORP. ' |
dw 4332 ; 0x10EC |
db 'Ascii Corporation ' |
dw 4333 ; 0x10ED |
db 'XILINX ' |
db 'XILINX. ' |
dw 4334 ; 0x10EE |
db 'Racore Computer Products ' |
dw 4335 ; 0x10EF |
db 'Curtiss-Wright Controls Embedded Computing ' |
dw 4336 ; 0x10F0 |
db 'TYAN COMPUTER ' |
dw 4337 ; 0x10F1 |
db 'S-Mos Systems ' |
dw 4340 ; 0x10F4 |
db 'NKK CORPORATION ' |
dw 4341 ; 0x10F5 |
db 'CREATIVE ELECTRONIC SYSTEMS SA ' |
dw 4342 ; 0x10F6 |
db 'Truevision ' |
dw 4346 ; 0x10FA |
db 'Thesys Microelectronics ' |
dw 4347 ; 0x10FB |
db 'I-O DATA DEVICE ' |
db 'I-O DATA DEVICE. ' |
dw 4348 ; 0x10FC |
db 'FAST MULTIMEDIA AG ' |
dw 4350 ; 0x10FE |
343,27 → 216,19 |
dw 4357 ; 0x1105 |
db 'VIA TECHNOLOGIES ' |
dw 4358 ; 0x1106 |
db 'ASCEND COMMUNICATIONS/Stratus Computer ' |
db 'ASCEND COMMUNICATIONS ' |
dw 4359 ; 0x1107 |
db 'Proteon Inc. ' |
dw 4360 ; 0x1108 |
db 'Adaptec/Cogent Data Technologies Inc ' |
dw 4361 ; 0x1109 |
db 'SIEMENS PC SYSTEME GMBH ' |
dw 4362 ; 0x110A |
db 'Chromatic Research Inc ' |
dw 4363 ; 0x110B |
db 'SANTA CRUZ OPERATION ' |
dw 4369 ; 0x1111 |
db 'Osicom Technologies Inc. ' |
dw 4370 ; 0x1112 |
db 'ACCTON TECHNOLOGY ' |
dw 4371 ; 0x1113 |
db 'Atmel Corp. ' |
dw 4372 ; 0x1114 |
db 'Media 100, Inc. ' |
db 'MEDIA 100 ' |
dw 4374 ; 0x1116 |
db 'Datacube Inc. ' |
db 'DATACUBE ' |
dw 4375 ; 0x1117 |
db 'FCI ELECTRONICS ' |
dw 4376 ; 0x1118 |
371,12 → 236,8 |
dw 4377 ; 0x1119 |
db 'EFFICIENT NETWORKS ' |
dw 4378 ; 0x111A |
db 'Tricord Systems Inc. ' |
dw 4380 ; 0x111C |
db 'INTEGRATED DEVICE TECH ' |
dw 4381 ; 0x111D |
db 'Precision Digital Images ' |
dw 4383 ; 0x111F |
db 'EMC CORPORATION ' |
dw 4384 ; 0x1120 |
db 'FORE SYSTEMS INC ' |
383,8 → 244,6 |
dw 4391 ; 0x1127 |
db 'HERMES ELECTRONICS COMPANY ' |
dw 4394 ; 0x112A |
db 'Infomedia ' |
dw 4398 ; 0x112E |
db 'IMAGING TECHNOLOGY ' |
dw 4399 ; 0x112F |
db 'PHILIPS SEMICONDUCTORS ' |
391,7 → 250,7 |
dw 4401 ; 0x1131 |
db 'MITEL CORP ' |
dw 4402 ; 0x1132 |
db 'Eicon Networks Corporation ' |
db 'EICON TECHNOLOGY CORPORATION ' |
dw 4403 ; 0x1133 |
db 'MERCURY COMPUTER SYSTEMS ' |
dw 4404 ; 0x1134 |
407,24 → 266,14 |
dw 4412 ; 0x113C |
db 'SANYO ELECTRIC CO-Information Systems Division ' |
dw 4414 ; 0x113E |
db 'Equinox Systems ' |
dw 4415 ; 0x113F |
db 'CREST MICROSYSTEM INC. ' |
dw 4417 ; 0x1141 |
db 'Alliance Semiconductor CA - USA ' |
dw 4418 ; 0x1142 |
db 'Cincinnati Milacron ' |
dw 4420 ; 0x1144 |
db 'WORKBIT CORPORATION ' |
dw 4421 ; 0x1145 |
db 'FORCE COMPUTERS GMBH ' |
dw 4422 ; 0x1146 |
db 'Interface Corp ' |
dw 4423 ; 0x1147 |
db 'SYSKONNECT/Marvell ' |
db 'SYSKONNECT ' |
dw 4424 ; 0x1148 |
db 'VMIC ' |
dw 4426 ; 0x114A |
db 'ANNABOOKS ' |
dw 4428 ; 0x114C |
db 'DIGI INTERNATIONAL ' |
431,12 → 280,6 |
dw 4431 ; 0x114F |
db 'MELCO INC ' |
dw 4436 ; 0x1154 |
db 'Pine Technology Ltd ' |
dw 4437 ; 0x1155 |
db 'Voarx R&D Inc ' |
dw 4440 ; 0x1158 |
db 'Mutech ' |
dw 4441 ; 0x1159 |
db 'PHOTRON LTD. ' |
dw 4444 ; 0x115C |
db 'XIRCOM ' |
445,14 → 288,8 |
dw 4449 ; 0x1161 |
db 'RENDITION ' |
dw 4451 ; 0x1163 |
db 'Imagraph Corporation ' |
dw 4453 ; 0x1165 |
db 'Reliance Computer Corp./ServerWorks ' |
db 'Reliance Computer ' |
dw 4454 ; 0x1166 |
db 'Centre f/Dev. of Adv. Computing ' |
dw 4457 ; 0x1169 |
db 'Polaris Communications ' |
dw 4458 ; 0x116A |
db 'ELECTRONICS FOR IMAGING ' |
dw 4462 ; 0x116E |
db 'INVENTEC CORPORATION ' |
461,20 → 298,10 |
dw 4465 ; 0x1171 |
db 'ALTERA CORPORATION ' |
dw 4466 ; 0x1172 |
db 'SBE ' |
dw 4470 ; 0x1176 |
db 'Alfa Inc ' |
dw 4472 ; 0x1178 |
db 'TOSHIBA AMERICA INFO SYSTEMS ' |
dw 4473 ; 0x1179 |
db 'GCE-8320B ' |
dw 4475 ; 0x117B |
db 'T/R Systems ' |
dw 4478 ; 0x117E |
db 'RICOH CO LTD ' |
dw 4480 ; 0x1180 |
db 'Dataworld ' |
dw 4485 ; 0x1185 |
db 'D-LINK SYSTEM INC ' |
dw 4486 ; 0x1186 |
db 'ADVANCED TECHNOLOGY LABORATORIES ' |
483,26 → 310,14 |
dw 4489 ; 0x1189 |
db 'PLATYPUS TECHNOLOGY PTY LTD ' |
dw 4491 ; 0x118B |
db 'Corollary Inc ' |
db 'COROLLARY ' |
dw 4492 ; 0x118C |
db 'BitFlow Inc ' |
dw 4493 ; 0x118D |
db 'Hermstedt AG ' |
dw 4494 ; 0x118E |
db 'Tripace ' |
dw 4496 ; 0x1190 |
db 'ACARD TECHNOLOGY ' |
dw 4497 ; 0x1191 |
db 'RATOC SYSTEMS INC ' |
dw 4501 ; 0x1195 |
db 'Gage Applied Technologies ' |
dw 4503 ; 0x1197 |
db 'Attachmate Corp. ' |
dw 4505 ; 0x1199 |
db 'MINDSHARE. ' |
dw 4506 ; 0x119A |
db 'Omega Micro Inc. ' |
dw 4507 ; 0x119B |
db 'BUG. ' |
dw 4509 ; 0x119D |
db 'FUJITSU MICROELECTRONICS LTD. ' |
511,13 → 326,11 |
dw 4511 ; 0x119F |
db 'HAMAMATSU PHOTONICS K.K. ' |
dw 4513 ; 0x11A1 |
db 'Systech Corp. ' |
dw 4520 ; 0x11A8 |
db 'InnoSys Inc. ' |
db 'INNOSYS ' |
dw 4521 ; 0x11A9 |
db 'ACTEL ' |
dw 4522 ; 0x11AA |
db 'GALILEO TECHNOLOGY LTD/Marvell Semiconductor, Inc.' |
db 'GALILEO TECHNOLOGY LTD. ' |
dw 4523 ; 0x11AB |
db 'LITE-ON COMMUNICATIONS INC ' |
dw 4525 ; 0x11AD |
525,23 → 338,12 |
dw 4526 ; 0x11AE |
db 'AVID TECHNOLOGY INC ' |
dw 4527 ; 0x11AF |
db 'V3 SEMICONDUCTOR INC./Quicklogic Corp ' |
db 'V3 SEMICONDUCTOR INC. ' |
dw 4528 ; 0x11B0 |
db 'EASTMAN KODAK ' |
dw 4530 ; 0x11B2 |
db 'BARR SYSTEMS INC. ' |
dw 4531 ; 0x11B3 |
db 'Radstone Technology Ltd. ' |
dw 4533 ; 0x11B5 |
db 'Xpoint Technologies Inc ' |
dw 4536 ; 0x11B8 |
db 'Pathlight Technology Inc. ' |
dw 4537 ; 0x11B9 |
_SECONDPART: ;lists 255 Vendors |
db 'Network Peripherals Inc ' |
dw 4540 ; 0x11BC |
db 'Pinnacle Systems Inc. ' |
dw 4541 ; 0x11BD |
db 'ASTRODESIGN ' |
dw 4543 ; 0x11BF |
db 'AGERE/LUCENT ' |
556,26 → 358,22 |
dw 4554 ; 0x11CA |
db 'SPECIALIX INTERNATIONAL LTD ' |
dw 4555 ; 0x11CB |
db 'NETACCESS/Primary Rate Inc ' |
db 'NETACCESS ' |
dw 4558 ; 0x11CE |
db 'LOCKHEED MARTIN-Electronics & Communications ' |
dw 4560 ; 0x11D0 |
db 'AuraVision Corporation ' |
db 'AURAVISION ' |
dw 4561 ; 0x11D1 |
db 'INTERCOM INC. ' |
dw 4562 ; 0x11D2 |
db 'Analog Devices, Inc. ' |
db 'ANALOG DEVICES ' |
dw 4564 ; 0x11D4 |
db 'IKON CORPORATION/Tahoma Technology ' |
db 'IKON CORPORATION ' |
dw 4565 ; 0x11D5 |
db 'TOSHIBA TEC CORPORATION ' |
dw 4569 ; 0x11D9 |
db 'NOVELL ' |
dw 4570 ; 0x11DA |
db 'Sega Enterprises Ltd ' |
dw 4571 ; 0x11DB |
db 'Zoran Corporation ' |
dw 4574 ; 0x11DE |
db 'NEW WAVE PDG ' |
dw 4575 ; 0x11DF |
db 'QUICKLOGIC CORPORATION ' |
584,28 → 382,12 |
dw 4588 ; 0x11EC |
db 'DOME IMAGING SYSTEMS INC ' |
dw 4590 ; 0x11EE |
db 'Compu-Shack GmbH ' |
dw 4592 ; 0x11F0 |
db 'Kinetic Systems Corporation ' |
dw 4596 ; 0x11F4 |
db 'Powermatic Data Systems Ltd ' |
dw 4598 ; 0x11F6 |
db 'PMC-SIERRA INC ' |
dw 4600 ; 0x11F8 |
db 'Comtrol Corp ' |
dw 4606 ; 0x11FE |
db 'Network General Corp ' |
dw 4610 ; 0x1202 |
db 'AGFA CORPORATION ' |
dw 4611 ; 0x1203 |
db 'AMDAHL CORPORATION ' |
dw 4614 ; 0x1206 |
db 'Parsytec GmbH ' |
dw 4616 ; 0x1208 |
db 'Sci Systems Inc ' |
dw 4617 ; 0x1209 |
db 'Cyclades Corporation ' |
dw 4622 ; 0x120E |
db 'ESSENTIAL COMMUNICATIONS ' |
dw 4623 ; 0x120F |
db 'PERFORMANCE TECHNOLOGIES. ' |
618,55 → 400,31 |
dw 4634 ; 0x121A |
db 'VIRATA LTD ' |
dw 4635 ; 0x121B |
db 'Ariel Corporation ' |
dw 4640 ; 0x1220 |
db 'CONTEC CO. LTD ' |
dw 4641 ; 0x1221 |
db 'ARTESYN COMMUNICATIONS PRODUCTS INC ' |
dw 4643 ; 0x1223 |
db 'Interactive Images ' |
dw 4644 ; 0x1224 |
db 'TECH-SOURCE ' |
dw 4647 ; 0x1227 |
db 'SICAN GMBH ' |
dw 4652 ; 0x122C |
db 'Aztech System Ltd ' |
dw 4653 ; 0x122D |
db 'MARCONI COMMUNICATIONS LTD ' |
dw 4658 ; 0x1232 |
db 'Sigma Designs, Inc ' |
dw 4662 ; 0x1236 |
db 'Solitron Technologies Inc. ' |
dw 4684 ; 0x124C |
db 'Stallion Technologies ' |
dw 4665 ; 0x124D |
db 'Infortrend Technology Inc ' |
dw 4667 ; 0x124F |
db 'Perceptive Solutions Inc. ' |
dw 4694 ; 0x1256 |
db 'Gilbarco Inc. ' |
dw 4696 ; 0x1258 |
db 'Asix Electronics Corp. ' |
dw 4699 ; 0x125B |
db 'Microdyne Corp. ' |
dw 4710 ; 0x1266 |
db 'S.A. Telecommunications ' |
dw 4711 ; 0x1267 |
db 'SOLITON SYSTEMS K.K. ' |
dw 4961 ; 0x1361 |
db 'CENTURY SYSTEMS. ' |
dw 4668 ; 0x123C |
db 'Engineering Design Team Inc. ' |
db 'ENGINEERING DESIGN TEAM. ' |
dw 4669 ; 0x123D |
db 'C-CUBE MICROSYSTEMS ' |
dw 4671 ; 0x123F |
db 'JAYCOR NETWORKS INC./JNI Corporation ' |
db 'JAYCOR NETWORKS INC. ' |
dw 4674 ; 0x1242 |
db 'AVM AUDIOVISUELLES MKTG & COMPUTER SYSTEM GMBH ' |
dw 4676 ; 0x1244 |
db 'SBS TECHNOLOGIES ' |
dw 4683 ; 0x124B |
db 'Hitachi Microcomputer System Ltd. ' |
db 'HITACHI ULSI SYSTEMS CO LTD ' |
dw 4688 ; 0x1250 |
db 'GUZIK TECHNICAL ENTERPRISES ' |
dw 4691 ; 0x1253 |
676,7 → 434,7 |
dw 4697 ; 0x1259 |
db 'AURORA TECHNOLOGIES. ' |
dw 4700 ; 0x125C |
db 'ESS TECHNOLOGY, INC. ' |
db 'ESS ' |
dw 4701 ; 0x125D |
db 'CONCURRENT TECHNOLOGIES ' |
dw 4703 ; 0x125F |
688,7 → 446,7 |
dw 4708 ; 0x1264 |
db 'TEKTRONIX ' |
dw 4712 ; 0x1268 |
db 'Nortel Networks Corp. ' |
db 'NORTEL NETWORKS ' |
dw 4716 ; 0x126C |
db 'SPLASH TECHNOLOGY. ' |
dw 4717 ; 0x126D |
702,7 → 460,7 |
dw 4724 ; 0x1274 |
db 'NETWORK APPLIANCE CORPORATION ' |
dw 4725 ; 0x1275 |
db 'Transtech Parallel Systems ' |
db 'TRANSTECH DSP LTD ' |
dw 4728 ; 0x1278 |
db 'TRANSMETA CORPORATION ' |
dw 4729 ; 0x1279 |
714,13 → 472,13 |
dw 4735 ; 0x127F |
db 'YOKOGAWA ELECTRIC CORPORATION ' |
dw 4737 ; 0x1281 |
db 'Integrated Technology Express Inc. ' |
db 'INTEGRATED TECHNOLOGY EXPRESS. ' |
dw 4739 ; 0x1283 |
db 'MAZET GMBH ' |
dw 4742 ; 0x1286 |
db 'TRANSWITCH CORPORATION ' |
dw 4747 ; 0x128B |
db 'G2 Networks Inc. ' |
db 'G2 NETWORKS. ' |
dw 4749 ; 0x128D |
db 'TATENO DENNOU. ' |
dw 4751 ; 0x128F |
734,13 → 492,13 |
dw 4759 ; 0x1297 |
db 'KNOWLEDGE TECHNOLOGY LAB. ' |
dw 4761 ; 0x1299 |
db 'VMETRO Inc. ' |
db 'VMETRO. ' |
dw 4762 ; 0x129A |
db 'VICTOR COMPANY OF JAPAN ' |
dw 4766 ; 0x129E |
db 'ALLEN- BRADLEY COMPANY ' |
dw 4768 ; 0x12A0 |
db 'Lucent Technologies AMR ' |
db 'LUCENT TECHNOLOGIES ' |
dw 4771 ; 0x12A3 |
db 'AMO GMBH ' |
dw 4775 ; 0x12A7 |
748,7 → 506,7 |
dw 4777 ; 0x12A9 |
db 'YUAN YUAN ENTERPRISE CO. LTD. ' |
dw 4779 ; 0x12AB |
db 'Alteon Networks Inc. ' |
db 'ALTEON WEBSYSTEMS INC ' |
dw 4782 ; 0x12AE |
db 'NATURAL MICROSYSTEMS ' |
dw 4790 ; 0x12B6 |
762,9 → 520,10 |
dw 4798 ; 0x12BE |
db 'Fujifilm Microdevices ' |
dw 4799 ; 0x12BF |
_SECONDPART: ;lists 255 Vendors |
db 'INFIMED ' |
dw 4800 ; 0x12C0 |
db 'Holtek Microelectronics Inc. ' |
db 'HOLTEK SEMICONDUCTOR INC ' |
dw 4803 ; 0x12C3 |
db 'Connect Tech Inc ' |
dw 4804 ; 0x12C4 |
780,7 → 539,7 |
dw 4818 ; 0x12D2 |
db 'GE VINGMED ULTRASOUND AS ' |
dw 4819 ; 0x12D3 |
db 'COMVERSE NETWORKS SYSTEM & Ulticom, Inc. ' |
db 'COMVERSE NETWORKS SYSTEM & Ulticom. ' |
dw 4820 ; 0x12D4 |
db 'Equator Technologies ' |
dw 4821 ; 0x12D5 |
796,7 → 555,7 |
dw 4830 ; 0x12DE |
db 'SBS Technologies Inc ' |
dw 4831 ; 0x12DF |
db 'Chase Research PLC ' |
db 'Chase Research ' |
dw 4832 ; 0x12E0 |
db 'Datum Inc. Bancomm-Timing Division ' |
dw 4834 ; 0x12E2 |
806,7 → 565,7 |
dw 4839 ; 0x12E7 |
db 'Real Vision ' |
dw 4842 ; 0x12EA |
db 'Aureal Semiconductor ' |
db 'AUREAL INC. ' |
dw 4843 ; 0x12EB |
db '3A ' |
dw 4844 ; 0x12EC |
824,7 → 583,7 |
dw 4868 ; 0x1304 |
db 'Computer Boards ' |
dw 4871 ; 0x1307 |
db 'LEVEL ONE COMMUNICATIONS/Jato Technologies Inc. ' |
db 'LEVEL ONE COMMUNICATIONS ' |
dw 4872 ; 0x1308 |
db 'Mitsubishi Electric MicroComputer ' |
dw 4874 ; 0x130A |
980,7 → 739,7 |
dw 5053 ; 0x13BD |
db 'SHAREWAVE INC ' |
dw 5055 ; 0x13BF |
db '3ware Inc. ' |
db '3WARE ' |
dw 5057 ; 0x13C1 |
db 'TECHNOTREND SYSTEMTECHNIK GMBH ' |
dw 5058 ; 0x13C2 |
1048,10 → 807,9 |
dw 5115 ; 0x13FB |
db 'MICRO SCIENCE INC ' |
dw 5117 ; 0x13FD |
_THIRDPART: ;lists 255 vendors |
db 'ARTX INC ' |
dw 5120 ; 0x1400 |
db 'Meilhaus Electronic GmbH Germany ' |
db 'MEILHAUS ELECTRONIC GmbH ' |
dw 5122 ; 0x1402 |
db 'FUNDAMENTAL SOFTWARE INC ' |
dw 5124 ; 0x1404 |
1113,7 → 871,7 |
dw 5190 ; 0x1446 |
db 'AIM GMBH ' |
dw 5191 ; 0x1447 |
db 'ADLINK Technology Inc ' |
db 'ADLINK TECHNOLOGY ' |
dw 5194 ; 0x144A |
db 'LORONIX INFORMATION SYSTEMS INC ' |
dw 5195 ; 0x144B |
1273,6 → 1031,7 |
dw 5312 ; 0x14C0 |
db 'MYRICOM INC. ' |
dw 5313 ; 0x14C1 |
_THIRDPART: ;lists 255 vendors |
db 'DTK COMPUTER ' |
dw 5314 ; 0x14C2 |
db 'MEDIATEK CORP. ' |
1365,9 → 1124,9 |
dw 5359 ; 0x14EF |
db 'CANON RESEACH CENTRE FRANCE ' |
dw 5360 ; 0x14F0 |
db 'Conexant Systems, Inc ' |
db 'CONEXANT ' |
dw 5361 ; 0x14F1 |
db 'Mobility Electronics, Inc. ' |
db 'MOBILITY ELECTRONICS ' |
dw 5362 ; 0x14F2 |
db 'BROADLOGIC ' |
dw 5363 ; 0x14F3 |
1559,7 → 1318,6 |
dw 5457 ; 0x1551 |
db 'RACAL AIRTECH LTD ' |
dw 5458 ; 0x1552 |
_FOURTHPART: ;lists 222 vendors |
db 'CHICONY ELECTRONICS CO LTD ' |
dw 5459 ; 0x1553 |
db 'PROLINK MICROSYSTEMS CORP. ' |
1582,7 → 1340,7 |
dw 5468 ; 0x155C |
db 'MAC SYSTEM CO LTD ' |
dw 5469 ; 0x155D |
db 'LP ELEKTRONIK GMBH/KUKA Controls GmbH ' |
db 'LP ELEKTRONIK GMBH ' |
dw 5470 ; 0x155E |
db 'PERLE SYSTEMS LIMITED ' |
dw 5471 ; 0x155F |
1590,7 → 1348,7 |
dw 5472 ; 0x1560 |
db 'VIEWGRAPHICS INC ' |
dw 5473 ; 0x1561 |
db 'Symbol Technologies, Inc. ' |
db 'SYMBOL TECHNOLOGIES ' |
dw 5474 ; 0x1562 |
db 'A-TREND ' |
dw 5475 ; 0x1563 |
1736,7 → 1494,7 |
dw 5547 ; 0x15AB |
db 'NORTH ATLANTIC INSTRUMENTS ' |
dw 5548 ; 0x15AC |
db 'VMware Inc. ' |
db 'VMWARE ' |
dw 5549 ; 0x15AD |
db 'AMERSHAM PHARMACIA BIOTECH ' |
dw 5550 ; 0x15AE |
1784,6 → 1542,7 |
dw 5572 ; 0x15C4 |
db 'PROCOMP INFORMATICS LTD ' |
dw 5573 ; 0x15C5 |
_FOURTHPART: ;lists 110 vendors |
db 'TECHNICAL UNIVERSITY OF BUDAPEST ' |
dw 5574 ; 0x15C6 |
db 'TATEYAMA SYSTEM LABORATORY CO LTD ' |
1816,7 → 1575,7 |
dw 5589 ; 0x15D5 |
db 'ENTRIDIA CORPORATION ' |
dw 5590 ; 0x15D6 |
db 'Rockwell-Collins Inc ' |
db 'ROCKWELL-COLLINS ' |
dw 5591 ; 0x15D7 |
db 'CYBERNETICS TECHNOLOGY CO LTD ' |
dw 5592 ; 0x15D8 |
1919,7 → 1678,7 |
db 'SCIEMETRIC INSTRUMENTS INC ' |
dw 5641 ; 0x1609 |
db 'Broadcom -SiByte ' |
dw 5741 ; 0x166D |
dw 5741 ; 0x127A |
db 'EPOX Computer Co ' |
dw 5781 ; 0x1695 |
db 'ALBATRON Corp. ' |
1956,7 → 1715,7 |
dw 19796 ; 0x4D54 |
db 'S S TECHNOLOGIES ' |
dw 20790 ; 0x5136 |
db 'S3 Graphics Co., Ltd. ' |
db 'S3 INC. ' |
dw 21299 ; 0x5333 |
db 'TERALOGIC INC ' |
dw 21580 ; 0x544C |
1972,7 → 1731,7 |
dw 34952 ; 0x8888 |
db 'COMPUTONE CORPORATION ' |
dw 36366 ; 0x8E0E |
db 'Adaptec Inc ' |
db 'ADAPTEC ' |
dw 36868 ; 0x9004 |
db 'GIGAPIXEL CORP ' |
dw 37274 ; 0x919A |
1994,7 → 1753,7 |
dw 51966 ; 0xCAFE |
db 'CATAPULT COMMUNICATIONS ' |
dw 52428 ; 0xCCCC |
db 'DY4 Systems Inc/Curtiss-Wright Controls Embed. Com' |
db 'DY4 Systems Inc ' |
dw 54484 ; 0xD4D4 |
db 'EKF ELEKTRONIK GMBH ' |
dw 58559 ; 0xE4BF |
2005,10 → 1764,10 |
db 'EPIGRAM INC ' |
dw 65242 ; 0xFEDA |
;---------------------------------------------------------------------- |
_UNKNOWN: db 'UNKNOWN VENDOR ' |
_UNKNOWN: db 'UNKOWN VENDOR ' |
_UNKNOWND: |
db 'UNKNOWN DEVICE ' |
db 'UNKOWN DEVICE ' |
Class0: |
db 'Prehistoric - misc ' |
2027,7 → 1786,7 |
db 03 ; 0x03 |
db 'Storage - RAID ' |
db 04 ; 0x04 |
db ' ' ;Storage - ATA with DMA |
db 'Storage - ATA with DMA ' |
db 05 ; 0x05 |
db 'Storage - Serial ATA ' |
db 06 ; 0x06 |
2053,7 → 1812,7 |
db 128 ; 0x80 |
Class3: |
db ' ' ;Display - VGA controller |
db 'Display - VGA controller ' |
db 00 ; 0x0 |
db 'Display - XGA controller ' |
db 01 ; 0x1 |
2089,7 → 1848,7 |
db 02 ; 0x02 |
db 'Bridge - PCI/MCA ' |
db 03 ; 0x03 |
db ' ';Bridge - PCI/PCI |
db 'Bridge - PCI/PCI ' |
db 04 ; 0x04 |
db 'Bridge - PCMCIA ' |
db 05 ; 0x05 |
2099,7 → 1858,7 |
db 07 ; 0x07 |
db 'Bridge - RACEway ' |
db 08 ; 0x08 |
db ' '; Bridge - Semi-transpar. PCI/PCI |
db 'Bridge - Semi-transpar. PCI/PCI ' |
db 09 ; 0x09 |
db 'Bridge - InfiniBand/PCI ' |
db 10 ; 0x0A |
2107,13 → 1866,13 |
db 128 ; 0x80 |
Class7: |
db ' ';Communication - Serial |
db 'Communication - Serial ' |
db 00 ; 0x0 |
db ' ';Communication - Parallel |
db 'Communication - Parallel ' |
db 01 ; 0x1 |
db 'Communication - Multiport Serial' |
db 02 ; 0x2 |
db ' ';Communication - Modem |
db 'Communication - Modem ' |
db 03 ; 0x3 |
db 'Communication - GPIB ' |
db 04 ; 0x4 |
2123,13 → 1882,13 |
db 128 ; 0x80 |
Class8: |
db ' ' ;System - PIC |
db 'System - PIC ' |
db 00 ; 0x0 |
db ' ' ;System - DMAC |
db 'System - DMAC ' |
db 01 ; 0x1 |
db ' ' ;System - Timer |
db 'System - Timer ' |
db 02 ; 0x2 |
db ' ' ;System - RTC |
db 'System - RTC ' |
db 03 ; 0x3 |
db 'System - PCI Hot-Plug ' |
db 04 ; 0x4 |
2145,7 → 1904,7 |
db 02 ; 0x2 |
db 'Input - Scanner ' |
db 03 ; 0x3 |
db ' ' ; Input - Gameport |
db 'Input - Gameport ' |
db 04 ; 0x4 |
db 'Input - misc ' |
db 128 ; 0x80 |
2174,13 → 1933,13 |
db 64 ; 0x40 |
ClassC: |
db ' ' ;Serial Bus - FireWire |
db 'Serial Bus - FireWire ' |
db 00 ; 0x0 |
db 'Serial Bus - ACCESS.bus ' |
db 01 ; 0x1 |
db 'Serial Bus - SSA ' |
db 02 ; 0x2 |
db ' ' ;Serial Bus - USB/USB2 |
db 'Serial Bus - USB/USB2 ' |
db 03 ; 0x3 |
db 'Serial Bus - Fibre Channel ' |
db 04 ; 0x4 |
2188,7 → 1947,7 |
db 05 ; 0x5 |
db 'Serial Bus - InfiniBand ' |
db 06 ; 0x6 |
db ' ' ;Serial Bus - IPMI |
db 'Serial Bus - IPMI ' |
db 07 ; 0x7 |
db 'Serial Bus - SERCOS ' |
db 08 ; 0x8 |
2214,7 → 1973,7 |
db 128 ; 0x80 |
ClassE: |
db ' ' ;Intelligent I/O - I/O contr. |
db 'Intelligent I/O - I/O contr. ' |
db 00 ; 0x0 |
ClassF: |
2245,4 → 2004,4 |
db 'DSP - Managamant card ' |
db 32 ; 0x20 |
db 'DSP - misc ' |
db 128 ; 0x80 |
db 128 ; 0x80 |
/programs/system/pcidev/trunk/macros.inc |
---|
123,10 → 123,8 |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
macro __mov reg,a { ; mike.dld |
if ~a eq |
mov reg,a |
end if |
} |
143,6 → 141,11 |
; language for programs |
lang fix ru ; ru en fr ge fi |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 177,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 221,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/system/panel/trunk/build.bat |
---|
File deleted |
\ No newline at end of file |
/programs/system/panel/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm @panel.asm @panel |
@pause |
/programs/system/panel/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm @panel.asm @panel |
@pause |
/programs/system/pic4/trunk/pic4.asm |
---|
0,0 → 1,679 |
; |
; BACKGROUND SET - Compile with fasm |
; |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; version |
dd START ; program start |
dd I_END ; image size |
dd 0x80000 ; reguired amount of memory |
dd 0x80000 ; stack pointer |
dd I_Param,0 |
include 'lang.inc' |
include 'macros.inc' |
START: |
call check_parameters |
call draw_window |
call load_texture |
call draw_image |
still: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 |
jz red |
cmp eax,2 |
jz key |
cmp eax,3 |
jz button |
jmp still |
key: |
mov eax,2 |
int 0x40 |
jmp still |
red: |
call draw_window |
jmp still |
button: |
mov eax,17 |
int 0x40 |
shr eax,8 |
and eax,255 |
cmp eax,101 ; tiled |
jne no101 |
mov eax,15 |
mov ebx,4 |
mov ecx,1 |
int 0x40 |
mov eax,15 |
mov ebx,3 |
int 0x40 |
jmp still |
no101: |
cmp eax,102 ; stretch |
jne no102 |
mov eax,15 |
mov ebx,4 |
mov ecx,2 |
int 0x40 |
mov eax,15 |
mov ebx,3 |
int 0x40 |
jmp still |
no102: |
cmp eax,1 ; end program |
jnz noproend |
or eax,-1 |
int 0x40 |
noproend: |
cmp eax,11 |
jz bg |
cmp eax,12 |
jz bg |
cmp eax,13 |
jz bg |
cmp eax,121 |
jb no_bg_select |
cmp eax,133 |
jg no_bg_select |
sub eax,121 |
shl eax,2 |
add eax,arrays |
mov eax,[eax] |
mov [usearray],eax |
call load_texture |
call draw_image |
jmp still |
no_bg_select: |
cmp eax,14+20 |
jge bg4 |
jmp bg2 |
check_parameters: |
cmp [I_Param],dword 'BOOT' |
je @f |
ret |
@@: |
call load_texture |
mov eax,15 |
mov ebx,1 |
mov ecx,256 |
mov edx,256 |
int 0x40 |
mov eax,15 |
mov ebx,5 |
mov ecx,0x40000 ; <<< 0x40000 for blue, 0x40000+1 for red, |
; <<< 0x40000+2 for green background at boot |
mov edx,0 |
mov esi,256*3*256 |
int 0x40 |
mov eax,15 |
mov ebx,4 |
mov ecx,2 |
int 0x40 |
mov eax,15 |
mov ebx,3 |
int 0x40 |
mov eax,-1 |
int 0x40 |
set_picture: |
mov eax,image+99-3*16 |
mov ebx,0x40000+255*3+255*3*256 |
newpix: |
mov ecx,[eax] |
mov [ebx],cx |
shr ecx,16 |
mov [ebx+2],cl |
add eax,3 |
sub ebx,3 |
cmp ebx,0x40002 |
jge newpix |
ret |
load_texture: |
call gentexture |
call set_picture |
ret |
; set background |
bg: |
mov edi,0x40000 |
cmp eax,12 |
jnz bb1 |
mov edi,0x40000+1 |
bb1: |
cmp eax,13 |
jnz bb2 |
mov edi,0x40000+2 |
bb2: |
mov eax,15 |
mov ebx,1 |
mov ecx,256 |
mov edx,256 |
int 0x40 |
mov eax,15 |
mov ebx,5 |
mov ecx,edi |
mov edx,0 |
mov esi,256*256*3 |
int 0x40 |
mov eax,15 |
mov ebx,3 |
int 0x40 |
jmp still |
; colored background |
bg2: |
push eax |
mov eax,15 |
mov ebx,1 |
mov ecx,8 |
mov edx,8 |
int 0x40 |
mov eax,[esp] |
sub eax,14 |
shl eax,2 |
mov edx,[colors+eax] |
mov esi,32*32*4 |
mov edi,0 |
mov ecx,0 |
dbl2: |
mov eax,15 |
mov ebx,2 |
int 0x40 |
add ecx,3 |
inc edi |
cmp edi,esi |
jb dbl2 |
mov eax,15 |
mov ebx,3 |
int 0x40 |
jmp still |
; shaped background |
bg4: |
sub eax,14+20 |
shl eax,3 |
add eax,shape |
mov ecx,[eax+0] |
mov edx,[eax+4] |
mov eax,15 |
mov ebx,1 |
int 0x40 |
mov eax,15 |
mov ebx,3 |
int 0x40 |
jmp still |
; ********************************************* |
; ******* CELLULAR TEXTURE GENERATION ********* |
; **** by Cesare Castiglia (dixan/sk/mfx) ***** |
; ********* dixan@spinningkids.org ********** |
; ********************************************* |
; * the algorythm is kinda simple. the color * |
; * component for every pixel is evaluated * |
; * according to the squared distance from * |
; * the closest point in 'ptarray'. * |
; ********************************************* |
gentexture: |
mov ecx,0 ; ycounter |
mov edi,0 ; pixel counter |
mov ebp,[usearray] |
ylup: |
mov ebx,0 |
; call precalcbar |
xlup: |
push edi |
mov edi, 0 |
mov esi, 512000000 ; abnormous initial value :) |
pixlup: |
push esi |
; add edi,4 |
mov eax,ebx ; evaluate first distance |
sub eax, [ebp+edi] ; x-x1 |
call wrappit |
imul eax |
mov esi, eax ; (x-x1)^2 |
mov eax, ecx |
add edi,4 |
sub eax, [ebp+edi] ; y-y1 |
call wrappit |
imul eax ; (y-y1)^2 |
add eax,esi ; (x-x1)^2+(y-y1)^2 |
pop esi |
cmp esi,eax |
jb ok ; compare and take the smaller one |
mov esi,eax |
ok: |
add edi,4 |
cmp [ebp+edi],dword 777 |
jne pixlup |
mov eax,esi ; now evaluate color... |
; cmp eax,255*24 |
; jbe ok2 |
; imul eax,12 |
; ok2: |
mov edi,24 ; 50 = max shaded distance |
idiv edi |
pop edi |
mov [image+51+edi],eax |
add edi,3 |
add ebx,1 ; bounce x loop |
cmp ebx,256 ; xsize |
jne xlup |
add ecx,1 |
cmp ecx,256 ; ysize |
jne ylup |
ret |
wrappit: |
cmp eax,0 ; this makes the texture wrap |
jg noabs |
neg eax |
noabs: |
cmp eax,128 |
jb nowrap |
neg eax |
add eax,256 |
nowrap: |
ret |
;precalcbar: |
; pusha |
; mov eax,1 |
; mov ebx,ecx |
; add ebx,18 |
; mov ecx,44 |
; mov edx,0x00000060 |
; bar: |
; add ecx,2 |
; add edx,0x00020100 |
; int 0x40 |
; cmp ecx,298 |
; jb bar |
; popa |
; ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ********* |
; ********************************************* |
draw_image: |
mov eax,7 |
mov ebx,0x40000 |
mov ecx,256*65536+255 |
mov edx,19*65536+65;55 |
int 0x40 |
ret |
y_add equ 44 ; 30 |
y_s equ 13 |
y_add2 equ 340 ;325 |
set equ 0 ;15 |
button_color equ 0A0A0A0h ; 207090 306090h |
wnd_color equ 3B0B0B0h ; 34090B0h |
draw_window: |
mov eax, 12 ; tell os about draw |
mov ebx, 1 |
int 0x40 |
mov eax, 0 ; define and draw window |
mov ebx, 220*65536+293 |
mov ecx, 50*65536+408 |
mov edx, wnd_color |
int 0x40 |
call draw_image |
mov eax,8 ; Blue button |
mov ebx,(set+195+27)*65536+17 |
mov ecx,y_add*65536+y_s |
mov edx,11 |
mov esi,0x004444cc |
int 0x40 |
mov eax,8 ; Red button |
mov ebx,(set+213+27)*65536+17 |
mov edx,12 |
mov esi,0x00cc4444 |
int 0x40 |
mov eax,8 ; Green button |
mov ebx,(set+258)*65536+17 |
mov edx,13 |
mov esi,0x0044cc44 |
int 0x40 |
mov eax, 8 ; tiled |
mov ebx, 96*65536+63 |
mov ecx, y_add*65536+y_s |
mov edx, 101 |
mov esi, button_color |
int 0x40 |
mov eax, 8 ; stretch |
mov ebx, 160*65536+61 |
mov edx, 102 |
int 0x40 |
mov eax, 4 ; window header |
mov ebx, 8*65536+8 |
mov ecx, 0x10ffffff |
mov edx, header |
mov esi, header.size |
int 0x40 |
mov ebx, 220*65536+30 |
mov ecx, 0 |
mov edx, apply_text |
mov esi, apply_text.size |
int 0x40 |
mov ebx, 19*65536+326 |
mov edx, image_buttons_text |
mov esi, image_buttons_text.size |
int 0x40 |
mov ebx, 19*65536+(y_add2+27) |
mov edx, simple_text |
mov esi, simple_text.size |
int 0x40 |
mov ecx, (y_add2)*65536+20 |
mov ebx, (18)*65536+25 |
mov edx, 121 |
mov esi, button_color |
mov edi, 9 |
mov eax, 8 |
@@: |
int 0x40 |
add ebx, 29*65536 |
inc edx |
dec edi |
jnz @b |
mov edx, 34+4 |
mov edi, 4 |
mov eax, 8 |
mov ebx, 18*65536+18 |
mov ecx, y_add*65536+y_s |
@@: |
int 0x40 |
inc edx |
add ebx, 19*65536 |
dec edi |
jnz @b |
;----------------------- |
mov edx,14 ; button number |
mov ebx,(18)*65536+17 ; button start x & size |
mov ecx,(y_add2+40)*65536+14 ; button start y & size |
newcb: |
mov esi,[(edx-14)*4+colors] |
mov eax,8 |
int 0x40 |
inc edx |
add ebx,20*65536 |
add esi,5*256*256 |
cmp edx,27 |
jnz newcb |
;----------------------- |
mov eax, 4 |
mov ebx, 8*65536+4+y_add |
mov ecx, 0 |
mov edx, la2 |
mov esi, la2.size |
int 0x40 |
mov eax,12 |
mov ebx,2 |
int 0x40 |
ret |
; DATA SECTION |
lsz header,\ |
ru, "¥¥à â®à ä® à ¡®ç¥£® á⮫ ",\ |
en, "BACKGROUND" |
lsz apply_text,\ |
ru, "ਬ¥¨âì:",\ |
en, "Apply:" |
lsz image_buttons_text,\ |
ru, "ë¡¥à¨â¥ ®¡à §¥æ:",\ |
en, "Select pattern:" |
lsz simple_text,\ |
ru, "¤®æ¢¥âë© ä®:",\ |
en, "Single-color background:" |
lsz la2,\ |
ru, " ",\ |
en, " TILED STRETCH" |
xx db 'x' |
colors: |
dd 0x770000 |
dd 0x007700 |
dd 0x000077 |
dd 0x777700 |
dd 0x770077 |
dd 0x007777 |
dd 0x777777 |
dd 0x335577 |
dd 0x775533 |
dd 0x773355 |
dd 0x553377 |
dd 0x000000 |
dd 0xcccccc |
shape: |
dd 1024,64 |
dd 1024,32 |
dd 2048,32 |
dd 4096,32 |
dd 512,16 |
dd 1024,16 |
dd 2048,16 |
dd 4096,16 |
dd 64,32 |
dd 64,16 |
dd 32,32 |
dd 8,8 |
dd 16,16 |
dd 64,64 |
usearray dd ptarray |
arrays dd ptarray,ptarray2,ptarray3,ptarray4,ptarray5,ptarray6 |
dd ptarray7,ptarray8,ptarray9 |
ptarray: |
dd 150,50 |
dd 120,30 |
dd 44,180 |
dd 50,66 |
dd 27,6 |
dd 95,212 |
dd 128,177 |
dd 201,212 |
dd 172,201 |
dd 250,100 |
dd 24,221 |
dd 11,123 |
dd 248,32 |
dd 34,21 |
dd 777 ; <- end of array |
ptarray2: |
dd 0,0,50,50,100,100,150,150,200,200,250,250 |
dd 50,150,150,50,200,100,100,200 |
dd 777 |
ptarray3: |
dd 55,150,150,55,200,105,105,200 |
dd 30,30,220,220 |
dd 777 |
ptarray4: |
dd 196,0,196,64,196,128,196,196 |
dd 64,32,64,96,64,150,64,228 |
dd 777 |
ptarray5: |
dd 196,0,196,64,196,128,196,196 |
dd 64,0,64,64,64,128,64,196 |
dd 777 |
ptarray6: |
dd 49,49,128,50,210,50 |
dd 50,128,128,128,210,128 |
dd 50,210,128,210,210,210 |
dd 777 |
ptarray7: |
dd 0,0 |
dd 196,196,64,64 |
dd 128,0 |
dd 0,128 |
dd 64,64,196,64 |
dd 196,196,64,196 |
dd 128,128 |
dd 777 |
ptarray8: |
dd 0, 128 |
dd 0, 128 |
dd 128, 0 |
dd 0, 128 |
dd 128, 0 |
dd 0, 128 |
dd 128, 0 |
dd 0, 128 |
dd 128, 0 |
dd 128, 128 |
dd 777 |
ptarray9: |
dd 0,248,64,128,128,64,196,48,160,160,94,224,240,96,5,5,777 |
I_Param: |
image: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/system/pic4/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm pic4.asm pic4 |
@pause |
/programs/system/pic4/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm pic4.asm pic4 |
@pause |
/programs/system/pic4/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/system/setup/trunk/build.bat |
---|
File deleted |
\ No newline at end of file |
/programs/system/setup/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm setup.asm setup |
@pause |
/programs/system/setup/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm setup.asm setup |
@pause |
/programs/system/setup/trunk/macros.inc |
---|
143,6 → 143,9 |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 177,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 221,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/system/cpuspeed/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm cpuspeed.asm cpuspeed |
@pause |
/programs/system/cpuspeed/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm cpuspeed.asm cpuspeed |
@pause |
/programs/system/cpuspeed/trunk/cpuspeed.asm |
---|
0,0 → 1,153 |
; |
; CPU SPEED INDICATIOR |
; |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x1000 ; required amount of memory |
dd 0x1000 ; esp |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
mov eax,18 |
mov ebx,5 |
int 0x40 |
xor edx,edx |
mov ebx,1000000 |
div ebx |
mov ebx,10 |
mov edi,text+19 |
mov ecx,5 |
newnum: |
xor edx,edx |
mov ebx,10 |
div ebx |
add dl,48 |
mov [edi],dl |
sub edi,1 |
loop newnum |
call draw_window ; at first, draw the window |
still: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
jmp still |
red: ; redraw |
call draw_window |
jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp still |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jnz still |
mov eax,-1 ; close this program |
int 0x40 |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
mov eax,48 |
mov ebx,3 |
mov ecx,sc |
mov edx,sizeof.system_colors |
int 0x40 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+200 ; [x start] *65536 + [x size] |
mov ecx,100*65536+65 ; [y start] *65536 + [y size] |
mov edx,[sc.work] ; color of work area RRGGBB,8->color glide |
mov esi,[sc.grab] ; color of grab bar RRGGBB,8->color |
or esi,0x80000000 |
mov edi,[sc.frame] ; color of frames RRGGBB |
int 0x40 |
; WINDOW LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
mov ecx,[sc.grab_text] ; color of text RRGGBB |
or ecx,0x10000000 |
mov edx,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
; CLOSE BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,(200-17)*65536+12 ; [x start] *65536 + [x size] |
mov ecx,5*65536+12 ; [y start] *65536 + [y size] |
mov edx,1 ; button id |
mov esi,[sc.grab_button] ; button color RRGGBB |
int 0x40 |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,[sc.work_text] |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,10 |
add edx,40 |
cmp [edx],byte 'x' |
jnz newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
; DATA AREA |
text: |
db 'CPU RUNNING AT MHZ ' |
db 'x' ; <- END MARKER, DONT DELETE |
labelt: |
db 'CPU SPEED' |
labellen: |
I_END: |
sc system_colors |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/system/cpuspeed/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs equ <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/system/run/trunk/editbox.inc |
---|
File deleted |
\ No newline at end of file |
/programs/system/run/trunk/run.txt |
---|
File deleted |
\ No newline at end of file |
/programs/system/run/trunk/txtbut.inc |
---|
File deleted |
\ No newline at end of file |
/programs/system/run/trunk/build_en.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm run.asm run |
@erase lang.inc |
@pause |
/programs/system/run/trunk/build_ru.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm run.asm run |
@erase lang.inc |
@pause |
/programs/system/run/trunk/macros.inc |
---|
1,17 → 1,5 |
;--- ¤à㣨¥ ¬ ªà®áë --- |
include 'editbox.inc' |
include 'txtbut.inc' |
;include 'gp.inc' |
;include 'label.inc' |
;include 'checkbox.inc' |
;include 'file_sys.inc' |
;include 'textwork.inc' |
;include 'ini.inc' |
include 'lang.inc' |
;--- § £®«®¢®ª --- |
macro meos_header par_buf,cur_dir_buf |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
18,294 → 6,261 |
db 'MENUET01' |
dd 0x01 |
dd __app_start |
dd __app_end |
dd __app_end |
dd __app_end |
if <par_buf> eq <> |
dd 0x0 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd par_buf |
end if |
if <cur_dir_buf> eq <> |
dd 0x0 |
else |
dd cur_dir_buf |
end if |
} |
;--- ®¯à¥¤¥«¨âì â®çªã ¢å®¤ --- |
macro app_start |
{ |
__app_start: |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
;--- ®¯à¥¤¥«¨âì ª®¥æ ¯à¨«®¦¥¨ï ¨ à §¬¥à á⥪ --- |
macro app_end stack_size |
macro code |
{ |
if <stack_size> eq <> |
rb 1024 |
else |
rb stack_size |
end if |
__app_end: |
__start: |
} |
CODE fix code |
;--- § ¢¥àè¨âì ⥪ã騩 ¯®â®ª --- |
macro app_close |
macro data |
{ |
xor eax,eax |
dec eax |
int 0x40 |
__data: |
} |
DATA fix data |
;--- ¯®«ãç¨âì ª®¤ ¦ ⮩ ª« ¢¨è¨ --- |
macro get_key |
macro udata |
{ |
mov eax,2 |
int 0x40 |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
;--- ¯®«ãç¨âì ª®¤ ¦ ⮩ ª®¯ª¨ --- |
macro get_pressed_button |
macro meos_app_end |
{ |
mov eax,17 |
int 0x40 |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
;--- á®®¡é¨âì á¨á⥬¥ ® ç «¥ ¯¥à¥à¨á®¢ª¨ ®ª --- |
macro start_draw_window |
{ |
mov eax,12 |
xor ebx,ebx |
inc ebx |
int 0x40 |
} |
;--- á®®¡é¨âì á¨á⥬¥ ® § ¢¥à襨¨ ¯¥à¥à¨á®¢ª¨ ®ª --- |
macro stop_draw_window |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
mov eax,12 |
mov ebx,2 |
int 0x40 |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
;--- ãáâ ®¢¨âì ¬ áªã ®¦¨¤ ¥¬ëå ᮡë⨩ --- |
macro set_events_mask mask |
{ |
mov eax,40 |
mov ebx,mask |
int 0x40 |
} |
;--- ¯®«ãç¨âì ¨ä®à¬ æ¨î ® ¯à®æ¥áᥠ--- |
macro get_procinfo proc_inf_buf,slot_num |
{ |
mov eax,9 |
mov ebx,proc_inf_buf |
if <slot_num> eq <> |
xor ecx,ecx |
dec ecx |
else |
mov ecx,slot_num |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
int 0x40 |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro get_sys_colors col_buf |
{ |
mov eax,48 |
mov ebx,3 |
mov ecx,col_buf |
mov edx,40 |
int 0x40 |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro get_grab_area |
{ |
mov eax,48 |
mov ebx,7 |
int 0x40 |
} |
macro get_scin_height |
{ |
mov eax,48 |
mov ebx,4 |
int 0x40 |
} |
macro min_window |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
mov eax,18 |
mov ebx,10 |
int 0x40 |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro activ_window slot_n |
{ |
mov eax,18 |
mov ebx,3 |
if <slot_n> eq <> |
else |
mov ecx,slot_n |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
int 0x40 |
} |
macro get_active_window |
{ |
mov eax,18 |
mov ebx,7 |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
macro delay time |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
mov eax,5 |
if <time> eq <> |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
mov ebx,time |
add arg1,arg2 |
end if |
int 0x40 |
else |
add arg1,arg2 |
end if |
} |
;--- ®¦¨¤ âì ᮡëâ¨ï --- |
macro wait_event redraw,key,button,mouse,ipc,other |
macro sub arg1,arg2 |
{ |
mov eax,10 |
int 0x40 |
dec ax |
if <redraw> eq <> |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
jz redraw |
sub arg1,arg2 |
end if |
dec ax |
if <key> eq <> |
else |
jz key |
sub arg1,arg2 |
end if |
dec ax |
if <button> eq <> |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
jz button |
mov arg1,arg2 |
end if |
dec ax |
dec ax |
dec ax |
if <mouse> eq <> |
else |
jz mouse |
mov arg1,arg2 |
end if |
if <ipc> eq <> |
else |
dec ax |
jz ipc |
end if |
if <other> eq <> |
jmp still |
else |
jmp other |
end if |
} |
;--- ¯®«ãç¨âì à §¬¥àë íªà --- |
macro get_screen_size |
{ |
mov eax,14 |
int 0x40 |
} |
macro get_screen_prop struc_ptr |
macro struct name |
{ |
mov eax,61 |
push eax eax |
xor ebx,ebx |
inc ebx |
int 0x40 |
mov [struc_ptr],eax |
pop eax |
inc ebx |
int 0x40 |
mov [struc_ptr+4],ax |
pop eax |
inc ebx |
int 0x40 |
mov [struc_ptr+6],eax |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
macro resize_mem mem_size |
; structures used in MeOS |
struc process_information |
{ |
mov eax,64 |
xor ebx,ebx |
inc ebx |
if <mem_size> eq <> |
else |
mov ecx,mem_size |
end if |
int 0x40 |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
evm_redraw equ 1 |
evm_key equ 10b |
evm_button equ 100b |
evm_mouse equ 100000b |
evm_ipc equ 1000000b |
struc procinfo |
struc system_colors |
{ |
.takts_per_second: dd ? |
.window_stack_pos: dw ? |
.slot_number: dw ? |
dw ? |
.name: rb 11 |
.align: db ? |
.addres: dd ? |
.use_mem: dd ? |
.pid: dd ? |
.left: dd ? |
.top: dd ? |
.width: dd ? |
.height: dd ? |
.slot_state: dw ? |
rb (1024-56) |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
struc sys_color_table |
{ |
.frames: dd ? ;+0 |
.grab: dd ? ;+4 |
.grab_button: dd ? ;+8 |
.grab_button_text: dd ? ;+12 |
.grab_text: dd ? ;+16 |
.work: dd ? ;+20 |
.work_button: dd ?;+24 |
.work_button_text: dd ? ;+28 |
.work_text: dd ? ;+32 |
.work_graph: dd ? ;+36 |
} |
struc screen_size |
{ |
.height: dw ? |
.width: dw ? |
} |
; constants |
struc screen_prop |
{ |
.height: dw ? ;+0 |
.width: dw ? ;+2 |
.bitspp: dw ? ;+4 |
.bytesps: dd ?;+6 |
} |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
struc ipc_buffer size |
{ |
.block: dd ? |
.in_use: dd ? |
.messages: rb size |
} |
;--- 梥â --- |
cl_white=0xffffff |
cl_black=0x000000 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
/programs/system/run/trunk/run.asm |
---|
1,261 → 1,198 |
window_y=88 |
;window_x=320 |
window_x=450 |
include 'macros.inc' |
meos_header par |
use_edit_box |
use_txt_button |
app_start |
cmp [par],byte 0 |
jne read_par |
set_events_mask evm_mouse+evm_button+evm_key+evm_redraw |
red: |
get_sys_colors sc |
set_sys_colors_txt_button run_but,sc |
push dword [sc.work_graph] |
pop [input_fn.focus_border_color] |
; <--- description ---> |
; compiler: FASM 1.54 |
; name: MenuetOS RUN |
; version: 0.02 |
; last update: 28/09/2004 |
; written by: Ivan Poddubny |
; e-mail: ivan-yar@bk.ru |
; <--- include all MeOS stuff ---> |
include "lang.inc" |
include "macros.inc" |
;;;lang fix en |
; <--- start of MenuetOS application ---> |
MEOS_APP_START |
;include "DEBUG.INC" |
; <--- start of code ---> |
CODE |
call draw_window ; at first create and draw the window |
wait_event: ; main cycle |
mcall 10 |
cmp eax, 1 ; if event == 1 |
je redraw ; jump to redraw handler |
cmp eax, 2 ; else if event == 2 |
je key ; jump to key handler |
cmp eax, 3 ; else if event == 3 |
je button ; jump to button handler |
jmp wait_event ; else return to the start of main cycle |
redraw: ; redraw event handler |
call draw_window |
still: |
wait_event red,key,button,mouse,,still |
key: |
get_key |
jmp wait_event |
key: ; key event handler |
mcall 2 |
cmp ah,13 |
je run |
key_edit_box input_fn |
jmp still |
button: |
get_pressed_button |
dec ah |
jz close |
dec ah |
jz run |
jmp still |
mouse: |
mouse_edit_box input_fn |
jmp still |
je _run |
cmp ah, 8 |
je .backspace |
read_par: |
mov esi,par |
mov edi,fn |
mov ecx,256 |
rep movsb |
run: |
mov bl, ah |
mov eax, [position] |
mov [filename + eax], bl |
inc [position] |
call draw_string |
jmp wait_event |
.backspace: |
xor eax,eax |
mov edi,file_info.name |
mov ecx,512 |
rep stosb |
mov edi,run_par |
mov ecx,256 |
rep stosb |
cmp [position], eax |
je wait_event |
dec [position] |
call draw_string |
jmp wait_event |
mov esi,fn |
mov edi,file_info.name |
cmp [esi],byte '"' |
je copy_fn_with_spaces |
copy_fn: |
cmp [esi],byte ' ' |
je .stop |
cmp [esi],byte 0 |
je .stop |
mov al,[esi] |
mov [edi],al |
inc esi |
inc edi |
jmp copy_fn |
.stop: |
jmp copy_par |
button: ; button event handler |
mcall 17 |
copy_fn_with_spaces: |
inc esi |
@@: |
cmp [esi],byte '"' |
je .stop |
cmp [esi],byte 0 |
je .stop |
mov al,[esi] |
mov [edi],al |
inc esi |
inc edi |
jmp @b |
.stop: |
cmp ah, 10 |
je _run |
copy_par: |
@@: |
inc esi |
cmp [esi],byte ' ' |
je @b |
mov edi,run_par |
@@: |
cmp [esi],byte 0 |
je .stop |
mov al,[esi] |
mov [edi],al |
inc esi |
inc edi |
jmp @b |
.stop: |
dec ah |
jne wait_event ; return if button id != 1 |
mov eax,70 |
mov ebx,file_info |
_exit: |
or eax, -1 ; exit application |
int 0x40 |
;cmp eax,0 |
;jg error |
bt eax,31 |
je error |
jmp still |
close: |
app_close |
error: |
_run: |
mcall 58, fileinfo |
; dps "58th function returned " |
; dpd eax |
; newline |
jmp _exit |
macro cmp_err code,text_ptr |
{ |
cmp al,code |
jne @f |
mov [status],text_ptr |
;jmp .draw_status |
@@: |
} |
neg eax |
;test al,al |
;jz close |
draw_window: |
mcall 12, 1 |
cmp_err 3,bad_file_sys |
mcall 14 |
and eax, 0xFFFF |
sub eax, 100 |
shl eax, 16 |
add eax, 80 |
mov ecx, eax |
cmp_err 5,file_not_find |
mov ebx, 148*65536+400 ; (window_cx)*65536+(window_sx) |
mov edx, 0x03DDDDDD ; work area color & window type 3 |
mcall 0 |
cmp_err 9,bad_fat_table |
mov ebx, 8*65536+8 ; coordinates |
mov ecx, 0x10ffffff ; color & font N1 |
mov edx, header ; address of text |
mov esi, header.size ; length of text |
mcall 4 |
cmp_err 10,acces_denyied |
mpack ebx, 10, 26 |
mov ecx, 0 |
mov edx, message |
mov esi, message.size |
mcall |
cmp_err 11,device_error |
mpack ebx, 385-(runbtn.size*6), runbtn.size*6+4 |
mpack ecx, 56, 14 |
mov edx, 10 |
mov esi, 0xa0a0a0 |
mcall 8 |
cmp_err 30,out_of_memory |
; mpack ebx, 385-runbtn.size*6-findbtn.size*6-8, findbtn.size*6+4 |
; inc edx |
; mcall 8 |
cmp_err 31,file_not_executable |
; mpack ebx, 388-runbtn.size*6-findbtn.size*6-7, 59 |
; mov ecx, 0 |
; mov edx, findbtn |
; mov esi, findbtn.size |
; mcall 4 |
cmp_err 32,many_processes |
mpack ebx, 388-runbtn.size*6, 59 |
mov ecx, 0 |
mov edx, runbtn |
mov esi, runbtn.size |
mcall 4 |
.draw_status: |
call draw_status |
jmp still |
call draw_string |
draw_window: |
start_draw_window |
get_screen_size |
mov cx,ax |
sub cx,window_y+20 |
shl ecx,16 |
mov cx,window_y |
shr eax,16 |
mov bx,ax |
sub bx,window_x |
shl ebx,15 |
mov bx,window_x |
mov edx,[sc.work] |
or edx,0x03000000 |
xor eax,eax |
xor esi,esi |
xor edi,edi |
int 0x40 |
mcall 12, 2 |
ret |
get_procinfo app |
mov ax,[app.width] |
sub ax,20 |
mov [input_fn.width],ax |
mov [run_but.width],ax |
draw_string: |
mpack ebx, 10, 380 |
mpack ecx, 38, 14 |
mov edx, 0xA0A0A0 |
mcall 13 |
mov bx,5 |
shl ebx,16 |
mov bx,ax |
add bx,15 |
mov cx,70 |
push cx |
shl ecx,16 |
pop cx |
mov edx,[sc.work_graph] |
mov eax,38 |
int 0x40 |
mpack ebx, 14, 41 |
mov ecx, 0 |
mov edx, filename |
mov esi, [position] |
mcall 4 |
ret |
draw_edit_box input_fn |
draw_txt_button run_but |
call draw_status_text |
stop_draw_window |
ret |
; <--- initialised data ---> |
DATA |
draw_status: |
mov ebx,5*65536+(window_x-5-5) |
mov ecx,(window_y-16)*65536+12 |
mov edx,[sc.work] |
mov eax,13 |
int 0x40 |
draw_status_text: |
mov edx,[status] |
xor esi,esi |
@@: |
cmp [edx+esi],byte 0 |
je @f |
inc esi |
jmp @b |
@@: |
mov eax,4 |
mov ebx,10*65536+(window_y-14) |
mov ecx,[sc.work_text] |
int 0x40 |
ret |
position dd filename.size |
run_but txt_button 0,10,15,50,2,0,0,run_but_text, |
if lang eq ru |
run_but_text db '',0 |
else |
run_but_text db 'RUN',0 |
end if |
input_fn edit_box 0,10,30,0xffffff,0,0xaaaaaa,0,511,fn,ed_focus+\ |
ed_always_focus |
lsz header,\ |
ru, " ¯ã᪠¯à®£à ¬¬ë",\ |
en, "Start program" |
if lang eq ru |
hello db '¢¥¤¨â¥ ¯®«ë© ¯ãâì ª ä ©«ã ¨ ¦¬¨â¥ Enter',0 |
bad_file_sys db '¥¨§¢¥áâ ï ä ©«®¢ ï á¨á⥬ ',0 ; 3 |
file_not_find db ' ©« ¥ ©¤¥',0 ; 5 |
bad_fat_table db ' ¡«¨æ FAT à §àãè¥ ',0 ; 9 |
acces_denyied db '®áâ㯠§ ¯à¥é¥',0 ; 10 |
device_error db '訡ª ãáâனá⢠',0 ; 11 |
out_of_memory db '¥¤®áâ â®ç® ¯ ¬ïâ¨',0 ; 30 |
file_not_executable db ' ©« ¥ ï¥âáï ¨á¯®«ï¥¬ë¬',0 ; 31 |
many_processes db '«¨èª®¬ ¬®£® ¯à®æ¥áᮢ',0 ; 32 |
else |
hello db 'Enter full path to file and press <Enter>',0 |
bad_file_sys db 'Unknown file system',0 ; 3 |
file_not_find db 'File not found',0 ; 5 |
bad_fat_table db 'FAT table corrupted',0 ; 9 |
acces_denyied db 'Access denied',0 ; 10 |
device_error db 'Device error',0 ; 11 |
out_of_memory db 'Out of memory',0 ; 30 |
file_not_executable db 'File is not executable',0 ; 31 |
many_processes db 'Too many processes',0 ; 32 |
end if |
lsz message,\ |
ru, "¢¥¤¨â¥ ¯ãâì ª ä ©«ã:",\ |
en, "Enter path to file:" |
status dd hello |
; lsz findbtn,\ |
; ru, " ©â¨...",\ |
; en, "Find..." |
file_info: |
.mode dd 7 |
.flags dd 0 |
.par dd run_par |
dd 0,0 |
.name rb 512 |
lsz runbtn,\ |
ru, " ¯ãáâ¨âì",\ |
en, "Run" |
flags dw ? |
fn rb 512 |
fileinfo: |
.mode dd 16 |
dd 0 |
.param dd 0 |
dd 0 |
.workarea dd workarea |
sc sys_color_table |
app procinfo |
run_par rb 256 |
par rb 256 |
app_end |
sz filename, "/rd/1/" |
rb 122 |
; <--- uninitialised data ---> |
UDATA |
workarea rb 4096 |
MEOS_APP_END |
; <--- end of MenuetOS application ---> |
/programs/system/sysmeter/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm sysmeter.asm sysmeter |
@pause |
/programs/system/sysmeter/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm sysmeter.asm sysmeter |
@pause |
/programs/system/sysmeter/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/system/sysmeter/trunk/sysmeter.asm |
---|
0,0 → 1,197 |
; |
; CPU USAGE for MenuetOS - Compile with FASM 1.30+ |
; |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os version |
dd START ; program start |
dd I_END ; program image size |
dd 0x1000 ; reguired amount of memory |
dd 0x1000 |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
START: |
call set_variables |
call draw_window |
mov edi,0 |
still: |
mov eax,23 |
mov ebx,10 |
int 0x40 |
cmp eax,1 |
je red |
cmp eax,2 |
je key |
cmp eax,3 |
je button |
inc edi |
cmp edi,10 |
jb still |
mov edi,0 |
call draw_usage |
jmp still |
red: |
call draw_window |
jmp still |
key: |
mov eax,2 |
int 0x40 |
jmp still |
button: |
mov eax,17 |
int 0x40 |
cmp al,byte 0 |
jnz still |
mov eax,-1 |
int 0x40 |
set_variables: |
pusha |
mov ecx,190 |
mov edi,pros |
mov eax,100 |
cld |
rep stosb |
popa |
ret |
draw_window: |
pusha |
mov eax,12 ; tell os about redraw |
mov ebx,1 |
int 0x40 |
mov eax,0 ; define and draw window |
mov ebx,50*65536+207 |
mov ecx,50*65536+127 |
mov edx,0x03000000 |
mov esi,0x806688aa |
mov edi,0x0088ccee |
int 0x40 |
mov eax,4 ; 'CPU USAGE' |
mov ebx,8*65536+8 |
mov ecx,dword 0x00ffffff |
mov edx,text |
mov esi,textlen-text |
int 0x40 |
mov eax,12 ; tell os about redraw end |
mov ebx,2 |
int 0x40 |
popa |
ret |
draw_usage: |
pusha ; CPU usage |
cld |
mov eax,18 ; TSC / SEC |
mov ebx,5 |
int 0x40 |
shr eax,20 |
push eax |
mov eax,18 ; IDLE / SEC |
mov ebx,4 |
int 0x40 |
shr eax,20 |
xor edx,edx |
mov ebx,100 |
mul ebx |
xor edx,edx |
pop ebx |
add ebx,1 |
div ebx |
push eax |
mov esi,pros+1 |
mov edi,pros |
mov ecx,195 |
cld |
rep movsb |
pop eax |
mov [pros+99],al |
mov eax,13 |
mov ebx,5*65536+1 |
mov esi,pros |
mov edi,pros+99 |
newpros: |
add esi,1 |
xor eax,eax ; up |
mov al,[esi] |
add eax,1 |
mov ecx,22*65536 |
mov cx,ax |
mov eax,13 |
mov edx,0x0 |
int 0x40 |
pusha ; down |
xor eax,eax |
mov al,[esi] |
mov ecx,22 |
add ecx,eax |
shl ecx,16 |
mov cx,101 |
sub cx,ax |
mov eax,13 |
mov edx,0xdddddd |
int 0x40 |
popa |
add ebx,2*65536 |
cmp esi,edi |
jb newpros |
popa |
ret |
; DATA AREA |
text: db 'CPU LOAD HISTORY ' |
textlen: |
pros: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/system/systrace/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm systrace.asm systrace |
@pause |
/programs/system/systrace/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm systrace.asm systrace |
@pause |
/programs/system/systrace/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/system/systrace/trunk/systrace.asm |
---|
0,0 → 1,211 |
; |
; SYSTEM CALL TRACE , V.Turjanmaa |
; |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x1000 ; memory for app |
dd 0x1000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
call draw_window ; at first, draw the window |
still: |
mov eax,23 ; wait here for event |
mov ebx,50 |
int 0x40 |
call display_calls |
cmp eax,1 ; redraw request ? |
je red |
cmp eax,2 ; key in buffer ? |
je key |
cmp eax,3 ; button in buffer ? |
je button |
jmp still |
red: ; redraw |
call draw_window |
jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp still |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne noclose |
mov eax,-1 ; close this program |
int 0x40 |
noclose: |
jmp still |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+465 ; [x start] *65536 + [x size] |
mov ecx,50*65536+265 ; [y start] *65536 + [y size] |
mov edx,0x03ffffff ; color of work area RRGGBB,8->color gl |
mov esi,0x808899ff ; color of grab bar RRGGBB,8->color gl |
mov edi,0x008899ff ; color of frames RRGGBB |
int 0x40 |
; WINDOW LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
mov ecx,0x00ddeeff ; color of text RRGGBB |
mov edx,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
mov eax,4 |
mov ebx,15*65536+55 |
mov ecx,0x0 |
mov edx,text |
mov esi,70 |
int 0x40 |
; CLOSE BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,(465-19)*65536+12 ; [x start] *65536 + [x size] |
mov ecx,5*65536+12 ; [y start] *65536 + [y size] |
mov edx,1 ; button id |
mov esi,0x6677cc ; button color RRGGBB |
; int 0x40 |
call display_calls |
mov eax,12 |
mov ebx,2 |
int 0x40 |
ret |
display_calls: |
pusha |
mov eax,13 |
mov ebx,15*65536+70 |
mov ecx,35*65536+10 |
mov edx,0xffffff |
int 0x40 |
mov eax,59 |
mov ebx,0 |
mov ecx,I_END |
mov edx,64*16 |
int 0x40 |
mov ecx,eax |
mov eax,47 |
mov ebx,10*65536 |
mov edx,15*65536+35 |
mov esi,0 |
int 0x40 |
mov ebx,75 |
mov edx,I_END |
newline: |
push ebx |
push edx |
mov edi,0 |
new_x: |
mov eax,13 |
mov ebx,edi |
shl ebx,6+16 |
add ebx,15*65536 |
mov bx,6*8 |
mov ecx,[esp+4] |
shl ecx,16 |
mov cx,10 |
mov edx,0xffffff |
int 0x40 |
mov eax,47 |
mov ebx,1+1*256+8*65536 |
mov ecx,[pos+edi*4] |
shl ecx,2 |
add ecx,[esp+0] |
mov edx,edi |
shl edx,6+16 |
mov dx,[esp+4] |
or edx,15*65536 |
mov esi,0x0 |
int 0x40 |
inc edi |
cmp edi,7 |
jb new_x |
pop edx |
pop ebx |
add ebx,10 |
add edx,64 |
cmp edx,I_END+16*64 |
jb newline |
popa |
ret |
; DATA AREA |
pos dd 0,15,12,14,13,9,8 |
text: |
db ' PID EAX EBX ECX EDX ESI EDI ' |
labelt: |
db 'SYSTEM CALL TRACE' |
labellen: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/mtdbg/mtdbg.txt |
---|
File deleted |
/programs/develop/mtdbg/mtdbg.asm |
---|
File deleted |
/programs/develop/mtdbg/build.bat |
---|
File deleted |
/programs/develop/fasm/trunk/fasm.asm |
---|
22,7 → 22,7 |
;; Menuet header |
appname equ "flat assembler " |
appname equ "FASM " |
use32 |
392,11 → 392,11 |
s_compile db 'COMPILE' |
s_run db ' RUN ' |
infile db 'example.asm' |
infile db 'EXAMPLE.ASM' |
times MAX_PATH+$-infile db 0 |
outfile db 'example' |
outfile db 'EXAMPLE' |
times MAX_PATH+$-outfile db 0 |
path db '/rd/1/' |
path db '/RD/1/' |
times MAX_PATH+$-path db 0 |
lf db 13,10,0 |
/programs/develop/fasm/trunk/version.inc |
---|
33,7 → 33,7 |
; cannot simply be copied and put under another distribution licence |
; (including the GNU Public Licence). |
VERSION_STRING equ "1.67.14" |
VERSION_STRING equ "1.67.13" |
VERSION_MAJOR = 1 |
VERSION_MINOR = 67 |
/programs/develop/fasm/trunk/x86_64.inc |
---|
223,10 → 223,6 |
cdq |
cmp ecx,edx |
jne value_out_of_range |
cmp [value_type],4 |
jne get_simm32_ok |
mov [value_type],2 |
get_simm32_ok: |
ret |
basic_reg: |
lods byte [esi] |
6023,9 → 6019,6 |
mov edx,[symbol_identifier] |
mov [address_symbol],edx |
mov edx,eax |
ror ecx,16 |
mov cl,[value_type] |
rol ecx,16 |
mov bx,0FF00h |
address_ok: |
ret |
/programs/develop/cmd/trunk/macros.inc |
---|
143,6 → 143,9 |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 177,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 221,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/develop/examples/md5/trunk/md5.asm |
---|
File deleted |
/programs/develop/examples/md5/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/develop/examples/md5/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/develop/examples/rtdata/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/develop/examples/rtdata/trunk/macros.inc |
---|
File deleted |
\ No newline at end of file |
/programs/develop/examples/rtdata/trunk/rtdata.asm |
---|
File deleted |
/programs/develop/examples/rtdata/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/develop/examples/ir/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/develop/examples/ir/trunk/ir.asm |
---|
File deleted |
/programs/develop/examples/ir/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/develop/examples/ir/trunk/macros.inc |
---|
File deleted |
\ No newline at end of file |
/programs/develop/examples/cpuspeed/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/develop/examples/cpuspeed/trunk/cpuspeed.asm |
---|
File deleted |
/programs/develop/examples/cpuspeed/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/develop/examples/cpuspeed/trunk/macros.inc |
---|
File deleted |
\ No newline at end of file |
/programs/develop/mview/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm mview.asm mview |
@pause |
/programs/develop/mview/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm mview.asm mview |
@pause |
/programs/develop/mview/trunk/macros.inc |
---|
0,0 → 1,267 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/develop/mview/trunk/mview.asm |
---|
0,0 → 1,1439 |
; CODE VIEWER - Compile with FASM for Menuet |
;B+ System header |
use32 |
org 0x0 |
db 'MENUET00' |
dd 38 |
dd START |
dd I_END |
dd 0x100000 |
dd 0x00000000 |
include 'lang.inc' |
include 'macros.inc' |
;E:. |
;B+ Definitions |
type_begin equ 0 |
type_end_normal equ 2 |
type_not_end equ 4 |
type_end_plus equ 6 |
type_include equ 8 |
type_file_end equ 11 |
; +1, if active jump |
char_end equ 11 |
new_line equ 10 |
win_width equ (496+6*6) |
win_field equ (4+10+6*6) |
win_toptext equ 38+4 |
;B+ Keys |
KEY_UP equ (130+48) |
KEY_DOWN equ (129+48) |
KEY_PGUP equ (136+48) |
KEY_PGDOWN equ (135+48) |
;E:. |
start_data equ (I_END+10+27+16) |
;E:. |
;B+ Execution |
START: |
jmp load_file1 |
;B+ Main cicle |
redr: |
call draw_window |
still: |
mov eax,10 |
int 0x40 |
still_: |
cmp eax,1 |
je redr |
cmp eax,2 |
jne no_key |
mov eax,2 |
int 0x40 |
jmp key |
no_key: |
cmp eax,3 |
jne still |
mov eax,17 |
int 0x40 |
cmp ah,1 |
jne .no_close |
mov eax,-1 |
int 0x40 |
.no_close: |
jmp button |
jmp still |
;E:. |
key: |
;B+ Scroll text |
mov ebx,[top_pos] |
mov [activ_pos],ebx |
mov bx,[top_line] |
mov [activ_line],bx |
mov bx,[top_depth] |
mov [activ_depth],bx |
mov ebx,[top_file] |
mov [activ_file],ebx |
cmp ah,KEY_DOWN ;key_up |
jne .no_down |
call line_down |
jmp .save_shift |
.no_down: |
cmp ah,KEY_UP ;key down |
jne .no_up |
call line_up |
jmp .save_shift |
.no_up: |
cmp ah,KEY_PGUP ;key page up |
jne .no_pgup |
mov edi,35 |
.next_line: |
call line_up |
dec edi |
jnz .next_line |
jmp .save_shift |
.no_pgup: |
cmp ah,KEY_PGDOWN ;key page down |
jne .no_pgdown |
mov edi,35 |
.next_line1: |
call line_down |
dec edi |
jnz .next_line1 |
jmp .save_shift |
.no_pgdown: |
jmp still |
.save_shift: |
mov ebx,[activ_pos] |
mov [top_pos],ebx |
mov bx,[activ_line] |
mov [top_line],bx |
mov bx,[activ_depth] |
mov [top_depth],bx |
mov ebx,[activ_file] |
mov [top_file],ebx |
; Show new text |
mov ebx,1 |
mov eax,12 |
int 0x40 |
call show_text |
mov ebx,2 |
mov eax,12 |
int 0x40 |
jmp still |
;E:. |
button: |
;B+ Distribute button events |
shr eax,8 |
and eax,0xff |
cmp eax,100 |
jge down_buttons |
;B+ Left buttons |
;B+ Find line place |
sub eax,2 |
mov ebx,[top_pos] |
mov [activ_pos],ebx |
mov bx,[top_depth] |
mov [activ_depth],bx |
mov ebx,[top_file] |
mov [activ_file],ebx |
mov bx,[top_line] |
mov [activ_line],bx |
mov ecx,eax |
or ecx,ecx |
jz .line_find |
.next_line: |
push ecx |
call line_down |
pop ecx |
loop .next_line |
.line_find: |
mov ebx,[activ_pos] |
;E:. |
;B+ Switch, if special line |
mov cx,[ebx] |
test cx,not 15 |
jnz still |
cmp cx,type_begin |
je .is_begin_end |
cmp cx,type_begin+1 |
jne .not_begin_end |
.is_begin_end: |
xor [ebx],word 1 |
mov ebx,[ebx+4] |
add ebx,[activ_file] |
xor [ebx],word 1 |
jmp .paint |
.not_begin_end: |
cmp cx,type_include |
je .open_file |
;close file |
cmp cx,type_include+1 |
jne .not_include |
xor [ebx],word 1 |
jmp .paint |
.open_file: |
;Open file |
cmp dword [ebx+4],-1 |
je .load_file |
xor [ebx],word 1 |
jmp .paint |
.paint1: |
pop ebx |
jmp .paint |
.load_file: |
push ebx |
;B+ Prepare file name |
mov ecx,26 |
mov edi,incl_filename |
mov al,' ' |
cld |
rep stosb |
mov cl,[skoba_txt] |
mov ch,[skoba_txt+1] |
add ebx,12 |
.next_char: |
cmp [ebx],cl |
je .begin |
cmp byte [ebx],new_line |
je .paint1 |
inc ebx |
jmp .next_char |
.begin: |
inc ebx |
mov esi,ebx |
.next_char1: |
cmp [ebx],ch |
je .end |
cmp byte [ebx],new_line |
je .paint1 |
inc ebx |
jmp .next_char1 |
.end: |
sub ebx,esi |
mov edi,incl_filename |
mov ecx,ebx |
push ecx |
rep movsb |
; mov al,0 |
; stosb |
;Save in memory |
mov ecx,[esp] |
mov esi,incl_filename |
mov edi,[end_of_file] |
rep movsb |
pop ecx |
mov [edi],ecx |
add ecx,2 |
add [end_of_file],ecx |
mov ebx,[esp] |
;E:. |
mov edi,[top_free_file] |
mov [ebx+4],edi |
mov [activ_pos],ebx |
mov eax,[activ_file] |
sub ebx,eax |
mov [incl_line],ebx |
push eax |
call line_down |
pop eax |
mov ebx,[activ_pos] |
sub ebx,eax |
mov [incl_next],ebx |
pop ebx |
xor [ebx],word 1 |
push eax |
mov eax,[end_of_file] |
add eax,16 |
mov [activ_file],eax |
lea edi,[file_array+4*edi] |
mov [edi],eax |
mov [activ_pos],eax |
mov ebx,[incl_line] |
mov [eax-12],ebx |
mov bx,[activ_line] |
dec bx |
mov word [eax-6],bx |
;B+ Save number for new file |
mov ebx,[esp] |
cmp ebx,[file_array] |
jne .no_root |
mov [eax-8],word 0 |
jmp .parent_ok |
.no_root: |
mov ebx,[esp] |
mov bl,[ebx-2] |
and ebx,0xff |
mov [eax-8],bx |
.parent_ok: |
push eax |
;E:. |
call add_file |
mov edi,[block_pointer] |
mov word [edi+4],char_end |
add [block_pointer],8 |
push edi |
call fresh_file |
pop edi eax |
mov [block_pointer],edi |
;B+ Save newfile line count |
mov edi,[line_] |
mov word [eax-4],di |
;E:. |
pop eax |
mov [activ_file],eax |
inc [top_free_file] |
jmp .paint |
.not_include: |
.paint: |
mov ebx,1 |
mov eax,12 |
int 0x40 |
call show_text |
mov ebx,2 |
mov eax,12 |
int 0x40 |
;E:. |
jmp still |
;E:. |
down_buttons: |
;B+ If down buttons |
cmp eax,101 |
je load_file ;Button 'Load' |
sub eax,100 |
mov edx,[str_table+4*eax] |
mov [str_start],edx |
;B+ Clear old info |
push edx |
;clear text |
mov ecx,0xaa0000 |
call print_str |
pop edx |
;clear memory place |
mov ecx,[edx] |
lea edi,[edx+8] |
mov eax,' ' |
cld |
rep stosb |
;E:. |
mov ebx,[edx] |
mov [max_len],ebx |
mov ebx,[edx+4] |
jmp load_str |
save_str: |
;B+ Save in base place |
;B+ If file convert to upper case |
mov eax,it1 |
cmp eax,[str_start] |
jne .no_file |
mov ecx,0xaa0000 |
mov edx,str_ |
mov esi,[it1] |
mov ebx,[it1+4] |
mov eax,4 |
int 0x40 |
mov edx,edi |
mov eax,str_ |
dec eax |
inc edx |
.next_char: |
inc eax |
dec edx |
jz .no_file |
cmp byte [eax],'a' |
jl .next_char |
cmp byte [eax],'z' |
jg .next_char |
add byte [eax],'A'-'a' |
jmp .next_char |
.no_file: |
;E:. |
mov edx,[str_start] |
add edx,8 |
mov ecx,edi |
add edi,edx |
mov byte [edi],char_end |
mov eax,it1 |
cmp eax,[str_start] |
jne .no_null |
mov byte [edi],' ' ;0 |
.no_null: |
mov esi,str_ |
mov edi,edx |
cld |
rep movsb |
mov ecx,0xffffff |
jmp print_str |
;E:. |
;E:. |
;E:. |
;B+ String tools |
;B+ Data for load string |
curs db '_' |
str_: times 100 db ' ' |
db char_end |
max_len dd 10 |
;E:. |
load_str: |
;B+ Load text field |
xor edi,edi |
mov ecx,0xffaaaa |
mov esi,1 |
.next_char: |
mov edx,curs |
mov eax,4 |
int 0x40 |
;B+ Get key event |
mov eax,10 |
int 0x40 |
push eax |
mov ecx,0xaa0000 |
mov eax,4 |
int 0x40 |
pop eax |
cmp eax,2 |
je .yes_key |
call save_str |
jmp still_ |
.yes_key: |
mov eax,2 |
int 0x40 |
;E:. |
;B+ Test enter |
cmp ah,13 |
jne .no_ok |
call save_str |
jmp still |
.no_ok: |
;E:. |
;B+ Test backspace |
cmp ah,8 |
jne .no_backsp |
or edi,edi |
jz .next_char |
mov byte [str_+edi],' ' |
mov ecx,0xaa0000 |
mov eax,4 |
int 0x40 |
dec edi |
sub ebx,6*65536 |
lea edx,[str_+edi] |
int 0x40 |
mov ecx,0xffaaaa |
jmp .next_char |
.no_backsp: |
;E:. |
;B+ Prin 1 char |
mov [str_+edi],ah |
mov ecx,0xaa0000 |
mov eax,4 |
int 0x40 |
mov ecx,0xffaaaa |
lea edx,[str_+edi] |
cmp [max_len],edi |
je .next_char |
int 0x40 |
add ebx,6*65536 |
inc edi |
;E:. |
jmp .next_char |
;E:. |
print_str: |
;B+ Print select string |
mov ebx,[str_start] |
lea edx,[ebx+8] |
mov esi,[ebx] |
mov ebx,[ebx+4] |
mov eax,4 |
int 0x40 |
;B+ Test special strings |
pusha |
mov eax,[str_start] |
cmp eax,it2 |
jge .is_ok1 |
popa |
ret |
.is_ok1: |
cmp eax,it3 |
jle .is_ok |
popa |
ret |
.is_ok: |
;E:. |
add eax,8 |
.next_char: |
mov esi,1 |
cmp byte [eax],' ' |
jne .no_space |
;B+ Draw special space |
push eax |
mov edx,space |
mov eax,4 |
int 0x40 |
push ebx |
sub ebx,1*65536 |
mov edx,dot |
int 0x40 |
add ebx,3*65536 |
int 0x40 |
pop ebx |
pop eax |
;E:. |
.no_space: |
add ebx,6*65536 |
cmp byte [eax],char_end |
jne .no_ret |
popa |
ret |
.no_ret: |
inc eax |
jmp .next_char |
space db '_' |
dot db '.' |
;E:. |
;E:. |
;B+ Add / remove files |
add_file: |
;B+ Load and link file |
mov eax,[activ_file] |
push eax |
mov ebx,incl_filename |
mov ecx,0 |
mov edx,-1 |
mov esi,eax |
mov eax,6 |
int 0x40 |
mov ebx,[esp] |
inc eax |
mov [ebx-16],eax |
dec eax |
add ebx,eax |
add eax,16+15 +20 ;??? |
add [end_of_file],eax |
mov byte [ebx],new_line |
mov word [ebx+1],char_end |
mov ax,[activ_line] |
mov word [ebx+3],ax |
mov eax,[incl_next] |
mov [ebx+5],eax |
mov dword [ebx+9],new_line |
mov byte [ebx+13],new_line |
pop ebx |
mov eax,[top_free_file] |
mov byte [ebx-2],al ; this file num |
mov byte [ebx-1],new_line |
ret |
;E:. |
;B+ Include file data |
incl_filename db 'KERNEL.ASM' |
if_e: |
times (26+incl_filename-if_e) db ' ' |
incl_line dd 0x0 |
incl_next dd 0x0 |
;E:. |
;E:. |
;E:. |
;B+ Visualization tools |
draw_window: |
;B+ Redraw window |
mov ebx,1 |
mov eax,12 |
int 0x40 |
;B+ Draw window |
mov ebx,((640-win_width)/2)*65536+win_width |
mov ecx,10*65536+win_toptext+35*10+1+2*16 |
mov edx,[color_depth] |
or edx,0x03000000 |
mov esi,0x80aaaaff |
mov edi,0x00009000 |
mov eax,0x0 |
int 0x40 |
;E:. |
;B+ Draw caption |
mov ebx,8*65537 |
mov ecx,0xffffff |
mov edx,caption |
mov esi,caption_end-caption |
mov eax,4 |
int 0x40 |
;E:. |
;B+ Draw first line |
mov ebx,5*65536+win_width-9 |
mov ecx,25*65536+win_toptext-22-4 |
mov edx,0xaa0000 |
mov eax,13 |
int 0x40 |
mov ebx,21*65536+29 |
mov ecx,0xffffff |
mov edx,line1up1 |
mov esi,line1up1_end-line1up1 |
mov eax,4 |
int 0x40 |
mov ebx,(win_field+6)*65536+29 |
mov edx,line1up2 |
mov esi,line1up2_end-line1up2 |
int 0x40 |
;E:. |
;B+ Main text zone |
;B+ Fill text |
;Clear type lines |
mov edi,lines_view |
mov ecx,35 |
mov eax,0 |
cld |
repe stosd |
call show_text |
;E:. |
;B+ Define left buttons |
; mov ebx,5*65536+9 |
; mov ecx,win_toptext*65536+9 |
; mov edx,0 |
; mov esi,0x9000a0 |
; mov eax,8 |
; mov edi,35 |
;.new_button: |
; int 0x40 |
; add ecx,10*65536 |
; inc edx |
; dec edi |
; jnz .new_button |
;E:. |
;B+ Vertical line |
mov ebx,(win_field-1)*65537 |
mov ecx,24*65536+win_toptext+35*10 |
mov edx,0xffffff |
mov eax,38 |
int 0x40 |
;E:. |
;E:. |
;B+ Down controle zone |
mov ebx,5*65536+win_width-9 |
mov ecx,(35*10+win_toptext+1)*65536+28 |
mov edx,0xaa0000 |
mov eax,13 |
int 0x40 |
mov eax,line1down |
mov ebx,filetxt |
mov ecx,filetxt_end |
call ins_button_prep |
mov edx,100 |
mov eax,8 |
int 0x40 |
mov eax,line1down |
mov ebx,loadtxt |
mov ecx,loadtxt_end |
call ins_button_prep |
inc edx |
mov eax,8 |
int 0x40 |
mov eax,line1down |
mov ebx,begintxt |
mov ecx,begintxt_end |
call ins_button_prep |
inc edx |
mov eax,8 |
int 0x40 |
mov eax,line1down |
mov ebx,endtxt |
mov ecx,endtxt_end |
call ins_button_prep |
inc edx |
mov eax,8 |
int 0x40 |
mov eax,line2down |
mov ebx,inctxt |
mov ecx,inctxt_end |
call ins_button_prep |
add ecx,14*65536 |
inc edx |
mov eax,8 |
int 0x40 |
mov eax,line2down |
mov ebx,septxt |
mov ecx,septxt_end |
call ins_button_prep |
add ecx,14*65536 |
inc edx |
mov eax,8 |
int 0x40 |
mov ebx,22*65536+35*10+win_toptext+4 |
mov ecx,0xffffff |
mov edx,line1down |
mov esi,line1down_end-line1down |
mov eax,4 |
int 0x40 |
add ebx,14 |
mov edx,line2down |
mov esi,line2down_end-line2down |
int 0x40 |
;E:. |
;B+ Down controle strings |
mov ecx,0xffffff |
mov eax,it1 |
mov [str_start],eax |
call print_str |
mov eax,it2 |
mov [str_start],eax |
call print_str |
mov eax,it3 |
mov [str_start],eax |
call print_str |
mov eax,it4 |
mov [str_start],eax |
call print_str |
mov eax,it5 |
mov [str_start],eax |
call print_str |
;E:. |
mov ebx,2 |
mov eax,12 |
int 0x40 |
ret |
;E:. |
ins_button_prep: |
;B+ Insert button |
push edx |
push eax |
sub ecx,ebx |
mov eax,6 |
mul ecx |
add eax,6 |
push ax |
mov eax,[esp+2] |
sub ebx,eax |
mov eax,6 |
mul ebx |
add eax,18 |
xchg eax,ebx |
shl ebx,16 |
pop bx |
mov ecx,(35*10+win_toptext+1)*65536+13 |
mov esi,0x00a050 |
pop eax |
pop edx |
ret |
;E:. |
show_text: |
;B+ Show text |
;B+ Show file on top |
mov ebx,(win_field+45)*65536+win_width-(win_field+45+8) |
mov ecx,25*65536+win_toptext-22-4 |
mov edx,0xaa0000 |
mov eax,13 |
int 0x40 |
mov edx,[top_file] |
xor esi,esi |
mov si,[edx-18] |
sub edx,18 |
sub edx,esi |
mov ebx,(win_field+45)*65536+29 |
mov ecx,0xffaaaa |
mov eax,4 |
int 0x40 |
;E:. |
mov ax,[top_line] |
mov [activ_line],ax |
mov ebx,[top_pos] |
mov [activ_pos],ebx |
mov ax,[top_depth] |
mov [activ_depth],ax |
mov eax,[top_file] |
mov [activ_file],eax |
mov ecx,35 |
mov [line_],0 |
.next_line: |
cmp [activ_depth],0 |
jne .next |
cmp byte [ebx],char_end |
je .end_of_file |
.next: |
push ecx |
call show_line |
call line_down |
inc [line_] |
pop ecx |
loop .next_line |
ret |
.end_of_file: |
push ecx |
call clear_line |
inc [activ_pos] |
inc [line_] |
pop ecx |
loop .end_of_file |
ret |
;E:. |
;B+ Button chars |
leftchars db '-','+',' ','H' |
db '?', 0 ,'!','H' |
db '&','x',' ', 0 |
;E:. |
show_line: |
;B+ Show line |
call clear_line |
mov ebx,ecx |
shr ebx,16 |
inc ebx |
or ebx,(win_field+6)*65536 |
push ebx |
push eax |
;B+ Draw left button char |
mov eax,[activ_pos] |
mov ax,[eax] |
test ax,not 15 |
jnz .no_text |
and eax,0xff |
lea edx,[leftchars+eax] |
and ebx,0xffff |
or ebx,8*65536 |
mov ecx,0xffffff |
mov esi,1 |
mov eax,4 |
int 0x40 |
mov ebx,[esp+4] |
.no_text: |
;E:. |
;B+ Draw line number |
xor ecx,ecx |
mov cx,[activ_line] |
mov edx,(10+4+4)*65536 |
mov dx,bx |
mov ebx,5*65536 |
mov esi,0xeeeeee |
mov eax,47 |
int 0x40 |
;E:. |
;B+ Find line length |
xor esi,esi |
mov eax,[activ_pos] |
cmp byte [eax],new_line |
je .len_ok |
test word [eax],not 15 |
jnz .next_char |
add eax,12 ;sckip system zone |
.next_char: |
cmp byte [eax],new_line |
je .len_ok |
inc esi |
inc eax |
jmp .next_char |
.len_ok: |
mov eax,6 |
mul esi |
mov ecx,eax |
add ecx,6 |
pop eax |
mov [eax+2],cx |
;E:. |
mov ecx,[textcolor] |
mov edx,[activ_pos] |
xor edi,edi |
xor ebx,ebx |
mov bx,word [edx] |
cmp bl,new_line |
je .normal_show_line |
test bx,not 15 |
jnz .normal_show_line |
or edi,ebx |
mov ecx,[color_type+4*ebx] |
add edx,12 ;sckip system zone |
.normal_show_line: |
pop ebx |
mov eax,4 |
int 0x40 |
test edi,4 ;bad type close block |
jz .nobad |
add ebx,65536 |
int 0x40 |
.nobad: |
ret |
;E:. |
color_type: |
;B+ Color data |
dd 0x00dddd,0x00ee00 ;0/1 begin 00ee00 |
dd 0x00b5b5,0xffa000 ;2/3 end 00d000 |
dd 0xffffff,-1 ;4 text end |
dd 0x00b5b5,0xffa000 ;6/7 auto end |
dd 0x80ccff,0x80aaff ;8/9 include |
dd -1 ,0xffa000 ;11 file end |
textcolor dd 0xffffff |
;E:. |
clear_line: |
;B+ Clear text in line |
;B+ Find line position |
mov eax,[line_] |
mov ecx,10 |
mul cx |
mov ecx,eax |
add ecx,win_toptext |
;E:. |
;B+ Draw/clear button |
push ecx |
shl ecx,16 |
mov cx,9 |
mov ebx,5*65536+9 |
mov edx,[line_] |
add edx,2 |
mov esi,0x9000a0 |
mov eax,8 |
int 0x40 |
pop ecx |
;E:. |
;B+ Clear zone for line |
shl ecx,16 |
mov cx,10 |
mov ebx,(5+11)*65536+win_field-5-12 |
xor edx,edx |
mov dx,[activ_depth] |
mov edx,[color_depth+4*edx] |
mov eax,13 |
int 0x40 |
;E:. |
;B+ Clear main text zone |
mov ebx,(win_field)*65536+(win_width-win_field-8) |
mov eax,[line_] |
lea eax,[lines_view+4*eax] |
push eax |
mov ax,[eax] |
cmp ax,[activ_depth] |
jne .draw_all_line |
mov eax,[esp] |
cmp bx,[eax+2] |
jle .draw_all_line |
mov bx,[eax+2] |
.draw_all_line: |
mov eax,13 |
int 0x40 |
;E:. |
;B+ Update line type I |
pop eax |
mov bx,[activ_depth] |
mov [eax],bx |
;E:. |
ret |
activ_depth dw 0x0 |
color_depth dd 0x404040,0x606060,0x707070,0x7a7a7a |
dd 0x878787,0x909090,0x9a9a9a,0xa5a5a5 |
dd 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 |
lines_view: times 35 dd 0 |
;E:. |
line_up: |
;B+ Line up |
;B+ Test jumps I |
mov ebx,[activ_pos] |
cmp ebx,[activ_file] |
jne .yes_scroll |
cmp [activ_depth],0 |
jz .top_of_file |
dec [activ_depth] |
xor eax,eax |
mov ax,[ebx-8] |
mov eax,[file_array+4*eax] |
mov [activ_file],eax |
add eax,[ebx-12] |
mov [activ_pos],eax |
mov ax,[ebx-6] |
mov [activ_line],ax |
.top_of_file: |
ret |
;E:. |
.yes_scroll: |
sub ebx,2 |
.normal_line_up1: |
cmp byte [ebx],new_line |
je .line_ok |
dec ebx |
jmp .normal_line_up1 |
.line_ok: |
;B+ Test for special line |
cmp dword [ebx],new_line |
jne .line_ok1 |
sub ebx,9 |
;E:. |
.line_ok1: |
inc ebx |
test word [ebx],not 15 |
jnz .normal_line_up |
test word [ebx],1 |
jz .normal_line_up |
;B+ Test jumps II |
cmp word [ebx],type_end_normal+1 |
je .to_begin |
cmp word [ebx],type_end_plus+1 |
je .to_begin |
cmp word [ebx],type_include+1 |
je .to_incl |
jmp .normal_line_up |
;E:. |
.to_begin: |
mov eax,[ebx+4] |
add eax,[activ_file] |
mov [activ_pos],eax |
mov ax,[ebx+2] |
inc ax |
sub [activ_line],ax |
ret |
.to_incl: |
inc [activ_depth] |
mov eax,[ebx+4] |
mov eax,[file_array+4*eax] |
mov [activ_file],eax |
mov bx,[eax-4] |
mov [activ_line],bx |
add eax,[eax-16] |
mov [activ_pos],eax |
ret |
.normal_line_up: |
mov [activ_pos],ebx |
dec [activ_line] |
ret |
;E:. |
line_down: |
;B+ Line down |
mov ebx,[activ_pos] |
cmp byte [ebx],char_end |
jne .yes_scroll |
cmp [activ_depth],0 |
jne .yes_scroll |
ret |
.yes_scroll: |
cmp byte [ebx],new_line |
je .normal_line_down |
test word [ebx],not 15 |
jnz .normal_line_down |
test word [ebx],1 |
jz .not_activated |
;B+ Test jumps |
cmp word [ebx],type_begin+1 |
jne .no_begin |
mov eax,[ebx+4] |
add eax,[activ_file] |
mov [activ_pos],eax |
mov ax,[ebx+2] |
add [activ_line],ax |
call line_down |
ret |
.no_begin: |
cmp word [ebx],type_end_normal+1 |
je .not_activated |
cmp word [ebx],type_end_plus+1 |
je .not_activated |
;goto include |
cmp word [ebx],type_include+1 |
jne .no_incl |
inc [activ_depth] |
mov eax,[ebx+4] |
mov eax,[file_array+4*eax] |
mov [activ_file],eax |
mov [activ_pos],eax |
mov [activ_line],1 |
ret |
.no_incl: |
;return from include |
cmp word [ebx],type_file_end |
jne .no_end |
;CHECK FOR FIRST |
mov ax,[ebx+2] |
mov [activ_line],ax |
dec [activ_depth] |
mov ecx,[activ_file] |
xor eax,eax |
mov ax,[ecx-8] |
mov eax,[file_array+4*eax] |
mov [activ_file],eax |
add eax,[ebx+4] |
mov [activ_pos],eax |
mov ebx,eax |
ret |
.no_end: |
;E:. |
.not_activated: |
add ebx,12 ;sckip system zone |
.normal_line_down: |
cmp byte [ebx],new_line |
je .line_ok |
cmp byte [ebx],char_end |
inc ebx |
jmp .normal_line_down |
.line_ok: |
inc ebx |
mov [activ_pos],ebx |
inc [activ_line] |
ret |
;E:. |
;B+ File possition var. |
line_ dd 0x0 ;Line on screen |
top_pos dd start_data |
top_line dw 1 |
top_depth dw 0x0 |
activ_pos dd start_data |
activ_line dw 0x0 ;Abs line in file |
;E:. |
;E:. |
;B+ Load file tools |
load_file: |
;B+ Main |
;B+ Init parameters |
mov [top_pos],start_data |
mov [activ_pos],start_data |
mov [top_file],start_data |
mov [activ_file],start_data |
mov [file_array],start_data |
mov [top_free_file],1 |
mov [end_of_file],start_data |
mov [top_line],1 |
mov esi,file_txt |
mov edi,incl_filename |
mov ecx,25 |
cld |
rep movsb |
;E:. |
load_file1: |
;B+ Load and fresh file |
mov eax,[end_of_file] |
push eax |
call add_file |
mov edi,[esp] |
mov esi,incl_filename |
sub edi,16+25+2 |
mov ecx,27 |
cld |
rep movsb |
pop edi |
mov word [edi-18],25 |
mov eax,[top_pos] |
mov [activ_pos],eax |
call fresh_file |
call draw_window |
jmp still |
;E:. |
;E:. |
fresh_file: |
;B+ Fresh file |
mov [line_],0 |
mov [next_],next |
.fresh_next: |
inc [line_] |
;Test open block |
mov eax,[begin_txt] |
mov ebx,[activ_pos] |
cmp [ebx],eax |
je block_begin |
;Test close block |
mov eax,[end_txt] |
cmp [ebx],eax |
je block_end |
;B+ Test include |
mov esi,ebx |
mov edi,include_txt |
mov ecx,20 |
cld |
rep cmpsb |
cmp byte [edi-1],char_end |
je include_file |
;E:. |
next: |
;B+ Go to next line |
mov ebx,[activ_pos] |
.next_char: |
cmp byte [ebx],new_line |
je yes_next |
cmp byte [ebx],char_end |
je file_end |
inc ebx |
jmp .next_char |
yes_next: |
inc ebx |
inc [activ_line] |
mov [activ_pos],ebx |
jmp fresh_file.fresh_next |
;E:. |
file_end: |
;B+ Auto set close block |
mov [next_],.try_fill_next |
sub ebx,5 |
dec [activ_line] |
mov [activ_pos],ebx |
.try_fill_next: |
add [activ_pos],5 |
inc [activ_line] |
mov ebx,[activ_pos] |
mov eax,[end_txt] |
mov ecx,[block_pointer] |
cmp word [ecx-4],char_end |
je .fill_ok |
inc [line_] |
call ins_5_bytes |
mov dword [ebx],eax |
mov byte [ebx+4],new_line |
mov byte [ebx+5],char_end |
mov [activ_pos],ebx |
jmp block_end |
;E:. |
.fill_ok: |
ret |
;E:. |
;B+ Specify line markers |
block_begin: |
;B+ Mark block begin |
;B+ Mark info in stack |
mov eax,[activ_pos] |
mov ebx,[block_pointer] |
push eax |
sub eax,[activ_file] |
mov [ebx],eax |
pop eax |
mov word [ebx+4],0 |
mov cx,[activ_line] |
mov word [ebx+6],cx |
add ebx,8 |
mov [block_pointer],ebx |
;E:. |
call ins_12_bytes |
;line / possition not ready |
mov word [eax],type_begin+1 |
mov dword [eax+8],new_line |
add [activ_pos],12 |
jmp [next_] |
;E:. |
block_end: |
;B+ Mark block end |
;B+ Mark end type I |
mov eax,[activ_pos] |
call ins_12_bytes |
mov ecx,[block_pointer] |
cmp word [ecx-4],char_end |
je .normal_line |
;E:. |
;Pop stack |
sub [block_pointer],8 |
sub ecx,8 |
;B+ Form this (END) line/place to BEGIN |
mov edx,[ecx] |
add edx,[activ_file] |
mov eax,[activ_pos] |
sub eax,[activ_file] |
mov [edx+4],eax |
mov bx,[activ_line] |
sub bx,[ecx+6] |
mov [edx+2],bx |
;E:. |
;B+ From stack line/place to this (END) |
mov eax,[activ_pos] |
mov edx,[ecx] |
mov [eax+4],edx |
mov [eax+2],bx |
;E:. |
;B+ Mark end type II |
mov word [eax],type_end_normal+1 |
mov ecx,[next_] |
cmp ecx,next |
je .yes_normal |
mov word [eax],type_end_plus+1 |
.yes_normal: |
mov dword [eax+8],new_line |
add [activ_pos],12 |
jmp [next_] |
.normal_line: |
mov word [eax],type_not_end |
mov dword [eax+8],new_line |
add [activ_pos],12 |
jmp [next_] |
;E:. |
;E:. |
include_file: |
;B+ Include and attach file |
mov eax,[activ_pos] |
push eax |
call ins_12_bytes |
pop eax |
mov word [eax],type_include |
mov word [eax+2],0 |
mov dword [eax+4],-1 |
mov dword [eax+8],new_line |
dec [line_] |
jmp [next_] |
;E:. |
next_ dd next |
;E:. |
;B+ Additional tools |
ins_12_bytes: |
mov ecx,[end_of_file] |
add [end_of_file],12 |
mov esi,ecx |
add ecx,12 |
mov edi,ecx |
sub ecx,11 |
sub ecx,eax |
std |
rep movsb |
mov ecx,[activ_file] |
add dword [ecx-16],12 |
ret |
ins_5_bytes: |
mov ecx,[end_of_file] |
add [end_of_file],5 |
mov esi,ecx |
add ecx,5 |
mov edi,ecx |
sub ecx,4 |
sub ecx,ebx |
std |
rep movsb |
mov ecx,[activ_file] |
add dword [ecx-16],5 |
ret |
ins_1_byte: |
mov ecx,[end_of_file] |
inc [end_of_file] |
mov esi,ecx |
inc ecx |
mov edx,ecx |
sub ecx,ebx |
std |
rep movsb |
mov ecx,[activ_file] |
inc dword [ecx-16] |
ret |
;E:. |
;E:. |
;B+ Data section |
;B+ View data |
caption db 'CODE VIEWER - ver. 0.2' |
caption_end: |
line1up1 db 'LINE' |
line1up1_end: |
line1up2 db 'FILE:' |
line1up2_end: |
line1down: |
filetxt db 'FILE->' |
filetxt_end: |
times 28 db ' ' |
loadtxt db 'LOAD' |
loadtxt_end: |
db ' BLOCK: ' |
begintxt db 'BEGIN->' |
begintxt_end: |
times 10 db ' ' |
db '...' |
times 10 db ' ' |
endtxt db '<-END' |
endtxt_end: |
line1down_end: |
line2down: |
inctxt db 'INCLUDE KEYWORD->' |
inctxt_end: |
times 46 db ' ' |
septxt db 'SEPARATORS->' |
septxt_end: |
line2down_end: |
;E:. |
;B+ Parameter strings |
str_start dd it1 |
str_table dd it1,0,it2,it3,it4,it5 |
;align |
it1: |
dd 25 |
dd (20+6*7)*65536+35*10+win_toptext+3 |
file_txt: |
db 'KERNEL.ASM ',char_end |
;align 4 |
it2: |
dd 4 |
dd (20+56*6)*65536+35*10+win_toptext+3 |
begin_txt: |
db ';B+ ',char_end |
;align 4 |
it3: |
dd 4 |
dd (20+71*6)*65536+35*10+win_toptext+3 |
end_txt: |
db ';E:.',char_end |
;align 4 |
it4: |
dd 43 |
dd (20+18*6)*65536+35*10+win_toptext+3+14 |
include_txt: |
db 'include ',char_end,' ' |
;align 4 |
it5: |
dd 2 |
dd (20+76*6)*65536+35*10+win_toptext+3+14 |
skoba_txt: |
db '"" ',char_end |
;E:. |
block_pointer dd block_stack+8 |
block_stack dw 0,0,char_end,0 |
times 10*2 dd 0x0 |
; STACK BOX: |
; ÚÄÄÄÄÄÄÄÄÄÂÄÄÄÄÂÄÄÄÄÏ |
; Óabs placeÓ 0 ÓlineÓ |
; ÀÄÄÄÄÄÄÄÄÄÁÄÄÄÄÁÄÄÄÄÙ |
; or 0000 'char_end' 00 - bottom |
top_file dd start_data |
activ_file dd start_data |
top_free_file dd 1 |
file_array dd start_data |
times 50 dd 0x0 |
end_of_file dd start_data |
; TEXT MARKER: |
; ÚÄÄÄÄÂÄÄÄÄÂÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÏ |
; ÓtypeÓn.l.Ónew placeÓ 13 Ó |
; ÀÄÄÄÄÁÄÄÄÄÁÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÙ |
;E:. |
;B+ Program preview |
;ÚÄÄÄÄÄ |
;ÓCODE VIEWER - ver. 0.2 o _ x |
;ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ |
;Ó Line | File: |
;Ó---------+--------------------- |
;Ó[+] | |
;Ó[-] | |
;Ó[ ] | |
;Ó[#] | |
;ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ |
;Ó [FILE->]___________ [LOAD] BLOCK: [BEGIN->];B+ú ... ;E:.[<-END] Ó |
;Ó [INCLUDE KEYWORD->]include [SEPARATORS->]"" |
;ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ |
;E:. |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/demos/eyes/trunk/eyes.asm |
---|
20,7 → 20,7 |
db "MENUET01" |
dd 0x01 |
dd ENTRANCE |
dd EYES_END |
dd I_END |
dd 0x3000 |
dd 0x3000 |
dd 0x0 |
30,61 → 30,93 |
ENTRANCE: ; start of code |
; ==== main ==== |
prepare_eyes: |
call prepare_eyes |
mov esi,imagedata ; transform grayscale to putimage format |
mov edi,skindata |
mov ecx,30 |
transform_loop: |
push ecx |
mov ecx,30 |
lp1: |
lodsb |
stosb |
stosb |
stosb |
loop lp1 |
sub esi,30 |
mov ecx,30 |
lp2: |
lodsb |
stosb |
stosb |
stosb |
loop lp2 |
pop ecx |
loop transform_loop |
call shape_window |
still: |
call draw_eyes ; draw those funny "eyes" |
mov eax,23 ; wait for event with timeout |
mov ebx,TIMEOUT |
mov eax,14 ; calculating screen position |
int 0x40 |
shr eax,1 |
mov ax,59 |
sub eax,30*65536 |
mov [win_ebx],eax |
mov [win_ecx],dword 10*65536+44 |
cmp eax,1 ; redraw ? |
jnz no_draw |
call redraw_overlap |
no_draw: |
mov esi,imagedata ; calculate shape reference area |
mov edi,winref |
mov ecx,900 ; disable drag bar |
mov al,0 |
rep stosb |
cmp eax,2 ; key ? |
jz key |
mov ecx,30 ; calculate circles for eyes |
shape_loop: |
push ecx |
cmp eax,3 ; button ? |
jz button |
call copy_line ; duplicate (we have two eyes :) |
sub esi,30 |
call copy_line |
jmp still ; loop |
pop ecx |
loop shape_loop |
; EVENTS |
; -====- shape -====- |
key: |
mov eax,2 ; just read and ignore |
int 0x40 |
jmp still |
shape_window: |
button: ; analyze button |
mov eax,-1 ; this is button 1 - we have only one button :-) |
mov eax,50 ; set up shape reference area |
xor ebx,ebx |
mov ecx,winref |
int 0x40 |
jmp still |
; -====- declarations -====- |
call draw_window |
imagedata equ EYES_END |
skindata equ EYES_END+925 |
winref equ EYES_END+6325 |
still: |
; -====- shape -====- |
call draw_eyes ; draw those funny "eyes" |
shape_window: |
mov eax,50 ; set up shape reference area |
mov ebx,0 |
mov ecx,winref |
_wait: |
mov eax,23 ; wait for event with timeout |
mov ebx,TIMEOUT |
int 0x40 |
dec eax |
jz redraw |
dec eax |
jz key |
dec eax |
jnz still |
button: |
or eax, -1 |
int 0x40 |
key: |
mov al, 2 |
int 0x40 |
jmp still |
redraw: |
call draw_window |
call redraw_eyes |
jmp _wait |
ret |
; -====- redrawing -====- |
draw_eyes: ; check mousepos to disable blinking |
98,8 → 130,22 |
redraw_ok: |
mov [mouse],eax |
redraw_overlap: ; label for redraw event (without checkmouse) |
redraw_eyes: |
mov eax,7 |
mov ebx,skindata |
mov ecx,60*65536+30 |
mov edx,15 |
int 0x40 |
mov eax,15 |
mov ebx,30 |
call draw_eye_point |
add eax,30 |
call draw_eye_point |
ret |
draw_window: |
mov eax,12 |
mov ebx,1 |
int 0x40 |
118,18 → 164,6 |
mov edx,1 |
int 0x40 |
mov eax,7 |
mov ebx,skindata |
mov ecx,60*65536+30 |
mov edx,15 |
int 0x40 |
mov eax,15 |
mov ebx,30 |
call draw_eye_point |
add eax,30 |
call draw_eye_point |
mov eax,12 |
mov ebx,2 |
int 0x40 |
139,10 → 173,8 |
draw_eye_point: ; draw eye point (EAX=X, EBX=Y) |
pusha |
mov ecx, [mouse] ; ecx = mousex, edx = mousey |
mov edx,ecx |
shr ecx,16 |
and edx,0xFFFF |
movzx ecx, word [mouse+2] ; ecx = mousex, esi = mousey |
movzx esi, word [mouse] |
; ===> calculate position |
149,132 → 181,82 |
push eax |
push ebx |
mov byte [sign1],0 |
mov esi, [win_ebx] |
shr esi,16 |
add eax,esi |
mov edx, [win_ebx] |
shr edx,16 |
add eax,edx |
sub ecx,eax ; ECX=ECX-EAX (signed) , ECX=|ECX| |
jnc abs_ok_1 |
neg ecx |
mov byte [sign1],1 |
abs_ok_1: |
mov [temp1],ecx |
push ecx ; save x distance |
mov byte [sign2],0 |
mov esi,[win_ecx] |
shr esi,16 |
add ebx,esi |
sub edx,ebx ; EDX=EDX-EBX (signed) , EDX=|EDX| |
mov edx,[win_ecx] |
shr edx,16 |
add ebx,edx |
sub esi,ebx ; EDX=EDX-EBX (signed) , EDX=|EDX| |
jnc abs_ok_2 |
neg edx |
neg esi |
mov byte [sign2],1 |
abs_ok_2: |
mov [temp2],edx |
pop ebx |
pop eax |
mov [temp2],esi |
push eax ; ECX*=ECX |
push edx |
xor eax,eax |
xor edx,edx |
mov ax,cx |
mul cx |
shl edx,16 |
or eax,edx |
mov ecx,eax |
pop edx |
pop eax |
; ESI = ECX*ECX+ESI*ESI |
imul ecx, ecx |
imul esi, esi |
add esi, ecx |
push eax ; EDX*=EDX |
push ecx |
mov ecx,edx |
xor eax,eax |
xor ecx,ecx ; EDX=SQRT(EBX) |
xor edx,edx |
mov ax,cx |
mul cx |
shl edx,16 |
or eax,edx |
mov edx,eax |
pop ecx |
pop eax |
push ebx |
push ecx |
push edx |
push eax |
mov ebx,ecx ; EBX=ECX+EDX |
add ebx,edx |
xor edi,edi ; ESI=SQRT(EBX) |
mov ecx,edi |
mov edx,edi |
inc edi |
mov eax,edi |
inc edi |
mov eax,1 |
sqrt_loop: |
; in this moment ecx=edx*edx, eax=1+2*edx |
add ecx,eax |
add eax,edi |
inc eax |
inc eax |
inc edx |
cmp ecx,ebx |
cmp ecx,esi |
jbe sqrt_loop |
dec edx |
mov esi,edx |
mov ax,si ; ESI=ESI/7 |
mov eax,edx ; EDX=EDX/7 |
mov dl,7 |
div dl |
and ax,0xFF |
mov si,ax ; ESI ? 0 : ESI=1 |
and eax,0xFF |
mov edx,eax ; EDX ? 0 : EDX=1 |
jnz nozeroflag1 |
mov si,1 |
inc edx |
nozeroflag1: |
pop eax |
pop edx |
pop ecx |
pop eax ; EAX = x distance |
; ECX=EAX/EDX |
div dl |
movzx ecx,al |
pop ebx |
push eax ; ECX=[temp1]/ESI |
push edx |
mov eax,[temp1] |
mov dx,si |
div dl |
mov cl,al |
and ecx,0xFF |
pop edx |
pop eax |
cmp byte [sign1],1 |
je subtract_1 |
add eax,ecx ; EAX=EAX+ECX |
jmp calc_ok_1 |
subtract_1: |
sub eax,ecx ; EAX=EAX-ECX |
calc_ok_1: |
cmp byte [sign1], 0 |
jz @f |
neg ecx |
@@: |
add eax, ecx |
push eax ; EDX=[temp2]/ESI |
push ecx |
push eax ; ESI=[temp2]/EDX |
mov eax,[temp2] |
mov dx,si |
div dl |
mov dl,al |
and dx,0xFF |
pop ecx |
movzx esi,al |
pop eax |
cmp byte [sign2],1 |
je subtract_2 |
add ebx,edx ; EBX=EBX+EDX |
jmp calc_ok_2 |
subtract_2: |
sub ebx,edx ; EBX=EBX-EDX |
calc_ok_2: |
cmp byte [sign2], 0 |
jz @f |
neg esi |
@@: |
add ebx, esi |
; <=== |
mov ecx,ebx ; draw point |
mov ebx,eax |
mov eax,13 |
dec ecx |
dec ecx |
dec ebx |
dec ebx |
; draw point |
lea ecx, [ebx-2] |
lea ebx, [eax-2] |
shl ecx,16 |
add ecx,4 |
shl ebx,16 |
288,82 → 270,13 |
; -====- working on images and window -====- |
prepare_eyes: |
;mov eax,6 ; load EYES.RAW |
;mov ebx,graphix |
;mov ecx,0x00000000 |
;mov edx,0xFFFFFFFF |
;mov esi,imagedata |
;int 0x40 |
;cmp eax,0xFFFFFFFF |
;jnz filefound |
;mov eax,-1 ; file not exists... |
;int 0x40 |
;filefound: |
mov esi,imagedata+25 ; transform grayscale to putimage format |
mov edi,skindata |
mov ecx,30 |
transform_loop: |
push ecx |
mov ecx,30 |
lp1: |
lodsb |
stosb |
stosb |
stosb |
loop lp1 |
sub esi,30 |
mov ecx,30 |
lp2: |
lodsb |
stosb |
stosb |
stosb |
loop lp2 |
pop ecx |
loop transform_loop |
mov eax,14 ; calculating screen position |
int 0x40 |
shr eax,1 |
mov ax,59 |
sub eax,30*65536 |
mov [win_ebx],eax |
mov [win_ecx],dword 10*65536+44 |
mov esi,imagedata+25 ; calculate shape reference area |
mov edi,winref |
mov ecx,900 ; disable drag bar |
mov al,0 |
rep stosb |
mov ecx,30 ; calculate circles for eyes |
shape_loop: |
push ecx |
call copy_line ; duplicate (we have two eyes :) |
sub esi,30 |
call copy_line |
pop ecx |
loop shape_loop |
ret |
copy_line: ; copy single line to shape reference area |
mov ecx,30 |
cpl_loop: |
lodsb |
cmp al,0xFF |
jnz set_one |
mov al,0 |
jmp cpl_ok |
set_one: |
mov al,1 |
cpl_ok: |
; input is image: 0xFF = white pixel, 0 = black pixel |
; output is membership boolean: 0 = pixel no, 1 = pixel ok |
inc eax |
stosb |
loop cpl_loop |
ret |
375,14 → 288,19 |
win_ebx dd 0x0 |
win_ecx dd 0x0 |
mouse dd 0xFFFFFFFF |
;graphix db "EYES.RAW " |
EYES_END: ; end of code |
imagedata: |
; texture is 900 bytes starting from 25th |
file "eyes.raw":25,900 |
I_END: |
; temporary storage for math routines |
temp1 dd 0 |
temp2 dd 0 |
sign1 db 0 |
sign2 db 0 |
sign1 db ? |
sign2 db ? |
align 4 |
temp2 dd ? |
EYES_END: ; end of code |
file "EYES.RAW" |
skindata rb 60*30*3 |
winref rb 45*60 |
/programs/demos/eyes/trunk/macros.inc |
---|
143,6 → 143,10 |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 178,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 222,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/demos/bgitest/trunk/bgifont.inc |
---|
4,7 → 4,7 |
; |
; Created: December 16, 2004 |
; |
; Last changed: August 27, 2006 |
; Last changed: February 2, 2005 |
; |
; Compile with FASM |
237,16 → 237,18 |
mov esi,edi ; esi->FontName |
mov [.dest],edi ; ptr to load font |
if ~ BGI_LEVEL eq KERNEL |
mov eax, 70 |
mov ebx, .fontattr |
mov [.fsize],1 |
mov eax,58 |
mov ebx,.fontinfo |
int 0x40 |
test eax, eax |
jnz .fail |
dps2 '1' |
mov eax, [.fileattr+32] |
mov [.fsize], eax |
shr ebx,9 |
inc ebx |
mov [.fsize],ebx |
mov ebx,.fontinfo |
mov eax,70 |
mov eax,58 |
int 0x40 ; ebx - file size |
else |
push edi esi edx |
338,22 → 340,11 |
.fontinfo: |
dd 0 |
dd 0 |
dd 0 |
.fsize dd 0 |
.dest dd 0 |
.fontfullname: |
dd 0x10000 |
db BGIFONT_PATH |
.font db 'FONT.CHR',0 |
.fontattr: |
dd 5 |
dd 0 |
dd 0 |
dd 0 |
dd .fileattr |
db 0 |
dd .fontfullname |
.fileattr rd 40/4 |
else |
.dest dd 0 |
.font db 'FONT CHR' |
488,7 → 479,6 |
loop .next |
mov ecx,edx ; ecx - x size |
movzx dx,byte[edi+6] |
mov [BGIheight],dx |
mov ebx,[esp+36] |
and ebx,BGI_HAMASK |
cmp ebx,BGI_HARIGHT |
700,7 → 690,7 |
.color dd ? |
.vec_end dd ? |
BGIfont_Ptr dd 0 |
BGIheight dw ? |
width dd ? |
deform dd ? |
BGIangle dd ? |
Xscale dd ? |
/programs/demos/bgitest/trunk/bgitest.asm |
---|
7,7 → 7,7 |
; Last changed: February 2, 2005 |
; |
BGIFONT_PATH equ '/RD/1/FONTS/' |
BGIFONT_PATH equ '/RD/1/' |
_X equ 340 |
_Y equ 240 |
35,8 → 35,8 |
mcall 47,0x80100,,,0x10ffffff |
jecxz .nofont |
lea ebx,[edx+80 shl 16+12] |
mov edx,_BGIfont_Prepare.fontfullname |
mov esi,_BGIfont_Prepare.fontattr-1 |
mov edx,_BGIfont_Prepare.dest+8 |
mov esi,BGIfont_Coo-1 |
sub esi,edx |
add ecx,0x3b800b8 |
BGIfont_Outtext |
/programs/demos/bgitest/trunk/macros.inc |
---|
143,6 → 143,10 |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 178,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 222,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/demos/3dcube2/trunk/macros.inc |
---|
123,10 → 123,8 |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
macro __mov reg,a { ; mike.dld |
if ~a eq |
mov reg,a |
end if |
} |
143,6 → 141,11 |
; language for programs |
lang fix ru ; ru en fr ge fi |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 177,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 221,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/demos/colors/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm colors.asm colors |
@pause |
/programs/demos/colors/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm colors.asm colors |
@pause |
/programs/demos/colors/trunk/colors.asm |
---|
0,0 → 1,206 |
; |
; COLOR TABLE |
; |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x1000 ; required amount of memory |
dd 0x1000 ; esp = 0x7FFF0 |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
call shape_window |
call draw_window ; at first, draw the window |
still: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
jmp still |
red: ; redraw |
call draw_window |
jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp still |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jnz noclose |
mov eax,0xffffffff ; close this program |
int 0x40 |
noclose: |
jmp still |
shape_window: |
pusha |
mov eax,50 ; give the address of reference area |
mov ebx,0 |
mov ecx,shape_reference |
int 0x40 |
mov eax,50 ; give the scaling ( 5 -> 2^5 ) |
mov ebx,1 |
mov ecx,5 |
int 0x40 |
popa |
ret |
shape_reference: |
db 1,0,1,0,1,0,1,0 |
db 0,1,0,1,0,1,0,1 |
db 1,0,1,0,1,0,1,0 |
db 0,1,0,1,0,1,0,1 |
db 1,0,1,0,1,0,1,0 |
db 0,1,0,1,0,1,0,1 |
db 1,0,1,0,1,0,1,0 |
db 0,1,0,1,0,1,0,1 |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+255 ; [x start] *65536 + [x size] |
mov ecx,100*65536+255 ; [y start] *65536 + [y size] |
mov edx,0x00000000 |
mov esi,0x8099bbff ; color of grab bar RRGGBB,8->color glide |
mov edi,0x0099bbee ; color of frames RRGGBB |
int 0x40 |
call draw_colors |
; CLOSE BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,5*65536+12 ; [x start] *65536 + [x size] |
mov ecx,5*65536+12 ; [y start] *65536 + [y size] |
mov edx,1 ; button id |
mov esi,0xccaa22 ; button color RRGGBB |
int 0x40 |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
draw_colors: |
pusha |
mov [bar],dword 0 |
mov eax,-1 |
mov ebx,0 |
mov ecx,0 |
mov edx,0 |
mov edi,0 |
dc1: |
add eax,1 |
cmp eax,256 |
jb na1 |
mov eax,0 |
add ebx,1 |
cmp ebx,256 |
jb na1 |
mov ebx,0 |
add ecx,5 |
na1: |
mov dl,al |
shl edx,8 |
mov dl,bl |
shl edx,8 |
mov dl,cl |
na2: |
pusha |
push edx |
xor edx,edx |
mov eax,edi |
mov ebx,256 |
div ebx |
mov ebx,edx |
mov ecx,eax |
add ebx,[addx] |
add ecx,[addy] |
pop edx |
mov eax,1 |
int 0x40 |
popa |
add edi,1 |
cmp edi,256*256 |
jb dc1 |
popa |
ret |
; DATA AREA |
I_END: |
bar dd ? |
add1 dd ? |
add2 dd ? |
addx dd ? |
addy dd ? |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/demos/colors/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/demos/fire/trunk/build.bat |
---|
File deleted |
\ No newline at end of file |
/programs/demos/fire/trunk/fire.asm |
---|
13,6 → 13,7 |
dd mem_end |
dd 0,0 ; no parameters, no path |
;include 'lang.inc' |
include 'macros.inc' |
START: |
/programs/demos/fire/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm fire.asm fire |
@pause |
/programs/demos/fire/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm fire.asm fire |
@pause |
/programs/demos/fire/trunk/macros.inc |
---|
143,6 → 143,10 |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 178,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 222,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/demos/fire2/trunk/build.bat |
---|
File deleted |
\ No newline at end of file |
/programs/demos/fire2/trunk/fire2.asm |
---|
9,6 → 9,7 |
dd mem_end |
dd 0x0, 0x0 |
;include 'lang.inc' |
START: |
mov edi, my_img |
/programs/demos/fire2/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm fire2.asm fire2 |
@pause |
/programs/demos/fire2/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm fire2.asm fire2 |
@pause |
/programs/media/pic4/trunk/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/media/pic4/trunk/macros.inc |
---|
File deleted |
\ No newline at end of file |
/programs/media/pic4/trunk/pic4.asm |
---|
File deleted |
\ No newline at end of file |
/programs/media/pic4/trunk/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/media/ac97snd/trunk/ac97wav.c |
---|
File deleted |
/programs/media/ac97snd/trunk/ac97wav.h |
---|
File deleted |
/programs/media/ac97snd/trunk/crt.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/mp3dec.vcproj |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/l3huff.h |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/bstream.c |
---|
File deleted |
\ No newline at end of file |
/programs/media/ac97snd/trunk/mp3dec/PROC32.INC |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/imdct.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/l1init.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/l2init.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/l3init.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/bstream.h |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/pow.asm |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/layer3.h |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/window.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/l3sf.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/e_pow.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/windowb.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/l3msis.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/mp3dec.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/fdct.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/l3hybrid.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/mp3dec.h |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/l3side.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/l3quant.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/l3huff.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/math_private.h |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/l3alias.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/sbt.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/l1dec.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/l2dec.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/l3dec.c |
---|
File deleted |
/programs/media/ac97snd/trunk/mp3dec/sbtb.c |
---|
File deleted |
/programs/media/ac97snd/trunk/ac97.sln |
---|
File deleted |
/programs/media/ac97snd/trunk/crt.h |
---|
File deleted |
/programs/media/ac97snd/trunk/k_lib.asm |
---|
File deleted |
/programs/media/ac97snd/trunk/PROC32.INC |
---|
File deleted |
/programs/media/ac97snd/trunk/kolibri.h |
---|
File deleted |
/programs/media/scrshoot/textwork.inc |
---|
File deleted |
\ No newline at end of file |
/programs/media/scrshoot/txtbut.inc |
---|
File deleted |
\ No newline at end of file |
/programs/media/scrshoot/editbox.inc |
---|
File deleted |
\ No newline at end of file |
/programs/media/scrshoot/build_ru.bat |
---|
File deleted |
\ No newline at end of file |
/programs/media/scrshoot/readme.txt |
---|
File deleted |
\ No newline at end of file |
/programs/media/scrshoot/scrwin.inc |
---|
File deleted |
\ No newline at end of file |
/programs/media/scrshoot/gp.inc |
---|
File deleted |
\ No newline at end of file |
/programs/media/scrshoot/scrshoot.asm |
---|
File deleted |
\ No newline at end of file |
/programs/media/scrshoot/scrsavef.inc |
---|
File deleted |
\ No newline at end of file |
/programs/media/scrshoot/file_sys.inc |
---|
File deleted |
\ No newline at end of file |
/programs/media/scrshoot/check.inc |
---|
File deleted |
\ No newline at end of file |
/programs/media/scrshoot/build_en.bat |
---|
File deleted |
\ No newline at end of file |
/programs/media/scrshoot/scrshoot.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/media/scrshoot/label.inc |
---|
File deleted |
\ No newline at end of file |
/programs/media/scrshoot/macros.inc |
---|
File deleted |
\ No newline at end of file |
/programs/media/scrshoot/checkbox.inc |
---|
File deleted |
\ No newline at end of file |
/programs/media/ac97 mp3/trunk/PROC32.INC |
---|
0,0 → 1,268 |
; Macroinstructions for defining and calling procedures |
macro stdcall proc,[arg] ; directly call STDCALL procedure |
{ common |
if ~ arg eq |
reverse |
pushd arg |
common |
end if |
call proc } |
macro invoke proc,[arg] ; indirectly call STDCALL procedure |
{ common |
if ~ arg eq |
reverse |
pushd arg |
common |
end if |
call [proc] } |
macro ccall proc,[arg] ; directly call CDECL procedure |
{ common |
size@ccall = 0 |
if ~ arg eq |
reverse |
pushd arg |
size@ccall = size@ccall+4 |
common |
end if |
call proc |
if size@ccall |
add esp,size@ccall |
end if } |
macro cinvoke proc,[arg] ; indirectly call CDECL procedure |
{ common |
size@ccall = 0 |
if ~ arg eq |
reverse |
pushd arg |
size@ccall = size@ccall+4 |
common |
end if |
call [proc] |
if size@ccall |
add esp,size@ccall |
end if } |
macro proc [args] ; define procedure |
{ common |
match name params, args> |
\{ define@proc name,<params \} } |
prologue@proc equ prologuedef |
macro prologuedef procname,flag,parmbytes,localbytes,reglist |
{ if parmbytes | localbytes |
push ebp |
mov ebp,esp |
if localbytes |
sub esp,localbytes |
end if |
end if |
irps reg, reglist \{ push reg \} } |
epilogue@proc equ epiloguedef |
macro epiloguedef procname,flag,parmbytes,localbytes,reglist |
{ irps reg, reglist \{ reverse pop reg \} |
if parmbytes | localbytes |
leave |
end if |
if flag and 10000b |
retn |
else |
retn parmbytes |
end if } |
macro define@proc name,statement |
{ local params,flag,regs,parmbytes,localbytes,current |
if used name |
name: |
match =stdcall args, statement \{ params equ args |
flag = 11b \} |
match =stdcall, statement \{ params equ |
flag = 11b \} |
match =c args, statement \{ params equ args |
flag = 10001b \} |
match =c, statement \{ params equ |
flag = 10001b \} |
match =params, params \{ params equ statement |
flag = 0 \} |
virtual at ebp+8 |
match =uses reglist=,args, params \{ regs equ reglist |
params equ args \} |
match =regs =uses reglist, regs params \{ regs equ reglist |
params equ \} |
match =regs, regs \{ regs equ \} |
match =,args, params \{ defargs@proc args \} |
match =args@proc args, args@proc params \{ defargs@proc args \} |
parmbytes = $ - (ebp+8) |
end virtual |
name # % = parmbytes/4 |
all@vars equ |
current = 0 |
match prologue:reglist, prologue@proc:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \} |
macro locals |
\{ virtual at ebp-localbytes+current |
macro label . \\{ deflocal@proc .,:, \\} |
struc db [val] \\{ \common deflocal@proc .,db,val \\} |
struc dw [val] \\{ \common deflocal@proc .,dw,val \\} |
struc dp [val] \\{ \common deflocal@proc .,dp,val \\} |
struc dd [val] \\{ \common deflocal@proc .,dd,val \\} |
struc dt [val] \\{ \common deflocal@proc .,dt,val \\} |
struc dq [val] \\{ \common deflocal@proc .,dq,val \\} |
struc rb cnt \\{ deflocal@proc .,rb cnt, \\} |
struc rw cnt \\{ deflocal@proc .,rw cnt, \\} |
struc rp cnt \\{ deflocal@proc .,rp cnt, \\} |
struc rd cnt \\{ deflocal@proc .,rd cnt, \\} |
struc rt cnt \\{ deflocal@proc .,rt cnt, \\} |
struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \} |
macro endl |
\{ purge label |
restruc db,dw,dp,dd,dt,dq |
restruc rb,rw,rp,rd,rt,rq |
restruc byte,word,dword,pword,tword,qword |
current = $-(ebp-localbytes) |
end virtual \} |
macro ret operand |
\{ match any, operand \\{ retn operand \\} |
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs> |
\\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \} |
macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2 |
end if \} } |
macro defargs@proc [arg] |
{ common |
if ~ arg eq |
forward |
local ..arg,current@arg |
match argname:type, arg |
\{ current@arg equ argname |
label ..arg type |
argname equ ..arg |
if dqword eq type |
dd ?,?,?,? |
else if tbyte eq type |
dd ?,?,? |
else if qword eq type | pword eq type |
dd ?,? |
else |
dd ? |
end if \} |
match =current@arg,current@arg |
\{ current@arg equ arg |
arg equ ..arg |
..arg dd ? \} |
common |
args@proc equ current@arg |
forward |
restore current@arg |
common |
end if } |
macro deflocal@proc name,def,[val] |
{ common |
match vars, all@vars \{ all@vars equ all@vars, \} |
all@vars equ all@vars name |
forward |
local ..var,..tmp |
..var def val |
match =?, val \{ ..tmp equ \} |
match any =dup (=?), val \{ ..tmp equ \} |
match tmp : value, ..tmp : val |
\{ tmp: end virtual |
initlocal@proc ..var,def value |
virtual at tmp\} |
common |
match first rest, ..var, \{ name equ first \} } |
macro initlocal@proc name,def |
{ virtual at name |
def |
size@initlocal = $ - name |
end virtual |
position@initlocal = 0 |
while size@initlocal > position@initlocal |
virtual at name |
def |
if size@initlocal - position@initlocal < 2 |
current@initlocal = 1 |
load byte@initlocal byte from name+position@initlocal |
else if size@initlocal - position@initlocal < 4 |
current@initlocal = 2 |
load word@initlocal word from name+position@initlocal |
else |
current@initlocal = 4 |
load dword@initlocal dword from name+position@initlocal |
end if |
end virtual |
if current@initlocal = 1 |
mov byte [name+position@initlocal],byte@initlocal |
else if current@initlocal = 2 |
mov word [name+position@initlocal],word@initlocal |
else |
mov dword [name+position@initlocal],dword@initlocal |
end if |
position@initlocal = position@initlocal + current@initlocal |
end while } |
macro endp |
{ purge ret,locals,endl |
finish@proc |
purge finish@proc |
restore regs@proc |
match all,args@proc \{ restore all \} |
restore args@proc |
match all,all@vars \{ restore all \} } |
macro local [var] |
{ common |
locals |
forward done@local equ |
match varname[count]:vartype, var |
\{ match =BYTE, vartype \\{ varname rb count |
restore done@local \\} |
match =WORD, vartype \\{ varname rw count |
restore done@local \\} |
match =DWORD, vartype \\{ varname rd count |
restore done@local \\} |
match =PWORD, vartype \\{ varname rp count |
restore done@local \\} |
match =QWORD, vartype \\{ varname rq count |
restore done@local \\} |
match =TBYTE, vartype \\{ varname rt count |
restore done@local \\} |
match =DQWORD, vartype \\{ label varname dqword |
rq count+count |
restore done@local \\} |
match , done@local \\{ virtual |
varname vartype |
end virtual |
rb count*sizeof.\#vartype |
restore done@local \\} \} |
match :varname:vartype, done@local:var |
\{ match =BYTE, vartype \\{ varname db ? |
restore done@local \\} |
match =WORD, vartype \\{ varname dw ? |
restore done@local \\} |
match =DWORD, vartype \\{ varname dd ? |
restore done@local \\} |
match =PWORD, vartype \\{ varname dp ? |
restore done@local \\} |
match =QWORD, vartype \\{ varname dq ? |
restore done@local \\} |
match =TBYTE, vartype \\{ varname dt ? |
restore done@local \\} |
match =DQWORD, vartype \\{ label varname dqword |
dq ?,? |
restore done@local \\} |
match , done@local \\{ varname vartype |
restore done@local \\} \} |
match ,done@local |
\{ var |
restore done@local \} |
common |
endl } |
/programs/media/ac97 mp3/trunk/ac97.sln |
---|
0,0 → 1,38 |
|
Microsoft Visual Studio Solution File, Format Version 9.00 |
# Visual Studio 2005 |
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pe2kos", "pe2kos\pe2kos.vcproj", "{50E3FB09-4E3A-4998-A824-6830405193AE}" |
EndProject |
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp3dec", "mp3dec\mp3dec.vcproj", "{97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}" |
EndProject |
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pow_test", "pow_test\pow_test.vcproj", "{9FE40739-2ADC-4241-8182-20E1B3C661A7}" |
EndProject |
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ac97", "ac97\ac97.vcproj", "{1C94A897-DA4F-45B2-B8A6-B97AD837828E}" |
EndProject |
Global |
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
Debug|Win32 = Debug|Win32 |
Release|Win32 = Release|Win32 |
EndGlobalSection |
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
{50E3FB09-4E3A-4998-A824-6830405193AE}.Debug|Win32.ActiveCfg = Debug|Win32 |
{50E3FB09-4E3A-4998-A824-6830405193AE}.Debug|Win32.Build.0 = Debug|Win32 |
{50E3FB09-4E3A-4998-A824-6830405193AE}.Release|Win32.ActiveCfg = Release|Win32 |
{50E3FB09-4E3A-4998-A824-6830405193AE}.Release|Win32.Build.0 = Release|Win32 |
{97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}.Debug|Win32.ActiveCfg = Debug|Win32 |
{97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}.Debug|Win32.Build.0 = Debug|Win32 |
{97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}.Release|Win32.ActiveCfg = Release|Win32 |
{97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}.Release|Win32.Build.0 = Release|Win32 |
{9FE40739-2ADC-4241-8182-20E1B3C661A7}.Debug|Win32.ActiveCfg = Debug|Win32 |
{9FE40739-2ADC-4241-8182-20E1B3C661A7}.Debug|Win32.Build.0 = Debug|Win32 |
{9FE40739-2ADC-4241-8182-20E1B3C661A7}.Release|Win32.ActiveCfg = Release|Win32 |
{9FE40739-2ADC-4241-8182-20E1B3C661A7}.Release|Win32.Build.0 = Release|Win32 |
{1C94A897-DA4F-45B2-B8A6-B97AD837828E}.Debug|Win32.ActiveCfg = Debug|Win32 |
{1C94A897-DA4F-45B2-B8A6-B97AD837828E}.Debug|Win32.Build.0 = Debug|Win32 |
{1C94A897-DA4F-45B2-B8A6-B97AD837828E}.Release|Win32.ActiveCfg = Release|Win32 |
{1C94A897-DA4F-45B2-B8A6-B97AD837828E}.Release|Win32.Build.0 = Release|Win32 |
EndGlobalSection |
GlobalSection(SolutionProperties) = preSolution |
HideSolutionNode = FALSE |
EndGlobalSection |
EndGlobal |
/programs/media/ac97 mp3/trunk/ac97wav.c |
---|
0,0 → 1,718 |
// |
// This file is part of the AC97 mp3 player. |
// (C) copyright Serge 2006 |
// email: infinity_sound@mail.ru |
// |
// This program is free software; you can redistribute it and/or modify |
// it under the terms of the GNU General Public License as published by |
// the Free Software Foundation; either version 2 of the License, or |
// (at your option) any later version. |
// |
// This program is distributed in the hope that it will be useful, |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// GNU General Public License for more details. |
#include "kolibri.h" |
#include "stdio.h" |
#include "string.h" |
#include "ac97wav.h" |
#include "mp3dec/mp3dec.h" |
void thread_proc(); |
void touch(char *buf, int size); |
extern char *__argv; |
//extern char __path; |
/***** for debug output only |
char formats[37][12] = |
{ "PCM_ALL", |
"PCM_2_16_48","PCM_1_16_48","PCM_2_16_44","PCM_1_16_44", |
"PCM_2_16_32","PCM_1_16_32","PCM_2_16_24","PCM_1_16_24", |
"PCM_2_16_22","PCM_1_16_22","PCM_2_16_16","PCM_1_16_16", |
"PCM_2_16_12","PCM_1_16_12","PCM_2_16_11","PCM_1_16_11", |
"PCM_2_16_8","PCM_1_16_8","PCM_2_8_48","PCM_1_8_48", |
"PCM_2_8_44","PCM_1_8_44","PCM_2_8_32","PCM_1_8_32", |
"PCM_2_8_24","PCM_1_8_24","PCM_2_8_22","PCM_1_8_22", |
"PCM_2_8_16","PCM_1_8_16","PCM_2_8_12","PCM_1_8_12", |
"PCM_2_8_11","PCM_1_8_11","PCM_2_8_8","PCM_1_8_8" |
}; |
*******/ |
DWORD hDrv; |
DWORD hSound; |
DWORD hBuff; |
DWORD event[2]; |
CTRL_INFO info; |
FILEINFO fileinfo; |
int m_vol; |
DWORD status; |
DWORD offset; |
DWORD first_sync; |
char *testbuff; |
char *outbuf; |
char *inpbuf; |
int inpsize; |
int outsize; |
char srv_name[] = "INFINITY"; |
char srv_intel[] = "SOUND"; |
char header[] = "AC97 MP3 player"; |
char buttons_text[]=" Play Stop << >> Vol- Vol+"; |
MPEG_DECODE_INFO mpginfo; |
MPEG_DECODE_PARAM param; |
void (*snd_play)(); |
void draw_window() |
{ |
BeginDraw(); |
DrawWindow(100,100,299,72,0x404040,3,0,0,0); |
make_button(7,24,45,13, 0x10|BT_NORMAL,0x808080); |
make_button(56,24,45,13, 0x11|BT_NORMAL,0x808080); |
make_button(104,24,45,13, 0x12|BT_NORMAL,0x808080); |
make_button(152,24,45,13, 0x13|BT_NORMAL,0x808080); |
make_button(200,24,45,13, 0x14|BT_NORMAL,0x808080); |
make_button(248,24,45,13, 0x15|BT_NORMAL,0x808080); |
make_button(7,41,286,11, 0x30|BT_HIDE|BT_NOFRAME,0x404040); |
draw_bar(7,41,286,11,0x404040); |
draw_bar(7,55,286,11,0x404040); |
write_text(12,58,0x004000|FONT0, __argv, strlen(__argv)); |
write_text(11,57,0x00FF20|FONT0, __argv, strlen(__argv)); |
write_text(8,8,0xFFFFFF|FONT0, header, strlen(header)); |
write_text(12,28,0x404040|FONT0,buttons_text,strlen(buttons_text)); |
write_text(11,27,0xA0FFA0|FONT0,buttons_text,strlen(buttons_text)); |
EndDraw(); |
}; |
void draw_progress_bar() |
{ DWORD x; |
x = 286.0f * (float)offset/(float)fileinfo.size; |
if(x==0) return; |
draw_bar(7,41,x,11,0xA0A0A0); |
draw_bar(x+7,41,286-x,11,0x404040); |
}; |
void debug_out_str(char* str) |
{ |
while (*str != 0) |
{ |
debug_out(*str); |
str++; |
} |
} |
int main() //int argc, char *argv[]) |
{ DWORD fmt; |
char *thread_stack; |
DWORD r_bytes; |
int retval; |
InitHeap(1024*1024); |
if(get_fileinfo(__argv, &fileinfo)==FILE_NOT_FOUND) |
return 0; |
if((hDrv=GetService(srv_intel))==0) |
return 0; |
if ((hSound=GetService(srv_name))==0) |
return 0; |
GetDevInfo(hDrv, &info); |
m_vol = GetMasterVol(hDrv,&m_vol); |
if (m_vol > 85) |
{ m_vol = 85; |
SetMasterVol(hDrv,m_vol); |
}; |
_asm {fninit}; |
mp3DecodeInit(); |
testbuff = UserAlloc(4096); |
get_fileinfo(__argv, &fileinfo); |
offset = 0; |
retval=read_file (__argv,testbuff,0,2048,&r_bytes); |
if (retval) return 0; |
fmt = test_wav((WAVEHEADER*)testbuff); |
if (fmt != 0) |
{ |
snd_play = &play_wave; |
outbuf = UserAlloc(32*1024); |
touch(outbuf, 32768); |
offset = 44; |
} |
else |
{ fmt = test_mp3(testbuff); |
if(fmt ==0) return 0; |
snd_play = &play_mp3; |
inpsize = mpginfo.maxInputSize*30; |
inpbuf = UserAlloc(inpsize); |
touch(inpbuf, inpsize); |
outsize = mpginfo.outputSize*30+0x10000; |
outbuf = UserAlloc(outsize); |
touch(outbuf, outsize); |
first_sync = offset; |
}; |
status = ST_PLAY; |
hBuff = CreateBuffer(hSound,fmt); |
if (hBuff == 0) return 0; |
thread_stack = UserAlloc(4096); |
thread_stack+=4092; |
CreateThread(thread_proc, thread_stack); |
while(1) |
{ delay(10); |
switch(status) |
{ case ST_PLAY: |
snd_play(); |
continue; |
case ST_STOP: |
StopBuffer(hSound, hBuff); |
status = ST_DONE; |
continue; |
case ST_EXIT: |
StopBuffer(hSound, hBuff); |
DestroyBuffer(hSound, hBuff); |
return 0; |
}; |
}; |
return 0; |
}; |
void touch(char *buf, int size) |
{ int i; |
for ( i = 0;i < size; i+=4096) |
buf[i] = 0; |
}; |
DWORD test_mp3(char *buf) |
{ int retval; |
int sync; |
WAVEHEADER whdr; |
DWORD r_bytes=2048; |
for (;;) |
{ |
if (!mp3FindSync(buf, 2048, &sync)) |
offset+= 2048; |
else break; |
if (offset >= fileinfo.size || offset >= 102400) |
return 0; |
retval = read_file (__argv,buf,offset,2048,&r_bytes); |
if(retval != 0) return 0; |
}; |
offset+=sync; |
retval = read_file (__argv,buf,offset,2048,&r_bytes); |
if(retval != 0) return 0; |
mp3GetDecodeInfo(buf, r_bytes, &mpginfo, 1); |
whdr.riff_id = 0x46464952; |
whdr.riff_format = 0x45564157; |
whdr.wFormatTag = 0x01; |
whdr.nSamplesPerSec = mpginfo.frequency; |
whdr.nChannels = mpginfo.channels; |
whdr.wBitsPerSample = mpginfo.bitsPerSample; |
return test_wav(&whdr); |
}; |
void wave_out(char* buff) |
{ DWORD ev[2]; |
GetNotify(&ev[0]); |
SetBuffer(hSound,hBuff,buff,ev[1],0x8000); |
} |
void play_mp3() |
{ int retval; |
DWORD r_bytes; |
char *inpPtr; |
char *outPtr; |
int inpBytes; |
int totalout; |
offset = first_sync; |
retval = read_file (__argv,inpbuf,offset,inpsize,&r_bytes); |
if(retval != 0) |
{ status = ST_STOP; |
return ; |
}; |
offset+=inpsize; |
mp3DecodeStart(inpbuf, inpsize); |
inpPtr = inpbuf+mpginfo.skipSize; |
inpBytes = inpsize-mpginfo.skipSize; |
outPtr = outbuf; |
totalout=0; |
memset(outbuf,0,0x10000); |
SetBuffer(hSound,hBuff,outbuf,0,0x10000); |
PlayBuffer(hSound, hBuff); |
_asm { fninit } |
while(1) |
{ if(status!=ST_PLAY) |
break; |
for(;;) |
{ param.inputBuf = inpPtr; |
param.inputSize = inpBytes; |
param.outputBuf = outPtr; |
if(!mp3DecodeFrame(¶m)) |
if( mp3GetLastError()== MP3_ERROR_OUT_OF_BUFFER) |
break; |
inpPtr += param.inputSize; |
inpBytes -= param.inputSize; |
outPtr+=param.outputSize; |
totalout+=param.outputSize; |
}; |
memmove(inpbuf, inpPtr, inpBytes); |
retval = read_file(__argv, &inpbuf[inpBytes],offset, inpsize-inpBytes, &r_bytes); |
offset+=r_bytes; |
if (r_bytes== 0) break; |
inpPtr = inpbuf; |
inpBytes += r_bytes; |
if(totalout < 32768) continue; |
outPtr = outbuf; |
while (totalout > 32768) |
{ wave_out(outPtr); |
totalout-=0x8000; |
outPtr+=0x8000; |
}; |
memmove(outbuf,outPtr, totalout); |
outPtr = outbuf+totalout; |
}; |
if(status != ST_EXIT) |
status = ST_STOP; |
}; |
void play_wave() |
{ |
int retval; |
int remain; |
int i; |
offset = 44; |
read_file (__argv,outbuf,offset,32*1024,0); |
offset+=32*1024; |
SetBuffer(hSound,hBuff,outbuf,0,0x8000); |
read_file (__argv,outbuf,offset,32*1024,0); |
offset+=32*1024; |
SetBuffer(hSound,hBuff,outbuf,0x8000,0x8000); |
PlayBuffer(hSound, hBuff); |
retval = 0; |
while(1) |
{ |
if(status!=ST_PLAY) |
break; |
GetNotify(&event[0]); |
if(retval == FILE_EOF) |
break; |
remain = fileinfo.size-offset; |
if(remain >=32768) |
{ retval = read_file (__argv,outbuf,offset,32*1024,0); |
offset+=32*1024; |
SetBuffer(hSound,hBuff,outbuf,event[1],0x8000); |
continue; |
}; |
if(remain == 0) |
{ retval = FILE_EOF; |
continue; |
}; |
read_file (__argv,outbuf,offset,remain,0); |
for(i=remain;i<32768;i++) |
outbuf[i] = 0; |
SetBuffer(hSound,hBuff,outbuf,event[1],0x8000); |
retval= FILE_EOF; |
}; |
if(status != ST_EXIT) |
status = ST_STOP; |
}; |
void snd_stop() |
{ |
StopBuffer(hSound, hBuff); |
}; |
void thread_proc() |
{ int evnt; |
int pos; |
int key; |
_asm { fninit }; |
draw_window(); |
while(1) |
{ if(status==ST_PLAY) |
{ draw_progress_bar(); |
evnt = wait_for_event(80); |
// debug_out_str("BIG ERROR...\x0D\x0A\x00"); |
} |
else |
evnt = wait_for_event_infinite(); |
switch(evnt) |
{ |
case EV_REDRAW: |
draw_window(); |
break; |
case EV_KEY: |
key = get_key(); |
if(key==27) |
{ status = ST_EXIT; |
exit(); |
}; |
if((key==45)||key==54) |
{ if(m_vol > 0) |
{ m_vol--; |
SetMasterVol(hDrv,m_vol); |
}; |
break; |
}; |
if((key==61)||key==56) |
{ if(m_vol < 90) |
{ m_vol++; |
SetMasterVol(hDrv,m_vol); |
}; |
}; |
break; |
case EV_BUTTON: |
switch(get_button_id()) |
{ case 1: |
status = ST_EXIT; |
exit(); |
break; |
case 0x10: |
status = ST_PLAY; |
continue; |
case 0x11: |
status = ST_STOP; |
break; |
// case 0x12: |
// case 0x13: |
case 0x14: |
if(m_vol > 0) |
{ m_vol--; |
SetMasterVol(hDrv,m_vol); |
}; |
break; |
case 0x15: |
if(m_vol < 90) |
{ m_vol++; |
SetMasterVol(hDrv,m_vol); |
}; |
break; |
case 0x30: |
if(status==ST_DONE) |
break; |
if(snd_play == play_mp3) |
continue; |
pos = (GetMousePos(REL_WINDOW)>>16)-7; |
offset = ((fileinfo.size-44)/286*pos+44)&0xFFFFFFFC; |
draw_progress_bar(); |
break; |
}; |
}; |
}; |
}; |
DWORD test_wav(WAVEHEADER *hdr) |
{ |
if(hdr->riff_id != 0x46464952) |
return 0; |
if(hdr->riff_format != 0x45564157) |
return 0; |
if (hdr->wFormatTag != 0x01) |
return 0; |
switch(hdr->nSamplesPerSec) |
{ case 48000: |
switch (hdr->nChannels) |
{ case 1: |
if(hdr->wBitsPerSample == 16) |
return PCM_1_16_48; |
else |
return PCM_1_8_48; |
case 2: |
if(hdr->wBitsPerSample == 16) |
return PCM_2_16_48; |
else |
return PCM_2_8_48; |
}; |
case 44100: |
switch (hdr->nChannels) |
{ case 1: |
if(hdr->wBitsPerSample == 16) |
return PCM_1_16_44; |
else |
return PCM_1_8_44; |
case 2: |
if(hdr->wBitsPerSample == 16) |
return PCM_2_16_44; |
else |
return PCM_2_8_44; |
}; |
case 32000: |
switch (hdr->nChannels) |
{ case 1: |
if(hdr->wBitsPerSample == 16) |
return PCM_1_16_32; |
else |
return PCM_1_8_32; |
case 2: |
if(hdr->wBitsPerSample == 16) |
return PCM_2_16_32; |
else |
return PCM_2_8_32; |
}; |
case 24000: |
switch (hdr->nChannels) |
{ case 1: |
if(hdr->wBitsPerSample == 16) |
return PCM_1_16_24; |
else |
return PCM_1_8_24; |
case 2: |
if(hdr->wBitsPerSample == 16) |
return PCM_2_16_24; |
else |
return PCM_2_8_24; |
}; |
case 22050: |
switch (hdr->nChannels) |
{ case 1: |
if(hdr->wBitsPerSample == 16) |
return PCM_1_16_22; |
else |
return PCM_1_8_22; |
case 2: |
if(hdr->wBitsPerSample == 16) |
return PCM_2_16_22; |
else |
return PCM_2_8_22; |
}; |
case 16000: |
switch (hdr->nChannels) |
{ case 1: |
if(hdr->wBitsPerSample == 16) |
return PCM_1_16_16; |
else |
return PCM_1_8_16; |
case 2: |
if(hdr->wBitsPerSample == 16) |
return PCM_2_16_16; |
else |
return PCM_2_8_16; |
}; |
case 12000: |
switch (hdr->nChannels) |
{ case 1: |
if(hdr->wBitsPerSample == 16) |
return PCM_1_16_12; |
else |
return PCM_1_8_12; |
case 2: |
if(hdr->wBitsPerSample == 16) |
return PCM_2_16_12; |
else |
return PCM_2_8_12; |
}; |
case 11025: |
switch (hdr->nChannels) |
{ case 1: |
if(hdr->wBitsPerSample == 16) |
return PCM_1_16_11; |
else |
return PCM_1_8_11; |
case 2: |
if(hdr->wBitsPerSample == 16) |
return PCM_2_16_11; |
else |
return PCM_2_8_11; |
}; |
case 8000: |
switch (hdr->nChannels) |
{ case 1: |
if(hdr->wBitsPerSample == 16) |
return PCM_1_16_8; |
else |
return PCM_1_8_8; |
case 2: |
if(hdr->wBitsPerSample == 16) |
return PCM_2_16_8; |
else |
return PCM_2_8_8; |
}; |
default: |
return 0; |
}; |
}; |
void delay (int val) |
{ |
_asm |
{ mov eax,5 |
mov ebx, [val] |
int 0x40 |
}; |
} |
int wait_for_event(int time) |
{ int retval; |
_asm |
{ mov eax,23 |
mov ebx,[time] |
int 0x40 |
mov [retval], eax |
}; |
return retval; |
}; |
int wait_for_event_infinite() |
{ int retval; |
_asm |
{ mov eax,10 |
int 0x40 |
mov [retval], eax |
}; |
return retval; |
}; |
void BeginDraw() |
{_asm |
{ mov eax,12 |
mov ebx, 1 |
int 0x40 |
}; |
}; |
void EndDraw() |
{ _asm |
{ mov eax,12 |
mov ebx, 2 |
int 0x40 |
}; |
}; |
void * __cdecl memmove ( void * dst, const void * src, size_t count) |
{ void * ret = dst; |
if (dst <= src || (char *)dst >= ((char *)src + count)) |
{ |
while (count--) |
{ *(char *)dst = *(char *)src; |
dst = (char *)dst + 1; |
src = (char *)src + 1; |
} |
} |
else |
{ |
dst = (char *)dst + count - 1; |
src = (char *)src + count - 1; |
while (count--) |
{ *(char *)dst = *(char *)src; |
dst = (char *)dst - 1; |
src = (char *)src - 1; |
} |
} |
return(ret); |
}; |
// debug_out_str(formats[fmt]); |
// debug_out_str("\x0D\x0A\x00"); |
// debug_out_str("pci cmd: "); |
// debug_out_hex(info.pci_cmd); |
// debug_out_str("\x0D\x0A\x00"); |
// debug_out_str("irq line: "); |
// debug_out_hex(info.irq); |
// debug_out_str("\x0D\x0A\x00"); |
// debug_out_str("global control: "); |
// debug_out_hex(info.glob_cntrl); |
// debug_out_str("\x0D\x0A\x00"); |
// debug_out_str("global status: "); |
// debug_out_hex(info.glob_sta); |
// debug_out_str("\x0D\x0A\x00"); |
// call _print_volume |
// debug_out_hex(whdr.nChannels); |
// debug_out_str("\x0D\x0A\x00"); |
// debug_out_hex(whdr.nSamplesPerSec); |
// debug_out_str("\x0D\x0A\x00"); |
// debug_out_hex(fmt); |
// debug_out_str("\x0D\x0A\x00"); |
/programs/media/ac97 mp3/trunk/ac97wav.h |
---|
0,0 → 1,86 |
// |
// This file is part of the AC97 mp3 player. |
// (C) copyright Serge 2006 |
// email: infinity_sound@mail.ru |
// |
// This program is free software; you can redistribute it and/or modify |
// it under the terms of the GNU General Public License as published by |
// the Free Software Foundation; either version 2 of the License, or |
// (at your option) any later version. |
// |
// This program is distributed in the hope that it will be useful, |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// GNU General Public License for more details. |
#define PCM_2_16_48 1 |
#define PCM_1_16_48 2 |
#define PCM_2_16_44 3 |
#define PCM_1_16_44 4 |
#define PCM_2_16_32 5 |
#define PCM_1_16_32 6 |
#define PCM_2_16_24 7 |
#define PCM_1_16_24 8 |
#define PCM_2_16_22 9 |
#define PCM_1_16_22 10 |
#define PCM_2_16_16 11 |
#define PCM_1_16_16 12 |
#define PCM_2_16_12 13 |
#define PCM_1_16_12 14 |
#define PCM_2_16_11 15 |
#define PCM_1_16_11 16 |
#define PCM_2_16_8 17 |
#define PCM_1_16_8 18 |
#define PCM_2_8_48 19 |
#define PCM_1_8_48 20 |
#define PCM_2_8_44 21 |
#define PCM_1_8_44 22 |
#define PCM_2_8_32 23 |
#define PCM_1_8_32 24 |
#define PCM_2_8_24 25 |
#define PCM_1_8_24 26 |
#define PCM_2_8_22 27 |
#define PCM_1_8_22 28 |
#define PCM_2_8_16 29 |
#define PCM_1_8_16 30 |
#define PCM_2_8_12 31 |
#define PCM_1_8_12 32 |
#define PCM_2_8_11 33 |
#define PCM_1_8_11 34 |
#define PCM_2_8_8 35 |
#define PCM_1_8_8 36 |
#define ST_DONE 0x0 |
#define ST_PLAY 0x1 |
#define ST_EXIT 0x2 |
#define ST_STOP 0x4 |
typedef struct |
{ DWORD riff_id; |
DWORD riff_size; |
DWORD riff_format; |
DWORD fmt_id; |
DWORD fmt_size; |
WORD wFormatTag; |
WORD nChannels; |
DWORD nSamplesPerSec; |
DWORD nAvgBytesPerSec; |
WORD nBlockAlign; |
WORD wBitsPerSample; |
DWORD data_id; |
DWORD data_size; |
} WAVEHEADER; |
DWORD test_wav(WAVEHEADER *hdr); |
DWORD test_mp3(char *buf); |
//void (*snd_play)(); |
void wave_out(char* buff); |
void play_wave(); |
void play_mp3(); |
void snd_stop(); |
/programs/media/ac97 mp3/trunk/crt.c |
---|
0,0 → 1,70 |
#include "crt.h" |
#define atexitBufferSize 32 |
char pureCallMessage[] = "PURE function call!"; |
char *__argv = 0; |
void (__cdecl *atExitList[atexitBufferSize])(); |
int atExitFnNum = 0; |
void exit() |
{ int i; |
for ( i = atExitFnNum - 1; i >= 0; i-- ) |
atExitList[i](); |
__asm |
{ |
mov eax, -1 |
int 0x40 |
}; |
}; |
int __cdecl atexit( void (__cdecl *func )( void )) |
{ |
// |
if ( atExitFnNum < atexitBufferSize ) |
{ |
// |
atExitList[atExitFnNum++] = func; |
return 0; |
} |
else |
{ |
return 1; |
} |
} |
int __cdecl _purecall() |
{ |
exit(); |
return 0; |
} |
#pragma section(".CRT$XCA",long,read,write) |
#pragma section(".CRT$XCZ",long,read,write) |
typedef void (__cdecl *_PVFV)(void); |
__declspec(allocate(".CRT$XCA")) _PVFV __xc_a[1] = { 0 }; |
__declspec(allocate(".CRT$XCZ")) _PVFV __xc_z[1] = { 0 }; |
// |
#pragma comment(linker, "/merge:.CRT=.rdata") |
// |
void crtStartUp() |
{_PVFV *pbegin; |
_asm {fninit}; |
for ( pbegin = __xc_a; pbegin < __xc_z; pbegin++ ) |
{ |
// |
if ( *pbegin != 0 ) |
(**pbegin)(); |
} |
__argv = *((char **)0x1C); |
main(); |
exit(); |
} |
/programs/media/ac97 mp3/trunk/crt.h |
---|
0,0 → 1,13 |
typedef unsigned __int32 Dword; |
typedef unsigned __int16 Word; |
typedef unsigned __int8 Byte; |
typedef unsigned __int32 size_t; |
extern char *__argv; |
void crtStartUp(); |
int __cdecl _purecall(); |
int __cdecl atexit( void (__cdecl *func )( void )); |
void exit(); |
int main(); |
/programs/media/ac97 mp3/trunk/k_lib.asm |
---|
0,0 → 1,714 |
; |
; This file is part of the AC97 mp3 player. |
; (C) copyright Serge 2006 |
; email: infinity_sound@mail.ru |
; |
; This program is free software; you can redistribute it and/or modify |
; it under the terms of the GNU General Public License as published by |
; the Free Software Foundation; either version 2 of the License, or |
; (at your option) any later version. |
; |
; This program is distributed in the hope that it will be useful, |
; but WITHOUT ANY WARRANTY; without even the implied warranty of |
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
; GNU General Public License for more details. |
format MS COFF |
include "proc32.inc" |
section '.text' code readable executable |
public _GetService@4 |
public _GetDevInfo@8 |
public _GetMasterVol@8 |
public _SetMasterVol@8 |
public _CreateBuffer@8 |
public _DestroyBuffer@8 |
public _SetBuffer@20 |
public _PlayBuffer@8 |
public _StopBuffer@8 |
public _InitHeap@4 |
public _UserAlloc@4 |
public _GetNotify@4 |
public _CreateThread@8 |
public _GetMousePos@4 |
public _get_fileinfo@8 |
public _read_file@20 |
public _get_key |
public _get_button_id |
public _DrawWindow@36 |
public _make_button@24 |
public _draw_bar@20 |
public _write_text@20 |
public _debug_out@4 |
public _debug_out_hex@4 |
public _memset |
struc FILEIO |
{ .cmd dd ? |
.offset dd ? |
dd ? |
.count dd ? |
.buff dd ? |
db ? |
.name dd ? |
}; |
struc CTRL_INFO |
{ .pci_cmd dd ? |
.irq dd ? |
.glob_cntrl dd ? |
.glob_sta dd ? |
.codec_io_base dd ? |
.ctrl_io_base dd ? |
.codec_mem_base dd ? |
.ctrl_mem_base dd ? |
.codec_id dd ? |
} |
CTRL_INFO_SIZE equ 9*4 |
SND_CREATE_DEV equ 1 |
SND_CREATE_BUFF equ 2 |
SND_PLAY equ 3 |
SND_STOP equ 4 |
SND_SETBUFF equ 5 |
SND_DESTROY_BUFF equ 6 |
DEV_SET_BUFF equ 4 |
DEV_NOTIFY equ 5 |
DEV_SET_MASTERVOL equ 6 |
DEV_GET_MASTERVOL equ 7 |
DEV_GET_INFO equ 8 |
align 4 |
proc _get_button_id |
mov eax,17 |
int 0x40 |
test al,al |
jnz @F |
shr eax,8 |
ret |
@@: |
xor eax,eax |
dec eax |
ret |
endp |
align 4 |
proc _get_fileinfo@8 stdcall, name:dword, info:dword |
push ebx |
push esi |
push edi |
xor eax, eax |
mov ebx, [name] |
mov ecx, [info] |
mov [fileio.cmd], 5 |
mov [fileio.offset], eax |
mov [fileio.offset+4], eax |
mov [fileio.count], eax |
mov [fileio.buff], ecx |
mov byte [fileio.buff+4], al |
mov [fileio.name], ebx |
mov eax, 70 |
lea ebx, [fileio] |
int 0x40 |
pop edi |
pop esi |
pop ebx |
ret |
endp |
align 4 |
proc _read_file@20 stdcall,name:dword, buff:dword, offset:dword,\ |
count:dword,reads:dword |
push ebx |
push esi |
push edi |
xor eax, eax |
mov ebx, [name] |
mov edx, [offset] |
mov esi, [buff] |
mov edi, [count] |
mov [fileio.cmd], eax |
mov [fileio.offset], edx |
mov [fileio.offset+4], eax |
mov [fileio.count], edi |
mov [fileio.buff], esi |
mov byte [fileio.buff+4], al |
mov [fileio.name], ebx |
mov eax, 70 |
lea ebx, [fileio] |
int 0x40 |
mov esi, [reads] |
test esi, esi |
jz @f |
mov [esi], ebx |
@@: |
pop edi |
pop esi |
pop ebx |
ret |
endp |
align 4 |
proc _get_key |
mov eax, 2 |
int 0x40 |
shr eax, 8 |
ret |
endp |
align 4 |
proc _InitHeap@4 stdcall, heap_size:dword |
push ebx |
mov eax, 68 |
mov ebx, 11 |
mov ecx, [heap_size] |
int 0x40 |
pop ebx |
ret |
endp |
align 4 |
proc _UserAlloc@4 stdcall, alloc_size:dword |
push ebx |
mov eax, 68 |
mov ebx, 12 |
mov ecx, [alloc_size] |
int 0x40 |
pop ebx |
ret |
endp |
align 4 |
proc _GetNotify@4 stdcall, p_ev:dword |
push ebx |
mov eax, 68 |
mov ebx, 14 |
mov ecx, [p_ev] |
int 0x40 |
pop ebx |
ret |
endp |
align 4 |
proc _CreateThread@8 stdcall, fn:dword, p_stack:dword |
push ebx |
mov eax, 51 |
mov ebx, 1 |
mov ecx, [fn] |
mov edx,[p_stack] |
int 0x40 |
pop ebx |
ret |
endp |
align 4 |
proc _GetMousePos@4 stdcall,rel_type:dword |
push ebx |
mov eax, 37 |
mov ebx, [rel_type] |
int 0x40 |
pop ebx |
ret |
endp |
align 4 |
proc CallServiceEx stdcall, ioctl:dword |
push ebx |
mov eax, 68 |
mov ebx, 17 |
mov ecx, [ioctl] |
int 0x40 |
pop ebx |
ret |
endp |
align 4 |
proc _GetService@4 stdcall, name:dword |
push ebx |
mov eax, 68 |
mov ebx, 16 |
mov ecx, [name] |
int 0x40 |
pop ebx |
ret |
endp |
align 4 |
proc _GetDevInfo@8 stdcall, hSrv:dword, p_info:dword |
locals |
handle dd ? |
io_code dd ? |
input dd ? |
inp_size dd ? |
output dd ? |
out_size dd ? |
endl |
push ebx |
mov eax, [hSrv] |
xor ebx, ebx |
mov ecx, [p_info] |
mov [handle], eax |
mov [io_code], DEV_GET_INFO |
mov [input], ebx |
mov [inp_size], ebx |
mov [output], ecx |
mov [out_size], CTRL_INFO_SIZE |
lea eax, [handle] |
stdcall CallServiceEx, eax |
pop ebx |
ret |
endp |
align 4 |
proc _GetMasterVol@8 stdcall, hSrv:dword,pvol:dword |
locals |
handle dd ? |
io_code dd ? |
input dd ? |
inp_size dd ? |
output dd ? |
out_size dd ? |
endl |
push ebx |
mov eax, [hSrv] |
mov ecx, [pvol] |
xor ebx, ebx |
mov [handle], eax |
mov [io_code], DEV_GET_MASTERVOL |
mov [input], ebx |
mov [inp_size], ebx |
mov [output], ecx |
mov [out_size], 4 |
lea eax, [handle] |
stdcall CallServiceEx, eax |
pop ebx |
ret |
endp |
align 4 |
proc _SetMasterVol@8 stdcall,hSrv:dword,vol:dword |
locals |
handle dd ? |
io_code dd ? |
input dd ? |
inp_size dd ? |
output dd ? |
out_size dd ? |
endl |
push ebx |
mov eax, [hSrv] |
lea ecx, [vol] |
xor ebx, ebx |
mov [handle], eax |
mov [io_code], DEV_SET_MASTERVOL |
mov [input], ecx |
mov [inp_size], 4 |
mov [output], ebx |
mov [out_size], 0 |
lea eax, [handle] |
stdcall CallServiceEx, eax |
pop ebx |
ret |
endp |
align 4 |
proc _CreateBuffer@8 stdcall, hSound:dword,format:dword |
locals |
handle dd ? |
io_code dd ? |
input dd ? |
inp_size dd ? |
output dd ? |
out_size dd ? |
endl |
push ebx |
mov eax, [hSound] |
lea ecx, [format] |
xor ebx, ebx |
mov [handle], eax |
mov [io_code], SND_CREATE_BUFF |
mov [input], ecx |
mov [inp_size], 4 |
mov [output], ebx |
mov [out_size], 0 |
lea eax, [handle] |
stdcall CallServiceEx, eax |
pop ebx |
ret |
endp |
align 4 |
proc _DestroyBuffer@8 stdcall, hSound:dword, str:dword |
locals |
handle dd ? |
io_code dd ? |
input dd ? |
inp_size dd ? |
output dd ? |
out_size dd ? |
endl |
push ebx |
mov eax, [hSound] |
lea ecx, [str] |
xor ebx, ebx |
mov [handle], eax |
mov [io_code], SND_DESTROY_BUFF |
mov [input], ecx |
mov [inp_size], 4 |
mov [output], ebx |
mov [out_size], 0 |
lea eax, [handle] |
stdcall CallServiceEx, eax |
pop ebx |
ret |
endp |
align 4 |
proc _SetBuffer@20 stdcall,hSound:dword, str:dword, src:dword, offs:dword, size:dword |
locals |
handle dd ? |
io_code dd ? |
input dd ? |
inp_size dd ? |
output dd ? |
out_size dd ? |
endl |
push ebx |
mov eax, [hSound] |
lea ecx, [str] |
xor ebx, ebx |
mov [handle], eax |
mov [io_code], SND_SETBUFF |
mov [input], ecx |
mov [inp_size], 16 |
mov [output], ebx |
mov [out_size], 0 |
lea eax, [handle] |
stdcall CallServiceEx, eax |
pop ebx |
ret |
endp |
align 4 |
proc _PlayBuffer@8 stdcall, hSound:dword, str:dword |
locals |
handle dd ? |
io_code dd ? |
input dd ? |
inp_size dd ? |
output dd ? |
out_size dd ? |
endl |
push ebx |
mov eax, [hSound] |
lea ecx, [str] |
xor ebx, ebx |
mov [handle], eax |
mov [io_code], SND_PLAY |
mov [input], ecx |
mov [inp_size], 4 |
mov [output], ebx |
mov [out_size], 0 |
lea eax, [handle] |
stdcall CallServiceEx, eax |
pop ebx |
ret |
endp |
align 4 |
proc _StopBuffer@8 stdcall, hSound:dword, str:dword |
locals |
handle dd ? |
io_code dd ? |
input dd ? |
inp_size dd ? |
output dd ? |
out_size dd ? |
endl |
push ebx |
mov eax, [hSound] |
lea ecx, [str] |
xor ebx, ebx |
mov [handle], eax |
mov [io_code], SND_STOP |
mov [input], ecx |
mov [inp_size], 4 |
mov [output], ebx |
mov [out_size], 0 |
lea eax, [handle] |
stdcall CallServiceEx, eax |
pop ebx |
ret |
endp |
align 4 |
proc _DrawWindow@36 stdcall, x:dword, y:dword, sx:dword, sy:dword,\ |
workcolor:dword, style:dword, captioncolor:dword,\ |
windowtype:dword, bordercolor:dword |
push ebx edi esi |
mov ebx, [x] |
mov ecx, [y] |
shl ebx, 16 |
shl ecx, 16 |
mov bx, word [sx] |
mov cx, word [sy] |
mov edx,[style] |
shl edx,24 |
add edx,[workcolor] |
mov esi,[windowtype] |
shl esi,24 |
add esi,[captioncolor] |
mov edi,[bordercolor] |
xor eax,eax |
int 0x40 |
pop esi edi ebx |
ret |
endp |
align 4 |
_make_button@24: |
;arg1 - x |
;arg2 - y |
;arg3 - xsize |
;arg4 - ysize |
;arg5 - id |
;arg6 - color |
push ebx esi |
mov ebx,[esp+12] |
shl ebx,16 |
mov bx,[esp+20] |
mov ecx,[esp+16] |
shl ecx,16 |
mov cx,[esp+24] |
mov edx,[esp+28] |
mov esi,[esp+32] |
mov eax,8 |
int 0x40 |
pop esi ebx |
ret 24 |
align 4 |
_draw_bar@20: |
;arg1 - x |
;arg2 - y |
;arg3 - xsize |
;arg4 - ysize |
;arg5 - color |
push ebx |
mov eax,13 |
mov ebx,[esp+8] |
shl ebx,16 |
mov bx,[esp+16] |
mov ecx,[esp+12] |
shl ecx,16 |
mov cx,[esp+20] |
mov edx,[esp+24] |
int 0x40 |
pop ebx |
ret 20 |
_write_text@20: |
;arg1 - x |
;arg2 - y |
;arg3 - color |
;arg4 - text |
;arg5 - len |
push ebx esi |
mov eax,4 |
mov ebx,[esp+12] |
shl ebx,16 |
mov bx,[esp+16] |
mov ecx,[esp+20] |
mov edx,[esp+24] |
mov esi,[esp+28] |
int 0x40 |
pop esi ebx |
ret 20 |
align 4 |
proc _debug_out@4 stdcall, val:dword |
push ebx |
mov ecx,[val] |
mov ebx,1 |
mov eax,63 |
int 0x40 |
pop ebx |
ret |
endp |
align 4 |
proc _debug_out_hex@4 stdcall val:dword |
locals |
count dd ? |
endl |
mov [count], 8 |
.new_char: |
rol [val], 4 |
mov ecx, [val] |
and ecx, 0x0f |
mov cl,byte [__hexdigits+ecx] |
mov eax, 63 |
mov ebx, 1 |
int 0x40 |
dec [count] |
jnz .new_char |
ret |
endp |
align 4 |
_memset: |
mov edx,[esp + 0ch] |
mov ecx,[esp + 4] |
test edx,edx |
jz short toend |
xor eax,eax |
mov al,[esp + 8] |
push edi |
mov edi,ecx |
cmp edx,4 |
jb tail |
neg ecx |
and ecx,3 |
jz short dwords |
sub edx,ecx |
adjust_loop: |
mov [edi],al |
add edi,1 |
sub ecx,1 |
jnz adjust_loop |
dwords: |
mov ecx,eax |
shl eax,8 |
add eax,ecx |
mov ecx,eax |
shl eax,10h |
add eax,ecx |
mov ecx,edx |
and edx,3 |
shr ecx,2 |
jz tail |
cld |
rep stosd |
main_loop_tail: |
test edx,edx |
jz finish |
tail: |
mov [edi],al |
add edi,1 |
sub edx,1 |
jnz tail |
finish: |
mov eax,[esp + 8] |
pop edi |
ret |
toend: |
mov eax,[esp + 4] |
ret |
public __ftol2_sse |
align 4 |
__ftol2_sse: |
push ebp |
mov ebp, esp |
sub esp, 20 |
and esp, 0xFFFFFFF0 |
fld st0 |
fst dword [esp+18] |
fistp qword [esp+10] |
fild qword [esp+10] |
mov edx, [esp+18] |
mov eax, [esp+10] |
test eax, eax |
jz .QnaNZ |
.not_QnaNZ: |
fsubp st1, st0 |
test edx, edx |
jns .pos |
fstp dword [esp] |
mov ecx, [esp] |
xor ecx, 0x80000000 |
add ecx, 0x7FFFFFFF |
adc eax, 0 |
mov edx, [esp+14] |
adc edx, 0 |
jmp .exit |
.pos: |
fstp dword [esp] |
mov ecx, [esp] |
add ecx, 0x7FFFFFFF |
sbb eax, 0 |
jmp .exit |
.QnaNZ: |
mov edx, [esp+14] |
test edx, 0x7FFFFFFF |
jne .not_QnaNZ |
fstp dword [esp+18] |
fstp dword [esp+18] |
.exit: |
leave |
ret |
public __fltused |
__fltused dd 0 |
align 4 |
__hexdigits db '0123456789ABCDEF' |
align 4 |
fileio FILEIO |
/programs/media/ac97 mp3/trunk/kolibri.h |
---|
0,0 → 1,109 |
// |
// This file is part of the AC97 mp3 player. |
// (C) copyright Serge 2006 |
// email: infinity_sound@mail.ru |
// |
// This program is free software; you can redistribute it and/or modify |
// it under the terms of the GNU General Public License as published by |
// the Free Software Foundation; either version 2 of the License, or |
// (at your option) any later version. |
// |
// This program is distributed in the hope that it will be useful, |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// GNU General Public License for more details. |
#define FONT0 0x00000000 |
#define FONT1 0x10000000 |
#define BT_NORMAL 0x00000000 |
#define BT_NOFRAME 0x20000000 |
#define BT_HIDE 0x40000000 |
#define BT_DEL 0x80000000 |
#define EV_REDRAW 1 |
#define EV_KEY 2 |
#define EV_BUTTON 3 |
#define REL_SCREEN 0 |
#define REL_WINDOW 1 |
#define FILE_NOT_FOUND 5 |
#define FILE_EOF 6 |
typedef unsigned int DWORD; |
typedef unsigned short int WORD; |
typedef struct |
{ DWORD pci_cmd; |
DWORD irq; |
DWORD glob_cntrl; |
DWORD glob_sta; |
DWORD codec_io_base; |
DWORD ctrl_io_base; |
DWORD codec_mem_base; |
DWORD ctrl_mem_base; |
DWORD codec_id; |
} CTRL_INFO; |
typedef struct |
{ DWORD cmd; |
DWORD offset; |
DWORD r1; |
DWORD count; |
DWORD buff; |
char r2; |
char *name; |
} FILEIO; |
typedef struct |
{ DWORD attr; |
DWORD flags; |
DWORD cr_time; |
DWORD cr_date; |
DWORD acc_time; |
DWORD acc_date; |
DWORD mod_time; |
DWORD mod_date; |
DWORD size; |
} FILEINFO; |
void _stdcall InitHeap(int heap_size); |
void* _stdcall UserAlloc(int size); |
void _stdcall GetNotify(DWORD *event); |
void _stdcall CreateThread(void *fn, char *p_stack); |
DWORD _stdcall GetMousePos(DWORD rel_type); |
int _stdcall GetService(char *srv_name); |
void _stdcall GetDevInfo(DWORD hSrv,CTRL_INFO *pInfo); |
int _stdcall GetMasterVol(DWORD hSrv,int* vol); |
int _stdcall SetMasterVol(DWORD hSrv, int vol); |
DWORD _stdcall CreateBuffer(DWORD hSrv, DWORD format); |
int _stdcall DestroyBuffer(DWORD hSrv, DWORD hBuff); |
int _stdcall SetBuffer(DWORD hSrv, DWORD hBuff,char* buff, |
DWORD offs, int size); |
int _stdcall PlayBuffer(DWORD hSrv, DWORD hBuff); |
int _stdcall StopBuffer(DWORD hSrv, DWORD hBuff); |
void _stdcall debug_out_hex(DWORD val); |
void debug_out_str(char* str); |
int _stdcall get_fileinfo(char *name,FILEINFO* pinfo); |
int _stdcall read_file (char *name,char*buff,int offset,int count,int *reads); |
void exit(); |
int get_key(void); |
int get_button_id(); |
void delay(int val); |
int wait_for_event(int time); |
int wait_for_event_infinite(); |
void BeginDraw(void); |
void EndDraw(void); |
void _stdcall DrawWindow(int x,int y, int sx, int sy,int workcolor,int style, |
int captioncolor,int windowtype,int bordercolor); |
void _stdcall debug_out(int ch); |
void _stdcall make_button(int x, int y, int xsize, int ysize, int id, int color); |
void _stdcall draw_bar(int x, int y, int xsize, int ysize, int color); |
void _stdcall write_text(int x,int y,int color,char* text,int len); |
/programs/media/ac97 mp3/trunk/mp3dec/PROC32.INC |
---|
0,0 → 1,268 |
; Macroinstructions for defining and calling procedures |
macro stdcall proc,[arg] ; directly call STDCALL procedure |
{ common |
if ~ arg eq |
reverse |
pushd arg |
common |
end if |
call proc } |
macro invoke proc,[arg] ; indirectly call STDCALL procedure |
{ common |
if ~ arg eq |
reverse |
pushd arg |
common |
end if |
call [proc] } |
macro ccall proc,[arg] ; directly call CDECL procedure |
{ common |
size@ccall = 0 |
if ~ arg eq |
reverse |
pushd arg |
size@ccall = size@ccall+4 |
common |
end if |
call proc |
if size@ccall |
add esp,size@ccall |
end if } |
macro cinvoke proc,[arg] ; indirectly call CDECL procedure |
{ common |
size@ccall = 0 |
if ~ arg eq |
reverse |
pushd arg |
size@ccall = size@ccall+4 |
common |
end if |
call [proc] |
if size@ccall |
add esp,size@ccall |
end if } |
macro proc [args] ; define procedure |
{ common |
match name params, args> |
\{ define@proc name,<params \} } |
prologue@proc equ prologuedef |
macro prologuedef procname,flag,parmbytes,localbytes,reglist |
{ if parmbytes | localbytes |
push ebp |
mov ebp,esp |
if localbytes |
sub esp,localbytes |
end if |
end if |
irps reg, reglist \{ push reg \} } |
epilogue@proc equ epiloguedef |
macro epiloguedef procname,flag,parmbytes,localbytes,reglist |
{ irps reg, reglist \{ reverse pop reg \} |
if parmbytes | localbytes |
leave |
end if |
if flag and 10000b |
retn |
else |
retn parmbytes |
end if } |
macro define@proc name,statement |
{ local params,flag,regs,parmbytes,localbytes,current |
if used name |
name: |
match =stdcall args, statement \{ params equ args |
flag = 11b \} |
match =stdcall, statement \{ params equ |
flag = 11b \} |
match =c args, statement \{ params equ args |
flag = 10001b \} |
match =c, statement \{ params equ |
flag = 10001b \} |
match =params, params \{ params equ statement |
flag = 0 \} |
virtual at ebp+8 |
match =uses reglist=,args, params \{ regs equ reglist |
params equ args \} |
match =regs =uses reglist, regs params \{ regs equ reglist |
params equ \} |
match =regs, regs \{ regs equ \} |
match =,args, params \{ defargs@proc args \} |
match =args@proc args, args@proc params \{ defargs@proc args \} |
parmbytes = $ - (ebp+8) |
end virtual |
name # % = parmbytes/4 |
all@vars equ |
current = 0 |
match prologue:reglist, prologue@proc:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \} |
macro locals |
\{ virtual at ebp-localbytes+current |
macro label . \\{ deflocal@proc .,:, \\} |
struc db [val] \\{ \common deflocal@proc .,db,val \\} |
struc dw [val] \\{ \common deflocal@proc .,dw,val \\} |
struc dp [val] \\{ \common deflocal@proc .,dp,val \\} |
struc dd [val] \\{ \common deflocal@proc .,dd,val \\} |
struc dt [val] \\{ \common deflocal@proc .,dt,val \\} |
struc dq [val] \\{ \common deflocal@proc .,dq,val \\} |
struc rb cnt \\{ deflocal@proc .,rb cnt, \\} |
struc rw cnt \\{ deflocal@proc .,rw cnt, \\} |
struc rp cnt \\{ deflocal@proc .,rp cnt, \\} |
struc rd cnt \\{ deflocal@proc .,rd cnt, \\} |
struc rt cnt \\{ deflocal@proc .,rt cnt, \\} |
struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \} |
macro endl |
\{ purge label |
restruc db,dw,dp,dd,dt,dq |
restruc rb,rw,rp,rd,rt,rq |
restruc byte,word,dword,pword,tword,qword |
current = $-(ebp-localbytes) |
end virtual \} |
macro ret operand |
\{ match any, operand \\{ retn operand \\} |
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs> |
\\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \} |
macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2 |
end if \} } |
macro defargs@proc [arg] |
{ common |
if ~ arg eq |
forward |
local ..arg,current@arg |
match argname:type, arg |
\{ current@arg equ argname |
label ..arg type |
argname equ ..arg |
if dqword eq type |
dd ?,?,?,? |
else if tbyte eq type |
dd ?,?,? |
else if qword eq type | pword eq type |
dd ?,? |
else |
dd ? |
end if \} |
match =current@arg,current@arg |
\{ current@arg equ arg |
arg equ ..arg |
..arg dd ? \} |
common |
args@proc equ current@arg |
forward |
restore current@arg |
common |
end if } |
macro deflocal@proc name,def,[val] |
{ common |
match vars, all@vars \{ all@vars equ all@vars, \} |
all@vars equ all@vars name |
forward |
local ..var,..tmp |
..var def val |
match =?, val \{ ..tmp equ \} |
match any =dup (=?), val \{ ..tmp equ \} |
match tmp : value, ..tmp : val |
\{ tmp: end virtual |
initlocal@proc ..var,def value |
virtual at tmp\} |
common |
match first rest, ..var, \{ name equ first \} } |
macro initlocal@proc name,def |
{ virtual at name |
def |
size@initlocal = $ - name |
end virtual |
position@initlocal = 0 |
while size@initlocal > position@initlocal |
virtual at name |
def |
if size@initlocal - position@initlocal < 2 |
current@initlocal = 1 |
load byte@initlocal byte from name+position@initlocal |
else if size@initlocal - position@initlocal < 4 |
current@initlocal = 2 |
load word@initlocal word from name+position@initlocal |
else |
current@initlocal = 4 |
load dword@initlocal dword from name+position@initlocal |
end if |
end virtual |
if current@initlocal = 1 |
mov byte [name+position@initlocal],byte@initlocal |
else if current@initlocal = 2 |
mov word [name+position@initlocal],word@initlocal |
else |
mov dword [name+position@initlocal],dword@initlocal |
end if |
position@initlocal = position@initlocal + current@initlocal |
end while } |
macro endp |
{ purge ret,locals,endl |
finish@proc |
purge finish@proc |
restore regs@proc |
match all,args@proc \{ restore all \} |
restore args@proc |
match all,all@vars \{ restore all \} } |
macro local [var] |
{ common |
locals |
forward done@local equ |
match varname[count]:vartype, var |
\{ match =BYTE, vartype \\{ varname rb count |
restore done@local \\} |
match =WORD, vartype \\{ varname rw count |
restore done@local \\} |
match =DWORD, vartype \\{ varname rd count |
restore done@local \\} |
match =PWORD, vartype \\{ varname rp count |
restore done@local \\} |
match =QWORD, vartype \\{ varname rq count |
restore done@local \\} |
match =TBYTE, vartype \\{ varname rt count |
restore done@local \\} |
match =DQWORD, vartype \\{ label varname dqword |
rq count+count |
restore done@local \\} |
match , done@local \\{ virtual |
varname vartype |
end virtual |
rb count*sizeof.\#vartype |
restore done@local \\} \} |
match :varname:vartype, done@local:var |
\{ match =BYTE, vartype \\{ varname db ? |
restore done@local \\} |
match =WORD, vartype \\{ varname dw ? |
restore done@local \\} |
match =DWORD, vartype \\{ varname dd ? |
restore done@local \\} |
match =PWORD, vartype \\{ varname dp ? |
restore done@local \\} |
match =QWORD, vartype \\{ varname dq ? |
restore done@local \\} |
match =TBYTE, vartype \\{ varname dt ? |
restore done@local \\} |
match =DQWORD, vartype \\{ label varname dqword |
dq ?,? |
restore done@local \\} |
match , done@local \\{ varname vartype |
restore done@local \\} \} |
match ,done@local |
\{ var |
restore done@local \} |
common |
endl } |
/programs/media/ac97 mp3/trunk/mp3dec/bstream.c |
---|
0,0 → 1,212 |
/* max bits required for any lookup - change if htable changes */ |
/* quad required 10 bit w/signs must have (MAXBITS+2) >= 10 */ |
#define MAXBITS 9 |
static unsigned int bitbuf; |
static int bits; |
static unsigned char *bs_ptr; |
static unsigned char *bs_ptr0; |
static unsigned char *bs_ptr_end; // optional for overrun test |
void bitget_init(unsigned char *buf) |
{ |
bs_ptr0 = bs_ptr = buf; |
bits = 0; |
bitbuf = 0; |
} |
int bitget(int n) |
{ |
unsigned int x; |
if (bits < n) |
{ /* refill bit buf if necessary */ |
while (bits <= 24) |
{ |
bitbuf = (bitbuf << 8) | *bs_ptr++; |
bits += 8; |
} |
} |
bits -= n; |
x = bitbuf >> bits; |
bitbuf -= x << bits; |
return x; |
} |
void bitget_skip(int n) |
{ |
unsigned int k; |
if (bits < n) |
{ |
n -= bits; |
k = n >> 3; |
/*--- bytes = n/8 --*/ |
bs_ptr += k; |
n -= k << 3; |
bitbuf = *bs_ptr++; |
bits = 8; |
} |
bits -= n; |
bitbuf -= (bitbuf >> bits) << bits; |
} |
void bitget_init_end(unsigned char *buf_end) |
{ |
bs_ptr_end = buf_end; |
} |
/*------------- check overrun -------------*/ |
int bitget_overrun() |
{ |
return bs_ptr > bs_ptr_end; |
} |
/*------------- get n bits from bitstream -------------*/ |
int bitget_bits_used() |
{ |
unsigned int n; /* compute bits used from last init call */ |
n = ((bs_ptr - bs_ptr0) << 3) - bits; |
return n; |
} |
/*------------- check for n bits in bitbuf -------------*/ |
void bitget_check(int n) |
{ |
if (bits < n) |
{ |
while (bits <= 24) |
{ |
bitbuf = (bitbuf << 8) | *bs_ptr++; |
bits += 8; |
} |
} |
} |
#if 0 |
/*------------- get 1 bit from bitstream -------------*/ |
int bitget_1bit() |
{ |
unsigned int x; |
if (bits <= 0) |
{ /* refill bit buf if necessary */ |
while (bits <= 24) |
{ |
bitbuf = (bitbuf << 8) | *bs_ptr++; |
bits += 8; |
} |
} |
bits--; |
x = bitbuf >> bits; |
bitbuf -= x << bits; |
return x; |
} |
/*------------- get 1 bit from bitstream NO CHECK -------------*/ |
int bitget_1bit() |
{ |
unsigned int x; |
bits--; |
x = bitbuf >> bits; |
bitbuf -= x << bits; |
return x; |
} |
#endif |
/* only huffman */ |
/*----- get n bits - checks for n+2 avail bits (linbits+sign) -----*/ |
int bitget_lb(int n) |
{ |
unsigned int x; |
if (bits < (n + 2)) |
{ /* refill bit buf if necessary */ |
while (bits <= 24) |
{ |
bitbuf = (bitbuf << 8) | *bs_ptr++; |
bits += 8; |
} |
} |
bits -= n; |
x = bitbuf >> bits; |
bitbuf -= x << bits; |
return x; |
} |
/*------------- get n bits but DO NOT remove from bitstream --*/ |
int bitget2(int n) |
{ |
unsigned int x; |
if (bits < (MAXBITS + 2)) |
{ /* refill bit buf if necessary */ |
while (bits <= 24) |
{ |
bitbuf = (bitbuf << 8) | *bs_ptr++; |
bits += 8; |
} |
} |
x = bitbuf >> (bits - n); |
return x; |
} |
/*------------- remove n bits from bitstream ---------*/ |
void bitget_purge(int n) |
{ |
bits -= n; |
bitbuf -= (bitbuf >> bits) << bits; |
} |
void mac_bitget_check(int n) |
{ |
if( bits < n ) { |
while( bits <= 24 ) { |
bitbuf = (bitbuf << 8) | *bs_ptr++; |
bits += 8; |
} |
} |
} |
int mac_bitget(int n) |
{ |
unsigned int code; |
bits -= n; |
code = bitbuf >> bits; |
bitbuf -= code << bits; |
return code; |
} |
int mac_bitget2(int n) |
{ |
return (bitbuf >> (bits-n)); |
} |
int mac_bitget_1bit() |
{ |
unsigned int code; |
bits--; |
code = bitbuf >> bits; |
bitbuf -= code << bits; |
return code; |
} |
void mac_bitget_purge(int n) |
{ |
bits -= n; |
bitbuf -= (bitbuf >> bits) << bits; |
} |
/* |
#define mac_bitget(n) ( bits -= n, \ |
code = bitbuf >> bits, \ |
bitbuf -= code << bits, \ |
code ) |
#define mac_bitget_1bit() ( bits--, \ |
code = bitbuf >> bits, \ |
bitbuf -= code << bits, \ |
code ) |
*/ |
/programs/media/ac97 mp3/trunk/mp3dec/bstream.h |
---|
0,0 → 1,23 |
typedef unsigned char byte; |
typedef unsigned int uint; |
typedef void (*SBT_PROC) (float *sample, void *pcm, int n); |
typedef void (*XFORM_PROC) (void *pcm, int igr); |
void bitget_init(unsigned char *buf); |
void bitget_init_end(unsigned char *buf_end); |
int bitget_overrun(); |
int bitget_bits_used(); |
void bitget_check(int n); |
int bitget(int n); |
void bitget_skip(int n); |
//int bitget_1bit(); |
int bitget_lb(int n); |
int bitget2(int n); |
void bitget_purge(int n); |
void mac_bitget_check(int n); |
int mac_bitget(int n); |
int mac_bitget_1bit(); |
int mac_bitget2(int n); |
void mac_bitget_purge(int n); |
/programs/media/ac97 mp3/trunk/mp3dec/e_pow.c |
---|
0,0 → 1,358 |
/* @(#)e_pow.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* Modified by Naohiko Shimizu/Tokai University, Japan 1997/08/25, |
for performance improvement on pipelined processors. |
*/ |
#if defined(LIBM_SCCS) && !defined(lint) |
static char rcsid[] = "$NetBSD: e_pow.c,v 1.9 1995/05/12 04:57:32 jtc Exp $"; |
#endif |
/* __ieee754_pow(x,y) return x**y |
* |
* n |
* Method: Let x = 2 * (1+f) |
* 1. Compute and return log2(x) in two pieces: |
* log2(x) = w1 + w2, |
* where w1 has 53-24 = 29 bit trailing zeros. |
* 2. Perform y*log2(x) = n+y' by simulating muti-precision |
* arithmetic, where |y'|<=0.5. |
* 3. Return x**y = 2**n*exp(y'*log2) |
* |
* Special cases: |
* 1. (anything) ** 0 is 1 |
* 2. (anything) ** 1 is itself |
* 3. (anything) ** NAN is NAN |
* 4. NAN ** (anything except 0) is NAN |
* 5. +-(|x| > 1) ** +INF is +INF |
* 6. +-(|x| > 1) ** -INF is +0 |
* 7. +-(|x| < 1) ** +INF is +0 |
* 8. +-(|x| < 1) ** -INF is +INF |
* 9. +-1 ** +-INF is NAN |
* 10. +0 ** (+anything except 0, NAN) is +0 |
* 11. -0 ** (+anything except 0, NAN, odd integer) is +0 |
* 12. +0 ** (-anything except 0, NAN) is +INF |
* 13. -0 ** (-anything except 0, NAN, odd integer) is +INF |
* 14. -0 ** (odd integer) = -( +0 ** (odd integer) ) |
* 15. +INF ** (+anything except 0,NAN) is +INF |
* 16. +INF ** (-anything except 0,NAN) is +0 |
* 17. -INF ** (anything) = -0 ** (-anything) |
* 18. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer) |
* 19. (-anything except 0 and inf) ** (non-integer) is NAN |
* |
* Accuracy: |
* pow(x,y) returns x**y nearly rounded. In particular |
* pow(integer,integer) |
* always returns the correct integer provided it is |
* representable. |
* |
* Constants : |
* The hexadecimal values are the intended ones for the following |
* constants. The decimal values may be used, provided that the |
* compiler will convert from decimal to binary accurately enough |
* to produce the hexadecimal values shown. |
*/ |
#include "math.h" |
#include "math_private.h" |
#define zero C[0] |
#define one C[1] |
#define two C[2] |
#define two53 C[3] |
#define huge C[4] |
#define tiny C[5] |
#define L1 C[6] |
#define L2 C[7] |
#define L3 C[8] |
#define L4 C[9] |
#define L5 C[10] |
#define L6 C[11] |
#define P1 C[12] |
#define P2 C[13] |
#define P3 C[14] |
#define P4 C[15] |
#define P5 C[16] |
#define lg2 C[17] |
#define lg2_h C[18] |
#define lg2_l C[19] |
#define ovt C[20] |
#define cp C[21] |
#define cp_h C[22] |
#define cp_l C[23] |
#define ivln2 C[24] |
#define ivln2_h C[25] |
#define ivln2_l C[26] |
double scalbn(double,int); |
#define EXTRACT_WORDS(ix0,ix1,d) \ |
do { \ |
ieee_double_shape_type ew_u; \ |
ew_u.value = (d); \ |
(ix0) = ew_u.parts.msw; \ |
(ix1) = ew_u.parts.lsw; \ |
} while (0) |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
bp[] = {1.0, 1.5,}, |
dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */ |
dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */ |
C[] = { |
0.0, |
1.0, |
2.0, |
9007199254740992.0 , |
1.0e300, |
1.0e-300, |
5.99999999999994648725e-01 , |
4.28571428578550184252e-01 , |
3.33333329818377432918e-01 , |
2.72728123808534006489e-01 , |
2.30660745775561754067e-01 , |
2.06975017800338417784e-01 , |
1.66666666666666019037e-01 , |
-2.77777777770155933842e-03 , |
6.61375632143793436117e-05 , |
-1.65339022054652515390e-06 , |
4.13813679705723846039e-08 , |
6.93147180559945286227e-01 , |
6.93147182464599609375e-01 , |
-1.90465429995776804525e-09 , |
8.0085662595372944372e-0017 , |
9.61796693925975554329e-01 , |
9.61796700954437255859e-01 , |
-7.02846165095275826516e-09 , |
1.44269504088896338700e+00 , |
1.44269502162933349609e+00 , |
1.92596299112661746887e-08 }; |
double pow_test(x,y) |
double x, y; |
{ |
double z,ax,z_h,z_l,p_h,p_l; |
double y1,t1,t2,r,s,t,u,v,w, t12,t14,r_1,r_2,r_3; |
int32_t i,j,k,yisint,n; |
int32_t hx,hy,ix,iy; |
u_int32_t lx,ly; |
EXTRACT_WORDS(hx,lx,x); |
EXTRACT_WORDS(hy,ly,y); |
ix = hx&0x7fffffff; iy = hy&0x7fffffff; |
/* y==zero: x**0 = 1 */ |
if((iy|ly)==0) return C[1]; |
/* +-NaN return x+y */ |
if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) || |
iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0))) |
return x+y; |
/* determine if y is an odd int when x < 0 |
* yisint = 0 ... y is not an integer |
* yisint = 1 ... y is an odd int |
* yisint = 2 ... y is an even int |
*/ |
yisint = 0; |
if(hx<0) { |
if(iy>=0x43400000) yisint = 2; /* even integer y */ |
else if(iy>=0x3ff00000) { |
k = (iy>>20)-0x3ff; /* exponent */ |
if(k>20) { |
j = ly>>(52-k); |
if((u_int32_t)(j<<(52-k))==ly) yisint = 2-(j&1); |
} else if(ly==0) { |
j = iy>>(20-k); |
if((int32_t)(j<<(20-k))==iy) yisint = 2-(j&1); |
} |
} |
} |
/* special value of y */ |
if(ly==0) { |
if (iy==0x7ff00000) { /* y is +-inf */ |
if(((ix-0x3ff00000)|lx)==0) |
return y - y; /* inf**+-1 is NaN */ |
else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */ |
return (hy>=0)? y: C[0]; |
else /* (|x|<1)**-,+inf = inf,0 */ |
return (hy<0)?-y: C[0]; |
} |
if(iy==0x3ff00000) { /* y is +-1 */ |
if(hy<0) return C[1]/x; else return x; |
} |
if(hy==0x40000000) return x*x; /* y is 2 */ |
if(hy==0x3fe00000) { /* y is 0.5 */ |
if(hx>=0) /* x >= +0 */ |
return sqrt(x); |
} |
} |
ax = fabs(x); |
/* special value of x */ |
if(lx==0) { |
if(ix==0x7ff00000||ix==0||ix==0x3ff00000){ |
z = ax; /*x is +-0,+-inf,+-1*/ |
if(hy<0) z = C[1]/z; /* z = (1/|x|) */ |
if(hx<0) { |
if(((ix-0x3ff00000)|yisint)==0) { |
z = (z-z)/(z-z); /* (-1)**non-int is NaN */ |
} else if(yisint==1) |
z = -z; /* (x<0)**odd = -(|x|**odd) */ |
} |
return z; |
} |
} |
/* (x<0)**(non-int) is NaN */ |
if(((((u_int32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x); |
/* |y| is huge */ |
if(iy>0x41e00000) { /* if |y| > 2**31 */ |
if(iy>0x43f00000){ /* if |y| > 2**64, must o/uflow */ |
if(ix<=0x3fefffff) return (hy<0)? C[4]*C[4]:C[5]*C[5]; |
if(ix>=0x3ff00000) return (hy>0)? C[4]*C[4]:C[5]*C[5]; |
} |
/* over/underflow if x is not close to one */ |
if(ix<0x3fefffff) return (hy<0)? C[4]*C[4]:C[5]*C[5]; |
if(ix>0x3ff00000) return (hy>0)? C[4]*C[4]:C[5]*C[5]; |
/* now |1-x| is tiny <= 2**-20, suffice to compute |
log(x) by x-x^2/2+x^3/3-x^4/4 */ |
t = x-1; /* t has 20 trailing zeros */ |
w = (t*t)*(0.5-t*(0.3333333333333333333333-t*0.25)); |
u = C[25]*t; /* ivln2_h has 21 sig. bits */ |
v = t*C[26]-w*C[24]; |
t1 = u+v; |
SET_LOW_WORD(t1,0); |
t2 = v-(t1-u); |
} else { |
double s2,s_h,s_l,t_h,t_l,s22,s24,s26,r1,r2,r3; |
n = 0; |
/* take care subnormal number */ |
if(ix<0x00100000) |
{ax *= C[3]; n -= 53; GET_HIGH_WORD(ix,ax); } |
n += ((ix)>>20)-0x3ff; |
j = ix&0x000fffff; |
/* determine interval */ |
ix = j|0x3ff00000; /* normalize ix */ |
if(j<=0x3988E) k=0; /* |x|<sqrt(3/2) */ |
else if(j<0xBB67A) k=1; /* |x|<sqrt(3) */ |
else {k=0;n+=1;ix -= 0x00100000;} |
SET_HIGH_WORD(ax,ix); |
/* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */ |
u = ax-bp[k]; /* bp[0]=1.0, bp[1]=1.5 */ |
v = C[1]/(ax+bp[k]); |
s = u*v; |
s_h = s; |
SET_LOW_WORD(s_h,0); |
/* t_h=ax+bp[k] High */ |
t_h = C[0]; |
SET_HIGH_WORD(t_h,((ix>>1)|0x20000000)+0x00080000+(k<<18)); |
t_l = ax - (t_h-bp[k]); |
s_l = v*((u-s_h*t_h)-s_h*t_l); |
/* compute log(ax) */ |
s2 = s*s; |
#ifdef DO_NOT_USE_THIS |
r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6))))); |
#else |
r1 = C[10]+s2*C[11]; s22=s2*s2; |
r2 = C[8]+s2*C[9]; s24=s22*s22; |
r3 = C[6]+s2*C[7]; s26=s24*s22; |
r = r3*s22 + r2*s24 + r1*s26; |
#endif |
r += s_l*(s_h+s); |
s2 = s_h*s_h; |
t_h = 3.0+s2+r; |
SET_LOW_WORD(t_h,0); |
t_l = r-((t_h-3.0)-s2); |
/* u+v = s*(1+...) */ |
u = s_h*t_h; |
v = s_l*t_h+t_l*s; |
/* 2/(3log2)*(s+...) */ |
p_h = u+v; |
SET_LOW_WORD(p_h,0); |
p_l = v-(p_h-u); |
z_h = C[22]*p_h; /* cp_h+cp_l = 2/(3*log2) */ |
z_l = C[23]*p_h+p_l*C[21]+dp_l[k]; |
/* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */ |
t = (double)n; |
t1 = (((z_h+z_l)+dp_h[k])+t); |
SET_LOW_WORD(t1,0); |
t2 = z_l-(((t1-t)-dp_h[k])-z_h); |
} |
s = C[1]; /* s (sign of result -ve**odd) = -1 else = 1 */ |
if(((((u_int32_t)hx>>31)-1)|(yisint-1))==0) |
s = -C[1];/* (-ve)**(odd int) */ |
/* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ |
y1 = y; |
SET_LOW_WORD(y1,0); |
p_l = (y-y1)*t1+y*t2; |
p_h = y1*t1; |
z = p_l+p_h; |
EXTRACT_WORDS(j,i,z); |
if (j>=0x40900000) { /* z >= 1024 */ |
if(((j-0x40900000)|i)!=0) /* if z > 1024 */ |
return s*C[4]*C[4]; /* overflow */ |
else { |
if(p_l+C[20]>z-p_h) return s*C[4]*C[4]; /* overflow */ |
} |
} else if((j&0x7fffffff)>=0x4090cc00 ) { /* z <= -1075 */ |
if(((j-0xc090cc00)|i)!=0) /* z < -1075 */ |
return s*C[5]*C[5]; /* underflow */ |
else { |
if(p_l<=z-p_h) return s*C[5]*C[5]; /* underflow */ |
} |
} |
/* |
* compute 2**(p_h+p_l) |
*/ |
i = j&0x7fffffff; |
k = (i>>20)-0x3ff; |
n = 0; |
if(i>0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */ |
n = j+(0x00100000>>(k+1)); |
k = ((n&0x7fffffff)>>20)-0x3ff; /* new k for n */ |
t = C[0]; |
SET_HIGH_WORD(t,n&~(0x000fffff>>k)); |
n = ((n&0x000fffff)|0x00100000)>>(20-k); |
if(j<0) n = -n; |
p_h -= t; |
} |
t = p_l+p_h; |
SET_LOW_WORD(t,0); |
u = t*C[18]; |
v = (p_l-(t-p_h))*C[17]+t*C[19]; |
z = u+v; |
w = v-(z-u); |
t = z*z; |
#ifdef DO_NOT_USE_THIS |
t1 = z - t*(C[12]+t*(C[13]+t*(C[14]+t*(C[15]+t*C[16])))); |
#else |
r_1 = C[15]+t*C[16]; t12 = t*t; |
r_2 = C[13]+t*C[14]; t14 = t12*t12; |
r_3 = t*C[12]; |
t1 = z - r_3 - t12*r_2 - t14*r_1; |
#endif |
r = (z*t1)/(t1-C[2])-(w+z*w); |
z = C[1]-(r-z); |
GET_HIGH_WORD(j,z); |
j += (n<<20); |
if((j>>20)<=0) z = scalbn(z,n); /* subnormal output */ |
else SET_HIGH_WORD(z,j); |
return s*z; |
} |
/programs/media/ac97 mp3/trunk/mp3dec/fdct.c |
---|
0,0 → 1,290 |
#include <math.h> |
static float coef32[31]; /* 32 pt dct coefs */ |
void fdct_init() /* gen coef for N=32 (31 coefs) */ |
{ |
int p, n, i, k; |
double t, pi; |
pi = 4.0 * atan(1.0); |
n = 16; |
k = 0; |
for (i = 0; i < 5; i++, n = n / 2) { |
for (p = 0; p < n; p++, k++) { |
t = (pi / (4 * n)) * (2 * p + 1); |
coef32[k] = (float) (0.50 / cos(t)); |
} |
} |
} |
static void forward_bf(int m, int n, float x[], float f[], float coef[]) |
{ |
int i, j, n2; |
int p, q, p0, k; |
p0 = 0; |
n2 = n >> 1; |
for (i = 0; i < m; i++, p0 += n) { |
k = 0; |
p = p0; |
q = p + n - 1; |
for (j = 0; j < n2; j++, p++, q--, k++) { |
f[p] = x[p] + x[q]; |
f[n2 + p] = coef[k] * (x[p] - x[q]); |
} |
} |
} |
/*------------------------------------------------------------*/ |
static void back_bf(int m, int n, float x[], float f[]) |
{ |
int i, j, n2, n21; |
int p, q, p0; |
p0 = 0; |
n2 = n >> 1; |
n21 = n2 - 1; |
for (i = 0; i < m; i++, p0 += n) { |
p = p0; |
q = p0; |
for (j = 0; j < n2; j++, p += 2, q++) |
f[p] = x[q]; |
p = p0 + 1; |
for (j = 0; j < n21; j++, p += 2, q++) |
f[p] = x[q] + x[q + 1]; |
f[p] = x[q]; |
} |
} |
/*------------------------------------------------------------*/ |
extern int m_enableEQ; |
extern float m_equalizer[32]; |
void fdct32(float x[], float c[]) |
{ |
float a[32]; /* ping pong buffers */ |
float b[32]; |
int p, q; |
if (m_enableEQ) { |
for (p = 0; p < 32; p++) x[p] *= m_equalizer[p]; |
} |
/* special first stage */ |
for (p = 0, q = 31; p < 16; p++, q--) { |
a[p] = x[p] + x[q]; |
a[16 + p] = coef32[p] * (x[p] - x[q]); |
} |
forward_bf(2, 16, a, b, coef32 + 16); |
forward_bf(4, 8, b, a, coef32 + 16 + 8); |
forward_bf(8, 4, a, b, coef32 + 16 + 8 + 4); |
forward_bf(16, 2, b, a, coef32 + 16 + 8 + 4 + 2); |
back_bf(8, 4, a, b); |
back_bf(4, 8, b, a); |
back_bf(2, 16, a, b); |
back_bf(1, 32, b, c); |
} |
/*------------------------------------------------------------*/ |
void fdct32_dual(float x[], float c[]) |
{ |
float a[32]; /* ping pong buffers */ |
float b[32]; |
int p, pp, qq; |
if (m_enableEQ) { |
for (p = 0; p < 32; p++) x[p] *= m_equalizer[p]; |
} |
/* special first stage for dual chan (interleaved x) */ |
pp = 0; |
qq = 2 * 31; |
for (p = 0; p < 16; p++, pp += 2, qq -= 2) |
{ |
a[p] = x[pp] + x[qq]; |
a[16 + p] = coef32[p] * (x[pp] - x[qq]); |
} |
forward_bf(2, 16, a, b, coef32 + 16); |
forward_bf(4, 8, b, a, coef32 + 16 + 8); |
forward_bf(8, 4, a, b, coef32 + 16 + 8 + 4); |
forward_bf(16, 2, b, a, coef32 + 16 + 8 + 4 + 2); |
back_bf(8, 4, a, b); |
back_bf(4, 8, b, a); |
back_bf(2, 16, a, b); |
back_bf(1, 32, b, c); |
} |
/*---------------convert dual to mono------------------------------*/ |
void fdct32_dual_mono(float x[], float c[]) |
{ |
float a[32]; /* ping pong buffers */ |
float b[32]; |
float t1, t2; |
int p, pp, qq; |
/* special first stage */ |
pp = 0; |
qq = 2 * 31; |
for (p = 0; p < 16; p++, pp += 2, qq -= 2) |
{ |
t1 = 0.5F * (x[pp] + x[pp + 1]); |
t2 = 0.5F * (x[qq] + x[qq + 1]); |
a[p] = t1 + t2; |
a[16 + p] = coef32[p] * (t1 - t2); |
} |
forward_bf(2, 16, a, b, coef32 + 16); |
forward_bf(4, 8, b, a, coef32 + 16 + 8); |
forward_bf(8, 4, a, b, coef32 + 16 + 8 + 4); |
forward_bf(16, 2, b, a, coef32 + 16 + 8 + 4 + 2); |
back_bf(8, 4, a, b); |
back_bf(4, 8, b, a); |
back_bf(2, 16, a, b); |
back_bf(1, 32, b, c); |
} |
/*------------------------------------------------------------*/ |
/*---------------- 16 pt fdct -------------------------------*/ |
void fdct16(float x[], float c[]) |
{ |
float a[16]; /* ping pong buffers */ |
float b[16]; |
int p, q; |
/* special first stage (drop highest sb) */ |
a[0] = x[0]; |
a[8] = coef32[16] * x[0]; |
for (p = 1, q = 14; p < 8; p++, q--) |
{ |
a[p] = x[p] + x[q]; |
a[8 + p] = coef32[16 + p] * (x[p] - x[q]); |
} |
forward_bf(2, 8, a, b, coef32 + 16 + 8); |
forward_bf(4, 4, b, a, coef32 + 16 + 8 + 4); |
forward_bf(8, 2, a, b, coef32 + 16 + 8 + 4 + 2); |
back_bf(4, 4, b, a); |
back_bf(2, 8, a, b); |
back_bf(1, 16, b, c); |
} |
/*------------------------------------------------------------*/ |
/*---------------- 16 pt fdct dual chan---------------------*/ |
void fdct16_dual(float x[], float c[]) |
{ |
float a[16]; /* ping pong buffers */ |
float b[16]; |
int p, pp, qq; |
/* special first stage for interleaved input */ |
a[0] = x[0]; |
a[8] = coef32[16] * x[0]; |
pp = 2; |
qq = 2 * 14; |
for (p = 1; p < 8; p++, pp += 2, qq -= 2) |
{ |
a[p] = x[pp] + x[qq]; |
a[8 + p] = coef32[16 + p] * (x[pp] - x[qq]); |
} |
forward_bf(2, 8, a, b, coef32 + 16 + 8); |
forward_bf(4, 4, b, a, coef32 + 16 + 8 + 4); |
forward_bf(8, 2, a, b, coef32 + 16 + 8 + 4 + 2); |
back_bf(4, 4, b, a); |
back_bf(2, 8, a, b); |
back_bf(1, 16, b, c); |
} |
/*------------------------------------------------------------*/ |
/*---------------- 16 pt fdct dual to mono-------------------*/ |
void fdct16_dual_mono(float x[], float c[]) |
{ |
float a[16]; /* ping pong buffers */ |
float b[16]; |
float t1, t2; |
int p, pp, qq; |
/* special first stage */ |
a[0] = 0.5F * (x[0] + x[1]); |
a[8] = coef32[16] * a[0]; |
pp = 2; |
qq = 2 * 14; |
for (p = 1; p < 8; p++, pp += 2, qq -= 2) |
{ |
t1 = 0.5F * (x[pp] + x[pp + 1]); |
t2 = 0.5F * (x[qq] + x[qq + 1]); |
a[p] = t1 + t2; |
a[8 + p] = coef32[16 + p] * (t1 - t2); |
} |
forward_bf(2, 8, a, b, coef32 + 16 + 8); |
forward_bf(4, 4, b, a, coef32 + 16 + 8 + 4); |
forward_bf(8, 2, a, b, coef32 + 16 + 8 + 4 + 2); |
back_bf(4, 4, b, a); |
back_bf(2, 8, a, b); |
back_bf(1, 16, b, c); |
} |
/*------------------------------------------------------------*/ |
/*---------------- 8 pt fdct -------------------------------*/ |
void fdct8(float x[], float c[]) |
{ |
float a[8]; /* ping pong buffers */ |
float b[8]; |
int p, q; |
/* special first stage */ |
b[0] = x[0] + x[7]; |
b[4] = coef32[16 + 8] * (x[0] - x[7]); |
for (p = 1, q = 6; p < 4; p++, q--) |
{ |
b[p] = x[p] + x[q]; |
b[4 + p] = coef32[16 + 8 + p] * (x[p] - x[q]); |
} |
forward_bf(2, 4, b, a, coef32 + 16 + 8 + 4); |
forward_bf(4, 2, a, b, coef32 + 16 + 8 + 4 + 2); |
back_bf(2, 4, b, a); |
back_bf(1, 8, a, c); |
} |
/*---------------- 8 pt fdct dual chan---------------------*/ |
void fdct8_dual(float x[], float c[]) |
{ |
float a[8]; /* ping pong buffers */ |
float b[8]; |
int p, pp, qq; |
/* special first stage for interleaved input */ |
b[0] = x[0] + x[14]; |
b[4] = coef32[16 + 8] * (x[0] - x[14]); |
pp = 2; |
qq = 2 * 6; |
for (p = 1; p < 4; p++, pp += 2, qq -= 2) |
{ |
b[p] = x[pp] + x[qq]; |
b[4 + p] = coef32[16 + 8 + p] * (x[pp] - x[qq]); |
} |
forward_bf(2, 4, b, a, coef32 + 16 + 8 + 4); |
forward_bf(4, 2, a, b, coef32 + 16 + 8 + 4 + 2); |
back_bf(2, 4, b, a); |
back_bf(1, 8, a, c); |
} |
/*---------------- 8 pt fdct dual to mono---------------------*/ |
void fdct8_dual_mono(float x[], float c[]) |
{ |
float a[8]; /* ping pong buffers */ |
float b[8]; |
float t1, t2; |
int p, pp, qq; |
/* special first stage */ |
t1 = 0.5F * (x[0] + x[1]); |
t2 = 0.5F * (x[14] + x[15]); |
b[0] = t1 + t2; |
b[4] = coef32[16 + 8] * (t1 - t2); |
pp = 2; |
qq = 2 * 6; |
for (p = 1; p < 4; p++, pp += 2, qq -= 2) |
{ |
t1 = 0.5F * (x[pp] + x[pp + 1]); |
t2 = 0.5F * (x[qq] + x[qq + 1]); |
b[p] = t1 + t2; |
b[4 + p] = coef32[16 + 8 + p] * (t1 - t2); |
} |
forward_bf(2, 4, b, a, coef32 + 16 + 8 + 4); |
forward_bf(4, 2, a, b, coef32 + 16 + 8 + 4 + 2); |
back_bf(2, 4, b, a); |
back_bf(1, 8, a, c); |
} |
/programs/media/ac97 mp3/trunk/mp3dec/imdct.c |
---|
0,0 → 1,222 |
#include <math.h> |
/*------ 18 point xform -------*/ |
static float w[18]; |
static float w2[9]; |
static float coef[9][4]; |
static float v[6]; |
static float v2[3]; |
static float coef87; |
/* |
typedef struct |
{ |
float *w; |
float *w2; |
void *coef; |
} |
IMDCT_INIT_BLOCK; |
static IMDCT_INIT_BLOCK imdct_info_18 = |
{w, w2, coef}; |
static IMDCT_INIT_BLOCK imdct_info_6 = |
{v, v2, &coef87}; |
*/ |
/*=============================================================*/ |
void imdct_init() |
{ |
int k, p, n; |
double t, pi; |
// IMDCT_INIT_BLOCK *addr; |
// float *w, *w2; |
// float *v, *v2, *coef87; |
/*--- 18 point --*/ |
// addr = imdct_init_addr_18(); |
// w = addr->w; |
// w2 = addr->w2; |
// coef = addr->coef; |
/*----*/ |
n = 18; |
pi = 4.0 * atan(1.0); |
t = pi / (4 * n); |
for (p = 0; p < n; p++) |
w[p] = (float) (2.0 * cos(t * (2 * p + 1))); |
for (p = 0; p < 9; p++) |
w2[p] = (float) (2.0 *cos(2 * t * (2 * p + 1))); |
t = pi / (2 * n); |
for (k = 0; k < 9; k++) |
{ |
for (p = 0; p < 4; p++) |
coef[k][p] = (float) (cos(t * (2 * k) * (2 * p + 1))); |
} |
/*--- 6 point */ |
// addr = imdct_init_addr_6(); |
// v = addr->w; |
// v2 = addr->w2; |
// coef87 = addr->coef; |
/*----*/ |
n = 6; |
pi = 4.0 * atan(1.0); |
t = pi / (4 * n); |
for (p = 0; p < n; p++) |
v[p] = (float) (2.0 *cos(t * (2 * p + 1))); |
for (p = 0; p < 3; p++) |
v2[p] = (float) (2.0 *cos(2 * t * (2 * p + 1))); |
t = pi / (2 * n); |
k = 1; |
p = 0; |
coef87 = (float) (cos(t * (2 * k) * (2 * p + 1))); |
/* adjust scaling to save a few mults */ |
for (p = 0; p < 6; p++) |
v[p] = v[p] / 2.0f; |
coef87 = (float) (2.0 * coef87); |
} |
/*--------------------------------------------------------------------*/ |
void imdct18(float f[18]) /* 18 point */ |
{ |
int p; |
float a[9], b[9]; |
float ap, bp, a8p, b8p; |
float g1, g2; |
for (p = 0; p < 4; p++) |
{ |
g1 = w[p] * f[p]; |
g2 = w[17 - p] * f[17 - p]; |
ap = g1 + g2; // a[p] |
bp = w2[p] * (g1 - g2); // b[p] |
g1 = w[8 - p] * f[8 - p]; |
g2 = w[9 + p] * f[9 + p]; |
a8p = g1 + g2; // a[8-p] |
b8p = w2[8 - p] * (g1 - g2); // b[8-p] |
a[p] = ap + a8p; |
a[5 + p] = ap - a8p; |
b[p] = bp + b8p; |
b[5 + p] = bp - b8p; |
} |
g1 = w[p] * f[p]; |
g2 = w[17 - p] * f[17 - p]; |
a[p] = g1 + g2; |
b[p] = w2[p] * (g1 - g2); |
f[0] = 0.5f * (a[0] + a[1] + a[2] + a[3] + a[4]); |
f[1] = 0.5f * (b[0] + b[1] + b[2] + b[3] + b[4]); |
f[2] = coef[1][0] * a[5] + coef[1][1] * a[6] + coef[1][2] * a[7] |
+ coef[1][3] * a[8]; |
f[3] = coef[1][0] * b[5] + coef[1][1] * b[6] + coef[1][2] * b[7] |
+ coef[1][3] * b[8] - f[1]; |
f[1] = f[1] - f[0]; |
f[2] = f[2] - f[1]; |
f[4] = coef[2][0] * a[0] + coef[2][1] * a[1] + coef[2][2] * a[2] |
+ coef[2][3] * a[3] - a[4]; |
f[5] = coef[2][0] * b[0] + coef[2][1] * b[1] + coef[2][2] * b[2] |
+ coef[2][3] * b[3] - b[4] - f[3]; |
f[3] = f[3] - f[2]; |
f[4] = f[4] - f[3]; |
f[6] = coef[3][0] * (a[5] - a[7] - a[8]); |
f[7] = coef[3][0] * (b[5] - b[7] - b[8]) - f[5]; |
f[5] = f[5] - f[4]; |
f[6] = f[6] - f[5]; |
f[8] = coef[4][0] * a[0] + coef[4][1] * a[1] + coef[4][2] * a[2] |
+ coef[4][3] * a[3] + a[4]; |
f[9] = coef[4][0] * b[0] + coef[4][1] * b[1] + coef[4][2] * b[2] |
+ coef[4][3] * b[3] + b[4] - f[7]; |
f[7] = f[7] - f[6]; |
f[8] = f[8] - f[7]; |
f[10] = coef[5][0] * a[5] + coef[5][1] * a[6] + coef[5][2] * a[7] |
+ coef[5][3] * a[8]; |
f[11] = coef[5][0] * b[5] + coef[5][1] * b[6] + coef[5][2] * b[7] |
+ coef[5][3] * b[8] - f[9]; |
f[9] = f[9] - f[8]; |
f[10] = f[10] - f[9]; |
f[12] = 0.5f * (a[0] + a[2] + a[3]) - a[1] - a[4]; |
f[13] = 0.5f * (b[0] + b[2] + b[3]) - b[1] - b[4] - f[11]; |
f[11] = f[11] - f[10]; |
f[12] = f[12] - f[11]; |
f[14] = coef[7][0] * a[5] + coef[7][1] * a[6] + coef[7][2] * a[7] |
+ coef[7][3] * a[8]; |
f[15] = coef[7][0] * b[5] + coef[7][1] * b[6] + coef[7][2] * b[7] |
+ coef[7][3] * b[8] - f[13]; |
f[13] = f[13] - f[12]; |
f[14] = f[14] - f[13]; |
f[16] = coef[8][0] * a[0] + coef[8][1] * a[1] + coef[8][2] * a[2] |
+ coef[8][3] * a[3] + a[4]; |
f[17] = coef[8][0] * b[0] + coef[8][1] * b[1] + coef[8][2] * b[2] |
+ coef[8][3] * b[3] + b[4] - f[15]; |
f[15] = f[15] - f[14]; |
f[16] = f[16] - f[15]; |
f[17] = f[17] - f[16]; |
} |
/*--------------------------------------------------------------------*/ |
/* does 3, 6 pt dct. changes order from f[i][window] c[window][i] */ |
void imdct6_3(float f[]) /* 6 point */ |
{ |
int w; |
float buf[18]; |
float *a, *c; // b[i] = a[3+i] |
float g1, g2; |
float a02, b02; |
c = f; |
a = buf; |
for (w = 0; w < 3; w++) |
{ |
g1 = v[0] * f[3 * 0]; |
g2 = v[5] * f[3 * 5]; |
a[0] = g1 + g2; |
a[3 + 0] = v2[0] * (g1 - g2); |
g1 = v[1] * f[3 * 1]; |
g2 = v[4] * f[3 * 4]; |
a[1] = g1 + g2; |
a[3 + 1] = v2[1] * (g1 - g2); |
g1 = v[2] * f[3 * 2]; |
g2 = v[3] * f[3 * 3]; |
a[2] = g1 + g2; |
a[3 + 2] = v2[2] * (g1 - g2); |
a += 6; |
f++; |
} |
a = buf; |
for (w = 0; w < 3; w++) |
{ |
a02 = (a[0] + a[2]); |
b02 = (a[3 + 0] + a[3 + 2]); |
c[0] = a02 + a[1]; |
c[1] = b02 + a[3 + 1]; |
c[2] = coef87 * (a[0] - a[2]); |
c[3] = coef87 * (a[3 + 0] - a[3 + 2]) - c[1]; |
c[1] = c[1] - c[0]; |
c[2] = c[2] - c[1]; |
c[4] = a02 - a[1] - a[1]; |
c[5] = b02 - a[3 + 1] - a[3 + 1] - c[3]; |
c[3] = c[3] - c[2]; |
c[4] = c[4] - c[3]; |
c[5] = c[5] - c[4]; |
a += 6; |
c += 6; |
} |
} |
/programs/media/ac97 mp3/trunk/mp3dec/l1dec.c |
---|
0,0 → 1,202 |
#include "bstream.h" |
#include "mp3dec.h" |
extern MPEG_DECODE_OPTION m_option; |
extern float m_sample[2304]; |
extern int m_nsb_limit; |
extern SBT_PROC m_sbt_proc; |
extern int m_max_sb; |
extern int m_stereo_sb; |
extern int m_bat[4][16]; |
extern int m_ballo[64]; |
extern unsigned int m_samp_dispatch[66]; |
extern float m_c_value[64]; |
extern unsigned int m_sf_dispatch[66]; |
extern float m_sf_table[64]; |
extern float m_cs_factor[3][64]; |
float m_look_c_valueL1[18]; |
float *m_cs_factorL1 = m_cs_factor[0]; |
int m_nbatL1; |
int m_bit_skip; |
static const int look_joint[16] = |
{ /* lookup stereo sb's by mode+ext */ |
64, 64, 64, 64, /* stereo */ |
2 * 4, 2 * 8, 2 * 12, 2 * 16, /* joint */ |
64, 64, 64, 64, /* dual */ |
32, 32, 32, 32, /* mono */ |
}; |
static const int bat_bit_masterL1[] = |
{ |
0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 |
}; |
void unpack_baL1(); |
void unpack_sfL1(); |
void unpack_sampL1(); |
void L1decode_frame(MPEG_HEADER* h, byte* mpeg, byte* pcm) |
{ |
int crc_size; |
crc_size = (h->error_prot) ? 2 : 0; |
bitget_init(mpeg + 4 + crc_size); |
m_stereo_sb = look_joint[(h->mode << 2) + h->mode_ext]; |
unpack_baL1(); /* unpack bit allocation */ |
unpack_sfL1(); /* unpack scale factor */ |
unpack_sampL1(); /* unpack samples */ |
m_sbt_proc(m_sample, pcm, 12); |
} |
void unpack_baL1() |
{ |
int j; |
int nstereo; |
m_bit_skip = 0; |
nstereo = m_stereo_sb; |
for (j = 0; j < m_nbatL1; j++) |
{ |
bitget_check(4); |
m_ballo[j] = m_samp_dispatch[j] = mac_bitget(4); |
if (j >= m_nsb_limit) |
m_bit_skip += bat_bit_masterL1[m_samp_dispatch[j]]; |
m_c_value[j] = m_look_c_valueL1[m_samp_dispatch[j]]; |
if (--nstereo < 0) |
{ |
m_ballo[j + 1] = m_ballo[j]; |
// flag as joint |
m_samp_dispatch[j] += 15; |
// flag for sf |
m_samp_dispatch[j + 1] = m_samp_dispatch[j]; |
m_c_value[j + 1] = m_c_value[j]; |
j++; |
} |
} |
// terminate with bit skip and end |
m_samp_dispatch[m_nsb_limit] = 31; |
m_samp_dispatch[j] = 30; |
} |
// unpack scale factor |
// combine dequant and scale factors |
void unpack_sfL1() |
{ |
int i; |
for (i = 0; i < m_nbatL1; i++) |
{ |
if (m_ballo[i]) |
{ |
bitget_check(6); |
m_cs_factorL1[i] = m_c_value[i] * m_sf_table[mac_bitget(6)]; |
} |
} |
} |
// unpack samples |
#define UNPACKL1_N(n) \ |
s[k] = m_cs_factorL1[k]*(bitget(n)-((1 << n-1) -1)); \ |
goto dispatch; |
#define UNPACKL1J_N(n) \ |
tmp = (bitget(n)-((1 << n-1) -1)); \ |
s[k] = m_cs_factorL1[k]*tmp; \ |
s[k+1] = m_cs_factorL1[k+1]*tmp; \ |
k++; \ |
goto dispatch; |
void unpack_sampL1() |
{ |
int j, k; |
float *s; |
long tmp; |
s = m_sample; |
for (j = 0; j < 12; j++) |
{ |
k = -1; |
dispatch: |
switch (m_samp_dispatch[++k]) |
{ |
case 0: |
s[k] = 0.0F; |
goto dispatch; |
case 1: |
UNPACKL1_N(2) /* 3 levels */ |
case 2: |
UNPACKL1_N(3) /* 7 levels */ |
case 3: |
UNPACKL1_N(4) /* 15 levels */ |
case 4: |
UNPACKL1_N(5) /* 31 levels */ |
case 5: |
UNPACKL1_N(6) /* 63 levels */ |
case 6: |
UNPACKL1_N(7) /* 127 levels */ |
case 7: |
UNPACKL1_N(8) /* 255 levels */ |
case 8: |
UNPACKL1_N(9) /* 511 levels */ |
case 9: |
UNPACKL1_N(10) /* 1023 levels */ |
case 10: |
UNPACKL1_N(11) /* 2047 levels */ |
case 11: |
UNPACKL1_N(12) /* 4095 levels */ |
case 12: |
UNPACKL1_N(13) /* 8191 levels */ |
case 13: |
UNPACKL1_N(14) /* 16383 levels */ |
case 14: |
UNPACKL1_N(15) /* 32767 levels */ |
/* -- joint ---- */ |
case 15 + 0: |
s[k + 1] = s[k] = 0.0F; |
k++; /* skip right chan dispatch */ |
goto dispatch; |
/* -- joint ---- */ |
case 15 + 1: |
UNPACKL1J_N(2) /* 3 levels */ |
case 15 + 2: |
UNPACKL1J_N(3) /* 7 levels */ |
case 15 + 3: |
UNPACKL1J_N(4) /* 15 levels */ |
case 15 + 4: |
UNPACKL1J_N(5) /* 31 levels */ |
case 15 + 5: |
UNPACKL1J_N(6) /* 63 levels */ |
case 15 + 6: |
UNPACKL1J_N(7) /* 127 levels */ |
case 15 + 7: |
UNPACKL1J_N(8) /* 255 levels */ |
case 15 + 8: |
UNPACKL1J_N(9) /* 511 levels */ |
case 15 + 9: |
UNPACKL1J_N(10) /* 1023 levels */ |
case 15 + 10: |
UNPACKL1J_N(11) /* 2047 levels */ |
case 15 + 11: |
UNPACKL1J_N(12) /* 4095 levels */ |
case 15 + 12: |
UNPACKL1J_N(13) /* 8191 levels */ |
case 15 + 13: |
UNPACKL1J_N(14) /* 16383 levels */ |
case 15 + 14: |
UNPACKL1J_N(15) /* 32767 levels */ |
/* -- end of dispatch -- */ |
case 31: |
bitget_skip(m_bit_skip); |
case 30: |
s += 64; |
} /* end switch */ |
} /* end j loop */ |
} |
/programs/media/ac97 mp3/trunk/mp3dec/l1init.c |
---|
0,0 → 1,87 |
#include "bstream.h" |
#include "mp3dec.h" |
#include <math.h> |
extern MPEG_DECODE_OPTION m_option; |
extern int m_frequency; |
extern float m_sample[2304]; |
extern int m_nsb_limit; |
extern int m_max_sb; |
extern int m_stereo_sb; |
extern SBT_PROC m_sbt_proc; |
extern float m_look_c_valueL1[18]; |
extern int m_nbatL1; |
//extern "sbt.c" |
void sbt_mono(float *sample, signed short *pcm, int ch); |
void sbt_dual(float *sample, signed short *pcm, int ch); |
void sbt16_mono(float *sample, signed short *pcm, int ch); |
void sbt16_dual(float *sample, signed short *pcm, int ch); |
void sbt8_mono(float *sample, signed short *pcm, int ch); |
void sbt8_dual(float *sample, signed short *pcm, int ch); |
void sbtB_mono(float *sample, unsigned char *pcm, int ch); |
void sbtB_dual(float *sample, unsigned char *pcm, int ch); |
void sbtB16_mono(float *sample, unsigned char *pcm, int ch); |
void sbtB16_dual(float *sample, unsigned char *pcm, int ch); |
void sbtB8_mono(float *sample, unsigned char *pcm, int ch); |
void sbtB8_dual(float *sample, unsigned char *pcm, int ch); |
static const SBT_PROC sbt_table[2][3][2] = |
{ |
sbt_mono, |
sbt_dual, |
sbt16_mono, |
sbt16_dual, |
sbt8_mono, |
sbt8_dual, |
sbtB_mono, |
sbtB_dual, |
sbtB16_mono, |
sbtB16_dual, |
sbtB8_mono, |
sbtB8_dual, |
}; |
void L1table_init() |
{ |
int i, stepL1; |
for (stepL1 = 4, i = 1; i < 16; i++, stepL1 <<= 1) { |
m_look_c_valueL1[i] = (float) (2.0 / (stepL1 - 1)); |
} |
} |
int L1decode_start(MPEG_HEADER* h) |
{ |
int i, k, bit_code, limit; |
/*- caller limit -*/ |
m_nbatL1 = 32; |
m_max_sb = m_nbatL1; |
m_nsb_limit = (m_option.freqLimit * 64L + m_frequency / 2) / m_frequency; |
/*---- limit = 0.94*(32>>reduction_code); ----*/ |
limit = (32 >> m_option.reduction); |
if (limit > 8) |
limit--; |
if (m_nsb_limit > limit) |
m_nsb_limit = limit; |
if (m_nsb_limit > m_max_sb) |
m_nsb_limit = m_max_sb; |
if (h->mode != 3) { /* adjust for 2 channel modes */ |
m_nbatL1 *= 2; |
m_max_sb *= 2; |
m_nsb_limit *= 2; |
} |
/* set sbt function */ |
bit_code = (m_option.convert & 8) ? 1 : 0; |
k = (h->mode == 3) ? 0 : (1 + m_option.convert); |
m_sbt_proc = sbt_table[bit_code][m_option.reduction][k];//[2][3][2] |
for (i = 0; i < 768; i++) |
m_sample[i] = 0.0F; |
return 1; |
} |
/programs/media/ac97 mp3/trunk/mp3dec/l2dec.c |
---|
0,0 → 1,306 |
#include "bstream.h" |
#include "mp3dec.h" |
extern float m_sample[2304]; |
extern int m_nsb_limit; |
int m_stereo_sb; |
int m_max_sb; |
SBT_PROC m_sbt_proc; |
float m_sf_table[64]; |
float m_look_c_valueL2[18]; |
char m_group3_table[32][3]; |
char m_group5_table[128][3]; |
short m_group9_table[1024][3]; |
int m_nbat[4];// = {3, 8, 12, 7}; |
int m_bat[4][16]; |
int m_ballo[64]; |
uint m_samp_dispatch[66]; |
float m_c_value[64]; |
uint m_sf_dispatch[66]; |
float m_cs_factor[3][64]; |
int m_bit_skip; |
static const int look_joint[16] = |
{ /* lookup stereo sb's by mode+ext */ |
64, 64, 64, 64, /* stereo */ |
2 * 4, 2 * 8, 2 * 12, 2 * 16, /* joint */ |
64, 64, 64, 64, /* dual */ |
32, 32, 32, 32, /* mono */ |
}; |
static const int bat_bit_masterL2[] = |
{ |
0, 5, 7, 9, 10, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48 |
}; |
void unpack_ba(); |
void unpack_sfs(); |
void unpack_sf(); |
void unpack_samp(); |
void L2decode_frame(MPEG_HEADER* h, byte* mpeg, byte* pcm) |
{ |
int crc_size; |
crc_size = (h->error_prot) ? 2 : 0; |
bitget_init(mpeg + 4 + crc_size); |
m_stereo_sb = look_joint[(h->mode << 2) + h->mode_ext]; |
unpack_ba(); // unpack bit allocation |
unpack_sfs(); // unpack scale factor selectors |
unpack_sf(); // unpack scale factor |
unpack_samp(); // unpack samples |
m_sbt_proc(m_sample, pcm, 36); |
} |
void unpack_ba() |
{ |
int i, j, k; |
int nstereo; |
int nbit[4] = {4, 4, 3, 2}; |
m_bit_skip = 0; |
nstereo = m_stereo_sb; |
k = 0; |
for (i = 0; i < 4; i++) { |
for (j = 0; j < m_nbat[i]; j++, k++) { |
bitget_check(4); |
m_ballo[k] = m_samp_dispatch[k] = m_bat[i][mac_bitget(nbit[i])]; |
if (k >= m_nsb_limit) |
m_bit_skip += bat_bit_masterL2[m_samp_dispatch[k]]; |
m_c_value[k] = m_look_c_valueL2[m_samp_dispatch[k]]; |
if (--nstereo < 0) { |
m_ballo[k + 1] = m_ballo[k]; |
m_samp_dispatch[k] += 18; /* flag as joint */ |
m_samp_dispatch[k + 1] = m_samp_dispatch[k]; /* flag for sf */ |
m_c_value[k + 1] = m_c_value[k]; |
k++; |
j++; |
} |
} |
} |
m_samp_dispatch[m_nsb_limit] = 37; /* terminate the dispatcher with skip */ |
m_samp_dispatch[k] = 36; /* terminate the dispatcher */ |
} |
void unpack_sfs() /* unpack scale factor selectors */ |
{ |
int i; |
for (i = 0; i < m_max_sb; i++) { |
bitget_check(2); |
if (m_ballo[i]) |
m_sf_dispatch[i] = mac_bitget(2); |
else |
m_sf_dispatch[i] = 4; /* no allo */ |
} |
m_sf_dispatch[i] = 5; /* terminate dispatcher */ |
} |
void unpack_sf() /* unpack scale factor */ |
{ /* combine dequant and scale factors */ |
int i; |
i = -1; |
dispatch:switch (m_sf_dispatch[++i]) |
{ |
case 0: /* 3 factors 012 */ |
bitget_check(18); |
m_cs_factor[0][i] = m_c_value[i] * m_sf_table[mac_bitget(6)]; |
m_cs_factor[1][i] = m_c_value[i] * m_sf_table[mac_bitget(6)]; |
m_cs_factor[2][i] = m_c_value[i] * m_sf_table[mac_bitget(6)]; |
goto dispatch; |
case 1: /* 2 factors 002 */ |
bitget_check(12); |
m_cs_factor[1][i] = m_cs_factor[0][i] = m_c_value[i] * m_sf_table[mac_bitget(6)]; |
m_cs_factor[2][i] = m_c_value[i] * m_sf_table[mac_bitget(6)]; |
goto dispatch; |
case 2: /* 1 factor 000 */ |
bitget_check(6); |
m_cs_factor[2][i] = m_cs_factor[1][i] = m_cs_factor[0][i] = |
m_c_value[i] * m_sf_table[mac_bitget(6)]; |
goto dispatch; |
case 3: /* 2 factors 022 */ |
bitget_check(12); |
m_cs_factor[0][i] = m_c_value[i] * m_sf_table[mac_bitget(6)]; |
m_cs_factor[2][i] = m_cs_factor[1][i] = m_c_value[i] * m_sf_table[mac_bitget(6)]; |
goto dispatch; |
case 4: /* no allo */ |
/*-- m_cs_factor[2][i] = m_cs_factor[1][i] = m_cs_factor[0][i] = 0.0; --*/ |
goto dispatch; |
case 5: /* all done */ |
; |
} /* end switch */ |
} |
/*-------------------------------------------------------------------------*/ |
#define UNPACK_N(n) s[k] = m_cs_factor[i][k]*(bitget(n)-((1 << n-1) -1)); \ |
s[k+64] = m_cs_factor[i][k]*(bitget(n)-((1 << n-1) -1)); \ |
s[k+128] = m_cs_factor[i][k]*(bitget(n)-((1 << n-1) -1)); \ |
goto dispatch; |
#define UNPACK_N2(n) bitget_check(3*n); \ |
s[k] = m_cs_factor[i][k]*(mac_bitget(n)-((1 << n-1) -1)); \ |
s[k+64] = m_cs_factor[i][k]*(mac_bitget(n)-((1 << n-1) -1)); \ |
s[k+128] = m_cs_factor[i][k]*(mac_bitget(n)-((1 << n-1) -1)); \ |
goto dispatch; |
#define UNPACK_N3(n) bitget_check(2*n); \ |
s[k] = m_cs_factor[i][k]*(mac_bitget(n)-((1 << n-1) -1)); \ |
s[k+64] = m_cs_factor[i][k]*(mac_bitget(n)-((1 << n-1) -1)); \ |
bitget_check(n); \ |
s[k+128] = m_cs_factor[i][k]*(mac_bitget(n)-((1 << n-1) -1)); \ |
goto dispatch; |
#define UNPACKJ_N(n) tmp = (bitget(n)-((1 << n-1) -1)); \ |
s[k] = m_cs_factor[i][k]*tmp; \ |
s[k+1] = m_cs_factor[i][k+1]*tmp; \ |
tmp = (bitget(n)-((1 << n-1) -1)); \ |
s[k+64] = m_cs_factor[i][k]*tmp; \ |
s[k+64+1] = m_cs_factor[i][k+1]*tmp; \ |
tmp = (bitget(n)-((1 << n-1) -1)); \ |
s[k+128] = m_cs_factor[i][k]*tmp; \ |
s[k+128+1] = m_cs_factor[i][k+1]*tmp; \ |
k++; /* skip right chan dispatch */ \ |
goto dispatch; |
/*-------------------------------------------------------------------------*/ |
void unpack_samp() /* unpack samples */ |
{ |
int i, j, k; |
float *s; |
int n; |
long tmp; |
s = m_sample; |
for (i = 0; i < 3; i++) |
{ /* 3 groups of scale factors */ |
for (j = 0; j < 4; j++) |
{ |
k = -1; |
dispatch:switch (m_samp_dispatch[++k]) |
{ |
case 0: |
s[k + 128] = s[k + 64] = s[k] = 0.0F; |
goto dispatch; |
case 1: /* 3 levels grouped 5 bits */ |
bitget_check(5); |
n = mac_bitget(5); |
s[k] = m_cs_factor[i][k] * m_group3_table[n][0]; |
s[k + 64] = m_cs_factor[i][k] * m_group3_table[n][1]; |
s[k + 128] = m_cs_factor[i][k] * m_group3_table[n][2]; |
goto dispatch; |
case 2: /* 5 levels grouped 7 bits */ |
bitget_check(7); |
n = mac_bitget(7); |
s[k] = m_cs_factor[i][k] * m_group5_table[n][0]; |
s[k + 64] = m_cs_factor[i][k] * m_group5_table[n][1]; |
s[k + 128] = m_cs_factor[i][k] * m_group5_table[n][2]; |
goto dispatch; |
case 3: |
UNPACK_N2(3) /* 7 levels */ |
case 4: /* 9 levels grouped 10 bits */ |
bitget_check(10); |
n = mac_bitget(10); |
s[k] = m_cs_factor[i][k] * m_group9_table[n][0]; |
s[k + 64] = m_cs_factor[i][k] * m_group9_table[n][1]; |
s[k + 128] = m_cs_factor[i][k] * m_group9_table[n][2]; |
goto dispatch; |
case 5: |
UNPACK_N2(4) /* 15 levels */ |
case 6: |
UNPACK_N2(5) /* 31 levels */ |
case 7: |
UNPACK_N2(6) /* 63 levels */ |
case 8: |
UNPACK_N2(7) /* 127 levels */ |
case 9: |
UNPACK_N2(8) /* 255 levels */ |
case 10: |
UNPACK_N3(9) /* 511 levels */ |
case 11: |
UNPACK_N3(10) /* 1023 levels */ |
case 12: |
UNPACK_N3(11) /* 2047 levels */ |
case 13: |
UNPACK_N3(12) /* 4095 levels */ |
case 14: |
UNPACK_N(13) /* 8191 levels */ |
case 15: |
UNPACK_N(14) /* 16383 levels */ |
case 16: |
UNPACK_N(15) /* 32767 levels */ |
case 17: |
UNPACK_N(16) /* 65535 levels */ |
/* -- joint ---- */ |
case 18 + 0: |
s[k + 128 + 1] = s[k + 128] = s[k + 64 + 1] = s[k + 64] = s[k + 1] = s[k] = 0.0F; |
k++; /* skip right chan dispatch */ |
goto dispatch; |
case 18 + 1: /* 3 levels grouped 5 bits */ |
n = bitget(5); |
s[k] = m_cs_factor[i][k] * m_group3_table[n][0]; |
s[k + 1] = m_cs_factor[i][k + 1] * m_group3_table[n][0]; |
s[k + 64] = m_cs_factor[i][k] * m_group3_table[n][1]; |
s[k + 64 + 1] = m_cs_factor[i][k + 1] * m_group3_table[n][1]; |
s[k + 128] = m_cs_factor[i][k] * m_group3_table[n][2]; |
s[k + 128 + 1] = m_cs_factor[i][k + 1] * m_group3_table[n][2]; |
k++; /* skip right chan dispatch */ |
goto dispatch; |
case 18 + 2: /* 5 levels grouped 7 bits */ |
n = bitget(7); |
s[k] = m_cs_factor[i][k] * m_group5_table[n][0]; |
s[k + 1] = m_cs_factor[i][k + 1] * m_group5_table[n][0]; |
s[k + 64] = m_cs_factor[i][k] * m_group5_table[n][1]; |
s[k + 64 + 1] = m_cs_factor[i][k + 1] * m_group5_table[n][1]; |
s[k + 128] = m_cs_factor[i][k] * m_group5_table[n][2]; |
s[k + 128 + 1] = m_cs_factor[i][k + 1] * m_group5_table[n][2]; |
k++; /* skip right chan dispatch */ |
goto dispatch; |
case 18 + 3: |
UNPACKJ_N(3) /* 7 levels */ |
case 18 + 4: /* 9 levels grouped 10 bits */ |
n = bitget(10); |
s[k] = m_cs_factor[i][k] * m_group9_table[n][0]; |
s[k + 1] = m_cs_factor[i][k + 1] * m_group9_table[n][0]; |
s[k + 64] = m_cs_factor[i][k] * m_group9_table[n][1]; |
s[k + 64 + 1] = m_cs_factor[i][k + 1] * m_group9_table[n][1]; |
s[k + 128] = m_cs_factor[i][k] * m_group9_table[n][2]; |
s[k + 128 + 1] = m_cs_factor[i][k + 1] * m_group9_table[n][2]; |
k++; /* skip right chan dispatch */ |
goto dispatch; |
case 18 + 5: |
UNPACKJ_N(4) /* 15 levels */ |
case 18 + 6: |
UNPACKJ_N(5) /* 31 levels */ |
case 18 + 7: |
UNPACKJ_N(6) /* 63 levels */ |
case 18 + 8: |
UNPACKJ_N(7) /* 127 levels */ |
case 18 + 9: |
UNPACKJ_N(8) /* 255 levels */ |
case 18 + 10: |
UNPACKJ_N(9) /* 511 levels */ |
case 18 + 11: |
UNPACKJ_N(10) /* 1023 levels */ |
case 18 + 12: |
UNPACKJ_N(11) /* 2047 levels */ |
case 18 + 13: |
UNPACKJ_N(12) /* 4095 levels */ |
case 18 + 14: |
UNPACKJ_N(13) /* 8191 levels */ |
case 18 + 15: |
UNPACKJ_N(14) /* 16383 levels */ |
case 18 + 16: |
UNPACKJ_N(15) /* 32767 levels */ |
case 18 + 17: |
UNPACKJ_N(16) /* 65535 levels */ |
/* -- end of dispatch -- */ |
case 37: |
bitget_skip(m_bit_skip); |
case 36: |
s += 3 * 64; |
} /* end switch */ |
} /* end j loop */ |
} /* end i loop */ |
} |
/programs/media/ac97 mp3/trunk/mp3dec/l2init.c |
---|
0,0 → 1,205 |
#include "bstream.h" |
#include "mp3dec.h" |
#include <math.h> |
extern MPEG_DECODE_OPTION m_option; |
extern int m_frequency; |
extern float m_sample[2304]; |
extern int m_nsb_limit; |
extern int m_max_sb; |
extern SBT_PROC m_sbt_proc; |
extern float m_sf_table[64]; |
extern float m_look_c_valueL2[18]; |
extern char m_group3_table[32][3]; |
extern char m_group5_table[128][3]; |
extern short m_group9_table[1024][3]; |
extern int m_nbat[4];// = {3, 8, 12, 7}; |
extern int m_bat[4][16]; |
/* ABCD_INDEX = lookqt[mode][sr_index][br_index] */ |
/* -1 = invalid */ |
static const char lookqt[4][3][16] = |
{ |
1, -1, -1, -1, 2, -1, 2, 0, 0, 0, 1, 1, 1, 1, 1, -1, /* 44ks stereo */ |
0, -1, -1, -1, 2, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, -1, /* 48ks */ |
1, -1, -1, -1, 3, -1, 3, 0, 0, 0, 1, 1, 1, 1, 1, -1, /* 32ks */ |
1, -1, -1, -1, 2, -1, 2, 0, 0, 0, 1, 1, 1, 1, 1, -1, /* 44ks joint stereo */ |
0, -1, -1, -1, 2, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, -1, /* 48ks */ |
1, -1, -1, -1, 3, -1, 3, 0, 0, 0, 1, 1, 1, 1, 1, -1, /* 32ks */ |
1, -1, -1, -1, 2, -1, 2, 0, 0, 0, 1, 1, 1, 1, 1, -1, /* 44ks dual chan */ |
0, -1, -1, -1, 2, -1, 2, 0, 0, 0, 0, 0, 0, 0, 0, -1, /* 48ks */ |
1, -1, -1, -1, 3, -1, 3, 0, 0, 0, 1, 1, 1, 1, 1, -1, /* 32ks */ |
// mono extended beyond legal br index |
// 1,2,2,0,0,0,1,1,1,1,1,1,1,1,1,-1, /* 44ks single chan */ |
// 0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,-1, /* 48ks */ |
// 1,3,3,0,0,0,1,1,1,1,1,1,1,1,1,-1, /* 32ks */ |
// legal mono |
1, 2, 2, 0, 0, 0, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, /* 44ks single chan */ |
0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, /* 48ks */ |
1, 3, 3, 0, 0, 0, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, /* 32ks */ |
}; |
/* bit allocation table look up */ |
/* table per mpeg spec tables 3b2a/b/c/d /e is mpeg2 */ |
/* look_bat[abcd_index][4][16] */ |
static const unsigned char look_bat[5][4][16] = |
{ |
/* LOOK_BATA */ |
0, 1, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, |
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, |
0, 1, 2, 3, 4, 5, 6, 17, 0, 0, 0, 0, 0, 0, 0, 0, |
0, 1, 2, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
/* LOOK_BATB */ |
0, 1, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, |
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, |
0, 1, 2, 3, 4, 5, 6, 17, 0, 0, 0, 0, 0, 0, 0, 0, |
0, 1, 2, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
/* LOOK_BATC */ |
0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
0, 1, 2, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
/* LOOK_BATD */ |
0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
0, 1, 2, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
/* LOOK_BATE */ |
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
0, 1, 2, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, |
0, 1, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
}; |
/* look_nbat[abcd_index]][4] */ |
static const unsigned char look_nbat[5][4] = |
{ |
3, 8, 12, 4, |
3, 8, 12, 7, |
2, 0, 6, 0, |
2, 0, 10, 0, |
4, 0, 7, 19, |
}; |
//extern "sbt.c" |
void sbt_mono(float *sample, signed short *pcm, int ch); |
void sbt_dual(float *sample, signed short *pcm, int ch); |
void sbt16_mono(float *sample, signed short *pcm, int ch); |
void sbt16_dual(float *sample, signed short *pcm, int ch); |
void sbt8_mono(float *sample, signed short *pcm, int ch); |
void sbt8_dual(float *sample, signed short *pcm, int ch); |
void sbtB_mono(float *sample, unsigned char *pcm, int ch); |
void sbtB_dual(float *sample, unsigned char *pcm, int ch); |
void sbtB16_mono(float *sample, unsigned char *pcm, int ch); |
void sbtB16_dual(float *sample, unsigned char *pcm, int ch); |
void sbtB8_mono(float *sample, unsigned char *pcm, int ch); |
void sbtB8_dual(float *sample, unsigned char *pcm, int ch); |
static const SBT_PROC sbt_table[2][3][2] = |
{ |
sbt_mono, |
sbt_dual, |
sbt16_mono, |
sbt16_dual, |
sbt8_mono, |
sbt8_dual, |
sbtB_mono, |
sbtB_dual, |
sbtB16_mono, |
sbtB16_dual, |
sbtB8_mono, |
sbtB8_dual, |
}; |
void L2table_init() |
{ |
int i, j, code; |
long stepL2[18] = { |
0, 3, 5, 7, 9, 15, 31, 63, 127, |
255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535 |
}; |
//c_values (dequant) |
for (i = 1; i < 18; i++) { |
m_look_c_valueL2[i] = 2.0F / stepL2[i]; |
} |
//scale factor table, scale by 32768 for 16 pcm output |
for (i = 0; i < 64; i++) { |
m_sf_table[i] = (float) (32768.0 * 2.0 * pow_test(2.0, -i / 3.0)); |
} |
//grouped 3 level lookup table 5 bit token |
for (i = 0; i < 32; i++) { |
code = i; |
for (j = 0; j < 3; j++) { |
m_group3_table[i][j] = (char) ((code % 3) - 1); |
code /= 3; |
} |
} |
//grouped 5 level lookup table 7 bit token |
for (i = 0; i < 128; i++) { |
code = i; |
for (j = 0; j < 3; j++) { |
m_group5_table[i][j] = (char) ((code % 5) - 2); |
code /= 5; |
} |
} |
//grouped 9 level lookup table 10 bit token |
for (i = 0; i < 1024; i++) { |
code = i; |
for (j = 0; j < 3; j++) { |
m_group9_table[i][j] = (short) ((code % 9) - 4); |
code /= 9; |
} |
} |
} |
int L2decode_start(MPEG_HEADER* h) |
{ |
int i, j, k, bit_code, limit; |
int abcd_index; |
// compute abcd index for bit allo table selection |
if (h->version == 1) // MPEG-1 |
abcd_index = lookqt[h->mode][h->fr_index][h->br_index]; |
else |
abcd_index = 4; // MPEG-2, MPEG-2.5 |
if (abcd_index < 0) |
return 0; // fail invalid Layer II bit rate index |
for (i = 0; i < 4; i++) { |
m_nbat[i] = look_nbat[abcd_index][i]; |
for (j = 0; j < 16; j++) { |
m_bat[i][j] = look_bat[abcd_index][i][j]; |
} |
} |
m_max_sb = m_nbat[0] + m_nbat[1] + m_nbat[2] + m_nbat[3]; |
// compute nsb_limit |
m_nsb_limit = (m_option.freqLimit * 64L + m_frequency / 2) / m_frequency; |
// caller limit |
// limit = 0.94*(32>>reduction_code); |
limit = (32 >> m_option.reduction); |
if (limit > 8) |
limit--; |
if (m_nsb_limit > limit) |
m_nsb_limit = limit; |
if (m_nsb_limit > m_max_sb) |
m_nsb_limit = m_max_sb; |
if (h->mode != 3) { |
// adjust for 2 channel modes |
for (i = 0; i < 4; i++) |
m_nbat[i] *= 2; |
m_max_sb *= 2; |
m_nsb_limit *= 2; |
} |
// set sbt function |
bit_code = (m_option.convert & 8) ? 1 : 0; |
k = (h->mode == 3) ? 0 : (1 + m_option.convert); |
m_sbt_proc = sbt_table[bit_code][m_option.reduction][k];//[2][3][2] |
// clear sample buffer, unused sub bands must be 0 |
for (i = 0; i < 2304; i++) |
m_sample[i] = 0.0F; |
return 1; |
} |
/programs/media/ac97 mp3/trunk/mp3dec/l3alias.c |
---|
0,0 → 1,38 |
#include <math.h> //sqrt |
static float csa[8][2]; /* antialias */ |
void alias_init() |
{ |
float Ci[8] = |
{ |
-0.6f, -0.535f, -0.33f, -0.185f, -0.095f, -0.041f, -0.0142f, -0.0037f |
}; |
int i; |
for (i = 0; i < 8; i++) |
{ |
csa[i][0] = (float) (1.0 / sqrt(1.0 + Ci[i] * Ci[i])); |
csa[i][1] = (float) (Ci[i] / sqrt(1.0 + Ci[i] * Ci[i])); |
} |
} |
void antialias(float x[], int n) |
{ |
int i, k; |
float a, b; |
for (k = 0; k < n; k++) |
{ |
for (i = 0; i < 8; i++) |
{ |
a = x[17 - i]; |
b = x[18 + i]; |
x[17 - i] = a * csa[i][0] - b * csa[i][1]; |
x[18 + i] = b * csa[i][0] + a * csa[i][1]; |
} |
x += 18; |
} |
} |
/programs/media/ac97 mp3/trunk/mp3dec/l3dec.c |
---|
0,0 → 1,350 |
#include "layer3.h" |
#include <string.h> |
#include <math.h> |
#ifndef min |
#define max(a,b) (((a) > (b)) ? (a) : (b)) |
#define min(a,b) (((a) < (b)) ? (a) : (b)) |
#endif |
extern int m_frame_size, m_pcm_size; |
// shared |
SAMPLE m_sample[2][2][576];//- sample union of int/float sample[ch][gr][576] |
int m_nsb_limit; |
SBT_PROC m_sbt_proc; |
XFORM_PROC m_xform_proc; |
int m_channels; //(mode == 3) ? 1 : 2 |
int m_ms_mode, m_is_mode; |
int m_sfBandIndex[2][22];// [long/short][cb] |
int m_nBand[2][22]; |
int m_band_limit; |
int m_band_limit21; // limit for sf band 21 |
int m_band_limit12; // limit for sf band 12 short |
int m_band_limit_nsb; |
int m_ncbl_mixed; |
SIDE_INFO m_side_info; |
SCALE_FACTOR m_scale_fac[2][2]; // [gr][ch] |
CB_INFO m_cb_info[2][2]; // [gr][ch] |
IS_SF_INFO m_is_sf_info; |
#define NBUF (8*1024) |
#define BUF_TRIGGER (NBUF-1500) |
int m_gr; |
int m_main_pos_bit; |
byte m_buf[NBUF]; |
int m_buf_ptr0, m_buf_ptr1; |
int m_nsamp[2][2]; // must start = 0, for m_nsamp[igr_prev] |
float m_yout[576]; // hybrid out, sbt in |
//extern "l3side.c" |
int L3get_side_info1(); |
int L3get_side_info2(int gr); |
//extern "l3sf.c" |
void L3get_scale_factor1(int gr, int ch); |
void L3get_scale_factor2(int gr, int ch); |
void huffman(void *xy, int n, int ntable); |
int huffman_quad(void *vwxy, int n, int nbits, int ntable); |
void dequant(SAMPLE sample[], int gr, int ch); |
void antialias(void *x, int n); |
void ms_process(void *x, int n); |
void is_process1(void *x, SCALE_FACTOR* sf, |
CB_INFO cb_info[2], int nsamp); |
void is_process2(void *x, SCALE_FACTOR * sf, |
CB_INFO cb_info[2], int nsamp); |
//extern "l3hybrid.c" |
int hybrid(void *xin, void *xprev, float *y, |
int btype, int nlong, int ntot, int nprev); |
int hybrid_sum(void *xin, void *xin_left, float *y, |
int btype, int nlong, int ntot); |
void sum_f_bands(void *a, void *b, int n); |
void freq_invert(float *y, int n); /* xform, */ |
void L3decode_main(MPEG_HEADER* h, byte *pcm, int gr); |
void L3decode_reset() |
{ |
m_buf_ptr0 = m_buf_ptr1 = 0; |
} |
void L3decode_frame(MPEG_HEADER* h, byte* mpeg, byte* pcm) |
{ |
int crc_size, side_size; |
int copy_size; |
if (h->mode == 1) { |
m_ms_mode = h->mode_ext >> 1; |
m_is_mode = h->mode_ext & 1; |
} |
else { |
m_ms_mode = 0; |
m_is_mode = 0; |
} |
crc_size = (h->error_prot) ? 2 : 0; |
bitget_init(mpeg + 4 + crc_size); |
if (h->version == 1) |
side_size = L3get_side_info1(); |
else |
side_size = L3get_side_info2(m_gr); |
m_buf_ptr0 = m_buf_ptr1 - m_side_info.main_data_begin;/* decode start point */ |
if (m_buf_ptr1 > BUF_TRIGGER) { /* shift buffer */ |
memmove(m_buf, m_buf + m_buf_ptr0, m_side_info.main_data_begin); |
m_buf_ptr0 = 0; |
m_buf_ptr1 = m_side_info.main_data_begin; |
} |
copy_size = m_frame_size - (4 + crc_size + side_size); |
//24/02/02 X-MaD |
if (copy_size < 0) { copy_size = copy_size * -1; } |
//if (copy_size < 0) { copy_size = 0; } |
//__try { |
memmove(m_buf + m_buf_ptr1, mpeg + (4 + crc_size + side_size), copy_size); |
//} __except(0){ |
// m_buf_ptr1 = 0; |
//} |
m_buf_ptr1 += copy_size; |
//24/02/02 X-MaD |
if (m_buf_ptr0 >= 0) { |
m_main_pos_bit = m_buf_ptr0 << 3; |
if (h->version == 1) { |
L3decode_main(h, pcm, 0); |
L3decode_main(h, pcm + (m_pcm_size / 2), 1); |
} |
else { |
L3decode_main(h, pcm, m_gr); |
m_gr = m_gr ^ 1; |
} |
} |
} |
void L3decode_main(MPEG_HEADER* h, byte *pcm, int gr) |
{ |
int ch; |
int n1, n2, n3, n4, nn2, nn3, nn4; |
int bit0, qbits, m0; |
for (ch = 0; ch < m_channels; ch ++) { |
bitget_init(m_buf + (m_main_pos_bit >> 3)); |
bit0 = (m_main_pos_bit & 7); |
if (bit0) bitget(bit0); |
m_main_pos_bit += m_side_info.gr[gr][ch].part2_3_length; |
bitget_init_end(m_buf + ((m_main_pos_bit + 39) >> 3)); |
// scale factors |
if (h->version == 1) |
L3get_scale_factor1(gr, ch); |
else |
L3get_scale_factor2(gr, ch); |
// huff data |
n1 = m_sfBandIndex[0][m_side_info.gr[gr][ch].region0_count]; |
n2 = m_sfBandIndex[0][m_side_info.gr[gr][ch].region0_count |
+ m_side_info.gr[gr][ch].region1_count + 1]; |
n3 = m_side_info.gr[gr][ch].big_values; |
n3 = n3 + n3; |
if (n3 > m_band_limit) n3 = m_band_limit; |
if (n2 > n3) n2 = n3; |
if (n1 > n3) n1 = n3; |
nn3 = n3 - n2; |
nn2 = n2 - n1; |
huffman(m_sample[ch][gr], n1, m_side_info.gr[gr][ch].table_select[0]); |
huffman(m_sample[ch][gr] + n1, nn2, m_side_info.gr[gr][ch].table_select[1]); |
huffman(m_sample[ch][gr] + n2, nn3, m_side_info.gr[gr][ch].table_select[2]); |
qbits = m_side_info.gr[gr][ch].part2_3_length - (bitget_bits_used() - bit0); |
nn4 = huffman_quad(m_sample[ch][gr] + n3, m_band_limit - n3, qbits, |
m_side_info.gr[gr][ch].count1table_select); |
n4 = n3 + nn4; |
m_nsamp[gr][ch] = n4; |
// limit n4 or allow deqaunt to sf band 22 |
if (m_side_info.gr[gr][ch].block_type == 2) |
n4 = min(n4, m_band_limit12); |
else |
n4 = min(n4, m_band_limit21); |
if (n4 < 576) |
memset(m_sample[ch][gr] + n4, 0, sizeof(SAMPLE) * (576 - n4)); |
if (bitget_overrun()) |
memset(m_sample[ch][gr], 0, sizeof(SAMPLE) * (576)); |
} |
// dequant |
for (ch = 0; ch < m_channels; ch++) { |
dequant(m_sample[ch][gr], gr, ch); |
} |
// ms stereo processing |
if (m_ms_mode) { |
if (m_is_mode == 0) { |
m0 = m_nsamp[gr][0]; // process to longer of left/right |
if (m0 < m_nsamp[gr][1]) |
m0 = m_nsamp[gr][1]; |
} |
else {// process to last cb in right |
m0 = m_sfBandIndex[m_cb_info[gr][1].cbtype][m_cb_info[gr][1].cbmax]; |
} |
ms_process(m_sample[0][gr], m0); |
} |
// is stereo processing |
if (m_is_mode) { |
if (h->version == 1) |
is_process1(m_sample[0][gr], &m_scale_fac[gr][1], |
m_cb_info[gr], m_nsamp[gr][0]); |
else |
is_process2(m_sample[0][gr], &m_scale_fac[gr][1], |
m_cb_info[gr], m_nsamp[gr][0]); |
} |
// adjust ms and is modes to max of left/right |
if (m_ms_mode || m_is_mode) { |
if (m_nsamp[gr][0] < m_nsamp[gr][1]) |
m_nsamp[gr][0] = m_nsamp[gr][1]; |
else |
m_nsamp[gr][1] = m_nsamp[gr][0]; |
} |
// antialias |
for (ch = 0; ch < m_channels; ch ++) { |
if (m_cb_info[gr][ch].ncbl == 0) |
continue; // have no long blocks |
if (m_side_info.gr[gr][ch].mixed_block_flag) |
n1 = 1; // 1 -> 36 samples |
else |
n1 = (m_nsamp[gr][ch] + 7) / 18; |
if (n1 > 31) |
n1 = 31; |
antialias(m_sample[ch][gr], n1); |
n1 = 18 * n1 + 8; // update number of samples |
if (n1 > m_nsamp[gr][ch]) |
m_nsamp[gr][ch] = n1; |
} |
// hybrid + sbt |
m_xform_proc(pcm, gr); |
} |
void xform_mono(void *pcm, int igr) |
{ |
int igr_prev, n1, n2; |
// hybrid + sbt |
n1 = n2 = m_nsamp[igr][0]; // total number bands |
if (m_side_info.gr[igr][0].block_type == 2) { // long bands |
if (m_side_info.gr[igr][0].mixed_block_flag) |
n1 = m_sfBandIndex[0][m_ncbl_mixed - 1]; |
else |
n1 = 0; |
} |
if (n1 > m_band_limit) |
n1 = m_band_limit; |
if (n2 > m_band_limit) |
n2 = m_band_limit; |
igr_prev = igr ^ 1; |
m_nsamp[igr][0] = hybrid(m_sample[0][igr], m_sample[0][igr_prev], |
m_yout, m_side_info.gr[igr][0].block_type, n1, n2, m_nsamp[igr_prev][0]); |
freq_invert(m_yout, m_nsamp[igr][0]); |
m_sbt_proc(m_yout, pcm, 0); |
} |
void xform_dual_right(void *pcm, int igr) |
{ |
int igr_prev, n1, n2; |
// hybrid + sbt |
n1 = n2 = m_nsamp[igr][1]; // total number bands |
if (m_side_info.gr[igr][1].block_type == 2) { // long bands |
if (m_side_info.gr[igr][1].mixed_block_flag) |
n1 = m_sfBandIndex[0][m_ncbl_mixed - 1]; |
else |
n1 = 0; |
} |
if (n1 > m_band_limit) |
n1 = m_band_limit; |
if (n2 > m_band_limit) |
n2 = m_band_limit; |
igr_prev = igr ^ 1; |
m_nsamp[igr][1] = hybrid(m_sample[1][igr], m_sample[1][igr_prev], |
m_yout, m_side_info.gr[igr][1].block_type, n1, n2, m_nsamp[igr_prev][1]); |
freq_invert(m_yout, m_nsamp[igr][1]); |
m_sbt_proc(m_yout, pcm, 0); |
} |
void xform_dual(void *pcm, int igr) |
{ |
int ch; |
int igr_prev, n1, n2; |
// hybrid + sbt |
igr_prev = igr ^ 1; |
for (ch = 0; ch < m_channels; ch++) { |
n1 = n2 = m_nsamp[igr][ch]; // total number bands |
if (m_side_info.gr[igr][ch].block_type == 2) { // long bands |
if (m_side_info.gr[igr][ch].mixed_block_flag) |
n1 = m_sfBandIndex[0][m_ncbl_mixed - 1]; |
else |
n1 = 0; |
} |
if (n1 > m_band_limit) |
n1 = m_band_limit; |
if (n2 > m_band_limit) |
n2 = m_band_limit; |
m_nsamp[igr][ch] = hybrid(m_sample[ch][igr], m_sample[ch][igr_prev], |
m_yout, m_side_info.gr[igr][ch].block_type, n1, n2, m_nsamp[igr_prev][ch]); |
freq_invert(m_yout, m_nsamp[igr][ch]); |
m_sbt_proc(m_yout, pcm, ch); |
} |
} |
void xform_dual_mono(void *pcm, int igr) |
{ |
int igr_prev, n1, n2, n3; |
// hybrid + sbt |
igr_prev = igr ^ 1; |
if ((m_side_info.gr[igr][0].block_type == m_side_info.gr[igr][1].block_type) |
&& (m_side_info.gr[igr][0].mixed_block_flag == 0) |
&& (m_side_info.gr[igr][1].mixed_block_flag == 0)) { |
n2 = m_nsamp[igr][0]; // total number bands max of L R |
if (n2 < m_nsamp[igr][1]) |
n2 = m_nsamp[igr][1]; |
if (n2 > m_band_limit) |
n2 = m_band_limit; |
if (m_side_info.gr[igr][0].block_type == 2) |
n1 = 0; |
else |
n1 = n2; // n1 = number long bands |
sum_f_bands(m_sample[0][igr], m_sample[1][igr], n2); |
n3 = m_nsamp[igr][0] = hybrid(m_sample[0][igr], m_sample[0][igr_prev], |
m_yout, m_side_info.gr[igr][0].block_type, n1, n2, m_nsamp[igr_prev][0]); |
} |
else { // transform and then sum (not tested - never happens in test) |
// left chan |
n1 = n2 = m_nsamp[igr][0]; // total number bands |
if (m_side_info.gr[igr][0].block_type == 2) { // long bands |
if (m_side_info.gr[igr][0].mixed_block_flag) |
n1 = m_sfBandIndex[0][m_ncbl_mixed - 1]; |
else |
n1 = 0; |
} |
n3 = m_nsamp[igr][0] = hybrid(m_sample[0][igr], m_sample[0][igr_prev], |
m_yout, m_side_info.gr[igr][0].block_type, n1, n2, m_nsamp[igr_prev][0]); |
// right chan |
n1 = n2 = m_nsamp[igr][1]; // total number bands |
if (m_side_info.gr[igr][1].block_type == 2) { // long bands |
if (m_side_info.gr[igr][1].mixed_block_flag) |
n1 = m_sfBandIndex[0][m_ncbl_mixed - 1]; |
else |
n1 = 0; |
} |
m_nsamp[igr][1] = hybrid_sum(m_sample[1][igr], m_sample[0][igr], |
m_yout, m_side_info.gr[igr][1].block_type, n1, n2); |
if (n3 < m_nsamp[igr][1]) |
n1 = m_nsamp[igr][1]; |
} |
freq_invert(m_yout, n3); |
m_sbt_proc(m_yout, pcm, 0); |
} |
/programs/media/ac97 mp3/trunk/mp3dec/l3huff.c |
---|
0,0 → 1,359 |
#include "layer3.h" |
#include "l3huff.h" |
//#ifdef _MSC_VER |
//#pragma warning(disable: 4505) |
//#endif |
/*===============================================================*/ |
/* max bits required for any lookup - change if htable changes */ |
/* quad required 10 bit w/signs must have (MAXBITS+2) >= 10 */ |
#define MAXBITS 9 |
static HUFF_ELEMENT huff_table_0[] = |
{0, 0, 0, 64}; /* dummy must not use */ |
/*-- 6 bit lookup (purgebits, value) --*/ |
static unsigned char quad_table_a[][2] = |
{ |
6, 11, 6, 15, 6, 13, 6, 14, 6, 7, 6, 5, 5, 9, |
5, 9, 5, 6, 5, 6, 5, 3, 5, 3, 5, 10, 5, 10, |
5, 12, 5, 12, 4, 2, 4, 2, 4, 2, 4, 2, 4, 1, |
4, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, 4, 4, 4, |
4, 8, 4, 8, 4, 8, 4, 8, 1, 0, 1, 0, 1, 0, |
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, |
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, |
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, |
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, |
1, 0, |
}; |
typedef struct |
{ |
HUFF_ELEMENT *table; |
int linbits; |
int ncase; |
} |
HUFF_SETUP; |
#define no_bits 0 |
#define one_shot 1 |
#define no_linbits 2 |
#define have_linbits 3 |
#define quad_a 4 |
#define quad_b 5 |
static HUFF_SETUP table_look[] = |
{ |
huff_table_0, 0, no_bits, |
huff_table_1, 0, one_shot, |
huff_table_2, 0, one_shot, |
huff_table_3, 0, one_shot, |
huff_table_0, 0, no_bits, |
huff_table_5, 0, one_shot, |
huff_table_6, 0, one_shot, |
huff_table_7, 0, no_linbits, |
huff_table_8, 0, no_linbits, |
huff_table_9, 0, no_linbits, |
huff_table_10, 0, no_linbits, |
huff_table_11, 0, no_linbits, |
huff_table_12, 0, no_linbits, |
huff_table_13, 0, no_linbits, |
huff_table_0, 0, no_bits, |
huff_table_15, 0, no_linbits, |
huff_table_16, 1, have_linbits, |
huff_table_16, 2, have_linbits, |
huff_table_16, 3, have_linbits, |
huff_table_16, 4, have_linbits, |
huff_table_16, 6, have_linbits, |
huff_table_16, 8, have_linbits, |
huff_table_16, 10, have_linbits, |
huff_table_16, 13, have_linbits, |
huff_table_24, 4, have_linbits, |
huff_table_24, 5, have_linbits, |
huff_table_24, 6, have_linbits, |
huff_table_24, 7, have_linbits, |
huff_table_24, 8, have_linbits, |
huff_table_24, 9, have_linbits, |
huff_table_24, 11, have_linbits, |
huff_table_24, 13, have_linbits, |
huff_table_0, 0, quad_a, |
huff_table_0, 0, quad_b, |
}; |
/*========================================================*/ |
void huffman(int xy[][2], int n, int ntable) |
{ |
int i; |
HUFF_ELEMENT *t; |
HUFF_ELEMENT *t0; |
int linbits; |
int bits; |
int code; |
int x, y; |
if (n <= 0) |
return; |
n = n >> 1; /* huff in pairs */ |
/*-------------*/ |
t0 = table_look[ntable].table; |
linbits = table_look[ntable].linbits; |
switch (table_look[ntable].ncase) |
{ |
default: |
/*------------------------------------------*/ |
case no_bits: |
/*- table 0, no data, x=y=0--*/ |
for (i = 0; i < n; i++) |
{ |
xy[i][0] = 0; |
xy[i][1] = 0; |
} |
return; |
/*------------------------------------------*/ |
case one_shot: |
/*- single lookup, no escapes -*/ |
for (i = 0; i < n; i++) |
{ |
mac_bitget_check((MAXBITS + 2)); |
bits = t0[0].b.signbits; |
code = mac_bitget2(bits); |
mac_bitget_purge(t0[1 + code].b.purgebits); |
x = t0[1 + code].b.x; |
y = t0[1 + code].b.y; |
if (x) |
if (mac_bitget_1bit()) |
x = -x; |
if (y) |
if (mac_bitget_1bit()) |
y = -y; |
xy[i][0] = x; |
xy[i][1] = y; |
if (bitget_overrun()) |
break; // bad data protect |
} |
return; |
/*------------------------------------------*/ |
case no_linbits: |
for (i = 0; i < n; i++) |
{ |
t = t0; |
for (;;) |
{ |
mac_bitget_check((MAXBITS + 2)); |
bits = t[0].b.signbits; |
code = mac_bitget2(bits); |
if (t[1 + code].b.purgebits) |
break; |
t += t[1 + code].ptr; /* ptr include 1+code */ |
mac_bitget_purge(bits); |
} |
mac_bitget_purge(t[1 + code].b.purgebits); |
x = t[1 + code].b.x; |
y = t[1 + code].b.y; |
if (x) |
if (mac_bitget_1bit()) |
x = -x; |
if (y) |
if (mac_bitget_1bit()) |
y = -y; |
xy[i][0] = x; |
xy[i][1] = y; |
if (bitget_overrun()) |
break; // bad data protect |
} |
return; |
/*------------------------------------------*/ |
case have_linbits: |
for (i = 0; i < n; i++) |
{ |
t = t0; |
for (;;) |
{ |
bits = t[0].b.signbits; |
code = bitget2(bits); |
if (t[1 + code].b.purgebits) |
break; |
t += t[1 + code].ptr; /* ptr includes 1+code */ |
mac_bitget_purge(bits); |
} |
mac_bitget_purge(t[1 + code].b.purgebits); |
x = t[1 + code].b.x; |
y = t[1 + code].b.y; |
if (x == 15) |
x += bitget_lb(linbits); |
if (x) |
if (mac_bitget_1bit()) |
x = -x; |
if (y == 15) |
y += bitget_lb(linbits); |
if (y) |
if (mac_bitget_1bit()) |
y = -y; |
xy[i][0] = x; |
xy[i][1] = y; |
if (bitget_overrun()) |
break; // bad data protect |
} |
return; |
} |
/*--- end switch ---*/ |
} |
int huffman_quad(int vwxy[][4], int n, int nbits, int ntable) |
{ |
int i; |
int code; |
int x, y, v, w; |
int tmp; |
int i_non_zero, tmp_nz; |
tmp_nz = 15; |
i_non_zero = -1; |
n = n >> 2; /* huff in quads */ |
if (ntable) |
goto case_quad_b; |
/* case_quad_a: */ |
for (i = 0; i < n; i++) |
{ |
if (nbits <= 0) |
break; |
mac_bitget_check(10); |
code = mac_bitget2(6); |
nbits -= quad_table_a[code][0]; |
mac_bitget_purge(quad_table_a[code][0]); |
tmp = quad_table_a[code][1]; |
if (tmp) |
{ |
i_non_zero = i; |
tmp_nz = tmp; |
} |
v = (tmp >> 3) & 1; |
w = (tmp >> 2) & 1; |
x = (tmp >> 1) & 1; |
y = tmp & 1; |
if (v) |
{ |
if (mac_bitget_1bit()) |
v = -v; |
nbits--; |
} |
if (w) |
{ |
if (mac_bitget_1bit()) |
w = -w; |
nbits--; |
} |
if (x) |
{ |
if (mac_bitget_1bit()) |
x = -x; |
nbits--; |
} |
if (y) |
{ |
if (mac_bitget_1bit()) |
y = -y; |
nbits--; |
} |
vwxy[i][0] = v; |
vwxy[i][1] = w; |
vwxy[i][2] = x; |
vwxy[i][3] = y; |
if (bitget_overrun()) |
break; // bad data protect |
} |
if (nbits < 0) |
{ |
i--; |
vwxy[i][0] = 0; |
vwxy[i][1] = 0; |
vwxy[i][2] = 0; |
vwxy[i][3] = 0; |
} |
i_non_zero = (i_non_zero + 1) << 2; |
if ((tmp_nz & 3) == 0) |
i_non_zero -= 2; |
return i_non_zero; |
/*--------------------*/ |
case_quad_b: |
for (i = 0; i < n; i++) |
{ |
if (nbits < 4) |
break; |
nbits -= 4; |
mac_bitget_check(8); |
tmp = mac_bitget(4) ^ 15; /* one's complement of bitstream */ |
if (tmp) |
{ |
i_non_zero = i; |
tmp_nz = tmp; |
} |
v = (tmp >> 3) & 1; |
w = (tmp >> 2) & 1; |
x = (tmp >> 1) & 1; |
y = tmp & 1; |
if (v) |
{ |
if (mac_bitget_1bit()) |
v = -v; |
nbits--; |
} |
if (w) |
{ |
if (mac_bitget_1bit()) |
w = -w; |
nbits--; |
} |
if (x) |
{ |
if (mac_bitget_1bit()) |
x = -x; |
nbits--; |
} |
if (y) |
{ |
if (mac_bitget_1bit()) |
y = -y; |
nbits--; |
} |
vwxy[i][0] = v; |
vwxy[i][1] = w; |
vwxy[i][2] = x; |
vwxy[i][3] = y; |
if (bitget_overrun()) |
break; // bad data protect |
} |
if (nbits < 0) |
{ |
i--; |
vwxy[i][0] = 0; |
vwxy[i][1] = 0; |
vwxy[i][2] = 0; |
vwxy[i][3] = 0; |
} |
i_non_zero = (i_non_zero + 1) << 2; |
if ((tmp_nz & 3) == 0) |
i_non_zero -= 2; |
return i_non_zero; /* return non-zero sample (to nearest pair) */ |
} |
/programs/media/ac97 mp3/trunk/mp3dec/l3huff.h |
---|
0,0 → 1,973 |
typedef union |
{ |
int ptr; |
struct |
{ |
unsigned char signbits; |
unsigned char x; |
unsigned char y; |
unsigned char purgebits; // 0 = esc |
} |
b; |
} |
HUFF_ELEMENT; |
/* TABLE 1 4 entries maxbits 3 linbits 0 */ |
static HUFF_ELEMENT huff_table_1[] = |
{ |
0xFF000003, 0x03010102, 0x03010001, 0x02000101, 0x02000101, /* 4 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000,}; |
/* max table bits 3 */ |
/* TABLE 2 9 entries maxbits 6 linbits 0 */ |
static HUFF_ELEMENT huff_table_2[] = |
{ |
0xFF000006, 0x06020202, 0x06020001, 0x05020102, 0x05020102, /* 4 */ |
0x05010202, 0x05010202, 0x05000201, 0x05000201, 0x03010102, /* 9 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 14 */ |
0x03010102, 0x03010102, 0x03010001, 0x03010001, 0x03010001, /* 19 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 24 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 29 */ |
0x03000101, 0x03000101, 0x03000101, 0x01000000, 0x01000000, /* 34 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 39 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 44 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 49 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 54 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 59 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 64 */ }; |
/* max table bits 6 */ |
/* TABLE 3 9 entries maxbits 6 linbits 0 */ |
static HUFF_ELEMENT huff_table_3[] = |
{ |
0xFF000006, 0x06020202, 0x06020001, 0x05020102, 0x05020102, /* 4 */ |
0x05010202, 0x05010202, 0x05000201, 0x05000201, 0x03000101, /* 9 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 14 */ |
0x03000101, 0x03000101, 0x02010102, 0x02010102, 0x02010102, /* 19 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 24 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 29 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010001, 0x02010001, /* 34 */ |
0x02010001, 0x02010001, 0x02010001, 0x02010001, 0x02010001, /* 39 */ |
0x02010001, 0x02010001, 0x02010001, 0x02010001, 0x02010001, /* 44 */ |
0x02010001, 0x02010001, 0x02010001, 0x02010001, 0x02000000, /* 49 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 54 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 59 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 64 */ }; |
/* max table bits 6 */ |
/* NO XING TABLE 4 */ |
/* TABLE 5 16 entries maxbits 8 linbits 0 */ |
static HUFF_ELEMENT huff_table_5[] = |
{ |
0xFF000008, 0x08030302, 0x08030202, 0x07020302, 0x07020302, /* 4 */ |
0x06010302, 0x06010302, 0x06010302, 0x06010302, 0x07030102, /* 9 */ |
0x07030102, 0x07030001, 0x07030001, 0x07000301, 0x07000301, /* 14 */ |
0x07020202, 0x07020202, 0x06020102, 0x06020102, 0x06020102, /* 19 */ |
0x06020102, 0x06010202, 0x06010202, 0x06010202, 0x06010202, /* 24 */ |
0x06020001, 0x06020001, 0x06020001, 0x06020001, 0x06000201, /* 29 */ |
0x06000201, 0x06000201, 0x06000201, 0x03010102, 0x03010102, /* 34 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 39 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 44 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 49 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 54 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 59 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 64 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 69 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 74 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 79 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 84 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 89 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 94 */ |
0x03010001, 0x03010001, 0x03000101, 0x03000101, 0x03000101, /* 99 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 104 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 109 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 114 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 119 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 124 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x01000000, /* 129 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 134 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 139 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 144 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 149 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 154 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 159 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 164 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 169 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 174 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 179 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 184 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 189 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 194 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 199 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 204 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 209 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 214 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 219 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 224 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 229 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 234 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 239 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 244 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 249 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 254 */ |
0x01000000, 0x01000000,}; |
/* max table bits 8 */ |
/* TABLE 6 16 entries maxbits 7 linbits 0 */ |
static HUFF_ELEMENT huff_table_6[] = |
{ |
0xFF000007, 0x07030302, 0x07030001, 0x06030202, 0x06030202, /* 4 */ |
0x06020302, 0x06020302, 0x06000301, 0x06000301, 0x05030102, /* 9 */ |
0x05030102, 0x05030102, 0x05030102, 0x05010302, 0x05010302, /* 14 */ |
0x05010302, 0x05010302, 0x05020202, 0x05020202, 0x05020202, /* 19 */ |
0x05020202, 0x05020001, 0x05020001, 0x05020001, 0x05020001, /* 24 */ |
0x04020102, 0x04020102, 0x04020102, 0x04020102, 0x04020102, /* 29 */ |
0x04020102, 0x04020102, 0x04020102, 0x04010202, 0x04010202, /* 34 */ |
0x04010202, 0x04010202, 0x04010202, 0x04010202, 0x04010202, /* 39 */ |
0x04010202, 0x04000201, 0x04000201, 0x04000201, 0x04000201, /* 44 */ |
0x04000201, 0x04000201, 0x04000201, 0x04000201, 0x03010001, /* 49 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 54 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 59 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 64 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 69 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 74 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 79 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 84 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 89 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 94 */ |
0x02010102, 0x02010102, 0x03000101, 0x03000101, 0x03000101, /* 99 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 104 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 109 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000000, 0x03000000, /* 114 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000, /* 119 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000, /* 124 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000,}; |
/* max table bits 7 */ |
/* TABLE 7 36 entries maxbits 10 linbits 0 */ |
static HUFF_ELEMENT huff_table_7[] = |
{ |
0xFF000006, 0x00000041, 0x00000052, 0x0000005B, 0x00000060, /* 4 */ |
0x00000063, 0x00000068, 0x0000006B, 0x06020102, 0x05010202, /* 9 */ |
0x05010202, 0x06020001, 0x06000201, 0x04010102, 0x04010102, /* 14 */ |
0x04010102, 0x04010102, 0x03010001, 0x03010001, 0x03010001, /* 19 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 24 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 29 */ |
0x03000101, 0x03000101, 0x03000101, 0x01000000, 0x01000000, /* 34 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 39 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 44 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 49 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 54 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 59 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 64 */ |
0xFF000004, 0x04050502, 0x04050402, 0x04040502, 0x04030502, /* 69 */ |
0x03050302, 0x03050302, 0x03040402, 0x03040402, 0x03050202, /* 74 */ |
0x03050202, 0x03020502, 0x03020502, 0x02050102, 0x02050102, /* 79 */ |
0x02050102, 0x02050102, 0xFF000003, 0x02010502, 0x02010502, /* 84 */ |
0x03050001, 0x03040302, 0x02000501, 0x02000501, 0x03030402, /* 89 */ |
0x03030302, 0xFF000002, 0x02040202, 0x02020402, 0x01040102, /* 94 */ |
0x01040102, 0xFF000001, 0x01010402, 0x01000401, 0xFF000002, /* 99 */ |
0x02040001, 0x02030202, 0x02020302, 0x02030001, 0xFF000001, /* 104 */ |
0x01030102, 0x01010302, 0xFF000001, 0x01000301, 0x01020202, /* 109 */ }; |
/* max table bits 6 */ |
/* TABLE 8 36 entries maxbits 11 linbits 0 */ |
static HUFF_ELEMENT huff_table_8[] = |
{ |
0xFF000008, 0x00000101, 0x0000010A, 0x0000010F, 0x08050102, /* 4 */ |
0x08010502, 0x00000112, 0x00000115, 0x08040202, 0x08020402, /* 9 */ |
0x08040102, 0x07010402, 0x07010402, 0x08040001, 0x08000401, /* 14 */ |
0x08030202, 0x08020302, 0x08030102, 0x08010302, 0x08030001, /* 19 */ |
0x08000301, 0x06020202, 0x06020202, 0x06020202, 0x06020202, /* 24 */ |
0x06020001, 0x06020001, 0x06020001, 0x06020001, 0x06000201, /* 29 */ |
0x06000201, 0x06000201, 0x06000201, 0x04020102, 0x04020102, /* 34 */ |
0x04020102, 0x04020102, 0x04020102, 0x04020102, 0x04020102, /* 39 */ |
0x04020102, 0x04020102, 0x04020102, 0x04020102, 0x04020102, /* 44 */ |
0x04020102, 0x04020102, 0x04020102, 0x04020102, 0x04010202, /* 49 */ |
0x04010202, 0x04010202, 0x04010202, 0x04010202, 0x04010202, /* 54 */ |
0x04010202, 0x04010202, 0x04010202, 0x04010202, 0x04010202, /* 59 */ |
0x04010202, 0x04010202, 0x04010202, 0x04010202, 0x04010202, /* 64 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 69 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 74 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 79 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 84 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 89 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 94 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 99 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 104 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 109 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 114 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 119 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x02010102, /* 124 */ |
0x02010102, 0x02010102, 0x02010102, 0x02010102, 0x03010001, /* 129 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 134 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 139 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 144 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 149 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 154 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 159 */ |
0x03010001, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 164 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 169 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 174 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 179 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 184 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 189 */ |
0x03000101, 0x03000101, 0x03000101, 0x02000000, 0x02000000, /* 194 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 199 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 204 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 209 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 214 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 219 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 224 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 229 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 234 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 239 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 244 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 249 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 254 */ |
0x02000000, 0x02000000, 0xFF000003, 0x03050502, 0x03040502, /* 259 */ |
0x02050402, 0x02050402, 0x01030502, 0x01030502, 0x01030502, /* 264 */ |
0x01030502, 0xFF000002, 0x02050302, 0x02040402, 0x01050202, /* 269 */ |
0x01050202, 0xFF000001, 0x01020502, 0x01050001, 0xFF000001, /* 274 */ |
0x01040302, 0x01030402, 0xFF000001, 0x01000501, 0x01030302, /* 279 */ }; |
/* max table bits 8 */ |
/* TABLE 9 36 entries maxbits 9 linbits 0 */ |
static HUFF_ELEMENT huff_table_9[] = |
{ |
0xFF000006, 0x00000041, 0x0000004A, 0x0000004F, 0x00000052, /* 4 */ |
0x00000057, 0x0000005A, 0x06040102, 0x06010402, 0x06030202, /* 9 */ |
0x06020302, 0x05030102, 0x05030102, 0x05010302, 0x05010302, /* 14 */ |
0x06030001, 0x06000301, 0x05020202, 0x05020202, 0x05020001, /* 19 */ |
0x05020001, 0x04020102, 0x04020102, 0x04020102, 0x04020102, /* 24 */ |
0x04010202, 0x04010202, 0x04010202, 0x04010202, 0x04000201, /* 29 */ |
0x04000201, 0x04000201, 0x04000201, 0x03010102, 0x03010102, /* 34 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 39 */ |
0x03010102, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 44 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03000101, /* 49 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 54 */ |
0x03000101, 0x03000101, 0x03000000, 0x03000000, 0x03000000, /* 59 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000, /* 64 */ |
0xFF000003, 0x03050502, 0x03050402, 0x02050302, 0x02050302, /* 69 */ |
0x02030502, 0x02030502, 0x03040502, 0x03050001, 0xFF000002, /* 74 */ |
0x02040402, 0x02050202, 0x02020502, 0x02050102, 0xFF000001, /* 79 */ |
0x01010502, 0x01040302, 0xFF000002, 0x01030402, 0x01030402, /* 84 */ |
0x02000501, 0x02040001, 0xFF000001, 0x01040202, 0x01020402, /* 89 */ |
0xFF000001, 0x01030302, 0x01000401,}; |
/* max table bits 6 */ |
/* TABLE 10 64 entries maxbits 11 linbits 0 */ |
static HUFF_ELEMENT huff_table_10[] = |
{ |
0xFF000008, 0x00000101, 0x0000010A, 0x0000010F, 0x00000118, /* 4 */ |
0x0000011B, 0x00000120, 0x00000125, 0x08070102, 0x08010702, /* 9 */ |
0x0000012A, 0x0000012D, 0x00000132, 0x08060102, 0x08010602, /* 14 */ |
0x08000601, 0x00000137, 0x0000013A, 0x0000013D, 0x08040102, /* 19 */ |
0x08010402, 0x08000401, 0x08030202, 0x08020302, 0x08030001, /* 24 */ |
0x07030102, 0x07030102, 0x07010302, 0x07010302, 0x07000301, /* 29 */ |
0x07000301, 0x07020202, 0x07020202, 0x06020102, 0x06020102, /* 34 */ |
0x06020102, 0x06020102, 0x06010202, 0x06010202, 0x06010202, /* 39 */ |
0x06010202, 0x06020001, 0x06020001, 0x06020001, 0x06020001, /* 44 */ |
0x06000201, 0x06000201, 0x06000201, 0x06000201, 0x04010102, /* 49 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 54 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 59 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 64 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 69 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 74 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 79 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 84 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 89 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 94 */ |
0x03010001, 0x03010001, 0x03000101, 0x03000101, 0x03000101, /* 99 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 104 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 109 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 114 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 119 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 124 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x01000000, /* 129 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 134 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 139 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 144 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 149 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 154 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 159 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 164 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 169 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 174 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 179 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 184 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 189 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 194 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 199 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 204 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 209 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 214 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 219 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 224 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 229 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 234 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 239 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 244 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 249 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 254 */ |
0x01000000, 0x01000000, 0xFF000003, 0x03070702, 0x03070602, /* 259 */ |
0x03060702, 0x03070502, 0x03050702, 0x03060602, 0x02070402, /* 264 */ |
0x02070402, 0xFF000002, 0x02040702, 0x02060502, 0x02050602, /* 269 */ |
0x02070302, 0xFF000003, 0x02030702, 0x02030702, 0x02060402, /* 274 */ |
0x02060402, 0x03050502, 0x03040502, 0x02030602, 0x02030602, /* 279 */ |
0xFF000001, 0x01070202, 0x01020702, 0xFF000002, 0x02040602, /* 284 */ |
0x02070001, 0x01000701, 0x01000701, 0xFF000002, 0x01020602, /* 289 */ |
0x01020602, 0x02050402, 0x02050302, 0xFF000002, 0x01060001, /* 294 */ |
0x01060001, 0x02030502, 0x02040402, 0xFF000001, 0x01060302, /* 299 */ |
0x01060202, 0xFF000002, 0x02050202, 0x02020502, 0x01050102, /* 304 */ |
0x01050102, 0xFF000002, 0x01010502, 0x01010502, 0x02040302, /* 309 */ |
0x02030402, 0xFF000001, 0x01050001, 0x01000501, 0xFF000001, /* 314 */ |
0x01040202, 0x01020402, 0xFF000001, 0x01030302, 0x01040001, /* 319 */ }; |
/* max table bits 8 */ |
/* TABLE 11 64 entries maxbits 11 linbits 0 */ |
static HUFF_ELEMENT huff_table_11[] = |
{ |
0xFF000008, 0x00000101, 0x00000106, 0x0000010F, 0x00000114, /* 4 */ |
0x00000117, 0x08070202, 0x08020702, 0x0000011C, 0x07010702, /* 9 */ |
0x07010702, 0x08070102, 0x08000701, 0x08060302, 0x08030602, /* 14 */ |
0x08000601, 0x0000011F, 0x00000122, 0x08050102, 0x07020602, /* 19 */ |
0x07020602, 0x08060202, 0x08060001, 0x07060102, 0x07060102, /* 24 */ |
0x07010602, 0x07010602, 0x08010502, 0x08040302, 0x08000501, /* 29 */ |
0x00000125, 0x08040202, 0x08020402, 0x08040102, 0x08010402, /* 34 */ |
0x08040001, 0x08000401, 0x07030202, 0x07030202, 0x07020302, /* 39 */ |
0x07020302, 0x06030102, 0x06030102, 0x06030102, 0x06030102, /* 44 */ |
0x06010302, 0x06010302, 0x06010302, 0x06010302, 0x07030001, /* 49 */ |
0x07030001, 0x07000301, 0x07000301, 0x06020202, 0x06020202, /* 54 */ |
0x06020202, 0x06020202, 0x05010202, 0x05010202, 0x05010202, /* 59 */ |
0x05010202, 0x05010202, 0x05010202, 0x05010202, 0x05010202, /* 64 */ |
0x04020102, 0x04020102, 0x04020102, 0x04020102, 0x04020102, /* 69 */ |
0x04020102, 0x04020102, 0x04020102, 0x04020102, 0x04020102, /* 74 */ |
0x04020102, 0x04020102, 0x04020102, 0x04020102, 0x04020102, /* 79 */ |
0x04020102, 0x05020001, 0x05020001, 0x05020001, 0x05020001, /* 84 */ |
0x05020001, 0x05020001, 0x05020001, 0x05020001, 0x05000201, /* 89 */ |
0x05000201, 0x05000201, 0x05000201, 0x05000201, 0x05000201, /* 94 */ |
0x05000201, 0x05000201, 0x03010102, 0x03010102, 0x03010102, /* 99 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 104 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 109 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 114 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 119 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 124 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010001, /* 129 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 134 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 139 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 144 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 149 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 154 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 159 */ |
0x03010001, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 164 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 169 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 174 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 179 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 184 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 189 */ |
0x03000101, 0x03000101, 0x03000101, 0x02000000, 0x02000000, /* 194 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 199 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 204 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 209 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 214 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 219 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 224 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 229 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 234 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 239 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 244 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 249 */ |
0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000, /* 254 */ |
0x02000000, 0x02000000, 0xFF000002, 0x02070702, 0x02070602, /* 259 */ |
0x02060702, 0x02050702, 0xFF000003, 0x02060602, 0x02060602, /* 264 */ |
0x02070402, 0x02070402, 0x02040702, 0x02040702, 0x03070502, /* 269 */ |
0x03050502, 0xFF000002, 0x02060502, 0x02050602, 0x01070302, /* 274 */ |
0x01070302, 0xFF000001, 0x01030702, 0x01060402, 0xFF000002, /* 279 */ |
0x02050402, 0x02040502, 0x02050302, 0x02030502, 0xFF000001, /* 284 */ |
0x01040602, 0x01070001, 0xFF000001, 0x01040402, 0x01050202, /* 289 */ |
0xFF000001, 0x01020502, 0x01050001, 0xFF000001, 0x01030402, /* 294 */ |
0x01030302,}; |
/* max table bits 8 */ |
/* TABLE 12 64 entries maxbits 10 linbits 0 */ |
static HUFF_ELEMENT huff_table_12[] = |
{ |
0xFF000007, 0x00000081, 0x0000008A, 0x0000008F, 0x00000092, /* 4 */ |
0x00000097, 0x0000009A, 0x0000009D, 0x000000A2, 0x000000A5, /* 9 */ |
0x000000A8, 0x07060202, 0x07020602, 0x07010602, 0x000000AD, /* 14 */ |
0x000000B0, 0x000000B3, 0x07050102, 0x07010502, 0x07040302, /* 19 */ |
0x07030402, 0x000000B6, 0x07040202, 0x07020402, 0x07040102, /* 24 */ |
0x06030302, 0x06030302, 0x06010402, 0x06010402, 0x06030202, /* 29 */ |
0x06030202, 0x06020302, 0x06020302, 0x07000401, 0x07030001, /* 34 */ |
0x06000301, 0x06000301, 0x05030102, 0x05030102, 0x05030102, /* 39 */ |
0x05030102, 0x05010302, 0x05010302, 0x05010302, 0x05010302, /* 44 */ |
0x05020202, 0x05020202, 0x05020202, 0x05020202, 0x04020102, /* 49 */ |
0x04020102, 0x04020102, 0x04020102, 0x04020102, 0x04020102, /* 54 */ |
0x04020102, 0x04020102, 0x04010202, 0x04010202, 0x04010202, /* 59 */ |
0x04010202, 0x04010202, 0x04010202, 0x04010202, 0x04010202, /* 64 */ |
0x05020001, 0x05020001, 0x05020001, 0x05020001, 0x05000201, /* 69 */ |
0x05000201, 0x05000201, 0x05000201, 0x04000000, 0x04000000, /* 74 */ |
0x04000000, 0x04000000, 0x04000000, 0x04000000, 0x04000000, /* 79 */ |
0x04000000, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 84 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 89 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 94 */ |
0x03010102, 0x03010102, 0x03010001, 0x03010001, 0x03010001, /* 99 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 104 */ |
0x03010001, 0x03010001, 0x03010001, 0x03010001, 0x03010001, /* 109 */ |
0x03010001, 0x03010001, 0x03010001, 0x03000101, 0x03000101, /* 114 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 119 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 124 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0xFF000003, /* 129 */ |
0x03070702, 0x03070602, 0x02060702, 0x02060702, 0x02070502, /* 134 */ |
0x02070502, 0x02050702, 0x02050702, 0xFF000002, 0x02060602, /* 139 */ |
0x02070402, 0x02040702, 0x02050602, 0xFF000001, 0x01060502, /* 144 */ |
0x01070302, 0xFF000002, 0x02030702, 0x02050502, 0x01070202, /* 149 */ |
0x01070202, 0xFF000001, 0x01020702, 0x01060402, 0xFF000001, /* 154 */ |
0x01040602, 0x01070102, 0xFF000002, 0x01010702, 0x01010702, /* 159 */ |
0x02070001, 0x02000701, 0xFF000001, 0x01060302, 0x01030602, /* 164 */ |
0xFF000001, 0x01050402, 0x01040502, 0xFF000002, 0x01040402, /* 169 */ |
0x01040402, 0x02060001, 0x02050001, 0xFF000001, 0x01060102, /* 174 */ |
0x01000601, 0xFF000001, 0x01050302, 0x01030502, 0xFF000001, /* 179 */ |
0x01050202, 0x01020502, 0xFF000001, 0x01000501, 0x01040001, /* 184 */ }; |
/* max table bits 7 */ |
/* TABLE 13 256 entries maxbits 19 linbits 0 */ |
static HUFF_ELEMENT huff_table_13[] = |
{ |
0xFF000006, 0x00000041, 0x00000082, 0x000000C3, 0x000000E4, /* 4 */ |
0x00000105, 0x00000116, 0x0000011F, 0x00000130, 0x00000139, /* 9 */ |
0x0000013E, 0x00000143, 0x00000146, 0x06020102, 0x06010202, /* 14 */ |
0x06020001, 0x06000201, 0x04010102, 0x04010102, 0x04010102, /* 19 */ |
0x04010102, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 24 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 29 */ |
0x03000101, 0x03000101, 0x03000101, 0x01000000, 0x01000000, /* 34 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 39 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 44 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 49 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 54 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 59 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 64 */ |
0xFF000006, 0x00000108, 0x00000111, 0x0000011A, 0x00000123, /* 69 */ |
0x0000012C, 0x00000131, 0x00000136, 0x0000013F, 0x00000144, /* 74 */ |
0x00000147, 0x0000014C, 0x00000151, 0x00000156, 0x0000015B, /* 79 */ |
0x060F0102, 0x06010F02, 0x06000F01, 0x00000160, 0x00000163, /* 84 */ |
0x00000166, 0x06020E02, 0x00000169, 0x060E0102, 0x06010E02, /* 89 */ |
0x0000016C, 0x0000016F, 0x00000172, 0x00000175, 0x00000178, /* 94 */ |
0x0000017B, 0x06060C02, 0x060D0302, 0x0000017E, 0x060D0202, /* 99 */ |
0x06020D02, 0x060D0102, 0x06070B02, 0x00000181, 0x00000184, /* 104 */ |
0x06030C02, 0x00000187, 0x060B0402, 0x05010D02, 0x05010D02, /* 109 */ |
0x060D0001, 0x06000D01, 0x060A0802, 0x06080A02, 0x060C0402, /* 114 */ |
0x06040C02, 0x060B0602, 0x06060B02, 0x050C0302, 0x050C0302, /* 119 */ |
0x050C0202, 0x050C0202, 0x05020C02, 0x05020C02, 0x050B0502, /* 124 */ |
0x050B0502, 0x06050B02, 0x06090802, 0x050C0102, 0x050C0102, /* 129 */ |
0xFF000006, 0x05010C02, 0x05010C02, 0x06080902, 0x060C0001, /* 134 */ |
0x05000C01, 0x05000C01, 0x06040B02, 0x060A0602, 0x06060A02, /* 139 */ |
0x06090702, 0x050B0302, 0x050B0302, 0x05030B02, 0x05030B02, /* 144 */ |
0x06080802, 0x060A0502, 0x050B0202, 0x050B0202, 0x06050A02, /* 149 */ |
0x06090602, 0x05040A02, 0x05040A02, 0x06080702, 0x06070802, /* 154 */ |
0x05040902, 0x05040902, 0x06070702, 0x06060702, 0x04020B02, /* 159 */ |
0x04020B02, 0x04020B02, 0x04020B02, 0x040B0102, 0x040B0102, /* 164 */ |
0x040B0102, 0x040B0102, 0x04010B02, 0x04010B02, 0x04010B02, /* 169 */ |
0x04010B02, 0x050B0001, 0x050B0001, 0x05000B01, 0x05000B01, /* 174 */ |
0x05060902, 0x05060902, 0x050A0402, 0x050A0402, 0x050A0302, /* 179 */ |
0x050A0302, 0x05030A02, 0x05030A02, 0x05090502, 0x05090502, /* 184 */ |
0x05050902, 0x05050902, 0x040A0202, 0x040A0202, 0x040A0202, /* 189 */ |
0x040A0202, 0x04020A02, 0x04020A02, 0x04020A02, 0x04020A02, /* 194 */ |
0xFF000005, 0x040A0102, 0x040A0102, 0x04010A02, 0x04010A02, /* 199 */ |
0x050A0001, 0x05080602, 0x04000A01, 0x04000A01, 0x05060802, /* 204 */ |
0x05090402, 0x04030902, 0x04030902, 0x05090302, 0x05080502, /* 209 */ |
0x05050802, 0x05070602, 0x04090202, 0x04090202, 0x04020902, /* 214 */ |
0x04020902, 0x05070502, 0x05050702, 0x04080302, 0x04080302, /* 219 */ |
0x04030802, 0x04030802, 0x05060602, 0x05070402, 0x05040702, /* 224 */ |
0x05060502, 0x05050602, 0x05030702, 0xFF000005, 0x03090102, /* 229 */ |
0x03090102, 0x03090102, 0x03090102, 0x03010902, 0x03010902, /* 234 */ |
0x03010902, 0x03010902, 0x04090001, 0x04090001, 0x04000901, /* 239 */ |
0x04000901, 0x04080402, 0x04080402, 0x04040802, 0x04040802, /* 244 */ |
0x04020702, 0x04020702, 0x05060402, 0x05040602, 0x03080202, /* 249 */ |
0x03080202, 0x03080202, 0x03080202, 0x03020802, 0x03020802, /* 254 */ |
0x03020802, 0x03020802, 0x03080102, 0x03080102, 0x03080102, /* 259 */ |
0x03080102, 0xFF000004, 0x04070302, 0x04070202, 0x03070102, /* 264 */ |
0x03070102, 0x03010702, 0x03010702, 0x04050502, 0x04070001, /* 269 */ |
0x04000701, 0x04060302, 0x04030602, 0x04050402, 0x04040502, /* 274 */ |
0x04060202, 0x04020602, 0x04050302, 0xFF000003, 0x02010802, /* 279 */ |
0x02010802, 0x03080001, 0x03000801, 0x03060102, 0x03010602, /* 284 */ |
0x03060001, 0x03000601, 0xFF000004, 0x04030502, 0x04040402, /* 289 */ |
0x03050202, 0x03050202, 0x03020502, 0x03020502, 0x03050001, /* 294 */ |
0x03050001, 0x02050102, 0x02050102, 0x02050102, 0x02050102, /* 299 */ |
0x02010502, 0x02010502, 0x02010502, 0x02010502, 0xFF000003, /* 304 */ |
0x03040302, 0x03030402, 0x03000501, 0x03040202, 0x03020402, /* 309 */ |
0x03030302, 0x02040102, 0x02040102, 0xFF000002, 0x01010402, /* 314 */ |
0x01010402, 0x02040001, 0x02000401, 0xFF000002, 0x02030202, /* 319 */ |
0x02020302, 0x01030102, 0x01030102, 0xFF000001, 0x01010302, /* 324 */ |
0x01030001, 0xFF000001, 0x01000301, 0x01020202, 0xFF000003, /* 329 */ |
0x00000082, 0x0000008B, 0x0000008E, 0x00000091, 0x00000094, /* 334 */ |
0x00000097, 0x030C0E02, 0x030D0D02, 0xFF000003, 0x00000093, /* 339 */ |
0x030E0B02, 0x030B0E02, 0x030F0902, 0x03090F02, 0x030A0E02, /* 344 */ |
0x030D0B02, 0x030B0D02, 0xFF000003, 0x030F0802, 0x03080F02, /* 349 */ |
0x030C0C02, 0x0000008D, 0x030E0802, 0x00000090, 0x02070F02, /* 354 */ |
0x02070F02, 0xFF000003, 0x020A0D02, 0x020A0D02, 0x030D0A02, /* 359 */ |
0x030C0B02, 0x030B0C02, 0x03060F02, 0x020F0602, 0x020F0602, /* 364 */ |
0xFF000002, 0x02080E02, 0x020F0502, 0x020D0902, 0x02090D02, /* 369 */ |
0xFF000002, 0x02050F02, 0x02070E02, 0x020C0A02, 0x020B0B02, /* 374 */ |
0xFF000003, 0x020F0402, 0x020F0402, 0x02040F02, 0x02040F02, /* 379 */ |
0x030A0C02, 0x03060E02, 0x02030F02, 0x02030F02, 0xFF000002, /* 384 */ |
0x010F0302, 0x010F0302, 0x020D0802, 0x02080D02, 0xFF000001, /* 389 */ |
0x010F0202, 0x01020F02, 0xFF000002, 0x020E0602, 0x020C0902, /* 394 */ |
0x010F0001, 0x010F0001, 0xFF000002, 0x02090C02, 0x020E0502, /* 399 */ |
0x010B0A02, 0x010B0A02, 0xFF000002, 0x020D0702, 0x02070D02, /* 404 */ |
0x010E0402, 0x010E0402, 0xFF000002, 0x02080C02, 0x02060D02, /* 409 */ |
0x010E0302, 0x010E0302, 0xFF000002, 0x01090B02, 0x01090B02, /* 414 */ |
0x020B0902, 0x020A0A02, 0xFF000001, 0x010A0B02, 0x01050E02, /* 419 */ |
0xFF000001, 0x01040E02, 0x010C0802, 0xFF000001, 0x010D0602, /* 424 */ |
0x01030E02, 0xFF000001, 0x010E0202, 0x010E0001, 0xFF000001, /* 429 */ |
0x01000E01, 0x010D0502, 0xFF000001, 0x01050D02, 0x010C0702, /* 434 */ |
0xFF000001, 0x01070C02, 0x010D0402, 0xFF000001, 0x010B0802, /* 439 */ |
0x01080B02, 0xFF000001, 0x01040D02, 0x010A0902, 0xFF000001, /* 444 */ |
0x01090A02, 0x010C0602, 0xFF000001, 0x01030D02, 0x010B0702, /* 449 */ |
0xFF000001, 0x010C0502, 0x01050C02, 0xFF000001, 0x01090902, /* 454 */ |
0x010A0702, 0xFF000001, 0x01070A02, 0x01070902, 0xFF000003, /* 459 */ |
0x00000023, 0x030D0F02, 0x020D0E02, 0x020D0E02, 0x010F0F02, /* 464 */ |
0x010F0F02, 0x010F0F02, 0x010F0F02, 0xFF000001, 0x010F0E02, /* 469 */ |
0x010F0D02, 0xFF000001, 0x010E0E02, 0x010F0C02, 0xFF000001, /* 474 */ |
0x010E0D02, 0x010F0B02, 0xFF000001, 0x010B0F02, 0x010E0C02, /* 479 */ |
0xFF000002, 0x010C0D02, 0x010C0D02, 0x020F0A02, 0x02090E02, /* 484 */ |
0xFF000001, 0x010A0F02, 0x010D0C02, 0xFF000001, 0x010E0A02, /* 489 */ |
0x010E0902, 0xFF000001, 0x010F0702, 0x010E0702, 0xFF000001, /* 494 */ |
0x010E0F02, 0x010C0F02,}; |
/* max table bits 6 */ |
/* NO XING TABLE 14 */ |
/* TABLE 15 256 entries maxbits 13 linbits 0 */ |
static HUFF_ELEMENT huff_table_15[] = |
{ |
0xFF000008, 0x00000101, 0x00000122, 0x00000143, 0x00000154, /* 4 */ |
0x00000165, 0x00000176, 0x0000017F, 0x00000188, 0x00000199, /* 9 */ |
0x000001A2, 0x000001AB, 0x000001B4, 0x000001BD, 0x000001C2, /* 14 */ |
0x000001CB, 0x000001D4, 0x000001D9, 0x000001DE, 0x000001E3, /* 19 */ |
0x000001E8, 0x000001ED, 0x000001F2, 0x000001F7, 0x000001FC, /* 24 */ |
0x00000201, 0x00000204, 0x00000207, 0x0000020A, 0x0000020F, /* 29 */ |
0x00000212, 0x00000215, 0x0000021A, 0x0000021D, 0x00000220, /* 34 */ |
0x08010902, 0x00000223, 0x00000226, 0x00000229, 0x0000022C, /* 39 */ |
0x0000022F, 0x08080202, 0x08020802, 0x08080102, 0x08010802, /* 44 */ |
0x00000232, 0x00000235, 0x00000238, 0x0000023B, 0x08070202, /* 49 */ |
0x08020702, 0x08040602, 0x08070102, 0x08050502, 0x08010702, /* 54 */ |
0x0000023E, 0x08060302, 0x08030602, 0x08050402, 0x08040502, /* 59 */ |
0x08060202, 0x08020602, 0x08060102, 0x00000241, 0x08050302, /* 64 */ |
0x07010602, 0x07010602, 0x08030502, 0x08040402, 0x07050202, /* 69 */ |
0x07050202, 0x07020502, 0x07020502, 0x07050102, 0x07050102, /* 74 */ |
0x07010502, 0x07010502, 0x08050001, 0x08000501, 0x07040302, /* 79 */ |
0x07040302, 0x07030402, 0x07030402, 0x07040202, 0x07040202, /* 84 */ |
0x07020402, 0x07020402, 0x07030302, 0x07030302, 0x06010402, /* 89 */ |
0x06010402, 0x06010402, 0x06010402, 0x07040102, 0x07040102, /* 94 */ |
0x07040001, 0x07040001, 0x06030202, 0x06030202, 0x06030202, /* 99 */ |
0x06030202, 0x06020302, 0x06020302, 0x06020302, 0x06020302, /* 104 */ |
0x07000401, 0x07000401, 0x07030001, 0x07030001, 0x06030102, /* 109 */ |
0x06030102, 0x06030102, 0x06030102, 0x06010302, 0x06010302, /* 114 */ |
0x06010302, 0x06010302, 0x06000301, 0x06000301, 0x06000301, /* 119 */ |
0x06000301, 0x05020202, 0x05020202, 0x05020202, 0x05020202, /* 124 */ |
0x05020202, 0x05020202, 0x05020202, 0x05020202, 0x05020102, /* 129 */ |
0x05020102, 0x05020102, 0x05020102, 0x05020102, 0x05020102, /* 134 */ |
0x05020102, 0x05020102, 0x05010202, 0x05010202, 0x05010202, /* 139 */ |
0x05010202, 0x05010202, 0x05010202, 0x05010202, 0x05010202, /* 144 */ |
0x05020001, 0x05020001, 0x05020001, 0x05020001, 0x05020001, /* 149 */ |
0x05020001, 0x05020001, 0x05020001, 0x05000201, 0x05000201, /* 154 */ |
0x05000201, 0x05000201, 0x05000201, 0x05000201, 0x05000201, /* 159 */ |
0x05000201, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 164 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 169 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 174 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 179 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 184 */ |
0x03010102, 0x03010102, 0x03010102, 0x03010102, 0x03010102, /* 189 */ |
0x03010102, 0x03010102, 0x03010102, 0x04010001, 0x04010001, /* 194 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 199 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 204 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04000101, /* 209 */ |
0x04000101, 0x04000101, 0x04000101, 0x04000101, 0x04000101, /* 214 */ |
0x04000101, 0x04000101, 0x04000101, 0x04000101, 0x04000101, /* 219 */ |
0x04000101, 0x04000101, 0x04000101, 0x04000101, 0x04000101, /* 224 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000, /* 229 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000, /* 234 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000, /* 239 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000, /* 244 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000, /* 249 */ |
0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000, /* 254 */ |
0x03000000, 0x03000000, 0xFF000005, 0x050F0F02, 0x050F0E02, /* 259 */ |
0x050E0F02, 0x050F0D02, 0x040E0E02, 0x040E0E02, 0x050D0F02, /* 264 */ |
0x050F0C02, 0x050C0F02, 0x050E0D02, 0x050D0E02, 0x050F0B02, /* 269 */ |
0x040B0F02, 0x040B0F02, 0x050E0C02, 0x050C0E02, 0x040D0D02, /* 274 */ |
0x040D0D02, 0x040F0A02, 0x040F0A02, 0x040A0F02, 0x040A0F02, /* 279 */ |
0x040E0B02, 0x040E0B02, 0x040B0E02, 0x040B0E02, 0x040D0C02, /* 284 */ |
0x040D0C02, 0x040C0D02, 0x040C0D02, 0x040F0902, 0x040F0902, /* 289 */ |
0xFF000005, 0x04090F02, 0x04090F02, 0x040A0E02, 0x040A0E02, /* 294 */ |
0x040D0B02, 0x040D0B02, 0x040B0D02, 0x040B0D02, 0x040F0802, /* 299 */ |
0x040F0802, 0x04080F02, 0x04080F02, 0x040C0C02, 0x040C0C02, /* 304 */ |
0x040E0902, 0x040E0902, 0x04090E02, 0x04090E02, 0x040F0702, /* 309 */ |
0x040F0702, 0x04070F02, 0x04070F02, 0x040D0A02, 0x040D0A02, /* 314 */ |
0x040A0D02, 0x040A0D02, 0x040C0B02, 0x040C0B02, 0x040F0602, /* 319 */ |
0x040F0602, 0x050E0A02, 0x050F0001, 0xFF000004, 0x030B0C02, /* 324 */ |
0x030B0C02, 0x03060F02, 0x03060F02, 0x040E0802, 0x04080E02, /* 329 */ |
0x040F0502, 0x040D0902, 0x03050F02, 0x03050F02, 0x030E0702, /* 334 */ |
0x030E0702, 0x03070E02, 0x03070E02, 0x030C0A02, 0x030C0A02, /* 339 */ |
0xFF000004, 0x030A0C02, 0x030A0C02, 0x030B0B02, 0x030B0B02, /* 344 */ |
0x04090D02, 0x040D0802, 0x030F0402, 0x030F0402, 0x03040F02, /* 349 */ |
0x03040F02, 0x030F0302, 0x030F0302, 0x03030F02, 0x03030F02, /* 354 */ |
0x03080D02, 0x03080D02, 0xFF000004, 0x03060E02, 0x03060E02, /* 359 */ |
0x030F0202, 0x030F0202, 0x03020F02, 0x03020F02, 0x040E0602, /* 364 */ |
0x04000F01, 0x030F0102, 0x030F0102, 0x03010F02, 0x03010F02, /* 369 */ |
0x030C0902, 0x030C0902, 0x03090C02, 0x03090C02, 0xFF000003, /* 374 */ |
0x030E0502, 0x030B0A02, 0x030A0B02, 0x03050E02, 0x030D0702, /* 379 */ |
0x03070D02, 0x030E0402, 0x03040E02, 0xFF000003, 0x030C0802, /* 384 */ |
0x03080C02, 0x030E0302, 0x030D0602, 0x03060D02, 0x03030E02, /* 389 */ |
0x030B0902, 0x03090B02, 0xFF000004, 0x030E0202, 0x030E0202, /* 394 */ |
0x030A0A02, 0x030A0A02, 0x03020E02, 0x03020E02, 0x030E0102, /* 399 */ |
0x030E0102, 0x03010E02, 0x03010E02, 0x040E0001, 0x04000E01, /* 404 */ |
0x030D0502, 0x030D0502, 0x03050D02, 0x03050D02, 0xFF000003, /* 409 */ |
0x030C0702, 0x03070C02, 0x030D0402, 0x030B0802, 0x02040D02, /* 414 */ |
0x02040D02, 0x03080B02, 0x030A0902, 0xFF000003, 0x03090A02, /* 419 */ |
0x030C0602, 0x03060C02, 0x030D0302, 0x02030D02, 0x02030D02, /* 424 */ |
0x02020D02, 0x02020D02, 0xFF000003, 0x030D0202, 0x030D0001, /* 429 */ |
0x020D0102, 0x020D0102, 0x020B0702, 0x020B0702, 0x02070B02, /* 434 */ |
0x02070B02, 0xFF000003, 0x02010D02, 0x02010D02, 0x030C0502, /* 439 */ |
0x03000D01, 0x02050C02, 0x02050C02, 0x020A0802, 0x020A0802, /* 444 */ |
0xFF000002, 0x02080A02, 0x020C0402, 0x02040C02, 0x020B0602, /* 449 */ |
0xFF000003, 0x02060B02, 0x02060B02, 0x03090902, 0x030C0001, /* 454 */ |
0x020C0302, 0x020C0302, 0x02030C02, 0x02030C02, 0xFF000003, /* 459 */ |
0x020A0702, 0x020A0702, 0x02070A02, 0x02070A02, 0x02060A02, /* 464 */ |
0x02060A02, 0x03000C01, 0x030B0001, 0xFF000002, 0x01020C02, /* 469 */ |
0x01020C02, 0x020C0202, 0x020B0502, 0xFF000002, 0x02050B02, /* 474 */ |
0x020C0102, 0x02090802, 0x02080902, 0xFF000002, 0x02010C02, /* 479 */ |
0x020B0402, 0x02040B02, 0x020A0602, 0xFF000002, 0x020B0302, /* 484 */ |
0x02090702, 0x01030B02, 0x01030B02, 0xFF000002, 0x02070902, /* 489 */ |
0x02080802, 0x020B0202, 0x020A0502, 0xFF000002, 0x01020B02, /* 494 */ |
0x01020B02, 0x02050A02, 0x020B0102, 0xFF000002, 0x01010B02, /* 499 */ |
0x01010B02, 0x02000B01, 0x02090602, 0xFF000002, 0x02060902, /* 504 */ |
0x020A0402, 0x02040A02, 0x02080702, 0xFF000002, 0x02070802, /* 509 */ |
0x020A0302, 0x01030A02, 0x01030A02, 0xFF000001, 0x01090502, /* 514 */ |
0x01050902, 0xFF000001, 0x010A0202, 0x01020A02, 0xFF000001, /* 519 */ |
0x010A0102, 0x01010A02, 0xFF000002, 0x020A0001, 0x02000A01, /* 524 */ |
0x01080602, 0x01080602, 0xFF000001, 0x01060802, 0x01090402, /* 529 */ |
0xFF000001, 0x01040902, 0x01090302, 0xFF000002, 0x01030902, /* 534 */ |
0x01030902, 0x02070702, 0x02090001, 0xFF000001, 0x01080502, /* 539 */ |
0x01050802, 0xFF000001, 0x01090202, 0x01070602, 0xFF000001, /* 544 */ |
0x01060702, 0x01020902, 0xFF000001, 0x01090102, 0x01000901, /* 549 */ |
0xFF000001, 0x01080402, 0x01040802, 0xFF000001, 0x01070502, /* 554 */ |
0x01050702, 0xFF000001, 0x01080302, 0x01030802, 0xFF000001, /* 559 */ |
0x01060602, 0x01070402, 0xFF000001, 0x01040702, 0x01080001, /* 564 */ |
0xFF000001, 0x01000801, 0x01060502, 0xFF000001, 0x01050602, /* 569 */ |
0x01070302, 0xFF000001, 0x01030702, 0x01060402, 0xFF000001, /* 574 */ |
0x01070001, 0x01000701, 0xFF000001, 0x01060001, 0x01000601, /* 579 */ }; |
/* max table bits 8 */ |
/* TABLE 16 256 entries maxbits 17 linbits 0 */ |
static HUFF_ELEMENT huff_table_16[] = |
{ |
0xFF000008, 0x00000101, 0x0000010A, 0x00000113, 0x080F0F02, /* 4 */ |
0x00000118, 0x0000011D, 0x00000120, 0x08020F02, 0x00000131, /* 9 */ |
0x080F0102, 0x08010F02, 0x00000134, 0x00000145, 0x00000156, /* 14 */ |
0x00000167, 0x00000178, 0x00000189, 0x0000019A, 0x000001A3, /* 19 */ |
0x000001AC, 0x000001B5, 0x000001BE, 0x000001C7, 0x000001D0, /* 24 */ |
0x000001D9, 0x000001DE, 0x000001E3, 0x000001E6, 0x000001EB, /* 29 */ |
0x000001F0, 0x08010502, 0x000001F3, 0x000001F6, 0x000001F9, /* 34 */ |
0x000001FC, 0x08040102, 0x08010402, 0x000001FF, 0x08030202, /* 39 */ |
0x08020302, 0x07030102, 0x07030102, 0x07010302, 0x07010302, /* 44 */ |
0x08030001, 0x08000301, 0x07020202, 0x07020202, 0x06020102, /* 49 */ |
0x06020102, 0x06020102, 0x06020102, 0x06010202, 0x06010202, /* 54 */ |
0x06010202, 0x06010202, 0x06020001, 0x06020001, 0x06020001, /* 59 */ |
0x06020001, 0x06000201, 0x06000201, 0x06000201, 0x06000201, /* 64 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 69 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 74 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 79 */ |
0x04010102, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 84 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 89 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 94 */ |
0x04010001, 0x04010001, 0x03000101, 0x03000101, 0x03000101, /* 99 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 104 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 109 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 114 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 119 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x03000101, /* 124 */ |
0x03000101, 0x03000101, 0x03000101, 0x03000101, 0x01000000, /* 129 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 134 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 139 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 144 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 149 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 154 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 159 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 164 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 169 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 174 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 179 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 184 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 189 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 194 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 199 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 204 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 209 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 214 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 219 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 224 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 229 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 234 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 239 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 244 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 249 */ |
0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000, /* 254 */ |
0x01000000, 0x01000000, 0xFF000003, 0x030F0E02, 0x030E0F02, /* 259 */ |
0x030F0D02, 0x030D0F02, 0x030F0C02, 0x030C0F02, 0x030F0B02, /* 264 */ |
0x030B0F02, 0xFF000003, 0x020F0A02, 0x020F0A02, 0x030A0F02, /* 269 */ |
0x030F0902, 0x03090F02, 0x03080F02, 0x020F0802, 0x020F0802, /* 274 */ |
0xFF000002, 0x020F0702, 0x02070F02, 0x020F0602, 0x02060F02, /* 279 */ |
0xFF000002, 0x020F0502, 0x02050F02, 0x010F0402, 0x010F0402, /* 284 */ |
0xFF000001, 0x01040F02, 0x01030F02, 0xFF000004, 0x01000F01, /* 289 */ |
0x01000F01, 0x01000F01, 0x01000F01, 0x01000F01, 0x01000F01, /* 294 */ |
0x01000F01, 0x01000F01, 0x020F0302, 0x020F0302, 0x020F0302, /* 299 */ |
0x020F0302, 0x000000E2, 0x000000F3, 0x000000FC, 0x00000105, /* 304 */ |
0xFF000001, 0x010F0202, 0x010F0001, 0xFF000004, 0x000000FA, /* 309 */ |
0x000000FF, 0x00000104, 0x00000109, 0x0000010C, 0x00000111, /* 314 */ |
0x00000116, 0x00000119, 0x0000011E, 0x00000123, 0x00000128, /* 319 */ |
0x04030E02, 0x0000012D, 0x00000130, 0x00000133, 0x00000136, /* 324 */ |
0xFF000004, 0x00000128, 0x0000012B, 0x0000012E, 0x040D0001, /* 329 */ |
0x00000131, 0x00000134, 0x00000137, 0x040C0302, 0x0000013A, /* 334 */ |
0x040C0102, 0x04000C01, 0x0000013D, 0x03020E02, 0x03020E02, /* 339 */ |
0x040E0202, 0x040E0102, 0xFF000004, 0x04030D02, 0x040D0202, /* 344 */ |
0x04020D02, 0x04010D02, 0x040B0302, 0x0000012F, 0x030D0102, /* 349 */ |
0x030D0102, 0x04040C02, 0x040B0602, 0x04030C02, 0x04070A02, /* 354 */ |
0x030C0202, 0x030C0202, 0x04020C02, 0x04050B02, 0xFF000004, /* 359 */ |
0x04010C02, 0x040C0001, 0x040B0402, 0x04040B02, 0x040A0602, /* 364 */ |
0x04060A02, 0x03030B02, 0x03030B02, 0x040A0502, 0x04050A02, /* 369 */ |
0x030B0202, 0x030B0202, 0x03020B02, 0x03020B02, 0x030B0102, /* 374 */ |
0x030B0102, 0xFF000004, 0x03010B02, 0x03010B02, 0x040B0001, /* 379 */ |
0x04000B01, 0x04090602, 0x04060902, 0x040A0402, 0x04040A02, /* 384 */ |
0x04080702, 0x04070802, 0x03030A02, 0x03030A02, 0x040A0302, /* 389 */ |
0x04090502, 0x030A0202, 0x030A0202, 0xFF000004, 0x04050902, /* 394 */ |
0x04080602, 0x03010A02, 0x03010A02, 0x04060802, 0x04070702, /* 399 */ |
0x03040902, 0x03040902, 0x04090402, 0x04070502, 0x03070602, /* 404 */ |
0x03070602, 0x02020A02, 0x02020A02, 0x02020A02, 0x02020A02, /* 409 */ |
0xFF000003, 0x020A0102, 0x020A0102, 0x030A0001, 0x03000A01, /* 414 */ |
0x03090302, 0x03030902, 0x03080502, 0x03050802, 0xFF000003, /* 419 */ |
0x02090202, 0x02090202, 0x02020902, 0x02020902, 0x03060702, /* 424 */ |
0x03090001, 0x02090102, 0x02090102, 0xFF000003, 0x02010902, /* 429 */ |
0x02010902, 0x03000901, 0x03080402, 0x03040802, 0x03050702, /* 434 */ |
0x03080302, 0x03030802, 0xFF000003, 0x03060602, 0x03080202, /* 439 */ |
0x02020802, 0x02020802, 0x03070402, 0x03040702, 0x02080102, /* 444 */ |
0x02080102, 0xFF000003, 0x02010802, 0x02010802, 0x02000801, /* 449 */ |
0x02000801, 0x03080001, 0x03060502, 0x02070302, 0x02070302, /* 454 */ |
0xFF000003, 0x02030702, 0x02030702, 0x03050602, 0x03060402, /* 459 */ |
0x02070202, 0x02070202, 0x02020702, 0x02020702, 0xFF000003, /* 464 */ |
0x03040602, 0x03050502, 0x02070001, 0x02070001, 0x01070102, /* 469 */ |
0x01070102, 0x01070102, 0x01070102, 0xFF000002, 0x01010702, /* 474 */ |
0x01010702, 0x02000701, 0x02060302, 0xFF000002, 0x02030602, /* 479 */ |
0x02050402, 0x02040502, 0x02060202, 0xFF000001, 0x01020602, /* 484 */ |
0x01060102, 0xFF000002, 0x01010602, 0x01010602, 0x02060001, /* 489 */ |
0x02000601, 0xFF000002, 0x01030502, 0x01030502, 0x02050302, /* 494 */ |
0x02040402, 0xFF000001, 0x01050202, 0x01020502, 0xFF000001, /* 499 */ |
0x01050102, 0x01050001, 0xFF000001, 0x01040302, 0x01030402, /* 504 */ |
0xFF000001, 0x01000501, 0x01040202, 0xFF000001, 0x01020402, /* 509 */ |
0x01030302, 0xFF000001, 0x01040001, 0x01000401, 0xFF000004, /* 514 */ |
0x040E0C02, 0x00000086, 0x030E0D02, 0x030E0D02, 0x03090E02, /* 519 */ |
0x03090E02, 0x040A0E02, 0x04090D02, 0x020E0E02, 0x020E0E02, /* 524 */ |
0x020E0E02, 0x020E0E02, 0x030D0E02, 0x030D0E02, 0x030B0E02, /* 529 */ |
0x030B0E02, 0xFF000003, 0x020E0B02, 0x020E0B02, 0x020D0C02, /* 534 */ |
0x020D0C02, 0x030C0D02, 0x030B0D02, 0x020E0A02, 0x020E0A02, /* 539 */ |
0xFF000003, 0x020C0C02, 0x020C0C02, 0x030D0A02, 0x030A0D02, /* 544 */ |
0x030E0702, 0x030C0A02, 0x020A0C02, 0x020A0C02, 0xFF000003, /* 549 */ |
0x03090C02, 0x030D0702, 0x020E0502, 0x020E0502, 0x010D0B02, /* 554 */ |
0x010D0B02, 0x010D0B02, 0x010D0B02, 0xFF000002, 0x010E0902, /* 559 */ |
0x010E0902, 0x020C0B02, 0x020B0C02, 0xFF000002, 0x020E0802, /* 564 */ |
0x02080E02, 0x020D0902, 0x02070E02, 0xFF000002, 0x020B0B02, /* 569 */ |
0x020D0802, 0x02080D02, 0x020E0602, 0xFF000001, 0x01060E02, /* 574 */ |
0x010C0902, 0xFF000002, 0x020B0A02, 0x020A0B02, 0x02050E02, /* 579 */ |
0x02070D02, 0xFF000002, 0x010E0402, 0x010E0402, 0x02040E02, /* 584 */ |
0x020C0802, 0xFF000001, 0x01080C02, 0x010E0302, 0xFF000002, /* 589 */ |
0x010D0602, 0x010D0602, 0x02060D02, 0x020B0902, 0xFF000002, /* 594 */ |
0x02090B02, 0x020A0A02, 0x01010E02, 0x01010E02, 0xFF000002, /* 599 */ |
0x01040D02, 0x01040D02, 0x02080B02, 0x02090A02, 0xFF000002, /* 604 */ |
0x010B0702, 0x010B0702, 0x02070B02, 0x02000D01, 0xFF000001, /* 609 */ |
0x010E0001, 0x01000E01, 0xFF000001, 0x010D0502, 0x01050D02, /* 614 */ |
0xFF000001, 0x010C0702, 0x01070C02, 0xFF000001, 0x010D0402, /* 619 */ |
0x010B0802, 0xFF000001, 0x010A0902, 0x010C0602, 0xFF000001, /* 624 */ |
0x01060C02, 0x010D0302, 0xFF000001, 0x010C0502, 0x01050C02, /* 629 */ |
0xFF000001, 0x010A0802, 0x01080A02, 0xFF000001, 0x01090902, /* 634 */ |
0x010C0402, 0xFF000001, 0x01060B02, 0x010A0702, 0xFF000001, /* 639 */ |
0x010B0502, 0x01090802, 0xFF000001, 0x01080902, 0x01090702, /* 644 */ |
0xFF000001, 0x01070902, 0x01080802, 0xFF000001, 0x010C0E02, /* 649 */ |
0x010D0D02,}; |
/* max table bits 8 */ |
/* NO XING TABLE 17 */ |
/* NO XING TABLE 18 */ |
/* NO XING TABLE 19 */ |
/* NO XING TABLE 20 */ |
/* NO XING TABLE 21 */ |
/* NO XING TABLE 22 */ |
/* NO XING TABLE 23 */ |
/* TABLE 24 256 entries maxbits 12 linbits 0 */ |
static HUFF_ELEMENT huff_table_24[] = |
{ |
0xFF000009, 0x080F0E02, 0x080F0E02, 0x080E0F02, 0x080E0F02, /* 4 */ |
0x080F0D02, 0x080F0D02, 0x080D0F02, 0x080D0F02, 0x080F0C02, /* 9 */ |
0x080F0C02, 0x080C0F02, 0x080C0F02, 0x080F0B02, 0x080F0B02, /* 14 */ |
0x080B0F02, 0x080B0F02, 0x070A0F02, 0x070A0F02, 0x070A0F02, /* 19 */ |
0x070A0F02, 0x080F0A02, 0x080F0A02, 0x080F0902, 0x080F0902, /* 24 */ |
0x07090F02, 0x07090F02, 0x07090F02, 0x07090F02, 0x07080F02, /* 29 */ |
0x07080F02, 0x07080F02, 0x07080F02, 0x080F0802, 0x080F0802, /* 34 */ |
0x080F0702, 0x080F0702, 0x07070F02, 0x07070F02, 0x07070F02, /* 39 */ |
0x07070F02, 0x070F0602, 0x070F0602, 0x070F0602, 0x070F0602, /* 44 */ |
0x07060F02, 0x07060F02, 0x07060F02, 0x07060F02, 0x070F0502, /* 49 */ |
0x070F0502, 0x070F0502, 0x070F0502, 0x07050F02, 0x07050F02, /* 54 */ |
0x07050F02, 0x07050F02, 0x070F0402, 0x070F0402, 0x070F0402, /* 59 */ |
0x070F0402, 0x07040F02, 0x07040F02, 0x07040F02, 0x07040F02, /* 64 */ |
0x070F0302, 0x070F0302, 0x070F0302, 0x070F0302, 0x07030F02, /* 69 */ |
0x07030F02, 0x07030F02, 0x07030F02, 0x070F0202, 0x070F0202, /* 74 */ |
0x070F0202, 0x070F0202, 0x07020F02, 0x07020F02, 0x07020F02, /* 79 */ |
0x07020F02, 0x07010F02, 0x07010F02, 0x07010F02, 0x07010F02, /* 84 */ |
0x080F0102, 0x080F0102, 0x08000F01, 0x08000F01, 0x090F0001, /* 89 */ |
0x00000201, 0x00000206, 0x0000020B, 0x00000210, 0x00000215, /* 94 */ |
0x0000021A, 0x0000021F, 0x040F0F02, 0x040F0F02, 0x040F0F02, /* 99 */ |
0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, /* 104 */ |
0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, /* 109 */ |
0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, /* 114 */ |
0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, /* 119 */ |
0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, /* 124 */ |
0x040F0F02, 0x040F0F02, 0x040F0F02, 0x040F0F02, 0x00000224, /* 129 */ |
0x00000229, 0x00000232, 0x00000237, 0x0000023A, 0x0000023F, /* 134 */ |
0x00000242, 0x00000245, 0x0000024A, 0x0000024D, 0x00000250, /* 139 */ |
0x00000253, 0x00000256, 0x00000259, 0x0000025C, 0x0000025F, /* 144 */ |
0x00000262, 0x00000265, 0x00000268, 0x0000026B, 0x0000026E, /* 149 */ |
0x00000271, 0x00000274, 0x00000277, 0x0000027A, 0x0000027D, /* 154 */ |
0x00000280, 0x00000283, 0x00000288, 0x0000028B, 0x0000028E, /* 159 */ |
0x00000291, 0x00000294, 0x00000297, 0x0000029A, 0x0000029F, /* 164 */ |
0x09040B02, 0x000002A4, 0x000002A7, 0x000002AA, 0x09030B02, /* 169 */ |
0x09080802, 0x000002AF, 0x09020B02, 0x000002B2, 0x000002B5, /* 174 */ |
0x09060902, 0x09040A02, 0x000002B8, 0x09070802, 0x090A0302, /* 179 */ |
0x09030A02, 0x09090502, 0x09050902, 0x090A0202, 0x09020A02, /* 184 */ |
0x09010A02, 0x09080602, 0x09060802, 0x09070702, 0x09090402, /* 189 */ |
0x09040902, 0x09090302, 0x09030902, 0x09080502, 0x09050802, /* 194 */ |
0x09090202, 0x09070602, 0x09060702, 0x09020902, 0x09090102, /* 199 */ |
0x09010902, 0x09080402, 0x09040802, 0x09070502, 0x09050702, /* 204 */ |
0x09080302, 0x09030802, 0x09060602, 0x09080202, 0x09020802, /* 209 */ |
0x09080102, 0x09070402, 0x09040702, 0x09010802, 0x000002BB, /* 214 */ |
0x09060502, 0x09050602, 0x09070102, 0x000002BE, 0x08030702, /* 219 */ |
0x08030702, 0x09070302, 0x09070202, 0x08020702, 0x08020702, /* 224 */ |
0x08060402, 0x08060402, 0x08040602, 0x08040602, 0x08050502, /* 229 */ |
0x08050502, 0x08010702, 0x08010702, 0x08060302, 0x08060302, /* 234 */ |
0x08030602, 0x08030602, 0x08050402, 0x08050402, 0x08040502, /* 239 */ |
0x08040502, 0x08060202, 0x08060202, 0x08020602, 0x08020602, /* 244 */ |
0x08060102, 0x08060102, 0x08010602, 0x08010602, 0x09060001, /* 249 */ |
0x09000601, 0x08050302, 0x08050302, 0x08030502, 0x08030502, /* 254 */ |
0x08040402, 0x08040402, 0x08050202, 0x08050202, 0x08020502, /* 259 */ |
0x08020502, 0x08050102, 0x08050102, 0x09050001, 0x09000501, /* 264 */ |
0x07010502, 0x07010502, 0x07010502, 0x07010502, 0x08040302, /* 269 */ |
0x08040302, 0x08030402, 0x08030402, 0x07040202, 0x07040202, /* 274 */ |
0x07040202, 0x07040202, 0x07020402, 0x07020402, 0x07020402, /* 279 */ |
0x07020402, 0x07030302, 0x07030302, 0x07030302, 0x07030302, /* 284 */ |
0x07040102, 0x07040102, 0x07040102, 0x07040102, 0x07010402, /* 289 */ |
0x07010402, 0x07010402, 0x07010402, 0x08040001, 0x08040001, /* 294 */ |
0x08000401, 0x08000401, 0x07030202, 0x07030202, 0x07030202, /* 299 */ |
0x07030202, 0x07020302, 0x07020302, 0x07020302, 0x07020302, /* 304 */ |
0x06030102, 0x06030102, 0x06030102, 0x06030102, 0x06030102, /* 309 */ |
0x06030102, 0x06030102, 0x06030102, 0x06010302, 0x06010302, /* 314 */ |
0x06010302, 0x06010302, 0x06010302, 0x06010302, 0x06010302, /* 319 */ |
0x06010302, 0x07030001, 0x07030001, 0x07030001, 0x07030001, /* 324 */ |
0x07000301, 0x07000301, 0x07000301, 0x07000301, 0x06020202, /* 329 */ |
0x06020202, 0x06020202, 0x06020202, 0x06020202, 0x06020202, /* 334 */ |
0x06020202, 0x06020202, 0x05020102, 0x05020102, 0x05020102, /* 339 */ |
0x05020102, 0x05020102, 0x05020102, 0x05020102, 0x05020102, /* 344 */ |
0x05020102, 0x05020102, 0x05020102, 0x05020102, 0x05020102, /* 349 */ |
0x05020102, 0x05020102, 0x05020102, 0x05010202, 0x05010202, /* 354 */ |
0x05010202, 0x05010202, 0x05010202, 0x05010202, 0x05010202, /* 359 */ |
0x05010202, 0x05010202, 0x05010202, 0x05010202, 0x05010202, /* 364 */ |
0x05010202, 0x05010202, 0x05010202, 0x05010202, 0x06020001, /* 369 */ |
0x06020001, 0x06020001, 0x06020001, 0x06020001, 0x06020001, /* 374 */ |
0x06020001, 0x06020001, 0x06000201, 0x06000201, 0x06000201, /* 379 */ |
0x06000201, 0x06000201, 0x06000201, 0x06000201, 0x06000201, /* 384 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 389 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 394 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 399 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 404 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 409 */ |
0x04010102, 0x04010102, 0x04010102, 0x04010102, 0x04010102, /* 414 */ |
0x04010102, 0x04010102, 0x04010001, 0x04010001, 0x04010001, /* 419 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 424 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 429 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 434 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 439 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04010001, /* 444 */ |
0x04010001, 0x04010001, 0x04010001, 0x04010001, 0x04000101, /* 449 */ |
0x04000101, 0x04000101, 0x04000101, 0x04000101, 0x04000101, /* 454 */ |
0x04000101, 0x04000101, 0x04000101, 0x04000101, 0x04000101, /* 459 */ |
0x04000101, 0x04000101, 0x04000101, 0x04000101, 0x04000101, /* 464 */ |
0x04000101, 0x04000101, 0x04000101, 0x04000101, 0x04000101, /* 469 */ |
0x04000101, 0x04000101, 0x04000101, 0x04000101, 0x04000101, /* 474 */ |
0x04000101, 0x04000101, 0x04000101, 0x04000101, 0x04000101, /* 479 */ |
0x04000101, 0x04000000, 0x04000000, 0x04000000, 0x04000000, /* 484 */ |
0x04000000, 0x04000000, 0x04000000, 0x04000000, 0x04000000, /* 489 */ |
0x04000000, 0x04000000, 0x04000000, 0x04000000, 0x04000000, /* 494 */ |
0x04000000, 0x04000000, 0x04000000, 0x04000000, 0x04000000, /* 499 */ |
0x04000000, 0x04000000, 0x04000000, 0x04000000, 0x04000000, /* 504 */ |
0x04000000, 0x04000000, 0x04000000, 0x04000000, 0x04000000, /* 509 */ |
0x04000000, 0x04000000, 0x04000000, 0xFF000002, 0x020E0E02, /* 514 */ |
0x020E0D02, 0x020D0E02, 0x020E0C02, 0xFF000002, 0x020C0E02, /* 519 */ |
0x020D0D02, 0x020E0B02, 0x020B0E02, 0xFF000002, 0x020D0C02, /* 524 */ |
0x020C0D02, 0x020E0A02, 0x020A0E02, 0xFF000002, 0x020D0B02, /* 529 */ |
0x020B0D02, 0x020C0C02, 0x020E0902, 0xFF000002, 0x02090E02, /* 534 */ |
0x020D0A02, 0x020A0D02, 0x020C0B02, 0xFF000002, 0x020B0C02, /* 539 */ |
0x020E0802, 0x02080E02, 0x020D0902, 0xFF000002, 0x02090D02, /* 544 */ |
0x020E0702, 0x02070E02, 0x020C0A02, 0xFF000002, 0x020A0C02, /* 549 */ |
0x020B0B02, 0x020D0802, 0x02080D02, 0xFF000003, 0x030E0001, /* 554 */ |
0x03000E01, 0x020D0001, 0x020D0001, 0x01060E02, 0x01060E02, /* 559 */ |
0x01060E02, 0x01060E02, 0xFF000002, 0x020E0602, 0x020C0902, /* 564 */ |
0x01090C02, 0x01090C02, 0xFF000001, 0x010E0502, 0x010A0B02, /* 569 */ |
0xFF000002, 0x01050E02, 0x01050E02, 0x020B0A02, 0x020D0702, /* 574 */ |
0xFF000001, 0x01070D02, 0x01040E02, 0xFF000001, 0x010C0802, /* 579 */ |
0x01080C02, 0xFF000002, 0x020E0402, 0x020E0202, 0x010E0302, /* 584 */ |
0x010E0302, 0xFF000001, 0x010D0602, 0x01060D02, 0xFF000001, /* 589 */ |
0x01030E02, 0x010B0902, 0xFF000001, 0x01090B02, 0x010A0A02, /* 594 */ |
0xFF000001, 0x01020E02, 0x010E0102, 0xFF000001, 0x01010E02, /* 599 */ |
0x010D0502, 0xFF000001, 0x01050D02, 0x010C0702, 0xFF000001, /* 604 */ |
0x01070C02, 0x010D0402, 0xFF000001, 0x010B0802, 0x01080B02, /* 609 */ |
0xFF000001, 0x01040D02, 0x010A0902, 0xFF000001, 0x01090A02, /* 614 */ |
0x010C0602, 0xFF000001, 0x01060C02, 0x010D0302, 0xFF000001, /* 619 */ |
0x01030D02, 0x010D0202, 0xFF000001, 0x01020D02, 0x010D0102, /* 624 */ |
0xFF000001, 0x010B0702, 0x01070B02, 0xFF000001, 0x01010D02, /* 629 */ |
0x010C0502, 0xFF000001, 0x01050C02, 0x010A0802, 0xFF000001, /* 634 */ |
0x01080A02, 0x01090902, 0xFF000001, 0x010C0402, 0x01040C02, /* 639 */ |
0xFF000001, 0x010B0602, 0x01060B02, 0xFF000002, 0x02000D01, /* 644 */ |
0x020C0001, 0x010C0302, 0x010C0302, 0xFF000001, 0x01030C02, /* 649 */ |
0x010A0702, 0xFF000001, 0x01070A02, 0x010C0202, 0xFF000001, /* 654 */ |
0x01020C02, 0x010B0502, 0xFF000001, 0x01050B02, 0x010C0102, /* 659 */ |
0xFF000001, 0x01090802, 0x01080902, 0xFF000001, 0x01010C02, /* 664 */ |
0x010B0402, 0xFF000002, 0x02000C01, 0x020B0001, 0x010B0302, /* 669 */ |
0x010B0302, 0xFF000002, 0x02000B01, 0x020A0001, 0x010A0102, /* 674 */ |
0x010A0102, 0xFF000001, 0x010A0602, 0x01060A02, 0xFF000001, /* 679 */ |
0x01090702, 0x01070902, 0xFF000002, 0x02000A01, 0x02090001, /* 684 */ |
0x01000901, 0x01000901, 0xFF000001, 0x010B0202, 0x010A0502, /* 689 */ |
0xFF000001, 0x01050A02, 0x010B0102, 0xFF000001, 0x01010B02, /* 694 */ |
0x01090602, 0xFF000001, 0x010A0402, 0x01080702, 0xFF000001, /* 699 */ |
0x01080001, 0x01000801, 0xFF000001, 0x01070001, 0x01000701, /* 704 */ }; |
/* max table bits 9 */ |
/* NO XING TABLE 25 */ |
/* NO XING TABLE 26 */ |
/* NO XING TABLE 27 */ |
/* NO XING TABLE 28 */ |
/* NO XING TABLE 29 */ |
/* NO XING TABLE 30 */ |
/* NO XING TABLE 31 */ |
/* done */ |
/programs/media/ac97 mp3/trunk/mp3dec/l3hybrid.c |
---|
0,0 → 1,265 |
#include <math.h> |
extern int m_band_limit; |
/* "imdct.c" */ |
void imdct18(float f[]); /* 18 point */ |
void imdct6_3(float f[]); /* 6 point */ |
/*-- windows by block type --*/ |
static float win[4][36]; |
void hwin_init() |
{ |
int i, j; |
double pi; |
pi = 4.0 * atan(1.0); |
/* type 0 */ |
for (i = 0; i < 36; i++) |
win[0][i] = (float) sin(pi / 36 * (i + 0.5)); |
/* type 1 */ |
for (i = 0; i < 18; i++) |
win[1][i] = (float) sin(pi / 36 * (i + 0.5)); |
for (i = 18; i < 24; i++) |
win[1][i] = 1.0F; |
for (i = 24; i < 30; i++) |
win[1][i] = (float) sin(pi / 12 * (i + 0.5 - 18)); |
for (i = 30; i < 36; i++) |
win[1][i] = 0.0F; |
/* type 3 */ |
for (i = 0; i < 6; i++) |
win[3][i] = 0.0F; |
for (i = 6; i < 12; i++) |
win[3][i] = (float) sin(pi / 12 * (i + 0.5 - 6)); |
for (i = 12; i < 18; i++) |
win[3][i] = 1.0F; |
for (i = 18; i < 36; i++) |
win[3][i] = (float) sin(pi / 36 * (i + 0.5)); |
/* type 2 */ |
for (i = 0; i < 12; i++) |
win[2][i] = (float) sin(pi / 12 * (i + 0.5)); |
for (i = 12; i < 36; i++) |
win[2][i] = 0.0F; |
/*--- invert signs by region to match mdct 18pt --> 36pt mapping */ |
for (j = 0; j < 4; j++) |
{ |
if (j == 2) |
continue; |
for (i = 9; i < 36; i++) |
win[j][i] = -win[j][i]; |
} |
/*-- invert signs for short blocks --*/ |
for (i = 3; i < 12; i++) |
win[2][i] = -win[2][i]; |
return; |
} |
/*====================================================================*/ |
int hybrid(float xin[], float xprev[], float y[18][32], |
int btype, int nlong, int ntot, int nprev) |
{ |
int i, j; |
float *x, *x0; |
float xa, xb; |
int n; |
int nout; |
int band_limit_nsb; |
if (btype == 2) |
btype = 0; |
x = xin; |
x0 = xprev; |
/*-- do long blocks (if any) --*/ |
n = (nlong + 17) / 18; /* number of dct's to do */ |
for (i = 0; i < n; i++) |
{ |
imdct18(x); |
for (j = 0; j < 9; j++) |
{ |
y[j][i] = x0[j] + win[btype][j] * x[9 + j]; |
y[9 + j][i] = x0[9 + j] + win[btype][9 + j] * x[17 - j]; |
} |
/* window x for next time x0 */ |
for (j = 0; j < 4; j++) |
{ |
xa = x[j]; |
xb = x[8 - j]; |
x[j] = win[btype][18 + j] * xb; |
x[8 - j] = win[btype][(18 + 8) - j] * xa; |
x[9 + j] = win[btype][(18 + 9) + j] * xa; |
x[17 - j] = win[btype][(18 + 17) - j] * xb; |
} |
xa = x[j]; |
x[j] = win[btype][18 + j] * xa; |
x[9 + j] = win[btype][(18 + 9) + j] * xa; |
x += 18; |
x0 += 18; |
} |
/*-- do short blocks (if any) --*/ |
n = (ntot + 17) / 18; /* number of 6 pt dct's triples to do */ |
for (; i < n; i++) |
{ |
imdct6_3(x); |
for (j = 0; j < 3; j++) |
{ |
y[j][i] = x0[j]; |
y[3 + j][i] = x0[3 + j]; |
y[6 + j][i] = x0[6 + j] + win[2][j] * x[3 + j]; |
y[9 + j][i] = x0[9 + j] + win[2][3 + j] * x[5 - j]; |
y[12 + j][i] = x0[12 + j] + win[2][6 + j] * x[2 - j] + win[2][j] * x[(6 + 3) + j]; |
y[15 + j][i] = x0[15 + j] + win[2][9 + j] * x[j] + win[2][3 + j] * x[(6 + 5) - j]; |
} |
/* window x for next time x0 */ |
for (j = 0; j < 3; j++) |
{ |
x[j] = win[2][6 + j] * x[(6 + 2) - j] + win[2][j] * x[(12 + 3) + j]; |
x[3 + j] = win[2][9 + j] * x[6 + j] + win[2][3 + j] * x[(12 + 5) - j]; |
} |
for (j = 0; j < 3; j++) |
{ |
x[6 + j] = win[2][6 + j] * x[(12 + 2) - j]; |
x[9 + j] = win[2][9 + j] * x[12 + j]; |
} |
for (j = 0; j < 3; j++) |
{ |
x[12 + j] = 0.0f; |
x[15 + j] = 0.0f; |
} |
x += 18; |
x0 += 18; |
} |
/*--- overlap prev if prev longer that current --*/ |
n = (nprev + 17) / 18; |
for (; i < n; i++) |
{ |
for (j = 0; j < 18; j++) |
y[j][i] = x0[j]; |
x0 += 18; |
} |
nout = 18 * i; |
/*--- clear remaining only to band limit --*/ |
band_limit_nsb = (m_band_limit + 17) / 18; /* limit nsb's rounded up */ |
for (; i < band_limit_nsb; i++) |
{ |
for (j = 0; j < 18; j++) |
y[j][i] = 0.0f; |
} |
return nout; |
} |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
/*-- convert to mono, add curr result to y, |
window and add next time to current left */ |
int hybrid_sum(float xin[], float xin_left[], float y[18][32], |
int btype, int nlong, int ntot) |
{ |
int i, j; |
float *x, *x0; |
float xa, xb; |
int n; |
int nout; |
if (btype == 2) |
btype = 0; |
x = xin; |
x0 = xin_left; |
/*-- do long blocks (if any) --*/ |
n = (nlong + 17) / 18; /* number of dct's to do */ |
for (i = 0; i < n; i++) |
{ |
imdct18(x); |
for (j = 0; j < 9; j++) |
{ |
y[j][i] += win[btype][j] * x[9 + j]; |
y[9 + j][i] += win[btype][9 + j] * x[17 - j]; |
} |
/* window x for next time x0 */ |
for (j = 0; j < 4; j++) |
{ |
xa = x[j]; |
xb = x[8 - j]; |
x0[j] += win[btype][18 + j] * xb; |
x0[8 - j] += win[btype][(18 + 8) - j] * xa; |
x0[9 + j] += win[btype][(18 + 9) + j] * xa; |
x0[17 - j] += win[btype][(18 + 17) - j] * xb; |
} |
xa = x[j]; |
x0[j] += win[btype][18 + j] * xa; |
x0[9 + j] += win[btype][(18 + 9) + j] * xa; |
x += 18; |
x0 += 18; |
} |
/*-- do short blocks (if any) --*/ |
n = (ntot + 17) / 18; /* number of 6 pt dct's triples to do */ |
for (; i < n; i++) |
{ |
imdct6_3(x); |
for (j = 0; j < 3; j++) |
{ |
y[6 + j][i] += win[2][j] * x[3 + j]; |
y[9 + j][i] += win[2][3 + j] * x[5 - j]; |
y[12 + j][i] += win[2][6 + j] * x[2 - j] + win[2][j] * x[(6 + 3) + j]; |
y[15 + j][i] += win[2][9 + j] * x[j] + win[2][3 + j] * x[(6 + 5) - j]; |
} |
/* window x for next time */ |
for (j = 0; j < 3; j++) |
{ |
x0[j] += win[2][6 + j] * x[(6 + 2) - j] + win[2][j] * x[(12 + 3) + j]; |
x0[3 + j] += win[2][9 + j] * x[6 + j] + win[2][3 + j] * x[(12 + 5) - j]; |
} |
for (j = 0; j < 3; j++) |
{ |
x0[6 + j] += win[2][6 + j] * x[(12 + 2) - j]; |
x0[9 + j] += win[2][9 + j] * x[12 + j]; |
} |
x += 18; |
x0 += 18; |
} |
nout = 18 * i; |
return nout; |
} |
/*--------------------------------------------------------------------*/ |
void sum_f_bands(float a[], float b[], int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
a[i] += b[i]; |
} |
/*--------------------------------------------------------------------*/ |
void freq_invert(float y[18][32], int n) |
{ |
int i, j; |
n = (n + 17) / 18; |
for (j = 0; j < 18; j += 2) |
{ |
for (i = 0; i < n; i += 2) |
{ |
y[1 + j][1 + i] = -y[1 + j][1 + i]; |
} |
} |
} |
/*--------------------------------------------------------------------*/ |
/programs/media/ac97 mp3/trunk/mp3dec/l3init.c |
---|
0,0 → 1,212 |
#include "layer3.h" |
extern MPEG_DECODE_OPTION m_option; |
extern SAMPLE m_sample[2][2][576]; |
extern int m_frequency; |
extern SBT_PROC m_sbt_proc; |
extern XFORM_PROC m_xform_proc; |
extern int m_channels; |
extern int m_sfBandIndex[2][22];// [long/short][cb] |
extern int m_nBand[2][22]; |
extern int m_band_limit; |
extern int m_band_limit21; // limit for sf band 21 |
extern int m_band_limit12; // limit for sf band 12 short |
extern int m_band_limit_nsb; |
extern int m_ncbl_mixed; |
extern int m_nsb_limit; |
extern int m_gr; |
extern int m_buf_ptr0, m_buf_ptr1; |
extern float m_yout[576]; |
//extern "l3sbt.c" |
void sbt_mono_L3(float *sample, signed short *pcm, int ch); |
void sbt_dual_L3(float *sample, signed short *pcm, int ch); |
void sbt16_mono_L3(float *sample, signed short *pcm, int ch); |
void sbt16_dual_L3(float *sample, signed short *pcm, int ch); |
void sbt8_mono_L3(float *sample, signed short *pcm, int ch); |
void sbt8_dual_L3(float *sample, signed short *pcm, int ch); |
void sbtB_mono_L3(float *sample, unsigned char *pcm, int ch); |
void sbtB_dual_L3(float *sample, unsigned char *pcm, int ch); |
void sbtB16_mono_L3(float *sample, unsigned char *pcm, int ch); |
void sbtB16_dual_L3(float *sample, unsigned char *pcm, int ch); |
void sbtB8_mono_L3(float *sample, unsigned char *pcm, int ch); |
void sbtB8_dual_L3(float *sample, unsigned char *pcm, int ch); |
//extern "l3dec.c" |
void xform_mono(void *pcm, int igr); |
void xform_dual(void *pcm, int igr); |
void xform_dual_mono(void *pcm, int igr); |
void xform_dual_right(void *pcm, int igr); |
static const SBT_PROC sbt_table[2][3][2] = |
{ |
sbt_mono_L3, |
sbt_dual_L3, |
sbt16_mono_L3, |
sbt16_dual_L3, |
sbt8_mono_L3, |
sbt8_dual_L3, |
// 8 bit output |
sbtB_mono_L3, |
sbtB_dual_L3, |
sbtB16_mono_L3, |
sbtB16_dual_L3, |
sbtB8_mono_L3, |
sbtB8_dual_L3, |
}; |
static const XFORM_PROC xform_table[5] = |
{ |
xform_mono, |
xform_dual, |
xform_dual_mono, |
xform_mono, /* left */ |
xform_dual_right, |
}; |
static const struct { |
int l[23]; |
int s[14]; |
} sfBandTable[3][3] = { |
// MPEG-1 |
{{ |
{0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 52, 62, 74, 90, 110, 134, 162, 196, 238, 288, 342, 418, 576}, |
{0, 4, 8, 12, 16, 22, 30, 40, 52, 66, 84, 106, 136, 192} |
},{ |
{0, 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 60, 72, 88, 106, 128, 156, 190, 230, 276, 330, 384, 576}, |
{0, 4, 8, 12, 16, 22, 28, 38, 50, 64, 80, 100, 126, 192} |
},{ |
{0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 54, 66, 82, 102, 126, 156, 194, 240, 296, 364, 448, 550, 576}, |
{0, 4, 8, 12, 16, 22, 30, 42, 58, 78, 104, 138, 180, 192} |
}}, |
// MPEG-2 |
{{ |
{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, |
{0, 4, 8, 12, 18, 24, 32, 42, 56, 74, 100, 132, 174, 192} |
},{ |
{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 114, 136, 162, 194, 232, 278, 332, 394, 464, 540, 576}, |
{0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 136, 180, 192} |
},{ |
{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, |
{0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192} |
}}, |
// MPEG-2.5, 11 & 12 KHz seem ok, 8 ok |
{{ |
{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, |
{0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192} |
},{ |
{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576}, |
{0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192} |
},{ |
// this 8khz table, and only 8khz, from mpeg123) |
{0, 12, 24, 36, 48, 60, 72, 88, 108, 132, 160, 192, 232, 280, 336, 400, 476, 566, 568, 570, 572, 574, 576}, |
{0, 8, 16, 24, 36, 52, 72, 96, 124, 160, 162, 164, 166, 192} |
}}, |
}; |
void quant_init(); |
void alias_init(); |
void msis_init(); |
void fdct_init(); |
void imdct_init(); |
void hwin_init(); |
void L3table_init() |
{ |
quant_init(); |
alias_init(); |
msis_init(); |
fdct_init(); |
imdct_init(); |
hwin_init(); |
} |
int L3decode_start(MPEG_HEADER* h) |
{ |
int i, j, k, v; |
int channels, limit; |
int bit_code; |
m_buf_ptr0 = 0; |
m_buf_ptr1 = 0; |
m_gr = 0; |
v = h->version - 1; |
if (h->version == 1) //MPEG-1 |
m_ncbl_mixed = 8; |
else //MPEG-2, MPEG-2.5 |
m_ncbl_mixed = 6; |
// compute nsb_limit |
m_nsb_limit = (m_option.freqLimit * 64L + m_frequency / 2) / m_frequency; |
// caller limit |
limit = (32 >> m_option.reduction); |
if (limit > 8) |
limit--; |
if (m_nsb_limit > limit) |
m_nsb_limit = limit; |
limit = 18 * m_nsb_limit; |
if (h->version == 1) { |
//MPEG-1 |
m_band_limit12 = 3 * sfBandTable[v][h->fr_index].s[13]; |
m_band_limit = m_band_limit21 = sfBandTable[v][h->fr_index].l[22]; |
} |
else { |
//MPEG-2, MPEG-2.5 |
m_band_limit12 = 3 * sfBandTable[v][h->fr_index].s[12]; |
m_band_limit = m_band_limit21 = sfBandTable[v][h->fr_index].l[21]; |
} |
m_band_limit += 8; // allow for antialias |
if (m_band_limit > limit) |
m_band_limit = limit; |
if (m_band_limit21 > m_band_limit) |
m_band_limit21 = m_band_limit; |
if (m_band_limit12 > m_band_limit) |
m_band_limit12 = m_band_limit; |
m_band_limit_nsb = (m_band_limit + 17) / 18; // limit nsb's rounded up |
/* |
gain_adjust = 0; // adjust gain e.g. cvt to mono sum channel |
if ((h->mode != 3) && (m_option.convert == 1)) |
gain_adjust = -4; |
*/ |
m_channels = (h->mode == 3) ? 1 : 2; |
if (m_option.convert) channels = 1; |
else channels = m_channels; |
bit_code = (m_option.convert & 8) ? 1 : 0; |
m_sbt_proc = sbt_table[bit_code][m_option.reduction][channels - 1];//[2][3][2] |
k = (h->mode != 3) ? (1 + m_option.convert) : 0; |
m_xform_proc = xform_table[k];//[5] |
/* |
if (bit_code) |
zero_level_pcm = 128;// 8 bit output |
else |
zero_level_pcm = 0; |
*/ |
// init band tables |
for (i = 0; i < 22; i ++) |
m_sfBandIndex[0][i] = sfBandTable[v][h->fr_index].l[i + 1]; |
for (i = 0; i < 13; i ++) |
m_sfBandIndex[1][i] = 3 * sfBandTable[v][h->fr_index].s[i + 1]; |
for (i = 0; i < 22; i ++) |
m_nBand[0][i] = sfBandTable[v][h->fr_index].l[i + 1] |
- sfBandTable[v][h->fr_index].l[i]; |
for (i = 0; i < 13; i ++) |
m_nBand[1][i] = sfBandTable[v][h->fr_index].s[i + 1] |
- sfBandTable[v][h->fr_index].s[i]; |
// clear buffers |
for (i = 0; i < 576; i++) |
m_yout[i] = 0.0f; |
for (i = 0; i < 2; i ++) |
{ for (j = 0; j < 2; j ++) |
{ for (k = 0; k < 576; k++) |
{ m_sample[i][j][k].x = 0.0f; |
m_sample[i][j][k].s = 0; |
} |
} |
} |
return 1; |
} |
/programs/media/ac97 mp3/trunk/mp3dec/l3msis.c |
---|
0,0 → 1,332 |
#include "layer3.h" |
#include <math.h> |
//#include <windows.h> |
extern IS_SF_INFO m_is_sf_info; |
extern int m_ms_mode, m_is_mode; |
extern int m_sfBandIndex[2][22];// [long/short][cb] |
extern int m_nBand[2][22]; |
/* intensity stereo */ |
/* if ms mode quant pre-scales all values by 1.0/sqrt(2.0) ms_mode in table |
compensates */ |
/* [ms_mode 0/1][sf][left/right] */ |
static float lr[2][8][2]; |
/* lr2[intensity_scale][ms_mode][sflen_offset+sf][left/right] */ |
static float lr2[2][2][64][2]; |
/*-------*msis_init_addr() |
pi = 4.0*atan(1.0); |
t = pi/12.0; |
for(i=0;i<7;i++) { |
s = sin(i*t); |
c = cos(i*t); |
// ms_mode = 0 |
lr[0][i][0] = (float)(s/(s+c)); |
lr[0][i][1] = (float)(c/(s+c)); |
// ms_mode = 1 |
lr[1][i][0] = (float)(sqrt(2.0)*(s/(s+c))); |
lr[1][i][1] = (float)(sqrt(2.0)*(c/(s+c))); |
} |
//sf = 7 |
//ms_mode = 0 |
lr[0][i][0] = 1.0f; |
lr[0][i][1] = 0.0f; |
// ms_mode = 1, in is bands is routine does ms processing |
lr[1][i][0] = 1.0f; |
lr[1][i][1] = 1.0f; |
------------*/ |
/*===============================================================*/ |
void msis_init1() |
{ |
int i; |
double s, c; |
double pi; |
double t; |
pi = 4.0 * atan(1.0); |
t = pi / 12.0; |
for (i = 0; i < 7; i++) |
{ |
s = sin(i * t); |
c = cos(i * t); |
/* ms_mode = 0 */ |
lr[0][i][0] = (float) (s / (s + c)); |
lr[0][i][1] = (float) (c / (s + c)); |
/* ms_mode = 1 */ |
lr[1][i][0] = (float) (sqrt(2.0) * (s / (s + c))); |
lr[1][i][1] = (float) (sqrt(2.0) * (c / (s + c))); |
} |
/* sf = 7 */ |
/* ms_mode = 0 */ |
lr[0][i][0] = 1.0f; |
lr[0][i][1] = 0.0f; |
/* ms_mode = 1, in is bands is routine does ms processing */ |
lr[1][i][0] = 1.0f; |
lr[1][i][1] = 1.0f; |
/*------- |
for(i=0;i<21;i++) m_nBand[0][i] = |
sfBandTable[sr_index].l[i+1] - sfBandTable[sr_index].l[i]; |
for(i=0;i<12;i++) m_nBand[1][i] = |
sfBandTable[sr_index].s[i+1] - sfBandTable[sr_index].s[i]; |
-------------*/ |
} |
/*===============================================================*/ |
void msis_init2() |
{ |
int k, n; |
double t; |
int intensity_scale, ms_mode, sf, sflen; |
float ms_factor[2]; |
ms_factor[0] = 1.0; |
ms_factor[1] = (float) sqrt(2.0); |
/* intensity stereo MPEG2 */ |
/* lr2[intensity_scale][ms_mode][sflen_offset+sf][left/right] */ |
for (intensity_scale = 0; intensity_scale < 2; intensity_scale++) |
{ |
t = pow_test(2.0, -0.25 * (1 + intensity_scale)); |
for (ms_mode = 0; ms_mode < 2; ms_mode++) |
{ |
n = 1; |
k = 0; |
for (sflen = 0; sflen < 6; sflen++) |
{ |
for (sf = 0; sf < (n - 1); sf++, k++) |
{ |
if (sf == 0) |
{ |
lr2[intensity_scale][ms_mode][k][0] = ms_factor[ms_mode] * 1.0f; |
lr2[intensity_scale][ms_mode][k][1] = ms_factor[ms_mode] * 1.0f; |
} |
else if ((sf & 1)) |
{ |
lr2[intensity_scale][ms_mode][k][0] = |
(float) (ms_factor[ms_mode] * pow_test(t, (sf + 1) / 2)); |
lr2[intensity_scale][ms_mode][k][1] = ms_factor[ms_mode] * 1.0f; |
} |
else |
{ |
lr2[intensity_scale][ms_mode][k][0] = ms_factor[ms_mode] * 1.0f; |
lr2[intensity_scale][ms_mode][k][1] = |
(float) (ms_factor[ms_mode] * pow_test(t, sf / 2)); |
} |
} |
/* illegal is_pos used to do ms processing */ |
if (ms_mode == 0) |
{ /* ms_mode = 0 */ |
lr2[intensity_scale][ms_mode][k][0] = 1.0f; |
lr2[intensity_scale][ms_mode][k][1] = 0.0f; |
} |
else |
{ |
/* ms_mode = 1, in is bands is routine does ms processing */ |
lr2[intensity_scale][ms_mode][k][0] = 1.0f; |
lr2[intensity_scale][ms_mode][k][1] = 1.0f; |
} |
k++; |
n = n + n; |
} |
} |
} |
} |
void msis_init() |
{ |
msis_init1(); |
msis_init2(); |
} |
/*===============================================================*/ |
void ms_process(float x[][1152], int n) /* sum-difference stereo */ |
{ |
int i; |
float xl, xr; |
/*-- note: sqrt(2) done scaling by dequant ---*/ |
for (i = 0; i < n; i++) |
{ |
xl = x[0][i] + x[1][i]; |
xr = x[0][i] - x[1][i]; |
x[0][i] = xl; |
x[1][i] = xr; |
} |
return; |
} |
void is_process1(float x[][1152], /* intensity stereo */ |
SCALE_FACTOR* sf, |
CB_INFO cb_info[2], /* [ch] */ |
int nsamp) |
{ |
int i, j, n, cb, w; |
float fl, fr; |
int m; |
int isf; |
float fls[3], frs[3]; |
int cb0; |
cb0 = cb_info[1].cbmax; /* start at end of right */ |
i = m_sfBandIndex[cb_info[1].cbtype][cb0]; |
cb0++; |
m = nsamp - i; /* process to len of left */ |
if (cb_info[1].cbtype) |
goto short_blocks; |
/*------------------------*/ |
/* long_blocks: */ |
for (cb = cb0; cb < 21; cb++) |
{ |
isf = sf->l[cb]; |
n = m_nBand[0][cb]; |
fl = lr[m_ms_mode][isf][0]; |
fr = lr[m_ms_mode][isf][1]; |
for (j = 0; j < n; j++, i++) |
{ |
if (--m < 0) |
goto exit; |
x[1][i] = fr * x[0][i]; |
x[0][i] = fl * x[0][i]; |
} |
} |
return; |
/*------------------------*/ |
short_blocks: |
for (cb = cb0; cb < 12; cb++) |
{ |
for (w = 0; w < 3; w++) |
{ |
isf = sf->s[w][cb]; |
fls[w] = lr[m_ms_mode][isf][0]; |
frs[w] = lr[m_ms_mode][isf][1]; |
} |
n = m_nBand[1][cb]; |
for (j = 0; j < n; j++) |
{ |
m -= 3; |
if (m < 0) |
goto exit; |
x[1][i] = frs[0] * x[0][i]; |
x[0][i] = fls[0] * x[0][i]; |
x[1][1 + i] = frs[1] * x[0][1 + i]; |
x[0][1 + i] = fls[1] * x[0][1 + i]; |
x[1][2 + i] = frs[2] * x[0][2 + i]; |
x[0][2 + i] = fls[2] * x[0][2 + i]; |
i += 3; |
} |
} |
exit: |
return; |
} |
typedef float ARRAY2[2]; |
void is_process2(float x[][1152], /* intensity stereo */ |
SCALE_FACTOR* sf, |
CB_INFO cb_info[2], /* [ch] */ |
int nsamp) |
{ |
int i, j, k, n, cb, w; |
float fl, fr; |
int m; |
int isf; |
int il[21]; |
int tmp; |
int r; |
ARRAY2 *lr; |
int cb0, cb1; |
lr = lr2[m_is_sf_info.intensity_scale][m_ms_mode]; |
if (cb_info[1].cbtype) |
goto short_blocks; |
/*------------------------*/ |
/* long_blocks: */ |
cb0 = cb_info[1].cbmax; /* start at end of right */ |
i = m_sfBandIndex[0][cb0]; |
m = nsamp - i; /* process to len of left */ |
/* gen sf info */ |
for (k = r = 0; r < 3; r++) |
{ |
tmp = (1 << m_is_sf_info.slen[r]) - 1; |
for (j = 0; j < m_is_sf_info.nr[r]; j++, k++) |
il[k] = tmp; |
} |
for (cb = cb0 + 1; cb < 21; cb++) |
{ |
isf = il[cb] + sf->l[cb]; |
// X-MaD 27-02-02 |
if (isf < 0) { isf = 0; } |
fl = 0; |
fr = 0; |
//try |
//{ |
fl = lr[isf][0]; |
fr = lr[isf][1]; |
n = m_nBand[0][cb]; |
//} |
//catch(...) |
//{ |
// isf = 0; |
//} |
// X-MaD 27-02-02 |
for (j = 0; j < n; j++, i++) |
{ |
if (--m < 0) |
{ |
goto exit; |
} |
x[1][i] = fr * x[0][i]; |
x[0][i] = fl * x[0][i]; |
} |
} |
return; |
/*------------------------*/ |
short_blocks: |
for (k = r = 0; r < 3; r++) |
{ |
tmp = (1 << m_is_sf_info.slen[r]) - 1; |
for (j = 0; j < m_is_sf_info.nr[r]; j++, k++) |
il[k] = tmp; |
} |
for (w = 0; w < 3; w++) |
{ |
cb0 = cb_info[1].cbmax_s[w]; /* start at end of right */ |
i = m_sfBandIndex[1][cb0] + w; |
cb1 = cb_info[0].cbmax_s[w]; /* process to end of left */ |
for (cb = cb0 + 1; cb <= cb1; cb++) |
{ |
isf = il[cb] + sf->s[w][cb]; |
fl = lr[isf][0]; |
fr = lr[isf][1]; |
n = m_nBand[1][cb]; |
for (j = 0; j < n; j++) |
{ |
x[1][i] = fr * x[0][i]; |
x[0][i] = fl * x[0][i]; |
i += 3; |
} |
} |
} |
exit: |
return; |
} |
/programs/media/ac97 mp3/trunk/mp3dec/l3quant.c |
---|
0,0 → 1,217 |
#include "layer3.h" |
#include <math.h> |
#include <string.h> //memmove |
extern SIDE_INFO m_side_info; |
extern SCALE_FACTOR m_scale_fac[2][2]; // [gr][ch] |
extern CB_INFO m_cb_info[2][2]; // [gr][ch] |
extern int m_nsamp[2][2]; |
extern int m_nBand[2][22]; |
extern int m_ncbl_mixed; |
#define GLOBAL_GAIN_SCALE (4*15) |
static const int pretab[2][22] = |
{ |
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, |
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0}, |
}; |
/* 8 bit plus 2 lookup x = pow(2.0, 0.25*(global_gain-210)) */ |
/* two extra slots to do 1/sqrt(2) scaling for ms */ |
/* 4 extra slots to do 1/2 scaling for cvt to mono */ |
static float look_global[256 + 2 + 4]; |
/*-------- scaling lookup |
x = pow(2.0, -0.5*(1+scalefact_scale)*scalefac + preemp) |
look_scale[scalefact_scale][preemp][scalefac] |
-----------------------*/ |
static float look_scale[2][4][32]; |
/*--- iSample**(4/3) lookup, -32<=i<=31 ---*/ |
#define ISMAX 32 |
static float look_pow[2 * ISMAX]; |
/*-- pow(2.0, -0.25*8.0*subblock_gain) --*/ |
static float look_subblock[8]; |
/*-- reorder buffer ---*/ |
static float re_buf[192][3]; |
typedef float ARRAY3[3]; |
void quant_init() |
{ |
int i; |
int scalefact_scale, preemp, scalefac; |
double tmp; |
/* 8 bit plus 2 lookup x = pow(2.0, 0.25*(global_gain-210)) */ |
/* extra 2 for ms scaling by 1/sqrt(2) */ |
/* extra 4 for cvt to mono scaling by 1/2 */ |
for (i = 0; i < 256 + 2 + 4; i++) |
look_global[i] = (float) pow_test(2.0, 0.25 * ((i - (2 + 4)) - 210 + GLOBAL_GAIN_SCALE)); |
/* x = pow(2.0, -0.5*(1+scalefact_scale)*scalefac + preemp) */ |
for (scalefact_scale = 0; scalefact_scale < 2; scalefact_scale++) |
{ |
for (preemp = 0; preemp < 4; preemp++) |
{ |
for (scalefac = 0; scalefac < 32; scalefac++) |
{ |
look_scale[scalefact_scale][preemp][scalefac] = |
(float) pow_test(2.0, -0.5 * (1 + scalefact_scale) * (scalefac + preemp)); |
} |
} |
} |
/*--- iSample**(4/3) lookup, -32<=i<=31 ---*/ |
for (i = 0; i < 64; i++) |
{ |
tmp = i - 32; |
look_pow[i] = (float) (tmp * pow_test(fabs(tmp), (1.0 / 3.0))); |
} |
/*-- pow(2.0, -0.25*8.0*subblock_gain) 3 bits --*/ |
for (i = 0; i < 8; i++) |
{ |
look_subblock[i] = (float) pow_test(2.0, 0.25 * -8.0 * i); |
} |
// quant_init_sf_band(sr_index); replaced by code in sup.c |
} |
void dequant(SAMPLE Sample[], int gr, int ch) |
{ |
SCALE_FACTOR* sf = &m_scale_fac[gr][ch]; |
GR_INFO* gr_info = &m_side_info.gr[gr][ch]; |
CB_INFO* cb_info = &m_cb_info[gr][ch]; |
int* nsamp = &m_nsamp[gr][ch]; |
int i, j; |
int cb, n, w; |
float x0, xs; |
float xsb[3]; |
double tmp; |
int ncbl; |
int cbs0; |
ARRAY3 *buf; /* short block reorder */ |
int nbands; |
int i0; |
int non_zero; |
int cbmax[3]; |
nbands = *nsamp; |
ncbl = 22; /* long block cb end */ |
cbs0 = 12; /* short block cb start */ |
/* ncbl_mixed = 8 or 6 mpeg1 or 2 */ |
if (gr_info->block_type == 2) |
{ |
ncbl = 0; |
cbs0 = 0; |
if (gr_info->mixed_block_flag) |
{ |
ncbl = m_ncbl_mixed; |
cbs0 = 3; |
} |
} |
/* fill in cb_info -- */ |
cb_info->lb_type = gr_info->block_type; |
if (gr_info->block_type == 2) |
cb_info->lb_type; |
cb_info->cbs0 = cbs0; |
cb_info->ncbl = ncbl; |
cbmax[2] = cbmax[1] = cbmax[0] = 0; |
/* global gain pre-adjusted by 2 if ms_mode, 0 otherwise */ |
x0 = look_global[(2 + 4) + gr_info->global_gain]; |
i = 0; |
/*----- long blocks ---*/ |
for (cb = 0; cb < ncbl; cb++) |
{ |
non_zero = 0; |
xs = x0 * look_scale[gr_info->scalefac_scale][pretab[gr_info->preflag][cb]][sf->l[cb]]; |
n = m_nBand[0][cb]; |
for (j = 0; j < n; j++, i++) |
{ |
if (Sample[i].s == 0) |
Sample[i].x = 0.0F; |
else |
{ |
non_zero = 1; |
if ((Sample[i].s >= (-ISMAX)) && (Sample[i].s < ISMAX)) |
Sample[i].x = xs * look_pow[ISMAX + Sample[i].s]; |
else |
{ |
tmp = (double) Sample[i].s; |
Sample[i].x = (float) (xs * tmp * pow_test(fabs(tmp), (1.0 / 3.0))); |
} |
} |
} |
if (non_zero) |
cbmax[0] = cb; |
if (i >= nbands) |
break; |
} |
cb_info->cbmax = cbmax[0]; |
cb_info->cbtype = 0; // type = long |
if (cbs0 >= 12) |
return; |
/*--------------------------- |
block type = 2 short blocks |
----------------------------*/ |
cbmax[2] = cbmax[1] = cbmax[0] = cbs0; |
i0 = i; /* save for reorder */ |
buf = re_buf; |
for (w = 0; w < 3; w++) |
xsb[w] = x0 * look_subblock[gr_info->subblock_gain[w]]; |
for (cb = cbs0; cb < 13; cb++) |
{ |
n = m_nBand[1][cb]; |
for (w = 0; w < 3; w++) |
{ |
non_zero = 0; |
xs = xsb[w] * look_scale[gr_info->scalefac_scale][0][sf->s[w][cb]]; |
for (j = 0; j < n; j++, i++) |
{ |
if (Sample[i].s == 0) |
buf[j][w] = 0.0F; |
else |
{ |
non_zero = 1; |
if ((Sample[i].s >= (-ISMAX)) && (Sample[i].s < ISMAX)) |
buf[j][w] = xs * look_pow[ISMAX + Sample[i].s]; |
else |
{ |
tmp = (double) Sample[i].s; |
buf[j][w] = (float) (xs * tmp * pow_test(fabs(tmp), (1.0 / 3.0))); |
} |
} |
} |
if (non_zero) |
cbmax[w] = cb; |
} |
if (i >= nbands) |
break; |
buf += n; |
} |
memmove(&Sample[i0].x, &re_buf[0][0], sizeof(float) * (i - i0)); |
*nsamp = i; /* update nsamp */ |
cb_info->cbmax_s[0] = cbmax[0]; |
cb_info->cbmax_s[1] = cbmax[1]; |
cb_info->cbmax_s[2] = cbmax[2]; |
if (cbmax[1] > cbmax[0]) |
cbmax[0] = cbmax[1]; |
if (cbmax[2] > cbmax[0]) |
cbmax[0] = cbmax[2]; |
cb_info->cbmax = cbmax[0]; |
cb_info->cbtype = 1; /* type = short */ |
} |
/programs/media/ac97 mp3/trunk/mp3dec/l3sf.c |
---|
0,0 → 1,353 |
#include "layer3.h" |
extern SIDE_INFO m_side_info; |
extern SCALE_FACTOR m_scale_fac[2][2]; // [gr][ch] |
extern IS_SF_INFO m_is_sf_info; |
extern int m_is_mode; |
static const int slen_table[16][2] = |
{ |
0, 0, 0, 1, |
0, 2, 0, 3, |
3, 0, 1, 1, |
1, 2, 1, 3, |
2, 1, 2, 2, |
2, 3, 3, 1, |
3, 2, 3, 3, |
4, 2, 4, 3, |
}; |
/* nr_table[size+3*is_right][block type 0,1,3 2, 2+mixed][4] */ |
/* for bt=2 nr is count for group of 3 */ |
static const int nr_table[6][3][4] = |
{ |
6, 5, 5, 5, |
3, 3, 3, 3, |
6, 3, 3, 3, |
6, 5, 7, 3, |
3, 3, 4, 2, |
6, 3, 4, 2, |
11, 10, 0, 0, |
6, 6, 0, 0, |
6, 3, 6, 0, /* adjusted *//* 15, 18, 0, 0, */ |
/*-intensity stereo right chan--*/ |
7, 7, 7, 0, |
4, 4, 4, 0, |
6, 5, 4, 0, |
6, 6, 6, 3, |
4, 3, 3, 2, |
6, 4, 3, 2, |
8, 8, 5, 0, |
5, 4, 3, 0, |
6, 6, 3, 0, |
}; |
void L3get_scale_factor1(int gr, int ch) |
{ |
SCALE_FACTOR* sf = &m_scale_fac[gr][ch]; |
GR_INFO* grdat = &m_side_info.gr[gr][ch]; |
int scfsi = m_side_info.scfsi[ch]; |
int sfb; |
int slen0, slen1; |
int block_type, mixed_block_flag, scalefac_compress; |
block_type = grdat->block_type; |
mixed_block_flag = grdat->mixed_block_flag; |
scalefac_compress = grdat->scalefac_compress; |
slen0 = slen_table[scalefac_compress][0]; |
slen1 = slen_table[scalefac_compress][1]; |
if (block_type == 2) { |
if (mixed_block_flag) { /* mixed */ |
for (sfb = 0; sfb < 8; sfb++) |
sf[0].l[sfb] = bitget(slen0); |
for (sfb = 3; sfb < 6; sfb++) { |
sf[0].s[0][sfb] = bitget(slen0); |
sf[0].s[1][sfb] = bitget(slen0); |
sf[0].s[2][sfb] = bitget(slen0); |
} |
for (sfb = 6; sfb < 12; sfb++) { |
sf[0].s[0][sfb] = bitget(slen1); |
sf[0].s[1][sfb] = bitget(slen1); |
sf[0].s[2][sfb] = bitget(slen1); |
} |
return; |
} |
for (sfb = 0; sfb < 6; sfb++) { |
sf[0].s[0][sfb] = bitget(slen0); |
sf[0].s[1][sfb] = bitget(slen0); |
sf[0].s[2][sfb] = bitget(slen0); |
} |
for (; sfb < 12; sfb++) { |
sf[0].s[0][sfb] = bitget(slen1); |
sf[0].s[1][sfb] = bitget(slen1); |
sf[0].s[2][sfb] = bitget(slen1); |
} |
return; |
} |
/* long blocks types 0 1 3, first granule */ |
if (gr == 0) |
{ |
for (sfb = 0; sfb < 11; sfb++) |
sf[0].l[sfb] = bitget(slen0); |
for (; sfb < 21; sfb++) |
sf[0].l[sfb] = bitget(slen1); |
return; |
} |
/* long blocks 0, 1, 3, second granule */ |
sfb = 0; |
if (scfsi & 8) |
for (; sfb < 6; sfb++) |
sf[0].l[sfb] = sf[-2].l[sfb]; |
else |
for (; sfb < 6; sfb++) |
sf[0].l[sfb] = bitget(slen0); |
if (scfsi & 4) |
for (; sfb < 11; sfb++) |
sf[0].l[sfb] = sf[-2].l[sfb]; |
else |
for (; sfb < 11; sfb++) |
sf[0].l[sfb] = bitget(slen0); |
if (scfsi & 2) |
for (; sfb < 16; sfb++) |
sf[0].l[sfb] = sf[-2].l[sfb]; |
else |
for (; sfb < 16; sfb++) |
sf[0].l[sfb] = bitget(slen1); |
if (scfsi & 1) |
for (; sfb < 21; sfb++) |
sf[0].l[sfb] = sf[-2].l[sfb]; |
else |
for (; sfb < 21; sfb++) |
sf[0].l[sfb] = bitget(slen1); |
} |
void L3get_scale_factor2(int gr, int ch) |
{ |
SCALE_FACTOR* sf = &m_scale_fac[gr][ch]; |
GR_INFO* grdat = &m_side_info.gr[gr][ch]; |
int is_and_ch = m_is_mode & ch; |
int sfb; |
int slen1, slen2, slen3, slen4; |
int nr1, nr2, nr3, nr4; |
int i, k; |
int preflag, intensity_scale; |
int block_type, mixed_block_flag, scalefac_compress; |
block_type = grdat->block_type; |
mixed_block_flag = grdat->mixed_block_flag; |
scalefac_compress = grdat->scalefac_compress; |
preflag = 0; |
intensity_scale = 0; /* to avoid compiler warning */ |
if (is_and_ch == 0) |
{ |
if (scalefac_compress < 400) |
{ |
slen2 = scalefac_compress >> 4; |
slen1 = slen2 / 5; |
slen2 = slen2 % 5; |
slen4 = scalefac_compress & 15; |
slen3 = slen4 >> 2; |
slen4 = slen4 & 3; |
k = 0; |
} |
else if (scalefac_compress < 500) |
{ |
scalefac_compress -= 400; |
slen2 = scalefac_compress >> 2; |
slen1 = slen2 / 5; |
slen2 = slen2 % 5; |
slen3 = scalefac_compress & 3; |
slen4 = 0; |
k = 1; |
} |
else |
{ |
scalefac_compress -= 500; |
slen1 = scalefac_compress / 3; |
slen2 = scalefac_compress % 3; |
slen3 = slen4 = 0; |
if (mixed_block_flag) |
{ |
slen3 = slen2; /* adjust for long/short mix logic */ |
slen2 = slen1; |
} |
preflag = 1; |
k = 2; |
} |
} |
else |
{ /* intensity stereo ch = 1 (right) */ |
intensity_scale = scalefac_compress & 1; |
scalefac_compress >>= 1; |
if (scalefac_compress < 180) |
{ |
slen1 = scalefac_compress / 36; |
slen2 = scalefac_compress % 36; |
slen3 = slen2 % 6; |
slen2 = slen2 / 6; |
slen4 = 0; |
k = 3 + 0; |
} |
else if (scalefac_compress < 244) |
{ |
scalefac_compress -= 180; |
slen3 = scalefac_compress & 3; |
scalefac_compress >>= 2; |
slen2 = scalefac_compress & 3; |
slen1 = scalefac_compress >> 2; |
slen4 = 0; |
k = 3 + 1; |
} |
else |
{ |
scalefac_compress -= 244; |
slen1 = scalefac_compress / 3; |
slen2 = scalefac_compress % 3; |
slen3 = slen4 = 0; |
k = 3 + 2; |
} |
} |
i = 0; |
if (block_type == 2) |
i = (mixed_block_flag & 1) + 1; |
nr1 = nr_table[k][i][0]; |
nr2 = nr_table[k][i][1]; |
nr3 = nr_table[k][i][2]; |
nr4 = nr_table[k][i][3]; |
/* return is scale factor info (for right chan is mode) */ |
if (is_and_ch) |
{ |
m_is_sf_info.nr[0] = nr1; |
m_is_sf_info.nr[1] = nr2; |
m_is_sf_info.nr[2] = nr3; |
m_is_sf_info.slen[0] = slen1; |
m_is_sf_info.slen[1] = slen2; |
m_is_sf_info.slen[2] = slen3; |
m_is_sf_info.intensity_scale = intensity_scale; |
} |
grdat->preflag = preflag; /* return preflag */ |
/*--------------------------------------*/ |
if (block_type == 2) |
{ |
if (mixed_block_flag) |
{ /* mixed */ |
if (slen1 != 0) /* long block portion */ |
for (sfb = 0; sfb < 6; sfb++) |
sf[0].l[sfb] = bitget(slen1); |
else |
for (sfb = 0; sfb < 6; sfb++) |
sf[0].l[sfb] = 0; |
sfb = 3; /* start sfb for short */ |
} |
else |
{ /* all short, initial short blocks */ |
sfb = 0; |
if (slen1 != 0) |
for (i = 0; i < nr1; i++, sfb++) |
{ |
sf[0].s[0][sfb] = bitget(slen1); |
sf[0].s[1][sfb] = bitget(slen1); |
sf[0].s[2][sfb] = bitget(slen1); |
} |
else |
for (i = 0; i < nr1; i++, sfb++) |
{ |
sf[0].s[0][sfb] = 0; |
sf[0].s[1][sfb] = 0; |
sf[0].s[2][sfb] = 0; |
} |
} |
/* remaining short blocks */ |
if (slen2 != 0) |
for (i = 0; i < nr2; i++, sfb++) |
{ |
sf[0].s[0][sfb] = bitget(slen2); |
sf[0].s[1][sfb] = bitget(slen2); |
sf[0].s[2][sfb] = bitget(slen2); |
} |
else |
for (i = 0; i < nr2; i++, sfb++) |
{ |
sf[0].s[0][sfb] = 0; |
sf[0].s[1][sfb] = 0; |
sf[0].s[2][sfb] = 0; |
} |
if (slen3 != 0) |
for (i = 0; i < nr3; i++, sfb++) |
{ |
sf[0].s[0][sfb] = bitget(slen3); |
sf[0].s[1][sfb] = bitget(slen3); |
sf[0].s[2][sfb] = bitget(slen3); |
} |
else |
for (i = 0; i < nr3; i++, sfb++) |
{ |
sf[0].s[0][sfb] = 0; |
sf[0].s[1][sfb] = 0; |
sf[0].s[2][sfb] = 0; |
} |
if (slen4 != 0) |
for (i = 0; i < nr4; i++, sfb++) |
{ |
sf[0].s[0][sfb] = bitget(slen4); |
sf[0].s[1][sfb] = bitget(slen4); |
sf[0].s[2][sfb] = bitget(slen4); |
} |
else |
for (i = 0; i < nr4; i++, sfb++) |
{ |
sf[0].s[0][sfb] = 0; |
sf[0].s[1][sfb] = 0; |
sf[0].s[2][sfb] = 0; |
} |
return; |
} |
/* long blocks types 0 1 3 */ |
sfb = 0; |
if (slen1 != 0) |
for (i = 0; i < nr1; i++, sfb++) |
sf[0].l[sfb] = bitget(slen1); |
else |
for (i = 0; i < nr1; i++, sfb++) |
sf[0].l[sfb] = 0; |
if (slen2 != 0) |
for (i = 0; i < nr2; i++, sfb++) |
sf[0].l[sfb] = bitget(slen2); |
else |
for (i = 0; i < nr2; i++, sfb++) |
sf[0].l[sfb] = 0; |
if (slen3 != 0) |
for (i = 0; i < nr3; i++, sfb++) |
sf[0].l[sfb] = bitget(slen3); |
else |
for (i = 0; i < nr3; i++, sfb++) |
sf[0].l[sfb] = 0; |
if (slen4 != 0) |
for (i = 0; i < nr4; i++, sfb++) |
sf[0].l[sfb] = bitget(slen4); |
else |
for (i = 0; i < nr4; i++, sfb++) |
sf[0].l[sfb] = 0; |
} |
/programs/media/ac97 mp3/trunk/mp3dec/l3side.c |
---|
0,0 → 1,127 |
#include "layer3.h" |
extern int m_channels; |
extern int m_ms_mode, m_is_mode; |
extern SIDE_INFO m_side_info; |
int L3get_side_info1() |
{ |
int gr, ch, size; |
m_side_info.main_data_begin = bitget(9); |
if (m_channels == 1) { |
m_side_info.private_bits = bitget(5); |
size = 17; |
} |
else { |
m_side_info.private_bits = bitget(3); |
size = 32; |
} |
for (ch = 0; ch < m_channels; ch ++) |
m_side_info.scfsi[ch] = bitget(4); |
for (gr = 0; gr < 2; gr ++) { |
for (ch = 0; ch < m_channels; ch ++) { |
GR_INFO* gr_info = &m_side_info.gr[gr][ch]; |
gr_info->part2_3_length = bitget(12); |
gr_info->big_values = bitget(9); |
gr_info->global_gain = bitget(8); |
//gr_info->global_gain += gain_adjust; |
if (m_ms_mode) gr_info->global_gain -= 2; |
gr_info->scalefac_compress = bitget(4); |
gr_info->window_switching_flag = bitget(1); |
if (gr_info->window_switching_flag) { |
gr_info->block_type = bitget(2); |
gr_info->mixed_block_flag = bitget(1); |
gr_info->table_select[0] = bitget(5); |
gr_info->table_select[1] = bitget(5); |
gr_info->subblock_gain[0] = bitget(3); |
gr_info->subblock_gain[1] = bitget(3); |
gr_info->subblock_gain[2] = bitget(3); |
/* region count set in terms of long block cb's/bands */ |
/* r1 set so r0+r1+1 = 21 (lookup produces 576 bands ) */ |
/* if(window_switching_flag) always 36 samples in region0 */ |
gr_info->region0_count = (8 - 1); /* 36 samples */ |
gr_info->region1_count = 20 - (8 - 1); |
} |
else { |
gr_info->mixed_block_flag = 0; |
gr_info->block_type = 0; |
gr_info->table_select[0] = bitget(5); |
gr_info->table_select[1] = bitget(5); |
gr_info->table_select[2] = bitget(5); |
gr_info->region0_count = bitget(4); |
gr_info->region1_count = bitget(3); |
} |
gr_info->preflag = bitget(1); |
gr_info->scalefac_scale = bitget(1); |
gr_info->count1table_select = bitget(1); |
} |
} |
return size; |
} |
int L3get_side_info2(int gr) |
{ |
int ch, size; |
m_side_info.main_data_begin = bitget(8); |
if (m_channels == 1) { |
m_side_info.private_bits = bitget(1); |
size = 9; |
} |
else { |
m_side_info.private_bits = bitget(2); |
size = 17; |
} |
m_side_info.scfsi[0] = 0; |
m_side_info.scfsi[1] = 0; |
for (ch = 0; ch < m_channels; ch ++) { |
m_side_info.gr[gr][ch].part2_3_length = bitget(12); |
m_side_info.gr[gr][ch].big_values = bitget(9); |
m_side_info.gr[gr][ch].global_gain = bitget(8);// + gain_adjust; |
if (m_ms_mode) m_side_info.gr[gr][ch].global_gain -= 2; |
m_side_info.gr[gr][ch].scalefac_compress = bitget(9); |
m_side_info.gr[gr][ch].window_switching_flag = bitget(1); |
if (m_side_info.gr[gr][ch].window_switching_flag) { |
m_side_info.gr[gr][ch].block_type = bitget(2); |
m_side_info.gr[gr][ch].mixed_block_flag = bitget(1); |
m_side_info.gr[gr][ch].table_select[0] = bitget(5); |
m_side_info.gr[gr][ch].table_select[1] = bitget(5); |
m_side_info.gr[gr][ch].subblock_gain[0] = bitget(3); |
m_side_info.gr[gr][ch].subblock_gain[1] = bitget(3); |
m_side_info.gr[gr][ch].subblock_gain[2] = bitget(3); |
/* region count set in terms of long block cb's/bands */ |
/* r1 set so r0+r1+1 = 21 (lookup produces 576 bands ) */ |
/* bt=1 or 3 54 samples */ |
/* bt=2 mixed=0 36 samples */ |
/* bt=2 mixed=1 54 (8 long sf) samples? or maybe 36 */ |
/* region0 discussion says 54 but this would mix long */ |
/* and short in region0 if scale factors switch */ |
/* at band 36 (6 long scale factors) */ |
if ((m_side_info.gr[gr][ch].block_type == 2)) { |
m_side_info.gr[gr][ch].region0_count = (6 - 1); /* 36 samples */ |
m_side_info.gr[gr][ch].region1_count = 20 - (6 - 1); |
} |
else {/* long block type 1 or 3 */ |
m_side_info.gr[gr][ch].region0_count = (8 - 1); /* 54 samples */ |
m_side_info.gr[gr][ch].region1_count = 20 - (8 - 1); |
} |
} |
else { |
m_side_info.gr[gr][ch].mixed_block_flag = 0; |
m_side_info.gr[gr][ch].block_type = 0; |
m_side_info.gr[gr][ch].table_select[0] = bitget(5); |
m_side_info.gr[gr][ch].table_select[1] = bitget(5); |
m_side_info.gr[gr][ch].table_select[2] = bitget(5); |
m_side_info.gr[gr][ch].region0_count = bitget(4); |
m_side_info.gr[gr][ch].region1_count = bitget(3); |
} |
m_side_info.gr[gr][ch].preflag = 0; |
m_side_info.gr[gr][ch].scalefac_scale = bitget(1); |
m_side_info.gr[gr][ch].count1table_select = bitget(1); |
} |
return size; |
} |
/programs/media/ac97 mp3/trunk/mp3dec/layer3.h |
---|
0,0 → 1,52 |
#include "bstream.h" |
#include "mp3dec.h" |
typedef struct { |
uint part2_3_length; |
uint big_values; |
uint global_gain; |
uint scalefac_compress; |
uint window_switching_flag; |
uint block_type; |
uint mixed_block_flag; |
uint table_select[3]; |
uint subblock_gain[3]; |
uint region0_count; |
uint region1_count; |
uint preflag; |
uint scalefac_scale; |
uint count1table_select; |
} GR_INFO; |
typedef struct { |
uint main_data_begin; |
uint private_bits; |
uint scfsi[2]; /* 4 bit flags [ch] */ |
GR_INFO gr[2][2]; /* [gr][ch] */ |
} SIDE_INFO; |
typedef struct { |
int l[23]; /* [cb] */ |
int s[3][13]; /* [window][cb] */ |
} SCALE_FACTOR; |
typedef struct { |
int cbtype; /* long=0 short=1 */ |
int cbmax; /* max crit band */ |
int lb_type; /* long block type 0 1 3 */ |
int cbs0; /* short band start index 0 3 12 (12=no shorts */ |
int ncbl; /* number long cb's 0 8 21 */ |
int cbmax_s[3]; /* cbmax by individual short blocks */ |
} CB_INFO; |
typedef struct { |
int nr[3]; |
int slen[3]; |
int intensity_scale; |
} IS_SF_INFO; |
typedef union { |
int s; |
float x; |
} SAMPLE; |
/programs/media/ac97 mp3/trunk/mp3dec/math_private.h |
---|
0,0 → 1,209 |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* from: @(#)fdlibm.h 5.1 93/09/24 |
* $Id: math_private.h,v 1.8 1998/11/27 11:33:46 drepper Exp $ |
*/ |
#ifndef _MATH_PRIVATE_H_ |
#define _MATH_PRIVATE_H_ |
/* The original fdlibm code used statements like: |
n0 = ((*(int*)&one)>>29)^1; * index of high word * |
ix0 = *(n0+(int*)&x); * high word of x * |
ix1 = *((1-n0)+(int*)&x); * low word of x * |
to dig two 32 bit words out of the 64 bit IEEE floating point |
value. That is non-ANSI, and, moreover, the gcc instruction |
scheduler gets it wrong. We instead use the following macros. |
Unlike the original code, we determine the endianness at compile |
time, not at run time; I don't see much benefit to selecting |
endianness at run time. */ |
/* A union which permits us to convert between a double and two 32 bit |
ints. */ |
typedef int int32_t; |
typedef unsigned int u_int32_t; |
typedef union |
{ |
double value; |
struct |
{ |
u_int32_t lsw; |
u_int32_t msw; |
} parts; |
} ieee_double_shape_type; |
/* Get two 32 bit ints from a double. */ |
#define EXTRACT_WORDS(ix0,ix1,d) \ |
do { \ |
ieee_double_shape_type ew_u; \ |
ew_u.value = (d); \ |
(ix0) = ew_u.parts.msw; \ |
(ix1) = ew_u.parts.lsw; \ |
} while (0) |
/* Get the more significant 32 bit int from a double. */ |
#define GET_HIGH_WORD(i,d) \ |
do { \ |
ieee_double_shape_type gh_u; \ |
gh_u.value = (d); \ |
(i) = gh_u.parts.msw; \ |
} while (0) |
/* Get the less significant 32 bit int from a double. */ |
#define GET_LOW_WORD(i,d) \ |
do { \ |
ieee_double_shape_type gl_u; \ |
gl_u.value = (d); \ |
(i) = gl_u.parts.lsw; \ |
} while (0) |
/* Set a double from two 32 bit ints. */ |
#define INSERT_WORDS(d,ix0,ix1) \ |
do { \ |
ieee_double_shape_type iw_u; \ |
iw_u.parts.msw = (ix0); \ |
iw_u.parts.lsw = (ix1); \ |
(d) = iw_u.value; \ |
} while (0) |
/* Set the more significant 32 bits of a double from an int. */ |
#define SET_HIGH_WORD(d,v) \ |
do { \ |
ieee_double_shape_type sh_u; \ |
sh_u.value = (d); \ |
sh_u.parts.msw = (v); \ |
(d) = sh_u.value; \ |
} while (0) |
/* Set the less significant 32 bits of a double from an int. */ |
#define SET_LOW_WORD(d,v) \ |
do { \ |
ieee_double_shape_type sl_u; \ |
sl_u.value = (d); \ |
sl_u.parts.lsw = (v); \ |
(d) = sl_u.value; \ |
} while (0) |
/* A union which permits us to convert between a float and a 32 bit |
int. */ |
typedef union |
{ |
float value; |
u_int32_t word; |
} ieee_float_shape_type; |
/* Get a 32 bit int from a float. */ |
#define GET_FLOAT_WORD(i,d) \ |
do { \ |
ieee_float_shape_type gf_u; \ |
gf_u.value = (d); \ |
(i) = gf_u.word; \ |
} while (0) |
/* Set a float from a 32 bit int. */ |
#define SET_FLOAT_WORD(d,i) \ |
do { \ |
ieee_float_shape_type sf_u; \ |
sf_u.word = (i); \ |
(d) = sf_u.value; \ |
} while (0) |
/* A union which permits us to convert between a long double and |
three 32 bit ints. */ |
typedef union |
{ |
long double value; |
struct |
{ |
u_int32_t lsw; |
u_int32_t msw; |
unsigned int sign_exponent:16; |
unsigned int empty:16; |
} parts; |
} ieee_long_double_shape_type; |
/* Get three 32 bit ints from a double. */ |
#define GET_LDOUBLE_WORDS(exp,ix0,ix1,d) \ |
do { \ |
ieee_long_double_shape_type ew_u; \ |
ew_u.value = (d); \ |
(exp) = ew_u.parts.sign_exponent; \ |
(ix0) = ew_u.parts.msw; \ |
(ix1) = ew_u.parts.lsw; \ |
} while (0) |
/* Set a double from two 32 bit ints. */ |
#define SET_LDOUBLE_WORDS(d,exp,ix0,ix1) \ |
do { \ |
ieee_long_double_shape_type iw_u; \ |
iw_u.parts.sign_exponent = (exp); \ |
iw_u.parts.msw = (ix0); \ |
iw_u.parts.lsw = (ix1); \ |
(d) = iw_u.value; \ |
} while (0) |
/* Get the more significant 32 bits of a long double mantissa. */ |
#define GET_LDOUBLE_MSW(v,d) \ |
do { \ |
ieee_long_double_shape_type sh_u; \ |
sh_u.value = (d); \ |
(v) = sh_u.parts.msw; \ |
} while (0) |
/* Set the more significant 32 bits of a long double mantissa from an int. */ |
#define SET_LDOUBLE_MSW(d,v) \ |
do { \ |
ieee_long_double_shape_type sh_u; \ |
sh_u.value = (d); \ |
sh_u.parts.msw = (v); \ |
(d) = sh_u.value; \ |
} while (0) |
/* Get int from the exponent of a long double. */ |
#define GET_LDOUBLE_EXP(exp,d) \ |
do { \ |
ieee_long_double_shape_type ge_u; \ |
ge_u.value = (d); \ |
(exp) = ge_u.parts.sign_exponent; \ |
} while (0) |
/* Set exponent of a long double from an int. */ |
#define SET_LDOUBLE_EXP(d,exp) \ |
do { \ |
ieee_long_double_shape_type se_u; \ |
se_u.value = (d); \ |
se_u.parts.sign_exponent = (exp); \ |
(d) = se_u.value; \ |
} while (0) |
#endif /* _MATH_PRIVATE_H_ */ |
/programs/media/ac97 mp3/trunk/mp3dec/mp3dec.c |
---|
0,0 → 1,513 |
#include "mp3dec.h" |
#include <string.h> |
#include <math.h> |
typedef unsigned char byte; |
typedef unsigned int uint; |
typedef unsigned short ushort; |
static const int br_tbl[3][3][16] = { |
{// MPEG-1 |
// Layer1 |
{ 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 0 }, |
// Layer2 |
{ 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 0 }, |
// Layer3 |
{ 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0 }, |
}, |
{// MPEG-2 |
// Layer1 |
{ 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0 }, |
// Layer2 |
{ 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 }, |
// Layer3 |
{ 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 }, |
}, |
{// MPEG-2.5 |
// Layer1 (not available) |
{ 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0 }, |
// Layer2 (not available) |
{ 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 }, |
// Layer3 |
{ 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 }, |
}, |
}; |
static const int fr_tbl[3][4] = { |
// MPEG-1 |
{ 44100, 48000, 32000, 0/*reserved*/ }, |
// MPEG-2 |
{ 22050, 24000, 16000, 0/*reserved*/ }, |
// MPEG-2.5 |
{ 11025, 12000, 8000, 0/*reserved*/ }, |
}; |
/* 1999/11/01í |
static const double ms_p_f_table[3][3] = |
{ |
// Layer1 |
{8.707483f, 8.0f, 12.0f}, |
// Layer2 |
{26.12245f, 24.0f, 36.0f}, |
// Layer3 |
{26.12245f, 24.0f, 36.0f}, |
}; |
*/ |
typedef void (*FRAME_PROC) (MPEG_HEADER* h, byte* mpeg, byte* pcm); |
MPEG_DECODE_OPTION m_option; |
FRAME_PROC m_frame_proc; |
int m_last_error; |
int m_frequency; |
int m_frame_size, m_pcm_size; |
int m_enableEQ; |
float m_equalizer[32]; |
//float m_band_tbl[2][32]; |
void L1table_init(); |
void L2table_init(); |
void L3table_init(); |
void L1decode_start(MPEG_HEADER* h); |
void L2decode_start(MPEG_HEADER* h); |
void L3decode_start(MPEG_HEADER* h); |
void L1decode_frame(MPEG_HEADER* h, byte* mpeg, byte* pcm); |
void L2decode_frame(MPEG_HEADER* h, byte* mpeg, byte* pcm); |
void L3decode_frame(MPEG_HEADER* h, byte* mpeg, byte* pcm); |
void _stdcall debug_out_hex(unsigned int val); |
void debug_out_str(char* str); |
void mp3DecodeInit() |
{ |
// _set_SSE2_enable(0); |
m_option.reduction = 0; |
m_option.convert = 0; |
m_option.freqLimit = 24000; |
L1table_init(); |
L2table_init(); |
L3table_init(); |
} |
int mp3GetHeader(byte* buf, MPEG_HEADER* h) |
{ |
h->version = (buf[1] & 0x08) >> 3; |
h->layer = (buf[1] & 0x06) >> 1; |
h->error_prot = (buf[1] & 0x01); |
h->br_index = (buf[2] & 0xf0) >> 4; |
h->fr_index = (buf[2] & 0x0c) >> 2; |
h->padding = (buf[2] & 0x02) >> 1; |
h->extension = (buf[2] & 0x01); |
h->mode = (buf[3] & 0xc0) >> 6; |
h->mode_ext = (buf[3] & 0x30) >> 4; |
h->copyright = (buf[3] & 0x08) >> 3; |
h->original = (buf[3] & 0x04) >> 2; |
h->emphasis = (buf[3] & 0x03); |
if (buf[0] != 0xFF) {//sync error |
m_last_error = MP3_ERROR_INVALID_SYNC; |
return 0; |
} |
if ((buf[1] & 0xF0) == 0xF0) //MPEG-1, MPEG-2 |
h->version = (h->version) ? 1 : 2; |
else if ((buf[1] & 0xF0) == 0xE0) //MPEG-2.5 |
h->version = 3; |
else { |
m_last_error = MP3_ERROR_INVALID_SYNC; |
return 0; |
} |
if (h->fr_index >= 3 || |
h->br_index == 0 || h->br_index >= 15 || |
h->layer == 0 || h->layer >= 4) { |
m_last_error = MP3_ERROR_INVALID_HEADER; |
return 0; |
} |
h->layer = 4 - h->layer; |
h->error_prot = (h->error_prot) ? 0 : 1; |
return 1; |
} |
int mp3GetLastError() |
{ |
return m_last_error; |
} |
int mp3FindSync(byte* buf, int size, int* sync) |
{ |
int i; |
*sync = 0; |
size -= 3; |
if (size <= 0) { |
m_last_error = MP3_ERROR_OUT_OF_BUFFER; |
return 0; |
} |
for (i = 0; i < size; i ++) { |
if (buf[i] == 0xFF) { |
if ((buf[i + 1] & 0xF0) == 0xF0) { |
break; |
} |
else if ((buf[i + 1] & 0xF0) == 0xE0) { |
break; |
} |
} |
} |
if (i == size) { |
m_last_error = MP3_ERROR_OUT_OF_BUFFER; |
return 0; |
} |
*sync = i; |
return 1; |
} |
void mp3GetDecodeOption(MPEG_DECODE_OPTION* option) |
{ |
*option = m_option; |
} |
int mp3SetDecodeOption(MPEG_DECODE_OPTION* option) |
{ |
m_option = *option; |
return 1; |
} |
int mp3SetEqualizer(int* value) |
{ |
int i; |
if (value == (void*)0) { |
m_enableEQ = 0; |
return 1; |
} |
m_enableEQ = 1; |
//60, 170, 310, 600, 1K, 3K |
for (i = 0; i < 6; i ++) { |
m_equalizer[i] = (float)pow_test(10,(double)value[i]/200); |
} |
//6K |
m_equalizer[6] = (float)pow_test(10,(double)value[6]/200); |
m_equalizer[7] = m_equalizer[6]; |
//12K |
m_equalizer[8] = (float)pow_test(10,(double)value[7]/200); |
m_equalizer[9] = m_equalizer[8]; |
m_equalizer[10] = m_equalizer[8]; |
m_equalizer[11] = m_equalizer[8]; |
//14K |
m_equalizer[12] = (float)pow_test(10,(double)value[8]/200); |
m_equalizer[13] = m_equalizer[12]; |
m_equalizer[14] = m_equalizer[12]; |
m_equalizer[15] = m_equalizer[12]; |
m_equalizer[16] = m_equalizer[12]; |
m_equalizer[17] = m_equalizer[12]; |
m_equalizer[18] = m_equalizer[12]; |
m_equalizer[19] = m_equalizer[12]; |
//16K |
m_equalizer[20] = (float)pow_test(10,(double)value[9]/200); |
m_equalizer[21] = m_equalizer[20]; |
m_equalizer[22] = m_equalizer[20]; |
m_equalizer[23] = m_equalizer[20]; |
m_equalizer[24] = m_equalizer[20]; |
m_equalizer[25] = m_equalizer[20]; |
m_equalizer[26] = m_equalizer[20]; |
m_equalizer[27] = m_equalizer[20]; |
m_equalizer[28] = m_equalizer[20]; |
m_equalizer[29] = m_equalizer[20]; |
m_equalizer[30] = m_equalizer[20]; |
m_equalizer[31] = m_equalizer[20]; |
return 1; |
} |
#define VBR_FRAMES_FLAG 0x0001 |
#define VBR_BYTES_FLAG 0x0002 |
#define VBR_TOC_FLAG 0x0004 |
#define VBR_SCALE_FLAG 0x0008 |
static int extractInt4(byte* buf) |
{// big endian extract |
return buf[3] | (buf[2] << 8) | |
(buf[1] << 16) | (buf[0] << 24); |
} |
int mp3GetDecodeInfo(byte* mpeg, int size, MPEG_DECODE_INFO* info, int decFlag) |
{ |
MPEG_HEADER* h = &info->header; |
byte* p = mpeg; |
int vbr; |
uint minBitRate, maxBitRate; |
uint i, j, flags; |
//int bitRate; |
//int frame_size; |
if (size < 156) {//max vbr header size |
m_last_error = MP3_ERROR_OUT_OF_BUFFER; |
return 0; |
} |
if (!mp3GetHeader(p, h)) { |
return 0; |
} |
//check VBR Header |
p += 4;//skip mpeg header |
if (h->error_prot) p += 2;//skip crc |
if (h->layer == 3) {//skip side info |
if (h->version == 1) {//MPEG-1 |
if (h->mode != 3) p += 32; |
else p += 17; |
} |
else {//MPEG-2, MPEG-2.5 |
if (h->mode != 3) p += 17; |
else p += 9; |
} |
} |
info->bitRate = br_tbl[h->version-1][h->layer-1][h->br_index] * 1000; |
info->frequency = fr_tbl[h->version-1][h->fr_index]; |
if (memcmp(p, "Xing", 4) == 0) {//VBR |
p += 4; |
flags = extractInt4(p); |
p += 4; |
if (!(flags & (VBR_FRAMES_FLAG | VBR_BYTES_FLAG))) { |
m_last_error = MP3_ERROR_INVALID_HEADER; |
return 0; |
} |
info->frames = extractInt4(p); |
p += 4; |
info->dataSize = extractInt4(p); |
p += 4; |
if (flags & VBR_TOC_FLAG) p += 100; |
if (flags & VBR_SCALE_FLAG) p += 4; |
/*///////////////////////////////// |
//WVBRÎ |
if ( p[0] == mpeg[0] && p[1] == mpeg[1] ) { |
info->skipSize = (int)(p - mpeg); |
} else { |
info->bitRate = br_tbl[h->version-1][h->layer-1][h->br_index] * 1000; |
switch (h->layer) { |
case 1://layer1 |
m_frame_size = (12 * info->bitRate / fr_tbl[h->version-1][h->fr_index]) * 4;//one slot is 4 bytes long |
if (h->padding) m_frame_size += 4; |
break; |
case 2://layer2 |
m_frame_size = 144 * info->bitRate / fr_tbl[h->version-1][h->fr_index]; |
if (h->padding) m_frame_size ++; |
break; |
case 3://layer3 |
m_frame_size = 144 * info->bitRate / fr_tbl[h->version-1][h->fr_index]; |
if (h->version != 1) //MPEG-2, MPEG-2.5 |
m_frame_size /= 2; |
if (h->padding) m_frame_size; |
break; |
} |
info->skipSize = (int)(m_frame_size); |
} |
info->bitRate = 0; |
/////////////////////////////////*/ |
vbr = 1; |
minBitRate = 0xffffffff; |
maxBitRate = 0; |
for (i = 1; i < 15; i ++) { |
j = br_tbl[h->version-1][h->layer-1][i] * 1000; |
if (j < minBitRate) minBitRate = j; |
if (j > maxBitRate) maxBitRate = j; |
} |
} |
else if (memcmp(p, "VBRI", 4) == 0) {//VBRI |
p += 10; |
info->dataSize = extractInt4(p); |
p += 4; |
info->frames = extractInt4(p); |
p += 4; |
vbr = 1; |
minBitRate = 0xffffffff; |
maxBitRate = 0; |
for (i = 1; i < 15; i ++) { |
j = br_tbl[h->version-1][h->layer-1][i] * 1000; |
if (j < minBitRate) minBitRate = j; |
if (j > maxBitRate) maxBitRate = j; |
} |
} |
else {//not VBR |
vbr = 0; |
info->frames = 0; |
//info->skipSize = 0; |
info->dataSize = 0; |
//info->bitRate = br_tbl[h->version-1][h->layer-1][h->br_index] * 1000; |
} |
// info->frequency = fr_tbl[h->version-1][h->fr_index]; |
// info->msPerFrame = ms_p_f_table[h->layer-1][h->fr_index]; |
// if (h->version == 3) info->msPerFrame *= 2; |
switch (h->layer) { |
case 1://layer1 |
info->outputSize = 384 >> m_option.reduction; |
//if (info->bitRate) { |
if (!vbr) { |
info->skipSize = 0; |
info->minInputSize = (12 * info->bitRate / info->frequency) * 4;//one slot is 4 bytes long |
info->maxInputSize = info->minInputSize + 4; |
} |
else { |
info->skipSize = (12 * info->bitRate / info->frequency + h->padding) * 4; |
info->minInputSize = (12 * minBitRate / info->frequency) * 4; |
info->maxInputSize = (12 * maxBitRate / info->frequency) * 4 + 4; |
} |
break; |
case 2://layer2 |
info->outputSize = 1152 >> m_option.reduction; |
//if (info->bitRate) { |
if (!vbr) { |
info->skipSize = 0; |
info->minInputSize = 144 * info->bitRate / info->frequency; |
info->maxInputSize = info->minInputSize + 1; |
} |
else { |
info->skipSize = 144 * info->bitRate / info->frequency + h->padding; |
info->minInputSize = 144 * minBitRate / info->frequency; |
info->maxInputSize = 144 * maxBitRate / info->frequency + 1; |
} |
break; |
case 3://layer3 |
i = (h->version == 1) ? 1 : 2; |
//info->outputSize = 1152 >> m_option.reduction; |
info->outputSize = (1152 >> m_option.reduction) / i; |
//if (info->bitRate) { |
if (!vbr) { |
info->skipSize = 0; |
info->minInputSize = 144 * info->bitRate / info->frequency / i; |
info->maxInputSize = info->minInputSize + 1; |
} |
else { |
info->skipSize = 144 * info->bitRate / info->frequency / i + h->padding; |
info->minInputSize = 144 * minBitRate / info->frequency / i; |
info->maxInputSize = 144 * maxBitRate / info->frequency / i + 1; |
} |
break; |
/* |
if (h->version != 1) { |
//MPEG-2, MPEG-2.5 |
info->outputSize /= 2; |
info->minInputSize /= 2; |
info->maxInputSize /= 2; |
} |
info->maxInputSize ++; |
break; */ |
} |
if ((h->mode == 3) || (m_option.convert & 3)) |
info->channels = 1; |
else |
info->channels = 2; |
if (m_option.convert & 8) { |
//not available |
info->bitsPerSample = 8; |
info->outputSize *= info->channels; |
} |
else { |
info->bitsPerSample = 16; |
info->outputSize *= info->channels * 2; |
} |
if ( decFlag == 1 ) { |
m_frequency = info->frequency; |
m_pcm_size = info->outputSize; |
} |
info->frequency >>= m_option.reduction; |
if (vbr) info->bitRate = 0; |
return 1; |
} |
void sbt_init(); |
int mp3DecodeStart(byte* mpeg, int size) |
{ |
MPEG_DECODE_INFO info; |
MPEG_HEADER* h = &info.header; |
if (!mp3GetDecodeInfo(mpeg, size, &info, 1)) { |
return 0; |
} |
sbt_init(); |
switch (h->layer) { |
case 1: |
L1decode_start(h); |
m_frame_proc = L1decode_frame; |
break; |
case 2: |
L2decode_start(h); |
m_frame_proc = L2decode_frame; |
break; |
case 3: |
L3decode_start(h); |
m_frame_proc = L3decode_frame; |
break; |
} |
return 1; |
} |
int mp3DecodeFrame(MPEG_DECODE_PARAM* param) |
{ |
MPEG_HEADER* h = ¶m->header; |
if (param->inputSize <= 4) { |
m_last_error = MP3_ERROR_OUT_OF_BUFFER; |
return 0; |
} |
if (!mp3GetHeader(param->inputBuf, h)) { |
return 0; |
} |
param->bitRate = br_tbl[h->version-1][h->layer-1][h->br_index] * 1000; |
switch (h->layer) { |
case 1://layer1 |
m_frame_size = (12 * param->bitRate / m_frequency + h->padding) * 4; |
break; |
case 2://layer2 |
m_frame_size = 144 * param->bitRate / m_frequency + h->padding; |
break; |
case 3://layer3 |
if (h->version == 1) m_frame_size = 144 * param->bitRate / m_frequency + h->padding; |
else m_frame_size = (144 * param->bitRate / m_frequency) / 2 + h->padding; |
break; |
} |
if (param->inputSize < m_frame_size) { |
m_last_error = MP3_ERROR_OUT_OF_BUFFER; |
return 0; |
} |
m_frame_proc(h, param->inputBuf, param->outputBuf); |
param->inputSize = m_frame_size; |
param->outputSize = m_pcm_size; |
return 1; |
} |
void null_frame_proc(MPEG_HEADER* h, byte* mpeg, byte* pcm) {} |
void L3decode_reset(); |
void mp3MuteStart(MPEG_DECODE_PARAM* param) |
{ |
m_frame_proc = null_frame_proc; |
} |
void mp3MuteEnd(MPEG_DECODE_PARAM* param) |
{ |
MPEG_HEADER* h = ¶m->header; |
switch (h->layer) { |
case 1: |
m_frame_proc = L1decode_frame; |
break; |
case 2: |
m_frame_proc = L2decode_frame; |
break; |
case 3: |
L3decode_reset(); |
m_frame_proc = L3decode_frame; |
break; |
} |
} |
/programs/media/ac97 mp3/trunk/mp3dec/mp3dec.h |
---|
0,0 → 1,76 |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define MP3_ERROR_UNKNOWN 1 |
#define MP3_ERROR_INVALID_PARAMETER 2 |
#define MP3_ERROR_INVALID_SYNC 3 |
#define MP3_ERROR_INVALID_HEADER 4 |
#define MP3_ERROR_OUT_OF_BUFFER 5 |
typedef struct { |
int version; //1:MPEG-1, 2:MPEG-2, 3:MPEG-2.5 |
int layer; //1:Layer1, 2:Layer2, 3:Layer3 |
int error_prot; //1:CRC on, 0:CRC off |
int br_index; |
int fr_index; |
int padding; |
int extension; |
int mode; |
int mode_ext; |
int copyright; |
int original; |
int emphasis; |
} MPEG_HEADER; |
typedef struct { |
int reduction; |
int convert; |
int freqLimit; |
} MPEG_DECODE_OPTION; |
typedef struct { |
MPEG_HEADER header; |
int channels; //oÍ`l |
int bitsPerSample; // |
int frequency; //TvO[giHzj |
int bitRate; //rbg[gibpsj |
int frames; //t[iVBR onlyj |
int skipSize; //iVBR onlyj |
int dataSize; //f[^TCYiVBR onlyj |
int minInputSize; //1t[ÌŬüÍTCY |
int maxInputSize; //1t[ÌÅåüÍTCY |
int outputSize; //1t[ÌoÍTCY |
} MPEG_DECODE_INFO; |
typedef struct { |
MPEG_HEADER header; |
int bitRate; //rbg[gibpsj |
void* inputBuf; |
int inputSize; |
void* outputBuf; |
int outputSize; |
} MPEG_DECODE_PARAM; |
void mp3DecodeInit(); |
int mp3GetLastError(); |
int mp3SetDecodeOption(MPEG_DECODE_OPTION* option); |
void mp3GetDecodeOption(MPEG_DECODE_OPTION* option); |
int mp3SetEqualizer(int* value); |
int mp3FindSync(void* buf, int size, int* sync); |
int mp3GetDecodeInfo(void* mpeg, int size, MPEG_DECODE_INFO* info, int decFlag); |
int mp3DecodeStart(void* buf, int size); |
int mp3DecodeFrame(MPEG_DECODE_PARAM* param); |
void mp3MuteStart(MPEG_DECODE_PARAM* param); |
void mp3MuteEnd(MPEG_DECODE_PARAM* param); |
double pow_test(double, double); |
#ifdef __cplusplus |
} |
#endif |
/programs/media/ac97 mp3/trunk/mp3dec/mp3dec.vcproj |
---|
0,0 → 1,280 |
<?xml version="1.0" encoding="windows-1251"?> |
<VisualStudioProject |
ProjectType="Visual C++" |
Version="8,00" |
Name="mp3dec" |
ProjectGUID="{97BF69A3-826A-47D6-94E4-05FDD8CFF1FC}" |
RootNamespace="mp3dec" |
Keyword="Win32Proj" |
> |
<Platforms> |
<Platform |
Name="Win32" |
/> |
</Platforms> |
<ToolFiles> |
</ToolFiles> |
<Configurations> |
<Configuration |
Name="Debug|Win32" |
OutputDirectory="$(SolutionDir)$(ConfigurationName)" |
IntermediateDirectory="$(ConfigurationName)" |
ConfigurationType="4" |
CharacterSet="1" |
> |
<Tool |
Name="VCPreBuildEventTool" |
/> |
<Tool |
Name="VCCustomBuildTool" |
/> |
<Tool |
Name="VCXMLDataGeneratorTool" |
/> |
<Tool |
Name="VCWebServiceProxyGeneratorTool" |
/> |
<Tool |
Name="VCMIDLTool" |
/> |
<Tool |
Name="VCCLCompilerTool" |
Optimization="0" |
PreprocessorDefinitions="WIN32;_DEBUG;_LIB" |
MinimalRebuild="true" |
BasicRuntimeChecks="3" |
RuntimeLibrary="3" |
UsePrecompiledHeader="0" |
WarningLevel="3" |
Detect64BitPortabilityProblems="true" |
DebugInformationFormat="4" |
/> |
<Tool |
Name="VCManagedResourceCompilerTool" |
/> |
<Tool |
Name="VCResourceCompilerTool" |
/> |
<Tool |
Name="VCPreLinkEventTool" |
/> |
<Tool |
Name="VCLibrarianTool" |
/> |
<Tool |
Name="VCALinkTool" |
/> |
<Tool |
Name="VCXDCMakeTool" |
/> |
<Tool |
Name="VCBscMakeTool" |
/> |
<Tool |
Name="VCFxCopTool" |
/> |
<Tool |
Name="VCPostBuildEventTool" |
/> |
</Configuration> |
<Configuration |
Name="Release|Win32" |
OutputDirectory="$(SolutionDir)$(ConfigurationName)" |
IntermediateDirectory="$(ConfigurationName)" |
ConfigurationType="4" |
CharacterSet="1" |
WholeProgramOptimization="1" |
> |
<Tool |
Name="VCPreBuildEventTool" |
/> |
<Tool |
Name="VCCustomBuildTool" |
/> |
<Tool |
Name="VCXMLDataGeneratorTool" |
/> |
<Tool |
Name="VCWebServiceProxyGeneratorTool" |
/> |
<Tool |
Name="VCMIDLTool" |
/> |
<Tool |
Name="VCCLCompilerTool" |
Optimization="2" |
InlineFunctionExpansion="2" |
EnableIntrinsicFunctions="true" |
FavorSizeOrSpeed="1" |
OmitFramePointers="true" |
PreprocessorDefinitions="WIN32;NDEBUG;_LIB" |
ExceptionHandling="0" |
RuntimeLibrary="0" |
StructMemberAlignment="1" |
BufferSecurityCheck="false" |
FloatingPointModel="2" |
UsePrecompiledHeader="0" |
WarningLevel="3" |
Detect64BitPortabilityProblems="true" |
DebugInformationFormat="3" |
CompileAs="1" |
/> |
<Tool |
Name="VCManagedResourceCompilerTool" |
/> |
<Tool |
Name="VCResourceCompilerTool" |
/> |
<Tool |
Name="VCPreLinkEventTool" |
/> |
<Tool |
Name="VCLibrarianTool" |
/> |
<Tool |
Name="VCALinkTool" |
/> |
<Tool |
Name="VCXDCMakeTool" |
/> |
<Tool |
Name="VCBscMakeTool" |
/> |
<Tool |
Name="VCFxCopTool" |
/> |
<Tool |
Name="VCPostBuildEventTool" |
/> |
</Configuration> |
</Configurations> |
<References> |
</References> |
<Files> |
<Filter |
Name="Source Files" |
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" |
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" |
> |
<File |
RelativePath=".\bstream.c" |
> |
</File> |
<File |
RelativePath=".\e_pow.c" |
> |
</File> |
<File |
RelativePath=".\fdct.c" |
> |
</File> |
<File |
RelativePath=".\imdct.c" |
> |
</File> |
<File |
RelativePath=".\l1dec.c" |
> |
</File> |
<File |
RelativePath=".\l1init.c" |
> |
</File> |
<File |
RelativePath=".\l2dec.c" |
> |
</File> |
<File |
RelativePath=".\l2init.c" |
> |
</File> |
<File |
RelativePath=".\l3alias.c" |
> |
</File> |
<File |
RelativePath=".\l3dec.c" |
> |
</File> |
<File |
RelativePath=".\l3huff.c" |
> |
</File> |
<File |
RelativePath=".\l3hybrid.c" |
> |
</File> |
<File |
RelativePath=".\l3init.c" |
> |
</File> |
<File |
RelativePath=".\l3msis.c" |
> |
</File> |
<File |
RelativePath=".\l3quant.c" |
> |
</File> |
<File |
RelativePath=".\l3sf.c" |
> |
</File> |
<File |
RelativePath=".\l3side.c" |
> |
</File> |
<File |
RelativePath=".\mp3dec.c" |
> |
</File> |
<File |
RelativePath=".\pow.asm" |
> |
<FileConfiguration |
Name="Release|Win32" |
> |
<Tool |
Name="VCCustomBuildTool" |
CommandLine="e:\fasm\fasm.exe $(InputPath) $(TargetDir)\$(InputName).obj
" |
Outputs="$(OutDir)\$(InputName).obj" |
/> |
</FileConfiguration> |
</File> |
<File |
RelativePath=".\sbt.c" |
> |
</File> |
<File |
RelativePath=".\sbtb.c" |
> |
</File> |
<File |
RelativePath=".\window.c" |
> |
</File> |
<File |
RelativePath=".\windowb.c" |
> |
</File> |
</Filter> |
<Filter |
Name="Header Files" |
Filter="h;hpp;hxx;hm;inl;inc;xsd" |
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" |
> |
</Filter> |
<Filter |
Name="Resource Files" |
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" |
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" |
> |
</Filter> |
<File |
RelativePath=".\ReadMe.txt" |
> |
</File> |
</Files> |
<Globals> |
</Globals> |
</VisualStudioProject> |
/programs/media/ac97 mp3/trunk/mp3dec/pow.asm |
---|
0,0 → 1,355 |
; ix87 specific implementation of pow function. |
; Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. |
; This file is part of the GNU C Library. |
; Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. |
; The GNU C Library is free software; you can redistribute it and/or |
; modify it under the terms of the GNU Library General Public License as |
; published by the Free Software Foundation; either version 2 of the |
; License, or (at your option) any later version. |
; The GNU C Library is distributed in the hope that it will be useful, |
; but WITHOUT ANY WARRANTY; without even the implied warranty of |
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
; Library General Public License for more details. |
; You should have received a copy of the GNU Library General Public |
; License along with the GNU C Library; see the file COPYING.LIB. If not, |
; write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
; Boston, MA 02111-1307, USA. */ |
format MS COFF |
include 'proc32.inc' |
section '.text' code readable executable |
;public _pow_test@8 |
public _scalbn |
align 4 |
proc _scalbn |
fild dword [esp+12] |
fld qword [esp+4] |
fscale |
fstp st1 |
ret |
endp |
proc _pow_test@8 stdcall x:dword, y:dword |
fld [x] |
fld [y] |
jmp __CIpow |
__CIpow: |
; fldl 12(%esp) // y |
fxam |
fnstsw ax |
mov dl,ah |
and ah, 0x45 |
cmp ah, 0x40 ; is y == 0 ? |
je .L_11 |
cmp ah, 0x05 ; is y == ±inf ? |
je .L_12 |
cmp ah, 0x01 ; is y == NaN ? |
je .L_30 |
fxch |
sub esp, 8 |
fxam |
fnstsw ax |
mov dh, ah |
and ah, 0x45 |
cmp ah, 0x40 |
je .L_20 ; x is ±0 |
cmp ah, 0x05 |
je .L_15 ; x is ±inf |
fxch ; y : x |
; First see whether `y' is a natural number. In this case we |
; can use a more precise algorithm. */ |
fld st ; y : y : x |
fistp qword [esp] ; y : x |
fild qword [esp] ; int(y) : y : x |
fucomp st1 ; y : x |
fnstsw ax |
sahf |
jne .L_2 |
; OK, we have an integer value for y. */ |
pop eax |
pop edx |
or edx,0 |
fstp st0 ; x |
jns .L_4 ; y >= 0, jump |
fidiv dword [one] ; 1/x (now referred to as x) |
neg eax |
adc edx,0 |
neg edx |
.L_4: |
fld1 ; 1 : x |
fxch |
.L_6: |
shrd edx, eax,1 |
jnc .L_5 |
fxch |
fmul st1,st0 ; x : ST*x |
fxch |
.L_5: |
fmul st0, st0 ; x*x : ST*x |
shr edx,1 |
mov ecx, eax |
or ecx, edx |
jnz .L_6 |
fstp st0 ; ST*x |
.L_30: |
ret |
align 4 |
; y is a real number. */ |
.L_2: |
fxch ; x : y |
fld1 ; 1.0 : x : y |
fld st1 ; x : 1.0 : x : y |
fsub st0,st1 ; x-1 : 1.0 : x : y |
fabs ; |x-1| : 1.0 : x : y |
fcomp qword [limit] ; 1.0 : x : y |
fnstsw ax |
fxch ; x : 1.0 : y |
sahf |
ja .L_7 |
fsub st0, st1 ; x-1 : 1.0 : y |
fyl2xp1 ; log2(x) : y |
jmp .L_8 |
.L_7: |
fyl2x ; log2(x) : y |
.L_8: |
fmul st0,st1 ; y*log2(x) : y |
fst st1 ; y*log2(x) : y*log2(x) |
frndint ; int(y*log2(x)) : y*log2(x) |
fsubr st1, st0 ; int(y*log2(x)) : fract(y*log2(x)) |
fxch ; fract(y*log2(x)) : int(y*log2(x)) |
f2xm1 ; 2^fract(y*log2(x))-1 : int(y*log2(x)) |
fld1 |
faddp ; 2^fract(y*log2(x)) : int(y*log2(x)) |
fscale ; 2^fract(y*log2(x))*2^int(y*log2(x)) : int(y*log2(x)) |
add esp,8 |
fstp st1 ; 2^fract(y*log2(x))*2^int(y*log2(x)) |
ret |
align 4 |
; // pow(x,±0) = 1 |
.L_11: |
fstp st0 ; pop y |
fld1 |
ret |
align 4 |
; y == ±inf |
.L_12: |
fstp st0 ; pop y |
; fld 4(%esp) ; x |
fabs |
fcomp qword [one] ; < 1, == 1, or > 1 |
fnstsw ax |
and ah,0x45 |
cmp ah,0x45 |
je .L_13 ; jump if x is NaN |
cmp ah,0x40 |
je .L_14 ; jump if |x| == 1 |
shl ah, 1 |
xor ah, dl |
and edx, 2 |
fld qword [inf_zero+edx+4] |
ret |
align 4 |
.L_14: |
fld qword [infinity] |
fmul qword [zero] ; raise invalid exception |
ret |
align 4 |
.L_13: |
; //fld 4(%esp) // load x == NaN |
ret |
align 4 |
; // x is ±inf |
.L_15: |
fstp st0 ; y |
test dh, 2 |
jz .L_16 ; jump if x == +inf |
; We must find out whether y is an odd integer. |
fld st ; y : y |
fistp qword [esp] ; y |
fild qword [esp] ; int(y) : y |
fucompp ; <empty> |
fnstsw ax |
sahf |
jne .L_17 |
; OK, the value is an integer, but is the number of bits small |
; enough so that all are coming from the mantissa? |
pop eax |
pop edx |
and al, 1 |
jz .L_18 ;// jump if not odd |
mov eax, edx |
or edx, eax |
jns .L_155 |
neg eax |
.L_155: |
cmp eax, 0x00200000 |
ja .L_18 ;// does not fit in mantissa bits |
; It's an odd integer. |
shr edx, 31 |
fld qword [minf_mzero+edx+8] |
ret |
align 4 |
.L_16: |
fcomp qword [zero] |
add esp, 8 |
fnstsw ax |
shr eax, 5 |
and eax, 8 |
fld qword [inf_zero+eax+1] |
ret |
align 4 |
.L_17: |
shl edx, 30 ;// sign bit for y in right position |
add esp ,8 |
.L_18: |
shr edx, 31 |
fld qword [inf_zero+edx+8] |
ret |
align 4 |
; x is ±0 |
.L_20: |
fstp st0 ; y |
test dl,2 |
jz .L_21 ; y > 0 |
;x is ±0 and y is < 0. We must find out whether y is an odd integer. |
test dh, 2 |
jz .L_25 |
fld st ; y : y |
fistp qword [esp] ; y |
fild qword [esp] ; int(y) : y |
fucompp ; <empty> |
fnstsw ax |
sahf |
jne .L_26 |
;OK, the value is an integer, but is the number of bits small |
;enough so that all are coming from the mantissa? |
pop eax |
pop edx |
and al, 1 |
jz .L_27 ; jump if not odd |
cmp edx,0xffe00000 |
jbe .L_27 ; does not fit in mantissa bits |
; It's an odd integer. |
; Raise divide-by-zero exception and get minus infinity value. |
fld1 |
fdiv qword [zero] |
fchs |
ret |
.L_25: |
fstp st0 |
.L_26: |
add esp,8 |
.L_27: |
;Raise divide-by-zero exception and get infinity value. |
fld1 |
fdiv qword [zero] |
ret |
align 4 |
; x is ±0 and y is > 0. We must find out whether y is an odd integer. |
.L_21: |
test dh,2 |
jz .L_22 |
fld st ; y : y |
fistp qword [esp] ; y |
fild qword [esp] ; int(y) : y |
fucompp ; <empty> |
fnstsw ax |
sahf |
jne .L_23 |
; OK, the value is an integer, but is the number of bits small |
; enough so that all are coming from the mantissa? |
pop eax |
pop edx |
and al,1 |
jz .L_24 ; jump if not odd |
cmp edx,0xffe00000 |
jae .L_24 ; does not fit in mantissa bits |
; It's an odd integer. |
fld qword [mzero] |
ret |
.L_22: |
fstp st0 |
.L_23: |
add esp,8 ; Don't use 2 x pop |
.L_24: |
fldz |
ret |
endp |
align 4 |
inf_zero: |
infinity: |
db 0,0,0,0,0,0,0xf0,0x7f |
zero: dq 0.0 |
minf_mzero: |
minfinity: |
db 0,0,0,0,0,0,0xf0,0xff |
mzero: |
db 0,0,0,0,0,0,0,0x80 |
one: |
dq 1.0 |
limit: |
dq 0.29 |
/programs/media/ac97 mp3/trunk/mp3dec/sbt.c |
---|
0,0 → 1,394 |
#include <math.h> |
/* "fdct.c" */ |
void fdct32(float *, float *); |
void fdct32_dual(float *, float *); |
void fdct32_dual_mono(float *, float *); |
void fdct16(float *, float *); |
void fdct16_dual(float *, float *); |
void fdct16_dual_mono(float *, float *); |
void fdct8(float *, float *); |
void fdct8_dual(float *, float *); |
void fdct8_dual_mono(float *, float *); |
/* "window.c" */ |
void window(float *vbuf, int vb_ptr, short *pcm); |
void window_dual(float *vbuf, int vb_ptr, short *pcm); |
void window16(float *vbuf, int vb_ptr, short *pcm); |
void window16_dual(float *vbuf, int vb_ptr, short *pcm); |
void window8(float *vbuf, int vb_ptr, short *pcm); |
void window8_dual(float *vbuf, int vb_ptr, short *pcm); |
/* circular window buffers */ |
int vb_ptr; |
int vb2_ptr; |
float vbuf[512]; |
float vbuf2[512]; |
void sbt_init() |
{ |
int i; |
/* clear window vbuf */ |
for (i = 0; i < 512; i++) |
{ |
vbuf[i] = 0.0F; |
vbuf2[i] = 0.0F; |
} |
vb2_ptr = vb_ptr = 0; |
} |
void sbt_mono(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct32(sample, vbuf + vb_ptr); |
window(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbt_dual(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct32_dual(sample, vbuf + vb_ptr); |
fdct32_dual(sample + 1, vbuf2 + vb_ptr); |
window_dual(vbuf, vb_ptr, pcm); |
window_dual(vbuf2, vb_ptr, pcm + 1); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 64; |
} |
} |
void sbt_dual_mono(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct32_dual_mono(sample, vbuf + vb_ptr); |
window(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbt_dual_left(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct32_dual(sample, vbuf + vb_ptr); |
window(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbt_dual_right(float *sample, short *pcm, int n) |
{ |
int i; |
sample++; /* point to right chan */ |
for (i = 0; i < n; i++) |
{ |
fdct32_dual(sample, vbuf + vb_ptr); |
window(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbt16_mono(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct16(sample, vbuf + vb_ptr); |
window16(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbt16_dual(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct16_dual(sample, vbuf + vb_ptr); |
fdct16_dual(sample + 1, vbuf2 + vb_ptr); |
window16_dual(vbuf, vb_ptr, pcm); |
window16_dual(vbuf2, vb_ptr, pcm + 1); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 32; |
} |
} |
void sbt16_dual_mono(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct16_dual_mono(sample, vbuf + vb_ptr); |
window16(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbt16_dual_left(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct16_dual(sample, vbuf + vb_ptr); |
window16(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbt16_dual_right(float *sample, short *pcm, int n) |
{ |
int i; |
sample++; |
for (i = 0; i < n; i++) |
{ |
fdct16_dual(sample, vbuf + vb_ptr); |
window16(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbt8_mono(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct8(sample, vbuf + vb_ptr); |
window8(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbt8_dual(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct8_dual(sample, vbuf + vb_ptr); |
fdct8_dual(sample + 1, vbuf2 + vb_ptr); |
window8_dual(vbuf, vb_ptr, pcm); |
window8_dual(vbuf2, vb_ptr, pcm + 1); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 16; |
} |
} |
void sbt8_dual_mono(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct8_dual_mono(sample, vbuf + vb_ptr); |
window8(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbt8_dual_left(float *sample, short *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct8_dual(sample, vbuf + vb_ptr); |
window8(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbt8_dual_right(float *sample, short *pcm, int n) |
{ |
int i; |
sample++; |
for (i = 0; i < n; i++) |
{ |
fdct8_dual(sample, vbuf + vb_ptr); |
window8(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbt_mono_L3(float *sample, short *pcm, int ch) |
{ |
int i; |
ch = 0; |
for (i = 0; i < 18; i++) |
{ |
fdct32(sample, vbuf + vb_ptr); |
window(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbt_dual_L3(float *sample, short *pcm, int ch) |
{ |
int i; |
if (ch == 0) |
for (i = 0; i < 18; i++) { |
fdct32(sample, vbuf + vb_ptr); |
window_dual(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 64; |
} |
else |
for (i = 0; i < 18; i++) { |
fdct32(sample, vbuf2 + vb2_ptr); |
window_dual(vbuf2, vb2_ptr, pcm + 1); |
sample += 32; |
vb2_ptr = (vb2_ptr - 32) & 511; |
pcm += 64; |
} |
} |
void sbt16_mono_L3(float *sample, short *pcm, int ch) |
{ |
int i; |
ch = 0; |
for (i = 0; i < 18; i++) |
{ |
fdct16(sample, vbuf + vb_ptr); |
window16(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbt16_dual_L3(float *sample, short *pcm, int ch) |
{ |
int i; |
if (ch == 0) |
{ |
for (i = 0; i < 18; i++) |
{ |
fdct16(sample, vbuf + vb_ptr); |
window16_dual(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 32; |
} |
} |
else |
{ |
for (i = 0; i < 18; i++) |
{ |
fdct16(sample, vbuf2 + vb2_ptr); |
window16_dual(vbuf2, vb2_ptr, pcm + 1); |
sample += 32; |
vb2_ptr = (vb2_ptr - 16) & 255; |
pcm += 32; |
} |
} |
} |
void sbt8_mono_L3(float *sample, short *pcm, int ch) |
{ |
int i; |
ch = 0; |
for (i = 0; i < 18; i++) |
{ |
fdct8(sample, vbuf + vb_ptr); |
window8(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbt8_dual_L3(float *sample, short *pcm, int ch) |
{ |
int i; |
if (ch == 0) |
{ |
for (i = 0; i < 18; i++) |
{ |
fdct8(sample, vbuf + vb_ptr); |
window8_dual(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 16; |
} |
} |
else |
{ |
for (i = 0; i < 18; i++) |
{ |
fdct8(sample, vbuf2 + vb2_ptr); |
window8_dual(vbuf2, vb2_ptr, pcm + 1); |
sample += 32; |
vb2_ptr = (vb2_ptr - 8) & 127; |
pcm += 16; |
} |
} |
} |
/programs/media/ac97 mp3/trunk/mp3dec/sbtb.c |
---|
0,0 → 1,382 |
#include <math.h> |
/* "fdct.c" */ |
void fdct32(float *, float *); |
void fdct32_dual(float *, float *); |
void fdct32_dual_mono(float *, float *); |
void fdct16(float *, float *); |
void fdct16_dual(float *, float *); |
void fdct16_dual_mono(float *, float *); |
void fdct8(float *, float *); |
void fdct8_dual(float *, float *); |
void fdct8_dual_mono(float *, float *); |
/* "windowb.c" */ |
void windowB(float *vbuf, int vb_ptr, unsigned char *pcm); |
void windowB_dual(float *vbuf, int vb_ptr, unsigned char *pcm); |
void windowB16(float *vbuf, int vb_ptr, unsigned char *pcm); |
void windowB16_dual(float *vbuf, int vb_ptr, unsigned char *pcm); |
void windowB8(float *vbuf, int vb_ptr, unsigned char *pcm); |
void windowB8_dual(float *vbuf, int vb_ptr, unsigned char *pcm); |
extern int vb_ptr; |
extern int vb2_ptr; |
extern float vbuf[512]; |
extern float vbuf2[512]; |
void sbtB_mono(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct32(sample, vbuf + vb_ptr); |
windowB(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbtB_dual(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct32_dual(sample, vbuf + vb_ptr); |
fdct32_dual(sample + 1, vbuf2 + vb_ptr); |
windowB_dual(vbuf, vb_ptr, pcm); |
windowB_dual(vbuf2, vb_ptr, pcm + 1); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 64; |
} |
} |
void sbtB_dual_mono(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct32_dual_mono(sample, vbuf + vb_ptr); |
windowB(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbtB_dual_left(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct32_dual(sample, vbuf + vb_ptr); |
windowB(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbtB_dual_right(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
sample++; /* point to right chan */ |
for (i = 0; i < n; i++) |
{ |
fdct32_dual(sample, vbuf + vb_ptr); |
windowB(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbtB16_mono(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct16(sample, vbuf + vb_ptr); |
windowB16(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbtB16_dual(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct16_dual(sample, vbuf + vb_ptr); |
fdct16_dual(sample + 1, vbuf2 + vb_ptr); |
windowB16_dual(vbuf, vb_ptr, pcm); |
windowB16_dual(vbuf2, vb_ptr, pcm + 1); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 32; |
} |
} |
void sbtB16_dual_mono(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct16_dual_mono(sample, vbuf + vb_ptr); |
windowB16(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbtB16_dual_left(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct16_dual(sample, vbuf + vb_ptr); |
windowB16(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbtB16_dual_right(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
sample++; |
for (i = 0; i < n; i++) |
{ |
fdct16_dual(sample, vbuf + vb_ptr); |
windowB16(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbtB8_mono(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct8(sample, vbuf + vb_ptr); |
windowB8(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbtB8_dual(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct8_dual(sample, vbuf + vb_ptr); |
fdct8_dual(sample + 1, vbuf2 + vb_ptr); |
windowB8_dual(vbuf, vb_ptr, pcm); |
windowB8_dual(vbuf2, vb_ptr, pcm + 1); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 16; |
} |
} |
void sbtB8_dual_mono(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct8_dual_mono(sample, vbuf + vb_ptr); |
windowB8(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbtB8_dual_left(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
for (i = 0; i < n; i++) |
{ |
fdct8_dual(sample, vbuf + vb_ptr); |
windowB8(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbtB8_dual_right(float *sample, unsigned char *pcm, int n) |
{ |
int i; |
sample++; |
for (i = 0; i < n; i++) |
{ |
fdct8_dual(sample, vbuf + vb_ptr); |
windowB8(vbuf, vb_ptr, pcm); |
sample += 64; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbtB_mono_L3(float *sample, unsigned char *pcm, int ch) |
{ |
int i; |
ch = 0; |
for (i = 0; i < 18; i++) |
{ |
fdct32(sample, vbuf + vb_ptr); |
windowB(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 32; |
} |
} |
void sbtB_dual_L3(float *sample, unsigned char *pcm, int ch) |
{ |
int i; |
if (ch == 0) |
for (i = 0; i < 18; i++) |
{ |
fdct32(sample, vbuf + vb_ptr); |
windowB_dual(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 32) & 511; |
pcm += 64; |
} |
else |
for (i = 0; i < 18; i++) |
{ |
fdct32(sample, vbuf2 + vb2_ptr); |
windowB_dual(vbuf2, vb2_ptr, pcm + 1); |
sample += 32; |
vb2_ptr = (vb2_ptr - 32) & 511; |
pcm += 64; |
} |
} |
void sbtB16_mono_L3(float *sample, unsigned char *pcm, int ch) |
{ |
int i; |
ch = 0; |
for (i = 0; i < 18; i++) |
{ |
fdct16(sample, vbuf + vb_ptr); |
windowB16(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 16; |
} |
} |
void sbtB16_dual_L3(float *sample, unsigned char *pcm, int ch) |
{ |
int i; |
if (ch == 0) |
{ |
for (i = 0; i < 18; i++) |
{ |
fdct16(sample, vbuf + vb_ptr); |
windowB16_dual(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 16) & 255; |
pcm += 32; |
} |
} |
else |
{ |
for (i = 0; i < 18; i++) |
{ |
fdct16(sample, vbuf2 + vb2_ptr); |
windowB16_dual(vbuf2, vb2_ptr, pcm + 1); |
sample += 32; |
vb2_ptr = (vb2_ptr - 16) & 255; |
pcm += 32; |
} |
} |
} |
void sbtB8_mono_L3(float *sample, unsigned char *pcm, int ch) |
{ |
int i; |
ch = 0; |
for (i = 0; i < 18; i++) |
{ |
fdct8(sample, vbuf + vb_ptr); |
windowB8(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 8; |
} |
} |
void sbtB8_dual_L3(float *sample, unsigned char *pcm, int ch) |
{ |
int i; |
if (ch == 0) |
{ |
for (i = 0; i < 18; i++) |
{ |
fdct8(sample, vbuf + vb_ptr); |
windowB8_dual(vbuf, vb_ptr, pcm); |
sample += 32; |
vb_ptr = (vb_ptr - 8) & 127; |
pcm += 16; |
} |
} |
else |
{ |
for (i = 0; i < 18; i++) |
{ |
fdct8(sample, vbuf2 + vb2_ptr); |
windowB8_dual(vbuf2, vb2_ptr, pcm + 1); |
sample += 32; |
vb2_ptr = (vb2_ptr - 8) & 127; |
pcm += 16; |
} |
} |
} |
/programs/media/ac97 mp3/trunk/mp3dec/window.c |
---|
0,0 → 1,503 |
// disable precision loss warning on type conversion |
#ifdef _MSC_VER |
#pragma warning(disable:4244 4056) |
#endif |
float wincoef[264] = |
{ // window coefs |
0.000000000f, 0.000442505f, -0.003250122f, 0.007003784f, |
-0.031082151f, 0.078628540f, -0.100311279f, 0.572036743f, |
-1.144989014f, -0.572036743f, -0.100311279f, -0.078628540f, |
-0.031082151f, -0.007003784f, -0.003250122f, -0.000442505f, |
0.000015259f, 0.000473022f, -0.003326416f, 0.007919312f, |
-0.030517576f, 0.084182739f, -0.090927124f, 0.600219727f, |
-1.144287109f, -0.543823242f, -0.108856201f, -0.073059082f, |
-0.031478882f, -0.006118774f, -0.003173828f, -0.000396729f, |
0.000015259f, 0.000534058f, -0.003387451f, 0.008865356f, |
-0.029785154f, 0.089706421f, -0.080688477f, 0.628295898f, |
-1.142211914f, -0.515609741f, -0.116577141f, -0.067520142f, |
-0.031738281f, -0.005294800f, -0.003082275f, -0.000366211f, |
0.000015259f, 0.000579834f, -0.003433228f, 0.009841919f, |
-0.028884888f, 0.095169067f, -0.069595337f, 0.656219482f, |
-1.138763428f, -0.487472534f, -0.123474121f, -0.061996460f, |
-0.031845093f, -0.004486084f, -0.002990723f, -0.000320435f, |
0.000015259f, 0.000625610f, -0.003463745f, 0.010848999f, |
-0.027801514f, 0.100540161f, -0.057617184f, 0.683914185f, |
-1.133926392f, -0.459472656f, -0.129577637f, -0.056533810f, |
-0.031814575f, -0.003723145f, -0.002899170f, -0.000289917f, |
0.000015259f, 0.000686646f, -0.003479004f, 0.011886597f, |
-0.026535034f, 0.105819702f, -0.044784546f, 0.711318970f, |
-1.127746582f, -0.431655884f, -0.134887695f, -0.051132202f, |
-0.031661987f, -0.003005981f, -0.002792358f, -0.000259399f, |
0.000015259f, 0.000747681f, -0.003479004f, 0.012939452f, |
-0.025085449f, 0.110946655f, -0.031082151f, 0.738372803f, |
-1.120223999f, -0.404083252f, -0.139450073f, -0.045837402f, |
-0.031387329f, -0.002334595f, -0.002685547f, -0.000244141f, |
0.000030518f, 0.000808716f, -0.003463745f, 0.014022826f, |
-0.023422241f, 0.115921021f, -0.016510010f, 0.765029907f, |
-1.111373901f, -0.376800537f, -0.143264771f, -0.040634155f, |
-0.031005858f, -0.001693726f, -0.002578735f, -0.000213623f, |
0.000030518f, 0.000885010f, -0.003417969f, 0.015121460f, |
-0.021575928f, 0.120697014f, -0.001068115f, 0.791213989f, |
-1.101211548f, -0.349868774f, -0.146362305f, -0.035552979f, |
-0.030532837f, -0.001098633f, -0.002456665f, -0.000198364f, |
0.000030518f, 0.000961304f, -0.003372192f, 0.016235352f, |
-0.019531250f, 0.125259399f, 0.015228271f, 0.816864014f, |
-1.089782715f, -0.323318481f, -0.148773193f, -0.030609131f, |
-0.029937742f, -0.000549316f, -0.002349854f, -0.000167847f, |
0.000030518f, 0.001037598f, -0.003280640f, 0.017349243f, |
-0.017257690f, 0.129562378f, 0.032379150f, 0.841949463f, |
-1.077117920f, -0.297210693f, -0.150497437f, -0.025817871f, |
-0.029281614f, -0.000030518f, -0.002243042f, -0.000152588f, |
0.000045776f, 0.001113892f, -0.003173828f, 0.018463135f, |
-0.014801024f, 0.133590698f, 0.050354004f, 0.866363525f, |
-1.063217163f, -0.271591187f, -0.151596069f, -0.021179199f, |
-0.028533936f, 0.000442505f, -0.002120972f, -0.000137329f, |
0.000045776f, 0.001205444f, -0.003051758f, 0.019577026f, |
-0.012115479f, 0.137298584f, 0.069168091f, 0.890090942f, |
-1.048156738f, -0.246505737f, -0.152069092f, -0.016708374f, |
-0.027725220f, 0.000869751f, -0.002014160f, -0.000122070f, |
0.000061035f, 0.001296997f, -0.002883911f, 0.020690918f, |
-0.009231566f, 0.140670776f, 0.088775635f, 0.913055420f, |
-1.031936646f, -0.221984863f, -0.151962280f, -0.012420653f, |
-0.026840210f, 0.001266479f, -0.001907349f, -0.000106812f, |
0.000061035f, 0.001388550f, -0.002700806f, 0.021789551f, |
-0.006134033f, 0.143676758f, 0.109161377f, 0.935195923f, |
-1.014617920f, -0.198059082f, -0.151306152f, -0.008316040f, |
-0.025909424f, 0.001617432f, -0.001785278f, -0.000106812f, |
0.000076294f, 0.001480103f, -0.002487183f, 0.022857666f, |
-0.002822876f, 0.146255493f, 0.130310059f, 0.956481934f, |
-0.996246338f, -0.174789429f, -0.150115967f, -0.004394531f, |
-0.024932859f, 0.001937866f, -0.001693726f, -0.000091553f, |
-0.001586914f, -0.023910521f, -0.148422241f, -0.976852417f, |
0.152206421f, 0.000686646f, -0.002227783f, 0.000076294f, |
}; |
void window(float *vbuf, int vb_ptr, short *pcm) |
{ |
int i, j; |
int si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 16; |
bx = (si + 32) & 511; |
coef = wincoef; |
/*-- first 16 --*/ |
for (i = 0; i < 16; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si = (si + 64) & 511; |
sum -= (*coef++) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
si++; |
bx--; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = tmp; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = tmp; |
/*-- last 15 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 15; i++) |
{ |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si = (si + 64) & 511; |
sum += (*coef--) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = tmp; |
} |
} |
/*------------------------------------------------------------*/ |
void window_dual(float *vbuf, int vb_ptr, short *pcm) |
{ |
int i, j; /* dual window interleaves output */ |
int si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 16; |
bx = (si + 32) & 511; |
coef = wincoef; |
/*-- first 16 --*/ |
for (i = 0; i < 16; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si = (si + 64) & 511; |
sum -= (*coef++) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
si++; |
bx--; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = tmp; |
pcm += 2; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = tmp; |
pcm += 2; |
/*-- last 15 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 15; i++) |
{ |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si = (si + 64) & 511; |
sum += (*coef--) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = tmp; |
pcm += 2; |
} |
} |
/*------------------------------------------------------------*/ |
/*------------------- 16 pt window ------------------------------*/ |
void window16(float *vbuf, int vb_ptr, short *pcm) |
{ |
int i, j; |
unsigned char si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 8; |
bx = si + 16; |
coef = wincoef; |
/*-- first 8 --*/ |
for (i = 0; i < 8; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si += 32; |
sum -= (*coef++) * vbuf[bx]; |
bx += 32; |
} |
si++; |
bx--; |
coef += 16; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = tmp; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx += 32; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = tmp; |
/*-- last 7 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 7; i++) |
{ |
coef -= 16; |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si += 32; |
sum += (*coef--) * vbuf[bx]; |
bx += 32; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = tmp; |
} |
} |
/*--------------- 16 pt dual window (interleaved output) -----------------*/ |
void window16_dual(float *vbuf, int vb_ptr, short *pcm) |
{ |
int i, j; |
unsigned char si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 8; |
bx = si + 16; |
coef = wincoef; |
/*-- first 8 --*/ |
for (i = 0; i < 8; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si += 32; |
sum -= (*coef++) * vbuf[bx]; |
bx += 32; |
} |
si++; |
bx--; |
coef += 16; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = tmp; |
pcm += 2; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx += 32; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = tmp; |
pcm += 2; |
/*-- last 7 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 7; i++) |
{ |
coef -= 16; |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si += 32; |
sum += (*coef--) * vbuf[bx]; |
bx += 32; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = tmp; |
pcm += 2; |
} |
} |
/*------------------- 8 pt window ------------------------------*/ |
void window8(float *vbuf, int vb_ptr, short *pcm) |
{ |
int i, j; |
int si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 4; |
bx = (si + 8) & 127; |
coef = wincoef; |
/*-- first 4 --*/ |
for (i = 0; i < 4; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si = (si + 16) & 127; |
sum -= (*coef++) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
si++; |
bx--; |
coef += 48; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = tmp; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = tmp; |
/*-- last 3 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 3; i++) |
{ |
coef -= 48; |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si = (si + 16) & 127; |
sum += (*coef--) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = tmp; |
} |
} |
/*--------------- 8 pt dual window (interleaved output) -----------------*/ |
void window8_dual(float *vbuf, int vb_ptr, short *pcm) |
{ |
int i, j; |
int si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 4; |
bx = (si + 8) & 127; |
coef = wincoef; |
/*-- first 4 --*/ |
for (i = 0; i < 4; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si = (si + 16) & 127; |
sum -= (*coef++) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
si++; |
bx--; |
coef += 48; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = tmp; |
pcm += 2; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = tmp; |
pcm += 2; |
/*-- last 3 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 3; i++) |
{ |
coef -= 48; |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si = (si + 16) & 127; |
sum += (*coef--) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = tmp; |
pcm += 2; |
} |
} |
/programs/media/ac97 mp3/trunk/mp3dec/windowb.c |
---|
0,0 → 1,427 |
extern float wincoef[264]; |
void windowB(float *vbuf, int vb_ptr, unsigned char *pcm) |
{ |
int i, j; |
int si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 16; |
bx = (si + 32) & 511; |
coef = wincoef; |
/*-- first 16 --*/ |
for (i = 0; i < 16; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si = (si + 64) & 511; |
sum -= (*coef++) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
si++; |
bx--; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; |
/*-- last 15 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 15; i++) |
{ |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si = (si + 64) & 511; |
sum += (*coef--) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; |
} |
} |
/*------------------------------------------------------------*/ |
void windowB_dual(float *vbuf, int vb_ptr, unsigned char *pcm) |
{ |
int i, j; /* dual window interleaves output */ |
int si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 16; |
bx = (si + 32) & 511; |
coef = wincoef; |
/*-- first 16 --*/ |
for (i = 0; i < 16; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si = (si + 64) & 511; |
sum -= (*coef++) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
si++; |
bx--; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; |
pcm += 2; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; |
pcm += 2; |
/*-- last 15 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 15; i++) |
{ |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si = (si + 64) & 511; |
sum += (*coef--) * vbuf[bx]; |
bx = (bx + 64) & 511; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; |
pcm += 2; |
} |
} |
/*------------------------------------------------------------*/ |
/*------------------- 16 pt window ------------------------------*/ |
void windowB16(float *vbuf, int vb_ptr, unsigned char *pcm) |
{ |
int i, j; |
unsigned char si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 8; |
bx = si + 16; |
coef = wincoef; |
/*-- first 8 --*/ |
for (i = 0; i < 8; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si += 32; |
sum -= (*coef++) * vbuf[bx]; |
bx += 32; |
} |
si++; |
bx--; |
coef += 16; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx += 32; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; |
/*-- last 7 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 7; i++) |
{ |
coef -= 16; |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si += 32; |
sum += (*coef--) * vbuf[bx]; |
bx += 32; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; |
} |
} |
/*--------------- 16 pt dual window (interleaved output) -----------------*/ |
void windowB16_dual(float *vbuf, int vb_ptr, unsigned char *pcm) |
{ |
int i, j; |
unsigned char si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 8; |
bx = si + 16; |
coef = wincoef; |
/*-- first 8 --*/ |
for (i = 0; i < 8; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si += 32; |
sum -= (*coef++) * vbuf[bx]; |
bx += 32; |
} |
si++; |
bx--; |
coef += 16; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; |
pcm += 2; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx += 32; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; |
pcm += 2; |
/*-- last 7 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 7; i++) |
{ |
coef -= 16; |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si += 32; |
sum += (*coef--) * vbuf[bx]; |
bx += 32; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; |
pcm += 2; |
} |
} |
/*------------------- 8 pt window ------------------------------*/ |
void windowB8(float *vbuf, int vb_ptr, unsigned char *pcm) |
{ |
int i, j; |
int si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 4; |
bx = (si + 8) & 127; |
coef = wincoef; |
/*-- first 4 --*/ |
for (i = 0; i < 4; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si = (si + 16) & 127; |
sum -= (*coef++) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
si++; |
bx--; |
coef += 48; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; |
/*-- last 3 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 3; i++) |
{ |
coef -= 48; |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si = (si + 16) & 127; |
sum += (*coef--) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; |
} |
} |
/*--------------- 8 pt dual window (interleaved output) -----------------*/ |
void windowB8_dual(float *vbuf, int vb_ptr, unsigned char *pcm) |
{ |
int i, j; |
int si, bx; |
float *coef; |
float sum; |
long tmp; |
si = vb_ptr + 4; |
bx = (si + 8) & 127; |
coef = wincoef; |
/*-- first 4 --*/ |
for (i = 0; i < 4; i++) |
{ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[si]; |
si = (si + 16) & 127; |
sum -= (*coef++) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
si++; |
bx--; |
coef += 48; |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; |
pcm += 2; |
} |
/*-- special case --*/ |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef++) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; |
pcm += 2; |
/*-- last 3 --*/ |
coef = wincoef + 255; /* back pass through coefs */ |
for (i = 0; i < 3; i++) |
{ |
coef -= 48; |
si--; |
bx++; |
sum = 0.0F; |
for (j = 0; j < 8; j++) |
{ |
sum += (*coef--) * vbuf[si]; |
si = (si + 16) & 127; |
sum += (*coef--) * vbuf[bx]; |
bx = (bx + 16) & 127; |
} |
tmp = (long) sum; |
if (tmp > 32767) |
tmp = 32767; |
else if (tmp < -32768) |
tmp = -32768; |
*pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; |
pcm += 2; |
} |
} |
/programs/media/ac97wav/trunk/ac97wav.asm |
---|
0,0 → 1,1103 |
;--------------------------------------------------------------------- |
; |
; MenuetOS AC97 WAV Player |
; |
; 0.03 November 10, 2004 doesn't halt if file not found |
; 0.04 November 11, 2004 better positioning (with mouse) |
; 0.05 November 14, 2004 internals clean up |
; fixed cutting sound at the edges |
; 0.06 November 17, 2004 fixed many bugs |
; 0.07 Nov 20, 2004 deactivates text box when 'play' pressed |
; stops playing before closing a window |
; 0.08 Nov 24, 2004 added support for 8bit and mono modes |
; +variable rate for some chipsets |
; 0.09 August 26, 2006 modified to use function 70 |
; |
; Use [flat assembler 1.64] to compile. |
; |
;--------------------------------------------------------------------- |
use32 ; turn on 32 bit mode |
org 0x0 ; the program is placed at 0 offset |
db 'MENUET01' ; 8-byte identifier of MenuetOS application |
dd 0x01 ; header version (always 1) |
dd START ; address of the beginning of the code |
dd IMAGE_END ; size of the program's image |
dd MEMORY_END ; how much memory does it need |
dd STACK_P ; a pointer to the top of the stack |
dd textbox_string |
; dd 0x0 ; address of buffer for parameters (not used) |
dd 0x0 ; reserved |
;--------------------------------------------------------------------- |
include "MACROS.INC" ; standart macros & constants |
include "MEOSFUNC.INC" ; MenuetOS API functions names |
include "DEBUG.INC" ; printing to debug board |
include "CONSTANT.INC" ; BIT?? constants |
include "AC97.INC" ; AC'97 constants |
include "PCI.INC" ; PCI interface |
include "CODEC.INC" ; functions for configuring codec |
include "FRONTEND.INC" ; main window |
;--------------------------------------------------------------------- |
; Uncomment these strings if you don't want to receive debug messages: |
; macro dps str {} ; dps prints a string without CRLF |
; macro dpd num {} ; prints unsigned decimal number |
; macro pregs {} ; outputs EAX, EBX, ECX, EDX |
; macro newline {} ; CRLF |
; macro print str {} ; output a string with CRLF |
; macro dph arg {} ; print hex number |
;--------------------------------------------------------------------- |
;macro device id, addr { dd id, addr } |
macro devices [id, str] |
{ |
common |
label supported_devices dword |
forward |
local string |
dd id |
dd string |
forward |
string db str |
db 0 |
} |
devices \ |
(ICH_DID shl 16) + INTEL_VID, "ICH" ,\ |
(ICH0_DID shl 16) + INTEL_VID, "ICH0" ,\ |
(ICH2_DID shl 16) + INTEL_VID, "ICH2" ,\ |
(ICH3_DID shl 16) + INTEL_VID, "ICH2" ,\ |
(ICH4_DID shl 16) + INTEL_VID, "ICH4" ,\ |
(ICH5_DID shl 16) + INTEL_VID, "ICH5" ,\ |
(MX440_DID shl 16) + INTEL_VID, "440MX" ,\ |
(SI7012_DID shl 16) + SIS_VID, "SI7012" ,\ |
(NFORCE_DID shl 16) + NVIDIA_VID, "NForce" ,\ |
(NFORCE2_DID shl 16) + NVIDIA_VID, "NForce2",\ |
(AMD8111_DID shl 16) + AMD_VID, "AMD8111",\ |
(AMD768_DID shl 16) + AMD_VID, "AMD768" |
dd 0 |
;--------------------------------------------------------------------- |
;--- MAIN PROGRAM -------------------------------------------------- |
;--------------------------------------------------------------------- |
START: |
; Print PCI version (for example, 2.16) |
; mcall MF_PCI, 0 |
; mov bl, al |
; movzx eax, ah |
; dps "PCI version: " |
; dpd eax |
; movzx eax, bl |
; dpd eax |
; newline |
; Check PCI access mechanism (must be 1 or 2) |
mcall MF_PCI, 2 |
dec al |
cmp al, 1 |
jna @f |
print "Error: cannot access PCI bus." |
jmp exit |
; dps "PCI returned " |
; movzx eax, al |
; dpd eax |
; newline |
@@: |
; Get last bus & then check all buses & devices |
mcall MF_PCI, 1 |
mov [lastbus], al |
; looking for a compatible device |
mov [bus], -1 |
.next_bus: |
inc [bus] |
mov al, [lastbus] |
cmp al, [bus] |
jb .device_not_found |
mov [devfn], 0 |
.next_devfn: |
mov cl, 0 |
call pciRegRead32 |
mov edi, supported_devices |
@@: |
mov ebx, [edi] |
test ebx, ebx |
jz @f |
cmp eax, ebx |
jnz .skip |
add edi, 4 |
mov [device_id], eax |
mov edx, [edi] |
call debug_outstr |
jmp proceed |
.skip: |
add edi, 8 |
jmp @b |
@@: |
inc [devfn] |
cmp [devfn], 255 |
jb .next_devfn |
jmp .next_bus |
.device_not_found: |
print "Could not find Intel AC'97 compatible codec!" |
print "1) Check if it's enabled in BIOS." |
print "2) Check if your device is included in the device list." |
jmp exit |
proceed: |
print " integrated AC97 audio codec detected." |
mov eax, [device_id] |
cmp eax, (ICH4_DID shl 16) + INTEL_VID |
je .newich |
cmp eax, (ICH5_DID shl 16) + INTEL_VID |
jne .nonewich |
.newich: |
mov [AC97ICH4], 1 |
.nonewich: |
cmp eax, (SI7012_DID shl 16) + SIS_VID |
jne @f |
mov [SI7012], 1 |
@@: |
;--------------------------------------------------------------------- |
; Get NAMBAR register base port address & save it |
mov cl, NAMBAR_REG |
call pciRegRead16 |
and eax, 0xFFFE |
mov [NAMBAR], ax |
test eax, eax |
jnz .mixer_base_ok |
print "Error: Intel ICH based AC97 audio codec disabled in BIOS!" |
jmp exit |
.mixer_base_ok: |
dps "NAMBAR: " |
dph eax |
; Get NABMBAR & save it |
mov cl, NABMBAR_REG |
call pciRegRead16 |
and eax, 0xFFC0 |
mov [NABMBAR], ax |
test eax, eax |
jnz .bm_base_ok |
print "Error: Intel ICH based AC97 audio codec disabled in BIOS!" |
jmp exit |
.bm_base_ok: |
dps " NABMBAR: " |
dph eax |
newline |
;--------------------------------------------------------------------- |
; Get IRQ (not used) |
mov cl, IRQ_REG |
call pciRegRead8 |
mov [AC97IRQ], al |
; Get Interrupt pin (not used) |
mov cl, INT_REG |
call pciRegRead8 |
mov [AC97INT], al |
; AC97ICH4 should work then... |
cmp [AC97ICH4], 1 |
jne .skip_ich4_init |
mov cl, ICH4_CFG_REG ; 0x41 |
call pciRegRead8 |
or al, 0x1 |
mov dl, al |
call pciRegWrite8 |
mov cl, 0x54 |
call pciRegRead16 |
and eax, 0xFFFF |
dps "Power Control & Status: " |
dph eax |
newline |
.skip_ich4_init: |
;--------------------------------------------------------------------- |
mov cl, PCI_CMD_REG |
call pciRegRead16 ; read PCI command register |
mov dx, ax |
or dx, IO_ENA+BM_ENA+BIT10 ; enable IO and bus master + disable |
; interrupts |
call pciRegWrite16 |
;--------------------------------------------------------------------- |
print "Enabling access to ports..." |
movzx ecx, [NAMBAR] |
mov edx, ecx |
add edx, NAM_SIZE |
mcall MF_PORTS, PRT_RESERVE |
test eax, eax |
jz @f |
print "Error: couldn't enable access to ports" |
jmp exit |
@@: |
movzx ecx, [NABMBAR] |
mov edx, ecx |
add edx, NABM_SIZE |
mcall MF_PORTS, PRT_RESERVE |
test eax, eax |
jz @f |
print "Error: couldn't enable access to ports" |
jmp exit |
@@: |
;--------------------------------------------------------------------- |
; setup the Codec |
mov eax, 48000 |
call codecConfig ; unmute codec, set rates. |
test eax, eax |
jnz @f |
print "Error: cannot initialize AC97 device." |
jmp fpexit |
@@: |
print "Congrutalations! Your device has been initialized properly!" |
call print_info |
;--------------------------------------------------------------------- |
; register reset the DMA engine. |
mov edx, PO_CR_REG ; PCM out control register |
mov al, RR ; reset |
call NABMBAR_write_byte |
;start fix for MM (1) |
mcall MF_INTERNAL_SERVICES,ALLOC_PHYS_MEM,120*1024 |
test eax,eax |
jz no_phys_buffers ;not enough memory |
mov [phys_wav_buffer1],eax |
add eax,60*1024 |
mov [phys_wav_buffer2],eax |
mcall MF_INTERNAL_SERVICES,ALLOC_PHYS_MEM,32*8 |
test eax,eax |
jnz @f |
mcall MF_INTERNAL_SERVICES,FREE_PHYS_MEM,[phys_wav_buffer1] |
jmp no_phys_buffers |
@@: |
mov [phys_bdl_buffer],eax |
;end fix for MM (1) |
; create Buffer Descriptors List |
call prepare_BDL |
; open player's window |
mcall MF_THREAD, THR_CREATE, thread, thread_stack |
; wait for command |
.new_check: |
cmp [status], ST_PLAY |
jne @f |
call play |
@@: |
cmp [status], ST_STOP |
jne @f |
call stop |
@@: |
cmp [status], ST_EXIT |
je stopexit |
mcall MF_DELAY, 10 |
jmp .new_check |
stopexit: |
call stop |
fpexit: |
; free ports |
movzx ecx, [NAMBAR] |
mov edx, ecx |
add edx, NAM_SIZE |
mcall MF_PORTS, PRT_FREE |
movzx ecx, [NABMBAR] |
mov edx, ecx |
add edx, NABM_SIZE |
mcall MF_PORTS, PRT_FREE |
;--------------------------------------------------------------------- |
;start fix for MM (2) |
mcall MF_INTERNAL_SERVICES,FREE_PHYS_MEM,[phys_bdl_buffer] |
mcall MF_INTERNAL_SERVICES,FREE_PHYS_MEM,[phys_wav_buffer1] |
;end fix for MM (2) |
exit: |
mcall MF_EXIT |
no_phys_buffers: |
print "allocation of physical buffers failed" |
jmp exit |
;--------------------------------------------------------------------- |
;--- FUNCTIONS ----------------------------------------------------- |
;--------------------------------------------------------------------- |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; prepare_BDL - initializes BUFFER DESCRIPTORS LIST |
prepare_BDL: |
mov ecx, 32 / 2 ; make 32 entries in BDL |
mov edi, BDL_BUFFER |
; call get_my_address |
mov ebx, 30*1024 |
cmp [SI7012], 1 |
jne @f |
add ebx, ebx |
@@: |
; set buf. desc. 0 to start of data file in memory |
push eax |
; add eax, WAV_BUFFER1 |
;start fix for MM (6) |
mov eax,[phys_wav_buffer1] |
;end fix for MM (6) |
stosd |
; set length to 60k samples. 1 sample is 16 bit or 2 bytes. |
mov eax, ebx ;60*1024 ; number of samples |
or eax, BUP |
stosd |
mov eax, [esp] |
; add eax, WAV_BUFFER2 |
;start fix for MM (7) |
mov eax,[phys_wav_buffer2] |
;end fix for MM (7) |
stosd |
mov eax, ebx ;60*1024 |
or eax, BUP |
stosd |
pop eax |
loop @b |
; tell the DMA engine where to find our list of Buffer Descriptors. |
; eax = base addr! |
;start fix for MM (3) |
;copy to physical memory |
mcall MF_INTERNAL_SERVICES,SET_PHYS_BUFFER,[phys_bdl_buffer],BDL_BUFFER,32*8 |
;physical address of bdl |
mov eax,[phys_bdl_buffer] |
;end fix for MM (3) |
mov edx, PO_BDBAR_REG |
; add eax, BDL_BUFFER |
call NABMBAR_write_dword |
ret |
;--------------------------------------------------------------------- |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; stop - stops current music |
;; in: nothing |
;; out: nothing |
stop: |
; print "STOP!" |
push eax edx |
mcall MF_DELAY, 10 |
mov edx, PO_CR_REG |
mov al, 0 |
call NABMBAR_write_byte |
cmp [status], ST_STOP |
jne .exit |
mov [status], ST_DONE |
.exit: |
pop edx eax |
ret |
;--------------------------------------------------------------------- |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; play - plays wav file! |
;; in: nothing |
;; out: nothing (but sound :) !corrupts registers! |
play: |
; at first, reset file and get file size |
mcall MF_SYSTREE, attrinfo |
test eax, eax |
jnz .notfound |
mov eax, [fileattr+32] |
mov [file_size], eax |
mov [fileinfo.first_byte], 0 |
mcall MF_SYSTREE, fileinfo ; load a block, returns error code in eax |
; and size of the file in ebx |
test eax, eax ; 0 - successful |
jz @f |
cmp eax, 6 ; 6 = eof - successful too |
jz @f |
.notfound: |
print "AC97: File not found!" |
mov [status], ST_STOP |
jmp .exit |
@@: |
mov al, [LOAD_BUFFER+32] ; bytes per sample |
dec al |
jz @f |
cmp al, 3 |
je @f |
sub al, [LOAD_BUFFER+22] ; channels |
add al, 2 |
@@: |
mov [wav_mode], al |
pusha |
movzx ebx,word [LOAD_BUFFER+24] |
mov eax,48000 |
xor edx,edx |
div ebx |
mov [difference_of_frequency],al |
; dph eax |
mov ecx,edx |
imul eax,ecx,10 |
xor edx,edx |
div ebx |
mov ecx,edx |
imul ecx,10 |
push eax |
mov eax,ecx |
xor edx,edx |
div ebx |
; dph eax |
cmp eax,5 |
jl .temp_15 |
pop eax |
; dph eax |
inc eax |
jmp .temp_16 |
.temp_15: |
pop eax |
.temp_16: |
mov [difference_of_frequency_1],al |
; dph eax |
xor edx,edx |
movzx ebx,[difference_of_frequency] |
imul ebx,10 |
add bl,[difference_of_frequency_1] |
mov [difference_of_frequency_2],bl |
; dph ebx |
popa |
movzx eax, word [LOAD_BUFFER+24] |
;dps "Freq: " |
;dpd eax |
;newline |
call set_sample_rate |
; change the last_valid_index to the (current_index-1) |
; the LVI register tells the DMA engine where to stop playing |
call updateLVI |
; if current index is odd, load buffer 1 then 0, jump to tuneLoop |
; if it is even, buffers 0 then 1; tuneLoop1 |
call getCurrentIndex |
and eax, BIT0 |
mov esi, eax |
push eax |
call update_next_buffer |
pop eax |
xor eax, 1 |
call update_next_buffer |
; start playing! |
mov edx, PO_CR_REG |
mov al, RPBM |
call NABMBAR_write_byte |
jmp [jumpto+esi*4] |
.tuneLoop: |
; wait while the current_index is even |
@@: |
; dps "a" |
mcall MF_DELAY, 7 |
call getCurrentIndex |
test al, BIT0 |
jz @b ; loop if not ready yet |
; print "fa" |
call updateLVI |
mov eax, 0 |
call update_next_buffer |
test al, al |
jnz .exit_wait |
cmp [status], ST_PLAY |
jne .exit |
test [volume], 0x10000000 ; test volume_changed bit |
je @f |
mov al, byte [volume] |
call setVolume |
and [volume], 0x0FFFFFFF ; clear vloume_changed bit |
@@: |
.tuneLoop1: |
@@: |
; dps "b" |
mcall MF_DELAY, 7 |
call getCurrentIndex |
test al, BIT0 |
jnz @b ; loop if not ready yet |
; print "fb" |
cmp [status], ST_PLAY |
jne .exit |
call updateLVI |
mov eax, 1 |
call update_next_buffer |
test al, al |
jnz .exit_wait |
jmp .tuneLoop |
.exit_wait: |
mcall MF_DELAY, 30 ; a little pause - let the player finish |
.exit: |
ret |
attempts db 0 |
buffers dd WAV_BUFFER1, WAV_BUFFER2 |
jumpto dd play.tuneLoop, play.tuneLoop1 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; update_first_buffer - load a chunk into the first buffer, increments offset |
;; in: eax = number - 0 or 1 |
;; out: error code, 0 - successful |
update_next_buffer: |
push esi edi |
movzx edx, byte [wav_mode] |
mov ecx, [blocks + edx * 4] |
mov [fileinfo.bytes], ecx |
mov esi, LOAD_BUFFER |
mov edi, [buffers+eax*4] |
push eax ;save buffer index |
start_attempts: |
mcall MF_SYSTREE, fileinfo |
test eax, eax |
jz @f |
cmp eax, 6 |
jz @f |
cmp [attempts],100 |
je @f |
inc [attempts] |
jmp start_attempts |
; dpd eax |
; newline |
; dpd [fileinfo.first_block] |
; newline |
@@: |
; print " loaded!" |
push eax ebx edx |
mov eax,ecx |
xor edx,edx |
imul eax,10 |
movzx ebx,[difference_of_frequency_2] |
div ebx |
mov ecx,eax |
; mov ebx,10 |
; mov eax,edx |
; xor edx,edx |
; div ebx |
; cmp edx,5 |
; jb temp_12_7 |
; inc ecx |
; temp_12_7: |
; cmp edx,0 |
; je temp_12_7 |
; inc ecx |
; temp_12_7: |
pop edx ebx |
mov eax,[esp+4] ;restore buffer index |
and ecx, not 511 |
add [fileinfo.first_byte], ecx ; +60Kb |
call [convert + edx * 4] |
;start fix for MM (4) |
mov eax,[esp+4] ;restore buffer index |
test eax,not 1 |
jz .ok |
print "buffer index out of range" |
dpd eax |
jmp .ret |
.ok: |
push ebp |
mov ebp,[phys_wav_buffer1+eax*4] |
mov edi,[buffers+eax*4] |
mcall MF_INTERNAL_SERVICES,SET_PHYS_BUFFER,ebp,edi,60*1024 |
pop ebp |
.ret: |
pop eax |
add esp,4 ;pop buffer index |
;end fix for MM (4) |
pop edi esi |
ret |
c8mono: |
mov [type_of_conversion],1 |
jmp for_all_type |
c8mono_1: |
lodsb |
call c8mono_2 |
push ax |
shl eax,16 |
pop ax |
push eax |
mov al,[esi] |
call c8mono_2 |
push ax |
shl eax,16 |
pop ax |
mov ebx,eax |
pop eax |
jmp for_all_type_1 |
c8mono_2: |
sub al, 0x80 |
cbw |
imul ax, 255 |
ret |
c8stereo: |
mov [type_of_conversion],2 |
jmp for_all_type |
c8stereo_1: |
lodsb |
call c8stereo_2 |
shl eax,16 |
lodsb |
call c8stereo_2 |
push eax |
mov al,[esi] |
call c8stereo_2 |
shl eax,16 |
mov al,[esi+1] |
call c8stereo_2 |
mov ebx,eax |
pop eax |
jmp for_all_type_1 |
c8stereo_2: |
sub al, 0x80 |
cbw |
imul ax, 255 |
ret |
c16mono: |
mov [type_of_conversion],3 |
jmp for_all_type |
c16mono_1: |
lodsw |
push ax |
shl eax,16 |
pop ax |
mov bx,[esi] |
shl ebx,16 |
mov bx,[esi] |
jmp for_all_type_1 |
c16stereo: |
for_all_type: |
xor edx,edx |
mov eax, 15*1024*10 |
movzx ebx,[difference_of_frequency_2] |
xor edx,edx |
div ebx |
mov ecx,eax |
; mov ebx,10 |
; mov eax,edx |
; xor edx,edx |
; div ebx |
; cmp edx,5 |
; jb temp_12_6 |
; inc ecx |
; temp_12_6: |
cmp edx,0 |
je temp_12_6 |
inc ecx |
temp_12_6: |
c16stereo_1: |
mov [znak],0 |
cmp [type_of_conversion],1 |
je c8mono_1 |
cmp [type_of_conversion],2 |
je c8stereo_1 |
cmp [type_of_conversion],3 |
je c16mono_1 |
lodsd |
mov ebx,[esi] |
for_all_type_1: |
cmp eax,ebx |
jne c16stereo_2 |
inc [znak] |
c16stereo_2: |
push eax |
push ecx |
sub eax,ebx |
push eax |
shl eax,16 |
movzx ebx,[difference_of_frequency] |
inc ebx |
xor edx,edx |
div ebx |
shr eax,16 |
mov ecx,eax |
pop eax |
xor ax,ax |
xor edx,edx |
div ebx |
shl eax,16 |
mov cx,ax |
mov ebx,ecx |
pop ecx |
pop eax |
mov dl,[difference_of_frequency] |
inc dl |
@@: |
temp_12: |
cmp [difference_of_frequency_1],0 |
je temp_12_3 |
cmp [difference_of_frequency_1],5 |
jne temp_12_4 |
cmp [difference_of_frequency_4],2 |
jne temp_12_3 |
jmp temp_12_5 |
temp_12_4: |
cmp [difference_of_frequency_4],10 |
jne temp_12_3 |
temp_12_5: |
cmp [znak],0 |
jne temp_12_5_1 |
sub eax,ebx |
jmp temp_12_5_2 |
temp_12_5_1: |
add eax,ebx |
temp_12_5_2: |
stosd |
inc [schetchik] |
mov [difference_of_frequency_4],0 |
temp_12_3: |
cmp [znak],0 |
jne temp_13 |
sub eax,ebx |
jmp temp_14 |
temp_13: |
add eax,ebx |
temp_14: |
cld |
dec dl |
jz temp_14_1 |
stosd |
inc [schetchik] |
inc [difference_of_frequency_4] |
jmp temp_12 |
temp_14_1: |
dec ecx |
cmp ecx,0 |
; jnz c16stereo_1 |
jg c16stereo_1 |
newline |
dph [schetchik] |
temp_14_2: |
cmp [schetchik],15360 |
jge temp_14_3 |
stosd |
inc [schetchik] |
jmp temp_14_2 |
temp_14_3: |
newline |
dph [schetchik] |
cmp [schetchik],15360 |
je temp_14_4 |
; mov [edi-4],dword 0 |
sub edi,4 |
; sub esi,4 |
temp_14_4: |
mov [schetchik],0 |
ret |
difference_of_frequency db 0 |
difference_of_frequency_1 db 0 |
difference_of_frequency_2 db 0 |
difference_of_frequency_4 db 0 |
schetchik dd 0 |
znak db 0 |
type_of_conversion db 0 |
convert dd c8mono, c8stereo, c16mono, c16stereo |
blocks dd 30*512, 60*512, 60*512, 120*512 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; get_my_address - get base address of the program in physical memory |
;; in: nothing |
;; out: eax = address |
;start fix for MM (8) |
;function shouldn't used. |
;get_my_address: |
; pushad |
; mcall MF_PROCINFO, procinfo, PN_MYSELF |
; popad |
; mov eax, [procinfo.memory_start] |
;ret |
;end fix for MM (8) |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; set the last valid index to something other than we're currently playing |
;; so that we never end |
;; |
;; this routine just sets the last valid index to 1 less than the index |
;; that we're currently playing, thus keeping it in and endless loop |
;; input: none |
;; output: none |
updateLVI: |
push eax |
call getCurrentIndex |
; dps "index " |
; dpd eax |
; newline |
dec al |
and al, INDEX_MASK |
call setLastValidIndex |
pop eax |
ret |
;--------------------------------------------------------------------- |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; returns AL = current index value |
getCurrentIndex: |
push edx |
mov edx, PO_CIV_REG |
call NABMBAR_read_byte |
pop edx |
ret |
;--------------------------------------------------------------------- |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; input AL = index # to stop on |
setLastValidIndex: |
push edx |
mov edx, PO_LVI_REG |
call NABMBAR_write_byte |
pop edx |
ret |
;--------------------------------------------------------------------- |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; print_info - outputs debug information |
;; in: nothing |
;; out: nothing |
print_info: |
dps "BUS: " |
movzx eax, [bus] |
dph eax |
dps " DEVFN: " |
movzx eax, [devfn] |
dph eax |
dps " IRQ: " |
movzx eax, [AC97IRQ] |
dpd eax |
newline |
dps "CODEC_POWER_CTRL: " |
mov edx, CODEC_POWER_CTRL_REG |
call NAMBAR_read_word |
dph eax |
dps " (bits 0-3 should be set)" |
newline |
mov edx, 0x28 |
call NAMBAR_read_word |
dph eax |
dps " - supported features" |
newline |
mov edx, 0x2A |
call NAMBAR_read_word |
dph eax |
dps " - config" |
newline |
mov edx, 0x2C |
call NAMBAR_read_word |
dph eax |
dps " - PCM rate" |
newline |
ret |
;--------------------------------------------------------------------- |
;--- DATA OF PROGRAM ----------------------------------------------- |
;--------------------------------------------------------------------- |
volume dd 15 |
attrinfo: |
dd 5 |
dd 0 |
dd 0 |
dd 0 |
dd fileattr |
db 0 |
dd textbox_string |
fileinfo: |
.mode dd 0 ; READ |
.first_byte dd 0 |
dd 0 |
.bytes dd 60*1024 ; 60 Kb |
.dest dd LOAD_BUFFER ;file_data |
; db "/HD/1/WINDOWS/MEDIA/WICEB7~1.WAV",0 |
;sz textbox_string, "/hd/1/testmuz/menuet11.wav",0 |
textbox_string: |
;--------------------------------------------------------------------- |
IMAGE_END: ; end of program's image |
rb 257 |
; rb 257-textbox_string.size |
; textbox_string.size |
;--------------------------------------------------------------------- |
device_id dd ? ; (device_id << 16) + vendor_id |
lastbus db ? ; pci coordinates |
bus db ? |
devfn db ? |
AC97ICH4 db ? ; Intel ICH4 codec flag |
SI7012 db ? ; SiS SI7012 codec flag |
NAMBAR dw ? ; Audio Mixers Registers (base) |
NABMBAR dw ? ; Bus Master Registers (base) |
AC97IRQ db ? ; Interrupt request |
AC97INT db ? ; Interrupt pin |
wav_mode db ? ; bits per sample & channels |
;--------------------------------------------------------------------- |
ST_DONE = 0x0 ; for interacting with player's window |
ST_PLAY = 0x1 |
ST_EXIT = 0x2 |
ST_STOP = 0x4 |
status db ? |
fileattr: rb 40 |
;--------------------------------------------------------------------- |
phys_bdl_buffer rd 1 |
phys_wav_buffer1 rd 1 |
phys_wav_buffer2 rd 1 |
align 32 |
; Buffer Descriptors List |
; ___________________________ |
; | physical address | dword |
; |_________________________| |
; | attr | length | dword max. length = 65535 samples |
; |_________________________| |
BDL_BUFFER: |
rb 32*8 ; 32 descriptors, 8 bytes each |
;--------------------------------------------------------------------- |
file_data: |
WAV_BUFFER1: |
rb 60 * 1024 ; 60 Kb |
WAV_BUFFER2: |
rb 60 * 1024 |
LOAD_BUFFER: |
rb 60 * 1024 |
;--------------------------------------------------------------------- |
procinfo process_information |
work_area: |
rb 0x10000 |
;--------------------------------------------------------------------- |
rb 0x800 |
thread_stack: |
rb 0x1000 ; for stack |
STACK_P: |
MEMORY_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/ac97wav/trunk/frontend.inc |
---|
0,0 → 1,276 |
thread: |
mov edi, textbox_string |
or ecx, -1 |
xor eax, eax |
repnz scasb |
not ecx |
dec ecx |
mov [textbox_position], cl |
call draw_window |
call main_loop |
mov [status], ST_EXIT |
mcall MF_EXIT |
;--------------------------------------------------------------------- |
main_loop: |
cmp [status], ST_PLAY |
je @f |
mcall MF_WAIT_EVENT |
jmp .handle_event |
@@: |
call draw_progress_bar |
mcall MF_WAIT_EVENT_TIMEOUT, 80 |
.handle_event: |
cmp eax, EV_REDRAW |
je redraw |
cmp eax, EV_BUTTON |
je button |
cmp eax, EV_KEY |
je key |
jmp main_loop |
redraw: |
call draw_window |
jmp main_loop |
key: |
mcall MF_GETKEY |
cmp [textbox_active], 1 |
jne main_loop |
cmp ah, 13 |
je .enter |
cmp ah, 8 |
je .backspace |
movzx ecx, [textbox_position] |
cmp ecx, 255 |
jae .enter |
mov [textbox_string + ecx], ah |
inc [textbox_position] |
call textbox_draw |
jmp main_loop |
.enter: |
mov [textbox_active], 0 |
call textbox_draw |
jmp main_loop |
.backspace: |
movzx ecx, [textbox_position] |
test ecx, ecx |
jz main_loop |
dec [textbox_position] |
mov [textbox_string + ecx - 1], byte 0 |
call textbox_draw |
jmp main_loop |
button: |
mcall MF_GETBUTTON |
cmp ah, 0x10 |
je play_button |
cmp ah, 0x11 |
je stop_button |
cmp ah, 0x12 |
je decr_button |
cmp ah, 0x13 |
je incr_button |
cmp ah, 0x14 |
je volm_button |
cmp ah, 0x15 |
je volp_button |
cmp ah, 0x20 |
je activate_textbox |
cmp ah, 0x30 |
je progressbar_click |
cmp ah, 1 |
jne main_loop |
; mov [status], ST_STOP |
; mcall MF_DELAY, 40 |
ret |
play_button: |
xor eax, eax |
xchg al, [textbox_active] |
cmp al, 0 |
je @f |
call textbox_draw |
@@: |
mov [status], ST_PLAY |
jmp main_loop |
stop_button: |
mov [status], ST_STOP |
jmp main_loop |
decr_button: |
; mov [status], ST_STOP |
; @@: |
; mcall 5, 1 |
; cmp [status], ST_DONE |
; jne @b |
; movzx esi, [textbox_position] |
; add esi, textbox_string |
; @@: |
; cmp byte [esi], '/' |
; je @f |
; dec esi |
; jmp @b |
; @@: |
; mov byte [esi+1], 0 |
; mov [fileinfo.first_block], 0 |
; mov [fileinfo.dest], WAV_BUFFER1 |
; mcall 58, fileinfo |
; add ebx, WAV_BUFFER1 |
; mov esi, WAV_BUFFER1+8 |
; .next_file: |
; cmp ebx, esi |
; jbe .fin |
; cmp word [esi], "WA" |
; jne .next_file |
; cmp byte [esi+1], "V" |
; jne .next_file |
; .fin: |
;mov eax, [fileinfo.first_block] |
;cmp eax, 1000 |
;jnl @f |
;mov [fileinfo.first_block], 0 |
;jmp main_loop |
;@@: |
;sub [fileinfo.first_block], 1000 |
;jmp main_loop |
incr_button: |
;add [fileinfo.first_block], 1000 |
jmp main_loop |
volm_button: |
inc byte [volume] |
and byte [volume], 0x1f |
jz volp_button |
or [volume], 0x10000000 |
jmp _print_volume |
; jmp main_loop |
volp_button: |
dec byte [volume] |
and byte [volume], 0x1f |
jz volm_button |
or [volume], 0x10000000 |
; jmp main_loop |
_print_volume: |
movzx eax, byte [volume] |
neg eax |
add eax, 31 |
dps "Volume: " |
dpd eax |
newline |
jmp main_loop |
activate_textbox: |
cmp [status], ST_DONE |
jne main_loop |
mov [textbox_active], 1 |
call textbox_draw |
jmp main_loop |
progressbar_click: |
;print "click on progress bar" |
cmp [status], ST_DONE |
je main_loop |
mcall MF_GETMOUSE, MS_COORDS_WINDOW |
shr eax, 16 ; get mouse.x |
sub eax, 7 |
jz @f |
imul [file_size] |
mov ebx, 286 |
div ebx |
@@: |
;dps "block: " |
;dpd eax |
;newline |
and eax, not 511 |
mov [fileinfo.first_byte], eax |
call draw_progress_bar |
jmp main_loop |
ret |
;--------------------------------------------------------------------- |
PBAR_WIDTH = 286 |
draw_window: |
mcall MF_DRAWSTATUS, DS_BEGIN |
mcall MF_WINDOW, <100,299>, <100,72>, 0x03404040 |
; create six buttons |
mov edi, 6 |
mpack ebx, 7, 45 |
mpack ecx, 24, 13 |
mov edx, 0x10 |
mov esi, 0xA0A0A0 |
@@: |
mcall MF_BUTTON |
add ebx, 48 shl 16 |
inc edx |
dec edi |
jnz @b |
mcall MF_TEXT, <8,8>, 0x10FFFFFF, header, header.size |
mcall ,<13,28>, 0x404040, buttons_text, buttons_text.size |
sub ebx, 0x00010001 |
mov ecx, 0xFFFFFF |
mcall |
call draw_progress_bar |
call textbox_draw |
mcall MF_DRAWSTATUS, DS_END |
ret |
;--------------------------------------------------------------------- |
textbox_draw: |
mcall MF_BUTTON, <7,285>, <55,10>, 0x60000020 |
mov edx, 0x808080 |
cmp [textbox_active], 1 |
jne @f |
mov edx, 0xA0A0A0 |
@@: |
mcall MF_BAR, <7,286>, <55,11> |
movzx esi, [textbox_position] |
mcall MF_TEXT, <10,56>, 0x404040, textbox_string |
ret |
;--------------------------------------------------------------------- |
draw_progress_bar: |
pushad |
mov eax, PBAR_WIDTH |
mul [fileinfo.first_byte] |
div [file_size] |
push eax |
mcall MF_BAR, <7,286>, <41,11>, 0x808080 |
mcall MF_BUTTON, , , 0x60000030 |
pop eax |
mov bx, ax |
mov edx, 0xA0A0A0 |
mcall MF_BAR |
popad |
ret |
;--------------------------------------------------------------------- |
sz header, "AC'97 WAV player - all PCM audio" |
sz buttons_text, " Play Stop << >> Vol- Vol+" |
textbox_active db 0 |
textbox_position db 0;textbox_string.size-1 |
file_size dd 100 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/ac97wav/trunk/macros.inc |
---|
0,0 → 1,268 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; language for programs |
lang fix ru ; ru en fr ge fi |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/ac97wav/trunk/meosfunc.inc |
---|
0,0 → 1,29 |
MF_WINDOW = 0 |
MF_GETKEY = 2 |
MF_TEXT = 4 |
MF_DELAY = 5 |
MF_BUTTON = 8 |
MF_PROCINFO = 9 |
PN_MYSELF = -1 |
MF_WAIT_EVENT = 10 |
MF_DRAWSTATUS = 12 |
DS_BEGIN = 1 |
DS_END = 2 |
MF_BAR = 13 |
MF_GETBUTTON = 17 |
MF_WAIT_EVENT_TIMEOUT = 23 |
MF_GETMOUSE = 37 |
MS_COORDS_WINDOW = 1 |
MF_PORTS = 46 |
PRT_RESERVE = 0 |
PRT_FREE = 1 |
MF_THREAD = 51 |
THR_CREATE = 1 |
MF_PCI = 62 |
MF_EXIT = -1 |
MF_INTERNAL_SERVICES = 68 |
ALLOC_PHYS_MEM =5 |
FREE_PHYS_MEM =6 |
SET_PHYS_BUFFER =7 |
GET_PHYS_BUFFER =8 |
MF_SYSTREE = 70 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/ac97wav/trunk/ac97.inc |
---|
0,0 → 1,288 |
; Vendor ids |
INTEL_VID = 0x8086 |
SIS_VID = 0x1039 |
NVIDIA_VID = 0x10DE |
AMD_VID = 0x1022 |
; Device ids |
ICH_DID = 0x2415 |
ICH0_DID = 0x2425 |
ICH2_DID = 0x2445 |
ICH3_DID = 0x2485 |
ICH4_DID = 0x24C5 |
ICH5_DID = 0x24D5 |
MX440_DID = 0x7195 |
SI7012_DID = 0x7012 |
NFORCE_DID = 0x01B1 |
NFORCE2_DID = 0x006A |
AMD8111_DID = 0x764D |
AMD768_DID = 0x7445 |
NAMBAR_REG = 0x10 ; native audio mixer BAR |
NAM_SIZE = 256 ; 256 bytes required. |
NABMBAR_REG = 0x14 ; native audio bus mastering BAR |
NABM_SIZE = 64 ; 64 bytes |
IRQ_REG = 0x3c ; IRQ holder for PCI |
INT_REG = 0x3d ; INT pin |
ICH4_CFG_REG = 0x41 ; ICH4 config register |
; BUS master registers, accessed via NABMBAR+offset |
; ICH supports 3 different types of register sets for three types of things |
; it can do, thus: |
; |
; PCM in (for recording) aka PI |
; PCM out (for playback) aka PO |
; MIC in (for recording) aka MC |
PI_BDBAR_REG = 0 ; PCM in buffer descriptor BAR |
PO_BDBAR_REG = 10h ; PCM out buffer descriptor BAR |
MC_BDBAR_REG = 20h ; MIC in buffer descriptor BAR |
; each buffer descriptor BAR holds a pointer which has entries to the buffer |
; contents of the .WAV file we're going to play. Each entry is 8 bytes long |
; (more on that later) and can contain 32 entries total, so each BAR is |
; 256 bytes in length, thus: |
BDL_SIZE = 32*8 ; Buffer Descriptor List size |
INDEX_MASK = 31 ; indexes must be 0-31 |
PI_CIV_REG = 4 ; PCM in current Index value (RO) |
PO_CIV_REG = 14h ; PCM out current Index value (RO) |
MC_CIV_REG = 24h ; MIC in current Index value (RO) |
;8bit read only |
; each current index value is simply a pointer showing us which buffer |
; (0-31) the codec is currently processing. Once this counter hits 31, it |
; wraps back to 0. |
; this can be handy to know, as once it hits 31, we're almost out of data to |
; play back or room to record! |
PI_LVI_REG = 5 ; PCM in Last Valid Index |
PO_LVI_REG = 15h ; PCM out Last Valid Index |
MC_LVI_REG = 25h ; MIC in Last Valid Index |
;8bit read/write |
; The Last Valid Index is a number (0-31) to let the codec know what buffer |
; number to stop on after processing. It could be very nasty to play audio |
; from buffers that aren't filled with the audio we want to play. |
PI_SR_REG = 6 ; PCM in Status register |
PO_SR_REG = 16h ; PCM out Status register |
MC_SR_REG = 26h ; MIC in Status register |
;16bit read/write |
; status registers. Bitfields follow: |
FIFO_ERR = BIT4 ; FIFO Over/Underrun W1TC. |
BCIS = BIT3 ; buffer completion interrupt status. |
; Set whenever the last sample in ANY |
; buffer is finished. Bit is only |
; set when the Interrupt on Complete |
; (BIT4 of control reg) is set. |
LVBCI = BIT2 ; Set whenever the codec has processed |
; the last buffer in the buffer list. |
; Will fire an interrupt if IOC bit is |
; set. Probably set after the last |
; sample in the last buffer is |
; processed. W1TC |
CELV = BIT1 ; Current buffer == last valid. |
; Bit is RO and remains set until LVI is |
; cleared. Probably set up the start |
; of processing for the last buffer. |
DCH = BIT0 ; DMA controller halted. |
; set whenever audio stream is stopped |
; or something else goes wrong. |
PI_PICB_REG = 8 ; PCM in position in current buffer(RO) |
PO_PICB_REG = 18h ; PCM out position in current buffer(RO) |
MC_PICB_REG = 28h ; MIC in position in current buffer (RO) |
;16bit read only |
; position in current buffer regs show the number of dwords left to be |
; processed in the current buffer. |
; |
PI_PIV_REG = 0ah ; PCM in Prefected index value |
PO_PIV_REG = 1ah ; PCM out Prefected index value |
MC_PIV_REG = 2ah ; MIC in Prefected index value |
;8bit, read only |
; Prefetched index value register. |
; tells which buffer number (0-31) has be prefetched. I'd imagine this |
; value follows the current index value fairly closely. (CIV+1) |
; |
PI_CR_REG = 0bh ; PCM in Control Register |
PO_CR_REG = 1bh ; PCM out Control Register |
MC_CR_REG = 2bh ; MIC in Control Register |
; 8bit |
; Control register *MUST* only be accessed as an 8bit value. |
; Control register. See bitfields below. |
; |
IOCE = BIT4 ; interrupt on complete enable. |
; set this bit if you want an intrtpt |
; to fire whenever LVBCI is set. |
FEIFE = BIT3 ; set if you want an interrupt to fire |
; whenever there is a FIFO (over or |
; under) error. |
LVBIE = BIT2 ; last valid buffer interrupt enable. |
; set if you want an interrupt to fire |
; whenever the completion of the last |
; valid buffer. |
RR = BIT1 ; reset registers. Nukes all regs |
; except bits 4:2 of this register. |
; Only set this bit if BIT 0 is 0 |
RPBM = BIT0 ; Run/Pause |
; set this bit to start the codec! |
GLOB_CNT_REG = 2ch ; Global control register |
SEC_RES_EN = BIT5 ; secondary codec resume event |
; interrupt enable. Not used here. |
PRI_RES_EN = BIT4 ; ditto for primary. Not used here. |
ACLINK_OFF = BIT3 ; Turn off the AC97 link |
ACWARM_RESET = BIT2 ; Awaken the AC97 link from sleep. |
; registers preserved, bit self clears |
ACCOLD_RESET = BIT1 ; Reset everything in the AC97 and |
; reset all registers. Not self clearin |
;g |
GPIIE = BIT0 ; GPI Interrupt enable. |
; set if you want an interrupt to |
; fire upon ANY of the bits in the |
; GPI (general pursose inputs?) not used |
;. |
GLOB_STS_REG = 30h ; Global Status register (RO) |
MD3 = BIT17 ; modem powerdown status (yawn) |
AD3 = BIT16 ; Audio powerdown status (yawn) |
RD_COMPLETE_STS = BIT15 ; Codec read timed out. 0=normal |
BIT3SLOT12 = BIT14 ; shadowed status of bit 3 in slot 12 |
BIT2SLOT12 = BIT13 ; shadowed status of bit 2 in slot 12 |
BIT1SLOT12 = BIT12 ; shadowed status of bit 1 in slot 12 |
SEC_RESUME_STS = BIT11 ; secondary codec has resumed (and irqed) |
PRI_RESUME_STS = BIT10 ; primary codec has resumed (and irqed) |
SEC_CODEC_RDY = BIT9 ; secondary codec is ready for action |
PRI_CODEC_RDY = BIT8 ; Primary codec is ready for action |
; software must check these bits before |
; starting the codec! |
MIC_IN_IRQ = BIT7 ; MIC in caused an interrupt |
PCM_OUT_IRQ = BIT6 ; One of the PCM out channels IRQed |
PCM_IN_IRQ = BIT5 ; One of the PCM in channels IRQed |
MODEM_OUT_IRQ = BIT2 ; modem out channel IRQed |
MODEM_IN_IRQ = BIT1 ; modem in channel IRQed |
GPI_STS_CHANGE = BIT0 ; set whenever GPI's have changed. |
; BIT0 of slot 12 also reflects this. |
ACC_SEMA_REG = 34h ; Codec write semiphore register |
CODEC_BUSY = BIT0 ; codec register I/O is happening |
; self clearing |
; |
; Buffer Descriptors List |
; As stated earlier, each buffer descriptor list is a set of (up to) 32 |
; descriptors, each 8 bytes in length. Bytes 0-3 of a descriptor entry point |
; to a chunk of memory to either play from or record to. Bytes 4-7 of an |
; entry describe various control things detailed below. |
; |
; Buffer pointers must always be aligned on a Dword boundry. |
; |
; |
IOC = BIT31 ; Fire an interrupt whenever this |
; buffer is complete. |
BUP = BIT30 ; Buffer Underrun Policy. |
; if this buffer is the last buffer |
; in a playback, fill the remaining |
; samples with 0 (silence) or not. |
; It's a good idea to set this to 1 |
; for the last buffer in playback, |
; otherwise you're likely to get a lot |
; of noise at the end of the sound. |
; |
; Bits 15:0 contain the length of the buffer, in number of samples, which |
; are 16 bits each, coupled in left and right pairs, or 32bits each. |
; Luckily for us, that's the same format as .wav files. |
; |
; A value of FFFF is 65536 samples. Running at 44.1Khz, that's just about |
; 1.5 seconds of sample time. FFFF * 32bits is 1FFFFh bytes or 128k of data. |
; |
; A value of 0 in these bits means play no samples. |
; |
;***************************************************************************** |
;* AC97 Codec registers include (based on Jeff Leyda AC97 wav player SDK :-) |
;***************************************************************************** |
; Not all codecs are created =al. Refer to the spec for your specific codec. |
; All registers are 16bits wide. Access to codec registers over the AC97 link |
; is defined by the OEM. |
; Secondary codec's are accessed by ORing in BIT7 of all register accesses. |
; each codec/mixer register is 16bits |
CODEC_RESET_REG = 00 ; reset codec |
CODEC_MASTER_VOL_REG = 02 ; master volume |
CODEC_HP_VOL_REG = 04 ; headphone volume |
CODEC_MASTER_MONO_VOL_REG = 06 ; master mono volume |
CODEC_MASTER_TONE_REG = 08 ; master tone (R+L) |
CODEC_PCBEEP_VOL_REG = 0ah ; PC beep volume |
CODEC_PHONE_VOL_REG = 0ch ; phone volume |
CODEC_MIC_VOL_REG = 0eh ; MIC volume |
CODEC_LINE_IN_VOL_REG = 10h ; line input volume |
CODEC_CD_VOL_REG = 12h ; CD volume |
CODEC_VID_VOL_REG = 14h ; video volume |
CODEC_AUX_VOL_REG = 16h ; aux volume |
CODEC_PCM_OUT_REG = 18h ; PCM output volume |
CODEC_RECORD_SELECT_REG = 1ah ; record select input |
CODEC_RECORD_VOL_REG = 1ch ; record volume |
CODEC_RECORD_MIC_VOL_REG = 1eh ; record mic volume |
CODEC_GP_REG = 20h ; general purpose |
CODEC_3D_CONTROL_REG = 22h ; 3D control |
; 24h is reserved |
CODEC_POWER_CTRL_REG = 26h ; powerdown control |
CODEC_EXT_AUDIO_REG = 28h ; extended audio |
CODEC_EXT_AUDIO_CTRL_REG = 2ah ; extended audio control |
CODEC_PCM_FRONT_DACRATE_REG = 2ch ; PCM out sample rate |
CODEC_PCM_SURND_DACRATE_REG = 2eh ; surround sound sample rate |
CODEC_PCM_LFE_DACRATE_REG = 30h ; LFE sample rate |
CODEC_LR_ADCRATE_REG = 32h ; PCM in sample rate |
CODEC_MIC_ADCRATE_REG = 34h ; mic in sample rate |
; registers 36-7a are reserved on the ICH |
CODEC_VENDORID1_REG = 7ch ; codec vendor ID 1 |
CODEC_VENDORID2_REG = 7eh ; codec vendor ID 2 |
; When 2 codecs are present in the system, use BIT7 to access the 2nd |
; set of registers, ie 80h-feh |
SECONDARY_CODEC = BIT7 ; 80-8f registers for 2nda |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/ac97wav/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm ac97wav.asm ac97wav |
@pause |
/programs/media/ac97wav/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm ac97wav.asm ac97wav |
@pause |
/programs/media/ac97wav/trunk/codec.inc |
---|
0,0 → 1,344 |
NAMBAR_read_byte: |
add dx, [NAMBAR] |
in al, dx |
ret |
NAMBAR_read_word: |
add dx, [NAMBAR] |
in ax, dx |
ret |
NAMBAR_read_dword: |
add dx, [NAMBAR] |
in eax, dx |
ret |
NAMBAR_write_byte: |
add dx, [NAMBAR] |
out dx, al |
ret |
NAMBAR_write_word: |
add dx, [NAMBAR] |
out dx, ax |
ret |
NAMBAR_write_dword: |
add dx, [NAMBAR] |
out dx, eax |
ret |
NABMBAR_read_byte: |
add dx, [NABMBAR] |
in al, dx |
ret |
NABMBAR_read_word: |
add dx, [NABMBAR] |
in ax, dx |
ret |
NABMBAR_read_dword: |
add dx, [NABMBAR] |
in eax, dx |
ret |
NABMBAR_write_byte: |
add dx, [NABMBAR] |
out dx, al |
ret |
NABMBAR_write_word: |
add dx, [NABMBAR] |
out dx, ax |
ret |
NABMBAR_write_dword: |
add dx, [NABMBAR] |
out dx, eax |
ret |
semaphore: |
push ecx edx |
mov edx, GLOB_STS_REG ; 0x30 global status register |
call NABMBAR_read_dword |
and eax, PRI_CODEC_RDY ; 100h primary codec ready |
jz .success ; exit if codec not ready !!! |
; mov ecx, 1024 ; try 1024 times |
mov ecx, 0ffffh ; try 65535 times |
.wait: |
mov edx, ACC_SEMA_REG ; 0x34 codec write semaphore |
call NABMBAR_read_byte |
and al, CODEC_BUSY ; 01h codec access semaphore |
jz .success ; exit if codec not busy !!! |
dec ecx |
jnz .wait |
pop edx ecx |
mov eax, 0 |
jmp .exit |
.success: |
pop edx ecx |
mov eax, 1 |
.exit: |
ret |
codecStop: |
push eax ebx edx |
mov edx, PO_CR_REG ; 0x1B control register |
mov al, 0 ; stop all PCM out data |
call NABMBAR_write_byte |
mcall MF_DELAY, eax ; ebx = (eax = MF_DELAY = 5); wait 50 ms |
mov edx, PO_CR_REG ; 0x1B control register |
mov al, RR ; reset PCM out regs |
call NABMBAR_write_byte |
mcall MF_DELAY, eax |
pop edx ebx eax |
ret |
; set voulme |
; in ax = volume level |
setVolume: |
push eax edx |
push eax |
call semaphore |
mov edx, CODEC_RESET_REG ; 0 |
xor eax, eax ; register reset the codec |
call NAMBAR_write_word |
call semaphore |
pop eax |
imul ax, 0101h ; set volume for both chn |
mov edx, CODEC_MASTER_VOL_REG ; 2 |
call NAMBAR_write_word |
push eax |
call semaphore |
pop eax ; set volume for both chn |
mov edx, CODEC_HP_VOL_REG ; 4 |
call NAMBAR_write_word |
push eax |
call semaphore |
mov edx, CODEC_CD_VOL_REG ; 12h |
pop eax ; set volume for both chn |
shr eax, 2 ; adjust CD VOL |
call NAMBAR_write_word |
call semaphore |
mov edx, CODEC_PCM_OUT_REG ; 18h |
mov ax, 0808h ; standard PCM out volume |
call NAMBAR_write_word |
pop edx eax |
ret |
samplerate dw 0 |
; enable codec, unmute stuff, set output to desired rate |
; in : ax = desired sample rate |
; out: ax = true or false |
; |
codecConfig: |
pushad |
mov [samplerate], ax ; save sample rate |
; mov edx, GLOB_STS_REG ; 30h global status register |
; call NABMBAR_read_dword |
; and eax, PRI_CODEC_RDY ; 0100h primary codec ready |
; jnz skip_init ; skip init if codec ready !!! |
; stop the codec if currently playing |
;;; call codecStop |
; mov edx, GLOB_STS_REG |
; call NABMBAR_read_dword |
; dps "GLOB_STA = " |
; dph eax |
; newline |
; mov edx, GLOB_CNT_REG |
; call NABMBAR_read_dword |
; dps "GLOB_CNT = " |
; dph eax |
; newline |
; mcall 5, 10 |
;; test eax, ACCOLD_RESET |
;; jnz .skip_cold_reset |
; print "cold reset" |
; do a cold reset |
mov edx, GLOB_CNT_REG ; 2ch global control register |
xor eax, eax |
call NABMBAR_write_dword ; enable (AC Link off clear) |
; print "wait" |
mcall 5, 5 |
; print "alive!" |
;; .skip_cold_reset: |
mov edx, GLOB_CNT_REG ; 2ch global control register |
mov eax, ACCOLD_RESET + PRI_RES_EN ; cold reset + primary resume |
call NABMBAR_write_dword ; 2 channels & 16 bit samples |
mov edx, GLOB_CNT_REG ; 2ch global control register |
call NABMBAR_read_dword |
and eax, ACCOLD_RESET ; cold reset |
jz init_error ; INIT FAILED !!! |
; print "cold reset finished" |
; wait for primary codec ready status |
mov ecx, 128 |
codec_ready_loop: |
mov edx, GLOB_STS_REG ; 30h global status register |
call NABMBAR_read_dword |
and eax, PRI_CODEC_RDY ; 0100h primary codec ready |
jnz codec_ready_exit ; move on if codec ready !!! |
mcall 5, 1 |
dec ecx |
jnz codec_ready_loop |
;dps "~" |
codec_ready_exit: |
; wait until codec init ready (*** replaces warm reset wait ***) |
mcall 5, 60 |
; test if codec ready bit is finally set |
mov edx, GLOB_STS_REG ; 30h global status register |
call NABMBAR_read_dword |
and eax, PRI_CODEC_RDY ; 0100h primary codec ready |
jnz codec_ready_bit_set ; move on if codec ready !!! |
cmp [AC97ICH4], 1 |
jne init_error |
; je codec_ready_bit_set ; ignore codec ready for ICH4 |
; jmp init_error ; codec ready bit not set !!! |
codec_ready_bit_set: |
; clear semaphore flag |
mov edx, CODEC_RESET_REG ; 0h codec reset register |
call NAMBAR_read_word |
; check if codec sections ready |
call semaphore |
test eax, eax |
jz init_error |
mov edx, CODEC_POWER_CTRL_REG ; 26h codec powerdown ctrl |
call NAMBAR_read_word |
and eax, 01111b |
cmp eax, 01111b |
jne init_error ; codec sections not ready |
; disable interrupts |
mov al, 0 |
mov edx, PI_CR_REG ; 0Bh PCM in control register |
call NABMBAR_write_byte |
mov edx, PO_CR_REG ; 1Bh PCM out control register |
call NABMBAR_write_byte |
mov edx, MC_CR_REG ; 2Bh MIC in control register |
call NABMBAR_write_byte |
; reset channels |
mov al, RR ; 02h reset Bus master regs |
mov edx, PI_CR_REG ; 0Bh PCM in control register |
call NABMBAR_write_byte |
mov edx, PO_CR_REG ; 1Bh PCM out control register |
call NABMBAR_write_byte |
mov edx, MC_CR_REG ; 2Bh MIC in control register |
call NABMBAR_write_byte |
; set default volume |
mov eax, 15 ; set average volume level |
call setVolume |
; set VRA and clear DRA (if not supported will be skipped) |
call semaphore |
test eax, eax |
jz init_error |
mov edx, CODEC_EXT_AUDIO_CTRL_REG ; register 2ah |
call NAMBAR_read_word ; get ext audio ctl |
mov ebx, eax |
call semaphore |
test eax, eax |
jz init_error |
mov eax, ebx |
and eax, 0FFFFh - BIT1 ; clear DRA (BIT1) |
or eax, BIT0 ; set VRA (BIT0) |
mov edx, CODEC_EXT_AUDIO_CTRL_REG ; register 2ah |
call NAMBAR_write_word ; write ext audio ctl |
; set desired sample rate |
skip_init: |
call semaphore |
test eax, eax |
jz init_error |
; mov edx, CODEC_PCM_FRONT_DACRATE_REG |
; call NAMBAR_read_word |
; and eax, 0xFFFF |
; newline |
; dps "old PCM OUT RATE: " |
; dpd eax |
; newline |
mov ax, [samplerate] ; restore sample rate |
; mov edx, CODEC_PCM_FRONT_DACRATE_REG ; register 2ch |
; call NAMBAR_write_word |
call set_sample_rate |
popad |
mov eax, 1 ; exit with success |
jmp exit_config |
init_error: |
popad |
xor eax, eax ; exit with error |
exit_config: |
ret |
set_sample_rate: ; rate in ax |
mov edx, CODEC_PCM_FRONT_DACRATE_REG ; 0x2C reg |
call NAMBAR_write_word |
ret |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/ac97wav/trunk/constant.inc |
---|
0,0 → 1,35 |
;constants of stuff that seem hard to remember at times. |
BIT0 EQU 1 |
BIT1 EQU 2 |
BIT2 EQU 4 |
BIT3 EQU 8 |
BIT4 EQU 10h |
BIT5 EQU 20h |
BIT6 EQU 40h |
BIT7 EQU 80h |
BIT8 EQU 100h |
BIT9 EQU 200h |
BIT10 EQU 400h |
BIT11 EQU 800h |
BIT12 EQU 1000h |
BIT13 EQU 2000h |
BIT14 EQU 4000h |
BIT15 EQU 8000h |
BIT16 EQU 10000h |
BIT17 EQU 20000h |
BIT18 EQU 40000h |
BIT19 EQU 80000h |
BIT20 EQU 100000h |
BIT21 EQU 200000h |
BIT22 EQU 400000h |
BIT23 EQU 800000h |
BIT24 EQU 1000000h |
BIT25 EQU 2000000h |
BIT26 EQU 4000000h |
BIT27 EQU 8000000h |
BIT28 EQU 10000000h |
BIT29 EQU 20000000h |
BIT30 EQU 40000000h |
BIT31 EQU 80000000h |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/ac97wav/trunk/debug.inc |
---|
0,0 → 1,131 |
macro debug_print str |
{ |
local ..string, ..label |
jmp ..label |
..string db str,0 |
..label: |
pushf |
pushad |
mov edx,..string |
call debug_outstr |
popad |
popf |
} |
dps fix debug_print |
macro debug_print_dec arg |
{ |
pushf |
pushad |
if ~arg eq eax |
mov eax,arg |
end if |
call debug_outdec |
popad |
popf |
} |
dpd fix debug_print_dec |
;--------------------------------- |
debug_outdec: ;(eax - num, edi-str) |
push 10 ;2 |
pop ecx ;1 |
push -'0' ;2 |
.l0: |
xor edx,edx ;2 |
div ecx ;2 |
push edx ;1 |
test eax,eax ;2 |
jnz .l0 ;2 |
.l1: |
pop eax ;1 |
add al,'0' ;2 |
call debug_outchar ; stosb |
jnz .l1 ;2 |
ret ;1 |
;--------------------------------- |
debug_outchar: ; al - char |
pushf |
pushad |
mov cl,al |
mov eax,63 |
mov ebx,1 |
int 0x40 |
popad |
popf |
ret |
debug_outstr: |
mov eax,63 |
mov ebx,1 |
@@: |
mov cl,[edx] |
test cl,cl |
jz @f |
int 40h |
inc edx |
jmp @b |
@@: |
ret |
macro newline |
{ |
dps <13,10> |
} |
macro print message |
{ |
dps message |
newline |
} |
macro pregs |
{ |
dps "EAX: " |
dpd eax |
dps " EBX: " |
dpd ebx |
newline |
dps "ECX: " |
dpd ecx |
dps " EDX: " |
dpd edx |
newline |
} |
macro debug_print_hex arg |
{ |
pushf |
pushad |
if ~arg eq eax |
mov eax, arg |
end if |
call debug_outhex |
popad |
popf |
} |
dph fix debug_print_hex |
debug_outhex: |
; eax - number |
mov edx, 8 |
.new_char: |
rol eax, 4 |
movzx ecx, al |
and cl, 0x0f |
mov cl, [__hexdigits + ecx] |
pushad |
mcall 63, 1 |
popad |
dec edx |
jnz .new_char |
ret |
__hexdigits: |
db '0123456789ABCDEF' |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/ac97wav/trunk/includes.inc |
---|
0,0 → 1,10 |
include "MACROS.INC" |
include "DEBUG.INC" |
include "CONSTANT.INC" |
include "AC97.INC" |
include "PCI.INC" |
include "CODEC.INC" |
include "FRONTEND.INC" |
MF_PCI = 62 |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/ac97wav/trunk/pci.inc |
---|
0,0 → 1,46 |
PCI_CMD_REG = 04h ; reg 04, command reg |
IO_ENA = 0x00000001 ; i/o decode enable |
MEM_ENA = 0x00000002 ; memory decode enable |
BM_ENA = 0x00000004 ; bus master enable |
pciRegRead8: ; register in CL! |
mov bl, 4 |
mov bh, [bus] |
mov ch, [devfn] |
mcall MF_PCI |
ret |
pciRegRead16: |
mov bl, 5 |
mov bh, [bus] |
mov ch, [devfn] |
mcall MF_PCI |
ret |
pciRegRead32: |
mov bl, 6 |
mov bh, [bus] |
mov ch, [devfn] |
mcall MF_PCI |
ret |
pciRegWrite8: ; value in DL! |
mov bl, 8 |
mov bh, [bus] |
mov ch, [devfn] |
mcall MF_PCI |
ret |
pciRegWrite16: |
mov bl, 9 |
mov bh, [bus] |
mov ch, [devfn] |
mcall MF_PCI |
ret |
pciRegWrite32: |
mov bl, 10 |
mov bh, [bus] |
mov ch, [devfn] |
mcall MF_PCI |
ret |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/midamp/trunk/MIDAMP.ASM |
---|
58,7 → 58,7 |
dd START |
dd I_END |
dd APP_MEM |
dd APP_MEM - 1024 |
dd APP_MEM ;stack size=1024 |
dd I_PARAM |
listsel dd 0 |
channel dd 0 |
357,7 → 357,7 |
dd 0 |
dd 0 |
dd 0 |
fsize dd APP_MEM-2048-workarea ; max size |
fsize dd APP_MEM-1024-workarea ; max size |
dd workarea |
I_END: ; ª®¥æ ¯à®£à ¬¬ë |
filename: |
/programs/media/midamp/trunk/macros.inc |
---|
143,6 → 143,10 |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 178,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 222,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/media/bmpview/trunk/bmpview.asm |
---|
0,0 → 1,694 |
; |
; BMP VIEWER |
; modified by Ivan Poddubny |
; |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x300000 ; memory for app |
dd 0xfff0 ; esp |
dd I_Param , 0x0 ; I_Param , I_Icon |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
cmp dword [I_Param],0 |
je noparam |
cmp dword [I_Param],'BOOT' |
jne noboot |
call load_image |
call set_as_background |
mov eax,15 |
mov ebx,4 |
mov ecx,2 |
int 0x40 |
mov eax,15 |
mov ebx,3 |
int 0x40 |
or eax,-1 |
int 0x40 |
noboot: |
mov edi,name_string |
mov al,0 |
mov ecx,70 |
rep stosb |
mov ecx,50 |
mov edi,I_Param |
repne scasb |
sub edi,I_Param |
mov ecx,edi |
mov esi,I_Param |
mov edi,name_string |
cld |
rep movsb |
call load_image |
noparam: |
call draw_window ; at first, draw the window |
still: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
je red |
cmp eax,2 ; key in buffer ? |
je key |
cmp eax,3 ; button in buffer ? |
je button |
jmp still |
red: ; redraw |
call draw_window |
jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp still |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne noclose |
mov eax,-1 ; close this program |
int 0x40 |
noclose: |
cmp ah,2 |
jne no_file_name |
call read_string |
jmp still |
no_file_name: |
cmp ah,3 |
jne no_load_image |
call load_image |
call draw_window |
jmp still |
no_load_image: |
cmp ah,4 |
jne no_setasbackground |
call set_as_background |
jmp still |
no_setasbackground: |
cmp ah,5 |
jne no_tiled |
mov eax,15 |
mov ebx,4 |
mov ecx,1 |
int 0x40 |
mov eax,15 |
mov ebx,3 |
int 0x40 |
jmp still |
no_tiled: |
cmp ah,6 |
jne no_stretch |
mov eax,15 |
mov ebx,4 |
mov ecx,2 |
int 0x40 |
mov eax,15 |
mov ebx,3 |
int 0x40 |
jmp still |
no_stretch: |
jmp still |
type dd 0x0 |
i_pos dd 0x0 |
x_size dd 0x1 |
y_size dd 0x1 |
bpp dd 0x24 |
temp dd 999 |
fileinfoblock: |
dd 0 ; 0 = read |
dd 0 ; first 512 block |
dd 1 ; number of blocks to read |
dd 0x10000+1024 ; read to |
dd 35 ; 17000 byte work area |
name_string: |
db '/HARDDISK/FIRST/MENUET/PICS/NEW.BMP',0 |
times 100 db 0 |
read_header: |
pusha |
mov edi,0x10000 |
mov ecx,100 |
mov eax,0 |
cld |
rep stosb |
mov [fileinfoblock+ 8],dword 1 |
mov [fileinfoblock+12],dword 0x10000 |
push dword [name_string-4] |
mov [name_string-4],dword 0x20000 |
mov eax,58 |
mov ebx,fileinfoblock |
int 0x40 |
pop dword [name_string-4] |
movzx eax,word [0x10000+0] |
mov [type],eax |
mov eax,[0x10000+10] |
mov [i_pos],eax |
mov eax,[0x10000+18] |
mov [x_size],eax |
mov eax,[0x10000+22] |
mov [y_size],eax |
movzx eax,word [0x10000+28] |
mov [bpp],eax |
popa |
ret |
draw_picture_info: |
pusha |
mov eax,13 |
mov ebx,380*65536+6*5 |
mov ecx,65*65536+40 |
mov edx,0xffffff |
int 0x40 |
mov eax,47 |
mov ebx,5*65536 |
mov ecx,[x_size] |
mov edx,380*65536+65 |
mov esi,0x224466 |
int 0x40 |
mov ecx,[y_size] |
add edx,10 |
int 0x40 |
mov ecx,[bpp] |
add edx,20 |
int 0x40 |
popa |
ret |
load_image: |
pusha |
call read_header |
cmp word [type],'BM' |
je ok_image |
cmp [bpp],24 |
je ok_image |
mov eax,13 ; not found ! |
mov ebx,150*65536+50 |
mov ecx,100*65536+50 |
mov edx,0xff0000 |
int 0x40 |
mov eax,5 |
mov ebx,100 |
int 0x40 |
jmp retimage |
ok_image: |
call draw_picture_info |
mov [fileinfoblock+8],dword 0x100000/512 |
mov eax,0x80000 |
sub eax,[i_pos] |
mov [fileinfoblock+12],eax |
push dword [name_string-4] |
mov [name_string-4],dword 0x20000 |
mov eax,58 |
mov ebx,fileinfoblock |
int 0x40 |
pop dword [name_string-4] |
mov eax,[x_size] |
imul eax,3 |
mov [x_delta],eax |
mov ebx,[y_size] |
dec ebx |
imul eax,ebx |
add eax,0x80000 |
mov esi,eax |
mov edi,0x180000 |
newln: |
push esi |
push edi |
mov ecx,[x_delta] |
cld |
rep movsb |
pop edi |
pop esi |
sub esi,[x_delta];640*3 |
add edi,[x_delta];640*3 |
cmp esi,0x80000 |
jge newln |
retimage: |
popa |
ret |
x_delta dd 0x1 |
draw_image: |
pusha |
; mov eax,7 ; draw with putimage |
; mov ebx,0x180000 |
; mov ecx,200*65536+160 |
; mov edx,14*65536+28 |
; int 0x40 |
; mov eax,5 |
; mov ebx,200 |
; int 0x40 |
mov ebx,0 ; show the image as 320x240 picture |
mov ecx,0 |
times 6 db 0x90 |
newpix: |
push ebx |
push ecx |
mov eax,[esp] |
imul eax,[y_size] |
mov ebx,240 |
xor edx,edx |
div ebx |
imul eax,3 |
imul eax,[x_size] |
mov esi,eax |
mov eax,[esp+4] |
imul eax,[x_size] |
mov ebx,320 |
xor edx,edx |
div ebx |
imul eax,3 |
add esi,eax |
mov edx,[0x180000+esi] |
and edx,0xffffff |
pop ecx |
pop ebx |
add ebx,20 |
add ecx,40 |
mov eax,1 |
int 0x40 |
add ebx,-20 |
add ecx,-40 |
inc ebx |
cmp ebx,320 |
jb newpix |
xor ebx,ebx |
inc ecx |
cmp ecx,240 |
jb newpix |
popa |
ret |
set_as_background: |
pusha |
mov esi,0x180000 |
new_smooth: |
xor eax,eax |
xor ebx,ebx |
mov al,[esi] |
mov bl,[esi+3] |
add eax,ebx |
mov bl,[esi+6] |
add eax,ebx |
mov bl,[esi+9] |
add eax,ebx |
shr eax,2 |
and eax,0xff |
inc esi |
cmp esi,0x180000+640*480*3 |
jbe new_smooth |
mov eax,15 |
mov ebx,1 |
mov ecx,[x_size] |
mov edx,[y_size] |
int 0x40 |
mov eax,15 |
mov ebx,5 |
mov ecx,0x180000 |
mov edx,0 |
mov esi,640*480*3 |
int 0x40 |
mov eax,15 |
mov ebx,3 |
int 0x40 |
popa |
ret |
ya dd 300 |
addr dd name_string |
case_sens db 0 |
read_string: |
pusha |
mov edi,[addr] |
mov eax,[addr] |
mov eax,[eax-4] |
mov [temp],eax |
add edi,eax |
call print_strings |
f11: |
mov eax,10 |
int 0x40 |
cmp eax,2 |
jne read_done |
int 0x40 |
shr eax,8 |
cmp eax,13 |
je read_done |
cmp eax,192 |
jne noclear |
xor eax,eax |
mov [temp],eax |
mov edi,[addr] |
mov [edi-4],eax |
mov ecx,49 |
cld |
rep stosb |
mov edi,[addr] |
call print_strings |
jmp f11 |
noclear: |
cmp eax,8 |
jnz nobsl |
cmp [temp],0 |
jz f11 |
dec [temp] |
mov edi,[addr] |
add edi,[temp] |
mov [edi],byte 0 |
mov eax,[addr] |
dec dword [eax-4] |
call print_strings |
jmp f11 |
nobsl: |
cmp [temp],50 |
jae read_done |
cmp eax,dword 31 |
jbe f11 |
cmp [case_sens],1 |
je keyok |
cmp eax,dword 95 |
jb keyok |
add eax,-32 |
keyok: |
mov edi,[addr] |
add edi,[temp] |
mov [edi],al |
inc [temp] |
mov eax,[addr] |
inc dword [eax-4] |
call print_strings |
cmp [temp],50 |
jbe f11 |
read_done: |
mov ecx,50 |
sub ecx,[temp] |
mov edi,[addr] |
add edi,[temp] |
xor eax,eax |
cld |
rep stosb |
mov [temp],999 |
call print_strings |
popa |
ret |
print_strings: |
pusha |
mov eax,13 |
mov ebx,80*65536+6*45 |
mov ecx,[ya] |
shl ecx,16 |
add ecx,12 |
mov edx,0xffffff |
int 0x40 |
mov edx,[addr] |
mov esi,[edx-4] |
mov eax,4 |
mov ebx,80*65536+2 |
add ebx,[ya] |
mov ecx,0 |
int 0x40 |
cmp [temp],50 |
ja @f |
mov eax,[ya] |
mov ebx,eax |
shl eax,16 |
add eax,ebx |
add eax,10 |
mov ecx,eax |
mov eax,[temp] |
imul eax,eax,6 |
add eax,80 |
mov ebx,eax |
shl eax,16 |
add ebx,eax |
mov eax,38 |
mov edx,0 |
int 0x40 |
@@: |
popa |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,20*65536+444 ; [x start] *65536 + [x size] |
mov ecx,10*65536+333 ; [y start] *65536 + [y size] |
mov edx,0x03ffffff ; color of work area RRGGBB,8->color gl |
mov esi,0x808899ff ; color of grab bar RRGGBB,8->color gl |
mov edi,0x008899ff ; color of frames RRGGBB |
int 0x40 |
; WINDOW LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
mov ecx,0x10ddeeff ; color of text RRGGBB |
mov edx,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
mov eax,8 |
mov ebx,20*65536+52 |
mov ecx,295*65536+16 |
mov edx,2 |
mov esi,0x306090 |
int 0x40 |
add ebx,336*65536+20 |
add ecx,5*65536 |
mov edx,3 |
int 0x40 |
sub ecx,20*65536 |
mov edx,4 |
int 0x40 |
sub ecx,40*65536 |
inc edx |
int 0x40 |
add ecx,20*65536 |
inc edx |
int 0x40 |
mov ebx,346*65536+45 |
mov edx,info+1 |
mov esi,15 |
newinfo: |
mov ecx,[tcolor] |
cmp [edx-1],byte 'w' |
jne nowhite |
mov ecx,[btcolor] |
nowhite: |
mov eax,4 |
int 0x40 |
add ebx,10 |
add edx,16 |
cmp [edx-1],byte 'x' |
jne newinfo |
mov ebx,20*65536+300 ; draw info text with function 4 |
mov ecx,[btcolor] |
mov edx,text |
mov esi,70 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,10 |
add edx,esi |
cmp [edx],byte 'x' |
jne newline |
call print_strings |
call draw_image |
call draw_picture_info |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
; DATA AREA |
tcolor dd 0x000000 |
btcolor dd 0x224466+0x808080 |
text: |
db ' FILE: ' |
db 'x' |
info: |
db ' IMAGE INFO ' |
db ' ' |
db ' X: ' |
db ' Y: ' |
db ' ' |
db ' BPP: ' |
db ' ' |
db ' ' |
db ' 16M COLOURS ' |
db ' 640x480 max ' |
times 10 db ' ' |
db 'w TILED ' |
db ' ' |
db 'w STRETCH ' |
db ' ' |
db 'w SET AS BGR ' |
db ' ' |
db 'w LOAD ' |
db 'x' |
labelt: db 'BMP VIEWER' |
labellen: |
I_END: |
I_Param: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/bmpview/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm bmpview.asm bmpview |
@pause |
/programs/media/bmpview/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm bmpview.asm bmpview |
@pause |
/programs/media/bmpview/trunk/macros.inc |
---|
0,0 → 1,267 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/cdplay/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm cdplay.asm cdplay |
@pause |
/programs/media/cdplay/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm cdplay.asm cdplay |
@pause |
/programs/media/cdplay/trunk/cdplay.asm |
---|
0,0 → 1,482 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; |
; CD PLAYER - Compile with fasm |
; |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x1000 ; reguired amount of memory |
dd 0x1000 |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
START: |
call draw_window |
still: |
mov eax,10 |
int 0x40 |
cmp eax,1 |
jz red |
cmp eax,2 |
jz key |
cmp eax,3 |
jz button |
jmp still |
red: |
call draw_window |
jmp still |
key: |
mov eax,2 |
int 0x40 |
jmp still |
button: |
mov eax,17 |
int 0x40 |
cmp ah,byte 41 |
jnz nostop |
call stop |
jmp still |
nostop: |
cmp ah,byte 42 |
jnz nogetinfo |
call getinfo |
jmp still |
nogetinfo: |
pusha |
cmp ah,100 |
jnz err |
jmp noerr |
err: |
xor ecx,ecx |
mov cl,ah |
shl ecx,3 |
add ecx,cdinfo |
add ecx,1 |
xor ebx,ebx |
mov ebx,[ecx] |
and ebx,0x00ffffff |
mov ecx,ebx |
mov ebx,1 |
mov eax,24 |
int 0x40 |
cmp eax,0 |
je noerr |
error: |
mov eax,13 |
mov ebx,10*65536+215 |
mov ecx,115*65536+13 |
mov edx,0x0088aacc |
int 0x40 |
mov eax,dword 0x00000004 ; write text |
mov ebx,12*65536+117 |
mov ecx,[tcolor] |
mov edx,infotext2 |
mov esi,itl2-infotext2 |
int 0x40 |
mov eax,5 |
mov ebx,200 |
int 0x40 |
noerr: |
popa |
shr eax,8 |
and eax,255 |
mov ebx,0 |
mov ecx,10 |
cmp eax,100 |
jnz noend |
mov eax,-1 |
int 0x40 |
noend: |
newc: |
cmp eax,ecx |
jb dri |
inc ebx |
sub eax,ecx |
jmp newc |
dri: |
mov ecx,48 |
add ebx,ecx |
mov [infotext+0],bl |
add eax,ecx |
mov [infotext+1],al |
call drawinfo |
jmp still |
getinfo: |
mov eax,24 ; get info |
mov ebx,1 |
mov ecx,0x010100 |
int 0x40 |
cmp eax,0 |
jnz gierror |
mov eax,13 |
mov ebx,10*65536+215 |
mov ecx,115*65536+13 |
mov edx,0x0088aacc |
int 0x40 |
mov eax,dword 0x00000004 ; write text |
mov ebx,12*65536+117 |
mov ecx,dword 0x00ffffff ; 8b window nro - RR GG BB color |
mov edx,infotext3 ; pointer to text beginning |
mov esi,itl3-infotext3 ; text length |
int 0x40 |
mov eax,5 |
mov ebx,100*10 |
int 0x40 |
mov eax,24 ; get info |
mov ebx,2 |
mov ecx,cdinfo |
mov edx,256 |
int 0x40 |
cmp eax,0 |
jz gi1 |
gierror: |
mov eax,13 |
mov ebx,10*65536+215 |
mov ecx,115*65536+13 |
mov edx,0x0088aacc |
int 0x40 |
mov eax,dword 0x00000004 ; write text |
mov ebx,12*65536+117 |
mov ecx,dword 0x00ffffff ; 8b window nro - RR GG BB color |
mov edx,infotext2 ; pointer to text beginning |
mov esi,itl2-infotext2 ; text length |
int 0x40 |
mov eax,5 |
mov ebx,200 |
int 0x40 |
gi1: |
call drawinfo |
ret |
stop: |
mov eax,24 ; get info |
mov ebx,3 |
int 0x40 |
ret |
; info bar |
drawinfo: |
; end |
xor eax,eax |
xor ebx,ebx |
mov ecx,10 |
mov al,[cdinfo+3] |
cld |
newco: |
cmp eax,ecx |
jb noco |
add ebx,1 |
sub eax,ecx |
jmp newco |
noco: |
add al,48 |
mov [infotext+32],al |
add bl,48 |
mov [infotext+31],bl |
; start |
xor eax,eax |
xor ebx,ebx |
mov al,[cdinfo+2] |
cld |
newco2: |
cmp eax,ecx |
jb noco2 |
add ebx,1 |
sub eax,ecx |
jmp newco2 |
noco2: |
add al,48 |
mov [infotext+17],al |
add bl,48 |
mov [infotext+16],bl |
mov eax,13 |
mov ebx,10*65536+219 |
mov ecx,115*65536+13 |
mov edx,[col] |
sub edx,0x101010 |
int 0x40 |
mov eax,4 ; write text |
mov ebx,12*65536+117 |
mov ecx,dword 0x00ffffff ; 8b window nro - RR GG BB color |
mov edx,infotext ; pointer to text beginning |
mov esi,itl-infotext ; text length |
int 0x40 |
ret |
draw_window: |
pusha |
mov eax,12 ; tell os about redraw |
mov ebx,1 |
int 0x40 |
mov eax,0 ; define and draw window |
mov ebx,170*65536+240 |
mov ecx,40*65536+135 |
mov edx,0x00b6aaff |
mov esi,0x80b9aaff; bbee - 0x202020 |
mov edi,0x00b9aaff ;bbee |
mov edx,[col] |
add edx,0x00000000 |
mov esi,[col] |
add esi,0x80000000 |
mov edi,[col] |
int 0x40 |
mov eax,4 ; write text |
mov ebx,8*65536+8 |
mov ecx,[tcolor] |
mov edx,labelt |
mov esi,labellen-labelt |
int 0x40 |
mov eax,8 ; CLOSE BUTTON |
mov ebx,(240-18)*65536+10 |
mov ecx,6 *65536+10 |
mov edx,100 |
mov esi,[col] |
sub esi,0x302010 |
int 0x40 |
; first row |
mov eax,8 ; button |
mov edx,1 ; button number |
mov ebx,9*65536+21 ; button start x & size |
mov ecx,30*65536+13 ; button start y & size |
mov esi,[bcolor] ; button color |
newbutton1: |
pusha |
int 0x40 |
popa |
pusha |
mov eax,dword 0x00000004 |
and ebx,65535*65536 |
shr ecx,16 |
add ebx,ecx |
add ebx,6*65536+3 |
mov ecx,[tcolor] |
shl edx,1 |
add edx,nro-2 |
mov esi,2 |
int 0x40 |
popa |
add ebx,22*65536 |
inc edx |
cmp edx,11 |
jnz newbutton1 |
; second row |
mov eax,8 ; button |
mov edx,11 ; button number |
mov ebx,9*65536+21 ; button start x & size |
mov ecx,50*65536+13 ; button start y & size |
mov esi,[bcolor] ; button color |
newbutton2: |
pusha |
int 0x40 |
popa |
pusha |
mov eax,dword 0x00000004 |
and ebx,65535*65536 |
shr ecx,16 |
add ebx,ecx |
add ebx,6*65536+3 |
mov ecx,[tcolor] |
shl edx,1 |
add edx,nro2-2-20 |
mov esi,2 |
int 0x40 |
popa |
add ebx,22*65536 |
inc edx |
cmp edx,21 |
jnz newbutton2 |
; third row |
mov eax,8 ; button |
mov edx,21 ; button number |
mov ebx,9*65536+21 ; button start x & size |
mov ecx,70*65536+13 ; button start y & size |
mov esi,[bcolor] ; button color |
newbutton3: |
pusha |
int 0x40 |
popa |
pusha |
mov eax,dword 0x00000004 |
and ebx,65535*65536 |
shr ecx,16 |
add ebx,ecx |
add ebx,6*65536+3 |
mov ecx,[tcolor] |
shl edx,1 |
add edx,nro3-2-40 |
mov esi,2 |
int 0x40 |
popa |
add ebx,22*65536 |
inc edx |
cmp edx,31 |
jnz newbutton3 |
; fourth row |
mov eax,8 ; button |
mov edx,41 ; button number |
mov ebx,9*65536+109 ; button start x & size |
mov ecx,90*65536+13 ; button start y & size |
mov esi,0x00aabbcc ; button color |
newbutton4: |
pusha |
int 0x40 |
popa |
pusha |
mov eax,4 |
and ebx,65535*65536 |
shr ecx,16 |
add ebx,ecx |
add ebx,9*65536+3 |
mov ecx,[tcolor] |
sub edx,41 |
shl edx,4 |
add edx,text |
mov esi,16 |
int 0x40 |
popa |
add ebx,110*65536 |
inc edx |
cmp edx,43 |
jnz newbutton4 |
call drawinfo |
mov eax,12 ; tell os about redraw end |
mov ebx,2 |
int 0x40 |
popa |
ret |
; DATA AREA |
col dd 0x7777aa |
tcolor dd 0xffffff |
bcolor dd 0xaabbcc |
labelt: db 'CD PLAYER' |
labellen: |
infotext: db '01 First Track: xx Last Track: xx ' |
itl: |
infotext2: db 'DEFINE CD ROM BASE WITH SETUP ' |
itl2: |
infotext3: db 'READING PLAYLIST - (10 secs) ' |
itl3: |
nro: db '01020304050607080910' |
nro2: db '11121314151617181920' |
nro3: db '21222324252627282930' |
text: db ' STOP READ PLAYLIST ' |
cdinfo: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/cdplay/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/scrshot/trunk/ascl.inc |
---|
0,0 → 1,933 |
lang equ ru ; ru en fr ge fi |
; |
; Assembler |
; SMALL |
; CODE |
; Libary |
; |
; Ver 0.14 By Pavlushin Evgeni (RUSSIA) |
; www.waptap@mail.ru |
;Please compile aplications on FASM ver1.54 or higer!!! |
;InfoList |
;0.01 scank,putpix,puttxt |
;0.02 label,random,colors |
;0.03 window,startwd,endwd,attributes |
;0.04 close,delay,scevent ~30.04.2004 |
;0.05 small random, ~04.05.2004 |
;0.06 wtevent ~09.05.2004 |
;0.07 timeevent ~23.05.2004 |
;0.08 txtput ~14.06.2004 |
;0.09 opendialog,savedialog ~20.06.2004 |
;0.10 wordstoreg by halyavin, add at ~30.08.2004 |
; random bug deleted eax is use. |
;0.11 loadfile from me +puttxt bug del ~07.09.2004 |
;0.12 open/save dialog ~13.09.2004 |
;0.13 dialogs bugs deleted |
;0.14 drawlbut ~03.10.2004 |
;0.15 extendet label! |
; LOADFILE |
; (SYNTAX) LOADFILE 'full_path_to_file',file_load_area,file_temp_area |
; (SAMPLE) LOADFILE '/rd/1/clock.bmp',load_area,temp_area |
macro loadfile file_name,file_load_area,file_temp_area |
{ |
local open,fileinfo,string |
jmp open |
fileinfo: |
dd 0 |
dd 0 |
dd 1 |
dd file_load_area |
dd file_temp_area |
string: |
db file_name,0 |
open: |
mov dword [fileinfo+8],1 ; how many blocks to read (1) |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
mov eax,[file_load_area+2] |
shr eax,9 ; ¯®¤¥«¨¬ 512 ¨ ¯à¨¡ ¢¨¬ 1 - ¯®«ã稬 ç¨á«® ¡«®ª®¢ |
inc eax |
mov dword [fileinfo+8],eax |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
} |
;*********************************************************** |
macro savefile file_name,file_save_area,file_temp_area,fsize |
{ |
local save,fileinfo,string ;,counter00 |
jmp save |
;counter00 dd 0 |
fileinfo: |
dd 1 |
dd 0 |
dd fsize ;counter00 |
dd file_save_area |
dd file_temp_area |
string: |
db file_name,0 |
save: |
;xor edi,edi |
; sub edi,file_save_area ; calculate dump size |
; mov edx,edi |
;mov [counter00],edi |
; mov dword [fileinfo+8],1 ; how many blocks to write (1) |
; mov eax,58 |
; mov ebx,fileinfo |
; int 0x40 |
; mov eax,[file_load_area+2] |
; shr eax,9 ; ¯®¤¥«¨¬ 512 ¨ ¯à¨¡ ¢¨¬ 1 - ¯®«ã稬 ç¨á«® ¡«®ª®¢ |
; inc eax |
; mov dword [fileinfo+8],eax |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
} |
;*********************************************************** |
;macro wordstoreg reg,hiword,loword |
;{ |
;if hiword eqtype 0 & loword eqtype 0 |
; mov reg,dword hiword*65536+loword |
;else if hiword eqtype 12 & loword eqtype eax |
; mov reg,dword hiword*65536 |
; add reg,dword loword |
;else if hiword eqtype 12 & loword eqtype [123] |
; mov reg,dword hiword*65536 |
; add reg,dword loword |
;else |
; mov reg,dword hiword |
; shl reg,16 |
; add reg,dword loword |
;end if |
;} |
macro dword2reg reg,doubleword |
{ |
if doubleword eq |
; not changes |
else |
mov reg,dword doubleword |
end if |
} |
macro words2reg reg,hiword,lowword |
{ |
if hiword eq |
if lowword eq |
; not changes |
else |
if lowword eqtype 12 |
and reg,dword 0xffff0000 |
add reg,dword lowword |
else |
and reg,dword 0xffff0000 |
add reg,dword lowword |
end if |
end if |
else |
if lowword eq |
if hiword eqtype 12 |
and reg,dword 0x0000ffff |
add reg,dword hiword*65536 |
else |
shl reg,16 |
add reg,dword hiword |
ror reg,16 |
end if |
else |
if lowword eqtype 12 & hiword eqtype 12 |
if lowword eq 0 & hiword eq 0 |
xor reg,reg |
else |
mov reg,dword hiword*65536+lowword |
end if |
else |
mov reg,dword hiword |
shl reg,16 |
add reg,dword lowword |
end if |
end if |
end if |
} |
; DRAW BUTTON with label |
macro drawlbut x,y,xs,ys,text,id,bcolor,tcolor |
{ |
local asd,lab |
jmp asd |
lab db text ;arg label |
asd: |
words2reg ebx,x,xs |
words2reg ecx,y,ys |
mov edx,id |
mov esi,bcolor |
mov eax,8 |
int 0x40 |
mov eax,asd-lab ;calc size |
mov ebx,6 |
mul ebx |
mov esi,eax |
mov eax,xs |
sub eax,esi |
shr eax,1 |
add eax,x |
mov edx,ys |
sub edx,7 |
shr edx,1 |
add edx,y |
mov ebx,eax |
shl ebx,16 |
add ebx,edx |
mov ecx,tcolor ;arg4 color |
mov edx,lab |
mov esi,asd-lab ;calc size |
mov eax,4 |
int 0x40 |
} |
macro opendialog redproc,openoff,erroff,path |
{ |
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc |
local run_fileinfo, param |
local getmesloop, loox, mred, mkey, mbutton, mgetmes |
local dlg_is_work, ready, procinfo |
; |
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec, |
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save) |
; |
cld |
;; mov esi,path |
mov edi,path |
mov eax,0 |
mov ecx,200 |
rep stosb |
;mov [get_loops],0 |
mov [dlg_pid_get],0 |
; Get my PID in dec format 4 bytes |
mov eax,9 |
mov ebx,procinfo |
mov ecx,-1 |
int 0x40 |
; convert eax bin to param dec |
mov eax,dword [procinfo+30] ;offset of myPID |
mov edi,param+4-1 ;offset to 4 bytes |
mov ecx,4 |
mov ebx,10 |
cld |
new_d: |
xor edx,edx |
div ebx |
add dl,'0' |
mov [edi],dl |
dec edi |
loop new_d |
; wirite 1 byte space to param |
mov [param+4],byte 32 ;Space for next parametr |
; and 1 byte type of dialog to param |
mov [param+5],byte 'O' ;Get Open dialog (Use 'S' for Save dialog) |
; |
; STEP2 prepare IPC area for get messages |
; |
; prepare IPC area |
mov [path],dword 0 |
mov [path+4],dword 8 |
; define IPC memory |
mov eax,60 |
mov ebx,1 ; define IPC |
mov ecx,path ; offset of area |
mov edx,150 ; size 150 bytes |
int 0x40 |
; change wanted events list 7-bit IPC event |
mov eax,40 |
mov ebx,01000111b |
int 0x40 |
; |
; STEP 3 run SYSTEM XTREE with parameters |
; |
mov eax,58 |
mov ebx,run_fileinfo |
int 0x40 |
call redproc |
mov [get_loops],0 |
getmesloop: |
mov eax,23 |
mov ebx,50 ;0.5 sec |
int 0x40 |
cmp eax,1 |
je mred |
cmp eax,2 |
je mkey |
cmp eax,3 |
je mbutton |
cmp eax,7 |
je mgetmes |
; Get number of procces |
mov ebx,procinfo |
mov ecx,-1 |
mov eax,9 |
int 0x40 |
mov ebp,eax |
loox: |
mov eax,9 |
mov ebx,procinfo |
mov ecx,ebp |
int 0x40 |
mov eax,[DLGPID] |
cmp [procinfo+30],eax ;IF Dialog find |
je dlg_is_work ;jmp to dlg_is_work |
dec ebp |
jnz loox |
jmp erroff |
dlg_is_work: |
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated |
je erroff ;TESTODP2 terminated too |
cmp [dlg_pid_get],dword 1 |
je getmesloop |
inc [get_loops] |
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated |
jae erroff |
jmp getmesloop |
mred: |
call redproc |
jmp getmesloop |
mkey: |
mov eax,2 |
int 0x40 ; read (eax=2) |
jmp getmesloop |
mbutton: |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne getmesloop |
mov eax,-1 ; close this program |
int 0x40 |
mgetmes: |
; If dlg_pid_get then second message get jmp to still |
cmp [dlg_pid_get],dword 1 |
je ready |
; First message is number of PID SYSXTREE dialog |
; convert PID dec to PID bin |
movzx eax,byte [path+16] |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+1] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+2] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+3] |
add eax,ebx |
sub eax,48 |
mov [DLGPID],eax |
; Claear and prepare IPC area for next message |
mov [path],dword 0 |
mov [path+4],dword 8 |
mov [path+8],dword 0 |
mov [path+12],dword 0 |
mov [path+16],dword 0 |
; Set dlg_pid_get for get next message |
mov [dlg_pid_get],dword 1 |
call redproc ;show DLG_PID |
jmp getmesloop |
ready: |
; |
; The second message get |
; Second message is 100 bytes path to SAVE/OPEN file |
; shl path string on 16 bytes |
; |
cld |
mov esi,path+16 |
mov edi,path |
mov ecx,200 |
rep movsb |
mov [edi],byte 0 |
jmp openoff |
; DATA AREA |
get_loops dd 0 |
dlg_pid_get dd 0 |
DLGPID dd 0 |
param: |
dd 0 ; My dec PID |
dd 0,0 ; Type of dialog |
run_fileinfo: |
dd 16 |
dd 0 |
dd param |
dd 0 |
dd procinfo ; 0x10000 |
;run_filepath |
db '/RD/1/SYSXTREE',0 |
procinfo: |
times 1024 db 0 |
} |
macro savedialog redproc,openoff,erroff,path |
{ |
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc |
local run_fileinfo, run_filepath, param |
local getmesloop, loox, mred, mkey, mbutton, mgetmes |
local dlg_is_work, ready, procinfo |
; |
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec, |
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save) |
; |
cld |
;; mov esi,path |
mov edi,path |
mov eax,0 |
mov ecx,200 |
rep stosb |
;mov [get_loops],0 |
mov [dlg_pid_get],0 |
; Get my PID in dec format 4 bytes |
mov eax,9 |
mov ebx,procinfo |
mov ecx,-1 |
int 0x40 |
; convert eax bin to param dec |
mov eax,dword [procinfo+30] ;offset of myPID |
mov edi,param+4-1 ;offset to 4 bytes |
mov ecx,4 |
mov ebx,10 |
cld |
new_d: |
xor edx,edx |
div ebx |
add dl,'0' |
mov [edi],dl |
dec edi |
loop new_d |
; wirite 1 byte space to param |
mov [param+4],byte 32 ;Space for next parametr |
; and 1 byte type of dialog to param |
mov [param+5],byte 'S' ;Get Open dialog (Use 'S' for Save dialog) |
; |
; STEP2 prepare IPC area for get messages |
; |
; prepare IPC area |
mov [path],dword 0 |
mov [path+4],dword 8 |
; define IPC memory |
mov eax,60 |
mov ebx,1 ; define IPC |
mov ecx,path ; offset of area |
mov edx,150 ; size 150 bytes |
int 0x40 |
; change wanted events list 7-bit IPC event |
mov eax,40 |
mov ebx,01000111b |
int 0x40 |
; |
; STEP 3 run SYSTEM XTREE with parameters |
; |
mov eax,58 |
mov ebx,run_fileinfo |
int 0x40 |
call redproc |
mov [get_loops],0 |
getmesloop: |
mov eax,23 |
mov ebx,50 ;0.5 sec |
int 0x40 |
cmp eax,1 |
je mred |
cmp eax,2 |
je mkey |
cmp eax,3 |
je mbutton |
cmp eax,7 |
je mgetmes |
; Get number of procces |
mov ebx,procinfo |
mov ecx,-1 |
mov eax,9 |
int 0x40 |
mov ebp,eax |
loox: |
mov eax,9 |
mov ebx,procinfo |
mov ecx,ebp |
int 0x40 |
mov eax,[DLGPID] |
cmp [procinfo+30],eax ;IF Dialog find |
je dlg_is_work ;jmp to dlg_is_work |
dec ebp |
jnz loox |
jmp erroff |
dlg_is_work: |
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated |
je erroff ;TESTODP2 terminated too |
cmp [dlg_pid_get],dword 1 |
je getmesloop |
inc [get_loops] |
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated |
jae erroff |
jmp getmesloop |
mred: |
call redproc |
jmp getmesloop |
mkey: |
mov eax,2 |
int 0x40 ; read (eax=2) |
jmp getmesloop |
mbutton: |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne getmesloop |
mov eax,-1 ; close this program |
int 0x40 |
mgetmes: |
; If dlg_pid_get then second message get jmp to still |
cmp [dlg_pid_get],dword 1 |
je ready |
; First message is number of PID SYSXTREE dialog |
; convert PID dec to PID bin |
movzx eax,byte [path+16] |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+1] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+2] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+3] |
add eax,ebx |
sub eax,48 |
mov [DLGPID],eax |
; Claear and prepare IPC area for next message |
mov [path],dword 0 |
mov [path+4],dword 8 |
mov [path+8],dword 0 |
mov [path+12],dword 0 |
mov [path+16],dword 0 |
; Set dlg_pid_get for get next message |
mov [dlg_pid_get],dword 1 |
call redproc ;show DLG_PID |
jmp getmesloop |
ready: |
; |
; The second message get |
; Second message is 100 bytes path to SAVE/OPEN file |
; shl path string on 16 bytes |
; |
cld |
mov esi,path+16 |
mov edi,path |
mov ecx,200 |
rep movsb |
mov [edi],byte 0 |
jmp openoff |
; DATA AREA |
get_loops dd 0 |
dlg_pid_get dd 0 |
DLGPID dd 0 |
param: |
dd 0 ; My dec PID |
dd 0,0 ; Type of dialog |
run_fileinfo: |
dd 16 |
dd 0 |
dd param |
dd 0 |
dd procinfo |
;run_filepath: |
db '/RD/1/SYSXTREE',0 |
procinfo: |
times 1024 db 0 |
} |
; RANDOM - generate random count (small) |
; (SYNTAX) RANDOM MaxCount,OutArgument |
; (SAMPLE) RANDOM 10000,eax |
; ( NOTE ) Maxint<65536 ; use random 65536,eax for more combinations |
randomuse = 0 |
macro random arg1,arg2 |
{ |
local rxproc |
randomuse = randomuse + 1 |
jmp rxproc |
if defined randomuse & randomuse = 1 |
randomproc: |
jmp rnj |
rsx1 dw 0x4321 |
rsx2 dw 0x1234 |
rnj: |
; mov eax,arg1 |
push bx |
push cx |
push dx |
push si |
push di |
mov cx,ax |
mov ax,word ptr rsx1 |
mov bx,word ptr rsx2 |
mov si,ax |
mov di,bx |
mov dl,ah |
mov ah,al |
mov al,bh |
mov bh,bl |
xor bl,bl |
rcr dl,1 |
rcr ax,1 |
rcr bx,1 |
add bx,di |
adc ax,si |
add bx,0x62e9 |
adc ax,0x3619 |
mov word ptr rsx1,bx |
mov word ptr rsx2,ax |
xor dx,dx |
cmp ax,0 |
je nodiv |
cmp cx,0 |
je nodiv |
div cx |
nodiv: |
mov ax,dx |
pop di |
pop si |
pop dx |
pop cx |
pop bx |
and eax,0000ffffh |
; mov arg2,0 |
; mov arg2,eax |
ret |
end if |
rxproc: |
mov eax,arg1 |
call randomproc |
mov arg2,eax |
} |
macro scank |
{ |
mov eax,10 |
int 0x40 |
} |
macro putpix x,y,color |
{ |
mov ebx,x |
mov ecx,y |
mov edx,color |
mov eax,1 |
int 0x40 |
} |
macro puttxt x,y,offs,size,color |
{ |
; mov ebx,x |
; shl ebx,16 |
; add ebx,y |
words2reg ebx,x,y |
dword2reg ecx,color |
dword2reg edx,offs |
dword2reg esi,size |
; mov ecx,color |
; mov edx,offs |
; mov esi,size |
mov eax,4 |
int 0x40 |
} |
macro outcount data, x, y, color, numtype |
{ |
mov ecx,data |
mov ebx,numtype |
mov bl,0 |
; mov edx,x*65536+y |
words2reg edx,x,y |
mov esi,color |
mov eax,47 |
int 0x40 |
} |
; SCEVENT - Scan event |
macro scevent red,key,but |
{ |
mov eax,11 |
int 0x40 |
dec eax |
jz red |
dec eax |
jz key |
dec eax |
jz but |
} |
; WTEVENT - Wait event |
macro wtevent red,key,but |
{ |
mov eax,10 |
int 0x40 |
dec eax |
jz red |
dec eax |
jz key |
dec eax |
jz but |
} |
; TIMEEVENT - Wite for event with timeout |
macro timeevent xfps,noevent,red,key,but |
{ |
mov eax,23 |
mov ebx,xfps |
int 0x40 |
cmp eax,0 |
je noevent |
dec eax |
jz red |
dec eax |
jz key |
dec eax |
jz but |
} |
; CLOSE - Close program |
macro close |
{ |
mov eax,-1 |
int 0x40 |
} |
; DELAY - Create delay 1/100 sec |
; (SYNTAX) Delay time |
; (SAMPLE) Delay 100 ;delay 2 sec 1/100*200=2 sec |
macro delay arg1 |
{ |
mov eax,5 |
mov ebx,arg1 |
int 0x40 |
} |
; WINDOW - Draw window |
; (SYNTAX) WINDOW Xstart,Ystart,'Text',Color |
; (SAMPLE) WINDOW 10,10,640+8,480+24,window_Skinned |
macro window arg1,arg2,arg3,arg4,arg5 |
{ |
; mov ebx,arg1*65536+arg3 |
; mov ecx,arg2*65536+arg4 |
words2reg ebx,arg1,arg3 |
words2reg ecx,arg2,arg4 |
mov edx,arg5 |
mov eax,0 |
int 0x40 |
} |
macro colorwindow arg1,arg2,arg3,arg4,arg5,arg6,arg7 |
{ |
; mov ebx,arg1*65536+arg3 |
; mov ecx,arg2*65536+arg4 |
words2reg ebx,arg1,arg3 |
words2reg ecx,arg2,arg4 |
mov edx,arg5 |
mov esi,arg6 |
mov edi,arg7 |
mov eax,0 |
int 0x40 |
} |
; STARTWD - Start of window draw |
macro startwd |
{ |
mov eax,12 |
mov ebx,1 |
int 0x40 |
} |
; ENDWD - End window draw |
macro endwd |
{ |
mov eax,12 |
mov ebx,2 |
int 0x40 |
} |
; LABEL - Put text to frame |
; (SYNTAX) LABEL Xstart,Ystart,'Text',Color |
; (SAMPLE) LABEL 10,12,'Hello World!',cl_Green+font_Big |
macro putlabel arg1,arg2,arg3,arg4 |
{ |
local asd,lab |
jmp asd |
lab db arg3 ;arg label |
asd: |
; mov ebx,arg1 ;arg1=y arg2=x |
; shl ebx,16 |
; add ebx,arg2 |
words2reg ebx,arg1,arg2 |
dword2reg ecx,arg4 |
mov edx,lab |
mov esi,asd-lab ;calc size |
mov eax,4 |
int 0x40 |
} |
;Key's |
key_Up equ 178 |
key_Down equ 177 |
key_Right equ 179 |
key_Left equ 176 |
key_Esc equ 27 |
key_Space equ 32 |
key_Enter equ 13 |
key_Bspace equ 8 |
key_F1 equ 50 |
key_F2 equ 51 |
key_F3 equ 52 |
key_F4 equ 53 |
key_F5 equ 54 |
key_F6 equ 55 |
key_F7 equ 56 |
key_F8 equ 57 |
key_F9 equ 48 |
key_F10 equ 49 |
key_F11 equ 68 |
key_F12 equ 255 |
key_Home equ 180 |
key_End equ 181 |
key_PgUp equ 184 |
key_PgDown equ 183 |
;Attributes |
;Window Attributes |
window_Skinned equ 0x03000000 |
window_Type2 equ 0x02000000 |
window_Type1 equ 0x00000000 |
window_Reserve equ 0x01000000 |
;Font Attributes |
font_Big equ 0x10000000 |
;Colors |
cl_White equ 0x00ffffff |
cl_Black equ 0x00000000 |
cl_Grey equ 0x00888888 |
cl_Red equ 0x00ff0000 |
cl_Lime equ 0x0000ff00 |
cl_Green equ 0x0000af00 |
cl_Blue equ 0x000000ff |
cl_Purple equ 0x008080ff |
cl_Violet equ 0x008040ff |
cl_Cyan equ 0x0040e0ff |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/scrshot/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm scrshot.asm scrshot |
@pause |
/programs/media/scrshot/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm scrshot.asm scrshot |
@pause |
/programs/media/scrshot/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/scrshot/trunk/readme.txt |
---|
0,0 → 1,26 |
ScrShoot v.0.1b - Ôîòîãðàô ýêðàíà (ScreenShooter) |
Àëãîðèòì çàïèñè áìï-ôàéëà âçÿò èç VSCREEN2, îäíàêî, |
ýòà ïðîãðàììà íèêàê íå ïðèòåíäóåò íà îòíîøåíèå ê íåé, êàê ê ñåðü¸çíîé ïðîãðàììå. |
Êîãäà-òî äàâíî ÿ óæå ïûòàëñÿ ïåðåäåëàòü vscreen, ÷òîáû ìîæíî áûëî èçìåíÿòü èìÿ |
ñîõðàíÿåìîãî ôàéëà, îäíàêî îí íå ïîëó÷èë ðàñïðîñòðîíåíèÿ (èççà êðèâîñòè êîäà íàâåðíîå :)). |
ScrShoot - ìàëåíüêàÿ ïðîãðàììêà (êîòîðàÿ çàíèìàåò äîñòàòî÷íî ÌÍÎÃÎ îïåðàòèâû), êîòîðàÿ |
ïðè íàæàòèè íà êëàâèøó PrintScreen ñîõðàíÿåò ñíèìîê ýêðàíà, àâòîìàòè÷åñêè èçìåíÿåò èìÿ ôàéëà, |
÷òî ïîçâîëÿåò äåëàòü äî 99 ñíèìêîâ. Ïðîãðàììà íå èìååò GUI, ïîýòîìó äàþ "êðàòêîå îïèñàíèå" |
- [Print Screen] - ñîõðàíèòü ñíèìîê ýêðàíà íà '/hd/1/SCREEN##.BMP', ãäå ## - íîìåð ñíèìêà. |
- ëåâûé [Alt] + [Print Screen] - ñîõðàíèòü ñíèìîê ýêðàíà íà '/rd/1/SCREEN##.BMP', |
ãäå ## - íîìåð ñíèìêà. |
- [Scroll Lock] - âûõîä èç ïðîãðàììû. |
Èçâåñòíî ÷òî: |
- âî âðåìÿ íàæàòèÿ êëàâèø ScrShoot äîëæåí áûòü àêòèâíûì (êòî íå ïîíÿë - ù¸ëêàåò íà êíîïå |
[SCRSHOOT] íà ïàíåëè.) |
- îäíî èçîáðàæåíèå çàïèñûâàåòñÿ íà ÆÄ äî 3õ ñåêóíä äëÿ 800õ600 è äî 5 ñåê. |
äëÿ 1024õ768, òî åñòü åñëè âåì íàäî ñäåëàòü êó÷ó ñêðèíîâ |
íàæèìàéòå íà ïðèíò ñêðèí íå ÷àùå 1 ðàçà â 3-5 ñåêóíä. |
- ðàçðåøåíèå ýêðàíà íå äîëæíî ïðåâûøàòü 1024õ768, òàê êàê òîãäà çàïèñü áìïøíèêà çàéì¸ò |
öåëóþ âå÷íîñòü, è ïàìÿòè áóäåò æðàòü ìíîãîâàòî. (íó ÿ êîíå÷íî êðàñêè ñãóñòèë, íî ýòî |
âñ¸ æå òàê) |
Ñèëüíûõ ãëþêîâ ÿ íå çàìåòèë, íî åñëè ÷òî - archangel{at}mail.kz |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/scrshot/trunk/scrshot.asm |
---|
0,0 → 1,232 |
;===[includes]===; |
include 'lang.inc' |
include 'ascl.inc' |
include 'macros.inc' |
;===[header and etc.]===; |
meos_app_start |
;===[code:]===; |
code |
;--------------------------------------- |
;====== we want keyborad events ======== |
mov eax,40 |
mov ebx,00000000000000000000000000000010b |
int 0x40 |
;====== wanna use keyboard scan codes == |
mov eax,66 |
mov ebx,1 |
mov ecx,1 |
int 0x40 |
;=======GET SCREEN SIZE================= |
mov eax,14 ; get screen size |
int 0x40 |
push eax |
and eax,0x0000ffff |
inc eax |
mov [size_y],eax |
pop eax |
shr eax,16 |
inc eax |
mov [size_x],eax |
mov eax,[size_x] |
shr eax,2 |
mov [cmp_ecx],eax |
mov eax,[size_x] |
xor edx,edx |
mov ebx,3 |
mul ebx |
mov [add_esi],eax |
mov eax,[size_y] |
shr eax,2 |
mov [cmp_edx],eax |
mov eax,[size_y] |
imul eax,[size_x] |
imul eax,3 |
mov [i_size],eax |
;======================================= |
still: |
mov eax,10 |
int 0x40 |
cmp eax,2 |
je key |
jmp still |
key: |
mov eax,2 |
int 0x40 |
cmp ah,55 ;===print screen to hdd |
je print_screen_hdd |
cmp ah,84 ;===alt+prnt.screen = print screen to fdd |
je print_screen_fdd |
cmp ah,70 ;===lets make exit - scroll lock |
je close_now |
jmp still |
close_now: |
close |
;================================== |
;===save file to hdd=============== |
print_screen_hdd: |
mov [savetofdd],0 |
call change_fname |
call save_screen |
jmp still |
;===save file to fdd=============== |
print_screen_fdd: |
mov [savetofdd],1 |
call change_fname |
call save_screen |
jmp still |
;===change our file name ========== |
change_fname: |
cmp [bmp_name+7],'9' |
jne addfname |
cmp [bmp_name+6],'9' |
je leavenow ;if name is > than 'screen99.bmp' then we do not change name |
mov [bmp_name+7],'0' |
add [bmp_name+6],0x1 |
jmp leavenow |
addfname: |
add [bmp_name+7],0x1 |
leavenow: |
ret |
;================================== |
;============SAVE SCREEN=========== |
read_pixel: |
pushad |
mov esi,eax |
mov eax,[size_x] |
mul ebx |
add eax,esi |
xchg eax,ebx |
mov eax,35 |
int 0x40 |
mov [esp+28],eax |
popad |
ret |
save_screen: |
pusha |
; 1) READ SCREEN |
mov edi,bmp_file_area+0x36 ;0x10036 |
mov eax,[size_y] |
dec eax |
mov [temp_y],eax |
ynew: |
xor eax,eax |
mov [temp_x],eax |
xnew: |
mov eax,[temp_x] |
mov ebx,[temp_y] |
call read_pixel |
mov [edi],eax |
add edi,3 |
inc [temp_x] |
mov eax,[size_x] |
cmp [temp_x],eax |
jb xnew |
dec [temp_y] |
cmp [temp_y],0 |
jge ynew |
; 2) BMP HEADER |
mov [bmp_file_area],word 'BM' ; bmp signature |
mov eax,[i_size] |
mov [bmp_file_area+34],eax ; image size |
mov ebx,0x36 |
mov [bmp_file_area+10],ebx ; headers size |
add eax,ebx |
mov [bmp_file_area+2],eax ; file size |
mov [bmp_file_area+14],dword 0x28 |
mov eax,[size_x] |
mov [bmp_file_area+18],eax ; x size |
mov eax,[size_y] |
mov [bmp_file_area+22],eax ; y size |
mov [bmp_file_area+26],word 1 |
mov [bmp_file_area+28],word 0x18 ; bpp = 24 = 0x18 |
; 3) SAVE FILE |
cmp [savetofdd],1 |
je save_to_fdd |
mov eax,56 |
mov ebx,bmp_name |
mov edx,bmp_file_area |
mov ecx,[i_size] |
add ecx,0x36 |
mov esi,path |
int 0x40 |
popa |
ret |
save_to_fdd: |
mov eax,33; |
mov ebx,bmp_name |
mov ecx,bmp_file_area |
mov edx,[i_size] |
add edx,0x36 |
mov esi,0 |
int 0x40 |
popa |
ret |
;======================================= |
;--------------------------------------- |
;===[DATA]===; |
data |
;--------------------------------------- |
bmp_name db 'SCREEN00BMP' |
path db 0 |
i_size dd 0x1 |
m_x dd 100 |
m_y dd 100 |
cmp_ecx dd 0 |
add_esi dd 0 |
cmp_edx dd 0 |
savetofdd db 0 |
;===[uninitialised data]===; |
udata |
;--------------------------------------- |
temp_x dd ? |
temp_y dd ? |
size_x dd ? |
size_y dd ? |
bmp_file_area: |
rb 0x250000 |
;the happy end |
meos_app_end |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/vscreen/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm vscreen.asm vscreen |
@pause |
/programs/media/vscreen/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm vscreen.asm vscreen |
@pause |
/programs/media/vscreen/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a { ; mike.dld |
if ~a eq |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; language for programs |
lang fix ru ; ru en fr ge fi |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/vscreen/trunk/vscreen.asm |
---|
0,0 → 1,417 |
; |
; VIRTUAL SCREEN 2 |
; based on the original VSCREEN |
; |
; Compile with FASM for Menuet |
;' |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x600000 ; required amount of memory |
dd 0xfff0 |
dd 0,0 |
scr equ 0x20000 |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
mov eax,14 ; get screen size |
int 0x40 |
push eax |
and eax,0x0000ffff |
inc eax |
mov [size_y],eax |
pop eax |
shr eax,16 |
inc eax |
mov [size_x],eax |
mov eax,[size_x] |
shr eax,2 |
mov [cmp_ecx],eax |
mov eax,[size_x] |
xor edx,edx |
mov ebx,3 |
mul ebx |
mov [add_esi],eax |
mov eax,[size_y] |
shr eax,2 |
mov [cmp_edx],eax |
mov eax,[size_y] |
imul eax,[size_x] |
imul eax,3 |
mov [i_size],eax |
red: |
call draw_window ; at first, draw the window |
still: |
call draw_screen |
mov eax,23 ; wait here for event with timeout |
mov ebx,[delay] |
int 0x40 |
dec eax ; redraw request ? |
jz red |
dec eax ; key in buffer ? |
jz key |
dec eax ; button in buffer ? |
jz button |
jmp still |
key: ; key |
mov eax,2 |
int 0x40 ; just read it and ignore |
jmp still |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jnz noclose |
exit: |
or eax,-1 ; close this program |
int 0x40 |
noclose: |
cmp ah,2 |
jnz still |
mov eax,51 |
xor ebx,ebx |
inc ebx |
mov ecx,thread_start |
mov edx,0xe000 |
int 0x40 |
jmp exit |
thread_start: |
mov eax,5 ; wait for termination (1 sec.) |
mov ebx,100 |
int 0x40 |
call save_screen |
jmp exit ; exit thread |
save_screen: |
pusha |
; mov eax,5 |
; mov ebx,500 |
; int 0x40 |
; xor ebx,ebx |
; mov edi,0x10036 ;0x10000 |
; mov esi,edi ;0x10000 |
; add esi,[i_size] |
; ss1: |
; mov eax,35 |
; int 0x40 |
; inc ebx |
; mov [edi],eax |
; add edi,3 |
; cmp edi,esi |
; jb ss1 |
; 1) READ SCREEN |
mov edi,0x10036 |
mov eax,[size_y] |
dec eax |
mov [temp_y],eax |
ynew: |
xor eax,eax |
mov [temp_x],eax |
xnew: |
mov eax,[temp_x] |
mov ebx,[temp_y] |
call read_pixel |
mov [edi],eax |
add edi,3 |
inc [temp_x] |
mov eax,[size_x] |
cmp [temp_x],eax |
jb xnew |
dec [temp_y] |
cmp [temp_y],0 |
jge ynew |
; 2) BMP HEADER |
mov [0x10000],word 'BM' ; bmp signature |
mov eax,[i_size] |
mov [0x10000+34],eax ; image size |
mov ebx,0x36 |
mov [0x10000+10],ebx ; headers size |
add eax,ebx |
mov [0x10000+2],eax ; file size |
mov [0x10000+14],dword 0x28 |
mov eax,[size_x] |
mov [0x10000+18],eax ; x size |
mov eax,[size_y] |
mov [0x10000+22],eax ; y size |
mov [0x10000+26],word 1 |
mov [0x10000+28],word 0x18 ; bpp = 24 = 0x18 |
; 3) SAVE FILE |
mov eax,56 |
mov ebx,filename |
mov edx,0x10000 |
mov ecx,[i_size] |
add ecx,0x36 |
mov esi,path |
int 0x40 |
popa |
ret |
filename db 'SCREEN BMP' |
path db 0 |
read_pixel: |
pushad |
mov esi,eax |
mov eax,[size_x] |
mul ebx |
add eax,esi |
xchg eax,ebx |
mov eax,35 |
int 0x40 |
mov [esp+28],eax |
popad |
ret |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
xor eax,eax ; function 0 : define and draw window |
movzx ebx,word [size_x] |
shr ebx,2 |
add ebx,100*65536+40 |
movzx ecx,word [size_y] |
shr ecx,2 |
add ecx,100*65536+75 |
mov edx,0x027777dd ;82 ; color of work area RRGGBB |
mov esi,0x807777dd ; color of grab bar RRGGBB,8->color gl |
mov edi,0x007777dd ; color of frames RRGGBB |
int 0x40 |
; WINDOW LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
mov ecx,0x10ffffff ; color of text RRGGBB |
mov edx,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
; CLOSE BUTTON |
mov eax,8 ; function 8 : define and draw button |
mov ebx,[size_x] |
shr ebx,2 |
add ebx,40-19 |
shl ebx,16 |
mov bx,12 ; [x start] *65536 + [x size] |
mov ecx,5*65536+12 ; [y start] *65536 + [y size] |
xor edx,edx ; button id |
inc edx |
mov esi,0x7777dd ; button color RRGGBB |
int 0x40 |
; save image |
mov ebx,20*65536 |
mov bx,word [size_x] |
shr bx,2 |
mov cx,word [size_y] |
shr cx,2 |
add cx,49 |
shl ecx,16 |
mov cx,12 |
mov edx,2 |
mov esi,0x4f4f9f |
int 0x40 |
shr ecx,16 |
mov ebx,25*65536 |
mov bx,cx |
add bx,3 |
mov eax,4 |
mov ecx,0xffffff |
mov edx,savetext |
mov esi,24 ;22 |
int 0x40 |
call draw_screen |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
draw_screen: |
pusha |
mov edi,scr |
xor ecx,ecx |
xor edx,edx |
xor esi,esi |
ds1: |
mov eax,35 |
mov ebx,esi |
int 0x40 |
stosd |
dec edi |
add esi,4 |
inc ecx |
cmp ecx,[cmp_ecx] ; 800/4 |
jb ds1 |
add esi,[add_esi] ; 800*3 |
xor ecx,ecx |
inc edx |
cmp edx,[cmp_edx] ; 600/4 |
jb ds1 |
mov eax,7 |
mov ebx,scr |
mov ecx,200*65536+160 |
mov ecx,[size_x] |
shr ecx,2 |
shl ecx,16 |
mov cx,word [size_y] |
shr cx,2 |
mov edx,20*65536+35 |
int 0x40 |
popa |
ret |
draw_magnify: |
pusha |
mov [m_x],dword 0x0 |
mov [m_y],dword 0x0 |
xor ecx,ecx |
xor edx,edx |
dm1: |
push edx |
mov eax,edx |
mul [size_x] |
pop edx |
add eax,ecx |
mov ebx,eax |
mov eax,35 |
int 0x40 |
pusha |
mov ebx,ecx |
mov ecx,edx |
shl ebx,3 |
add ebx,20 |
shl ebx,16 |
mov bx,8 |
shl ecx,3 |
add ecx,35 |
shl ecx,16 |
mov cx,8 |
mov edx,eax |
mov eax,13 |
int 0x40 |
popa |
inc ecx |
cmp ecx,40 |
jnz dm1 |
xor ecx,ecx |
inc edx |
cmp edx,32 |
jnz dm1 |
popa |
ret |
; DATA AREA |
i_size dd 0x1 |
m_x dd 100 |
m_y dd 100 |
cmp_ecx dd 0 |
add_esi dd 0 |
cmp_edx dd 0 |
delay dd 100 |
labelt: |
db 'VIRTUAL SCREEN 2' |
labellen: |
savetext db 'SAVE AS /HD/1/SCREEN.BMP ' |
I_END: |
temp_x dd ? |
temp_y dd ? |
size_x dd ? |
size_y dd ? |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/xpaint/trunk/ascgl.inc |
---|
0,0 → 1,1385 |
lang equ ru |
; |
; Assembler |
; SMALL |
; CODE |
; Graphics |
; Libary |
; |
; Ver 0.18 By Pavlushin Evgeni (RUSSIA) |
; www.waptap@mail.ru |
;InfoList |
;0.01 LoadImage |
;0.02 SetBmp |
;0.03 Bmptoimg, Setimg ~01.03.2004 |
;0.04 Bug deleted, copyimg ~03.05.2004 |
;0.05 fullimg, collimg ~05.05.2004 |
;0.06 getimg ~09.05.2004 |
;0.07 convbmp ~13.05.2004 |
;0.08 fps ~14.05.2004 |
;0.09 drawfbox ~03.06.2004 |
;0.10 all macros optimized by Halyavin A., add at ~07.06.2004 |
;0.11 many macros optimized by Halyavin A., add at ~30.08.2004 |
;0.12 bmptoimg ~07.09.2004 |
;0.13 imgtoimg ~08.09.2004 |
;0.14 imgtoimg modify not brake bmp pict! ~09.09.2004 |
;0.15 giftoimg, giftoani ~10.09.2004 |
;0.16 setframe, rgbtobgr, setbmp deleted ~20.09.2004 |
;0.17 modification giftoimg, giftoani, getframeoff ~01.10.2004 |
;0.18 aframetoimg,aimgtoimg,frametoimg ~03.10.2004 |
aframetoimg_use_count=0 |
macro aframetoimg img, x, y, canvas,acol |
{ |
local loo,loo2,acolor |
aframetoimg_use_count=aframetoimg_use_count+1 |
if aframetoimg_use_count = 1 |
jmp end_aframetoimg_proc |
acolor dd 0 |
aframetoimg_proc: |
;getout coord |
mov [acolor],ebp |
mov edx,ebx ;img ;xsize |
movzx eax,word [edx] |
add eax,esi ;y cor |
; mov eax,esi ;y cor |
mul dword [ecx] ;canvas xsize |
add eax,edi ;x cor |
mov ebp,ebx ;img ;xsize |
movzx edx,word [ebp] |
add eax,edx |
mov ebp,eax |
shl eax,1 |
add ebp,eax |
add ebp,ecx ;canvas+8;start |
add ebp,8 |
;get img size |
add ebx,4 |
mov eax,ebx ;img ;xsize |
movzx esi,word [eax] |
movzx edi,word [eax+2] |
add ebx,4 |
mov edx,ebx ;img+8 |
loo2: |
push esi |
loo: |
;test on alpha color |
mov eax,[edx] |
shl eax,8 |
shr eax,8 |
cmp eax,[acolor] |
jne yx |
add edx,3 |
add ebp,3 |
jmp nx |
yx: |
mov al,byte [edx] |
mov byte [ebp],al |
inc ebp |
inc edx |
mov al,byte [edx] |
mov byte [ebp],al |
inc ebp |
inc edx |
mov al,byte [edx] |
mov byte [ebp],al |
inc ebp |
inc edx |
nx: |
dec esi |
jnz loo |
pop esi |
sub ebp,3 |
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3) |
sub eax,esi |
add ebp,eax |
shl eax,1 |
add ebp,eax |
add ebp,3 |
dec edi |
jnz loo2 |
ret |
end_aframetoimg_proc: |
end if |
push img |
push canvas |
push x |
push y |
push acol |
pop ebp |
pop esi |
pop edi |
pop ecx |
pop ebx |
call aframetoimg_proc |
} |
frametoimg_use_count=0 |
macro frametoimg img, x, y, canvas |
{ |
local loo,loo2 |
frametoimg_use_count=frametoimg_use_count+1 |
if frametoimg_use_count = 1 |
jmp end_frametoimg_proc |
frametoimg_proc: |
;getout coord |
mov edx,ebx ;img ;xsize |
movzx eax,word [edx] |
add eax,esi ;y cor |
; mov eax,esi ;y cor |
mul dword [ecx] ;canvas xsize |
add eax,edi ;x cor |
mov ebp,ebx ;img ;xsize |
movzx edx,word [ebp] |
add eax,edx |
mov ebp,eax |
shl eax,1 |
add ebp,eax |
add ebp,ecx ;canvas+8;start |
add ebp,8 |
;get img size |
add ebx,4 |
mov eax,ebx ;img ;xsize |
movzx esi,word [eax] |
movzx edi,word [eax+2] |
add ebx,4 |
mov edx,ebx ;img+8 |
loo2: |
push esi |
loo: |
mov al,byte [edx] |
mov byte [ebp],al |
inc ebp |
inc edx |
mov al,byte [edx] |
mov byte [ebp],al |
inc ebp |
inc edx |
mov al,byte [edx] |
mov byte [ebp],al |
inc ebp |
inc edx |
dec esi |
jnz loo |
pop esi |
sub ebp,3 |
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3) |
sub eax,esi |
add ebp,eax |
shl eax,1 |
add ebp,eax |
add ebp,3 |
dec edi |
jnz loo2 |
ret |
end_frametoimg_proc: |
end if |
push img |
push canvas |
push x |
push y |
pop esi |
pop edi |
pop ecx |
pop ebx |
call frametoimg_proc |
} |
aimgtoimg_use_count=0 |
macro aimgtoimg img, x, y, canvas,acol |
{ |
local loo,loo2,acolor |
aimgtoimg_use_count=aimgtoimg_use_count+1 |
if aimgtoimg_use_count = 1 |
jmp end_aimgtoimg_proc |
acolor dd 0 |
aimgtoimg_proc: |
;getout coord |
mov [acolor],ebp |
mov eax,esi ;y cor |
mul dword [ecx] ;canvas xsize |
add eax,edi ;x cor |
mov ebp,eax |
shl eax,1 |
add ebp,eax |
add ebp,ecx ;canvas+8;start |
add ebp,8 |
;get img size |
mov eax,ebx ;img ;xsize |
mov esi,[eax] |
add ebx,4 |
mov eax,ebx ; img+4 ;ysize |
mov edi,[eax] |
add ebx,4 |
mov edx,ebx ;img+8 |
loo2: |
push esi |
loo: |
;test on alpha color |
mov eax,[edx] |
shl eax,8 |
shr eax,8 |
cmp eax,[acolor] |
jne yx |
add edx,3 |
add ebp,3 |
jmp nx |
yx: |
mov al,byte [edx] |
mov byte [ebp],al |
inc ebp |
inc edx |
mov al,byte [edx] |
mov byte [ebp],al |
inc ebp |
inc edx |
mov al,byte [edx] |
mov byte [ebp],al |
inc ebp |
inc edx |
nx: |
dec esi |
jnz loo |
pop esi |
sub ebp,3 |
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3) |
sub eax,esi |
add ebp,eax |
shl eax,1 |
add ebp,eax |
add ebp,3 |
dec edi |
jnz loo2 |
ret |
end_aimgtoimg_proc: |
end if |
push img |
push canvas |
push x |
push y |
push acol |
pop ebp |
pop esi |
pop edi |
pop ecx |
pop ebx |
call aimgtoimg_proc |
} |
imgtoimg_use_count=0 |
macro imgtoimg img, x, y, canvas |
{ |
local loo,loo2 |
imgtoimg_use_count=imgtoimg_use_count+1 |
if imgtoimg_use_count = 1 |
jmp end_imgtoimg_proc |
imgtoimg_proc: |
;getout coord |
mov eax,esi ;y cor |
mul dword [ecx] ;canvas xsize |
add eax,edi ;x cor |
mov ebp,eax |
shl eax,1 |
add ebp,eax |
add ebp,ecx ;canvas+8;start |
add ebp,8 |
;get img size |
mov eax,ebx ;img ;xsize |
mov esi,[eax] |
add ebx,4 |
mov eax,ebx ; img+4 ;ysize |
mov edi,[eax] |
add ebx,4 |
mov edx,ebx ;img+8 |
loo2: |
push esi |
loo: |
mov al,byte [edx] |
mov byte [ebp],al |
inc ebp |
inc edx |
mov al,byte [edx] |
mov byte [ebp],al |
inc ebp |
inc edx |
mov al,byte [edx] |
mov byte [ebp],al |
inc ebp |
inc edx |
dec esi |
jnz loo |
pop esi |
sub ebp,3 |
mov eax,[ecx] ;offset = offset+((canxsize-imgxsize)*3) |
sub eax,esi |
add ebp,eax |
shl eax,1 |
add ebp,eax |
add ebp,3 |
dec edi |
jnz loo2 |
ret |
end_imgtoimg_proc: |
end if |
push img |
push canvas |
push x |
push y |
pop esi |
pop edi |
pop ecx |
pop ebx |
call imgtoimg_proc |
} |
;DrawBox |
macro drawfbox x,y,xs,ys,color |
{ |
words2reg ebx,x,xs ;x*65536+xs |
words2reg ecx,y,ys ;y*65536+ys |
mov edx,color |
mov eax,13 |
int 0x40 |
} |
; FPS - Set Frame Per Second Display |
fps_show_frequency=40 |
macro fps x,y,color,delcolor |
{ |
local spdat,savetime,new_time,fps,fps_cntr,out_fps,new_time,ttt |
local no_out_fps |
jmp spdat |
savetime dd 0 |
fps_cntr dd 0 |
fps dd 0 |
ttt dd 0 |
spdat: |
get_time: |
mov eax,3 |
int 0x40 |
cmp eax,[savetime] |
jne new_time |
inc [fps_cntr] |
cmp dword [ttt],0 |
je out_fps |
dec dword [ttt] |
jmp no_out_fps |
new_time: |
mov [savetime],eax |
mov ebx,[fps_cntr] |
mov [fps],ebx |
mov [fps_cntr],0 |
out_fps: |
if ~(delcolor eq ) |
mov ebx,x*65536+36 |
mov ecx,y*65536+7 |
mov edx,delcolor |
mov eax,13 |
int 0x40 |
end if |
mov dword [ttt],fps_show_frequency |
mov eax,47 |
mov ebx,6*65536 |
; mov bl,0 |
mov edx,x*65536+y |
mov esi,color |
mov ecx,[fps] |
int 0x40 |
no_out_fps: |
} |
; COLLIMG - Collusion image's |
_1dbounce_count=0; |
macro collimg img1_off,x1,y1,img2_off,x2,y2,otv |
{ |
local bounce,exit,anot,bc,nbc |
mov esi,[img1_off] ;xs1 |
mov edi,[img2_off] ;ys2 |
mov eax,x1 ; |
mov ebx,x2 ; |
call _1dbounce |
mov edx,ecx |
mov esi,[img1_off+4] ;ys1 |
mov edi,[img2_off+4] ;ys2 |
mov eax,y1 ; |
mov ebx,y2 ; |
call _1dbounce |
add edx,ecx |
cmp edx,2 |
je bounce |
mov otv,0 |
jmp exit |
_1dbounce_count=_1dbounce_count+1 |
if _1dbounce_count = 1 |
_1dbounce: |
cmp ebx,eax |
jb anot |
add eax,esi |
cmp eax,ebx |
jbe nbc |
bc: |
mov ecx,1 |
ret |
anot: |
add ebx,edi |
cmp ebx,eax |
ja bc |
nbc: |
xor ecx,ecx |
ret |
end if |
bounce: |
mov otv,1 |
exit: |
} |
macro rgbtobgr image |
{ |
local loo |
mov eax,[image] |
mul dword [image+4] |
mov ecx,eax |
mov esi,image+8 |
; add esi,8 |
loo: |
mov al,[esi] |
mov bl,[esi+2] |
mov [esi],bl |
mov [esi+2],al |
add esi,3 |
dec ecx |
jnz loo |
} |
macro setimg x , y ,arg3 |
{ |
mov eax,7 |
mov ebx,arg3 |
add ebx,8 |
mov cx,[arg3] |
shl ecx,16 |
add cx,[arg3+4] |
; wordstoreg ecx,[arg3],[arg3+4] |
words2reg edx, x , y ;arg1*65536+arg2 |
int 0x40 |
} |
macro setframe x , y ,arg3 |
{ |
mov eax,7 |
mov ebx,arg3 |
add ebx,8 |
words2reg edx, x , y ;arg1*65536+arg2 |
add edx,dword [arg3] |
mov ecx,dword [arg3+4] |
int 0x40 |
} |
macro getimg imgsrc,x,y,xs,ys,imgdest |
{ |
local cyc |
if xs eqtype 0 |
mov dword [imgdest],xs |
else |
mov eax,xs |
mov dword [imgdest],eax |
end if |
if ys eqtype 0 |
mov dword [imgdest+4],ys |
else |
mov eax,ys |
mov dword [imgdest+4],eax |
end if |
mov eax,dword [imgsrc] ;getx size |
; lea ecx,[eax+2*eax] |
mov ecx,eax |
shl ecx,1 |
add ecx,eax |
mov ebx,y |
mul ebx |
add eax,x |
mov edx,ecx |
lea eax,[eax+2*eax] ;eax=offset on imsrc |
; mov ebp,eax |
; shl eax,1 |
; add eax,ebp |
mov ecx,xs |
mov ebx,ys |
mov edi,8+imgdest |
lea esi,[eax+8+imgsrc] |
; mov esi,eax |
; add esi,8 |
; add esi,imgsrc |
cld |
cyc: |
movsw |
movsb |
dec ecx |
jne cyc |
add esi,edx |
mov ecx,xs |
sub esi,ecx |
sub esi,ecx |
sub esi,ecx |
dec ebx |
jne cyc |
} |
macro copyimg img2_off,img1_off |
{ |
mov eax,dword [img1_off] |
mov ebx,dword [img1_off+4] |
mul ebx |
lea ecx,[eax+2*eax] |
lea esi,[img1_off+8] |
lea edi,[img2_off+8] |
cld |
rep movsb |
} |
macro fullimg img_off,xs,ys,color |
{ |
local cop |
mov eax,xs |
mov ebx,ys |
mov dword [img_off],eax |
mov dword [img_off+4],ebx |
mul ebx |
lea ebp,[eax+2*eax] |
mov esi,color |
if color eqtype 0 |
mov ecx,color/65536 |
else |
mov ecx,esi |
shr ecx,16 |
end if |
xor edi,edi |
cop: |
mov word [img_off+8+edi],si |
add edi,2 |
mov byte [img_off+8+edi],cl |
inc edi |
cmp edi,ebp |
jne cop |
} |
; number of frame in ecx |
; callculatin offset of raw data |
macro getframeoff num_of_frame,offset_of_animation,offset_of_frame |
{ |
local loo,setpic |
mov ebp,num_of_frame ;ecx |
mov esi,offset_of_animation;Image |
loo: |
cmp ebp,0 |
je setpic |
movzx eax,word [esi+4] |
movzx ebx,word [esi+6] |
mul ebx ;dword [esi+4] |
mov ebx,3 |
mul ebx |
add eax,8 |
add esi,eax |
dec ebp |
jmp loo |
setpic: |
mov dword offset_of_frame,esi |
} |
; BMPTOIMG -Convert BMP format TO IMG format |
; (SYNTAX) BMPTOIMG BMP_source_offset,IMG_dest_ofset |
; (SAMPLE) View BMPLS.ASM sample. |
; ( NOTE ) This is macros is not brake bmp structure! Tested in 32,8,4 bits |
bmptoimg_data_area_count=0 |
macro bmptoimg bmp_load_area,img_dest_area |
{ |
local fileinfo,string,end_bmp,nodix |
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2 |
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize |
;local qwe,bmpfn |
; convert: |
movzx eax,word [bmp_load_area+28] |
mul dword [bmp_load_area+18] |
add eax,31 |
shr eax,5 |
mov dword [bmptoimg_data_area_dwps],eax ;dwps-doublewords per string |
shl eax,2 |
mov dword [bmptoimg_data_area_bps],eax ;bps-bytes per string |
cmp dword [bmp_load_area+34],0 |
jne yespicsize ;if picture size is defined |
mul dword [bmp_load_area+22] |
mov dword [bmp_load_area+34],eax |
yespicsize: |
mov ebp,img_dest_area+8 |
mov eax,bmp_load_area |
mov ebx,eax |
add ebx, [bmp_load_area+2];file size |
inc ebx |
mov dword [bmptoimg_soi],ebx ;soi-start of image area for drawing |
add eax, [bmp_load_area+10] |
mov dword [bmptoimg_data_area_sop],eax ;sop-start of picture in file |
add eax, [bmp_load_area+34] |
mov dword [bmptoimg_data_area_eop],eax ;eop-end of picture in file |
mov eax, [bmp_load_area+18] |
lea eax,[eax+2*eax] ;3x pixels in eax |
mov edi,dword [bmptoimg_soi] ;initializing |
mov esi,dword [bmptoimg_data_area_eop] |
sub esi,dword [bmptoimg_data_area_bps] |
nextstring: |
push edi |
push ebp |
cmp word [bmp_load_area+28],24 |
jne convertno32 |
mov edi,ebp |
mov ecx,[bmptoimg_data_area_dwps] |
cld |
rep movsd |
convert1: |
pop ebp |
pop edi |
sub esi,dword [bmptoimg_data_area_bps] |
sub esi,dword [bmptoimg_data_area_bps] |
cmp esi,dword [bmptoimg_data_area_sop] |
jb end_bmp |
add edi,eax |
add ebp,eax |
jmp nextstring |
convertno32: |
mov ebx,bmp_load_area |
add ebx, [bmp_load_area+14] |
add ebx,14 ;start of color table |
push esi |
add esi,dword [bmptoimg_data_area_bps] |
mov dword [bmptoimg_data_area_eos],esi |
pop esi |
nextelem: |
push eax |
movzx eax,byte [esi] |
cmp word [bmp_load_area+28],4 |
je convert4bpp |
cmp word [bmp_load_area+28],1 |
je convert1bpp |
call converttable |
convert2: |
pop eax |
inc esi |
cmp esi,dword [bmptoimg_data_area_eos] |
jae convert1 |
add edi,3 |
add ebp,3 |
jmp nextelem |
convert4bpp: |
shl ax,4 |
shr al,4 |
push ax |
movzx eax,ah |
call converttable |
add edi,3 |
add ebp,3 |
pop ax |
movzx eax,al |
call converttable |
jmp convert2 |
convert1bpp: |
mov ecx,eax |
mov edx,7 |
nextbit: |
xor eax,eax |
bt ecx,edx |
jnc noaddelem |
inc eax |
noaddelem: |
push edx |
call converttable |
pop edx |
dec edx |
js convert2 |
add edi,3 |
add ebp,3 |
jmp nextbit |
converttable: |
shl eax,2 |
add eax,ebx |
mov edx, dword [eax] |
; mov dword [edi],edx |
mov [ebp],edx |
ret |
bmptoimg_data_area_count=bmptoimg_data_area_count+1 |
if bmptoimg_data_area_count = 1 |
; DATA AREA |
bmptoimg_soi dd 0 |
bmptoimg_data_area_bps dd 0 |
bmptoimg_data_area_dwps dd 0 |
bmptoimg_data_area_sop dd 0 |
bmptoimg_data_area_eop dd 0 |
bmptoimg_data_area_eos dd 0 |
end if |
end_bmp: |
mov eax,dword [bmp_load_area+18] |
mov ebx,dword [bmp_load_area+22] |
mov dword [img_dest_area],eax |
mov dword [img_dest_area+4],ebx |
} |
; For convert RGB to BGR |
COLOR_ORDER equ MENUETOS |
macro giftoani gifsrc,imgsrc,num_of_frames |
{ |
local hasharea, ReadGIF, nextblock,_null |
local globalColor, img_count, cur_info, img_start |
local codesize, compsize, bit_count, CC, EOI, Palette |
local block_ofs, table_ptr, gifmacend |
local no_gc, block_skip, no_comm, noextblock, uselocal |
local setPal, filltable, reinit, cycle, zadd, noinc |
local notintable, er, zend, nxt, continue, ex, Gif_skipmap |
local Gif_get_sym, shift, nextbl, noblock, loop1, exx |
local Gif_output, next, loop2 |
_null equ 0x1000 ; 0x1000 |
; jmp sss |
; if defined gif_hash_offset |
; else |
; hasharea: |
; times 4096 dd 0 ;4096 |
; end if |
;sss: |
mov esi,gifsrc ;ª § ⥫ì ä ¨« ¢ ¯ ¬ï⨠|
mov edi,imgsrc ;ª § ⥫ì ᯨ᮪ ª à⨮ª |
if defined gif_hash_offset |
mov eax,gif_hash_offset ; ¡®ç ï ®¡« áâì ¬¨¨¬ã¬ 4096*4 ¡ ©â |
else |
mov eax,hasharea ; ¡®ç ï ®¡« áâì ¬¨¨¬ã¬ 4096*4 ¡ ©â |
end if |
call ReadGIF |
push ecx |
pop dword num_of_frames |
jmp gifmacend |
if defined gif_hash_offset |
else |
hasharea: |
times 4096 dd 0 ;4096 |
end if |
ReadGIF: |
push esi edi |
mov [table_ptr],eax |
mov [cur_info],edi |
xor eax,eax |
mov [globalColor],eax |
mov [img_count],eax |
inc eax |
cmp dword[esi],'GIF8' |
jne er ; signature |
mov ecx,[esi+0xa] |
inc eax |
add esi,0xd |
mov edi,esi |
bt ecx,7 |
jnc nextblock |
mov [globalColor],esi |
call Gif_skipmap |
nextblock: |
cmp byte[edi],0x21 |
jne noextblock |
inc edi |
cmp byte[edi],0xf9 ; Graphic Control Ext |
jne no_gc |
add edi,7 |
jmp nextblock |
no_gc: |
cmp byte[edi],0xfe ; Comment Ext |
jne no_comm |
inc edi |
block_skip: |
movzx eax,byte[edi] |
lea edi,[edi+eax+1] |
cmp byte[edi],0 |
jnz block_skip |
inc edi |
jmp nextblock |
no_comm: |
cmp byte[edi],0xff ; Application Ext |
jne nextblock |
add edi,13 |
jmp block_skip |
noextblock: |
cmp byte[edi],0x2c ; image beginning |
jne er |
inc [img_count] |
inc edi |
mov esi,[cur_info] |
xchg esi,edi |
movsd |
movsd |
push edi |
movzx ecx,word[esi] |
inc esi |
bt ecx,7 |
jc uselocal |
push [globalColor] |
mov edi,esi |
jmp setPal |
uselocal: |
call Gif_skipmap |
push esi |
setPal: |
movzx ecx,byte[edi] |
inc ecx |
mov [codesize],ecx |
dec ecx |
pop [Palette] |
lea esi,[edi+1] |
mov edi,[table_ptr] |
xor eax,eax |
cld |
lodsb ; eax - block_count |
add eax,esi |
mov [block_ofs],eax |
mov [bit_count],8 |
mov eax,1 |
shl eax,cl |
mov [CC],eax |
inc eax |
mov [EOI],eax |
lea ecx,[eax-1] |
mov eax, _null shl 16 |
filltable: |
stosd |
inc eax |
loop filltable |
pop edi |
mov [img_start],edi |
reinit: |
mov edx,[EOI] |
inc edx |
push [codesize] |
pop [compsize] |
call Gif_get_sym |
cmp eax,[CC] |
je reinit |
call Gif_output |
cycle: |
movzx ebx,ax |
call Gif_get_sym |
cmp eax,edx |
jae notintable |
cmp eax,[CC] |
je reinit |
cmp eax,[EOI] |
je zend |
call Gif_output |
zadd: |
push eax |
mov eax,[table_ptr] |
mov [eax+edx*4],ebx |
pop eax |
cmp edx,0xFFF |
jae cycle |
inc edx |
bsr ebx,edx |
cmp ebx,[compsize] |
jne noinc |
inc [compsize] |
noinc: |
jmp cycle |
notintable: |
push eax |
mov eax,ebx |
call Gif_output |
push ebx |
movzx eax,bx |
call Gif_output |
pop ebx eax |
jmp zadd |
er: |
pop edi |
jmp ex |
zend: |
; mov eax,[.cur_info] ; skip offset to next frame |
; mov [eax],edi |
mov [cur_info],edi |
add esi,2 |
xchg esi,edi |
nxt: |
cmp byte[edi],0 |
jnz continue |
inc edi |
jmp nxt |
continue: |
cmp byte[edi],0x3b ;read next frame |
jne nextblock |
xor eax,eax |
stosd |
mov ecx,[img_count] |
ex: |
pop edi esi |
ret |
Gif_skipmap: |
; in: ecx - image descriptor, esi - pointer to colormap |
; out: edi - pointer to area after colormap |
and ecx,111b |
inc ecx ; color map size |
mov ebx,1 |
shl ebx,cl |
lea ebx,[ebx*2+ebx] |
lea edi,[esi+ebx] |
ret |
Gif_get_sym: |
mov ecx,[compsize] |
push ecx |
xor eax,eax |
shift: |
ror byte[esi],1 |
rcr eax,1 |
dec [bit_count] |
jnz loop1 |
inc esi |
cmp esi,[block_ofs] |
jb noblock |
push eax |
xor eax,eax |
lodsb |
test eax,eax |
jnz nextbl |
mov eax,[EOI] |
sub esi,2 |
add esp,8 |
jmp exx |
nextbl: |
add eax,esi |
mov [block_ofs],eax |
pop eax |
noblock: |
mov [bit_count],8 |
loop1: |
loop shift |
pop ecx |
rol eax,cl |
exx: |
xor ecx,ecx |
ret |
Gif_output: |
push esi eax edx |
mov edx,[table_ptr] |
next: |
push word[edx+eax*4] |
mov ax,word[edx+eax*4+2] |
inc ecx |
cmp ax,_null |
jnz next |
shl ebx,16 |
mov bx,[esp] |
loop2: |
pop ax |
lea esi,[eax+eax*2] |
add esi,[Palette] |
if COLOR_ORDER eq MENUETOS |
mov esi,[esi] |
bswap esi |
shr esi,8 |
mov [edi],esi |
add edi,3 |
else |
movsw |
movsb |
end if |
loop loop2 |
pop edx eax esi |
ret |
globalColor dd 1 |
img_count dd 1 |
cur_info dd 1 ; image table pointer |
img_start dd 1 |
codesize dd 1 |
compsize dd 1 |
bit_count dd 1 |
CC dd 1 |
EOI dd 1 |
Palette dd 1 |
block_ofs dd 1 |
table_ptr dd 1 |
gifmacend: |
} |
macro giftoimg gifsrc,imgsrc |
{ |
local hasharea, ReadGIF, nextblock,_null |
local globalColor, img_count, cur_info, img_start |
local codesize, compsize, bit_count, CC, EOI, Palette |
local block_ofs, table_ptr, gifmacend |
local no_gc, block_skip, no_comm, noextblock, uselocal |
local setPal, filltable, reinit, cycle, zadd, noinc |
local notintable, er, zend, nxt, continue, ex, Gif_skipmap |
local Gif_get_sym, shift, nextbl, noblock, loop1, exx |
local Gif_output, next, loop2 |
_null equ 0x1000 ; 0x1000 |
mov esi,gifsrc ;ª § ⥫ì ä ¨« ¢ ¯ ¬ï⨠|
mov edi,imgsrc ;ª § ⥫ì ᯨ᮪ ª à⨮ª |
if defined gif_hash_offset |
mov eax,gif_hash_offset ; ¡®ç ï ®¡« áâì ¬¨¨¬ã¬ 4096*4 ¡ ©â |
else |
mov eax,hasharea ; ¡®ç ï ®¡« áâì ¬¨¨¬ã¬ 4096*4 ¡ ©â |
end if |
call ReadGIF |
jmp gifmacend |
if defined gif_hash_offset |
else |
hasharea: |
times 4096 dd 0 ;4096 |
end if |
ReadGIF: |
push esi edi |
mov [table_ptr],eax |
mov [cur_info],edi |
xor eax,eax |
mov [globalColor],eax |
mov [img_count],eax |
inc eax |
cmp dword[esi],'GIF8' |
jne er ; signature |
mov ecx,[esi+0xa] |
inc eax |
add esi,0xd |
mov edi,esi |
bt ecx,7 |
jnc nextblock |
mov [globalColor],esi |
call Gif_skipmap |
nextblock: |
cmp byte[edi],0x21 |
jne noextblock |
inc edi |
cmp byte[edi],0xf9 ; Graphic Control Ext |
jne no_gc |
add edi,7 |
jmp nextblock |
no_gc: |
cmp byte[edi],0xfe ; Comment Ext |
jne no_comm |
inc edi |
block_skip: |
movzx eax,byte[edi] |
lea edi,[edi+eax+1] |
cmp byte[edi],0 |
jnz block_skip |
inc edi |
jmp nextblock |
no_comm: |
cmp byte[edi],0xff ; Application Ext |
jne nextblock |
add edi,13 |
jmp block_skip |
noextblock: |
cmp byte[edi],0x2c ; image beginning |
jne er |
inc [img_count] |
inc edi |
mov esi,[cur_info] |
xchg esi,edi |
; movsd |
; movsd |
mov bp,word[esi+4] |
movzx ebx,bp |
mov [edi],ebx |
mov bp,word[esi+6] |
movzx ebx,bp |
mov [edi+4],ebx |
add edi,8 |
add esi,8 |
push edi |
movzx ecx,word[esi] |
inc esi |
bt ecx,7 |
jc uselocal |
push [globalColor] |
mov edi,esi |
jmp setPal |
uselocal: |
call Gif_skipmap |
push esi |
setPal: |
movzx ecx,byte[edi] |
inc ecx |
mov [codesize],ecx |
dec ecx |
pop [Palette] |
lea esi,[edi+1] |
mov edi,[table_ptr] |
xor eax,eax |
cld |
lodsb ; eax - block_count |
add eax,esi |
mov [block_ofs],eax |
mov [bit_count],8 |
mov eax,1 |
shl eax,cl |
mov [CC],eax |
inc eax |
mov [EOI],eax |
lea ecx,[eax-1] |
mov eax, _null shl 16 |
filltable: |
stosd |
inc eax |
loop filltable |
pop edi |
mov [img_start],edi |
reinit: |
mov edx,[EOI] |
inc edx |
push [codesize] |
pop [compsize] |
call Gif_get_sym |
cmp eax,[CC] |
je reinit |
call Gif_output |
cycle: |
movzx ebx,ax |
call Gif_get_sym |
cmp eax,edx |
jae notintable |
cmp eax,[CC] |
je reinit |
cmp eax,[EOI] |
je zend |
call Gif_output |
zadd: |
push eax |
mov eax,[table_ptr] |
mov [eax+edx*4],ebx |
pop eax |
cmp edx,0xFFF |
jae cycle |
inc edx |
bsr ebx,edx |
cmp ebx,[compsize] |
jne noinc |
inc [compsize] |
noinc: |
jmp cycle |
notintable: |
push eax |
mov eax,ebx |
call Gif_output |
push ebx |
movzx eax,bx |
call Gif_output |
pop ebx eax |
jmp zadd |
er: |
pop edi |
jmp ex |
zend: |
; mov eax,[.cur_info] ; skip offset to next frame |
; mov [eax],edi |
mov [cur_info],edi |
add esi,2 |
xchg esi,edi |
nxt: |
cmp byte[edi],0 |
jnz continue |
inc edi |
jmp nxt |
continue: |
; cmp byte[edi],0x3b ;read next frame |
; jne nextblock |
xor eax,eax |
stosd |
mov ecx,[img_count] |
ex: |
pop edi esi |
ret |
Gif_skipmap: |
; in: ecx - image descriptor, esi - pointer to colormap |
; out: edi - pointer to area after colormap |
and ecx,111b |
inc ecx ; color map size |
mov ebx,1 |
shl ebx,cl |
lea ebx,[ebx*2+ebx] |
lea edi,[esi+ebx] |
ret |
Gif_get_sym: |
mov ecx,[compsize] |
push ecx |
xor eax,eax |
shift: |
ror byte[esi],1 |
rcr eax,1 |
dec [bit_count] |
jnz loop1 |
inc esi |
cmp esi,[block_ofs] |
jb noblock |
push eax |
xor eax,eax |
lodsb |
test eax,eax |
jnz nextbl |
mov eax,[EOI] |
sub esi,2 |
add esp,8 |
jmp exx |
nextbl: |
add eax,esi |
mov [block_ofs],eax |
pop eax |
noblock: |
mov [bit_count],8 |
loop1: |
loop shift |
pop ecx |
rol eax,cl |
exx: |
xor ecx,ecx |
ret |
Gif_output: |
push esi eax edx |
mov edx,[table_ptr] |
next: |
push word[edx+eax*4] |
mov ax,word[edx+eax*4+2] |
inc ecx |
cmp ax,_null |
jnz next |
shl ebx,16 |
mov bx,[esp] |
loop2: |
pop ax |
lea esi,[eax+eax*2] |
add esi,[Palette] |
if COLOR_ORDER eq MENUETOS |
mov esi,[esi] |
bswap esi |
shr esi,8 |
mov [edi],esi |
add edi,3 |
else |
movsw |
movsb |
end if |
loop loop2 |
pop edx eax esi |
ret |
globalColor dd 1 |
img_count dd 1 |
cur_info dd 1 ; image table pointer |
img_start dd 1 |
codesize dd 1 |
compsize dd 1 |
bit_count dd 1 |
CC dd 1 |
EOI dd 1 |
Palette dd 1 |
block_ofs dd 1 |
table_ptr dd 1 |
gifmacend: |
} |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/xpaint/trunk/ascgml.inc |
---|
0,0 → 1,49 |
lang equ ru |
; |
; Assembler |
; SMALL |
; CODE |
; GaMe |
; Libary |
; |
; Ver 0.03 By Pavlushin Evgeni (RUSSIA) |
; www.waptap@mail.ru |
;InfoList |
;0.01 correct |
;0.02 control ~14.05.2004 |
;0.03 all macros optimized by halyavin, add at ~07.06.2004 |
; corectiryemoe,corectnoe,step |
macro correct arg1,arg2,arg3 |
{ |
local plus,minus,equal |
mov eax,arg2 |
cmp arg1,eax |
je equal |
mov eax,arg3 |
ja minus |
plus: |
add arg1,eax |
jmp equal |
minus: |
sub arg1,eax |
equal: |
} |
macro control min,max,arg |
{ |
local gr,low,norm |
mov eax,max |
cmp arg,eax |
jg gr |
mov eax,min |
cmp arg,eax |
jnl norm |
gr: |
low: |
mov arg,eax |
norm: |
} |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/xpaint/trunk/ascl.inc |
---|
0,0 → 1,897 |
lang equ ru ; ru en fr ge fi |
; |
; Assembler |
; SMALL |
; CODE |
; Libary |
; |
; Ver 0.14 By Pavlushin Evgeni (RUSSIA) |
; www.waptap@mail.ru |
;Please compile aplications on FASM ver1.54 or higer!!! |
;InfoList |
;0.01 scank,putpix,puttxt |
;0.02 label,random,colors |
;0.03 window,startwd,endwd,attributes |
;0.04 close,delay,scevent ~30.04.2004 |
;0.05 small random, ~04.05.2004 |
;0.06 wtevent ~09.05.2004 |
;0.07 timeevent ~23.05.2004 |
;0.08 txtput ~14.06.2004 |
;0.09 opendialog,savedialog ~20.06.2004 |
;0.10 wordstoreg by halyavin, add at ~30.08.2004 |
; random bug deleted eax is use. |
;0.11 loadfile from me +puttxt bug del ~07.09.2004 |
;0.12 open/save dialog ~13.09.2004 |
;0.13 dialogs bugs deleted |
;0.14 drawlbut ~03.10.2004 |
;0.15 extendet label! |
; LOADFILE |
; (SYNTAX) LOADFILE 'full_path_to_file',file_load_area,file_temp_area |
; (SAMPLE) LOADFILE '/rd/1/clock.bmp',load_area,temp_area |
macro loadfile file_name,file_load_area,file_temp_area |
{ |
local open,fileinfo,string |
jmp open |
fileinfo: |
dd 0 |
dd 0 |
dd 1 |
dd file_load_area |
dd file_temp_area |
string: |
db file_name,0 |
open: |
mov dword [fileinfo+8],1 ; how many blocks to read (1) |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
mov eax,[file_load_area+2] |
shr eax,9 ; ¯®¤¥«¨¬ 512 ¨ ¯à¨¡ ¢¨¬ 1 - ¯®«ã稬 ç¨á«® ¡«®ª®¢ |
inc eax |
mov dword [fileinfo+8],eax |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
} |
;macro wordstoreg reg,hiword,loword |
;{ |
;if hiword eqtype 0 & loword eqtype 0 |
; mov reg,dword hiword*65536+loword |
;else if hiword eqtype 12 & loword eqtype eax |
; mov reg,dword hiword*65536 |
; add reg,dword loword |
;else if hiword eqtype 12 & loword eqtype [123] |
; mov reg,dword hiword*65536 |
; add reg,dword loword |
;else |
; mov reg,dword hiword |
; shl reg,16 |
; add reg,dword loword |
;end if |
;} |
macro dword2reg reg,doubleword |
{ |
if doubleword eq |
; not changes |
else |
mov reg,dword doubleword |
end if |
} |
macro words2reg reg,hiword,lowword |
{ |
if hiword eq |
if lowword eq |
; not changes |
else |
if lowword eqtype 12 |
and reg,dword 0xffff0000 |
add reg,dword lowword |
else |
and reg,dword 0xffff0000 |
add reg,dword lowword |
end if |
end if |
else |
if lowword eq |
if hiword eqtype 12 |
and reg,dword 0x0000ffff |
add reg,dword hiword*65536 |
else |
shl reg,16 |
add reg,dword hiword |
ror reg,16 |
end if |
else |
if lowword eqtype 12 & hiword eqtype 12 |
if lowword eq 0 & hiword eq 0 |
xor reg,reg |
else |
mov reg,dword hiword*65536+lowword |
end if |
else |
mov reg,dword hiword |
shl reg,16 |
add reg,dword lowword |
end if |
end if |
end if |
} |
; DRAW BUTTON with label |
macro drawlbut x,y,xs,ys,text,id,bcolor,tcolor |
{ |
local asd,lab |
jmp asd |
lab db text ;arg label |
asd: |
words2reg ebx,x,xs |
words2reg ecx,y,ys |
mov edx,id |
mov esi,bcolor |
mov eax,8 |
int 0x40 |
mov eax,asd-lab ;calc size |
mov ebx,6 |
mul ebx |
mov esi,eax |
mov eax,xs |
sub eax,esi |
shr eax,1 |
add eax,x |
mov edx,ys |
sub edx,7 |
shr edx,1 |
add edx,y |
mov ebx,eax |
shl ebx,16 |
add ebx,edx |
mov ecx,tcolor ;arg4 color |
mov edx,lab |
mov esi,asd-lab ;calc size |
mov eax,4 |
int 0x40 |
} |
macro opendialog redproc,openoff,erroff,path |
{ |
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc |
local run_fileinfo, param |
local getmesloop, loox, mred, mkey, mbutton, mgetmes |
local dlg_is_work, ready, procinfo |
; |
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec, |
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save) |
; |
cld |
;; mov esi,path |
mov edi,path |
mov eax,0 |
mov ecx,200 |
rep stosb |
;mov [get_loops],0 |
mov [dlg_pid_get],0 |
; Get my PID in dec format 4 bytes |
mov eax,9 |
mov ebx,procinfo |
mov ecx,-1 |
int 0x40 |
; convert eax bin to param dec |
mov eax,dword [procinfo+30] ;offset of myPID |
mov edi,param+4-1 ;offset to 4 bytes |
mov ecx,4 |
mov ebx,10 |
cld |
new_d: |
xor edx,edx |
div ebx |
add dl,'0' |
mov [edi],dl |
dec edi |
loop new_d |
; wirite 1 byte space to param |
mov [param+4],byte 32 ;Space for next parametr |
; and 1 byte type of dialog to param |
mov [param+5],byte 'O' ;Get Open dialog (Use 'S' for Save dialog) |
; |
; STEP2 prepare IPC area for get messages |
; |
; prepare IPC area |
mov [path],dword 0 |
mov [path+4],dword 8 |
; define IPC memory |
mov eax,60 |
mov ebx,1 ; define IPC |
mov ecx,path ; offset of area |
mov edx,150 ; size 150 bytes |
int 0x40 |
; change wanted events list 7-bit IPC event |
mov eax,40 |
mov ebx,01000111b |
int 0x40 |
; |
; STEP 3 run SYSTEM XTREE with parameters |
; |
mov eax,58 |
mov ebx,run_fileinfo |
int 0x40 |
call redproc |
mov [get_loops],0 |
getmesloop: |
mov eax,23 |
mov ebx,50 ;0.5 sec |
int 0x40 |
cmp eax,1 |
je mred |
cmp eax,2 |
je mkey |
cmp eax,3 |
je mbutton |
cmp eax,7 |
je mgetmes |
; Get number of procces |
mov ebx,procinfo |
mov ecx,-1 |
mov eax,9 |
int 0x40 |
mov ebp,eax |
loox: |
mov eax,9 |
mov ebx,procinfo |
mov ecx,ebp |
int 0x40 |
mov eax,[DLGPID] |
cmp [procinfo+30],eax ;IF Dialog find |
je dlg_is_work ;jmp to dlg_is_work |
dec ebp |
jnz loox |
jmp erroff |
dlg_is_work: |
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated |
je erroff ;TESTODP2 terminated too |
cmp [dlg_pid_get],dword 1 |
je getmesloop |
inc [get_loops] |
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated |
jae erroff |
jmp getmesloop |
mred: |
call redproc |
jmp getmesloop |
mkey: |
mov eax,2 |
int 0x40 ; read (eax=2) |
jmp getmesloop |
mbutton: |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne getmesloop |
mov eax,-1 ; close this program |
int 0x40 |
mgetmes: |
; If dlg_pid_get then second message get jmp to still |
cmp [dlg_pid_get],dword 1 |
je ready |
; First message is number of PID SYSXTREE dialog |
; convert PID dec to PID bin |
movzx eax,byte [path+16] |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+1] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+2] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+3] |
add eax,ebx |
sub eax,48 |
mov [DLGPID],eax |
; Claear and prepare IPC area for next message |
mov [path],dword 0 |
mov [path+4],dword 8 |
mov [path+8],dword 0 |
mov [path+12],dword 0 |
mov [path+16],dword 0 |
; Set dlg_pid_get for get next message |
mov [dlg_pid_get],dword 1 |
call redproc ;show DLG_PID |
jmp getmesloop |
ready: |
; |
; The second message get |
; Second message is 100 bytes path to SAVE/OPEN file |
; shl path string on 16 bytes |
; |
cld |
mov esi,path+16 |
mov edi,path |
mov ecx,200 |
rep movsb |
mov [edi],byte 0 |
jmp openoff |
; DATA AREA |
get_loops dd 0 |
dlg_pid_get dd 0 |
DLGPID dd 0 |
param: |
dd 0 ; My dec PID |
dd 0,0 ; Type of dialog |
run_fileinfo: |
dd 16 |
dd 0 |
dd param |
dd 0 |
dd procinfo ; 0x10000 |
;run_filepath |
db '/RD/1/SYSXTREE',0 |
procinfo: |
times 1024 db 0 |
} |
macro savedialog redproc,openoff,erroff,path |
{ |
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc |
local run_fileinfo, run_filepath, param |
local getmesloop, loox, mred, mkey, mbutton, mgetmes |
local dlg_is_work, ready, procinfo |
; |
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec, |
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save) |
; |
cld |
;; mov esi,path |
mov edi,path |
mov eax,0 |
mov ecx,200 |
rep stosb |
;mov [get_loops],0 |
mov [dlg_pid_get],0 |
; Get my PID in dec format 4 bytes |
mov eax,9 |
mov ebx,procinfo |
mov ecx,-1 |
int 0x40 |
; convert eax bin to param dec |
mov eax,dword [procinfo+30] ;offset of myPID |
mov edi,param+4-1 ;offset to 4 bytes |
mov ecx,4 |
mov ebx,10 |
cld |
new_d: |
xor edx,edx |
div ebx |
add dl,'0' |
mov [edi],dl |
dec edi |
loop new_d |
; wirite 1 byte space to param |
mov [param+4],byte 32 ;Space for next parametr |
; and 1 byte type of dialog to param |
mov [param+5],byte 'S' ;Get Open dialog (Use 'S' for Save dialog) |
; |
; STEP2 prepare IPC area for get messages |
; |
; prepare IPC area |
mov [path],dword 0 |
mov [path+4],dword 8 |
; define IPC memory |
mov eax,60 |
mov ebx,1 ; define IPC |
mov ecx,path ; offset of area |
mov edx,150 ; size 150 bytes |
int 0x40 |
; change wanted events list 7-bit IPC event |
mov eax,40 |
mov ebx,01000111b |
int 0x40 |
; |
; STEP 3 run SYSTEM XTREE with parameters |
; |
mov eax,58 |
mov ebx,run_fileinfo |
int 0x40 |
call redproc |
mov [get_loops],0 |
getmesloop: |
mov eax,23 |
mov ebx,50 ;0.5 sec |
int 0x40 |
cmp eax,1 |
je mred |
cmp eax,2 |
je mkey |
cmp eax,3 |
je mbutton |
cmp eax,7 |
je mgetmes |
; Get number of procces |
mov ebx,procinfo |
mov ecx,-1 |
mov eax,9 |
int 0x40 |
mov ebp,eax |
loox: |
mov eax,9 |
mov ebx,procinfo |
mov ecx,ebp |
int 0x40 |
mov eax,[DLGPID] |
cmp [procinfo+30],eax ;IF Dialog find |
je dlg_is_work ;jmp to dlg_is_work |
dec ebp |
jnz loox |
jmp erroff |
dlg_is_work: |
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated |
je erroff ;TESTODP2 terminated too |
cmp [dlg_pid_get],dword 1 |
je getmesloop |
inc [get_loops] |
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated |
jae erroff |
jmp getmesloop |
mred: |
call redproc |
jmp getmesloop |
mkey: |
mov eax,2 |
int 0x40 ; read (eax=2) |
jmp getmesloop |
mbutton: |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne getmesloop |
mov eax,-1 ; close this program |
int 0x40 |
mgetmes: |
; If dlg_pid_get then second message get jmp to still |
cmp [dlg_pid_get],dword 1 |
je ready |
; First message is number of PID SYSXTREE dialog |
; convert PID dec to PID bin |
movzx eax,byte [path+16] |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+1] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+2] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+3] |
add eax,ebx |
sub eax,48 |
mov [DLGPID],eax |
; Claear and prepare IPC area for next message |
mov [path],dword 0 |
mov [path+4],dword 8 |
mov [path+8],dword 0 |
mov [path+12],dword 0 |
mov [path+16],dword 0 |
; Set dlg_pid_get for get next message |
mov [dlg_pid_get],dword 1 |
call redproc ;show DLG_PID |
jmp getmesloop |
ready: |
; |
; The second message get |
; Second message is 100 bytes path to SAVE/OPEN file |
; shl path string on 16 bytes |
; |
cld |
mov esi,path+16 |
mov edi,path |
mov ecx,200 |
rep movsb |
mov [edi],byte 0 |
jmp openoff |
; DATA AREA |
get_loops dd 0 |
dlg_pid_get dd 0 |
DLGPID dd 0 |
param: |
dd 0 ; My dec PID |
dd 0,0 ; Type of dialog |
run_fileinfo: |
dd 16 |
dd 0 |
dd param |
dd 0 |
dd procinfo |
;run_filepath: |
db '/RD/1/SYSXTREE',0 |
procinfo: |
times 1024 db 0 |
} |
; RANDOM - generate random count (small) |
; (SYNTAX) RANDOM MaxCount,OutArgument |
; (SAMPLE) RANDOM 10000,eax |
; ( NOTE ) Maxint<65536 ; use random 65536,eax for more combinations |
randomuse = 0 |
macro random arg1,arg2 |
{ |
local rxproc |
randomuse = randomuse + 1 |
jmp rxproc |
if defined randomuse & randomuse = 1 |
randomproc: |
jmp rnj |
rsx1 dw 0x4321 |
rsx2 dw 0x1234 |
rnj: |
; mov eax,arg1 |
push bx |
push cx |
push dx |
push si |
push di |
mov cx,ax |
mov ax,word ptr rsx1 |
mov bx,word ptr rsx2 |
mov si,ax |
mov di,bx |
mov dl,ah |
mov ah,al |
mov al,bh |
mov bh,bl |
xor bl,bl |
rcr dl,1 |
rcr ax,1 |
rcr bx,1 |
add bx,di |
adc ax,si |
add bx,0x62e9 |
adc ax,0x3619 |
mov word ptr rsx1,bx |
mov word ptr rsx2,ax |
xor dx,dx |
cmp ax,0 |
je nodiv |
cmp cx,0 |
je nodiv |
div cx |
nodiv: |
mov ax,dx |
pop di |
pop si |
pop dx |
pop cx |
pop bx |
and eax,0000ffffh |
; mov arg2,0 |
; mov arg2,eax |
ret |
end if |
rxproc: |
mov eax,arg1 |
call randomproc |
mov arg2,eax |
} |
macro scank |
{ |
mov eax,10 |
int 0x40 |
} |
macro putpix x,y,color |
{ |
mov ebx,x |
mov ecx,y |
mov edx,color |
mov eax,1 |
int 0x40 |
} |
macro puttxt x,y,offs,size,color |
{ |
; mov ebx,x |
; shl ebx,16 |
; add ebx,y |
words2reg ebx,x,y |
dword2reg ecx,color |
dword2reg edx,offs |
dword2reg esi,size |
; mov ecx,color |
; mov edx,offs |
; mov esi,size |
mov eax,4 |
int 0x40 |
} |
macro outcount data, x, y, color, numtype |
{ |
mov ecx,data |
mov ebx,numtype |
mov bl,0 |
; mov edx,x*65536+y |
words2reg edx,x,y |
mov esi,color |
mov eax,47 |
int 0x40 |
} |
; SCEVENT - Scan event |
macro scevent red,key,but |
{ |
mov eax,11 |
int 0x40 |
dec eax |
jz red |
dec eax |
jz key |
dec eax |
jz but |
} |
; WTEVENT - Wait event |
macro wtevent red,key,but |
{ |
mov eax,10 |
int 0x40 |
dec eax |
jz red |
dec eax |
jz key |
dec eax |
jz but |
} |
; TIMEEVENT - Wite for event with timeout |
macro timeevent xfps,noevent,red,key,but |
{ |
mov eax,23 |
mov ebx,xfps |
int 0x40 |
cmp eax,0 |
je noevent |
dec eax |
jz red |
dec eax |
jz key |
dec eax |
jz but |
} |
; CLOSE - Close program |
macro close |
{ |
mov eax,-1 |
int 0x40 |
} |
; DELAY - Create delay 1/100 sec |
; (SYNTAX) Delay time |
; (SAMPLE) Delay 100 ;delay 2 sec 1/100*200=2 sec |
macro delay arg1 |
{ |
mov eax,5 |
mov ebx,arg1 |
int 0x40 |
} |
; WINDOW - Draw window |
; (SYNTAX) WINDOW Xstart,Ystart,'Text',Color |
; (SAMPLE) WINDOW 10,10,640+8,480+24,window_Skinned |
macro window arg1,arg2,arg3,arg4,arg5 |
{ |
; mov ebx,arg1*65536+arg3 |
; mov ecx,arg2*65536+arg4 |
words2reg ebx,arg1,arg3 |
words2reg ecx,arg2,arg4 |
mov edx,arg5 |
mov eax,0 |
int 0x40 |
} |
macro colorwindow arg1,arg2,arg3,arg4,arg5,arg6,arg7 |
{ |
mov ebx,arg1*65536+arg3 |
mov ecx,arg2*65536+arg4 |
mov edx,arg5 |
mov esi,arg6 |
mov edi,arg7 |
mov eax,0 |
int 0x40 |
} |
; STARTWD - Start of window draw |
macro startwd |
{ |
mov eax,12 |
mov ebx,1 |
int 0x40 |
} |
; ENDWD - End window draw |
macro endwd |
{ |
mov eax,12 |
mov ebx,2 |
int 0x40 |
} |
; LABEL - Put text to frame |
; (SYNTAX) LABEL Xstart,Ystart,'Text',Color |
; (SAMPLE) LABEL 10,12,'Hello World!',cl_Green+font_Big |
macro label arg1,arg2,arg3,arg4 |
{ |
local asd,lab |
jmp asd |
lab db arg3 ;arg label |
asd: |
; mov ebx,arg1 ;arg1=y arg2=x |
; shl ebx,16 |
; add ebx,arg2 |
words2reg ebx,arg1,arg2 |
dword2reg ecx,arg4 |
mov edx,lab |
mov esi,asd-lab ;calc size |
mov eax,4 |
int 0x40 |
} |
;Key's |
key_Up equ 178 |
key_Down equ 177 |
key_Right equ 179 |
key_Left equ 176 |
key_Esc equ 27 |
key_Space equ 32 |
key_Enter equ 13 |
key_Bspace equ 8 |
key_F1 equ 50 |
key_F2 equ 51 |
key_F3 equ 52 |
key_F4 equ 53 |
key_F5 equ 54 |
key_F6 equ 55 |
key_F7 equ 56 |
key_F8 equ 57 |
key_F9 equ 48 |
key_F10 equ 49 |
key_F11 equ 68 |
key_F12 equ 255 |
key_Home equ 180 |
key_End equ 181 |
key_PgUp equ 184 |
key_PgDown equ 183 |
;Attributes |
;Window Attributes |
window_Skinned equ 0x03000000 |
window_Type2 equ 0x02000000 |
window_Type1 equ 0x00000000 |
window_Reserve equ 0x01000000 |
;Font Attributes |
font_Big equ 0x10000000 |
;Colors |
cl_White equ 0x00ffffff |
cl_Black equ 0x00000000 |
cl_Grey equ 0x00888888 |
cl_Red equ 0x00ff0000 |
cl_Lime equ 0x0000ff00 |
cl_Green equ 0x0000af00 |
cl_Blue equ 0x000000ff |
cl_Purple equ 0x008080ff |
cl_Violet equ 0x008040ff |
cl_Cyan equ 0x0040e0ff |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/xpaint/trunk/ascml.inc |
---|
0,0 → 1,93 |
lang equ ru |
; |
; Assembler |
; SMALL |
; CODE |
; Massive operation |
; Libary |
; |
; Ver 0.1 By Pavlushin Evgeni (RUSSIA) |
; www.waptap@mail.ru |
;InfoList |
;0.01 readmas,compmas,findmas |
macro readmas masoff,obroff |
{ |
local loo |
mov edi,masoff |
add edi,8 |
mov ebp,[masoff] ;elements |
mov edx,[masoff+4] ;elemsize |
mov eax,0 ;count |
loo: |
pushad |
call obroff |
popad |
add edi,edx |
inc eax |
cmp eax,ebp |
jne loo |
} |
macro compmas masoff1,masoff2,obroff |
{ |
local loo,loo2 |
mov esi,masoff2 |
add esi,8 |
mov ecx,[masoff2] |
mov ebx,[masoff2+4] |
mov eax,0 |
loo2: |
push eax |
mov edi,masoff1 |
add edi,8 |
mov ebp,[masoff1] ;elements1 |
mov edx,[masoff1+4] ;elemsize1 |
mov eax,0 ;count |
loo: |
pushad |
call obroff |
popad |
add edi,edx |
inc eax |
cmp eax,ebp |
jne loo |
add esi,ebx |
pop eax |
inc eax |
cmp eax,ecx |
jne loo2 |
} |
macro findmas masoff,obroff |
{ |
local loo,looend,lend |
mov edi,masoff |
add edi,8 |
mov ebp,[masoff] ;elements |
mov edx,[masoff+4] ;elemsize |
mov eax,0 ;count |
loo: |
pushad |
mov eax,0 |
call obroff |
cmp eax,1 |
je looend |
popad |
add edi,edx |
inc eax |
cmp eax,ebp |
jne loo |
stc |
jmp lend |
looend: |
popad |
clc |
lend: |
} |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/xpaint/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm xpaint.asm xpaint |
@pause |
/programs/media/xpaint/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm xpaint.asm xpaint |
@pause |
/programs/media/xpaint/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a { ; mike.dld |
if ~a eq |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; language for programs |
lang fix ru ; ru en fr ge fi |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/media/xpaint/trunk/xpaint.asm |
---|
0,0 → 1,1706 |
; |
; Show Mini Sample by Pavlushin Evgeni for ASCL |
; www.waptap@mail.ru |
; |
;bits brushes(right mouse button)! |
;resize pucture(cross buttons)! |
;Open BMP MIA MHI grafic files! |
;Save as MIA MHI(zip from MHC -70% size)! |
;Support full files 800*600 |
;Open and save dialogs is work! |
; 27Ver Gif load support |
; 28Ver Dialogs is work |
;****************************************************************************** |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd IM_END ; size of image |
dd I_END ; memory for app |
dd I_END ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
;****************************************************************************** |
include 'lang.inc' |
include 'macros.inc' |
include 'ascl.inc' |
include 'ascgl.inc' |
hashtable equ MHC_END |
ifile equ MHC_END+65536*8 ;4 |
ofile equ (MHC_END+65536*8)+2000000 ;1000000 |
gif_hash_offset = ofile |
START: ; start of execution |
mov eax,40 |
mov ebx,0100111b |
int 0x40 |
; clear picture color White |
mov ecx,1024*768*3 |
mov eax,0xffffffff |
mov edi,image_area |
cld |
rep stosb |
call draw_window |
call setbrush |
rstill: |
mov eax,37 |
mov ebx,1 |
int 0x40 |
mov ebx,eax |
shr eax,16 ;x |
and ebx,0xffff ;y |
sub eax,5+6 |
sub ebx,22+30+6 |
cmp eax,640 ;for detect out of screen |
ja still |
cmp ebx,480 |
ja still |
mov [xt],ebx |
mov [yt],eax |
still: |
mov eax,40 |
mov ebx,0100111b |
int 0x40 |
wtevent red,key,button |
mov ebx,2 |
mov eax,37 |
int 0x40 |
cmp eax,1 |
je tescor ;if left button not pressed! |
cmp eax,2 |
je cbr ;if right button pressed! |
jmp rstill |
; jmp still |
cbr: |
cmp dword [brush],9 ;9 brush matrix |
jnae nocr |
mov [brush],-1 ;0 |
nocr: |
inc [brush] |
call setbrush |
jmp still |
;Set brush |
setbrush: |
mov eax,[brush] |
mov ebx,4*32 |
mul ebx |
mov ecx,4*32 |
mov esi,brushtable |
add esi,eax |
mov edi,matrix |
cld |
rep movsb |
delay 10 |
ret |
tescor: |
mov eax,37 |
mov ebx,1 |
int 0x40 |
mov ebx,eax |
shr eax,16 ;x |
and ebx,0xffff ;y |
sub eax,5+6 |
sub ebx,22+30+6 |
push eax |
push ebx |
mov ecx,eax ;[yt] |
mov edx,ebx ;[xt] |
mov eax,[xt] |
mov ebx,[yt] |
pop [xt] |
pop [yt] |
call line |
; mov [yt],eax |
; mov [xt],ebx |
call out_image |
jmp still |
red: |
call draw_window |
jmp still |
key: ; key |
int 0x40 ; read (eax=2) |
jmp still |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne noclose |
mov eax,-1 ; close this program |
int 0x40 |
noclose: |
cmp ah,10 |
jb no_palbut |
cmp ah,10+32;64 |
ja no_palbut |
mov ecx,0 |
mov cl,ah |
sub cl,10 |
shl ecx,2 |
mov ebx,[colortable+ecx] |
mov [color],ebx |
;Update color boxes |
drawfbox 20,32,20,15,[backcolor] |
drawfbox 12,28,20,15,[color] |
jmp still |
no_palbut: |
cmp ah,6 |
jne no_left |
mov esi,0 |
mov edi,0 |
mov ebp,[img_ysize] |
x_pls: |
mov ecx,0 |
mov edx,[img_xsize] |
x_pl: |
mov al,[image_area+edi+ecx] |
mov [image_area+esi+ecx],al |
mov al,[image_area+edi+ecx+1] |
mov [image_area+esi+ecx+1],al |
mov al,[image_area+edi+ecx+2] |
mov [image_area+esi+ecx+2],al |
add ecx,3 |
dec edx |
jnz x_pl |
add edi,[img_xsize] |
add edi,[img_xsize] |
add edi,[img_xsize] |
add esi,[img_xsize] |
add esi,[img_xsize] |
add esi,[img_xsize] |
sub esi,3 |
dec ebp |
jns x_pls |
dec [img_xsize] |
jmp red |
no_left: |
cmp ah,7 |
jne no_right |
mov eax,[img_xsize] |
mul [img_ysize] |
mov ebx,3 |
mul ebx |
mov edi,eax |
mov eax,[img_xsize] |
inc eax |
mul [img_ysize] |
mov ebx,3 |
mul ebx |
mov esi,eax |
; mov esi,0 |
; mov edi,0 |
mov ebp,[img_ysize] |
x_mns: |
mov ecx,[img_xsize] ;0 |
add ecx,[img_xsize] |
add ecx,[img_xsize] |
mov edx,[img_xsize] |
x_mn: |
mov al,[image_area+edi+ecx] |
mov [image_area+esi+ecx],al |
mov al,[image_area+edi+ecx+1] |
mov [image_area+esi+ecx+1],al |
mov al,[image_area+edi+ecx+2] |
mov [image_area+esi+ecx+2],al |
sub ecx,3 |
dec edx |
jnz x_mn |
mov dword [image_area+esi+ecx+0],0xffffffff |
sub edi,[img_xsize] |
sub edi,[img_xsize] |
sub edi,[img_xsize] |
sub esi,[img_xsize] |
sub esi,[img_xsize] |
sub esi,[img_xsize] |
sub esi,3 |
dec ebp |
jns x_mns |
inc [img_xsize] |
jmp red |
no_right: |
cmp ah,8 |
jne no_up |
dec [img_ysize] |
jmp red |
no_up: |
cmp ah,9 |
jne no_down |
inc [img_ysize] |
jmp red |
no_down: |
;SAVE MIA |
cmp ah,80 |
jne no_save |
savedialog draw_window, mia_is_save, still, string |
mia_is_save: |
mov dword [fileinfo],1 ;write |
mov eax,[img_xsize] |
mul [img_ysize] |
mov edx,eax |
add edx,eax |
add edx,eax |
add edx,8 |
cmp edx,1024*768*3+20000 |
ja still |
mov dword [fileinfo+12],image ;from read |
mov dword [fileinfo+8],edx ;1 |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
; puttxt 20,4,string,40,cl_White |
jmp still |
no_save: |
;OPEN MIA |
cmp ah,81 |
jne no_open |
opendialog draw_window, mia_is_open, still, string |
mia_is_open: |
mov dword [fileinfo],0 ;read |
mov dword [fileinfo+12],image ;from read |
mov dword [fileinfo+8],1 |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
mov eax,ebx |
shr eax,9 |
inc eax |
mov dword [fileinfo+8],eax |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
; puttxt 20,4,string,40,cl_White |
jmp red |
no_open: |
cmp ah,82 |
jne no_save_mhc |
savedialog draw_window, mhi_is_save, still, string |
mhi_is_save: |
call fill_filebufs |
mov eax,[img_xsize] |
mul [img_ysize] |
mov edx,eax |
add edx,eax |
add edx,eax |
add edx,8 |
mov ecx,edx |
mov esi,image |
mov edi,ifile |
cld |
rep movsb |
mov eax,edx |
call compress |
cmp edx,1024*768*3+20000 |
ja still |
mov dword [fileinfo],1 ;write |
mov dword [fileinfo+12],ofile ;from read |
mov dword [fileinfo+8],edx ;1 |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
; puttxt 20,4,string,40,cl_White |
jmp still |
no_save_mhc: |
;OPEN MHI |
cmp ah,83 |
jne no_open_mhc |
opendialog draw_window, mhi_is_open, still, string |
mhi_is_open: |
call fill_filebufs |
mov dword [fileinfo],0 ;read |
mov dword [fileinfo+12],ofile ;ofile for decompress |
mov dword [fileinfo+8],1 |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
push ebx ;push file size |
mov eax,ebx |
shr eax,9 |
inc eax |
mov dword [fileinfo+8],eax |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
; puttxt 20,4,string,40,cl_White |
; delay 100 |
pop eax ;pop file size |
call decompress |
mov ecx,edx |
mov esi,ifile ;image |
mov edi,image ;ifile |
cld |
rep movsb |
jmp red |
no_open_mhc: |
cmp ah,84 |
jne no_save_bmp |
jmp still |
no_save_bmp: |
cmp ah,85 |
jne no_open_bmp |
opendialog draw_window, bmp_is_open, still, string |
bmp_is_open: |
mov dword [fileinfo],0 ;read |
mov dword [fileinfo+12],MHC_END ;from read |
mov dword [fileinfo+8],1 |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
mov eax,[MHC_END+2] |
shr eax,9 |
inc eax |
mov dword [fileinfo+8],eax |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
; puttxt 20,4,string,40,cl_White |
bmptoimg MHC_END,image |
jmp red |
no_open_bmp: |
cmp ah,86 |
jne no_save_gif |
jmp still |
no_save_gif: |
cmp ah,87 |
jne no_open_gif |
opendialog draw_window, gif_is_open, still, string |
gif_is_open: |
mov dword [fileinfo],0 ;read |
mov dword [fileinfo+12],MHC_END ;from read |
mov dword [fileinfo+8],1 |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
mov eax,[MHC_END+2] |
shr eax,9 |
inc eax |
mov dword [fileinfo+8],eax |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
puttxt 20,4,string,40,cl_White |
giftoimg MHC_END,image |
jmp red |
no_open_gif: |
cmp ah,100 |
jne nor1 |
mov eax,[img_xsize] |
mul [img_ysize] |
mov edx,eax |
add edx,eax |
add edx,eax |
mov esi,image+8 |
norx: |
mov al,byte [esi+2] |
and al,01b ;10000000b |
cmp al,0 |
jna xe |
; mov al,255 |
mov byte [esi],0;255 |
mov byte [esi+1],0;0 |
mov byte [esi+2],255;0 |
jmp xa |
xe: |
mov byte [esi],255 |
mov byte [esi+1],255 |
mov byte [esi+2],255 |
xa: |
add esi,3 |
cmp esi,edx |
jnae norx |
jmp red |
nor1: |
jmp still |
fileinfo: |
dd 0 |
dd 0 |
dd 1 |
dd MHC_END |
dd out_image_area ;16384 |
string: |
times 256 db 0 |
;times 256 db 0 |
;times 256 db 0 |
;filename db "IMAGE MIA" |
;mhcfilename db "IMAGE MHI" |
soi dd 0 |
pxs dd 0 |
pys dd 0 |
out_image: |
mov eax,[prcinfo.x_size] |
sub eax,21 |
cmp eax,[img_xsize] ;640 |
jna no_x |
mov eax,[img_xsize] ;640 |
no_x: |
mov [pxs],eax |
mov eax,[prcinfo.y_size] |
sub eax,68 |
cmp eax,[img_ysize] ;480 |
jna no_y |
mov eax,[img_ysize] ;480 |
no_y: |
mov [pys],eax |
mov eax,[pxs] |
cmp eax,[img_xsize] ;640 |
jne trans |
mov eax,[pys] |
cmp eax,[img_ysize] ;480 |
jne trans |
mov eax,7 |
mov ebx,image_area |
mov ecx,[pxs] ;640 |
shl ecx,16 |
add ecx,[pys] ;480 |
mov edx,(5+6)*65536+(22+6+30) ;+30 Reserve for buttons |
int 0x40 |
ret |
trans: |
mov ebp,[pys]; 180 |
mov esi,image_area |
mov edi,out_image_area |
loox: |
mov ecx,[pxs] ;200*3 |
add ecx,[pxs] |
add ecx,[pxs] |
cld |
rep movsb |
mov eax,[img_xsize] ;640 |
sub eax,[pxs] |
add esi,eax |
add esi,eax |
add esi,eax |
dec ebp |
jnz loox |
mov eax,7 |
mov ebx,out_image_area |
mov ecx,[pxs] |
shl ecx,16 |
add ecx,[pys] |
mov edx,(5+6)*65536+(22+6+30) ;+30 Reserve for buttons |
int 0x40 |
ret |
;set put to massive |
puti: |
mov eax,edx |
mov ebx,ecx |
setput: |
pushad |
cmp eax,[img_xsize] ;640 |
jae nosetput |
cmp ebx,[img_ysize] ;480 |
jae nosetput |
mov edi,ebx |
mov ebx,3 ;x*3 |
mul ebx |
mov esi,eax |
mov eax,[img_xsize] ;640*3 ;Y*640*3 |
add eax,[img_xsize] |
add eax,[img_xsize] |
mov ebx,edi |
mul ebx |
add eax,esi |
mov ebp,[img_xsize] |
shl ebp,4 |
add ebp,16 |
mov esi,ebp |
add esi,ebp |
add esi,ebp |
sub eax,esi ;(16+640*16)*3 |
mov esi,0 |
mlix: |
push eax |
mov edi,[matrix+esi*4] |
mloo: |
shr edi,1 |
jnc nosp |
; cmp eax,640*480*3 ;for detect out of screen |
; jae nosp |
push eax |
mov eax,[img_xsize] |
mul [img_ysize] |
mov ebx,eax |
add ebx,eax |
add ebx,eax |
pop eax |
cmp eax,ebx |
jae nosp |
mov ebx,[color] |
mov byte [image_area+eax],bl ;0x00ff |
shr ebx,8 |
mov byte [image_area+eax+1],bl ;0x33 |
shr ebx,8 |
mov byte [image_area+eax+2],bl ;0x33 |
nosp: |
add eax,3 |
cmp edi,0 |
jne mloo |
pop eax |
add eax,[img_xsize] ;640*3 |
add eax,[img_xsize] |
add eax,[img_xsize] |
inc esi |
cmp esi,32 |
jnae mlix |
nosetput: |
popad |
ret |
matrix: |
times 32 dd 0 |
brushtable: |
;standart put |
times 12 dd 0 |
dd 00000000000000000000000000000000b |
dd 00000000000000000000000000000000b |
dd 00000000000000000000000000000000b |
dd 00000000000000000000000000000000b |
dd 00000000000000010000000000000000b |
dd 00000000000000000000000000000000b |
dd 00000000000000000000000000000000b |
dd 00000000000000000000000000000000b |
times 12 dd 0 |
;put size 2 |
times 12 dd 0 |
dd 00000000000000000000000000000000b |
dd 00000000000000000000000000000000b |
dd 00000000000000000000000000000000b |
dd 00000000000000000000000000000000b |
dd 00000000000000011000000000000000b |
dd 00000000000000011000000000000000b |
dd 00000000000000000000000000000000b |
dd 00000000000000000000000000000000b |
times 12 dd 0 |
;put size 3 |
times 12 dd 0 |
dd 00000000000000000000000000000000b |
dd 00000000000000000000000000000000b |
dd 00000000000000000000000000000000b |
dd 00000000000000111000000000000000b |
dd 00000000000000111000000000000000b |
dd 00000000000000111000000000000000b |
dd 00000000000000000000000000000000b |
dd 00000000000000000000000000000000b |
times 12 dd 0 |
;put size 4 |
times 12 dd 0 |
dd 00000000000000000000000000000000b |
dd 00000000000000000000000000000000b |
dd 00000000000000111000000000000000b |
dd 00000000000001111100000000000000b |
dd 00000000000001111100000000000000b |
dd 00000000000001111100000000000000b |
dd 00000000000000111000000000000000b |
dd 00000000000000000000000000000000b |
times 12 dd 0 |
;put slash ld-ru |
times 12 dd 0 |
dd 00000000000000000000000000000000b |
dd 00000000000000000010000000000000b |
dd 00000000000000000100000000000000b |
dd 00000000000000001000000000000000b |
dd 00000000000000010000000000000000b |
dd 00000000000000100000000000000000b |
dd 00000000000001000000000000000000b |
dd 00000000000010000000000000000000b |
times 12 dd 0 |
;put slash lu-rd |
times 12 dd 0 |
dd 00000000000000000000000000000000b |
dd 00000000000010000000000000000000b |
dd 00000000000001000000000000000000b |
dd 00000000000000100000000000000000b |
dd 00000000000000010000000000000000b |
dd 00000000000000001000000000000000b |
dd 00000000000000000100000000000000b |
dd 00000000000000000010000000000000b |
times 12 dd 0 |
;pricel |
times 8 dd 0 |
dd 00000000000000000000000000000000b |
dd 00000000000000010000000000000000b |
dd 00000000000000010000000000000000b |
dd 00000000000000010000000000000000b |
dd 00000000000000010000000000000000b |
dd 00000000000011111110000000000000b |
dd 00000000000010010010000000000000b |
dd 00000000000010000010000000000000b |
dd 00000000111111010111111000000000b |
dd 00000000000010000010000000000000b |
dd 00000000000010010010000000000000b |
dd 00000000000011111110000000000000b |
dd 00000000000000010000000000000000b |
dd 00000000000000010000000000000000b |
dd 00000000000000010000000000000000b |
dd 00000000000000010000000000000000b |
times 8 dd 0 |
;krest |
times 12 dd 0 |
dd 00000000000000000000000000000000b |
dd 00000000000010000010000000000000b |
dd 00000000000001000100000000000000b |
dd 00000000000000101000000000000000b |
dd 00000000000000010000000000000000b |
dd 00000000000000101000000000000000b |
dd 00000000000001000100000000000000b |
dd 00000000000010000010000000000000b |
times 12 dd 0 |
;krest |
times 12 dd 0 |
dd 00000000000000000000000000000000b |
dd 00000000000010000010000000000000b |
dd 00000000000000000000000000000000b |
dd 00000000000000000000000000000000b |
dd 00000000000000000000000000000000b |
dd 00000000000000000000000000000000b |
dd 00000000000000000000000000000000b |
dd 00000000000010000010000000000000b |
times 12 dd 0 |
;smile |
times 8 dd 0 |
dd 00000111110000000000000b |
dd 00011000001100000000000b |
dd 00100000000010000000000b |
dd 01000000000001000000000b |
dd 01000000000001000000000b |
dd 10001100011000100000000b |
dd 10001100011000100000000b |
dd 10000000000000100000000b |
dd 10000000000000100000000b |
dd 10010000000100100000000b |
dd 01001000001001000000000b |
dd 01000111110001000000000b |
dd 00100000000010000000000b |
dd 00011000001100000000000b |
dd 00000111110000000000000b |
dd 00000000000000000000000000000000b |
times 8 dd 0 |
;round |
dd 00000000000111111111100000000000b |
dd 00000000011000000000011000000000b |
dd 00000001100000000000000110000000b |
dd 00000010000000000000000001000000b |
dd 00000100000000000000000000100000b |
dd 00001000000000000000000000010000b |
dd 00010000000000000000000000001000b |
dd 00100000000000000000000000000100b |
dd 00100000000000000000000000000100b |
dd 01000000000000000000000000000010b |
dd 01000000000000000000000000000010b |
dd 10000000000000000000000000000001b |
dd 10000000000000000000000000000001b |
dd 10000000000000000000000000000001b |
dd 10000000000000000000000000000001b |
dd 10000000000000000000000000000001b |
dd 10000000000000000000000000000001b |
dd 10000000000000000000000000000001b |
dd 10000000000000000000000000000001b |
dd 10000000000000000000000000000001b |
dd 10000000000000000000000000000001b |
dd 01000000000000000000000000000010b |
dd 01000000000000000000000000000010b |
dd 00100000000000000000000000000100b |
dd 00100000000000000000000000000100b |
dd 00010000000000000000000000001000b |
dd 00001000000000000000000000010000b |
dd 00000100000000000000000000100000b |
dd 00000010000000000000000001000000b |
dd 00000001100000000000000110000000b |
dd 00000000011000000000011000000000b |
dd 00000000000111111111100000000000b |
;Draw line procedure |
line: |
jmp n |
previous_X dw -1 |
previous_Y dw -1 |
X_increment dw -1 |
Y_increment dw -1 |
n: |
push ax |
push bx |
push cx |
push dx |
pop cx ;yed |
pop dx ;xed |
pop [previous_Y] |
pop [previous_X] |
mov ax,cx |
sub ax,[previous_X] |
jns dx_pos |
neg ax |
mov [X_increment],1 |
jmp dx_neg |
dx_pos: mov [X_increment],-1 |
dx_neg: mov bx,dx |
sub bx,[previous_Y] |
jns dy_pos |
neg bx |
mov [Y_increment],1 |
jmp dy_neg |
dy_pos: mov [Y_increment],-1 |
dy_neg: shl ax,1 |
shl bx,1 |
pusha |
call puti |
popa |
cmp ax,bx |
jna dx_le_dy |
mov di,ax |
shr di,1 |
neg di |
add di,bx |
cycle: |
cmp cx,[previous_X] |
je exit_bres |
cmp di,0 |
jl fractlt0 |
add dx,[Y_increment] |
sub di,ax |
fractlt0: |
add cx,[X_increment] |
add di,bx |
pusha |
call puti |
popa |
jmp cycle |
dx_le_dy: |
mov di,bx |
shr di,1 |
neg di |
add di,ax |
cycle2: |
cmp dx,[previous_Y] |
je exit_bres |
cmp di,0 |
jl fractlt02 |
add cx,[X_increment] |
sub di,bx |
fractlt02: |
add dx,[Y_increment] |
add di,ax |
pusha |
call puti |
popa |
jmp cycle2 |
exit_bres: |
ret |
draw_window: |
startwd |
window 40,40,(586+8),(380+24),window_Skinned+0x00ffffff |
label 12,8,'2D EXAMPLE: ASCL XPAINT',cl_White+font_Big |
; Get proc info |
mov eax,9 |
mov ebx,prcinfo |
mov ecx,-1 |
int 0x40 |
mov eax,[prcinfo.x_size] |
mov ebp,[prcinfo.y_size] |
sub eax,5+4 |
sub ebp,22+4 |
drawfbox 5,22,eax,ebp,0x00e0f0f4 |
; call out_image |
; draw resize buttons |
mov eax,8 |
mov ebx,(341)*65536+9 |
mov ecx,(22+6+6)*65536+6 |
mov edx,6 ;start with 6 |
mov esi,0x00aaaaaa |
int 0x40 |
inc edx |
add ebx,15*65536 |
int 0x40 |
mov ebx,(340+10)*65536+6 |
mov ecx,(22+6-2)*65536+8 |
inc edx |
mov esi,0x00aaaaaa |
int 0x40 |
inc edx |
add ecx,14*65536 |
int 0x40 |
;Draw now and back color |
drawfbox 20,32,20,15,[backcolor] |
drawfbox 12,28,20,15,[color] |
;Draw buttons color set |
mov eax,8 |
mov ebx,(40+6)*65536+8 |
mov ecx,(22+6)*65536+8 |
mov edx,10 ;start with 10 |
mov edi,0 |
nextbut: |
mov esi,dword [colorbuttable+edi*4] |
int 0x40 |
add ecx,(10)*65536 |
inc edx |
inc edi |
mov esi,dword [colorbuttable+edi*4] |
int 0x40 |
sub ecx,(10)*65536 |
add ebx,(10)*65536 |
inc edx |
inc edi |
cmp edi,32 ;64 buttons, 2 string of 32 buttons |
jnae nextbut |
;Save as not ziped image button |
mov eax,8 |
mov ebx,(365+6)*65536+50 |
mov ecx,(22+6)*65536+8 |
mov edx,80 ;ID |
mov esi,cl_Grey |
int 0x40 |
label (365+7),(22+7),"SAVE MIA",cl_White |
;Open not zipped image button |
mov eax,8 |
mov ebx,(365+6)*65536+50 |
mov ecx,(36+6)*65536+8 |
mov edx,81 ;ID |
mov esi,cl_Grey |
int 0x40 |
label (365+7),(36+7),"OPEN MIA",cl_White |
;Save as MHC ziped image button |
mov eax,8 |
mov ebx,(420+6)*65536+50 |
mov ecx,(22+6)*65536+8 |
mov edx,82 ;ID |
mov esi,cl_Grey |
int 0x40 |
label (420+7),(22+7),"SAVE MHI",cl_White |
;Open MHC zipped image button |
mov eax,8 |
mov ebx,(420+6)*65536+50 |
mov ecx,(36+6)*65536+8 |
mov edx,83 ;ID |
mov esi,cl_Grey |
int 0x40 |
label (420+7),(36+7),"OPEN MHI",cl_White |
;Save as Bitmap image button |
mov eax,8 |
mov ebx,(475+6)*65536+50 |
mov ecx,(22+6)*65536+8 |
mov edx,84 ;ID |
mov esi,cl_Grey |
int 0x40 |
label (475+7),(22+7),"SAVE NOT",cl_White |
;Open Bitmap image button |
mov eax,8 |
mov ebx,(475+6)*65536+50 |
mov ecx,(36+6)*65536+8 |
mov edx,85 ;ID |
mov esi,cl_Grey |
int 0x40 |
label (475+7),(36+7),"OPEN BMP",cl_White |
;Save as GIF image button |
mov eax,8 |
mov ebx,(530+6)*65536+50 |
mov ecx,(22+6)*65536+8 |
mov edx,86 ;ID |
mov esi,cl_Grey |
int 0x40 |
label (530+7),(22+7),"SAVE NOT",cl_White |
;Open GIF image button |
mov eax,8 |
mov ebx,(530+6)*65536+50 |
mov ecx,(36+6)*65536+8 |
mov edx,87 ;ID |
mov esi,cl_Grey |
int 0x40 |
label (530+7),(36+7),"OPEN GIF",cl_White |
;Draw filter buttons |
mov eax,8 |
mov ebx,(590+6)*65536+6 |
mov ecx,(22+6)*65536+6 |
mov edx,100 ;start with 100 |
mov edi,0 |
nextfbut: |
mov esi,0x00aa0000 |
int 0x40 |
add ecx,(8)*65536 |
inc edx |
inc edi |
mov esi,0x0000aa00 |
int 0x40 |
add ecx,(8)*65536 |
inc edx |
inc edi |
mov esi,0x000000aa |
int 0x40 |
sub ecx,(8*2)*65536 |
add ebx,(8)*65536 |
inc edx |
inc edi |
cmp edi,8*3 ;24 buttons, 3 string of 8 buttons |
jnae nextfbut |
endwd |
call out_image |
ret |
; Get from MHC Archiver by Nikita Lesnikov |
; ======== compression/decompression engine ======== |
compress: ; File compression |
compress_filefound: |
jmp lzp_compress ; compress with order-2 LZP |
compress_dumpdata: |
ret |
decompress: ; File decompression |
decompress_filefound: |
cmp byte [ofile],0 ; Invalid method! |
jz right_method |
mov edx,0 ;0 size |
ret |
right_method: |
jmp lzp_decompress |
decompress_dumpdata: |
ret |
fill_filebufs: ; Fill filebufs with garbage to simplify matching |
pusha |
cld |
mov eax,0xF7D9A03F ; <- "magic number" :) just garbage... |
mov ecx,2000000/2 ;4 |
mov edi,ifile |
rep stosd |
popa |
ret |
; ==== algorithms section ==== |
; Method 0: LZP compression algorithm |
lzp_compress: ; EDX - how much bytes to dump |
cld ; clear direction flag |
mov esi,ifile ; init pointers |
mov edi,ofile |
push eax ; write header: ID0+4bfilesize => total 5 bytes |
xor eax,eax |
stosb |
pop eax |
stosd |
pusha ; fill hash table |
mov eax,ifile |
mov edi,hashtable |
mov ecx,65536*2 ;*1 |
rep stosd |
popa |
add eax,esi ; calculate endpointer |
mov dword [endpointer],eax |
movsw ; copy three bytes |
movsb |
mov dword [controlp],edi |
inc edi |
mov byte [controld],0 |
mov byte [controlb],0 |
c_loop: |
cmp dword [endpointer],esi ; check end of file |
ja c_loop_ok |
jmp finish_c_loop |
c_loop_ok: |
call chash |
call compare |
jz two_match_c |
lodsb |
mov byte [literal],al |
call chash |
call compare |
jz lit_match_c |
mov al,0 |
call putbit |
mov al,byte [literal] |
stosb |
movsb |
jmp end_c_loop |
lit_match_c: |
mov al,1 |
call putbit |
mov al,0 |
call putbit |
mov al,byte [literal] |
stosb |
jmp encode_match |
two_match_c: |
mov al,1 |
call putbit |
call putbit |
encode_match: |
call incpos |
call compare |
jz one_c |
mov al,0 |
call putbit |
jmp end_c_loop |
one_c: |
call incpos |
mov al,1 |
call putbit |
call compare |
jnz ec1 |
call incpos |
call compare |
jnz ec2 |
call incpos |
call compare |
jnz ec3 |
call incpos |
mov al,1 |
call putbit |
call putbit |
call compare |
jnz ec4 |
call incpos |
call compare |
jnz ec5 |
call incpos |
call compare |
jnz ec6 |
call incpos |
call compare |
jnz ec7 |
call incpos |
call compare |
jnz ec8 |
call incpos |
call compare |
jnz ec9 |
call incpos |
call compare |
jnz ec10 |
call incpos |
mov al,1 |
call putbit |
call putbit |
call putbit |
xor ecx,ecx |
match_loop_c: |
cmp esi,dword [endpointer] |
jae out_match_loop_c |
call compare |
jnz out_match_loop_c |
inc ecx |
call incpos |
jmp match_loop_c |
out_match_loop_c: |
mov al,0xFF |
out_lg: |
cmp ecx,255 |
jb out_lg_out |
stosb |
sub ecx,255 |
jmp out_lg |
out_lg_out: |
mov al,cl |
stosb |
jmp end_c_loop |
ec10: |
mov al,1 |
call putbit |
call putbit |
mov al,0 |
call putbit |
jmp end_c_loop |
ec9: |
mov al,1 |
call putbit |
mov al,0 |
call putbit |
mov al,1 |
call putbit |
jmp end_c_loop |
ec8: |
mov al,1 |
call putbit |
mov al,0 |
call putbit |
call putbit |
jmp end_c_loop |
ec7: |
mov al,0 |
call putbit |
mov al,1 |
call putbit |
call putbit |
jmp end_c_loop |
ec6: |
mov al,0 |
call putbit |
mov al,1 |
call putbit |
mov al,0 |
call putbit |
jmp end_c_loop |
ec5: |
mov al,0 |
call putbit |
call putbit |
mov al,1 |
call putbit |
jmp end_c_loop |
ec4: |
mov al,0 |
call putbit |
call putbit |
call putbit |
jmp end_c_loop |
ec3: |
mov al,1 |
call putbit |
mov al,0 |
call putbit |
jmp end_c_loop |
ec2: |
mov al,0 |
call putbit |
mov al,1 |
call putbit |
jmp end_c_loop |
ec1: |
mov al,0 |
call putbit |
call putbit |
end_c_loop: |
jmp c_loop |
finish_c_loop: |
mov eax,dword [controlp] ; store last tagbyte |
mov bl,byte [controld] |
mov [eax], byte bl |
sub edi,ofile ; calculate dump size |
mov edx,edi |
jmp compress_dumpdata |
; LZP decompression algorithm |
lzp_decompress: ; EDX - how much bytes to dump |
cld |
mov edi,ifile |
mov esi,ofile+1 |
pusha ; fill hash table |
mov eax,ifile |
mov edi,hashtable |
mov ecx,65536*2 ;*1 |
rep stosd |
popa |
lodsd |
mov ebx,edi |
add ebx,eax |
mov dword [endpointer],ebx |
movsw |
movsb |
lodsb |
mov byte [controld],al |
mov byte [controlb],0 |
d_loop: |
cmp dword [endpointer],edi |
ja d_loop_ok |
jmp finish_d_loop |
d_loop_ok: |
call getbit |
cmp al,0 |
jnz match_d |
call dhash |
movsb |
call dhash |
movsb |
jmp end_d_loop |
match_d: |
call getbit |
cmp al,0 |
jnz no_literal_before_match |
call dhash |
movsb |
no_literal_before_match: |
call dhash |
mov ecx,1 |
call copymatch |
call getbit |
cmp al,0 |
jz end_d_loop |
mov ecx,1 |
call copymatch |
call getbit |
cmp al,0 |
jz dc2 |
mov ecx,2 |
call copymatch |
call getbit |
cmp al,0 |
jz end_d_loop |
mov ecx,1 |
call copymatch |
call getbit |
cmp al,0 |
jz dc4 |
mov ecx,4 |
call copymatch |
call getbit |
cmp al,0 |
jz dc5 |
call getbit |
cmp al,0 |
jz dc6 |
mov ecx,3 |
call copymatch |
do: |
lodsb |
xor ecx,ecx |
mov cl,al |
call copymatch |
cmp al,0xFF |
jnz end_do |
jmp do |
end_do: |
jmp end_d_loop |
dc6: |
mov ecx,2 |
call copymatch |
jmp end_d_loop |
dc5: |
call getbit |
cmp al,0 |
jz ndc5 |
mov ecx,1 |
call copymatch |
ndc5: |
jmp end_d_loop |
dc4: |
call getbit |
cmp al,0 |
jz ndc4 |
call getbit |
mov ecx,3 |
cmp al,1 |
jz ndcc4 |
dec ecx |
ndcc4: |
call copymatch |
jmp end_d_loop |
ndc4: |
call getbit |
cmp al,0 |
jz ndccc4 |
mov ecx,1 |
call copymatch |
ndccc4: |
jmp end_d_loop |
dc2: |
call getbit |
cmp al,0 |
jz ndc2 |
mov ecx,1 |
call copymatch |
ndc2: |
end_d_loop: |
jmp d_loop |
finish_d_loop: |
mov edx, dword [ofile+1] |
jmp decompress_dumpdata |
; LZP subroutines |
putbit: ; bit -> byte tag, AL holds bit for output |
pusha |
mov cl,byte [controlb] |
shl al,cl |
mov bl,byte [controld] |
or bl,al |
mov byte [controld],bl |
inc cl |
cmp cl,8 |
jnz just_increment |
mov byte [controlb],0 |
mov byte [controld],0 |
push edi |
mov edi, dword [controlp] |
mov al,bl |
stosb |
pop edi |
mov dword [controlp],edi |
popa |
inc edi |
ret |
just_increment: |
mov byte [controlb],cl |
popa |
ret |
getbit: ; tag byte -> bit, AL holds input |
push ecx |
mov al,byte [controld] |
mov cl,byte [controlb] |
shr al,cl |
and al,1 |
inc cl |
cmp cl,8 |
jnz just_increment_d |
mov byte [controlb],0 |
push eax |
lodsb |
mov byte [controld],al |
pop eax |
pop ecx |
ret |
just_increment_d: |
mov byte [controlb],cl |
pop ecx |
ret |
chash: ; calculate hash -> mp -> fill position |
pusha |
xor eax,eax |
mov al, byte [esi-1] |
mov ah, byte [esi-2] |
shl eax,2 |
add eax,hashtable |
mov edx,dword [eax] |
mov dword [mp],edx |
mov dword [eax],esi |
popa |
ret |
dhash: ; calculate hash -> mp -> fill position |
pusha |
xor eax,eax |
mov al, byte [edi-1] |
mov ah, byte [edi-2] |
shl eax,2 |
add eax,hashtable |
mov edx,dword [eax] |
mov dword [mp],edx |
mov dword [eax],edi |
popa |
ret |
copymatch: ; ECX bytes from [mp] to [rp] |
push esi |
mov esi,dword [mp] |
rep movsb |
mov dword [mp],esi |
pop esi |
ret |
compare: ; compare [mp] with [cpos] |
push edi |
push esi |
mov edi,dword [mp] |
cmpsb |
pop esi |
pop edi |
ret |
incpos: |
inc dword [mp] |
inc esi |
ret |
; LZP algorithm data |
endpointer dd 0 |
controlp dd 0 |
controlb db 0 |
controld db 0 |
mp dd 0 |
literal db 0 |
; the end... - Nikita Lesnikov (nlo_one) |
; DATA AREA |
newline dd 0 |
xt dd 100 |
yt dd 100 |
counter dd 0 |
tsoi dd 0 |
view dd 0 |
brush dd 0 |
color dd 0x00000000 |
backcolor dd 0xffffff |
colortable: |
dd 0x00000000 ;black |
dd 0x00FFFFFF ;white |
dd 0x00808080 ;dark-gray |
dd 0x00C0C0C0 ;gray |
dd 0x00000080 ;dark-blue |
dd 0x000000ff ;blue |
dd 0x00400080 ;dark-violet |
dd 0x008000ff ;violet |
dd 0x00800080 ;dark-pink |
dd 0x00ff00ff ;pink |
dd 0x00800040 ; |
dd 0x00ff0080 ; |
dd 0x00800000 ;brown |
dd 0x00ff0000 ;red |
dd 0x00802000 ; |
dd 0x00ff4000 ;dark-orange |
dd 0x00804000 ; |
dd 0x00ff8000 ;orange |
dd 0x00804000 ; |
dd 0x00ff8000 ;orange |
dd 0x00808000 ;oliva |
dd 0x00ffff00 ;yellow |
dd 0x00608000 ; |
dd 0x00C0ff00 ; |
dd 0x00408000 ;green |
dd 0x0080ff00 ;lime |
dd 0x00008000 ; |
dd 0x0000ff00 ; |
dd 0x00008040 ;dark-salat |
dd 0x0000ff80 ;salat |
dd 0x00008080 ;dark-water |
dd 0x0000ffff ;water |
colorbuttable: |
dd 0x001e1e1e ;black |
dd 0x00dedede ;white |
dd 0x00808080 ;dark-gray |
dd 0x00C0C0C0 ;gray |
dd 0x001e1e80 ;dark-blue |
dd 0x001e1ede ;blue |
dd 0x00401e80 ;dark-violet |
dd 0x00801ede ;violet |
dd 0x00801e80 ;dark-pink |
dd 0x00de1ede ;pink |
dd 0x00801e40 ; |
dd 0x00de1e80 ; |
dd 0x00801e1e ;brown |
dd 0x00de1e1e ;red |
dd 0x0080201e ; |
dd 0x00de401e ;dark-orange |
dd 0x0080401e ; |
dd 0x00de801e ;orange |
dd 0x0080401e ; |
dd 0x00de801e ;orange |
dd 0x0080801e ;oliva |
dd 0x00dede1e ;yellow |
dd 0x0060801e ; |
dd 0x00C0de1e ; |
dd 0x0040801e ;green |
dd 0x0080de1e ;lime |
dd 0x001e801e ; |
dd 0x001ede1e ; |
dd 0x001e8040 ;dark-salat |
dd 0x001ede80 ;salat |
dd 0x00008080 ;dark-water |
dd 0x0000dede ;water |
prcinfo process_information |
;IM_END: |
image: |
img_xsize dd 200 |
img_ysize dd 180 |
IM_END: |
image_area: |
;rb 1024*768*3 |
out_image_area = image_area+(1024*768*3) |
;rb 640*480*3 |
MHC_END = image_area+(1024*768*3)*2 |
I_END = MHC_END+6000000 ;6 megs for work mhc algorythm |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/other/calc/trunk/calc.asm |
---|
87,7 → 87,6 |
mov esi,18 |
call atof |
fst [trans2] |
cmp eax,33 |
jne no_sign |
cmp [dsign],byte '-' |
/programs/other/calc/trunk/macros.inc |
---|
143,6 → 143,10 |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 178,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 222,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/other/archer/trunk/macros.inc |
---|
218,13 → 218,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/other/archer/trunk/build_en.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm @rcher.asm @rcher |
@erase lang.inc |
@pause |
/programs/other/archer/trunk/build_ru.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm @rcher.asm @rcher |
@erase lang.inc |
@pause |
/programs/other/rtfread/trunk/rtfread.asm |
---|
19,7 → 19,7 |
;RENDER equ BGI |
RENDER equ FREE |
BGIFONT_PATH equ '/rd/1/fonts/' |
BGIFONT_PATH equ '/rd/1/' |
FONT_NAME equ 'LITT' |
TOP =35 |
MODE equ RTF |
/programs/other/rtfread/trunk/macros.inc |
---|
143,6 → 143,11 |
; language for programs |
lang fix ru ; ru en fr ge fi |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 179,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 223,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/other/rtfread/trunk/build_en.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm rtfread.asm rtfread |
@erase lang.inc |
@pause |
/programs/other/rtfread/trunk/build_ru.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm rtfread.asm rtfread |
@erase lang.inc |
@pause |
/programs/other/mhc/trunk/build_ge.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix ge >lang.inc |
@fasm mhc.asm mhc |
@erase lang.inc |
@pause |
/programs/other/mhc/trunk/build_en.bat |
---|
1,5 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm mhc.asm mhc |
@erase lang.inc |
@pause |
/programs/other/mhc/trunk/macros.inc |
---|
143,6 → 143,10 |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 178,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 222,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/other/tinypad2/trunk/ascl.inc |
---|
0,0 → 1,929 |
; |
; Assembler |
; SMALL |
; CODE |
; Libary |
; |
; Ver 0.14 By Pavlushin Evgeni (RUSSIA) |
; www.waptap@mail.ru |
;Please compile aplications on FASM ver1.54 or higer!!! |
;InfoList |
;0.01 scank,putpix,puttxt |
;0.02 label,random,colors |
;0.03 window,startwd,endwd,attributes |
;0.04 close,delay,scevent ~30.04.2004 |
;0.05 small random, ~04.05.2004 |
;0.06 wtevent ~09.05.2004 |
;0.07 timeevent ~23.05.2004 |
;0.08 txtput ~14.06.2004 |
;0.09 opendialog,savedialog ~20.06.2004 |
;0.10 wordstoreg by halyavin, add at ~30.08.2004 |
; random bug deleted eax is use. |
;0.11 loadfile from me +puttxt bug del ~07.09.2004 |
;0.12 open/save dialog ~13.09.2004 |
;0.13 dialogs bugs deleted |
;0.14 drawlbut ~03.10.2004 |
;0.15 extendet label! |
; LOADFILE |
; (SYNTAX) LOADFILE 'full_path_to_file',file_load_area,file_temp_area |
; (SAMPLE) LOADFILE '/rd/1/clock.bmp',load_area,temp_area |
macro loadfile file_name,file_load_area,file_temp_area |
{ |
local open,fileinfo,string |
jmp open |
fileinfo: |
dd 0 |
dd 0 |
dd 1 |
dd file_load_area |
dd file_temp_area |
string: |
db file_name,0 |
open: |
mov dword [fileinfo+8],1 ; how many blocks to read (1) |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
mov eax,[file_load_area+2] |
shr eax,9 ; ¯®¤¥«¨¬ 512 ¨ ¯à¨¡ ¢¨¬ 1 - ¯®«ã稬 ç¨á«® ¡«®ª®¢ |
inc eax |
mov dword [fileinfo+8],eax |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
} |
;*********************************************************** |
macro savefile file_name,file_save_area,file_temp_area,fsize |
{ |
local save,fileinfo,string ;,counter00 |
jmp save |
;counter00 dd 0 |
fileinfo: |
dd 1 |
dd 0 |
dd fsize ;counter00 |
dd file_save_area |
dd file_temp_area |
string: |
db file_name,0 |
save: |
;xor edi,edi |
; sub edi,file_save_area ; calculate dump size |
; mov edx,edi |
;mov [counter00],edi |
; mov dword [fileinfo+8],1 ; how many blocks to write (1) |
; mov eax,58 |
; mov ebx,fileinfo |
; int 0x40 |
; mov eax,[file_load_area+2] |
; shr eax,9 ; ¯®¤¥«¨¬ 512 ¨ ¯à¨¡ ¢¨¬ 1 - ¯®«ã稬 ç¨á«® ¡«®ª®¢ |
; inc eax |
; mov dword [fileinfo+8],eax |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
} |
;*********************************************************** |
;macro wordstoreg reg,hiword,loword |
;{ |
;if hiword eqtype 0 & loword eqtype 0 |
; mov reg,dword hiword*65536+loword |
;else if hiword eqtype 12 & loword eqtype eax |
; mov reg,dword hiword*65536 |
; add reg,dword loword |
;else if hiword eqtype 12 & loword eqtype [123] |
; mov reg,dword hiword*65536 |
; add reg,dword loword |
;else |
; mov reg,dword hiword |
; shl reg,16 |
; add reg,dword loword |
;end if |
;} |
macro dword2reg reg,doubleword |
{ |
if doubleword eq |
; not changes |
else |
mov reg,dword doubleword |
end if |
} |
macro words2reg reg,hiword,lowword |
{ |
if hiword eq |
if lowword eq |
; not changes |
else |
if lowword eqtype 12 |
and reg,dword 0xffff0000 |
add reg,dword lowword |
else |
and reg,dword 0xffff0000 |
add reg,dword lowword |
end if |
end if |
else |
if lowword eq |
if hiword eqtype 12 |
and reg,dword 0x0000ffff |
add reg,dword hiword*65536 |
else |
shl reg,16 |
add reg,dword hiword |
ror reg,16 |
end if |
else |
if lowword eqtype 12 & hiword eqtype 12 |
if lowword eq 0 & hiword eq 0 |
xor reg,reg |
else |
mov reg,dword hiword*65536+lowword |
end if |
else |
mov reg,dword hiword |
shl reg,16 |
add reg,dword lowword |
end if |
end if |
end if |
} |
; DRAW BUTTON with label |
macro drawlbut x,y,xs,ys,text,id,bcolor,tcolor |
{ |
local asd,lab |
jmp asd |
lab db text ;arg label |
asd: |
words2reg ebx,x,xs |
words2reg ecx,y,ys |
mov edx,id |
mov esi,bcolor |
mov eax,8 |
int 0x40 |
mov eax,asd-lab ;calc size |
mov ebx,6 |
mul ebx |
mov esi,eax |
mov eax,xs |
sub eax,esi |
shr eax,1 |
add eax,x |
mov edx,ys |
sub edx,7 |
shr edx,1 |
add edx,y |
mov ebx,eax |
shl ebx,16 |
add ebx,edx |
mov ecx,tcolor ;arg4 color |
mov edx,lab |
mov esi,asd-lab ;calc size |
mov eax,4 |
int 0x40 |
} |
macro opendialog redproc,openoff,erroff,path |
{ |
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc |
local run_fileinfo, param |
local getmesloop, loox, mred, mkey, mbutton, mgetmes |
local dlg_is_work, ready, procinfo |
; |
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec, |
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save) |
; |
cld |
;; mov esi,path |
mov edi,path |
xor eax,eax |
mov ecx,(1024+16)/4 |
rep stosd |
;mov [get_loops],0 |
mov [dlg_pid_get],0 |
; Get my PID in dec format 4 bytes |
mov eax,9 |
mov ebx,procinfo |
mov ecx,-1 |
int 0x40 |
; convert eax bin to param dec |
mov eax,dword [procinfo+30] ;offset of myPID |
mov edi,param+4-1 ;offset to 4 bytes |
mov ecx,4 |
mov ebx,10 |
cld |
new_d: |
xor edx,edx |
div ebx |
add dl,'0' |
mov [edi],dl |
dec edi |
loop new_d |
; wirite 1 byte space to param |
mov [param+4],byte 32 ;Space for next parametr |
; and 1 byte type of dialog to param |
mov [param+5],byte 'O' ;Get Open dialog (Use 'S' for Save dialog) |
; |
; STEP2 prepare IPC area for get messages |
; |
; prepare IPC area |
mov [path],dword 0 |
mov [path+4],dword 8 |
; define IPC memory |
mov eax,60 |
mov ebx,1 ; define IPC |
mov ecx,path ; offset of area |
mov edx,1024+16 ; size |
int 0x40 |
; change wanted events list 7-bit IPC event |
mov eax,40 |
mov ebx,01000111b |
int 0x40 |
; |
; STEP 3 run SYSTEM XTREE with parameters |
; |
mov eax,70 |
mov ebx,run_fileinfo |
int 0x40 |
call redproc |
mov [get_loops],0 |
getmesloop: |
mov eax,23 |
mov ebx,50 ;0.5 sec |
int 0x40 |
dec eax |
jz mred |
dec eax |
jz mkey |
dec eax |
jz mbutton |
cmp al, 7-3 |
jz mgetmes |
; Get number of procces |
mov ebx,procinfo |
mov ecx,-1 |
mov eax,9 |
int 0x40 |
mov ebp,eax |
loox: |
mov eax,9 |
mov ebx,procinfo |
mov ecx,ebp |
int 0x40 |
mov eax,[DLGPID] |
cmp [procinfo+30],eax ;IF Dialog find |
je dlg_is_work ;jmp to dlg_is_work |
dec ebp |
jnz loox |
jmp erroff |
dlg_is_work: |
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated |
je erroff ;TESTODP2 terminated too |
cmp [dlg_pid_get],dword 1 |
je getmesloop |
inc [get_loops] |
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated |
jae erroff |
jmp getmesloop |
mred: |
call redproc |
jmp getmesloop |
mkey: |
mov eax,2 |
int 0x40 ; read (eax=2) |
jmp getmesloop |
mbutton: |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne getmesloop |
mov eax,-1 ; close this program |
int 0x40 |
mgetmes: |
; If dlg_pid_get then second message get jmp to still |
cmp [dlg_pid_get],dword 1 |
je ready |
; First message is number of PID SYSXTREE dialog |
; convert PID dec to PID bin |
movzx eax,byte [path+16] |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+1] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+2] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+3] |
add eax,ebx |
sub eax,48 |
mov [DLGPID],eax |
; Claear and prepare IPC area for next message |
mov [path],dword 0 |
mov [path+4],dword 8 |
mov [path+8],dword 0 |
mov [path+12],dword 0 |
mov [path+16],dword 0 |
; Set dlg_pid_get for get next message |
mov [dlg_pid_get],dword 1 |
call redproc ;show DLG_PID |
jmp getmesloop |
ready: |
; |
; The second message get |
; Second message is 100 bytes path to SAVE/OPEN file |
; shl path string on 16 bytes |
; |
cld |
mov esi,path+16 |
mov edi,path |
mov ecx,1024/4 |
rep movsd |
mov [edi],byte 0 |
jmp openoff |
; DATA AREA |
get_loops dd 0 |
dlg_pid_get dd 0 |
DLGPID dd 0 |
param: |
dd 0 ; My dec PID |
dd 0,0 ; Type of dialog |
run_fileinfo: |
dd 7 |
dd 0 |
dd param |
dd 0 |
dd 0 |
;run_filepath |
db '/RD/1/SYSXTREE',0 |
procinfo: |
times 1024 db 0 |
} |
macro savedialog redproc,openoff,erroff,path |
{ |
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc |
local run_fileinfo, run_filepath, param |
local getmesloop, loox, mred, mkey, mbutton, mgetmes |
local dlg_is_work, ready, procinfo |
; |
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec, |
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save) |
; |
cld |
;; mov esi,path |
mov edi,path |
xor eax,eax |
mov ecx,(1024+16)/4 |
rep stosd |
;mov [get_loops],0 |
mov [dlg_pid_get],0 |
; Get my PID in dec format 4 bytes |
mov eax,9 |
mov ebx,procinfo |
mov ecx,-1 |
int 0x40 |
; convert eax bin to param dec |
mov eax,dword [procinfo+30] ;offset of myPID |
mov edi,param+4-1 ;offset to 4 bytes |
mov ecx,4 |
mov ebx,10 |
cld |
new_d: |
xor edx,edx |
div ebx |
add dl,'0' |
mov [edi],dl |
dec edi |
loop new_d |
; wirite 1 byte space to param |
mov [param+4],byte 32 ;Space for next parametr |
; and 1 byte type of dialog to param |
mov [param+5],byte 'S' ;Get Open dialog (Use 'S' for Save dialog) |
; |
; STEP2 prepare IPC area for get messages |
; |
; prepare IPC area |
mov [path],dword 0 |
mov [path+4],dword 8 |
; define IPC memory |
mov eax,60 |
mov ebx,1 ; define IPC |
mov ecx,path ; offset of area |
mov edx,1024+16 ; size |
int 0x40 |
; change wanted events list 7-bit IPC event |
mov eax,40 |
mov ebx,01000111b |
int 0x40 |
; |
; STEP 3 run SYSTEM XTREE with parameters |
; |
mov eax,70 |
mov ebx,run_fileinfo |
int 0x40 |
call redproc |
mov [get_loops],0 |
getmesloop: |
mov eax,23 |
mov ebx,50 ;0.5 sec |
int 0x40 |
dec eax |
jz mred |
dec eax |
jz mkey |
dec eax |
jz mbutton |
cmp al, 7-3 |
jz mgetmes |
; Get number of procces |
mov ebx,procinfo |
mov ecx,-1 |
mov eax,9 |
int 0x40 |
mov ebp,eax |
loox: |
mov eax,9 |
mov ebx,procinfo |
mov ecx,ebp |
int 0x40 |
mov eax,[DLGPID] |
cmp [procinfo+30],eax ;IF Dialog find |
je dlg_is_work ;jmp to dlg_is_work |
dec ebp |
jnz loox |
jmp erroff |
dlg_is_work: |
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated |
je erroff ;TESTODP2 terminated too |
cmp [dlg_pid_get],dword 1 |
je getmesloop |
inc [get_loops] |
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated |
jae erroff |
jmp getmesloop |
mred: |
call redproc |
jmp getmesloop |
mkey: |
mov eax,2 |
int 0x40 ; read (eax=2) |
jmp getmesloop |
mbutton: |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne getmesloop |
mov eax,-1 ; close this program |
int 0x40 |
mgetmes: |
; If dlg_pid_get then second message get jmp to still |
cmp [dlg_pid_get],dword 1 |
je ready |
; First message is number of PID SYSXTREE dialog |
; convert PID dec to PID bin |
movzx eax,byte [path+16] |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+1] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+2] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+3] |
add eax,ebx |
sub eax,48 |
mov [DLGPID],eax |
; Claear and prepare IPC area for next message |
mov [path],dword 0 |
mov [path+4],dword 8 |
mov [path+8],dword 0 |
mov [path+12],dword 0 |
mov [path+16],dword 0 |
; Set dlg_pid_get for get next message |
mov [dlg_pid_get],dword 1 |
call redproc ;show DLG_PID |
jmp getmesloop |
ready: |
; |
; The second message get |
; Second message is 100 bytes path to SAVE/OPEN file |
; shl path string on 16 bytes |
; |
cld |
mov esi,path+16 |
mov edi,path |
mov ecx,1024/4 |
rep movsd |
mov [edi],byte 0 |
jmp openoff |
; DATA AREA |
get_loops dd 0 |
dlg_pid_get dd 0 |
DLGPID dd 0 |
param: |
dd 0 ; My dec PID |
dd 0,0 ; Type of dialog |
run_fileinfo: |
dd 7 |
dd 0 |
dd param |
dd 0 |
dd 0 |
;run_filepath: |
db '/RD/1/SYSXTREE',0 |
procinfo: |
times 1024 db 0 |
} |
; RANDOM - generate random count (small) |
; (SYNTAX) RANDOM MaxCount,OutArgument |
; (SAMPLE) RANDOM 10000,eax |
; ( NOTE ) Maxint<65536 ; use random 65536,eax for more combinations |
randomuse = 0 |
macro random arg1,arg2 |
{ |
local rxproc |
randomuse = randomuse + 1 |
jmp rxproc |
if defined randomuse & randomuse = 1 |
randomproc: |
jmp rnj |
rsx1 dw 0x4321 |
rsx2 dw 0x1234 |
rnj: |
; mov eax,arg1 |
push bx |
push cx |
push dx |
push si |
push di |
mov cx,ax |
mov ax,word ptr rsx1 |
mov bx,word ptr rsx2 |
mov si,ax |
mov di,bx |
mov dl,ah |
mov ah,al |
mov al,bh |
mov bh,bl |
xor bl,bl |
rcr dl,1 |
rcr ax,1 |
rcr bx,1 |
add bx,di |
adc ax,si |
add bx,0x62e9 |
adc ax,0x3619 |
mov word ptr rsx1,bx |
mov word ptr rsx2,ax |
xor dx,dx |
cmp ax,0 |
je nodiv |
cmp cx,0 |
je nodiv |
div cx |
nodiv: |
mov ax,dx |
pop di |
pop si |
pop dx |
pop cx |
pop bx |
and eax,0000ffffh |
; mov arg2,0 |
; mov arg2,eax |
ret |
end if |
rxproc: |
mov eax,arg1 |
call randomproc |
mov arg2,eax |
} |
macro scank |
{ |
mov eax,10 |
int 0x40 |
} |
macro putpix x,y,color |
{ |
mov ebx,x |
mov ecx,y |
mov edx,color |
mov eax,1 |
int 0x40 |
} |
macro puttxt x,y,offs,size,color |
{ |
; mov ebx,x |
; shl ebx,16 |
; add ebx,y |
words2reg ebx,x,y |
dword2reg ecx,color |
dword2reg edx,offs |
dword2reg esi,size |
; mov ecx,color |
; mov edx,offs |
; mov esi,size |
mov eax,4 |
int 0x40 |
} |
macro outcount data, x, y, color, numtype |
{ |
mov ecx,data |
mov ebx,numtype |
mov bl,0 |
; mov edx,x*65536+y |
words2reg edx,x,y |
mov esi,color |
mov eax,47 |
int 0x40 |
} |
; SCEVENT - Scan event |
macro scevent red,key,but |
{ |
mov eax,11 |
int 0x40 |
dec eax |
jz red |
dec eax |
jz key |
dec eax |
jz but |
} |
; WTEVENT - Wait event |
macro wtevent red,key,but |
{ |
mov eax,10 |
int 0x40 |
dec eax |
jz red |
dec eax |
jz key |
dec eax |
jz but |
} |
; TIMEEVENT - Wite for event with timeout |
macro timeevent xfps,noevent,red,key,but |
{ |
mov eax,23 |
mov ebx,xfps |
int 0x40 |
cmp eax,0 |
je noevent |
dec eax |
jz red |
dec eax |
jz key |
dec eax |
jz but |
} |
; CLOSE - Close program |
macro close |
{ |
mov eax,-1 |
int 0x40 |
} |
; DELAY - Create delay 1/100 sec |
; (SYNTAX) Delay time |
; (SAMPLE) Delay 100 ;delay 2 sec 1/100*200=2 sec |
macro delay arg1 |
{ |
mov eax,5 |
mov ebx,arg1 |
int 0x40 |
} |
; WINDOW - Draw window |
; (SYNTAX) WINDOW Xstart,Ystart,'Text',Color |
; (SAMPLE) WINDOW 10,10,640+8,480+24,window_Skinned |
macro window arg1,arg2,arg3,arg4,arg5 |
{ |
; mov ebx,arg1*65536+arg3 |
; mov ecx,arg2*65536+arg4 |
words2reg ebx,arg1,arg3 |
words2reg ecx,arg2,arg4 |
mov edx,arg5 |
mov eax,0 |
int 0x40 |
} |
macro colorwindow arg1,arg2,arg3,arg4,arg5,arg6,arg7 |
{ |
; mov ebx,arg1*65536+arg3 |
; mov ecx,arg2*65536+arg4 |
words2reg ebx,arg1,arg3 |
words2reg ecx,arg2,arg4 |
mov edx,arg5 |
mov esi,arg6 |
mov edi,arg7 |
mov eax,0 |
int 0x40 |
} |
; STARTWD - Start of window draw |
macro startwd |
{ |
mov eax,12 |
mov ebx,1 |
int 0x40 |
} |
; ENDWD - End window draw |
macro endwd |
{ |
mov eax,12 |
mov ebx,2 |
int 0x40 |
} |
; LABEL - Put text to frame |
; (SYNTAX) LABEL Xstart,Ystart,'Text',Color |
; (SAMPLE) LABEL 10,12,'Hello World!',cl_Green+font_Big |
macro putlabel arg1,arg2,arg3,arg4 |
{ |
local asd,lab |
jmp asd |
lab db arg3 ;arg label |
asd: |
; mov ebx,arg1 ;arg1=y arg2=x |
; shl ebx,16 |
; add ebx,arg2 |
words2reg ebx,arg1,arg2 |
dword2reg ecx,arg4 |
mov edx,lab |
mov esi,asd-lab ;calc size |
mov eax,4 |
int 0x40 |
} |
;Key's |
key_Up equ 178 |
key_Down equ 177 |
key_Right equ 179 |
key_Left equ 176 |
key_Esc equ 27 |
key_Space equ 32 |
key_Enter equ 13 |
key_Bspace equ 8 |
key_F1 equ 50 |
key_F2 equ 51 |
key_F3 equ 52 |
key_F4 equ 53 |
key_F5 equ 54 |
key_F6 equ 55 |
key_F7 equ 56 |
key_F8 equ 57 |
key_F9 equ 48 |
key_F10 equ 49 |
key_F11 equ 68 |
key_F12 equ 255 |
key_Home equ 180 |
key_End equ 181 |
key_PgUp equ 184 |
key_PgDown equ 183 |
;Attributes |
;Window Attributes |
window_Skinned equ 0x03000000 |
window_Type2 equ 0x02000000 |
window_Type1 equ 0x00000000 |
window_Reserve equ 0x01000000 |
;Font Attributes |
font_Big equ 0x10000000 |
;Colors |
cl_White equ 0x00ffffff |
cl_Black equ 0x00000000 |
cl_Grey equ 0x00888888 |
cl_Red equ 0x00ff0000 |
cl_Lime equ 0x0000ff00 |
cl_Green equ 0x0000af00 |
cl_Blue equ 0x000000ff |
cl_Purple equ 0x008080ff |
cl_Violet equ 0x008040ff |
cl_Cyan equ 0x0040e0ff |
/programs/other/tinypad2/trunk/tinypad2.asm |
---|
0,0 → 1,4093 |
; SYSTEM HEADER: |
use32 |
org 0x0 |
db 'MENUET01' ; identifier |
dd 0x01 ; version |
dd START ; pointer to start |
dd TINYPAD_END ; size of file |
dd 0x300f00 ;0x500000; 0x3fff00;0x300000 ; size of memory |
dd 0xeff0 ;0x4fffff ;0x3ff000;0xeff0 ; esp |
dd I_PARAM ; parameters |
dd 0 ; reserved |
include 'ascl.inc' |
include 'lang.inc' |
include 'macros.inc' ; useful stuff |
include 'dialogs1.inc' |
include 'scroll.inc' |
include 'debug.inc' |
purge mov ; SPEED |
;****************************************************************************** |
; INITIALIZING |
START: |
;debug_print_hex TINYPAD_END |
call mask_events |
cmp [I_PARAM],byte 0 |
jz noparams |
;//Willow |
cmp byte[I_PARAM],'*' |
jne .noipc |
; convert size from decimal representation to dword |
mov esi, I_PARAM+1 |
xor edx, edx |
xor eax, eax |
@@: |
lodsb |
test al, al |
jz @f |
lea edx, [edx*4+edx] |
lea edx, [edx*2+eax] |
jmp @b |
@@: |
add edx,20 |
mcall 60,1,0x10000-16 |
mov dword[0x10000+-16+4],8 |
mcall 40,1000000b |
mcall 23,200 |
; dpd eax |
cmp eax,7 |
jne exit_now |
mov esi,0x10000-16 |
mov byte[esi],1 |
call mask_events |
mov eax,[esi+12] |
inc eax |
call file_found |
jmp do_load_file.restorecursor |
.noipc: |
;//Willow |
; parameters are at I_PARAM |
mov esi,I_PARAM |
mov edi,filename |
mov ecx,50 |
cld |
rep movsb |
mov edi,filename |
mov ecx,50 |
xor eax,eax |
repne scasb |
sub edi,filename |
dec edi |
mov [filename_len],edi |
jmp do_load_file |
noparams: |
jmp newfile |
;****************************************************************************** |
; MAIN LOOP |
still: |
call writepos ; write current position & number of strings |
call mouse_info |
mov eax,10 ; wait here until event |
int 0x40 |
cmp eax,1 |
je red |
cmp eax,2 |
je key |
cmp eax,3 |
je button |
cmp eax,6 |
je mouse |
jmp still |
;****************************************************************************** |
; ********************************* |
; * MOUSE * |
; ********************************* |
mouse: |
mov eax,37 ;mouse click |
mov ebx,2 |
int 0x40 |
cmp eax,0 |
je .leave_now |
;if exit window is on |
cmp [exit_wnd_on],1 |
jne @f |
mov [exit_wnd_on],0 |
jmp red |
;else |
@@: |
cmp eax,1 ;mouse 1 |
jne .leave_now |
mov eax,37 ;mouse position |
mov ebx,1 |
int 0x40 |
mov word[mouse_y],ax |
shr eax,16 |
mov word[mouse_x],ax |
cmp [mouse_x],7 |
jb .leave_now ;.leave_now ;if < |
cmp [mouse_x],485;487 |
ja .leave_now ;.leave_now ;if > |
cmp [mouse_y],45 |
jb .leave_now ;.leave_now ;if < |
cmp [mouse_y],342 ;345 |
ja .leave_now ;.leave_now ;if > |
call main_cursor_move |
.leave_now: |
jmp still |
; ********************************* |
; * BUTTON HANDLER * |
; ********************************* |
button: |
mov eax,17 |
int 0x40 |
;;;;;;;;;;;;;;;exit dialog box check;;;;;;;;;;;;; |
cmp ah,49 |
je save_and_exit |
cmp ah,48 |
je exit_now |
cmp ah,47 |
mov [exit_wnd_on],0 |
je red |
cmp ah,46 |
jne @f |
call save_file |
jmp newfile |
@@: |
cmp ah,45 |
je newfile |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;;;;;;;;;;;;;;;;MENU CHECK;;;;;;;;;;;;;;;;;;;;;;; |
cmp ah,15 |
jne no_d_w |
call draw_window_for_dialogs |
jmp still |
no_d_w: |
cmp ah,97 |
je draw_win_menu_file |
cmp ah,98 |
je draw_win_menu_code |
cmp ah,96 |
je draw_win_menu_text |
cmp ah,95 |
je goto_string |
cmp ah,92 |
je search_window |
cmp ah,94 |
je red |
cmp ah,99 |
je help_wnd |
cmp ah,100 |
je new_pad_wnd |
cmp ah,101 |
je doyouwannasave |
cmp ah,102 |
jne nosavenow |
for_key_save: |
savedialog draw_window_for_dialogs,copy_fpath_s,saveerror,mypath |
nosavenow: |
cmp ah,103 |
jne noopennow |
for_key_open: |
opendialog draw_window_for_dialogs,copy_fpath,openerror,mypath |
noopennow: |
cmp ah,104 |
je exit |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
shr eax,8 |
cmp al,50 |
jne no_search |
; SEARCH { |
search: |
cmp [lines],1 ;something like bug fix |
je red ;still |
xor esi,esi |
mov edi,[post] |
add edi,80 |
imul ecx,[lines],80 |
sub ecx,edi ; ecx (loop counter) = lines*80-(post+80) |
news: |
push edi |
news2: |
; 1) LOAD BYTES |
mov al,[esi+search_string] |
mov bl,[edi+0x80000] |
; 2) COMPARE BYTES |
cmp al,bl |
je yes_char |
; 3) LETTER? |
cmp al,'A' |
jb notequal |
cmp al,'z' |
ja notequal |
; 4) A->a OR a->A |
cmp al,'a' |
jb @f |
add al,-32 |
jmp compare_bytes |
@@: |
cmp al,'Z' |
ja notequal |
add al,32 |
compare_bytes: |
cmp al,bl |
jne notequal |
yes_char: |
inc edi |
inc esi |
cmp esi,[search_len] |
jge sfound |
jmp news2 |
notequal: |
pop edi |
xor esi,esi |
inc edi |
loop news |
call string_not_found |
jmp still |
sfound: |
mov eax,edi |
cdq ; edx = 0; |
mov ebx,80 |
div ebx |
;;;;; imul eax,80 |
; lea eax,[eax+eax*4] ; eax *= 5; |
; shl eax,4 ; eax *= 16; |
; mov [post],eax |
mov [posy],0 |
;--------------- |
; mov ebx,80 |
; div ebx |
call goto_pos |
call draw_vertical_scroll |
jmp still |
; SEARCH } |
no_search: |
; TOOLBAR { |
cmp eax,10000 |
jb no_toolbar |
add eax,-10000 |
jne @f |
lbl_compile_file: |
mov [run_outfile],0 |
call start_fasm |
jmp still |
@@: |
dec eax |
jnz @f |
lbl_run_outfile: |
mov [run_outfile],1 |
call start_fasm |
jmp still |
@@: |
dec eax |
jnz @f |
call open_debug_board |
jmp still |
@@: |
dec eax |
jnz still |
call open_sysfuncs_txt |
jmp still |
; TOOLBAR } |
no_toolbar: |
cmp al,4 |
jne noid4 |
; LOAD_FILE { |
do_load_file: |
mov [modified],0 |
call empty_work_space |
cmp [filename],'/' |
jne @f |
call loadhdfile |
jmp .restorecursor |
@@: |
call loadfile1 |
.restorecursor: |
mov edi,0x78000 |
mov ecx,80*80/4 |
mov eax,0x01010101 |
cld |
rep stosd |
xor eax,eax |
mov [post],eax |
mov [posx],eax |
mov [posy],eax |
; enable color syntax for ASM and INC files: |
mov [asm_mode], 0 |
mov eax, [filename_len] |
add eax, filename |
cmp word [eax-3],'AS' |
jne @f |
cmp byte [eax-1],'M' |
jne @f |
mov [asm_mode], 1 |
jmp .nocol |
@@: |
cmp word [eax-3],'IN' |
jne @f |
cmp byte [eax-1],'C' |
jne @f |
mov [asm_mode], 1 |
@@: |
.nocol: |
; if the header is the same as the previous, |
; just redraw the text area |
; else redraw the window |
;------pos00=filename_len |
mov eax,[filename_len] |
mov [pos00],eax |
;------------------------- |
mov ecx, [filename_len] |
add ecx, 10 ; strlen(" - TINYPAD"); |
cmp ecx, [headlen] |
jne @f |
add ecx, -10 |
mov esi, filename ; strcmp(filename,header); |
mov edi, header |
rep cmpsb |
jne @f |
call drawfile |
call draw_window_for_dialogs ;redraw, because it's needed |
cmp [to_return],0 |
je still |
ret |
;jmp still |
@@: |
call set_title |
cmp [to_return],0 |
je still |
ret |
; jmp still |
; LOAD_FILE } |
noid4: |
cmp al, 2 |
jz yessave |
dec al ; close if butid == 0 |
jnz nosave |
; EXIT: |
exit: |
cmp [modified],0 |
je exit_now |
mov eax,55 ; beep |
mov ebx,eax |
mov esi,save_beep1 |
int 0x40 |
delay 4 |
mov eax,55 ; beep |
mov ebx,eax |
mov esi,save_beep2 |
int 0x40 |
;---------"EXIT" dialog box |
mov eax,13 |
mov ebx,150*65536+200 |
mov ecx,100*65536+70 |
mov edx,[sc.work_graph] ;0x00dd9438 ;0x00ff7512 |
int 0x40 |
mov eax,38 |
mov ebx,150*65536+350 |
mov ecx,100*65536+100 |
mov edx,cl_White |
int 0x40 |
mov eax,38 |
mov ebx,150*65536+350 |
mov ecx,170*65536+170 |
mov edx,cl_White |
int 0x40 |
mov eax,38 |
mov ebx,150*65536+150 |
mov ecx,100*65536+170 |
mov edx,cl_White |
int 0x40 |
mov eax,38 |
mov ebx,350*65536+350 |
mov ecx,100*65536+170 |
mov edx,cl_White |
int 0x40 |
if lang eq ru |
putlabel 190,120,'®åà ¨âì ¤®ªã¬¥â?',cl_White |
drawlbut 170,140,30,15,' ',49,[sc.work_button],cl_White |
drawlbut 230,140,30,15,'¥â',48,[sc.work_button],cl_White |
drawlbut 290,140,45,15,'⬥ ',47,[sc.work_button],cl_White |
else |
putlabel 190,120,'Save the document?',cl_White |
drawlbut 170,140,30,15,'Yes',49,[sc.work_button],cl_White |
drawlbut 230,140,30,15,'No',48,[sc.work_button],cl_White |
drawlbut 290,140,45,15,'Cancel',47,[sc.work_button],cl_White |
end if |
mov [exit_wnd_on],1 |
;---------------- |
jmp still |
exit_now: |
mov [MainWndClosed], 1 |
or eax, -1 |
int 0x40 |
save_and_exit: |
call save_file |
jmp exit_now |
; mov [MainWndClosed], 1 |
; or eax, -1 |
; int 0x40 |
; SAVE_FILE { |
yessave: |
call clear_screen |
call drawwindow |
call save_file |
; call clear_screen |
; call drawwindow |
mov [modified],0 |
jmp still |
; SAVE_FILE } |
nosave: |
inc al |
call read_string |
jmp still |
;********************************** |
;* REDRAW HANDLER * |
;********************************** |
red: |
; ¯¥à¥à¨á®¢ª ®ª |
call clear_screen |
call drawwindow |
jmp still |
;********************************** |
;* KEY HANDLER * |
;********************************** |
key: |
mov eax, 2 ; GET KEY |
int 0x40 |
cmp [exit_wnd_on],1 ;exit window is ON? |
jne no_exit_wnd ; no - goto other checks |
; cmp eax,13 ;enter - save n exit |
; je save_and_exit |
; cmp eax,173 ;ctrl+enter - exit |
; je exit_now |
mov [exit_wnd_on],0 ;other keys - cancel |
; call draw_window_for_dialogs |
jmp red ;redraw and still |
no_exit_wnd: |
shr eax, 8 |
; HELP_TEXT { |
cmp al, 210 ; Ctrl + F1 |
jne no_help_text |
help_wnd: |
call clear_screen |
call drawwindow |
mov eax, 51 |
mov ebx, 1 |
mov ecx, help_thread_start |
mov edx, 0xfff0 |
int 0x40 |
jmp still |
help_thread_start: |
call draw_help_wnd |
still_hw: |
cmp [MainWndClosed], 1 |
je exit_hw |
mov eax, 10 |
int 0x40 |
cmp eax, 1 |
je red_hw |
cmp eax, 2 |
je key_hw |
cmp eax, 3 |
je button_hw |
jmp still_hw |
red_hw: |
call draw_help_wnd |
jmp still_hw |
key_hw: |
; mov eax, 2 |
int 0x40 |
cmp ah, 27 |
jne still_hw |
button_hw: |
mov eax, 17 |
int 0x40 |
exit_hw: |
or eax, -1 |
int 0x40 |
; draw help window |
draw_help_wnd: |
mov eax, 12 |
mov ebx, 1 |
int 0x40 |
xor eax, eax |
mov ebx, 200 shl 16 + 320 |
mov ecx, 200 shl 16 + 260 |
mov edx, 0x03e0e0e0 ; work |
mov esi, [sc.grab] |
or esi, 0x80000000 ; grab |
mov edi, [sc.frame] ; frame |
int 0x40 |
mov eax, 4 |
mov ebx, 8 shl 16 + 8 |
mov ecx, 0xffffff |
mov edx, help_wnd_header |
mov esi, hlphead_len |
int 0x40 |
mov eax, 4 |
mov ebx, 8 shl 16 + 34 |
xor ecx, ecx |
mov esi, 51 |
mov edx, help_text |
.new_help_line: |
int 0x40 |
add ebx, 10 |
add edx, esi |
cmp [edx], byte 'x' |
jne .new_help_line |
mov eax, 12 |
mov ebx, 2 |
int 0x40 |
ret |
; HELP_TEXT } |
no_help_text: |
; LOAD_FILE { |
cmp al, 211 ; Ctrl + F2 |
je for_key_open ;do_load_file |
; LOAD_FILE } |
; SEARCH { |
cmp al, 212 ; Ctrl + F3 |
je search |
; SEARCH } |
; SAVE_FILE { |
cmp al, 213 ; Ctrl + F4 |
je yessave |
; SAVE_FILE } |
; ENTER_FILENAME { |
cmp al, 214 ; Ctrl + F5 |
jne @f |
jmp for_key_save |
@@: |
; ENTER_FILENAME } |
; ENTER_SEARCH { |
cmp al, 215 ; Ctrl + F6 |
jne @f |
; mov al, 51 |
; call read_string |
; jmp still |
jmp search_window |
@@: |
; ENTER_SEARCH } |
; CHANGE_LAYOUT { |
cmp al, 217 ; Ctrl + F8 |
jne @f |
call layout |
jmp still |
@@: |
; CHANGE_LAYOUT } |
; COMPILE_FILE { |
cmp al, 208 |
je lbl_compile_file |
; COMPILE_FILE } |
; RUN_OUTFILE { |
cmp al, 209 |
je lbl_run_outfile |
; RUN_OUTFILE } |
;run debug board { ----- |
cmp al,255 |
jne @f |
call open_debug_board |
call activate_me |
jmp still |
;} |
@@: |
;open sysfuncR { ----- |
; cmp al,228 |
; jne @f |
; call open_sysfuncs_txt |
; jmp still |
; @@: |
;fast_save_and_open { |
cmp al,216 |
jne @f |
call make_fast_so |
jmp still |
;} |
@@: |
; 3 times english -> àãá᪨© |
; 2 times àãá᪨© -> english |
; COPY START { |
cmp al, 19 |
jne no_copy_start |
mov eax, [post] |
imul ebx, [posy], 80 |
add eax, ebx |
mov [copy_start], eax |
jmp still |
; COPY START } |
no_copy_start: |
; COPY END { |
cmp al, 5 |
jne no_copy_end |
cmp [copy_start], 0 |
je still |
mov ecx, [post] |
imul ebx, [posy], 80 |
add ecx, ebx |
add ecx, 80 |
cmp ecx, [copy_count] |
jb still |
sub ecx, [copy_start] |
mov [copy_count], ecx |
mov esi, [copy_start] |
add esi, 0x80000 |
mov edi, 0x2f0000 |
cld |
rep movsb |
jmp still |
; COPY END } |
no_copy_end: |
; PASTE { |
cmp al, 16 |
jne no_copy_paste |
cmp [copy_count], 0 |
je still |
mov eax,[copy_count] |
cdq |
mov ebx, 80 |
div ebx |
add [lines], eax |
mov ecx, 0x2e0000 |
mov eax, [post] |
imul ebx, [posy], 80 |
add eax, ebx |
add eax, 0x80000 |
sub ecx, eax |
mov esi, 0x2e0000 |
sub esi, [copy_count] |
mov edi, 0x2e0000 |
std |
rep movsb |
mov esi, 0x2f0000 |
mov edi, [post] |
imul eax, [posy], 80 |
add edi, eax |
add edi, 0x80000 |
mov ecx, [copy_count] |
cld |
rep movsb |
call clear_screen |
call drawfile |
call draw_vertical_scroll |
mov [modified],1 |
jmp still |
; PASTE } |
no_copy_paste: |
; INSERT_SEPARATOR { |
cmp al,0xc ; Ctrl+L |
jne no_insert_separator |
imul eax,[posy],80 |
add eax,[post] |
add eax,0x80000 |
mov ebx,eax |
imul eax,[lines],80 |
add eax,0x80000 ; ⥯¥àì 㪠§ë¢ ¥â ª®¥æ ä ©« |
mov ecx,eax ; size |
sub ecx,ebx |
inc ecx |
mov esi,eax ; from |
mov edi,eax |
add edi,80 ; to |
std |
rep movsb |
mov ecx,80/4 |
mov esi,comment_string |
mov edi,ebx |
cld |
rep movsd |
inc [lines] |
call clear_screen |
call drawfile |
;call calc_scroll_size_and_pos |
call draw_vertical_scroll |
mov [modified],1 |
jmp still |
; INSERT_SEPARATOR } |
no_insert_separator: |
; DEL_LINE { |
cmp al,4 |
jne no_delete_line |
mov eax,[post] |
cdq |
mov ebx,80 |
div ebx |
add eax,[posy] |
inc eax |
cmp eax,[lines] |
jge still |
dec dword [lines] |
imul edi,[posy],80 |
add edi,[post] |
add edi,0x80000 |
mov esi,edi |
add esi,80 |
mov ecx,0x2e0000 |
sub ecx,esi |
shr ecx,4 |
cld |
rep movsd |
call clear_screen |
call drawfile |
;call calc_scroll_size_and_pos |
call draw_vertical_scroll |
mov [modified],1 |
jmp still |
; DEL_LINE } |
no_delete_line: |
; ENTER { |
cmp al,13 |
jnz noenter |
; lines down |
mov eax,[posy] |
inc eax |
; imul eax,80 |
lea eax,[eax+eax*4] ; eax *= 5 |
shl eax,4 ; eax *= 16 |
add eax,0x80000 |
add eax,[post] |
mov ebx,eax |
; ebx = ([posy]+1)*80 + 0x80000 + [post] |
; ebx -> first byte of next string |
imul eax,[lines],80 |
add eax,0x80000 |
mov ecx,eax |
; ecx = [lines]*80 + 0x80000 |
; ecx -> end of the document |
cmp ebx,ecx |
jz .bug_fixed |
@@: |
dec ecx |
mov dl,[ecx] |
mov [ecx+80],dl |
cmp ecx,ebx |
jnz @b |
.bug_fixed: |
; save for later |
imul eax,[posy],80 |
add eax,0x80000 |
add eax,[post] |
mov ebx,eax |
add eax,[posx] |
; eax = 0x80000 + [post] + [posy]*80 + [posx] |
push eax |
dec ebx |
xor ecx,ecx |
@@: |
cmp ecx,80 |
je @f |
inc ecx |
inc ebx |
cmp byte [ebx],' ' |
je @b |
@@: |
dec ecx |
cmp ecx,80-1 |
jne @f |
; mov [posx],0 |
jmp .lbl |
@@: |
cmp [posx],ecx |
jbe @f |
mov [posx],ecx |
jmp .lbl |
@@: |
mov [posx],0 |
.lbl: |
inc [posy] |
;clear line |
imul eax,[posy],80 |
add eax,0x80000 |
add eax,[post] |
mov edi,eax |
mov eax,' ' |
mov ecx,80/4 |
cld |
rep stosd |
; end of line to next line beginning |
imul eax,[posy],80 |
add eax,0x80000 |
add eax,[post] |
; add eax,[posx] |
mov ebx,eax |
; ebx -> beginning of this line |
pop esi |
mov edi,eax |
@@: |
mov al,[esi] |
mov [ebx],al |
mov [esi],byte ' ' |
inc esi |
inc ebx |
cmp esi,edi |
jb @b |
inc [lines] |
mov ecx,[posy] |
cmp ecx,[slines] |
jne @f |
dec [posy] |
add [post],80 |
@@: |
call clear_screen |
call drawfile |
;call calc_scroll_size_and_pos |
call draw_vertical_scroll |
mov [modified],1 |
jmp still |
; ENTER } |
noenter: |
; UP { |
cmp al,130+48 |
jnz noup |
mov ecx,[posy] |
test ecx,ecx |
jnz .up1 |
mov ecx,[post] |
test ecx,ecx |
jz still |
add ecx,-80 |
mov [post],ecx |
call clear_screen |
jmp .finish |
.up1: |
dec ecx |
mov [posy],ecx |
.finish: |
call drawfile |
call draw_vertical_scroll |
;call calc_scroll_size_and_pos |
jmp still |
; UP } |
noup: |
; DOWN { |
cmp al,129+48 |
jnz nodown |
mov ecx,[posy] |
mov eax,[slines] |
dec eax |
cmp ecx,eax |
jb .do1 ; goto do1 if [posy] < [slines]-1 |
mov eax,[lines] |
sub eax,[slines] |
dec eax |
jb still ; goto still if [lines] < [slines]-1 |
; imul eax,80 |
lea eax,[eax+eax*4] |
shl eax,4 |
cmp [post],eax |
jg still ; goto still if [post] > ([lines]-[slines]-1)*80 |
add [post],80 |
call clear_screen |
call drawfile |
call draw_vertical_scroll |
;call calc_scroll_size_and_pos |
jmp still |
.do1: |
pusha |
mov eax,[post] |
cdq |
mov ebx,80 |
div ebx |
add eax,[posy] |
inc eax |
cmp eax,[lines] |
jb .do10 |
popa |
jmp still |
.do10: |
popa |
inc ecx |
mov [posy],ecx |
call drawfile |
call draw_vertical_scroll |
;call calc_scroll_size_and_pos |
jmp still |
; DOWN } |
nodown: |
; LEFT { |
cmp al,128+48 |
jnz noleft |
cmp [posx],0 |
je still |
dec [posx] |
call drawfile |
jmp still |
; LEFT } |
noleft: |
; RIGHT { |
cmp al,131+48 |
jnz noright |
cmp [posx],79 |
je still |
inc [posx] |
call drawfile |
jmp still |
; RIGHT } |
noright: |
; PAGE_UP { |
page_up: |
cmp al,136+48 |
jnz nopu |
scrl_up: |
mov eax,[slines] |
dec eax |
; imul eax,80 |
lea eax,[eax+eax*4] |
shl eax,4 |
mov ecx,[post] |
cmp eax,ecx |
jbe pu1 |
mov ecx,eax |
pu1: |
sub ecx,eax |
mov [post],ecx |
call clear_screen |
call drawfile |
call draw_vertical_scroll |
;call calc_scroll_size_and_pos |
jmp still |
; PAGE_UP } |
nopu: |
; PAGE_DOWN { |
page_down: |
cmp al,135+48 |
jnz nopd |
scrl_down: |
mov eax,[lines] |
cmp eax,[slines] |
jb still |
mov eax,[post] ; eax = offset |
cdq |
mov ebx,80 |
div ebx ; eax /= 80 |
mov ecx,[lines] ; ecx = lines in the file |
cmp eax,ecx ; if eax < ecx goto pfok |
jnb still |
mov eax,[slines] ; eax = lines on the screen |
dec eax ; eax-- |
; imul eax,80 ; eax *= 80 |
lea eax,[eax+eax*4] |
shl eax,4 |
add [post],eax ; offset += eax |
mov eax,[lines] ; eax = lines in the file |
sub eax,[slines] ; eax -= lines on the screen |
; imul eax,80 ; eax *= 80 |
lea eax,[eax+eax*4] |
shl eax,4 |
cmp [post],eax |
jb @f |
mov [post],eax |
@@: |
call clear_screen |
call drawfile |
call draw_vertical_scroll |
;call calc_scroll_size_and_pos |
jmp still |
; PAGE_DOWN } |
nopd: |
; HOME { |
cmp al,132+48 |
jnz nohome |
push 0 |
pop [posx] |
call drawfile |
jmp still |
; HOME } |
nohome: |
; END { |
end_key: |
cmp al,133+48 |
jnz noend |
imul eax,[posy],80 |
add eax,0x80000 |
add eax,[post] |
mov esi,eax |
add eax,80+1 |
@@: dec eax |
cmp eax,esi |
je @f |
cmp byte [eax-1],' ' |
jbe @b |
@@: |
sub eax,esi |
cmp eax,80-1 |
jbe @f |
dec eax |
@@: |
mov [posx],eax |
call drawfile |
jmp still |
; END } |
noend: |
; GO_START { |
cmp al,251 ; Ctrl + [ |
jnz no_go_to_start |
push 0 |
pop [post] ; offset = 0 |
call clear_screen |
call drawfile ; draw file |
call draw_vertical_scroll |
;call calc_scroll_size_and_pos |
jmp still ; go to still |
; GO_START } |
no_go_to_start: |
; GO_END { |
cmp al,253 ; Ctrl + ] |
jnz no_go_to_end |
cmp [lines],30 ;to fix ctrl+] bug |
jb @f |
mov eax,[lines] ; eax = lines in the file |
sub eax,[slines] ; eax -= lines on the screen |
; imul eax,80 ; eax *= 80 (length of line) |
lea eax,[eax+eax*4] |
shl eax,4 |
mov [post],eax ; offset in the file |
call clear_screen |
call drawfile ; draw file |
call draw_vertical_scroll |
@@: |
jmp still ; go to still |
; GO_END } |
no_go_to_end: |
; DELETE { |
cmp al,134+48 |
jne nodel |
imul eax,[posy],80 |
add eax,0x80000 |
add eax,[post] |
add eax,[posx] |
mov ecx,eax |
imul eax,[posy],80 |
add eax,0x80000+79 |
add eax,[post] |
mov ebx,eax |
push ebx |
dec ecx |
dec ebx |
push ecx ebx |
push ebx |
imul eax,[posy],80 |
add eax,0x80000 |
add eax,[post] |
mov ecx,eax |
xor eax,eax |
cdq |
pop ebx |
dec ecx |
@@: |
inc ecx |
mov dh,[ecx] |
cmp dh,33 |
jb .nok |
xor eax,eax |
inc eax |
.nok: |
cmp ecx,ebx |
jb @b |
pop ebx ecx |
@@: |
inc ecx |
mov dl,[ecx+1] |
mov [ecx],dl |
cmp ecx,ebx |
jb @b |
pop ebx |
mov [ebx],byte 32 |
test eax,eax |
jz dellinesup |
call clear_screen |
call drawfile |
mov [modified],1 |
jmp still |
dellinesup: |
; lines -1 |
pusha |
mov eax,[post] |
cdq |
mov ebx,80 |
div ebx |
add eax,[posy] |
inc eax |
cmp eax,[lines] |
jb @f |
popa |
mov [modified],1 |
jmp still |
@@: |
popa |
dec [lines] |
; lines up |
mov [posx],dword 0 |
imul eax,[posy],80 |
add eax,0x80000-1 |
add eax,[post] |
mov ebx,eax |
push ebx |
imul eax,[lines],80 |
add eax,0x80000-1 |
add eax,[post] |
mov ecx,eax |
pop ebx |
@@: |
mov dl,[ebx+80] |
mov [ebx],dl |
inc ebx |
cmp ecx,ebx |
jnz @b |
call clear_screen |
call drawfile |
mov [modified],1 |
jmp still |
; DELETE } |
nodel: |
; INSERT { |
cmp al,137+48 |
jnz noins |
imul eax,[posy],80 |
add eax,0x80000 |
add eax,[post] |
add eax,[posx] |
mov ecx,eax |
; ecx = [posy]*80+0x80000+[post]+[posx] |
imul eax,[posy],80 |
add eax,0x80000+79 |
add eax,[post] |
mov ebx,eax |
; ebx = [posy]*80+0x80000+79+[post] |
.movstr: |
dec ebx |
mov dl,[ebx] |
mov [ebx+1],dl |
cmp ecx,ebx |
jb .movstr |
mov [ecx],byte ' ' |
call invalidate_string |
call drawfile |
mov [modified],1 |
jmp still |
; INSERT } |
noins: |
; BACKSPACE { |
cmp al,8 |
jnz nobs |
mov ecx,[posx] |
test ecx,ecx |
jz still |
dec ecx |
mov [posx],ecx |
imul eax,[posy],80 |
add eax,0x80000 |
add eax,[post] |
add eax,[posx] |
mov ebx,eax |
push ebx |
imul eax,[posy],80 |
add eax,0x80000+79 |
add eax,[post] |
mov ebx,eax |
pop ecx |
push ebx |
dec ecx |
.movleft: |
inc ecx |
mov dl,[ecx+1] |
mov [ecx],dl |
cmp ecx,ebx |
jb .movleft |
pop ebx |
mov [ebx],byte ' ' |
call invalidate_string |
call drawfile |
mov [modified],1 |
jmp still |
; BACKSPACE } |
nobs: |
; TAB { |
cmp eax,9 ; Tab |
jne notab |
mov eax,[posx] |
cmp eax,80-1 |
jae still |
add eax,5 ; 9 5 3 |
and eax,11111100b ; ...1000b, ...100b, ...10b |
dec eax |
mov [posx], eax |
call drawfile |
mov [modified],1 |
jmp still |
; TAB } |
notab: |
; ADD_KEY { |
push eax ; add key |
imul eax,[posy],80 |
add eax,0x80000 |
add eax,[post] |
add eax,[posx] |
mov ecx,eax |
push ecx |
imul eax,[posy],80 |
add eax,0x80000+79 |
add eax,[post] |
mov ebx,eax |
.movright: |
dec ebx |
mov al,[ebx] |
mov [ebx+1],al |
cmp ecx,ebx |
jbe .movright |
pop ebx |
pop eax |
mov [ebx],al |
mov edx,78 |
mov ecx,[posx] |
cmp edx,ecx |
jb noxp |
inc ecx |
mov [posx],ecx |
noxp: |
call invalidate_string |
call drawfile |
mov [modified],1 |
; call draw_vertical_scroll |
jmp still |
; ADD_KEY } |
;****************************************************************************** |
start_fasm: |
cmp [asm_mode],1 |
je @f |
ret |
@@: |
mov esi,filename |
mov edi,fasm_parameters |
cmp byte [esi],'/' |
je .yes_systree |
mov ecx,[filename_len] |
rep movsb |
mov al,',' |
stosb |
mov ecx,[filename_len] |
add ecx,-4 |
mov esi,filename |
rep movsb |
mov al,',' |
stosb |
mov [edi],dword '/RD/' |
add edi,4 |
mov [edi],word '1/' |
inc edi |
inc edi |
mov al,0 |
stosb |
jmp .run |
.yes_systree: |
add esi,[filename_len] |
dec esi |
xor ecx,ecx |
mov al,'/' |
@@: |
cmp [esi],al |
je @f |
dec esi |
inc ecx |
jmp @b |
@@: |
inc esi |
push esi |
push esi |
push ecx |
rep movsb |
mov al,',' |
stosb |
pop ecx |
pop esi |
add ecx,-4 |
rep movsb |
mov al,',' |
stosb |
pop ecx |
sub ecx,filename |
mov esi,filename |
rep movsb |
mov al,0 |
stosb |
.run: |
cmp [run_outfile],1 |
jne @f |
dec edi |
mov eax,',run' |
stosd |
mov al,0 |
stosb |
@@: |
mov eax,19 |
mov ebx,fasm_filename |
mov ecx,fasm_parameters |
int 0x40 |
ret |
open_debug_board: |
mov eax,19 |
mov ebx,debug_filename |
xor ecx,ecx |
int 0x40 |
ret |
open_sysfuncs_txt: |
mov eax,19 |
mov ebx,tinypad_filename |
mov ecx,sysfuncs_filename |
int 0x40 |
ret |
empty_work_space: |
; ®ç¨áâ¨âì ¢á¥ |
mov eax,' ' |
mov edi,0x80000 |
mov ecx,(0x300000-0x90000)/4 |
cld |
rep stosd |
mov edi,0x10000 |
mov ecx,0x60000/4 |
rep stosd |
ret |
clear_screen: |
; ®ç¨áâ¨âì íªà |
mov ecx,80*40 |
mov edi,0x78000 |
xor eax,eax |
@@: |
mov [edi],eax |
add edi,4 |
dec ecx |
jnz @b |
ret |
invalidate_string: |
imul eax,[posy],80 |
add eax,0x78000 |
mov edi,eax |
mov al,1 |
mov ecx,80/4 |
rep stosd |
ret |
layout: |
; ᬥ¨âì à ᪫ ¤ªã ª« ¢¨ âãàë |
mov eax,19 |
mov ebx,setup |
mov ecx,param_setup |
int 0x40 |
mov eax,5 |
mov ebx,eax |
int 0x40 |
call activate_me |
ret |
activate_me: |
; 1) get info about me |
mov eax,9 |
mov ebx,procinfo |
mov ecx,-1 |
int 0x40 |
; eax = number of processes |
; save process counter |
inc eax |
inc eax |
mov [proccount],eax |
mov eax,[procinfo.PID] |
mov [PID],eax |
; 2) get my process number |
mov eax,9 |
mov ebx,procinfo |
mov ecx,[proccount] |
@@: |
dec ecx |
jz @f ; counter=0 => not found? => return |
mov eax,9 |
int 0x40 |
mov edx,[procinfo.PID] |
cmp edx,[PID] |
jne @b |
;found: ecx = process_number |
mov eax,18 |
mov ebx,3 |
int 0x40 |
mov eax,5 |
mov ebx,eax |
int 0x40 |
@@: |
ret |
; ******************************************************************* |
; ************************** DRAW WINDOW ************************** |
; ******************************************************************* |
align 4 |
drawwindow: |
mov eax,12 ; WINDOW DRAW START |
mov ebx,1 |
int 0x40 |
mov [menu_is_on],0 |
mov eax,48 ; get system colors |
mov ebx,3 |
mov ecx,sc |
mov edx,sizeof.system_colors |
int 0x40 |
mov [sc.work],0xe0e0e0 |
xor eax,eax ; DEFINE WINDOW |
mov ebx,100*65536+506 ; 496 |
mov ecx,75*65536+400 ;385;400 ; sum < 480 for 640x480 |
mov edx,[sc.work] |
add edx,0x03000000 |
mov esi,[sc.grab] |
or esi,0x80000000 |
mov edi,[sc.frame] |
int 0x40 |
; header string |
mov eax,4 |
mov ebx,10*65536+8 |
mov ecx,[sc.grab_text] |
mov edx,header |
mov esi,[headlen] |
int 0x40 |
mov eax,9 ; get info about me |
mov ebx,procinfo |
or ecx,-1 |
int 0x40 |
mov eax,[procinfo.y_size] |
mov [do_not_draw],1 ; do_not_draw = true |
cmp eax,100 |
jb .no_draw ; do not draw text & buttons if height < 100 |
mov [do_not_draw],0 ; do_not_draw = false |
add eax,-(46+47) ; 46 = y offs |
cdq |
mov ebx,10 |
div ebx |
mov [slines],eax |
cmp eax,[posy] |
jnb @f |
dec eax |
mov [posy],eax |
@@: |
mov eax,[procinfo.y_size] ; calculate buttons position |
add eax,-47 |
mov [dstart],eax |
; mov eax,8 ; STRING BUTTON |
; mov ebx,5*65536+57 |
; mov ecx,[dstart] |
; add ecx,29 |
; shl ecx,16 |
; add ecx,13 |
; mov edx,51 ;;;;;-----string button ID=51 |
; mov esi,[sc.work_button] |
; int 0x40 |
; SEARCH BUTTON |
; mov ebx,(505-129)*65536+125 |
; mov edx,50 |
; mov esi,[sc.work_button] |
; int 0x40 |
; mov eax,4 ; SEARCH TEXT |
; mov ebx,[dstart] |
; add ebx,7*65536+32 |
; mov ecx,[sc.work_button_text] |
; mov edx,searcht |
; mov esi,searchtl-searcht |
; int 0x40 |
mov eax,13 ; BAR STRIPE |
mov ebx,5*65536+497 |
mov ecx,[dstart] |
shl ecx,16 |
add ecx,30 ;15 |
mov edx,0x00aaaaaa |
int 0x40 |
; mov eax,4 ; FIRST TEXT LINE (POSITION...) |
; mov ebx,12*65536 |
; add ebx,[dstart] |
; add ebx,38 ;18 |
; mov ecx,[sc.work_button_text] |
; mov edx,htext2 |
; mov esi,htextlen2-htext2 |
; int 0x40 |
call drawfile |
; mov eax,[dstart] |
; add eax,31 |
; mov [ya],eax |
; mov [addr],search_string |
; call print_text |
.no_draw: |
call draw_win_menu |
call draw_vertical_scroll |
mov eax,12 ; WINDOW DRAW END |
mov ebx,2 |
int 0x40 |
ret |
; ********************************** |
; *********** DRAWFILE *********** |
; ********************************** |
drawfile: |
;--------------- |
cmp [menu_is_on],1 |
jne .ff |
call drawwindow |
.ff: |
;--------------- |
mov [next_not_quote],1 |
mov [next_not_quote2],1 |
mov eax,[post] ; print from position |
pusha |
mov edi,[post] |
mov [posl],edi |
mov ebx,8*65536+46 ; letters (46 = y offs) |
xor ecx,ecx |
mov edx,0x80000 |
add edx,eax |
mov edi,edx |
imul esi,[slines],80 |
add edi,esi |
nd: |
pusha |
mov edx,ebx |
mov edi,ebx |
add edi,(6*65536)*80 |
wi1: |
; draw ? |
pusha |
push ecx |
imul eax,[posx],6 |
add eax,8 |
shl eax,16 |
mov ecx,eax |
; ecx = ([posx]*6+8)<<16 |
imul eax,[posy],10 |
add eax,46 ; y offs |
add eax,ecx |
; eax = [posy]*10+46+ecx |
pop ecx |
cmp edx,eax |
jnz drwa |
mov eax,0x7ffff |
call check_pos |
jmp drlet |
drwa: |
popa |
pusha |
imul eax,[posxm],6 |
add eax,8 |
shl eax,16 |
mov ecx,eax |
imul eax,[posym],10 |
add eax,46 ; y offs |
add eax,ecx |
cmp edx,eax |
jnz drwa2 |
mov eax,0x7ffff |
call check_pos |
jmp drlet |
drwa2: |
popa |
pusha |
mov eax,0x78000 ; screen |
add eax,[posl] ; screen+abs |
sub eax,[post] ; eax = screen+abs-base = y*80+x + screen |
mov edx,0x80000 ; file |
add edx,[posl] ; edx = absolute |
mov bl,[edx] ; in the file |
call check_pos |
mov cl,[eax] ; on the screen |
cmp bl,cl |
jnz drlet |
popa |
jmp nodraw |
; draw letter |
drlet: |
mov [eax],bl ; mov byte to the screen |
mov [tmpabc],bl |
popa ; restore regs |
;!!!!!!!!!!!! |
cmp [tmpabc],' ' |
je @f |
call draw_letter |
jmp nodraw |
@@: |
call clear_char |
nodraw: |
inc [posl] |
add edx,6*65536 |
cmp edx,edi |
jz wi3 |
jmp wi1 |
wi3: |
popa |
add ebx,10 |
add edx,80 |
cmp edi,edx |
jbe nde |
jmp nd |
nde: |
mov eax,[posx] |
mov ebx,[posy] |
mov [posxm],eax |
mov [posym],ebx |
popa |
ret |
stText = 0 |
stInstr = 1 |
stReg = 2 |
stNum = 3 |
stQuote = 4 |
stComment = 5 |
stSymbol = 6 |
align 4 |
clear_char: |
pusha |
mov ebx,[sc.work] |
push ecx |
imul eax,[posx],6 |
add eax,8 |
shl eax,16 |
mov ecx,eax |
imul eax,[posy],10 |
add eax,46 ; 26 |
add eax,ecx |
pop ecx |
cmp edx,eax |
jnz @f |
mov ebx,0xffffff ; light blue 0x00ffff |
@@: |
; draw bar |
push ebx |
mov eax,13 |
mov ebx,edx |
mov bx,6 |
mov ecx,edx |
shl ecx,16 |
add ecx,10 |
pop edx |
int 0x40 |
popa |
ret |
align 4 |
; CHECK_POSITION { |
check_pos: |
cmp [asm_mode],1 |
je @f |
mov [d_status],stText |
ret |
@@: |
pushad |
; COMMENT TERMINATOR |
cmp [d_status],stComment |
jnz @f |
mov eax,[posl] |
sub eax,[post] |
cdq |
mov ebx,80 |
div ebx |
test edx,edx |
jnz end_check_pos |
mov [d_status],stText |
@@: |
; QUOTE TERMINATOR B |
cmp [next_not_quote],1 |
jne @f |
mov [d_status],stText |
@@: |
mov eax,[posl] |
add eax,0x80000 |
mov edx,eax |
mov al,[eax] |
; QUOTE TERMINATOR A |
cmp [d_status],stQuote |
jnz @f |
cmp al,[quote] |
jne end_check_pos |
mov [next_not_quote],1 |
jmp end_check_pos |
@@: |
mov [next_not_quote],0 |
; START QUOTE 1 |
cmp al,"'" |
jne @f |
mov [d_status],stQuote |
mov [quote],al |
jmp end_check_pos |
@@: |
; START QUOTE 2 |
cmp al,'"' |
jne @f |
mov [d_status],stQuote |
mov [quote],al |
jmp end_check_pos |
@@: |
; START COMMENT |
cmp al,';' |
jne @f |
mov [d_status],stComment |
jmp end_check_pos |
@@: |
; NUMBER TERMINATOR |
cmp [d_status],stNum |
jne nonumt |
mov ecx,23 |
@@: |
dec ecx |
jz nonumt |
cmp al,[symbols+ecx] |
jne @b |
nonumt1: |
mov [d_status],stText |
nonumt: |
; START NUMBER |
cmp [d_status],stNum |
je end_check_pos |
cmp al,'0' |
jb nonum |
cmp al,'9' |
ja nonum |
mov bl,[edx-1] |
mov ecx,23 |
@@: |
dec ecx |
jz nonum |
cmp bl,[symbols+ecx] |
jne @b |
@@: |
mov [d_status],stNum |
jmp end_check_pos |
nonum: |
; SYMBOL |
mov esi,symbols |
mov ecx,21 |
@@: |
cmp byte [esi],al |
je @f |
dec ecx |
jz nosymbol |
inc esi |
jmp @b |
@@: |
mov [d_status],stSymbol |
jmp end_check_pos |
nosymbol: |
mov [d_status],stText |
end_check_pos: |
popad |
ret |
; CHECK_POSITION } |
;;;;;;;;;;;;;;;;; |
;; DRAW LETTER ;; |
;;;;;;;;;;;;;;;;; |
draw_letter: |
call clear_char |
pusha |
mov ebx,edx ; x & y |
mov eax,[d_status] |
mov ecx,[eax*4+color_tbl] |
mov eax,4 |
xor esi,esi |
inc esi |
mov edx,0x80000 |
mov edi,[posl] |
add edx,edi |
int 0x40 |
popa |
ret |
; ******************************************** |
; **************** SAVEFILE **************** |
; ******************************************** |
save_file: |
mov esi,0x80000 |
mov edi,0x10000 |
or ecx,-1 |
.new_string: |
inc ecx |
call save_string |
cmp ecx,[lines] |
jb .new_string |
sub edi,0x10004 ; why??? |
mov [filelen],edi |
cmp byte [filename],'/' |
je .systree_save |
mov eax,33 |
mov ebx,filename |
mov ecx,0x10000 |
mov edx,[filelen] |
xor esi,esi |
int 0x40 |
test eax,eax |
je .finish |
; call file_not_found |
call disk_is_full |
;============================== |
jmp .finish |
.systree_save: |
mov eax,[filelen] |
mov [fileinfo_write+8],eax |
mov esi,filename |
mov edi,pathfile_write |
mov ecx,50 |
cld |
rep movsb |
mov eax,58 |
mov ebx,fileinfo_write |
int 0x40 |
cmp eax,0 |
je .finish |
call disk_is_full |
.finish: |
call draw_window_for_dialogs |
mov [modified],0 |
ret |
save_string: |
push ecx |
push esi |
mov eax,esi |
mov ebx,eax |
add ebx,79 |
.countlen: |
cmp ebx,eax |
jb .endcount |
cmp byte [ebx],' ' |
jne .endcount |
dec ebx |
jmp .countlen |
.endcount: |
inc ebx |
sub ebx,eax |
mov ecx,ebx |
jecxz .endcopy |
.copystr: |
mov al,[esi] |
mov [edi],al |
inc esi |
inc edi |
dec ecx |
jnz .copystr |
.endcopy: |
mov eax,0x0a0d |
stosw |
pop esi |
add esi,80 |
pop ecx |
ret |
; ******************************************** |
; **************** LOADFILE **************** |
; ******************************************** |
loadhdfile: |
mov esi,filename |
mov edi,pathfile_read |
mov ecx,250 ;50 |
cld |
rep movsb |
mov eax,58 |
mov ebx,fileinfo_read |
int 0x40 |
xchg eax,ebx |
inc eax |
test ebx,ebx ;errorcode=0 - ok |
je file_found |
cmp ebx,6 ;errorcode=5 - ok |
je file_found |
call file_not_found |
ret |
loadfile1: |
mov eax,6 ; 6 = open file |
mov ebx,filename |
xor ecx,ecx |
mov edx,16800 |
mov esi,0x10000 |
int 0x40 |
inc eax ; eax = -1 -> file not found |
jnz file_found ;strannaya proverka (Ed) |
call file_not_found |
ret |
file_found: |
dec eax |
; eax = file size |
jz .finish |
mov [filesize],eax |
mov edi,0x80000 ; clear all |
@@: |
mov [edi],byte ' ' |
inc edi |
cmp edi,0x2effff |
jnz @b |
mov [lines],0 |
mov edi,0x10000 |
mov ebx,0x80000 |
; edi = from |
; ebx = to |
; eax = filesize |
.new_char: |
mov cl,[edi] ; get_char(); |
cmp cl,13 ; if (char==13) |
je .new_str1 ; goto .new_str1; |
cmp cl,10 ; if (char==10) |
je .new_str2 ; goto .new_str2; |
mov [ebx],cl ; store_char(); |
inc ebx ; dest++; |
.back: |
inc edi ; src++; |
dec eax ; counter--; |
jnz .new_char ; if (counter!=0) goto .new_char; |
.finish: |
inc [lines] ; [lines]++; |
ret |
.new_str1: |
pusha |
mov eax,ebx ; eax = destination |
add eax,-0x80000 ; eax = offset |
cdq |
mov ecx,80 |
div ecx ; offset /= 80; |
test edx,edx ; if not the first char in the string |
jne @f ; go forward |
test eax,eax ; if first line |
je @f ; go forward |
cmp [edi-1],byte 10; if previous char != 10 continue without line feed |
jne .contin |
@@: |
inc eax ; offset++; |
imul eax,80 ; offset *= 80; |
add eax,0x80000 |
mov [esp+4*4],eax ; to ebx |
.contin: |
popa |
inc edi ; do not look on the next char (10) |
dec eax ; counter--; |
inc [lines] ; [lines]++; |
jmp .back |
.new_str2: |
pusha |
mov eax,ebx |
add eax,-0x80000 |
cdq |
mov ecx,80 |
div ecx |
inc eax |
imul eax,80 |
add eax,0x80000 |
mov [esp+4*4],eax ; to ebx |
popa |
inc [lines] |
jmp .back |
file_not_found: |
mov eax,55 ; beep |
mov ebx,eax |
mov esi,error_beep |
int 0x40 |
mov [lines],1 ; open empty document |
mov [to_return2],1 |
call openerror |
ret |
disk_is_full: |
mov eax,55 ; beep |
mov ebx,eax |
mov esi,error_beep |
int 0x40 |
mov [to_return2],1 |
call saveerror |
mov [error2_found],1 |
ret |
; ***************************** |
; ****** WRITE POSITION ****** |
; ***************************** |
writepos: |
cmp [do_not_draw],1 ; return if drawing is not permitted |
jne @f |
ret |
@@: |
pusha |
mov eax,[posx] |
inc eax |
cdq |
mov ebx,10 |
div ebx |
add al,'0' |
add dl,'0' |
mov [htext2+ 9],al |
mov [htext2+10],dl |
mov eax,[post] |
cdq |
mov ebx,80 |
div ebx |
mov [real_posy],eax ;=====!!!!!!!!! |
add eax,[posy] |
inc eax |
mov ebx,10 |
cdq |
div ebx |
add dl,'0' |
mov [htext2+16],dl ; 00001 |
cdq |
div ebx |
add dl,'0' |
mov [htext2+15],dl ; 00010 |
cdq |
div ebx |
add dl,'0' |
mov [htext2+14],dl ; 00100 |
cdq |
div ebx |
add dl,'0' |
add al,'0' |
mov [htext2+13],dl ; 01000 |
mov [htext2+12],al ; 10000 |
mov eax,[lines] ; number of lines |
cdq |
mov ebx,10 |
div ebx |
add dl,'0' |
mov [htext2+31],dl ; 0001 |
cdq |
div ebx |
add dl,'0' |
mov [htext2+30],dl ; 0010 |
cdq |
div ebx |
add dl,'0' |
mov [htext2+29],dl ; 0100 |
cdq |
div ebx |
add dl,'0' |
add al,'0' |
mov [htext2+28],dl |
mov [htext2+27],al ; 10000 |
; ! |
; mov [htext2+42], word 'RU' |
; mov eax,13 ; draw bar |
; mov ebx,5*65536+38*6 |
; mov ecx,[dstart] |
; shl ecx,16 |
; add ecx,15 |
; mov edx,[sc.work_graph] |
; int 0x40 |
mov eax,13 ; BAR STRIPE |
mov ebx,5*65536+497 |
mov ecx,[dstart] |
add ecx,29;30 ;15 |
shl ecx,16 |
add ecx,14 |
mov edx,[sc.work_graph] |
int 0x40 |
mov eax,4 ; write position |
mov ebx,12*65536 |
mov bx,word [dstart] |
add ebx,33 ;18 |
mov ecx,[sc.work_button_text] |
mov edx,htext2 |
mov esi,38 |
int 0x40 |
cmp [modified],1 |
jne no_mod |
if lang eq ru |
putlabel 270,386,' ',[sc.work_button_text] |
else |
putlabel 270,386,'MODIFIED',[sc.work_button_text] |
end if |
no_mod: |
popa |
ret |
;----------------------------- |
; search window |
;----------------------------- |
search_window: |
mov eax,13 |
mov ebx,55*65536+380 |
mov ecx,100*65536+60 |
mov edx,[sc.work_graph] |
int 0x40 |
mov eax,38 |
mov ebx,55*65536+435 |
mov ecx,100*65536+100 |
mov edx,cl_White |
int 0x40 |
mov eax,38 |
mov ebx,55*65536+55 |
mov ecx,100*65536+160 |
mov edx,cl_White |
int 0x40 |
mov eax,38 |
mov ebx,435*65536+435 |
mov ecx,100*65536+160 |
mov edx,cl_White |
int 0x40 |
mov eax,38 |
mov ebx,55*65536+435 |
mov ecx,160*65536+160 |
mov edx,cl_White |
int 0x40 |
if lang eq ru |
drawlbut 375,110,50,15,'®¨áª',50,[sc.work_button],[sc.work_button_text] |
drawlbut 375,130,50,15,'⬥ ',94,[sc.work_button],[sc.work_button_text] |
else |
drawlbut 375,110,50,15,'Search',50,[sc.work_button],[sc.work_button_text] |
drawlbut 375,130,50,15,'Cancel',94,[sc.work_button],[sc.work_button_text] |
end if |
call read_string |
; add eax,31 |
; mov [ya],eax |
; mov [addr],search_string |
; call print_text |
jmp search |
string_not_found: |
mov eax,13 |
mov ebx,150*65536+200 |
mov ecx,100*65536+70 |
mov edx,[sc.work_graph] ;0x00dd9438 ;0x00ff7512 |
int 0x40 |
mov eax,38 |
mov ebx,150*65536+350 |
mov ecx,100*65536+100 |
mov edx,cl_White |
int 0x40 |
mov eax,38 |
mov ebx,150*65536+350 |
mov ecx,170*65536+170 |
mov edx,cl_White |
int 0x40 |
mov eax,38 |
mov ebx,150*65536+150 |
mov ecx,100*65536+170 |
mov edx,cl_White |
int 0x40 |
mov eax,38 |
mov ebx,350*65536+350 |
mov ecx,100*65536+170 |
mov edx,cl_White |
int 0x40 |
if lang eq ru |
putlabel 195,120,'âப ¥ ©¤¥ !',cl_White |
else |
putlabel 195,120,'String not found!',cl_White |
end if |
drawlbut 235,140,30,15,'ª',94,[sc.work_button],cl_White |
ret |
read_string: |
push eax |
;---------------- |
mov eax,40 |
mov ebx,00000000000000000000000000000111b |
int 0x40 |
;---------------- |
pop eax |
; cmp al,51 |
; jz .f2 |
; ret |
.f2: |
mov [addr],dword search_string |
mov eax,[dstart] |
add eax,17+14 |
mov [ya],eax |
mov [case_sens],1 |
.rk: |
mov edi,[addr] |
mov eax,[addr] |
mov eax,[eax-4] |
mov [temp],eax |
add edi,eax |
call print_text |
.waitev: |
mov eax, 10 |
int 0x40 |
cmp eax, 2 |
jne .read_done |
int 0x40 |
shr eax, 8 |
cmp al, 13 ; enter |
je .read_done |
cmp al,27 |
jne ._f |
jmp red |
._f: |
cmp al, 192 ; Ctrl + space |
jne .noclear |
xor eax, eax |
mov [temp], eax |
mov edi, [addr] |
mov [edi-4], eax |
mov ecx, 49 |
cld |
rep stosb |
mov edi, [addr] |
call print_text |
jmp .waitev |
.noclear: |
cmp al, 8 ; backspace |
jnz .nobsl |
cmp [temp], 0 |
jz .waitev |
dec [temp] |
mov edi, [addr] |
add edi, [temp] |
mov [edi], byte 0 |
mov eax,[addr] |
dec dword [eax-4] |
call print_text |
jmp .waitev |
.nobsl: |
cmp [temp],50 |
jae .read_done |
; CONVERT CHAR TO UPPER CASE: |
cmp al, ' ' ; below "space" - ignore |
jb .waitev |
cmp [case_sens], 1 ; case sensitive? |
je .keyok |
cmp al, 'a' |
jb .keyok |
cmp al, 'z' |
ja .keyok |
sub al, 32 |
.keyok: |
mov edi,[addr] |
add edi,[temp] |
mov [edi],al |
inc [temp] |
mov eax,[addr] |
inc dword [eax-4] |
call print_text |
cmp [temp],50 |
jbe .waitev |
.read_done: |
mov ecx,50 |
sub ecx,[temp] |
mov edi,[addr] |
add edi,[temp] |
xor eax,eax |
cld |
rep stosb |
mov [temp],987 |
call print_text |
call mask_events |
ret |
print_text: |
pusha |
mov eax,13 |
mov ebx,64*65536+50*6+2 |
; mov ecx,[ya] |
; shl ecx,16 |
; add ecx,12 |
mov ecx,110*65536+12 |
mov edx,[sc.work] |
int 0x40 |
mov edx,[addr] |
mov esi,[edx-4] |
mov eax,4 |
mov ebx,65*65536+112 ;2 |
; add ebx,[ya] |
mov ecx,[color_tbl+0] |
int 0x40 |
cmp [temp],50 |
ja @f |
; draw cursor |
; { |
; mov eax,[ya] |
mov eax,18*65536+102 ;65 |
mov ebx,eax |
shl eax,16 |
add eax,ebx |
add eax,10 |
mov ecx,eax |
mov eax,[temp] |
; imul eax,6 |
lea eax,[eax+eax*2] |
shl eax,1 |
add eax,65 |
mov ebx,eax |
shl eax,16 |
add ebx,eax |
mov eax,38 |
mov edx,[color_tbl+0] |
int 0x40 |
; } |
@@: |
popa |
ret |
; mov eax,8 ; STRING BUTTON |
; mov ebx,5*65536+57 |
; mov ecx,[dstart] |
; add ecx,29 |
; shl ecx,16 |
; add ecx,13 |
; mov edx,51 ;;;;;-----string button ID=51 |
; mov esi,[sc.work_button] |
; int 0x40 |
; SEARCH BUTTON |
; mov ebx,(505-129)*65536+125 |
; mov edx,50 |
; mov esi,[sc.work_button] |
; int 0x40 |
; mov eax,4 ; SEARCH TEXT |
; mov ebx,[dstart] |
; add ebx,7*65536+32 |
; mov ecx,[sc.work_button_text] |
; mov edx,searcht |
; mov esi,searchtl-searcht |
; int 0x40 |
; **************************** |
; ******* READ STRING ******** |
; **************************** |
goto_string: |
mov [num_goto_string],0 |
call read_str_num |
mov eax,[num_goto_string] |
cmp eax,[lines] |
ja .leave |
;--------------- |
mov [posy],0 |
call goto_pos |
.leave: |
call draw_window_for_dialogs |
call mask_events |
jmp still |
read_str_num: |
push eax |
;---------------- |
mov eax,40 |
mov ebx,00000000000000000000000000000111b |
int 0x40 |
;---------------- |
pop eax |
mov eax,13 |
mov ebx,100*65536+100 |
mov ecx,70*65536+60 |
mov edx,[sc.work_button] |
int 0x40 |
mov eax,38 |
mov ebx,100*65536+200 |
mov ecx,70*65536+70 |
mov edx,cl_White |
int 0x40 |
mov eax,38 |
mov ebx,100*65536+200 |
mov ecx,130*65536+130 |
mov edx,cl_White |
int 0x40 |
mov eax,38 |
mov ebx,100*65536+100 |
mov ecx,70*65536+130 |
mov edx,cl_White |
int 0x40 |
mov eax,38 |
mov ebx,200*65536+200 |
mov ecx,70*65536+130 |
mov edx,cl_White |
int 0x40 |
putlabel 105,75,'GoTo Line #',cl_White |
mov eax,13 |
mov ebx,110*65536+40 |
mov ecx,90*65536+12;[ya] |
mov edx,[sc.work] |
int 0x40 |
outcount [num_goto_string],112,92,cl_Black,6*65536 |
drawlbut 110,105,40,15,'GoTo',93,cl_Grey,cl_Black |
drawlbut 153,105,40,15,'Cancel',94,cl_Grey,cl_Black |
.waitev: |
mov eax, 10 |
int 0x40 |
; cmp eax,6 |
; je .mouse |
cmp eax,3 |
je .but |
cmp eax, 2 |
; jne .read_done |
jne .waitev |
int 0x40 |
shr eax, 8 |
cmp al, 13 ; enter |
je .read_done |
cmp al,27 |
je goto_string.leave |
cmp al, 8 ; backspace |
jnz .nobsl |
xor edx,edx |
mov eax,[num_goto_string] |
mov ebx,dword 10 |
div ebx |
mov [num_goto_string],eax |
call print_text2 |
jmp .waitev |
;.mouse: |
;mov eax,37 |
;mov ebx,2 |
;int 0x40 |
;cmp eax,2 |
;je goto_string.leave |
;jmp .waitev |
.but: |
mov eax,17 |
int 0x40 |
cmp ah,94 |
je goto_string.leave |
cmp ah,93 |
je .read_done |
jmp .waitev |
.nobsl: |
xor ecx,ecx |
xor edx,edx |
sub al,48 |
mov cl,al |
mov eax,[num_goto_string] |
cmp eax,99999 |
ja .read_done |
mov ebx,10 |
mul ebx |
add eax,ecx |
mov [num_goto_string],eax |
call print_text2 |
jmp .waitev |
.read_done: |
mov eax,[num_goto_string] |
dec eax |
mov [num_goto_string],eax |
call print_text2 |
ret |
print_text2: |
pusha |
mov eax,13 |
mov ebx,110*65536+40 |
mov ecx,90*65536+12;[ya] |
mov edx,[sc.work] |
int 0x40 |
outcount [num_goto_string],112,92,cl_Black,6*65536 |
popa |
ret |
;****************************************************************************** |
calc_scroll_size_and_pos: |
;cmp [menu_is_on],0 |
;je ._ff |
;call drawwindow |
;mov [menu_is_on],0 |
;._ff: |
cmp [lines],30 |
jbe .lines_less_30 |
xor edx,edx |
mov eax,[post] |
mov ebx,80 |
div ebx |
add eax,[posy] |
;add eax,[slines] |
;checking for bug |
mov ebx,[lines] |
sub ebx,30 |
cmp eax,ebx |
ja .f |
mov [VScroll_1+16],eax |
jmp .ff |
.f: |
mov [VScroll_1+16],ebx |
.ff: |
;--------------------- |
mov eax,[lines] |
sub eax,30 ;---max=lines-30 |
mov [VScroll_1+12],eax |
jmp .leave |
.lines_less_30: |
mov [VScroll_1+16],dword 0 |
mov [VScroll_1+12],dword 1 |
.leave: |
ret |
;============Draw vertical scroll bar========= |
draw_vertical_scroll: |
call calc_scroll_size_and_pos |
;======================== |
xor ecx,ecx ;start at top of controls list |
Draw_Controls_Loop: ;Redraw Controls Loop |
mov ebp, [App_Controls+ecx] ;get controls data location |
or ebp,ebp ;is this the last control? |
jz Draw_Controls_Done ; |
call dword [App_Controls+ecx+4] ;call controls draw function |
add ecx, 12 ;get next control |
jmp Draw_Controls_Loop ;loop till done |
Draw_Controls_Done: ;all done |
;======================== |
mov eax,38 |
mov ebx,488*65536+488 |
mov ecx,43*65536+388 |
mov edx,0x00000000 |
int 0x40 |
ret |
mouse_info: |
;call |
mov eax, 37 ;get mouse cordinates |
mov ebx, 1 ; |
int 0x40 ; |
mov ecx, eax ; |
push ecx ; |
mov eax, 37 ;get mouse buttons |
mov ebx, 2 ; |
int 0x40 ; |
;------------------ |
; if menu is on - then we need to redraw window before continue |
cmp eax,1 |
jne ._f1 |
pusha |
cmp [menu_is_on],0 |
je ._ff |
call drawwindow |
mov [menu_is_on],0 |
._ff: |
popa |
._f1: |
;------------------ |
cmp [mouseb], eax ;compare old mouse states to new states |
jne redraw_mouse_info ; |
cmp [mousey], cx ; |
jne redraw_mouse_info ; |
shr ecx, 16 ; |
cmp [mousex], cx ; |
jne redraw_mouse_info ; |
pop ecx ; |
ret ;return if no change in states |
redraw_mouse_info: |
pop ecx |
mov [mouseb], eax ;save new mouse states |
mov dword [mousey], ecx |
xor ecx, ecx |
Check_Mouse_Over_Controls_Loop: |
mov ebp, [App_Controls+ecx] |
or ebp, ebp |
jz Check_Mouse_Over_Controls_Loop_done |
movzx eax,word [ebp+2] |
cmp ax, [mousex] |
ja mouse_not_on_control |
movzx eax,word [ebp+6] |
cmp ax, [mousey] |
ja mouse_not_on_control |
movzx eax,word [ebp] |
add ax, [ebp+2] |
cmp ax, [mousex] |
jb mouse_not_on_control |
movzx eax,word [ebp+4] |
add ax, [ebp+6] |
cmp ax, [mousey] |
jb mouse_not_on_control |
call dword [App_Controls+ecx+8] |
;------------------------------ |
cmp [mouseb],1 |
jne mouse_not_on_control |
mov eax,[VScroll_1+16] |
call goto_pos |
;------------------------------ |
mouse_not_on_control: |
add ecx, 12 |
jmp Check_Mouse_Over_Controls_Loop |
Check_Mouse_Over_Controls_Loop_done: |
ret |
;****************************************************************************** |
goto_pos: |
;pusha |
mov ecx,eax ;save new position number in ecx for future |
cmp [lines],30 ;check for 'cursor' bug |
jbe .lines_less_30 |
;--------------- |
mov edx,[lines] ;if new pos is > than (lines-30) |
sub edx,30 |
cmp eax,edx |
ja .f1 |
jmp .ff |
.f1: |
mov eax,edx ;than newpos is = (lines-30) |
sub ecx,edx ;and posY=newpos-(lines-30) |
mov [posy],ecx |
.ff: |
;----------------------- |
;in eax must be string number |
mov ecx,80 |
mul ecx |
; add eax,[slines] |
; sub |
;------------------------ |
mov [post],eax |
.lines_less_30: |
call clear_screen |
call drawfile |
;popa |
ret |
;****************************************************************************** |
mask_events: |
mov eax,40 |
mov ebx,00100111b |
int 0x40 |
ret |
;****************************************************************************** |
main_cursor_move: |
;call drawwindow |
sub [mouse_x],7 |
sub [mouse_y],45 |
xor edx,edx |
mov eax,[mouse_x] |
mov ebx,6 |
div ebx ;eax=result |
mov [posx],eax |
xor edx,edx |
mov eax,dword [mouse_y] |
mov ebx,dword 10 |
div ebx ;eax=result=new posY |
;error checking ------ |
cmp [lines],dword 1 ;for "1st line" bug |
je ._do_nothing |
mov ebx,[lines] |
sub ebx,dword 1 |
cmp eax,ebx ;[lines] |
ja ._do_nothing |
;---------------------- |
mov [posy],eax |
._do_nothing: |
call clear_screen |
call drawfile |
call draw_vertical_scroll |
ret |
;****************************************************************************** |
make_fast_so: |
;=========================== |
; 1) get info about me |
mov eax,9 |
mov ebx,procinfo |
mov ecx,-1 |
int 0x40 |
; eax = number of processes |
; save process counter |
inc eax |
inc eax |
mov [proccount],eax |
mov eax,[procinfo.PID] |
mov [PID],eax |
;========================== |
mov eax,51 |
mov ebx,1 |
mov ecx,fast_so_thread_start |
mov edx,so_stack |
int 0x40 |
ret |
;****************************************************************************** |
;fast save & fast open |
draw_fastso_window: |
startwd |
colorwindow 120,100,454,70,window_Type1+0x00cccccc,0x00cccccc,cl_Black |
call draw_string00 |
drawlbut 10,40,30,20,'Save',17,cl_Grey,cl_Black |
drawlbut 50,40,30,20,'Open',18,cl_Grey,cl_Black |
drawlbut 90,40,37,20,'Close',19,cl_Grey,cl_Black |
endwd |
ret |
draw_string00: |
mov ebx,10*65536+433 |
mov ecx,10*65536+20 |
mov edx,0x00ffffff |
mov eax,13 |
int 0x40 |
push eax |
mov eax,6*65536 |
mul dword [pos00] |
add eax,10*65536+6 |
mov ebx,eax |
pop eax |
mov edx,0x6a73d0 |
int 0x40 |
mov eax,4 |
mov ebx,12*65536+17 |
mov ecx,cl_Black ;0x00000000 |
mov edx,mypath ;filename ;path |
mov esi,71 ;200 |
int 0x40 |
ret |
fast_so_thread_start: |
;copy filename to mypath |
cld |
mov esi,filename |
mov edi,mypath |
mov ecx,71 ;200 |
rep movsb |
mov edi,mypath |
mov ecx,71 ;200 |
xor eax,eax |
repne scasb |
;end copy |
call draw_fastso_window |
fastso_still: |
wtevent fred,fkey,fbut |
jmp fastso_still |
fred: |
call draw_fastso_window |
jmp fastso_still |
;====KEY |
fkey: |
mov eax,2 |
int 0x40 |
cmp ah,179 |
jne noright00 |
mov eax,[pos00] |
cmp eax,70 ;41 |
ja fastso_still |
inc eax |
mov [pos00],eax |
call draw_string00 |
jmp fastso_still |
noright00: |
cmp ah,176 |
jne noleft00 |
mov eax,[pos00] |
test eax,eax |
je fastso_still |
dec eax |
mov [pos00],eax |
call draw_string00 |
jmp fastso_still |
noleft00: |
cmp ah,182 |
jne nodelete00 |
call shiftback00 |
call draw_string00 |
jmp fastso_still |
nodelete00: |
cmp ah,8 |
jne noback00 |
mov eax,[pos00] |
test eax,eax |
je fastso_still |
dec eax |
mov [pos00],eax |
call shiftback00 |
call draw_string00 |
jmp fastso_still |
noback00: |
enter00: |
cmp ah,19 ;ctrl+s |
je fast_save |
cmp ah,15 ;ctrl+o |
je fast_open |
cmp ah,27 ;esli escape |
jne noesc00 |
jmp closethis ;to zakrivaem okno i nifiga ne delayem |
noesc00: |
cmp dword [pos00],71 ;200 ;42 |
jae fastso_still ;if pos>71 then jump to still |
;============letters================== |
;~~~~~~~TEST CODE~~~~~~~~~ |
; upper case |
shr eax,8 |
cmp eax,dword 31 |
jbe no_lit |
cmp eax,dword 95 |
jb capital |
sub eax,32 |
capital: |
;~~~~~~~~~~~~~~~~~~~~~~~~~ |
mov edi,mypath ;filename ;mypath ;**************PATHNAME |
add edi,71 ;200 ;count of letters |
mov esi,edi |
dec esi |
mov ecx,71 ;200 ;again??? |
sub ecx,[pos00] |
std |
rep movsb |
;shr eax,8 |
mov esi,mypath ;filename ;*************PATH AGAIN |
add esi,[pos00] |
mov byte [esi],al |
inc dword [pos00] |
call draw_string00 |
no_lit: |
jmp fastso_still |
;=============================== |
shiftback00: |
mov edi,mypath ;filename ;******PATH |
add edi,[pos00] |
mov esi,edi |
inc esi |
mov ecx,71 ;200 ; count??? |
sub ecx,[pos00] |
cld |
rep movsb |
ret |
;****************************************************************************** |
;====button |
fbut: |
mov eax,17 |
int 0x40 |
cmp ah,17 |
je fast_save |
cmp ah,18 |
je fast_open |
cmp ah,19 |
je closethis |
jmp fastso_still |
;****************************************************************************** |
;****************************************************************************** |
fast_open: |
call path_copy |
call set_title |
mov [to_return],1 |
call do_load_file |
jmp closethis |
fast_save: |
call path_copy |
call save_file |
call set_title |
;call copy_fpath_s |
closethis: |
mov [to_return],0 |
cmp [error_found],1 |
je @f |
call activate_main |
@@: |
mov [error_found],0 |
close |
activate_main: |
mov eax,9 |
mov ebx,procinfo |
mov ecx,[proccount] |
@@: |
dec ecx |
jz @f ; counter=0 => not found? => return |
mov eax,9 |
int 0x40 |
mov edx,[procinfo.PID] |
cmp edx,[PID] |
jne @b |
;found: ecx = process_number |
mov eax,18 |
mov ebx,3 |
int 0x40 |
mov eax,5 |
mov ebx,eax |
int 0x40 |
@@: |
ret |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
doyouwannasave: |
;****************************************************************************** |
cmp [modified],0 |
je newfile |
mov eax,55 ; beep |
mov ebx,eax |
mov esi,save_beep1 |
int 0x40 |
delay 4 |
mov eax,55 ; beep |
mov ebx,eax |
mov esi,save_beep2 |
int 0x40 |
mov eax,13 |
mov ebx,150*65536+200 |
mov ecx,100*65536+70 |
mov edx,[sc.work_graph] ;0x00dd9438 ;0x00ff7512 |
int 0x40 |
mov eax,38 |
mov ebx,150*65536+350 |
mov ecx,100*65536+100 |
mov edx,cl_White |
int 0x40 |
mov eax,38 |
mov ebx,150*65536+350 |
mov ecx,170*65536+170 |
mov edx,cl_White |
int 0x40 |
mov eax,38 |
mov ebx,150*65536+150 |
mov ecx,100*65536+170 |
mov edx,cl_White |
int 0x40 |
mov eax,38 |
mov ebx,350*65536+350 |
mov ecx,100*65536+170 |
mov edx,cl_White |
int 0x40 |
if lang eq ru |
putlabel 190,120,'®åà ¨âì ¤®ªã¬¥â?',cl_White |
drawlbut 170,140,30,15,' ',46,[sc.work_button],cl_White |
drawlbut 230,140,30,15,'¥â',45,[sc.work_button],cl_White |
drawlbut 290,140,45,15,'⬥ ',47,[sc.work_button],cl_White |
else |
putlabel 190,120,'Save document?',cl_White |
drawlbut 170,140,30,15,'Yes',46,[sc.work_button],cl_White |
drawlbut 230,140,30,15,'No',45,[sc.work_button],cl_White |
drawlbut 290,140,45,15,'Cancel',47,[sc.work_button],cl_White |
end if |
mov [exit_wnd_on],1 |
jmp still |
;------------- |
newfile: |
;if filename is not NEWDOC## than change it to it! |
mov eax,dword [orig_filename] |
cmp dword [filename],eax ;[orig_filename] |
je @f |
cld |
mov esi,orig_filename |
mov edi,filename |
mov ecx,71 ;50 |
rep movsb |
mov edi,filename |
mov ecx,71 ;50 |
xor eax,eax |
repne scasb |
sub edi,filename |
dec edi |
mov [filename_len],edi |
@@: |
call change_fname |
call set_title |
call draw_window_for_dialogs |
call empty_work_space |
mov [lines],1 |
jmp do_load_file.restorecursor |
change_fname: |
cmp [filename+7],'9' |
jne addfname |
cmp [filename+6],'9' |
je error_creating_new_file |
mov [filename+7],'0' |
add [filename+6],0x1 |
jmp leavenow |
addfname: |
add [filename+7],0x1 |
leavenow: |
ret |
set_title: |
cmp [error2_found],1 |
je no_set_title |
mov esi, filename |
mov edi, header |
mov ecx, [filename_len] |
mov eax, ecx |
add eax, 10 |
mov [headlen], eax |
cld |
rep movsb |
mov [edi], dword ' - ' |
add edi, 3 |
mov esi, htext |
mov ecx, htext.size |
rep movsb |
call drawwindow |
no_set_title: |
mov [error2_found],0 |
ret |
draw_window_for_dialogs: |
call clear_screen |
call drawwindow |
ret |
copy_fpath: |
call mask_events |
call path_copy |
call set_title |
call draw_window_for_dialogs |
jmp do_load_file |
copy_fpath_s: |
call mask_events |
call path_copy |
call save_file |
call set_title |
call draw_window_for_dialogs |
jmp still |
path_copy: |
cld |
mov esi,mypath |
mov edi,filename |
mov ecx,250 ;71 ;50 |
rep movsb |
mov edi,filename |
mov ecx,250 ;71 ;50 |
xor eax,eax |
repne scasb |
sub edi,filename |
dec edi |
mov [filename_len],edi |
ret |
openerror: |
mov eax,360 |
mov ebx,openerrtext |
mov ecx,1 |
call alert_box |
cmp [to_return2],1 |
jne jmp_to_still |
mov [to_return2],0 |
mov [error_found],1 |
call mask_events |
ret |
saveerror: |
mov eax,390 |
mov ebx,saveerrtext |
mov ecx,1 |
call alert_box |
cmp [to_return2],0 |
je jmp_to_still |
mov [to_return2],0 |
mov [error_found],1 |
call mask_events |
ret |
;jmp still |
jmp_to_still: |
call mask_events |
jmp still |
error_creating_new_file: |
mov eax,200 |
mov ebx,newfileerror |
mov ecx,1 |
call alert_box |
jmp still |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;;;;;;;;;;;;;;MENU;;;;;;;;;;;;;;;;;;;;;; |
draw_win_menu: |
;mov eax,8 |
;mov ebx,145*65536+276 |
;mov ecx,22*65536+15 |
;mov edx,00100000000000000000000000001111b |
;mov esi,0x00aaaaaa |
;int 0x40 |
mov eax,13 |
mov ebx,5*65536+497 |
mov ecx,22*65536+17 |
mov edx,[sc.work_graph] ;0x00999999 |
int 0x40 |
mov ecx,39*65536+5 |
mov edx,0x00aaaaaa |
int 0x40 |
if lang eq ru |
drawlbut 5,22,70,15,' ©«',97,[sc.work_button],[sc.work_button_text] |
drawlbut 75,22,70,15,'®¤',98,[sc.work_button],[sc.work_button_text] |
drawlbut 145,22,70,15,'¥ªáâ',96,[sc.work_button],[sc.work_button_text] |
drawlbut 431,22,70,15,'¯à ¢ª ',99,[sc.work_button],[sc.work_button_text] |
else |
drawlbut 5,22,70,15,'File',97,[sc.work_button],[sc.work_button_text] |
drawlbut 75,22,70,15,'Code',98,[sc.work_button],[sc.work_button_text] |
drawlbut 145,22,70,15,'Text',96,[sc.work_button],[sc.work_button_text] |
drawlbut 431,22,70,15,'Help',99,[sc.work_button],[sc.work_button_text] |
end if |
ret |
draw_win_menu_file: |
call clear_screen |
call drawwindow |
;mov eax,13 |
;mov ebx,5*65536+71 |
;mov ecx,35*65536+90 |
;mov edx,[sc.grab_button];0x00999999 |
;int 0x40 |
;mov eax,38 |
;mov ebx,5*65536+35 |
;mov ecx,40*65536+47 |
;mov edx,0x00ff0000 |
;int 0x40 |
mov [menu_is_on],1 |
if lang eq ru |
drawlbut 5,38,70,15,'®¢®¥ ®ª®',100,[sc.grab_button],[sc.grab_button_text] |
drawlbut 5,53,70,15,'®¢ë©',101,[sc.grab_button],[sc.grab_button_text] |
drawlbut 5,68,70,15,'®åà ¨âì',2,[sc.grab_button],[sc.grab_button_text] |
drawlbut 5,83,70,15,'®åà. ª ª',102,[sc.grab_button],[sc.grab_button_text] |
drawlbut 5,98,70,15,'âªàëâì',103,[sc.grab_button],[sc.grab_button_text] |
drawlbut 5,113,70,15,'ë室',104,[sc.grab_button],[sc.grab_button_text] |
else |
drawlbut 5,38,70,15,'New window',100,[sc.grab_button],[sc.grab_button_text] |
drawlbut 5,53,70,15,'New',101,[sc.grab_button],[sc.grab_button_text] |
drawlbut 5,68,70,15,'Save',2,[sc.grab_button],[sc.grab_button_text] |
drawlbut 5,83,70,15,'Save as',102,[sc.grab_button],[sc.grab_button_text] |
drawlbut 5,98,70,15,'Open',103,[sc.grab_button],[sc.grab_button_text] |
drawlbut 5,113,70,15,'Exit',104,[sc.grab_button],[sc.grab_button_text] |
end if |
jmp still |
draw_win_menu_code: |
call clear_screen |
call drawwindow |
if lang eq ru |
drawlbut 75,38,70,15,'®¬¯¨«.',10000,[sc.grab_button],[sc.grab_button_text] |
drawlbut 75,53,70,15,' ¯ãáâ¨âì',10001,[sc.grab_button],[sc.grab_button_text] |
drawlbut 75,68,70,15,'®áª ®â«.',10002,[sc.grab_button],[sc.grab_button_text] |
drawlbut 75,83,70,15,'SysFunc',10003,[sc.grab_button],[sc.grab_button_text] |
else |
drawlbut 75,38,70,15,'Compile',10000,[sc.grab_button],[sc.grab_button_text] |
drawlbut 75,53,70,15,'Run',10001,[sc.grab_button],[sc.grab_button_text] |
drawlbut 75,68,70,15,'Debug board',10002,[sc.grab_button],[sc.grab_button_text] |
drawlbut 75,83,70,15,'SysFunc',10003,[sc.grab_button],[sc.grab_button_text] |
end if |
mov [menu_is_on],1 |
jmp still |
draw_win_menu_text: |
call clear_screen |
call drawwindow |
if lang eq ru |
drawlbut 145,38,70,15,'GoTo Line#',95,[sc.grab_button],[sc.grab_button_text] |
drawlbut 145,53,70,15,' ©â¨',92,[sc.grab_button],[sc.grab_button_text] |
drawlbut 145,68,70,15,' ©â¨ ¤ «¥¥',50,[sc.grab_button],[sc.grab_button_text] |
else |
drawlbut 145,38,70,15,'GoTo Line#',95,[sc.grab_button],[sc.grab_button_text] |
drawlbut 145,53,70,15,'Find',92,[sc.grab_button],[sc.grab_button_text] |
drawlbut 145,68,70,15,'Find next',50,[sc.grab_button],[sc.grab_button_text] |
end if |
mov [menu_is_on],1 |
jmp still |
new_pad_wnd: |
mov eax,19 |
mov ebx,tinypad_filename |
mov ecx,0 |
int 0x40 |
jmp still |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
if lang eq ru |
openerrtext db '訡ª ®âªàëâ¨ï ä ©« ¨«¨ ®âªàë⨥ ®â¬¥¥®!',0 |
saveerrtext db '訡ª á®åà ¥¨ï ä ©« ¨«¨ á®åà ¥¨¥ ®â¬¥¥®!',0 |
newfileerror db '¥¢®§¬®¦® ᮧ¤ âì ®¢ë© ä ©«',0 |
else |
openerrtext db 'Error while opening file or opening canceled!',0 |
saveerrtext db 'Error while saving file or saving canceled!',0 |
newfileerror db 'Cannot create new file',0 |
end if |
; ******************** |
; ****** DATA ****** |
; ******************** |
sz fasm_filename, 'FASM ' |
sz debug_filename, 'BOARD ' |
sz tinypad_filename, 'TINYPAD ' |
lsz sysfuncs_filename,\ |
ru, <'SYSFUNCR.TXT',0>,\ |
en, <'SYSFUNCS.TXT',0> |
sz setup, 'SETUP ' ; we need to run SETUP to change keyboard layout |
param_setup db 'LANG',0 ; parameter for SETUP |
addr dd filename ; address of input string |
filename_len dd 12 |
filename db 'NEWDOC00.TXT' |
times 256 db 0;51-12 db 0 |
;times db 0 ; ï ¥ § î ¯®ç¥¬ã ¨«« ¥ ¯®áâ ¢¨« íâã áâà®çªã |
orig_filename db 'NEWDOC00.TXT' |
rb 256 |
search_len dd 5 |
search_string db 'still' |
times 51-5 db 0 |
case_sens db 0 ; for search function |
align 4 |
comment_string: |
db ';***************************************' |
db '*************************************** ' |
; INTERFACE DATA: |
sz htext, 'TINYPAD' |
;sz toolbar_btn_text, 'COMPILE RUN BOARD SYSFUNC' |
searcht: |
if lang eq ru |
db ' > ' |
db ' ' |
else |
db ' STRING > ' |
db ' SEARCH ' |
end if |
searchtl: |
htext2: |
if lang eq ru |
db ' 00:00000 00000 ' |
else |
db 'POSITION 00:00000 LENGTH 00000 LINES ' |
end if |
htextlen2: |
help_text: |
if lang eq ru |
db ' : ' |
db ' ' |
db ' CTRL+F1 : â® ®ª® ' |
db ' CTRL+S : ¥à¢ ï áâப ¤«ï ª®¯¨à®¢ ¨ï ' |
db ' CTRL+E : ®á«¥¤ïï áâப ¤«ï ª®¯¨à®¢ ¨ï ' |
db ' CTRL+P : áâ ¢¨âì ¢ë¡à ®¥ ⥪ãéãî ¯®§¨æ¨î ' |
db ' CTRL+D : ¤ «¨âì áâபã ' |
db ' CTRL+L : áâ ¢¨âì áâபã-à §¤¥«¨â¥«ì ' |
db ' CTRL+[ : ¥à¥©â¨ ¢ ç «® ä ©« ' |
db ' CTRL+] : ¥à¥©â¨ ¢ ª®¥æ ä ©« ' |
db ' CTRL+F2 : £à㧨âì ä ©« ' |
db ' CTRL+F3 : ®¨áª ' |
db ' CTRL+F4 : ®åà ¨âì ä ©« ' |
db ' CTRL+F5 : ®åà ¨âì ä ©« ª ª... ' |
db ' CTRL+F6 : ¢¥á⨠áâப㠤«ï ¯®¨áª ' |
db ' CTRL+F7 : "ª® ¡ëáâண® á®åà ¥¨ï ¨ § £à㧪¨" ' |
db ' CTRL+F8 : ¬¥¨âì à ᪫ ¤ªã ª« ¢¨ âãàë ' |
db ' CTRL+F9 : ®¬¯¨«¨à®¢ âì ä ©« ' |
db ' CTRL+F10 : ®¬¯¨«¨à®¢ âì ¨ § ¯ãáâ¨âì ' |
db ' F12 : ¯ãáâ¨âì ¤®áªã ®â« ¤ª¨ ' |
db 'x' |
else |
db ' COMMANDS: ' |
db ' ' |
db ' CTRL+F1 : SHOW THIS WINDOW ' |
db ' CTRL+S : SELECT FIRST STRING TO COPY ' |
db ' CTRL+E : SELECT LAST STRING TO COPY ' |
db ' CTRL+P : PASTE SELECTED TO CURRENT POSITION ' |
db ' CTRL+D : DELETE CURRENT LINE ' |
db ' CTRL+L : INSERT SEPARATOR LINE ' |
db ' CTRL+[ : GO TO THE BEGINNING OF FILE ' |
db ' CTRL+] : GO TO THE END OF FILE ' |
db ' CTRL+F2 : LOAD FILE ' |
db ' CTRL+F3 : SEARCH ' |
db ' CTRL+F4 : SAVE FILE ' |
db ' CTRL+F5 : SAVE FILE AS... ' |
db ' CTRL+F6 : ENTER SEARCH STRING ' |
db ' CTRL+F7 : DRAW "FAST SAVE AND OPEN" WINDOW ' |
db ' CTRL+F8 : CHANGE KEYBOARD LAYOUT ' |
db ' CTRL+F9 : COMPILE FILE ' |
db ' CTRL+F10 : RUN OUTFILE ' |
db ' F12 : OPEN DEBUG BOARD ' |
db 'x' |
end if |
help_wnd_header: |
if lang eq ru |
db '',0 |
else |
db 'TINYPAD HELP',0 |
end if |
hlphead_len = $ - help_wnd_header |
save_yes_no: |
if lang eq ru |
db '®åà ¨âì ä ©« ¯¥à¥¤ ¢ë室®¬?',0 |
else |
db 'Save file before exit?',0 |
end if |
VScroll_1: |
dw 13 ;width +0 |
dw 489 ;x +2 |
dw 341 ;326 ;height +4 |
dw 43 ;y +6 |
dd 0 ;min +8 |
dd 100 ;scrl_max ;lines ;max +12 |
dd 0 ;cur_pos ;current +16 |
dd 1 ;small change +20 |
dd 10 ;big change +24 |
App_Controls: |
dd VScroll_1 , drawvscroll, VScroll_mouse_over ; |
dd 0,0,0 ;last control do not delete |
; END OF INTERFACE DATA |
symbols db '%#&*\:/<>|{}()[]=+-,. ' |
error_beep: |
db 0xA0,0x30,0 |
save_beep1: |
db 0x84,0x43,0 |
save_beep2: |
db 0x84,0x48,0 |
align 4 |
fileinfo_read: |
dd 0 |
dd 0 |
dd 300000/512 |
dd 0x10000 |
dd 0x70000 |
pathfile_read: |
times 250 db 0 ;51 db 0 |
align 4 |
fileinfo_write: |
dd 1 |
dd 0 |
dd 0 |
dd 0x10000 |
dd 0x70000 |
pathfile_write: |
times 250 db 0 ; 51 db 0 |
align 4 |
temp dd 0xabc ; used in read_string |
d_status dd 0 |
color_tbl: |
dd 0x00000000 ; text |
dd 0x00000000 ; instruction |
dd 0x00000000 ; register |
dd 0x00009000 ; number |
dd 0x00a00000 ; quote |
dd 0x00909090 ; comment |
dd 0x003030f0 ; symbol |
next_not_quote2 db 0 ; " |
next_not_quote db 0 ; ' |
quote db 0 |
asm_mode db 0 ; ASM highlight? |
tmpabc db 0 |
I_PARAM db 0 ; parameters are HERE - ¯ à ¬¥âàë ¡ã¤ãâ ç¨ âìáï ! |
TINYPAD_END: ; end of file |
; Uninitialised data |
; ¥¨¨æ¨ «¨§¨à®¢ ë¥ ¤ ë¥ |
align 4 |
posx dd ? ; x íªà ¥ (on the screen) |
posy dd ? ; y íªà ¥ |
post dd ? ; ᬥ饨¥ ®â ç « - offset |
posl dd ? |
lines dd ? ; ª®«¨ç¥á⢮ áâப ¢ ¤®ªã¬¥â¥ |
posxm dd ? |
posym dd ? |
dstart dd ? ; ᬥ饨¥ ¯® ®á¨ y ¤«ï ®âà¨á®¢ª¨ ª®¯®ª ¨ ¤à. |
filelen dd ? ; ¤«¨ ä ©« |
PID dd ? ; ¨¤¥â¨ä¨ª â®à ¯à®æ¥áá |
proccount dd ? ; ª®«¨ç¥á⢮ ¯à®æ¥áᮢ |
filesize dd ? ; à §¬¥à ä ©« |
ya dd ? ; ¤«ï read_string |
slines dd ? ; number of strings on the screen - ª®«¨ç¥á⢮ áâப íªà ¥ |
run_outfile dd ? ; for FASM |
copy_start dd ? ; Ctrl+S |
copy_count dd ? ; Ctrl+E |
headlen dd ? ; header length |
do_not_draw dd ? ; to draw or not to draw - this is a serious question ;) |
MainWndClosed dd ? |
sc system_colors |
to_return db 0 |
to_return2 db 0 |
error_found db 0 |
error2_found db 0 |
header: ; window header - § £®«®¢®ª ®ª |
rb 256 |
; ¨ä®à¬ æ¨ï ® ¯à®æ¥áᥠ§ ¯¨áë¢ ¥âáï ¢ íâã áâàãªâãàã |
procinfo process_information |
virtual at procinfo |
fasm_parameters rb 256 |
end virtual |
pos00 dd 0 |
newdoc db ? |
mypath: |
times 1024+16 db 0 |
real_posy dd 0 |
vscroll_size dd 0 |
vscroll_pos dd 0 |
cur_pos dd 0 |
scrl_max dd 100 |
mouse_x dd 0 |
mouse_y dd 0 |
mousey dw 0 |
mousex dw 0 |
mouseb dd 0 |
num_goto_string dd 0 |
menu_is_on db 0 |
exit_wnd_on db 0 |
modified db 0 |
;fast save n open stack |
rb 1024 |
so_stack: |
;growing down |
; the end! |
/programs/other/tinypad2/trunk/ReadMe.txt |
---|
0,0 → 1,203 |
-= [v 3.78b] =- |
¥àá¨ï ¡ë« ᤥ« áà §ã ¯®á«¥ ⮣® ª ª ï ¢ë«®¦¨« ¯à¥¤., ® ï ¥ñ ¥ ¢ëª« ¤ë¢ «, |
â ª ª ª ¤¥ï«áï ¥éñ ¤®à ¡®â âì. |
®¢®¥: |
- ¯®¨áª á¯àïâ ¢ ¬¥î, £®àïç ï ª« ¢¨è ctrl+F7, ¯®¨áª ¤ «¥¥ - ctrl+F8 |
- ¡®«¥¥ ¤«¨ ï áâப ®âªàëâ¨ï ä ©«®¢, ¥ ¦¥« â¥«ì® ®âªàë¢ âì ¯ã⨠|
>71 ᨬ¢®« , â ª ª ª ¬®£ãâ ¢®§¨ªãâì ®è¨¡ª¨ ¯à¨ à ¡®â¥ á ®ª®¬ "¡ëáâண® á/§" |
íâ® ¯à®áâ® ¤®¯®«¥¨¥ ª ¯à¥¤ë¤ã饬㠢ë¯ãáªã. ¤ «ìè¥ ¡ã¤¥â ¨á¯à ¢«¥®: |
- £«îª á ¥ ªâ¨¢ë¬¨ ®ª ¬¨. |
-= [v 3.78a] =- |
த¥ à ¡®â ¥â.. :) |
®¢®¥: |
- ªà®«« ¢§ïâ á "Scroll.inc", ¢â®à ª®â®à®£® Jason Delozier. |
¯à¨æ¨¯ ¤¢¨¦¥¨ï ¯® ¤®ªã¬¥âã ¯®«®áâìî ¨§¬¥ñ (¯® áà ¢¥¨î |
á ¯à®è«®© ¢¥àᨥ©). |
- ãàá®à ¤¢¨£ ¥âáï ª«¨ª®¬ ¬ë誨. |
- ®¡ ¢«¥ äãªæ¨ï Goto Line #. |
(enter-goto; esc - cancel) |
¤®áâ â®ç® ¯®«¥§ ï äãªæ¨ï, ª®£¤ ä á¬( ¤®áª¥ ®â« ¤ª¨) ¯¨è¥â çâ® ®è¨¡ª |
¢ â ª®©-â® áâப¥... |
- á¯à ¢«¥ ¡ £ á § ¤ ¨¥¬ ¨¬¥¨ ®¢®£® ä ©« |
- á¯à ¢«¥ ¡ £ á® áâப®© ¯®¨áª (¯à¨ "¯®¨áª¥" ¯®á«¥¤¥© áâப¨) |
- á¯à ¢«¥ ¡ £ ¯®á«¥ ¢ë§®¢ ¤¨ «®£®¢ ®âªàëâ¨ï/á®åà ¥¨ï. |
⥯¥àì áªà®«« ¯®á«¥ ¨å ¯à®¤®«¦ ¥â à ¡®â âì ;) |
- ¥«ª¨¥ ¨á¯à ¢«¥¨ï ¢ à ¡®â¥ ¬¥î. |
®ï¢¨«áï: |
£«îª, ª ª ¢ LC - ¯à¨ ¦ ⨨ ¢ ®¡« á⨠®ª , ¤ ¦¥ ¥á«¨ ®ª® ¥ ªâ¨¢®, |
ªãàᮢ ¨ áªà®«« ¡ à ¢áñ à ¢® ॠ£¨àãîâ ¬ëèªã. |
¡®â î ¤: |
-ᯨ᪮¬ ¯®á«¥¤¨å ä ©«®¢ |
-§ £à㧪®© "color table'a" |
â ª ¦¥, ¤® ¯®á¬®âà¥âì ¨á室¨ª¨ HeEd'a, â®ç¥¥ äãªæ¨¨ ¯¥à¥ª®¤¨à®¢ª¨. |
------------------------------------------------- |
-= [v 3.77a] =- |
éñ ®¤ «ìä . |
íâ®â à §: |
- ¤®¡ ¢«¥ ¯®«®á ¯à®ªã⪨ |
- ¨á¯à ¢«¥® ®ª® ¢®¯à®á "á®åà ¨âì ¤®ªã¬¥â", â ª ª ª ï § ¬¥â¨« |
çâ® ®® ¦à «® ¬®£® ¯à®æ¥áá®à®£® ¢à¥¬¥¨. |
- ®¡®¢«¥¨¥ íªà ¯®á«¥ ¤¨ «®£®¢ á®åà ¥¨ï ¨ ®âªàëâ¨ï |
§ ¬¥âªã: áªà®«« ¯®«®áâìî ᤥ« ¬®© ¨ ¯®í⮬ã, ¢®§¬®¦®, ¥áâì £«îª¨. |
â ª ª ª ï ¥ èñ« ¡®«¥¥ å®à®è¥© ä®à¬ã«ë, áªà®«« ¢á¥£¤ ¥¬®£® ¥ ¤®¥§¦ ¥â ¤® |
¢¥àå , § â® ¨ª®£¤ ¥ ¯¥à¥á¥ª ¥â ¨¦îî ª®¯ªã (¢à®¤¥ ¡ë) |
ª®¯ª¨ áªà®«« "¢¢¥àå" ¨ "¢¨§" íª¢¨¢ «¥âë pg.up ¨ pg.down |
§¬¥à áªà®«« ¦¥á⪮ § ªà¥¯«ñ, â ª ª ª ᪮஠¡ã¤¥â § ¯¥à饮 |
¨§¬¥ïâì à §¬¥ë ®ª . |
¥ ¯®«ãç¨âáï: |
¡à âì ®£à ¨ç¥¨¥ ¢ 80 ᨬ¢®«®¢ ¨ ¯à¨á®¡ ç¨âì ¯®¤¤¥à¦ªã BGI èà¨ä⮢. |
஡«¥¬ ¢ ᫨誮¬ ¨§¢à éñ®¬ «£®à¨â¬¥ ¢ë¢®¤ ᨬ¢®«®¢ (¯® ªà ©¥© |
¬¥à¥ ¬¥ â ª ¯®ª § «®áì), ¯à®é¥ ¡ã¤¥â ¯¥à¥¤¥« âì ¢áñ ¯® ®¢®©, |
¢§ï¢ ¥ª®â®àë¥ äãªæ¨¨ ®âáî¤ . |
á«¥¤ãî饩 ¢¥àᨨ ¯« ¨àã¥âáï: |
- äãªæ¨ï "goto string #" |
- ¨§¬¥¥¨¥ 梥â ⥪áâ (¨ ᯥæ. ᨬ¢®«®¢) ¨ à ¡®ç¥© ®¡« áâ¨. |
- á®åà ¥¨¥ ¥¡®«ì讣® ᯨ᪠"¯®á«¥¤¨å । ªâ¨à㥬ëå ä ©«®¢" |
¯®áâ à îáì, ® ¢áñ ¦¥ ¨ç¥£® ¥ ®¡¥é î.... |
-= [v 3.76 ] =- |
®¢â®àë© à¥¬¥©ª â ©¨¯ ¤ :) « ¢¨ âãà à㫨â. |
â® ®¢®£®? |
- "ª® ¡ëáâண® á®åà ¥¨ï ¨ § £à㧪¨" ¤«ï ¯à®¯¨áë¢ ¨ï ¯ã⨠|
ª ä ©«ã "¢àãçãî". í⮬ ¦¥ ®ª¥ £®àï稥 ª« ¢¨è¨ - |
ctrl+s - á®åà ¨âì, ctrl+o - ®âªàëâì, esc - ®â¬¥ |
- ®àï稥 ª« ¢¨è¨ ¤«ï ª®¬¯¨«ï樨(CTRL+F9), |
ª®¬¯¨«ï樨 ¨ § ¯ã᪠(CTRL+F10), ¨ ¤®áª¨ ®â« ¤ª¨(F12) |
- £« ¢®¥ ®ª® ®áâ ñâáï ªâ¨¢ë¬ ¯®á«¥ § ¯ã᪠¤®áª¨ ®â« ¤ª¨ |
¨ ®ª ¡ëáâண® á®åà ¥¨ï (⮫쪮 £®àï稬¨ ª« ¢¨è ¬¨) |
- á¯à ¢«¥ £«îª ¢ë«¥â ¨ï ¯à¨ ¯®¯ë⪥ ¯®¨áª ¢ ¯ãá⮬ |
¤®ªã¬¥â¥ |
- ®¡« £®à®¦¥ ¯¨áª ¨§ ᯨª¥à , ⥯¥àì ¯®å®¦ ¯¨áª ®«¨¡à¨ 3 |
- ®¯ª¨ ¢ë஢¥ë ¤«ï ¨á¯®«ì§®¢ ¨ï ᪨ |
- ¯® ¥¯®ïâë¬ ¬¥ ¯à¨ç¨ ¬ ä ©«ë á®åà ñë¥ ¢ ¨¦¥¬ ॣ¨áâॠ|
¡á®«îâ® ¥ ¯à¨¨¬ «¨áì sysxtree ¨ 㦮 ¡ë«® ¨å ®âªàë¢ âì |
¢àãçãî ¯à®¯¨áë¢ ï ¯ãâì. ¨á¯à ¢«¥® ®¡ëçë¬ ¯¥à¥¢®¤®¬ ¢ ¢¥à娩 |
ॣ¨áâà. |
- ®ª á®®¡é¥¨ï ¯à¨ ¯¥à¥¯®«¥®¬ ¤¨áª¥ (â ¦¥ ¯à®æ¥¤ãà , çâ® ¨ ¤«ï erroff ã |
savedialog) |
- ¨á¯à ¢«¥ ¬®© ¡ £ - ¯à¨ ¥¢®§¬®¦®á⨠á®åà ¥¨ï ⥯¥àì ®áâ ñâáï áâ àë© ¯ãâì |
ª ä ©«ã (¨ ¨¬ï). |
- ¨á¯à ¢«¥® ¥éñ ¯ à®çª ¬¥«ª¨å ¥¤®çñ⮢ (¬®¨å?!). |
â® ¥ ᤥ« ®? |
áñ ¥éñ ¥â ¯®¤¤¥à¦ª¨ èà¨ä⮢ BGI ¨ |
¨§¬¥¥¨ï 梥â ä® /⥪áâ . ®âï ï ᮬ¥¢ îáì, çâ® BGI èà¨äâë ¯àאַ "¥®¡å®¤¨¬ |
ë" |
¢ á¬-¡«®ª®â¥. |
®ª ¥éñ ¥ ®¡à ¡ âë¢ ¥âáï ®è¨¡ª "fat12 § ¯®«¥" - ¢à®¤¥ ¡ë ¤ ¦¥ äãªæ¨¨ ¢ ï¤ |
ॠ¥â... |
®çã ¯¥à¥©â¨ ᪠-ª®¤ë, â® ¢ ᪨ ¯®¢â®àïîâáï ª®¤ë. |
-------------------------------------------- |
¨ ¥éñ: ® ®è¨¡ª å ¨ ªà¨â¨ª¥ - ¬¥ (¥ "¬¥ï") ¬ë«® ¨«¨ ä®àã¬. |
-------------------------------------------- |
áâ®à¨ï... |
-= [ v 3.75b ] =- |
.... |
¥¬¥©ª :) Tinypad'a : |
ã«¡ à ⥯¥àì á¯àïâ ¢ ¬¥î. «ï á®åà ¥¨ï ¨ ®âªàëâ¨ï ¨á¯®«ì§ãîâáï |
¤¨ «®£¨ ¨§ ASCL ¢«îè¨ ¢£¥¨ï. á¯à ¢«¥ "¦ã⪨©" ¡ £ - ª®£¤ |
á®åà ï¥èì ¤®ªã¬¥â ¯®¤ ¤à㣨¬ ¨¬¥¥¬, ¢ áâப¥ § £®«®¢ª ®áâ ¢ «®áì |
áâ ஥ §¢ ¨¥. |
®¡ ¢«¥ë ¤¨ «®£®¢ë¥ ®ª ¯à¨ ®è¨¡ª å ¨ ¢ë室¥. ®¡ ¢«¥ ª®¯ª |
"®¢ë©", ¯à¨ ¦ ⨨ ª®â®àãî § ¤ ñâáï ¢®¯à®á ® á®åà ¥¨¨ ä ©« , § ⥬ |
ᮧ¤ ñâáï ¤®ªã¬¥â á ®¢ë¬ ¨¬¥¥¬. ªá¨¬ «ì® 99 ®¢ëå ¤®ªã¬¥â®¢. ®¯ª |
"®¢®¥ ®ª®" ®âªàë¢ ¥â ®¢®¥ ®ª® ©¨¯ ¤ (§ ¯ã᪠¥â ®¢ë© ¯à®æ¥áá). |
£àãá⮬... |
¡® ¢á¥å ®è¨¡ª å ¬¥ ¬ë«®, ¯®¯à®¡ãî ¨á¯à ¢¨âì. |
¨ «®£ "á®åà ¨âì ª ª" á®åà ï¥â ⮫쪮 £®â®¢ë¥ ä ©«ë (â® ¥áâì ¯®¢¥àå ¨å, |
¥«ì§ï ᮧ¤ âì ®¢ë©). |
ਠ¯®¯ë⪥ ¯®¨áª áâப¨ ¢ ¯ãá⮬ ¤®ªã¬¥â¥ ¯à®£ ¢ë«¥â ¥â :( |
ਠ¢ë室¥, ª®£¤ ¢ë« §¨â ®ª®èª® á ¢®¯à®á®¬ "á®åà ¨âì ä ©«?" - ¤ - á®åà ï¥â |
¤®ªã¬¥â ¨ § ªàë¢ ¥â ®ª®, ¥â - ¥ á®åà ï¥â ¨ ¢ë室¨â, ¥«çñª ¯® à ¡®ç¥© ®¡« |
á⨠|
â ©¨¯ ¤ íª¢¨¢ «¥â¥ ª®¯ª¥ ®â¬¥ , ª®â®à®© ¥âã ;), ¯à ¢¤ ¥á«¨ ®ª® á®®¡é¥¨ |
ï |
¯¥à¥¬¥áâ¨âì, £« ¢®¥ ®ª® ¥ ®¡®¢«ï¥âáï. â® ¢ë§¢ ® "ᯥæ¨ä¨ç¥áª¨¬" ª®¤®¬, â |
ª |
ª ª ¡®«¥¥ ¯à®á⮣® à¥è¥¨ï ï ¥ èñ«. |
ᯠᨡª å... |
ᥬ ᯠᨡ ! ¢«îè¨ã § ASCL, «ï¢¨ã, Willow ¨ ¢á¥¬ á 襣® ä®à㬠¯®¬®éì. |
¡ã¤ã饬... |
¥á«¨ ¯®«ãç¨âáï, ¬®¦® ¡ã¤¥â ॠ«¨§®¢ âì ¯®¤¤¥à¦ªã BGI èà¨ä⮢... ¥éñ ¥ ᬮâ५ |
¨å ª®¤ -- áâà è®! |
â®, ¡«%? |
DoomEd Archangel |
archangel@mail.kz / meos-wall.narod.ru |
-= [ v 3.75a ------> v 3.6 ] =- |
;****************************************************************************** |
; project name: TINYPAD |
; compiler: flat assmebler 1.52 alpha 3 |
; version: 3.75a |
; last update: 24/03/2004 |
; maintained by: Ivan Poddubny |
; e-mail: ivan-yar@bk.ru |
;****************************************************************************** |
; HISTORY: |
; 3.75a |
; fixed converting char to upper case in read_string |
; 3.75 |
; rewrote save_file from scratch; bugfix in loadfile; |
; 3.74 |
; optimisation |
; 3.73 |
; completly new load_file function |
; 3.72 |
; speed++ |
; 3.71 |
; error beep |
; 3.6,3.7: |
; many bugs fixed |
; simple toolbar |
; compile, run applications from TINYPAD, all fasm output is in debug board |
; TAB button |
; auto-indent |
; Ctrl+L - insert comment string |
;****************************************************************************** |
; Memory 0x300000: |
; stack 0x00eff0 - áâíª |
; stack for help 0x00fff0 - |
; stack for help 0x00fff0 |
/programs/other/tinypad2/trunk/archive.txt |
---|
0,0 → 1,8 |
«ï ç¨ îé¨å à ¡®â âì á MeOS - ®¯¨á ¨¥ ä ©«®¢ ¢ í⮬ à娢¥: |
tinypad - ᪮¬¯¨«¨à®¢ ë© ¨á¯®«ï¥¬ë© ä ©« MeOS |
tinypad.asm - ¨áå®¤ë© ª®¤ |
ascl.inc - assembler small code library ®â ¢«îè¨ ¢£¥¨ï |
(äãªæ¨ï label § ¬¥¥ putlabel) |
dialogs1.inc - ¤¨ «®£®¢ë¥ ®ª , messagebox'ë ¨ ¥ ®ç¥ì å®à®è¥¥ ¬¥î. |
macros.inc - ⮦¥ § ¬¥ç ⥫ìë© ¡®à ¬ ªà®á®¢. |
/programs/other/tinypad2/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm tinypad2.asm tinypad2 |
@pause |
/programs/other/tinypad2/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm tinypad2.asm tinypad2 |
@pause |
/programs/other/tinypad2/trunk/dialogs1.inc |
---|
0,0 → 1,597 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; ; |
; DIALOGS1.INC ; |
; ; |
; COMPILE WITH FASM for MENUET ; |
; ; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
menus dd 3 ; number of menus |
m_x dd 0x5 ; x start |
m_y dd 20 ; y start |
m_xs dd 290 ; x size |
m_ys dd 14 ; y size |
g_stack dd 0xf000 ; thread stack - required |
menu:; AB C D E F G |
db '*D FILE +Save File +Load File +- +Quit ' |
db '*B EDIT +Copy +Paste ' |
db '*B HELP +Setup +About.. ' |
db '@' ; end mark |
; A : Data type '*' -> New menu , '+' -> menu selection |
; B : Number of selections in menu (A+) |
; C : Menu header text |
; D-G : Menu selection text |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; |
; DATA BELOW IS FOR DIALOGS1.INC INTERNALS |
menu_action dd '----' |
window_on db 0 |
g_n dd -1 |
g_x dd 0x0 |
g_t dd 0x0 |
g_1 dd 0x0 |
g_l dd 0x0 |
closet db 0 |
table: times 1024 db 0 |
last_mouse dd 0x0 |
mo_x dd 0x0 |
mo_y dd 0x0 |
check_mouse: |
pusha |
cmp [window_on],1 |
je no_open |
mov eax,37 |
mov ebx,2 |
int 0x40 |
cmp [window_on],0 |
jne openw2 |
cmp eax,0 |
je no_open |
openw2: |
waitformouse: |
mov eax,23 |
mov ebx,2 |
int 0x40 |
cmp eax,0 |
jne no_open |
mov eax,37 |
mov ebx,2 |
int 0x40 |
cmp eax,0 |
jne waitformouse |
mov eax,37 |
mov ebx,1 |
int 0x40 |
mov esi,eax |
shr eax,16 |
xor edx,edx |
mov ebx,50 |
div ebx |
mov edx,eax |
cmp edx,[g_n] |
je no_open |
cmp edx,[menus] |
jge no_open |
mov eax,esi |
and eax,0xffff |
mov ebx,[m_y] |
cmp eax,ebx |
jbe no_open |
add ebx,[m_ys] |
cmp eax,ebx |
jge no_open |
cmp [window_on],0 |
je noww |
mov [closet],1 |
mov ecx,100 |
waitm: |
mov eax,5 |
mov ebx,1 |
int 0x40 |
dec ecx |
jz no_open |
cmp [window_on],0 |
jne waitm |
noww: |
mov eax,edx |
jmp cll |
no_open: |
mov [last_mouse],esi |
popa |
ret |
cll: |
mov [window_on],2 |
mov [g_n],eax |
mov [g_x],96 |
mov [g_t],0 |
mov [g_1],1 |
mov eax,9 |
mov ebx,table |
mov ecx,-1 |
int 0x40 |
mov eax,[table+34] |
mov [mo_x],eax |
mov eax,[table+38] |
mov [mo_y],eax |
mov eax,51 |
mov ebx,1 |
mov ecx,alert_entry |
mov edx,[g_stack] |
int 0x40 |
mov [esp+28],dword 0 ; clear button entry |
mov [menu_action],'MD ' |
check_gr: |
popa |
ret |
draw_menu: |
mov eax,9 |
mov ebx,table |
mov ecx,-1 |
int 0x40 |
cmp [table+46],dword 30 |
jb drmr |
mov eax,13 ; white background |
mov ebx,[m_x] |
shl ebx,16 |
add ebx,[m_xs] |
inc ebx |
mov ecx,[m_y] |
shl ecx,16 |
add ecx,[m_ys] |
mov edx,0xf0f8ff |
int 0x40 |
mov eax,38 ; egde lines |
mov ebx,[m_x] |
shl ebx,16 |
add ebx,[m_x] |
add ebx,[m_xs] |
mov ecx,[m_y] |
shl ecx,16 |
add ecx,[m_y] |
mov edx,0x000000 |
int 0x40 |
mov eax,38 |
mov ecx,[m_y] |
add ecx,[m_ys] |
shl ecx,16 |
add ecx,[m_y] |
add ecx,[m_ys] |
int 0x40 |
mov esi,menu-1 |
mov edi,[m_x] |
mov ebp,1 |
new_menu: |
inc esi |
cmp [esi],byte '*' |
jne drmnl1 |
push esi |
mov eax,4 |
mov ebx,edi |
shl ebx,16 |
add ebx,[m_y] |
add ebx,0x00050004 |
mov ecx,0x000000 |
mov edx,esi |
add edx,3 |
mov esi,12 |
int 0x40 ; draw text |
pop esi |
add esi,2 |
add edi,50 |
inc ebp |
drmnl1: |
cmp [esi],byte '@' |
jne new_menu |
drmr: |
ret |
alert_box: |
; eax : x size - min 200 |
; ebx : pointer to ASCIIZ - max 128 character text |
; ecx : button 1 id ( OK or YES ) |
; edx : button 2 id or zero ( NO ) |
cmp [window_on],0 |
jne alert_box_return |
mov [window_on],1 |
cmp eax,100 |
jg size_ok |
mov eax,100 |
size_ok: |
mov [g_x],eax |
mov [g_t],ebx |
mov [g_1],ecx |
mov ecx,0 |
new_search: |
cmp [ebx],byte 0 |
je found_len |
inc ebx |
inc ecx |
cmp ecx,128 |
jbe new_search |
found_len: |
mov [g_l],ecx |
mov eax,51 |
mov ebx,1 |
mov ecx,alert_entry |
mov edx,[g_stack] |
int 0x40 |
mov [menu_action],'MA ' |
alert_box_return: |
ret |
alert_entry: |
call alert_draw_window |
alert_still: |
mov eax,23 ; wait here for event |
mov ebx,1 |
int 0x40 |
cmp eax,1 ; redraw request ? |
je alert_red |
cmp eax,2 ; key in buffer ? |
je alert_key |
cmp eax,3 ; button in buffer ? |
je alert_button |
cmp [closet],0 |
jne ccc |
mov eax,9 |
mov ebx,table |
mov ecx,-1 |
int 0x40 |
cmp ax,[table+4] |
je no_close |
ccc: |
mov [closet],0 |
mov [g_n],-1 |
mov [menu_action],'----' |
mov [window_on],0 |
mov eax,-1 |
int 0x40 |
no_close: |
jmp alert_still |
alert_red: ; redraw |
call alert_draw_window |
jmp alert_still |
alert_key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp alert_still |
alert_button: ; button |
mov eax,17 ; get id |
int 0x40 |
shr eax,8 |
cmp eax,3 |
jg no_action1 |
dec eax |
shl eax,2 |
mov eax,dword [eax+rtext] |
mov [menu_action],eax |
jmp action_done |
no_action1: |
sub eax,16 |
add eax,65 |
shl eax,8 |
mov ebx,[g_n] |
add ebx,65 |
add eax,ebx |
mov [menu_action],eax |
action_done: |
mov [closet],0 |
mov [g_n],-1 |
mov [window_on],0 |
mov eax,-1 ; close this program |
int 0x40 |
rtext db 'NO YES OK ' |
jmp alert_still |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
alert_draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
cmp [window_on],2 |
jne no_win_type_2 |
mov edx,menu-1 |
mov ecx,[g_n] |
add ecx,1 |
find_menu: |
inc edx |
cmp [edx],byte '*' |
je menu_loop |
jmp find_menu |
menu_loop: |
loop find_menu |
movzx ebp,byte [edx+1] |
sub ebp,64 |
push edx |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,[g_n] |
imul ebx,50 |
add ebx,[mo_x] |
add ebx,[m_x] |
shl ebx,16 |
add ebx,[g_x] |
mov ecx,[mo_y] |
add ecx,[m_y] |
add ecx,[m_ys] |
shl ecx,16 |
mov edx,14 |
imul edx,ebp |
add edx,7 |
add ecx,edx |
mov edx,0x00ffffff ; color of work area RRGGBB,8->color gl |
mov esi,0x00ffffff ; color of grab bar RRGGBB,8->color gl |
mov edi,0x000000cc ; color of frames RRGGBB |
int 0x40 |
pop edx |
mov ebx,5*65536+7 ; draw info text with function 4 |
mov ecx,0x10000000 |
mov esi,12 |
mov ebp,16 |
no_d_found: |
inc edx |
cmp [edx],byte '*' |
je d_drawed |
cmp [edx],byte '@' |
je d_drawed |
cmp [edx],byte '+' |
jne no_d_found |
inc edx |
pusha ; draw button |
mov eax,8 |
mov ecx,ebx |
mov ebx,[g_x] |
add ebx,0x0000fffe |
shl ecx,16 |
add ecx,0xfffc0000+14 |
mov edx,0x40000000 |
add edx,ebp |
mov esi,0 |
int 0x40 |
popa |
mov eax,4 ; draw text |
int 0x40 |
inc ebp |
add ebx,14 |
jmp no_d_found |
d_drawed: |
no_win_type_2: |
cmp [window_on],1 |
jne no_win_1 |
mov eax,14 ; to middle of screen |
int 0x40 |
mov ecx,eax |
and ecx,0xffff |
shr ecx,1 |
shr eax,1 |
mov ebx,[g_x] |
shr ebx,1 |
shl ebx,16 |
sub eax,ebx |
mov ebx,eax |
mov eax,0 ; function 0 : define and draw window |
mov bx,word [g_x] |
sub ecx,80 |
shl ecx,16 |
mov cx,110 ; [y start] *65536 + [y size] |
mov edx,0x02ffffff ; color of work area RRGGBB,8->color gl |
mov esi,0x80d05050 ; color of grab bar RRGGBB,8->color gl |
mov edi,0x00d05050 ; color of frames RRGGBB |
int 0x40 |
mov eax,4 ; label |
mov ebx,8*65536+8 |
mov ecx,0x10ddeeff |
mov edx,alert_labelt1 |
mov esi,alert_label1len-alert_labelt1 |
int 0x40 |
mov eax,4 |
mov ebx,10*65536+43 |
mov ecx,0x10000000 |
mov edx,[g_t] |
mov esi,[g_l] |
int 0x40 |
cmp [g_1],1 |
jne gadgets_no_1 |
mov eax,8 |
mov ebx,[g_x] |
sub ebx,100 |
shr ebx,1 |
shl ebx,16 |
add ebx,30*65536+40 |
mov ecx,75*65536+16 |
mov edx,3 |
mov esi,0x446688 |
int 0x40 |
mov eax,4 |
mov ebx,[g_x] |
sub ebx,100 |
shr ebx,1 |
shl ebx,16 |
add ebx,31*65536+80 |
mov ecx,0x10ffffff |
mov edx,alert_t2 |
mov esi,alert_t2len-alert_t2 |
int 0x40 |
gadgets_no_1: |
cmp [g_1],2 |
jne gadgets_no_2 |
mov eax,8 |
mov ebx,[g_x] |
sub ebx,100 |
shr ebx,1 |
shl ebx,16 |
add ebx,0*65536+40 |
mov ecx,75*65536+16 |
mov edx,1 |
mov esi,0x446688 |
int 0x40 |
mov eax,8 |
mov ebx,[g_x] |
sub ebx,100 |
shr ebx,1 |
shl ebx,16 |
add ebx,57*65536+40 |
mov ecx,75*65536+16 |
mov edx,2 |
mov esi,0x446688 |
int 0x40 |
mov eax,4 |
mov ebx,[g_x] |
sub ebx,100 |
shr ebx,1 |
shl ebx,16 |
add ebx,1*65536+80 |
mov ecx,0x10ffffff |
mov edx,alert_t1 |
mov esi,alert_t1len-alert_t1 |
int 0x40 |
gadgets_no_2: |
no_win_1: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
; DATA AREA |
alert_t1: |
db ' No Yes' |
alert_t1len: |
alert_t2: |
db ' OK' |
alert_t2len: |
alert_labelt1: |
db 'ALERT' |
alert_label1len: |
/programs/other/tinypad2/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a { ; mike.dld |
if ~a eq |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; language for programs |
lang fix ru ; ru en fr ge fi |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
/programs/other/tinypad2/trunk/scroll.inc |
---|
0,0 → 1,440 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ; |
;; Scroll.inc ; |
;; ; |
;; Vertical Scroll Bar Example for MenuetOS ; |
;; ; |
;; Version 0.2 27 February 2005 ; |
;; ; |
;; ; |
;; GNU GENERAL PUBLIC LICENSE ; |
;; Version 2, June 1991 ; |
;; ; |
;; Copyright 2005 Jason Delozier, ; |
;; cordata51@hotmail.com ; |
;; ; |
;; See file COPYING for details ; |
;; ; |
;; Updates: ; |
;; - FPU not longer used for calculations -Feb 27, 2005 ; |
;; ; |
;; ; |
;; TODO: ; |
;; - Create Message Handler and only allow runtime arguments ; |
;; to be processed through the message handler ; |
;; - Remove all local varibles and only allow working varible to ; |
;; reside in scroll bar structure. ; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;***************************************************************************** |
;* |
;* VScroll Structure Equates |
;* |
;***************************************************************************** |
VScroll_width equ 0 |
VScroll_x equ 2 |
VScroll_height equ 4 |
VScroll_y equ 6 |
VScroll_min equ 8 |
VScroll_max equ 12 |
VScroll_current equ 16 |
VScroll_s_change equ 20 |
VScroll_b_change equ 24 |
;Example VScroll Structure |
;VScroll_1: |
; dw 16 ;width +0 |
; dw 100 ;x +2 |
; dw 200 ;height +4 |
; dw 40 ;y +6 |
; dd 0 ;min +8 |
; dd 1000;max +12 |
; dd 1 ;current +16 |
; dd 1 ;small change +20 |
; dd 10 ;big change +24 |
VScroll_Min_Height dw 16 ;scroll box |
Vscroll_Fixed_Height dw 16 ;height of scroll buttons (up and down) |
;************************************** |
;* |
;* Mouse Over VScroll |
;* |
;************************************** |
vsm1 dd 0 |
vstoff dd 0 |
VScroll_mouse_over: |
cmp [mouseb], 1 |
je VScroll_Mouse_Has_Mouse |
cmp [mouseb], 0 |
jne VScroll_mouse_over_done2 |
mov [vsm1], 0 |
jmp VScroll_mouse_over_done2 |
VScroll_Mouse_Has_Mouse: |
push ecx |
mov ecx, [vsm1] |
shl ecx,2 |
call dword [VScroll_Mouse_Jumptable+ecx] |
VScroll_mouse_over_done: |
pop ecx |
VScroll_mouse_over_done2: |
ret |
VScroll_Mouse_Jumptable: |
dd VScroll_Mouse_Find |
dd VScroll_Mouse_On_Up |
dd VScroll_Mouse_On_Down |
dd VScroll_Mouse_Above_Thumb |
dd VScroll_Mouse_Below_Thumb |
dd VScroll_Mouse_On_Thumb |
VScroll_Mouse_Find: |
inc ecx |
call dword [VScroll_Mouse_Jumptable+ecx*4] |
cmp [vsm1], 0 |
jne VScroll_mouse_over_done2 |
cmp ecx, 5 |
je VScroll_mouse_over_done2 |
jmp VScroll_Mouse_Find |
;************************************** |
;Is Mouse at Up button |
VScroll_Mouse_On_Up: |
push eax |
movzx eax, word [ebp+VScroll_y] |
add ax, word [Vscroll_Fixed_Height] |
cmp [mousey], ax |
pop eax |
ja VScroll_Mouse_On_Up2 |
mov [vsm1], 1 |
call VScroll_Small_Up |
VScroll_Mouse_On_Up2: |
ret |
;************************************** |
;Is Mouse at Down button |
VScroll_Mouse_On_Down: |
push eax |
movzx eax,word [ebp+VScroll_y] |
add ax, word [ebp+VScroll_height] |
sub ax, word [Vscroll_Fixed_Height] |
cmp [mousey], ax |
pop eax |
jb VScroll_Mouse_On_Down2 |
mov [vsm1], 2 |
call VScroll_Small_Down |
VScroll_Mouse_On_Down2: |
ret |
;************************************** |
;Is Mouse above Scroll Thumb |
VScroll_Mouse_Above_Thumb: |
push eax |
push ecx |
push edx |
call Vscroll_SBox_Area |
add cx, word [ebp+VScroll_y] |
add cx, word [Vscroll_Fixed_Height] ;plus height of scroll button |
cmp cx, [mousey] |
pop edx |
pop ecx |
pop eax |
jb VScroll_Mouse_Above_Thumb2 |
mov [vsm1], 3 |
call VScroll_Big_Up |
VScroll_Mouse_Above_Thumb2: |
ret |
;************************************** |
;Is Mouse below scroll thumb |
VScroll_Mouse_Below_Thumb: |
push eax |
push ecx |
push edx |
call Vscroll_SBox_Area |
add cx, word [ebp+VScroll_y] |
add cx, word [Vscroll_Fixed_Height] ;plus height of scroll button |
add cx, ax |
cmp cx, [mousey] |
pop edx |
pop ecx |
pop eax |
ja VScroll_Mouse_Below_Thumb2 |
mov [vsm1], 4 |
call VScroll_Big_Down |
VScroll_Mouse_Below_Thumb2: |
ret |
;************************************** |
;Mouse is on Scroll Thumb |
VScroll_Mouse_On_Thumb: |
pusha |
cmp [vsm1], 5 ;first time moving since we clicked? |
je VScroll_Mouse_On_Thumb1 ;if not jump.. we already have offset |
mov [vsm1], 5 ;determine offset between mouse pointer and top of thumb |
call Vscroll_SBox_Area ;get top of thumb coordinate |
add cx, word [ebp+VScroll_y] ;make screen coordinate |
add cx, word [Vscroll_Fixed_Height] ;plus height of scroll button and top |
movzx esi,word [mousey] ;get mouse position |
sub esi, ecx ;make offset between top of thumb |
mov [vstoff], esi ;and mouse pointer then save it |
VScroll_Mouse_On_Thumb1: ; |
movzx esi, [mousey] ;get mouse y value |
sub si, word [ebp+VScroll_y] ;get y starting value of scroll bar |
sub si, [Vscroll_Fixed_Height] |
sub esi, [vstoff] ; |
call Vscroll_SBox_Area ; |
VScroll_Mouse_On_Thumb2: ; |
cmp [ebp+VScroll_current], edx ;only redraw if change occured |
je VScroll_Mouse_On_Thumb3 ; |
mov [ebp+VScroll_current], edx ;new current value |
call drawvscrolla ;redraw scroll background and thumb |
VScroll_Mouse_On_Thumb3: ; |
popa ; |
ret |
;************************************** |
;***************************************************************************** |
;* |
;* Vscroll_SBox_Area |
;* |
;* Purpose: To determine the area of the Scroll Bar Thumb and the current |
;* value of scroll based on top pixel of thumb. |
;* |
;* Inputs: |
;* EBP - Structure of scroll bar |
;* ESI - Top of Thumb - optional |
;* |
;* Outputs: |
;* EAX - Thumb Height |
;* ECX - Top of thumb |
;* EDX - Current Value based on top pixel of thumb. Valid when ESI |
;* is given as input. |
;* |
;* This procedure is divided up into 5 specific functions. |
;* 1. ((Vmax-VMin)/Small Change)= Total Changes |
;* 2. Height - (2* Fixed Button Height) = Total Pixels |
;* 3. Total Pixels - Total Changes = Thumb Height (must be >= 16) |
;* Minimum Height of 16 is varible [VScroll_Min_Height] |
;* 4. (((Tot Pixels - Thumb Height)* Current)/Max-min)=Top Pixel of Thumb |
;* 5. ((Mouse Top * (max-Min))/(Total Pix - Thumb Height)) = Current |
;* Step 5 is only valid if ESI is supplied as an input. |
;* |
;* |
;***************************************************************************** |
Vscroll_SBox_Area: |
push ebx |
push esi |
push edi |
;Step 1. Determine Total Changes |
mov eax, dword [ebp+VScroll_max] ;get max scroll |
sub eax, dword [ebp+VScroll_min] ;sub minmum scroll for total scro |
xor edx,edx |
push eax |
div dword [ebp+VScroll_s_change] ; |
;eax = total changes ((max-min)/Small Change) |
;Step 2. Determine Total Pixels |
movzx ecx, word [ebp+VScroll_height] ;height of entire scroll bar |
mov bx, word [Vscroll_Fixed_Height] ;minus height of both scroll button |
shl bx, 1 |
sub cx, bx |
push ecx |
;ecx = total pixels (Total Height - (2*Fixed Button Height) |
;Step 3. Determine Thumb Height |
cmp ecx, eax |
jbe vs1 |
sub ecx, eax |
cmp cx, word [VScroll_Min_Height] |
jb vs1 |
jmp vs2 |
vs1: |
movzx ecx, word [VScroll_Min_Height] |
vs2: |
;ecx = Thumb Height (Total Pixels - Total Changes) >=16 |
;Step 4. Determine Top Pixel of Thumb |
pop edi ;Total Pixels |
sub edi, ecx ; |
;edi = Total Pixels - thumb Height |
mov eax, edi ; |
mul dword [ebp+VScroll_current] ;get current scroll value |
pop ebx ;max scroll |
push ecx ; |
div ebx ; |
mov ecx, eax ; |
;ecx = top pixel of thumb |
;Step 5. Determine Current Value based on Mouse Position |
cmp si,0 |
jge vss4 |
mov eax, dword [ebp+VScroll_min] |
jmp vsdone1 |
vss4: |
cmp esi, edi |
jbe vss3 |
mov eax, dword [ebp+VScroll_max] |
jmp vsdone1 |
vss3: |
mov eax,ebx ;max scroll |
mul esi ;Top Pixel of mouse |
div edi ;Total Pixels - Thumb Height |
;eax = Current Value |
vsdone1: |
mov edx, eax ;Current Value |
pop eax ;Thumb Height |
pop edi |
pop esi |
pop ebx |
ret |
;***************************************************************************** |
;* |
;***************************************************************************** |
;ebp is structure |
drawvscroll: |
pusha |
;up button |
mov eax, 13 ;button system function |
mov edx,0x00777777 ;0x6677cc ;color |
mov ebx, [ebp+VScroll_width] ;x-start/width |
mov cx, word [ebp+VScroll_y] ;get bottom of scroll bar |
shl ecx, 16 |
mov cx, [Vscroll_Fixed_Height] ;fixed height |
int 0x40 |
;down button |
mov ebx, [ebp+VScroll_width] ;x-start/width |
mov cx, word [ebp+VScroll_y] ;get bottom of scroll bar |
add cx, word [ebp+VScroll_height] ; |
sub cx, [Vscroll_Fixed_Height] ;y-start is 12 pixel from bottom |
shl ecx, 16 ; |
mov cx, [Vscroll_Fixed_Height] ;fixed height |
int 0x40 |
;------- 'ASCL.INC' needs to be included to use this -- |
putlabel 493,46,'',cl_Black |
putlabel 493,372,'',cl_Black |
;------------------------------------------------------ |
popa |
drawvscrolla: |
pusha |
mov eax, 13 ;Draw Scroll Box Background |
mov edx, 0x00999999;0 ;color |
push edx |
movzx edx, word [Vscroll_Fixed_Height] |
mov ebx, [ebp+VScroll_width] ;x-start/width |
movzx ecx,word [ebp+VScroll_y] ;y-start |
add ecx, edx ;add fixed height button |
shl ecx, 16 ;do height next |
mov cx,word [ebp+VScroll_height] ;y-start |
sub cx, dx ;subtract fixed height of up button |
sub cx, dx ;subtract fixed height of down button |
pop edx |
int 0x40 ;tell system to draw it |
;determine height of scroll box (thumb) |
call Vscroll_SBox_Area |
add cx, [ebp+VScroll_y] |
add cx, 16 |
shl ecx, 16 |
mov cx, ax |
mov eax, 13 ;draw scroll box |
mov ebx, [ebp+VScroll_width] ;x-start/width |
mov edx, 0x00bbbbbb ;0x999999 |
int 0x40 |
;call Draw_Scroll_info |
popa |
ret |
;***************************************************************************** |
;***************************************************************************** |
;* VScroll_Big_Up |
;* VScroll_Small_Up |
;***************************************************************************** |
;need to update for signed values |
VScroll_Big_Up: |
push eax |
push ebx |
mov eax, dword [ebp+VScroll_b_change] |
jmp VScroll_Up |
VScroll_Small_Up: |
push eax |
push ebx |
mov eax, dword [ebp+VScroll_s_change] |
VScroll_Up: |
mov ebx, dword [ebp+VScroll_min] ;get minimum value |
cmp [ebp+VScroll_current], ebx ;are we at minimum already? |
je VScroll_Up_exit ;if so leave |
sub [ebp+VScroll_current], eax ; |
jnc VScroll_Up_done |
mov [ebp+VScroll_current], ebx |
VScroll_Up_done: |
cmp [ebp+VScroll_current], ebx ;if current is greater then max |
jae VScroll_Up_done2 |
mov [ebp+VScroll_current], ebx |
VScroll_Up_done2: |
;redraw |
call drawvscroll ;temp? |
VScroll_Up_exit: |
pop ebx |
pop eax |
ret |
;***************************************************************************** |
;***************************************************************************** |
;* VScroll_Big_Down |
;* VScroll_Small_Down |
;***************************************************************************** |
;need to update for signed values |
VScroll_Big_Down: |
push eax |
push ebx |
mov eax, dword [ebp+VScroll_b_change];get big change value |
jmp VScroll_Down |
VScroll_Small_Down: |
push eax |
push ebx |
mov eax, dword [ebp+VScroll_s_change];get small change value |
VScroll_Down: |
mov ebx, dword [ebp+VScroll_max] ;get maximum scroll value |
cmp [ebp+VScroll_current], ebx ;are we at max already? |
je VScroll_Down_exit ;if so leave |
add [ebp+VScroll_current], eax ;add change to current |
jno VScroll_Down_done ;dont go beyond bounds of register |
mov [ebp+VScroll_current], ebx ;if we did then we at max |
VScroll_Down_done: ; |
cmp [ebp+VScroll_current], ebx ;if current is greater then max |
jbe VScroll_Down_done2 ; |
mov [ebp+VScroll_current], ebx ;then we at max |
VScroll_Down_done2: ; |
;redraw |
call drawvscroll ;temp? |
VScroll_Down_exit: |
pop ebx |
pop eax |
ret |
;***************************************************************************** |
/programs/fs/kfar/trunk/kfar.asm |
---|
3596,14 → 3596,12 |
dd aJpg, jpegview |
dd aJpeg, jpegview |
dd aGif, gifview |
dd aWav, ac97 |
dd aMp3, ac97 |
dd aWav, ac97wav |
dd aMp3, ac97wav |
dd aMid, midamp |
dd aBmp, mv |
dd aPng, archer |
dd aRtf, rtfread |
dd a3ds, view3ds |
dd aLif, life2 |
associations_end: |
aAsm db 'asm',0 |
3620,7 → 3618,7 |
aWav db 'wav',0 |
aMp3 db 'mp3',0 |
ac97 db '/rd/1/AC97SND',0 |
ac97wav db '/rd/1/AC97WAV',0 |
aMid db 'mid',0 |
midamp db '/rd/1/MIDAMP',0 |
3634,12 → 3632,6 |
aRtf db 'rtf',0 |
rtfread db '/rd/1/RtfRead',0 |
a3ds db '3ds',0 |
view3ds db '/rd/1/3d/view3ds',0 |
aLif db 'lif',0 |
life2 db '/rd/1/demos/life2',0 |
bConfirmDelete db 1 |
; ¤¥áì § ª 稢 îâáï ª®ä¨£ãà æ¨®ë¥ ¤ ë¥ |
/programs/fs/sysxtree/trunk/sysxtree.asm |
---|
607,11 → 607,9 |
mov ebx, gifview |
cmp ecx, 'GIF' |
jz run |
mov ebx, ac97 |
mov ebx, ac97wav |
cmp ecx, 'WAV' |
jz run |
cmp ecx, 'MP3' |
jz run |
mov ebx, midamp |
cmp ecx, 'MID' |
jz run |
633,12 → 631,6 |
jz run |
cmp ecx, 'INC' |
jz run |
mov ebx, life2 |
cmp ecx, 'LIF' |
jz run |
mov ebx, view3ds |
cmp ecx, '3DS' and not 0x20202020 |
jz run |
jmp still |
execute: |
2548,14 → 2540,12 |
bmpview db '/RD/1/MV',0 |
jpgview db '/RD/1/JPEGVIEW',0 |
gifview db '/RD/1/GIFVIEW',0 |
ac97 db '/RD/1/AC97SND',0 |
ac97wav db '/RD/1/AC97WAV',0 |
rtfread db '/RD/1/RTFREAD',0 |
; //// Willow |
pngview db '/RD/1/@RCHER',0 |
; //// Willow |
midamp db '/RD/1/MIDAMP',0 |
view3ds db '/RD/1/3D/VIEW3DS',0 |
life2 db '/RD/1/DEMOS/LIFE2',0 |
more_char db 10h |
/programs/fs/sysxtree/trunk/macros.inc |
---|
1,3 → 1,15 |
; language for programs |
lang fix en ; ru en fr ge fi |
@^ fix macro comment { |
^@ fix } |
macro m2m dest,src { |
push src |
pop dest |
} |
; new application structure |
macro meos_app_start |
{ |
77,35 → 89,72 |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
name db data |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
if lang eq lng |
db data |
end if |
common |
.size = $-name |
end if |
} |
macro szc name,elsz,[data] { ; from MFAR [mike.dld] |
common |
local s,m |
m = 0 |
if used name |
label name |
virtual at 0 |
db data |
s = $ |
end virtual |
d#elsz s |
if m < s |
m = s |
end if |
db data |
.size = $-name |
.maxl = m |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
macro lszc name,elsz,[lng,data] { ; from MFAR [mike.dld] |
common |
local s,m,c |
m = 0 |
c = 0 |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
if lang eq lng |
virtual at 0 |
db data |
s = $ |
end virtual |
d#elsz s |
if m < s |
m = s |
end if |
db data |
c = c+1 |
end if |
common |
if used name |
.size = $-name |
.maxl = m |
.count = c |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
123,6 → 172,12 |
end if |
} |
;macro __mov reg,a { ; mike.dld |
; if ~a eq |
; mov reg,a |
; end if |
;} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
142,7 → 197,72 |
} |
; ------------------------- |
macro header a,[b] { |
common |
use32 |
org 0 |
db 'MENUET',a |
forward |
if b eq |
dd 0 |
else |
dd b |
end if } |
macro section name { align 16 |
label name } |
macro func name { |
if ~used name |
display 'FUNC NOT USED: ',`name,13,10 |
else |
align 4 |
name: |
;pushad |
;pushfd |
;dps `name |
;newline |
;mcall 5,1 |
;popfd |
;popad |
} |
macro endf { end if } |
macro diff16 title,l1,l2 |
{ |
local s,d |
s = l2-l1 |
display title,': 0x' |
repeat 8 |
d = '0' + s shr ((8-%) shl 2) and $0F |
if d > '9' |
d = d + 'A'-'9'-1 |
end if |
display d |
end repeat |
display 13,10 |
} |
macro diff10 title,l1,l2 |
{ |
local s,d,z,m |
s = l2-l1 |
z = 0 |
m = 1000000000 |
display title,': ' |
repeat 10 |
d = '0' + s / m |
s = s - (s/m)*m |
m = m / 10 |
if d <> '0' |
z = 1 |
end if |
if z <> 0 |
display d |
end if |
end repeat |
display 13,10 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 294,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
194,54 → 314,230 |
} |
macro RGB [a] { |
common |
match (r=,g=,b),a \{ |
\dd ((r) shl 16) or ((g) shl 8) or (b) |
\} |
} |
struc POINT _t,_dx,_dy { |
.x _t _dx |
.y _t _dy |
} |
; Macroinstructions for defining data structures |
macro struct name |
{ |
{ fields@struct equ name |
match child parent, name \{ fields@struct equ child,fields@\#parent \} |
sub@struct equ |
struc db [val] \{ \common fields@struct equ fields@struct,.,db,<val> \} |
struc dw [val] \{ \common fields@struct equ fields@struct,.,dw,<val> \} |
struc du [val] \{ \common fields@struct equ fields@struct,.,du,<val> \} |
struc dd [val] \{ \common fields@struct equ fields@struct,.,dd,<val> \} |
struc dp [val] \{ \common fields@struct equ fields@struct,.,dp,<val> \} |
struc dq [val] \{ \common fields@struct equ fields@struct,.,dq,<val> \} |
struc dt [val] \{ \common fields@struct equ fields@struct,.,dt,<val> \} |
struc rb count \{ fields@struct equ fields@struct,.,db,count dup (?) \} |
struc rw count \{ fields@struct equ fields@struct,.,dw,count dup (?) \} |
struc rd count \{ fields@struct equ fields@struct,.,dd,count dup (?) \} |
struc rp count \{ fields@struct equ fields@struct,.,dp,count dup (?) \} |
struc rq count \{ fields@struct equ fields@struct,.,dq,count dup (?) \} |
struc rt count \{ fields@struct equ fields@struct,.,dt,count dup (?) \} |
macro db [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,db,<val> \} |
macro dw [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dw,<val> \} |
macro du [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,du,<val> \} |
macro dd [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dd,<val> \} |
macro dp [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dp,<val> \} |
macro dq [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dq,<val> \} |
macro dt [val] \{ \common \local anonymous |
fields@struct equ fields@struct,anonymous,dt,<val> \} |
macro rb count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,db,count dup (?) \} |
macro rw count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dw,count dup (?) \} |
macro rd count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dd,count dup (?) \} |
macro rp count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dp,count dup (?) \} |
macro rq count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dq,count dup (?) \} |
macro rt count \{ \local anonymous |
fields@struct equ fields@struct,anonymous,dt,count dup (?) \} |
macro union \{ fields@struct equ fields@struct,,union,< |
sub@struct equ union \} |
macro struct \{ fields@struct equ fields@struct,,substruct,< |
sub@struct equ substruct \} |
virtual at 0 } |
macro ends |
{ match , sub@struct \{ restruc db,dw,du,dd,dp,dq,dt |
restruc rb,rw,rd,rp,rq,rt |
purge db,dw,du,dd,dp,dq,dt |
purge rb,rw,rd,rp,rq,rt |
purge union,struct |
match name=,fields,fields@struct \\{ fields@struct equ |
make@struct name,fields |
fields@\\#name equ fields \\} |
end virtual \} |
match any, sub@struct \{ fields@struct equ fields@struct> \} |
restore sub@struct } |
macro make@struct name,[field,type,def] |
{ common |
if $ |
display 'Error: definition of ',`name,' contains illegal instructions.',0Dh,0Ah |
err |
end if |
local define |
define equ name |
forward |
local sub |
match , field \{ make@substruct type,name,sub def |
define equ define,.,sub, \} |
match any, field \{ define equ define,.#field,type,<def> \} |
common |
match fields, define \{ define@struct fields \} } |
macro define@struct name,[field,type,def] |
{ common |
local list |
list equ |
forward |
if ~ field eq . |
name#field type def |
sizeof.#name#field = $ - name#field |
else |
rb sizeof.#type |
end if |
local value |
match any, list \{ list equ list, \} |
list equ list <value> |
common |
sizeof.#name = $ |
restruc name |
match values, list \{ |
struc name value \\{ |
match any, fields@struct \\\{ fields@struct equ fields@struct,.,name,<values> \\\} |
match , fields@struct \\\{ label . |
forward |
match , value \\\\{ field type def \\\\} |
match any, value \\\\{ field type value |
if ~ field eq . |
rb sizeof.#name#field - ($-field) |
end if \\\\} |
common \\\} \\} \} } |
macro enable@substruct |
{ macro make@substruct substruct,parent,name,[field,type,def] |
\{ \common |
\local define |
define equ parent,name |
\forward |
\local sub |
match , field \\{ match any, type \\\{ enable@substruct |
make@substruct type,name,sub def |
purge make@substruct |
define equ define,.,sub, \\\} \\} |
match any, field \\{ define equ define,.\#field,type,<def> \\} |
\common |
match fields, define \\{ define@\#substruct fields \\} \} } |
enable@substruct |
macro define@union parent,name,[field,type,def] |
{ common |
virtual at 0 |
name name |
sizeof.#name = $ - name |
forward |
if ~ field eq . |
virtual at 0 |
parent#field type def |
sizeof.#parent#field = $ - parent#field |
end virtual |
} |
if sizeof.#parent#field > $ |
rb sizeof.#parent#field - $ |
end if |
else if sizeof.#type > $ |
rb sizeof.#type - $ |
end if |
common |
sizeof.#name = $ |
end virtual |
struc name [value] \{ \common |
label .\#name |
last@union equ |
forward |
match any, last@union \\{ virtual at .\#name |
field type def |
end virtual \\} |
match , last@union \\{ match , value \\\{ field type def \\\} |
match any, value \\\{ field type value \\\} \\} |
last@union equ field |
common rb sizeof.#name - ($ - .\#name) \} } |
macro define@substruct parent,name,[field,type,def] |
{ common |
virtual at 0 |
forward |
if ~ field eq . |
parent#field type def |
sizeof.#parent#field = $ - parent#field |
else |
rb sizeof.#type |
end if |
local value |
common |
sizeof.#name = $ |
end virtual |
struc name value \{ |
label .\#name |
forward |
match , value \\{ field type def \\} |
match any, value \\{ field type value |
if ~ field eq . |
rb sizeof.#parent#field - ($-field) |
end if \\} |
common \} } |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
} |
struct process_information |
cpu_usage dd ? ; +0 |
window_stack_position dw ? ; +4 |
window_stack_value dw ? ; +6 |
not_used1 dw ? ; +8 |
process_name rb 12 ; +10 |
memory_start dd ? ; +22 |
used_memory dd ? ; +26 |
PID dd ? ; +30 |
x_start dd ? ; +34 |
y_start dd ? ; +38 |
x_size dd ? ; +42 |
y_size dd ? ; +46 |
slot_state dw ? ; +50 |
rb (1024-52) |
ends |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
frame dd ? |
grab dd ? |
grab_button dd ? |
grab_button_text dd ? |
grab_text dd ? |
work dd ? |
work_button dd ? |
work_button_text dd ? |
work_text dd ? |
work_graph dd ? |
ends |
; constants |
/programs/fs/copyr/trunk/macros.inc |
---|
143,6 → 143,9 |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
174,7 → 177,7 |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & ((arg2 eqtype 0) | (arg2 eqtype '0')) |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
218,13 → 221,7 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
dw ? ; +52 - reserved |
.client_left dd ? ; +54 |
.client_top dd ? ; +58 |
.client_width dd ? ; +62 |
.client_height dd ? ; +66 |
.wnd_state db ? ; +70 |
rb (1024-71) |
rb (1024-52) |
} |
struct process_information |
/programs/fs/hexhd/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm hexhd.asm hexhd |
@pause |
/programs/fs/hexhd/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm hexhd.asm hexhd |
@pause |
/programs/fs/hexhd/trunk/hexhd.asm |
---|
0,0 → 1,235 |
; |
; EXAMPLE APPLICATION |
; |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x5000 ; required amount of memory |
dd 0x5000 ; esp = 0x7FFF0 |
dd 0x00000000 ; reserved=no extended header |
include 'lang.inc' |
include 'macros.inc' |
START: ; start of execution |
call open_file |
call draw_window ; at first, draw the window |
still: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
je red |
cmp eax,2 ; key in buffer ? |
je key |
cmp eax,3 ; button in buffer ? |
je button |
jmp still |
red: ; redraw |
call draw_window |
jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp still |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne noclose |
mov eax,-1 ; close this program |
int 0x40 |
noclose: |
cmp ah,2 |
jne noexam |
jmp still |
noexam: |
cmp ah,3 |
jne noback |
mov edi,block |
cmp dword [edi],0 |
je nonext |
dec dword [edi] |
call open_file |
call draw_window |
noback: |
cmp ah,4 |
jne nonext |
mov edi,block |
inc dword [edi] |
call open_file |
call draw_window |
nonext: |
jmp still |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,0*65536+400 ; [x start] *65536 + [x size] |
mov ecx,0*65536+270+200 ; [y start] *65536 + [y size] |
mov edx,0x038899aa;1111cc ; color of work area RRGGBB,8->c |
int 0x40 |
mov eax,4 ; function 4 : write text to window |
mov ebx,144*65536+8 ; [x start] *65536 + [y start] |
mov ecx,0x00ffffff ; color of text RRGGBB |
mov edx,labelt ; pointer to text beginning |
mov esi,labellen-labelt ; text length |
int 0x40 |
mov eax,47 ;decimal |
mov ecx,[block] |
mov edx,64*65536+34 |
mov ebx,10 |
shl ebx,16 |
mov esi,0x00ffffff |
int 0x40 |
add edx,128*65536 ;hex |
mov bh,1 |
int 0x40 |
mov eax,8 |
mov ebx,280*65536+16*6 |
mov ecx,30*65536+14 |
mov edx,2 |
mov esi,0x3f49df;5599cc |
int 0x40 |
mov ebx,15*65536+32 |
add edx,1 |
mov eax,8 |
int 0x40 |
add ebx,127*65536 |
add edx,1 |
mov eax,8 |
int 0x40 |
mov eax,4 |
mov ebx,14*65536+33 |
mov ecx,0xffffff |
mov edx,buttons |
mov esi,blen-buttons |
int 0x40 |
mov ebx,280*65536+65 ; draw info text with function 4 |
mov ecx,0xffffff |
mov edx,text |
mov esi,16 |
mov edi,16*2 |
newline: |
pusha ; hext |
mov edi,16 |
mov ecx,edx |
mov edx,ebx |
sub edx,265*65536 |
newhex: |
mov eax,47 |
mov ebx,0x00020101 |
xor esi,0xffff00 |
int 0x40 |
add edx,16*65536 |
add ecx,1 |
dec edi |
jne newhex |
popa |
mov eax,4 ; text |
int 0x40 |
add ebx,12 |
add edx,16 |
dec edi |
jnz newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
open_file: |
pusha |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
popa |
ret |
; DATA AREA |
fileinfo: |
dd 8 |
block dd 0 |
dd 1 |
dd text |
dd os |
db '/HARDDISK/FIRST',0 |
labelt: |
db 'EDITOR HEXADECIMAL' |
labellen: |
buttons db ' << >> << OPTIONS >> ' |
blen: |
os: |
times 16384 db ? |
text: |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/fs/hexhd/trunk/macros.inc |
---|
0,0 → 1,265 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a { ; mike.dld |
if ~a eq |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/fs/rdfdel/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm rdfdel.asm rdfdel |
@pause |
/programs/fs/rdfdel/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm rdfdel.asm rdfdel |
@pause |
/programs/fs/rdfdel/trunk/macros.inc |
---|
0,0 → 1,266 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/fs/rdfdel/trunk/rdfdel.asm |
---|
0,0 → 1,232 |
; |
; FILE COPIER |
; |
; Compile with FASM for Menuet |
; |
use32 |
org 0x0 |
db 'MENUET00' ; 8 byte id |
dd 38 ; required os |
dd START ; program start |
dd I_END ; program image size |
dd 0x1000 ; required amount of memory |
dd 0x1000 |
dd 0 ; reserved=no extended header |
include "lang.inc" |
include "macros.inc" |
START: ; start of execution |
call draw_window ; at first, draw the window |
still: |
mov eax,10 ; wait here for event |
int 0x40 |
cmp eax,1 ; redraw request ? |
jz red |
cmp eax,2 ; key in buffer ? |
jz key |
cmp eax,3 ; button in buffer ? |
jz button |
jmp still |
red: ; redraw |
call draw_window |
jmp still |
key: ; key |
mov eax,2 ; just read it and ignore |
int 0x40 |
jmp still |
button: ; button |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jnz noclose |
mov eax,0xffffffff ; close this program |
int 0x40 |
noclose: |
cmp ah,3 ; delete ? |
jnz nodelete |
mov eax,32 |
mov ebx,destination |
int 0x40 |
jmp still |
nodelete: |
cmp ah,4 |
jz f2 |
jmp nof12 |
f2: |
mov [addr],dword destination |
mov [ya],dword 35 |
jmp rk |
rk: |
mov edi,[addr] |
mov al,' ' |
mov ecx,11 |
rep stosb |
call print_text |
mov edi,[addr] |
f11: |
mov eax,10 |
int 0x40 |
cmp eax,2 |
jz fbu |
jmp still |
fbu: |
mov eax,2 |
int 0x40 |
shr eax,8 |
cmp eax,8 |
jnz nobs |
cmp edi,[addr] |
jz f11 |
sub edi,1 |
mov [edi],byte 0 |
call print_text |
jmp f11 |
nobs: |
cmp eax,dword 31 |
jbe f11 |
cmp eax,dword 95 |
jb keyok |
sub eax,32 |
keyok: |
mov [edi],al |
call print_text |
add edi,1 |
mov esi,[addr] |
add esi,11 |
cmp esi,edi |
jnz f11 |
jmp still |
print_text: |
mov eax,13 |
mov ebx,109*65536+11*6 |
mov ecx,[ya] |
shl ecx,16 |
mov cx,8 |
mov edx,0xffffff |
int 0x40 |
mov eax,4 |
mov ebx,109*65536 |
add ebx,[ya] |
mov ecx,0x000000 |
mov edx,[addr] |
mov esi,11 |
int 0x40 |
ret |
nof12: |
jmp still |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,1 ; 1, start of draw |
int 0x40 |
; DRAW WINDOW |
mov eax,0 ; function 0 : define and draw window |
mov ebx,100*65536+230 ; [x start] *65536 + [x size] |
mov ecx,100*65536+105 ; [y start] *65536 + [y size] |
mov edx,0x03ffffff ; color of work area RRGGBB |
int 0x40 |
; WINDOW LABEL |
mov eax,4 ; function 4 : write text to window |
mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
mov ecx,0x10ffffff ; color of text RRGGBB |
mov edx,header ; pointer to text beginning |
mov esi,header.len ; text length |
int 0x40 |
mov esi,0xbbbbbb |
mov eax,8 ; DELETE BUTTON |
mov ebx,20*65536+190 |
mov ecx,63*65536+15 |
mov edx,3 |
int 0x40 |
mov eax,8 |
mov ebx,200*65536+10 |
mov ecx,33*65536+10 |
mov edx,4 |
int 0x40 |
mov esi,destination |
mov edi,text+14 |
mov ecx,11 |
cld |
rep movsb |
mov ebx,25*65536+35 ; draw info text with function 4 |
mov ecx,0x0 |
mov edx,text |
mov esi,40 |
newline: |
mov eax,4 |
int 0x40 |
add ebx,16*2 |
add edx,40 |
cmp [edx],byte 'x' |
jnz newline |
mov eax,12 ; function 12:tell os about windowdraw |
mov ebx,2 ; 2, end of draw |
int 0x40 |
ret |
; DATA AREA |
destination db 'EXAMPLE.ASM' |
addr dd 0x0 |
ya dd 0x0 |
text: |
db 'FILENAME : yyyyyyyyyyy ' |
db ' DELETE FROM RAMDISK ' |
db 'x' ; <- END MARKER, DONT DELETE |
header: |
db 'RAMDISK FILE DELETE' |
.len = $ - header |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/games/freecell/Pick.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/games/freecell/DiamSml.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/games/freecell/build.bat |
---|
File deleted |
\ No newline at end of file |
/programs/games/freecell/Cross.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/games/freecell/Buben.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/games/freecell/HeartUD.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/games/freecell/Spade.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/games/freecell/ClubSml.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/games/freecell/Heart.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/games/freecell/DiamUD.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/games/freecell/play.txt |
---|
File deleted |
/programs/games/freecell/SpadeSml.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/games/freecell/Diam.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/games/freecell/ClubUD.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/games/freecell/HeartSml.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/games/freecell/MACROS.INC |
---|
File deleted |
\ No newline at end of file |
/programs/games/freecell/freecell.ASM |
---|
File deleted |
\ No newline at end of file |
/programs/games/freecell/SpadeUD.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/games/freecell/Club.bmp |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/programs/games/pipes/pipes.asm |
---|
File deleted |
/programs/games/pipes/build.bat |
---|
File deleted |
\ No newline at end of file |
/programs/games/pipes/pipes.raw |
---|
File deleted |
\ No newline at end of file |
/programs/games/tetris/trunk/tetris.asm |
---|
220,7 → 220,7 |
jmp still |
end_program: |
or eax,-1 ; close this program |
mov eax,-1 ; close this program |
int 0x40 |
go_new_game: |
/programs/games/life/trunk/ascl.inc |
---|
0,0 → 1,835 |
lang equ ru ; ru en fr ge fi |
; |
; Assembler |
; SMALL |
; CODE |
; Libary |
; |
; Ver 0.14 By Pavlushin Evgeni (RUSSIA) |
; www.waptap@mail.ru |
;Please compile aplications on FASM ver1.54 or higer!!! |
;InfoList |
;0.01 scank,putpix,puttxt |
;0.02 label,random,colors |
;0.03 window,startwd,endwd,attributes |
;0.04 close,delay,scevent ~30.04.2004 |
;0.05 small random, ~04.05.2004 |
;0.06 wtevent ~09.05.2004 |
;0.07 timeevent ~23.05.2004 |
;0.08 txtput ~14.06.2004 |
;0.09 opendialog,savedialog ~20.06.2004 |
;0.10 wordstoreg by halyavin, add at ~30.08.2004 |
; random bug deleted eax is use. |
;0.11 loadfile from me +puttxt bug del ~07.09.2004 |
;0.12 open/save dialog ~13.09.2004 |
;0.13 dialogs bugs deleted |
;0.14 drawlbut ~03.10.2004 |
; LOADFILE |
; (SYNTAX) LOADFILE 'full_path_to_file',file_load_area,file_temp_area |
; (SAMPLE) LOADFILE '/rd/1/clock.bmp',load_area,temp_area |
macro loadfile file_name,file_load_area,file_temp_area |
{ |
local open,fileinfo,string |
jmp open |
fileinfo: |
dd 0 |
dd 0 |
dd 1 |
dd file_load_area |
dd file_temp_area |
string: |
db file_name,0 |
open: |
mov dword [fileinfo+8],1 ; how many blocks to read (1) |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
mov eax,[file_load_area+2] |
shr eax,9 ; ¯®¤¥«¨¬ 512 ¨ ¯à¨¡ ¢¨¬ 1 - ¯®«ã稬 ç¨á«® ¡«®ª®¢ |
inc eax |
mov dword [fileinfo+8],eax |
mov eax,58 |
mov ebx,fileinfo |
int 0x40 |
} |
macro wordstoreg reg,hiword,loword |
{ |
if hiword eqtype 0 & loword eqtype 0 |
mov reg,hiword*65536+loword |
else if hiword eqtype 12 & loword eqtype eax |
mov reg,hiword*65536 |
add reg,loword |
else if hiword eqtype 12 & loword eqtype [123] |
mov reg,hiword*65536 |
add reg,loword |
else |
mov reg,hiword |
shl reg,16 |
add reg,loword |
end if |
} |
; DRAW BUTTON with label |
macro drawlbut x,y,xs,ys,text,id,bcolor,tcolor |
{ |
local asd,lab |
jmp asd |
lab db text ;arg label |
asd: |
wordstoreg ebx,x,xs |
wordstoreg ecx,y,ys |
mov edx,id |
mov esi,bcolor |
mov eax,8 |
int 0x40 |
mov eax,asd-lab ;calc size |
mov ebx,6 |
mul ebx |
mov esi,eax |
mov eax,xs |
sub eax,esi |
shr eax,1 |
add eax,x |
mov edx,ys |
sub edx,7 |
shr edx,1 |
add edx,y |
mov ebx,eax |
shl ebx,16 |
add ebx,edx |
mov ecx,tcolor ;arg4 color |
mov edx,lab |
mov esi,asd-lab ;calc size |
mov eax,4 |
int 0x40 |
} |
macro opendialog redproc,openoff,erroff,path |
{ |
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc |
local run_fileinfo, param |
local getmesloop, loox, mred, mkey, mbutton, mgetmes |
local dlg_is_work, ready, procinfo |
; |
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec, |
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save) |
; |
cld |
;; mov esi,path |
mov edi,path |
mov eax,0 |
mov ecx,200 |
rep stosb |
;mov [get_loops],0 |
mov [dlg_pid_get],0 |
; Get my PID in dec format 4 bytes |
mov eax,9 |
mov ebx,procinfo |
mov ecx,-1 |
int 0x40 |
; convert eax bin to param dec |
mov eax,dword [procinfo+30] ;offset of myPID |
mov edi,param+4-1 ;offset to 4 bytes |
mov ecx,4 |
mov ebx,10 |
cld |
new_d: |
xor edx,edx |
div ebx |
add dl,'0' |
mov [edi],dl |
dec edi |
loop new_d |
; wirite 1 byte space to param |
mov [param+4],byte 32 ;Space for next parametr |
; and 1 byte type of dialog to param |
mov [param+5],byte 'O' ;Get Open dialog (Use 'S' for Save dialog) |
; |
; STEP2 prepare IPC area for get messages |
; |
; prepare IPC area |
mov [path],dword 0 |
mov [path+4],dword 8 |
; define IPC memory |
mov eax,60 |
mov ebx,1 ; define IPC |
mov ecx,path ; offset of area |
mov edx,150 ; size 150 bytes |
int 0x40 |
; change wanted events list 7-bit IPC event |
mov eax,40 |
mov ebx,01000111b |
int 0x40 |
; |
; STEP 3 run SYSTEM XTREE with parameters |
; |
mov eax,58 |
mov ebx,run_fileinfo |
int 0x40 |
call redproc |
mov [get_loops],0 |
getmesloop: |
mov eax,23 |
mov ebx,50 ;0.5 sec |
int 0x40 |
cmp eax,1 |
je mred |
cmp eax,2 |
je mkey |
cmp eax,3 |
je mbutton |
cmp eax,7 |
je mgetmes |
; Get number of procces |
mov ebx,procinfo |
mov ecx,-1 |
mov eax,9 |
int 0x40 |
mov ebp,eax |
loox: |
mov eax,9 |
mov ebx,procinfo |
mov ecx,ebp |
int 0x40 |
mov eax,[DLGPID] |
cmp [procinfo+30],eax ;IF Dialog find |
je dlg_is_work ;jmp to dlg_is_work |
dec ebp |
jnz loox |
jmp erroff |
dlg_is_work: |
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated |
je erroff ;TESTODP2 terminated too |
cmp [dlg_pid_get],dword 1 |
je getmesloop |
inc [get_loops] |
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated |
jae erroff |
jmp getmesloop |
mred: |
call redproc |
jmp getmesloop |
mkey: |
mov eax,2 |
int 0x40 ; read (eax=2) |
jmp getmesloop |
mbutton: |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne getmesloop |
mov eax,-1 ; close this program |
int 0x40 |
mgetmes: |
; If dlg_pid_get then second message get jmp to still |
cmp [dlg_pid_get],dword 1 |
je ready |
; First message is number of PID SYSXTREE dialog |
; convert PID dec to PID bin |
movzx eax,byte [path+16] |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+1] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+2] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+3] |
add eax,ebx |
sub eax,48 |
mov [DLGPID],eax |
; Claear and prepare IPC area for next message |
mov [path],dword 0 |
mov [path+4],dword 8 |
mov [path+8],dword 0 |
mov [path+12],dword 0 |
mov [path+16],dword 0 |
; Set dlg_pid_get for get next message |
mov [dlg_pid_get],dword 1 |
call redproc ;show DLG_PID |
jmp getmesloop |
ready: |
; |
; The second message get |
; Second message is 100 bytes path to SAVE/OPEN file |
; shl path string on 16 bytes |
; |
cld |
mov esi,path+16 |
mov edi,path |
mov ecx,200 |
rep movsb |
mov [edi],byte 0 |
jmp openoff |
; DATA AREA |
get_loops dd 0 |
dlg_pid_get dd 0 |
DLGPID dd 0 |
param: |
dd 0 ; My dec PID |
dd 0,0 ; Type of dialog |
run_fileinfo: |
dd 16 |
dd 0 |
dd param |
dd 0 |
dd procinfo ; 0x10000 |
;run_filepath |
db '/RD/1/SYSXTREE',0 |
procinfo: |
times 256 db 0 |
} |
macro savedialog redproc,openoff,erroff,path |
{ |
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc |
local run_fileinfo, run_filepath, param |
local getmesloop, loox, mred, mkey, mbutton, mgetmes |
local dlg_is_work, ready, procinfo |
; |
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec, |
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save) |
; |
cld |
;; mov esi,path |
mov edi,path |
mov eax,0 |
mov ecx,200 |
rep stosb |
;mov [get_loops],0 |
mov [dlg_pid_get],0 |
; Get my PID in dec format 4 bytes |
mov eax,9 |
mov ebx,procinfo |
mov ecx,-1 |
int 0x40 |
; convert eax bin to param dec |
mov eax,dword [procinfo+30] ;offset of myPID |
mov edi,param+4-1 ;offset to 4 bytes |
mov ecx,4 |
mov ebx,10 |
cld |
new_d: |
xor edx,edx |
div ebx |
add dl,'0' |
mov [edi],dl |
dec edi |
loop new_d |
; wirite 1 byte space to param |
mov [param+4],byte 32 ;Space for next parametr |
; and 1 byte type of dialog to param |
mov [param+5],byte 'S' ;Get Open dialog (Use 'S' for Save dialog) |
; |
; STEP2 prepare IPC area for get messages |
; |
; prepare IPC area |
mov [path],dword 0 |
mov [path+4],dword 8 |
; define IPC memory |
mov eax,60 |
mov ebx,1 ; define IPC |
mov ecx,path ; offset of area |
mov edx,120 ; size 150 bytes |
int 0x40 |
; change wanted events list 7-bit IPC event |
mov eax,40 |
mov ebx,01000111b |
int 0x40 |
; |
; STEP 3 run SYSTEM XTREE with parameters |
; |
mov eax,58 |
mov ebx,run_fileinfo |
int 0x40 |
call redproc |
mov [get_loops],0 |
getmesloop: |
mov eax,23 |
mov ebx,50 ;0.5 sec |
int 0x40 |
cmp eax,1 |
je mred |
cmp eax,2 |
je mkey |
cmp eax,3 |
je mbutton |
cmp eax,7 |
je mgetmes |
; Get number of procces |
mov ebx,procinfo |
mov ecx,-1 |
mov eax,9 |
int 0x40 |
mov ebp,eax |
loox: |
mov eax,9 |
mov ebx,procinfo |
mov ecx,ebp |
int 0x40 |
mov eax,[DLGPID] |
cmp [procinfo+30],eax ;IF Dialog find |
je dlg_is_work ;jmp to dlg_is_work |
dec ebp |
jnz loox |
jmp erroff |
dlg_is_work: |
cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated |
je erroff ;TESTODP2 terminated too |
cmp [dlg_pid_get],dword 1 |
je getmesloop |
inc [get_loops] |
cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated |
jae erroff |
jmp getmesloop |
mred: |
call redproc |
jmp getmesloop |
mkey: |
int 0x40 ; read (eax=2) |
jmp getmesloop |
mbutton: |
mov eax,17 ; get id |
int 0x40 |
cmp ah,1 ; button id=1 ? |
jne getmesloop |
mov eax,-1 ; close this program |
int 0x40 |
mgetmes: |
; If dlg_pid_get then second message get jmp to still |
cmp [dlg_pid_get],dword 1 |
je ready |
; First message is number of PID SYSXTREE dialog |
; convert PID dec to PID bin |
movzx eax,byte [path+16] |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+1] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+2] |
add eax,ebx |
sub eax,48 |
imul eax,10 |
movzx ebx,byte [path+16+3] |
add eax,ebx |
sub eax,48 |
mov [DLGPID],eax |
; Claear and prepare IPC area for next message |
mov [path],dword 0 |
mov [path+4],dword 8 |
mov [path+8],dword 0 |
mov [path+12],dword 0 |
mov [path+16],dword 0 |
; Set dlg_pid_get for get next message |
mov [dlg_pid_get],dword 1 |
call redproc ;show DLG_PID |
jmp getmesloop |
ready: |
; |
; The second message get |
; Second message is 100 bytes path to SAVE/OPEN file |
; shl path string on 16 bytes |
; |
cld |
mov esi,path+16 |
mov edi,path |
mov ecx,200 |
rep movsb |
mov [edi],byte 0 |
jmp openoff |
; DATA AREA |
get_loops dd 0 |
dlg_pid_get dd 0 |
DLGPID dd 0 |
param: |
rb 4 ; My dec PID |
rb 6 ; Type of dialog |
run_fileinfo: |
dd 16 |
dd 0 |
dd param |
dd 0 |
dd procinfo |
run_filepath: |
db '/RD/1/SYSXTREE',0 |
procinfo: |
times 256 db 0 |
} |
; RANDOM - generate random count (small) |
; (SYNTAX) RANDOM MaxCount,OutArgument |
; (SAMPLE) RANDOM 10000,eax |
; ( NOTE ) Maxint<65536 ; use random 65536,eax for more combinations |
randomuse = 0 |
macro random arg1,arg2 |
{ |
local rxproc |
randomuse = randomuse + 1 |
jmp rxproc |
if defined randomuse & randomuse = 1 |
randomproc: |
jmp rnj |
rsx1 dw 0x4321 |
rsx2 dw 0x1234 |
rnj: |
; mov eax,arg1 |
push bx |
push cx |
push dx |
push si |
push di |
mov cx,ax |
mov ax,word ptr rsx1 |
mov bx,word ptr rsx2 |
mov si,ax |
mov di,bx |
mov dl,ah |
mov ah,al |
mov al,bh |
mov bh,bl |
xor bl,bl |
rcr dl,1 |
rcr ax,1 |
rcr bx,1 |
add bx,di |
adc ax,si |
add bx,0x62e9 |
adc ax,0x3619 |
mov word ptr rsx1,bx |
mov word ptr rsx2,ax |
xor dx,dx |
cmp ax,0 |
je nodiv |
cmp cx,0 |
je nodiv |
div cx |
nodiv: |
mov ax,dx |
pop di |
pop si |
pop dx |
pop cx |
pop bx |
and eax,0000ffffh |
; mov arg2,0 |
; mov arg2,eax |
ret |
end if |
rxproc: |
mov eax,arg1 |
call randomproc |
mov arg2,eax |
} |
macro scank |
{ |
mov eax,10 |
int 0x40 |
} |
macro putpix x,y,color |
{ |
mov ebx,x |
mov ecx,y |
mov edx,color |
mov eax,1 |
int 0x40 |
} |
macro puttxt x,y,offs,size,color |
{ |
; mov ebx,x |
; shl ebx,16 |
; add ebx,y |
wordstoreg ebx,x,y |
mov ecx,color |
mov edx,offs |
mov esi,size |
mov eax,4 |
int 0x40 |
} |
macro outcount data, x, y, color, numtype |
{ |
mov ecx,data |
mov ebx,numtype |
mov bl,0 |
; mov edx,x*65536+y |
wordstoreg edx,x,y |
mov esi,color |
mov eax,47 |
int 0x40 |
} |
; SCEVENT - Scan event |
macro scevent red,key,but |
{ |
mov eax,11 |
int 0x40 |
dec eax |
jz red |
dec eax |
jz key |
dec eax |
jz but |
} |
; WTEVENT - Wait event |
macro wtevent red,key,but |
{ |
mov eax,10 |
int 0x40 |
dec eax |
jz red |
dec eax |
jz key |
dec eax |
jz but |
} |
; TIMEEVENT - Wite for event with timeout |
macro timeevent xfps,noevent,red,key,but |
{ |
mov eax,23 |
mov ebx,xfps |
int 0x40 |
cmp eax,0 |
je noevent |
dec eax |
jz red |
dec eax |
jz key |
dec eax |
jz but |
} |
; CLOSE - Close program |
macro close |
{ |
mov eax,-1 |
int 0x40 |
} |
; DELAY - Create delay 1/100 sec |
; (SYNTAX) Delay time |
; (SAMPLE) Delay 100 ;delay 2 sec 1/100*200=2 sec |
macro delay arg1 |
{ |
mov eax,5 |
mov ebx,arg1 |
int 0x40 |
} |
; WINDOW - Draw window |
; (SYNTAX) WINDOW Xstart,Ystart,'Text',Color |
; (SAMPLE) WINDOW 10,10,640+8,480+24,window_Skinned |
macro window arg1,arg2,arg3,arg4,arg5 |
{ |
; mov ebx,arg1*65536+arg3 |
; mov ecx,arg2*65536+arg4 |
wordstoreg ebx,arg1,arg3 |
wordstoreg ecx,arg2,arg4 |
mov edx,arg5 |
mov eax,0 |
int 0x40 |
} |
macro colorwindow arg1,arg2,arg3,arg4,arg5,arg6,arg7 |
{ |
mov ebx,arg1*65536+arg3 |
mov ecx,arg2*65536+arg4 |
mov edx,arg5 |
mov esi,arg6 |
mov edi,arg7 |
mov eax,0 |
int 0x40 |
} |
; STARTWD - Start of window draw |
macro startwd |
{ |
mov eax,12 |
mov ebx,1 |
int 0x40 |
} |
; ENDWD - End window draw |
macro endwd |
{ |
mov eax,12 |
mov ebx,2 |
int 0x40 |
} |
; LABEL - Put text to frame |
; (SYNTAX) LABEL Xstart,Ystart,'Text',Color |
; (SAMPLE) LABEL 10,12,'Hello World!',cl_Green+font_Big |
macro label arg1,arg2,arg3,arg4 |
{ |
local asd,lab |
jmp asd |
lab db arg3 ;arg label |
asd: |
; mov ebx,arg1 ;arg1=y arg2=x |
; shl ebx,16 |
; add ebx,arg2 |
wordstoreg ebx,arg1,arg2 |
mov ecx,arg4 ;arg4 color |
mov edx,lab |
mov esi,asd-lab ;calc size |
mov eax,4 |
int 0x40 |
} |
;Key's |
key_Up equ 178 |
key_Down equ 177 |
key_Right equ 179 |
key_Left equ 176 |
key_Esc equ 27 |
key_Space equ 32 |
key_Enter equ 13 |
key_Bspace equ 8 |
key_F1 equ 50 |
key_F2 equ 51 |
key_F3 equ 52 |
key_F4 equ 53 |
key_F5 equ 54 |
key_F6 equ 55 |
key_F7 equ 56 |
key_F8 equ 57 |
key_F9 equ 48 |
key_F10 equ 49 |
key_F11 equ 68 |
key_F12 equ 255 |
key_Home equ 180 |
key_End equ 181 |
key_PgUp equ 184 |
key_PgDown equ 183 |
;Attributes |
;Window Attributes |
window_Skinned equ 0x03000000 |
window_Type2 equ 0x02000000 |
window_Type1 equ 0x00000000 |
window_Reserve equ 0x01000000 |
;Font Attributes |
font_Big equ 0x10000000 |
;Colors |
cl_White equ 0x00ffffff |
cl_Black equ 0x00000000 |
cl_Grey equ 0x00888888 |
cl_Red equ 0x00ff0000 |
cl_Lime equ 0x0000ff00 |
cl_Green equ 0x0000af00 |
cl_Blue equ 0x000000ff |
cl_Purple equ 0x008080ff |
cl_Violet equ 0x008040ff |
cl_Cyan equ 0x0040e0ff |
/programs/games/life/trunk/life.asm |
---|
0,0 → 1,190 |
; |
; LIFE.ASM |
; |
; This program displays Conways game of life |
; |
; Compile with FASM for Menuet; |
; |
; |
; Version 0.1 30th March 2004 |
; Mike Hibbett |
; |
; Version 0.2 23th May 2004 |
; Random generation dots with start |
; |
; Convert to ASCL Libary by Pavlushin Evgeni |
; |
; This is an experiment to see how small a usefull application can get |
; |
use32 |
org 0x0 |
db 'MENUET01' ; 8 byte id |
dd 0x01 ; header version |
dd START ; start of code |
dd I_END ; size of image |
dd 0x100000 ; memory for app |
dd 0x100000 ; esp |
dd 0x0 , 0x0 ; I_Param , I_Icon |
include 'ascl.inc' |
macro setcell x,y { mov [esi + 512*(y)*3 + (x)*3], al } |
START: |
mov al, 0xFF |
mov esi, I_END |
; This is the seed pattern. |
; Life needs a seed pattern, which is 'hardcode' at compile time |
; The grid is 512 wide (x direction) by 512 deep (y direction) |
; setcell take the arguments setcell x,y |
; 0,0 is the top left corner. |
setcell 200,120 |
setcell 201,120 |
setcell 200,121 |
setcell 199,121 |
setcell 200,122 |
setcell 70,120 |
setcell 71,120 |
setcell 70,121 |
setcell 69,121 |
setcell 70,122 |
call draw_window |
;Random generation dots |
mov ecx,20000 |
xxx: |
push ecx |
random 30000,edi ;up pice of screen |
mov al,0xff |
shl edi,3 |
; mov [I_END+edi],al |
; random 50000,edi ;down pice of screen |
; mov al,0xff |
; shl edi,3 |
add edi,512*460 ;760 |
mov [I_END+edi],al |
pop ecx |
dec ecx |
jnz xxx |
still: |
timeevent 5,nokey,red,key,button ;Wait EVENT with 5 fps |
jmp still |
red: ; REDRAW WINDOW |
call draw_window |
jmp still |
key: ; KEY |
mov eax,2 ; get it, but ignore |
int 0x40 |
nokey: |
; cycle life state |
mov esi, I_END + 512*3 |
mov al, 0xFF |
lifeloop: |
mov ah, 0 |
cmp [esi - 3], al |
jne t2 |
inc ah |
t2: |
cmp [esi + 3], al |
jne t3 |
inc ah |
t3: |
cmp [esi - 512*3], al |
jne t4 |
inc ah |
t4: |
cmp [esi + 512*3], al |
jne t5 |
inc ah |
t5: |
cmp [esi - 512*3 - 3], al |
jne t6 |
inc ah |
t6: |
cmp [esi - 512*3 + 3], al |
jne t7 |
inc ah |
t7: |
cmp [esi + 512*3 - 3], al |
jne t8 |
inc ah |
t8: |
cmp [esi + 512*3 + 3], al |
jne tend |
inc ah |
tend: |
; If cell is empty but has 3 neigbours, birth |
; If cell is occupied and has 2,3 neigbours, live |
; else die |
cmp ah, 3 |
jne btest |
mov [esi+1], al |
jmp nextcell |
btest: |
cmp ah, 2 |
jne nextcell |
cmp [esi], al |
jne nextcell |
mov [esi+1], al |
nextcell: |
add esi, 3 |
cmp esi, I_END + 512*512*3 |
jne lifeloop |
; copy new generation across |
mov ecx, 512*512*3 |
mov esi, I_END+1 |
mov edi, I_END |
rep movsb ; copy the data across |
mov ecx, 512*512 |
mov esi, I_END |
nc1: |
mov [esi+2], byte 0 |
add esi, 3 |
loop nc1 |
mov ebx, I_END |
mov ecx, 512*65536+512 |
mov edx, 5*65536+20 |
mov eax,7 |
int 0x40 |
jmp still |
button: ; BUTTON - only close supported |
close |
; ********************************************* |
; ******* WINDOW DEFINITIONS AND DRAW ******** |
; ********************************************* |
draw_window: |
startwd |
window 50,50,512+9,512+23,window_Skinned |
label 8,8,'Life Screen',cl_White+font_Big |
endwd |
ret |
I_END: |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/programs/games/life/trunk/build_en.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix en >lang.inc |
@fasm life.asm life |
@pause |
/programs/games/life/trunk/build_ru.bat |
---|
0,0 → 1,4 |
@erase lang.inc |
@echo lang fix ru >lang.inc |
@fasm life.asm life |
@pause |
/programs/games/life/trunk/macros.inc |
---|
0,0 → 1,267 |
; new application structure |
macro meos_app_start |
{ |
use32 |
org 0x0 |
db 'MENUET01' |
dd 0x01 |
dd __start |
dd __end |
dd __memory |
dd __stack |
if used __params & ~defined __params |
dd __params |
else |
dd 0x0 |
end if |
dd 0x0 |
} |
MEOS_APP_START fix meos_app_start |
macro code |
{ |
__start: |
} |
CODE fix code |
macro data |
{ |
__data: |
} |
DATA fix data |
macro udata |
{ |
if used __params & ~defined __params |
__params: |
db 0 |
__end: |
rb 255 |
else |
__end: |
end if |
__udata: |
} |
UDATA fix udata |
macro meos_app_end |
{ |
align 32 |
rb 2048 |
__stack: |
__memory: |
} |
MEOS_APP_END fix meos_app_end |
; macro for defining multiline text data |
struc mstr [sstring] |
{ |
forward |
local ssize |
virtual at 0 |
db sstring |
ssize = $ |
end virtual |
dd ssize |
db sstring |
common |
dd -1 |
} |
; strings |
macro sz name,[data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if used name |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
common |
if used name |
label name |
end if |
forward |
if (used name)&(lang eq lng) |
db data |
end if |
common |
if used name |
.size = $-name |
end if |
} |
; easy system call macro |
macro mpack dest, hsrc, lsrc |
{ |
if (hsrc eqtype 0) & (lsrc eqtype 0) |
mov dest, (hsrc) shl 16 + lsrc |
else |
if (hsrc eqtype 0) & (~lsrc eqtype 0) |
mov dest, (hsrc) shl 16 |
add dest, lsrc |
else |
mov dest, hsrc |
shl dest, 16 |
add dest, lsrc |
end if |
end if |
} |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
; optimize the code for size |
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp> |
macro add arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
inc arg1 |
else |
add arg1,arg2 |
end if |
else |
add arg1,arg2 |
end if |
} |
macro sub arg1,arg2 |
{ |
if (arg2 eqtype 0) |
if (arg2) = 1 |
dec arg1 |
else |
sub arg1,arg2 |
end if |
else |
sub arg1,arg2 |
end if |
} |
macro mov arg1,arg2 |
{ |
if (arg1 in __regs) & (arg2 eqtype 0) |
if (arg2) = 0 |
xor arg1,arg1 |
else if (arg2) = 1 |
xor arg1,arg1 |
inc arg1 |
else if (arg2) = -1 |
or arg1,-1 |
else if (arg2) > -128 & (arg2) < 128 |
push arg2 |
pop arg1 |
else |
mov arg1,arg2 |
end if |
else |
mov arg1,arg2 |
end if |
} |
macro struct name |
{ |
virtual at 0 |
name name |
sizeof.#name = $ - name |
end virtual |
} |
; structures used in MeOS |
struc process_information |
{ |
.cpu_usage dd ? ; +0 |
.window_stack_position dw ? ; +4 |
.window_stack_value dw ? ; +6 |
.not_used1 dw ? ; +8 |
.process_name rb 12 ; +10 |
.memory_start dd ? ; +22 |
.used_memory dd ? ; +26 |
.PID dd ? ; +30 |
.x_start dd ? ; +34 |
.y_start dd ? ; +38 |
.x_size dd ? ; +42 |
.y_size dd ? ; +46 |
.slot_state dw ? ; +50 |
rb (1024-52) |
} |
struct process_information |
struc system_colors |
{ |
.frame dd ? |
.grab dd ? |
.grab_button dd ? |
.grab_button_text dd ? |
.grab_text dd ? |
.work dd ? |
.work_button dd ? |
.work_button_text dd ? |
.work_text dd ? |
.work_graph dd ? |
} |
struct system_colors |
; constants |
; events |
EV_IDLE = 0 |
EV_TIMER = 0 |
EV_REDRAW = 1 |
EV_KEY = 2 |
EV_BUTTON = 3 |
EV_EXIT = 4 |
EV_BACKGROUND = 5 |
EV_MOUSE = 6 |
EV_IPC = 7 |
EV_STACK = 8 |
; event mask bits for function 40 |
EVM_REDRAW = 1b |
EVM_KEY = 10b |
EVM_BUTTON = 100b |
EVM_EXIT = 1000b |
EVM_BACKGROUND = 10000b |
EVM_MOUSE = 100000b |
EVM_IPC = 1000000b |
EVM_STACK = 10000000b |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |