|
Forum Index : Microcontroller and PC projects : Lemmings....
| Author | Message | ||||
| Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1531 |
Thank you, one of the problems to be solved is that the levels are larger than the screen. At the moment, I’m controlling the Lemmings’ behaviour by checking the PIXEL function. This won’t work if, in later levels, the Lemmings also move off-screen. One possible approach would be to store the levels simultaneously as a 1-bit (black-and-white) array and carry out the query there. However, I’m not sure whether this is a fast enough or memory-efficient solution. To support this, every lemming you click on currently (as a test) turns into a digger. If you do this on the lower level, it digs its way out of the screen, as there are no boundaries there yet. Cheers Martin Edited 2026-09-04 17:49 by Martin H. 'no comment |
||||
| Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 6090 |
Hi Martin, A quick temporary solution would be to only animate lemmings that are in view. That would make the game playable when scrolling through the level. But lemmings could "accumulate" just outside the view area. Volhout PicomiteVGA PETSCII ROBOTS |
||||
| Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 6090 |
Hi Martin, If (just if !!) you could change the display engine to work on ONE framebuffer, AND the lemmings could move in multiples of 2 pixels, there is a possible solution. 1/ everything is written on layer L, and there is NO transparency. This is the display plane. 2/ The N layer is completely covered by the L layer (and thus invisible), and contains a 1:2 copy of the world map (can be in black and white, but consumes 38k anyway). The PIXEL should be executed on N layer, with ((x+x_pan)/2, (y+y_pan)/2) as coordinate. There has to be a sub that adapts the N layer for the digger/explosions parallel to updates in the L layer. Advantage is that the N map can show clear walking paths that not necessarily are identical to the graphics on L layer (in example: the path to the exit). Lemmings could walk "in front" of objects, where they in current system they would stop and turn back. This could work for maps that are up to 640x480 with a view of 320x240. But the lemmings have to move in 2 pixel movements (-or- move in one pixel movements, but pixel checks are only performed every 2 animation steps). That is also a speed advantage. Volhout Edited 2026-09-04 19:04 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
| Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 6090 |
Hi Martin, Another solution could be to still use the F framebuffer to hold the 1:2 map, and use N and L for display. But then the heap becomes and issue, but maybe with clever management of variables it may be do-able. Maybe combine elements in the arrays, to shrink the arrays (Tilemap uses 2 bytes for x, 2 bytes for y). DIM sprt(80,8) could maybe be converted to DIM sprt(80,2) when combining parameters. One 64 bit integer could easily hold SPType (4 bits),SPx(10 bits), SPy(10bits) and SPDIR (2 bits). But maybe a 16/16/16/16 bit dividion is simpler to make decoding for. You could also save space by OPTION BASE 1 (you are not using 0 anyway). Make minimal use of strings. Regards, Volhout Edited 2026-09-04 19:50 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
| Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1531 |
Volhout So, without getting too imprecise, we could halve the number of horizontal bits in the ‘mask’. That should work. If we assume a maximum size of 640x160 (as with the NES), that would take us from 12,800 to 6,400 bytes. If we do the same for the height, that saves another half. That leaves 3,200 bytes for the Mask DIM MASK$(40)Length 40 Queries for objects outside the image could then be handled using PEEK and Bit-masking. Let’s assume that bricks in the Builder are 4x2 pixels in size and the overlap is 2 pixels; in that case, even this can be reduced. Just a thought, but one thing at a time Regarding the number of sprites: I’ve now played through loads of Lemmings levels using UAE and Dosbox, and there are rarely more than 30 Lemmings on screen at any one time. And even if there were more, only a few individual sprites would flicker, not all of them. In Sub disp_lms The background: As we are not using the framebuffer, we have to make all the changes before the image is rendered, so to speak. Options: 1. sprt(f,SPDIR) could be set to 2 instead of 1 to mark the direction to left. This saves the left shift during image build-up. 2.There is an ‘IF’ statement which checks whether the animation value is greater than 15; if so, it shifts the sprite source’s Y-coordinates down by 16. and the X -256 Let’s see if I can speed this up even more. Interactions between sprites and Layer N take place anyway. The digger is already removing sections from the ground in Layer N.The changes must, of course, then be applied to the form as well. First of all, I need to write a small programme that can create tilemaps from images of the levels. EDIT: Have a look and see if it runs any faster now Sub disp_lms Local f,srcx,srcy,lTyp,lAni,lDir,lnum,lems(snum) FRAMEBUFFER write l For f=1 To snum If sprt(f,SPTyp) Then Inc lnum:lems(lnum)=f Next FRAMEBUFFER wait CLS For n=1 To lnum f=lems(n) lTyp=sprt(f,SPTyp) ldir=sprt(f,SPDIR)<<1 srcx=ssrc(lTyp,ldir) srcy=ssrc(lTyp,ldir+1) lAni=sprt(f,SPAni)<<4 Inc srcy,16*(lAni>255):lAni=LAni Mod 256 Blit Flash 3,l, srcx+lAni,srcy,sprt(f,SPX),sprt(f,SPY),16,16,9 Next Blit flash 3,l,MsrcX+mActive,MsrcY,mx,my,16,16,9'Mouse Cursor End Sub Edited 2026-09-04 23:22 by Martin H. 'no comment |
||||
| Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 6090 |
Martin, Top display shows idle time. I do not see much improvement, running 30 lemmings in a 50ms tick. Both displ_lms are in the code. just rename the required version you want to test. Lemmings.zip Volhout Edited 2026-09-04 23:30 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
| Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1531 |
Hi Harm, Branchless loops usually run faster. So far, I’ve been using the Mouse as an indicator, as it’s the last thing to be drawn. I’ll try out your version alongside the other two. If they’re all equally fast, then I suppose that’s as good as it gets. As I said, there are rarely more than 30 Lemmings on screen at the same time. And even if there were, only a few would flicker briefly, which wouldn’t be noticeable in the horde. That’s why I wouldn’t regard that as a decisive factor.Imho still better than wasting 38k on a framebuffer Cheers and thanks Martin Edited 2026-09-04 23:46 by Martin H. 'no comment |
||||
| Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 6090 |
Martin, There is one thing I can think of that may help speed up. split up the sprt() and ssrc() 2 dimensional arrays in multiple one dimensional arrays. ldir=sprt(f,SPDIR) requires to search for 4 variablesldir=sprt_SPDIR(f) requires to search for 3 variablesNot sure how much this helps... Volhout Edited 2026-09-04 23:47 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
| Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1531 |
60 Lemmings on Picomite ![]() 'no comment |
||||
| homa Guru Joined: 05/11/2021 Location: GermanyPosts: 684 |
|
||||
| Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 6090 |
Nice, What did you do ? Clock the CPU at 378MHz ? You can clearly see that the idle time changes in steps of roughly 16ms (60Hz video FRAMEBUFFER WAIT). I was running 252MHz, since that was default for VGA video. Nice work Martin Volhjout PicomiteVGA PETSCII ROBOTS |
||||
| Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1531 |
Of course, I overclocked the Pico to 378 MHz for this test. Towards the end, you can see that the mouse cursor flickers even in the lower section, but, as mentioned earlier, this isn’t noticeable in the dense crowd of Lemmings, as only those that cannot be drawn within a single frame flicker. 'no comment |
||||
Grogster![]() Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 10034 |
Those progress demo videos are superb! I only posted this thread, mainly as a bit of fun and a laugh. I never expected anyone to actually pick up the gautlet! VERY happy that it has been, though, cos this is looking better and better all the time. Watching this thread with much interest, even if I don't comment that much. Mainly, as I know NOTHING AT ALL about writing game code, as I have never EVER written a game, so I know it is well beyond me. ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
| Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1531 |
I made this video to show that the flickering of individual lemmings in the horde goes unnoticed. The reason is… To avoid using the framebuffer, all the lemmings are drawn directly onto the layer 20 times per second. The process involves waiting for VSync, clearing the layer and redrawing ALL the lemmings before the frame reaches that position. You can tell how far the frame build-up has progressed by the flickering of the crosshairs, which are always drawn last. I’d say the Pico is fast enough.... ![]() Cheers Martin Edited 2026-09-05 18:09 by Martin H. 'no comment |
||||
| Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 6090 |
In my own demo of lemming, I originally als did a clear screen, then started drawing the lemmings. A later version I tried erasing a small box at each lemmings old position, then advancing position, then drawing the lemming at the new position. Doing so is slighty slower,but completely witbout screen flicker. PicomiteVGA PETSCII ROBOTS |
||||
| Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1531 |
Hi Harm, if you clear a rectangle around each lemming, you do run the risk of overwriting the lemmings you’ve just drawn if they’re right next to each other. When it comes to the ‘dirt’ levels, I’d definitely would use the Sega Master System levels as a template, as they’re made up of tiles. ![]() Personally, I don’t think these levels are particularly well done, but this would make it possible to use TILEMAP for all levels. Now I just need to find a way to load the tiles without taking up another flash slot. Then I can get started on creating the tilemaps. Cheers Martin 'no comment |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |