Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 484 → Rev 485

/programs/media/iconedit/trunk/iconedit.asm
14,7 → 14,7
dd 0x0 , 0x0 ; I_Param , I_Icon
 
include 'lang.inc'
include 'macros.inc'
include '..\..\..\macros.inc'
 
window_x_size equ 346
window_y_size equ 312
33,7 → 33,7
 
mov eax,23 ; wait here for event
mov ebx,1 ; for 1ms
int 0x40
mcall
 
cmp eax,1 ; redraw request ?
je red
50,7 → 50,7
key:
 
mov eax,2 ; get a key
int 0x40 ; do it
mcall ; do it
shr eax,8 ; move it to al
cmp byte [editstate],0 ; are we in edit mode
je check_mouse ; if not start loop again
94,12 → 94,12
 
button: ; button
mov eax,17 ; get id
int 0x40
mcall
 
cmp ah,1 ; button id=1 ?
jne button_3
mov eax,-1 ; close this program
int 0x40
mcall
button_3:
cmp ah,3 ; was it button 3 - FILENAME
jne button_4 ; no then try button 4
134,15 → 134,21
mov byte [editstate],0 ; dont want to be in edit mode
call draw_filename ; update filename
call clear_graph_icon ; clear the icon and edit screens
jmp check_mouse
 
button_7:
cmp ah,7 ; was it button 7 - FLIP ICON
jne button_8 ; no then try button 8
call flip_icon ; flip
jmp check_mouse
 
button_8:
cmp ah,8 ; was it button 8 - MIRROR ICON
jne button_9 ; no then try button 9
call flip_diag ; flip L/R and U/D
call flip_icon ; cheated now have to flip it
jmp check_mouse
 
button_9:
cmp ah,9 ; was it button 9 - FLIP L/R and U/D
jne button_10 ; no then try button 10
149,6 → 155,8
call flip_diag ; flip L/R and U/D
call draw_icon ; update icon
call draw_graph ; update graph
jmp check_mouse
 
button_10:
cmp ah,10 ; was it button 9 - SET AS BGR
jne check_mouse ; no then exit
163,28 → 171,20
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
mcall
; DRAW WINDOW
mov eax,0 ; function 0 : define and draw window
mov ebx,100*65536+window_x_size ; [x start] *65536 + [x size]
mov ecx,100*65536+window_y_size ; [y start] *65536 + [y size]
mov edx,0x03ffffff ; color of work area 0x00RRGGBB
mov esi,0x807799bb ; color of grab bar 0x00RRGGBB
mov edi,0x007799bb ; color of frames 0x00RRGGBB
int 0x40
; WINDOW LABEL
mov eax,4 ; function 4 : write text to window
mov ebx,7*65536+7 ; [x start] *65536 + [y start]
mov ecx,0xddeeff ; color of text 0x00RRGGBB
mov edx,labelt ; pointer to text beginning
mov esi,11 ; text length
int 0x40
; DRAW BUTTON BAR
mov edx,0x13ffffff ; color of work area 0x00RRGGBB
mov edi,title ; WINDOW LABEL
mcall
mov eax,13 ; function 13 : draw bar
mov ebx,5*65536+window_x_size-9 ; [x start] *65536 + [x size]
mov ecx,(window_y_size-20)*65536+16 ; [y start] *65536 + [y size]
mov edx,0x7799bb ; colour 0x00RRGGBB
int 0x40
mcall
; DEFINE BUTTON 3 : FILENAME
mov eax,8 ; function 8 : define button
mov ebx,5*65536+62 ; [x start] *65536 + [x size]
191,7 → 191,7
mov ecx,(window_y_size-19)*65536+14 ; [y start] *65536 + [y size]
mov edx,3 ; button id number
mov esi,0x7799bb ; button color 0x00RRGGBB
int 0x40
mcall
; BUTTON 3 TEXT
mov eax,4 ; function 4 : write text to window
mov ebx,13*65536+window_y_size-15 ; [x start] *65536 + [y start]
198,7 → 198,7
mov ecx,0xddeeff ; text color 0x00RRGGBB
mov edx,button_text_3 ; pointer to text beginning
mov esi,8 ; text length
int 0x40
mcall
 
