I am currently working on a high speed graphics .DLL routine
and was dissapointed in the results I got with PowerBasic. I
will explain my design and maybe someone can tell me if its a
design flaw, or PB compiler. The routine works, but runs slower
than Windows API.
The first step in the design is to Load Bitmaps into memory.
The system has a link lists of bitmaps that you pre-load that
can be used as textures. The current system can have a total of 40
different bitmap arrays running at the same time, each holding
variable # of bitmaps to be rendered.
The bitmaps are stored in a Type definition shown below.
Type Bitmap
picWidth as Integer
picHeight as Integer
BackGround as Integer
bmpData (128) as DWORD
End Type
The array bmpData(128) is used to hold up to 32K pages of data each.
I use the GetStrAlloc command to allocate 32K bytes of data each page
until the entire bitmap is stored.
Once the bitmap data is stored. You can declare a Set_Screen command
This command which declares a 2 dimensional array. Screen (width,height)
This represent your Windows Picture box where the render will be
finally display.
*Now, all copies are done on this Screen Array.
Function GetBMPPixel (ByVal GType%, ByVal PixX%, ByVal PixY%) EXPORT As WORD
Dim page As WORD, bytes As DWORD
Dim bmpColor as WORD PTR
page = 0
Select Case GType%
Case 0, 2
bytes = PixX% + (PixY% * @GraphicsData.Icon2D.Icon.pWidth)
Case Else
bytes = PixX% + (PixY% * @GraphicsData.Icon2D.notIcon.pWidth)
End Select
page = FIX(bytes/16000)
bytes = bytes - (page * 16000)
Select Case GType%
Case 0, 2
bmpColor = @GraphicsData.Icon2D.Icon.bmpPages(page)
Case Else
bmpColor = @GraphicsData.Icon2D.notIcon.bmpPages(page)
End Select
GetBMPPixel = @bmpColor[bytes]
End Function
This routine retrieves a pixel color from the bitmap type def.
The structure I am using hold 2 bitmaps for each structure, so maybe
its the SelectCase branch that is slowing the routine, but I don't
know.
You find a bitmap pixel, the system has to find the bitmap type
structure, calculate the page and locate the byte. I wrote a
a simple function to retrieve a bitmap pixel from the type
definition and set the appropriate Screen(x,y) location to the
new value.
Endless copies can be completed and then an UpdateScreen command
can be executed to send the final render to the PictureBox.
I have a AMDK380Mhz machine and the copy routine is much slower
than I would expect for a machine of this speed. I am using
PowerBasic 2.0 16bit compiler, but was wondering if my approach
was wrong.
------------------
Explorations v3.0 RPG Development System
http://www.explore-rpg.com
and was dissapointed in the results I got with PowerBasic. I
will explain my design and maybe someone can tell me if its a
design flaw, or PB compiler. The routine works, but runs slower
than Windows API.
The first step in the design is to Load Bitmaps into memory.
The system has a link lists of bitmaps that you pre-load that
can be used as textures. The current system can have a total of 40
different bitmap arrays running at the same time, each holding
variable # of bitmaps to be rendered.
The bitmaps are stored in a Type definition shown below.
Type Bitmap
picWidth as Integer
picHeight as Integer
BackGround as Integer
bmpData (128) as DWORD
End Type
The array bmpData(128) is used to hold up to 32K pages of data each.
I use the GetStrAlloc command to allocate 32K bytes of data each page
until the entire bitmap is stored.
Once the bitmap data is stored. You can declare a Set_Screen command
This command which declares a 2 dimensional array. Screen (width,height)
This represent your Windows Picture box where the render will be
finally display.
*Now, all copies are done on this Screen Array.
Function GetBMPPixel (ByVal GType%, ByVal PixX%, ByVal PixY%) EXPORT As WORD
Dim page As WORD, bytes As DWORD
Dim bmpColor as WORD PTR
page = 0
Select Case GType%
Case 0, 2
bytes = PixX% + (PixY% * @GraphicsData.Icon2D.Icon.pWidth)
Case Else
bytes = PixX% + (PixY% * @GraphicsData.Icon2D.notIcon.pWidth)
End Select
page = FIX(bytes/16000)
bytes = bytes - (page * 16000)
Select Case GType%
Case 0, 2
bmpColor = @GraphicsData.Icon2D.Icon.bmpPages(page)
Case Else
bmpColor = @GraphicsData.Icon2D.notIcon.bmpPages(page)
End Select
GetBMPPixel = @bmpColor[bytes]
End Function
This routine retrieves a pixel color from the bitmap type def.
The structure I am using hold 2 bitmaps for each structure, so maybe
its the SelectCase branch that is slowing the routine, but I don't
know.
You find a bitmap pixel, the system has to find the bitmap type
structure, calculate the page and locate the byte. I wrote a
a simple function to retrieve a bitmap pixel from the type
definition and set the appropriate Screen(x,y) location to the
new value.
Endless copies can be completed and then an UpdateScreen command
can be executed to send the final render to the PictureBox.
I have a AMDK380Mhz machine and the copy routine is much slower
than I would expect for a machine of this speed. I am using
PowerBasic 2.0 16bit compiler, but was wondering if my approach
was wrong.
------------------
Explorations v3.0 RPG Development System
http://www.explore-rpg.com
Comment