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

📄 iconedit.asm

📁 menuet os应用程序源代码,很多汇编写的应用程序
💻 ASM
📖 第 1 页 / 共 3 页
字号:
    jne  next_r_g_outer         ; no then start the next one

                                ; DRAW PALETTE GREEN + BLUE SECTION
    mov  edi,0                  ; as above
next_g_b_outer:
    mov  esi,0
next_g_b_inner:
    mov  eax,1
    mov  ebx,edi
    shr  ebx,3
    add  ebx,269
    mov  ecx,esi
    shr  ecx,3
    add  ecx,250
    mov  edx,255
    sub  edx,edi
    shl  edx,16
    add  edx,esi
    int  0x40
    add  esi,5
    cmp  esi,255
    jne  next_g_b_inner
    add  edi,5
    cmp  edi,255
    jne  next_g_b_outer

                                ; DRAW PALETTE BLUE + RED SECTION
    mov  edi,0                  ; as above
next_b_r_outer:
    mov  esi,0
next_b_r_inner:
    mov  eax,1
    mov  ebx,edi
    shr  ebx,3
    add  ebx,301
    mov  ecx,esi
    shr  ecx,3
    add  ecx,250
    mov  edx,edi
    shl  edx,8
    add  edx,esi
    int  0x40
    add  esi,5
    cmp  esi,255
    jne  next_b_r_inner
    add  edi,5
    cmp  edi,255
    jne  next_b_r_outer

                                ; DRAW GREYSCALE
    mov  edi,0
next_b_w_outer:
    mov  esi,0
next_b_w_inner:
    mov  eax,1
    mov  ebx,edi
    shr  ebx,3
    add  ebx,308
    mov  ecx,esi
    shr  ecx,3
    add  ecx,211
    mov  edx,esi
    shl  edx,8
    add  edx,esi
    shl  edx,8
    add  edx,esi
    int  0x40
    add  esi,5
    cmp  esi,255
    jne  next_b_w_inner
    add  edi,5
    cmp  edi,255
    jne  next_b_w_outer

    cmp  [first_run],0          ; is it the first window draw
    jne  dont_load              ; no then dont reload the file
    call load_file              ; load initial file
    mov  [first_run],1          ; first window draw done
dont_load:
    call draw_icon              ; draw icon area
    call draw_graph             ; draw edit area

    mov  eax,12                 ; function 12:tell os about windowdraw
    mov  ebx,2                  ; 2, end of draw
    int  0x40

    ret                         ; return

;   *********************************************
;   *******  SET BACKGROUND              ********
;   *********************************************
set_background:

    mov  ecx,image+3600         ; point to our decode buffer
    mov  edx,image+54+32*32*3-96    ; point to last line of bmp

    mov  edi,0                  ; zero line count
decode_line:
    mov  esi,0                  ; zero column count
decode_column:
    mov  ebx,[edx]              ; get our data
    mov  [ecx],ebx              ; store our data
    add  ecx,4                  ; add 4 bytes to pointer as using double word
    add  edx,4                  ; add 4 bytes to pointer
    inc  esi                    ; increment column count
    cmp  esi,24                 ; have we done all columns
    jne  decode_column          ; no then do some more
    sub  edx,192                ; move back 2 lines of bmp data
    inc  edi                    ; increment line count
    cmp  edi,33                 ; have we done all lines
    jne  decode_line            ; no then do another one

    mov  eax,15                 ; background
    mov  ebx,1                  ; set background size
    mov  ecx,32                 ; x size
    mov  edx,32                 ; y size
    int  0x40                   ; 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
    mov  ebx,3                  ; draw background
    int  0x40                   ; do it

    ret                         ; return

;   *********************************************
;   *******  GET SCREEN X and Y SIZE     ********
;   *********************************************
get_screen_size:

    mov  eax,14                 ; function 14 : get screen max
    int  0x40                   ; returns eax : 0xXXXXYYYY
    push eax                    ; save reg
    and  eax,0x0000ffff         ; split out y size
    add  eax,1                  ; add 1 to remove zero base
    mov  [y_size],eax           ; store for later
    pop  eax                    ; restore reg
    shr  eax,16                 ; move x size down the reg
    add  eax,1                  ; add 1 to remove zero base
    mov  [x_size],eax           ; store for later

    ret

;   *********************************************
;   *******  LOAD FILE                   ********
;   *********************************************
load_file:

    mov  eax,6                  ; function 6 : load file
    mov  ebx,icon               ; point to the name
    mov  ecx,0                  ; reserved
    mov  edx,200000             ; reserved
    mov  esi,image              ; point to image buffer
    int  0x40                   ; do it

    ret                         ; return

;   *********************************************
;   *******  SAVE FILE                   ********
;   *********************************************
save_file:

    mov  eax,33                 ; function 33 : save file
    mov  ebx,icon               ; point to name
    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

    ret                         ; return

