File: delay.c

package info (click to toggle)
invaders 1.0.0-8
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 176 kB
  • ctags: 192
  • sloc: ansic: 678; sh: 70; makefile: 39; asm: 28
file content (39 lines) | stat: -rw-r--r-- 568 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "delay.h"

#include "io.h"

#include "video.h"
#include "keyboard.h"

static void delay_wait_short (uint32 x)
{
  uint16 val;
  uint8 lo, hi;

  val=x+20000;

  outb(32+16,0x43);
  outb(val&255,0x40);
  outb(val>>8,0x40);
  
  do outb(0xe2,0x43); while (inb(0x40)&64);

  for (;;) {
    outb(0,0x43);
    lo=inb(0x40);
    hi=inb(0x40);
    val=((uint16)lo) | (((uint16)hi) << 8);
    if (val<20000) break;
    key_polling();
  };
};

void delay_wait (uint32 x)
{
  while (x>30000) {
    x-=30000;
    delay_wait_short(30000);
  };
  delay_wait_short(x);
};