Only print LED state if it has changed

Tue, 28 Dec 2010 21:47:43 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Tue, 28 Dec 2010 21:47:43 +0000
changeset 72
c66c98c7a768
parent 71
22452603e214
child 73
05ef5f3c5246

Only print LED state if it has changed

src/memory.c file | annotate | diff | revisions
     1.1 --- a/src/memory.c	Tue Dec 28 19:55:13 2010 +0000
     1.2 +++ b/src/memory.c	Tue Dec 28 21:47:43 2010 +0000
     1.3 @@ -286,12 +286,14 @@
     1.4  				// TODO: handle the ctrl bits properly
     1.5  				// TODO: &0x8000 --> dismiss 60hz intr
     1.6  				state.dma_reading = (data & 0x4000);
     1.7 -				state.leds = (~data & 0xF00) >> 8;
     1.8 -				printf("LEDs: %s %s %s %s\n",
     1.9 -						(state.leds & 8) ? "R" : "-",
    1.10 -						(state.leds & 4) ? "G" : "-",
    1.11 -						(state.leds & 2) ? "Y" : "-",
    1.12 -						(state.leds & 1) ? "R" : "-");
    1.13 +				if (state.leds != ((~data & 0xF00) >> 8)) {
    1.14 +					state.leds = (~data & 0xF00) >> 8;
    1.15 +					printf("LEDs: %s %s %s %s\n",
    1.16 +							(state.leds & 8) ? "R" : "-",
    1.17 +							(state.leds & 4) ? "G" : "-",
    1.18 +							(state.leds & 2) ? "Y" : "-",
    1.19 +							(state.leds & 1) ? "R" : "-");
    1.20 +				}
    1.21  				handled = true;
    1.22  				break;
    1.23  			case 0x0B0000:				// TM/DIALWR