call draw_filename ; update filename
 
208,32 → 208,32
mov ecx,(window_y_size-19)*65536+14 ; [y start] *65536 + [y size]
mov edx,4 ; button id number
mov esi,0x7799bb ; button color 0x00RRGGBB
int 0x40
mcall
; DEFINE BUTTON 5 : SAVE
mov ebx,(window_x_size-43)*65536+38 ; [x start] *65536 + [x size]
mov edx,5 ; button id number
int 0x40
mcall
; DEFINE BUTTON 6 : CLEAR ICON
mov ebx,268*65536+72 ; [x start] *65536 + [x size]
mov ecx,65*65536+14 ; [y start] *65536 + [y size]
mov edx,6 ; button id number
int 0x40
mcall
; DEFINE BUTTON 7 : FLIP VERTICAL
mov ecx,85*65536+14 ; [y start] *65536 + [y size]
mov edx,7 ; button id number
int 0x40
mcall
; DEFINE BUTTON 8 : FLIP HORIZONTAL
mov ecx,105*65536+14 ; [y start] *65536 + [y size]
mov edx,8 ; button id number
int 0x40
mcall
; DEFINE BUTTON 9 : SET AS BACKGROUND
mov ecx,125*65536+14 ; [y start] *65536 + [y size]
mov edx,9 ; button id number
int 0x40
mcall
; DEFINE BUTTON 10 : SET AS BACKGROUND
mov ecx,145*65536+14 ; [y start] *65536 + [y size]
mov edx,10 ; button id number
int 0x40
mcall
; BUTTON 4 TEXT
mov eax,4 ; function 4 : write text to window
mov ebx,267*65536+window_y_size-15 ; [x start] *65536 + [y start]
240,67 → 240,67
mov ecx,0xddeeff ; text color 0x00RRGGBB
mov edx,button_text_4 ; pointer to text beginning
mov esi,4 ; text length
int 0x40
mcall
; BUTTON 5 TEXT
mov ebx,311*65536+window_y_size-15 ; [x start] *65536 + [y start]
mov edx,button_text_5 ; pointer to text beginning
int 0x40
mcall
; BUTTON 6 TEXT
mov ebx,275*65536+69 ; [x start] *65536 + [y start]
mov edx,button_text_6 ; pointer to text beginning
mov esi,10 ; text length
int 0x40
mcall
; BUTTON 7 TEXT
mov ebx,275*65536+89 ; [x start] *65536 + [y start]
mov edx,button_text_7 ; pointer to text beginning
int 0x40
mcall
; BUTTON 8 TEXT
mov ebx,275*65536+109 ; [x start] *65536 + [y start]
mov edx,button_text_8 ; pointer to text beginning
int 0x40
mcall
; BUTTON 9 TEXT
mov ebx,275*65536+129 ; [x start] *65536 + [y start]
mov edx,button_text_9 ; pointer to text beginning
int 0x40
mcall
; BUTTON 10 TEXT
mov ebx,275*65536+149 ; [x start] *65536 + [y start]
mov edx,button_text_10 ; pointer to text beginning
int 0x40
mcall
; DRAW GRAPH BACKGROUND
mov eax,13 ; function 13 : draw bar
mov ebx,6*65536+257 ; [x start] *65536 + [x size]
mov ecx,26*65536+257 ; [y start] *65536 + [y size]
mov edx,0x7799bb ; colour 0x00RRGGBB
int 0x40
mcall
; DRAW ICON BACKGROUND
mov ebx,268*65536+34 ; [x start] *65536 + [x size]
mov ecx,26*65536+34 ; [y start] *65536 + [y size]
int 0x40
mcall
; DRAW PALETTE BACKGROUND
mov ebx,268*65536+34 ; [x start] *65536 + [x size]
mov ecx,217*65536+33 ; [y start] *65536 + [y size]
int 0x40
mcall
; DRAW PALETTE BACKGROUND
mov ebx,268*65536+33 ; [x start] *65536 + [x size]
mov ecx,250*65536+33 ; [y start] *65536 + [y size]
int 0x40
mcall
; DRAW PALETTE BACKGROUND
mov ebx,301*65536+33 ; [x start] *65536 + [x size]
mov ecx,249*65536+34 ; [y start] *65536 + [y size]
int 0x40
mcall
; DRAW GREYSCALE BACKGROUND
mov ebx,307*65536+34 ; [x start] *65536 + [x size]
mov ecx,210*65536+34 ; [y start] *65536 + [y size]
int 0x40
mcall
; DRAW SELECTED COLOUR BACKGROUND
mov ebx,268*65536+73 ; [x start] *65536 + [x size]
mov ecx,171*65536+34 ; [y start] *65536 + [y size]
int 0x40
mcall
; DRAW WHITE TO START
mov ebx,269*65536+71 ; [x start] *65536 + [x size]
mov ecx,172*65536+32 ; [y start] *65536 + [y size]
mov edx,0xffffff ; colour 0x00RRGGBB
int 0x40
mcall
; DRAW PALETTE RED + GREEN SECTION
xor edi,edi ; clear column loop count
next_r_g_outer:
319,7 → 319,7
add edx,255 ; maximum green
sub edx,esi ; minus line count
shl edx,8 ; into position 0x00RRGG00
int 0x40
mcall
add esi,5 ; colour in steps of 5 to keep small
cmp esi,255 ; have we done a line
jne next_r_g_inner ; nop then do next pixel
343,7 → 343,7
sub edx,edi
shl edx,16
add edx,esi
int 0x40
mcall
add esi,5
cmp esi,255
jne next_g_b_inner
366,7 → 366,7
mov edx,edi
shl edx,8
add edx,esi
int 0x40
mcall
add esi,5
cmp esi,255
jne next_b_r_inner
391,7 → 391,7
add edx,esi
shl edx,8
add edx,esi
int 0x40
mcall
add esi,5
cmp esi,255
jne next_b_w_inner
409,7 → 409,7
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
mcall
 
ret ; return
 
441,17 → 441,17
mov ebx,1 ; set background size
mov ecx,32 ; x size
mov edx,32 ; y size
int 0x40 ; do it
mcall ; do it
mov ebx,4 ; type of background draw
mov ecx,1 ; tile
mcall ; do it
mov ebx,5 ; blockmove image to os bgr memory
mov ecx,image+3600 ; point to image
mov edx,0 ; start of bgr memory
mov esi,32*32*3 ; byte count
int 0x40 ; do it
mov ebx,4 ; type of background draw
mov ecx,1 ; tile
int 0x40 ; do it
mcall ; do it
mov ebx,3 ; draw background
int 0x40 ; do it
mcall ; do it
 
ret ; return
 
461,7 → 461,7
get_screen_size:
 
mov eax,14 ; function 14 : get screen max
int 0x40 ; returns eax : 0xXXXXYYYY
mcall ; returns eax : 0xXXXXYYYY
push eax ; save reg
and eax,0x0000ffff ; split out y size
add eax,1 ; add 1 to remove zero base
483,7 → 483,7
mov ecx,0 ; reserved
mov edx,200000 ; reserved
mov esi,image ; point to image buffer
int 0x40 ; do it
mcall ; do it
 
ret ; return
 
497,7 → 497,7
mov ecx,image ; point to our data
mov edx,54+32*32*3 ; how much data to transfer
xor esi,esi ; 0 - create a new file
int 0x40 ; do it
mcall ; do it
 
ret ; return
 
511,7 → 511,7
mov ebx,73*65536+81 ; [x start] *65536 + [x size]
mov ecx,(window_y_size-19)*65536+15 ; [y start] *65536 + [y size]
mov edx,0x557799 ; colour 0x00RRGGBB
int 0x40
mcall
 
mov eax,4 ; function 4 : write text to window
mov ebx,78*65536+(window_y_size-15) ; [y start] *65536 + [y size]
522,7 → 522,7
jne no_active_1 ; no then jump over change colour
mov ecx,0x00112299 ; else change colour
no_active_1:
int 0x40 ; do it
mcall ; do it
popa ; return all registers to original
ret ; return
 
