/programs/media/jpegview/trunk/filelib.asm |
---|
1,52 → 1,46 |
file_handler: |
.position=0 |
.size=4 |
.bufer_block=8 |
.operation=12 |
.first_block=16 |
.n_blocks=20 |
.bufer=24 |
.work_area=28 |
.name=32 |
.st_size=32+128 |
.operation=0 |
.position=4 |
.reserved=8 |
.n_bytes=12 |
.bufer=16 |
.name=20 |
.st_size=20+1024 |
open: ;esi=name_string |
;retorna eax |
pushad |
push dword [work_area] |
mov ecx,512 ;bufer |
call malloc |
push edi |
mov ecx,file_handler.st_size |
call mallocz |
pop dword[edi+file_handler.bufer] |
pop dword[edi+file_handler.work_area] |
mov [esp+28],edi |
mov ecx,100 |
push edi |
mov ecx,1024 |
add edi,file_handler.name |
call movedata |
mov edi,[esp+28] |
mov byte[edi+file_handler.n_blocks],1 |
mov eax,58 |
pop edi |
; test if file exists |
lea ebx,[edi+file_handler.operation] |
push edi |
mov byte[ebx],5 |
mov dword[ebx+16],fileattr |
mov eax,70 |
int 0x40 |
pop edi |
cmp eax,2 |
jz .virtual |
test eax,eax |
jnz close.b |
mov [edi+file_handler.size],ebx |
@@: |
clc |
popad |
ret |
.virtual: |
mov byte [fileattr], 0x10 |
jmp @b |
close: |
pushad |
.b: |
mov eax,[esp+28] |
mov edi,[eax+file_handler.bufer] |
mov edi,[esp+28] |
call free |
mov edi,eax |
call free |
popad |
xor eax,eax |
ret |
55,88 → 49,20 |
read: ;(f,bufer,nbytes) eax,edi,ecx ncr |
;retorna bytes leidos en ecx |
pushad |
mov edx,[eax+file_handler.size] |
sub edx,[eax+file_handler.position] |
cmp edx,ecx |
jnc .nb_ok |
mov ecx,edx |
mov [esp+24],edx |
.nb_ok: |
jecxz .final |
mov byte[eax+file_handler.operation],0 |
test dword[eax+file_handler.position],511 |
jz .l1 |
call .bufer |
.l1: |
mov edx,ecx |
shr edx,9 |
jz .l2 |
mov [eax+file_handler.n_blocks],edx |
mov edx,[eax+file_handler.position] |
shr edx,9 |
mov [eax+file_handler.first_block],edx |
xchg edi,[eax+file_handler.bufer] |
pushad |
lea ebx,[eax+file_handler.operation] |
mov eax,58 |
int 40h |
cmp eax,0ffffff00h |
jnc .error |
popad |
xchg edi,[eax+file_handler.bufer] |
mov edx,ecx |
and edx,0fffffe00h |
add [eax+file_handler.position],edx |
add edi,edx |
.l2: |
and ecx,511 |
jz .final |
call .bufer |
.final: |
popad |
ret |
.bufer: |
pushad |
mov ebx,[eax+file_handler.position] |
shr ebx,9 |
cmp ebx,[eax+file_handler.bufer_block] |
je .l3 |
mov [eax+file_handler.first_block],ebx |
mov [eax+file_handler.bufer_block],ebx |
mov dword[eax+file_handler.n_blocks],1 |
lea ebx,[eax+file_handler.operation] |
mov eax,58 |
int 40h |
cmp eax,0ffffff00h |
jnc .error |
.l3: |
mov byte [ebx], 0 |
mov [ebx+12], ecx |
mov [ebx+16], edi |
mov eax, 70 |
int 0x40 |
cmp ebx, -1 |
sbb ebx, -1 |
mov eax,[esp+28] |
mov edx,[eax+file_handler.position] |
mov esi,[eax+file_handler.bufer] |
and edx,511 |
add esi,edx |
neg edx |
add edx,512 |
cmp ecx,edx |
jc .l4 |
mov ecx,edx |
.l4: |
add [eax+file_handler.position],ecx |
sub [esp+24],ecx |
pop edi |
call movedata |
push edi |
add [eax+file_handler.position], ebx |
mov [esp+24], ebx |
popad |
ret |
.error: |
popad |
popad |
xor ecx,ecx |
stc |
ret |
ftell: mov edx,[eax+file_handler.position] |
ret |
lseek: ;eax=file edx=pos |
/programs/media/jpegview/trunk/jpeglib.asm |
---|
99,6 → 99,8 |
eoi: |
mov esp,[ebp] |
; do not close file - this will be done by caller |
and dword [ebp+fichero], 0 |
call jpeg_close |
popad |
xor ebp,ebp |
/programs/media/jpegview/trunk/jpegview.asm |
---|
18,7 → 18,10 |
; unos retoques |
; version 0.14 10th August 2004 |
; Mike Hibbett Added setting default colours |
; version 0.15 24th August 2006 |
; diamond (rewritten to function 70) |
; |
memsize=20000h |
org 0 |
PARAMS = memsize - 1024 |
33,7 → 36,6 |
dd memsize - 1024 ; esp |
dd PARAMS , 0x0 ; I_Param , I_Icon |
include 'lang.inc' |
stack_size=4096 + 1024 |
include 'macros.inc' |
50,10 → 52,6 |
mov edi,fin |
call add_mem |
; Get some memory |
mov ecx,16384 |
call malloc |
mov [work_area],edi |
call colorprecalc ;inicializa tablas usadas para pasar de ybr a bgr |
call draw_window |
call read_string.rs_done |
148,10 → 146,6 |
mov ecx,memsize-fin-stack_size ; size |
mov edi,fin ; pointer |
call add_mem ; mark memory from fin to 0x100000-1024 as free |
; Get some memory |
mov ecx,16384 ; get 16 Kb of memory |
call malloc ; returns pointer in edi |
mov [work_area],edi ; save it |
call colorprecalc ; calculate colors |
mov esi,name_string |
call open |
244,15 → 238,12 |
; Draw the window to the appropriate size - it may have |
; been resized by the user |
mov eax, 0 |
cmp [winxs], ax |
cmp [winxs], 0 |
jne dw_001 |
; Give the screen some inital defaults |
mov ax, 400 |
mov [winxs], ax |
mov ax, 300 |
mov [winys], ax |
mov [winxs], 400 |
mov [winys], 300 |
mov ax, 100 |
mov [winxo], ax |
mov [winyo], ax |
273,16 → 264,12 |
mov [winys], ax |
dw_002: |
mov bx, [winxo] |
shl ebx, 16 |
mov ebx, dword [winxo-2] |
mov bx, [winxs] |
mov cx, [winyo] |
shl ecx, 16 |
mov ecx, dword [winyo-2] |
mov cx, [winys] |
mov eax,0 ; DRAW WINDOW |
xor eax,eax ; DRAW WINDOW |
mov edx,[wcolor] |
add edx,0x02000000 |
mov esi,0x80557799 |
461,15 → 448,15 |
ret |
slideshow: |
test dword[file_dir],-1 |
cmp [file_dir], 0 |
jnz .exit |
test dword[jpeg_st],-1 |
cmp [jpeg_st], 0 |
jz .exit |
mov esi,name_string |
movzx ecx,byte[name_string.cursor] |
.l1: |
cmp byte[esi+ecx],'/' |
je .l2 |
jz .l2 |
loop .l1 |
.exit: |
ret |
479,66 → 466,41 |
mov byte[esi+ecx],'/' |
test eax,eax |
jz .exit |
mov dword[eax+file_handler.size],-1 ;directory size is always 0 |
test byte [fileattr], 0x10 |
jz .exit |
mov [file_dir],eax |
inc cl |
inc ecx |
mov [name_string.cursor],cl |
display_next: |
mov ebx, [file_dir] |
test ebx, ebx |
jnz @f |
ret |
@@: |
mov byte [ebx], 1 |
mov byte [ebx+12], 1 |
mov dword [ebx+16], dirinfo |
mov eax, 70 |
int 0x40 |
mov eax,[file_dir] |
test eax,eax |
jnz .l1 |
ret |
.l1: |
mov ecx,32 |
sub esp,ecx |
mov edi,esp |
call read |
cmp ecx,32 |
jnc .l11 |
.l10: |
add esp,32 |
mov eax,dword[file_dir] |
mov dword[file_dir],0 |
inc dword [eax+4] |
cmp ebx, 1 |
jz @f |
mov eax, [file_dir] |
and [file_dir], 0 |
jmp close |
.l11: |
mov esi,esp |
@@: |
movzx edi,byte[name_string.cursor] |
add edi,name_string |
lea esi, [dirinfo+32+40] |
@@: |
lodsb |
cmp al,0 |
je .l10 |
cmp al,229 |
jne .l0 |
add esp,32 |
jmp display_next |
.l0: |
stosb |
mov cl,7 |
.l2: |
lodsb |
cmp al,32 |
jna .l3 |
stosb |
loop .l2 |
.l3: |
lea esi,[esp+8] |
mov al,'.' |
stosb |
mov cl,3 |
.l4: |
lodsb |
cmp al,32 |
jna .l5 |
stosb |
loop .l4 |
.l5: |
mov al,0 |
stosb |
cmp edi,name_string.end |
jc .l5 |
add esp,32 |
test al, al |
jnz @b |
mov ecx, name_string.end |
sub ecx, edi |
rep stosb |
call print_strings |
mov esi,name_string |
call open |
558,7 → 520,6 |
jmp jpeg_display |
include 'filelib.asm' |
include 'memlib.asm' |
include 'jpeglib.asm' |
567,7 → 528,7 |
; DATA AREA |
wcolor dd 0x000000 |
labelt db 'Jpegview v0.14' |
labelt db 'Jpegview v0.15' |
labellen: |
setname db 'SLIDESHOW' |
setnamelen: |
580,18 → 541,16 |
x_numofbytes dd 0 |
x_numofb2 dd 0 |
x_counter dd 0 |
winxo: dw 0 |
winyo: dw 0 |
winxs: dw 0 |
winys: dw 0 |
jpeg_st: dd 0 |
file_dir: dd 0 |
work_area: dd 0 |
winxo dw 0 |
winyo dw 0 |
winxs dw 0 |
winys dw 0 |
jpeg_st dd 0 |
file_dir dd 0 |
tcolor dd 0x000000 |
btcolor dd 0x224466+0x808080 |
name_string: db '/rd/1/jpegview.jpg',0 |
rb 100 |
rb 256 |
.end: |
.cursor: db 19 |
.cursor2: db 0 |
612,5 → 571,5 |
fin: |
I_END: |
fileattr: rb 40 |
dirinfo: rb 32+304 |
/programs/media/jpegview/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 |