Login
Search for:


Previous | Next

From: Rachy (all posts)
Date: 1999-01-21
Subject: GCR encode
Ahojka!

I don't know who asked for it, but here is a little C source from Frodo,
it converts 4 bytes to 5 GCR encoded bytes.



/*
* Convert 4 bytes to 5 GCR encoded bytes
*/

const uint16 gcr_table[16] = {
0x0a, 0x0b, 0x12, 0x13, 0x0e, 0x0f, 0x16, 0x17,
0x09, 0x19, 0x1a, 0x1b, 0x0d, 0x1d, 0x1e, 0x15
};

void Job1541::gcr_conv4(uint8 *from, uint8 *to)
{
uint16 g;

g = (gcr_table[*from >> 4] << 5) | gcr_table[*from & 15];
*to++ = g >> 2;
*to = (g << 6) & 0xc0;
from++;

g = (gcr_table[*from >> 4] << 5) | gcr_table[*from & 15];
*to++ |= (g >> 4) & 0x3f;
*to = (g << 4) & 0xf0;
from++;

g = (gcr_table[*from >> 4] << 5) | gcr_table[*from & 15];
*to++ |= (g >> 6) & 0x0f;
*to = (g << 2) & 0xfc;
from++;

g = (gcr_table[*from >> 4] << 5) | gcr_table[*from & 15];
*to++ |= (g >> 8) & 0x03;
*to = g;
}




Bye:
Rajnai Almos

+---------------------------=%%&##########&%%=-------------------------+
| Rachy of Bi0Hazard | Only Amiga makes it |TankcsapdaMeta| F0NT! |
|e-mail: racs@fs2.bdtf.hu | possible! |llicaHelloween| Editor|
+-----ICQ:-16342960---------=%%&##########&%%=---Phone:+36 20 9891489--+

Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon