Skip to content

Instantly share code, notes, and snippets.

@Themaister
Created May 2, 2012 19:43
Show Gist options
  • Save Themaister/2579672 to your computer and use it in GitHub Desktop.
Save Themaister/2579672 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <system.h>
#include <io.h>
#include <unistd.h>
#define WR_REG(reg, val) IOWR(SNES_##reg##_BASE, 0, val)
#define RD_REG(reg) IORD(SNES_##reg##_BASE, 0)
int main(void)
{
for (;;)
{
WR_REG(CLK, 1);
WR_REG(LATCH, 0);
usleep(12);
WR_REG(LATCH, 1);
usleep(12);
WR_REG(LATCH, 0);
unsigned val = 0;
unsigned i;
for (i = 0; i < 12; i++)
{
usleep(6);
val >>= 1;
val |= (RD_REG(DATA) & 1) << 11;
WR_REG(CLK, 0);
usleep(6);
WR_REG(CLK, 1);
}
val = (~val) & ((1 << 12) - 1);
IOWR(LEDR_BASE, 0, val);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment