Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 485 → Rev 484

/programs/media/pic4/trunk/pic4.asm
12,7 → 12,7
dd I_Param,0
 
include 'lang.inc'
include '..\..\..\macros.inc'
include 'macros.inc'
 
START:
mov eax,48
31,16 → 31,18
still:
 
mov eax,10 ; wait here for event
mcall
 
dec eax
int 0x40
cmp eax,1
jz red
dec eax
jnz button
cmp eax,2
jz key
cmp eax,3
jz button
jmp still
 
key:
mov al,2
mcall
mov eax,2
int 0x40
jmp still
 
red:
48,10 → 50,11
jmp still
 
button:
mov al,17
mcall
mov eax,17
int 0x40
 
shr eax,8
and eax,255
 
cmp eax,101 ; tiled
jne no101
58,10 → 61,10
mov eax,15
mov ebx,4
mov ecx,1
mcall
int 0x40
mov eax,15
mov ebx,3
mcall
int 0x40
jmp still
no101:
 
70,18 → 73,18
mov eax,15
mov ebx,4
mov ecx,2
mcall
int 0x40
mov eax,15
mov ebx,3
mcall
int 0x40
jmp still
no102:
 
cmp eax,1 ; end program
jnz no_end
jnz noproend
or eax,-1
mcall
no_end:
int 0x40
noproend:
 
cmp eax,11
jz bg
123,7 → 126,7
mov ebx,1
mov ecx,256
mov edx,256
mcall
int 0x40
 
mov eax,15
mov ebx,5
131,19 → 134,19
; <<< 0x40000+2 for green background at boot
mov edx,0
mov esi,256*3*256
mcall
int 0x40
 
mov eax,15
mov ebx,4
mov ecx,2
mcall
int 0x40
 
mov eax,15
mov ebx,3
mcall
int 0x40
 
mov eax,-1
mcall
int 0x40
 
 
 
191,7 → 194,7
mov ebx,1
mov ecx,256
mov edx,256
mcall
int 0x40
 
mov eax,15
mov ebx,5
198,11 → 201,11
mov ecx,edi
mov edx,0
mov esi,256*256*3
mcall
int 0x40
 
mov eax,15
mov ebx,3
mcall
int 0x40
 
jmp still
 
213,30 → 216,35
 
push eax
 
mcall 15,4,1
 
mov eax,15
mov ebx,1
mov ecx,1
mov edx,1
mcall
mov ecx,8
mov edx,8
int 0x40
 
pop eax
mov eax,[esp]
 
sub eax,14
imul eax,3
shl eax,2
 
mov ecx,fill
add ecx,eax
mov edx,[colors+eax]
 
mov esi,32*32*4
mov edi,0
mov ecx,0
dbl2:
mov eax,15
mov ebx,5
xor edx,edx
mov esi,3*1*1
mcall
mov ebx,2
int 0x40
add ecx,3
inc edi
cmp edi,esi
jb dbl2
 
 
mov eax,15
mov ebx,3
mcall
int 0x40
 
jmp still
 
253,11 → 261,11
 
mov eax,15
mov ebx,1
mcall
int 0x40
 
mov eax,15
mov ebx,3
mcall
int 0x40
 
jmp still
 
354,7 → 362,7
mov ebx,0x40000
mov ecx,256*65536+255
mov edx,14*65536+40;55
mcall
int 0x40
 
ret
 
369,7 → 377,7
 
mov eax, 12 ; tell os about draw
mov ebx, 1
mcall
int 0x40
 
xor eax, eax ; define and draw window
mov ebx, 220*65536+293
376,8 → 384,8
mov ecx, 50*65536+408
mov edx, [sc.work]
or edx, 0x33000000
mov edi, title
mcall
mov edi, header
int 0x40
 
call draw_image
 
386,17 → 394,17
mov ecx,y_add*65536+y_s
mov edx,11
mov esi,0x005555bb
mcall
int 0x40
;mov eax,8 ; Red button
mov ebx,(set+208+27)*65536+17
mov edx,12
mov esi,0x00bb5555
mcall
int 0x40
;mov eax,8 ; Green button
mov ebx,(set+253)*65536+17
mov edx,13
mov esi,0x0055bb55
mcall
int 0x40
 
;mov eax, 8 ; tiled
mov ebx, 90*65536+63
403,12 → 411,12
mov ecx, y_add*65536+y_s
mov edx, 101
mov esi, [sc.work_button]
mcall
int 0x40
 
;mov eax, 8 ; stretch
mov ebx, 154*65536+61
mov edx, 102
mcall
int 0x40
 
mov eax, 4
mov ebx, 215*65536+5
415,17 → 423,17
mov ecx, [sc.work_text]
mov edx, apply_text
mov esi, apply_text.size
mcall
int 0x40
 
mov ebx, 14*65536+301
mov edx, image_buttons_text
mov esi, image_buttons_text.size
mcall
int 0x40
 
mov ebx, 14*65536+(y_add2+27)
mov edx, simple_text
mov esi, simple_text.size
mcall
int 0x40
 
mov ecx, (y_add2)*65536+20
mov ebx, (13)*65536+25
434,7 → 442,7
mov edi, 9
mov eax, 8
@@:
mcall
int 0x40
add ebx, 29*65536
inc edx
dec edi
443,11 → 451,11
 
mov edx, 34+4
mov edi, 4
;mov eax, 8
mov eax, 8
mov ebx, 13*65536+18
mov ecx, y_add*65536+y_s
@@:
mcall
int 0x40
inc edx
add ebx, 19*65536
dec edi
455,7 → 463,6
 
 
;-----------------------
mov eax,8
mov edx,14 ; button number
mov ebx,(13)*65536+17 ; button start x & size
mov ecx,(y_add2+40)*65536+14 ; button start y & size
463,10 → 470,12
newcb:
mov esi,[(edx-14)*4+colors]
 
mcall
mov eax,8
int 0x40
 
inc edx
add ebx,20*65536
add esi,5*256*256
 
cmp edx,27
jnz newcb
477,11 → 486,11
mov ecx, [sc.work_button_text]
mov edx, la2
mov esi, la2.size
mcall
int 0x40
 
mov eax,12
mov ebx,2
mcall
int 0x40
 
ret
 
490,9 → 499,9
; DATA SECTION
 
if lang eq ru
title db 'ƒ¥­¥à â®à ä®­  à ¡®ç¥£® á⮫ ',0
header db 'ƒ¥­¥à â®à ä®­  à ¡®ç¥£® á⮫ ',0
else
title db 'Background',0
header db 'Background',0
end if
 
lsz apply_text,\
526,23 → 535,9
dd 0x775533
dd 0x773355
dd 0x553377
dd 0x111111
dd 0x000000
dd 0xcccccc
 
fill:
db 0x00,0x00,0x77
db 0x00,0x77,0x00
db 0x77,0x00,0x00
db 0x00,0x77,0x77
db 0x77,0x00,0x77
db 0x77,0x77,0x00
db 0x77,0x77,0x77
db 0x77,0x55,0x33
db 0x33,0x55,0x77
db 0x55,0x33,0x77
db 0x77,0x33,0x55
db 0x11,0x11,0x11
db 0xcc,0xcc,0xcc
 
shape:
 
/programs/media/pic4/trunk/build_en.bat
1,5 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm pic4.asm pic4
@erase lang.inc
@pause
/programs/media/pic4/trunk/build_ru.bat
1,5 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm pic4.asm pic4
@erase lang.inc
@pause
/programs/media/pic4/trunk/macros.inc
0,0 → 1,269
; 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) | (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
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
 
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