Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Dma trick to flip bitmap.
2012-04-07 10:49
Flavioweb

Registered: Nov 2011
Posts: 447
Dma trick to flip bitmap.

it's possible, using some d011/18 manipulation to flip top/down a bitmap?
More in details, is possible to show, for eg, from raster line $33 to $42 as normal, then flip from $43 to $52 then show things as normal until end of screen?
If 'yes' ... How?
2012-04-07 11:18
Repose

Registered: Oct 2010
Posts: 222
No, I don't think so, the fetch address is always incrementing and it would have to be a hardware feature to decrement it.
You might try defining an upside-down charset and switch between those at the right times.
I've seen reflection effects, but I assume they were just coded.
2012-04-07 11:24
algorithm

Registered: May 2002
Posts: 702
You can do this no problem via character mode but the height would be rather limited. using d018/dd00/d011 furthermore it would require a considerable amount of gfx space

Alternatively you can wobble and stretch bitmaps/FLI etc

If you want true bitmap flipping, then opt for the software only method, however having it run every frame would be unlikely unless bitmap area is small
2012-04-07 13:12
chatGPZ

Registered: Dec 2001
Posts: 11135
it would help to know what exactly you want to do... some kind of FPP based routine could be used, for example.
2012-04-07 13:41
Flavioweb

Registered: Nov 2011
Posts: 447
Quoting Groepaz
it would help to know what exactly you want to do... some kind of FPP based routine could be used, for example.

it'quite complicated to explain and it's actually only an idea, but i need to flip a portion of bitmap moving the effect from top to bottom, leaving at least, the part over the top of effect flipped correctly.
But i can't use a totally flipped image and split screen, because i need that only the part where effect is show to be flipped. So if i flip top part, with a totally flipped img to switch i have bottom part instead top part flipped...
2012-04-07 13:57
Repose

Registered: Oct 2010
Posts: 222
I understand what you mean. You can't simply switch between two full-screen bitmaps, because you want only from Y1-Y2 to be flipped, for that part of the graphic only.
This can still be done with charsets.
In a typical arrangement, the letters

@P...{248}
AQ...{249}
BR...{250}
...
O{31}...{255}

.. etc. in a 16x16 charset bitmap.
You would have an alternate charset with flipped image data. To present the effect from Y1=8 to Y2=15, present:
@P
N{30} *Alternate charset active
BR

So, you are copying 16 bytes/row of effect, fetching the letter 15-N (you can figure out the formula, put it in a table). Then using a raster to change charsets from Y1-Y2.
If the effect moves down, slowly enough, you have to store 32 bytes/row of effect/screen. The effect is limited to mod(8) heights, however :(

You can also use a normal bitmap for most the screen, leaving the effect of size (256/40)=6 char-rows of max height for the effect area. This requires *duplicating* the image data of the bitmap, into the charsets. The area duplicated is also limited; meaning that Yn can only vary +-3 rows of some part of the graphic. For example, if the effect is 8 lines high, it could only occur over say the first 6 char-rows, unless you use even more charset memory.

You could also use line-crunching to do the 15-N idea, but with a full bitmap, but you couldn't return to normal again, because the un-flipped bitmap would now be line-crunched also.

Does the area of effect have to be completely flexible? My approach is quite limited.

Let's compare to pure data-copy. I think you have about 17,000 cycles/frame, that's time for 2100 bytes pure copy (LDA/STA), 53 lines or 6 chars! So software is actually better, if you use 100% CPU time.
2012-04-07 14:31
Flavioweb

Registered: Nov 2011
Posts: 447
i can also use 100% cpu time for the effect, because i have in mind to use this effect just as one-shot introduction for next part of routine. So no music or other things are involved.
I think that only 3/4 line height max are sufficient for my -idea-.
However i need to make this effect flowing down by 1 line at time, covering all bitmap height.
2012-04-07 15:01
Repose

Registered: Oct 2010
Posts: 222
Then that's easy,
calculation for byte in bitmap:
addr=int(y/8)*320+(y and 7)+int(x/8)*8
(int(x/8)*8=(x and 248))

base1=start addr of normal bitmap graphic data
base2=start addr of flipped bitmap
bitmap=VIC multicolor base address
x=x coordinate (not used)
y=y coordinate
You will use a table of 200*2 bytes for addr.

To flip from Y1 to Y2:

for j=(y2-y1)-1 to 0 step -1 'the height
addr_src=base2+table(199-y1-j)'flipped addr
addr_dst=bitmap+table(y+j)'bitmap addr
for i=39 to 0 step -8
poke addr_dst+i, peek(addr_src+i)
next i
next j

addr_src=base1+table(y1-1)'normal addr
addr_dst=bitmap+table(y1-1)'bitmap addr
for i=39 to 0 step -8
poke addr_dst+i, peek(addr_src+i) 'clean up line above
next i

This is valid for as long as effect is moving down. Skip 2nd part if y1=0, also ensure y2<=199 etc.

Start in top border. Requires 25k of data. You can save 4k by not storing some parts of the image where effect is not needed, ie only middle 150 lines in base1 and base2.

You do not need to keep all 25k on disk; only one bitmap (~9k) can be loaded, then copied normal and flipped, to base1 and base2.
2012-04-07 17:42
Monte Carlos

Registered: Jun 2004
Posts: 351
You can flip a bitmap without any tricks and without color clash if the mirror axis is in the middle of a character line. Maybe this could be of use for your effect.

Monte
2012-04-07 19:13
Repose

Registered: Oct 2010
Posts: 222
Oh, as far as color, you could scroly down while physically moving bitmap up, to get color split in a different line, relatively. You would have to work this through.
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Dymo/G★P
Guests online: 102
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Dawnfall V1.1  (9.5)
8 Quadrants  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Birth of a Flower  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top NTSC-Fixers
1 Pudwerx  (10)
2 Booze  (9.7)
3 Stormbringer  (9.7)
4 Fungus  (9.6)
5 Grim Reaper  (9.3)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.041 sec.