Receive byte across link cable
From GbdevWiki
Revision as of 06:53, 9 October 2014 by A cat (Talk | contribs) (Created page with '<pre> #include <gb/gb.h> #include <stdio.h> void main(void){ while(1){//the program is in a while loop so it keeps checking again and again for a byte printf("Receivi…')
#include <gb/gb.h>
#include <stdio.h>
void main(void){
while(1){//the program is in a while loop so it keeps checking again and again for a byte
printf("Receiving...");
/*look for a byte being sent through the link cable
if there is a byte set _io_in to the value of the byte
*/
receive_byte();
/* Wait for IO completion... */
while(_io_status == IO_RECEIVING){;}
if(_io_status == IO_IDLE){
printf("Received:\n%d\n", (int)_io_in);
}
else{
printf("error: %d\n", _io_status);
}
}
}