3

I am new to C; I have an image file translated by means of online tools into a .h and .c file. The C file contains an array of 1024 16 bit hexadecimal numbers, used to denote on/off of bits. I want to read this file and draw the image onscreen using DMA...but I'm very much at a loss as to how to do this. Can anybody out there help? Does anyone even know what I'm talking about?

Michael Burr
  • 333,147
  • 50
  • 533
  • 760
Philip
  • 31
  • 1
  • 3
  • Just to be clear - by VBA you're talking about the "Visual Boy Advance" emulator for the Nintendo Game Boy Advance - right? I think most people here will think of VBA as "Visual Basic for Applications". – Michael Burr Apr 23 '12 at 04:06

1 Answers1

4

To draw an image onscreen, use DMA[3]. This is channel 3 of DMA for images.

This is how you set up DMA in a .h file: http://nocash.emubase.de/gbatek.htm#gbadmatransfers

And then to draw an image using DMA:

#######include image.h 

DMA[3].src = (specify your image source here, where you're drawing from)

DMA[3].dst = (where you're drawing pixels to)

In your scenario, I think you indicate the name of the file in your source.

Keep in mind you're using POINTERS to images for src and dst.

DMA[3].cnt = (how many times you want to do it) | flag1 | flag2...

Here are some flags:
DMA_SOURCE_FIXED means you draw from the same pixel over and over again. If this is what you want, then turn this bit on in cnt.
DMA_DESTINATION_FIXED applies that you're drawing TO the same pixel over and over again. If this is what you want, then turn on this bit in cnt.

Otherwise, DMA_SOURCE_INCREMENT and DMA_DESTINATION_INCREMENT are on by default (if not, you can turn them on in cnt anyway).

This is what I used for VBA, so I'm sorry if this does not answer your question (I'm kind of inexperienced with C as well...).

@Michael Yes, I mean the Visual Boy Advance

Josh Darnell
  • 11,304
  • 9
  • 38
  • 66
Yaiba
  • 41
  • 3