Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to pack and unpack a string?
#1
could anyone write a guide on how to pack and unpack a string using something like aplib or megalz?
Reply
#2
How big is the string?
Reply
#3
here is the string:
Quote:PART 1
Bruce Hall, a slightly built youth 16 years of age, fair haired and blue eyed, stood 4' 8" in shoes and despite that slight assistance still could not see over the brick wall behind which he believed stood a flying machine. At least that was what he'd overheard two delivery boys discussing outside the local butchers shop.

"I aint lying Sid, I seen it wiv me own eyes. It were one of them airyplanes, I'd swear to it. I couldn't see it proper mind cos the bloke dint want me ter come in past the gatehouse when I was delivering 'is bangers. Tole me ter mind me own business and keep me mouf shut. So I stood up on the pedals of me bike an' just caught a look at sumfing like a big box kite. Well wot else could it be, tell me that?"

"Don't be so daft Alf! I know that place, its all full of box hedges and that, like a maze sorta fing. One o' them fancy gardens the nobs has wiv all fountains and peacocks and fings. 'ow could a bloke get a flying machine dahn in that lot unless ee crashed o' course. I bet wot you saw was prolly a marquee or sumfing for a garden party most likely. I'll ask old Bert when I see 'im e's a gardener there."

Bruce nicknamed Toad by his school mates for obvious reasons, had what almost amounted to an obsession about flying. He'd designed and built a succession of models, each larger than its predessor and most of which now rested in the uppermost branches of various trees or as crumpled remains, after encountering a more solid structure and falling to earth. He collected every magazine and book he could find with descriptions of these fledgling machines and their intrepid pilots but had yet to see one in flight or even earthbound despite his best efforts at tracking one down though he knew they were to be found quite close by.

Being effectively a prisoner of his boarding school with only the freedom permitted by the tradition of Sunday Walks, Bruce's effective radius of travel within the time allotted was only about three miles and the local flying field was five miles distant. It was unlikely that a flyer would ever pass over the school especially since to do so would mean having to fly over the town and as he knew well they were restricted to flights over open country as much for their own safety as anyone elses.

So, here was possibly his best opportunity to see an aircraft up close, if indeed it really was behind the wall but situated as it was parallel to a busy main road and completely lacking convenient trees or other means of scalng it easily, he had to find a way in and the tall iron gates that barred entrance to the driveway were the best point of entry, he could probably have squeezed between their bars were it not for the ever vigilant gate keeper who resided in the gatehouse that was part of the ornate brick archway.

Toad considered his options, should he:-
CLIMB 1. Make an attempt at climbing the wall despite the difficulty (CLI)
KNOCK 2. Knock at the gatehouse door and ask to retrieve something of his that the wind blew over the wall. (KNO)
SEARCH 3. Keep walking the perimeter searching for another way in. (SEA)
END

There are also going to be others, that is just one.
Reply
#4
I used unpacking [search for megaLZ] in the tutorial here: <!-- m --><a class="postlink" href="https://docs.google.com/document/d/1vUneCCC18oXLglzoRcJdrMDUSh7vaO_tGDjzjOc8IhU/edit">https://docs.google.com/document/d/1vUn ... c8IhU/edit</a><!-- m -->

Though it's not strings specifically.

To pack:
Write the text into a file, and use the windows based packer to make a compressed data lump. You can then #include that data lump in your code in asm context.


I don't think you can unpack text to a string space and use it like a string, so you're going to have to have a spot of memory to unpack these to. You can either use the malloc function to make one, or DIM a space, and use @variable to access the memory address. Make sure it's a big enough buffer to allow the largest piece of text into, so you don't overwrite anything after it. (Buffer overrun problems are notorious).

Then you'd need to write a function to print each character at that address. It's basically a for/next loop increasing the address and printing chr$(peek address) to the screen. The easiest way to do it is to have a unique terminator character - such as a 0 or 255 byte, at the end, and detect that so you know to stop printing and exit your loop. Then you don't need to know the unpacked length of each string, which is probably a size saving over the alternative, which would be to put bytes representing the size of the text at the start of each text block.

Don't forget to put in labels for each block so you can find them. Maybe you can put those labels into an array?
Reply
#5
thanks thats a good step-by-step tutorial
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)