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

📄 iconedit.asm

📁 menuet os应用程序源代码,很多汇编写的应用程序
💻 ASM
📖 第 1 页 / 共 3 页
字号:
;
;   Modified from original icon editor
;
;   Compile with FASM for Menuet
;

use32

               org    0x0

               db     'MENUET01'              ; 8 byte id
               dd     0x01                    ; header version
               dd     START                   ; start of code
               dd     I_END                   ; size of image
               dd     0x100000                ; memory for app
               dd     0x7fff0                 ; esp
               dd     0x0 , 0x0               ; I_Param , I_Icon


window_x_size  equ    346
window_y_size  equ    312

START:                          ; start of execution

    call draw_window            ; at first, draw the window
    call get_screen_size        ; get screen x and y size

check_mouse:

    call draw_mouse             ; are we editing the icon
    call check_colour           ; are we selecting a colour

still:

    mov  eax,23                 ; wait here for event
    mov  ebx,1                  ; for 1ms
    int  0x40

    cmp  eax,1                  ; redraw request ?
    je   red
    cmp  eax,2                  ; key in buffer ?
    je   key
    cmp  eax,3                  ; button in buffer ?
    je   button

    jmp  check_mouse            ; start loop again

  red:                          ; redraw
    call draw_window            ; draw our window
    jmp  check_mouse            ; start the loop again
    key:

    mov  eax,2                  ; get a key
    int  0x40                   ; 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
    cmp  al,8                   ; is it a backspace
    jne  no_bksp                ; if no jump over backspace code
    cmp  byte [editpos],0       ; is it the first character
    je   no_del_last            ; if yes jump over backspace code
    dec  byte [editpos]         ; decrement our position
    xor  ebx,ebx                ; clear pointer
    mov  bl,byte [editpos]      ; get our position
    add  ebx,icon               ; add our offset
    mov  byte [ebx],0           ; delete character
no_del_last:
    call draw_filename          ; update filename
    jmp  check_mouse            ; start loop again
no_bksp:
    cmp  al,13                  ; is it the enter key
    jne  no_enter               ; no then jump over enter code
    mov  byte [editstate],0     ; get out of edit mode
    call draw_filename          ; update filename
    jmp check_mouse             ; start loop again
no_enter:
    cmp  al,31                  ; are we below character 31
    jbe  no_lit                 ; then must be illegal
    cmp  al,97                  ; are we below character 97
    jb   capital                ; then must be ok
    sub  eax,32                 ; else subtract 32 from it to make it legal
capital:
    xor  ebx,ebx                ; clear our pointer
    mov  bl,byte [editpos]      ; get our position
    add  ebx,icon               ; add our offset
    mov  byte [ebx],al          ; move our character into buffer
    inc  byte [editpos]         ; increment our edit position
    cmp  byte [editpos],12      ; are we at our last position
    jne  no_null_state          ; no then jump over last position code
    mov  byte [editstate],0     ; get out of edit mode
no_null_state:
    call draw_filename          ; update filename
no_lit:
    jmp  check_mouse            ; start loop again

  button:                       ; button
    mov  eax,17                 ; get id
    int  0x40

    cmp  ah,1                   ; button id=1 ?
    jne  button_3
    mov  eax,-1                 ; close this program
    int  0x40
  button_3:
    cmp  ah,3                   ; was it button 3 - FILENAME
    jne  button_4               ; no then try button 4
    cld                         ;
    mov  byte [editstate],1     ; enter edit mode
    mov  edi,icon               ; point to our buffer
    mov  eax,0x20202020         ; file reg with 4 spaces
    mov  ecx,3                  ; going to write it 3 times
    rep  stosd                  ; repeat giving 12 spaces
    mov  byte [editpos],0       ; zero our edit position
    call draw_filename          ; update filename
    jmp  check_mouse            ; start loop again
  button_4:
    cmp  ah,4                   ; was it button 4 - LOAD
    jne  button_5               ; no then try button 5
    mov  byte [editstate],0     ; dont want to be in edit mode
    call draw_filename          ; update filename
    call load_file              ; load the file
    call draw_icon              ; update icon screen
    call draw_graph             ; update edit screen
    jmp  check_mouse            ; start loop again
  button_5:
    cmp  ah,5                   ; was it button 5 - SAVE
    jne  button_6               ; no then try button 6
    mov  byte [editstate],0     ; dont want to be in edit mode
    call draw_filename          ; update filename
    call save_file              ; save the file
    jmp  check_mouse            ; start loop again
  button_6:
    cmp  ah,6                   ; was it button 6 - CLEAR ICON
    jne  button_7               ; no then try button 7
    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
  button_7:
    cmp  ah,7                   ; was it button 7 - FLIP ICON
    jne  button_8               ; no then try button 8
    call flip_icon              ; flip
  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
  button_9:
    cmp  ah,9                   ; was it button 9 - FLIP L/R and U/D
    jne  button_10              ; no then try button 10
    call flip_diag              ; flip L/R and U/D
    call draw_icon              ; update icon
    call draw_graph             ; update graph
  button_10:
    cmp  ah,10                  ; was it button 9 - SET AS BGR
    jne  check_mouse            ; no then exit
    call set_background         ; set as background

    jmp  check_mouse            ; start loop again

