News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Manipulating video memory directly>?

Started by Draco9898, October 26, 2004, 10:12:11 PM

Previous topic - Next topic

Draco9898

Can you access the videos memory directly through playbasic?

I wanna try my hand at manipulating this to create fast and nice looking pixel effects...
I.E: 2d underwater effects, heat waves, screen fading, siluettes/etc...

I assume that editing the video memeory would have to be the fastest thing you can do? Should be blindingly fast if it can be done on the genesis/amiga/etc...

I love the old school stuff, it'll never come back either, lol
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

kevin

#1
QuoteCan you access the videos memory directly through playbasic?

 No, you can't grab an address and 'read/write' pixels directly.

 However all of the vector art routines in PB have effects modes built into them.  

QuoteI wanna try my hand at manipulating this to create fast and nice looking pixel effects...
I.E: 2d underwater effects, heat waves, screen fading, siluettes/etc...

I assume that editing the video memeory would have to be the fastest thing you can do? Should be blindingly fast if it can be done on the genesis/amiga/etc...

Sorry to burst your bubble, but directly manipulating video memory on the PC is virtually a waste of time, even from C / Assembly.   The main technical reason for this, is that the Video Memory on your video card, was not designed to be read from by processor.   While you can write to video memory fairly quickly, reading form it are hopelessly slow.    

The other main issue is that manipulating screen fulls of pixels individually in interpreted PB is just not going to be viable full stop.  So it is far more efficient, to try and recreate such effects with built effects, than heading down this road.

I do have a solution in mind which is 'partly' in place already, but you'll have to wait until both the next generation of the rendering engine and the new PB runtime are done.   While It's not really possible to solve this issue, at least it'll give users some options.

For example, you should be able to do things like full screen alpha blending, image fading, rotation.. this will also make all the vector ink modes faster also..  but of course the price for this functionality is the normal image rendering would be far slower... You can't have it both ways.  

All in All though, I doubt you'll see, any hands on video/image memory access, until PB is compiled to machine code.   Which is a while off yet.


 Update: This information is obsolette, modern versions of PlayBASIC support manipulating Video & FX image buffers directly.

Update:  PlayBASIC To DLL Development Blog(Convert PLayBASIC to Machine Code)



Draco9898

#2
Ouchies, so much for my idea, hehehe :huh:

