📄 mmenu.asm
字号:
rm001:
xor edx, edx
div ebx
add dl, '0'
mov [edi], dl
dec edi
loop rm001
mov [edi+5], byte 0
mov eax,58
mov ebx,startfile
int 0x40
mov [childPID], eax
ret
;***************************************************************************
; Function
; parseParams
;
; Description
; Looks at the input parameters; Are we the main menu, and where are
; we drawn?
;
;***************************************************************************
parseParams:
mov edi, I_Param
; set up Menu type variable
mov al, [edi] ; MAINMENU or SUBMENUxxx
mov [menuType], al
pp001:
inc edi
cmp [edi], byte ' '
jne pp001
pp002:
inc edi
cmp [edi], byte ' '
je pp001
pp003:
mov eax, [startX]
imul eax, 10
movzx ebx, byte [edi]
sub bl, byte '0'
add eax, ebx
mov [startX], eax
inc edi
cmp [edi], byte '0'
jae pp003
inc edi
pp004:
mov eax, [startY]
imul eax, 10
movzx ebx, byte [edi]
sub bl, byte '0'
add eax, ebx
mov [startY], eax
inc edi
cmp [edi], byte '0'
jae pp004
ret
;***************************************************************************
; Function
; buildMenuImage
;
; Description
; Constructs the menu picture by copying in small bits of the image
; from pre-loaded bmp files
;
;***************************************************************************
buildMenuImage:
; Note, we do funny maths here because the bmp image
; is stored with a multiple of 4 pixels per row
xor eax, eax
mov [menuDepth], eax
mov ecx, BMP_MT_DEPTH
cmp [menuType], byte 'M'
je @f
mov ecx, BMP_MTF_DEPTH
@@:
add [menuDepth], ecx
mov esi, BMP_MT + BMPHEADER
mov edi, MENU_IMAGE
cld
fill1:
push ecx
push esi
mov ecx, BMP_MT_WIDTH * BPP
rep movsb
pop esi
add esi, ((BMP_MT_WIDTH * BPP) + 3) and 0xFFFC
pop ecx
loop fill1
; Add 1 centre bar for each option to be displayed
mov ecx, [numOptions]
dec ecx
fill2_1:
push ecx
mov ecx, BMP_MC_DEPTH
add [menuDepth], ecx
mov esi, BMP_MC + BMPHEADER
fill2:
push ecx
push esi
mov ecx, BMP_MC_WIDTH * BPP
rep movsb
pop esi
add esi, ((BMP_MC_WIDTH * BPP) + 3) and 0xFFFC
pop ecx
loop fill2
pop ecx
loop fill2_1
mov ecx, BMP_MB_DEPTH
add [menuDepth], ecx
mov esi, BMP_MB + BMPHEADER
fill3:
push ecx
push esi
mov ecx, BMP_MB_WIDTH * BPP
rep movsb
pop esi
add esi, ((BMP_MB_WIDTH * BPP) + 3) and 0xFFFC
pop ecx
loop fill3
ret
;***************************************************************************
; Function
; setWindowForm
;
; Description
; Scans the panel image looking for the curved outline, so it can
; generate a free-form outline window
;
;***************************************************************************
setWindowForm:
; Create the free-form pixel map;
; black is the 'ignore' colour
mov esi,0
mov edx, [menuDepth]
imul edx, MENU_WIDTH
newpix:
mov eax,[ MENU_IMAGE + esi*BPP]
mov bl,0
and eax,0xffffff
cmp eax,0x000000
je cred
mov bl,1
cred:
mov [esi+ MENU_AREA ],bl
inc esi
cmp esi,edx
jbe newpix
; set the free-form window in the OS
mov eax,50
mov ebx,0
mov ecx,MENU_AREA
int 0x40
ret
;***************************************************************************
; Function
; readBitmaps
;
; Description
; Loads the picture elements used to construct the panel image
;
;***************************************************************************
readBitmaps:
; Main panel button, plus curves
mov eax, 58
mov ebx, mt
cmp [menuType], byte 'M'
je @f
mov ebx, mtf
@@:
int 0x40
mov eax, 58
mov ebx, mc
int 0x40
mov eax, 58
mov ebx, mb
int 0x40
ret
;***************************************************************************
; Function
; readMenuOptions
;
; Description
; using the application input parameter I-Param ( which specifies
; the name of the menu ), builds the list of menu options.
; This list is used to determine the size of the menu and the
; icons, text that appear on the menu.
; This updates numOptions and optionsList
; I hate reading text files :o)
;
;***************************************************************************
readMenuOptions:
xor eax, eax
mov [numOptions], eax ; Start with a empty list
mov eax, 58
mov ebx, optionsf
int 0x40
cld
mov esi, OPTIONSFILE
; Skip through the file to our menu list, as defined by I_Params
rmo000a:
mov edi, I_Param
rmo000:
inc esi
cmp [esi-1], byte '['
je rmo001
jmp rmo000
rmo001:
cmpsb
je rmo001
; If the last character was ], we have a match
cmp [esi-1],byte ']'
jne rmo000a ; No? Then look for next
; Build menu table list
mov edi, MENUTABLE
rmoLoop:
; Found correct submenu.
; Skip any whitespace or comments, to get to first character of option
call skipWhite
call nextLine
call findParam
cmp [esi], byte '[' ; Have we come to the end of the list?
je rmoExit ; Yes, so we have finished
; Add menu item into the list
inc dword [numOptions]
; MENUTABLE is an array of menu options
; the format is
; dd pointer to menu text, asciiz
; dd pointer to option type string, asciiz
; dd pointer to menu icon string, ascii z
; dd pointer to appname or submenu name, asciiz
virtual at edi
mtext dd ?
mopt dd ?
micon dd ?
mname dd ?
end virtual
mov [mtext], esi ; Mark start of text string
rmo002:
inc esi
cmp [esi-1], byte ','
jne rmo002
mov [esi-1], byte 0 ; zero terminate ascii string
call skipWhite
mov [mopt], esi ; Mark start of text string
rmo003:
inc esi
cmp [esi-1], byte ','
jne rmo003
mov [esi-1], byte 0 ; zero terminate ascii string
call skipWhite
mov [micon], esi ; Mark start of text string
rmo004:
inc esi
cmp [esi-1], byte ','
jne rmo004
mov [esi-1], byte 0 ; zero terminate ascii string
call skipWhite
mov [mname], esi ; Mark start of text string
; Finially, find the end of the line, and zero terminate it
rmo005:
inc esi
cmp [esi], byte 0x0a
je rmo006
cmp [esi], byte 0x0d
je rmo006
cmp [esi], byte 0x09
je rmo006
cmp [esi], byte ' '
je rmo006
jmp rmo005
rmo006:
mov [esi], byte 0 ; zero terminate ascii string
add edi, 16
jmp rmoLoop
rmoExit:
ret
;***************************************************************************
; Function
; skipWhite
;
; Description
; skips any tabs or spaces
;
;***************************************************************************
skipWhite:
mov al, [esi]
cmp al, ' '
je sw002 ; skip space char
cmp al, 0x09
je sw002 ; skip tab char
ret
sw002:
inc esi
jmp skipWhite
;***************************************************************************
; Function
; nextLine
;
; Description
; skips to the beginning of the next line
;
;***************************************************************************
nextLine:
mov al, [esi]
cmp al, 0x0a
je nl002 ; We have reached the end
cmp al, 0x0d
je nl002
inc esi
jmp nextLine
nl002: ; Now skip the CR/LF bits
inc esi
mov al, [esi]
cmp al, 0x0a
je nl003
cmp al, 0x0d
je nl003
ret ; Now at start of new line
nl003:
inc esi
ret ; Now at start of new line
;***************************************************************************
; Function
; findParam
;
; Description
; skips comments and blank lines until the next parameter if found
; source is in esi; dont touch edi
;
;***************************************************************************
findParam:
mov al, [esi] ; get file character
; is it a comment line?
cmp al, '#'
jne fp002
call nextLine ; Move to next line
jmp findParam
fp002:
call skipWhite ; Move past any spaces
; Was it an empty line?
mov al, [esi]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -