Misc fixes and updates.

Minor code cleanups.
Fix parenthesis imbalance in keyboard led test.
The printf() call is only used in 32bit mode - make this explicit to
    the compiler - it improves the code generation.
Clear the screen after initializing the vga option rom.
diff --git a/TODO b/TODO
index d7acfe5..5ad0428 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,5 @@
+Clean up timer code.  Don't use PORT_DIAG as delay mechanism.
+
 Disable a20 on jump to 16bit mode.
 
 Do a pci scan for ide controllers - don't just assume ISA ports are
@@ -34,13 +36,24 @@
 The __call16 code does a long jump to the interrupt trampolines - this
 is unnecessary.
 
-Fix makefiles so that they rebuild the required files automatically.
-
 Cleanup setting of ES on GET/SET_BDA
 
+Audit code for 16bit protected mode accesses.
+
+Support 1ab1 from 16bit protected mode.
+
+Verify option roms wont stomp on seabios stack and bss.
+
 Possibly implement 32bit pcibios support.
 
 Allow one to select adding 32 bit code to 0xf000 or in a separate
 location.
 
+See if it is possible to handle interrupts while in 32bit mode.
+
 Look at integrating the lgpl vgabios into tree.
+
+Look at usb booting specs.  Look at possibly supporting usb
+keyboard/mice.
+
+Add a graphical boot splash screen?
diff --git a/src/bregs.h b/src/bregs.h
index f7060e8..2c36239 100644
--- a/src/bregs.h
+++ b/src/bregs.h
@@ -7,6 +7,8 @@
 #ifndef __BREGS_H
 #define __BREGS_H
 
