mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-22 14:33:51 +00:00
62 lines
3.6 KiB
C
62 lines
3.6 KiB
C
|
|
#include <string.h>
|
|
|
|
typedef unsigned char byte;
|
|
typedef signed char sbyte;
|
|
typedef unsigned short word;
|
|
|
|
__sfr __at (0x2) bitshift_offset;
|
|
volatile __sfr __at (0x3) bitshift_read;
|
|
__sfr __at (0x4) bitshift_value;
|
|
__sfr __at (0x6) watchdog_strobe;
|
|
|
|
byte __at (0x2400) vidmem[224][32]; // 256x224x1 video memory
|
|
|
|
void main();
|
|
// start routine @ 0x0
|
|
// set stack pointer, enable interrupts
|
|
void start() {
|
|
__asm
|
|
LD SP,#0x2400
|
|
DI
|
|
__endasm;
|
|
main();
|
|
}
|
|
|
|
const byte bitmap1[] =
|
|
{9,56,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x01,0x00,0x00,0x00,0x00,0x80,0xfb,0xff,0xf0,0x01,0x00,0x00,0x00,0x00,0x40,0x04,0x80,0xf3,0x01,0x00,0x00,0x00,0x00,0xb8,0x00,0x00,0xfa,0x01,0x00,0x00,0x00,0x00,0x06,0xfe,0x03,0xfa,0x01,0x00,0x00,0x00,0x00,0x83,0xff,0x03,0xfd,0x01,0x80,0x00,0x00,0x00,0x81,0xcf,0x00,0xfc,0x00,0x80,0x01,0xc0,0x9f,0x01,0x00,0x00,0xfc,0x00,0x80,0x01,0x30,0xe0,0x00,0x00,0x00,0xf8,0x00,0xc0,0x01,0x0c,0x84,0x41,0x00,0x00,0xf8,0x01,0xc0,0x07,0x04,0xf8,0xc2,0x00,0x00,0xf8,0x03,0xc0,0x07,0x06,0x00,0x43,0x00,0x00,0xf2,0x03,0xc0,0x07,0x02,0x80,0x00,0xf8,0x0f,0xe4,0x03,0xe0,0xff,0x04,0xf8,0x00,0xfe,0x1f,0xe8,0x07,0xe0,0x03,0x07,0x80,0x00,0xbe,0x0f,0xec,0x07,0xe0,0x01,0x06,0x80,0x00,0x3c,0x00,0x92,0x07,0xe0,0x00,0x0a,0xff,0x00,0x00,0x00,0x00,0x07,0xe0,0x00,0x24,0x08,0x01,0x00,0x00,0x00,0x07,0x60,0x00,0xc6,0x88,0x01,0x00,0x00,0x00,0x07,0x60,0x00,0x02,0x7e,0x03,0x00,0x00,0x80,0x07,0x60,0x00,0xfe,0x27,0x02,0x00,0x00,0x80,0x07,0x60,0x00,0xc1,0x43,0x02,0x00,0x00,0xc0,0x07,0x70,0xc0,0xc0,0x43,0x04,0x00,0x00,0xc0,0x03,0x70,0x40,0xc1,0x67,0x08,0x00,0x00,0xe0,0x03,0x70,0x00,0xe1,0x7f,0x10,0x00,0x1c,0xf0,0x01,0xf0,0x00,0xfa,0xff,0xa0,0x01,0x7f,0xfe,0x00,0xf0,0x00,0xe2,0x1f,0xc1,0x60,0xfe,0x7f,0x00,0xe0,0x81,0x87,0x0f,0x82,0x81,0xfe,0x3f,0x00,0xe0,0x83,0xc8,0x0f,0x02,0xa5,0xfe,0x0f,0x00,0xe0,0x7f,0xf9,0xbf,0x13,0x9f,0xfd,0x00,0x00,0xe0,0x03,0x81,0xff,0x1f,0x61,0x00,0x00,0x06,0xe0,0x03,0x02,0xfe,0x8f,0x01,0x00,0x6c,0x04,0x80,0x01,0x02,0xfc,0x83,0x01,0x00,0xc0,0x04,0x80,0x01,0x03,0x0e,0x81,0x00,0x04,0x80,0x03,0x80,0x01,0xfe,0x01,0x62,0x50,0x08,0x00,0x00,0x80,0x01,0x48,0x00,0x1c,0x80,0x08,0x00,0x00,0x80,0x03,0x50,0x00,0x1c,0x00,0x07,0x00,0x00,0x80,0x03,0x50,0x00,0x34,0x00,0x00,0x00,0x00,0x80,0x03,0x50,0x00,0x24,0x00,0x00,0x00,0x00,0x80,0x07,0x90,0x00,0x3a,0x00,0x00,0x00,0x00,0x80,0x0f,0x98,0x00,0x10,0x00,0x00,0x00,0x00,0x80,0x3f,0x0c,0x07,0x10,0x00,0x00,0x00,0x00,0x00,0xc1,0x03,0x18,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
|
|
;
|
|
|
|
void draw_shifted_sprite(const byte* src, byte x, byte y) {
|
|
byte i,j;
|
|
byte* dest = &vidmem[x][y>>3];
|
|
byte w = *src++;
|
|
byte h = *src++;
|
|
bitshift_offset = y & 7;
|
|
for (j=0; j<h; j++) {
|
|
bitshift_value = 0;
|
|
for (i=0; i<w; i++) {
|
|
bitshift_value = *src++;
|
|
*dest++ = bitshift_read;
|
|
}
|
|
bitshift_value = 0;
|
|
*dest++ = bitshift_read;
|
|
dest += 31-w;
|
|
}
|
|
}
|
|
|
|
void clrscr() {
|
|
memset(vidmem, 0, sizeof(vidmem));
|
|
}
|
|
|
|
void main() {
|
|
byte x;
|
|
// TODO: clear memory
|
|
clrscr();
|
|
for (x=0; x<255; x++) {
|
|
draw_shifted_sprite(bitmap1, x, x);
|
|
watchdog_strobe++;
|
|
}
|
|
main();
|
|
}
|