📄 jacts.asm
字号:
invoke SetTimer, hWnd, timer_num, eax, NULL
mov timer_handle, eax
mov def_acorr, 'S'
call recalc
invoke update_display, hWnd
invoke set_ini, 1, hWnd ;save current settings
invoke EnableWindow, ab_handle, FALSE ;disable buttons
invoke EnableWindow, cdtb_handle, FALSE
invoke EnableWindow, rab_handle, FALSE
invoke EnableWindow, start_handle, FALSE
invoke EnableWindow, sw_handle, FALSE
invoke EnableWindow, sc_handle, FALSE ;disable listboxes
invoke EnableWindow, mc_handle, FALSE
invoke EnableWindow, hc_handle, FALSE
invoke EnableWindow, sdc_handle, FALSE ;disable DT control
ret
.endif
;we are here if CountDown fuction is selected
invoke GetDlgItemText, hWnd, IDC_HC, addr d_buffer, 256
;determine setting of Timer Hour listbox
mov ax, word ptr d_buffer
mov hc_str, ax ;get 2 digit setting into hc_str
xor eax, eax
mov al, d_buffer ;significant char of Timer Hours
sub al, '0' ;convert to number
imul ax, 10 ;mul by 10
mov st_hour, ax
xor eax, eax
mov al, d_buffer + 1 ;second char of Timer Hours
sub al, '0'
add st_hour, ax ;add minutes to hours
mov ax, st_hour
cwde ;convert timer hours WORD to DWORD
mov ebx, 60
mul ebx ;Multiply by 60 to get minutes
mov timer_min, eax ;# of minutes from the Timer Hours
invoke GetDlgItemText, hWnd, IDC_MC, addr d_buffer, 256
;determine setting of Timer Miunte listbox
mov ax, word ptr d_buffer
mov mc_str, ax
xor eax, eax
mov al, d_buffer ;significant char of Timer Minutes
sub al, '0'
imul ax, 10
mov st_min, ax
mov al, d_buffer + 1 ;second char of Timer Minutes
sub al, '0'
add st_min, ax
mov ax, st_min
cwde
add eax, timer_min ;Add # of minutes from Hour control
mov repeat_mins, eax ;store timer minutes incase repeat after
imul eax, 60
mov timer_sec, eax ;# of seconds from Hour & Minute controls
mov repeat_secs, eax
invoke GetDlgItemText, hWnd, IDC_SC, addr d_buffer, 256
;determine setting of Timer Second listbox
mov ax, word ptr d_buffer
mov sc_str, ax
xor eax, eax
mov al, d_buffer ;significant char of Timer Minutes
sub al, '0'
imul ax, 10
mov st_sec, ax
mov al, d_buffer + 1 ;second char of Timer Minutes
sub al, '0'
add st_sec, ax
mov ax, st_sec
cwde
add eax, repeat_secs ;store timer seconds incase repeat after
mov repeat_secs, eax
push eax ;temporarily save seconds
invoke GetLocalTime, addr system_time
invoke SystemTimeToFileTime, addr system_time, addr time_now
pop eax ;restore timer seonds
mov ebx, 10000000 ;conversion for seonds to filetime units
mul ebx ;edx:eax holds filetime units to be added to time_now
mov ebx, time_now.dwLowDateTime
add ebx, eax ;add time_now low WORD to timer low WORD
mov alarm_time.dwLowDateTime, ebx ;save in alarm time
mov ebx, time_now.dwHighDateTime
adc ebx, edx ;add with carry, time now high WORD to timer high WORD
mov alarm_time.dwHighDateTime, ebx ;save in alarm time
invoke SendMessage, rab_handle, BM_GETCHECK, 0, 0
;determine if Repeat After button is pushed
.if (eax) ;Repeat After CountDown Checked
mov def_acorr, 'R'
.else
mov def_acorr, 'C'
.endif
mov eax, 1000 ;start Timer for 1 second
invoke SetTimer, hWnd, timer_num, eax, NULL
mov timer_handle, eax
call recalc
invoke update_display, hWnd
invoke set_ini, 1, hWnd ;save current settings
invoke EnableWindow, ab_handle, FALSE ;disable buttons
invoke EnableWindow, cdtb_handle, FALSE
invoke EnableWindow, rab_handle, FALSE
invoke EnableWindow, start_handle, FALSE
invoke EnableWindow, sw_handle, FALSE
invoke EnableWindow, sc_handle, FALSE ;disable listboxes
invoke EnableWindow, mc_handle, FALSE
invoke EnableWindow, hc_handle, FALSE
invoke EnableWindow, sdc_handle, FALSE ;disable control
.endif
jmp @F
no_cdt:
invoke MessageBox, hWnd, addr nocdt, NULL, MB_OK
;display no time in hours and minutes listbox error
@@:
ret
start_timer ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Ini File description:
; Header 50 bytes long including cr/lf
;0 Joe's Alarm/Countdown Timer/StopWatch (c) 2000-2001 MASM32 ;plus 13, 10
; Body
;60 Hours:xx ;previous hours setting plus 13, 10
;70 Minutes:xx ;previous minutes setting plus 13, 10
;82 Seconds:xx ;previous seconds settingplus 13, 10
;94 ACorR:x ;previous function setting Alarm, Countdown, Repeat after, or Stopwatch
;103 Wav:
;107 file name of default wav file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;-----------------------------------------------------
set_ini PROC fType:WORD, hWnd:HWND
;_____________________________________________________
LOCAL iniHandle:HWND
LOCAL bRead:DWORD
LOCAL temp_dw:DWORD
invoke CreateFile, addr iniFileName, GENERIC_READ or GENERIC_WRITE, \
0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, NULL
;try to create a new ini file
mov iniHandle, eax
invoke GetLastError ;error will show if file exists
.if (eax != ERROR_ALREADY_EXISTS) ;File Needs to be Created or
; error opening file
.if (eax == 0) ;New File Created
lea eax, w_buffer
lea ebx, IDStr
sub eax, ebx
mov temp_dw, eax ;length of IDStr & other values in temp_dw
invoke WriteFile, iniHandle, addr IDStr, temp_dw, addr bRead, NULL
;write IDStr to new file
mov def_hours, 1 ;establish abrtrary defaults
mov def_mins, 30
mov def_secs, 0
mov def_acorr, 'A'
invoke CloseHandle, iniHandle ;close new ini file
ret
.else ;Error opening file
invoke CloseHandle, iniHandle
invoke MessageBox, hWnd, addr iniFileName, addr AppName, MB_OK
;display error opening file dialog
mov def_hours, 1 ;establish abrtrary defaults
mov def_mins, 30
mov def_secs, 0
mov def_acorr, 'A'
ret
.endif
.endif
;We're here if the file was opened as already existing
; Check to see if this is a valid file
; And read in default values!
invoke ReadFile, iniHandle, addr d_buffer, sizeof IDStr, addr bRead, NULL
;read IDStr into d+buffer
lea edi, d_buffer ;String read from .ini file in d_buffer
lea esi, IDStr ;Compare with the one built into this program
mov ecx, sizeof IDStr ;How many character to compare
cld
repe cmpsb ;Compare
.if (!ZERO?) ;Strings did not compare
invoke MessageBox, hWnd, addr ini_nom, addr AppName, MB_OK
invoke CloseHandle, iniHandle
mov def_hours, 1 ;establish abrtrary defaults
mov def_mins, 30
mov def_acorr, 'A'
ret
.endif
;fType is parameter passed to this routine
; 0 - Read in settings saved from previous use at program start
; 1 - Save current timer settings
; 2 - Save new wave file name
;FilePointer is currently pointing to "Hours:"
.if (fType == 0) ;Read in initial values
invoke SetFilePointer, iniHandle, 6, NULL, FILE_CURRENT
;skips string "Hours:"
invoke ReadFile, iniHandle, addr d_buffer, 2, addr bRead, NULL
;reads 2 digit Hour string
xor eax, eax
mov al, d_buffer ;significant char of Timer Hours
mov byte ptr hc_str, al
sub al, '0'
imul ax, 10
mov def_hours, eax
xor eax, eax
mov al, d_buffer + 1 ;second char of Timer Hours
mov byte ptr hc_str+1, al
sub al, '0'
add def_hours, eax ;timer hours in def_hours, used to set listbox
invoke SetFilePointer, iniHandle, 10, NULL, FILE_CURRENT
;skips CR, LF, & string "Minutes:"
invoke ReadFile, iniHandle, addr d_buffer, 2, addr bRead, NULL
;reads 2 digit Minute string
xor eax, eax
mov al, d_buffer ;first char of Timer Minutes
mov byte ptr mc_str, al
sub al, '0'
imul ax, 10
mov def_mins, eax
xor eax, eax
mov al, d_buffer + 1 ;second char of Timer Minutes
mov byte ptr mc_str+1, al
sub al, '0'
add def_mins, eax ;timer minutes in def_mins, used to set listbox
invoke SetFilePointer, iniHandle, 10, NULL, FILE_CURRENT
;skips CR, LF, & string "Seconds:"
invoke ReadFile, iniHandle, addr d_buffer, 2, addr bRead, NULL
;reads 2 digit Second string
xor eax, eax
mov al, d_buffer ;first char of Timer Minutes
mov byte ptr sc_str, al
sub al, '0'
imul ax, 10
mov def_secs, eax
xor eax, eax
mov al, d_buffer + 1 ;second char of Timer Minutes
mov byte ptr sc_str+1, al
sub al, '0'
add def_secs, eax ;timer minutes in def_mins, used to set listbox
invoke SetFilePointer, iniHandle, 8, NULL, FILE_CURRENT
;skips CR, LF, & string "CRorR:"
invoke ReadFile, iniHandle, addr d_buffer, 1, addr bRead, NULL
;reads 1 char CRorR string
mov al, byte ptr d_buffer
mov def_acorr, al ;previous value A,C,R, or S in def_acorr
invoke SetFilePointer, iniHandle, 6, NULL, FILE_CURRENT
;skips CR, LF, & string "Wav:"
invoke ReadFile, iniHandle, addr d_buffer, MAX_PATH, addr bRead, NULL
;reads wav file name
invoke lstrcpy, addr wav_name, addr d_buffer
;copies file name into wav_name variable
invoke CloseHandle, iniHandle
ret
.elseif (fType == 1) ;save timer settings
mov eax, sizeof IDStr
add eax, sizeof hStr
sub eax, 4
invoke SetFilePointer, iniHandle, eax, NULL, FILE_BEGIN
;sets file pointer to just after "Hours:"
invoke WriteFile, iniHandle, addr hc_str, 2, addr bRead, NULL
;writes Hour string
invoke SetFilePointer, iniHandle, 10, NULL, FILE_CURRENT
;sets file pointer to just after CR, LF, & "Minutes:"
invoke WriteFile, iniHandle, addr mc_str, 2, addr bRead, NULL
;writes Minute string
invoke SetFilePointer, iniHandle, 10, NULL, FILE_CURRENT
;sets file pointer to just after CR, LF, & "Seconds:"
invoke WriteFile, iniHandle, addr sc_str, 2, addr bRead, NULL
;writes Second string
invoke SetFilePointer, iniHandle, 8, NULL, FILE_CURRENT
;sets file pointer to just after CR,LF,&"CRorR:"
invoke WriteFile, iniHandle, addr def_acorr, 1, addr bRead, NULL
invoke CloseHandle, iniHandle
ret
.elseif (fType == 2) ;Save new wav file name
lea eax, initial_wav_name
lea ecx, IDStr
sub eax, ecx
invoke SetFilePointer, iniHandle, eax, NULL, FILE_BEGIN
invoke SetEndOfFile, iniHandle
invoke s_length, addr wav_name
mov temp_dw, eax
invoke WriteFile, iniHandle, addr wav_name, temp_dw, addr bRead, NULL
mov temp_dw, 0
invoke WriteFile, iniHandle, addr temp_dw, 1, addr bRead, NULL
invoke CloseHandle, iniHandle
ret
.endif
set_ini ENDP
;----------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -