4.5.9 Script Settings Overview

This is a breakdown of all the scripts in defined in the Script Settings along with mentions of what files are included within them and what files they get included in. This is based on the Metroidvania Module, but should generally apply to all modules in most cases.

## System

### Main

* Overview: Includes Base. That’s all that is in here.
* File: Routines\BASE\_4\_5\System\MainASM.asm
* Define: SCR\_MAIN
* Includes: Base

### Header

* Overview: Data that goes at the beginning of a rom file to tell an emulator hardware information about the intended cartridge.
* File: Routines\BASE\_4\_5\System\Header.asm
* Define: SCR\_HEADER
* Included by: Base

### System Constants

* Overview: Constants are a way of giving a name to numerical values to help make code easier to read. They don’t take up space because when the game gets assembled, these names are discarded and the original numerical value is all that remains.
* File: Routines\BASE\_4\_5\System\SystemConstants.asm
* Define: SCR\_SYSTEM\_CONSTANTS
* Included by: Base
* Includes:
	+ GameData\UserDefinedConstants.asm
		- This is where the constants defined in the User Constants tab go.
	+ GameData\HUD\_BOX\_CONSTANTS.dat
		- Constants pertaining to the HUD and other Boxes’ width and height as well as constants for HUD Assets.
	+ GameData\HUD\_CONSTANTS.dat
		- Constants for which values correspond to HUD tiles. Also has masks for each of the HUD elements.

### Memory Map

* Overview: Defines how the different regions of RAM will be used. See section on Memory Map.
* File: Routines\BASE\_4\_5\System\MemoryMap.asm
* Define: SCR\_MEMORY\_MAP
* Included by: Base
* Includes:
	+ GameData/ZP\_RAM.asm
	+ GameData/Variables/UserVariables.asm
	+ System\ggsound\_ram.asm
	+ GameData/System\_RAM.asm
	+ GameData/Object\_RAM.asm

### Reset

* Overview: This is where the code of you starts. For the most part it zeroes out a lot of values and turns on some stuff. After this is complete the program moves on to Initialize.
* File: Routines\BASE\_4\_5\System\Reset.asm
* Define: SCR\_RESET
* Included by: Base

### NMI

* Overview: At the end of every frame, the main program gets interrupted by this routine. It takes care of loading all the updated graphics information to PPU to be drawn for the next frame.
* File: Routines\BASE\_4\_5\System\NMI.asm
* Define: SCR\_NMI
* Included by: Base
* Includes:
	+ Load Palettes
	+ Load Sprite Palettes
	+ Handle Update Tiles

### Assign Banks

* Overview: Similar to how the Memory Map assigns regions of RAM for various purposes, this file defines which banks all of your asm files will go to.
* File: Routines\BASE\_4\_5\System\AssignBanks.asm
* Define: SCR\_ASSIGN\_BANKS
* Included by: Base
* Includes all the Bank files (00 to 1E)

### Vectors

* Overview: The main thing that happens here is that the address for NMI and RESET (and IRQ) are kept here so the NES knows where to go when the game start (RESET) and when the end of a frame is reached (NMI).  Not really sure what the values assigned to $FFF0 to $FFF9 in this file are for.
* File: Routines\BASE\_4\_5\System\Vectors.asm
* Define: SCR\_VECTORS
* Included by: Base

### Load Subroutines

* Overview: Includes the files for various subroutines. Most of these subroutines are not defined through NESmaker’s Script Settings.  Also has a definition for a constant called DATABANK1 here for some reason.
* File: Routines\BASE\_4\_5\Game\LoadAllSubroutines.asm
* Define: SCR\_LOAD\_SUBROUTINES
* Included by: Base
* Includes from the Game\Subroutines\ folder not found in Script Settings:
	+ doBankswitchY.asm
	+ doLoadBackgroundPalette.asm
	+ doLoadObjectPalette.asm
	+ doLoadObjectSubPalette.asm
	+ doLoadChrRam.asm
	+ doLoadNametableData.asm
	+ doLoadAttributeData.asm
	+ doLoadCollisionTable.asm
	+ doCleanUpSpriteRam.asm
	+ doWaitFrame.asm
	+ doHandleBounds.asm
	+ doLoadScreen.asm
	+ doLoadScreen2.asm
	+ ToggleTables.asm
	+ ejectionSubroutines.asm
	+ doLoadScreenData.asm
	+ doLoadNametableDataFull.asm
	+ doHandleCreateState.asm
	+ doChangeActionStep.asm
	+ doGetRandomNumber.asm
	+ updateAction.asm
	+ doClearAllMonsters.asm
	+ doDrawBox.asm
	+ doDrawText.asm
	+ doDrawTilesDirect.asm
	+ doDrawVariableTiles.asm
	+ doDrawNumbers.asm
	+ doUpdateHudElement.asm
	+ doUpdateHudTiles.asm
	+ doUpdateHudVarTiles.asm
	+ doUpdateHudNumber.asm
	+ doHandleInputReads.asm
	+ doCreateObject.asm
	+ locationFinders.asm
