Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
asm coding question (for an fb project)
#11
Quote:There isn't supposed to be anything there. The only pixel that was coloured is (99,99). Thanks for clearing it up for me, these routines are sooo fast.

There is no way to dereference using asm and have the function return an integer? I have a feeling that I will forget a * somewhere and spend hours pulling my hair out over it.
Code:
'asm2.bas
function point32 (byval x as integer,byval y as integer, byval memory as integer ptr) as integer
asm
mov eax, dword ptr [y]
mov ebx, eax

' multiply y by 320*4
shl eax, 10 '*1024
shl ebx, 8  '* 256
add eax, ebx

' add x*4
mov ebx, dword ptr [x]
shl ebx,2
add eax,ebx

' add the buffer offset and the size of the surface info
mov ebx,dword ptr [memory]
add eax,ebx
add eax, 4

'return
'deref eax
mov [function], eax
end asm
END function

dim memory as integer ptr
dim coladr as integer
dim col    as integer
screenres 320,200,32

screenlock
memory = screenptr
pset(99,99),&H123456
coladr=point32(99,99,memory)
coladr-=4 ' 4 bytes !!!
col=peek(integer,coladr)
screenunlock

? "color on (99,99)=";hex(col)

sleep
Why you will add 4 byte?

Joshy
sorry about my english
Reply


Messages In This Thread
asm coding question (for an fb project) - by d.j.peters - 01-30-2006, 11:02 AM
asm coding question (for an fb project) - by DrV - 01-31-2006, 03:23 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)