Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 108 → Rev 109

/programs/demos/tube/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm tube.asm tube
@pause
/programs/demos/tube/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm tube.asm tube
@pause
/programs/demos/tube/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/demos/tube/trunk/tube.asm
0,0 → 1,277
 
; (Ü) ( ) Ü ) ( ) 256b intro by baze/3SC for Syndeecate 2001 use NASM to
; ßÛß ÛÜÛ ÛÛÛ ÛÛÜ loveC: thanks, Serzh: eat my socks dude ;] compile the
; ( ) ( ) ( ) ( ) e-mail: baze@stonline.sk, web: www.3SC.sk source code
 
; Menuet port by VT
 
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd START
dd I_END
dd 0x40000
dd 0x3ff00
dd 0,0
 
include 'macros.inc'
 
START:
 
call draw_window
 
call init_tube
 
push ebx
 
still:
 
pop ebx
 
call MAIN
 
push ebx
 
mov eax,23
mov ebx,1
int 0x40
 
cmp eax,1
jne no_red
call draw_window
jmp still
no_red:
 
cmp eax,0
je still
 
mov eax,-1
int 0x40
 
 
SCREEN equ 160
PIXBUF equ 200h
EYE equ EYE_P-2
 
 
MAIN:
 
add bh,10;8
mov edi,PIXBUF
fadd dword [di-PIXBUF+TEXUV-4]
push di
mov dx,-80
 
TUBEY:
 
mov bp,-160
 
TUBEX:
 
mov si,TEXUV
fild word [si-TEXUV+EYE]
mov [si],bp
fild word [si]
mov [si],dx
fild word [si]
mov cl,2
 
ROTATE:
 
fld st3
fsincos
fld st2
fmul st0,st1
fld st4
fmul st0,st3
db 0xde,0xe9 ; fsubp st1,st0
db 0xd9,0xcb ; fxch st3
fmulp st2,st0
fmulp st3,st0
faddp st2,st0
db 0xd9,0xca ; fxch st2
 
loop ROTATE
 
fld st1
db 0xdc,0xc8 ; fmul st0,st
fld st1
db 0xdc,0xc8 ; fmul st0,st
faddp st1,st0
fsqrt
db 0xde,0xfb ; fdivp st3,st0
fpatan
fimul word [si-4]
fistp word [si]
fimul word [si-4]
fistp word [si+1]
mov si,[si]
 
lea ax,[bx+si]
add al,ah
and al,64
mov al,-5
jz STORE_1
 
shl si,2
lea ax,[bx+si]
sub al,ah
mov al,-16
jns STORE_1
 
shl si,1
mov al,-48
 
STORE_1:
 
; add al,[ebx+esi+0x80000]
add [di],al
inc di
 
inc bp
cmp bp,160
 
EYE_P:
 
jnz TUBEX
inc dx
cmp dx,80
jnz TUBEY
 
call display_image
 
pop si
mov ch,SCREEN*320/256
 
BLUR:
 
inc si
sar byte [si],2
loop BLUR
 
ret
 
 
 
display_image:
 
pusha
 
mov esi,PIXBUF
mov edi,0x10000
newp:
movzx edx,byte [esi]
shl edx,4
; mov dh,dl
mov [edi],edx
 
add edi,3
inc esi
 
cmp esi,320*160+PIXBUF
jbe newp
 
mov eax,7
mov ecx,320*65536+160
mov edx,10*65536+27
mov ebx,0x10000
int 0x40
 
popa
ret
 
 
 
draw_window:
 
pusha
 
mov eax,12
mov ebx,1
int 0x40
 
mov eax,0
mov ebx,100*65536+339
mov ecx,100*65536+198
mov edx,0x03225588
mov esi,0x0
mov esi,0x0
int 0x40
 
mov eax,4
mov ebx,8*65536+8
mov ecx,0xffffff
mov edx,labeltext
mov esi,19
int 0x40
 
mov eax,12
mov ebx,2
int 0x40
 
popa
ret
 
labeltext db 'TUBE.ASM - with FPU'
 
db 41,0,0xC3,0x3C
 
TEXUV:
 
init_tube:
 
mov ecx,256
 
PAL1:
 
mov dx,3C8h
mov ax,cx
inc dx
sar al,1
js PAL2
mul al
shr ax,6
 
PAL2:
 
mov al,0
jns PAL3
sub al,cl
shr al,1
shr al,1
 
PAL3:
 
mov bx,cx
mov [ebx+0x1000],bh
loop PAL1
mov ecx,256
 
TEX:
 
mov bx,cx
add ax,cx
rol ax,cl
mov dh,al
sar dh,5
adc dl,dh
adc dl,[ebx+255+0x1000]
shr dl,1
mov [ebx+0x1000],dl
not bh
mov [ebx+0x1000],dl
loop TEX
 
fninit
fldz
 
ret
 
 
I_END:
 
 
 
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property