forked from arti/vt1200
75 lines
1.6 KiB
C
75 lines
1.6 KiB
C
/* main.c -- Bad Apple payload, one-frame mode and (later) playback. */
|
|
#include "movie.h"
|
|
|
|
#define MOVIE_BASE 0x00080000
|
|
#define MOVIE_MAX 0x00308000
|
|
#define VRAM_BASE 0x04000000
|
|
#define ROW_BITS 2048
|
|
#define MARK 0x01810000
|
|
|
|
extern void fill_run_();
|
|
extern void fill_init_();
|
|
|
|
unsigned int fill_daddr;
|
|
unsigned int fill_dydx;
|
|
unsigned int fill_color;
|
|
|
|
void fill_rect(x, y, w, h, color)
|
|
int x;
|
|
int y;
|
|
int w;
|
|
int h;
|
|
int color;
|
|
{
|
|
if (w <= 0 || h <= 0) {
|
|
return;
|
|
}
|
|
fill_daddr = VRAM_BASE + (unsigned int)y * ROW_BITS + (unsigned int)x;
|
|
fill_dydx = ((unsigned int)h << 16) | (unsigned int)w;
|
|
/* The decoder's colour is the canvas value: 1 = black, 0 = white. */
|
|
fill_color = color ? 0x0000 : 0xFFFF;
|
|
fill_run_();
|
|
}
|
|
|
|
static void paint(x, y, w, h, color, ctx)
|
|
int x;
|
|
int y;
|
|
int w;
|
|
int h;
|
|
int color;
|
|
void *ctx;
|
|
{
|
|
fill_rect(x, y, w, h, color);
|
|
}
|
|
|
|
int main()
|
|
{
|
|
struct movie_header header;
|
|
int rc;
|
|
|
|
fill_init_();
|
|
|
|
/* Start from white; the OS left its own screen behind. */
|
|
fill_rect(0, 0, 1280, 1024, 0);
|
|
|
|
rc = movie_open((unsigned char *)MOVIE_BASE, MOVIE_MAX, &header);
|
|
if (rc != 0) {
|
|
*(unsigned int *)MARK = 0xBAD00001;
|
|
for (;;) {
|
|
}
|
|
}
|
|
|
|
rc = movie_decode_frame((unsigned char *)MOVIE_BASE, MOVIE_MAX, 0,
|
|
&header, paint, 0);
|
|
if (rc != 0) {
|
|
*(unsigned int *)MARK = 0xBAD00002;
|
|
for (;;) {
|
|
}
|
|
}
|
|
|
|
*(unsigned int *)MARK = 0; /* FRAME */
|
|
*(unsigned int *)(MARK + 0x10 * 8) = 1; /* STATUS: painted */
|
|
for (;;) {
|
|
}
|
|
}
|