#include <gb.h>
#include <stdio.h>

void main()
{
puts("GAMEBOY PIC PORT");
puts("8 bit Bi-Direct.");
puts("plus N64 Joystick");
puts("by Ken Kaarvik");

  while(1) {
 _io_out=2;
   send_byte();
   while(_io_status==IO_SENDING);
   receive_byte();
   while(_io_status==IO_RECEIVING);
   gotoxy(0,5);
    printf("x-axis  %d   ",_io_in);
    delay(10);
    
 _io_out=3;
   send_byte();
   while(_io_status==IO_SENDING);
   receive_byte();
   while(_io_status==IO_RECEIVING);
   gotoxy(0,7);
    printf("y-axis  %d   ",_io_in);
    delay(10);
    
 _io_out=0;
   send_byte();
   while(_io_status==IO_SENDING);
   receive_byte();
   while(_io_status==IO_RECEIVING);
   gotoxy(0,9);
    printf("byte 0 $%x    ",_io_in);
    delay(10);

  _io_out=1;
   send_byte();
   while(_io_status==IO_SENDING);
   receive_byte();
   while(_io_status==IO_RECEIVING);
   gotoxy(0,11);
    printf("byte 1 $%x    ",_io_in);
    delay(10);
     
     _io_out=0xF0;      /*B7-B4 low    B4-B0 float high*/
     send_byte();
     while(_io_status==IO_SENDING);
     receive_byte();
     while(_io_status==IO_RECEIVING);
     gotoxy(0,13);
      printf("Write  $%x    ",_io_out);
      gotoxy(0,15);
      printf("Read   $%x    ",_io_in);
   }
}
