07-03-2003, 04:35 AM
I'd say use UGL, not becuase i was part of making it. But becuase it does exactly what you're asking for. But i know how you feel about changing libs. But take a look at this, and you don't have to worry about compability. 320x200x8 with 1 page works on all video cards.
Code:
''
'' Example
''
''
defint a-z
'$include: 'ugl.bi'
const xRes = 320
const yRes = 200
const cFmt = ugl.8bit
const sprXRes = 16
const sprYRes = 16
const SPRITES = 128
dim shared hVideoDC as long
dim shared hBackBDC as long
dim shared hSpritDC( SPRITES-1 ) as long
dim i as integer
dim x as integer
dim y as integer
dim filename as string
''
'' Init UGL
''
if ( uglInit = false ) then
ExitError "0x0000, Could not init UGL..."
end if
''
'' Set video mode
''
hVideoDC = uglSetVideoDC( cFmt, xRes, yRes, 1 )
if ( hVideoDC = false ) then
ExitError "0x0001, Could not set video mod..."
end if
''
'' Allocate a DC to use as a backbuffer
'' Try to allocate it in conventional memory, if
'' that fails try ems. Should be foolproof.
''
hBackBDC = uglNew( ugl.mem, cFmt, xRes, yRes )
if ( hBackBDC = false ) then
hBackBDC = uglNew( ugl.ems, cFmt, xRes, yRes )
if ( hBackBDC = false ) then
ExitError "0x0002, Could not create a backbuffer..."
end if
end if
''
'' Allocate DCs for the sprites using the same
'' method we used for the backbuffer
''
if ( uglNewMult( hSpritDC(), SPRITES, ugl.mem, cFmt, sprXRes, sprYRes ) _
= false ) then
if ( uglNewMult( hSpritDC(), SPRITES, ugl.ems, cFmt, sprXRes, sprYRes ) _
= false ) then
ExitError "0x0003, Could not create sprite surfaces..."
end if
end if
''
'' Load sprites
''
for i = 0 to SPRITES-1
filename = "gfx\sprite" + ltrim$( str$( i ) ) + ".bmp"
if ( uglPutBMP( hSpritDC(i), 0, 0, filename ) = false ) then
ExitError "0x0004, Could not load " + filename
end if
next i
do
''
'' Blit the sprites to the backbuffer
''
for y = 0 to yRes step sprYRes
for x = 0 to xRes step sprXRes
uglPut hBackBDC, x, y, hSpritDC( x mod SPRITES )
next x
next y
''
'' Blit the backbuffer to video
''
uglPut hVideoDC, 0, 0, hBackBDC
loop until ( inkey$ <> "" )
''
'' Restore the video mode, clean up UGL and quit
''
uglRestore
uglEnd
end
oship me and i will give you lots of guurrls and beeea