;   *********************************************
;   *******  DRAW FILENAME TO SCREEN     ********
;   *********************************************
draw_filename:
                                ; DRAW COLOUR BACKGROUND
    pusha                       ; save all registers on stack
    mov  eax,13                 ; function 13 : draw bar
    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

    mov  eax,4                  ; function 4 : write text to window
    mov  ebx,78*65536+(window_y_size-15)     ; [y start] *65536 + [y size]
    xor  ecx,ecx                ; colour 0x00RRGGBB = black
    mov  edx,icon               ; point to text
    mov  esi,12                 ; number of characters to write
    cmp  byte [editstate],1     ; are we in edit mode
    jne  no_active_1            ; no then jump over change colour
    mov  ecx,0x00112299         ; else change colour
no_active_1:
    int  0x40                   ; do it
    popa                        ; return all registers to original
    ret                         ; return

;   *********************************************
;   *******  DRAW ICON FROM LOADED FILE  ********
;   *********************************************
draw_icon:

    mov  ecx,27                 ; y start position
    mov  eax,image+51+32*32*3   ; point to our bmp data
    mov  edi,0                  ; line count
line:
    mov  esi,0                  ; column count
    mov  ebx,269+31             ; x start position
pixel:
    mov  edx,[eax]              ; colour 0x00RRGGBB from image data
    push eax                    ; save our position
    mov  eax,1                  ; function 1 : put pixel
    int  0x40                   ; do it
    pop  eax                    ; restore our position
    sub  eax,3                  ; point to next pixel colour
    dec  ebx                    ; move our x position
    inc  esi                    ; increment our column count
    cmp  esi,32                 ; have we done all columns
    jne  pixel                  ; no then do next pixel
    inc  ecx                    ; move our y position
    inc  edi                    ; increment line count
    cmp  edi,32                 ; have we done all lines
    jne  line                   ; no then do next line

    ret                         ; return

;   *********************************************
;   *******  DRAW GRAPH FROM LOADED FILE  *******
;   *********************************************
draw_graph:

    mov  edi,0                  ; line count
    mov  eax,image+51+32*32*3   ; point to our bmp data
next_lin:
    mov  ecx,edi                ; use our line count for position
    shl  ecx,3                  ; multiply by eight
    add  ecx,27                 ; add y start position
    shl  ecx,16                 ; move into top eight bytes [y start]
    add  ecx,7                  ; add box height [y size]
    mov  esi,32                 ; column count
next_bo:
    mov  ebx,esi                ; use our column count for position
    shl  ebx,3                  ; multiply by eight
    add  ebx,-1                 ; add a correction
    shl  ebx,16                 ; and move into top eight bytes [x start]
    add  ebx,7                  ; add box width [x size]
    mov  edx,[eax]              ; point to bmp data
    push eax                    ; save our position
    mov  eax,13                 ; function 13 : draw bar
    int  0x40                   ; do it
    pop  eax                    ; restore our position
    sub  eax,3                  ; point to next pixel colour
    dec  esi                    ; increment column count
    cmp  esi,0                  ; have we done all columns
    jne  next_bo                ; no then do the next column
    inc  edi                    ; increment line count
    cmp  edi,32                 ; have we done all lines
    jne  next_lin               ; no then do the next line

    ret                         ; return

;   *********************************************
;   *******  CLEAR GRAPH and ICON AREA   ********
;   *********************************************
clear_graph_icon:

                                ; CLEAR IMAGE DATA
    mov  edi,image+54           ; point to our data
    mov  eax,0x00000000         ; data to write
    mov  ecx,(32*32*3)/4        ; how much data
    rep  stosd                  ; repeat until all data transfered
    call draw_icon              ; draw a blank icon
    call draw_graph             ; draw a blank graph

    ret                         ; return

;   *********************************************
;   *******  FLIP ICON TOP to BOTTOM     ********
;   *********************************************
flip_icon:

    mov  ecx,image+54            ; point at first line
    mov  edx,image+54+32*32*3+96 ; point 1 line past end

    mov  edi,0                   ; zero line count
lines:
    mov  esi,0                   ; zero column count
    sub  edx,192                 ; move back 2 lines
columns:
    mov  eax,[ecx]               ; get bytes
    mov  ebx,[edx]               ; get bytes
    mov  [ecx],ebx               ; swap bytes
    mov  [edx],eax               ; swap bytes
    add  ecx,4                   ; move pointer
    add  edx,4                   ; move pointer
    inc  esi                     ; increment column count
    cmp  esi,24                  ; have we done all columns
    jne  columns                 ; no then do next column
    inc  edi                     ; increment line count
    cmp  edi,16                  ; have we done all lines
    jne  lines                   ; no then do next line
    call draw_icon               ; update icon
    call draw_graph              ; update graph

    ret                          ; return

;   *********************************************
;   *******  FLIP ICON DIAGONAL          ********
;   *********************************************
flip_diag:

    mov  ecx,image+54            ; point line 1 first bytes
    mov  edx,image+3600          ; point to  buffer
    xor  esi,esi                 ; zero byte count

    pusha                        ; save all registers
copy_out:
    mov  eax,[ecx]               ; get bytes
    mov  [edx],eax               ; copy bytes
    add  ecx,4                   ; move pointer
    add  edx,4                   ; move pointer
    inc  esi                     ; increment byte count
    cmp  esi,24*32               ; have we done all bytes
    jne  copy_out                ; no then do the next

⌨️ 快捷键说明

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