Is it difficult to program sprite engines?

ZXNet echo conference «code.zx»

From Alexey Goncharov To All 15 December 2006

Hello Romanich Upon first acquaintance with the docks, V9990 is disgusting for a programmer. For a sprite engine, in my opinion, you also don’t need much more than two screens, blits with clipping, color key and alpha. It is best to beat pictures manually, using your own converter. Although I once met Such software lacked versatility. So cut and reduce the colors. The cycle in general should not change. And working with sprites, including collision, usually requires Z coordinates for the pieces. PS: according to http://msxbanzai.tni.nl/v9990/manual.html the chip has "VRAM WRITE" ADDRESS" and "VRAM READ ADDRESS", but of course sprites are faster =)

From Roman Dubinin To All 15 December 2006

Hello, All Greetings everyone! It's probably no secret that I made a video card based on the V9990. What the beast, I think there’s no need to explain either... In the past, I have encountered programming 2D graphics on a PC. Started with software implementation of engines, finished with acceleration of “old” video cards (STrio 64V+, Voodoo2,Vooodoo3, S3 Savage4, RivaTNT M64). Programmed naturally under DOS without using any graphics libraries. Came to the conclusion that Almost all 2D engines of the above accelerated cards contain the following: 1) Secondary surface - where sprites (bitmaps) are stored 2) Primary surface - which is displayed on the screen 3) Next comes either blitzing of surfaces (from the back surface to the first) or flipping (when surfaces drawn and displayed change places with frequency display scan) 4) BitBlt with all varieties (transparency/operations...) 5) Hardware clipping of parts of sprites (bitmaps that extend beyond the screen) 6) Raster operations during blitting and bit masks When mastering the sprite modes, the V9990 encountered difficulties - IMHO it’s inconvenient use sprites, as this, in my opinion, complicates programming graphics. In the VDP memory there is a sprite attribute table where the following are indicated: x,y - sprite, its palette index and attributes (mirror/enable/disable,...). Inconvenientwrite algorithms for the collision of two sprites, a small number of colors per one sprite, being forced to smash a large image into pieces, etc., etc... The question is this. Maybe someone who has programmed sprite (tile) modes will explain how to write programs using sprites. In particular we are interested in: 1) What is the fastest way to convert a bitmap into sprites and optimize colors when partitioning 2) How to implement sprite collision analysis 3) How to manipulate sprites to conveniently display a large image from them 4) how the main loop should be built in the program to display these sprites 5) and many other things that I did not name, but exist in nature For V9990, take into account that 1 sprite = 16x16pix, 16 colors I will be happy to listen to the advice and suggestions of programmers who used sprite graphics :)

From Roman Dubinin To All 15 December 2006

Hello NovaStorm Just in case, I’ll note that the V9990 has a 2D blitter, but it’s so slow that even the “lousy” video cards of the 90s were tens of times superior to it speed. In other words: 1) Software 2D rendering on a PC is faster than the V9990 blitter (a paradox but true) 2) 2D axel engines of PC cards DO NOT GIVE a gain in speed compared to 1). But they are drop dead easy to use (no need to make the software yourself) This is true if you write the rendering in bare asma ;)

From Nikolay Gribeshchenko To All 15 December 2006

Hello Romanich Rom> How to manipulate sprites to conveniently display a large image from them IMHO sprites are not designed to display a large image. it's clear that it's not convenient... there is such a trick, if the object is large, then it is not placed as a sprite, but as a background and then scroll, etc.

From Dmitry Malychev To All 15 December 2006

Hello, ng_dead IMHO today using all sorts of sprite engines is pure masochism. Otherwise, you should probably search the Internet for a document on the topic “How to write an amateur game on Sega" or something like that (precisely according to all sorts of techniques and standard decisions). Surely there will be something common for all sprite-tiles modes. I also didn’t find any mention of collision detection in the V9990 docs, and for some reason This fact doesn’t surprise me at all... :v2_sleep:

From Nikolay Gribeshchenko To All 15 December 2006

Hello Lethargeek Let> I also didn’t find any mention of collision detection in the V9990 docs Well then, calculating collisions manually is the only way out = a bunch of extra checks at every cycle. 2Romanych. try looking for information on the MSX forums, there are many examples with slips by algorithms.

From Nikolay Gribeshchenko To All 15 December 2006

Hello Romanich Rom> regarding the V9990 collision flag - it simply doesn’t exist Well then, we calculate collisions programmatically, but here it all depends on the type of toy and programmer skills :)

From Nikolay Gribeshchenko To All 15 December 2006

Hello Romanich Damn, did I understand correctly, v9990 does not have a sprite collision flag? or what am I missed it?

From Nikolay Gribeshchenko To All 15 December 2006

Hello new art new> Why is this flag easier than manually checking Sprite Boxes? Allows you to exclude unnecessary checks from the main loop. Instead of calculate all collisions (even if there are none!), just check the flag. if 1 Let's go to the calculation.

From Vyacheslav Kalinin To All 15 December 2006

Hello, ng_dead ng_> Damn, did I understand correctly, v9990 does not have a sprite collision flag? or me ng_> what did I miss? Why is this flag easier than manually checking Sprite Boxes? Hardware collision is useful only if it takes into account transparent pixels (collision with pixel precision). The topic is somehow very strange, on the Spectrum they wrote everything with pens and didn’t bother, but here almost everything is done by the video processor and such basic questions arise.

From Roman Dubinin To All 15 December 2006

Hello new art new> The topic is somehow very strange, on the Spectrum they wrote everything with pens and not new> were steaming, but here almost everything is done by the video percent and such things arise new> elementary questions. new> It’s not weird at all - I just didn’t work with sprites and that’s all... so please help... Regarding the collision flag V9990 - it simply doesn’t exist

From Alexey Goncharov To All 15 December 2006

Hello, Vladimir Kladov "what problems"? And there, I suppose, the number of sprites is limited, not on scanline, so in general...

From Vladimir Kladov To All 15 December 2006

Hello Romanich if sprites need to contain more than 16 colors, this is not difficult at all organize with several adjacent/overlapping sprites. And it's convenient to do separate animation of the head/legs/arms. And if there is transparency, then in general, what problems. Doubling the number of colors is elementary. And then it triples quadruples, etc. Chew?

From Robus To All 16 December 2006

Hello Romanich Rom> In the past, I came across programming 2D graphics on a PC. Started Rom> with software implementation of engines, finished with acceleration of “old” ones Rom> video cards (STrio 64V+, Voodoo2,Vooodoo3, S3 Savage4, RivaTNT Rom> M64). Programmed naturally under DOS without using any Rom> graphic libraries. Wow... I like it!!! Can you share your work or descriptions of how precisely to program these jokes. Actually, I also somehow STrio 64V+ I was poking around on this topic, but after I saw that other cards did not support accelerations, then I abandoned them. But I would be very interested to see how is all this done at a low level??? What ports, memory points... But I don’t have V9990 I have never met, or I don’t know that I have met. But if you look at it in general, then no I see special problems programming sprites. And their calculation of the collision is the same, like, simple. I just compared the coordinates with the processor, or I didn’t understand. Quarrel, what for offtopic.

From Roman Dubinin To All 16 December 2006

Hello Robus Rob> Wow... I love it!!! Can you share your work or Rob> descriptions of exactly how to program these jokes. Rob> The developments are as follows: 1) S3 Trio 64V+ 2D engine 2) S3 Savage4 2D engine (unfortunately I didn’t find any information on the 3D engine) 3) Voodoo2 2D+3D (the axel is quite difficult to program due to big initialization of everything) 4) Voodoo3 2D+3D (the complete opposite of Voodoo2 - easy ;) 5) Riva TNT M64 2D - and then only blitzing WITHOUT COLOR KEY (the most buggy hardware model of the engine - registers are not tied to anything) It was a long time ago... (2004-2005) Whatever I find reserved for CDR, I’ll post it :) The coolest program for Voodoo2 and Voodoo3 - a fully ported tunnel Jan Horn (hopefully a famous person - writes an OpenGL demo)... And note, I don’t I started tinkering with Glide and so on - and wrote a meager semblance of OpenGL Sorry for being offtopic, but I feel like people are interested!!! :) Rob> but after I saw that other cards did not support Rob> accelerations, then I abandoned them. Rob> This is the main drawback of all axels. It would be optimal to do this - in BIOS special interrupt function - we get a pointer to a structure consisting ofentry points of axel functions. Watch the challenges in blankets and everything! And fucked up is the one who says that the axel is only available in CPU protected mode, there is a flat one real (FLAT) mode - so DOS works fine on it (in 16-bit mode 32-bit memory accesses are available - and all addresses are physical, not linear as in DPMI) Rob> But I would be very interested to see how everything is at a low level Rob> is this being done??? What ports, memory points... Rob> Relatively old cards have axel registers mapped to ports - so you can get into them in real-mode :) Newer ones - registers are mapped to 32-bit memory address space. If I find the specifications in .txt, I’ll post them too... For Voodoo2/3 the PDF is enough They weigh a lot (you can find them on the Internet). I'll try to post links.

From deathsoft To All 16 December 2006

Hello Robus Rob> What ports, memory points... At one time I ordered printed documentation for S3 ViRGE (of different models), came 2 volumes (500 pages each) and 2 thin books with differences between DX2 and GX2 models, there is a detailed document about 3D with pictures and a description of all memory mapped registers

From deathsoft To All 16 December 2006

Hello Romanich Rom> we get a pointer to a structure consisting of entry points Rom> axel functions. There was a standard VBE AF (vesa bios accelerated functions), but everyone forgot about it, because dos had died by that time (it only supported 2D acceleration). From prog I only know those who support it: scitech display doctor www.scitechsoft.com (the program is still available on their ftp)

From Robus To All 18 December 2006

Hello Romanich Rom> The programs were written in TMT Pascal, run under DOS, Win98 TMT is the best thing made in PiCi from languages!!! I write EVERYTHING on it now, by the way, I have TMT 4!!! It was difficult to get!!! Please send me your achievements!!! RobusAsmoCoder@ukr.net

From Roman Dubinin To All 18 December 2006

Hello Robus Gentlemen! We've gone off topic. It’s good about PC, but something about sprites are discussed somewhat sluggishly! Come on, programmers, let’s shake some code ;)

From deathsoft To All 18 December 2006

Hello Romanich Rom> Robus, I wrote a letter to you - Mail Divelery spat out the message o Rom> unsuccessful attempt to send... Rom> There's a mistake in the soap, an extra 'o' after Asm. The soap should have been taken from the profile (I sent him BIOS sources from nvidia, everything went fine)

From Roman Dubinin To All 18 December 2006

Hello Robus Rob> TMT is the best thing done in PiCi among languages!!! I'm on it now Rob> I write EVERYTHING, by the way, I have TMT 4 !!! It was difficult to get!!! Rob> Please send me your work!!! RobusAsmoCoder@ukr.net Robus, I wrote a letter to you - Mail Divelery spat out the message about the unsuccessful trying to send... Please throw TMT4 on my soap. mail; RomanichApparate@mail.ru;

From Roman Dubinin To All 18 December 2006

Hello Romanich Here's what I promised - some of the 2D/3D engines of some cards! ATTENTION!!! The base address in some programs is taken as a constant!!! - so either use PCI INT, or look at the basic ones in the Win98 driver properties addresses (usually the first one is LFB, the second one is Graphic Engine Base Addr.) File: 2D3Dengine.rar http://zx.pk.ru/attachment.php?attachmentid=4310

From Roman Dubinin To All 20 December 2006

Hello deathsoft After analyzing, I came to the conclusion that these sprites are not so bad. After all, on The same NES, SEGA MD, SNES wrote the same games and even good ones! Just need have or acquire a “sprite mentality” in order to learn professionally use them... There are advantages to sprite hardware engines, namely: 1) There is no need to create buffers and clean them (saving time and memory) 2) Moving sprites is achieved by changing a few units of bytes, not the entire area of the image*color depth (even with hardware blitting cycles - they cannot be avoided) 3) Color key (same as DD) The only thing is to write a sprite manager correctly. Something like highlight sprites from such and such to such and such to image such and such... Is the train of thought correct or will there be gimor? :v2_conf2:

From Nikolay Gribeshchenko To All 20 December 2006

Hello Romanich Rom> The only thing is to write a sprite manager correctly. Something like Rom> select sprites from such and such to image such and such... Rom> Is the train of thought correct or will it be a gimmick? The main thing is to arrange the data correctly in memory... then there will be no hemorrhoids.

From Dmitry Malychev To All 21 December 2006

Hello Romanich All the same, most likely you will have to write different procedures for different types objects (especially if the object is composed of several sprites). With parameters - coordinates, flip, animation phase (this should be determined by the procedure itself, on whether the current sprite pointers are configured to the desired phase, and change them if necessary - because there are not enough sprites for the entire animation). A common belief is that you can get by with “changing a couple of bytes” - it's an illusion. This is true only for very simple toys. Blitting is cooler anyway. ;)

From Roman Dubinin To All 21 December 2006

Hello Lethargeek Here is the concept of a 2D engine (a game designer's dream) for matrices: File: MicroEngine2D.txt http://zx.pk.ru/attachment.php?attachmentid=4335

From Nikolay Gribeshchenko To All 21 December 2006

Hello Lethargeek Let> it is the procedure itself that should determine whether the desired phase is configured Let> current sprite pointers, and change them if necessary - Let> because there are not enough sprites for the entire animation Why put all the animation into sprites at once? number of sprites = number objects. animation phases are changed by changing the pointer to the sprite data.

From Alexey Goncharov To All 21 December 2006

Hello Romanich Judging by the structure, video memory is not mapped to the main field? If yes, then rather bad, although not fatal. Regarding color depth, it would be nice have sprites in 32 bit RGBA (or some other order) that would be absorbed and, being transformed, they would form video memory in their native format. Regarding functions... it seems to me that there is a lot of unnecessary stuff. No scrolling (same BLIT), nor Positive/negative seem to be needed. Scaling/mirroring/rotating/perverting is also kind of unnecessary, if there is enough memory it’s true =) and will it support AVR? So what remains blitting with key and alpha, and if you don’t need more, then why not iron DMA in FPGA? But if you look at everything as a whole, it turns out to be a good engine, although “old-fashioned”.

From Roman Dubinin To All 22 December 2006

Hello NovaStorm My job is to suggest... And then look... I chose the functions based on my needs and what is seen in practice. I think that effects (filters/blur/rotation/...) are needed - at least for animation or special effects (remember Super Nintend games). And in general, it’s a good idea to adapt OpenGL and Smart filters for 2D. But I don't I insist... By the way, no one has smart filtration varieties or formulas? (on high-level language). Otherwise Stepin is silent (and even his examples on ASMA are to pick uncomfortable...)

From Alexey Goncharov To All 22 December 2006

Hello Romanich http://www.ferzkopp.net/joomla/content/view/19/14/ From there SDL_rotozoom and possibly SDL_imageFilter. Been using it for a long time impressions are not fast, but high quality. PS; If; there is memory, well, its mode7, etc. Even on the GBA this is not impressive.