14 January 2021, 18:07 | #1 |
Registered User
Join Date: May 2001
Location: ?
Posts: 19,645
|
Proper way to load files during runtime?
I am now at the point of my current development where I have to load a file during runtime.
For the time being I am not bothering with fetching directories and building a requester, I just want to load, during runtime, a file that is found in the same path as the executable (a music module file). Here is how the beef of my program sort of looks like: Code:
; bunch of other stuff done before like loading and defining shapes BLITZ ; Functions I want accessed through Blitz ; GO HERE ; Create Display CreateDisplay #COPPERLIST_MAIN ; Draw the elements the first time DrawBackground {#BITMAP_BACKGROUND} RefreshScreen {True,True,True,True,True,True} ; Blitz mode stuff BlitzKeys On BlitzRepeat 50,20 Filter Off ; ------ MAIN LOOP ------ ; While Joyb(0)=0 ; Here goes my main loop code ; HERE ; main loop code end VWait Wend ; ---- MAIN LOOP END ---- ; Code:
; ------ MAIN LOOP ------ ; ; ------ MAIN LOOP ------ ; While Joyb(0)=0 ; Here goes my main loop code While timeToLoad = -1 QAmiga MyModuleLoadProcedure{"modulename.mod"} timeToLoad = 0 Blitz Wend ; main loop code end VWait Wend ; ---- MAIN LOOP END ---- ; Anyway, just really confused about the order things need to be in at this point. This is worse than Pascal :P |
14 January 2021, 20:36 | #2 | |
Registered User
Join Date: Nov 2015
Location: Vaasa, Finland
Posts: 525
|
Quote:
Therefore these days I always try to use a simple program structure that looks something like this: Code:
---Beginning--- A long gosub list for all kinds of startup operations Also gosubs to graphics loaders are here. The whole program "runs" from this beginning section, from start until end. Repeat Gosub MAINLOOP Until (ESC pressed = true) Goto ProgramEnd ; program ends here ---Starup Gosubs--- Variable initialization, Arrays and Bitmap creations, etc. ---Screen Setup--- BLITZ command is given here InitCoplist etc. ---MAINLOOP--- This too is just a long gosub list ---Mainloop Gosubs--- Game logic, Blit routines, etc. ---LOADERS--- QAMIGA command is given here. All loading operations are put under the QAMIGA. At the end of the loaders BLITZ is given again. ---Program End--- |
|
14 January 2021, 23:31 | #3 | |
Registered User
Join Date: May 2001
Location: ?
Posts: 19,645
|
Quote:
From what I see, your way to make things, makes it a bit more complicated to me order wise, because from all I read, it seems like Blitz likes to do things from the top down, and my method works this way, while yours has all the stuff after the main loop. Anyway, in my example above, basically, what I am doing, is AMIGAing right before calling a procedure that needs the system to be on, and BLITZing back after the program comes back from it. Or at least I think so. I included code like that into the thing I am working on, and it did not complain, nor crash, so I am *thinking* it worked, but I need more testing. Last edited by Amiga1992; 15 January 2021 at 00:23. |
|
14 January 2021, 23:43 | #4 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
|
Yeah, file access commands simply can't be used in Blitz, so if it appears to work, then it does Other commands are more subtle, and the issues arise when they're compiled in one position and executed in the other. Your procedure is most likely defined in Amiga mode at the top of your code, so it will contain the correct code for Amiga-mode use. QAmiga and Blitz either side of the call then just make sure the switch happens before and after, but they could equally be in the procedure itself and then wouldn't be required either side of the call.
|
14 January 2021, 23:46 | #5 | |
Registered User
Join Date: May 2001
Location: ?
Posts: 19,645
|
Quote:
Now I have a section where I do lots of things in Amiga mode, including procedure declaration, then a bunch of other stuff in Blitz mode, including procedures used during Blitz mode. Will look nice, hopefully, after I separate it in files and include it, but I don't wanna do that until I am finished because tokenization (wish this wasn't needed, I hate it) By the way That would make the procedures only work when you call them from an already established BLITZ mode. By leaving the mode switches outside of the procedure, I can call the procedure while I am already in Amiga mode without changing anything, or when I am in Blitz mode by doing the necessary switches. Last edited by Amiga1992; 14 January 2021 at 23:52. |
|
15 January 2021, 10:22 | #6 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
|
Yeah, that flexibility makes sense, fair enough
|
15 January 2021, 16:10 | #7 |
Registered User
Join Date: May 2001
Location: ?
Posts: 19,645
|
OK so now, how am I supposed to know if the file I want to load fits in memory? I rather work to do this kind of check now than have a nightmare later on.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Proper capitalization of CD files? | Pheonix | support.Apps | 2 | 13 July 2020 12:27 |
Where to find proper lha files for my tf328? | gjb1985 | support.Other | 5 | 25 November 2018 22:48 |
how much .abk files can I load simultaneously | Blackgoat | Coders. AMOS | 9 | 22 March 2016 18:45 |
Cannot load some dms files in WinUAE | anthonyhead | support.WinUAE | 18 | 31 May 2010 05:40 |
Save/Load State with HDF-Files | Frieshansen | support.WinUAE | 2 | 10 March 2007 18:09 |
|
|