Allas #1 Posted August 7, 2008 This should be easy, but believe or not, I never saw this on the past. I want to load a game into 2 stages: - First stage load the intro, play a music and wait until you press the START key - Second stage load the main game. There is no back to the First stage. I want both stages join on a unique XEX file. What are the structure of the file that should be. Or better still, how it can be do on a MADs assembler environment? I'll appreciate any help on this topic. Thanks Quote Share this post Link to post Share on other sites
seban #2 Posted August 7, 2008 (edited) Hi! If I correctly understand your problem, solutions is very simple, and the file structure must be as follows: <intro data segments> <init address> ($2e2,$2e3) <game data segments> <run address> ($2e0,$2e1) If you have two XEX files: intro and game, the intro source must have init segment, for example you can do in this way: ; intro code org $a000 init lda #$00 sta $22f ... ... intro code here ... ... rts; here is end of intro, rerurn to the loader. org $2e2 dta a(init) org $2000 ; game code run lda #$00 sta $22f ... ... ... game code here org $2e0 dta a(run) But remember that your intro code must restore all modified interrupt vectors, and turn off the sound generators (the simple way is put zero to $d200-$d20f locations), before do the RTS opcode. with greetings Seban/SLIGHT Edited August 7, 2008 by seban Quote Share this post Link to post Share on other sites
drac030 #3 Posted August 7, 2008 (edited) This should be easy, but believe or not, I never saw this on the past. I want to load a game into 2 stages: - First stage load the intro, play a music and wait until you press the START key - Second stage load the main game. There is no back to the First stage. I want both stages join on a unique XEX file. What are the structure of the file that should be. Or better still, how it can be do on a MADs assembler environment? I'll appreciate any help on this topic. Thanks This is trivial. You run the first stage through the init vector, do all, wait for START key (just don't close any files). Once pressed, terminate with RTS. This will get it back to the loader, and it will load the second stage, which you run through the run vector. You can have as many these stages as you want. org $2000 stage1 ... your code ... wait for user input rts ;cont loading org $02e2 .word stage1 stage2 ... your code rts ;cont loading org $02e2 ;init vector .word stage2 .... stagen ... your code rts ;terminate org $02e0 ;run vector .word stagen Oooops, seban was faster Edited August 7, 2008 by drac030 Quote Share this post Link to post Share on other sites
Marius #4 Posted August 7, 2008 And what when you have only one -too big for memory- binary file? What is the assembler solution to let this too big file load in two stages? (intro and main part) Thanks M Quote Share this post Link to post Share on other sites
Heaven/TQA #5 Posted August 7, 2008 In Metagalactic Llamas I converted the main game. Then I coded the intro. After both were running ok I simply linked them together in MADS. with 2 INS instructions. Quote Share this post Link to post Share on other sites
Rybags #6 Posted August 7, 2008 You could even get tricky and have custom SIO which leaves 2 voices you can play music with while the next part loads. You can overlay segments, no problem. Just remember of course not to have any vectors left behind that rely on the previous section being there. So far as programming goes, you're probably best off developing the Stages as seperate programs altogether. Then just manually concatenate the files together to create the final module. Quote Share this post Link to post Share on other sites
sup8pdct #7 Posted August 7, 2008 This should be easy, but believe or not, I never saw this on the past. I want to load a game into 2 stages: - First stage load the intro, play a music and wait until you press the START key - Second stage load the main game. There is no back to the First stage. I want both stages join on a unique XEX file. What are the structure of the file that should be. Or better still, how it can be do on a MADs assembler environment? I'll appreciate any help on this topic. Thanks I got draconus to load from SDX and 256K ram. I simply broke droconus in to 3 bits and made several stages. First 2 load bits in to memory then hide them to ram under the roms, then load the main bulk of the program, load the bit of code that overwrites dos in lo memory then run. Very cool loading that game from a harddrive under dos control Have done that with several games. James Quote Share this post Link to post Share on other sites
[email protected] #8 Posted August 7, 2008 You could even get tricky and have custom SIO which leaves 2 voices you can play music with while the next part loads. You can overlay segments, no problem. Just remember of course not to have any vectors left behind that rely on the previous section being there. So far as programming goes, you're probably best off developing the Stages as seperate programs altogether. Then just manually concatenate the files together to create the final module. Oh, I knew this could be done, but any pointers to how you can play two voices while loading? Take Atarian care Quote Share this post Link to post Share on other sites
seban #9 Posted August 7, 2008 (edited) Hi! You need two things: 1) own SIO routines 2) ultra fast music player While POKEY do the serial transmission only two channels (merged in one 16 bit channel, to give 16-bit precise baud rate generator) are used. Next two channels is free for your use. The system SIO routines is not prepared to work correctly with any music player. But after some changes it is possible to adopt it to co-operation with simple and fast music player. But in my opinion the best solution is... write own SIO routines. How it works in real world, You can see our old production Overmind. This trackmo have own IRQ loader, and plays music all the time (while loading next parts, music player plays only 2-channel music) with greetings Seban/SLIGHT Edited August 7, 2008 by seban Quote Share this post Link to post Share on other sites
Heaven/TQA #10 Posted August 7, 2008 Cze Seban... I love Overmind. the trackloader not very often used in A8 productions which is imho simply lacking of knowledge and available (readable) sources... we have discussed here several times f.e. the digi-sio-loader in Energy Zine and I have the sources as Jaskier made them available but polish source and embedded digiplayer plus MPT player... of course optimised... not very handy for beginners... So, Seban... any chance for a MADS version of the track loader? in combination of RMT? Quote Share this post Link to post Share on other sites
seban #11 Posted August 7, 2008 (edited) Hi Heaven! You are right, there are no to much productions that use own SIO routines or IRQ loader. I don't have much free time, but if I find some free time, I try to describe how to do own SIO routines or how to write IRQ loader. The additional problem is my fatal "english" I don't write or speak very often in this language So sorry for any mistakes big greetz Heaven! Seban/SLIGHT Edited August 7, 2008 by seban Quote Share this post Link to post Share on other sites
sup8pdct #12 Posted August 7, 2008 Hi! You need two things: 1) own SIO routines 2) ultra fast music player While POKEY do the serial transmission only two channels (merged in one 16 bit channel, to give 16-bit precise baud rate generator) are used. Next two channels is free for your use. The system SIO routines is not prepared to work correctly with any music player. But after some changes it is possible to adopt it to co-operation with simple and fast music player. But in my opinion the best solution is... write own SIO routines. How it works in real world, You can see our old production Overmind. This trackmo have own IRQ loader, and plays music all the time (while loading next parts, music player plays only 2-channel music) with greetings Seban/SLIGHT Here is one way to do it. This is very much a hack. It copies the osRom (XL) to ram and changes the sio routine to enable the music to play. It is also a bootable routine. The music I stole from some educational program and removed the voices that were used for SIO. Also there is very much a lack of comments, so any questions, I may remember the answer to them boot_music_loader.txt Quote Share this post Link to post Share on other sites
Allas #13 Posted August 7, 2008 Thanks for all replies. There were very clear and instructive. Quote Share this post Link to post Share on other sites
Allas #14 Posted August 9, 2008 (edited) Another question.... I have some problem on executing a program that overpass the $C000 address memory. I set the $D301 with $FF so I expected I can write program code on $C000-$FFFF. Is there any limitation on this zone? Edited August 9, 2008 by Allas Quote Share this post Link to post Share on other sites
Heaven/TQA #15 Posted August 9, 2008 well... Allas...it depends... you need to install your "NMI"-service routine to be on the safe side. Quote Share this post Link to post Share on other sites
bob_er #16 Posted August 9, 2008 Generally, you should: 1. Turn ROM off, 2. Install your own NMI interrupt (as Heaven said), 3. Copy your code to $C000-$FFFF 4. Execute it, 5. Before last RTS and loading next part turn ROM on and restore original NMI interrupt. Quote Share this post Link to post Share on other sites
Rybags #17 Posted August 10, 2008 You shouldn't just store in $D301, you should use AND/OR to do individual bitsetting. Also, there's lots of software that doesn't work if you have BASIC enabled. Which is kinda bad considering it only takes a bit of extra effort to just disable it and set the appropriate flag to keep it disabled on warmstart. Quote Share this post Link to post Share on other sites
Allas #18 Posted August 18, 2008 In Metagalactic Llamas I converted the main game. Then I coded the intro. After both were running ok I simply linked them together in MADS. with 2 INS instructions. I tried using something like this: opt h- ins "maingame.xex" ins "introG2F.xex" opt h+ It seems easy, and the intro load, but I can't get to load the maingame module. After leave the introG2F module, there is no signs of continue loading work. Is there any hint for this? Quote Share this post Link to post Share on other sites
Rybags #19 Posted August 18, 2008 Can you run it in the emulator then hit F8 and see what the PC is? A simple debug technique is to just reserve a memory location, then store into it periodically. Have different values for different stages of the program, so when you halt it you can tell roughly what was in progress. Or, just do something simple and visual like changing the background colour. Quote Share this post Link to post Share on other sites
Allas #20 Posted August 18, 2008 (edited) I have 2 files on the same structure as G2F programs. It's necessary maingame have to load from disk after intro leaves, because both programs use the same memory to work. I guess there are some changes Heaven should do at the G2F Intro Megalactic to let the normal loading of the game. This is the common routine that G2F use to leave the program: jsr fade_out ;fade out colors mva #$00 pmcntl ;PMG disabled tax sta:rne hposp0,x+ mva #$ff portb ;ROM switch on mva #$40 nmien ;only NMI interrupts, DLI disabled cli ;IRQ enabled ;jmp ($000a) ;jump to DOS (I commented this because it's necesary to reach the RTS) rts Edited August 18, 2008 by Allas Quote Share this post Link to post Share on other sites
MaPa #21 Posted August 18, 2008 (edited) In Metagalactic Llamas I converted the main game. Then I coded the intro. After both were running ok I simply linked them together in MADS. with 2 INS instructions. I tried using something like this: opt h- ins "maingame.xex" ins "introG2F.xex" opt h+ It seems easy, and the intro load, but I can't get to load the maingame module. After leave the introG2F module, there is no signs of continue loading work. Is there any hint for this? I guess you have to remove $FF,$FF header (first two bytes of file) from introG2F.xex file and left only start address and length. Answer based on the example given, elsewhere you wrote about intro working and maingame not loading sou you maybe just switched the order of inserted files, then remove the two bytes from maingame.xex instead Edited August 18, 2008 by MaPa Quote Share this post Link to post Share on other sites
Rybags #22 Posted August 18, 2008 $FFFF on subsequent sections shouldn't matter. Any properly written binary loader should know that they are allowable, and compensate. Maybe some work variables for the loader are being overwritten? Might be an idea to check what locations are in use by loader and G2F and subsequent sections to see if that's the case. Also, you might want to try a compact binary loader like this one. Just delete the other files from the disk image and give it a go. Fairly sure it can cope with anything that loads at about $580 or above. Demo_disk_1.zip Quote Share this post Link to post Share on other sites
MaPa #23 Posted August 18, 2008 $FFFF on subsequent sections shouldn't matter. Any properly written binary loader should know that they are allowable, and compensate. So I can't load to $FFFF address? Quote Share this post Link to post Share on other sites
Rybags #24 Posted August 18, 2008 (edited) Why would you ever want to? But, in theory it's perfectly "legal". $FFFF, $FFFF, $00FF, for example would specify start address $FFFF, end address $FF. Depends how the loader's written. I just use the algorithm: GET STARTL, STARTH IF STARTL AND STARTH = 255 THEN GET STARTL, STARTH GET FINISHL, FINISHH You don't want to loop back if "STARTL, STARTH = 255" as you have the potential to keep on reading the file if e.g. there was a sequence of $FF bytes. Edited August 18, 2008 by Rybags Quote Share this post Link to post Share on other sites
MaPa #25 Posted August 18, 2008 Why would you ever want to? But, in theory it's perfectly "legal". $FFFF, $FFFF, $00FF, for example would specify start address $FFFF, end address $FF. Depends how the loader's written. I just use the algorithm: GET STARTL, STARTH IF STARTL AND STARTH = 255 THEN GET STARTL, STARTH GET FINISHL, FINISHH You don't want to loop back if "STARTL, STARTH = 255" as you have the potential to keep on reading the file if e.g. there was a sequence of $FF bytes. Hmm you can load over 64k so it loads from beggining? I'm just curious, so at end it depends on loader.. one can interpret it as header+start address $ffff and end address $00ff or just another block without header with start and end addresses both $ffff filled with byte $ff... Quote Share this post Link to post Share on other sites