* Includes listed under Subroutines in the Script Settings
	+ Handle Screen Update
	+ Handle Drawing Boxes
	+ Handle Objects
	+ Load Scroll Column
	+ Compare Object Boxes
	+ Handle Camera
* Includes listed under Game in the Script Settings
	+ Menu Management
* Includes listed under Behaviors in the Script Settings
	+ Update Position
	+ Start Moving
	+ Stop Moving
	+ Change Facing Direction
* Includes listed under Common in the Script Settings
	+ Handle Drawing Hud
* Odd include that I’m not sure how to categorize in my scheme thus far
	+ GameData\DataBank01\_Includes.asm
* Also includes the files for the 16 AI routines as well as the hi lo tables of pointers for the addresses of those routines.

### Math Functions

* Overview: A file dedicated for placing math functions. Default file includes functions to add and subtract values for use in the HUD.
* File: Routines\BASE\_4\_5\System\simpleMath.asm
* Define: SCR\_MATH\_FUNCTIONS
* Included by: Base

### Base

* Overview: Basically a high-level outline of definition files and what essentially becomes the content for the static bank. Not really any code in this file, just includes to other files.
* File: Routines\BASE\_4\_5\System\Base.asm
* Define: SCR\_BASE
* Included by: Main
* Includes:
	+ Header
	+ System Constants
	+ GameData\macroList.asm
		- Overview: Loads the list of macros for the assembler to reference when assembling your game.
		- See section on Macros.
	+ Memory Map
	+ Sound\ggsound.inc
	+ Assign Banks
	+ Reset
	+ Initialize
	+ NMI
	+ Main Game Loop
	+ GameData\ScriptTables.asm
	+ Math Functions
	+ Load Subroutines
	+ Vectors

### Extra SFX

* Overview: a place to put extra SFX I guess in case you are running out of room in the sound bank. While there are some labels in here, everything is commented out.
* File: Routines\BASE\_4\_5\Game\Subroutines\ExtraSFX.asm
* Define: SCR\_EXTRA\_SOUND\_EFFECTS
* Included by: Uh… doesn’t look like it’s included by anything so even if you put something in here, it won’t end up in your game.

## Banks

### Bank00 - ScreenData 0 to Bank0F - ScreenData 15

* Overview: Holds the nametable, collision, screen info, and attribute data data for all the screens. Banks 00 to 07 are the overworld screens, banks 08 to 0F are the underworld screens. Each bank contains two rows of standard screens or 1 row of “High Resolution” screens.
* File: Routines\BASE\_4\_5\System\BankData\Bank0X.asm
* Define: SCR\_BANK0X
* Included in: Assign Banks
* Includes 3 files for each XX numbered screen: ScreenData\Nametables\Screen\_Over\_XX.nam, ScreenData\CollisionTables\Screen\_Over\_XX.col, and ScreenData\AttributeTables\Screen\_Over\_XX.att. The col files also hold the screen info data.

### Bank10 - CHR bank 0

* Overview: Holds the CHR files for Background tiles 00 to 05, Screen Specific tiles 00 to 09, and Path Tiles 00 to 07.
* File: Routines\BASE\_4\_5\System\BankData\Bank10.asm
* Define: SCR\_BANK10
* Included by: Assign Banks
* Included files are located in the Graphics\Backgrounds\ folder.

### Bank11 - CHR bank 1

* Overview: Holds the CHR files for Background tiles 06 to 11, Screen Specific tiles 10 to 19, and \*Path Tiles 08 to 15.
* File: Routines\BASE\_4\_5\System\BankData\Bank11.asm
* Define: SCR\_BANK11
* Included by: Assign Banks
* Included files are located in the Graphics\Backgrounds\ folder.

### Bank12 - CHR bank 2

* Overview: Holds the CHR files for Background tiles 12 to 17, Screen Specific tiles 20 to 29, and Path Tiles 16 to 23.
* File: Routines\BASE\_4\_5\System\BankData\Bank12.asm
* Define: SCR\_BANK12
* Included by: Assign Banks
* Included files are located in the Graphics\Backgrounds\ folder.

