⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iconedit.asm

📁 基于Menuet OS的用户应用程序及其系统应用程序(用户:BMP/jpg图片查看器 系统:CPU 状态监控程序等)
💻 ASM
📖 第 1 页 / 共 3 页
字号:
    popa                         ; restore all registers

    mov  edx,image+3600+32*32*3-3       ; point to last bytes
copy_in:
    mov  eax,[edx]               ; get bytes
    mov  [ecx],eax               ; copy to image first bytes
    add  ecx,3                   ; move pointer 3 bytes
    sub  edx,3                   ; move pointer 3 bytes
    inc  esi                     ; increment byte count
    cmp  esi,32*32               ; have we done all bytes
    jne  copy_in                 ; no then do next

    ret                          ; return

;   *********************************************
;   *******  DRAW MOUSE ON GRAPH / ICON  ********
;   *********************************************
draw_mouse:

    mov  eax,37                 ; function 37
    mov  ebx,2                  ; sub function 2 : check for mouse button
    int  0x40                   ; do it
    cmp  eax,0                  ; was a button pressed
    je   exit_mouse             ; no then jump to exit
    cmp  eax,1                  ; left hand button
    je   colour_mouse           ; we are using selected colour
    mov  [draw_colour],0x000000 ; else draw with black
    jmp  blank                  ; jmp over colour select
colour_mouse:
    mov  eax,[sel_colour]       ; get our selected colour
    mov  [draw_colour],eax      ; save our selected colour
blank:
    mov  eax,37                 ; function 37
    mov  ebx,1                  ; sub function 1 : get mouse position
    int  0x40                   ; 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
    mov  [my_pos],eax           ; save y position
    pop  eax                    ; restore our x/y position
    shr  eax,16                 ; shift x into lower bytes
    add  eax,1                  ; add 1 because we are zero based
    mov  [mx_pos],eax           ; save x position
    cmp  [mx_pos],7             ; check we are within x/y limits
    jle   exit_mouse
    cmp  [mx_pos],263
    jge   exit_mouse
    cmp  [my_pos],27
    jle   exit_mouse
    cmp  [my_pos],283
    jge   exit_mouse
    mov  eax,[mx_pos]           ; calculate nearest square and save
    sub  eax,7                  ; subtract 7 graph zero offset
    shr  eax,3                  ; divide by 8 (box size) loose remainder
    mov  [icon_x],eax           ; save for use later in icon
    shl  eax,3                  ; multiply by 8 to get box position
    add  eax,7                  ; add 7 graph zero offset
    mov  [gx_pos],eax           ; save graph x position
    mov  eax,[my_pos]           ; repeat for y
    sub  eax,27                 ;
    shr  eax,3                  ;
    mov  [icon_y],eax           ;
    shl  eax,3                  ;
    add  eax,27                 ;
    mov  [gy_pos],eax           ;
    mov  eax,13                 ; function 13 : draw bar
    mov  ebx,[gx_pos]           ; load graph x position
    shl  ebx,16                 ; shift into high bytes
    add  ebx,7                  ; add box size
    mov  ecx,[gy_pos]           ; repeat for y
    shl  ecx,16                 ;
    add  ecx,7                  ;
    mov  edx,[draw_colour]      ; give it a colour
    int  0x40                   ; do it
    mov  eax,1                  ; function 1 : put pixel
    mov  ebx,[icon_x]           ; icon x from above
    add  ebx,269                ; add icon x offset
    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
    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
    mov  eax,96                 ; 96 or 3 bytes per colour * 32 columns
    mul  ebx                    ; multiply by 96 result in eax
    add  ecx,eax                ; add to our position
    mov  ebx,[icon_x]           ; get the correct column
    mov  eax,3                  ; 3 bytes per colour
    mul  ebx                    ; multiply by 3 result in eax
    add  ecx,eax                ; add to our position
    mov  ebx,[draw_colour]      ; get our colour
    mov  [ecx],bl             ; move blue into image data
    mov  [ecx+1],bh             ; move green into image data
    shr  ebx,16                 ; shift red down
    mov  [ecx+2],bl               ; move red into image data
exit_mouse:

    ret                         ; return

;   *********************************************
;   *******  GET COLOUR TO DRAW WITH     ********
;   *********************************************
check_colour:

    mov  eax,37                 ; function 37
    mov  ebx,2                  ; sub function 2 : check for mouse button
    int  0x40                   ; 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
    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
    mov  [my_pos],eax           ; save y position
    pop  eax                    ; restore our x/y position
    shr  eax,16                 ; shift x into lower bytes
    add  eax,1                  ; add 1 because we are zero based
    mov  [mx_pos],eax           ; save x position
    cmp  [mx_pos],270           ; check we are within x/y limits
    jl   check_rb
    cmp  [mx_pos],301
    jg   check_rb
    cmp  [my_pos],219
    jl   check_rb
    cmp  [my_pos],250
    jg   check_rb

    call decode_mouse

    mov  edi,0
