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

📄 mmenu.asm

📁 Application sources:A084.ZIP
💻 ASM
📖 第 1 页 / 共 3 页
字号:
    cmp     al, 0x0a
    je      fp003                   
    cmp     al, 0x0d
    je      fp003
    ret                             ; We have the parameter!

fp003:
    ; It was an empty line; Read past the end of line marker
    ; and return to findParam for next line
    inc     esi
    mov     al, [esi]
    cmp     al, 0x0a
    je      fp004                  
    cmp     al, 0x0d
    je      fp004
    jmp     findParam

fp004:
    inc     esi
    jmp     findParam




;   *********************************************
;   *******  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, [startX] ;0 + MENU_WIDTH
    shl     ebx, 16
    add     ebx, MENU_WIDTH - 1
;    dec     ebx
    mov     ecx, [startY] ; 28 * 65536
    shl     ecx, 16
    add     ecx, [menuDepth]
    mov     edx,0x01000000 ; 0x02ffffff  ; col of work area RRGGBB,8->color gl
    mov     esi,0x815080d0             ; color of grab bar  RRGGBB,8->color gl
    mov     edi,0x005080d0             ; color of frames    RRGGBB
    int     0x40

    
    mov     ecx, [numOptions]
    mov     eax, 8                       ; function 8 : define and draw button
    mov     ebx, 0*65536+MENU_WIDTH      ; [x start] *65536 + [x size]
    mov     edx, 0x60000000             ; button id - 6 at front means no rect
    mov     esi, 0x6688dd                ; button color RRGGBB
    mov     edi, BMP_MT_DEPTH*65536 + 34 ; [y start] *65536 + [y size]
    cmp     [menuType], byte 'M'
    je     @f
    mov     edi, BMP_MTF_DEPTH*65536 + 34 ; [y start] *65536 + [y size]
@@:

dw001:
    pusha
    mov     ecx, edi
    int     0x40
    popa
    add     edi, 34 * 65536
    add     edx, 16                     ; Make button id offset into MENUTABLE
    loop    dw001
    
    ; Place the image on the screen
    mov     eax,7
    mov     ebx,MENU_IMAGE    
    mov     ecx, MENU_WIDTH * 65536
    add     ecx, [menuDepth]
    mov     edx,0
    int     0x40
    

    ; add the text labels to the menu
    mov     ecx, [numOptions]
    mov     edi, MENUTABLE
    mov     eax, 4                  ; Write text
    mov     ebx, 46 * 65536 + 32
    cmp     [menuType], byte 'M'
    je     @f
    mov     ebx, 46 * 65536 + 20
@@:

dwText:    
    pusha
    mov     edx, [edi]
    call    strLen                  
    xor     ecx, ecx                ; Black text
    int     0x40
    popa
    add     ebx, 34
    add     edi, 16
    loop    dwText
    
    mov     eax,12                    ; function 12:tell os about windowdraw
    mov     ebx,2                     ; 2, end of draw
    int     0x40

    ret


;***************************************************************************
;   Function
;      strLen
;
;   Description
;       Optimised to work with drawText: Returns length of string
;       string pointed to by edx
;       result in esi
;       ecx used as temp variable
;
;***************************************************************************
strLen:
    
    mov     esi, edx
    dec     esi
sl000:
    inc     esi
    cmp     [esi], byte 0
    jne     sl000
    sub     esi, edx
    
    ret


;***************************************************************************
;   Function
;      drawIcon
;
;   Description
;       Loads an icon file ( fname ) and renders it into the menu image
;       at the current position.
;       The icon must be 32x32, 24 bit colour. If it is a .ico file, It must
;       have an alpha channel, although it isn't used.
;
;       This is mike.dld's code, ripped from icon.asm
;
;       icon file name pointed to by esi
;       top left position to display icon in edi
;
;***************************************************************************
drawIcon:
    push    edi
    
    ; Copy the filename across
    mov     edi, tmpfn
    mov     ecx, 256
    cld
    rep     movsb
    
    xor     eax, eax
    mov     [tmpf], eax
    mov     [tmpf+4], eax
    dec     eax
    mov     [tmpf+8], eax
    mov     eax, ICON_FILE    
    mov     [tmpf+12], eax
    
    
    ; Read the .ico or .bmp file
    mov     eax, 58
    mov     ebx, tmpf
    int     0x40    


    ; What type of image file is it?
    mov     [itype],0
    cmp     word[ICON_FILE],'BM'
    je      @f
    inc     [itype]
  @@:
    
    pop     esi
    mov     ecx, esi

    ; esi points to menu image top left position
    ; We point to the end since the icon image is 'upside down'
    add     esi, (MENU_WIDTH * 31 * BPP)
    
    ; edi scans through icon image
    mov     edi,ICON_FILE+62 ; 6 - header, 16 - iconinfo, 40 - bitmapinfo
    cmp     [itype],0
    jne     @f
    mov     edi,ICON_FILE+54
  @@:
    xor     ebp,ebp

