Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 30 → Rev 31

/programs/cdplay/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm cdplay.asm cdplay
@pause
/programs/cdplay/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm cdplay.asm cdplay
@pause
/programs/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/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