|
|
|
@ -11,6 +11,7 @@ byte __at (0xc000) palette[16];
|
|
|
|
|
volatile byte __at (0xc804) input0;
|
|
|
|
|
volatile byte __at (0xc806) input1;
|
|
|
|
|
volatile byte __at (0xc80c) input2;
|
|
|
|
|
byte __at (0xc80c) sound_pia;
|
|
|
|
|
byte __at (0xc900) rom_select;
|
|
|
|
|
volatile byte __at (0xcb00) video_counter;
|
|
|
|
|
byte __at (0xcbff) watchdog0x39;
|
|
|
|
@ -82,38 +83,105 @@ __endasm;
|
|
|
|
|
main();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define LOCHAR 0x21
|
|
|
|
|
#define HICHAR 0x5e
|
|
|
|
|
#define LOCHAR 0x20
|
|
|
|
|
#define HICHAR 0x7e
|
|
|
|
|
|
|
|
|
|
const byte font8x8[HICHAR-LOCHAR+1][8] = {
|
|
|
|
|
{ 0x18,0x18,0x18,0x18,0x00,0x00,0x18,0x00 }, { 0x66,0x66,0x66,0x00,0x00,0x00,0x00,0x00 }, { 0x66,0x66,0xff,0x66,0xff,0x66,0x66,0x00 }, { 0x18,0x3e,0x60,0x3c,0x06,0x7c,0x18,0x00 }, { 0x62,0x66,0x0c,0x18,0x30,0x66,0x46,0x00 }, { 0x3c,0x66,0x3c,0x38,0x67,0x66,0x3f,0x00 }, { 0x06,0x0c,0x18,0x00,0x00,0x00,0x00,0x00 }, { 0x0c,0x18,0x30,0x30,0x30,0x18,0x0c,0x00 }, { 0x30,0x18,0x0c,0x0c,0x0c,0x18,0x30,0x00 }, { 0x00,0x66,0x3c,0xff,0x3c,0x66,0x00,0x00 }, { 0x00,0x18,0x18,0x7e,0x18,0x18,0x00,0x00 }, { 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x30 }, { 0x00,0x00,0x00,0x7e,0x00,0x00,0x00,0x00 }, { 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00 }, { 0x00,0x03,0x06,0x0c,0x18,0x30,0x60,0x00 }, { 0x3c,0x66,0x6e,0x76,0x66,0x66,0x3c,0x00 }, { 0x18,0x18,0x38,0x18,0x18,0x18,0x7e,0x00 }, { 0x3c,0x66,0x06,0x0c,0x30,0x60,0x7e,0x00 }, { 0x3c,0x66,0x06,0x1c,0x06,0x66,0x3c,0x00 }, { 0x06,0x0e,0x1e,0x66,0x7f,0x06,0x06,0x00 }, { 0x7e,0x60,0x7c,0x06,0x06,0x66,0x3c,0x00 }, { 0x3c,0x66,0x60,0x7c,0x66,0x66,0x3c,0x00 }, { 0x7e,0x66,0x0c,0x18,0x18,0x18,0x18,0x00 }, { 0x3c,0x66,0x66,0x3c,0x66,0x66,0x3c,0x00 }, { 0x3c,0x66,0x66,0x3e,0x06,0x66,0x3c,0x00 }, { 0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00 }, { 0x00,0x00,0x18,0x00,0x00,0x18,0x18,0x30 }, { 0x0e,0x18,0x30,0x60,0x30,0x18,0x0e,0x00 }, { 0x00,0x00,0x7e,0x00,0x7e,0x00,0x00,0x00 }, { 0x70,0x18,0x0c,0x06,0x0c,0x18,0x70,0x00 }, { 0x3c,0x66,0x06,0x0c,0x18,0x00,0x18,0x00 }, { 0x3c,0x66,0x6e,0x6e,0x60,0x62,0x3c,0x00 }, { 0x18,0x3c,0x66,0x7e,0x66,0x66,0x66,0x00 }, { 0x7c,0x66,0x66,0x7c,0x66,0x66,0x7c,0x00 }, { 0x3c,0x66,0x60,0x60,0x60,0x66,0x3c,0x00 }, { 0x78,0x6c,0x66,0x66,0x66,0x6c,0x78,0x00 }, { 0x7e,0x60,0x60,0x78,0x60,0x60,0x7e,0x00 }, { 0x7e,0x60,0x60,0x78,0x60,0x60,0x60,0x00 }, { 0x3c,0x66,0x60,0x6e,0x66,0x66,0x3c,0x00 }, { 0x66,0x66,0x66,0x7e,0x66,0x66,0x66,0x00 }, { 0x3c,0x18,0x18,0x18,0x18,0x18,0x3c,0x00 }, { 0x1e,0x0c,0x0c,0x0c,0x0c,0x6c,0x38,0x00 }, { 0x66,0x6c,0x78,0x70,0x78,0x6c,0x66,0x00 }, { 0x60,0x60,0x60,0x60,0x60,0x60,0x7e,0x00 }, { 0x63,0x77,0x7f,0x6b,0x63,0x63,0x63,0x00 }, { 0x66,0x76,0x7e,0x7e,0x6e,0x66,0x66,0x00 }, { 0x3c,0x66,0x66,0x66,0x66,0x66,0x3c,0x00 }, { 0x7c,0x66,0x66,0x7c,0x60,0x60,0x60,0x00 }, { 0x3c,0x66,0x66,0x66,0x66,0x3c,0x0e,0x00 }, { 0x7c,0x66,0x66,0x7c,0x78,0x6c,0x66,0x00 }, { 0x3c,0x66,0x60,0x3c,0x06,0x66,0x3c,0x00 }, { 0x7e,0x18,0x18,0x18,0x18,0x18,0x18,0x00 }, { 0x66,0x66,0x66,0x66,0x66,0x66,0x3c,0x00 }, { 0x66,0x66,0x66,0x66,0x66,0x3c,0x18,0x00 }, { 0x63,0x63,0x63,0x6b,0x7f,0x77,0x63,0x00 }, { 0x66,0x66,0x3c,0x18,0x3c,0x66,0x66,0x00 }, { 0x66,0x66,0x66,0x3c,0x18,0x18,0x18,0x00 }, { 0x7e,0x06,0x0c,0x18,0x30,0x60,0x7e,0x00 }, { 0x3c,0x30,0x30,0x30,0x30,0x30,0x3c,0x00 }, { 0x00,0x60,0x30,0x18,0x0c,0x06,0x03,0x00 }, { 0x3c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3c,0x00 }, { 0x00,0x18,0x3c,0x7e,0x18,0x18,0x18,0x18 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static byte font_table[HICHAR-LOCHAR+1][8*4];
|
|
|
|
|
|
|
|
|
|
void fill_char_table_entry(char ch) {
|
|
|
|
|
const byte* src = &font8x8[ch-LOCHAR][0];
|
|
|
|
|
byte* data = &font_table[ch-LOCHAR][0];
|
|
|
|
|
int i,j,pixels;
|
|
|
|
|
for (i=0; i<8; i++) {
|
|
|
|
|
byte b = *src++;
|
|
|
|
|
for (j=0; j<4; j++) {
|
|
|
|
|
pixels = 0;
|
|
|
|
|
if (b & 0x80) pixels |= 0xf0;
|
|
|
|
|
if (b & 0x40) pixels |= 0x0f;
|
|
|
|
|
*data++ = pixels;
|
|
|
|
|
b <<= 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
WATCHDOG;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void fill_char_table() {
|
|
|
|
|
char ch;
|
|
|
|
|
for (ch=LOCHAR; ch<=HICHAR; ch++) {
|
|
|
|
|
fill_char_table_entry(ch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const char CH_32[] = { 0x21,0x51,0x00 };
|
|
|
|
|
const char CH_33[] = { 0x21,0x55,0xf0,0xf0,0xf0,0x00,0xf0 };
|
|
|
|
|
const char CH_34[] = { 0x42,0x52,0xf0,0xf0,0xf0,0xf0 };
|
|
|
|
|
const char CH_35[] = { 0x42,0x55,0xf0,0xf0,0xff,0xf0,0xf0,0xf0,0xff,0xf0,0xf0,0xf0 };
|
|
|
|
|
const char CH_36[] = { 0x42,0x55,0x0f,0xf0,0xff,0x00,0x0f,0xf0,0xff,0x00,0x0f,0x00 };
|
|
|
|
|
const char CH_37[] = { 0x42,0x55,0xf0,0x00,0x00,0xf0,0x0f,0x00,0xf0,0x00,0x00,0xf0 };
|
|
|
|
|
const char CH_38[] = { 0x42,0x55,0xff,0x00,0xff,0x00,0xff,0xf0,0xf0,0xf0,0x0f,0xf0 };
|
|
|
|
|
const char CH_39[] = { 0x21,0x52,0xf0,0xf0 };
|
|
|
|
|
const char CH_40[] = { 0x32,0x55,0x0f,0x00,0xf0,0x00,0xf0,0x00,0xf0,0x00,0x0f,0x00 };
|
|
|
|
|
const char CH_41[] = { 0x32,0x55,0xf0,0x00,0x0f,0x00,0x0f,0x00,0x0f,0x00,0xf0,0x00 };
|
|
|
|
|
const char CH_42[] = { 0x42,0x53,0xf0,0xf0,0x0f,0x00,0xf0,0xf0 };
|
|
|
|
|
const char CH_43[] = { 0x42,0x43,0x0f,0x00,0xff,0xf0,0x0f,0x00 };
|
|
|
|
|
const char CH_44[] = { 0x32,0x22,0x0f,0x00,0xf0,0x00 };
|
|
|
|
|
const char CH_45[] = { 0x42,0x31,0xff,0xf0 };
|
|
|
|
|
const char CH_46[] = { 0x21,0x11,0xf0 };
|
|
|
|
|
const char CH_47[] = { 0x42,0x55,0x00,0xf0,0x00,0xf0,0x0f,0x00,0xf0,0x00,0xf0,0x00 };
|
|
|
|
|
const char CH_48[] = { 0x42,0x55,0x0f,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xff,0x00 };
|
|
|
|
|
const char CH_49[] = { 0x32,0x55,0x0f,0x00,0xff,0x00,0x0f,0x00,0x0f,0x00,0x0f,0x00 };
|
|
|
|
|
const char CH_50[] = { 0x42,0x55,0xff,0x00,0x00,0xf0,0x0f,0x00,0xf0,0x00,0xff,0xf0 };
|
|
|
|
|
const char CH_51[] = { 0x42,0x55,0xff,0x00,0x00,0xf0,0x0f,0x00,0x00,0xf0,0xff,0x00 };
|
|
|
|
|
const char CH_52[] = { 0x42,0x55,0xf0,0xf0,0xf0,0xf0,0xff,0xf0,0x00,0xf0,0x00,0xf0 };
|
|
|
|
|
const char CH_53[] = { 0x42,0x55,0xff,0xf0,0xf0,0x00,0xff,0x00,0x00,0xf0,0xff,0x00 };
|
|
|
|
|
const char CH_54[] = { 0x42,0x55,0x0f,0xf0,0xf0,0x00,0xff,0xf0,0xf0,0xf0,0xff,0xf0 };
|
|
|
|
|
const char CH_55[] = { 0x42,0x55,0xff,0xf0,0x00,0xf0,0x0f,0x00,0xf0,0x00,0xf0,0x00 };
|
|
|
|
|
const char CH_56[] = { 0x42,0x55,0xff,0xf0,0xf0,0xf0,0xff,0xf0,0xf0,0xf0,0xff,0xf0 };
|
|
|
|
|
const char CH_57[] = { 0x42,0x55,0xff,0xf0,0xf0,0xf0,0xff,0xf0,0x00,0xf0,0xff,0x00 };
|
|
|
|
|
const char CH_58[] = { 0x21,0x43,0xf0,0x00,0xf0 };
|
|
|
|
|
const char CH_59[] = { 0x32,0x44,0x0f,0x00,0x00,0x00,0x0f,0x00,0xf0,0x00 };
|
|
|
|
|
const char CH_60[] = { 0x42,0x55,0x00,0xf0,0x0f,0x00,0xf0,0x00,0x0f,0x00,0x00,0xf0 };
|
|
|
|
|
const char CH_61[] = { 0x42,0x43,0xff,0xf0,0x00,0x00,0xff,0xf0 };
|
|
|
|
|
const char CH_62[] = { 0x42,0x55,0xf0,0x00,0x0f,0x00,0x00,0xf0,0x0f,0x00,0xf0,0x00 };
|
|
|
|
|
const char CH_63[] = { 0x42,0x55,0xff,0xf0,0x00,0xf0,0x0f,0x00,0x00,0x00,0x0f,0x00 };
|
|
|
|
|
const char CH_64[] = { 0x42,0x55,0x0f,0x00,0xf0,0xf0,0xff,0xf0,0xf0,0x00,0x0f,0xf0 };
|
|
|
|
|
const char CH_65[] = { 0x42,0x55,0x0f,0x00,0xf0,0xf0,0xff,0xf0,0xf0,0xf0,0xf0,0xf0 };
|
|
|
|
|
const char CH_66[] = { 0x42,0x55,0xff,0x00,0xf0,0xf0,0xff,0x00,0xf0,0xf0,0xff,0x00 };
|
|
|
|
|
const char CH_67[] = { 0x42,0x55,0x0f,0xf0,0xf0,0x00,0xf0,0x00,0xf0,0x00,0x0f,0xf0 };
|
|
|
|
|
const char CH_68[] = { 0x42,0x55,0xff,0x00,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xff,0x00 };
|
|
|
|
|
const char CH_69[] = { 0x42,0x55,0xff,0xf0,0xf0,0x00,0xff,0xf0,0xf0,0x00,0xff,0xf0 };
|
|
|
|
|
const char CH_70[] = { 0x42,0x55,0xff,0xf0,0xf0,0x00,0xff,0xf0,0xf0,0x00,0xf0,0x00 };
|
|
|
|
|
const char CH_71[] = { 0x42,0x55,0x0f,0xf0,0xf0,0x00,0xff,0xf0,0xf0,0xf0,0x0f,0xf0 };
|
|
|
|
|
const char CH_72[] = { 0x42,0x55,0xf0,0xf0,0xf0,0xf0,0xff,0xf0,0xf0,0xf0,0xf0,0xf0 };
|
|
|
|
|
const char CH_73[] = { 0x42,0x55,0xff,0xf0,0x0f,0x00,0x0f,0x00,0x0f,0x00,0xff,0xf0 };
|
|
|
|
|
const char CH_74[] = { 0x42,0x55,0x00,0xf0,0x00,0xf0,0x00,0xf0,0xf0,0xf0,0x0f,0x00 };
|
|
|
|
|
const char CH_75[] = { 0x42,0x55,0xf0,0xf0,0xf0,0xf0,0xff,0x00,0xf0,0xf0,0xf0,0xf0 };
|
|
|
|
|
const char CH_76[] = { 0x42,0x55,0xf0,0x00,0xf0,0x00,0xf0,0x00,0xf0,0x00,0xff,0xf0 };
|
|
|
|
|
const char CH_77[] = { 0x42,0x55,0xf0,0xf0,0xff,0xf0,0xff,0xf0,0xf0,0xf0,0xf0,0xf0 };
|
|
|
|
|
const char CH_78[] = { 0x42,0x55,0xf0,0xf0,0xff,0xf0,0xff,0xf0,0xff,0xf0,0xf0,0xf0 };
|
|
|
|
|
const char CH_79[] = { 0x42,0x55,0x0f,0x00,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0x0f,0x00 };
|
|
|
|
|
const char CH_80[] = { 0x42,0x55,0xff,0x00,0xf0,0xf0,0xff,0x00,0xf0,0x00,0xf0,0x00 };
|
|
|
|
|
const char CH_81[] = { 0x42,0x55,0x0f,0x00,0xf0,0xf0,0xf0,0xf0,0xff,0xf0,0x0f,0xf0 };
|
|
|
|
|
const char CH_82[] = { 0x42,0x55,0xff,0x00,0xf0,0xf0,0xff,0xf0,0xff,0x00,0xf0,0xf0 };
|
|
|
|
|
const char CH_83[] = { 0x42,0x55,0x0f,0xf0,0xf0,0x00,0x0f,0x00,0x00,0xf0,0xff,0x00 };
|
|
|
|
|
const char CH_84[] = { 0x42,0x55,0xff,0xf0,0x0f,0x00,0x0f,0x00,0x0f,0x00,0x0f,0x00 };
|
|
|
|
|
const char CH_85[] = { 0x42,0x55,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0x0f,0xf0 };
|
|
|
|
|
const char CH_86[] = { 0x42,0x55,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0x0f,0x00,0x0f,0x00 };
|
|
|
|
|
const char CH_87[] = { 0x42,0x55,0xf0,0xf0,0xf0,0xf0,0xff,0xf0,0xff,0xf0,0xf0,0xf0 };
|
|
|
|
|
const char CH_88[] = { 0x42,0x55,0xf0,0xf0,0xf0,0xf0,0x0f,0x00,0xf0,0xf0,0xf0,0xf0 };
|
|
|
|
|
const char CH_89[] = { 0x42,0x55,0xf0,0xf0,0xf0,0xf0,0x0f,0x00,0x0f,0x00,0x0f,0x00 };
|
|
|
|
|
const char CH_90[] = { 0x42,0x55,0xff,0xf0,0x00,0xf0,0x0f,0x00,0xf0,0x00,0xff,0xf0 };
|
|
|
|
|
const char CH_91[] = { 0x42,0x55,0xff,0xf0,0xf0,0x00,0xf0,0x00,0xf0,0x00,0xff,0xf0 };
|
|
|
|
|
const char CH_92[] = { 0x42,0x43,0xf0,0x00,0x0f,0x00,0x00,0xf0 };
|
|
|
|
|
const char CH_93[] = { 0x42,0x55,0xff,0xf0,0x00,0xf0,0x00,0xf0,0x00,0xf0,0xff,0xf0 };
|
|
|
|
|
const char CH_94[] = { 0x42,0x52,0x0f,0x00,0xf0,0xf0 };
|
|
|
|
|
const char CH_95[] = { 0x42,0x11,0xff,0xf0 };
|
|
|
|
|
const char CH_96[] = { 0x32,0x52,0xf0,0x00,0x0f,0x00 };
|
|
|
|
|
const char CH_97[] = { 0x42,0x44,0xff,0x00,0x0f,0xf0,0xf0,0xf0,0xff,0xf0 };
|
|
|
|
|
const char CH_98[] = { 0x42,0x55,0xf0,0x00,0xff,0x00,0xf0,0xf0,0xf0,0xf0,0xff,0x00 };
|
|
|
|
|
const char CH_99[] = { 0x42,0x44,0x0f,0xf0,0xf0,0x00,0xf0,0x00,0x0f,0xf0 };
|
|
|
|
|
const char CH_100[] = { 0x42,0x55,0x00,0xf0,0x0f,0xf0,0xf0,0xf0,0xf0,0xf0,0x0f,0xf0 };
|
|
|
|
|
const char CH_101[] = { 0x42,0x44,0x0f,0xf0,0xf0,0xf0,0xff,0x00,0x0f,0xf0 };
|
|
|
|
|
const char CH_102[] = { 0x42,0x55,0x00,0xf0,0x0f,0x00,0xff,0xf0,0x0f,0x00,0x0f,0x00 };
|
|
|
|
|
const char CH_103[] = { 0x42,0x45,0x0f,0xf0,0xf0,0xf0,0xff,0xf0,0x00,0xf0,0x0f,0x00 };
|
|
|
|
|
const char CH_104[] = { 0x42,0x55,0xf0,0x00,0xff,0x00,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0 };
|
|
|
|
|
const char CH_105[] = { 0x21,0x55,0xf0,0x00,0xf0,0xf0,0xf0 };
|
|
|
|
|
const char CH_106[] = { 0x42,0x56,0x00,0xf0,0x00,0x00,0x00,0xf0,0x00,0xf0,0xf0,0xf0,0x0f,0x00 };
|
|
|
|
|
const char CH_107[] = { 0x42,0x55,0xf0,0x00,0xf0,0xf0,0xff,0x00,0xff,0x00,0xf0,0xf0 };
|
|
|
|
|
const char CH_108[] = { 0x42,0x55,0xff,0x00,0x0f,0x00,0x0f,0x00,0x0f,0x00,0xff,0xf0 };
|
|
|
|
|
const char CH_109[] = { 0x42,0x44,0xff,0xf0,0xff,0xf0,0xff,0xf0,0xf0,0xf0 };
|
|
|
|
|
const char CH_110[] = { 0x42,0x44,0xff,0x00,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0 };
|
|
|
|
|
const char CH_111[] = { 0x42,0x44,0x0f,0x00,0xf0,0xf0,0xf0,0xf0,0x0f,0x00 };
|
|
|
|
|
const char CH_112[] = { 0x42,0x45,0xff,0x00,0xf0,0xf0,0xf0,0xf0,0xff,0x00,0xf0,0x00 };
|
|
|
|
|
const char CH_113[] = { 0x42,0x45,0x0f,0xf0,0xf0,0xf0,0xf0,0xf0,0x0f,0xf0,0x00,0xf0 };
|
|
|
|
|
const char CH_114[] = { 0x42,0x44,0x0f,0xf0,0xf0,0x00,0xf0,0x00,0xf0,0x00 };
|
|
|
|
|
const char CH_115[] = { 0x42,0x44,0x0f,0xf0,0xff,0x00,0x0f,0xf0,0xff,0x00 };
|
|
|
|
|
const char CH_116[] = { 0x42,0x55,0x0f,0x00,0xff,0xf0,0x0f,0x00,0x0f,0x00,0x0f,0xf0 };
|
|
|
|
|
const char CH_117[] = { 0x42,0x44,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0x0f,0xf0 };
|
|
|
|
|
const char CH_118[] = { 0x42,0x44,0xf0,0xf0,0xf0,0xf0,0xff,0xf0,0x0f,0x00 };
|
|
|
|
|
const char CH_119[] = { 0x42,0x44,0xf0,0xf0,0xff,0xf0,0xff,0xf0,0xff,0xf0 };
|
|
|
|
|
const char CH_120[] = { 0x42,0x44,0xf0,0xf0,0x0f,0x00,0x0f,0x00,0xf0,0xf0 };
|
|
|
|
|
const char CH_121[] = { 0x42,0x45,0xf0,0xf0,0xf0,0xf0,0x0f,0xf0,0x00,0xf0,0x0f,0x00 };
|
|
|
|
|
const char CH_122[] = { 0x42,0x44,0xff,0xf0,0x0f,0xf0,0xff,0x00,0xff,0xf0 };
|
|
|
|
|
const char CH_123[] = { 0x42,0x55,0x0f,0xf0,0x0f,0x00,0xf0,0x00,0x0f,0x00,0x0f,0xf0 };
|
|
|
|
|
const char CH_124[] = { 0x21,0x55,0xf0,0xf0,0x00,0xf0,0xf0 };
|
|
|
|
|
const char CH_125[] = { 0x42,0x55,0xff,0x00,0x0f,0x00,0x00,0xf0,0x0f,0x00,0xff,0x00 };
|
|
|
|
|
const char CH_126[] = { 0x42,0x52,0x0f,0xf0,0xff,0x00 };
|
|
|
|
|
const char* const FONT_TABLE[95] = { CH_32, CH_33, CH_34, CH_35, CH_36, CH_37, CH_38, CH_39, CH_40, CH_41, CH_42, CH_43, CH_44, CH_45, CH_46, CH_47, CH_48, CH_49, CH_50, CH_51, CH_52, CH_53, CH_54, CH_55, CH_56, CH_57, CH_58, CH_59, CH_60, CH_61, CH_62, CH_63, CH_64, CH_65, CH_66, CH_67, CH_68, CH_69, CH_70, CH_71, CH_72, CH_73, CH_74, CH_75, CH_76, CH_77, CH_78, CH_79, CH_80, CH_81, CH_82, CH_83, CH_84, CH_85, CH_86, CH_87, CH_88, CH_89, CH_90, CH_91, CH_92, CH_93, CH_94, CH_95, CH_96, CH_97, CH_98, CH_99, CH_100, CH_101, CH_102, CH_103, CH_104, CH_105, CH_106, CH_107, CH_108, CH_109, CH_110, CH_111, CH_112, CH_113, CH_114, CH_115, CH_116, CH_117, CH_118, CH_119, CH_120, CH_121, CH_122, CH_123, CH_124, CH_125, CH_126, };
|
|
|
|
|
|
|
|
|
|
inline word swapw(word j) {
|
|
|
|
|
return ((j << 8) | (j >> 8));
|
|
|
|
@ -145,25 +213,20 @@ inline void draw_vline(word x1, byte y1, byte h, byte color) {
|
|
|
|
|
blitter.flags = (x1&1) ? DSTSCREEN|SOLID|ODDONLY : DSTSCREEN|SOLID|EVENONLY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void blit_copy(byte x1, byte y1, byte w, byte h, const byte* data) {
|
|
|
|
|
inline void blit_copy_solid(word x, byte y, byte w, byte h, const byte* data, byte solid) {
|
|
|
|
|
blitter.width = w^4;
|
|
|
|
|
blitter.height = h^4;
|
|
|
|
|
blitter.sstart = swapw((word)data);
|
|
|
|
|
blitter.dstart = x1+y1*256; // swapped
|
|
|
|
|
blitter.flags = DSTSCREEN|FGONLY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void blit_copy_solid(byte x1, byte y1, byte w, byte h, const byte* data, byte solid) {
|
|
|
|
|
blitter.width = w^4;
|
|
|
|
|
blitter.height = h^4;
|
|
|
|
|
blitter.sstart = swapw((word)data);
|
|
|
|
|
blitter.dstart = x1+y1*256; // swapped
|
|
|
|
|
blitter.solid = solid;
|
|
|
|
|
blitter.flags = DSTSCREEN|FGONLY|SOLID;
|
|
|
|
|
blitter.sstart = swapw((word)data);
|
|
|
|
|
blitter.dstart = (x>>1)+y*256; // swapped
|
|
|
|
|
if (solid)
|
|
|
|
|
blitter.flags = (x&1) ? DSTSCREEN|FGONLY|SOLID|RSHIFT : DSTSCREEN|FGONLY|SOLID;
|
|
|
|
|
else
|
|
|
|
|
blitter.flags = (x&1) ? DSTSCREEN|RSHIFT : DSTSCREEN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// bias sprites by +12 pixels
|
|
|
|
|
#define XBIAS 6
|
|
|
|
|
// bias sprites by +4 pixels
|
|
|
|
|
#define XBIAS 2
|
|
|
|
|
|
|
|
|
|
inline void draw_sprite(const byte* data, byte x, byte y) {
|
|
|
|
|
blitter.width = data[0]^4;
|
|
|
|
@ -219,15 +282,18 @@ void erase_sprite_strided(const byte* data, byte x, byte y, byte stride) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void draw_char(char ch, byte x, byte y, byte color) {
|
|
|
|
|
if (ch < LOCHAR || ch > HICHAR) return;
|
|
|
|
|
blit_copy_solid(x, y, 4, 8, font_table[ch - LOCHAR], color);
|
|
|
|
|
byte draw_char(char ch, word x, byte y, byte color) {
|
|
|
|
|
const byte* shape;
|
|
|
|
|
if (ch < LOCHAR || ch > HICHAR) return 1;
|
|
|
|
|
shape = FONT_TABLE[ch - LOCHAR];
|
|
|
|
|
blit_copy_solid(x, y - (shape[1]>>4),
|
|
|
|
|
shape[0] & 0xf, shape[1] & 0xf, shape+2, color);
|
|
|
|
|
return shape[0] >> 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void draw_string(const char* str, byte x, byte y, byte color) {
|
|
|
|
|
void draw_string(const char* str, word x, byte y, byte color) {
|
|
|
|
|
while (*str) {
|
|
|
|
|
draw_char(*str++, x, y, color);
|
|
|
|
|
x += 4;
|
|
|
|
|
x += draw_char(*str++, x, y, color);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -498,6 +564,8 @@ static Actor* free_list;
|
|
|
|
|
static Actor* effects_list;
|
|
|
|
|
static byte frame;
|
|
|
|
|
|
|
|
|
|
static word score; // bcd score
|
|
|
|
|
|
|
|
|
|
#define PLAYER 1
|
|
|
|
|
#define LASER 2
|
|
|
|
|
|
|
|
|
@ -513,12 +581,6 @@ void remove_actor(Actor* a) {
|
|
|
|
|
*a->prevptr = a->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char in_rect(const Actor* e, byte x, byte y, byte w, byte h) {
|
|
|
|
|
byte eh = e->shape[0];
|
|
|
|
|
byte ew = e->shape[1];
|
|
|
|
|
return (x >= e->x-w && x <= e->x+ew && y >= e->y-h && y <= e->y+eh);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void draw_actor_normal(Actor* a) {
|
|
|
|
|
draw_sprite(a->shape, a->x, a->y);
|
|
|
|
|
}
|
|
|
|
@ -565,6 +627,27 @@ word rand() {
|
|
|
|
|
return lfsr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
word bcd_add(word a, word b) {
|
|
|
|
|
a; b; // to avoid "unused variable" warning
|
|
|
|
|
__asm
|
|
|
|
|
ld hl,#4
|
|
|
|
|
add hl,sp
|
|
|
|
|
ld iy,#2
|
|
|
|
|
add iy,sp
|
|
|
|
|
ld a,0 (iy) ; load a (lo)
|
|
|
|
|
add a, (hl) ; add b (lo)
|
|
|
|
|
daa ; convert to BCD
|
|
|
|
|
ld c,a
|
|
|
|
|
ld a,1 (iy) ; load a (hi)
|
|
|
|
|
inc hl
|
|
|
|
|
adc a, (hl) ; add b (hi) + carry
|
|
|
|
|
daa
|
|
|
|
|
ld b,a
|
|
|
|
|
ld l, c
|
|
|
|
|
ld h, b ; result in HL reg
|
|
|
|
|
__endasm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
signed char random_dir() {
|
|
|
|
|
byte x = rand();
|
|
|
|
|
if (x < 85) return 0;
|
|
|
|
@ -613,6 +696,8 @@ bool test_actor_pixels(Actor* a) {
|
|
|
|
|
a->x + a->shape[0]*2);
|
|
|
|
|
byte y2 = minbyte(test_actor->y + test_actor->shape[1],
|
|
|
|
|
a->y + a->shape[1]);
|
|
|
|
|
if (x2 < x1) x2 = 255; // clip to 8-bit coord.
|
|
|
|
|
if (y2 < y1) y2 = 255; // clip to 8-bit coord.
|
|
|
|
|
if (x2 <= x1 || y2 <= y1) return false;
|
|
|
|
|
//draw_box(x1,y1,x2,y2,0xff);
|
|
|
|
|
p1 = &test_actor->shape[2+(y1-test_actor->y)*test_actor->shape[0]];
|
|
|
|
@ -655,6 +740,7 @@ void setup_collision(Actor* a) {
|
|
|
|
|
void destroy_player() {
|
|
|
|
|
Actor* a = &actors[PLAYER];
|
|
|
|
|
byte i;
|
|
|
|
|
sound_pia = 1; // play sound
|
|
|
|
|
for (i=0; i<60; i++) {
|
|
|
|
|
WATCHDOG;
|
|
|
|
|
while (video_counter != 0xfc) ;
|
|
|
|
@ -699,12 +785,17 @@ void laser_move(Actor* a) {
|
|
|
|
|
// move enemy to effects list
|
|
|
|
|
remove_actor(collided);
|
|
|
|
|
add_actor(&effects_list, collided);
|
|
|
|
|
// play sound
|
|
|
|
|
sound_pia = 2;
|
|
|
|
|
// add score
|
|
|
|
|
score = bcd_add(score, 5);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// move laser
|
|
|
|
|
// check for wall collisions
|
|
|
|
|
a->x += a->u.laser.dx;
|
|
|
|
|
if (a->x > 255-8) a->shape = NULL;
|
|
|
|
|
if (a->u.laser.dx > 0 && a->x < 8) a->shape = NULL;
|
|
|
|
|
if (a->u.laser.dx < 0 && a->x > 255-8) a->shape = NULL;
|
|
|
|
|
a->y += a->u.laser.dy;
|
|
|
|
|
if (a->y > 255-8) a->shape = NULL;
|
|
|
|
|
}
|
|
|
|
@ -765,11 +856,6 @@ Actor* new_actor() {
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void redraw_playfield(Actor* a) {
|
|
|
|
|
a;
|
|
|
|
|
draw_box(0,0,303,255,0x11);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Actor* new_effect(ActorDrawFn draw) {
|
|
|
|
|
Actor* a = new_actor();
|
|
|
|
|
a->draw = draw;
|
|
|
|
@ -782,13 +868,13 @@ void init() {
|
|
|
|
|
blit_solid(0, 0, 255, 255, 0);
|
|
|
|
|
memset(actors, 0, sizeof(actors));
|
|
|
|
|
memcpy(palette, palette_data, 16);
|
|
|
|
|
fill_char_table();
|
|
|
|
|
player_list = fast_list = obstacle_list = free_list = NULL;
|
|
|
|
|
memset(slow_lists, 0, sizeof(slow_lists));
|
|
|
|
|
// add all actors to free list
|
|
|
|
|
for (i=MAX_ACTORS-1; i>0; i--) {
|
|
|
|
|
add_actor(&free_list, &actors[i]);
|
|
|
|
|
}
|
|
|
|
|
score = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void make_player_actors() {
|
|
|
|
@ -823,13 +909,42 @@ void make_enemy_actors() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void draw_bcd_word(word bcd, word x, byte y, byte color) {
|
|
|
|
|
byte j;
|
|
|
|
|
x += 4*4;
|
|
|
|
|
for (j=0; j<4; j++) {
|
|
|
|
|
x -= 4;
|
|
|
|
|
draw_char('0'+(bcd & 0xf), x, y, color);
|
|
|
|
|
bcd >>= 4;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void draw_score(Actor* a) {
|
|
|
|
|
a;
|
|
|
|
|
draw_string("Plyr 1", 278, 8, 0xee);
|
|
|
|
|
// draw digits in color 0 so the background is erased
|
|
|
|
|
draw_bcd_word(score, 278, 20, 0);
|
|
|
|
|
// last two digits of score are "00"
|
|
|
|
|
draw_char('0', 278+16, 20, 0);
|
|
|
|
|
draw_char('0', 278+20, 20, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void draw_playfield(Actor* a) {
|
|
|
|
|
a;
|
|
|
|
|
draw_box(0,0,275,255,0x11);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
init();
|
|
|
|
|
make_player_actors();
|
|
|
|
|
make_enemy_actors();
|
|
|
|
|
new_effect(redraw_playfield);
|
|
|
|
|
WATCHDOG;
|
|
|
|
|
// add low-priority effects here, because new effects
|
|
|
|
|
// are added to the head of the list
|
|
|
|
|
new_effect(draw_score);
|
|
|
|
|
new_effect(draw_playfield);
|
|
|
|
|
// main loop
|
|
|
|
|
while (actors[PLAYER].shape) {
|
|
|
|
|
WATCHDOG;
|
|
|
|
|
effects_new_frame();
|
|
|
|
|
while (video_counter >= 0x90) effects_next();
|
|
|
|
|
update_screen_section(1);
|
|
|
|
@ -837,11 +952,17 @@ void main() {
|
|
|
|
|
update_screen_section(0);
|
|
|
|
|
switch (frame & 7) {
|
|
|
|
|
case 0:
|
|
|
|
|
draw_box(0,0,303,255,0x11);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
frame++;
|
|
|
|
|
WATCHDOG;
|
|
|
|
|
}
|
|
|
|
|
main();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SOUND ROM
|
|
|
|
|
|
|
|
|
|
const byte __at(0x9000) SOUND_ROM[] = {
|
|
|
|
|
0xdb,0x00,0xb7,0x20,0x01,0x76,0x11,0x02,0x40,0xdb,0x00,0x4f,0x0d,0x06,0x00,0x69,0x60,0x29,0x29,0x09,0x29,0x01,0xc5,0x00,0x09,0x01,0x0a,0x00,0xed,0xb0,0xcd,0x04,0x01,0x3e,0x00,0xd3,0x00,0x76,0xc9,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xc0,0x40,0xc0,0x40,0xc0,0x40,0xc0,0x40,0xc0,0x40,0xc0,0x40,0xc0,0x40,0xc0,0x40,0xc0,0x40,0xc0,0x40,0xc0,0x40,0xc0,0x40,0xc0,0x40,0xc0,0x40,0xc0,0x40,0xc0,0x40,0x80,0x88,0x90,0x98,0xa0,0xa8,0xb0,0xb8,0xc0,0xc8,0xd0,0xd8,0xe0,0xe8,0xf0,0xf8,0x00,0x08,0x10,0x18,0x20,0x28,0x30,0x38,0x40,0x48,0x50,
|
|
|
|
|
0x58,0x60,0x68,0x70,0x78,0x00,0x0c,0x18,0x24,0x2d,0x35,0x3b,0x3f,0x40,0x3f,0x3b,0x35,0x2d,0x24,0x18,0x0c,0x00,0xf4,0xe8,0xdc,0xd3,0xcb,0xc5,0xc1,0xc0,0xc1,0xc5,0xcb,0xd3,0xdc,0xe8,0xf4,0x60,0x37,0x3f,0x5c,0x16,0xca,0xc2,0xa5,0xfe,0xba,0x77,0x89,0xaa,0x77,0x13,0xd8,0xae,0x82,0xfd,0x22,0x9c,0x46,0xde,0x14,0x50,0xb4,0x97,0x46,0x54,0x9d,0x60,0x2b,0xd0,0x07,0x00,0x00,0xb8,0x0b,0xff,0xff,0x40,0x00,0xf4,0x01,0x00,0x00,0xd0,0x07,0xfc,0xff,0x60,0x00,0xed,0x4b,0x04,0x40,0x78,0x0f,0x0f,0x0f,0xe6,0x1f,0xe6,0x1f,0x5f,0x16,0x00,0xfd,0x21,0x00,0x40,0xfd,0x7e,0x00,0x83,0x5f,0xfd,0x7e,0x01,0x8a,0x57,0x1a,0xd3,0x00,0x2a,0x06,0x40,0x09,0x4d,0x44,0xed,
|
|
|
|
|
0x43,0x04,0x40,0xc9,0x01,0x27,0x00,0x21,0x0a,0x40,0x5e,0x6b,0x26,0x00,0x09,0x22,0x00,0x40,0xed,0x4b,0x02,0x40,0x59,0x50,0x1b,0xed,0x53,0x02,0x40,0x78,0xb1,0xc8,0xcd,0xd9,0x00,0xcd,0xd9,0x00,0xcd,0xd9,0x00,0xcd,0xd9,0x00,0xcd,0xd9,0x00,0xcd,0xd9,0x00,0xcd,0xd9,0x00,0xcd,0xd9,0x00,0xed,0x4b,0x06,0x40,0x2a,0x08,0x40,0x09,0x4d,0x44,0xed,0x43,0x06,0x40,0xed,0x4b,0x08,0x40,0x3a,0x0b,0x40,0x6f,0x17,0x9f,0x67,0x09,0x4d,0x44,0xed,0x43,0x08,0x40,0x18,0xb8,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,
|
|
|
|
|
};
|
|
|
|
|