[29] | 1 | ; AiR-BOOT (c) Copyright 1998-2008 M. Kiewitz
|
---|
| 2 | ;
|
---|
| 3 | ; This file is part of AiR-BOOT
|
---|
| 4 | ;
|
---|
| 5 | ; AiR-BOOT is free software: you can redistribute it and/or modify it under
|
---|
| 6 | ; the terms of the GNU General Public License as published by the Free
|
---|
| 7 | ; Software Foundation, either version 3 of the License, or (at your option)
|
---|
| 8 | ; any later version.
|
---|
| 9 | ;
|
---|
| 10 | ; AiR-BOOT is distributed in the hope that it will be useful, but WITHOUT ANY
|
---|
| 11 | ; WARRANTY: without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 12 | ; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
---|
| 13 | ; details.
|
---|
| 14 | ;
|
---|
| 15 | ; You should have received a copy of the GNU General Public License along with
|
---|
| 16 | ; AiR-BOOT. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 17 | ;
|
---|
[8] | 18 | ;---------------------------------------------------------------------------
|
---|
| 19 | ; AiR-BOOT / TIMER
|
---|
| 20 | ;---------------------------------------------------------------------------
|
---|
| 21 |
|
---|
[51] | 22 | IFDEF MODULE_NAMES
|
---|
[30] | 23 | DB 'TIMER',0
|
---|
| 24 | ENDIF
|
---|
| 25 |
|
---|
[8] | 26 | ; This here is one of the rare cases that I'm using DIV and MUL opcodes. I
|
---|
| 27 | ; could have coded around them in here as well, but I was too lazy. Most of
|
---|
| 28 | ; the time, I'm not using them. If you want to look at something "leet", look
|
---|
| 29 | ; at SPECIAL\FX.asm =)
|
---|
| 30 |
|
---|
| 31 | ; In: Nothing
|
---|
| 32 | ; Out: DX:AX - Current TimerTicCount
|
---|
| 33 | TIMER_GetTicCount Proc Near Uses ds si
|
---|
| 34 | push 0040h
|
---|
| 35 | pop ds
|
---|
| 36 | mov si, 006Ch
|
---|
| 37 | mov ax, word ptr ds:[si]
|
---|
| 38 | mov dx, word ptr ds:[si+2]
|
---|
| 39 | ret
|
---|
| 40 | TIMER_GetTicCount EndP
|
---|
| 41 |
|
---|
| 42 | ; In: AL - Timer-Tics to wait
|
---|
| 43 | ; Out: Nothing
|
---|
| 44 | TIMER_WaitTicCount Proc Near Uses ax bx dx
|
---|
[30] | 45 | ;movzx bx, al
|
---|
| 46 | mov bl,al
|
---|
| 47 | mov bh,0
|
---|
| 48 |
|
---|
[8] | 49 | call TIMER_GetTicCount
|
---|
| 50 | add bx, ax ; BX - Required lower Tic
|
---|
| 51 | TWTC_Loop:
|
---|
| 52 | call TIMER_GetTicCount
|
---|
| 53 | cmp ax, bx
|
---|
| 54 | jb TWTC_Loop
|
---|
| 55 | ret
|
---|
| 56 | TIMER_WaitTicCount EndP
|
---|
| 57 |
|
---|
| 58 | ; In: AL - Seconds
|
---|
| 59 | ; Out: AX - Tics
|
---|
| 60 | TIMER_TranslateSecToTic Proc Near Uses bx dx
|
---|
| 61 | or al, al
|
---|
| 62 | jz TTSTT_Zerod
|
---|
| 63 | xor ah, ah
|
---|
| 64 | mov dl, 5
|
---|
| 65 | div dl ; Seconds : 5
|
---|
| 66 | mov bh, ah
|
---|
| 67 | xor ah, ah
|
---|
| 68 | mov bl, 91
|
---|
| 69 | mul bl ; Result * 91
|
---|
| 70 | mov dx, ax
|
---|
[30] | 71 | ;movzx ax, bh
|
---|
| 72 | mov al,bh
|
---|
| 73 | mov ah,0
|
---|
| 74 |
|
---|
[8] | 75 | mov bl, 18
|
---|
| 76 | mul bl ; Remainder * 18
|
---|
| 77 | add ax, dx ; Add both together...
|
---|
| 78 | TTSTT_Zerod:
|
---|
| 79 | ret
|
---|
| 80 | TIMER_TranslateSecToTic EndP
|
---|
| 81 |
|
---|
| 82 | ; In: AX - Tics
|
---|
| 83 | ; Out: AL - Seconds
|
---|
| 84 | TIMER_TranslateTicToSec Proc Near Uses bx dx
|
---|
| 85 | or ax, ax
|
---|
| 86 | jz TTTTS_Overflow
|
---|
| 87 | cmp ax, 23295
|
---|
| 88 | ja TTTTS_Overflow
|
---|
| 89 | mov dl, 91
|
---|
| 90 | div dl ; Tics : 91
|
---|
| 91 | mov dh, al
|
---|
[30] | 92 | ;movzx ax, ah
|
---|
| 93 | mov al,ah
|
---|
| 94 | mov ah,0
|
---|
| 95 |
|
---|
[8] | 96 | mov dl, 18
|
---|
| 97 | div dl ; Remainder : 18
|
---|
| 98 | xor ah, ah ; We dont need that remainder
|
---|
| 99 | xchg dh, al
|
---|
| 100 | mov bl, 5
|
---|
| 101 | mul bl ; Result * 5
|
---|
[30] | 102 | ;movzx dx, dh
|
---|
| 103 | mov dl,dh
|
---|
| 104 | mov dh,0
|
---|
| 105 |
|
---|
[8] | 106 | add ax, dx ; Add both together...
|
---|
| 107 | ret
|
---|
| 108 | TTTTS_Overflow:
|
---|
| 109 | xor ax, ax
|
---|
| 110 | ret
|
---|
| 111 | TIMER_TranslateTicToSec EndP
|
---|