From: MagerValp on
>>>>> "WM" == Wolfgang Moser <wnhp(a)d81.de.invalid> writes:

WM> Something that took my attention, too, were the two lines with the
WM> bit shift quirks done in BASIC. I had the feeling that doing
WM> floating point math would a bit more "type- in-efficient".

WM> 200 v=0 : for k=1 to 4
WM> 210 q=asc(mid$(q$,k,1)): gosub 300
WM> 220 v=v*64 + q: next
WM> 230 for k=2 to 0 step -1
WM> 240 q=v : v=v/256 : q=q-256*int(v)
WM> 250 poke a+k,q: c=(c+q) and 255: next
WM> 260 return

Aha, interesting.

--
___ . . . . . + . . o
_|___|_ + . + . + . Per Olofsson, arkadspelare
o-o . . . o + MagerValp(a)cling.gu.se
- + + . http://www.cling.gu.se/~cl3polof/
From: MagerValp on
>>>>> "WM" == Wolfgang Moser <wnhp(a)d81.de.invalid> writes:

WM> Btw. this just remembered me to some old software registration key
WM> system, where the following 5-Bit mapping was used.

WM> convTable:array [0..$1F] of char =(
WM> '0','1','2','3','A','B','C','D','E','F','G','H','4','5','6','J',
WM> 'K','L','M','N','7','8','9','P','Q','R','S','T','W','X','Y','Z'
WM> );
WM> ...
WM> if not (Key[i] in ['0'..'9', 'A'..'H', 'J'..'N',
WM> 'P'..'T', 'W'..'Z']) then break;

WM> The characters: 'I', 'O' (Oh), 'U' and 'V' were omitted to reduce
WM> misinterpretations.

Hmm, we might have a winner here. You can fit 19+1 bytes per line with
this scheme, resulting in 36 lines of data. The tricky part is
handling the checksum byte in a convenient way.

--
___ . . . . . + . . o
_|___|_ + . + . + . Per Olofsson, arkadspelare
o-o . . . o + MagerValp(a)cling.gu.se
- + + . http://www.cling.gu.se/~cl3polof/
From: Wolfgang Moser on
MagerValp schrieb:
> WM> 200 v=0 : for k=1 to 4
> WM> 210 q=asc(mid$(q$,k,1)): gosub 300
> WM> 220 v=v*64 + q: next
> WM> 230 for k=2 to 0 step -1
> WM> 240 q=v : v=v/256 : q=q-256*int(v)
> WM> 250 poke a+k,q: c=(c+q) and 255: next
> WM> 260 return
>
> Aha, interesting.

and perhaps easy adoptable to a 5-bit scheme, not?

Which bit depth comes with the C64's floating point
format regarding the base (anything but exponent
and sign)? Too less, hmmm... thus another technique
is needed like intermediate-15-bit-register
shifting, with "shifting" meaning to use '*' and
'/' operations.


Womo

From: Wolfgang Moser on
Hi Per,

I don't like competitions. They're simply costing
too much time for nothing.

> WM> if not (Key[i] in ['0'..'9', 'A'..'H', 'J'..'N',
> WM> 'P'..'T', 'W'..'Z']) then break;
>
> Hmm, we might have a winner here. You can fit 19+1 bytes per line with
> this scheme, resulting in 36 lines of data. The tricky part is
> handling the checksum byte in a convenient way.

hmmmm, 18 byte for data and 11 bits per line as
a checksum sounds reasonable.

A (not so) quick proof of concept may be (char
decoding at 300 omitted):

10 data 1234567890abcdefghjklmnpqrstwxy
20 data yzxwtsrqpnmlkjhgfedcba098765432
99 data end
110 read a$
120 if a$="end" then end
130 r=0 : s=0 : ck=0
140 for i=1 to len(a$)
150 : if s<8 goto 200
160 : s=s-8
170 : q=r/exp(s * log(2)) and 255
180 : print q;",";
190 : ck = ck + q and 2047
200 : q=asc(mid$(a$,i,1)) : gosub 300
210 : r=32 * (r and 127) + q
220 : s=s+5
230 next i
240 print " ==> 11 bit checksum is: ";r and 2047;" vs. ";ck
250 goto 110
300 return


Womo

PS: line 170 means shift r right by s
From: MagerValp on
>>>>> "WM" == Wolfgang Moser <wnhp(a)d81.de.invalid> writes:

WM> Which bit depth comes with the C64's floating point format
WM> regarding the base (anything but exponent and sign)?

IIRC, 8-bit exponent, 1-bit sign, and 31-bit mantissa. Plenty of
precision there.

How about something like this:

readline:
read a$
if a$="end" then end
v=0 : s=0 : c=0
for i=1 to len(a$)
q=asc(mid$(a$,i,1)) : gosub conv32
v=v*32+q : s=s+5
if s<7 goto nextchar
q=v and 255 : v=v/256 : s=s-8
if i=len(a$) goto checksum
poke a,q : a=a+1 : c=c+q
goto nextchar

checksum:
if c<>q then print "checksum error" : end

nextchar:
next
goto readline

(Hmm, I should write a simple basic preprocessor, so you can write
line number-less code like this)

19+1 bytes per line gives 36 lines of data. The same method can be
used with base-64 of course, giving 30 lines of data. What would
people prefer though?

--
___ . . . . . + . . o
_|___|_ + . + . + . Per Olofsson, arkadspelare
o-o . . . o + MagerValp(a)cling.gu.se
- + + . http://www.cling.gu.se/~cl3polof/