;   *********************************************
;   *******  WINDOW DEFINITIONS AND DRAW ********
;   *********************************************
draw_window:

    mov  eax,12                 ; function 12:tell os about windowdraw
    mov  ebx,1                  ; 1, start of draw
    int  0x40
                                ; 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  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
                                ; DEFINE BUTTON 3 : FILENAME
    mov  eax,8                  ; function 8 : define button
    mov  ebx,5*65536+62         ; [x start] *65536 + [x size]
    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
                                ; 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]
    mov  ecx,0xddeeff           ; text color 0x00RRGGBB
    mov  edx,button_text_3      ; pointer to text beginning
    mov  esi,8                  ; text length
    int  0x40

    call draw_filename          ; update filename

                                ; DEFINE BUTTON 4 : LOAD
    mov  eax,8                  ; function 8 : define button
    mov  ebx,(window_x_size-87)*65536+38     ; [x start] *65536 + [x size]
    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
                                ; 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
                                ; 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
                                ; DEFINE BUTTON 7 : FLIP VERTICAL
    mov  ecx,85*65536+14        ; [y start] *65536 + [y size]
    mov  edx,7                  ; button id number
    int  0x40
                                ; DEFINE BUTTON 8 : FLIP HORIZONTAL
    mov  ecx,105*65536+14       ; [y start] *65536 + [y size]
    mov  edx,8                  ; button id number
    int  0x40
                                ; DEFINE BUTTON 9 : SET AS BACKGROUND
    mov  ecx,125*65536+14       ; [y start] *65536 + [y size]
    mov  edx,9                  ; button id number
    int  0x40
                                ; DEFINE BUTTON 10 : SET AS BACKGROUND
    mov  ecx,145*65536+14       ; [y start] *65536 + [y size]
    mov  edx,10                 ; button id number
    int  0x40
                                ; 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]
    mov  ecx,0xddeeff           ; text color 0x00RRGGBB
    mov  edx,button_text_4      ; pointer to text beginning
    mov  esi,4                  ; text length
    int  0x40
                                ; 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
                                ; 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
                                ; BUTTON 7 TEXT
    mov  ebx,275*65536+89       ; [x start] *65536 + [y start]
    mov  edx,button_text_7      ; pointer to text beginning
    int  0x40
                                ; BUTTON 8 TEXT
    mov  ebx,275*65536+109      ; [x start] *65536 + [y start]
    mov  edx,button_text_8      ; pointer to text beginning
    int  0x40
                                ; BUTTON 9 TEXT
    mov  ebx,275*65536+129      ; [x start] *65536 + [y start]
    mov  edx,button_text_9      ; pointer to text beginning
    int  0x40
                                ; BUTTON 10 TEXT
    mov  ebx,275*65536+149      ; [x start] *65536 + [y start]
    mov  edx,button_text_10     ; pointer to text beginning
    int  0x40
                                ; 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
                                ; 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
                                ; 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
                                ; 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
                                ; 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
                                ; 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
                                ; 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
                                ; 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
                                ; DRAW PALETTE RED + GREEN SECTION
    xor  edi,edi                ; clear column loop count
next_r_g_outer:
    xor  esi,esi                ; clear line loop count
next_r_g_inner:
    mov  eax,1                  ; function 1 : putpixel
    mov  ebx,edi                ; get column count
    shr  ebx,3                  ; divide by 8
    add  ebx,269                ; add our x offset
    mov  ecx,esi                ; get our line count
    shr  ecx,3                  ; divide by 8
    add  ecx,218                ; add our y offset
    mov  edx,255                ; maximum red
    sub  edx,edi                ; minus column count
    shl  edx,8                  ; into position 0x0000RR00
    add  edx,255                ; maximum green
    sub  edx,esi                ; minus line count
    shl  edx,8                  ; into position 0x00RRGG00
    int  0x40
    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
    add  edi,5                  ; colour in steps of 5 to keep small
    cmp  edi,255                ; have we done all columns

⌨️ 快捷键说明

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