2023-10-25 07:50:14 +00:00
|
|
|
/*
|
|
|
|
* mii_video.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 2023 Michel Pollet <buserror@gmail.com>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2024-01-20 12:05:26 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
2023-10-25 07:50:14 +00:00
|
|
|
|
|
|
|
// TODO move VRAM stuff to somewhere else
|
|
|
|
#define MII_VIDEO_WIDTH (280 * 2)
|
|
|
|
#define MII_VIDEO_HEIGHT (192 * 2)
|
2024-01-20 12:05:26 +00:00
|
|
|
// in case padding is needed, these can be changed
|
2024-01-22 17:08:06 +00:00
|
|
|
|
|
|
|
#if 0 // Loads of padding to align to power of 2 sizes
|
|
|
|
#define MII_VRAM_WIDTH (1024 * 4)
|
|
|
|
#define MII_VRAM_HEIGHT 512
|
|
|
|
#else
|
2024-01-20 12:05:26 +00:00
|
|
|
#define MII_VRAM_WIDTH (MII_VIDEO_WIDTH * 4)
|
|
|
|
#define MII_VRAM_HEIGHT MII_VIDEO_HEIGHT
|
2024-01-22 17:08:06 +00:00
|
|
|
#endif
|
2023-10-25 07:50:14 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
MII_VIDEO_COLOR = 0,
|
|
|
|
MII_VIDEO_GREEN,
|
|
|
|
MII_VIDEO_AMBER,
|
2024-01-22 17:08:06 +00:00
|
|
|
MII_VIDEO_MODE_COUNT
|
2023-10-25 07:50:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mii_t;
|
|
|
|
|
|
|
|
typedef struct mii_video_t {
|
2024-01-20 12:05:26 +00:00
|
|
|
void * state; // protothread state in mii_video.c
|
|
|
|
uint8_t timer_id; // timer id for the video thread
|
|
|
|
uint8_t line; // current line
|
|
|
|
uint32_t pixels[MII_VRAM_WIDTH * MII_VRAM_HEIGHT];
|
|
|
|
uint32_t frame_count; // incremented every frame
|
|
|
|
uint32_t frame_drawn;
|
|
|
|
uint8_t color_mode; // color, green, amber
|
2023-10-25 07:50:14 +00:00
|
|
|
} mii_video_t;
|
|
|
|
|
|
|
|
bool
|
|
|
|
mii_access_video(
|
|
|
|
struct mii_t *mii,
|
|
|
|
uint16_t addr,
|
|
|
|
uint8_t * byte,
|
|
|
|
bool write);
|
|
|
|
void
|
2024-01-20 12:05:26 +00:00
|
|
|
mii_video_init(
|
|
|
|
mii_t *mii);
|
2023-10-25 07:50:14 +00:00
|
|
|
|
|
|
|
|