541,7 → 541,7
mov edx,[eax] ; colour 0x00RRGGBB from image data
push eax ; save our position
mov eax,1 ; function 1 : put pixel
int 0x40 ; do it
mcall ; do it
pop eax ; restore our position
sub eax,3 ; point to next pixel colour
dec ebx ; move our x position
578,7 → 578,7
mov edx,[eax] ; point to bmp data
push eax ; save our position
mov eax,13 ; function 13 : draw bar
int 0x40 ; do it
mcall ; do it
pop eax ; restore our position
sub eax,3 ; point to next pixel colour
dec esi ; increment column count
674,7 → 674,7
 
mov eax,37 ; function 37
mov ebx,2 ; sub function 2 : check for mouse button
int 0x40 ; do it
mcall ; do it
cmp eax,0 ; was a button pressed
je exit_mouse ; no then jump to exit
cmp eax,1 ; left hand button
687,7 → 687,7
blank:
mov eax,37 ; function 37
mov ebx,1 ; sub function 1 : get mouse position
int 0x40 ; do it
mcall ; do it
push eax ; save our x/y position for later
and eax,0x0000ffff ; y is in lower bytes
add eax,1 ; add 1 because we are zero based
726,7 → 726,7
shl ecx,16 ;
add ecx,7 ;
mov edx,[draw_colour] ; give it a colour
int 0x40 ; do it
mcall ; do it
mov eax,1 ; function 1 : put pixel
mov ebx,[icon_x] ; icon x from above
add ebx,269 ; add icon x offset
733,7 → 733,7
mov ecx,[icon_y] ; icon y from above
add ecx,27 ; add icon y offset
mov edx,[draw_colour] ; give it a colour
int 0x40 ; do it
mcall ; do it
mov ecx,image+54 ; point to our data
mov ebx,31 ; 32 lines in image zero based
sub ebx,[icon_y] ; get the correct line
760,12 → 760,12
 
mov eax,37 ; function 37
mov ebx,2 ; sub function 2 : check for mouse button
int 0x40 ; do it
mcall ; do it
cmp eax,0 ; was a button pressed
je exit_draw ; no then jump to exit
mov eax,37 ; function 37
mov ebx,1 ; sub function 1 : get mouse position
int 0x40 ; do it
mcall ; do it
push eax ; save our x/y position for later
and eax,0x0000ffff ; y is in lower bytes
add eax,1 ; add 1 because we are zero based
798,7 → 798,7
add ecx,211
mov edx,[sel_colour]
add edx,esi
int 0x40
mcall
add esi,5
cmp esi,255
jne next_sel_rg_inner
835,7 → 835,7
shl eax,8
add edx,eax
mov eax,1
int 0x40
mcall
add esi,5
cmp esi,255
jne next_sel_rb_inner
872,7 → 872,7
shl eax,16
add edx,eax
mov eax,1
int 0x40
mcall
add esi,5
cmp esi,255
jne next_sel_bg_inner
897,7 → 897,7
mov ebx,269*65536+71
mov ecx,172*65536+32
mov edx,[sel_colour]
int 0x40
mcall
 
mov eax,[sel_colour]
mov [draw_colour],eax
910,7 → 910,7
mov ecx,[sel_colour]
mov edx,273*65536+176
mov esi,0x000000
int 0x40
mcall
 
exit_draw:
 
924,7 → 924,7
 
mov eax,37
xor ebx,ebx
int 0x40
mcall
mov ebx,eax
mov ecx,eax
and ebx,0xffff0000
935,7 → 935,7
add ebx,ecx
mov eax,35
dec ebx
int 0x40
mcall
 
mov [sel_colour],eax
 
969,7 → 969,7
button_text_9 db 'FLIP DIAG '
button_text_10 db 'SET AS BGR'
 
labelt: db 'ICON EDITOR'
title db 'ICON EDITOR',0
 
icon: db 'WRITE.BMP '