![]() |
![]() |
#1 |
Registered User
Join Date: Jan 2017
Location: Antwerp / Belgium
Posts: 189
|
Efficiënt loading and displaying image slices
Hey!
I'm working in system friendly C. I have some questions about loading images and displaying (parts of them) on screen. I landed on my "solution" because it was the only way I found that worked, but I have a feeling I'm doing all sorts of super inefficient things. Currently I store the images as uncompressed bitplane data in an external file. When I want to "blit" pieces on screen I know the data has to be in Chip Ram. Chipram is valuable though, and limited. So I first load them in Fast Ram at the preload stage. Then when I need them, I copy the data to Chip ram and construct a Bitmap that I can use. To "contruct the bitmap" the only way that I know how to do that, is to first setup an "image", because I can directly assign a memory pointer to the bitplanes data. Then I construct a bitmap, initiate a rastport for the bitmap, initiate all the bitplanes and then use "DrawImage" to draw the entire image on the rastport of the bitmap. Then I can free the original memory and the bitmap, keeping only the rastport (and attached bitmap) This feels super inefficient because in this process I have to hold the entire image in chipram twice for a short time. Anyone knows a way or knows an example how I can just point the .planes pointers of the bitmap directly to a memory location? That should work, no? To illustrate my current approach, I made a standalone example, available at https://github.com/steffest/amiga-c/...tToChip/main.c Any help appreciated, I'm just throwing stuff on the wall until something sticks :-) |
![]() |
![]() |
#2 |
Registered User
Join Date: Jan 2017
Location: Antwerp / Belgium
Posts: 189
|
Sometimes it helps to just to write a situation down on a forum and create an example, just to get things clear in your head.
I didn't realize yet that AllocRaster is very similar to AllocMemory and that the .planes array of the bitmap is "nothing more" then pointers to the allocated chip memory, so I can just CopyMem the data from Fast ram to those pointers. Works! en much simpeler. Reworked (better) example on https://github.com/steffest/amiga-c/...oChip/better.c |
![]() |
![]() |
#3 |
Returning fan!
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,456
|
Nice work
![]() |
![]() |
![]() |
#4 |
Registered User
Join Date: Nov 2015
Location: Perth, Australia
Posts: 73
|
I've been working on an OS friendly game and have spent some time thinking about this.
I have a data file that contains definitions for game structures - such as Items, Monsters and anything else. One of these types is an "ImageSet" - a collection of related images or animation frames. The data file is loaded into - preferably fast - memory where it can be accessed as a tree of C structs. Source graphics are processed and stored in other files as raw interleaved bitplanes. The ImageSet struct contains an embedded BitMap that initially has its planes set to NULL. The first time the game needs to render one of the frames, it will load the bitplane data into chip ram and set the plane pointers on the BitMap of the ImageSet. Then I can use BltBitMapRastPort or BltMaskBitMapRastPort to draw the frame to a RastPort. Right now, I simply load the image data into chip ram but my plan is to make the game a bit smarter and cache it in fast ram, copying it in and out of chip ram as needed. |
![]() |
![]() |
#5 | |
Registered User
Join Date: Jan 2017
Location: Antwerp / Belgium
Posts: 189
|
Quote:
Yes, that's a similar setup as what I'm aiming for. One question: does storing the data as interleaved bitplanes has any benefits? (as oposed to non interleaved) |
|
![]() |
![]() |
#6 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,659
|
Yes, interleaved bitmaps can support blitting all bitplanes in a single blit when the dimensions of the source and destination bitmaps are different (when they are the same dimensions, non-interleaved can also support single-blitting).
|
![]() |
![]() |
#7 | |
Registered User
Join Date: Nov 2015
Location: Perth, Australia
Posts: 73
|
Quote:
Yep, pretty much this. Using interleaved bitmaps can reduce the time spent setting up the blitter because it's only done once instead of for each plane. However, the trade off is that for masked blits you will need a mask the same size as the source. |
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Amiga 1200 problems, displaying only scanlines over a black image | Liam Hallows | support.Hardware | 3 | 28 November 2020 09:47 |
Most efficient way of storing x/y values over frames | mcgeezer | Coders. General | 13 | 07 October 2020 02:18 |
Questions re: Efficient blitting | earok | Coders. Blitz Basic | 11 | 01 January 2017 06:41 |
possible bug in image loading | DaveMB | support.FS-UAE | 6 | 28 October 2013 21:07 |
[REQ:ASM] Loading a static image and its palette | jman | Coders. Tutorials | 3 | 04 June 2011 14:08 |
|
|