Harry Potter Posted October 10, 2021 Share Posted October 10, 2021 Hi! I need help with my file compression technique. Currently, I am writing output in the wrong direction: I'm starting at bit 0 instead of 7. How do I write and align information starting at bit 7? I understand that this is a stupid question, but I'm stumped here. Quote Link to comment Share on other sites More sharing options...
Rybags Posted October 10, 2021 Share Posted October 10, 2021 Shift or rotate the input bits in the other direction maybe. 1 Quote Link to comment Share on other sites More sharing options...
thorfdbg Posted October 10, 2021 Share Posted October 10, 2021 You keep two state variables, a "bit buffer" and a "counter" that takes care of the number of free bits in the buffer (i.e. initially 8 for a byte-buffer). On writing a bit, you decrement the bit-counter and shift your input left by the number of bits indicated in the bit-counter. Then or the bits into the bit buffer. If the bit counter is now zero, write out the byte, zero the bit buffer and reset the bit counter to 8. If you are only writing single bits, then instead of left-shifting with a loop, use a look-up table that gives you the value indexed by the bit counter, and only use the table if the input bit is 0. Alternative solution: Every time a bit arrives, shift the bit buffer left by one bit, put the new bit into the LSB, decrement the bit counter. If the bit-counter is 0, write out the bit buffer, zero the bit buffer and reset the bit counter to 8. Quote Link to comment Share on other sites More sharing options...
xxl Posted October 10, 2021 Share Posted October 10, 2021 7 hours ago, Harry Potter said: Currently, I am writing output in the wrong direction: I'm starting at bit 0 instead of 7. How do I write and align information starting at bit 7? you need basic tools to solve this problem. That tool is knowing the 6502's commands ... unfortunately 1 Quote Link to comment Share on other sites More sharing options...
danwinslow Posted October 10, 2021 Share Posted October 10, 2021 I think he just wants some attention. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted October 10, 2021 Author Share Posted October 10, 2021 I do want some attention, but my posts are true. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.