Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BINARY FILE write
#1
hey guys... I understand how to read a hex file and get the data to ram, I am just asking how can i write the file. I have included my code for reading which works great... I just need to reverse it without adding spaces or anything leading at the front and end file... 

file is a ROM image so HEX "c000: 00 78 66 34 55 67 89" .eg no address or spaces. just 4k ascii dump I want to write back 
 
Code: (Select All)
DIM SHARED c16(7, 15, 255) AS _UNSIGNED _BYTE, charload AS _UNSIGNED _BYTE, CHARACTER64 AS STRING * 1
' ----------------------------------------------------------------------------------------------------
READROM816: OPEN FILENAME$ FOR BINARY AS #1
FOR CHRDOLLAR% = 0 TO 255
FOR VERTPIXEL% = 0 TO 15
GET #1, , charload
        FOR HORIPIXEL% = 0 TO 7
IF readbit(HORIPIXEL%, charload) THEN c16(7 - HORIPIXEL%, VERTPIXEL%, CHRDOLLAR%) = 1 ELSE c16(7 - HORIPIXEL%, VERTPIXEL%, CHRDOLLAR%) = 0
NEXT
NEXT
NEXT
CLOSE #1
RETURN

WRITEROM816: OPEN FILENAME$ FOR BINARY AS #1
FOR CHRDOLLAR% = 0 TO 255
HEXCHARACTER=0
FOR VERTPIXEL% = 0 TO 15
FOR HORIPIXEL% = 0 TO 7
CHARACTER% = c16(HORIPIXEL%, VERTPIXEL%, CHRDOLLAR%)
NEXT HORIPIXEL%
??? PRINT OR PUT #1, HEX CODE HERE 'HEXCHARACTER "&H CHARACTER%"    EACH CELL IS ONE ASC(HEX 0 TO 255) SO WHEN WRITTEN IS "0A3D44FAFF" eg.
NEXT VERTPIXEL%
NEXT CHRDOLLAR%
CLOSE #1
RETURN
Do I use the 
                        put #1, with dot comma  at the end or not

    or

                         print #1 with dot comma at the end or not

also I know i need to change the above to send hex out to the file..

Thank you for any help or suggestions...
Reply


Messages In This Thread
BINARY FILE write - by pmackay - 08-24-2025, 07:01 AM
RE: BINARY FILE write - by SMcNeill - 08-24-2025, 07:35 AM
RE: BINARY FILE write - by pmackay - 08-24-2025, 08:27 AM
RE: BINARY FILE write - by pmackay - 08-24-2025, 09:54 AM
RE: BINARY FILE write - by SMcNeill - 08-24-2025, 05:18 PM
RE: BINARY FILE write - by pmackay - 08-24-2025, 07:08 PM
RE: BINARY FILE write - by dakra137 - 09-29-2025, 01:06 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question fast file find with wildcards, optional date range, match # bytes, binary compare? madscijr 8 1,293 12-19-2024, 03:55 PM
Last Post: SpriggsySpriggs
  Binary file write eoredson 9 1,563 09-26-2023, 02:25 AM
Last Post: eoredson
  Write data to EXE file Steffan-68 8 1,977 05-15-2023, 06:41 PM
Last Post: Steffan-68

Forum Jump:


Users browsing this thread: