****************************************************************************** #1 IN AN OCCASIONAL SERIES OF HELPFUL TUTORIALS: GETTING FONTS OF DIFFERENT SIZES INTO SCROLLERS. ****************************************************************************** Note: I only wrote this because I felt I wanted to do something which could maybe help beginners (like myself) to adjust the sizes of the fonts within the Mike Cross scroller routine. This is probably useless for anybody who`s been coding for more than a few months, but I for one find setting up fonts and the blitter, a real chore, and I can`t be the only one (or am I!): This is my first `tutorial` for the ACC disks and is being written to complement the scroller tutorial by Mike Cross. At the end of the tutorial, Mike suggested that you could try putting a 32 X 64 sized font into his scroll routine. I looked at the main code and thought to myself: `No Problem!` I was only slightly wrong! If you use the scroll routine as printed in the tutorial, it will work perfectly. (Actually I couldn`t get it to work at all and in the end for some reason, and resorted to modifying one the sources supplied!) The code is set up for any CORRECTLY SET OUT 32 pixel wide by 28 pixels deep font. I`m not sure why Mike has used this size, as every font of this type I have seen has been 32 X 32, which means a little modification to the code is necessary. The first thing you need is obviously a really flash font that nobody can read! (It makes people think your scroller is saying something interesting when really it is just the same old rubbish as every other one before it!) Next you need to load up deluxe paint, (or whatever.) The `easiest way` is to select a lo-res screen with the appropriate number of colours. Then you select `page size` from the picture menu. A requestor will pop up with the current page size showing, and you should enter `832` into `width`. Don`t bother putting you font height in as Dpaint just ignores you! Click on `OK` and Dpaint will ask you if you want the image stretched, just click `NO`, or `YES` if you want to be different, it doesn`t really make any difference. Next you should load up your font, (in IFF format of course.) For this tutorial, I`m using my personal favourite which should be somewhere on this disk under the unassuming name of `Charset4.IFF`. Load it up and you will see it on the screen. Now the fun starts! At the moment, if you try and stick this font straight into the scroller, you will not get the desired results, i.e. it won`t work! The first thing to do is make a grid, yes, thats the way I like to do it! Oh dear, I forgot to mention, you may need to have more colours on the screen than there are in the font so you can delete the grid afterwards. Sorry! (It`s only my first tutorial!) Anyway, choose a nice colour for the grid, preferably one which is not in the font, so you can see it better. Hang on a sec, I`ve just had an idea! Wait here, I`ll be right back after these messages!?!?!?........... ...........Coca Cola is it!..... .....Amiga Coders Club! The best thing since sliced bread!..... .....9 out of 10 cats said their owners prefered it!..... ....Um! sorry about that! Temporary loss of sanity! Normal service will be resumed momentarily!..... Hi there! I`m back! Did you miss me? Anyway, while you were wondering what the hell I was talking about, I was playing around with the colours in Dpaint, and came up with this idea: Just change all the colours used by your font in the palette to white, in our example that would be colours 1-7 (background=0) You then have a pure(ish) white font which is much easier to position perfectly in say a bright green grid than a font which contains more colours than the rainbow. Use one of the colour registers which is not used in the font itself, otherwise half the font will disappear when you try and delete the grid, believe me, I know! Now comes the bit where I will probably have to go into a lot of pixel perfect detail, as messing up in this section could mean having to redo everything later on! You now have to build a grid 832 X 64! Oh so you`re thinking thats no problem? Well I can tell you that you probably think it is easy, but I can never get it exactly right, OK? Each square on the grid must be EXACTLY 32 pixels wide, (or whatever width your font is). To draw this, switch `COORDS` on from the prefs window, and draw a horizontal green line, (in a blank area), 33 pixels wide. Why 33 and not 32? Well, each `vertical` line you will draw later, will only represent THE BLANK 1 PIXEL SPACE AT THE END OF EACH FONT AND NOT THE START *AND* END OF THE FONT! Got it? No? Ok: A 32 pixel wide font is only really 31 pixels wide. The extra 1 pixel at the end is there so that when you display one letter after another in the scroller, that blank line will seperate each letter. If you don`t believe me, try using a font with no blank spaces. Right, now that we`ve got that sorted, I will contine. You now have a very fetching green line, you should now zoom in to a degree where the line fills most of the zoom window, but you can still see it all. Now place the pixel ACTUALLY ON THE EXTREME LEFT OF THE LINE SO YOU CANNOT SEE THE NEW PIXEL AS IT IS HIDDEN UNDER YOUR LINE, and draw a vertical line, 33 pixels high. (If all this does not make sense, I apologise, to be quite frank, it doesn`t really make much sense to me!) You should now have an `L` shape on the screen, unless of course you are just reading this straight off the disk, without Dpaint running, in which case I`d like you to imagine a Green `L`, 33 pixels wide, and 33 pixels high, in fact, if you`re not going to bother loading dpaint, you might as well just imagine a nice, working scroller, and just forget about all this boring tutorial, and go and plant a tree somewhere!!!!! (Sorry, the typing is going to my head!) At severe risk of starting up a (major) political debate (Major. Geddit?) I`d just like to say that I whole-heartedly agree with Mike Cross`s statement that Douglas Hurd, does, in fact, have a very silly voice! (People who never read ACC7.2, should ignore this last statement, and continue with the tutorial. (Tutorial! HA! Who am I kidding! I haven`t written anything to do with this tutorial for the past.......13 or so lines!, so I think I`ll go off for a nice cold shower and a lie down in a darkened room!)) Brrr. I`m freezing now, (But sane!)...On with the tutorial! Now where was I..... OK. You have an `L` shape and you should now draw another vertical line at the other end, the same height as the last. You now have a `U` shape. Pick it up as a brush, and check it fits around one of the characters in the font. You should find the two vertical lines either side are exactly the same height as the font, (i.e. they don`t stick up over the top pixels.) You should also have a green line which lies along the bottom of the letter, If not you must type out: `I must follow Neil`s tutorials more carefully.` 400 times, send it into the disk, (And no cheating with the `Block Copy` commands in a Word Processor.) And then start reading the tutorial again! Now find a nice big, blank area, (scroll the screen to the right if you need by sticking the mouse near the right of the screen and pressing `N`. Now you need to chain a row of these `U` shapes together so that a single 1 pixel wide veritical bar appears at regular intervals by cutting it out as a brush and overlaying each vertical bar over the last so you end up with a pretty pattern, sonething like this: |_|_|_|_|_|_|_|_| The number you have is not really important, as long as you have at least two. Now comes the difficult lineing up bit: Luckily, our example is already lined up with one character every 32 pixels, but this will not always be the case so I will do it the hard way for you! First thing is to make sure you have some free space at the bottom of the screen and pick up your font and move it down so you have some blank space at the top. If you can`t move it down, then just cut out the top layer of characters and paste them to the right of the page in some blank space for now. You should now pick up your green grid, and ensure the screen is definetely as far left as it can go. (Move the mouse to the left and keep pressing `N` until you reach it. This is very important. Ok, now place your grid in the top left area of the screen, and get ready for some seriously detailed positioning: Just a quick check first, you should now have at least 32 pixels of free space in the top left area of the screen, and your row of green `U` shapes picked up as a brush. Now listen very carefully, I shall say this only once ..... Position the green brush so that it is as high up in the screen as you can get, without having the top of the brush disappearing. Now make sure the brush is as far to the left of the screen as possible, and then move it, very slowly, 1 pixel to the left so the first bar on the left of the brush JUST disappears, then make sure you are as far up as possible again, and stamp your brush down. Now wipe the sweat from your forehead, and pick up say the letter `A`, on it`s own, and move it into the very first, top-left square, (zoom in if you like,) and position it so that the far right hand side of the font is touching but not going over the right hand green line, make sure the bottom is also touching, but not going over the green line at the bottom, and stamp it down. You should now Have the letter `A` perfectly positioned in the top left hand corner of the screen. Yippee! It took us about 152 lines to do that!!!!! Now pick up `B` and put it dead central in the second square, and check it fits without going over ANY of the green lines or having anything chopped off the top. If it does lose a bit, or goes over a line, then don`t panic! Just break down crying, switch your computer off, and go downstairs to watch Neighbours! Now you should pick up a bit of that green grid you made earlier (Blue Peter again!), either from the top, or from where you stamped it down. now scroll the screen across, putting the squares in at the same regular intervals. When you can`t fit any more in, you should check there really are 26 individual boxes (one for each letter of the alphabet!) and the last one has a green line at the very last pixel. If everything is OK, you should then pat yourself on the back (harder than you think! Go on, try it!), and then start picking up each letter and then putting it in it`s proper place, you know A, B, C, D, ... X, Y, Z. NOTE: The example font, Charset4.IFF, is correctly laid out with the right number of spaces, so you can pick up, say four or five characters and stamp them all down at the smae time, but this may not be the case for all fonts. Warning: When you put the letter `T` from Charset4.IFF in a square, there will be a 2 PIXEL gap insead of one, as whoever draw this font made the `T` a bit too narrow. By now you should be thinking `At last, we`re getting somewhere`, and you should have all the letters from A-Z in their respective boxes. Now you`ve got to get the green grid once more, and make an exact duplicate of all these boxes, directly below them so you have something like this: |_|_|_|_|_|_|_|_|_|_|_|_|_|_|_| |_|_|_|_|_|_|_|_|_|_|_|_|_|_|_| <------26 BOXES PER ROW------> NOTE: When putting your extra boxes in, you should make sure the tops only just touch the bottoms of the others. (Yes, I know it sounds rude!) Now you have to put in the extra characters, if you want. Before doing this though, I have to mention that using the layout Mike described in his tutorial does not work. I have examined an ASCII table and I know it should work BUT IT JUST DOESN`T WORK (for me, anyway!) For example, putting a `$` dollar sign in the scroller text, did not Produce one, what did show up was an asterisk `*`. From working out what appeared when you entered each code, I found a new format which is as follows: ABCDEFGHIJKLMNOPQRSTUVWXYZ <-- Same as scroller tutorial. 456789 !"#$%& ()*+,-./0123 <-- My new settings! | | SPACE | SORRY! DON`T KNOW WHAT THIS IS! Note: I think these are right, but I wrote them in shorthand, in pencil on the back of a bit of paper, and it`s not that easy to decipher!!! What this means is you must put the characters in the new space allocated to them, e.g. put the number 4 in the square under `A`, etc. WARNING: THIS FORMAT MAY WELL BE WRONG! IT IS JUST ONE THAT I FOUND TO WORK WHEN I COULDN`T GET THE ONE MIKE GAVE US TO WORK! MARK, MIKE, ANYBODY, AM I DOING SOMETHING WRONG? I USED THE SOURCE FROM THE 16 COLOUR SCROLL WITHOUT ALTERING THE GETCHAR CODE! LOOKING AT IT AGAIN, I THINK YOU MUST HAVE TO ADD, OR SUBTRACT SOMETHING TO THE LINE_2 POINTER BEFORE MUTIPLYING IT BY 4, HELP? It is important to note that when putting the new characters on the second line, that you do not leave a gap between the bottom of the alphabetical characters, and the top of the extra characters, not even the green line! so if you want to fill an entire square with an extra character, you should ensure it has a gap of at least one (black) line between the bottom of the char and the green line. GOT THAT? GOOD. Just a quick mention about replacing extra characters with your own graphics. If, on the second line there are any symbols you don`t use in your scroller, you can replace these with your own graphics, (Logos, Names, Etc.) You then just enter the corresponding key in the text, and the new graphic will appear. See my scroller demo in the source section to see how it`s dene. Right, now the `fun` part: Choose the fill option from the main Dpaint control panel, and press F10 to reveal as much of the screen as possible, then place the fill gadget over a section of the green line, and press the right mouse button, and like magic, it disappears! Now scroll the screen and repeat. Keep doing this until you have got rid of every single trace of the green lines. Now you have to change all the colours back to their original state (if you changed them to white at the start.) The easiest way to do this is to load the font again (AS A BRUSH!) and select `USE BRUSH PALETTE` from the colour menu, and voila! Now get rid of the font brush by selecting a small one from the main panel, and save out your pic. Note: In the example, I used, I saved it out as a 16 colour pic, (4 bitplanes. You might want to do the same if you are following this exactly.) Now load it into your favourite IFF Converter. My personal favourite is IFFMaster, and select it`s pickup a brush section (or whatever.) Then make sure you select an area of 832 pixels wide by 64 pixels deep, and save the brush as RAW data. As a simple check you used the right size, the raw file should be 26624 bytes long if you used 4 bitplanes (16 colours), or less if you only used the proper 3 planes (probably about 19968 bytes long). If not, you should shoot yourself, or try again, whichever appeals to you the most! Now comes the fun part of this tutorial, getting that great font you`ve just done, scrolling across the screen! Except that bit will have to wait as I`ve been typing non-stop for about 4 hours, it`s 00:15 now, and I want to get up early tomorrow to finish this before the post is collected .......... Good Night! ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ Good morning! Well I failed miserably to get up early! It`s 11:15 now, and so Mark will be getting this disk a day later now! GETTING THE FONT INTO THE SOURCE: OK you have your nice raw font, and you`ve loaded Genam up. Good. Now load the `16-Colour-Scroll.s` up from wherever it is, and we`ll get started: The first thing you should do is to go down to somewhere near the bottom of the source, and replace the incbin file on the `Font` line with whatever you saved your new font as. Now find the copper list, and enter all your new colours (somehow). Then locate the command : ` dc.w $6009,$fffe,$bplcon0,$4200 ` In case you didn`t know, this command just tells the copper to wait for line $60 before opening a 4 bitplane screen. You should then see all the bitplane pointers, followed by the line: ` dc.w $7c09,$fffe,bplcon0,$0200 ` This signifies the end of our (short) screen. At the moment, this causes a 28 pixel high screen to be opened ($7c - $60 = $1c (28 decimal)) which we need to make a bit bigger for our taller font. Well, If Mikes 28 pixel high font requires a 28 pixel high screen, then what would our 32 pixel high font require? Yes, that`s right: a 64 pixel high screen! (Joke!) OK, we need a 32 pixel high screen. If your happy with the horizontal location of Mike`s scroller, then you can add 4 pixels onto the end of the screens location: $7c + 4 = $80 (128 decimal). Simply replace the $7c with the $80 and our larger screen will be brought into existance! So we now have a screen ranging from line 96 to line 128. If you like, we can change the horizontal position of the scroller by simply Changing $60 to a higher number (e.g. $b0), and adding 32 onto this number: ($b0 + 32 = $d0) so you would replace $80 in the original sequence with $d0. Don`t bother doing this if you don`t want to though! I have a confession to make at this point: I can`t work out why Mike uses a screen size of 7296 in his scroller, with a screen of 46 words wide, and 28 lines deep. Even with 4 bitplanes this only totals 5152 bytes. Why the bigger screen then Mike? That screen size seems to work fine with a bigger font, If you are trying an even bigger font, and strange things are happening, you can try increasing this number to see if it will help. I can`t tell you by how much, because I can`t figure out how Mike has worked it out! Now you have a screen of the correct height. The next thing to do is to alter the blitter sections! Oh No! Not the BLITTER!!! OK, I apologise for being a little over dramatic, it`s just that to date, most of my `experiments` with the blitter have been largely unsuccessful, but this bit is not really all that painful: First we`ll deal with the PLOP routine (Mike! Couldn`t you think of a `better` name then?) All this section does is to copy a letter from the font screen, held somewhere in the Amiga`s vast memory, to a small, hidden area, just to the right of our scroller`s screen. Luckily, we don`t really need to alter much blitter stuff here. The only thing needing changing is the BLISIZE register: The original command is: ` move.w #%0000011110 000010,bltsize(A5) ` The split in the middle is only there to show the two parts of the register. The rightmost part is the width (in 16 bit words) of your character. At the moment it is set up for a 2 word blit (32 horizontal pixels), If you need a wider scroller (64 pixels?), this is one of the things that you must change. At the moment however, it is fine for our current font. The leftmost section of bits, is the height (in lines/pixels) of our blit. At the moment it is set up for a 30 line blit. Since our font is 32 pixels high, we will have to increase this to 32. This is done as follows: ' move.w #%0000100000 000010,bltsize(a5) ` Note: The split should not be entered into your code, it is only there to help increase readablity. All this command does is copy 32 bits and 2 words (32 pixels) from the font, onto the screen. Simple, eh? Note: In the example scroller I have provided, I only use a 31 LINE BLIT EVEN THOUGH THE FONT IS 32 PIXELS HIGH! Why? Well, when I blitted the extra chars on line two onto the screen, small white dots appeared below them. I do not know why. To counter this, I simply blitted a smaller area. This also chops 1 line off the bottom of my font, but it`s not really noticeable, OK? You may not need to do this, but I did! If you intend to use a taller font, you should increase this height setting to whatever you need. Next comes the command: ` add.w #$17f8,a2 ` All this does is increase the blitter pointers so that it can loop around and do the next bitplane. To work out what you should put in here, you simply divide the total size of your raw font by the number of bitplanes used. In the example font used, I cheated and left it with 4 Bitplanes (16 colours) even though it only used 8 colours. I won`t explain why, but this means my font is 26624/4 = 6656 bytes per plane. (or $1a00 if you prefer hex notation!) So just replace #$17f8 with the new size (#$1a00 or 6656 in our example). Ahh! Here`s why Mike has used a screen of size 7296. Because he adds 1824 to each plane (4 times), and 1824 * 4 = 7296. Unless he knows something I don`t, (and in the case of programming, he knows a lot more than I do!), then this might have been used for a different sized scroller, but never changed! NEXT: The blitter screen scroll routine: The scroll routine needs to be changed in a similar was as the PLOP routine was. The original works pretty well for any scroller size, but as usual it is necessary to change the Blitsize bit again. The Original: ` move.w #%0000011110 010111,bltsize(a5) ` As usual it is split just to show which part represents blit width (right hand side), and blit height. This time the scroller blits a screen of 23 words (368 pixels). This is perfect as long as you leave the ddfstart and ddfstop settings as they are in the copper list (overscan mode). You would only need to change this if you decide that you want to use a screen of a different width (if your font is very wide and you still want it to appear in the overscan area?). The height is set to 30 lines and, of course, this should be changed to the height of your scroll (32 pixels). This is done as follows: ` move.w #$0000100000 010111,bltsize(a5) ` This will blit on a 32 pixel high screen. After this comes the familiar: ` add.w #1824,a0 ` Just do the same as before with this one, (i.e. replace 1824 with your total screen size divided by the number of planes you`re using). Right. The blitter section was pretty painless, wasn`t it? Just remember to entre whatever values are relevent for your font size. Got that? Now for the last bit: ALTERING THE CHARACTER READING ROUTINE FOR NEW FONTS: There are a couple of thing you need to change in this section. The first is to find the `Line_1` bit. All this does is discover the offset in your font for your new character. All that really concerns us here is the: ` mulu #4,d0 ` This just multiplies your letter by the number of bytes in it`s width. For example, if you have a font 64 pixels wide, you would replace that command with: ` mulu` #8,d0 ` This would skip 8 bytes (64 pixels) for each character in the font. Just remember, your font`s width should always be a multiple of 8, eg 8, 16 ,24, 32, 40, etc. You should also change the same command in `Line_2` The last thing that needs changing (as far as I can remember!), is the command: ` addi.w #3096,d0 ` Which is the number added to the font when `jumping` down to the second line, (the extra characters). This is calculated by simply dividing the total size of your font by the number of bitplanes (in the example: 26624/4 = 6656) and dividing that by two again (6656/2 = 3328). This gives you the number you should replace `3096` with. Well, looking over the source again, I think that`s about everything. Remember, all the values I`ve given you are for the blitter, etc, are only for a font of this EXACT size. Use the techniques I`ve mentioned to work out the values necessary for your`s. OK? I`d just like to say to people out there who think this tutorial is dealing with a very basic thing that even stuff like this can be very difficult and time consuming for beginners, and seeing as this disk caters for beginners and experts alike, I thought I might give some help to people who had as many problems as I did, getting new fonts into the scroll routine. I `d also like to ask that if anybody who learnt how to scroll from the tutorial does several scrollers, they should probably write their OWN scroll routine without using Mike`s source, otherwise they will be just using his scroller for every one they do, and it`s much nicer to be able to say that the code is all your own work, isn`t it. Just a little tip for anybody who has ever written a long scroll text, especially one with pauses etc, If they want to see how a certain bit near the end looks, then try testing for the right mousebutton, and if it is pressed, increase the text pointer by about 20. Then if you press, or hold down the button, it will quickly skip past all the bits at the start. Simple, but effective. Well that`s about it for this tutorial. Probably the longest thing I`ve ever typed on any computer! It`s about 25K long! I know know how Mike feels doing these things, although believe it or not, this thing is nearly 5000 words long, and the longest one Mike`s done is about 4000 (the scroller one!) And I`m only a 2 fingered typist (although I can sometimes use 4 if my fingers do what I tell them!?!?). Anyway, Mike`s are much better than mine anyway, and I tend to waffle on for quite a bit about nothing, just like I`m doing here! Well I can`t think of a really suitable ending for this so I will just say........... .........Nothing! Neil. 12/02/91. 13:37.