Fast Image Routine & Saving a sequence
- Posted by Ralf Nieuwenhuijsen <nieuwen at POP.XS4ALL.NL> May 27, 1997
- 700 views
####################### Faster Image Routines ####################### I have just seen the XP3 image routines and noticed that they could be a lot faster, i will start off with the VGA memory addressing. The VGA memory is 64000 bytes big, it's NOT 320*200. Remember that you needn't have to locate a pixel on screen by x & y positions, unless you really want to!! And if you do, do not calculate your pos in memory with (y*200), but make a look-up table. You should always make a look-up table in graphic-mode. Doing stuff like * and / takes more time from the CPU then using an Euphoria Pixel routine. Better not use sequences, but allocate memory space and copy pieces of memory to the VGA memory. If you want to copy more than one entire row, poke it all in once instead of poking row by row. However the you must poke an entire row, cause after the place where the row ends the new one should start! Why does 0 or 6 return 1 instead of 6 ?? and does anyone know why you can't use XOR on sequences??? It would be helpfull for sprites, the best idea would be to have mem_copy functions with OR, XOR, NOT & AND. And to have the ability to skip a number of bytes each 320 or 200 or any other specified value with a mem_copy command, (If anyone at RDS woud be so nice to include it in a new version, ask me for details about the suggestion to skip a number of values, i'll then explain it better.) If you use sprites, you must copy each horizontal line seperately, if you do so (and you must for sprites) you should start each line where the first not see-through pixel is. You can store these values in a look-up table(sequence!) . And offcourse you must end where the last not see-through pixel is, this speeds sprites with a lot of see-through pixels on the side up a lot! Also mark for each sprite if it has any see-through pixels NOT on a side. Cause if all the pixels are on the side, you needn't have to check for see-through pixels. Balls in pinball games could be draw a lot quicker that way, starting each horizontal line where the real image begins and ending each horizontal line where the real picture ends. The above sprite method is not usefull when your sprite is as width as the screen, if it is you should copy all the horizontal lines in once instead of each line seperately. You can also use sequences, then you must have a virtual screen with the background data and a virtual screen with the foreground data, each of the SAME size. Don't use a 2-dimensioned sequence, but use one long sequence, cause it uses less memory, and can be poked very quickly to the screen in once . (Only if the virtual screens have the sane width as the real screen!) The only comment on the XP3 source is that they poke each line seperately which they needn't, they can poke it all in once!! ````````````````````````````````````````````````````````````````````` ######################### Saving a sequence to disk ######################### The XP3 source also allows you to load & save multiple pictures to disk, that's handy but very restrictive. I'll write a routine which save an Euphoria sequence to disk with LZH Compression maintaining it's orgininal structure. That kind of routine can be used for a much more purposes. I will be using the same technique as i used in EDM.E ````````````````````````````````````````````````````````````````````` BTW This mail maight look really negative about your routines(XP3), but i'm not. I have much more inspiration now thanks to your routines, and your alpha version of your game looks really nice, still i would change the code the poke virtual screens (like the ones you use) in once, not row by row! And i really appriciate people sharing code like this, take for example lord generic production which problely has really nice routines, but they aren't available unless you pay them money. I know that they earn the money and they problely need it too, but it's unfair to all the people (including you) who do give their techniques away for free. He uses the font library and sound blaster routines, but do they get any of the money he earns with it?? I do not know, but i am curious, if not it would be so unfair!! (Since they do got to pay for his routines!!) I know, it was too long, i should be ashamed and your problely didn't read it all too, well that's your problem isn't it?? BTW How many dutch people are on this ?? (I know about 2) Ralf Nieuwenhuijsen nieuwen at xs4all.nl ````````````````````````````````````````````````````````````````