Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Embedding and Extracting MANY files !
#1
I am developing a conversion utility for the X16 that pipes two other conversion utilities together for the final output.

The file formats are fairly obscure (these are for the 8 bit Commander X16 platform)

The sequence is MIDI FILE --> VGM FILE --> ZSM FILE

( ZSM is currently Commander X16 only VGM is an old chiptune format used by Many arcade machines. )



I already have this setup and working as a Bash Script.   The code to do the task is relatively straight forward.  
I'm mainly writing the QB64PE shell program to increase ease of use and allow renaming of the output file.

I want to embed the utilities I depend on in the Main Executable & extract them on first run.   

I know how to do this.   The problem is that one of the utilities (mid2vgm) depends on it's own assets folder
with 130+ individual instrument files !.     

I could go through the tedium of an EMBED for each individual file.    I don't want to do this !.  I also
don't want to introduce any other dependencies for my app (such as Winzip or other !)   I want the extraction
to be handled entirely in my own code ! 

Is there a way to do this efficiently !   Has someone else ran into similiar !
Reply
#2
Seems like this has been discussed already?
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#3
(11-14-2025, 07:10 PM)bplus Wrote: Seems like this has been discussed already?


If so I would like to know where the thread is ?   There can be a bit of a needle and haystack
issue when searching through here !
Reply
#4
(11-14-2025, 05:12 PM)ahenry3068 Wrote: The file formats are fairly obscure (these are for the 8 bit Commander X16 platform)
The sequence is MIDI FILE --> VGM FILE --> ZSM FILE

If you get this working, I'd be very interested in seeing your code that parses the MIDI file, as a basis for a utility to convert from MIDI to tab-delimited text and back...
Reply
#5
(11-14-2025, 07:28 PM)madscijr Wrote:
(11-14-2025, 05:12 PM)ahenry3068 Wrote: The file formats are fairly obscure (these are for the 8 bit Commander X16 platform)
The sequence is MIDI FILE --> VGM FILE --> ZSM FILE

If you get this working, I'd be very interested in seeing your code that parses the MIDI file, as a basis for a utility to convert from MIDI to tab-delimited text and back...

  I don't want to get your hopes up.   That part is taken care of by the midi2vgm program (*that is what I'm trying to embed*)   I don't have the source for that  !

(11-14-2025, 07:28 PM)madscijr Wrote:
(11-14-2025, 05:12 PM)ahenry3068 Wrote: The file formats are fairly obscure (these are for the 8 bit Commander X16 platform)
The sequence is MIDI FILE --> VGM FILE --> ZSM FILE

If you get this working, I'd be very interested in seeing your code that parses the MIDI file, as a basis for a utility to convert from MIDI to tab-delimited text and back...

  If you have any 6502 assembly language experience the Commander X16 program MELODIUS does Midi parsing and playback.   It's source is on GitHub
The developers tag is MooingLemur.
Reply
#6
Hmm, was thinking, maybe you could make a bas program to generate all that embed code so you don't have to type it all out, then paste it in your code maybe something like:

Code: (Select All)
f$ = _Files$("filedir/*.*") 'wherever the files are located

Do While Len(f$) > 0
    Print "$EMBED:'"; f$; "','"; f$; "'"
    f$ = _Files$
Loop

If that output is valid, you could output it to a file to grab and paste in your program.  I guess you may have to come up with a better naming method for the handle name.

- Dav

Find my programs here in Dav's QB64 Corner
Reply
#7
I would go this route (if it's only one folder) to make two groups of files to be inserted (via BASE64, if it were via BASE85, move the characters two to the right to avoid quotes and not confuse the DATA command) and then when unpacking from the EXE, do it in such a way that before unpacking it, you move the string back two characters) (this complication is eliminated with BASE64) and then:

First unpack the files that don't have their own folder.
Then via QB64PE command MKDIR create a folder, switch to it with the CHDIR command and do the same as in the previous case with the second set of files. Then via CHDIR ".." you return back.


However, I am now studying @DAV's suggestion, because the resulting EXE file size would be smaller, but the condition must be met that each file must be called in the source for the compiler to include it. Then it can be written to harddrive via _WriteFile. I have never used it (Base64 yes), I will look into it.


Reply
#8
(11-14-2025, 07:33 PM)ahenry3068 Wrote: I don't want to get your hopes up.   That part is taken care of by the midi2vgm program (*that is what I'm trying to embed*)   I don't have the source for that  !
...
If you have any 6502 assembly language experience the Commander X16 program MELODIUS does Midi parsing and playback.   It's source is on GitHub
The developers tag is MooingLemur.

Thanks for explaining - no worries, I just figured it was worth asking.
I do (or rather, did) have some experience playing with 6502 assembly back in the day making little routines for games on the Commodore 64, but that's now 40 years ago, LoL. Back during Covid, I had a pet project where I made a working 6502 assembler in MS Excel. I quickly realized that programming assembly, and for the C64, was a hell of a lot more tedious than I remembered! (Actually that helped motivate me to look for an alternate programming platform for making simple PC games, which led me to QB64. Much better for my purposes!)

Anyway, thanks and good luck with your project.
Reply
#9
Code: (Select All)

$Embed:'1.avi','a'
'  file name , file handle


file$ = _Embedded$("a") '      call file from EXE
_WriteFile "1copy.avi", file$ ' save file from EXE as 1copy.avi


So you need to write a program that creates strings like this: "$Embed filename, pointer" for all files in a folder with a directory and subdirectory in the form of an array. Then you put that in the source code. I would try one subfolder with one file first...


Reply
#10
https://qb64phoenix.com/forum/showthread...0#pid36610

Oh I was remembering loading and embedding multiple image files. I don't know a file is a file, just a bunch of ones and zeros, no?
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  More info about Random Access files PhilOfPerth 28 818 02-25-2026, 01:50 PM
Last Post: ahenry3068
  program that stitches together a bunch of image files into one giant poster? madscijr 15 2,281 10-24-2024, 06:08 PM
Last Post: madscijr
  Linux HTTP WEB Server Issues - Large Files Fail old_coder 0 442 03-27-2024, 08:33 PM
Last Post: old_coder
  Making the content list of files inside a Zip ? euklides 13 2,324 02-08-2024, 03:52 PM
Last Post: euklides
  Indexed files PhilOfPerth 19 3,515 11-05-2023, 11:31 PM
Last Post: PhilOfPerth

Forum Jump:


Users browsing this thread: 1 Guest(s)