Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 30 → Rev 31

/programs/plasma/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm plasma.asm plasma
@pause
/programs/plasma/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm plasma.asm plasma
@pause
/programs/plasma/trunk/graph8.inc
0,0 → 1,16
blit_8_to_32:
mov esi,virtual_screen_8 ; ESI=src
mov edi,virtual_screen_32 ; EDI=dst
mov ecx,WND_SIZE_X*WND_SIZE_Y ; ECX=size
.blit_next:
xor eax,eax ; EAX=byte to blit
mov al,[esi]
shl eax,2
mov eax,[_palette+eax]
mov [edi],ax
shr eax,16
mov [edi+2],al
inc esi
add edi,3
loop .blit_next
ret
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/plasma/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/plasma/trunk/plasma.asm
0,0 → 1,186
; Originally written by Jarek Pelczar
include "lang.inc"
include "macros.inc"
 
WND_SIZE_X = 320
WND_SIZE_Y = 200
 
MEOS_APP_START
CODE
fninit
mov al,40
mov bl,101b
int 0x40
call init_palette
call init_texture
jmp .paint_window
.event_loop:
mov al,23
mov ebx,1
int 0x40
test eax,eax
je .draw_screen
dec eax
je .paint_window
 
or eax,-1
int 0x40
 
.draw_screen:
call blit_8_to_32
mov al,7
mov ebx,virtual_screen_32
mov ecx,(WND_SIZE_X shl 16)+WND_SIZE_Y
mov edx,(4 shl 16)+24
int 0x40
call rotate_pal
jmp .event_loop
 
.paint_window:
mov al,12
push eax
xor ebx,ebx
inc ebx
int 0x40
 
xor eax,eax
mov ebx,(100 shl 16)+(WND_SIZE_X+8)
mov ecx,(100 shl 16)+(WND_SIZE_Y+28)
mov edx,0x03000000
int 0x40
 
mov al,7
mov ebx,virtual_screen_32
mov ecx,(WND_SIZE_X shl 16)+WND_SIZE_Y
mov edx,(4 shl 16)+24
int 0x40
 
mov al,4
mov ebx,0x00060006
mov ecx,0x10ffffff
mov edx,window_title
mov esi,window_title_len
int 0x40
 
pop eax
and ebx,2 ; bit 1 is set
int 0x40
 
jmp .event_loop
 
init_palette:
mov edi,_palette
mov ecx,64
xor eax,eax
.color1:
inc ah
mov al,ah
stosb
xor al,al
stosb
stosb
inc edi
loop .color1
mov ecx,64
push ecx
xor eax,eax
.color2:
mov al,63
stosb
mov al,ah
stosb
xor al,al
stosb
inc ah
inc edi
loop .color2
pop ecx
push ecx
xor eax,eax
.color3:
mov al,63
stosb
stosb
mov al,ah
stosb
inc ah
inc edi
loop .color3
pop ecx
mov eax,0x003f3f3f
rep stosd
ret
 
init_texture:
fldpi
mov [_fpom16],180
fidiv [_fpom16]
fstp [_st_rad]
mov edi,virtual_screen_8
cdq
.itex_vertical:
xor ecx,ecx
fld [_st_rad]
mov [_fpom16],5
fimul [_fpom16]
mov [_fpom16],dx
fimul [_fpom16]
fsin
fmul [_multiplier]
fstp [_fpom32]
.itex_horizontal:
fld [_st_rad]
mov [_fpom16],3
fimul [_fpom16]
mov [_fpom16],cx
fimul [_fpom16]
fsin
fmul [_multiplier]
fadd [_fpom32]
mov [_fpom16],127
fiadd [_fpom16]
fistp [_fpom16]
mov ax,[_fpom16]
inc eax
stosb
inc ecx
cmp ecx,WND_SIZE_X
jne .itex_horizontal
inc edx
cmp edx,WND_SIZE_Y
jne .itex_vertical
ret
 
rotate_pal:
mov ebx,[_palette+4]
mov edi,_palette+4
mov esi,_palette+8
xor ecx,ecx
mov cl,255
; cld
rep movsd
mov [_palette+1020],ebx
ret
 
include "graph8.inc"
 
DATA
_multiplier dd 63.5
 
window_title:
db 'Plasma'
window_title_len = $ - window_title
 
UDATA
_fpom32 rd 1
_fpom16 rw 1
_st_rad rd 1
_palette: rd 256
 
virtual_screen_8:
rb WND_SIZE_X*WND_SIZE_Y
 
virtual_screen_32:
rb WND_SIZE_X*WND_SIZE_Y*3
 
MEOS_APP_END
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property