Files
HackerOoT/include/ultra64/thread.h
Yanis42 c4be73b629 Merged decomp into HackerOoT (#21)
* Improve rcp.h, remove `HW_REG` macro (#1425)

* Real rcp.h

* Correction to comment in initialize.c

* Try fix R4300.h

* Adjust rcp.h formatting, remove defines in other headers that are now in rcp.h

* Suggested changes, document a bug in the modified osAiSetNextBuffer

* More rcp.h formatting changes

* Fix misc 18 (#1423)

* two more ABS

* fixup item_name_static texs outnames

* fixup CollisionCheck_SetOCvsOC docs

* Cleanup int comments alignments

* collsion -> collision

* `SQ*` macros fixup

* use `LERP` more

* static -> `s` prefix

* grammar: dont -> don't

* 3

* Improvements to Video Interface related functions and data (#1332)

* Improvements to VI related functions

* Fix

* Suggested changes

* Comment enum values

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Suggested changes, plus comments in visetspecial.c

* Name gViConfigModeType

* Further suggested changes

* Format

* Fix comment on modeLPN2

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* TwoHeadArena and TwoHeadGfxArena docs (#1349)

* TwoHeadArena and TwoHeadGfxArena docs, ALIGNOF macro

* AllocStart -> AllocHead , AllocEnd -> AllocTail

* Format

* Suggested changes

* Fix

* Further suggested changes

* z_en_horse_zelda doc (#1430)

* z_en_horse_zelda doc

Zelda's horse has been better documented. Horse seemed to follow a path around Hyrule Field

* `z_en_horse_zelda` revised based on feedback

* Update z_en_horse_zelda.c

EnHorseZelda_ResetAnimation -> EnHorseZelda_SetupStop

* z_horse_zelda: changes based on feedback

* Mempak doc (#1382)

* Mempak doc

* Format

* Suggested changes

* Further changes

* Update item names (#1376)

* Reevaluate item names (`ItemID` enum)

* format

* Carry `ItemID` changes to `ExchangeItemID`

* format

* Add item enum comments on items to slots array

* Rename slots according to current item enum names

* Add item enum comments on items to PlayerItemAction array

* Rename PlayerItemAction enum names according to current item enum names

* gi, gid names...

* `QUEST_GERUDO_CARD` -> `QUEST_GERUDOS_CARD`

* `DUNGEON_KEY_BOSS` -> `DUNGEON_BOSS_KEY`

* `UPG_` sticks/nuts : +deku

* Fixed remove array enum comments in `sDebugSaveEquips`

* "magic beans" -> "magic bean" (singular)

* cucco -> chicken (the one from weird egg, "alarm clock bird" from literal japanese translation)

* Document Timers (#1412)

* Document Timers, First Draft

* some progress

* more timer docs

* cleanup

* small cleanup

* more cleanup

* comments

* more cleanup

* extra comment

* more docs

* brackets

* PR Suggestions

* cleanup, missed some

* more suggestions

* more PR Suggestions

* small change

* environmental

* More documentation for `z_std_dma.c` (#1415)

* More documentation for z_std_dma

* uintptr casts for rom symbols in z64animation.h and z_kanfont.c

* Format

* Suggested changes, more defines for static texture sizes

* PI Interface -> PI

* Further suggested changes

* Format

* Comments about item_name and map_name texture assumptions

* `z_en_bird` doc (#1431)

* `z_en_bird` doc

Documented `z_en_bird`

* `Z_en_bird` changes from feedback

* Update z_en_bird.c

* `z_en_bird`: suggested changes

* `z_en_bird`: changes based on feedback

animation speed mod field changed, redundant comments removed.

* z_shot_sun: minor doc (#1429)

* z_shot_sun: minor doc

document one field and function remaining in z_shot_sun

* z_shot_sun: updated state doc'ing

* Update z_shot_sun.c

format enum

* ran format.py

* `z_shot_sun`: changes based on feedback

gave enum better name, removed redundant comment.

* Update z_shot_sun.c

enum changed.

* `z_obj_lift`: doc remaining funcs and field (#1440)

* `z_obj_lift`: doc funcs and field

doc remaining funcs and field in `z_obj_lift`

* `z_obj_lift`: shakeVec->shakeOrientation

* removed space from copy-paste of field name

* Small `Actor_UpdateAll` doc (#1432)

* Small `Actor_UpdateAll` doc

* improve, "freeze"

* rename "freeze category masks"

* shorten to "category freeze mask" everywhere

* Doc object_rs (#1439)

* Document En_Ko Animations (#1306)

* Document Kokiri Children animations

* Remove BOY, GIRL, and FADO prefixes

* Formatting

* Further prefix removal

* more fixups

Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>

* Document Hud Mode (#1323)

* begin interface alpha docs

* more progress/docs

* First draft of docs done

* cleanup

* Consistency

* Display -> Mode

* Remaining display -> mode

* Better docs

* Small touchups

* Small Update

* Apply discord discussion

* small fix

* More discussions

* PR Suggestions

* Roman PR Suggestions

* better comments

* PR Suggestions

* another suggestion

* discord discussions

* cleanup comments

* more discord/pr suggestions

* Document NPC talking and player tracking (#1426)

* Rename npc dialog state variable

* Rename and doc NPC actor talking funtion

* Introduce NpcTalkState enum

* Rename NPC_TALK_STATE enum values

* Document NpcPlayerInteractionState and related functions

* Rename player tracking opt enum variants

* Rename npc functions, interact info

* Minor npc actor function tweaks

* Minor comment fixes for npc

* Generalize NPC player tracking to point tracking

* Change unused NpcInteractInfo field type and name

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Rename headRot and torsoRot

* Rename GetTalkState to UpdateTalkState

* Minor comment fixes

* Rename rotateActorShape and clarify related comments

* Remove unneeded parentheses in z_en_heishi4.c

* Reformat

* Remove unclear comment

* Rename yPosOffset to yOffset

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Player doc: Temporary `PLAYER_ANIMGROUP` names from original animation names (#1446)

* Name `PLAYER_ANIMGROUP_` based on original names

* format

* add comment indicating source of names

* Document HREG debugging system (#1351)

* progress

* progress

* change

* named most

* name prerender things

* fix and format

* play prefix

* address most comments (still a few more things to do)

* fix error

* reword input test comments

* some more

* rework env draw flags

* add hilite

* merge and format

* init to proper values

* rename env draw flag names

* 7 to 6

* more small changes

* Name scenes (scene enum, entrance enum, various identifiers) (#1343)

* Comment names on titled scenes

* Comment some more scene names

* Comment some map assets symbol prefixes

* Name collapse sequence scenes (from the non-collapse equivalent scene's name + `_COLLAPSE`)

* Name ganon/ganondorf boss scenes (symbol prefix suffixed with `Scene` to prevent confusion with boss actors)

* Fix symbol prefix for back alley night scene

* Name the two grave scenes (normal and fairy's fountain variant)

* Name most houses, name/update misc scenes

Co-authored-by: fig02 <fig02srl@gmail.com>

* (hakaana) `GRAVE` -> `REDEAD_GRAVE` to be more specific

Co-authored-by: fig02 <fig02srl@gmail.com>

* `miharigoya_scene`: `market_guard_house`

* `kakariko_scene` -> `kakariko_center_house`

* `richards_house` -> `dog_lady_house` (for localization differences)

* Revert "Comment some map assets symbol prefixes"

This reverts commit 210a38a6288d5d2fa318059f31988ca7ceb5c708.

* remove other xml prefixes

* ganon_boss, ganondorf_boss

* comments to namefixer

* `KAKARIKO_CENTER_HOUSE` -> `KAKARIKO_CENTER_GUEST_HOUSE`

* two collapse sequence scenes -> `GANONS_TOWER_COLLAPSE_`interior/exterior

* Run namefixer

`find src include -type f -exec ./tools/namefixer.py {} \;`

* run formatter

Co-authored-by: fig02 <fig02srl@gmail.com>

* Add skybox .h and cleanup, `SkyboxDraw_` -> `Skybox_` (#1435)

* Add skybox .h and cleanup

* move forward declared structs to top of file

* `SkyboxDraw_` -> `Skybox_`

* format

* move more forward declared structs to top of file

* Document Surface Material (#1447)

* material

* cleanup

* iron boots

* climb

* more docs

* rename

* small fix

* comments

* adjust bug comment

* simplify comment

* Document Camera for Elevator Platforms (Camera_Special7) (#1448)

* document camera for vertical platforms

* cleanup

* another rename

* small

* another rename

* add comment

* PR Suggestions

* more cleanup

* oops

* adjust comment

* Skelanime/Animation header cleanup (#1434)

* Skelanime/Animation header cleanup

* touch up names of the two existing moveFlags macros

* formatter is a dum dum D:

* fixed z_select.h changes

* fixed config entrance name

Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com>
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>
Co-authored-by: blackgamma7 <blackgamma7@gmail.com>
Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
Co-authored-by: Charles Averill <46544495+CharlesAverill@users.noreply.github.com>
Co-authored-by: Lauri Koskela <luryus@users.noreply.github.com>
Co-authored-by: fig02 <fig02srl@gmail.com>
2022-12-03 19:02:57 +01:00

145 lines
4.7 KiB
C

#ifndef ULTRA64_THREAD_H
#define ULTRA64_THREAD_H
#define OS_PRIORITY_MAX 255
#define OS_PRIORITY_VIMGR 254
#define OS_PRIORITY_RMON 250
#define OS_PRIORITY_RMONSPIN 200
#define OS_PRIORITY_PIMGR 150
#define OS_PRIORITY_SIMGR 140
#define OS_PRIORITY_APPMAX 127
#define OS_PRIORITY_IDLE 0
#define OS_PRIORITY_THREADTAIL -1
#define OS_STATE_STOPPED 1
#define OS_STATE_RUNNABLE 2
#define OS_STATE_RUNNING 4
#define OS_STATE_WAITING 8
#define OS_FLAG_CPU_BREAK 1
#define OS_FLAG_FAULT 2
#ifdef _LANGUAGE_C
#include "ultratypes.h"
typedef s32 OSPri;
typedef s32 OSId;
typedef union {
struct {
/* 0x00 */ f32 f_odd;
/* 0x04 */ f32 f_even;
} f;
f64 d;
} __OSfp; // size = 0x08
typedef struct {
/* 0x000 */ u64 at, v0, v1, a0, a1, a2, a3;
/* 0x038 */ u64 t0, t1, t2, t3, t4, t5, t6, t7;
/* 0x078 */ u64 s0, s1, s2, s3, s4, s5, s6, s7;
/* 0x0B8 */ u64 t8, t9, gp, sp, s8, ra;
/* 0x0E8 */ u64 lo, hi;
/* 0x0F8 */ u32 sr, pc, cause, badvaddr, rcp;
/* 0x10C */ u32 fpcsr;
/* 0x110 */ __OSfp fp0, fp2, fp4, fp6, fp8, fp10, fp12, fp14;
/* 0x150 */ __OSfp fp16, fp18, fp20, fp22, fp24, fp26, fp28, fp30;
} __OSThreadContext; // size = 0x190
typedef struct {
/* 0x00 */ u32 flag;
/* 0x04 */ u32 count;
/* 0x08 */ u64 time;
} __OSThreadprofile; // size = 0x10
typedef struct OSThread {
/* 0x00 */ struct OSThread* next;
/* 0x04 */ OSPri priority;
/* 0x08 */ struct OSThread** queue;
/* 0x0C */ struct OSThread* tlnext;
/* 0x10 */ u16 state;
/* 0x12 */ u16 flags;
/* 0x14 */ OSId id;
/* 0x18 */ s32 fp;
/* 0x1C */ __OSThreadprofile* thprof;
/* 0x20 */ __OSThreadContext context;
} OSThread; // size = 0x1B0
typedef struct {
OSThread* next;
OSPri priority;
} __OSThreadTail; // size = 0x8
#else
// OSThread struct member offsets
#define THREAD_NEXT 0x00
#define THREAD_PRI 0x04
#define THREAD_QUEUE 0x08
#define THREAD_TLNEXT 0x0C
#define THREAD_STATE 0x10
#define THREAD_FLAGS 0x12
#define THREAD_ID 0x14
#define THREAD_FP 0x18
#define THREAD_PROFILE 0x1C
#define THREAD_CONTEXT 0x20
#define THREAD_AT (THREAD_CONTEXT + 0x000)
#define THREAD_V0 (THREAD_CONTEXT + 0x008)
#define THREAD_V1 (THREAD_CONTEXT + 0x010)
#define THREAD_A0 (THREAD_CONTEXT + 0x018)
#define THREAD_A1 (THREAD_CONTEXT + 0x020)
#define THREAD_A2 (THREAD_CONTEXT + 0x028)
#define THREAD_A3 (THREAD_CONTEXT + 0x030)
#define THREAD_T0 (THREAD_CONTEXT + 0x038)
#define THREAD_T1 (THREAD_CONTEXT + 0x040)
#define THREAD_T2 (THREAD_CONTEXT + 0x048)
#define THREAD_T3 (THREAD_CONTEXT + 0x050)
#define THREAD_T4 (THREAD_CONTEXT + 0x058)
#define THREAD_T5 (THREAD_CONTEXT + 0x060)
#define THREAD_T6 (THREAD_CONTEXT + 0x068)
#define THREAD_T7 (THREAD_CONTEXT + 0x070)
#define THREAD_S0 (THREAD_CONTEXT + 0x078)
#define THREAD_S1 (THREAD_CONTEXT + 0x080)
#define THREAD_S2 (THREAD_CONTEXT + 0x088)
#define THREAD_S3 (THREAD_CONTEXT + 0x090)
#define THREAD_S4 (THREAD_CONTEXT + 0x098)
#define THREAD_S5 (THREAD_CONTEXT + 0x0A0)
#define THREAD_S6 (THREAD_CONTEXT + 0x0A8)
#define THREAD_S7 (THREAD_CONTEXT + 0x0B0)
#define THREAD_T8 (THREAD_CONTEXT + 0x0B8)
#define THREAD_T9 (THREAD_CONTEXT + 0x0C0)
#define THREAD_GP (THREAD_CONTEXT + 0x0C8)
#define THREAD_SP (THREAD_CONTEXT + 0x0D0)
#define THREAD_S8 (THREAD_CONTEXT + 0x0D8)
#define THREAD_RA (THREAD_CONTEXT + 0x0E0)
#define THREAD_LO (THREAD_CONTEXT + 0x0E8)
#define THREAD_HI (THREAD_CONTEXT + 0x0F0)
#define THREAD_SR (THREAD_CONTEXT + 0x0F8)
#define THREAD_PC (THREAD_CONTEXT + 0x0FC)
#define THREAD_CAUSE (THREAD_CONTEXT + 0x100)
#define THREAD_BADVADDR (THREAD_CONTEXT + 0x104)
#define THREAD_RCP (THREAD_CONTEXT + 0x108)
#define THREAD_FPCSR (THREAD_CONTEXT + 0x10C)
#define THREAD_FP0 (THREAD_CONTEXT + 0x110)
#define THREAD_FP2 (THREAD_CONTEXT + 0x118)
#define THREAD_FP4 (THREAD_CONTEXT + 0x120)
#define THREAD_FP6 (THREAD_CONTEXT + 0x128)
#define THREAD_FP8 (THREAD_CONTEXT + 0x130)
#define THREAD_FP10 (THREAD_CONTEXT + 0x138)
#define THREAD_FP12 (THREAD_CONTEXT + 0x140)
#define THREAD_FP14 (THREAD_CONTEXT + 0x148)
#define THREAD_FP16 (THREAD_CONTEXT + 0x150)
#define THREAD_FP18 (THREAD_CONTEXT + 0x158)
#define THREAD_FP20 (THREAD_CONTEXT + 0x160)
#define THREAD_FP22 (THREAD_CONTEXT + 0x168)
#define THREAD_FP24 (THREAD_CONTEXT + 0x170)
#define THREAD_FP26 (THREAD_CONTEXT + 0x178)
#define THREAD_FP28 (THREAD_CONTEXT + 0x180)
#define THREAD_FP30 (THREAD_CONTEXT + 0x188)
#endif
#endif