Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 340 → Rev 341

/programs/system/rdsave/trunk/rdsave.asm
1,109 → 1,182
;
; Save Ramdisk to HD and FD
; RDsave ¤«ï Kolibri (0.6.5.0 ¨ áâ àè¥)
;
; Mario79 2005
; Compile with FASM for Menuet
; Heavyiron 12.02.2007
;
 
; Š®¬¯¨«¨à®¢ âì FASM'®¬
;
;---------------------------------------------------------------------
include 'lang.inc'
include 'macros.inc'
 
appname equ 'RDsave '
version equ '1.1'
version equ '1.2'
 
use32
org 0x0
use32 ; ¢ª«îç¨âì 32-¡¨â­ë© ०¨¬  áᥬ¡«¥à 
org 0x0 ;  ¤à¥á æ¨ï á ­ã«ï
 
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd 0x1000 ; memory for app
dd 0x1000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
db 'MENUET01' ; 8-¡ ©â­ë© ¨¤¥­â¨ä¨ª â®à MenuetOS
dd 0x01 ; ¢¥àá¨ï § £®«®¢ª  (¢á¥£¤  1)
dd START ;  ¤à¥á ¯¥à¢®© ª®¬ ­¤ë
dd I_END ; à §¬¥à ¯à®£à ¬¬ë
dd 0x1000 ; ª®«¨ç¥á⢮ ¯ ¬ïâ¨
dd 0x1000 ;  ¤à¥á ¢¥à設ë áâíª 
dd 0x0 ;  ¤à¥á ¡ãä¥à  ¤«ï ¯ à ¬¥â஢ (­¥ ¨á¯®«ì§ã¥âáï)
dd 0x0 ; § à¥§¥à¢¨à®¢ ­®
 
include 'editbox.inc'
use_edit_box
 
;******************************************************************************
;---------------------------------------------------------------------
;--- €—€‹Ž Žƒ€ŒŒ› ----------------------------------------------
;---------------------------------------------------------------------
 
 
START: ; start of execution
xor eax,eax
mov edi,bootpath
mov ecx,128
rep stosd
 
mcall 6,filename,0,-1,bootpath
 
mov esi,bootpath+1
mov cx,512
start_search:
lodsb
cmp al,"'"
jz set_end_path
dec cx
cmp cx,0
ja start_search
set_end_path:
mov [esi-1],byte 0
 
START:
mov eax,40
mov ebx,101b
mov ebx, 100111b
int 0x40
red: ; ¯¥à¥à¨á®¢ âì ®ª­®
call draw_window ; ¢ë§ë¢ ¥¬ ¯à®æ¥¤ãàã ®âà¨á®¢ª¨ ®ª­ 
 
red:
call draw_window
;---------------------------------------------------------------------
;--- –ˆŠ‹ Ž€Ž’Šˆ ‘Ž›’ˆ‰ ----------------------------------------
;---------------------------------------------------------------------
 
still:
mov eax, 10 ; wait here for event
int 0x40
push 10
pop eax
int 40h
 
dec eax ; redraw request ?
je red
; dec eax
; dec eax ; button in buffer ?
; je button
dec eax ; ¯¥à¥à¨á®¢ âì ®ª­®?
jz red ; ¥á«¨ ¤  - ­  ¬¥âªã red
dec eax
jz key
dec eax
jz button
 
mouse:
mouse_edit_boxes editbox,editbox_end
jmp still
 
button: ; button
mov eax,17 ; get id
button:
mov al,17 ; ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
int 0x40
 
cmp ah,1 ; ª­®¯ª  á id=1("§ ªàëâì")?
jne noclose
or eax,-1 ; äã­ªæ¨ï -1: § ¢¥àè¨âì ¯à®£à ¬¬ã
int 0x40
 
noclose:
cmp ah,2
jne ah_3
mcall 18,6,1
jmp red
ah_3:
jne path_2
call clear_err
mov al,16
mov ebx,1
int 0x40
call check_for_error
jmp still
path_2:
cmp ah,3
jne ah_4
mcall 18,6,2
jmp red
ah_4:
jne path_3
call clear_err
mov al,16
mov ebx,2
int 0x40
call check_for_error
jmp still
path_3:
cmp ah,4
jne ah_5
mcall 18,6,3,bootpath+1
jmp red
ah_5:
cmp ah,5
jne ah_6
mcall 16,1
jmp red
ah_6:
cmp ah,6
jne ah_1
mcall 16,2
jmp red
jne path_4
call clear_err
mov al,18
mov ebx,6
mov ecx,path3
int 0x40
call check_for_error
jmp still
path_4:
call clear_err
mov eax,18
mov ebx,6
mov ecx,path4
int 0x40
call check_for_error
jmp still
 
ah_1:
cmp ah,1
je exit
key:
mov al,2
int 0x40
key_edit_boxes editbox,editbox_end
jmp still
 
