6502_linux_logo/ascii2hgr2bit.c

153 lines
4.4 KiB
C
Raw Normal View History

2017-07-16 15:27:38 +00:00
/*
6502 Linux Logo
2017-07-17 07:52:37 +00:00
Michaelangel007
https://github.com/Michaelangel007/6502_linux_logo
gcc -Wall -Wextra ascii2hgr2bit.c -o ascii2hgr2bit
2017-07-16 15:27:38 +00:00
*/
#include <stdio.h>
/*
2017-07-17 08:07:14 +00:00
Cleaned up fugly logo by Albert Lai <aylai@unixg.ubc.ca>
2017-07-16 15:27:38 +00:00
* Width is now 70 chars to be exact 4 pixels/char for 280 resolution
2017-07-17 08:07:14 +00:00
* Logo takes up 210 bytes (2 bits/char) compared to 80*12 = 960 byte
2017-07-16 15:27:38 +00:00
* X is now symmetrical
* Fixed L,i,n kerning
* Fixed x Penguin kerning
* Fixed L to fit
2017-07-17 08:07:14 +00:00
* Chopped off 2 columns of penguin to fit 70 chars
2017-07-16 15:27:38 +00:00
https://github.com/deater/linux_logo/blob/master/logos/banner.logo
*/
2017-07-17 07:52:37 +00:00
int gbOutputHgr = 0; // 0 = 2bits/2pixel, 1=HGR bytes
2017-07-16 15:27:38 +00:00
unsigned char gaLogoBits[ 280 / 2 * 192 / 8 ]; // packed bits
const char* gaLogo70 =
/*
ASCII:
70 chars * 12 scanlines = 840 bytes
Bitpacked 1-bit/4 pixels
Bitpacked 2-bits/2 pixels
70 chars * 2 bits/char / 8 bits/byte = 17.5 bytes / scanline
17.5 bytes/scanline * 12 scanlines = 210 bytes
Char &3 Color
@ 00 Black
A 01 Blue
B 10 Orange
_ 11 White
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17.5
<--><--><--><--><--><--><--><--><--><--><--><--><--><--><--><--><--><-->
*/
#if 1
2017-07-16 15:27:38 +00:00
"__________________________________________________________@@@@@_______"
"_________________________________________________________@@@@@@@______"
"______________A__________________________________________@@_@_@@______"
"@@@@@@_______AA@_________________________________________@BBBBB@______"
"__@@__________@________________________________________@@__BBB__@@____"
"__@@_______AAA__@@@_@@@@___@@@____@@@__@@@@@_@@@@@____@__________@@___"
"__@@______A__A@__@@@____@@__@@_____@@____@@___@@_____@____________@@__"
"__@@_____A___A@__@@_____@@__@@_____@@_____@@_@@______@____________@@@_"
"__@@________AA@__@@_____@@__@@_____@@______@@@______BB@___________@@B_"
"__@@_____@_AA@___@@_____@@__@@_____@@_____@@_@@____BBBBB@_______@BBBBB"
"__@@____@@_AA@_@_@@_____@@__@@@___@@@____@@___@@___BBBBBB@_____@BBBBBB"
"@@@@@@@@@@__@@@_@@@@___@@@@___@@@@_@@@_@@@@@_@@@@@__BBBBB@@@@@@@BBBBB_"
#else
2017-07-17 07:52:37 +00:00
// _@_@_@_@_@_@_@ = PACK: $33,$33,$33,$33 -> HGR: $33,$66,$4C,$19 (MSB=0)
2017-07-17 07:52:37 +00:00
// 1100110011001100110011001100 $B3,$E6,$CC,$99 (MSB=1)
//"_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@"
2017-07-17 07:52:37 +00:00
/*
Bit Packing 2 bits / 1 pixels
<--CC--> <--CC--> <--CC--> <--CC--> Packed Bytes
|11001100|11001100|11001100|11001100| Packed Bits
|hgfedcba|ponmlkji|xwvutsrq|FEDCBAzy|
| | | | |
|76543210|76543210|76543210|76543210| Bit Position
| 0 | 1 | 2 | 3 | Byte
| | | | |
|1gfedcba|1nmlkjih|1utsrqpo|1BAzyxwv|
|11001100|10011001|10110011|11100110|
<--CC--> <--99--> <--B3--> <--E6--> HGR Bytes
@_@_@_@_@_@_@_ = 00110011001100110011001100
= 11001100110011001100110011 (reverse bits)
= PACK: $CC,$CC,$CC,$CC
-> HGR: $CC,$99,$B3,$E6 (MSB=1)
HGR: $4C,$19,$33,$66 (MSB=0)
*/
"@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_@_"
2017-07-16 15:27:38 +00:00
#endif
;
int main( const int nArg, const char *aArg[] )
{
(void) aArg;
if( nArg > 1 )
gbOutputHgr = 1;
2017-07-16 15:27:38 +00:00
const char *src = gaLogo70;
unsigned char *dst = gaLogoBits;
unsigned int bit = 0;
2017-07-16 15:27:38 +00:00
unsigned char shl = 0;
unsigned int len = 0;
unsigned int i;
while( *src )
{
bit |= (*src & 3) << shl;
shl += 2;
if( gbOutputHgr )
{
if( shl >= 8 )
{
shl -= 7 ;
*dst++= (0x80 | bit);
bit >>= 7;
}
} else {
2017-07-16 15:27:38 +00:00
if( shl >= 8 )
{
shl -= 8 ;
*dst++= bit;
2017-07-16 15:27:38 +00:00
bit = 0;
}
}
2017-07-16 15:27:38 +00:00
src++;
}
len = (unsigned int)(dst - gaLogoBits);
2017-07-17 07:52:37 +00:00
printf( "PackedLen\n" );
2017-07-16 15:27:38 +00:00
printf( " dfb $%02X\n", len );
2017-07-17 07:52:37 +00:00
printf( "PackedBits\n");
printf( " ; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 byte\n" );
printf( " ; 0 16 32 48 64 80 96 112 128 144 160 176 192 208 224 240 256 272 8 24 40 56 72 88 104 120 136 152 168 184 200 216 232 248 264 px\n" );
2017-07-16 15:27:38 +00:00
for( i = 0; i < len; i++ )
{
2017-07-17 07:52:37 +00:00
if( (i % (35)) == 0 )
2017-07-16 15:27:38 +00:00
{
if( i > 0 )
printf( "\n" );
printf( " dfb " );
}
printf( "$%02X,", gaLogoBits[ i ] );
}
printf( "\n" );
return 0;
}