Bingo!
The underlying problem was in LoadSprite:
SprA(nr) = & dest 'must be the address (byref as any)
indexbase 0
include "wFunc.h"
Dim SprA(512) As Long
Dim SprW(512) As Long
Dim SprH(512) As Long
Function LoadSprite(file as string, byref dest as any, byval w as long, byval h as long) as long
'===============================================================================================
Static nr as long
Long hnd,count
hnd = CreateFile(file, GENERIC_WRITE or GENERIC_READ, FILE_SHARE_READ Or FILE_SHARE_WRITE, SYS_SEC, OPEN_ALWAYS, 0, 0)
count = GetFileSize hnd,sys_long
ReadFile hnd,dest,count,&dwcount, sys_no
CloseHandle hnd
nr +=1
SprW(nr) = w: SprH(nr) = h
SprA(nr) = & dest 'must be the address (byref as any)
Function = nr
End Function
Dim pal(64) as long
Long ix
/*
Sub Sprite(byval nr as long,byval x as long,byval y as long,byval v as long)
'===========================================================================
Long z, adr
adr = SprA(nr)
For b=0 To SprH(nr)-1
For a=0 To SprW(nr)-1
z = b*(SprW(nr)*v) + a
'iF adr(z) >0 <-- this is the original value
iF pal(z) >0 '<-- after watching, remove all pal(z)
SetPixel BackHdc,a+x,b+y,pal(z) 'adr(z) <-- this is the original value
End iF
Next: Next
End Sub
*/
Sub Sprite(byval nr as long,byval x as long,byval y as long,byval v as long)
'===========================================================================
Long a,z
dim byref adr as long
& adr = sprA(nr)
For b=0 To SprH(nr)-1
For a=0 To SprW(nr)-1
z = b*(SprW(nr)*v) + a
iF adr(z) >0 '<-- this is the original value
SetPixel BackHdc,a+x,b+y,adr(z) '<-- this is the original value
End iF
Next
Next
End Sub
OpenWindow "Test",640,480,ws_overlapped
SetFont 16,16,0,"times"
dim zahl as long
zahl=LoadSprite "logo/box.bin",pal,8,8
While WinExit=0
ClearBuffer RGB(0,0,200)
For ix=0 To 200
Sprite zahl,Rand(0,640),Rand(0,480),1
Next
Text "Frames: " + Str(ShowFrames),0,0,RGB(255,255,255)
DoEvents
FlipBuffer
Wend
WinEnd
Charles