next_sel_rg_outer:
    mov  esi,0
next_sel_rg_inner:
    mov  eax,1
    mov  ebx,edi
    shr  ebx,3
    add  ebx,308
    mov  ecx,esi
    shr  ecx,3
    add  ecx,211
    mov  edx,[sel_colour]
    add  edx,esi
    int  0x40
    add  esi,5
    cmp  esi,255
    jne  next_sel_rg_inner
    add  edi,5
    cmp  edi,255
    jne  next_sel_rg_outer


check_rb:

    cmp  [mx_pos],270           ; check we are within x/y limits
    jl   check_bg
    cmp  [mx_pos],301
    jg   check_bg
    cmp  [my_pos],251
    jle  check_bg
    cmp  [my_pos],282
    jg   check_bg

    call decode_mouse

    mov  edi,0
next_sel_rb_outer:
    mov  esi,0
next_sel_rb_inner:
    mov  ebx,edi
    shr  ebx,3
    add  ebx,308
    mov  ecx,esi
    shr  ecx,3
    add  ecx,211
    mov  edx,[sel_colour]
    mov  eax,esi
    shl  eax,8
    add  edx,eax
    mov  eax,1
    int  0x40
    add  esi,5
    cmp  esi,255
    jne  next_sel_rb_inner
    add  edi,5
    cmp  edi,255
    jne  next_sel_rb_outer


check_bg:

    cmp  [mx_pos],301           ; check we are within x/y limits
    jl   get_colour
    cmp  [mx_pos],333
    jg   get_colour
    cmp  [my_pos],251
    jl   get_colour
    cmp  [my_pos],282
    jg   get_colour

    call decode_mouse

    mov  edi,0
next_sel_bg_outer:
    mov  esi,0
next_sel_bg_inner:
    mov  ebx,edi
    shr  ebx,3
    add  ebx,308
    mov  ecx,esi
    shr  ecx,3
    add  ecx,211
    mov  edx,[sel_colour]
    mov  eax,esi
    shl  eax,16
    add  edx,eax
    mov  eax,1
    int  0x40
    add  esi,5
    cmp  esi,255
    jne  next_sel_bg_inner
    add  edi,5
    cmp  edi,255
    jne  next_sel_bg_outer

get_colour:

    cmp  [mx_pos],309           ; check we are within x/y limits
    jl   exit_draw
    cmp  [mx_pos],340
    jg   exit_draw
    cmp  [my_pos],212
    jl   exit_draw
    cmp  [my_pos],243
    jg   exit_draw

    call decode_mouse

    mov  eax,13
    mov  ebx,269*65536+71
    mov  ecx,172*65536+32
    mov  edx,[sel_colour]
    int  0x40

    mov  eax,[sel_colour]
    mov  [draw_colour],eax

    mov  eax,47
    xor  ebx,ebx
    mov  ebx,6
    shl  ebx,16
    mov  bh,1
    mov  ecx,[sel_colour]
    mov  edx,273*65536+176
    mov  esi,0x000000
    int  0x40

exit_draw:

    ret

;   *********************************************
;   *******  DECODE MOUSE POSITION GET PIX  *****
;   *********************************************

decode_mouse:

    mov  eax,37
    xor  ebx,ebx
    int  0x40
    mov  ebx,eax
    mov  ecx,eax
    and  ebx,0xffff0000
    shr  ebx,16
    and  ecx,0x0000ffff
    mov  eax,[x_size]
    imul ecx,eax
    add  ebx,ecx
    mov  eax,35
    dec  ebx
    int  0x40

    mov  [sel_colour],eax

    ret

;   *********************************************
;   *******  DATA AREA                      *****
;   *********************************************

mx_pos            dd  0x0
my_pos            dd  0x0

gx_pos            dd  0x0
gy_pos            dd  0x0

icon_x            dd  0x0
icon_y            dd  0x0

x_size            dd  0x0
y_size            dd  0x0

sel_colour        dd  0x00ffffff
draw_colour       dd  0x00ffffff

button_text_3     db  'FILENAME'
button_text_4     db  'LOAD'
button_text_5     db  'SAVE'
button_text_6     db  'CLEAR ICON'
button_text_7     db  'FLIP VERT '
button_text_8     db  'FLIP HORIZ'
button_text_9     db  'FLIP DIAG '
button_text_10    db  'SET AS BGR'

labelt:           db  'ICON EDITOR'

icon:             db  'WRITE.BMP   '

editpos           db  0
editstate         db  0

first_run         db  0

image:

I_END:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -