昨日の補足

nesdev にある Standard Read for 2 Controllers and Famicom のコードが最適でそのコードは rol 命令を利用している. ror; bcc とするにはループの外で <$6e,x に #$80 を store する必要がある. sty zp,x という addressing は実在するため 1 byte 無駄なく実装できた.

	org $C5F7
	tax
	ldy	#$81
	sty	$4016
	dey
	sty	$4016
	sty	<$6e,x
lc604:
	lda	$4016,x
	and	#%11
	cmp	#1
	ror	<$6e,x
	bcc	lc604
	rts
	fill	$C60F