LOCAL wc:WNDCLASSEX LOCAL msg:MSG LOCAL hwnd:HWND
mov wc.cbSize, SIZEOF WNDCLASSEX mov wc.style, CS_HREDRAW or CS_VREDRAW mov wc.lpfnWndProc, OFFSET WndProc mov wc.cbClsExtra, NULL mov wc.cbWndExtra, NULL push hInst pop wc.hInstance
mov wc.hbrBackground, COLOR_WINDOW+1 mov wc.lpszMenuName, NULL
mov wc.lpszClassName, OFFSET ClassName invoke LoadIcon, NULL, IDI_APPLICATION mov wc.hIcon, eax mov wc.hIconSm, eax
invoke LoadCursor, NULL, IDC_ARROW mov wc.hCursor, eax
invoke RegisterClassEx, addr wc
INVOKE CreateWindowEx, NULL, ADDR ClassName, ADDR AppName,\\
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,\\
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL,\\ hInst, NULL
mov hwnd, eax
INVOKE ShowWindow, hwnd, SW_SHOWNORMAL INVOKE UpdateWindow, hwnd
.WHILE TRUE
INVOKE GetMessage, ADDR msg, NULL, 0, 0 .BREAK .IF (!eax)
INVOKE TranslateMessage, ADDR msg INVOKE DispatchMessage, ADDR msg
.ENDW
mov eax, msg.wParam ret
WinMain endp
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
local @stPs:PAINTSTRUCT local @stRect:RECT local @hDc local @playf:WORD
.IF uMsg == WM_DESTROY
invoke midiOutClose, hdc invoke PostQuitMessage, NULL
.ELSEIF uMsg == WM_PAINT
invoke BeginPaint, hWnd, addr @stPs mov @hDc,eax
invoke GetClientRect, hWnd, addr @stRect
invoke DrawText, @hDc, addr szText, -1, addr @stRect,\\
DT_SINGLELINE or DT_CENTER or DT_VCENTER
invoke EndPaint, hWnd, addr @stPs
.ELSEIF uMsg == WM_CHAR
mov @playf, 0h push
wParam
pop midiPu
4.2创建声音
对于最简单音调的建立,使其高音与低音分明,并对全音与半音进行相应操作。
.if midiPu == 61h ; 'a'
mov midiYu, -24
.elseif midiPu == 62h
mov midiYu, -12
.elseif midiPu == 63h
mov midiYu, 0
.elseif midiPu == 64h
mov midiYu, 12
.elseif midiPu == 65h
mov midiYu, 24
.elseif midiPu == 66h
mov midiYu, 36
.elseif midiPu == 67h
mov midiYu, 48
;===============全音==== .elseif midiPu == 31h mov midiPu, 3ch
mov @playf, 1
.elseif midiPu == 32h mov midiPu, 3eh
mov @playf, 1
.elseif midiPu == 33h mov midiPu, 40h
mov @playf, 1
.elseif midiPu == 34h
mov midiPu, 41h
; 'b'
; 'c'
; 'd'
; 'e'
; 'f'
; 'g'
mov @playf, 1
.elseif midiPu == 35h mov midiPu, 43h
mov @playf, 1
.elseif midiPu == 36h mov midiPu, 45h
mov @playf, 1
.elseif midiPu == 37h mov midiPu, 47h
mov @playf, 1
;================半音==== .elseif midiPu == 71h mov midiPu, 3dh
mov @playf, 1
.elseif midiPu == 77h mov midiPu, 3fh
mov @playf, 1
.elseif midiPu == 72h mov midiPu, 42h
mov @playf, 1
.elseif midiPu == 74h mov midiPu, 44h
mov @playf, 1
.elseif midiPu == 79h mov midiPu, 46h
mov @playf, 1
.endif
; 'w' ; 'q'
; 'r'
; 't'
; 'y'