1
0
mirror of https://github.com/cc65/cc65.git synced 2024-10-31 20:06:11 +00:00

Improve helloworld example for Supervision

This commit is contained in:
Fabrizio Caruso 2019-10-06 13:41:02 +02:00 committed by Oliver Schmidt
parent 915836b3ec
commit eb83a3fd0f

View File

@ -1,17 +1,15 @@
#include <supervision.h>
#include <peekpoke.h>
#define SV_OFFSET 0x0A
#define SV_INIT_POSITION (SV_VIDEO+0x0A*48+0x0A)
unsigned char h_char[] = {0x66,0x66,0x66,0x7e,0x66,0x66,0x66,0x00};
unsigned char e_char[] = {0x7e,0x60,0x60,0x78,0x60,0x60,0x7e,0x00};
unsigned char l_char[] = {0x60,0x60,0x60,0x60,0x60,0x60,0x7e,0x00};
unsigned char o_char[] = {0x3c,0x66,0x66,0x66,0x66,0x66,0x3c,0x00};
unsigned char w_char[] = {0x63,0x63,0x63,0x6b,0x7f,0x77,0x63,0x00};
unsigned char r_char[] = {0x7c,0x66,0x66,0x7c,0x78,0x6c,0x66,0x00};
unsigned char d_char[] = {0x78,0x6c,0x66,0x66,0x66,0x6c,0x78,0x00};
#define BYTES_PER_LINE 48
const unsigned char h_char[] = {0x66,0x66,0x66,0x7E,0x66,0x66,0x66,0x00};
const unsigned char e_char[] = {0x7E,0x60,0x60,0x78,0x60,0x60,0x7E,0x00};
const unsigned char l_char[] = {0x60,0x60,0x60,0x60,0x60,0x60,0x7E,0x00};
const unsigned char o_char[] = {0x3C,0x66,0x66,0x66,0x66,0x66,0x3C,0x00};
const unsigned char w_char[] = {0x63,0x63,0x63,0x6B,0x7F,0x77,0x63,0x00};
const unsigned char r_char[] = {0x7C,0x66,0x66,0x7C,0x78,0x6C,0x66,0x00};
const unsigned char d_char[] = {0x78,0x6C,0x66,0x66,0x66,0x6C,0x78,0x00};
void clear_screen(void)
{
@ -23,37 +21,48 @@ void clear_screen(void)
}
}
unsigned char bit_reverse_lookup[16] =
unsigned char reversed_map_one_to_two_lookup[16] =
{
0x0, 0x8, 0x4, 0xC, 0x2, 0xA, 0x6, 0xE,
0x1, 0x9, 0x5, 0xD, 0x3, 0xB, 0x7, 0xF
0x00, 0xC0, 0x30, 0xF0, 0x0C, 0xCC, 0x3C, 0xFC,
0x03, 0xC3, 0x33, 0xF3, 0x0F, 0xCF, 0x3F, 0xFF
};
unsigned char bit_reverse(unsigned char n)
unsigned char left_map_one_to_two(unsigned char n)
{
return (bit_reverse_lookup[n&0b1111] << 4) | bit_reverse_lookup[n>>4];
return reversed_map_one_to_two_lookup[n >> 4];
}
unsigned char right_map_one_to_two(unsigned char n)
{
return reversed_map_one_to_two_lookup[n&0x0F];
}
void display_char(const unsigned char x, const unsigned char y, const unsigned char *ch)
{
unsigned char k;
for(k=0;k<8;++k)
{ \
SV_VIDEO[2*(y)+BYTES_PER_LINE*k+BYTES_PER_LINE*(x<<3)] = left_map_one_to_two(ch[k]);
SV_VIDEO[2*(y)+BYTES_PER_LINE*k+BYTES_PER_LINE*(x<<3)+1] = right_map_one_to_two(ch[k]);
}
}
int main()
{
unsigned char i;
{
clear_screen();
for(i=0;i<8;++i)
{
POKE(SV_INIT_POSITION+1 +i*48,bit_reverse(h_char[i]));
POKE(SV_INIT_POSITION+2 +i*48,bit_reverse(e_char[i]));
POKE(SV_INIT_POSITION+3 +i*48,bit_reverse(l_char[i]));
POKE(SV_INIT_POSITION+4 +i*48,bit_reverse(l_char[i]));
POKE(SV_INIT_POSITION+5 +i*48,bit_reverse(o_char[i]));
POKE(SV_INIT_POSITION+7 +i*48,bit_reverse(w_char[i]));
POKE(SV_INIT_POSITION+8 +i*48,bit_reverse(o_char[i]));
POKE(SV_INIT_POSITION+9 +i*48,bit_reverse(r_char[i]));
POKE(SV_INIT_POSITION+10+i*48,bit_reverse(l_char[i]));
POKE(SV_INIT_POSITION+11+i*48,bit_reverse(d_char[i]));
}
display_char(3,2, h_char);
display_char(3,3, e_char);
display_char(3,4, l_char);
display_char(3,5, l_char);
display_char(3,6, o_char);
display_char(3,8, w_char);
display_char(3,9, o_char);
display_char(3,10,r_char);
display_char(3,11,l_char);
display_char(3,12,d_char);
while(1) {};