### Bank13 - Monster CHR bank 0

* Overview: Holds the CHR files for Monster tiles 0\_00 to 0\_07
* File: Routines\BASE\_4\_5\System\BankData\Bank13.asm
* Define: SCR\_BANK13
* Included by: Assign Banks
* Included files are located in the Graphics\Sprites\ folder.

### Bank14 - Monster CHR bank 1

* Overview: Holds the CHR files for Monster tiles 1\_00 to 1\_07
* File: Routines\BASE\_4\_5\System\BankData\Bank14.asm
* Define: SCR\_BANK14
* Included by: Assign Banks
* Included files are located in the Graphics\Sprites\ folder.

### Bank15 - Game Object CHR bank

* Overview: Holds the CHR file for the GameObjectTiles.
* File: Routines\BASE\_4\_5\System\BankData\Bank15.asm
* Define: SCR\_BANK15
* Included by: Assign Banks
* Included files are located in the Graphics\Sprites\ folder.

### Bank16 - Reference Tables

* Overview: Mostly holds tables for pointers to various things like graphical information, some \*routines, and text. Also has some data for text groups, palettes, and some luts.
* File: Routines\BASE\_4\_5\System\BankData\Bank16.asm
* Define: SCR\_BANK16
* Included by: Assign Banks
* Includes:
	+ ScreenData\npcTextGroup.dat
	+ ScreenData\PaletteInfo.pal
	+ ScreenData\ObjectPals.pal
	+ GameData\ObjectStatusPointers.asm
	+ GameData\ObjectBehaviorLuts.asm

### Bank17 - Object Behaviours

* Overview: Most of the routines in the Behaviors folder in the script settings end up here.
* File: Routines\BASE\_4\_5\System\BankData\Bank17.asm
* Define: SCR\_BANK17
* Included by: Assign Banks
* Includes:
	+ Change AI Step
	+ Change Anim Step
	+ Change Attribute
	+ Change Background Palette
	+ Change Bakcground Tile
	+ Change Game State
	+ Change Game SubState
	+ Change Gravity
	+ Change Speed
	+ Change Sprite Priority
	+ Change Sprite Palette
	+ Change Background Subpalette
	+ Check Global Var
	+ Check Local Var
	+ Create Object
	+ Destroy Current Object
	+ Destroy Selected Object
	+ Draw Sprite
	+ Flip AI Bits
	+ Move Towards Object
	+ Move Towards Position
	+ No Behavior
	+ Open Box
	+ Play Music
	+ Play Sound
	+ Reverse Direction
	+ Run Code
	+ Run Subroutine
	+ Set Global Var
	+ Set Local Var
	+ Stop Sounds
	+ Update Hud
	+ Update Position

### Bank18 - Overflow Logic

* Overview: There are various routines in here. About half of them you will find in the Script Settings, but the other half are directly written into this file.
* File: Routines\BASE\_4\_5\System\BankData\Bank18.asm
* Define: SCR\_BANK18
* Different modules use different variants of this bank file.
* Included by Assign Banks
* Includes:
	+ ScreenData\ObjectData\SolidEdgeObjectReaction.dat
	+ Sprite Pre-Draw
	+ Pickup Script
	+ Sprite Post-draw
	+ Tile Collision State
	+ Handle Tile Collisions
	+ Update State
	+ Handle Object Updates
	+ Solid Reaction 1 to 7
	+ doMoveTowardsPoint.asm
	+ GameData\HUD\_UPDATES.dat
* Additional Routines:
	+ doTileObservationLogic
	+ doHandleBounds\_bank18
	+ doEraseBox\_bank18
		- Commented out
	+ doDrawHud\_bank18
	+ doUpdateHudElement\_bank18
	+ getPathInfo
		- Commented out
		- Alternate locations:
			* Game\Subroutines\doGetPathInfo.asm
			* Game\MOD\_shooter\Banks\Bank18\_shooter.asm
			* Game\MOD\_Brawlerbase\Banks\Bank18\_BralwerBase.asm
* Look Up Tables:
	+ TileTableLo and Hi
	+ octant\_adjust
	+ atan\_tab
	+ log2\_tab
	+ AngleToHVelLo
	+ AngleToHVelLo

### Bank19 - Text

* Overview: This is where text is stored.
* File: Routines\BASE\_4\_5\System\BankData\Bank19.asm
* Define: SCR\_BANK19
* Included by: Assign Banks
* Includes ScreenData\npcText01.dat

