0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

C言語で MSX ゲームプログラミング初級 Part02

0
Posted at

main.c
#include <stdint.h>
#include <stdio.h>

#include "bios.h"

void main() {
  BIOS_CLS();

  // カタカナは半角カタカナで入力し、ファイルをShift-JISで保存する
  printf("マウガ セメコンデ キマシタ\n");
  printf("1.タタカウ\n");
  printf("2.ニゲル\n");

  while (1) {
    uint8_t key = *(uint8_t*)(NEWKEY + 0);  // 0行目のキーコードを取得

    if (key == 253) {
      // 1キーが押された場合(テンキーの1ではない)
      printf("マオウニショウリシ ヘイワガ オトズレマシタ\n");
      printf("GAME CLER!\n");
      break;
    }

    if (key == 251) {
      // 2キーが押された場合(テンキーの2ではない)
      printf("マオウガ セカイヲ ホロボシマシタ\n");
      printf("GAME OVER\n");
      break;
    }
  }
}
bios.h
/*
現在押下されているキーマトリクスの値が格納されているワークエリアのアドレス
0行:0xFBE5~10行:0xFBF5
参考URL: キースキャン
https://ngs.no.coocan.jp/doc/wiki.cgi/TechHan?page=3%BE%CF+%A5%AD%A1%BC%A5%DC%A1%BC%A5%C9%A1%A6%A5%A4%A5%F3%A5%BF%A1%BC%A5%D5%A5%A7%A5%A4%A5%B9
*/
#define	NEWKEY 0xFBE5

void BIOS_CLS();
bios.c
// 画面クリア
void BIOS_CLS()
{
#asm
XOR		A		; // フラグレジスタのゼロフラグを1にする
CALL	00C3H
#endasm
}
0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?