English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 15 November 2020, 17:33   #1
AlfaRomeo
A1200 040 SAM440EP 667
 
AlfaRomeo's Avatar
 
Join Date: Jan 2008
Location: Lisbon / Portugal
Posts: 873
AmiBlitz copy memory to file

Hello,

I tried to copy some bytes in memory to a file in disk with the blitz basic code:

Code:
  
r=OpenFile(0,"Ram:Text")
WriteMem 0,FAddress.l,FLength.l              ;copy to file 0 a memory block from FAddress with the FLength
r=WriteFile (0,"Ram:Text") : CloseFile 0    ;copy file 0 to file Ram:Text 
FreeMem_ FAddress,FLength                    ; clean memory
It didn't work, the resulting file "Ram:Text" has 0 bytes.

Any help in this is welcome because there are very few examples of WriteMem/ReadMem in the net.
AlfaRomeo is offline  
Old 15 November 2020, 18:00   #2
clenched
Registered User
 
Join Date: Sep 2008
Location: Gainesville U.S.A.
Posts: 771
Snipppet from Banshee tile map ripper. Open is not needed. Switch order of two Write commands. See if FileOutput 0 helps.
Code:
AMIGA
DefaultOutput
NPrint "saving ",Par$(1),".iff "
SaveBitmap 0,Par$(1)+".iff",0
NPrint "saving ",Par$(1),".map"
l.l=WriteFile(0,Par$(1)+".map")
FileOutput 0
WriteMem 0,ma,sz
CloseFile 0
End

Last edited by clenched; 15 November 2020 at 18:19.
clenched is offline  
Old 15 November 2020, 21:18   #3
AlfaRomeo
A1200 040 SAM440EP 667
 
AlfaRomeo's Avatar
 
Join Date: Jan 2008
Location: Lisbon / Portugal
Posts: 873
Thanks for your help clenched

already understood the dynamic of Read/Write from memory to file:
first we need to open the file with WriteFile()
then we read the block of memory with WriteMem

Code:
If WriteFile(0,"Ram:Text")
  WriteMem 0,FAddress.l,FLength.l
  NPrint "File Writed"
  CloseFile 0
EndIf
AlfaRomeo is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Easy way to copy a file? AGS Coders. System 52 16 August 2014 23:10
C++ to Assembler conversion (speedup) memory copy hack NovaCoder Coders. General 35 09 February 2010 20:37
Copy CF card file to ram:, insert other CF card, copy over? Photon support.Hardware 16 21 July 2009 22:05
Very slow file copy? DDNI support.WinUAE 4 16 March 2009 22:16
DMA memory to memory copy BlueAchenar Coders. General 14 22 January 2009 23:29

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:07.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.11766 seconds with 13 queries