Jump to content
Allas

Multistage file loading method

Recommended Posts

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

Share this post


Link to post
Share on other sites

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 by seban

Share this post


Link to post
Share on other sites
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 by drac030

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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 :cool:

Have done that with several games.

 

James

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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 by seban

Share this post


Link to post
Share on other sites

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? :D

Share this post


Link to post
Share on other sites

Hi Heaven! :D

 

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 by seban

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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 by Allas

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 by Allas

Share this post


Link to post
Share on other sites
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 by MaPa

Share this post


Link to post
Share on other sites

$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

Share this post


Link to post
Share on other sites
$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?

Share this post


Link to post
Share on other sites

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 by Rybags

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...