exit:
or eax,-1 ; close this program
 
check_for_error: ;Ž¡à ¡®â稪 ®è¨¡®ª
cmp eax,0
jne err1
mov ecx,[sc.work_text]
mov edx,ok
jmp print
err1:
cmp eax,1
jne err3
mov ecx,0xdd2222
mov edx,error11
jmp print
err3:
cmp eax,3
jne err5
mov ecx,0xdd2222
mov edx,error3
jmp print
err5:
cmp eax,5
jne err8
mov ecx,0xdd2222
mov edx,error5
jmp print
err8:
cmp eax,8
jne err9
mov ecx,0xdd2222
mov edx,error8
jmp print
err9:
cmp eax,9
jne err10
mov ecx,0xdd2222
mov edx,error9
jmp print
err10:
cmp eax,10
jne err11
mov ecx,0xdd2222
mov edx,error10
jmp print
err11:
mov ecx,0xdd2222
mov edx,error11
jmp print
 
print:
mov eax,4 ;­ ¤¯¨á¨
mov ebx,20 shl 16 + 148
or ecx,0x80000000
int 0x40
ret
 
clear_err:
mov al,13
mov ebx,15 shl 16 + 240
mov ecx,145 shl 16 +15
mov edx,[sc.work]
int 0x40
ret
 
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
;---------------------------------------------------------------------
;--- Ž…„…‹…ˆ… ˆ Ž’ˆ‘Ž‚Š€ ŽŠ€ ----------------------------------
;---------------------------------------------------------------------
 
draw_window:
 
113,100 → 186,149
mov edx,sizeof.system_colors
int 0x40
 
mov eax, 12 ; function 12:tell os about windowdraw
mov ebx, 1 ; 1, start of draw
mov eax,12 ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
mov bl,1 ; 1 - ­ ç¨­ ¥¬ à¨á®¢ âì
int 0x40
; DRAW WINDOW
mov eax, 0 ; function 0 : define and draw window
mov ebx, 200*65536+230 ; [x start] *65536 + [x size]
mov ecx, 200*65536+260 ; [y start] *65536 + [y size]
mov edx, [sc.work] ; color of work area RRGGBB,8->color gl
 
; ‘Ž‡„€ðŒ ŽŠŽ
xor eax,eax ; äã­ªæ¨ï 0 : ®¯à¥¤¥«¨âì ¨ ®âà¨á®¢ âì ®ª­®
mov ebx,200 shl 16 + 270 ; [x áâ àâ] *65536 + [x à §¬¥à]
mov ecx,200 shl 16 + 190 ; [y áâ àâ] *65536 + [y à §¬¥à]
mov edx,[sc.work] ; 梥â à ¡®ç¥© ®¡« á⨠RRGGBB,8->color gl
or edx,0x33000000
mov edi,header ; WINDOW LABEL
mov edi,header ; ‡€ƒŽ‹Ž‚ŽŠ ŽŠ€
int 0x40
 
mcall 8,<11,17>,<26,17>,2,[sc.work_button]
inc edx
mcall , ,<56,17>, ,
inc edx
mcall , ,<86,17>, ,
inc edx
mcall , ,<166,17>, ,
inc edx
mcall , ,<196,17>, ,
draw_edit_boxes editbox,editbox_end ;à¨á®¢ ­¨¥ edit box'®¢
 
mov ecx,[sc.work_button_text]
or ecx,0x10000000
mcall 4,<17,31>, ,text_123,1
add ebx,30
add edx,1
mcall
add ebx,30
add edx,1
mcall
add ebx,80
add edx,1
mcall
add ebx,30
add edx,1
mcall
mov al,13 ;®âà¨á®¢ª  ⥭¥© ª­®¯®ª
mov ebx,194 shl 16 + 60
mov ecx,34 shl 16 +15
mov edx,0x444444
int 0x40
 
add ecx,20 shl 16
int 0x40
 
add ecx,20 shl 16
int 0x40
 
add ecx,40 shl 16
int 0x40
 
mov eax,8 ;®âà¨á®¢ª  ª­®¯®ª
sub ebx,4 shl 16
sub ecx,4 shl 16
mov edx,5
mov esi,[sc.work_button]
int 0x40
 
sub ecx,40 shl 16
dec edx
int 0x40
 
sub ecx,20 shl 16
dec edx
int 0x40
 
sub ecx,20 shl 16
dec edx
int 0x40
 
mov al,4 ;­ ¤¯¨á¨
mov ebx,45 shl 16 + 12
mov ecx,[sc.work_text]
or ecx,0x80000000
mcall ,<40,31>, ,text_1,
add ebx,30
mcall , , ,text_2,
add ebx,30
mcall , , ,text_3,
mcall ,<15,115>, ,text_4,
mcall ,<35,125>, ,text_5,
mov edx,label1
int 0x40
 
