TODO:Crash Bandicoot Hacking Wikia

## Remaining topics to discuss

* Entry Point
* Game Loop
* NS/Paging System

1. EID encoding/decoding; determining type from EID string
2. Filesystem Mapping?
3. Entry Querying
4. Page Operations

  a.  Initialization/Deinitialization
i.  Paging and Subsystem Initialization
ii. Paging and Subsystem Deinitialization
  b.  Page Management
i.    Page Allocation
    ii.   Page Deallocation (free)
    iii.  Page Creation
    iv.  Page Deletion (truncatePages)
  c.  Page Update
i.   Update Page (single)
- incl Page Chunk Decompression/Initialization
- Chunk Decompress Routine
ii.  Update Pages (global)
         - incl Update New Pages (called from level update when load new zone)
    iii. Update Page [chunk] Entries
  d.  Page Search and Request/Open
    i.  Search
       A.  Find Hash Pair
       B.  Find Page (that contains entry w/EID)
    ii.  Request/Open
       A.  Page Chunk
       - Pages a single new page with req. CID, EID
       B.  Page Entry
       - Variant intended to page a single new page with req. entry w/EID; since paging the new page requires Updating Page Entries, which replaces the data fields of hash pairs for its entries with pointers to them, this returns a pointer to the resolved entry in its hash pair
       C.  Open Entry
       - Variant intended to increment read requests for an already paged page with req. entry w/EID;will page chunk if it does not exist; can optionally schedule paging the chunk with req. entry as part of a 'group' of contiguous chunks, during next page update
         i) \*\*Open Entry Given Container Chunk - also a variant, is just the bottom half of the open entry routine
       D.  Close Entry
       - Decrements read requests for an already paged page with req. entry w/EID;
       E.  Unpage Chunk
       - Clears the chunk's entry in the page map
       F.  Close Entries and Unpage Chunk
       - Closes chunk's n last opened entries, and unpages if all have been closed
  e.  Page Queries
A.  Get Number of Free or Available Pages
    B.  Get Number of Free or Available Pages With Specified List Entries
  f.  Texture Pages
    A.  Unpage Texture Page
  g.  Zone-Specific
    A.  Close Zone Entries and Unpage Zone Chunks
    B.  Unpage a Texture Page among Zone Entries [i.e. that is already paged]
 Misc/incomplete
  a.  Seek Disc to file
  b.  Find Audio Page?
* Hardware Initialization

1. Hardware Init Routine
2. Hardware Deinit Routine

* ​Hardware Libraries

1. ​Controller

​a.  Controller Initialization
b.  Controller Read
2.  GPU
a.  GPU Initialization
b.  GPU Deinitialization
c.  GPU Shaders
d.  GPU Driver
A.  Clear Screen
B.  Fill Screen w/Black Tile
C.  Draw Sync
- incl root counter callback
D.  OT (prim list)
i.   Initialize OT
ii.  Get OT Pointer
E.  Swap Buffers and Render Stage
F.  Render Primitive
G. Game Rate Calculations
3.  GFX
a.  [Page] Texture Chunk to VRAM
b.  Global Matrices
A.  Set Projection and Screen Offset
B.  Generate View Matrix, Rot, Angles, World Models, etc.
C.  Generate Matrices for Map\*\*
c.  Global Light Matrices
A.  Light Matrix Generation
d.  Matrix Transformation Routine
e.  Primitive Creation
A.  Objects
i.  Object SVTX Primitive Creation
- incl. 3 clipping-related routines
- incl. 2 svtx vertex shading (light) routines
- incl. assembly routine portion
ii.  Object CVTX Primitive Creation
iii. Object Sprite Primitive Creation
- incl. rotation assembly portion
- incl. assembly routine portion
iv.  Object Font Primitive Creation

B.  Worlds (incomplete, format only partially explained)
i.   World Model Creation
- incl also sub\_8001A460?
ii.  World Primitive Creation
- 7 Variations, incl 1 unused
- incl. optimized world model copying
- incl. assembly routine portion for each variation
f. Memory Card Images
A. 3 undocumented routines
g.  Audio Matrix Generation (assembly portion)

-GOOL/Objects

1. OPAT Initialization/Deinitialization
2. sub\_8001AC60?
3. Object Hierarchy
a. Object Left-parent/Right-sibling desc.
 b. Object Adoption
i. Add Child Object
ii. Remove Child Object
c) Object Traversal
i)   General Traversal
1) Pre-order traversal with callback
2) Post-order traversal with callback
3) List handle pre-order traversal with callback
4) List handle post-order traversal with callback
ii)  Object Find Traversal
1) Object Find traversal with callback
- Callback routines: HasID, HasStateFlags
2) Object Find/Query traversal (no callback)
 - Find nearest object (incl. send asynchronously handled event-another routine)
4) Object Initialization, Creation, and Termination
a) Object Initialization
b) Object Creation
i)   Process Object 'Creation'
ii)  Entity Object Spawning
c) Object Termination
i)   3 Object Termination variants
ii)  Mass Object Termination
5) Object Update
a) Object Trans Block Interpretation
b) Object Code Block Interpretation
c) Object Colors Update
d) Object Physics Update
- Object Paths
e) Object Primitive Creation
- Text Creation Routines
f) Object Bound Box Update
g) Object Bound Collision Registration
6) GOOL
a) Changing Object State
b) Sending Object Events
- incl. Object Collision Events
- incl. Broadcasting Events
- Incl. nearest object query
c) Interpret Object
- incl. GOOL Reference Translation
- incl. Reading Control Pad
- See also geometric computations and calculations for objects

-Geometric Computations/Calculations

1) For Objects
a) Object Rotation
- 2 Variations
2) Seek
3) Distance
a) Euclidean distance
- in 3 space
- in XYZ plane
b) Manhattan distance
c) Absolute 1D distance
4) Angles
a) Angular distance
b) Angle in XZ plane (btwn 2 vectors)
c) Angle in YZ plane (btwn 2 vectors)
5) Vector Operations
 a) Matrix Transformation
2 variations... (1 for visual, 1 for audio)
b) 2D Projection
6) Collision Test
a) Test 2 3D spaces for a collision
b) Test point for containment by 3D space
c) Test 3D space given by 2 points for collision with another 3D space
7) General Math Functions
a) Sine
b) Cosine
c) Square Root
d) Atan2 (ratan2)
-GOOL Globals Initialization...

-Level

1) Initialization
- LDAT Initialization
- GOOL Globals Reset
- Load Universal Entries
- Create HUD + Level Restart (\*sub\_8002E98C)
(Level Restart Creates Crash Object)
2) Level Update
- Zone
 A) Camera Path
i) Progress
- Update Sort List
- Camera Update
- incl update level misc
3) Level Current Zone Spawn Objects [outlier]
4) Level Save State
5) Level Restart
6) Level-Specific
a) Level Specific World Vertex Shader Parameter Initialization
b) Level Specific Audio Vector Parameter Initialization
-Camera

1) Camera Update
 a) Camera Follow
A) Camera Get Projected Progress Non-forward
B) Camera Get Projected Progress Forward
C) Camera Adjust Progress (w/speed)
b) Other Camera Modes
A) Camera Calculate Progress
B) Other: todo
c) Death Camera
TODO

-Sort List

1) Format
2) Encoding/Decoding

-Solid Surface Collision

1) Node Querying
-(one routine calls query routine for each zone)
2) Translation
-incl smooth, pull, and stop at solid
a) Stopping at Floor
- incl. Finding Highest Object Below
- incl. Finding Average Y
b) Stopping at Walls
A) Wall Plot
i)   Initialization/Deinitialization (BINF)
ii)  Plotting a Wall
- 2 Variations
iii) Node Subdivision Wall Plotting
iv)  Object Sides Wall Plotting
v)   Zone Boundaries Wall Plotting
vi)  Testing the Wall Plot
- Replotting Walls
c) Stopping at Ceiling
- incl. Finding Ceiling
d) Stopping at Bottom Zone Bounds
e) Node Death Events
- incl. Handle Nodes...
3) GOOL Operations
a) Vector Rebound
b) Closest Solid Thing Above/Below or in Front/Behind
c) Highest Solid Thing Above
d) TODO remaining
-Audio/MIDI

TODO

-Memory Card

TODO

-Misc

1) Demo Mode
a) PBAK initialization
b) Demo mode routine
c) 4 Random Number routines