### Bank1A - Empty

* Overview: It’s empty except for an example of the new way of including additional text.
* File: Routines\BASE\_4\_5\System\BankData\Bank1A.asm
* Define: SCR\_BANK1A
* Included by: Assign Banks

### Bank1B - Music

* Overview: Holds the GGSound engine, the music and sound data that you import, and the routine for music updates that runs in the main loop.
* File: Routines\BASE\_4\_5\System\BankData\Bank1B.asm
* Define: SCR\_BANK1B
* Included by: Assign Banks
* Includes:
	+ System\ggsound.asm
	+ Sound\AllSongs\_WithSFX.asm

### Bank1C - Luts, Anim, Physics

* Overview: Object data that was set in NESmaker. Routines for handling actions, animations, and sprite drawing. Object Collisions routines, though the rest of physics are in another bank. Hurt routines.
* File: Routines\BASE\_4\_5\System\BankData\Bank1C.asm
* Define: SCR\_BANK1C
* Included by: Assign Banks
* Includes:
	+ ScreenData\ObjectInfo.dat
	+ ScreenData\ObjectPointers.pnt
	+ ScreenData\ObjectData\ObjectLutTable.dat
	+ Game\Subroutines\TimerEndScripts.asm
	+ Game\Subroutines\doObjectAction.asm
	+ Handle Drawing Sprites
	+ Handle Sprite Animation Timer
	+ Update Action Timer
	+ Object Collision State
	+ Handle Object Collisions
	+ Handle Player Hurt
	+ Handle Monster Hurt
* Look Up Tables:
	+ ObjectLoSpriteAddressLo and Hi
	+ ObjectHiSpriteAddressLo and Hi

### Bank1D - Empty

* Overview: It’s empty.
* File: Routines\BASE\_4\_5\System\BankData\Bank1D.asm
* Define: SCR\_BANK1D
* Included by: Assign Banks

### Bank1E - Extra CHR bank

* Overview: Just has the CHR file for the HUD tiles.
* File: Routines\BASE\_4\_5\System\BankData\Bank1E.asm
* Define: SCR\_BANK1E
* Included by: Assign Banks
* Includes Graphics\Backgrounds\CHR\_HudTiles.chr

## Behaviors

I think the distinction between a behavior and a subroutine is that behaviors are actually the meat of the Macros. My guess is that Joe separated this code out of the macro files is because the problem with macro is that they essentially copy and paste the code into the final build. If a macro is used several times, that means you end up with the same code duplicated all over the place and wasting space. This separation also has the added benefit of making it easier to debug with Mesen if you’ve imported the labels. It looks like some of these files are essentially blank so maybe Joe hasn’t updated all the macros he intends to yet, or it wasn’t practical to do it for every macro. The downside to having this separation is that you have to be sure you are in the correct bank in order to use the macro. It seems that all of these routines just return except for four of them. See section on Macros.

### Change AI Step

* Overview: Does nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oChangeAIstep.asm
* Define: SCR\_CHANGE\_AI\_STEP
* Included by: Bank17 - Object Behaviours

### Change Anim Step

* Overview: Does nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oChangeAnimationStep.asm
* Define: SCR\_CHANGE\_ANIMATION\_STEP
* Included by: Bank17 - Object Behaviours

### Change Attribute

* Overview: Does nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oChangeAttribute.asm
* Define: SCR\_CHANGE\_ATTRIBUTE
* Included by: Bank17 - Object Behaviours

### Change Background Palette

* Overview: Does nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oChangeBackgroundPalette.asm
* Define: SCR\_CHANGE\_BACKGROUND\_PALETTE
* Included by: Bank17 - Object Behaviours

### Change Bakcground Tile

* Note: The name is misspelled. You can correct it and it will be fine, but I kept it this way because that's how it comes by default.
* Overview: Does nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oChangeBackgroundTile.asm
* Define: SCR\_CHANGE\_BACKGROUND\_TILE
* Included by: Bank17 - Object Behaviours

### Change Facing Direction

* Overview:
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oChangeFacingDirection.asm
* Define: SCR\_CHANGE\_FACING\_DIRECTION
* Included by: Load Subroutines

### Change Game State

* Overview: Does nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oChangeGameState.asm
* Define: SCR\_CHANGE\_GAME\_STATE
* Included by: Bank17 - Object Behaviours

### Change Game SubState

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oChangeGameSubState.asm
* Define: SCR\_CHANGE\_GAME\_SUB\_STATE
* Included by: Bank17 - Object Behaviours

### Change Gravity

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oChangeGravity.asm
* Define: SCR\_CHANGE\_GRAVITY
* Included by: Bank17 - Object Behaviours

### Change Speed

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oChangeSpeed.asm
* Define: SCR\_CHANGE\_SPEED
* Included by: Bank17 - Object Behaviours

### Change Sprite Priority

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oChangeSpritePriority.asm
* Define: SCR\_CHANGE\_SPRITE\_PRIORITY
* Included by: Bank17 - Object Behaviours

### Change Sprite Palette

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oChangeSpriteSubpalette.asm
* Define: SCR\_CHANGE\_SPRITE\_PALETTE
* Included by: Bank17 - Object Behaviours

### Change Background Subpalette

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oChangeSubpalette.asm
* Define: SCR\_CHANGE\_SUBPALETTE
* Included by: Bank17 - Object Behaviours

### Check Global Var

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oCheckGlobalVariable.asm
* Define: SCR\_CHECK\_GLOBAL\_VARIABLE
* Included by: Bank17 - Object Behaviours

### Check Local Var

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oCheckLocalVariable.asm
* Define: SCR\_CHECK\_LOCAL\_VARIABLE
* Included by: Bank17 - Object Behaviours

### Create Object

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oCreateObjectAtPosition.asm
* Define: SCR\_CREATE\_OBJECT
* Included by: Bank17 - Object Behaviours

### Destroy Current Object

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oDestroyCurrentObject.asm
* Define: SCR\_DESTROY\_CURRENT\_OBJECT
* Included by: Bank17 - Object Behaviours

### Destroy Select Object

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oDestroySelectedObject.asm
* Define: SCR\_DESTROY\_SELECTED\_OBJECT
* Included by: Bank17 - Object Behaviours

### Draw Sprite

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oDrawSprite.asm
* Define: SCR\_DRAW\_SPRITE
* Included by: Bank17 - Object Behaviours

### Flip AI Bits

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oFlipAiBits.asm
* Define: SCR\_FLIP\_AI\_BITS
* Included by: Bank17 - Object Behaviours

### Move Towards Object

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oMoveTowardsObject.asm
* Define: SCR\_MOVE\_TOWARES\_POSITION
* Included by: Bank17 - Object Behaviours

### Move Towards Position

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oMoveTowardsPosition.asm
* Define: SCR\_MOVE\_TOWARDS\_OBJECT
* Included by: Bank17 - Object Behaviours

### No Behavior

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oNoBehavior.asm
* Define: SCR\_NO\_BEHAVIOR
* Included by: Bank17 - Object Behaviours

### Open Box

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oOpenBox.asm
* Define: SCR\_OPEN\_BOX
* Included by: Bank17 - Object Behaviours

### Play Music

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oPlayMusic.asm
* Define: SCR\_PLAY\_MUSIC
* Included by: Bank17 - Object Behaviours

### Play Sound

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oPlaySoundEffect.asm
* Define: SCR\_PLAY\_SFX
* Included by: Bank17 - Object Behaviours

### Reverse Direction

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oReverseDirection.asm
* Define: SCR\_REVERSE\_DIRECTION
* Included by: Bank17 - Object Behaviours

### Run Code

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oRunCode.asm
* Define: SCR\_RUN\_CODE
* Included by: Bank17 - Object Behaviours

### Run Subroutine

Overview: Does Nothing

* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oRunSubroutine.asm
* Define: SCR\_RUN\_SUBROUTINE
* Included by: Bank17 - Object Behaviours

### Set Global Var

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oSetGlobalVariable.asm
* Define: SCR\_SET\_GLOBAL\_VARIABLE
* Included by: Bank17 - Object Behaviours

### Set Local Var

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oSetLocalVariable.asm
* Define: SCR\_SET\_LOCAL\_VARIABLE
* Included by: Bank17 - Object Behaviours

### Start Moving

* Overview:
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oStartMovingInADirection.asm
* Define: SCR\_START\_MOVING
* Included by: Load Subroutines

### Stop Sounds

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oStopAllSounds.asm
* Define: SCR\_STOP\_SOUNDS
* Included by: Bank17 - Object Behaviours

### Stop Moving

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oStopMoving.asm
* Define: SCR\_STOP\_MOVING
* Included by: Load Subroutines

### Update Hud

* Overview: Does Nothing
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oUpdateHud.asm
* Define: SCR\_UPDATE\_HUD
* Included by: Bank17 - Object Behaviours

### Update Position

