VOOZH about

URL: https://qiita.com/Stosstruppe/items/d211251cb439524cc856

⇱ MSX キーボードイベント #MSX - Qiita


👁 Image
1

Go to list of users who liked

0

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 5 years have passed since last update.

@Stosstruppe

MSX キーボードイベント

1
Posted at
kbevt.c
/*
z80dk kbevt.c キーボードイベント
zcc +msx -lndos -create-app kbevt.c

WebMSXにa.casをドロップ
bload"cas:",r
*/

# include <stdio.h>

int snsmat(int line)
{
# asm
	ld	a, l
	call	$0141		; SNSMAT
	ld	l, a
	ld	h, 0
# endasm
}

char *mat[][] = {
	{ "7", "6", "5", "4", "3", "2", "1", "0" },
	{ "+", "[", "@", "\\", "^", "-", "9", "8" },
	{ "B", "A", "_", "/", ">", "<", "]", "*" },
	{ "J", "I", "H", "G", "F", "E", "D", "C" },
	{ "R", "Q", "P", "O", "N", "M", "L", "K" },
	{ "Z", "Y", "X", "W", "V", "U", "T", "S" },
	{ "F3", "F2", "F1", "KANA", "CPAS", "GRAPH", "CTRL", "SHIFT" },
	{ "RETURN", "SELECT", "BS", "STOP", "TAB", "ESC", "F5", "F4" },
	{ "RIGHT", "DOWN", "UP", "LEFT", "DEL", "INS", "CLS", "SPACE" },
	{ "4", "3", "2", "1", "0", "/", "+", "*" },
	{ ".", ",", "-", "9", "8", "7", "6", "5" }
};

void main()
{
	int bits[2][11];
	int iold = 0;
	int inew = 1;

	for (int i = 0; i <= 10; i++) {
		bits[iold][i] = snsmat(i);
	}

	for (;;) {
		for (int i = 0; i <= 10; i++) {
			bits[inew][i] = snsmat(i);
		}
		for (int i = 0; i <= 10; i++) {
			int bold = bits[iold][i];
			int bnew = bits[inew][i];
			int diff = bold ^ bnew;
			if (diff) {
				int bit = 0x80;
				for (int j = 0; j < 8; j++) {
					if (diff & bit) {
						printf("%s %s\n", mat[i][j],
							(bnew & bit) ? "Up" : "Down");
					}
					bit >>= 1;
				}
			}
		}
		iold = inew;
		inew = 1 - iold;
	}
}

ROMカートリッジ版

1

Go to list of users who liked

0
0

Go to list of comments

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1

Go to list of users who liked

0