+#include "types.h" // u16
+
 
 /****************************************************************
  * Registers saved/restored in romlayout.S
diff --git a/src/cdrom.c b/src/cdrom.c
index 57c2ce4..0ccc2c4 100644
--- a/src/cdrom.c
+++ b/src/cdrom.c
@@ -435,11 +435,7 @@
 
     int ret = atapi_is_ready(device);
     if (ret)
-        dprintf(1, "ata_is_ready returned %d\n", ret);
-
-    // if not found
-    if (device >= CONFIG_MAX_ATA_DEVICES)
-        return 2;
+        dprintf(1, "atapi_is_ready returned %d\n", ret);
 
     // Read the Boot Record Volume Descriptor
     u8 buffer[2048];
diff --git a/src/kbd.c b/src/kbd.c
index 5dbb257..d63c8c3 100644
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -374,7 +374,7 @@
 {
     u8 shift_flags = GET_BDA(kbd_flag0);
     u8 led_flags = GET_BDA(kbd_led);
-    if (((shift_flags >> 4) & 0x07) ^ ((led_flags & 0x07) == 0))
+    if ((((shift_flags >> 4) & 0x07) ^ (led_flags & 0x07)) == 0)
         return;
 
     outb(0xed, PORT_PS2_DATA);
diff --git a/src/mouse.c b/src/mouse.c
index 08beafe..cb471db 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -384,7 +384,8 @@
     u8 mouse_flags_1 = GET_EBDA(mouse_flag1);
     u8 mouse_flags_2 = GET_EBDA(mouse_flag2);
 
-    if ((mouse_flags_2 & 0x80) != 0x80)
+    if (! (mouse_flags_2 & 0x80))
+        // far call handler not installed
         return;
 
     u8 package_count = mouse_flags_2 & 0x07;
@@ -402,9 +403,6 @@
     u16 X      = GET_EBDA(mouse_data[1]);
     u16 Y      = GET_EBDA(mouse_data[2]);
     SET_EBDA(mouse_flag1, 0);
-    // check if far call handler installed
-    if (! (mouse_flags_2 & 0x80))
-        return;
 
     u32 func = GET_EBDA(far_call_pointer);
     asm volatile(
diff --git a/src/output.c b/src/output.c
index 8b58485..d9671ac 100644
--- a/src/output.c
+++ b/src/output.c
@@ -1,4 +1,4 @@
-// Raw screen writing code.
+// Raw screen writing and debug output code.
 //
 // Copyright (C) 2008  Kevin O'Connor <kevin@koconnor.net>
 //
@@ -33,6 +33,7 @@
                 , oldparam, oldier, newparam, newier);
 }
 
+// Write a character to the serial port.
 static void
 debug_serial(char c)
 {
@@ -44,9 +45,13 @@
     outb(c, DEBUG_PORT);
 }
 
+// Show a character on the screen.
 static void
 screenc(u8 c)
 {
+    if (MODE16)
+        // printf is only used in 32bit code.
+        return;
     struct bregs br;
     memset(&br, 0, sizeof(br));
     br.ah = 0x0e;
@@ -54,7 +59,7 @@
     call16_int(0x10, &br);
 }
 
-// Write a charcter to the framebuffer.
+// Output a character.
 static void
 putc(u16 action, char c)
 {
@@ -78,7 +83,7 @@
     }
 }
 
-// Write a string to the framebuffer.
+// Ouptut a string.
 static void
 puts(u16 action, const char *s)
 {
@@ -86,7 +91,7 @@
         putc(action, *s);
 }
 
-// Write a string to the framebuffer.
+// Output a string that is in the CS segment.
 static void
 puts_cs(u16 action, const char *s)
 {
@@ -98,7 +103,7 @@
     }
 }
 
-// Write an unsigned integer to the screen.
+// Output an unsigned integer.
 static void
 putuint(u16 action, u32 val)
 {
@@ -115,7 +120,7 @@
     puts(action, d);
 }
 
-// Write a single digit hex character to the screen.
+// Output a single digit hex character.
 static inline void
 putsinglehex(u16 action, u32 val)
 {
@@ -126,7 +131,7 @@
     putc(action, val);
 }
 
-// Write an integer in hexadecimal to the screen.
+// Output an integer in hexadecimal.
 static void
 puthex(u16 action, u32 val)
 {
diff --git a/src/pcibios.c b/src/pcibios.c
index 05d7856..545ad8d 100644
--- a/src/pcibios.c
+++ b/src/pcibios.c
@@ -23,6 +23,7 @@
     regs->ax = 0x0001;
     regs->bx = 0x0210;
     regs->cx = 0;
+    // XXX - regs->cl should equal max bus number.
     regs->edx = 0x20494350; // "PCI "
     // XXX - bochs bios code sets edi to point to 32bit code - but no
     // reference to this in spec.
diff --git a/src/pic.c b/src/pic.c
index 129fc34..f895798 100644
--- a/src/pic.c
+++ b/src/pic.c
@@ -16,7 +16,7 @@
     // Send ICW1 (select OCW1 + will send ICW4)
     outb(0x11, PORT_PIC1_CMD);
     outb(0x11, PORT_PIC2_CMD);
-    // Send ICW2 (base irqs: 0x08-0x0f for irq0-7, 0x70-0x78 for irq8-15)
+    // Send ICW2 (base irqs: 0x08-0x0f for irq0-7, 0x70-0x77 for irq8-15)
     outb(0x08, PORT_PIC1_DATA);
     outb(0x70, PORT_PIC2_DATA);
     // Send ICW3 (cascaded pic ids)
diff --git a/src/post.c b/src/post.c
index 0a64f17..9e0d5ff 100644
--- a/src/post.c
+++ b/src/post.c
@@ -273,6 +273,20 @@
     }
 }
 
+// Call into vga code to turn on console.
+static void
+vga_setup()
+{
+    dprintf(1, "Scan for VGA option rom\n");
+    rom_scan(0xc0000, 0xc7800);
+
+    dprintf(1, "Turning on vga console\n");
+    struct bregs br;
+    memset(&br, 0, sizeof(br));
+    br.ax = 0x0003;
+    call16_int(0x10, &br);
+}
+
 // Main setup code.
 static void
 post()
@@ -292,8 +306,7 @@
 
     ram_probe();
 
-    dprintf(1, "Scan for VGA option rom\n");
-    rom_scan(0xc0000, 0xc7800);
+    vga_setup();
 
     printf("BIOS - begin\n\n");