* Overview:
* File: Routines\BASE\_4\_5\System\ObjectBehaviors\oUpdatePosition.asm
* Define: SCR\_UPDATE\_POSITION
* Included by: Load Subroutines

## Game

### Initialize

* Overview: Runs immediately after Reset. Does initial set up. Creates the Player Object
* File: Routines\BASE\_4\_5\Game\Initialization.asm
* Define: SCR\_INITIALIZE
* Included by: Base
* Includes:
	+ ScreenData\init.ini
	+ GameData\InitializationScripts\hudVarInits.asm

### Main Game Loop

* Overview: The heart of the game. The game will loop over this code while the game is running to consistently update all the processes that make the game work. See Program Flow
* File: Routines\BASE\_4\_5\Game\MainGameLoop.asm
* Define: SCR\_MAIN\_LOOP
* Included by: Base
* Includes Handle Game Timer

### Handle Input Scripts

* Overview: This is blank by default. I guess input gets handled elsewhere. Nothing is including this define.
* File: Routines\BASE\_4\_5\Game\Subroutines\doHandleInputScripts.asm
* Define: SCR\_HANDLE\_INPUT\_SCRIPTS

### Extra Screen Load

* Overview: I think this is where you are supposed to put the code for checking screen flags.
* File: Routines\BASE\_4\_5\Game\MOD\_PlatformerBase\Game\extraScreenLoad\_PlatformBase.asm
* Define: SCR\_EXTRA\_SCREEN\_LOAD
* Included by: doLoadScreen.asm

### Post screen load

* Overview: Blank by default, but in the advanced MetroidVania tutorial it is used as a place for handling lock blocks.
* File: Routines\BASE\_4\_5\Game\Subroutines\blank.asm
* Define: SCR\_POST\_SCREEN\_LOAD
* Included by: doLoadScreen.asm

### Pickup Script

* Overview: Blank by default.
* File: Routines\BASE\_4\_5\Game\MOD\_MetroidVania\Game\pickup\_MetroidVania.asm
* Define: SCR\_PICKUP\_SCRIPTS
* Included by: Bank18 - Overflow Logic

### Sprite Pre-Draw

* Overview: Place code here to draw additional sprites before update calculations are made.
* File: Routines\BASE\_4\_5\Game\Subroutines\doSpritePreDraw.asm
* Define: SCR\_SPRITE\_PREDRAW
* Included by: Bank18 - Overflow Logic
* Includes: Handle Drawing Sprite Hud

### Sprite Post-Draw

* Overview: Place code here to draw additional sprites after update calculations are made. Blank by default.
* File: Routines\BASE\_4\_5\Game\Subroutines\doSpritePostDraw.asm
* Define: SCR\_SPRITE\_POSTDRAW
* Included by: Bank18 - Overflow Logic

### Handle Game Timer

* Overview: Place code here to handle an in game timer as demonstrated in the Arcade Platformer Advanced Tutorial. Blank by default.
* File: Routines\BASE\_4\_5\Game\Subroutines\blank.asm
* Define: SCR\_HANDLE\_GAME\_TIMER
* Included by: Main Game Loop

### Extra Tables

* Overview: I guess put extra tables here. So far there is just a hi lo table with one entry called TextLibrary. I guess this is for the extra text method using the text in Bank 1A.
* File: Routines\BASE\_4\_5\Game\MOD\_PlatformerBase\Game\ExtraTables\_PlatformerBase.asm
* Define: SCR\_TABLES
* Included by: ToggleTables.asm

### Menu Management

* Overview: My deductive reasoning skill lead me to believe this is for making menus. Blank by default
* File: Routines\BASE\_4\_5\Game\Subroutines\blank.asm
* Define: SCR\_MENU\_MANAGER
* Included by: Load Subroutines

### Tile Types

* Folder holding up to 16 tile types, see Tile Types section
* Folder: Routines\BASE\_4\_5\Game\TileScripts\
* Define: SCR\_TILE\_XX

### Common

#### Handle Player Hurt

* Overview: Code for hurting the player because there is something wrong with you.
* File: Routines\BASE\_4\_5\Game\MOD\_MetroidVania\Common\hurtPlayer\_MetroidVania.asm
* Define: SCR\_HANDLE\_PLAYER\_HURT
* Included by: Bank1C - Luts, Anim, Physics

#### Handle Monster Hurt

* Overview: Code for hurting monsters, but if you created the monsters, what does that make you?
* File: Routines\BASE\_4\_5\Game\MOD\_PlatformerBase\Common\hurtMonster\_PlatformBase.asm
* Define: SCR\_HANDLE\_MONSTER\_HURT
* Included by: Bank1C - Luts, Anim, Physics