l00:
    push    ecx
    
    virtual at edi
      r  db ?
      g  db ?
      b  db ?
      a  db ?
    end virtual
    
    virtual at esi+ebp
      ar db ?
      ag db ?
      ab db ?
    end virtual

    movzx   cx,[a]
    
    cmp     [itype],0
    jne     @f
    mov     eax,[edi]
    and     eax,0x00ffffff
    test    eax,eax
    jnz     @f
    mov     al,[ar]
    mov     [esi+ebp+0],al
    mov     al,[ag]
    mov     [esi+ebp+1],al
    mov     al,[ab]
    mov     [esi+ebp+2],al
    jmp     no_transp
  @@:

    xor     eax,eax
    mov     al,[r]
    cmp     [itype],0
    je      @f
    movzx   bx,[ar]
    sub     ax,bx
    mov     bx,cx
    imul    bx
    xor     edx,edx
    mov     bx,255
    div     bx
    movzx   ebx,[ar]
    add     eax,ebx
  @@:
    mov     [esi+ebp+0],al

    xor     eax,eax
    mov     al,[g]
    cmp     [itype],0
    je      @f
    movzx   bx,[ag]
    sub     ax,bx
    mov     bx,cx
    imul    bx
    xor     edx,edx
    mov     bx,255
    div     bx
    movzx   bx,[ag]
    add     eax,ebx
  @@:
    mov     [esi+ebp+1],al

    xor     eax,eax
    mov     al,[b]
    cmp     [itype],0
    je      @f
    movzx   bx,[ab]
    sub     ax,bx
    mov     bx,cx
    imul    bx
    xor     edx,edx
    mov     bx,255
    div     bx
    movzx   bx,[ab]
    add     eax,ebx
  @@:
    mov     [esi+ebp+2],al

no_transp:
    pop     ecx
    add     edi,3
    add     edi,[itype]

    add     ebp,3
    cmp     ebp,32*3
    jl      l00
    
    xor     ebp,ebp

    sub     esi,MENU_WIDTH * BPP
    cmp     esi, ecx
    jge     l00

    ret



;***************************************************************************
;   Function
;      renderIcons
;
;   Description
;       Reads the icon images and renders them into the menu bitmap
;
;***************************************************************************
renderIcons:
    mov     ecx, [numOptions]
    mov     esi, MENUTABLE + 8 ; Offset to menu icon filename
    mov     edi, MENU_IMAGE + (6 + (BMP_MT_DEPTH * MENU_WIDTH)) * BPP
    cmp     [menuType], byte 'M'
    je     @f
    mov     edi, MENU_IMAGE + (6 + (BMP_MTF_DEPTH * MENU_WIDTH)) * BPP
@@:

ri001:
    pusha
    mov     esi, [esi]
    call    drawIcon
    popa
    add     esi, 16
    add     edi, 34 * MENU_WIDTH * BPP
    loop    ri001
        
    ret




    
    

; Data area

childPID    dd  0

received_messages:

      db  0      ; lock byte
      db  0,0,0  ; reserved
      dd  8      ; pointer to free msg position from received_messages
      times 16 db 0  

lastButton  dd -1
startX:     dd  0                   ; Place to draw menu
startY:     dd  0
newX:       dd  0
newY:       dd  0

menuType:   db  0                   ; 0 == main, 1 == sub
menuDepth:  dd  0                   ; Real depth of menu
numOptions: dd  5                   ; Number of menu options ( 5 is test )

itype	    dd  0
appname     db  '            '

mtf:
    dd  0
    dd  0
    dd  -1                          ; Amount to load - all of it
    dd  BMP_MT                      ; Place to store file data
    dd  OSWORKAREA                  ; os work area - 16KB
    db  '/rd/1/mtf.bmp',0

mt:
    dd  0
    dd  0
    dd  -1                          ; Amount to load - all of it
    dd  BMP_MT                      ; Place to store file data
    dd  OSWORKAREA                  ; os work area - 16KB
    db  '/rd/1/mt.bmp',0

mc:
    dd  0
    dd  0
    dd  -1                          ; Amount to load - all of it
    dd  BMP_MC                      ; Place to store file data
    dd  OSWORKAREA                  ; os work area - 16KB
    db  '/rd/1/mc.bmp',0

mb:
    dd  0
    dd  0
    dd  -1                          ; Amount to load - all of it
    dd  BMP_MB                      ; Place to store file data
    dd  OSWORKAREA                  ; os work area - 16KB
    db  '/rd/1/mb.bmp',0

optionsf:
    dd  0
    dd  0
    dd  -1                          ; Amount to load - all of it
    dd  OPTIONSFILE                 ; Place to store file data
    dd  OSWORKAREA                  ; os work area - 16KB
    db  '/rd/1/mpanel.dat',0


tmpf:
    dd  0
    dd  0
    dd  -1                          ; Amount to load - all of it
    dd  ICON_FILE                   ; Place to store file data
    dd  OSWORKAREA                  ; os work area - 16KB
tmpfn:
    times 256 db 0                  ; space for the filename


startfile:
    dd  16                          ; Start file option
    dd  0                           ; Reserved, 0
    dd  params                      ; Parameters 
    dd  0                           ; Reserved, 0
    dd  OSWORKAREA                  ; OS work area - 16KB
    db  '/rd/1/mmenu',0
    
params:     ; Shared with I_Params
I_Param:    ; 256 bytes    

I_END:




⌨️ 快捷键说明

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