How to read memory ???????

Just starting out? Need help? Post your questions and find answers here.
Skipsy
User
User
Posts: 98
Joined: Wed Apr 30, 2003 12:26 pm
Location: France

How to read memory ???????

Post by Skipsy »

Damn' !!!!!!!! :x I guess I need to upgrade my brain (too)

I am having problem trying to read memory content.
I have loaded a sprite, found the memory address where it is stored
(thks to Fred) but the data I read don't match with the file dump.

Can you see what's wrong with this :

Code: Select all

If LoadSprite(0, "sprites.bmp") = 0
  MessageRequester("Problème","sprites.bmp'",0)
  End
endif
SIZE = FileSize("sprites.bmp") 
;DisplaySprite( 0, 0,100)

StartDrawing( spriteoutput( 0 ) )

ADDRESS.l = DrawingBuffer()

OpenConsole()

for ITER.l = 0 to SIZE 
  DONNEE1.b  = peekb(ADDRESS + ITER )
  printn( hex( DONNEE1 ) )
  CallDebugger
Next
Thank you guys !
Beware of the man who has the solution before he understands the problem...
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post by jack »

the hex function treats numbers as signed numbers,
perhaps this will work

Code: Select all

If LoadSprite(0, "sprites.bmp") = 0 
  MessageRequester("Problème","sprites.bmp'",0) 
  End 
endif 
SIZE = FileSize("sprites.bmp") 
;DisplaySprite( 0, 0,100) 

StartDrawing( spriteoutput( 0 ) ) 

ADDRESS.l = DrawingBuffer() 

OpenConsole() 

for ITER.l = 0 to SIZE 
  DONNEE1.b  = peekb(ADDRESS + ITER ) 
  printn( hex( DONNEE1 )&$ff ) 
  CallDebugger 
Next 
notice that i only added "&$ff" to the print hex statement.
hope this helps.
Skipsy
User
User
Posts: 98
Joined: Wed Apr 30, 2003 12:26 pm
Location: France

Post by Skipsy »

Hummmm... Same problem.

I did another test : The sprite I load is a 50x50 black image.
When I open the file with a Hexa editor I can see that it is filled with value
00 (except the BMP header of course).

The program displays data that don't exist in my file :? :?
Beware of the man who has the solution before he understands the problem...
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Sprite data isn't a rectangular area. You have to use the 'DrawingBufferPitch()' to see the length of a single pixel line. This is due because of memory alinment, to get maximum performance. Search for this word on the forum, it should have some example which show how manipulate sprite data
Skipsy
User
User
Posts: 98
Joined: Wed Apr 30, 2003 12:26 pm
Location: France

Post by Skipsy »

Oh yes, I understand sprites data is not rectangular but I don't really
mind about his form and the length of the line in the buffer... as long as
all data are contiguous :?:

Tell me if I am wrong : I have the address where the sprite data is
stored, I guess I should be able to read all data from the begining to the
end (which is "begining + buffer-length") byte after byte.

Or do you mean data could be "splitted" ?

8O
Beware of the man who has the solution before he understands the problem...
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

That's wrong. The sprite data is organized line by line:
d: data, which is the width of the sprite (and it depends of the PixelFormat)
x: boundary alinment

ddddddddddddddddddddxxxx
ddddddddddddddddddddxxxx
ddddddddddddddddddddxxxx

so to go from line 1 to line 2

*Buffer+DrawingBufferPitch()

You can't assume than the sprite width is exactly a line in video memory. It can be less, like shown above. This is why the DrawingBufferPitch() command is always needed.
Skipsy
User
User
Posts: 98
Joined: Wed Apr 30, 2003 12:26 pm
Location: France

Post by Skipsy »

OK... Too complex for what I want to do :oops:
I just want to read the full BMP, crypt it and save it.

I gonna try with 'File' and 'Memory' instructions.

Thanks all,
:wink:
Beware of the man who has the solution before he understands the problem...
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

Why don't you try reading all the data from the file, and crypting that.. then save to a new file?!?! Just an idea though...

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
Skipsy
User
User
Posts: 98
Joined: Wed Apr 30, 2003 12:26 pm
Location: France

Post by Skipsy »

I did it... (a LOT easier) and realized that it does match with I expect
to do.
To summarize : I am writing a game and spent as much time coding than
I spent creating sprites, images etc...
So I'd like to have this files not easy to chnge by anybody.

With that solution I finally have the un-crypted file on the disk. :?

I'd like now to be able to use LoadSprite() to load the crypted file and
un-crypt it in sprite memory.

I am afraid I am back to Fred suggestions :!: :!:
Beware of the man who has the solution before he understands the problem...
Post Reply