ZX81の回想禄

PR

×

プロフィール

ZX81

ZX81

カレンダー

コメント新着

コメントに書き込みはありません。

キーワードサーチ

▼キーワード検索

2026.04.13
XML


結局3つから絞れなかったので
スクロールに合わせて渦巻を表示してみて決めたいと思います。

ーーーーーmain.cpp

#include <stdio.h>

#include <string.h>

#include <input.h>      // in_Wait

#include "key.h"

#include "map.h"

#include "whirl.h"

void main()

{

    unsigned char key;

unsigned char *pos;

    map_init();

    map_draw();

    while (1)

    {

        key = key_pressed();

        if (key == 0)

        {

            continue;

        }

        if (key & KBIT_ENT)

        {

            break;

        }

if (key & KBIT_UP)

{

            map_scroll(-1);

}

else if (key & KBIT_DN)

{

            map_scroll(1);

}

        map_draw();

        whirl_draw(render_pos);

        if (key & KBIT_SPC)

        {

            in_Wait(100);

        }

    }

}

ーーーー whirl .h

/*

 *      ZX81 Whirl Handling Module header

 */

#ifndef _ZX81_WHIRL_H

#define _ZX81_WHIRL_H

extern int render_pos;

// Map functions

void whirl_init(void);

void whirl_draw(int render_pos);

#endif  // _ZX81_WHIRL_H

ーーーーー whirl .cpp
/*
 *      ZX81 Whirl Handling Module program
 */
#include <stdio.h>
#include <string.h>
#include "map.h"
#include "whirl.h"
unsigned char whirl_chr[][50] = {
{0x87,0x03,0x03,0x86,0x00,
 0x05,0x06,0x03,0x04,0x05,
 0x86,0x02,0x01,0x05,0x05,
 0x00,0x03,0x03,0x87,0x01,
 0x02,0x03,0x03,0x01,0x00,
 0x00,0x83,0x83,0x83,0x00,
 0x06,0x87,0x83,0x04,0x00,
 0x05,0x05,0x83,0x02,0x04,
 0x05,0x86,0x83,0x01,0x05,
 0x02,0x83,0x83,0x06,0x00},
{0x87,0x01,0x00,0x86,0x00,
 0x01,0x06,0x02,0x04,0x01,
 0x00,0x04,0x00,0x04,0x00,
 0x86,0x02,0x02,0x87,0x01,
 0x00,0x01,0x00,0x01,0x00,
 0x00,0x83,0x83,0x04,0x00,
 0x02,0x87,0x83,0x02,0x00,
 0x05,0x01,0x00,0x01,0x05,
 0x01,0x86,0x83,0x01,0x01,
 0x02,0x83,0x83,0x06,0x00},
{0x87,0x03,0x01,0x00,0x00,
 0x05,0x00,0x03,0x04,0x04,
 0x05,0x05,0x00,0x01,0x05,
 0x00,0x02,0x01,0x87,0x01,
 0x00,0x00,0x03,0x01,0x00,
 0x00,0x00,0x83,0x04,0x00,
 0x00,0x87,0x04,0x02,0x04,
 0x04,0x05,0x00,0x04,0x05,
 0x05,0x00,0x83,0x01,0x00,
 0x02,0x83,0x00,0x00,0x00}
/*
{0x87,0x01,0x02,0x86,0x00},
{0x01,0x06,0x01,0x04,0x05},
{0x04,0x04,0x00,0x04,0x00},
{0x86,0x00,0x03,0x87,0x01},
{0x00,0x03,0x00,0x01,0x00},
{0x00,0x83,0x00,0x04,0x00},
{0x06,0x00,0x83,0x02,0x04},
{0x01,0x01,0x00,0x01,0x00},
{0x04,0x86,0x04,0x01,0x05},
{0x02,0x04,0x87,0x06,0x00},
*/
};
#define WHIRL_MAX   3
struct {
    int y;
    int x;
} whirl_tbl[WHIRL_MAX]  =
{
 { 1,11},
 { 4,13},
 { 7,15}
};
// screen address
#define D_DX            33      // 32+1(CR)
#define D_DY            24
// ----------------------------------------------------------
// 初期化
// ----------------------------------------------------------
void whirl_init(void)
{
}
// ----------------------------------------------------------
// VRAM へ描画
//   start_y を先頭として、論理 0..RENDER_DY-1 を順に出力
// ----------------------------------------------------------
void whirl_draw(int render_pos)
{
    int i, wy, y, dy;
    unsigned char *chrp;
    unsigned char *pos;
    for (i = 0; i < WHIRL_MAX; i++)
    {
        wy = whirl_tbl[i].y * 2;
        dy = wy - ((render_pos+1) / 2);
        if ((dy >= -4) && (dy <= 23))
        {
            if (dy < 0)
            {
                pos = getscrnaddr(0, whirl_tbl[i].x+4);
            }
            else
            {
                pos = getscrnaddr(dy, whirl_tbl[i].x+4);
            }
            if (render_pos & 1)
            {
                chrp = &whirl_chr[i][25];
            }
            else
            {
                chrp = &whirl_chr[i][0];
            }
            for (y = 0; y < 5; y++)
            {
                if ((dy <= 23) && (dy >= 0))
                {
                    memcpy(pos, chrp, 5);
                }
                if (dy >= 0)
                {
                    pos += D_DX;
                }
                chrp += 5;
                dy++;
            }
        }
    }
}

いつものように、下記でビルドします。
 zcc +zx81 map.c key.c whirl.c main.c -create-app​

表示結果については、次回確認していきます。









お気に入りの記事を「いいね!」で応援しよう

最終更新日  2026.04.13 19:48:24
コメント(0) | コメントを書く
[ZX81C言語でのプログラム開発] カテゴリの最新記事


【毎日開催】
15記事にいいね!で1ポイント
10秒滞在
いいね! -- / --
おめでとうございます!
ミッションを達成しました。
※「ポイントを獲得する」ボタンを押すと広告が表示されます。
x
X

© Rakuten Group, Inc.
X
Design a Mobile Website
スマートフォン版を閲覧 | PC版を閲覧
Share by: