Future Driver

Virtua Roaching

About Virtua Roaching

I made a peripheral of Megadrive and it is a photodetector.
Virtua Roaching is a software for the photodetector.
The photodetector connect to controller port 2.
Play with roaches all you want by Virtua Roaching.

How to play Virtua Roaching


光を当てるとゴキブリが逃げる
Darken up the photodetector when roaches flock to the screen.

暗くするとゴキブリが集る
Light up the photodetector when roaches away from the screen.

Total 32 roaches under the TV.
The roaches away from the screen or flock to the screen in response to brightness.
You can only enjoy the response.

Circuit detail

This controller contain three main devices. LDR, op-amp and A/D converter.
I used a breadboard for simplicity.


How to control the photodetector

ADC0804 have 8bits resolution but this circuit is using higher 4bits only.
Sample code is as follows.

/* 初期化 */
void initAD(){
	/* ポート2の入出力方向を設定する */
	*(uchar *)0xA1000B = 0xE0;	/* photodetector is connected to port 2 */
}
/* ADコンバータアクセス時のウェイト */
void waitAD{
	asm("nop");
}
/* ADデータの読み取り */
uint readAD(){
	register d;

	/* A/D変換を開始する */
	*(uchar *)0xA10005 = 0x20;	/* write enable = start the A/D convertion */
	waitAD;
	*(uchar *)0xA10005 = 0x60;	/* write disable */
	waitAD;

	/* A/D変換が完了するまで待つ */
	do{
		waitAD;
	}while(*(uchar *)0xA10005 & 0x10);	/* if complete, this bit is zero. */

	/* 変換結果を読む */
	*(uchar *)0xA10005 = 0x40;	/* read enable */
	waitAD;
	d = *(uchar *)0xA10005 & 0x0F;	/* read value */
	*(uchar *)0xA10005 = 0x60;	/* read disable */
	waitAD;

	return d;	/* d = 0 to 15 */
}


inserted by FC2 system