Expand description
the bsp-node class seems broken - it has int16's that get used a pointers.
Types
bsp-header: drawablesource
Fields
type: type
id: int16
bsphere: vector
info: file-info
all-visible-list: pointer
visible-list-length: int16
extra-vis-list-length: int16
drawable-trees: drawable-tree-array
pat: pointer
pat-length: int32
texture-remap-table: pointer
texture-remap-table-len: int32
texture-ids: pointer
texture-page-count: int32
unknown-basic: basic
name: symbol
nickname: symbol
vis-info: level-vis-info
actors: drawable-inline-array-actor
cameras: array
nodes: inline-array
level: level
current-leaf-idx: uint16
texture-flags: texture-page-flag
cam-outside-bsp: uint8
cam-using-back: uint8
cam-box-idx: uint16
ambients: symbol
subdivide-close: float
subdivide-far: float
race-meshes: array
actor-birth-order: pointer
light-hash: light-hash
nav-meshes: array
actor-groups: array
region-trees: array
region-array: region-array
collide-hash: collide-hash
wind-array-length: int32
city-level-info: city-level-info
vis-spheres: vector-array
region-tree: drawable-tree-region-prim
tfrag-masks: texture-masks-array
tfrag-closest: pointer
tfrag-mask-count: uint32
shrub-masks: texture-masks-array
shrub-closest: pointer
shrub-mask-count: uint32
alpha-masks: texture-masks-array
alpha-closest: pointer
alpha-mask-count: uint32
water-masks: texture-masks-array
water-closest: pointer
water-mask-count: uint32
bsp-scale: vector
bsp-offset: vector
unk-data: uint32
end: uint8
Methods
birth(obj: bsp-header) => nonesource
deactivate-entities(obj: bsp-header) => nonesource
bsp-node: structuresource
collide-stats: structuresource
Fields
calls: uint32
spheres: uint32
nodes: uint32
frags: uint32
tris: uint32
output: uint32
pad0: uint32
total-target: uint32
target-cache-fill: uint32
target-ray-poly: uint32
view-frustum: structuresource
Functions
inspect-bsp-tree(arg0: bsp-header, arg1: bsp-node) => nonesource
map-bsp-tree(arg0: function, arg1: bsp-header, arg2: bsp-node) => nonesource
Expand description
The "bsp" is the main level data structure: the bsp-header contains references to all static level data.
The "bsp-tree" is a bsp used to associate camera positions with lists of visibible objects.
Functions
bsp-camera-asm(arg0: bsp-header, arg1: vector) => nonesource
Determine which leaf node of the bsp we are in, and store this in the bsp-header.
build-masks(arg0: bsp-header) => nonesource
Allocate texture masks as needed for a level.
level-remap-texture(arg0: texture-id) => texture-idsource
Remap a texture id.
mem-usage-bsp-tree(arg0: bsp-header, arg1: bsp-node, arg2: memory-usage-block, arg3: int) => nonesource
Compute the memory usage of the bsp-tree part of a bsp-header
print-collide-stats() => nonesource
Display collide stats on screen.
Variables
*test-shrub*: intsource
Types
level: basicsource
Fields
type: type
name: symbol
load-name: string
nickname: string
index: int32
status: symbol
borrow-level: level
borrow-from-level: level
heap: kheap
borrow-heap: kheap
bsp: bsp-header
art-group: load-dir-art-group
info: level-load-info
texture-page: texture-page
loaded-texture-page: texture-page
loaded-texture-page-count: int32
entity: entity-links-array
closest-object: float
closest-object-array: float
upload-size: int32
inside-boxes: symbol
display?: symbol
render?: symbol
meta-inside?: symbol
force-inside?: symbol
mood-context: mood-context
mood-func: function
mood-init: function
vis-bits: pointer
all-visible?: symbol
force-all-visible?: symbol
linking: symbol
vis-info: level-vis-info
vis-self-index: int32
vis-adj-index: int32
vis-buffer: uint8
mem-usage-block: memory-usage-block
mem-usage: int32
code-memory-start: pointer
code-memory-end: pointer
load-start-time: time-frame
load-stop-time: time-frame
load-buffer: uint32
load-buffer-size: uint32
load-buffer-last: uint32
load-buffer-mode: load-buffer-mode
display-start-time: time-frame
memory-mask: uint32
task-mask: task-mask
tfrag-gs-test: gs-test
texture-dirty-masks: texture-mask
texture-mask: texture-mask
sky-mask: texture-mask
tfrag-masks: texture-masks-array
tfrag-dists: pointer
shrub-masks: texture-masks-array
shrub-dists: pointer
alpha-masks: texture-masks-array
alpha-dists: pointer
water-masks: texture-masks-array
water-dists: pointer
tfrag-last-calls: int32
tfrag-last-calls-u32: uint32
texture-anim-array: texture-anim-array
light-hash: light-hash
draw-priority: float
draw-index: int32
part-engine: engine
user-object: basic
loaded-text-info-count: int32
loaded-text-info: game-text-info
level-type: type
load-order: int64
pad: int8
Methods
deactivate(obj: level) => _type_source
Take a level out of active/alive
is-object-visible?(obj: level, arg0: int) => symbolsource
Is drawable arg0 visible? Note that this will return #f if the visibility data is not loaded.
level-method-11: unknown
bsp-name(obj: level) => symbolsource
Get the name of the bsp. If this can't be done, get the name of the level.
compute-memory-usage!(obj: level, force?: symbol) => memory-usage-blocksource
Calculates the memory usage of the level, returns and stores the [[memory-usage-block]]
in mem-usage-block
as well as the total size in mem-usage
@see memory-usage-block::10
inside-boxes-check(obj: level, arg0: vector) => symbolsource
NOTE: this function used to check if we were in boxes - here it just checks
a flag. However, it is still used to set the inside-boxes field, so it keeps
the name we gave it in Jak 1.
The jak 2 behavior is that any loaded level (with a bsp) is considered 'in-boxes'
except for if the require-force-inside flag is set in the bsp-header, in which case
it requires the level to be marked as force-inside?
update-vis!(obj: level, vis-info: level-vis-info, unused: uint, in-bsp-vis-string: pointer) => symbolsource
load-continue(obj: level) => _type_source
Run the loading/login state machine.
This will only make progress on loading, linking, and login for loads that have already started.
No 'scary' state transitions (like birth, alive, deactivate) are made here.
load-begin(obj: level) => _type_source
Begin loading a level.
This assigns memory to a level and is somewhat confusing.
login-begin(obj: level) => _type_source
Begin login of a level after linking.
The login is spread over multiple frames.
debug-print-region-splitbox(obj: level, arg0: vector, arg1: object) => nonesource
Display debug info about the regions of a level.
get-art-group-by-name(obj: level, arg0: string) => art-groupsource
As the name implies, look through the art-groups of this level and get the one
with the given name. Return #f if not found.
level-method-22(obj: level, arg0: symbol) => intsource
lookup-text(obj: level, arg0: text-id, arg1: symbol) => stringsource
level-method-24: unknown
level-status-update!(obj: level, arg0: symbol) => _type_source
Try to update the level to the given status, calling whatever is needed
to make it happen.
This can do both loading, linking, login, and activation.
This is somewhat similar to level-get-for-use, but requires that you already have
the level object.
This function is the way to transition from loaded to alive/active.
load-required-packages(obj: level) => _type_source
Load packages for a level.
This just loads common, and this feature is not really useful.
Packages were only used during development, and seem only partially used in Jak 2
(the only package is common).
init-vis-from-bsp(obj: level) => nonesource
Set up a level's vis-infos from a bsp.
level-group: basicsource
Fields
type: type
length: int32
log-in-level-bsp: bsp-header
loading-level: level
entity-link: entity-links
border?: symbol
vis?: symbol
want-level: basic
receiving-level: basic
load-commands: pair
play?: symbol
target-pos: vector
camera-pos: vector
heap: kheap
sound-bank: basic
disk-load-timing?: symbol
load-level: basic
load-size: uint32
load-time: float
load-login-time: float
draw-level-count: int32
draw-level: level
draw-index-map: uint8
load-order: uint64
pad: uint8
level: level
level0: level
level1: level
level2: level
level3: level
level4: level
level5: level
default-level: level
pad2: uint8
Methods
level-get(obj: level-group, arg0: symbol) => levelsource
Get a level by name or load-name
level-get-with-status(obj: level-group, arg0: symbol) => levelsource
Get a level with the given status.
get-level-by-heap-ptr-and-status(obj: level-group, arg0: pointer, arg1: symbol) => levelsource
Get a level by a heap pointer and status.
If no matching level is found, return #f.
The purpose of the status check is possibly to prevent bugs with getting stuff
from a level that's just been replaced with another.
level-get-for-use(obj: level-group, arg0: symbol, arg1: symbol) => levelsource
Request a level by name in the given state.
Will return quickly (non-blocking) and might not be able to get a level in the desired state,
though it will ofborrow do some small amount of work to make progress on loading.
This is the most general/powerful function like this: if there is no level with this name
it will kick out levels as needed to make a free slot, and set up a new level, and start
the load. This should only be used when you might want to start a load.
activate-levels!(obj: level-group) => intsource
Set all levels to active.
debug-print-entities(obj: level-group, arg0: symbol, arg1: type) => nonesource
debug-draw-actors(obj: level-group, arg0: symbol) => nonesource
assign-draw-indices(obj: level-group) => nonesource
Sort the levels by draw priority.
actors-update(obj: level-group) => nonesource
update-nav-meshes-method(obj: level-group) => nonesource
Clashes with a function name
level-update(obj: level-group) => nonesource
level-get-target-inside(obj: level-group) => levelsource
Get the level that target is 'in'. With a bunch of tricks for what 'in' really means.
alloc-levels-if-needed(obj: level-group, arg0: symbol) => nonesource
Setup for playing levels by loading the required base packages (art, common)
and allocating the level heap.
load-commands-set!(obj: level-group, arg0: pair) => nonesource
Set the load-commands of a level.
art-group-get-by-name(obj: level-group, arg0: string, arg1: pointer) => art-groupsource
Search all levels for an art-group. Return the art group, or #f. Optionally return the level index.
alt-load-command-get-index(obj: level-group, arg0: symbol, arg1: int) => pairsource
Get the n-th alt-load-command for the given level.
This is likely unused in jak 2 because no levels have alt-load-commands.
update-vis-volumes(obj: level-group) => nonesource
update-vis-volumes-from-nav-mesh(obj: level-group) => nonesource
print-volume-sizes(obj: level-group) => nonesource
level-status(obj: level-group, arg0: symbol) => symbolsource
Get the status of a level by name, return #f if no level is found.
load-in-progress?(obj: level-group) => symbolsource
Is a level being loaded right now?
level-get-most-disposable(obj: level-group) => levelsource
Get the level that's least useful.
level-load-info: basicsource
Fields
type: type
name-list: symbol
index: int16
task-level: uint8
name: symbol
visname: symbol
nickname: symbol
dbname: symbol
taskname: symbol
other-name-1: symbol
packages: pair
memory-mode: load-buffer-mode
music-bank: symbol
ambient-sounds: symbol
sound-reverb: float
mood-func: symbol
mood-init: symbol
ocean: symbol
sky: symbol
use-camera-other: symbol
part-engine-max: int32
city-map-bits: uint64
continues: pair
tasks: pair
priority: int32
load-commands: pair
alt-load-commands: pair
bsp-mask: uint64
buzzer: int32
buttom-height: meters
run-packages: pair
prev-level: symbol
next-level: symbol
wait-for-load: symbol
login-func: symbol
activate-func: symbol
deactivate-func: symbol
kill-func: symbol
borrow-size: uint16
borrow-level: symbol
borrow-display?: symbol
base-task-mask: task-mask
texture-anim: symbol
texture-anim-tfrag: symbol
texture-anim-pris: symbol
texture-anim-shrub: symbol
texture-anim-alpha: symbol
texture-anim-water: symbol
texture-anim-twarp: symbol
texture-anim-pris2: symbol
texture-anim-sprite: symbol
texture-anim-map: symbol
texture-anim-sky: symbol
draw-priority: float
level-flags: uint32
fog-height: float
bigmap-id: bigmap-id
ocean-near-translucent?: symbol
ocean-far?: symbol
mood-range: mood-range
max-rain: float
fog-mult: float
ocean-alpha: float
extra-sound-bank: pair
level-vis-info: basicsource
Fields
type: type
level: level
from-level: level
from-bsp: bsp-header
flags: vis-info-flag
length: uint32
allocated-length: uint32
dictionary-length: uint32
dictionary: uint32
string-block: uint32
ramdisk: uint32
vis-bits: uint32
current-vis-string: uint32
vis-string: uint32
Variables
LEVEL_TOTAL: unknownsource
Functions
city-start() => nonesource
Variables
*level-load-list*: pairsource
*task-level*: arraysource
const atoll: level-load-infosource
const casboss: level-load-infosource
const cascity: level-load-infosource
const castle: level-load-infosource
const chartest: level-load-infosource
const consiteb: level-load-infosource
const ctyfarmb: level-load-infosource
const ctyfence: level-load-infosource
const ctygena: level-load-infosource
const ctygenb: level-load-infosource
const ctygenc: level-load-infosource
const ctyinda: level-load-infosource
const ctyindb: level-load-infosource
const ctykora: level-load-infosource
const ctymarka: level-load-infosource
const ctymarkb: level-load-infosource
const ctyport: level-load-infosource
const ctysluma: level-load-infosource
const ctyslumb: level-load-infosource
const ctyslumc: level-load-infosource
const ctywide: level-load-infosource
const demo: level-load-infosource
const dig1: level-load-infosource
const dig3a: level-load-infosource
const dig3b: level-load-infosource
const drill: level-load-infosource
const drillb: level-load-infosource
const drillmid: level-load-infosource
const drillmtn: level-load-infosource
const fordumpa: level-load-infosource
const fordumpb: level-load-infosource
const fordumpc: level-load-infosource
const fordumpd: level-load-infosource
const forest: level-load-infosource
const forestb: level-load-infosource
const forexita: level-load-infosource
const forexitb: level-load-infosource
const forresca: level-load-infosource
const forrescb: level-load-infosource
const garage: level-load-infosource
const gungame: level-load-infosource
const halfpipe: level-load-infosource
const hideout: level-load-infosource
const hiphog: level-load-infosource
const introcst: level-load-infosource
const lerrol: level-load-infosource
const ljakdax: level-load-infosource
const ljkdxash: level-load-infosource
const lkeirift: level-load-infosource
const lkiddoge: level-load-infosource
const lmeetbrt: level-load-infosource
const loutcstb: level-load-infosource
const lpackage: level-load-infosource
const lportrun: level-load-infosource
const lpower: level-load-infosource
const lprotect: level-load-infosource
const lprsncst: level-load-infosource
const lprtrace: level-load-infosource
const lracebb: level-load-infosource
const lracebf: level-load-infosource
const lracecb: level-load-infosource
const lracecf: level-load-infosource
const lracedb: level-load-infosource
const lracedf: level-load-infosource
const lracelit: level-load-infosource
const lsack: level-load-infosource
const lsamergd: level-load-infosource
const lshuttle: level-load-infosource
const lsmysbrt: level-load-infosource
const ltess: level-load-infosource
const lthrnout: level-load-infosource
const ltrnkrkd: level-load-infosource
const ltrntess: level-load-infosource
const ltrnysam: level-load-infosource
const lwidea: level-load-infosource
const lwideb: level-load-infosource
const lwidec: level-load-infosource
const lwidesta: level-load-infosource
const lysamsam: level-load-infosource
const lyskdcd: level-load-infosource
const mincan: level-load-infosource
const mountain: level-load-infosource
const mtnext: level-load-infosource
const nest: level-load-infosource
const nestb: level-load-infosource
const onintent: level-load-infosource
const outrocst: level-load-infosource
const palboss: level-load-infosource
const palcab: level-load-infosource
const palent: level-load-infosource
const palout: level-load-infosource
const palroof: level-load-infosource
const palshaft: level-load-infosource
const portwall: level-load-infosource
const prison: level-load-infosource
const ruins: level-load-infosource
const sewer: level-load-infosource
const sewerb: level-load-infosource
const sewesc: level-load-infosource
const sewescb: level-load-infosource
const skatepark: level-load-infosource
const stadblmp: level-load-infosource
const stadium: level-load-infosource
const stadiumb: level-load-infosource
const stadiumc: level-load-infosource
const stadiumd: level-load-infosource
const strip: level-load-infosource
const tobytest: level-load-infosource
const tomba: level-load-infosource
const tombb: level-load-infosource
const tombboss: level-load-infosource
const tombc: level-load-infosource
const tombd: level-load-infosource
const tombe: level-load-infosource
const tombext: level-load-infosource
const under: level-load-infosource
const village1: level-load-infosource
const vistest: level-load-infosource
Expand description
the level heap is a giant block of memory which is seperated into "pages" so that it can easily
be split into different sizes for the different kinds of level sizes.
it is split into 6 sections, 24-24-25-25-24-24 pages large.
this means the "center" portion of the main level heap is actually "larger"
which is why there is a special small-center level memory mode for two-section
levels that want to be placed in the middle of the heap for that slight size boost.
some code checks for 7 bits in the memory mask, indicating the heap was originally split
into 7 sections, which might explain the weird sizes in the center.
Functions
add-bsp-drawable(arg0: bsp-header, arg1: level, arg2: symbol, arg3: display-frame) => nonesource
Draw this bsp!
Calling draw on a bsp mostly just adds stuff to background-work, so maybe that's why
it's called 'add'. This also will do a debug-draw on the entire bsp if the
display-strip-lines option is set.
bg(arg0: symbol) => nonesource
Begin playing a level. Works with or without dproc running (won't start it).
give-all-stuff() => game-featuresource
level-update-after-load(lev: level, lstate: login-state) => levelsource
Make progress on login.
Will set status to loaded when done.
load-buffer-resize(arg0: level, arg1: dgo-header) => nonesource
Adjust the load buffers size and location.
The dgo-header passed in should be the load buffer we're about to use.
lookup-level-info(arg0: symbol) => level-load-infosource
Get level-load-info for the specified level.
The level-load-info for all levels is always available to the engine and is used
to figure out how to load levels.
play-boot() => nonesource
Entry point from C to initialize game for running.
This simply calls (play #t #t) in a GOAL thread.
remap-level-name(arg0: level-load-info) => symbolsource
Get the name of a level to use. Picks the visname if the vis? setting is on.
show-level(arg0: symbol) => intsource
update-sound-banks() => intsource
Load sound banks as needed.
Variables
*print-login*: symbolsource
const BORROW_MULT: unknownsource
DEBUG_LEVEL_HEAP_MULT: unknownsource
DEBUG_LEVEL_HEAP_SIZE: unknownsource
DEBUG_LEVEL_PAGE_SIZE: unknownsource
LEVEL_HEAP_SIZE: unknownsource
LEVEL_PAGE_SIZE: unknownsource
LEVEL_PAGE_SIZE_KB: unknownsource
NUM_LEVEL_PAGES: unknownsource
Types
drawable-inline-array-region-prim: drawable-inline-arraysource
drawable-region-face: drawable-region-primsource
drawable-region-prim: drawablesource
Fields
type: type
id: int16
bsphere: vector
region: region
Methods
debug-draw-region(obj: drawable-region-prim, arg0: int) => nonesource
track-region(obj: drawable-region-prim, arg0: region-prim-area) => symbolsource
TODO