#### Handle Drawing Hud

* Overview: Calls the routine for drawing a background HUD in Bank 18. Ultimate gets called from the macro DrawHud called in the doLoadScreen.asm routine.
* File: Routines\BASE\_4\_5\Game\Subroutines\blank.asm
* Define: SCR\_HANDLE\_HUD
* Included by: Load Subroutines
* Includes: GameData\HUD\_INCLUDES.dat

#### Handle Drawing Sprite Hud

* Overview: Where to put the sprite hud code. Blank by default.
* File: Routines\BASE\_4\_5\Game\MOD\_MetroidVania\Common\doDrawSpriteHud\_metroidvania.asm
* Define: SCR\_DRAW\_SPRITE\_HUD
* Included by: Sprite Pre-Draw

### AI Behaviors

* Folder holding up to 16 AI behaviours, see AI Behaviors section
* Folder: Routines\BASE\_4\_5\Game\Subroutines\
* Define: SCR\_AI\_X
* AI\_edge\_reactions
	+ Folder holding up to 8 Edge Reactions, see Reactions section
* AI\_Solid\_reactions
	+ Folder holding up to 8 Solid Reactions, see Reactions section

## SubRoutines

### Handle Physics

* Overview: Handles physics.
* File: Routines\BASE\_4\_5\Game\MOD\_PlatformerBase\Subroutines\doHandlePhysics\_PlatformBase.asm
* Define: SCR\_HANDLE\_PHYSICS
* Included by: Handle Objects

### Handle Camera

* Overview:
* File: Routines\BASE\_4\_5\Game\MOD\_MetroidVania\Subroutines\doUpdateCamera.asm
* Define: SCR\_HANDLE\_CAMERA
* Included by: Load Subroutines

### Handle Drawing Sprites

* Overview:
* File: Routines\BASE\_4\_5\Game\MOD\_PlatformerBase\Subroutines\doDrawSprites\_PlatformBase.asm
* Define: SCR\_HANDLE\_DRAWING\_SPRITES
* Included by: Bank1C - Luts, Anim, Physics
* Includes:

### Handle Objects

* Overview:
* File: Routines\BASE\_4\_5\Game\Subroutines\doHandleObjects\_withinCamera.asm
* Define: SCR\_HANDLE\_OBJECTS
* Included by: Load Subroutines
* Includes:
	+ Destroy State
	+ Create State
	+ Input State
	+ Handle Physics
	+ Draw State

### Handle Object Updates

* Overview:
* File: Routines\BASE\_4\_5\Game\Subroutines\doHandleUpdateObjects.asm
* Define: SCR\_HANDLE\_OBJECT\_UPDATE
* Included by: Bank18 - Overflow Logic

### Handle Tile Collisions

* Overview:
* File: Routines\BASE\_4\_5\Game\MOD\_PlatformerBase\Subroutines\doHandleTileCollisions\_PlatformBase.asm
* Define: SCR\_HANDLE\_TILE\_COLLISIONS
* Included by: Bank18 - Overflow Logic

### Handle Object Collisions

* Overview:
* File: Routines\BASE\_4\_5\Game\MOD\_PlatformerBase\Subroutines\doHandleObjectCollisions\_PlatformerBase.asm
* Define: SCR\_HANDLE\_OBJECT\_COLLISIONS
* Included by: Bank1C - Luts, Anim, Physics
* Includes: Pickup Script

### Load Palettes

* Overview:
* File: Routines\BASE\_4\_5\Game\DataLoadScripts\LoadBackgroundPalettes\_NMI.asm
* Define: SCR\_LOAD\_PALETTES
* Included by: NMI

### Load Sprite Palettes

* Overview:
* File: Routines\BASE\_4\_5\Game\DataLoadScripts\LoadSpritePalettes\_NMI.asm
* Define: SCR\_LOAD\_SPRITE\_PALETTES
* Included by: NMI

### Create State

* Overview: Retrieves object health data and stores it in the current object.
* File: Routines\BASE\_4\_5\Game\MOD\_PlatformerBase\Subroutines\doCreateState\_addExtraVariables\_PlatformBase.asm
* Define: SCR\_CREATE\_STATE
* Included by: Handle Objects

### Input State

* Overview: Does nothing
* File: Routines\BASE\_4\_5\Game\Subroutines\doInputState.asm
* Define: SCR\_INPUT\_STATE
* Included by: Handle Objects

