Game Initialization Info

PH5

New member
Hi all. I'm trying to figure out where the game initialization ends and the start of the gameplay begins. I need to insert some code in right after the screen gets loaded and ready to go so I can set some user variable data. I thought it would be at the end of LoadScreenData.asm file, but my tests show that the game objects aren't active yet at that point. Does anyone know where that point is?
 

dale_coop

Moderator
Staff member
In the "HandleScreenLoads.asm" script (around line 178), just after those lines:
Code:
;; LOAD SCREEN DATA:	
	
	LoadScreen screenBank, currentMap, newScreen, #SCREEN_DATA_OFFSET
	;;;; if newScreen, the screen that is being loaded
	;;;; is an odd screen, it should load the right nametable, collision and attribute table.
	;;;; otherwise it should load the left.
You can insert your code.
 

PH5

New member
I tried that, but I found that it didn't do what I wanted. I found that the best place to put it was at the end of the mainasm.asm file just before JMP MainGameLoop. A word of warning to anyone who wants to do this. Obviously, you want to make a new custom module to work on if you are going to monkey with the mainasm.asm file, as you will break your other projects if you don't. Follow Joe's Creating Custom Modules video. Also, I found that the game objects where still not quite ready to go at that point in the script, at least for what I wanted to do. I had to put in some code that did the changes I needed on the 2nd loop through the main game loop, at which point everything seemed to be fully initialized.
 

dale_coop

Moderator
Staff member
Yeah, but it depends of what you want to do...
I used the handle screen loads script to initialize all my variables at the beginning of each new screens (and doing some special checks).
(Note that there is also the HandleStateChanges scrip ... for the first screen loaded, and for win screen, start screen... for every change of game state, in fact).

So, I guess your needs are very specifics.
 

PH5

New member
Yes, I was trying to get some information from the game objects on the screen after it loaded. What I did worked, but I know it was specific to my needs. Your way will certainly be best for other things.
 

dale_coop

Moderator
Staff member
If you wanted infos about the objects loaded on the screen, you right, it's not in the Handle Screen Loads (too early for what you want to do)... In fact you want the screen already loaded and all the objects already loaded... so more in the Handle Update Objects. Or as you did make your own routine HandleMyStuffs and call it from the MainASM.asm.
 
Top Bottom