I suppose the old game systems can read video memory faster than?  :(  Kinda Ironic (and sad) ....lol

Kinda strange then...think you could use Direct X to do it?   :blink:


Maybe I got the wrong idea in my head, would it be better to store your own section of memory in RAM, manipulate it, and dump this to the screen?
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

kevin

#3
QuoteOuchies, so much for my idea, hehehe  

 Some of things are doable, but not currently.  jsut like in the 8/16 days you will have to design things to suit the platform.

   
QuoteI suppose the old game systems can read video memory faster than?  Kinda Ironic (and sad) ....lol

A combination of things, one key difference to the Amiga (for example), was the  Video Memory and System Memory where shared.  They sat upon the same bus.  They don't in the PC..  Hence why modern 3D card are really a entire PC on a card.  Once data is sent to the card, the main cpu really can't access it again.   Which is the issue with Pixel effects

In the old days though, Some effects where build right into the hardware, as  most 8bit platforms used planar or chr map screen formats, combined with of raster interpret effects (copper on the amiga).  These were al cheaply done on these platforms, but  sadly these are not native to the PC.

For example, On the Amiga effects like parallax transparency (as seen in RoboCod for example)  where a mere by product the Amiga planar displays.  A trivial effect on the amiga, not so trivial on the PC, as gfx data is stored completely different.  


Also See->Palette Mapped / Raster Bars & Glenz Vectors in PlayBASIC


QuoteKinda strange then...think you could use Direct X to do it?

already does.. It's prolly possible to set up the Blitter to handle things like planar xor/and/or'ing.  Which would sort of give 'overlay' transparency effect, but the it certainly can't alpha blend the two surfaces together.

kevin

QuoteMaybe I got the wrong idea in my head, would it be better to store your own section of memory in RAM, manipulate it, and dump this to the screen?

Yes, this is what FX buffers are all about.  FX buffer are partly in place already.   This solution will remove the read video memory issue completely, but then fast blits are not an option.   So you win in some areas, and loose in others..

Moreover, you could do some effects using the blitter in video memory, but it can't do everything..

Draco9898

#5
Hmmm well that bites, hehe.... :rolleyes:

I still think it's ironic it's so hard to try to create these 2d graphic effects and its already been done on video game systems that are easily 50x  less powerful and they only have like 4 MB of RAM, lol

Maybe I should start writting games that work on a genesis emulator or something >_<
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

kevin

#6
QuoteI still think it's ironic it's so hard to try to create these 2d graphic effects and its already been done on video game systems that are easily 50x less powerful and they only have like 4 MB of RAM, lol

 yeah it's frustrating, and it always has been..  like trying to do say texture mapping on Amiga/ST etc.  Planar was neat way of doing some 2D effects, until you had to manipulate individual pixels.   Then it was hopeless...  


QuoteMaybe I should start writting games that work on a genesis emulator or something >_< 

 What hardware does the genesis use ?

Draco9898

#7
The genesis uses a shockingly slow 7  megahertz  RISC (Reduced intructions) processor!

   *  Model Number: MK-1601 (r1), MK-1631 (r2).
   * CPU: Motorola 68000 at 7.61 MHz
         o 1 MByte (8 Mbit) ROM Area
         o 64 KByte RAM Area
   * Co-Processor: Z80 @ 4 MHz (Not Present in MK-1631)
         o Controls PSG (Programmable Sound Generator) & FM Chips
         o 8 KBytes of dedicated Sound Ram
   * Graphics:
         o 64 simultaneous colors of 512 color pallete.
         o Pixel resolution: 320 x 224
         o VDP (Video Display Processor)
               + Dedicated video display processor
               + Controls playfield & sprites
               + 64 KBytes of dedicated VRAM (Video Ram)
               + 64 x 9-bits of CRAM (Color RAM)
         o 3 Planes: 2 scrolling playfields, 1 sprite plane
   * Sound:
         o PSG (TI 76489 chip)
         o FM chip (Yamaha YM 2612)
         o 6-channel stereo
         o 8 KBytes RAM
         o Signal/Noise Ratio: 14dB


Shocking isn't it? Lol....and to think such hard-to-do 2d effects are done with ease on what could seem by the specs as a outdated piece of trash :) Must be some way to do this... :ph34r:

Could you make a precalculated array that would tell the video to manipulate the pixels how you wish? that's the only thing I can think of? I'm not a real real programmer :/ Just a mere graphics freak :(
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

kevin

#8
The 680x0 and Z80 are both CISC chips.  Haven't used a Z80 is well over a decade, but have spent the bulk of the 90's using 680x0's . My favorite cpu's

One thing that we are working towards is the creation of byte code translators.  So compiled PB programs could be moved to other host platforms.  

I'm not suggesting it's possible to move all of PB to the genesis (for example), but it would be possible to build a translator that could generate code for a small subset of the PB command set.  In other words, if PB allowed for direct memory access it's highly likely  indeed, that it  be used to generate code.  Without the need of the user knowing any 68k/z80 assembly or C

Obviously in that of situation, the user have would need know the machine 'memory map' and hardware very well though.   But you could build you own wrapper fucntions in PB to make it simpler..

Draco9898

#9
hehehe I was just kidding, but that would be pretty cool, the genesis is dead, hehe, has been for like 10 years X_X

I miss the times when they made games that actually involed some type of interesting gameplay >_<
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

kevin

Yeah i know, it was just an example.

Draco9898

I'm trying to scan the net for any examples of how to do any kinda of simple 2d effects, no luck, hehehe  :blink: Guess I'll just make nice looking parallaxing backgrounds >_<
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin