| 1 |
|
|---|
| 2 | ; Disclaimer:
|
|---|
| 3 | ;=============
|
|---|
| 4 | ; The sourcecode is released via www.netlabs.org CVS *ONLY*.
|
|---|
| 5 | ; You MUST NOT upload it to other servers nor republish it in any way.
|
|---|
| 6 | ; The sourcecode is still COPYRIGHTED and NOT RELEASED UNDER GPL.
|
|---|
| 7 | ; It's (c) Copyright 1998-2003 by Martin Kiewitz.
|
|---|
| 8 | ; You may recompile the source and do *PRIVATE* modifications, but please keep
|
|---|
| 9 | ; in mind that modifying this code needs at least *some* assembly skill. If
|
|---|
| 10 | ; you mess up your system, because you needed to hack your way through, don't
|
|---|
| 11 | ; blame me. Releasing a customized version of AiR-BOOT, selling it in any form
|
|---|
| 12 | ; or reusing parts of this source is *PROHIBITED*. Ask me, if you have some
|
|---|
| 13 | ; idea about new functionality *before* developing the code, otherwise I will
|
|---|
| 14 | ; definitely reject it. Also please accept, that I have some basic design
|
|---|
| 15 | ; rules on AiR-BOOT and I will maintain them at all costs, so this won't get
|
|---|
| 16 | ; another GRUB.
|
|---|
| 17 |
|
|---|
| 18 | ;---------------------------------------------------------------------------
|
|---|
| 19 | ; AiR-BOOT / TIMER
|
|---|
| 20 | ;---------------------------------------------------------------------------
|
|---|
| 21 |
|
|---|
| 22 | ; This here is one of the rare cases that I'm using DIV and MUL opcodes. I
|
|---|
| 23 | ; could have coded around them in here as well, but I was too lazy. Most of
|
|---|
| 24 | ; the time, I'm not using them. If you want to look at something "leet", look
|
|---|
| 25 | ; at SPECIAL\FX.asm =)
|
|---|
| 26 |
|
|---|
| 27 | ; In: Nothing
|
|---|
| 28 | ; Out: DX:AX - Current TimerTicCount
|
|---|
| 29 | TIMER_GetTicCount Proc Near Uses ds si
|
|---|
| 30 | push 0040h
|
|---|
| 31 | pop ds
|
|---|
| 32 | mov si, 006Ch
|
|---|
| 33 | mov ax, word ptr ds:[si]
|
|---|
| 34 | mov dx, word ptr ds:[si+2]
|
|---|
| 35 | ret
|
|---|
| 36 | TIMER_GetTicCount EndP
|
|---|
| 37 |
|
|---|
| 38 | ; In: AL - Timer-Tics to wait
|
|---|
| 39 | ; Out: Nothing
|
|---|
| 40 | TIMER_WaitTicCount Proc Near Uses ax bx dx
|
|---|
| 41 | movzx bx, al
|
|---|
| 42 | call TIMER_GetTicCount
|
|---|
| 43 | add bx, ax ; BX - Required lower Tic
|
|---|
| 44 | TWTC_Loop:
|
|---|
| 45 | call TIMER_GetTicCount
|
|---|
| 46 | cmp ax, bx
|
|---|
| 47 | jb TWTC_Loop
|
|---|
| 48 | ret
|
|---|
| 49 | TIMER_WaitTicCount EndP
|
|---|
| 50 |
|
|---|
| 51 | ; In: AL - Seconds
|
|---|
| 52 | ; Out: AX - Tics
|
|---|
| 53 | TIMER_TranslateSecToTic Proc Near Uses bx dx
|
|---|
| 54 | or al, al
|
|---|
| 55 | jz TTSTT_Zerod
|
|---|
| 56 | xor ah, ah
|
|---|
| 57 | mov dl, 5
|
|---|
| 58 | div dl ; Seconds : 5
|
|---|
| 59 | mov bh, ah
|
|---|
| 60 | xor ah, ah
|
|---|
| 61 | mov bl, 91
|
|---|
| 62 | mul bl ; Result * 91
|
|---|
| 63 | mov dx, ax
|
|---|
| 64 | movzx ax, bh
|
|---|
| 65 | mov bl, 18
|
|---|
| 66 | mul bl ; Remainder * 18
|
|---|
| 67 | add ax, dx ; Add both together...
|
|---|
| 68 | TTSTT_Zerod:
|
|---|
| 69 | ret
|
|---|
| 70 | TIMER_TranslateSecToTic EndP
|
|---|
| 71 |
|
|---|
| 72 | ; In: AX - Tics
|
|---|
| 73 | ; Out: AL - Seconds
|
|---|
| 74 | TIMER_TranslateTicToSec Proc Near Uses bx dx
|
|---|
| 75 | or ax, ax
|
|---|
| 76 | jz TTTTS_Overflow
|
|---|
| 77 | cmp ax, 23295
|
|---|
| 78 | ja TTTTS_Overflow
|
|---|
| 79 | mov dl, 91
|
|---|
| 80 | div dl ; Tics : 91
|
|---|
| 81 | mov dh, al
|
|---|
| 82 | movzx ax, ah
|
|---|
| 83 | mov dl, 18
|
|---|
| 84 | div dl ; Remainder : 18
|
|---|
| 85 | xor ah, ah ; We dont need that remainder
|
|---|
| 86 | xchg dh, al
|
|---|
| 87 | mov bl, 5
|
|---|
| 88 | mul bl ; Result * 5
|
|---|
| 89 | movzx dx, dh
|
|---|
| 90 | add ax, dx ; Add both together...
|
|---|
| 91 | ret
|
|---|
| 92 | TTTTS_Overflow:
|
|---|
| 93 | xor ax, ax
|
|---|
| 94 | ret
|
|---|
| 95 | TIMER_TranslateTicToSec EndP
|
|---|