mcall ,<35,41>, ,text_6,
mcall ,<35,101>, ,text_6,
mcall ,<40,171>, ,text_7,
mcall ,<40,201>, ,text_8,
mcall ,<25,10>, ,text_9,
mcall ,<25,150>, ,text_10,
mov ebx,150 shl 16 + 35
mov edx,path1
int 0x40
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
add ebx,20
mov edx,path2
int 0x40
ret
 
mov ebx,75 shl 16 + 75
mov edx,path3
int 0x40
 
mov ebx,30 shl 16 + 97
mov edx,label2
int 0x40
 
mov ebx,40 shl 16 + 135
mov edx,label3
int 0x40
 
mov ecx,[sc.work_button_text]
or ecx,0x80000000
mov ebx,195 shl 16 + 35
mov edx,save
int 0x40
 
add ebx,20
int 0x40
 
add ebx,20
int 0x40
 
add ebx,40
int 0x40
 
mov al,12 ; äã­ªæ¨ï 12: á®®¡é¨âì Ž‘ ®¡ ®âà¨á®¢ª¥ ®ª­ 
mov ebx,2 ; 2, § ª®­ç¨«¨ à¨á®¢ âì
int 0x40
 
ret ; ¢ë室¨¬ ¨§ ¯à®æ¥¤ãàë
 
 
;---------------------------------------------------------------------
;--- „€›… Žƒ€ŒŒ› ----------------------------------------------
;---------------------------------------------------------------------
 
header db appname,version,0
 
text_123 db '12345'
editbox:
edit1 edit_box 170,10,113,0xffffff,0,0,0,1024,path4,ed_focus
editbox_end:
 
path1 db '/fd/1/',0
path2 db '/fd/2/',0
path3 db '/hd0/1/kolibri.img',0
 
if lang eq ru
save db '‘®åà ­¨âì',0
label1 db '‚ë¡¥à¨â¥ ®¤¨­ ¨§ ¢ à¨ ­â®¢:',0
label2 db 'ˆ«¨ ¢¢¥¤¨â¥ ¯®«­ë© ¯ãâì ª ä ©«ã:',0
label3 db '‚ᥠ¯ ¯ª¨ ¤®«¦­ë áãé¥á⢮¢ âì',0
ok db 'RAM-¤¨áª á®åà ­¥­ ãᯥ譮',0
error3 db '¥¨§¢¥áâ­ ï ä ©«®¢ ï á¨á⥬ ',0
error5 db '¥áãé¥áâ¢ãî騩 ¯ãâì',0
error8 db '¥â ¬¥áâ  ­  ¤¨áª¥',0
error9 db '’ ¡«¨æ  FAT à §àã襭 ',0
error10 db '„®áâ㯠§ ¯à¥é¥­',0
error11 db 'Žè¨¡ª  ãáâனá⢠',0
 
text_1 db '‚ ¯ ¯ªã ‘:\KOLIBRI',0
text_2 db '‚ ª®à¥­ì ¤¨áª  ‘',0
text_3 db 'ãâì ¢ ä ©«¥ RD2HD.TXT',0
text_4 db '¯.3 ¤«ï १¥à¢­®£® á®åà ­¥­¨ï',0
text_5 db 'â.ª. ¢ ï¤à¥ ¥£® ­¥â.',0
text_6 db '(¯ ¯ª  ¤®«¦­  ¯à¨áãâá⢮¢ âì)',0
text_7 db '  /FD/1',0
text_8 db '  /FD/2',0
text_9 db '‘®åà ­¥­¨¥ ­  ¦¥á⪨© ¤¨áª:',0
text_10 db '‘®åà ­¥­¨¥ ­  ¤¨áª¥âã:',0
 
else
save db ' Save',0
label1 db 'Select one of the variants:',0
label2 db ' Or enter full path to file:',0
label3 db ' All folders must exist',0
ok db 'RAM-drive was saved successfully',0
error3 db 'Unknown file system',0
error5 db 'Incorrect path',0
error8 db 'Disk is full',0
error9 db 'FAT table corrupted',0
error10 db 'Access denied',0
error11 db 'Device error',0
 
text_1 db 'To the folder C:\KOLIBRI',0
text_2 db 'To the root of C',0
text_3 db 'To path in the file RD2HD.TXT',0
text_4 db 'p.3 for backup, as the kernel',0
text_5 db 'can not boot from there.',0
text_6 db '(folder must exist)',0
text_7 db 'To /FD/1',0
text_8 db 'To /FD/2',0
text_9 db 'Save to hard disk:',0
text_10 db 'Save to floppy:',0
 
end if
 
filename db 'RD2HD TXT'
I_END:
;---------------------------------------------------------------------
 
I_END: ; ¬¥âª  ª®­æ  ¯à®£à ¬¬ë
 
sc system_colors
bootpath:
path4 rb 1025;1024+1