Listing 5

ch = (unsigned char)((y * colx + x) >> 15);    /*  find current page */
if (ch != old_page)                /*  only change page if different */
  {
    dx = ati_extreg;      /*  location of ATI card external register */
    asm("     cli     ");          /*  disable interrupts */
    asm("     mov     al,0b2h");   /*  page select */
  asm(dx,"    out     dx,al");      /*  ATI extended register */
    asm("     inc     dl");
    asm("     in      al,dx");
    asm("     mov     ah,al");
    asm("     and     ah,0e1h");    /*  page mask */
  asm(ch,"    or      ah,ch");      /*  ch = memory page desired */
    asm("     mov     al,0b2h");    /*  page select */
    asm("     dec     dl");
    asm("     out     dx, ax");
    asm("     sti     ");           /*  enable interrupts */
    old_page = ch;
  }
addr = 655360 + ((y * colx + x) % 65536);
poke(addr, color);          /*  write direct to real video memory */