Subject: Re: [stella] Thinking like a computer (harder than it sounds) From: Erik Mooney <emooney@xxxxxxxxxxxxxxxx> Date: Wed, 2 Jun 1999 10:24:19 -0400 (EDT) |
> >> As we only need 6 bits of every byte, we can overlap the cards in > >> memory, every four cards in three bytes: > >> > >> AAAAAABB BBBBCCCC CCDDDDDD EEEEEEFF FFFFGGGG GGHHHHHH > > >Don't forget that someone's also gonna have to *draw* a screen with all > >these cards. I doubt you'd have time to extract card values out of that > >packing during a screen kernel, and you can forget about using Andrew > >Davie's packing method for that :) I'd use one byte per card to make that > >a good deal simpler. > > I take it doing by nibbles isn't that bad though? That's what I'd guess. All you have to do to get a nibble value out of a byte is AND it with $0F or $F0. To get values out of your packing scheme, you need to read from two memory locations and do some tricky shifting and stuff to combine the fragments together. > >Actually, you need but _one_ bit, not two, for each card after the first. > >After the first card, you know what color each card below will be, so you > >only need one bit to distinguish suit. E.g., if the top card is the queen > >of spades, you only need one bit to tell whether the next one is the jack > >of hearts or the jack of diamonds. > > Ah! Did I miss that, or are you refining? I was refining.. didn't notice that till now. > >Of course, you need some counter to keep track of how many cards in the > >stack (your terminator won't work anymore.) Still, though, that's 6 bits > >for the top card plus 4 for the counter plus 12 for the other cards; > >smaller than your 6 bits for the top card plus 2 each for 12 other cards. > > True. Of course, to avoid packing & unpacking time, we'll just use one > byte for the top card, and exactly two bytes for the up stack. I assume > we'd start those two bytes with the counter itself? You could probably do that - 12 bits for the stack and 4 for the counter should compress neatly into two bytes. > Well, actually, I had the (uncompressed) ace piles at 4 bytes, but if > we use one byte to store the order of suits (you'd have to juggle a > terminator state, starting with/alternating 00000000 and 11111111 states > as you added), then you'd only need two bytes (4 nibbles) for the top > card values, saving one more byte. What I'd do is just hardcode the ace piles into a fixed order.. that solves everything there. -- Archives (includes files) at http://www.biglist.com/lists/stella/archives/ Unsub & more at http://www.biglist.com/lists/stella/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [stella] Thinking like a comput, Russ Perry Jr | Thread | Re: [stella] Thinking like a comput, Russ Perry Jr |
Re: [stella] Thinking like a comput, Russ Perry Jr | Date | Re: [stella] Thinking like a comput, Russ Perry Jr |
Month |