MANUAL FOR WRAP (6502 ASSEMBLER) This file describes the program WRAP which demostrates how to wordwrap a block of text in memory onto the screen. The manual and software is (C)1998 SPROW INSTRUCTIONS- At the BASIC prompt,type CHAIN"WRAP" The program will assemble itself in RAM,and then go to look for the file called 'Tester' on the current filing system.This it will load into RAM too. The demostration text will then be printed on the screen,wordwrapped to 40 columns (even thought the test text is not).Printing stops when a character zero is found in the text. Please note that this software is not intended to be a stand alone product,but is simply a demonstration of how YOUR programs could wordwrap far faster than the equivalent BASIC program. HOW IT WORKS Say we have a block of text which was written in 80 column mode,but we want to show this is 40 column mode instead.A crude way to do this would be simply to print it out unmodified,but this would result in some words being broken across the ends of lines. It is therefore desireable to wordwrap the text.This may be done by considering some special cases: Here are the 40 columns 0123456789012345678901234567890123456789 Here's a random string ABCDE EFGHIJK LMNOPQ . RTSUVWXYZ,abcdef ghij. Fortunately this will look OK even if we'd simply printed it out.To word wrap you move a pointer to the 40th character,then back up 1 character at a time until you find a space.Here,that occurs on the very first letter,as there's a space at the end of the line. Here are the 40 columns 0123456789012345678901234567890123456789 Here's a random string ABCDE EFGHIJK LMNOPQ . RTSUVWXYZ,abcdefg hij. Applying the above rules the wordwrap will be made after the full stop as that is where the first space is.It would appear as: Here are the 40 columns 0123456789012345678901234567890123456789 Here's a random string ABCDE EFGHIJK LMNOPQ . RTSUVWXYZ,abcdefghij. Which isn't very satisfactory.If instead we look for any charcter with an ASCii value LESS THAN the letter '0' (number 48) then the wordwrap will occur at the comma instead,as this has ASCii value 44.It'll look like Here are the 40 columns 0123456789012345678901234567890123456789 Here's a random string ABCDE EFGHIJK LMNOPQ . RTSUVWXYZ, abcdefghij. Much better.But what happens in the extreme cases? A 42 letter long word,or a zero length word.Well,when tracking backwards in search of a character less than ASCii 48 if you realise that you're at the beginning of the string,at offset 0,then simply print out a fixed 40 letters.This will leave you part way through a string,whereupon you can then jump forward another 40 letters and carry on as before.In this way an 85 letter string would be split up into 2 fixed length 40 characters then a 'normal' string. By a zero length word I mean one with a carriage return only in it.These can be dealt with by performing a newline,then starting scanning again after the CR character. KNOWN PROBLEMS/FUTURE ENHANCEMENTS- No known problems HISTORY- V1.00 First version,to be added to the OS_PrettyPrint ROM for the BBC Micro DISTRIBUTION- The assembler which does the wordwrapping function is (C)1998 SPROW and must not be altered without the author's permission.You are however free to distribute any software which includes the routine,with no royalty payments,provided the above condition is met.