use LOG functions for kbc debugging, make KBC debugging optional

Thu, 03 Mar 2011 08:18:57 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Thu, 03 Mar 2011 08:18:57 +0000
changeset 99
2d06b823a015
parent 98
d1af20db5f02
child 100
d6f699f89303

use LOG functions for kbc debugging, make KBC debugging optional

src/keyboard.c file | annotate | diff | revisions
     1.1 --- a/src/keyboard.c	Thu Mar 03 08:15:09 2011 +0000
     1.2 +++ b/src/keyboard.c	Thu Mar 03 08:18:57 2011 +0000
     1.3 @@ -1,7 +1,11 @@
     1.4  #include <stdbool.h>
     1.5  #include "SDL.h"
     1.6 +#include "utils.h"
     1.7  #include "keyboard.h"
     1.8  
     1.9 +// Enable/disable KBC debugging
    1.10 +#define kbc_debug false
    1.11 +
    1.12  /**
    1.13   * Key map -- a mapping from SDLK_xxx constants to scancodes and vice versa.
    1.14   */
    1.15 @@ -222,7 +226,7 @@
    1.16  
    1.17  		for (int i=0; i<(sizeof(ks->keystate)/sizeof(ks->keystate[0])); i++) {
    1.18  			if (ks->keystate[i]) {
    1.19 -				printf("\tKBC KEY DOWN: %d\n", i);
    1.20 +				LOG_IF(kbc_debug, "KBC KEY DOWN: %d\n", i);
    1.21  				ks->buffer[ks->writep] = i;
    1.22  				last_writep = ks->writep;
    1.23  				ks->writep = (ks->writep + 1) % KEYBOARD_BUFFER_SIZE;
    1.24 @@ -234,7 +238,7 @@
    1.25  			ks->buffer[ks->writep - 1] |= 0x80;
    1.26  		}else{
    1.27  			// If no keys down, then send All Keys Up byte
    1.28 -			printf("\tKBC ALL KEYS UP\n");
    1.29 +			LOG_IFS(kbc_debug, "KBC ALL KEYS UP\n");
    1.30  			ks->buffer[ks->writep] = KEY_ALL_UP;
    1.31  			ks->writep = (ks->writep + 1) % KEYBOARD_BUFFER_SIZE;
    1.32  			if (ks->buflen < KEYBOARD_BUFFER_SIZE) ks->buflen++;
    1.33 @@ -280,14 +284,14 @@
    1.34  //			0 +								// SR5: Receiver Overrun
    1.35  //			0 +								// SR6: Parity Error
    1.36  		if (keyboard_get_irq(ks)) sr |= 0x80;	// SR7: IRQ status
    1.37 -		printf("\tKBC DBG: sr=%02X\n", sr);
    1.38 +		//LOG_IF(kbc_debug, "KBC DBG: sr=%02X\n", sr);
    1.39  		return sr;
    1.40  	} else {
    1.41  		// return data, pop off the fifo
    1.42  		uint8_t x = ks->buffer[ks->readp];
    1.43  		ks->readp = (ks->readp + 1) % KEYBOARD_BUFFER_SIZE;
    1.44  		if (ks->buflen > 0) ks->buflen--;
    1.45 -		//printf("\tKBC DBG: rxd=%02X\n", x);
    1.46 +		//LOG_IF(kbc_debug, "\tKBC DBG: rxd=%02X\n", x);
    1.47  		return x;
    1.48  	}
    1.49  }
    1.50 @@ -313,10 +317,11 @@
    1.51  		ks->rxie = (val & 0x80)==0x80;
    1.52  	} else {
    1.53  		// Write command to KBC -- TODO!
    1.54 -		printf("KBC TODO: write keyboard data 0x%02X\n", val);
    1.55  		if (val == KEY_CMD_RESET) {
    1.56 -			printf("\tKBC: KEYBOARD RESET!\n");
    1.57 +			LOG_IFS(kbc_debug, "KBC: KEYBOARD RESET!\n");
    1.58  			ks->readp = ks->writep = ks->buflen = 0;
    1.59 +		} else {
    1.60 +			LOG("KBC TODO: write keyboard data 0x%02X\n", val);
    1.61  		}
    1.62  	}
    1.63  }