### Update State

* Overview: Does nothing
* File: Routines\BASE\_4\_5\Game\Subroutines\doUpdateState.asm
* Define: SCR\_UPDATE\_STATE
* Included by: Bank18 - Overflow Logic

### Draw State

* Overview: Does nothing
* File: Routines\BASE\_4\_5\Game\Subroutines\doDrawState.asm
* Define: SCR\_DRAW\_STATE
* Included by: Handle Objects

### Tile Collision State

* Overview: Does nothing
* File: Routines\BASE\_4\_5\Game\Subroutines\doTileCollisionState.asm
* Define: SCR\_TILE\_COLLISION\_STATE
* Included by: Bank18 - Overflow Logic

### Object Collision State

* Overview: Does nothing
* File: Routines\BASE\_4\_5\Game\Subroutines\doObjectCollisionState.asm
* Define: SCR\_OBJECT\_COLLISION\_STATE
* Included by: Bank1C - Luts, Anim, Physics

### Bounds

* Overview: Does nothing
* File: Routines\BASE\_4\_5\Game\Subroutines\doBoundsState.asm
* Define: SCR\_BOUNDS\_STATE
* Included by: Commented out in Handle Objects

### Timer

* Overview: Does nothing
* File: Routines\BASE\_4\_5\Game\Subroutines\doTimerState.asm
* Define: SCR\_TIMER\_STATE
* Included by: Commented out in Handle Objects

### Destroy State

* Overview: Does nothing
* File: Routines\BASE\_4\_5\Game\Subroutines\doDestroyState.asm
* Define: SCR\_DESTROY\_STATE
* Included by: Handle Objects

### Handle Sprite Animation Timer

* Overview: “Check to see if this object in this state animates. If the animation speed is zero, it does not animate.”
* File: Routines\BASE\_4\_5\Game\Subroutines\doUpdateSpriteTimer.asm
* Define: SCR\_UPDATE\_SPRITE\_TIMER
* Included by: Bank1C - Luts, Anim, Physics

### Handle H Scroll

* Overview: Does nothing
* File: Routines\BASE\_4\_5\Game\Subroutines\blank.asm
* Define: SCR\_HANDLE\_H\_SCROLL
* Included by: Commented out in Handle Objects

### Load Scroll Column

* Overview: Does nothing
* File: Routines\BASE\_4\_5\Game\Subroutines\blank.asm
* Define: SCR\_LOAD\_SCROLL\_COLUMN
* Included by: Load Subroutines

### Handle Update Tiles

* Overview: NMI loading of column of scroll tiles. “This routine will spread over two frames. The offset for where in the column is being drawn will be held in scrollOffsetCounter. It will load 32 (#$20) tiles per frame, but not quite, because the screen is only 240 px high. So there are 3 reads per tile, 12 per metatile...12x15 rows = 180.”
* File: Routines\BASE\_4\_5\Game\Subroutines\doUpdateScrollColumn.asm
* Define: SCR\_UPDATE\_SCROLL\_COLUMN
* Included by: NMI

### Handle V Scroll

* Overview: Does nothing
* File: Routines\BASE\_4\_5\Game\Subroutines\blank.asm
* Define: SCR\_HANDLE\_V\_SCROLL
* Included by: Commented out in Handle Objects

### Handle Screen Update

* Overview:
* File: Routines\BASE\_4\_5\Game\Subroutines\doHandleUpdateScreen.asm
* Define: SCR\_HANDLE\_SCREEN\_UPDATE
* Included by: Load Subroutines

### Update Action Timer

* Overview:
* File: Routines\BASE\_4\_5\Game\Subroutines\doUpdateActionTimer.asm
* Define: SCR\_UPDATE\_ACTION\_TIMER
* Included by: Bank1C - Luts, Anim, Physics

### Compare Object Boxes

* Overview:
* File: Routines\BASE\_4\_5\Game\Subroutines\doCompareBoundingBoxes\_multiScreen.asm
* Define: SCR\_COMPARE\_BBOX
* Included by: Bank1C - Luts, Anim, Physics

### Handle Drawing Boxes

* Overview:
* File: Routines\BASE\_4\_5\Game\Subroutines\doDrawBox.asm
* Define: SCR\_DRAW\_BOX
* Included by: Load Subroutines

### Handle Path Data

* Overview: Does nothing
* File: Routines\BASE\_4\_5\Game\Subroutines\blank.asm
* Define: SCR\_HANDLE\_PATHS
* Included by: doLoadNametableDataFull.asm