1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-17 11:05:58 +00:00
8bitworkshop/presets/mw8080bw/shifter.c
2017-05-05 09:29:07 -04:00

63 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,/*{w:72,h:56,bpp:1,xform:"rotate(-90deg)"}*/
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,0xDC,0x00,0x80,0x01,0xC0,0x9F,0x01,0x00,0x00,0xDC,0x00,0x80,0x01,0x30,0xE0,0x00,0x00,0x00,0xD8,0x00,0xC0,0x01,0x0C,0x84,0x41,0x00,0x00,0x98,0x01,0xC0,0x07,0x04,0xF8,0xC2,0x00,0x00,0x38,0x03,0xC0,0x07,0x06,0x00,0x43,0x00,0x00,0x72,0x02,0xC0,0x07,0x02,0x80,0x00,0xF8,0x0F,0xE4,0x02,0xE0,0xFF,0x04,0xF8,0x00,0xFE,0x1F,0xE8,0x04,0xE0,0x03,0x07,0x80,0x00,0xBE,0x0F,0xEC,0x05,0xE0,0x01,0x06,0x80,0x00,0x3C,0x00,0x92,0x05,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();
}