[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More thoughts about Lode Runner & other multiload games...



On Saturday, September 29, 2012 11:38:51 PM UTC-5, Steve Nickolas wrote:
> On Sat, 29 Sep 2012, TommyGoog wrote:
> 
> 
> 
> > On Saturday, September 29, 2012 3:45:38 PM UTC-5, Steve Nickolas wrote:
> 
> >> http://1.buric.co/lrrbcd.zip
> 
> >>
> 
> >>
> 
> >>
> 
> >> Given a sector containing a level from Lode Runner, these tools will
> 
> >>
> 
> >> convert between the 256-byte (only 224 used) raw sector form and a
> 
> >>
> 
> >> 196-byte format made through what I call "reverse binary-coded decimal
> 
> >>
> 
> >> packing".
> 
> >>
> 
> >>
> 
> >>
> 
> >> Basically, each nibble contains a value from 0-9 (where they could take a
> 
> >>
> 
> >> value up to 15).  This means each byte has only 100 options, instead of
> 
> >>
> 
> >> 256.  A range of 100 will fit in 7 bits (which have a range of 128).
> 
> >>
> 
> >> Therefore by taking the converted values, and packing 8 bytes in 7 by
> 
> >>
> 
> >> discarding the top bits, the file is reduced from 224 used bytes to 196.
> 
> >>
> 
> >>
> 
> >>
> 
> >> lrrbcd.c is a tool to encode levels using this scheme.
> 
> >>
> 
> >> lrunrbcd.c is a tool to decode levels using this scheme.
> 
> >>
> 
> >>
> 
> >>
> 
> >> I haven't translated the UNRBCD algo to 6502 yet.  Also, it breaks in
> 
> >>
> 
> >> Watcom C, so you'll probably need to use GNU C (e.g., MinGW).
> 
> >>
> 
> >>
> 
> >>
> 
> >> -uso.
> 
> >
> 
> > The code in Lrrbcd.c has the following instruction that seems out of place:
> 
> >
> 
> >   tbuf[k]=((k&0xF0)>>4)*10+(k&0x0F);
> 
> >
> 
> > Tommy
> 
> >
> 
> 
> 
> It's not - it's the un-BCDing.  It's equivalent to ((k/16)*10)+(k%10) 
> 
> functionally.
> 
> 
> 
> -uso.

At line 35 of the file is the line that does the un-BCDing:
   tbuf[k]=((ibuf[k]&0xF0)>>4)*10+(ibuf[k]&0x0F);

The instruction at line 69 of the file seems extraneous:
   tbuf[k]=((k&0xF0)>>4)*10+(k&0x0F);

Tommy