├── .dockerignore ├── .gitignore ├── .gitlab-ci.yml ├── .gitlab └── merge_request_templates │ └── default.md ├── .gitmodules ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── asm ├── core1 │ └── ultra │ │ ├── exceptasm.s │ │ ├── libm_vals.s │ │ ├── parameters.s │ │ └── setintmask.s └── ultra │ ├── exceptasm.s │ ├── parameters.s │ └── setintmask.s ├── decompressed.pal.yaml ├── decompressed.us.v10.yaml ├── diff ├── first_diff.py ├── ido └── ido5.3_recomp │ ├── Makefile │ ├── acpp │ ├── as1 │ ├── cc │ ├── cc_c.c │ ├── cfe │ ├── copt │ ├── elf.h │ ├── err.english.cc │ ├── header.h │ ├── helpers.h │ ├── libc_impl.c │ ├── libc_impl.h │ ├── recomp │ ├── recomp.cpp │ ├── ugen │ ├── ugen_c.c │ ├── ujoin │ ├── uld │ ├── umerge │ ├── uopt │ └── usplit ├── include ├── 2.0L │ ├── PR │ │ ├── PRimage.h │ │ ├── R4300.h │ │ ├── abi.h │ │ ├── gbi.h │ │ ├── gs2dex.h │ │ ├── gt.h │ │ ├── gu.h │ │ ├── leo.h │ │ ├── leoappli.h │ │ ├── libaudio.h │ │ ├── mbi.h │ │ ├── n_abi.h │ │ ├── n_libaudio.h │ │ ├── n_libaudio_s_to_n.h │ │ ├── os.h │ │ ├── os_ai.h │ │ ├── os_cache.h │ │ ├── os_cont.h │ │ ├── os_convert.h │ │ ├── os_debug.h │ │ ├── os_eeprom.h │ │ ├── os_error.h │ │ ├── os_exception.h │ │ ├── os_flash.h │ │ ├── os_gbpak.h │ │ ├── os_gio.h │ │ ├── os_host.h │ │ ├── os_internal.h │ │ ├── os_internal_debug.h │ │ ├── os_internal_error.h │ │ ├── os_internal_exception.h │ │ ├── os_internal_gio.h │ │ ├── os_internal_host.h │ │ ├── os_internal_reg.h │ │ ├── os_internal_rsp.h │ │ ├── os_internal_si.h │ │ ├── os_internal_thread.h │ │ ├── os_internal_tlb.h │ │ ├── os_libc.h │ │ ├── os_message.h │ │ ├── os_motor.h │ │ ├── os_pfs.h │ │ ├── os_pi.h │ │ ├── os_rdp.h │ │ ├── os_reg.h │ │ ├── os_rsp.h │ │ ├── os_si.h │ │ ├── os_system.h │ │ ├── os_thread.h │ │ ├── os_time.h │ │ ├── os_tlb.h │ │ ├── os_version.h │ │ ├── os_vi.h │ │ ├── os_voice.h │ │ ├── ramrom.h │ │ ├── rcp.h │ │ ├── rdb.h │ │ ├── region.h │ │ ├── rmon.h │ │ ├── sched.h │ │ ├── sp.h │ │ ├── sptask.h │ │ ├── ucode.h │ │ ├── ucode_debug.h │ │ ├── ultraerror.h │ │ ├── ultralog.h │ │ ├── ultratypes.h │ │ └── uportals.h │ ├── assert.h │ └── ultra64.h ├── actor.h ├── animation.h ├── assets.h ├── bool.h ├── bs_funcs.h ├── bsint.h ├── core1 │ ├── core1.h │ ├── eeprom.h │ ├── framebufferdraw.h │ ├── lookup.h │ ├── main.h │ ├── mem.h │ ├── ml.h │ ├── mlmtx.h │ ├── pfsmanager.h │ ├── rarezip.h │ ├── sns.h │ ├── sprite.h │ ├── ucode.h │ ├── viewport.h │ └── vimgr.h ├── core2 │ ├── anctrl.h │ ├── anim │ │ └── sprite.h │ ├── ba │ │ ├── anim.h │ │ ├── carry.h │ │ ├── drone.h │ │ ├── flap.h │ │ ├── model.h │ │ ├── physics.h │ │ └── timer.h │ ├── bonetransform.h │ ├── camera.h │ ├── code_6DA30.h │ ├── coords.h │ ├── core2.h │ ├── file.h │ ├── lighting.h │ ├── modelRender.h │ ├── nc │ │ └── camera.h │ ├── particle.h │ ├── skeletalanim.h │ ├── statetimer.h │ ├── timedfunc.h │ ├── vla.h │ └── yaw.h ├── cseq.h ├── cseqp.h ├── enums.h ├── file_and_line.h ├── functions.h ├── gc │ ├── gc.h │ ├── gcbound.h │ └── gctransition.h ├── generic.h ├── guint.h ├── initfx.h ├── macro.inc ├── math.h ├── model.h ├── music.h ├── n_abi.h ├── n_cseqp.h ├── n_synth.h ├── osint.h ├── overlays.h ├── piint.h ├── prelude.s ├── prop.h ├── rand.h ├── rarezip.h ├── save.h ├── seqp.h ├── stdarg.h ├── string.h ├── structs.h ├── synthInternals.h ├── time.h ├── variables.h ├── version.h └── viint.h ├── level_symbols.us.v10.txt ├── manual_syms.pal.txt ├── manual_syms.us.v10.txt ├── packages.txt ├── progress └── progress_total.svg ├── requirements.txt ├── rzip_dummy_addrs.pal.txt ├── rzip_dummy_addrs.us.v10.txt ├── src ├── BGS │ ├── bss_pad.c │ ├── ch │ │ ├── bigalligator.c │ │ ├── code_2270.c │ │ ├── code_8A60.c │ │ ├── croctus.c │ │ ├── flibbit.c │ │ ├── frogminigame.c │ │ ├── leafboat.c │ │ ├── mrvile.c │ │ ├── mudhut.c │ │ ├── pinkegg.c │ │ ├── tanktup.c │ │ ├── yellowflibbit.c │ │ └── yumblie.c │ ├── code_3030.c │ ├── code_3420.c │ ├── code_8DF0.c │ ├── code_9750.c │ └── crc.c ├── CC │ ├── CC.h │ ├── bss_pad.c │ ├── ch │ │ ├── sawblade.c │ │ └── tooth.c │ ├── code_0.c │ ├── code_13C0.c │ ├── code_19B0.c │ ├── code_1B90.c │ ├── code_1F70.c │ ├── code_3400.c │ ├── code_530.c │ ├── code_BF0.c │ └── crc.c ├── CCW │ ├── bss_pad.c │ ├── ch │ │ ├── grublinhood.c │ │ └── vacationtexttrigger.c │ ├── code_0.c │ ├── code_14B0.c │ ├── code_160.c │ ├── code_1B20.c │ ├── code_21A0.c │ ├── code_2270.c │ ├── code_2B00.c │ ├── code_3050.c │ ├── code_3310.c │ ├── code_3DA0.c │ ├── code_4530.c │ ├── code_4960.c │ ├── code_4D00.c │ ├── code_50D0.c │ ├── code_5540.c │ ├── code_5BF0.c │ ├── code_61E0.c │ ├── code_6620.c │ ├── code_6AC0.c │ ├── code_6EC0.c │ ├── code_7120.c │ ├── code_7570.c │ ├── code_76C0.c │ ├── code_7BC0.c │ ├── code_7BF0.c │ └── code_950.c ├── FP │ ├── bss_pad.c │ ├── ch │ │ ├── bearcub.c │ │ ├── boggy1.c │ │ ├── boggy2.c │ │ ├── boggy3.c │ │ ├── cavewozza.c │ │ ├── present.c │ │ ├── racesled.c │ │ ├── scarfsled.c │ │ ├── snowmanbutton.c │ │ ├── twinkly.c │ │ ├── twinklybox.c │ │ ├── twinklymuncher.c │ │ ├── wozza.c │ │ ├── wozzasjig.c │ │ ├── xmastree.c │ │ ├── xmastreeeggtoll.c │ │ ├── xmastreeice.c │ │ ├── xmastreestar.c │ │ └── xmastreeswitch.c │ ├── code_19E0.c │ ├── code_1FF0.c │ ├── code_A1C0.c │ ├── code_ABD0.c │ ├── code_B4D0.c │ └── ma │ │ ├── slalom.c │ │ ├── snowbutton.c │ │ └── snowy.c ├── GV │ ├── bss_pad.c │ ├── ch │ │ ├── ancientone.c │ │ ├── buriedpyramid.c │ │ ├── gobi1.c │ │ ├── gobi2.c │ │ ├── gobi3.c │ │ ├── gobirock.c │ │ ├── gobirope.c │ │ ├── histup.c │ │ ├── mazectrl.c │ │ ├── sarcophagus.c │ │ ├── toots.c │ │ └── trunker.c │ ├── code_2EE0.c │ ├── code_3630.c │ ├── code_3AA0.c │ ├── code_3B10.c │ ├── code_3BB0.c │ ├── code_3D90.c │ ├── code_43B0.c │ ├── code_4740.c │ ├── code_5570.c │ ├── code_61E0.c │ ├── code_6370.c │ ├── code_6F80.c │ ├── code_7060.c │ ├── code_7D50.c │ ├── code_7DB0.c │ ├── code_7FC0.c │ ├── code_7FF0.c │ ├── code_9B70.c │ ├── code_9C10.c │ ├── matchinggame.c │ └── waterctrl.c ├── MM │ ├── ch │ │ ├── chimpystump.c │ │ ├── conga.c │ │ ├── grublin.c │ │ ├── hut.c │ │ ├── juju.c │ │ ├── jujuhitbox.c │ │ ├── lmonkey.c │ │ ├── orange.c │ │ └── orangepad.c │ ├── code_24C0.c │ └── crc.c ├── MMM │ ├── bss_pad.c │ ├── ch │ │ ├── loggo.c │ │ ├── motzhand.c │ │ └── napper.c │ ├── code_16B0.c │ ├── code_2040.c │ ├── code_2F60.c │ ├── code_3120.c │ ├── code_3420.c │ ├── code_3D50.c │ ├── code_47D0.c │ ├── code_5000.c │ ├── code_DC0.c │ └── crc.c ├── RBB │ ├── bss_pad.c │ ├── ch │ │ ├── anchor.c │ │ ├── anchorctrl.c │ │ ├── anchorswitch.c │ │ ├── axle.c │ │ ├── bellbuoy.c │ │ ├── boombox.c │ │ ├── bossboombox.c │ │ ├── bossboomboxctrl.c │ │ ├── cog.c │ │ ├── dolphin.c │ │ ├── eggtoll1.c │ │ ├── enginefan.c │ │ ├── enginefanswitch.c │ │ ├── engineparts.c │ │ ├── grimlet.c │ │ ├── propellor.c │ │ ├── propellorswitch.c │ │ ├── rarewareflag.c │ │ ├── rowboat.c │ │ ├── whistle.c │ │ ├── whistlectrl.c │ │ └── whistleswitch.c │ ├── code_1570.c │ ├── code_640.c │ ├── code_9670.c │ ├── code_9840.c │ ├── code_CA0.c │ └── propellorctrl.c ├── SM │ ├── ch │ │ ├── attacktutorial.c │ │ ├── jumptutorial.c │ │ ├── smbottles.c │ │ └── vegetables.c │ ├── code_0.c │ ├── code_2900.c │ ├── code_3FC0.c │ ├── code_44D0.c │ ├── code_46C0.c │ ├── code_46C0.us.v10.c │ ├── code_5B0.c │ ├── code_BF0.c │ └── code_F0.c ├── TTC │ ├── ch │ │ ├── blubber.c │ │ ├── clam.c │ │ ├── leaky.c │ │ ├── lockup.c │ │ ├── nipper.c │ │ ├── treasure.c │ │ └── treasurehunt.c │ ├── code_26D0.c │ ├── code_3040.c │ └── ma │ │ └── castle.c ├── core1 │ ├── audio │ │ ├── auxbus.c │ │ ├── bnkf.c │ │ ├── cents2ratio.c │ │ ├── code_219D0.c │ │ ├── code_21A80.c │ │ ├── code_21AF0.c │ │ ├── code_21B50.c │ │ ├── copy.c │ │ ├── cseq.c │ │ ├── cspgettempo.c │ │ ├── cspplay.c │ │ ├── cspsetbank.c │ │ ├── cspsetseq.c │ │ ├── cspsettempo.c │ │ ├── cspsetvol.c │ │ ├── cspstop.c │ │ ├── drvrNew.c │ │ ├── env.c │ │ ├── event.c │ │ ├── filter.c │ │ ├── heapalloc.c │ │ ├── heapinit.c │ │ ├── load.c │ │ ├── mainbus.c │ │ ├── n_adpcm.c │ │ ├── n_auxbus.c │ │ ├── n_csplayer.c │ │ ├── n_csq.c │ │ ├── n_drvrNew.c │ │ ├── n_env.c │ │ ├── n_envresample.c │ │ ├── n_load.c │ │ ├── n_mainbus.c │ │ ├── n_resample.c │ │ ├── n_resample_add01.c_ │ │ ├── n_reverb.c │ │ ├── n_save.c │ │ ├── n_save_add01.c_ │ │ ├── n_seq.c │ │ ├── n_seqplayer.c │ │ ├── n_sl.c │ │ ├── n_synaddplayer.c │ │ ├── n_synallocfx.c │ │ ├── n_synallocvoice.c │ │ ├── n_syndelete.c │ │ ├── n_synfreevoice.c │ │ ├── n_synsetfxmix.c │ │ ├── n_synsetpan.c │ │ ├── n_synsetpitch.c │ │ ├── n_synsetpriority.c │ │ ├── n_synsetvol.c │ │ ├── n_synstartvoice.c │ │ ├── n_synstartvoiceparam.c │ │ ├── n_synstopvoice.c │ │ ├── n_synthesizer.c │ │ ├── resample.c │ │ ├── reverb.c │ │ ├── save.c │ │ ├── seq.c │ │ ├── sl.c │ │ ├── synallocfx.c │ │ ├── syndelete.c │ │ └── synthesizer.c │ ├── bamotor.c │ ├── code_0.c │ ├── code_11AC0.c │ ├── code_15B30.c │ ├── code_1BE90.c │ ├── code_1D00.c │ ├── code_1D5D0.c │ ├── code_3250.c │ ├── code_5650.c │ ├── code_660.c │ ├── code_7090.c │ ├── code_72B0.c │ ├── code_7F60.c │ ├── code_8C50.c │ ├── code_9D30.c │ ├── code_CE60.c │ ├── crccalc.c │ ├── data_1E820.c │ ├── defragmanager.c │ ├── depthbuffer.c │ ├── eeprom.c │ ├── framebufferdraw.c │ ├── gu │ │ ├── cosf.c │ │ ├── guint.h │ │ ├── mtxutil.c │ │ ├── normalize.c │ │ ├── ortho.c │ │ ├── rotate.c │ │ ├── sinf.c │ │ ├── sqrtf.c │ │ └── translate.c │ ├── inflate.c │ ├── initthread.c │ ├── io │ │ ├── ai.c │ │ ├── aigetlen.c │ │ ├── aisetfreq.c │ │ ├── aisetnextbuf.c │ │ ├── cartrominit.c │ │ ├── conteeplongread.c │ │ ├── conteeplongwrite.c │ │ ├── conteepread.c │ │ ├── conteepwrite.c │ │ ├── contpfs.c │ │ ├── contramread.c │ │ ├── contramwrite.c │ │ ├── contreaddata.c │ │ ├── controller.c │ │ ├── controller.h │ │ ├── contsetch.c │ │ ├── crc.c │ │ ├── devmgr.c │ │ ├── dpgetstat.c │ │ ├── dpsetstat.c │ │ ├── epirawdma.c │ │ ├── epirawread.c │ │ ├── epirawwrite.c │ │ ├── leodiskinit.c │ │ ├── leointerrupt.c │ │ ├── motor.c │ │ ├── pfschecker.c │ │ ├── pfsgetstatus.c │ │ ├── pfsinit.c │ │ ├── pfsisplug.c │ │ ├── piacs.c │ │ ├── pigetcmdq.c │ │ ├── pimgr.c │ │ ├── pirawdma.c │ │ ├── pirawread.c │ │ ├── piread.c │ │ ├── si.c │ │ ├── siacs.c │ │ ├── siint.h │ │ ├── sirawdma.c │ │ ├── sirawread.c │ │ ├── sirawwrite.c │ │ ├── sp.c │ │ ├── spgetstat.c │ │ ├── sprawdma.c │ │ ├── spsetpc.c │ │ ├── spsetstat.c │ │ ├── sptask.c │ │ ├── sptaskyield.c │ │ ├── sptaskyielded.c │ │ ├── vi.c │ │ ├── viblack.c │ │ ├── vigetcurrcontext.c │ │ ├── vigetcurrframebuf.c │ │ ├── vigetnextframebuf.c │ │ ├── vimgr.c │ │ ├── vimodempallan1.c │ │ ├── vimodentsclan1.c │ │ ├── vimodepallan1.c │ │ ├── visetevent.c │ │ ├── visetmode.c │ │ ├── visetspecial.c │ │ ├── viswapbuf.c │ │ └── viswapcontext.c │ ├── ll.c │ ├── ll_cvt.c │ ├── lookup.c │ ├── memory.c │ ├── ml.c │ ├── mlmtx.c │ ├── n_reverb_add01.c_ │ ├── n_reverb_add02.c_ │ ├── n_reverb_add03.c_ │ ├── n_reverb_add04.c_ │ ├── os │ │ ├── createmesgqueue.c │ │ ├── createthread.c │ │ ├── destroythread.c │ │ ├── getthreadpri.c │ │ ├── gettime.c │ │ ├── initialize.c │ │ ├── jammesg.c │ │ ├── kdebugserver.c │ │ ├── pidma.c │ │ ├── recvmesg.c │ │ ├── resetglobalintmask.c │ │ ├── sendmesg.c │ │ ├── seteventmesg.c │ │ ├── setglobalintmask.c │ │ ├── settimer.c │ │ ├── settreadpri.c │ │ ├── startthread.c │ │ ├── stopthread.c │ │ ├── stoptimer.c │ │ ├── thread.c │ │ ├── timerintr.c │ │ ├── virtualtophysical.c │ │ └── yieldthread.c │ ├── overlay.c │ ├── overlaymanager.c │ ├── pfsmanager.c │ ├── pimanager.c │ ├── sns.c │ ├── sprite.c │ ├── stub_13640.c │ ├── stub_1D590.c │ ├── stub_2FA0.c │ ├── stub_3A70.c │ ├── syncprintf.c │ ├── ucode.c │ ├── viewport.c │ └── vimgr.c ├── core2 │ ├── abilityprogress.c │ ├── anctrl.c │ ├── anim │ │ └── sprite.c │ ├── animcache.c │ ├── animtexturecache.c │ ├── anseq.c │ ├── ba │ │ ├── anim.c │ │ ├── carriedobj.c │ │ ├── carry.c │ │ ├── drone.c │ │ ├── falldamage.c │ │ ├── flap.c │ │ ├── marker.c │ │ ├── model.c │ │ └── physics.c │ ├── babuzz.c │ ├── baeyes.c │ ├── baflag.c │ ├── bainput.c │ ├── bakey.c │ ├── basfx.c │ ├── bastick.c │ ├── batimer.c │ ├── bs │ │ ├── ant.c │ │ ├── bBarge.c │ │ ├── bEggAss.c │ │ ├── bEggHead.c │ │ ├── bFlap.c │ │ ├── bFlip.c │ │ ├── bFly.c │ │ ├── bLongLeg.c │ │ ├── bPeck.c │ │ ├── bShock.c │ │ ├── bSwim.c │ │ ├── bTrot.c │ │ ├── bWhirl.c │ │ ├── bbuster.c │ │ ├── bee.c │ │ ├── beeFly.c │ │ ├── beeMain.c │ │ ├── carry.c │ │ ├── claw.c │ │ ├── climb.c │ │ ├── croc.c │ │ ├── crouch.c │ │ ├── die.c │ │ ├── drone.c │ │ ├── droneenter.c │ │ ├── dronegoto.c │ │ ├── dronelook.c │ │ ├── dronevanish.c │ │ ├── dronexform.c │ │ ├── jig.c │ │ ├── jump.c │ │ ├── ow.c │ │ ├── pumpkin.c │ │ ├── rebound.c │ │ ├── rest.c │ │ ├── sled.c │ │ ├── slide.c │ │ ├── splat.c │ │ ├── stand.c │ │ ├── surf.c │ │ ├── swim.c │ │ ├── talk.c │ │ ├── throw.c │ │ ├── timeout.c │ │ ├── turn.c │ │ ├── twirl.c │ │ ├── walk.c │ │ ├── walrus.c │ │ └── washy.c │ ├── bsList.c │ ├── bsStoredState.c │ ├── ch │ │ ├── badShad.c │ │ ├── bat.c │ │ ├── beehive.c │ │ ├── bigbutt.c │ │ ├── bottlesbonus.c │ │ ├── bottlesbonuscursor.c │ │ ├── bubble.c │ │ ├── clankerwhipcrack.c │ │ ├── climbBase.c │ │ ├── clucker.c │ │ ├── code_468E0.c │ │ ├── code_CFA60.c │ │ ├── collectible.c │ │ ├── crab.c │ │ ├── drips.c │ │ ├── firefx.c │ │ ├── flotsam.c │ │ ├── gameSelect.c │ │ ├── ghost.c │ │ ├── gloop.c │ │ ├── gravestone.c │ │ ├── icecube.c │ │ ├── jiggy.c │ │ ├── jigsawdance.c │ │ ├── jinjo.c │ │ ├── mole.c │ │ ├── molehill.c │ │ ├── musicnote.c │ │ ├── overlaycopyright.c │ │ ├── overlaynocontroller.c │ │ ├── overlaypressstart.c │ │ ├── shrapnel.c │ │ ├── snacker.c │ │ ├── snacker.h │ │ ├── snowball.c │ │ ├── snowman.c │ │ ├── snowmanhat.c │ │ ├── soundsource.c │ │ ├── termite.c │ │ ├── trainers.c │ │ ├── wadingboots.c │ │ └── whipcrack.c │ ├── climb.c │ ├── code_10CD0.c │ ├── code_11040.c │ ├── code_11460.c │ ├── code_11660.c │ ├── code_117D0.c │ ├── code_11870.c │ ├── code_12360.c │ ├── code_12F30.c │ ├── code_13780.c │ ├── code_13A00.c │ ├── code_14420.c │ ├── code_1550.c │ ├── code_15F20.c │ ├── code_16010.c │ ├── code_16C60.c │ ├── code_2240.c │ ├── code_33250.c │ ├── code_33310.c │ ├── code_336F0.c │ ├── code_33AB0.c │ ├── code_33C30.c │ ├── code_33F90.c │ ├── code_34310.c │ ├── code_34790.c │ ├── code_35520.c │ ├── code_379B0.c │ ├── code_37E50.c │ ├── code_3B2C0.c │ ├── code_3EAD0.c │ ├── code_3EC30.c │ ├── code_400F0.c │ ├── code_41460.c │ ├── code_41F30.c │ ├── code_41FB0.c │ ├── code_42CB0.c │ ├── code_43250.c │ ├── code_43800.c │ ├── code_43A40.c │ ├── code_45310.c │ ├── code_47BD0.c │ ├── code_4A6F0.c │ ├── code_4BD70.c │ ├── code_4BE10.c │ ├── code_4C020.c │ ├── code_50490.c │ ├── code_509D0.c │ ├── code_517A0.c │ ├── code_51950.c │ ├── code_53A10.c │ ├── code_53C10.c │ ├── code_54D50.c │ ├── code_55180.c │ ├── code_55390.c │ ├── code_556C0.c │ ├── code_55850.c │ ├── code_57C70.c │ ├── code_581D0.c │ ├── code_59780.c │ ├── code_599E0.c │ ├── code_59A80.c │ ├── code_5BEB0.c │ ├── code_5C240.c │ ├── code_5C870.c │ ├── code_5DBC0.c │ ├── code_5FB00.c │ ├── code_5FD80.c │ ├── code_5FD90.c │ ├── code_62FD0.c │ ├── code_630D0.c │ ├── code_63410.c │ ├── code_63690.c │ ├── code_637D0.c │ ├── code_654C0.c │ ├── code_66490.c │ ├── code_66D90.c │ ├── code_66FB0.c │ ├── code_67650.c │ ├── code_69F60.c │ ├── code_6A4B0.c │ ├── code_6AEF0.c │ ├── code_6B030.c │ ├── code_6B30.c │ ├── code_6CD20.c │ ├── code_6CEC0.c │ ├── code_6D030.c │ ├── code_6D270.c │ ├── code_6D490.c │ ├── code_6DA30.c │ ├── code_7060.c │ ├── code_70C30.c │ ├── code_70F20.c │ ├── code_71820.c │ ├── code_72060.c │ ├── code_72B10.c │ ├── code_73640.c │ ├── code_74090.c │ ├── code_74290.c │ ├── code_74420.c │ ├── code_74910.c │ ├── code_74ED0.c │ ├── code_75480.c │ ├── code_75930.c │ ├── code_75E90.c │ ├── code_77E50.c │ ├── code_7AF80.c │ ├── code_83340.c │ ├── code_851D0.c │ ├── code_857B0.c │ ├── code_85800.c │ ├── code_8DC20.c │ ├── code_90E0.c │ ├── code_91E10.c │ ├── code_9290.c │ ├── code_935F0.c │ ├── code_9450.c │ ├── code_94620.c │ ├── code_94780.c │ ├── code_94A20.c │ ├── code_956B0.c │ ├── code_98CB0.c │ ├── code_999A0.c │ ├── code_9A740.c │ ├── code_9A9D0.c │ ├── code_9B180.c │ ├── code_9B650.c │ ├── code_9B990.c │ ├── code_9BD0.c │ ├── code_9C170.c │ ├── code_9D640.c │ ├── code_9D760.c │ ├── code_9E370.c │ ├── code_A4D00.c │ ├── code_A5BC0.c │ ├── code_A600.c │ ├── code_A960.c │ ├── code_ABC00.c │ ├── code_AC520.c │ ├── code_AD110.c │ ├── code_AD5B0.c │ ├── code_AE290.c │ ├── code_AEDA0.c │ ├── code_B3580.c │ ├── code_B3A80.c │ ├── code_B5040.c │ ├── code_B5E00.c │ ├── code_B62B0.c │ ├── code_B6640.c │ ├── code_B6C60.c │ ├── code_B6EA0.c │ ├── code_B6EA0.h │ ├── code_B7F40.c │ ├── code_B8020.c │ ├── code_B8070.c │ ├── code_B8080.c │ ├── code_B850.c │ ├── code_B8860.c │ ├── code_B9090.c │ ├── code_B9770.c │ ├── code_BD100.c │ ├── code_BDCC0.c │ ├── code_BE2C0.c │ ├── code_BEF20.c │ ├── code_C0B80.c │ ├── code_C0CF0.c │ ├── code_C0E60.c │ ├── code_C2F30.c │ ├── code_C31A0.c │ ├── code_C3A40.c │ ├── code_C4320.c │ ├── code_C4B0.c │ ├── code_C4F40.c │ ├── code_C5440.c │ ├── code_C5AF0.c │ ├── code_C5CC0.c │ ├── code_C5F00.c │ ├── code_C61C0.c │ ├── code_C62B0.c │ ├── code_C76D0.c │ ├── code_C7CC0.c │ ├── code_C8230.c │ ├── code_C8360.c │ ├── code_C8490.c │ ├── code_C8760.c │ ├── code_C89C0.c │ ├── code_C97F0.c │ ├── code_C9E70.c │ ├── code_C9E70.h │ ├── code_C9F00.c │ ├── code_CB050.c │ ├── code_CB610.c │ ├── code_CB8A0.c │ ├── code_CBBF0.c │ ├── code_CBD10.c │ ├── code_CC1E0.c │ ├── code_CD0A0.c │ ├── code_CD3F0.c │ ├── code_CD6E0.c │ ├── code_CECD0.c │ ├── code_CF090.c │ ├── code_CF3E0.c │ ├── code_CF5F0.c │ ├── code_D0CA0.c │ ├── code_D2180.c │ ├── code_D5D10.c │ ├── code_D5FD0.c │ ├── code_D6180.c │ ├── code_D6600.c │ ├── code_D9B0.c │ ├── code_DA3A0.c │ ├── code_DA760.c │ ├── code_DAAA0.c │ ├── code_DB010.c │ ├── code_DC4B0.c │ ├── code_E910.c │ ├── code_EE40.c │ ├── code_EF50.c │ ├── code_F8EAF0.c │ ├── coords.c │ ├── eggshatter.c │ ├── file.c │ ├── fla.c │ ├── fx │ │ ├── airscore.c │ │ ├── common1score.c │ │ ├── common2score.c │ │ ├── common3score.c │ │ ├── healthscore.c │ │ ├── honeycarrierscore.c │ │ ├── jinjoscore.c │ │ ├── lifescore.c │ │ ├── ripple.c │ │ └── sparkle.c │ ├── gc │ │ ├── bound.c │ │ ├── dialog.c │ │ ├── parade.c │ │ ├── pauseMenu.c │ │ ├── section.c │ │ ├── sky.c │ │ ├── transition.c │ │ ├── zoombox.c │ │ └── zoombox.h │ ├── honeycombscore.c │ ├── jiggyscore.c │ ├── levelspecificflags.c │ ├── mapModel.c │ ├── mapspecificflags.c │ ├── modelRender.c │ ├── mumboscore.c │ ├── nc │ │ ├── cameranodelist.c │ │ ├── dynamicCam1.c │ │ ├── dynamicCam10.c │ │ ├── dynamicCam11.c │ │ ├── dynamicCam12.c │ │ ├── dynamicCam13.c │ │ ├── dynamicCam3.c │ │ ├── dynamicCam4.c │ │ ├── dynamicCam5.c │ │ ├── dynamicCam8.c │ │ ├── dynamicCam9.c │ │ ├── dynamicCamA.c │ │ ├── dynamicCamB.c │ │ ├── dynamicCamC.c │ │ ├── dynamicCamD.c │ │ ├── dynamicCamF.c │ │ ├── dynamicCamera.c │ │ ├── firstpersoncamera.c │ │ ├── randomCamera.c │ │ └── staticCamera.c │ ├── particle.c │ ├── pitch.c │ ├── playerutils.c │ ├── quizquestionaskedbitfield.c │ ├── rand.c │ ├── roll.c │ ├── skeletalanim.c │ ├── snackerctl.c │ ├── snackerctl.h │ ├── spawnqueue.c │ ├── statetimer.c │ ├── string.c │ ├── time.c │ ├── timedfuncqueue.c │ ├── vla.c │ └── yaw.c ├── cutscenes │ ├── bss_pad.c │ ├── code_0.c │ ├── code_60F0.c │ ├── code_6730.c │ ├── code_69F0.c │ └── code_6C90.c ├── done │ ├── bk_boot_1050.c │ ├── cartrominit.c │ ├── createmesgqueue.c │ ├── createthread.c │ ├── destroythread.c │ ├── devmgr.c │ ├── epirawdma.c │ ├── epirawread.c │ ├── epirawwrite.c │ ├── getthreadpri.c │ ├── inflate.c │ ├── initialize.c │ ├── kdebugserver.c │ ├── leodiskinit.c │ ├── leointerrupt.c │ ├── ll.c │ ├── overlays.c │ ├── piacs.c │ ├── pigetstat.c │ ├── pimgr.c │ ├── pirawdma.c │ ├── pirawread.c │ ├── rarezip.c │ ├── recvmesg.c │ ├── resetglobalintmask.c │ ├── sendmesg.c │ ├── seteventmesg.c │ ├── setglobalintmask.c │ ├── setthreadpri.c │ ├── si.c │ ├── sirawread.c │ ├── sirawwrite.c │ ├── startthread.c │ ├── thread.c │ ├── virtualtophysical.c │ └── yieldthread.c ├── emptyLvl │ └── code_0.c ├── fight │ ├── chbossjinjo.c │ ├── chbossjinjobase.c │ ├── chbossshadow.c │ ├── chfinalboss.c │ ├── chgreenblast.c │ ├── chjinjonator.c │ ├── chjinjonatorbase.c │ ├── chspellbarrier.c │ ├── chspellfireball.c │ ├── chstonejinjo.c │ ├── fight.c │ └── fight.h └── lair │ ├── bss_pad.c │ ├── ch │ ├── brentilda.c │ └── cauldron.c │ ├── code_0.c │ ├── code_5ED0.c │ ├── code_86F0.c │ ├── code_9C40.c │ ├── code_A170.c │ ├── code_A430.c │ ├── code_A4A0.c │ ├── code_A810.c │ ├── code_AD70.c │ ├── code_BBD0.c │ ├── code_C1C0.c │ └── code_C6C0.c ├── symbol_addrs.pal.txt ├── symbol_addrs.us.v10.txt └── tools ├── decomp_me_ctx.sh ├── generate_asset_enums.py ├── m2ctx.py ├── mips_to_c_ctx.sh ├── progress.py ├── progress_read.py ├── rareunzip.py ├── set_o32abi_bit.py ├── sound_func_val_unwrap └── splat_inputs.py /.dockerignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | .gitlab-ci.yml 3 | Dockerfile 4 | README.md 5 | LICENSE 6 | 7 | asm/ 8 | assets/ 9 | include/ 10 | ido/ 11 | build/ 12 | bin/ 13 | src/ 14 | 15 | baserom* 16 | *.z64 17 | 18 | Makefile 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ignore all rom files 2 | baseroms/* 3 | *.z64 4 | *.n64 5 | *.v64 6 | 7 | #compiled or ripped asm 8 | asm/nonmatchings 9 | asm/*.s 10 | asm/*/*.s 11 | asm/core1/os 12 | !asm/ultra 13 | !asm/core1/ultra 14 | build/* 15 | build/ 16 | 17 | #binaries ripped from the ROMs 18 | assets/ 19 | assets/* 20 | bin/ 21 | bin/* 22 | tools/bk_crc/bk_crc 23 | 24 | # This folder will hold modified asset binaries 25 | # these assets will override the original game 26 | # assets in the bin/ at compile time. 27 | mod/ 28 | mod/* 29 | 30 | 31 | #compiled object files 32 | *.slo 33 | *.lo 34 | *.o 35 | *.obj 36 | 37 | #Precompiled Headers 38 | *.gch 39 | *.pch 40 | 41 | #compiled dynamic libraries 42 | *.so 43 | *.dylib 44 | *.dll 45 | 46 | #static libraries 47 | *.lai 48 | *.la 49 | *.a 50 | *.lib 51 | 52 | #misc 53 | __pycache__/ 54 | *__pycache__/ 55 | expected/ 56 | .*/ 57 | !.gitlab/ 58 | *.ld 59 | *.map 60 | *auto.txt 61 | .splat_cache 62 | .splat_cache* 63 | diff_settings.py 64 | ctx.c 65 | nonmatchings/ 66 | undefined_syms_auto* 67 | undefined_funcs_auto* 68 | 69 | #progress reports 70 | *.csv 71 | 72 | #secret folder 73 | tmp/ 74 | tmp/* 75 | -------------------------------------------------------------------------------- /.gitlab/merge_request_templates/default.md: -------------------------------------------------------------------------------- 1 | ## What Type Of PR Is This? (Check All Applicable) 2 | - [ ] Feature 3 | - [ ] Bug Fix 4 | - [ ] Documentation Update 5 | - [ ] Revert 6 | - [ ] Other 7 | 8 | ## Describe Your Changes 9 | 10 | ## Checklist Before Requesting A Review 11 | - [ ] Running 'Make' results in 'OK' for version us.v10 12 | - [ ] Documentation follows the writing style found in [Style-Guide](https://gitlab.com/banjo.decomp/banjo-kazooie/-/wikis/Style-Guide) -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tools/asm-differ"] 2 | path = tools/asm-differ 3 | url = https://github.com/simonlindholm/asm-differ.git 4 | [submodule "tools/asm-processor"] 5 | path = tools/asm-processor 6 | url = https://github.com/simonlindholm/asm-processor.git 7 | [submodule "tools/n64splat"] 8 | path = tools/n64splat 9 | url = https://github.com/ethteck/splat 10 | [submodule "tools/ido-static-recomp"] 11 | path = tools/ido-static-recomp 12 | url = https://github.com/Emill/ido-static-recomp.git 13 | [submodule "tools/bk_asset_tool"] 14 | path = tools/bk_asset_tool 15 | url = https://github.com/MittenzHugg/bk_asset_tool.git 16 | [submodule "tools/bk_rom_compressor"] 17 | path = tools/bk_rom_compressor 18 | url = https://github.com/MittenzHugg/bk_rom_compressor.git 19 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 AS build 2 | ENV DEBIAN_FRONTEND=noninteractive 3 | 4 | # (for debug purposes) 5 | RUN echo "System arch: $(uname -a)\nDPKG arch: $(dpkg --print-architecture)" 6 | 7 | # Install package dependencies 8 | COPY packages.txt ./ 9 | RUN apt-get update && apt-get install -y $(cat packages.txt) && rm packages.txt 10 | 11 | # Install Rust/Cargo 12 | # NOTE: We replace /proc/self/exe with /bin/sh in the script to avoid issues with Docker 13 | RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sed 's#/proc/self/exe#\/bin\/sh#g' | CARGO_HOME=/opt/cargo sh -s -- -y 14 | ENV PATH=/opt/cargo/bin:$PATH 15 | 16 | # Install Python dependencies 17 | COPY requirements.txt ./ 18 | COPY tools/n64splat/requirements.txt ./tools/n64splat/requirements.txt 19 | RUN python3 -m pip install -r requirements.txt 20 | 21 | WORKDIR /banjo 22 | ENTRYPOINT ["/bin/bash", "-c"] 23 | -------------------------------------------------------------------------------- /asm/core1/ultra/libm_vals.s: -------------------------------------------------------------------------------- 1 | .rdata 2 | .align 4 3 | .globl __libm_qnan_f 4 | __libm_qnan_f: 5 | .word 0x7F810000 6 | -------------------------------------------------------------------------------- /asm/core1/ultra/parameters.s: -------------------------------------------------------------------------------- 1 | #include "PR/R4300.h" 2 | #include "sys/asm.h" 3 | #include "sys/regdef.h" 4 | 5 | .text 6 | ABS(leoBootID, 0x800001a0) 7 | ABS(osTvType, 0x80000300) 8 | ABS(osRomType, 0x80000304) 9 | ABS(osRomBase, 0x80000308) 10 | ABS(osResetType, 0x8000030c) 11 | ABS(osCicId, 0x80000310) 12 | ABS(osVersion, 0x80000314) 13 | ABS(osMemSize, 0x80000318) 14 | ABS(osAppNMIBuffer, 0x8000031c) 15 | 16 | .space 0x60 17 | /* padded to 0x60 in the object file */ 18 | -------------------------------------------------------------------------------- /asm/ultra/parameters.s: -------------------------------------------------------------------------------- 1 | #include "PR/R4300.h" 2 | #include "sys/asm.h" 3 | #include "sys/regdef.h" 4 | 5 | .text 6 | ABS(leoBootID, 0x800001a0) 7 | ABS(osTvType, 0x80000300) 8 | ABS(osRomType, 0x80000304) 9 | ABS(osRomBase, 0x80000308) 10 | ABS(osResetType, 0x8000030c) 11 | ABS(osCicId, 0x80000310) 12 | ABS(osVersion, 0x80000314) 13 | ABS(osMemSize, 0x80000318) 14 | ABS(osAppNMIBuffer, 0x8000031c) 15 | 16 | .space 0x60 17 | /* padded to 0x60 in the object file */ 18 | -------------------------------------------------------------------------------- /diff: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | python3 ./tools/asm-differ/diff.py -wm3 $1 4 | 5 | 6 | -------------------------------------------------------------------------------- /ido/ido5.3_recomp/Makefile: -------------------------------------------------------------------------------- 1 | IRIX_ROOT := ../ido5.3_compiler 2 | 3 | cc: OPT_CFLAGS := -O2 4 | cfe: OPT_CFLAGS := -O2 5 | uopt: OPT_CFLAGS := -O2 6 | ugen: OPT_CFLAGS := -O2 7 | as1: OPT_CFLAGS := -O2 8 | acpp: OPT_CFLAGS := -O2 9 | 10 | RECOMP := recomp 11 | 12 | ugen_c.c: RECOMP_FLAGS := --conservative 13 | 14 | all: cc cfe uopt ugen as1 acpp copt ujoin uld umerge usplit err.english.cc 15 | 16 | clean: 17 | $(RM) cc* cfe* uopt* ugen* as1* acpp* copt* ujoin* uld* umerge* usplit* err.english.cc $(RECOMP) libc_impl.o 18 | 19 | $(RECOMP): recomp.cpp 20 | $(CXX) $^ -o $@ -std=c++11 -O2 -Wno-switch `pkg-config --cflags --libs capstone` 21 | 22 | libc_impl.o: libc_impl.c libc_impl.h 23 | $(CC) $< -c -fno-strict-aliasing -O2 -DIDO53 24 | 25 | err.english.cc: $(IRIX_ROOT)/usr/lib/err.english.cc 26 | cp $^ $@ 27 | 28 | cc_c.c: $(IRIX_ROOT)/usr/bin/cc $(RECOMP) 29 | ./$(RECOMP) $(RECOMP_FLAGS) $< > $@ 30 | 31 | %_c.c: $(IRIX_ROOT)/usr/lib/% $(RECOMP) 32 | ./$(RECOMP) $(RECOMP_FLAGS) $< > $@ 33 | 34 | %: %_c.c libc_impl.o 35 | $(CC) libc_impl.o $< -o $@ $(OPT_CFLAGS) -fno-strict-aliasing -lm -no-pie 36 | 37 | .PHONY: all clean 38 | -------------------------------------------------------------------------------- /ido/ido5.3_recomp/acpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n64decomp/banjo-kazooie/fd208f77ca80cc07a7adbeb205a3c40dd8fa4539/ido/ido5.3_recomp/acpp -------------------------------------------------------------------------------- /ido/ido5.3_recomp/as1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n64decomp/banjo-kazooie/fd208f77ca80cc07a7adbeb205a3c40dd8fa4539/ido/ido5.3_recomp/as1 -------------------------------------------------------------------------------- /ido/ido5.3_recomp/cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n64decomp/banjo-kazooie/fd208f77ca80cc07a7adbeb205a3c40dd8fa4539/ido/ido5.3_recomp/cc -------------------------------------------------------------------------------- /ido/ido5.3_recomp/cfe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n64decomp/banjo-kazooie/fd208f77ca80cc07a7adbeb205a3c40dd8fa4539/ido/ido5.3_recomp/cfe -------------------------------------------------------------------------------- /ido/ido5.3_recomp/copt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n64decomp/banjo-kazooie/fd208f77ca80cc07a7adbeb205a3c40dd8fa4539/ido/ido5.3_recomp/copt -------------------------------------------------------------------------------- /ido/ido5.3_recomp/header.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "libc_impl.h" 9 | #include "helpers.h" 10 | 11 | #define RM_RN 0 12 | #define RM_RZ 1 13 | #define RM_RP 2 14 | #define RM_RM 3 15 | 16 | union FloatReg { 17 | float f[2]; 18 | uint32_t w[2]; 19 | double d; 20 | }; 21 | 22 | #define cvt_w_d(f) \ 23 | ((fcsr & RM_RZ) ? ((isnan(f) || f <= -2147483649.0 || f >= 2147483648.0) ? (fcsr |= 0x40, 2147483647) : (int)f) : (assert(0), 0)) 24 | 25 | #define cvt_w_s(f) cvt_w_d((double)f) 26 | 27 | static union FloatReg f0 = {{0, 0}}, f2 = {{0, 0}}, f4 = {{0, 0}}, f6 = {{0, 0}}, f8 = {{0, 0}}, 28 | f10 = {{0, 0}}, f12 = {{0, 0}}, f14 = {{0, 0}}, f16 = {{0, 0}}, f18 = {{0, 0}}, f20 = {{0, 0}}, 29 | f22 = {{0, 0}}, f24 = {{0, 0}}, f26 = {{0, 0}}, f28 = {{0, 0}}, f30 = {{0, 0}}; 30 | static uint32_t fcsr = 1; 31 | -------------------------------------------------------------------------------- /ido/ido5.3_recomp/helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef HELPERS_H 2 | #define HELPERS_H 3 | 4 | #include 5 | 6 | #define MEM_U32(a) (*(uint32_t *)(mem + a)) 7 | #define MEM_S32(a) (*(int32_t *)(mem + a)) 8 | #define MEM_U16(a) (*(uint16_t *)(mem + ((a) ^ 2))) 9 | #define MEM_S16(a) (*(int16_t *)(mem + ((a) ^ 2))) 10 | #define MEM_U8(a) (*(uint8_t *)(mem + ((a) ^ 3))) 11 | #define MEM_S8(a) (*(int8_t *)(mem + ((a) ^ 3))) 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /ido/ido5.3_recomp/recomp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n64decomp/banjo-kazooie/fd208f77ca80cc07a7adbeb205a3c40dd8fa4539/ido/ido5.3_recomp/recomp -------------------------------------------------------------------------------- /ido/ido5.3_recomp/ugen: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n64decomp/banjo-kazooie/fd208f77ca80cc07a7adbeb205a3c40dd8fa4539/ido/ido5.3_recomp/ugen -------------------------------------------------------------------------------- /ido/ido5.3_recomp/ujoin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n64decomp/banjo-kazooie/fd208f77ca80cc07a7adbeb205a3c40dd8fa4539/ido/ido5.3_recomp/ujoin -------------------------------------------------------------------------------- /ido/ido5.3_recomp/uld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n64decomp/banjo-kazooie/fd208f77ca80cc07a7adbeb205a3c40dd8fa4539/ido/ido5.3_recomp/uld -------------------------------------------------------------------------------- /ido/ido5.3_recomp/umerge: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n64decomp/banjo-kazooie/fd208f77ca80cc07a7adbeb205a3c40dd8fa4539/ido/ido5.3_recomp/umerge -------------------------------------------------------------------------------- /ido/ido5.3_recomp/uopt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n64decomp/banjo-kazooie/fd208f77ca80cc07a7adbeb205a3c40dd8fa4539/ido/ido5.3_recomp/uopt -------------------------------------------------------------------------------- /ido/ido5.3_recomp/usplit: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/n64decomp/banjo-kazooie/fd208f77ca80cc07a7adbeb205a3c40dd8fa4539/ido/ido5.3_recomp/usplit -------------------------------------------------------------------------------- /include/2.0L/PR/os_version.h: -------------------------------------------------------------------------------- 1 | 2 | /*---------------------------------------------------------------------* 3 | Copyright (C) 1998 Nintendo. 4 | 5 | $RCSfile: os_version.h,v $ 6 | $Revision: 1.2 $ 7 | $Date: 1999/06/17 01:33:01 $ 8 | *---------------------------------------------------------------------*/ 9 | 10 | #ifndef _OS_VERSION_H_ 11 | #define _OS_VERSION_H_ 12 | 13 | #define OS_MAJOR_VERSION "2.0K" /* major version */ 14 | #define OS_MINOR_VERSION 0 /* patch level */ 15 | 16 | #endif /* !_OS_VERSION_H_ */ 17 | -------------------------------------------------------------------------------- /include/animation.h: -------------------------------------------------------------------------------- 1 | #ifndef ANIMATION_H 2 | #define ANIMATION_H 3 | 4 | #include "prop.h" 5 | size_t anim_getSize(void); 6 | enum asset_e anim_getIndex(Animation *this); 7 | f32 anim_getTimer(Animation *this); 8 | f32 anim_getDuration(Animation *this); 9 | void anim_new(Animation *this, bool arg1); 10 | void anim_setTimer(Animation *this, f32 arg1); 11 | void anim_80289790(Animation* this, void (*arg1)(s32, s32)); 12 | void anim_80289798(Animation *this, s32 arg1); 13 | void anim_setDuration(Animation *this, f32 arg1); 14 | 15 | //represents the transformation on a given model bone 16 | 17 | 18 | typedef union 19 | { 20 | struct{ 21 | u16 unk0_15: 1; 22 | u16 unk0_14: 1; 23 | u16 unk0_13: 14; 24 | s16 unk2; 25 | }; 26 | }AnimationFileData; 27 | 28 | 29 | typedef struct animation_file_elem_s{ 30 | u16 unk0_15:12; 31 | u16 unk0_3:4; 32 | s16 data_cnt; 33 | AnimationFileData data[]; 34 | }AnimationFileElement; 35 | 36 | typedef struct animation_file_s{ 37 | s16 unk0; 38 | s16 unk2; 39 | s16 elem_cnt; 40 | u8 pad6[2]; 41 | } AnimationFile; 42 | 43 | 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /include/assets.h: -------------------------------------------------------------------------------- 1 | #ifndef ASSETS_H 2 | #define ASSETS_H 3 | 4 | #include 5 | #include "structs.h" 6 | 7 | typedef struct asset_rom_table_head_s{ 8 | u32 count; 9 | u32 unk4; 10 | } AssetROMHead; 11 | 12 | typedef struct asset_file_meta_s{ 13 | u32 offset; 14 | s16 compFlag; 15 | s16 unk6; 16 | } AssetFileMeta; 17 | 18 | 19 | extern u8 assets_ROM_START[]; //rom file asset bin; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /include/bool.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef BANJO_KAZOOIE_BOOL_H 4 | #define BANJO_KAZOOIE_BOOL_H 5 | 6 | typedef int bool; 7 | #define NOT(boolean) ((boolean) ^ 1) 8 | #define BOOL(boolean) ((boolean) ? TRUE : FALSE) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /include/core1/eeprom.h: -------------------------------------------------------------------------------- 1 | #ifndef BANJO_KAZOOIE_CORE1_EEPROM_H 2 | #define BANJO_KAZOOIE_CORE1_EEPROM_H 3 | 4 | s32 eeprom_writeBlocks(s32 file, s32 offset, void *buffer, s32 count); 5 | s32 eeprom_readBlocks(s32 file, s32 offset, void *buffer, s32 count); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /include/core1/lookup.h: -------------------------------------------------------------------------------- 1 | #ifndef BANJO_KAZOOIE_CORE1_LOOKUP_H 2 | #define BANJO_KAZOOIE_CORE1_LOOKUP_H 3 | 4 | enum comusic_e lookup_getCoMusicId(s32 idx); 5 | enum sfx_e lookup_getSfxId(s32 idx); 6 | enum asset_e lookup_getAnimAssetId(s32 idx); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /include/core1/main.h: -------------------------------------------------------------------------------- 1 | #ifndef BANJO_KAZOOIE_CORE1_MAIN_H 2 | #define BANJO_KAZOOIE_CORE1_MAIN_H 3 | 4 | void func_8023DA20(s32 arg0); 5 | void func_8023DA74(void); 6 | void func_8023DA9C(s32 arg0); 7 | u32 globalTimer_getTimeMasked(u32 mask); 8 | //s32 globalTimer_getTime(void); 9 | void globalTimer_reset(void); 10 | enum map_e getSpecialBootMap(void); 11 | enum map_e getDefaultBootMap(void); 12 | void func_8023DBAC(void); 13 | void func_8023DBDC(void); 14 | void core1_init(void); 15 | void globalTimer_incTimer(void); 16 | void globalTimer_decTimer(void); 17 | void mainLoop(void); 18 | void mainThread_entry(void *arg); 19 | void func_8023DFF0(s32 arg0); 20 | s32 func_8023E000(void); 21 | void setBootMap(enum map_e map_id); 22 | void mainThread_create(void); 23 | OSThread *mainThread_get(void); 24 | void disableInput_set(void); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /include/core1/mem.h: -------------------------------------------------------------------------------- 1 | #ifndef BANJO_KAZOOIE_CORE1_MEMORY_H 2 | #define BANJO_KAZOOIE_CORE1_MEMORY_H 3 | 4 | /** 5 | * copy memory area 6 | */ 7 | void memcpy(void * dst, void *src, int size); 8 | 9 | /** 10 | * copy an array of wide_characters 11 | */ 12 | void wmemcpy(void * dst, void *src, int size); 13 | 14 | 15 | /** 16 | * copy memory area 17 | */ 18 | void memmove(u8* dst, u8* src, s32 n); 19 | #endif 20 | -------------------------------------------------------------------------------- /include/core1/sprite.h: -------------------------------------------------------------------------------- 1 | #ifndef BANJO_KAZOOIE_CORE1_SPRITE_H 2 | #define BANJO_KAZOOIE_CORE1_SPRITE_H 3 | 4 | u32 sprite_getUnk8(BKSprite *this); 5 | u32 sprite_getUnkA(BKSprite *this); 6 | u32 sprite_getUnk6(BKSprite *this); 7 | u32 sprite_getUnk4(BKSprite *this); 8 | s32 sprite_getFrameCount(BKSprite *this); 9 | BKSpriteFrame *sprite_getFramePtr(BKSprite *this, u32 frame_id); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /include/core1/ucode.h: -------------------------------------------------------------------------------- 1 | #ifndef BANJO_KAZOOIE_CORE1_UCODE_H 2 | #define BANJO_KAZOOIE_CORE1_UCODE_H 3 | 4 | void ucode_load(void); 5 | void ucode_stub1(void); // does nothing 6 | void ucode_stub2(void); // performs dummy read on PI 7 | s32 ucode_stub3(void); // returns always 0 8 | void ucode_getPtrAndSize(void **ptr, u32 *size); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /include/core1/vimgr.h: -------------------------------------------------------------------------------- 1 | #ifndef BANJO_KAZOOIE_CORE1_VIMGR_H 2 | #define BANJO_KAZOOIE_CORE1_VIMGR_H 3 | 4 | typedef struct struct_1_s{ 5 | OSMesgQueue *messageQueue; 6 | OSMesg message; 7 | } struct1; 8 | 9 | u32 getOtherFramebuffer(void); 10 | s32 viMgr_func_8024BD94(void); 11 | s32 getActiveFramebuffer(void); 12 | void viMgr_func_8024BDAC(OSMesgQueue *mq, OSMesg msg); 13 | void viMgr_init(void); 14 | void viMgr_func_8024BF94(s32 arg0); 15 | s32 viMgr_func_8024BFA0(void); 16 | void viMgr_func_8024BFAC(void); 17 | void viMgr_func_8024BFD8(s32 arg0); 18 | void viMgr_func_8024C1B4(void); 19 | void viMgr_func_8024C1DC(void); 20 | void viMgr_func_8024C1FC(OSMesgQueue *mq, OSMesg msg); 21 | void viMgr_setActiveFramebuffer(s32 arg0); 22 | void viMgr_entry(void *arg0); 23 | void viMgr_setScreenBlack(s32 active); 24 | void viMgr_clearFramebuffers(void); 25 | s32 viMgr_func_8024C4E8(void); 26 | void viMgr_func_8024C4F8(s32 arg0); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /include/core2/ba/anim.h: -------------------------------------------------------------------------------- 1 | #ifndef __CORE2_BA_ANIM_H__ 2 | #define __CORE2_BA_ANIM_H__ 3 | 4 | enum baanim_update_type_e { 5 | BAANIM_UPDATE_0_NONE, 6 | BAANIM_UPDATE_1_NORMAL, 7 | BAANIM_UPDATE_2_SCALE_HORZ, 8 | BAANIM_UPDATE_3_SCALE_VERT 9 | }; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /include/core2/ba/carry.h: -------------------------------------------------------------------------------- 1 | #ifndef __BA_CARRY_H__ 2 | #define __BA_CARRY_H__ 3 | 4 | #include 5 | #include "prop.h" 6 | 7 | void bacarry_init(void); 8 | void bacarry_end(void); 9 | void bacarry_update(void); 10 | 11 | void bacarry_reset_marker(void); 12 | ActorMarker *bacarry_get_marker(void); 13 | void bacarry_set_marker(ActorMarker *arg0); 14 | void bacarry_set_offsets(f32 height, f32 rotation); 15 | 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /include/core2/ba/drone.h: -------------------------------------------------------------------------------- 1 | #ifndef __BA_DRONE_H__ 2 | #define __BA_DRONE_H__ 3 | 4 | #include 5 | #include "prop.h" 6 | 7 | typedef enum ba_drone_type_e{ 8 | BA_DRONE_NONE, 9 | BA_DRONE_GOTO, 10 | BA_DRONE_LOOK, 11 | BA_DRONE_UNKNOWN_3, 12 | BA_DRONE_TRANSFORM, 13 | BA_DRONE_ENTER, 14 | BA_DRONE_VANISH 15 | } BaDroneType; 16 | 17 | void badrone_set_type(BaDroneType type); 18 | BaDroneType badrone_get_type(void); 19 | void badrone_get_position_and_duration(f32 position[3], f32 *duration); 20 | 21 | enum bs_e badrone_enter(void); 22 | enum bs_e badrone_goto(f32 position[3], f32 duration, void (*arg2)(ActorMarker *), ActorMarker *arg3); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /include/core2/ba/flap.h: -------------------------------------------------------------------------------- 1 | #ifndef __BA_FLAP_H__ 2 | #define __BA_FLAP_H__ 3 | 4 | #include 5 | 6 | s32 baflap_getCount(void); 7 | bool baflap_add(f32 duration); 8 | void baflap_reset(void); 9 | void baflap_activate(bool active); 10 | void baflap_update(void); 11 | 12 | 13 | #endif // __BA_FLAP_H__ -------------------------------------------------------------------------------- /include/core2/ba/model.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLAYER_MODEL_H_ 2 | #define _PLAYER_MODEL_H_ 3 | 4 | enum player_model_direction_e { 5 | PLAYER_MODEL_DIR_BANJO = 1, 6 | PLAYER_MODEL_DIR_KAZOOIE = 2, 7 | PLAYER_MODEL_DIR_GLOBAL = 3 8 | }; 9 | 10 | void baModel_80292048(s32, f32, f32, f32); 11 | void baModel_setDirection(enum player_model_direction_e arg0); 12 | void baModel_setScale(f32); 13 | void baModel_setYDisplacement(f32); 14 | void baModel_8029217C(f32); 15 | void baModel_setVisible(s32 arg0); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /include/core2/ba/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __BA_TIMER_H__ 2 | #define __BA_TIMER_H__ 3 | 4 | #include 5 | 6 | void batimer_incrementBy(s32 id, f32 inc_value_sec); 7 | int batimer_decrement(s32 id); 8 | void batimer_increment(s32 id); 9 | f32 batimer_get(s32 id); 10 | int batimer_isAt(s32 id, f32 value_sec); 11 | int batimer_isLessThan(s32 id, f32 value_sec); 12 | int batimer_isGreaterThan(s32 id, f32 value_sec); 13 | int batimer_isNonzero(s32 id); 14 | int batimer_isZero(s32 id); 15 | void batimer_set(s32 id, f32 value_sec); 16 | #endif 17 | -------------------------------------------------------------------------------- /include/core2/bonetransform.h: -------------------------------------------------------------------------------- 1 | #ifndef _BONE_TRANSFORMATION_H_ 2 | #define _BONE_TRANSFORMATION_H_ 3 | #include 4 | 5 | typedef struct { 6 | f32 unk0[4]; 7 | f32 scale[3]; 8 | f32 unk1C[3]; 9 | }BoneTransform; 10 | 11 | typedef struct bone_transform_list_s{ 12 | BoneTransform *ptr; 13 | s32 count; 14 | }BoneTransformList; 15 | #endif 16 | -------------------------------------------------------------------------------- /include/core2/code_6DA30.h: -------------------------------------------------------------------------------- 1 | #ifndef __CORE2_6DA30__ 2 | #define __CORE2_6DA30__ 3 | 4 | void print_bold_overlapping(s32 x, s32 y, f32 arg2, u8* string); 5 | void print_bold_spaced(s32 x, s32 y, u8* string); 6 | void print_dialog(s32 x, s32 y, u8* string); 7 | void print_dialog_w_bg(s32 x, s32 y, u8* string); 8 | void print_dialog_gradient(s32 x, s32 y, u8* string, u8 arg3, u8 arg4); 9 | void func_802F79D0(s32 x, s32 y, u8* string, s32 arg3, s32 arg4); 10 | #endif 11 | -------------------------------------------------------------------------------- /include/core2/coords.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "bool.h" 3 | 4 | void coords_copy(s32 min_out[3], s32 max_out[3], s32 min_in[3], s32 max_in[3]); 5 | s32 coords_func_8033EAF8(s32 min[3], s32 max[3], f32 position[3], f32 direction[3]); 6 | bool coords_isPointInside(s32 min[3], s32 max[3], s32 point[3]); 7 | bool coords_isPointInsideWithOffset(s32 min[3], s32 max[3], s32 point[3], s32 offset); 8 | void coords_scale(s32 min[3], s32 max[3], s32 ratio); 9 | void coords_translate(s32 min[3], s32 max[3], f32 translation[3]); 10 | -------------------------------------------------------------------------------- /include/core2/core2.h: -------------------------------------------------------------------------------- 1 | #ifndef __CORE_2_H__ 2 | #define __CORE_2_H__ 3 | 4 | #include "core2/timedfunc.h" 5 | #include "gc/gc.h" 6 | #include "core2/code_6DA30.h" 7 | #include "core2/anctrl.h" 8 | 9 | void func_80351A04(Struct68s *arg0, s32 arg1); 10 | void func_80351A14(Struct68s *arg0, Struct68DrawMethod arg1); 11 | void func_8035179C_copyPosition(Struct68s* arg0, f32 arg1[3]); 12 | void func_80351814(Struct68s *arg0, f32 arg1[3]); 13 | f32 func_80351830(Struct68s *arg0); 14 | 15 | 16 | extern void sfxsource_setSampleRate(u8, s32); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /include/core2/lighting.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIGHTING_H_ 2 | #define _LIGHTING_H_ 3 | #include 4 | 5 | typedef struct { 6 | f32 position[3]; 7 | f32 positionCopy[3]; 8 | f32 unk18; // unk 9 | f32 unk1C; // unk 10 | f32 unk20; // result of unk18 / actor scale, some sort of distance 11 | f32 unk24; // result of unk1C / actor scale, some sort of distance (determines whether to modify rgb of vertex) 12 | s32 rgb[3]; // rgb 13 | u8 unk34; // some sort of flag 14 | u8 pad35[0x3]; 15 | } Lighting; //size 0x38 16 | 17 | void lighting_free(); 18 | void lighting_init(); 19 | #endif 20 | -------------------------------------------------------------------------------- /include/core2/nc/camera.h: -------------------------------------------------------------------------------- 1 | #ifndef __CORE2_NC_CAMERA_H__ 2 | #define __CORE2_NC_CAMERA_H__ 3 | 4 | enum camera_type_e{ 5 | CAMERA_TYPE_1_UNKNOWN = 1, 6 | CAMERA_TYPE_2_DYNAMIC = 2, 7 | CAMERA_TYPE_3_STATIC = 3, 8 | CAMERA_TYPE_4_RANDOM = 4 9 | }; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /include/core2/particle.h: -------------------------------------------------------------------------------- 1 | #ifndef _PARTICLE_EMITTER_H_ 2 | #define _PARTICLE_EMITTER_H_ 3 | 4 | #define PART_EMIT_NO_OPA 0x20 5 | #define PART_EMIT_NO_DEPTH 0x10 6 | #define PART_EMIT_NO_LOOP 0x8 7 | 8 | #define PART_EMIT_ROTATABLE 0x1 9 | 10 | 11 | void particleEmitter_setAlpha(ParticleEmitter *this, s32 alpha); 12 | void particleEmitter_setSfx(ParticleEmitter *this, enum sfx_e sfx_id, s32 arg2); 13 | void func_802EFA04(ParticleEmitter *this, f32); 14 | void particleEmitter_setParticleCallback(ParticleEmitter *this, void (*arg1)(ParticleEmitter *this, f32 pos[3])); 15 | void func_802EFA20(ParticleEmitter *this, f32, f32); 16 | void func_802EFA34(ParticleEmitter *this, f32); 17 | void func_802EFA40(ParticleEmitter *this, f32 (*)[3]); 18 | void particleEmitter_func_802EFA78(ParticleEmitter *this, s32 arg1); 19 | void func_802EFF5C(ParticleEmitter *this, f32, f32, f32); 20 | void func_802EFF7C(ParticleEmitter *this, f32, f32, f32); 21 | void func_802EFF9C(ParticleEmitter *this, f32); 22 | void partEmitMgr_freeEmitter(ParticleEmitter *this); 23 | 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /include/core2/statetimer.h: -------------------------------------------------------------------------------- 1 | #ifndef _STATE_TIMER_ 2 | #define _STATE_TIMER_ 3 | 4 | #include 5 | #include "structs.h" 6 | 7 | enum state_timer_e{ 8 | STATE_TIMER_0_UNKNOWN, 9 | STATE_TIMER_1_THROW = 1, 10 | STATE_TIMER_2_LONGLEG, 11 | STATE_TIMER_3_TURBO_TALON, 12 | STATE_TIMER_4_UNKNOWN, 13 | STATE_TIMER_5_UNKNOWN, //slide timer 14 | STATE_TIMER_6_UNKNOWN //trot slide timer 15 | }; 16 | 17 | f32 stateTimer_get(enum state_timer_e timer_id); 18 | f32 stateTimer_getPrevious(enum state_timer_e timer_id); 19 | bool stateTimer_isActive(enum state_timer_e timer_id); 20 | bool stateTimer_isDone(enum state_timer_e timer_id); 21 | bool stateTimer_isAt(enum state_timer_e timer_id, f32 value); 22 | void stateTimer_free(void); 23 | void stateTimer_init(void); 24 | void stateTimer_clear(enum state_timer_e timer_id); 25 | void stateTimer_set(enum state_timer_e timer_id, f32 value); 26 | void stateTimer_update(void); 27 | #endif 28 | -------------------------------------------------------------------------------- /include/core2/timedfunc.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIMED_FUNC_H__ 2 | #define __TIMED_FUNC_H__ 3 | #include 4 | 5 | #include "generic.h" 6 | 7 | #define reinterpret_cast(type, var) (*((type *)&var)) 8 | 9 | 10 | void timedFunc_set_0(f32 time, GenFunction_0 funcPtr); 11 | void timedFunc_set_1(f32 time, GenFunction_1 funcPtr, s32 arg0); 12 | void timedFunc_set_2(f32 time, GenFunction_2 funcPtr, s32 arg0, s32 arg1); 13 | void timedFunc_set_3(f32 time, GenFunction_3 funcPtr, s32 arg0, s32 arg1, s32 arg2); 14 | void timedFunc_set_4(f32 time, GenFunction_4 funcPtr, s32 arg0, s32 arg1, s32 arg2, s32 arg3); 15 | void timedFunc_set_5(f32 time, GenFunction_5 funcPtr, s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4); 16 | void timedFunc_set_6(f32 time, GenFunction_6 funcPtr, void* argPtr ); 17 | void timedJiggySpawn(f32 time, s32 jiggyId, f32 *position); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/core2/vla.h: -------------------------------------------------------------------------------- 1 | #ifndef _STATIC_LENGTH_ARRAY_H_ 2 | #define _STATIC_LENGTH_ARRAY_H_ 3 | 4 | #include 5 | 6 | typedef struct variable_length_array{ 7 | s32 elem_size; 8 | void * begin; 9 | void * end; 10 | void * mem_end; 11 | u8 data[]; 12 | }VLA; 13 | 14 | #define vector(T) struct variable_length_array 15 | //^defined to keep element type with vla 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /include/core2/yaw.h: -------------------------------------------------------------------------------- 1 | #ifndef _YAW_H_ 2 | #define _YAW_H_ 3 | 4 | enum yaw_state_e{ 5 | YAW_STATE_0_NONE, 6 | YAW_STATE_1_DEFAULT, 7 | YAW_STATE_2_UNBOUNDED, 8 | YAW_STATE_3_BOUNDED 9 | }; 10 | 11 | void yaw_init(void); 12 | void yaw_update(void); 13 | void yaw_setUpdateState(s32); 14 | void yaw_setIdeal(f32 arg0); 15 | void yaw_set(f32 arg0); 16 | void yaw_applyIdeal(void); 17 | s32 yaw_getUpdateState(void); 18 | f32 yaw_get(void); 19 | f32 yaw_getIdeal(void); 20 | void yaw_setVelocityBounded(f32 arg0, f32 arg1); 21 | void yaw_setVelocityUnbounded(f32 arg0); 22 | void yaw_rotateTimed(f32 time_sec); 23 | #endif 24 | -------------------------------------------------------------------------------- /include/cseq.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #ifndef __cseq__ 5 | #define __cseq__ 6 | 7 | 8 | char __alCSeqNextDelta(ALCSeq *seq, s32 *pDeltaTicks); 9 | 10 | 11 | #endif /* __cseq__ */ 12 | -------------------------------------------------------------------------------- /include/cseqp.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef __cseqp__ 4 | #define __cseqp__ 5 | 6 | 7 | void __CSPPostNextSeqEvent(ALCSPlayer *seqp); 8 | 9 | 10 | #endif /* __cseqp__ */ 11 | -------------------------------------------------------------------------------- /include/file_and_line.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_AND_LINE_H_ 2 | #define _FILE_AND_LINE_H_ 3 | #include 4 | extern void func_8033F000(const char *, const char *, int); 5 | 6 | 7 | #ifdef NONMATCHING 8 | #define LINE(line_num) __LINE__ 9 | #define FILE(file_name) __FILE__ 10 | #define matching_assert(EX, F, L) assert(EX) 11 | #else 12 | #define LINE(line_num) line_num 13 | #ifdef __ANSI_CPP__ 14 | #define FILE(file_name) # file_name 15 | #else 16 | #define FILE(file_name) "file_name" 17 | #endif 18 | 19 | #ifdef __ANSI_CPP__ 20 | #define matching_assert(EX, F, L) ((EX)?((void)0):func_8033F000( # EX , # F, L)) 21 | #else 22 | #define matching_assert(EX, F , L) ((EX)?((void)0):func_8033F000("EX", "F", L)) 23 | #endif 24 | #endif 25 | 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /include/gc/gc.h: -------------------------------------------------------------------------------- 1 | #ifndef __GC_H__ 2 | #define __GC_H__ 3 | 4 | #include "gc/gcbound.h" 5 | #include "gc/gctransition.h" 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /include/gc/gcbound.h: -------------------------------------------------------------------------------- 1 | #ifndef GCBOUND_H 2 | #define GCBOUND_H 3 | #include 4 | 5 | #include "structs.h" 6 | 7 | 8 | void gcbound_draw(Gfx **dl); 9 | void gcbound_alpha(s32 a); 10 | void gcbound_color(s32 r, s32 g, s32 b); 11 | void gcbound_reset(void); 12 | #endif 13 | -------------------------------------------------------------------------------- /include/gc/gctransition.h: -------------------------------------------------------------------------------- 1 | #ifndef __GC_TRANSITION__ 2 | #define __GC_TRANSITION__ 3 | 4 | void gctransition_defrag(void); 5 | void gctransition_draw(Gfx **arg0, Mtx **arg1, Vtx **arg2); 6 | void gctransition_8030BD4C(void); 7 | f32 gctransition_8030BD88(void); 8 | int gctransition_done(void); 9 | int gctransition_active(void); 10 | int gctransition_8030BDC0(void); 11 | void gctransition_8030BE3C(void); 12 | void gctransition_8030BE60(void); 13 | void gctransition_8030BEA4(s32 arg0); 14 | void gctransition_update(void); 15 | void gctransition_reset(void); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /include/generic.h: -------------------------------------------------------------------------------- 1 | #ifndef _GENERIC_METHODS_H_ 2 | #define _GENERIC_METHODS_H_ 3 | 4 | typedef void (* GenFunction_0)(void); 5 | typedef void (* GenFunction_1)(s32); 6 | typedef void (* GenFunction_2)(s32, s32); 7 | typedef void (* GenFunction_3)(s32, s32, s32); 8 | typedef void (* GenFunction_4)(s32, s32, s32, s32); 9 | typedef void (* GenFunction_5)(s32, s32, s32, s32, s32); 10 | typedef void (* GenFunction_6)(void *); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /include/guint.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * * 3 | * Copyright (C) 1994, Silicon Graphics, Inc. * 4 | * * 5 | * These coded instructions, statements, and computer programs contain * 6 | * unpublished proprietary information of Silicon Graphics, Inc., and * 7 | * are protected by Federal copyright law. They may not be disclosed * 8 | * to third parties or copied or duplicated in any form, in whole or * 9 | * in part, without the prior written consent of Silicon Graphics, Inc. * 10 | * * 11 | **************************************************************************/ 12 | #include "mbi.h" 13 | #include "gu.h" 14 | 15 | typedef union 16 | { 17 | struct 18 | { 19 | unsigned int hi; 20 | unsigned int lo; 21 | } word; 22 | 23 | double d; 24 | } du; 25 | 26 | typedef union 27 | { 28 | unsigned int i; 29 | float f; 30 | } fu; 31 | 32 | #ifndef __GL_GL_H__ 33 | 34 | typedef float Matrix[4][4]; 35 | 36 | #endif 37 | 38 | #define ROUND(d) (int)(((d) >= 0.0) ? ((d) + 0.5) : ((d) - 0.5)) 39 | #define ABS(d) ((d) > 0) ? (d) : -(d) 40 | 41 | extern float __libm_qnan_f; -------------------------------------------------------------------------------- /include/macro.inc: -------------------------------------------------------------------------------- 1 | # Assembly Macros 2 | 3 | .set K0BASE, 0x80000000 4 | .set K1BASE, 0xA0000000 5 | .set K2BASE, 0xC0000000 6 | 7 | .macro glabel label 8 | .global \label 9 | .ent \label 10 | .balign 4 11 | \label: 12 | .endm 13 | 14 | .macro dlabel label 15 | .global \label 16 | \label: 17 | .endm 18 | 19 | .macro jlabel label 20 | \label: 21 | .endm 22 | 23 | .macro endlabel label 24 | .end \label 25 | .endm 26 | 27 | .macro .word32 x 28 | .word \x 29 | .endm 30 | -------------------------------------------------------------------------------- /include/music.h: -------------------------------------------------------------------------------- 1 | #ifndef MUSIC_H 2 | #define MUSIC_H 3 | #include 4 | #include "structs.h" 5 | 6 | typedef struct struct_B_s{ 7 | s32 unk0; 8 | s32 chan; 9 | f32 unk8; 10 | f32 unkC; 11 | f32 unk10; 12 | } structBs; 13 | 14 | typedef struct music_track_s{ 15 | s16 unk0; 16 | u8 unk2; 17 | u8 unk3; 18 | ALCSeq cseq; 19 | ALCSPlayer cseqp; 20 | s16 index; 21 | s16 index_cpy; 22 | f32 unk17C; 23 | f32 unk180; 24 | u8 unk184[0xE]; 25 | u8 unk192[0xE]; 26 | } MusicTrack; 27 | 28 | typedef struct music_track_meta_s{ 29 | char *name; 30 | u16 unk4; 31 | // u8 pad6[2]; 32 | }MusicTrackMeta; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /include/n_cseqp.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef __n_cseqp__ 4 | #define __n_cseqp__ 5 | 6 | 7 | void __n_CSPPostNextSeqEvent(N_ALCSPlayer *seqp); 8 | 9 | 10 | #endif /* __cseqp__ */ 11 | -------------------------------------------------------------------------------- /include/overlays.h: -------------------------------------------------------------------------------- 1 | OVERLAY(core2,0) 2 | OVERLAY(emptyLvl,1) 3 | OVERLAY(CC,2) 4 | OVERLAY(MMM,3) 5 | OVERLAY(GV,4) 6 | OVERLAY(TTC,5) 7 | OVERLAY(MM,6) 8 | OVERLAY(BGS,7) 9 | OVERLAY(RBB,8) 10 | OVERLAY(FP,9) 11 | OVERLAY(CCW,10) 12 | OVERLAY(SM,11) 13 | OVERLAY(cutscenes,12) 14 | OVERLAY(lair,13) 15 | OVERLAY(fight,14) 16 | -------------------------------------------------------------------------------- /include/prelude.s: -------------------------------------------------------------------------------- 1 | .set noat 2 | .set noreorder 3 | .set gp=64 4 | .macro glabel label 5 | .global \label 6 | \label: 7 | .endm 8 | 9 | .macro dlabel label 10 | .global \label 11 | \label: 12 | .endm 13 | 14 | .macro jlabel label 15 | \label: 16 | .endm 17 | 18 | .macro endlabel label 19 | .endm -------------------------------------------------------------------------------- /include/rand.h: -------------------------------------------------------------------------------- 1 | #ifndef __RANDOM_H__ 2 | #define __RANDOM_H__ 3 | #include 4 | 5 | f32 randf (void); 6 | f32 randf2(f32 min, f32 max); 7 | s32 randi2(s32 min, s32 max); 8 | #endif 9 | -------------------------------------------------------------------------------- /include/save.h: -------------------------------------------------------------------------------- 1 | #ifndef __SAVE_H__ 2 | #define __SAVE_H__ 3 | 4 | typedef struct{ 5 | u8 magic; 6 | u8 slotIndex; 7 | u8 data[0x70]; 8 | u8 padding[0x2]; 9 | u32 checksum; 10 | }SaveData; 11 | 12 | typedef struct { 13 | u32 snsItems; 14 | u8 padding[0x18]; 15 | u32 checksum; 16 | }GlobalData; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /include/string.h: -------------------------------------------------------------------------------- 1 | #ifndef STRING_H 2 | #define STRING_H 3 | 4 | #include "structs.h" 5 | 6 | void strcat(char *dst, char *src); 7 | void strcatc(char *dst, char src); 8 | void strFToA(char *dst, f32 val); 9 | void _strFToA(char *dst, f32 val, s32 decPlaces); 10 | void strIToA(char *str, s32 num); 11 | void _strIToA(char *str, s32 num, char base); 12 | void strcpy(char *dst, char *src); 13 | s32 strlen(char *str); 14 | void strToUpper(char *str); 15 | 16 | 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /include/time.h: -------------------------------------------------------------------------------- 1 | #ifndef __GL_TIME_H__ 2 | #define __GL_TIME_H__ 3 | 4 | #include 5 | 6 | void time_reset(void); 7 | void time_setDeltaReal_sec(f32 d_seconds); 8 | void time_setDeltaReal_frames(s32 d_frames); 9 | s32 time_getDeltaReal_frames(void); 10 | f32 time_getDelta(void); 11 | f32 time_func_8033DDB8(void); 12 | f32 time_getDelta_frames(void); 13 | void time_setMultiplier(f32 multiplier); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /include/variables.h: -------------------------------------------------------------------------------- 1 | #ifndef VARIABLES_H 2 | #define VARIABLES_H 3 | 4 | #define BAD_PI 3.141592654 5 | #define BAD_DTOR (BAD_PI/ 180.0) 6 | #define M_TAU (2*M_PI) 7 | #define BAD_TAU 6.2831853 8 | 9 | 10 | struct Overlay { 11 | void *start; 12 | void *end; 13 | }; 14 | 15 | extern struct Overlay gOverlayTable[]; 16 | 17 | extern f32 climbPoleBottom[3]; 18 | extern f32 climbPoleTop[3]; 19 | #endif 20 | -------------------------------------------------------------------------------- /include/version.h: -------------------------------------------------------------------------------- 1 | #ifndef __BANJO_KAZOOIE_VERSION_H__ 2 | #define __BANJO_KAZOOIE_VERSION_H__ 3 | 4 | //These values of `VERSION` match the values defined via the Makefile 5 | #define VERSION_USA_1_0 0 6 | #define VERSION_PAL 1 7 | #define VERSION_USA_1_1 2 8 | #define VERSION_JP 3 9 | 10 | #if VERSION == VERSION_USA_1_0 11 | #define USA10_EXCLUSIVE(body) body 12 | #else 13 | #define USA10_EXCLUSIVE(body) 14 | #endif 15 | 16 | #if VERSION == VERSION_PAL 17 | #define PAL_EXCLUSIVE(body) body 18 | #else 19 | #define PAL_EXCLUSIVE(body) 20 | #endif 21 | 22 | #if VERSION == VERSION_USA_1_1 23 | #define USA11_EXCLUSIVE(body) body 24 | #else 25 | #define USA11_EXCLUSIVE(body) 26 | #endif 27 | 28 | #if VERSION == VERSION_JP 29 | #define JP_EXCLUSIVE(body) body 30 | #else 31 | #define JP_EXCLUSIVE(body) 32 | #endif 33 | 34 | #if VERSION == VERSION_USA_1_0 35 | #define VER_SELECT(usa0, pal, usa1, jp) usa0 36 | #elif VERSION == VERSION_PAL 37 | #define VER_SELECT(usa0, pal, usa1, jp) pal 38 | #elif VERSION == VERSION_USA_1_1 39 | #define VER_SELECT(usa0, pal, usa1, jp) usa1 40 | #elif VERSION == VERSION_JP 41 | #define VER_SELECT(usa0, pal, usa1, jp) jp 42 | #endif 43 | 44 | #if VERSION == VERSION_PAL 45 | #define FRAMERATE 50 46 | #else 47 | #define FRAMERATE 60 48 | #endif 49 | 50 | #endif // __BANJO_KAZOOIE_VERSION_H__ 51 | -------------------------------------------------------------------------------- /level_symbols.us.v10.txt: -------------------------------------------------------------------------------- 1 | SM_resetSpawnableActors = 0x80386810; 2 | mm_func_803888B0 = 0x803888B0; 3 | code26D0_resetSpawnableActorsForTTC = 0x80388AC0; 4 | code_3E30_isSecretCheatCodeRelatedValueEqualToScrambledAddressValue = 0x8038BF8C; 5 | cc_func_803870E0 = 0x803870E0; 6 | cc_func_80387DA0 = 0x80387DA0; 7 | bgs_func_803885DC = 0x803885DC; 8 | bgs_func_8038F1E0 = 0x8038F1E0; 9 | fp_func_80391324 = 0x80391324; 10 | gv_func_80387118 = 0x80387118; 11 | gv_func_8038F154 = 0x8038F154; 12 | mmm_func_803890E0 = 0x803890E0; 13 | rbb_func_80386C48 = 0x80386C48; 14 | ccw_func_8038DB6C = 0x8038DB6C; 15 | lair_func_8038A0C4 = 0x8038A0C4; 16 | lair_func_8038CD48 = 0x8038CD48; 17 | lair_func_8038CF18 = 0x8038CF18; 18 | lair_func_8038E0B0 = 0x8038E0B0; 19 | lair_func_8038E768 = 0x8038E768; 20 | fight_addSpawnableActors = 0x803863F0; 21 | cutscene_func_8038C4E0 = 0x8038C4E0; 22 | chmole_learnedAllSpiralMountainAbilities = 0x802DA498; 23 | 24 | -------------------------------------------------------------------------------- /packages.txt: -------------------------------------------------------------------------------- 1 | binutils-mips-linux-gnu 2 | build-essential 3 | cmake 4 | gcc-mips-linux-gnu 5 | less 6 | curl 7 | libglib2.0-0 8 | libssl-dev 9 | python3 10 | python3-pip 11 | unzip 12 | wget 13 | openssl 14 | -------------------------------------------------------------------------------- /progress/progress_total.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Banjo-Kazooie (us.v10) 17 | Banjo-Kazooie (us.v10) 18 | 19 | 20 | 100.0000% 21 | 100.0000% 22 | 23 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | -r tools/n64splat/requirements.txt 2 | ansiwrap 3 | anybadge 4 | capstone 5 | colorama 6 | cxxfilt 7 | pycparser 8 | pylibyaml 9 | pypng 10 | python-Levenshtein 11 | python-ranges 12 | pyyaml 13 | watchdog 14 | -------------------------------------------------------------------------------- /rzip_dummy_addrs.pal.txt: -------------------------------------------------------------------------------- 1 | boot_core1_rzip_ROM_START = 0xF3D980; 2 | boot_core1_rzip_ROM_END = 0xF5BEC0; 3 | boot_core2_rzip_ROM_START = 0xF5BEC0; 4 | boot_core2_rzip_ROM_END = 0xFC8460; 5 | boot_CC_rzip_ROM_START = 0xFC8460; 6 | boot_CC_rzip_ROM_END = 0xFCA3C0; 7 | boot_MMM_rzip_ROM_START = 0xFCA3C0; 8 | boot_MMM_rzip_ROM_END = 0xFCD5C0; 9 | boot_GV_rzip_ROM_START = 0xFCD5C0; 10 | boot_GV_rzip_ROM_END = 0xFD2CC0; 11 | boot_TTC_rzip_ROM_START = 0xFD2CC0; 12 | boot_TTC_rzip_ROM_END = 0xFD6900; 13 | boot_MM_rzip_ROM_START = 0xFD6900; 14 | boot_MM_rzip_ROM_END = 0xFD8930; 15 | boot_BGS_rzip_ROM_START = 0xFD8930; 16 | boot_BGS_rzip_ROM_END = 0xFDDE80; 17 | boot_RBB_rzip_ROM_START = 0xFDDE80; 18 | boot_RBB_rzip_ROM_END = 0xFE3060; 19 | boot_FP_rzip_ROM_START = 0xFE3060; 20 | boot_FP_rzip_ROM_END = 0xFE8CA0; 21 | boot_CCW_rzip_ROM_START = 0xFFA830; 22 | boot_CCW_rzip_ROM_END = 0xFFF090; 23 | boot_SM_rzip_ROM_START = 0xFE8CA0; 24 | boot_SM_rzip_ROM_END = 0xFEB540; 25 | boot_cutscenes_rzip_ROM_START = 0xFEB540; 26 | boot_cutscenes_rzip_ROM_END = 0xFED780; 27 | boot_lair_rzip_ROM_START = 0xFED780; 28 | boot_lair_rzip_ROM_END = 0xFF4A50; 29 | boot_fight_rzip_ROM_START = 0xFF4A50; 30 | boot_fight_rzip_ROM_END = 0xFFA830; 31 | boot_emptyLvl_rzip_ROM_START = 0xFFF090; 32 | boot_emptyLvl_rzip_ROM_END = 0xFFF0B0; -------------------------------------------------------------------------------- /rzip_dummy_addrs.us.v10.txt: -------------------------------------------------------------------------------- 1 | boot_core1_rzip_ROM_START = 0xF19250; 2 | boot_core1_rzip_ROM_END = 0xF37F90; 3 | boot_core2_rzip_ROM_START = 0xF37F90; 4 | boot_core2_rzip_ROM_END = 0xFA3FD0; 5 | boot_CC_rzip_ROM_START =0xFA3FD0; 6 | boot_CC_rzip_ROM_END = 0xFA5F50; 7 | boot_MMM_rzip_ROM_START = 0xFA5F50; 8 | boot_MMM_rzip_ROM_END = 0xFA9150; 9 | boot_GV_rzip_ROM_START = 0xFA9150; 10 | boot_GV_rzip_ROM_END = 0xFAE860; 11 | boot_TTC_rzip_ROM_START = 0xFAE860; 12 | boot_TTC_rzip_ROM_END = 0xFB24A0; 13 | boot_MM_rzip_ROM_START = 0xFB24A0; 14 | boot_MM_rzip_ROM_END = 0xFB44E0; 15 | boot_BGS_rzip_ROM_START = 0xFB44E0; 16 | boot_BGS_rzip_ROM_END = 0xFB9A30; 17 | boot_RBB_rzip_ROM_START = 0xFB9A30; 18 | boot_RBB_rzip_ROM_END = 0xFBEBE0; 19 | boot_FP_rzip_ROM_START = 0xFBEBE0; 20 | boot_FP_rzip_ROM_END = 0xFC4810; 21 | boot_CCW_rzip_ROM_START = 0xFD6190; 22 | boot_CCW_rzip_ROM_END = 0xFDAA10; 23 | boot_SM_rzip_ROM_START = 0xFC4810; 24 | boot_SM_rzip_ROM_END = 0xFC6F20; 25 | boot_cutscenes_rzip_ROM_START = 0xFC6F20; 26 | boot_cutscenes_rzip_ROM_END = 0xFC9150; 27 | boot_lair_rzip_ROM_START = 0xFC9150; 28 | boot_lair_rzip_ROM_END = 0xFD0420; 29 | boot_fight_rzip_ROM_START = 0xFD0420; 30 | boot_fight_rzip_ROM_END = 0xFD6190; 31 | boot_emptyLvl_rzip_ROM_START = 0xFDAA10; 32 | boot_emptyLvl_rzip_ROM_END = 0xFDAA30; 33 | -------------------------------------------------------------------------------- /src/BGS/bss_pad.c: -------------------------------------------------------------------------------- 1 | char pad_BGS_D_80391230[0x10]; 2 | -------------------------------------------------------------------------------- /src/BGS/ch/bigalligator.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | 6 | 7 | 8 | 9 | void chLargeCrocodile_init(Actor *); 10 | 11 | /* .data */ 12 | ActorInfo chLargeCrocodile = {MARKER_DC_BIG_ALLIGATOR, ACTOR_F6_BIG_ALLIGATOR, ASSET_397_MODEL_BIG_ALLIGATOR, 0x01, NULL, 13 | chLargeCrocodile_init, actor_update_func_80326224, actor_draw, 14 | 0, 0, 0.0f, 0 15 | }; 16 | 17 | /* .code */ 18 | void chLargeCrocodile_init(Actor *this){ 19 | if(this->initialized) 20 | return; 21 | this->marker->propPtr->unk8_3 = 1; 22 | actor_collisionOff(this); 23 | this->initialized = TRUE; 24 | } 25 | -------------------------------------------------------------------------------- /src/BGS/crc.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | //TODO Implement CRC calculation in Makefile(?) 4 | u32 D_80390B20 = 0x00282B61; //BGS.code CRC1 5 | u32 D_80390B24 = 0xccdaeea0; //BGS.code CRC2 6 | u32 D_80390B28 = 0x0002DE6B; //BGS.data CRC1 (with this value = 0) 7 | -------------------------------------------------------------------------------- /src/CC/CC.h: -------------------------------------------------------------------------------- 1 | #ifndef CC_H 2 | #define CC_H 3 | 4 | s32 func_80388010(void); 5 | void func_8038803C(s32 arg0); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /src/CC/bss_pad.c: -------------------------------------------------------------------------------- 1 | char pad_CC_D_80389F70[0x10]; 2 | -------------------------------------------------------------------------------- /src/CC/crc.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* .data */ 4 | //TODO Implement CRC calculation in Makefile(?) 5 | u32 D_80389BE0 = 0x000D46A1; //CC.code CRC1 6 | u32 D_80389BE4 = 0x871BA43E; //CC.code CRC2 7 | u32 D_80389BE8 = 0x0000DF9F; //CC.data CRC1 (with this value = 0) 8 | -------------------------------------------------------------------------------- /src/CCW/bss_pad.c: -------------------------------------------------------------------------------- 1 | char pad_CCW_8038FDD0[0x10]; 2 | -------------------------------------------------------------------------------- /src/CCW/code_21A0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void func_803885F8(Actor *this); 6 | 7 | /* .data */ 8 | ActorInfo D_8038ECA0 = { 9 | 0x1C2, 0x30B, 0x4E3, 10 | 0x0, NULL, 11 | func_803885F8, NULL, actor_draw, 12 | 0, 0, 1.0f, 0 13 | }; 14 | 15 | /* .code */ 16 | void func_80388590(Actor *this, s32 next_state){ 17 | if(next_state == 1){ 18 | skeletalAnim_set(this->unk148, 0x219, 0.0f, 1.0f); 19 | skeletalAnim_setBehavior(this->unk148, SKELETAL_ANIM_4_STOPPED); 20 | } 21 | this->state = next_state; 22 | } 23 | 24 | void func_803885F8(Actor *this){ 25 | if(!this->volatile_initialized){ 26 | this->volatile_initialized = TRUE; 27 | if(fileProgressFlag_get(FILEPROG_E5_CCW_FLOWER_AUTUMN)){ 28 | func_80388590(this, 1); 29 | } 30 | else{ 31 | marker_despawn(this->marker); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/CCW/code_7570.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void func_8038D9E0(Actor *this); 6 | 7 | /* .data */ 8 | ActorInfo D_8038F6F0 = { 0x1C3, 0x30C, 0x4E4, 0x0, NULL, func_8038D9E0, NULL, actor_draw, 0, 0, 0.0f, 0}; 9 | 10 | /* .code */ 11 | void func_8038D960(Actor *this, s32 next_state) { 12 | if (next_state == 1) { 13 | skeletalAnim_set(this->unk148, 0x21C, 0.0f, 6.0f); 14 | skeletalAnim_setBehavior(this->unk148, SKELETAL_ANIM_2_ONCE); 15 | } 16 | if (next_state == 2) { 17 | func_80326310(this); 18 | } 19 | this->state = next_state; 20 | } 21 | 22 | void func_8038D9E0(Actor *this) { 23 | f32 sp24; 24 | f32 sp20; 25 | ActorMarker *temp_v0; 26 | 27 | if (!this->volatile_initialized) { 28 | this->volatile_initialized = TRUE; 29 | this->depth_mode = 2; 30 | this->marker->unk40_22 = TRUE; 31 | func_8038D960(this, 1); 32 | } 33 | if (this->state == 1) { 34 | this = this; 35 | skeletalAnim_getProgressRange(this->unk148, &sp24, &sp20); 36 | if ((sp24 < 0.25f) && (sp20 >= 0.25f)) { 37 | func_8038D960(this, 2); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/CCW/code_7BC0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void func_8038DFB0(Actor *this); 6 | 7 | 8 | ActorAnimationInfo D_8038F8B0[] = { 9 | {0x000, 0.0f}, 10 | {0x234, 2.0f} 11 | }; 12 | 13 | ActorInfo D_8038F8C0 = { 0x251, 0x37E, 0x506, 14 | 0x1, D_8038F8B0, 15 | func_8038DFB0, actor_update_func_80326224, actor_draw, 16 | 0, 0, 0.0f, 0 17 | }; 18 | 19 | /* .code */ 20 | void func_8038DFB0(Actor *this){ 21 | this->marker->propPtr->unk8_3 = TRUE; 22 | actor_collisionOff(this); 23 | } 24 | -------------------------------------------------------------------------------- /src/FP/bss_pad.c: -------------------------------------------------------------------------------- 1 | char pad_FP_80392F10[0x10]; 2 | -------------------------------------------------------------------------------- /src/FP/code_A1C0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void func_803905B0(Actor *this); 6 | 7 | /* .data */ 8 | ActorInfo D_803926C0 = { 0x20E, 0x33E, 0x49C, 9 | 0x1, NULL, 10 | func_803905B0, actor_update_func_80326224, func_80325340, 11 | 0, 0, 0.0f, 0 12 | }; 13 | 14 | /* .code */ 15 | void func_803905B0(Actor *this){ 16 | if(!this->volatile_initialized){ 17 | this->volatile_initialized = TRUE; 18 | actor_collisionOff(this); 19 | } 20 | this->marker->propPtr->unk8_3 = BOOL(func_8038DD14(this)); 21 | } 22 | -------------------------------------------------------------------------------- /src/FP/code_B4D0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | static struct { 6 | u8 sound; 7 | f32 position[3]; 8 | } Me; 9 | 10 | /* .code */ 11 | void func_803918C0(void){ 12 | Actor *pntWozza; 13 | if(map_get() == MAP_7F_FP_WOZZAS_CAVE){ 14 | Me.sound = func_8030ED2C(SFX_128_FIRE_CRACKING, 2); 15 | sfxsource_playSfxAtVolume(Me.sound, 1.0f); 16 | pntWozza = actorArray_findActorFromActorId(0x353); 17 | if(pntWozza){ 18 | Me.position[0] = pntWozza->position_x; 19 | Me.position[1] = pntWozza->position_y; 20 | Me.position[2] = pntWozza->position_z; 21 | } 22 | else{ 23 | Me.position[0] = Me.position[1] = Me.position[2] = 0.0f; 24 | } 25 | } 26 | } 27 | 28 | void func_8039195C(void){ 29 | if(Me.sound){ 30 | sfxsource_freeSfxsourceByIndex(Me.sound); 31 | Me.sound = 0; 32 | } 33 | } 34 | 35 | void func_80391994(void){ 36 | if(map_get() == MAP_7F_FP_WOZZAS_CAVE){ 37 | func_8030DB04(Me.sound, 22000, Me.position, 400.0f, 1200.0f); 38 | func_8030E2C4(Me.sound); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/GV/bss_pad.c: -------------------------------------------------------------------------------- 1 | char pad_GV_D_80391A20[0x10]; 2 | -------------------------------------------------------------------------------- /src/GV/code_3AA0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void GV_func_80389E90(Actor *this); 6 | void GV_func_80389EA8(Actor *this); 7 | 8 | /* .data */ 9 | ActorInfo D_80390F00 = { MARKER_AB_RUBEES_EGG_POT, ACTOR_11D_RUBEES_EGG_POT, ASSET_3E1_MODEL_RUBEES_EGG_POT, 10 | 0x1, NULL, 11 | GV_func_80389E90, GV_func_80389EA8, actor_draw, 12 | 2500, 0, 0.9f, 0 13 | }; 14 | 15 | /* .code */ 16 | void GV_func_80389E90(Actor *this){ 17 | this->marker->propPtr->unk8_3 = FALSE; 18 | } 19 | 20 | void GV_func_80389EA8(Actor *this){ 21 | this->marker->propPtr->unk8_3 = FALSE; 22 | this->unk4C = 100 + 40*func_8038E178(); 23 | func_80343DEC(this); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/GV/code_3B10.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | #include "core2/statetimer.h" 6 | extern void player_stateTimer_set(s32, f32); 7 | extern f32 player_stateTimer_get(enum state_timer_e); 8 | 9 | /* .data */ 10 | //TODO Implement CRC calculation in Makefile(?) 11 | u32 D_80390F30 = 0x00274530; //GV.code CRC1 12 | u32 D_80390F34 = 0xAA18BBF3; //GV.code CRC2 13 | u32 D_80390F38 = 0x0003031C; //GV.data CRC1 (with this value = 0) 14 | 15 | 16 | /* .code */ 17 | void func_80389F00(void){ 18 | if(getGameMode() != GAME_MODE_7_ATTRACT_DEMO && 2.0f < player_stateTimer_get(STATE_TIMER_3_TURBO_TALON)){ 19 | player_stateTimer_set(STATE_TIMER_3_TURBO_TALON, 2.0f); 20 | } 21 | } 22 | 23 | void func_80389F5C(void){ 24 | u32 sp1C; 25 | osPiReadIo(0x800, &sp1C); 26 | sp1C <<= 0x10; 27 | if(sp1C != 0x10000) 28 | func_80389F00(); 29 | } 30 | -------------------------------------------------------------------------------- /src/GV/code_6F80.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void func_8038D3AC(Actor *this); 6 | 7 | /* .data */ 8 | ActorInfo D_80391260 = { 0x1A5, 0x288, 0x402, 9 | 0, NULL, 10 | func_8038D3AC, NULL, func_80325340, 11 | 0, 0, 0.0f, 0 12 | }; 13 | 14 | /* .bss */ 15 | u8 D_80391AA0; 16 | 17 | /* .code */ 18 | void func_8038D370(ActorMarker *this_marker, ActorMarker *other_marker){ 19 | D_80391AA0 = 5; 20 | } 21 | 22 | int func_8038D388(void){ 23 | return D_80391AA0 ? 1 : 0; 24 | } 25 | 26 | void func_8038D3AC(Actor *this){ 27 | if(!this->volatile_initialized){ 28 | this->volatile_initialized = TRUE; 29 | marker_setCollisionScripts(this->marker, func_8038D370, NULL, NULL); 30 | D_80391AA0 = 0; 31 | if(fileProgressFlag_getN(FILEPROG_F8_KING_SANDYBUTT_PYRAMID_STATE, 2) == 3){ 32 | marker_despawn(this->marker); 33 | } 34 | } 35 | else{ 36 | if(D_80391AA0 > 0){ 37 | D_80391AA0--; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/GV/code_7D50.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | struct { 6 | s32 unk0; 7 | s32 unk4; 8 | s32 unk8; 9 | }GV_D_80391AB0; 10 | 11 | /* .code */ 12 | void func_8038E140(void){ 13 | GV_D_80391AB0.unk0++; 14 | func_8025A6EC(COMUSIC_2B_DING_B, 26000); 15 | } 16 | 17 | s32 func_8038E178(void){ 18 | return GV_D_80391AB0.unk0; 19 | } 20 | 21 | s32 func_8038E184(void){ 22 | return 5; 23 | } 24 | 25 | void func_8038E18C(void){ 26 | GV_D_80391AB0.unk8 = TRUE; 27 | } 28 | -------------------------------------------------------------------------------- /src/GV/code_7FC0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void func_8038E3B0(Actor *this); 6 | 7 | /* .data */ 8 | ActorAnimationInfo GV_D_80391380[] = { 9 | {0, 0.0f}, 10 | {0, 0.0f} 11 | }; 12 | ActorInfo GV_D_80391390 = { 0xFA, 0x1F8, 0x423, 13 | 0x1, GV_D_80391380, 14 | func_8038E3B0, actor_update_func_80326224, actor_draw, 15 | 0, 0x100, 0.0f, 0 16 | }; 17 | 18 | ActorInfo D_803913B4 = { 0xFB, 0x1F9, 0x424, 19 | 0x1, GV_D_80391380, 20 | func_8038E3B0, actor_update_func_80326224, actor_draw, 21 | 0, 0x100, 0.0f, 0 22 | }; 23 | 24 | /* .code */ 25 | void func_8038E3B0(Actor *this){ 26 | this->marker->propPtr->unk8_3 = TRUE; 27 | actor_collisionOff(this); 28 | } 29 | -------------------------------------------------------------------------------- /src/GV/code_9B70.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | 6 | void func_8038FF60(void){} 7 | 8 | void func_8038FF68(void){ 9 | 10 | if(map_get() != MAP_12_GV_GOBIS_VALLEY) return; 11 | 12 | if(jiggyscore_isCollected(JIGGY_42_GV_WATER_PYRAMID)){ 13 | func_8034DE60(&func_8034C528(0x190)->type_6D, 0.0f, 270.0f, 0.0f, 1); 14 | } 15 | else{ 16 | func_8034E71C(&func_8034C5AC(0x130)->type_73, -1500, 0.0f); 17 | } 18 | } 19 | 20 | void func_8038FFF4(void){} 21 | -------------------------------------------------------------------------------- /src/MM/crc.c: -------------------------------------------------------------------------------- 1 | //!!!DONE 2 | #include 3 | #include "functions.h" 4 | #include "variables.h" 5 | 6 | /* .data */ 7 | //TODO Implement CRC calculation in Makefile(?) 8 | u32 D_803899C0 = 0x000C740C; //MM.code CRC1 9 | u32 D_803899C4 = 0xCD249CB3; //MM.code CRC2 10 | u32 D_803899C8 = 0x0000D44F; //MM.data CRC1 (with this value = 0) 11 | 12 | void chmumbo_func_802D1724(void); 13 | 14 | void func_80387EC0(void) { 15 | u32 *temp_v0; 16 | u32 temp_a0; 17 | 18 | temp_v0 = (u32* )chmumbo_func_802D1724; 19 | if (getGameMode() != GAME_MODE_7_ATTRACT_DEMO) { 20 | temp_a0 = (temp_v0[2] & 0x03FFFFFF)*4; //get offset 21 | temp_a0 += (u32)&temp_v0[3] & 0xF0000000; //get region 22 | ((u32 *)temp_a0)[0] = 0x03E00008; //jr $ra 23 | ((u32 *)temp_a0)[1] = 0x24020002; //addiu $v0, $zero, 0x2 24 | 25 | osWritebackDCache((void *)temp_a0, 8); 26 | osInvalICache((void *)temp_a0, 8); 27 | } 28 | } 29 | 30 | void MM_func_80387F44(void) { 31 | s32 sp1C; 32 | 33 | osPiReadIo(0x578, (u32 *)&sp1C); 34 | sp1C = sp1C & (sp1C ^ 0xFFFF0000); 35 | if (sp1C != 0x8965){ 36 | func_80387EC0(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/MMM/bss_pad.c: -------------------------------------------------------------------------------- 1 | char pad_D_8038C4C0[0x10]; 2 | -------------------------------------------------------------------------------- /src/MMM/crc.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | u32 D_8038C300 = 0x00146061; 4 | u32 D_8038C304 = 0xEC79D7B4; 5 | u32 D_8038C308 = 0x0001B98D; 6 | u32 D_8038C30C = 0x0; 7 | -------------------------------------------------------------------------------- /src/RBB/bss_pad.c: -------------------------------------------------------------------------------- 1 | char pad_RBB_80391270[0x10]; 2 | -------------------------------------------------------------------------------- /src/RBB/ch/bossboomboxctrl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | 6 | void chBossBoomBoxCtrl_update(Actor *this); 7 | 8 | /* .data */ 9 | ActorInfo RBB_D_80390CF0 = { 10 | 0x1C0, 0x2AD, 0x0, 0x0, NULL, 11 | chBossBoomBoxCtrl_update, NULL, func_80325340, 12 | 0, 0, 0.0f, 0 13 | }; 14 | 15 | /* .code */ 16 | void __chBossBoomBoxCtrl_setState(Actor *this, s32 new_state){ 17 | this->state = new_state; 18 | } 19 | 20 | void chBossBoomBoxCtrl_update(Actor *this){ 21 | if(!this->volatile_initialized){ 22 | 23 | this->volatile_initialized = TRUE; 24 | if(jiggyscore_isSpawned(JIGGY_56_RBB_BOSS_BOOM_BOX) && !volatileFlag_get(VOLATILE_FLAG_2_FF_IN_MINIGAME)){ 25 | marker_despawn(this->marker); 26 | }else{ 27 | __spawnQueue_add_4((GenFunction_4)spawnQueue_actor_f32, ACTOR_281_BOSS_BOOM_BOX_LARGEST, reinterpret_cast(s32,this->position_x), reinterpret_cast(s32,this->position_y), reinterpret_cast(s32,this->position_z)); 28 | __chBossBoomBoxCtrl_setState(this, 1); 29 | } 30 | }//L8038DEF4 31 | } 32 | -------------------------------------------------------------------------------- /src/RBB/ch/rarewareflag.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void func_8038C300(Actor *this); 6 | 7 | ActorInfo D_80390B40 = { 8 | 0x198, 0x1ca, 0x41e, 0x0, NULL, 9 | func_8038C300, NULL, actor_draw, 10 | 0, 0, 0.0f, 0 11 | }; 12 | 13 | void func_8038C300(Actor *this){ 14 | if(!this->volatile_initialized){ 15 | this->marker->propPtr->unk8_3 = 1; 16 | this->volatile_initialized = TRUE; 17 | skeletalAnim_set(this->unk148, 0x140, 0.0f, 1.0f); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/SM/code_0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | extern void anSeq_func_80288F78(Actor*, f32, s32); 6 | 7 | /* .code */ 8 | void SM_func_803863F0(Actor *this, s32 arg1) { 9 | anSeq_func_80288F78(this, 0.20f, 0xF280FA); 10 | } 11 | 12 | void SM_func_80386420(Actor *arg0, s32 arg1) { 13 | anSeq_func_80288F78(arg0, 0.20f, 0x3ED803E); 14 | anSeq_func_80288F78(arg0, 0.35f, 0x3ED8C3E); 15 | anSeq_func_80288F78(arg0, 0.71f, 0x21F336); 16 | anSeq_func_80288F78(arg0, 0.79f, 0x21F336); 17 | anSeq_func_80288F78(arg0, 0.80f, 0x3ED8C3E); 18 | anSeq_func_80288F78(arg0, 0.87f, 0x21F336); 19 | } 20 | 21 | /* .data */ 22 | Struct63s D_8038AAC0[] = { 23 | {0x20A, SM_func_803863F0}, 24 | 0 25 | }; 26 | 27 | Struct63s D_8038AAD0[] = { 28 | {0x208, SM_func_80386420}, 29 | 0 30 | }; 31 | -------------------------------------------------------------------------------- /src/SM/code_2900.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | /* .code */ 6 | void func_80388CF0(void){ 7 | if(getGameMode() != GAME_MODE_7_ATTRACT_DEMO){ 8 | func_8034DEB4(func_8034C528(0x1F2), 0.0f); 9 | func_8034DEB4(func_8034C528(0x1F3), -5000.0f); 10 | } 11 | } 12 | 13 | void func_80388D48(void){ 14 | if(*(u32*)PHYS_TO_K1(0x200) - PHYS_TO_K1(0xC290000)){ 15 | func_80388CF0(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/SM/code_46C0.us.v10.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | int func_8038AAB0(void){return 0;} 6 | -------------------------------------------------------------------------------- /src/SM/code_BF0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void __codeBF0_draw(Actor *this); 6 | 7 | /* .data */ 8 | ActorInfo gCodeBF0 = { 9 | MARKER_134_UNKNOWN, ACTOR_16E_UNKNOWN, NULL, 10 | 1, NULL, 11 | __codeBF0_draw, actor_update_func_80326224, func_80325340, 12 | 2000, 0, 0.0f, 0 13 | }; 14 | 15 | /* .code */ 16 | static void __codeBF0_draw(Actor *this){ 17 | if(!this->volatile_initialized){ 18 | this->unk10_12 = 0; 19 | this->unk38_31 = this->unk10_12; 20 | this->volatile_initialized = TRUE; 21 | actor_collisionOff(this); 22 | } 23 | 24 | switch(this->state){ 25 | case 1: 26 | if(this->unk38_31++ == 2){ 27 | this->unk10_12 = actorArray_actorCount(ACTOR_16F_QUARRIE); 28 | subaddie_set_state(this, 2); 29 | } 30 | break; 31 | case 2: 32 | if(this->unk10_12 == 0) 33 | marker_despawn(this->marker); 34 | break; 35 | } 36 | } 37 | 38 | bool codeBF0_shouldSpawnQuarrieHoneyComb(ActorMarker *marker){ 39 | Actor *actor = marker_getActor(marker); 40 | 41 | return (--actor->unk10_12) == 0 ? TRUE : FALSE; 42 | } 43 | -------------------------------------------------------------------------------- /src/TTC/code_3040.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | extern s32 D_80276CB0; 6 | 7 | /* .data */ 8 | // code crc0 9 | s32 D_8038C750 = 0x0016D2FD; 10 | // code crc1 11 | s32 D_8038C754 = 0xFB70B01D; 12 | // data crc 13 | s32 D_8038C758 = 0x0004EFAC; 14 | 15 | /* .bss */ 16 | struct { 17 | u8 pad0[4]; 18 | s32 unk4; 19 | u8 pad8[4]; 20 | s32 unkC; 21 | } sD_8038D6F0; 22 | 23 | /* .code */ 24 | void __code3040_func_80389430(){ 25 | if(getGameMode() != GAME_MODE_7_ATTRACT_DEMO){ 26 | func_8029CF48(2, 1, 0.0f); 27 | } 28 | } 29 | 30 | void code3040_func_80389468(void){ 31 | if(sD_8038D6F0.unk4 != D_8038C754 || sD_8038D6F0.unkC != D_80276CB0){ 32 | __code3040_func_80389430(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/core1/audio/auxbus.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "synthInternals.h" 3 | 4 | Acmd *alAuxBusPull(void *filter, s16 *outp, s32 outCount, s32 sampleOffset, Acmd *p) 5 | { 6 | Acmd *ptr = p; 7 | ALAuxBus *m = (ALAuxBus *)filter; 8 | ALFilter **sources = m->sources; 9 | s32 i; 10 | 11 | /* 12 | * clear the output buffers here 13 | */ 14 | aClearBuffer(ptr++, AL_AUX_L_OUT, outCount<<1); 15 | aClearBuffer(ptr++, AL_AUX_R_OUT, outCount<<1); 16 | 17 | for (i = 0; i < m->sourceCount; i++) { 18 | ptr = (sources[i]->handler)(sources[i], outp, outCount, sampleOffset, 19 | ptr); 20 | } 21 | 22 | return ptr; 23 | } 24 | 25 | s32 alAuxBusParam(void *filter, s32 paramID, void *param) 26 | { 27 | ALAuxBus *m = (ALAuxBus *) filter; 28 | ALFilter **sources = m->sources; 29 | 30 | switch (paramID) { 31 | 32 | case (AL_FILTER_ADD_SOURCE): 33 | sources[m->sourceCount++] = (ALFilter *) param; 34 | break; 35 | 36 | default: 37 | /* ??? */ 38 | break; 39 | } 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /src/core1/audio/cents2ratio.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | f32 alCents2Ratio(s32 cents) 4 | { 5 | f32 x; 6 | f32 ratio = 1.0f; 7 | 8 | if (cents >= 0) { 9 | x = 1.00057779f; /* 2^(1/1200) */ 10 | } else { 11 | x = 0.9994225441f; /* 2^(-1/1200) */ 12 | cents = -cents; 13 | } 14 | 15 | while (cents) { 16 | if (cents & 1) 17 | ratio *= x; 18 | x *= x; 19 | cents >>= 1; 20 | } 21 | 22 | return ratio; 23 | } 24 | -------------------------------------------------------------------------------- /src/core1/audio/code_219D0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | 6 | void func_8025F3F0(ALCSPlayer *seqp, f32 arg1, f32 arg2) 7 | { 8 | ALEvent evt; 9 | 10 | evt.type = AL_UNK18_EVT; //event type not listed; 11 | evt.msg.unk18.unk0 = arg1; 12 | evt.msg.unk18.unk4 = arg2; 13 | alEvtqPostEvent(&seqp->evtq, &evt, 0); 14 | } 15 | -------------------------------------------------------------------------------- /src/core1/audio/code_21A80.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | #include "n_synth.h" 5 | 6 | u8 func_8025F4A0(N_ALCSPlayer *seqp, u8 chan) 7 | { 8 | return seqp->chanState[chan].unkA; 9 | } 10 | -------------------------------------------------------------------------------- /src/core1/audio/code_21AF0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void func_8025F510(ALCSPlayer *seqp, u8 chan, u8 arg2) 6 | { 7 | ALEvent evt; 8 | 9 | evt.type = AL_SEQP_MIDI_EVT; 10 | evt.msg.midi.ticks = 0; 11 | evt.msg.midi.status = AL_MIDI_ControlChange | chan; 12 | evt.msg.midi.byte1 = 0x7D; 13 | evt.msg.midi.byte2 = arg2; 14 | 15 | alEvtqPostEvent(&seqp->evtq, &evt, 0); 16 | } 17 | -------------------------------------------------------------------------------- /src/core1/audio/code_21B50.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "n_synth.h" 3 | 4 | void func_8025F5C0(N_ALSeqPlayer *arg0, u8 arg1){ 5 | ALEvent evt; 6 | 7 | evt.type = AL_SEQP_MIDI_EVT; 8 | evt.msg.midi.ticks = 0; 9 | evt.msg.midi.status = AL_MIDI_ChannelModeSelect; 10 | evt.msg.midi.byte1 = 0x7E; 11 | evt.msg.midi.byte2 = arg1; 12 | alEvtqPostEvent(&arg0->evtq, &evt, 0); 13 | } 14 | 15 | void func_8025F570(N_ALSeqPlayer *arg0, u8 arg1){ 16 | ALEvent evt; 17 | 18 | evt.type = AL_SEQP_MIDI_EVT; 19 | evt.msg.midi.ticks = 0; 20 | evt.msg.midi.status = AL_MIDI_ChannelModeSelect; 21 | evt.msg.midi.byte1 = 0x7F; 22 | evt.msg.midi.byte2 = arg1; 23 | alEvtqPostEvent(&arg0->evtq, &evt, 0); 24 | } 25 | -------------------------------------------------------------------------------- /src/core1/audio/copy.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void alCopy(void *src, void *dest, s32 len) 6 | { 7 | s32 i; 8 | u8 *s = (u8 *)src; 9 | u8 *d = (u8 *)dest; 10 | 11 | for (i = 0; i < len; i++){ 12 | *d++ = *s++; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/core1/audio/cspgettempo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | s32 alCSPGetTempo(ALCSPlayer *seqp){ 6 | if(seqp->target == NULL) 7 | return 0; 8 | return seqp->uspt / seqp->target->qnpt; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /src/core1/audio/cspplay.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | 6 | void alCSPPlay(ALCSPlayer *seqp) 7 | { 8 | ALEvent evt; 9 | 10 | evt.type = AL_SEQP_PLAY_EVT; 11 | alEvtqPostEvent(&seqp->evtq, &evt, 0); 12 | } 13 | -------------------------------------------------------------------------------- /src/core1/audio/cspsetbank.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void alCSPSetBank(ALCSPlayer *seqp, ALBank *b) 6 | { 7 | ALEvent evt; 8 | 9 | evt.type = AL_SEQP_BANK_EVT; 10 | evt.msg.spbank.bank = b; 11 | 12 | alEvtqPostEvent(&seqp->evtq, &evt, 0); 13 | } 14 | -------------------------------------------------------------------------------- /src/core1/audio/cspsetseq.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void alCSPSetSeq(ALCSPlayer *seqp, ALCSeq *seq) 4 | { 5 | ALEvent evt; 6 | 7 | evt.type = AL_SEQP_SEQ_EVT; 8 | evt.msg.spseq.seq = seq; 9 | 10 | alEvtqPostEvent(&seqp->evtq, &evt, 0); 11 | } 12 | -------------------------------------------------------------------------------- /src/core1/audio/cspsettempo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void alCSPSetTempo(ALCSPlayer *seqp, s32 tempo) 6 | { 7 | ALEvent evt; 8 | 9 | evt.type = AL_SEQP_META_EVT; 10 | evt.msg.tempo.status = AL_MIDI_Meta; 11 | evt.msg.tempo.type = AL_MIDI_META_TEMPO; 12 | evt.msg.tempo.byte1 = (tempo & 0xff0000)>>16; 13 | evt.msg.tempo.byte2 = (tempo & 0xff00)>>8; 14 | evt.msg.tempo.byte3 = tempo & 0xff; 15 | 16 | alEvtqPostEvent(&seqp->evtq, &evt, 0); 17 | } 18 | -------------------------------------------------------------------------------- /src/core1/audio/cspsetvol.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | 6 | void alCSPSetVol(ALCSPlayer *seqp, s16 vol) 7 | { 8 | ALEvent evt; 9 | 10 | evt.type = AL_SEQP_VOL_EVT; 11 | evt.msg.spvol.vol = vol; 12 | 13 | alEvtqPostEvent(&seqp->evtq, &evt, 0); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /src/core1/audio/cspstop.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | void alCSPStop(ALCSPlayer *seqp) 5 | { 6 | ALEvent evt; 7 | 8 | evt.type = AL_SEQP_STOPPING_EVT; 9 | alEvtqPostEvent(&seqp->evtq, &evt, 0); 10 | } 11 | -------------------------------------------------------------------------------- /src/core1/audio/filter.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "synthInternals.h" 3 | 4 | void alFilterNew(ALFilter *f, ALCmdHandler h, ALSetParam s, s32 type) 5 | { 6 | f->source = 0; 7 | f->handler = h; 8 | f->setParam = s; 9 | f->inp = 0; 10 | f->outp = 0; 11 | f->type = type; 12 | } 13 | -------------------------------------------------------------------------------- /src/core1/audio/heapalloc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "synthInternals.h" 3 | 4 | void *alHeapDBAlloc(u8 *file, s32 line, ALHeap *hp, s32 num, s32 size) 5 | { 6 | s32 bytes; 7 | u8 *ptr = 0; 8 | 9 | bytes = (num*size + AL_CACHE_ALIGN) & ~AL_CACHE_ALIGN; 10 | 11 | #ifdef _DEBUG 12 | hp->count++; 13 | bytes += sizeof(HeapInfo); 14 | #endif 15 | 16 | if ((hp->cur + bytes) <= (hp->base + hp->len)) { 17 | 18 | ptr = hp->cur; 19 | hp->cur += bytes; 20 | 21 | #ifdef _DEBUG 22 | ((HeapInfo *)ptr)->magic = AL_HEAP_MAGIC; 23 | ((HeapInfo *)ptr)->size = bytes; 24 | ((HeapInfo *)ptr)->count = hp->count; 25 | if (file) { 26 | ((HeapInfo *)ptr)->file = file; 27 | ((HeapInfo *)ptr)->line = line; 28 | } else { 29 | ((HeapInfo *)ptr)->file = (u8 *) "unknown"; 30 | ((HeapInfo *)ptr)->line = 0; 31 | } 32 | 33 | ptr += sizeof(HeapInfo); 34 | #endif 35 | 36 | } else { 37 | #ifdef _DEBUG 38 | __osError(ERR_ALHEAPNOFREE, 1, size); 39 | #endif 40 | } 41 | 42 | return ptr; 43 | } 44 | -------------------------------------------------------------------------------- /src/core1/audio/heapinit.c: -------------------------------------------------------------------------------- 1 | #include "synthInternals.h" 2 | #include 3 | 4 | void alHeapInit(ALHeap *hp, u8 *base, s32 len) 5 | { 6 | s32 extraAlign = (AL_CACHE_ALIGN+1) - ((s32) base & AL_CACHE_ALIGN); 7 | 8 | if (extraAlign != AL_CACHE_ALIGN+1) 9 | hp->base = base + extraAlign; 10 | else 11 | hp->base = base; 12 | 13 | hp->len = len; 14 | hp->cur = hp->base; 15 | hp->count = 0; 16 | } 17 | -------------------------------------------------------------------------------- /src/core1/audio/mainbus.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "synthInternals.h" 3 | 4 | Acmd *alMainBusPull(void *filter, s16 *outp, s32 outCount, s32 sampleOffset, Acmd *p) 5 | { 6 | Acmd *ptr = p; 7 | ALMainBus *m = (ALMainBus *)filter; 8 | ALFilter **sources = m->sources; 9 | s32 i; 10 | 11 | /* 12 | * clear the output buffers here 13 | */ 14 | aClearBuffer(ptr++, AL_MAIN_L_OUT, outCount<<1); 15 | aClearBuffer(ptr++, AL_MAIN_R_OUT, outCount<<1); 16 | 17 | for (i = 0; i < m->sourceCount; i++) { 18 | ptr = (sources[i]->handler)(sources[i], outp, outCount, sampleOffset, 19 | ptr); 20 | aSetBuffer(ptr++, 0, 0, 0, outCount<<1); 21 | aMix(ptr++, 0, 0x7fff, AL_AUX_L_OUT, AL_MAIN_L_OUT); 22 | aMix(ptr++, 0, 0x7fff, AL_AUX_R_OUT, AL_MAIN_R_OUT); 23 | } 24 | 25 | return ptr; 26 | } 27 | 28 | s32 alMainBusParam(void *filter, s32 paramID, void *param) 29 | { 30 | ALMainBus *m = (ALMainBus *) filter; 31 | ALFilter **sources = m->sources; 32 | 33 | switch (paramID) { 34 | 35 | case (AL_FILTER_ADD_SOURCE): 36 | sources[m->sourceCount++] = (ALFilter *) param; 37 | break; 38 | 39 | default: 40 | /* ??? */ 41 | break; 42 | } 43 | 44 | return 0; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/core1/audio/n_auxbus.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | #include "n_synth.h" 5 | 6 | Acmd *n_alAuxBusPull(s32 sampleOffset, Acmd *p) 7 | { 8 | Acmd *ptr = p; 9 | N_ALAuxBus *m = (N_ALAuxBus *)n_syn->auxBus; 10 | N_PVoice **sources = m->sources; 11 | s32 i; 12 | 13 | #ifndef N_MICRO 14 | aClearBuffer(ptr++, AL_AUX_L_OUT, FIXED_SAMPLE<<1); 15 | aClearBuffer(ptr++, AL_AUX_R_OUT, FIXED_SAMPLE<<1); 16 | #else 17 | aClearBuffer(ptr++, N_AL_AUX_L_OUT, N_AL_DIVIDED<<1); 18 | #endif 19 | 20 | for (i = 0; i < m->sourceCount; i++) 21 | ptr = n_alEnvmixerPull(sources[i],sampleOffset,ptr); 22 | return ptr; 23 | } 24 | -------------------------------------------------------------------------------- /src/core1/audio/n_envresample.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "n_synth.h" 3 | 4 | 5 | int 6 | n_alEnvmixerParam(N_PVoice *filter, s32 paramID, void *param) 7 | { 8 | N_PVoice *e = filter; 9 | 10 | switch (paramID) { 11 | case (AL_FILTER_ADD_UPDATE): 12 | if (e->em_ctrlTail) { 13 | e->em_ctrlTail->next = (ALParam *)param; 14 | } else { 15 | e->em_ctrlList = (ALParam *)param; 16 | } 17 | e->em_ctrlTail = (ALParam *)param; 18 | break; 19 | case (AL_FILTER_RESET): 20 | e->em_first = 1; 21 | e->em_motion = AL_STOPPED; 22 | e->em_volume = 1; 23 | e->rs_delta = 0.0; 24 | e->rs_first = 1; 25 | e->rs_upitch = 0; 26 | n_alLoadParam(e, AL_FILTER_RESET, param); 27 | break; 28 | case (AL_FILTER_START): 29 | e->em_motion = AL_PLAYING; 30 | break; 31 | default: 32 | #if 1 33 | n_alLoadParam(e, paramID, param); 34 | #else 35 | n_alResampleParam(e, paramID, param); 36 | #endif 37 | break; 38 | } 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /src/core1/audio/n_mainbus.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "n_synth.h" 3 | 4 | Acmd *n_alMainBusPull( s32 sampleOffset, Acmd *p) 5 | { 6 | Acmd *ptr = p; 7 | 8 | #ifndef N_MICRO 9 | aClearBuffer(ptr++, AL_MAIN_L_OUT, FIXED_SAMPLE<<1); 10 | aClearBuffer(ptr++, AL_MAIN_R_OUT, FIXED_SAMPLE<<1); 11 | #else 12 | aClearBuffer(ptr++, N_AL_MAIN_L_OUT, N_AL_DIVIDED<<1); 13 | #endif 14 | 15 | ptr = (n_syn->mainBus->filter.handler)(sampleOffset,ptr); 16 | 17 | #ifndef N_MICRO 18 | aSetBuffer(ptr++, 0, 0, 0, FIXED_SAMPLE<<1); 19 | aMix(ptr++, 0, 0x7fff, AL_AUX_L_OUT, AL_MAIN_L_OUT); 20 | aMix(ptr++, 0, 0x7fff, AL_AUX_R_OUT, AL_MAIN_R_OUT); 21 | #else 22 | aMix(ptr++, 0, 0x7fff, N_AL_AUX_L_OUT, N_AL_MAIN_L_OUT); 23 | aMix(ptr++, 0, 0x7fff, N_AL_AUX_R_OUT, N_AL_MAIN_R_OUT); 24 | #endif 25 | 26 | return ptr; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /src/core1/audio/n_resample_add01.c_: -------------------------------------------------------------------------------- 1 | n_aResample(ptr++, osVirtualToPhysical(e->rs_state), e->rs_first, incr, inp, 0); 2 | 3 | -------------------------------------------------------------------------------- /src/core1/audio/n_save.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "n_synth.h" 3 | 4 | Acmd *n_alSavePull( s32 sampleOffset, Acmd *p) 5 | { 6 | Acmd *ptr = p; 7 | 8 | ptr = n_alMainBusPull(sampleOffset, ptr); 9 | 10 | #ifndef N_MICRO 11 | aSetBuffer (ptr++, 0, 0, 0, FIXED_SAMPLE<<1); 12 | aInterleave(ptr++, AL_MAIN_L_OUT, AL_MAIN_R_OUT); 13 | aSetBuffer (ptr++, 0, 0, 0, FIXED_SAMPLE<<2); 14 | aSaveBuffer(ptr++, n_syn->sv_dramout); 15 | #else 16 | #include "n_save_add01.c_" 17 | #endif 18 | return ptr; 19 | } 20 | -------------------------------------------------------------------------------- /src/core1/audio/n_save_add01.c_: -------------------------------------------------------------------------------- 1 | n_aInterleave(ptr++); 2 | n_aSaveBuffer(ptr++, FIXED_SAMPLE<<2, 0, n_syn->sv_dramout); 3 | -------------------------------------------------------------------------------- /src/core1/audio/n_sl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | #include "n_libaudio.h" 6 | 7 | 8 | N_ALSynth *D_80276E80 = NULL; 9 | N_ALSynth *n_syn = NULL; 10 | 11 | void n_alInit(N_ALGlobals *g, ALSynConfig *config) 12 | { 13 | if (D_80276E80 != NULL) 14 | return; 15 | 16 | D_80276E80 = &g->drvr; 17 | 18 | if (n_syn != NULL) 19 | return; 20 | 21 | n_syn = &g->drvr; 22 | 23 | n_alSynNew(config); 24 | } 25 | 26 | void n_alClose(N_ALGlobals *glob) 27 | { 28 | if (D_80276E80) 29 | { 30 | n_alSynDelete(); 31 | 32 | D_80276E80 = NULL; 33 | n_syn = NULL; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/core1/audio/n_synallocfx.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | #include "n_synth.h" 5 | 6 | ALFxRef n_alSynAllocFX( s16 bus, ALSynConfig *c, ALHeap *hp) 7 | { 8 | n_alFxNew(&n_syn->auxBus->fx_array[bus], c, hp); 9 | return(n_syn->auxBus->fx_array[bus]); 10 | } 11 | -------------------------------------------------------------------------------- /src/core1/audio/n_syndelete.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "n_synth.h" 3 | 4 | 5 | void n_alSynDelete(void){ 6 | n_syn->head = NULL; 7 | n_syn->n_seqp1 = NULL; 8 | n_syn->n_seqp2 = NULL; 9 | n_syn->unk5C = NULL; 10 | n_syn->unk60 = NULL; 11 | n_syn->unk64 = NULL; 12 | n_syn->unk68 = NULL; 13 | n_syn->unk6C = NULL; 14 | n_syn->unk70 = NULL; 15 | n_syn->n_sndp = NULL; 16 | } 17 | -------------------------------------------------------------------------------- /src/core1/audio/n_synfreevoice.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "n_synth.h" 3 | 4 | void n_alSynFreeVoice(N_ALVoice *voice) 5 | { 6 | ALFilter *f; 7 | ALFreeParam *update; 8 | 9 | if (voice->pvoice) { 10 | 11 | if (voice->pvoice->offset) { /* if voice was stolen */ 12 | update = (ALFreeParam *)__n_allocParam(); 13 | ALFailIf(update == 0, ERR_ALSYN_NO_UPDATE); 14 | 15 | /* 16 | * set voice data 17 | */ 18 | update->delta = n_syn->paramSamples + voice->pvoice->offset; 19 | update->type = AL_FILTER_FREE_VOICE; 20 | update->pvoice = (PVoice *)voice->pvoice; 21 | 22 | n_alEnvmixerParam(voice->pvoice, AL_FILTER_ADD_UPDATE, update); 23 | } else { 24 | _n_freePVoice(voice->pvoice); 25 | } 26 | 27 | voice->pvoice = 0; 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/core1/audio/n_synsetfxmix.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "n_synth.h" 3 | 4 | 5 | void n_alSynSetFXMix(N_ALVoice *v, u8 fxmix) 6 | { 7 | ALParam *update; 8 | 9 | if (v->pvoice) { 10 | /* 11 | * get new update struct from the free list 12 | */ 13 | update = __n_allocParam(); 14 | ALFailIf(update == 0, ERR_ALSYN_NO_UPDATE); 15 | 16 | /* 17 | * set offset and fxmix data 18 | */ 19 | update->delta = n_syn->paramSamples + v->pvoice->offset; 20 | update->type = AL_FILTER_SET_FXAMT; 21 | if (fxmix < 0) 22 | update->data.i = -fxmix; 23 | else 24 | update->data.i = fxmix; 25 | update->next = 0; 26 | 27 | n_alEnvmixerParam(v->pvoice, AL_FILTER_ADD_UPDATE, update); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/core1/audio/n_synsetpan.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "n_synth.h" 3 | 4 | void n_alSynSetPan(N_ALVoice *v, u8 pan) 5 | { 6 | ALParam *update; 7 | ALFilter *f; 8 | 9 | if (v->pvoice) { 10 | 11 | /* 12 | * get new update struct from the free list 13 | */ 14 | update = __n_allocParam(); 15 | ALFailIf(update == 0, ERR_ALSYN_NO_UPDATE); 16 | 17 | /* 18 | * set offset and pan data 19 | */ 20 | update->delta = n_syn->paramSamples + v->pvoice->offset; 21 | update->type = AL_FILTER_SET_PAN; 22 | update->data.i = pan; 23 | update->next = 0; 24 | 25 | n_alEnvmixerParam(v->pvoice, AL_FILTER_ADD_UPDATE, update); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/core1/audio/n_synsetpitch.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "n_synth.h" 3 | 4 | void n_alSynSetPitch( N_ALVoice *v, f32 pitch) 5 | { 6 | ALParam *update; 7 | ALFilter *f; 8 | 9 | if (v->pvoice) { 10 | /* 11 | * get new update struct from the free list 12 | */ 13 | 14 | update = __n_allocParam(); 15 | ALFailIf(update == 0, ERR_ALSYN_NO_UPDATE); 16 | 17 | /* 18 | * set offset and pitch data 19 | */ 20 | update->delta = n_syn->paramSamples + v->pvoice->offset; 21 | update->type = AL_FILTER_SET_PITCH; 22 | update->data.f = pitch; 23 | update->next = 0; 24 | 25 | n_alEnvmixerParam(v->pvoice, AL_FILTER_ADD_UPDATE, update); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/core1/audio/n_synsetpriority.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void n_alSynSetPriority(N_ALVoice *voice, s16 priority){ 5 | voice->priority = priority; 6 | } 7 | -------------------------------------------------------------------------------- /src/core1/audio/n_synsetvol.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "n_synth.h" 3 | 4 | 5 | void n_alSynSetVol( N_ALVoice *v, s16 volume, ALMicroTime t) 6 | { 7 | ALParam *update; 8 | ALFilter *f; 9 | 10 | if (v->pvoice) { 11 | /* 12 | * get new update struct from the free list 13 | */ 14 | update = __n_allocParam(); 15 | ALFailIf(update == 0, ERR_ALSYN_NO_UPDATE); 16 | 17 | /* 18 | * set offset and volume data 19 | */ 20 | update->delta = n_syn->paramSamples + v->pvoice->offset; 21 | update->type = AL_FILTER_SET_VOLUME; 22 | update->data.i = volume; 23 | update->moredata.i = _n_timeToSamples( t); 24 | update->next = 0; 25 | 26 | //f = v->pvoice->channelKnob; 27 | //(*f->setParam)(f, AL_FILTER_ADD_UPDATE, update); 28 | n_alEnvmixerParam(v->pvoice, AL_FILTER_ADD_UPDATE, update); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/core1/audio/n_synstartvoiceparam.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "synthInternals.h" 3 | #include "n_synth.h" 4 | 5 | 6 | void n_alSynStartVoiceParams(N_ALVoice *v, ALWaveTable *w, 7 | f32 pitch, s16 vol, ALPan pan, u8 fxmix, 8 | ALMicroTime t) 9 | { 10 | ALStartParamAlt *update; 11 | 12 | 13 | 14 | if ( v->pvoice) { 15 | /* 16 | * get new update struct from the free list 17 | */ 18 | update = (ALStartParamAlt *)__n_allocParam(); 19 | ALFailIf(update == 0, ERR_ALSYN_NO_UPDATE); 20 | 21 | if (fxmix < 0) 22 | fxmix = -fxmix; 23 | 24 | /* 25 | * set offset and fxmix data 26 | */ 27 | update->delta = n_syn->paramSamples + v->pvoice->offset; 28 | update->next = 0; 29 | update->type = AL_FILTER_START_VOICE_ALT; 30 | 31 | update->unity = v->unityPitch; 32 | update->pan = pan; 33 | update->volume = vol; 34 | update->fxMix = fxmix; 35 | update->pitch = pitch; 36 | update->samples = _n_timeToSamples( t); 37 | update->wave = w; 38 | 39 | n_alEnvmixerParam(v->pvoice, AL_FILTER_ADD_UPDATE, update); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/core1/audio/n_synstopvoice.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "n_synth.h" 3 | 4 | 5 | void n_alSynStopVoice( N_ALVoice *v) 6 | { 7 | ALParam *update; 8 | 9 | if (v->pvoice) { 10 | 11 | update = __n_allocParam(); 12 | ALFailIf(update == 0, ERR_ALSYN_NO_UPDATE); 13 | 14 | update->delta = n_syn->paramSamples + v->pvoice->offset; 15 | update->type = AL_FILTER_STOP_VOICE; 16 | update->next = 0; 17 | 18 | n_alEnvmixerParam(v->pvoice, AL_FILTER_ADD_UPDATE, update); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/core1/audio/save.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "synthInternals.h" 3 | 4 | Acmd *alSavePull(void *filter, s16 *outp, s32 outCount, s32 sampleOffset, 5 | Acmd *p) 6 | 7 | { 8 | Acmd *ptr = p; 9 | ALSave *f = (ALSave *)filter; 10 | ALFilter *source = f->filter.source; 11 | 12 | ptr = (*source->handler)(source, outp, outCount, sampleOffset, ptr); 13 | 14 | aSetBuffer (ptr++, 0, 0, 0, outCount<<1); 15 | aInterleave(ptr++, AL_MAIN_L_OUT, AL_MAIN_R_OUT); 16 | aSetBuffer (ptr++, 0, 0, 0, outCount<<2); 17 | aSaveBuffer(ptr++, f->dramout); 18 | return ptr; 19 | } 20 | 21 | s32 alSaveParam(void *filter, s32 paramID, void *param) 22 | { 23 | ALSave *a = (ALSave *) filter; 24 | ALFilter *f = (ALFilter *) filter; 25 | s32 pp = (s32) param; 26 | 27 | switch (paramID) { 28 | case (AL_FILTER_SET_SOURCE): 29 | f->source = (ALFilter *) param; 30 | break; 31 | 32 | case (AL_FILTER_SET_DRAM): 33 | a->dramout = pp; 34 | break; 35 | 36 | default: 37 | break; 38 | } 39 | return 0; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/core1/audio/sl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | ALGlobals *alGlobals = NULL; 6 | 7 | void alInit(ALGlobals *g, ALSynConfig *c){ 8 | if (!alGlobals) { /* already initialized? */ 9 | alGlobals = g; 10 | alSynNew(&alGlobals->drvr, c); 11 | } 12 | } 13 | 14 | void alClose(ALGlobals *glob) 15 | { 16 | if (alGlobals) { 17 | alSynDelete(&glob->drvr); 18 | alGlobals = 0; 19 | } 20 | } 21 | 22 | void alLink(ALLink *ln, ALLink *to){ 23 | ln->next = to->next; 24 | ln->prev = to; 25 | if (to->next) 26 | to->next->prev = ln; 27 | to->next = ln; 28 | } 29 | 30 | void alUnlink(ALLink *ln){ 31 | if (ln->next) 32 | ln->next->prev = ln->prev; 33 | if (ln->prev) 34 | ln->prev->next = ln->next; 35 | } 36 | -------------------------------------------------------------------------------- /src/core1/audio/synallocfx.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "synthInternals.h" 3 | 4 | ALFxRef *alSynAllocFX(ALSynth *s, s16 bus, ALSynConfig *c, ALHeap *hp) 5 | { 6 | alFxNew(&s->auxBus[bus].fx[0], c, hp); 7 | alFxParam(&s->auxBus[bus].fx[0], AL_FILTER_SET_SOURCE, 8 | &s->auxBus[bus]); 9 | alMainBusParam(s->mainBus, AL_FILTER_ADD_SOURCE,&s->auxBus[bus].fx[0]); 10 | 11 | return (ALFxRef)(&s->auxBus[bus].fx[0]); 12 | } 13 | -------------------------------------------------------------------------------- /src/core1/audio/syndelete.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void alSynDelete(ALSynth *drvr) 4 | { 5 | drvr->head = 0; 6 | } 7 | -------------------------------------------------------------------------------- /src/core1/crccalc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "core1/core1.h" 3 | 4 | // transform seed (in mips3 file) 5 | u32 func_8025C29C(u32 *seed); // TODO: This function does not exist in source code, why does it work? 6 | 7 | void glcrc_calc_checksum(void *start, void *end, u32 checksum[2]) { 8 | u8 *p; 9 | u32 shift = 0; 10 | u64 seed = 0x8F809F473108B3C1; 11 | u32 crc1 = 0; 12 | u32 crc2 = 0; 13 | u32 tmp; 14 | 15 | // CRC1: Iterate forwards over bytes 16 | for (p = start; (void *)p < end; p++) { 17 | seed += *p << (shift & 15); 18 | tmp = func_8025C29C(&seed); 19 | shift += 7; 20 | crc1 ^= tmp; 21 | } 22 | 23 | // CRC2: Iterate backwards over bytes 24 | for (p = (u8 *)end - 1; (void *)p >= start; p--) { 25 | seed += *p << (shift & 15); 26 | tmp = func_8025C29C(&seed); 27 | shift += 3; 28 | crc2 ^= tmp; 29 | } 30 | 31 | checksum[0] = crc1; 32 | checksum[1] = crc2; 33 | } 34 | -------------------------------------------------------------------------------- /src/core1/data_1E820.c: -------------------------------------------------------------------------------- 1 | unsigned long long D_80276E70 = 0xAB8D9F7781280783; 2 | -------------------------------------------------------------------------------- /src/core1/eeprom.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "core1/core1.h" 3 | #include "save.h" 4 | 5 | #define ROUND_UP_DIVIDE(a, b) (((a) + (b) - 1) / (b)) 6 | 7 | // The round up divide is not technically needed, but will come in handy for modding 8 | #define GAMEFILE_NUM_BLOCKS ROUND_UP_DIVIDE(sizeof(SaveData), EEPROM_BLOCK_SIZE) 9 | 10 | s32 eeprom_writeBlocks(s32 file, s32 offset, void *buffer, s32 count) { 11 | s32 address = file * GAMEFILE_NUM_BLOCKS + offset; 12 | s32 ret; 13 | 14 | func_8024F35C(3); 15 | ret = osEepromLongWrite(pfsManager_getFrameReplyQ(), address, buffer, count * EEPROM_BLOCK_SIZE); 16 | func_8024F35C(0); 17 | 18 | return ret; 19 | } 20 | 21 | s32 eeprom_readBlocks(s32 file, s32 offset, void *buffer, s32 count) { 22 | s32 address = file * GAMEFILE_NUM_BLOCKS + offset; 23 | s32 ret; 24 | 25 | func_8024F35C(3); 26 | ret = osEepromLongRead(pfsManager_getFrameReplyQ(), address, buffer, count * EEPROM_BLOCK_SIZE); 27 | func_8024F35C(0); 28 | 29 | return ret; 30 | } 31 | -------------------------------------------------------------------------------- /src/core1/gu/guint.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * * 3 | * Copyright (C) 1994, Silicon Graphics, Inc. * 4 | * * 5 | * These coded instructions, statements, and computer programs contain * 6 | * unpublished proprietary information of Silicon Graphics, Inc., and * 7 | * are protected by Federal copyright law. They may not be disclosed * 8 | * to third parties or copied or duplicated in any form, in whole or * 9 | * in part, without the prior written consent of Silicon Graphics, Inc. * 10 | * * 11 | **************************************************************************/ 12 | 13 | #include "mbi.h" 14 | #include "gu.h" 15 | 16 | typedef union 17 | { 18 | struct 19 | { 20 | unsigned int hi; 21 | unsigned int lo; 22 | } word; 23 | 24 | double d; 25 | } du; 26 | 27 | typedef union 28 | { 29 | unsigned int i; 30 | float f; 31 | } fu; 32 | 33 | #ifndef __GL_GL_H__ 34 | 35 | typedef float Matrix[4][4]; 36 | 37 | #endif 38 | 39 | #define ROUND(d) (int)(((d) >= 0.0) ? ((d) + 0.5) : ((d) - 0.5)) 40 | #define ABS(d) ((d) > 0) ? (d) : -(d) 41 | 42 | extern float __libm_qnan_f; 43 | -------------------------------------------------------------------------------- /src/core1/gu/normalize.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | 6 | void guNormalize(float *x, float *y, float *z) 7 | { 8 | float m; 9 | 10 | m = gu_sqrtf((*x)*(*x) + (*y)*(*y) + (*z)*(*z)); 11 | m = (f32)1.0/ m; 12 | *x *= m; 13 | *y *= m; 14 | *z *= m; 15 | } 16 | -------------------------------------------------------------------------------- /src/core1/gu/ortho.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | 6 | void guOrthoF(float mf[4][4], float l, float r, float b, float t, float n, float f, float scale) 7 | { 8 | int i, j; 9 | 10 | guMtxIdentF(mf); 11 | 12 | mf[0][0] = 2/(r-l); 13 | mf[1][1] = 2/(t-b); 14 | mf[2][2] = -2/(f-n); 15 | mf[3][0] = -(r+l)/(r-l); 16 | mf[3][1] = -(t+b)/(t-b); 17 | mf[3][2] = -(f+n)/(f-n); 18 | mf[3][3] = 1; 19 | 20 | for (i=0; i<4; i++) 21 | for (j=0; j<4; j++) 22 | mf[i][j] *= scale; 23 | } 24 | 25 | void guOrtho(Mtx *m, float l, float r, float b, float t, float n, float f, float scale) 26 | { 27 | float mf[4][4]; 28 | 29 | guOrthoF(mf, l, r, b, t, n, f, scale); 30 | guMtxF2L(mf, m); 31 | } 32 | -------------------------------------------------------------------------------- /src/core1/gu/rotate.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | f32 sinf(f32); 6 | f32 cosf(f32); 7 | 8 | void guRotateF(float mf[4][4], float a, float x, float y, float z) 9 | { 10 | static f32 D_80285900 = 3.1415926 / 180.0; 11 | float sine; 12 | float cosine; 13 | float ab, bc, ca, t; 14 | 15 | 16 | guNormalize(&x, &y, &z); 17 | a *= D_80285900; 18 | sine = sinf(a); 19 | cosine = cosf(a); 20 | t = (1-cosine); 21 | ab = x*y*t; 22 | bc = y*z*t; 23 | ca = z*x*t; 24 | 25 | guMtxIdentF(mf); 26 | 27 | t = x*x; 28 | mf[0][0] = t+cosine*(1-t); 29 | mf[2][1] = bc-x*sine; 30 | mf[1][2] = bc+x*sine; 31 | 32 | t = y*y; 33 | mf[1][1] = t+cosine*(1-t); 34 | mf[2][0] = ca+y*sine; 35 | mf[0][2] = ca-y*sine; 36 | 37 | t = z*z; 38 | mf[2][2] = t+cosine*(1-t); 39 | mf[1][0] = ab-z*sine; 40 | mf[0][1] = ab+z*sine; 41 | } 42 | 43 | void guRotate(Mtx *m, float a, float x, float y, float z) 44 | { 45 | float mf[4][4]; 46 | 47 | guRotateF(mf, a, x, y, z); 48 | guMtxF2L(mf, m); 49 | } 50 | -------------------------------------------------------------------------------- /src/core1/gu/sqrtf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | 6 | float gu_sqrtf(float val){ 7 | return sqrtf(val); 8 | } 9 | -------------------------------------------------------------------------------- /src/core1/gu/translate.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | 6 | void guTranslateF(float mf[4][4], float x, float y, float z) 7 | { 8 | guMtxIdentF(mf); 9 | 10 | mf[3][0] = x; 11 | mf[3][1] = y; 12 | mf[3][2] = z; 13 | } 14 | 15 | 16 | void guTranslate(Mtx *m, float x, float y, float z) 17 | { 18 | float mf[4][4]; 19 | 20 | guTranslateF(mf, x, y, z); 21 | guMtxF2L(mf, m); 22 | } 23 | -------------------------------------------------------------------------------- /src/core1/initthread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "core1/core1.h" 3 | #include "functions.h" 4 | #include "variables.h" 5 | 6 | #define INIT_THREAD_STACK_SIZE 0x200 7 | 8 | u8 sInitThreadStack[INIT_THREAD_STACK_SIZE]; // Size based on the previous symbol's address 9 | OSThread sInitThread; 10 | 11 | void initThread_entry(void *arg); 12 | 13 | void initThread_create(void) { 14 | osCreateThread(&sInitThread, 1, initThread_entry, NULL, sInitThreadStack + INIT_THREAD_STACK_SIZE, OS_PRIORITY_IDLE); 15 | osStartThread(&sInitThread); 16 | } 17 | 18 | void piMgr_init(void); 19 | void mainThread_create(void); 20 | OSThread *mainThread_get(void); 21 | 22 | void initThread_entry(void *arg) 23 | { 24 | piMgr_init(); 25 | mainThread_create(); 26 | osStartThread(mainThread_get()); 27 | while (1); 28 | } 29 | -------------------------------------------------------------------------------- /src/core1/io/ai.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | s32 __osAiDeviceBusy(void) 5 | { 6 | register s32 status = IO_READ(AI_STATUS_REG); 7 | if (status & AI_STATUS_FIFO_FULL) 8 | 9 | return 1; 10 | 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /src/core1/io/aigetlen.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | u32 osAiGetLength(void) 4 | { 5 | return IO_READ(AI_LEN_REG); 6 | } 7 | -------------------------------------------------------------------------------- /src/core1/io/aisetfreq.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "osint.h" 3 | 4 | s32 osAiSetFrequency(u32 frequency) 5 | { 6 | register unsigned int dacRate; 7 | register int bitRate; 8 | register float f; 9 | f = osViClock / (float)frequency + .5f; 10 | dacRate = f; 11 | if (dacRate < AI_MIN_DAC_RATE) 12 | return -1; 13 | bitRate = (dacRate / 66) & 0xFF; 14 | if (bitRate > AI_MAX_BIT_RATE) 15 | bitRate = AI_MAX_BIT_RATE; 16 | IO_WRITE(AI_DACRATE_REG, dacRate - 1); 17 | IO_WRITE(AI_BITRATE_REG, bitRate - 1); 18 | IO_WRITE(AI_CONTROL_REG, AI_CONTROL_DMA_ON); 19 | return osViClock / (s32)dacRate; 20 | } 21 | -------------------------------------------------------------------------------- /src/core1/io/aisetnextbuf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "osint.h" 4 | 5 | s32 osAiSetNextBuffer(void *bufPtr, u32 size) 6 | { 7 | static u8 hdwrBugFlag = 0; 8 | char *bptr = bufPtr; 9 | if (hdwrBugFlag != 0) 10 | bptr -= 0x2000; 11 | 12 | if ((((u32)bufPtr + size) & 0x3fff) == 0x2000) 13 | hdwrBugFlag = 1; 14 | else 15 | hdwrBugFlag = 0; 16 | 17 | if (__osAiDeviceBusy()) 18 | return -1; 19 | 20 | IO_WRITE(AI_DRAM_ADDR_REG, osVirtualToPhysical(bptr)); 21 | IO_WRITE(AI_LEN_REG, size); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /src/core1/io/cartrominit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | extern OSPiHandle *__osPiTable; 6 | 7 | OSPiHandle CartRomHandle; 8 | OSPiHandle *osCartRomInit(void) 9 | { 10 | u32 domain; 11 | u32 saveMask; 12 | 13 | domain = 0; 14 | 15 | if (CartRomHandle.baseAddress == PHYS_TO_K1(PI_DOM1_ADDR2)) 16 | return &CartRomHandle; 17 | 18 | CartRomHandle.type = DEVICE_TYPE_CART; 19 | CartRomHandle.baseAddress = PHYS_TO_K1(PI_DOM1_ADDR2); 20 | osPiRawReadIo(NULL, &domain); 21 | CartRomHandle.latency = domain & 0xff; 22 | CartRomHandle.pulse = (domain >> 8) & 0xff; 23 | CartRomHandle.pageSize = (domain >> 0x10) & 0xf; 24 | CartRomHandle.relDuration = (domain >> 0x14) & 0xf; 25 | CartRomHandle.domain = PI_DOMAIN1; 26 | CartRomHandle.speed = 0; 27 | 28 | bzero(&CartRomHandle.transferInfo, sizeof(__OSTranxInfo)); 29 | 30 | saveMask = __osDisableInt(); 31 | CartRomHandle.next = __osPiTable; 32 | __osPiTable = &CartRomHandle; 33 | __osRestoreInt(saveMask); 34 | 35 | return &CartRomHandle; 36 | }//*/ 37 | -------------------------------------------------------------------------------- /src/core1/io/conteeplongread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "controller.h" 3 | s32 osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, int length) 4 | { 5 | s32 ret; 6 | ret = 0; 7 | while (length > 0) 8 | { 9 | ERRCK(osEepromRead(mq, address, buffer)); 10 | length -= EEPROM_BLOCK_SIZE; 11 | address++; 12 | buffer += EEPROM_BLOCK_SIZE; 13 | } 14 | return ret; 15 | } 16 | -------------------------------------------------------------------------------- /src/core1/io/conteeplongwrite.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "controller.h" 3 | 4 | s32 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, int length) 5 | { 6 | s32 ret; 7 | ret = 0; 8 | while (length > 0) 9 | { 10 | ERRCK(osEepromWrite(mq, address, buffer)); 11 | length -= EEPROM_BLOCK_SIZE; 12 | address++; 13 | buffer += EEPROM_BLOCK_SIZE; 14 | osSetTimer(&__osEepromTimer, 12000 * osClockRate / 1000000, 0, &__osEepromTimerQ, &__osEepromTimerMsg); 15 | osRecvMesg(&__osEepromTimerQ, NULL, OS_MESG_BLOCK); 16 | } 17 | return ret; 18 | } 19 | -------------------------------------------------------------------------------- /src/core1/io/contsetch.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "controller.h" 3 | #include "siint.h" 4 | 5 | s32 osContSetCh(u8 ch) 6 | { 7 | s32 ret; 8 | ret = 0; 9 | __osSiGetAccess(); 10 | if (ch > MAXCONTROLLERS) 11 | { 12 | __osMaxControllers = 4; 13 | } 14 | else 15 | { 16 | __osMaxControllers = ch; 17 | } 18 | __osContLastCmd = CONT_CMD_END; //TODO: is this right? 19 | __osSiRelAccess(); 20 | return ret; 21 | } 22 | -------------------------------------------------------------------------------- /src/core1/io/crc.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | u8 __osContAddressCrc(u16 addr) 4 | { 5 | u8 temp; 6 | u8 temp2; 7 | int i; 8 | temp = 0; 9 | for (i = 0; i < 16; i++) 10 | { 11 | if (temp & 0x10) 12 | temp2 = 21; 13 | else 14 | temp2 = 0; 15 | 16 | temp <<= 1; 17 | temp |= (u8)((addr & 0x400) ? 1 : 0); 18 | addr <<= 1; 19 | temp ^= temp2; 20 | } 21 | return temp & 0x1f; 22 | } 23 | u8 __osContDataCrc(u8 *data) 24 | { 25 | u8 temp; 26 | u8 temp2; 27 | int i; 28 | int j; 29 | temp = 0; 30 | for (i = 0; i <= 32; i++, data++) 31 | { 32 | for (j = 7; j >= 0; j--) 33 | { 34 | if (temp & 0x80) 35 | temp2 = 133; 36 | else 37 | temp2 = 0; 38 | temp <<= 1; 39 | if (i == 32) 40 | temp &= -1; 41 | else 42 | temp |= ((*data & (1 << j)) ? 1 : 0); 43 | temp ^= temp2; 44 | } 45 | } 46 | return temp; 47 | } 48 | -------------------------------------------------------------------------------- /src/core1/io/dpgetstat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | u32 osDpGetStatus(){ 5 | return IO_READ(DPC_STATUS_REG); 6 | } 7 | -------------------------------------------------------------------------------- /src/core1/io/dpsetstat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void osDpSetStatus(u32 data) 5 | { 6 | IO_WRITE(DPC_STATUS_REG, data); 7 | } 8 | -------------------------------------------------------------------------------- /src/core1/io/epirawread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "piint.h" 4 | 5 | s32 osEPiRawReadIo(OSPiHandle *pihandle, u32 devAddr, u32 *data) 6 | { 7 | register u32 stat; 8 | register u32 domain; 9 | 10 | WAIT_ON_IOBUSY(stat); 11 | 12 | *data = IO_READ(pihandle->baseAddress | devAddr); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /src/core1/io/epirawwrite.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "piint.h" 3 | 4 | s32 osEPiRawWriteIo(OSPiHandle *pihandle, u32 devAddr, u32 data) 5 | { 6 | register u32 stat; 7 | register u32 domain; 8 | 9 | WAIT_ON_IOBUSY(stat); 10 | 11 | IO_WRITE(pihandle->baseAddress | devAddr, data); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /src/core1/io/leodiskinit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | OSPiHandle LeoDiskHandle; 6 | OSPiHandle *__osDiskHandle; 7 | OSPiHandle *osLeoDiskInit() 8 | { 9 | u32 saveMask; 10 | LeoDiskHandle.type = DEVICE_TYPE_64DD; 11 | LeoDiskHandle.baseAddress = PHYS_TO_K1(PI_DOM2_ADDR1); 12 | LeoDiskHandle.latency = 3; 13 | LeoDiskHandle.pulse = 6; 14 | LeoDiskHandle.pageSize = 6; 15 | LeoDiskHandle.relDuration = 2; 16 | LeoDiskHandle.domain = PI_DOMAIN2; 17 | IO_WRITE(PI_BSD_DOM2_LAT_REG, LeoDiskHandle.latency); 18 | IO_WRITE(PI_BSD_DOM2_PWD_REG, LeoDiskHandle.pulse); 19 | IO_WRITE(PI_BSD_DOM2_PGS_REG, LeoDiskHandle.pageSize); 20 | IO_WRITE(PI_BSD_DOM2_RLS_REG, LeoDiskHandle.relDuration); 21 | LeoDiskHandle.speed = 0; 22 | bzero(&LeoDiskHandle.transferInfo, sizeof(__OSTranxInfo)); 23 | saveMask = __osDisableInt(); 24 | LeoDiskHandle.next = __osPiTable; 25 | __osPiTable = &LeoDiskHandle; 26 | __osDiskHandle = &LeoDiskHandle; 27 | __osRestoreInt(saveMask); 28 | return &LeoDiskHandle; 29 | } 30 | -------------------------------------------------------------------------------- /src/core1/io/pfsgetstatus.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "controller.h" 3 | #include "siint.h" 4 | 5 | extern OSPifRam __osPfsPifRam; 6 | s32 __osPfsGetStatus(OSMesgQueue *queue, int channel) 7 | { 8 | s32 ret; 9 | OSMesg dummy; 10 | u8 pattern; 11 | OSContStatus data[4]; 12 | ret = 0; 13 | __osPfsRequestData(CONT_CMD_REQUEST_STATUS); 14 | ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); 15 | osRecvMesg(queue, &dummy, OS_MESG_BLOCK); 16 | ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam); 17 | osRecvMesg(queue, &dummy, OS_MESG_BLOCK); 18 | __osPfsGetInitData(&pattern, data); 19 | if (((data[channel].status & CONT_CARD_ON) != 0) && ((data[channel].status & CONT_CARD_PULL) != 0)) 20 | return PFS_ERR_NEW_PACK; 21 | if ((data[channel].errno != 0) || ((data[channel].status & CONT_CARD_ON) == 0)) 22 | return PFS_ERR_NOPACK; 23 | if ((data[channel].status & CONT_ADDR_CRC_ER) != 0) 24 | return PFS_ERR_CONTRFAIL; 25 | return ret; 26 | } 27 | -------------------------------------------------------------------------------- /src/core1/io/pfsinit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "controller.h" 3 | #include "siint.h" 4 | 5 | s32 osPfsInit(OSMesgQueue *queue, OSPfs *pfs, int channel) 6 | { 7 | s32 ret; 8 | ret = 0; 9 | __osSiGetAccess(); 10 | ret = __osPfsGetStatus(queue, channel); 11 | __osSiRelAccess(); 12 | if (ret != 0) 13 | return ret; 14 | 15 | pfs->queue = queue; 16 | pfs->channel = channel; 17 | pfs->status = 0; 18 | pfs->activebank = -1; 19 | ERRCK(__osGetId(pfs)); 20 | 21 | ret = osPfsChecker(pfs); 22 | pfs->status |= PFS_INITIALIZED; 23 | return ret; 24 | } 25 | -------------------------------------------------------------------------------- /src/core1/io/piacs.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define PI_Q_BUF_LEN 1 4 | u32 __osPiAccessQueueEnabled = 0; 5 | OSMesg piAccessBuf[PI_Q_BUF_LEN]; // todo bss 6 | OSMesgQueue __osPiAccessQueue; 7 | void __osPiCreateAccessQueue(void) 8 | { 9 | 10 | __osPiAccessQueueEnabled = 1; 11 | osCreateMesgQueue(&__osPiAccessQueue, piAccessBuf, PI_Q_BUF_LEN); 12 | osSendMesg(&__osPiAccessQueue, NULL, OS_MESG_NOBLOCK); 13 | } 14 | void __osPiGetAccess(void) 15 | { 16 | OSMesg dummyMesg; 17 | if (!__osPiAccessQueueEnabled) 18 | __osPiCreateAccessQueue(); 19 | osRecvMesg(&__osPiAccessQueue, &dummyMesg, OS_MESG_BLOCK); 20 | } 21 | void __osPiRelAccess(void) 22 | { 23 | osSendMesg(&__osPiAccessQueue, NULL, OS_MESG_NOBLOCK); 24 | } 25 | -------------------------------------------------------------------------------- /src/core1/io/pigetcmdq.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | extern OSDevMgr __osPiDevMgr; 6 | 7 | OSMesgQueue *osPiGetCmdQueue(void){ 8 | if (!__osPiDevMgr.active) 9 | return NULL; 10 | return __osPiDevMgr.cmdQueue; 11 | } 12 | -------------------------------------------------------------------------------- /src/core1/io/pirawdma.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef WAIT_ON_IOBUSY 4 | #define WAIT_ON_IOBUSY(stat) \ 5 | stat = IO_READ(PI_STATUS_REG); \ 6 | while (stat & (PI_STATUS_IO_BUSY | PI_STATUS_DMA_BUSY)) \ 7 | stat = IO_READ(PI_STATUS_REG); 8 | #endif 9 | 10 | s32 osPiRawStartDma(s32 direction, u32 devAddr, void *dramAddr, u32 size) 11 | { 12 | register u32 stat; 13 | WAIT_ON_IOBUSY(stat); 14 | IO_WRITE(PI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr)); 15 | IO_WRITE(PI_CART_ADDR_REG, K1_TO_PHYS((u32)osRomBase | devAddr)); 16 | switch (direction) 17 | { 18 | case OS_READ: 19 | IO_WRITE(PI_WR_LEN_REG, size - 1); 20 | break; 21 | case OS_WRITE: 22 | IO_WRITE(PI_RD_LEN_REG, size - 1); 23 | break; 24 | default: 25 | return -1; 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /src/core1/io/pirawread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "piint.h" 3 | 4 | s32 osPiRawReadIo(u32 devAddr, u32 *data) 5 | { 6 | register u32 stat; 7 | WAIT_ON_IOBUSY(stat); 8 | *data = IO_READ((u32)osRomBase | devAddr); 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /src/core1/io/piread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "piint.h" 3 | 4 | s32 osPiReadIo(u32 devAddr, u32 *data) 5 | { 6 | register s32 ret; 7 | __osPiGetAccess(); 8 | ret = osPiRawReadIo(devAddr, data); 9 | __osPiRelAccess(); 10 | return ret; 11 | } 12 | -------------------------------------------------------------------------------- /src/core1/io/si.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | int __osSiDeviceBusy() 6 | { 7 | register u32 stat = IO_READ(SI_STATUS_REG); 8 | if (stat & (SI_STATUS_DMA_BUSY | SI_STATUS_RD_BUSY)) 9 | return 1; 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /src/core1/io/siacs.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define SI_Q_BUF_LEN 1 4 | u32 __osSiAccessQueueEnabled = 0; 5 | OSMesg siAccessBuf[SI_Q_BUF_LEN]; 6 | OSMesgQueue __osSiAccessQueue; 7 | 8 | void __osSiCreateAccessQueue(void) 9 | { 10 | __osSiAccessQueueEnabled = 1; 11 | osCreateMesgQueue(&__osSiAccessQueue, siAccessBuf, SI_Q_BUF_LEN); 12 | osSendMesg(&__osSiAccessQueue, NULL, OS_MESG_NOBLOCK); 13 | } 14 | void __osSiGetAccess(void) 15 | { 16 | OSMesg dummyMesg; 17 | if (!__osSiAccessQueueEnabled) 18 | __osSiCreateAccessQueue(); 19 | osRecvMesg(&__osSiAccessQueue, &dummyMesg, OS_MESG_BLOCK); 20 | } 21 | void __osSiRelAccess(void) 22 | { 23 | osSendMesg(&__osSiAccessQueue, NULL, OS_MESG_NOBLOCK); 24 | } 25 | -------------------------------------------------------------------------------- /src/core1/io/siint.h: -------------------------------------------------------------------------------- 1 | #ifndef _SIINT_H 2 | #define _SIINT_H 3 | #include 4 | #include 5 | 6 | void __osSiGetAccess(void); 7 | void __osSiRelAccess(void); 8 | int __osSiDeviceBusy(void); 9 | void __osSiCreateAccessQueue(void); 10 | #endif 11 | -------------------------------------------------------------------------------- /src/core1/io/sirawdma.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | s32 __osSiRawStartDma(s32 direction, void *dramAddr) 4 | { 5 | if (__osSiDeviceBusy()) 6 | return -1; 7 | 8 | if (direction == OS_WRITE) 9 | osWritebackDCache(dramAddr, 64); 10 | 11 | IO_WRITE(SI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr)); 12 | 13 | if (direction == OS_READ) 14 | IO_WRITE(SI_PIF_ADDR_RD64B_REG, 0x1FC007C0); 15 | else 16 | IO_WRITE(SI_PIF_ADDR_WR64B_REG, 0x1FC007C0); 17 | 18 | if (direction == OS_READ) 19 | osInvalDCache(dramAddr, 64);//bzero(dramAddr, 64); 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /src/core1/io/sirawread.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | s32 __osSiRawReadIo(u32 devAddr, u32 *data) 4 | { 5 | if (__osSiDeviceBusy()) 6 | return -1; 7 | *data = IO_READ(devAddr); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /src/core1/io/sirawwrite.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | s32 __osSiRawWriteIo(u32 devAddr, u32 data) 4 | { 5 | 6 | if (__osSiDeviceBusy()) 7 | return -1; 8 | IO_WRITE(devAddr, data); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /src/core1/io/sp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "osint.h" 5 | 6 | int __osSpDeviceBusy() 7 | { 8 | register u32 stat = IO_READ(SP_STATUS_REG); 9 | if (stat & (SP_STATUS_DMA_BUSY | SP_STATUS_DMA_FULL | SP_STATUS_IO_FULL)) 10 | return 1; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /src/core1/io/spgetstat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | u32 __osSpGetStatus() 5 | { 6 | return IO_READ(SP_STATUS_REG); 7 | } 8 | -------------------------------------------------------------------------------- /src/core1/io/sprawdma.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "osint.h" 4 | 5 | s32 __osSpRawStartDma(s32 direction, u32 devAddr, void *dramAddr, u32 size) 6 | { 7 | if (__osSpDeviceBusy()) 8 | return -1; 9 | IO_WRITE(SP_MEM_ADDR_REG, devAddr); 10 | IO_WRITE(SP_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr)); 11 | if (direction == OS_READ) 12 | IO_WRITE(SP_WR_LEN_REG, size - 1); 13 | else 14 | IO_WRITE(SP_RD_LEN_REG, size - 1); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /src/core1/io/spsetpc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | s32 __osSpSetPc(u32 data) 5 | { 6 | register u32 stat = IO_READ(SP_STATUS_REG); 7 | if (!(stat & SP_STATUS_HALT)) 8 | return -1; 9 | else 10 | { 11 | IO_WRITE(SP_PC_REG, data); 12 | } 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /src/core1/io/spsetstat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void __osSpSetStatus(u32 data){ 5 | IO_WRITE(SP_STATUS_REG, data); 6 | } 7 | -------------------------------------------------------------------------------- /src/core1/io/sptaskyield.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void osSpTaskYield(void) 5 | { 6 | __osSpSetStatus(SP_SET_YIELD); 7 | } 8 | -------------------------------------------------------------------------------- /src/core1/io/sptaskyielded.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | OSYieldResult osSpTaskYielded(OSTask *tp) 6 | { 7 | u32 status; 8 | OSYieldResult result; 9 | status = __osSpGetStatus(); 10 | if (status & SP_STATUS_YIELDED) 11 | result = OS_TASK_YIELDED; 12 | else 13 | result = 0; 14 | if (status & SP_STATUS_YIELD) 15 | { 16 | tp->t.flags |= result; 17 | tp->t.flags &= ~(OS_TASK_DP_WAIT); 18 | } 19 | return result; 20 | } 21 | -------------------------------------------------------------------------------- /src/core1/io/vi.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "viint.h" 5 | 6 | static __OSViContext vi[2] = {0}; 7 | __OSViContext *__osViCurr = &vi[0]; 8 | __OSViContext *__osViNext = &vi[1]; 9 | void __osViInit(void) 10 | { 11 | bzero(vi, sizeof(vi)); 12 | __osViCurr = &vi[0]; 13 | __osViNext = &vi[1]; 14 | __osViNext->retraceCount = 1; 15 | __osViCurr->retraceCount = 1; 16 | __osViNext->framep = (void*)K0BASE; 17 | __osViCurr->framep = (void*)K0BASE; 18 | if (osTvType == OS_TV_TYPE_PAL) 19 | { 20 | __osViNext->modep = &osViModePalLan1; 21 | } 22 | else if (osTvType == OS_TV_TYPE_MPAL) 23 | { 24 | __osViNext->modep = &osViModeMpalLan1; 25 | } 26 | else 27 | { 28 | __osViNext->modep = &osViModeNtscLan1; 29 | } 30 | __osViNext->state = VI_STATE_BLACK; 31 | __osViNext->control = __osViNext->modep->comRegs.ctrl; 32 | while (IO_READ(VI_CURRENT_REG) > 10) //wait for vsync? 33 | ; 34 | IO_WRITE(VI_CONTROL_REG, 0); //pixel size blank (no data, no sync) 35 | __osViSwapContext(); 36 | } 37 | -------------------------------------------------------------------------------- /src/core1/io/viblack.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | #include "viint.h" 5 | 6 | void osViBlack(u8 active) 7 | { 8 | register u32 saveMask = __osDisableInt(); 9 | if (active) 10 | __osViNext->state |= VI_STATE_BLACK; 11 | else 12 | __osViNext->state &= ~VI_STATE_BLACK; 13 | __osRestoreInt(saveMask); 14 | } 15 | -------------------------------------------------------------------------------- /src/core1/io/vigetcurrcontext.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "viint.h" 3 | 4 | __OSViContext *__osViGetCurrentContext(void) 5 | { 6 | return __osViCurr; 7 | } 8 | -------------------------------------------------------------------------------- /src/core1/io/vigetcurrframebuf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "viint.h" 3 | 4 | void *osViGetCurrentFramebuffer(void) 5 | { 6 | register u32 saveMask; 7 | void *framep; 8 | saveMask = __osDisableInt(); 9 | framep = __osViCurr->framep; 10 | __osRestoreInt(saveMask); 11 | return framep; 12 | } 13 | -------------------------------------------------------------------------------- /src/core1/io/vigetnextframebuf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | #include "viint.h" 5 | 6 | void *osViGetNextFramebuffer(void) 7 | { 8 | register u32 saveMask; 9 | void *framep; 10 | saveMask = __osDisableInt(); 11 | framep = __osViNext->framep; 12 | __osRestoreInt(saveMask); 13 | return framep; 14 | } 15 | -------------------------------------------------------------------------------- /src/core1/io/visetevent.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | #include "viint.h" 5 | 6 | void osViSetEvent(OSMesgQueue *mq, OSMesg m, u32 retraceCount){ 7 | register u32 saveMask; 8 | saveMask = __osDisableInt(); 9 | __osViNext->msgq = mq; 10 | __osViNext->msg = m; 11 | __osViNext->retraceCount = retraceCount; 12 | __osRestoreInt(saveMask); 13 | } 14 | -------------------------------------------------------------------------------- /src/core1/io/visetmode.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "viint.h" 3 | 4 | void osViSetMode(OSViMode *modep) 5 | { 6 | register u32 saveMask; 7 | saveMask = __osDisableInt(); 8 | __osViNext->modep = modep; 9 | __osViNext->state = VI_STATE_01; 10 | __osViNext->control = __osViNext->modep->comRegs.ctrl; 11 | __osRestoreInt(saveMask); 12 | } 13 | -------------------------------------------------------------------------------- /src/core1/io/viswapbuf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | #include "viint.h" 5 | 6 | void osViSwapBuffer(void* frameBufPtr){ 7 | u32 saveMask = __osDisableInt(); 8 | __osViNext->framep = frameBufPtr; 9 | __osViNext->state |= VI_STATE_10; 10 | __osRestoreInt(saveMask); 11 | } 12 | -------------------------------------------------------------------------------- /src/core1/ll.c: -------------------------------------------------------------------------------- 1 | unsigned long long __ull_rshift(unsigned long long a0, unsigned long long a1) 2 | { 3 | return a0 >> a1; 4 | } 5 | unsigned long long __ull_rem(unsigned long long a0, unsigned long long a1) 6 | { 7 | return a0 % a1; 8 | } 9 | unsigned long long __ull_div(unsigned long long a0, unsigned long long a1) 10 | { 11 | return a0 / a1; 12 | } 13 | 14 | unsigned long long __ll_lshift(unsigned long long a0, unsigned long long a1) 15 | { 16 | return a0 << a1; 17 | } 18 | 19 | long long __ll_rem(unsigned long long a0, long long a1) 20 | { 21 | return a0 % a1; 22 | } 23 | 24 | long long __ll_div(long long a0, long long a1) 25 | { 26 | return a0 / a1; 27 | } 28 | 29 | unsigned long long __ll_mul(unsigned long long a0, unsigned long long a1) 30 | { 31 | return a0 * a1; 32 | } 33 | 34 | void __ull_divremi(unsigned long long *div, unsigned long long *rem, unsigned long long a2, unsigned short a3) 35 | { 36 | *div = a2 / a3; 37 | *rem = a2 % a3; 38 | } 39 | long long __ll_mod(long long a0, long long a1) 40 | { 41 | long long tmp = a0 % a1; 42 | if ((tmp < 0 && a1 > 0) || (tmp > 0 && a1 < 0)) 43 | { 44 | 45 | tmp += a1; 46 | } 47 | return tmp; 48 | } 49 | 50 | long long __ll_rshift(long long a0, long long a1) 51 | { 52 | return a0 >> a1; 53 | } 54 | -------------------------------------------------------------------------------- /src/core1/ll_cvt.c: -------------------------------------------------------------------------------- 1 | long long __d_to_ll(double a0) 2 | { 3 | return a0; 4 | } 5 | 6 | long long __f_to_ll(float a0) 7 | { 8 | return a0; 9 | } 10 | 11 | unsigned long long __d_to_ull(double a0) 12 | { 13 | return a0; 14 | } 15 | 16 | unsigned long long __f_to_ull(float a0) 17 | { 18 | return a0; 19 | } 20 | 21 | double __ll_to_d(long long a0) 22 | { 23 | return a0; 24 | } 25 | 26 | float __ll_to_f(long long a0) 27 | { 28 | return a0; 29 | } 30 | 31 | double __ull_to_d(unsigned long long a0) 32 | { 33 | return a0; 34 | } 35 | 36 | float __ull_to_f(unsigned long long a0) 37 | { 38 | return a0; 39 | } 40 | -------------------------------------------------------------------------------- /src/core1/n_reverb_add01.c_: -------------------------------------------------------------------------------- 1 | n_aLoadBuffer(ptr++, before_end<<1, buff, osVirtualToPhysical(curr_ptr)); 2 | n_aLoadBuffer(ptr++, after_end<<1, buff+(before_end<<1), osVirtualToPhysical(r->base)); 3 | } else { 4 | n_aLoadBuffer(ptr++, count<<1, buff, osVirtualToPhysical(curr_ptr)); 5 | } 6 | -------------------------------------------------------------------------------- /src/core1/n_reverb_add02.c_: -------------------------------------------------------------------------------- 1 | n_aSaveBuffer(ptr++, before_end<<1, buff, osVirtualToPhysical(curr_ptr)); 2 | n_aSaveBuffer(ptr++, after_end<<1, buff+(before_end<<1), osVirtualToPhysical(r->base)); 3 | } else { 4 | n_aSaveBuffer(ptr++, FIXED_SAMPLE<<1, buff, osVirtualToPhysical(curr_ptr)); 5 | } 6 | -------------------------------------------------------------------------------- /src/core1/n_reverb_add03.c_: -------------------------------------------------------------------------------- 1 | { 2 | s16 tmp; 3 | 4 | tmp = buff >> 8; 5 | n_aLoadADPCM(ptr++, 32, osVirtualToPhysical(lp->fcvec.fccoef)); 6 | n_aPoleFilter(ptr++, lp->first, lp->fgain, tmp, osVirtualToPhysical(lp->fstate)); 7 | } 8 | -------------------------------------------------------------------------------- /src/core1/n_reverb_add04.c_: -------------------------------------------------------------------------------- 1 | { 2 | s16 tmp; 3 | 4 | tmp = buff >> 8; 5 | n_aResample(ptr++, osVirtualToPhysical(d->rs->state), d->rs->first, ratio, rbuff + (ramalign<<1), tmp); 6 | } 7 | -------------------------------------------------------------------------------- /src/core1/os/createmesgqueue.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | extern struct __osThreadTail 6 | { 7 | OSThread *next; 8 | OSPri priority; 9 | } __osThreadTail; 10 | 11 | void osCreateMesgQueue(OSMesgQueue *mq, OSMesg *msg, s32 msgCount) 12 | { 13 | mq->mtqueue = (OSThread *)&__osThreadTail; 14 | mq->fullqueue = (OSThread *)&__osThreadTail; 15 | mq->validCount = 0; 16 | mq->first = 0; 17 | mq->msgCount = msgCount; 18 | mq->msg = msg; 19 | } 20 | -------------------------------------------------------------------------------- /src/core1/os/createthread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void __osCleanupThread(void); 6 | extern OSThread *__osActiveQueue; 7 | void osCreateThread(OSThread *t, OSId id, void (*entry)(void *), void *arg, void *sp, OSPri p) 8 | { 9 | register u32 saveMask; 10 | OSIntMask mask; 11 | t->id = id; 12 | t->priority = p; 13 | t->next = NULL; 14 | t->queue = NULL; 15 | t->context.pc = (u32)entry; 16 | t->context.a0 = (u64)arg; 17 | t->context.sp = (u64)sp - 16; 18 | t->context.ra = (u64)__osCleanupThread; 19 | // t->context.ra = (u64)func_8026ABE0; 20 | mask = OS_IM_ALL; 21 | t->context.sr = SR_IMASK | SR_EXL | SR_IE; 22 | t->context.rcp = (mask & RCP_IMASK) >> RCP_IMASKSHIFT; 23 | t->context.fpcsr = (u32)(FPCSR_FS | FPCSR_EV); 24 | t->fp = 0; 25 | t->state = OS_STATE_STOPPED; 26 | t->flags = 0; 27 | saveMask = __osDisableInt(); 28 | t->tlnext = __osActiveQueue; 29 | __osActiveQueue = t; 30 | __osRestoreInt(saveMask); 31 | } 32 | -------------------------------------------------------------------------------- /src/core1/os/destroythread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | extern OSThread *__osRunningThread; 6 | extern OSThread *__osActiveQueue; 7 | extern void __osDispatchThread(void); 8 | 9 | void osDestroyThread(OSThread *t) 10 | { 11 | register u32 saveMask; 12 | register OSThread *pred; 13 | register OSThread *succ; 14 | saveMask = __osDisableInt(); 15 | if (t == NULL) 16 | { 17 | t = __osRunningThread; 18 | } 19 | else 20 | { 21 | if (t->state != OS_STATE_STOPPED) 22 | { 23 | __osDequeueThread(t->queue, t); 24 | } 25 | } 26 | if (__osActiveQueue == t) 27 | { 28 | __osActiveQueue = __osActiveQueue->tlnext; 29 | } 30 | else 31 | { 32 | pred = __osActiveQueue; 33 | while (succ = pred->tlnext) 34 | { 35 | if (succ == t) 36 | { 37 | pred->tlnext = t->tlnext; 38 | break; 39 | } 40 | pred = succ; 41 | } 42 | } 43 | if (t == __osRunningThread) 44 | { 45 | __osDispatchThread(); 46 | } 47 | __osRestoreInt(saveMask); 48 | } 49 | -------------------------------------------------------------------------------- /src/core1/os/getthreadpri.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | extern OSThread *__osRunningThread; 6 | 7 | OSPri osGetThreadPri(OSThread *thread) 8 | { 9 | if (thread == NULL) 10 | thread = __osRunningThread; 11 | return thread->priority; 12 | } 13 | -------------------------------------------------------------------------------- /src/core1/os/gettime.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "osint.h" 3 | 4 | 5 | OSTime osGetTime() 6 | { 7 | u32 tmptime; 8 | u32 elapseCount; 9 | OSTime currentCount; 10 | register u32 saveMask; 11 | saveMask = __osDisableInt(); 12 | tmptime = osGetCount(); 13 | elapseCount = tmptime - __osBaseCounter; 14 | currentCount = __osCurrentTime; 15 | __osRestoreInt(saveMask); 16 | return currentCount + elapseCount; 17 | } 18 | -------------------------------------------------------------------------------- /src/core1/os/jammesg.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern OSThread *__osRunningThread; 4 | 5 | s32 osJamMesg(OSMesgQueue *mq, OSMesg msg, s32 flag) 6 | { 7 | register u32 saveMask = __osDisableInt(); 8 | while (mq->validCount >= mq->msgCount) 9 | { 10 | if (flag == OS_MESG_BLOCK) 11 | { 12 | __osRunningThread->state = OS_STATE_WAITING; 13 | __osEnqueueAndYield(&mq->fullqueue); 14 | } 15 | else 16 | { 17 | __osRestoreInt(saveMask); 18 | return -1; 19 | } 20 | } 21 | 22 | mq->first = (mq->first + mq->msgCount - 1) % mq->msgCount; 23 | mq->msg[mq->first] = msg; 24 | mq->validCount++; 25 | if (mq->mtqueue->next != NULL) 26 | { 27 | osStartThread(__osPopThread(&mq->mtqueue)); 28 | } 29 | __osRestoreInt(saveMask); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /src/core1/os/kdebugserver.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | //not included in final rom, but __osThreadSave is here for some reason 4 | OSThread __osThreadSave; 5 | -------------------------------------------------------------------------------- /src/core1/os/pidma.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | extern OSDevMgr __osPiDevMgr; 6 | 7 | s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, u32 devAddr, void *dramAddr, u32 size, OSMesgQueue *mq) 8 | { 9 | register s32 ret; 10 | if (!__osPiDevMgr.active) 11 | return -1; 12 | if (direction == OS_READ) 13 | mb->hdr.type = OS_MESG_TYPE_DMAREAD; 14 | else 15 | mb->hdr.type = OS_MESG_TYPE_DMAWRITE; 16 | mb->hdr.pri = priority; 17 | mb->hdr.retQueue = mq; 18 | mb->dramAddr = dramAddr; 19 | mb->devAddr = devAddr; 20 | mb->size = size; 21 | mb->piHandle = NULL; 22 | if (priority == OS_MESG_PRI_HIGH) 23 | { 24 | ret = osJamMesg(osPiGetCmdQueue(), (OSMesg)mb, OS_MESG_NOBLOCK); 25 | } 26 | else 27 | { 28 | ret = osSendMesg(osPiGetCmdQueue(), (OSMesg)mb, OS_MESG_NOBLOCK); 29 | } 30 | return ret; 31 | } 32 | -------------------------------------------------------------------------------- /src/core1/os/recvmesg.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | extern OSThread *__osRunningThread;//_osRunningThread; 6 | 7 | s32 osRecvMesg(OSMesgQueue *mq, OSMesg *msg, s32 flags) 8 | { 9 | register u32 saveMask; 10 | saveMask = __osDisableInt(); 11 | 12 | while (MQ_IS_EMPTY(mq)) 13 | { 14 | if (flags == OS_MESG_NOBLOCK) 15 | { 16 | __osRestoreInt(saveMask); 17 | return -1; 18 | } 19 | __osRunningThread->state = OS_STATE_WAITING; 20 | __osEnqueueAndYield(&mq->mtqueue); 21 | } 22 | 23 | if (msg != NULL) 24 | { 25 | *msg = mq->msg[mq->first]; 26 | } 27 | mq->first = (mq->first + 1) % mq->msgCount; 28 | mq->validCount--; 29 | if (mq->fullqueue->next != NULL) 30 | { 31 | osStartThread(__osPopThread(&mq->fullqueue)); 32 | } 33 | __osRestoreInt(saveMask); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /src/core1/os/resetglobalintmask.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void __osResetGlobalIntMask(OSHWIntr interrupt) 5 | { 6 | register u32 saveMask = __osDisableInt(); 7 | 8 | //not sure about these constants, SR_IBIT3 is external level 3 INT0, which I think corresponds to the rcp 9 | //os.h has several masks defined that end in 401 but non that are just 401 10 | __OSGlobalIntMask &= ~(interrupt & ~(SR_IBIT3 | SR_IE)); 11 | 12 | __osRestoreInt(saveMask); 13 | } 14 | -------------------------------------------------------------------------------- /src/core1/os/sendmesg.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | extern OSThread *__osRunningThread; 6 | 7 | s32 osSendMesg(OSMesgQueue *mq, OSMesg msg, s32 flags) 8 | { 9 | register u32 saveMask; 10 | register s32 last; 11 | saveMask = __osDisableInt(); 12 | while (MQ_IS_FULL(mq)) 13 | { 14 | if (flags == OS_MESG_BLOCK) 15 | { 16 | __osRunningThread->state = OS_STATE_WAITING; 17 | __osEnqueueAndYield(&mq->fullqueue); 18 | } 19 | else 20 | { 21 | __osRestoreInt(saveMask); 22 | return -1; 23 | } 24 | } 25 | last = (mq->first + mq->validCount) % mq->msgCount; 26 | mq->msg[last] = msg; 27 | mq->validCount++; 28 | if (mq->mtqueue->next != NULL) 29 | { 30 | osStartThread(__osPopThread(&mq->mtqueue)); 31 | } 32 | __osRestoreInt(saveMask); 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /src/core1/os/seteventmesg.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "osint.h" 3 | 4 | __OSEventState __osEventStateTab[OS_NUM_EVENTS]; 5 | void osSetEventMesg(OSEvent event, OSMesgQueue *mq, OSMesg msg) 6 | { 7 | register u32 saveMask = __osDisableInt(); 8 | __OSEventState *es; 9 | 10 | es = &__osEventStateTab[event]; 11 | es->messageQueue = mq; 12 | es->message = msg; 13 | __osRestoreInt(saveMask); 14 | } 15 | -------------------------------------------------------------------------------- /src/core1/os/setglobalintmask.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void __osSetGlobalIntMask(OSHWIntr mask) 5 | { 6 | register u32 saveMask = __osDisableInt(); 7 | __OSGlobalIntMask |= mask; 8 | __osRestoreInt(saveMask); 9 | } 10 | -------------------------------------------------------------------------------- /src/core1/os/settimer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "osint.h" 3 | int osSetTimer(OSTimer *t, OSTime value, OSTime interval, OSMesgQueue *mq, OSMesg msg) 4 | { 5 | OSTime time; 6 | t->next = NULL; 7 | t->prev = NULL; 8 | t->interval = interval; 9 | if(value != 0) t->value = value; 10 | else t->value = interval; 11 | t->mq = mq; 12 | t->msg = msg; 13 | time = __osInsertTimer(t); 14 | if(__osTimerList->next == t) { 15 | __osSetTimerIntr(time); 16 | } 17 | return 0; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /src/core1/os/settreadpri.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | extern OSThread *__osRunningThread; 6 | extern OSThread *__osRunQueue; 7 | 8 | void osSetThreadPri(OSThread *t, OSPri pri) 9 | { 10 | register u32 saveMask = __osDisableInt(); 11 | if (t == NULL) 12 | t = __osRunningThread; 13 | if (t->priority != pri) 14 | { 15 | t->priority = pri; 16 | if (t != __osRunningThread && t->state != OS_STATE_STOPPED) 17 | { 18 | __osDequeueThread(t->queue, t); 19 | __osEnqueueThread(t->queue, t); 20 | } 21 | if (__osRunningThread->priority < __osRunQueue->priority) 22 | { 23 | __osRunningThread->state = OS_STATE_RUNNABLE; 24 | __osEnqueueAndYield(&__osRunQueue); 25 | } 26 | } 27 | __osRestoreInt(saveMask); 28 | } 29 | -------------------------------------------------------------------------------- /src/core1/os/startthread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | 6 | extern OSThread * __osRunQueue; 7 | extern OSThread * __osRunningThread; 8 | 9 | void osStartThread(OSThread *t) 10 | { 11 | register u32 saveMask = __osDisableInt(); 12 | switch (t->state) 13 | { 14 | case OS_STATE_WAITING: 15 | t->state = OS_STATE_RUNNABLE; 16 | __osEnqueueThread(&__osRunQueue, t); 17 | break; 18 | case OS_STATE_STOPPED: 19 | if (t->queue == NULL || t->queue == &__osRunQueue) 20 | { 21 | t->state = OS_STATE_RUNNABLE; 22 | __osEnqueueThread(&__osRunQueue, t); 23 | } 24 | else 25 | { 26 | t->state = OS_STATE_WAITING; 27 | __osEnqueueThread(t->queue, t); 28 | __osEnqueueThread(&__osRunQueue, __osPopThread(t->queue)); 29 | } 30 | break; 31 | } 32 | if (__osRunningThread == NULL) 33 | { 34 | __osDispatchThread(); 35 | } 36 | else 37 | { 38 | if (__osRunningThread->priority < __osRunQueue->priority) 39 | { 40 | __osRunningThread->state = OS_STATE_RUNNABLE; 41 | __osEnqueueAndYield(&__osRunQueue); 42 | } 43 | } 44 | __osRestoreInt(saveMask); 45 | } 46 | -------------------------------------------------------------------------------- /src/core1/os/stopthread.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern OSThread *__osRunningThread; 4 | 5 | void osStopThread(OSThread *t) 6 | { 7 | register u32 saveMask = __osDisableInt(); 8 | register u16 state; 9 | if (t == NULL) 10 | { 11 | state = OS_STATE_RUNNING; 12 | } 13 | else 14 | { 15 | state = t->state; 16 | } 17 | switch (state) 18 | { 19 | case OS_STATE_RUNNING: 20 | __osRunningThread->state = OS_STATE_STOPPED; 21 | __osEnqueueAndYield(NULL); 22 | break; 23 | case OS_STATE_RUNNABLE: 24 | case OS_STATE_WAITING: 25 | t->state = OS_STATE_STOPPED; 26 | __osDequeueThread(t->queue, t); 27 | break; 28 | } 29 | __osRestoreInt(saveMask); 30 | } 31 | -------------------------------------------------------------------------------- /src/core1/os/stoptimer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "osint.h" 3 | 4 | int osStopTimer(OSTimer *t) 5 | { 6 | register u32 savedMask; 7 | OSTimer *timep; 8 | 9 | if (t->next == NULL) 10 | return -1; 11 | savedMask = __osDisableInt(); 12 | timep = t->next; 13 | if (timep != __osTimerList) 14 | { 15 | timep->value += t->value; 16 | } 17 | t->prev->next = t->next; 18 | t->next->prev = t->prev; 19 | t->next = NULL; 20 | t->prev = NULL; 21 | if (__osTimerList->next == __osTimerList) 22 | { 23 | __osSetCompare(0); 24 | } 25 | __osRestoreInt(savedMask); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /src/core1/os/thread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "osint.h" 3 | 4 | struct __osThreadTail __osThreadTail = {0, -1}; 5 | OSThread *__osRunQueue = (OSThread *)&__osThreadTail; 6 | OSThread *__osActiveQueue = (OSThread *)&__osThreadTail; 7 | OSThread *__osRunningThread = {0}; 8 | OSThread *__osFaultedThread = {0}; 9 | void __osDequeueThread(OSThread **queue, OSThread *t) 10 | { 11 | register OSThread *pred; 12 | register OSThread *succ; 13 | pred = (OSThread *)queue; //this is actually legit.. 14 | succ = pred->next; 15 | while (succ != NULL) 16 | { 17 | if (succ == t) 18 | { 19 | pred->next = t->next; 20 | return; 21 | } 22 | pred = succ; 23 | succ = pred->next; 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/core1/os/virtualtophysical.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "osint.h" 4 | 5 | u32 osVirtualToPhysical(void *addr) 6 | { 7 | if (IS_KSEG0(addr)) 8 | { 9 | return K0_TO_PHYS(addr); 10 | } 11 | else if (IS_KSEG1(addr)) 12 | { 13 | return K1_TO_PHYS(addr); 14 | } 15 | else 16 | { 17 | return __osProbeTLB(addr); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/core1/os/yieldthread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "osint.h" 3 | 4 | void osYieldThread(void){ 5 | register u32 saveMask = __osDisableInt(); 6 | __osRunningThread->state = OS_STATE_RUNNABLE; 7 | __osEnqueueAndYield(&__osRunQueue); 8 | __osRestoreInt(saveMask); 9 | } 10 | -------------------------------------------------------------------------------- /src/core1/sprite.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "core1/core1.h" 3 | 4 | u32 sprite_getUnk8(BKSprite *this) { 5 | return this->unk8; 6 | } 7 | 8 | u32 sprite_getUnkA(BKSprite *this) { 9 | return this->unkA; 10 | } 11 | 12 | u32 sprite_getUnk6(BKSprite *this) { 13 | return this->unk6; 14 | } 15 | 16 | u32 sprite_getUnk4(BKSprite *this) { 17 | return this->unk4; 18 | } 19 | 20 | s32 sprite_getFrameCount(BKSprite *this) { 21 | return this->frameCnt; 22 | } 23 | 24 | BKSpriteFrame *sprite_getFramePtr(BKSprite *this, u32 frame_id) { 25 | BKSpriteFrame *sprite_frame; 26 | sprite_frame = (BKSpriteFrame *) (this->offsets[frame_id] + ((s32) ((*this).offsets + this->frameCnt))); 27 | return sprite_frame; 28 | } 29 | -------------------------------------------------------------------------------- /src/core1/stub_13640.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "core1/core1.h" 3 | 4 | s32 stub_13640_get(void); 5 | void stub_13640_init(void); 6 | void stub_13640_set(s32 value); 7 | 8 | static s32 sUnused; 9 | 10 | s32 stubVar_13640_get(void) { 11 | return sUnused; 12 | } 13 | 14 | void stub_13640_init(void) { 15 | stub_13640_set(0); 16 | } 17 | 18 | void stub_13640_set(s32 arg0) { 19 | sUnused = arg0; 20 | } 21 | -------------------------------------------------------------------------------- /src/core1/stub_1D590.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "core1/core1.h" 3 | 4 | void dummy_func_8025AFB0(void) {} 5 | void dummy_func_8025AFB8(void) {} 6 | void dummy_func_8025AFC0(Gfx **gfx, Mtx **mtx, Vtx **vtx) {} 7 | s32 dummy_func_8025AFD0(void) { return 0; } 8 | -------------------------------------------------------------------------------- /src/core1/syncprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void osSyncPrintf(const char *fmt, ...) 6 | { 7 | int ans; 8 | va_list ap; 9 | // these functions intentionally left blank. ifdeffed out in rom release 10 | } 11 | void rmonPrintf(const char *fmt, ...) 12 | { 13 | int ans; 14 | va_list ap; 15 | } 16 | -------------------------------------------------------------------------------- /src/core1/ucode.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "core1/core1.h" 4 | #include "functions.h" 5 | #include "variables.h" 6 | 7 | #define UCODE_SIZE 256 8 | 9 | static u8 sUcodeData[UCODE_SIZE]; 10 | static s32 D_80283380; 11 | static s32 D_80283384; 12 | static s32 D_80283388; 13 | 14 | void ucode_load(void) { 15 | D_80283384 = *(s32 *)PHYS_TO_K1(0x04000000) ^ -1; 16 | D_80283388 = D_80283384 ? 0x01 : 0x00; 17 | 18 | D_80283380 = *(s32 *)PHYS_TO_K1(0x04001000) ^ 0x17D7; 19 | D_80283388 |= D_80283380 ? 0x02 : 0x00; 20 | 21 | if (D_80283388 == 0) { 22 | piMgr_read(&sUcodeData, 0xB0000B70, UCODE_SIZE); 23 | } 24 | } 25 | 26 | void ucode_stub1(void) {} 27 | 28 | void ucode_stub2(void) { 29 | osPiReadIo(0, NULL); 30 | } 31 | 32 | s32 ucode_stub3(void) { 33 | return 0; 34 | } 35 | 36 | void ucode_getPtrAndSize(void **ptr, u32 *size) { 37 | *ptr = &sUcodeData; 38 | *size = UCODE_SIZE; 39 | } 40 | -------------------------------------------------------------------------------- /src/core2/baflag.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | #include "enums.h" 5 | 6 | /*.bss */ 7 | u8 BaFlags[0x1C]; 8 | 9 | /* code */ 10 | void baflag_clearAll(void){ 11 | int i; 12 | for(i = 1; i < 0x1C; i++){ 13 | baflag_clear(i); 14 | } 15 | } 16 | 17 | bool baflag_isTrue(enum misc_flag_e arg0){ 18 | return BaFlags[arg0]; 19 | } 20 | 21 | bool baflag_isFalse(enum misc_flag_e arg0){ 22 | return !BaFlags[arg0]; 23 | } 24 | 25 | void baflag_set(enum misc_flag_e arg0){ 26 | BaFlags[arg0] = TRUE; 27 | } 28 | 29 | void baflag_clear(enum misc_flag_e arg0){ 30 | BaFlags[arg0] = FALSE; 31 | } 32 | 33 | void baflag_toggle(enum misc_flag_e arg0){ 34 | if(BaFlags[arg0]){ 35 | BaFlags[arg0] = FALSE; 36 | } 37 | else { 38 | BaFlags[arg0] = TRUE; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/core2/bs/surf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | #include "core2/ba/physics.h" 6 | 7 | /* .bss */ 8 | s32 D_8037D560; 9 | 10 | /* .code */ 11 | void func_802B5FD0(void) { 12 | AnimCtrl *anim_ctrl; 13 | 14 | anim_ctrl = baanim_getAnimCtrlPtr(); 15 | anctrl_reset(anim_ctrl); 16 | anctrl_setIndex(anim_ctrl, ASSET_69_ANIM_BSSURF); 17 | anctrl_setDuration(anim_ctrl, 1.8f); 18 | anctrl_setPlaybackType(anim_ctrl, ANIMCTRL_LOOP); 19 | anctrl_start(anim_ctrl, "bssurf.c", 0x33); 20 | func_8029C7F4(1, 1, 3, BA_PHYSICS_NORMAL); 21 | baphysics_set_target_horizontal_velocity(0.0f); 22 | D_8037D560 = 1; 23 | } 24 | 25 | void func_802B6064(void) { 26 | enum bs_e next_state; 27 | 28 | next_state = 0; 29 | if (bakey_pressed(BUTTON_A)) { 30 | next_state = BS_5_JUMP; 31 | } 32 | if (D_8037D560 == 0) { 33 | next_state = BS_1_IDLE; 34 | } 35 | D_8037D560 = 0; 36 | if (baflag_isTrue(BA_FLAG_6)) { 37 | next_state = BS_53_TIMEOUT; 38 | } 39 | bs_setState(next_state); 40 | } 41 | 42 | void func_802B60D0(void){} 43 | 44 | void func_802B60D8(void) { 45 | if (bs_getInterruptType() == BS_INTR_D_SURF) { 46 | D_8037D560 = 1; 47 | func_8029A86C(2); 48 | return; 49 | } 50 | func_80296608(); 51 | } 52 | -------------------------------------------------------------------------------- /src/core2/ch/musicnote.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void func_802C9C30(Actor* this); 6 | 7 | /* .data */ 8 | ActorInfo D_80366C50 = { 9 | MARKER_5F_MUSIC_NOTE, ACTOR_51_MUSIC_NOTE, ASSET_6D6_MODEL_MUSIC_NOTE, 0, NULL, 10 | func_802C9C30, actor_update_func_80326224, func_80325934, 11 | 0, 0, 0.6f, 0 12 | }; 13 | 14 | /* .code */ 15 | void func_802C9C30(Actor* this){ 16 | this->scale = 0.42857143f; 17 | } 18 | -------------------------------------------------------------------------------- /src/core2/ch/snacker.h: -------------------------------------------------------------------------------- 1 | #ifndef __BANJO_KAZOOIE_CORE2_CH_SNACKER_H__ 2 | #define __BANJO_KAZOOIE_CORE2_CH_SNACKER_H__ 3 | 4 | #include "prop.h" // for ActorInfo 5 | #include "../snackerctl.h" //for SnackerCtlState 6 | 7 | extern ActorInfo gChSnacker; 8 | 9 | void chSnacker_initialize(void); 10 | void chsnacker_setControlState(SnackerCtlState nextState); 11 | 12 | #endif // __BANJO_KAZOOIE_CORE2_CH_SNACKER_H__ 13 | -------------------------------------------------------------------------------- /src/core2/ch/snowmanhat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void chSnowmanHat_update(Actor *this); 6 | 7 | /* .data */ 8 | ActorInfo chSnowmanHat = { 9 | MARKER_B3_SIR_SLUSH_HAT, ACTOR_126_SIR_SLUSH_HAT, ASSET_379_MODEL_SIRSLUSH_HAT, 10 | 0x1, NULL, 11 | chSnowmanHat_update, actor_update_func_80326224, actor_draw, 12 | 4500, 0, 1.0f, 0 13 | }; 14 | 15 | /* code */ 16 | void chSnowmanHat_update(Actor *this){ 17 | switch(this->state){ 18 | case 1: 19 | this->position[0] += this->velocity[0]; 20 | this->position[1] += this->velocity[1]; 21 | this->position[2] += this->velocity[2]; 22 | 23 | this->velocity[1] += -3.0f; 24 | 25 | this->pitch += 10.0f; 26 | if( 360.0f <= this->pitch) 27 | this->pitch -= 360.0f; 28 | 29 | if(this->position_y <= mapModel_getFloorY(this->position)){ 30 | subaddie_set_state(this, 2); 31 | FUNC_8030E8B4(SFX_1D_HITTING_AN_ENEMY_1, 1.0f, 32750, this->position, 2250, 4500); 32 | } 33 | break; 34 | 35 | case 2: 36 | func_80326310(this); 37 | break; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/core2/code_10CD0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | #include "core2/statetimer.h" 5 | 6 | /* .bss */ 7 | u8 D_8037C530; 8 | 9 | /* .code */ 10 | void func_80297C60(s32 arg0){ 11 | D_8037C530 = arg0; 12 | } 13 | 14 | s32 func_80297C6C(void){ 15 | return D_8037C530; 16 | } 17 | 18 | void func_80297C78(void){ 19 | D_8037C530 = 0; 20 | func_80297C60(1); 21 | stateTimer_clear(STATE_TIMER_4_UNKNOWN); 22 | } 23 | 24 | void func_80297CA8(void){ 25 | func_80297CCC(0.6f); 26 | } 27 | 28 | void func_80297CCC(f32 value){ 29 | stateTimer_set(STATE_TIMER_4_UNKNOWN, value); 30 | func_80297C60(3); 31 | } 32 | 33 | void func_80297CF8(void){ 34 | if(stateTimer_isDone(STATE_TIMER_4_UNKNOWN)){ 35 | func_80297C60(1); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/core2/code_11040.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | /* .bss */ 6 | f32 D_8037C550; 7 | f32 D_8037C554; 8 | u8 D_8037C558; 9 | 10 | /* .code */ 11 | void func_80297FD0(s32 arg0){ 12 | D_8037C558 = arg0; 13 | } 14 | 15 | void func_80297FDC(void){ 16 | f32 diff = D_8037C554 - D_8037C550; 17 | if(mlAbsF(diff) < 0.001){ 18 | D_8037C550 = D_8037C554; 19 | } 20 | else{ 21 | D_8037C550 += ml_clamp_f(diff, -0.12f, 0.12f); 22 | } 23 | } 24 | 25 | void func_80298068(void){ 26 | f32 f2 = yaw_getIdeal() - yaw_get(); 27 | if(180.0f < f2){ 28 | f2 -= 360.0f; 29 | } 30 | else if(f2 < -180.0f){ 31 | f2 += 360.0f; 32 | } 33 | D_8037C554 = ml_map_f(f2, -40.0f, 40.0f, 1.0f, -1.0f); 34 | func_80297FDC(); 35 | } 36 | 37 | void func_80298114(void){} 38 | 39 | void func_8029811C(void){ 40 | D_8037C554 = D_8037C550 = 0.0f; 41 | D_8037C558 = 0; 42 | func_80297FD0(1); 43 | func_80297FD0(2); 44 | } 45 | 46 | void func_80298168(void){ 47 | if(D_8037C558 != 1 && D_8037C558 == 2){ 48 | func_80298068(); 49 | } 50 | } 51 | 52 | void func_802981A4(void){ 53 | if(D_8037C558 != 1 && D_8037C558 == 2){ 54 | func_80298114(); 55 | } 56 | } 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/core2/code_15F20.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | extern f32 func_8033DE30(s32); 6 | 7 | /* .bss */ 8 | u8 D_8037D1F0[5]; 9 | f32 D_8037D1F8[5]; 10 | 11 | /* .code */ 12 | s32 func_8029CEB0(void){ 13 | return func_802944F4(); 14 | } 15 | 16 | f32 func_8029CED0(void) { 17 | s32 temp_v0; 18 | 19 | temp_v0 = func_8029CEB0(); 20 | if (D_8037D1F0[temp_v0] != 0) { 21 | return D_8037D1F8[temp_v0]; 22 | } 23 | return func_8033DE30(temp_v0); 24 | } 25 | 26 | bool func_8029CF20(s32 arg0) { 27 | return func_802944F4() == arg0; 28 | } 29 | 30 | void func_8029CF48(s32 arg0, s32 arg1, f32 arg2) { 31 | D_8037D1F0[arg0] = arg1; 32 | D_8037D1F8[arg0] = arg2; 33 | } 34 | 35 | void func_8029CF6C(void) { 36 | s32 i; 37 | 38 | for(i = 0; i < 5; i++){ 39 | D_8037D1F0[i] = 0; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/core2/code_33250.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | #include 6 | #include 7 | 8 | static void __code33250_func_802BA23C(CameraNodeType4 *this, s32 arg1); 9 | 10 | /* .code */ 11 | CameraNodeType4 *cameraNodeType4_init(){ 12 | CameraNodeType4 * this; 13 | 14 | this = malloc(sizeof(CameraNodeType4)); 15 | __code33250_func_802BA23C(this, 1); 16 | return this; 17 | } 18 | 19 | void cameraNodeType4_free(CameraNodeType4 *this){ 20 | free(this); 21 | } 22 | 23 | s32 code33250_func_802BA234(CameraNodeType4 *this){ 24 | return this->unknownFlag; 25 | } 26 | 27 | static void __code33250_func_802BA23C(CameraNodeType4 *this, s32 arg1){ 28 | this->unknownFlag = arg1; 29 | } 30 | 31 | void cameraNodeType4_fromFile(File *file_ptr, CameraNodeType4 *this){ 32 | while(!file_isNextByteExpected(file_ptr, 0)){ 33 | file_getWord_ifExpected(file_ptr, 1, &this->unknownFlag); 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/core2/code_33C30.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "core1/core1.h" 3 | #include "functions.h" 4 | #include "variables.h" 5 | 6 | extern void func_802BEA4C(f32[3], f32[3], f32, f32[3]); 7 | extern ActorProp *func_80320EB0(ActorMarker *, f32, s32); 8 | 9 | /* .bss */ 10 | ActorMarker *D_8037D810; 11 | 12 | /* .code */ 13 | Actor *func_802BABC0(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ 14 | return NULL; 15 | } 16 | 17 | void func_802BABD8(void){ 18 | if(D_8037D810 != NULL){ 19 | marker_free(D_8037D810); 20 | D_8037D810 = NULL; 21 | } 22 | } 23 | 24 | void func_802BAC10(void){ 25 | D_8037D810 = NULL; 26 | } 27 | 28 | bool func_802BAC1C(void) { 29 | return BOOL(func_80320EB0(D_8037D810, 100.0f, 1) != NULL); 30 | } 31 | 32 | void func_802BAC58(void) { 33 | f32 vp_position[3]; 34 | f32 vp_rotation[3]; 35 | f32 sp1C[3]; 36 | 37 | viewport_getPosition_vec3f(vp_position); 38 | viewport_getRotation_vec3f(vp_rotation); 39 | func_802BEA4C(vp_rotation, vp_position, 150.0f, sp1C); 40 | if (D_8037D810 == NULL) { 41 | D_8037D810 = func_8032FBE4(sp1C, func_802BABC0, 1, 0x15D); 42 | } 43 | else{ 44 | func_8032F64C(sp1C, D_8037D810); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/core2/code_3EC30.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void func_802C5BC0(Actor *this); 6 | 7 | /* .data */ 8 | ActorInfo D_80365FB0 = { 0x65, 0xF3, 0x0, 0x0, 0x0, func_802C5BC0, actor_update_func_80326224, func_80325340, 0, 0, 0.0f, 0}; 9 | 10 | /* .code */ 11 | void func_802C5BC0(Actor *this){ 12 | if(!this->initialized){ 13 | actor_collisionOff(this); 14 | this->lifetime_value = 0.0f; 15 | this->pitch = 90.0f; 16 | fxRipple_802F3554(4, this->position); 17 | this->initialized = TRUE; 18 | } 19 | else{ 20 | this->lifetime_value += time_getDelta(); 21 | if(2.0 < this->lifetime_value) 22 | marker_despawn(this->marker); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/core2/code_41F30.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void chextralife_update(Actor *this); 6 | 7 | ActorInfo chExtraLife = { MARKER_61_EXTRA_LIFE, ACTOR_49_EXTRA_LIFE, ASSET_36E_MODEL_EXTRA_LIFE, 8 | 0x0, NULL, 9 | chextralife_update, actor_update_func_80326224, func_80325934, 10 | 0, 0, 0.7f, 0 11 | }; 12 | 13 | void chextralife_update(Actor *this){ 14 | if(!this->initialized){ 15 | func_8032AA58(this, 0.8f); 16 | this->initialized = TRUE; 17 | if(volatileFlag_get(VOLATILE_FLAG_1) || volatileFlag_get(VOLATILE_FLAG_2_FF_IN_MINIGAME)){ 18 | marker_despawn(this->marker); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/core2/code_599E0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | s32 func_802E0970(enum sfx_e sfxId, f32 arg1, f32 arg2, f32 arg3, s32 sampleRate, bool arg5, f32 position[3]) { 6 | f32 temp_f0; 7 | f32 phi_f2; 8 | 9 | phi_f2 = (arg5) ? arg1 : arg2; 10 | 11 | temp_f0 = arg3 * 0.5; 12 | func_8030E878(sfxId, randf2(phi_f2 - temp_f0, phi_f2 + temp_f0), sampleRate, position, 1000.0f, 2300.0f); 13 | return NOT(arg5); 14 | } 15 | -------------------------------------------------------------------------------- /src/core2/code_5FD80.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | 6 | UNK_TYPE(s32) func_802E6D10(UNK_TYPE(s32 *) arg0){ 7 | return *arg0; 8 | } 9 | -------------------------------------------------------------------------------- /src/core2/code_62FD0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | s32 meshList_getVtxCount(BKMeshList *meshList){ 6 | s32 i; 7 | s32 v1 = 0; 8 | BKMesh *v0 = (BKMesh *)(meshList + 1); 9 | 10 | for(i = 0; i < meshList->meshCount_0; ++i){ 11 | v1 += v0->vtxCount_2; 12 | v0 = (BKMesh *)&((s16*)(v0 +1))[v0->vtxCount_2]; 13 | 14 | } 15 | return v1; 16 | } 17 | 18 | BKMesh * meshList_getMesh(BKMeshList *meshList, s32 mesh_id){ 19 | s32 i; 20 | BKMesh *v1 = (BKMesh *)(meshList + 1); 21 | 22 | for(i=0; i < meshList->meshCount_0; i++){ 23 | if(v1->uid_0 == mesh_id){ 24 | return v1; 25 | } 26 | v1 = (BKMesh *)&((s16*)(v1 +1 ))[v1->vtxCount_2]; 27 | } 28 | return NULL; 29 | } 30 | 31 | bool meshList_meshContainsVtx(BKMeshList * meshList, s32 mesh_id, void *vtx_id){ 32 | s32 i; 33 | BKMesh *v0 = meshList_getMesh(meshList, mesh_id); 34 | 35 | if(v0){ 36 | for(i = 0; i < v0->vtxCount_2; i++){ 37 | if(((s16*)(v0 + 1))[i] == *(s16 *)vtx_id){ 38 | return TRUE; 39 | } 40 | } 41 | } 42 | return FALSE; 43 | } 44 | -------------------------------------------------------------------------------- /src/core2/code_66490.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | 6 | bool func_802ED420(BKModelUnk20List *arg0, u8 *arg1, u32 arg2) { 7 | BKModelUnk20_0 *start_ptr; 8 | 9 | start_ptr = (BKModelUnk20_0 *)(arg0 + 1); 10 | while(arg2 != 0){ 11 | if (start_ptr[*arg1].unkC != 0) { 12 | return TRUE; 13 | } 14 | arg2--; 15 | arg1++; 16 | } 17 | return FALSE; 18 | } 19 | 20 | void func_802ED52C(BKModelUnk20List *arg0, f32 arg1[3], f32 arg2) { 21 | BKModelUnk20_0 *start_ptr; 22 | BKModelUnk20_0 *end_ptr; 23 | BKModelUnk20_0 *i_ptr; 24 | s32 i; 25 | s16 sp18[3]; 26 | 27 | start_ptr = ( BKModelUnk20_0 *)(arg0 + 1); 28 | sp18[0] = (s16) (arg1[0] * (1.0 / arg2)); 29 | sp18[1] = (s16) (arg1[1] * (1.0 / arg2)); 30 | sp18[2] = (s16) (arg1[2] * (1.0 / arg2)); 31 | end_ptr = start_ptr + arg0->unk0; 32 | for(i_ptr = start_ptr; i_ptr < end_ptr; i_ptr++){ 33 | for(i = 0; i < 3; i++){ 34 | if ((sp18[i] < i_ptr->unk0[i]) || (i_ptr->unk6[i] < sp18[i])) { 35 | break; 36 | } 37 | } 38 | i_ptr->unkC = (i == 3); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/core2/code_6AEF0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | 6 | 7 | /* .bss */ 8 | u8 D_80380A00; 9 | 10 | 11 | /* .code */ 12 | void func_802F1E80(void){ 13 | func_802F1190(D_80380A00); 14 | } 15 | 16 | void func_802F1EA4(void){ 17 | D_80380A00 = func_802F0F78(0x10); 18 | } 19 | 20 | ParticleEmitter *func_802F1EC8(f32 *position) { 21 | static s32 D_80368AA0[3] = {0xC8, 0xC8, 0xE6}; 22 | 23 | ParticleEmitter *p_emitter; 24 | 25 | p_emitter = func_802F0EF0(D_80380A00); 26 | particleEmitter_setPosition(p_emitter, position); 27 | particleEmitter_setSprite(p_emitter, ASSET_700_SPRITE_DUST); 28 | particleEmitter_setParticleVelocityRange(p_emitter, -10.0f, 10.0f, -10.0f, 10.0f, 240.0f, 10.0f); 29 | particleEmitter_setRGB(p_emitter, D_80368AA0); 30 | particleEmitter_setFade(p_emitter, 0.2f, 0.3f); 31 | particleEmitter_setStartingScaleRange(p_emitter, 0.2f, 0.4f); 32 | particleEmitter_setFinalScaleRange(p_emitter, 0.85f, 0.9f); 33 | particleEmitter_setParticleLifeTimeRange(p_emitter, 0.3f, 0.35f); 34 | return p_emitter; 35 | } 36 | -------------------------------------------------------------------------------- /src/core2/code_6CEC0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | extern ParticleEmitter *func_802F0EF0(u8); 6 | 7 | /* .bss */ 8 | u8 D_80380A80; 9 | 10 | /* .code */ 11 | void func_802F3E50(void){ 12 | func_802F1190(D_80380A80); 13 | } 14 | 15 | void func_802F3E74(void){ 16 | D_80380A80 = func_802F0F78(0xF); 17 | } 18 | 19 | ParticleEmitter *func_802F3E98(f32 pos[3], enum asset_e sprite_id){ 20 | ParticleEmitter *this; 21 | this = func_802F0EF0(D_80380A80); 22 | 23 | particleEmitter_setSprite(this, sprite_id); 24 | particleEmitter_setAccelerationRange(this, 25 | 0.0f, -250.0f, 0.0f, 26 | 0.0f, -250.0f, 0.0f 27 | ); 28 | particleEmitter_setFade(this, 0.4f, 0.8f); 29 | particleEmitter_setPosition(this, pos); 30 | particleEmitter_setStartingScaleRange(this, 0.22f, 0.22f); 31 | particleEmitter_setFinalScaleRange(this, 0.03f, 0.03f); 32 | particleEmitter_setAngularVelocityRange(this, 33 | 0.0f, 0.0f, 200.0f, 34 | 0.0f, 0.0f, 240.0f 35 | ); 36 | particleEmitter_setParticleLifeTimeRange(this, 0.7f, 0.7f); 37 | func_802EFF50(this, 1.0f); 38 | return this; 39 | } 40 | -------------------------------------------------------------------------------- /src/core2/code_77E50.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "core1/core1.h" 3 | #include "functions.h" 4 | #include "variables.h" 5 | 6 | void func_802FEDE0(BKTextureList *texture_list, s32 indx, s32 x_offset, s32 y_offset){ 7 | u16 *sp24; 8 | u16 *frame_buffer_ptr; 9 | s32 y; 10 | s32 x; 11 | 12 | sp24 = (u16*)func_802EA620(texture_list) + indx*32*32; 13 | frame_buffer_ptr = gFramebuffers[getActiveFramebuffer()]; 14 | for(y = 0; y < 32; y++){//L802FEE60 15 | for(x = 0; x < 32; x++){//L802FEE68 16 | sp24[32*(31 - y) + x] = frame_buffer_ptr[(y_offset + y)*gFramebufferWidth + (x_offset + x)] | 1; //framebuffer to texture??? 17 | }; 18 | }; 19 | } 20 | 21 | //framebuffer_to_model_texture 22 | void func_802FEF48(BKModelBin *model_bin){ 23 | BKTextureList *texture_list; 24 | s32 x, y; 25 | 26 | texture_list = model_getTextureList(model_bin); 27 | osInvalDCache((void *)gFramebuffers[getActiveFramebuffer()], gFramebufferWidth * gFramebufferHeight*2); 28 | 29 | for(y = 0; y < 8; y++){//L802FEFEC 30 | for(x = 0; x < 10; x++){ 31 | //get textures from framebuffer??? 32 | func_802FEDE0(texture_list, 10*y + x, 32*x + (gFramebufferWidth - 10*32)/2, (s32)32*y + (gFramebufferHeight - 8*32)/2); 33 | } 34 | }; 35 | 36 | osWriteBackDCacheAll(); 37 | } 38 | -------------------------------------------------------------------------------- /src/core2/code_857B0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | /* .bss */ 6 | s32 D_80382460; 7 | 8 | /* .code */ 9 | void func_8030C740(void){ 10 | f32 sp1C[3]; 11 | D_80382460 = 1; 12 | if(nodeprop_findPositionFromActorId(0x16, sp1C)){ 13 | D_80382460 = 0; 14 | } 15 | } 16 | 17 | s32 func_8030C77C(void){ 18 | return D_80382460; 19 | } 20 | -------------------------------------------------------------------------------- /src/core2/code_9D760.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void func_803246F0(u8* self, s32 indx){ 6 | self[indx - 1] = 0xff; 7 | } 8 | 9 | void func_80324700(u8* self){ 10 | u8* i_ptr; 11 | 12 | for(i_ptr = self; i_ptr < self + 0x10; i_ptr++){ 13 | if(*i_ptr != 0xFF){ 14 | func_8033A45C((i_ptr - self) + 1, *i_ptr); 15 | } 16 | } 17 | } 18 | 19 | void func_80324770(u8* self, s32 indx, s32 value){ 20 | self[indx - 1] = value; 21 | } 22 | 23 | void func_8032477C(u8 *self){ 24 | free(self); 25 | } 26 | 27 | u8 *func_8032479C(void){ 28 | u8 *self; 29 | s32 i; 30 | 31 | self = (u8*)malloc(0x10); 32 | for(i = 0; i < 0x10; i++){ 33 | self[i] = 0xff; 34 | } 35 | return self; 36 | } 37 | -------------------------------------------------------------------------------- /src/core2/code_A600.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void func_802915B8(void); 6 | void func_802915E4(void); 7 | 8 | /* .bss */ 9 | f32 D_8037C090; 10 | f32 D_8037C094; 11 | s32 D_8037C098; 12 | 13 | /* .code */ 14 | void func_80291590(void){ 15 | func_802915B8(); 16 | func_802915E4(); 17 | } 18 | 19 | void func_802915B8(void){ 20 | D_8037C090 = 30.0f; 21 | } 22 | 23 | void func_802915CC(f32 arg0){ 24 | D_8037C090 = arg0; 25 | } 26 | 27 | f32 func_802915D8(void){ 28 | return D_8037C090; 29 | } 30 | 31 | void func_802915E4(void){ 32 | D_8037C094 = 100.0f; 33 | } 34 | 35 | void func_802915F8(f32 arg0){ 36 | D_8037C094 = arg0; 37 | } 38 | 39 | f32 func_80291604(void){ 40 | return D_8037C094; 41 | } 42 | 43 | void func_80291610(ActorMarker *this_marker, ActorMarker *other_marker){ 44 | func_8028F55C(1, other_marker); 45 | } 46 | 47 | void func_80291634(ActorMarker *this_marker, ActorMarker *other_marker){ 48 | func_8028F428(2, other_marker); 49 | } 50 | 51 | void func_80291658(s32 arg0){ return; } 52 | 53 | s32 func_80291660(void){ 54 | return D_8037C098; 55 | } 56 | -------------------------------------------------------------------------------- /src/core2/code_A960.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | #include "core2/ba/physics.h" 5 | #include "core2/ba/timer.h" 6 | 7 | void codeA960_forceLoadzone(s32); 8 | 9 | int isLoadzoneFlagSet(void){ 10 | return baflag_isTrue(BA_FLAG_15_LOADZONE); 11 | } 12 | 13 | void func_80291910(void){ 14 | codeA960_forceLoadzone(0); 15 | } 16 | 17 | void codeA960_forceLoadzone(s32 arg0){ 18 | if(!isLoadzoneFlagSet()){ 19 | baflag_set(BA_FLAG_15_LOADZONE); 20 | if(arg0){ 21 | batimer_set(5, 2.0f); 22 | func_8029C984(); 23 | bs_setState(BS_5A_LOADZONE); 24 | baModel_setVisible(FALSE); 25 | baphysics_set_type(BA_PHYSICS_FREEZE); 26 | func_8029151C(6); 27 | } 28 | } 29 | } 30 | 31 | void func_802919A0(void){ 32 | if(isLoadzoneFlagSet() && batimer_decrement(5)){ 33 | func_8029B890(); 34 | codeA960_forceLoadzone(0); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/core2/code_B6640.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | 6 | void points_to_boundingBoxWithMargin(f32 p1[3], f32 p2[3], f32 margin, f32 min[3], f32 max[3]) { 7 | s32 i; 8 | 9 | i = 0; 10 | for(i = 0; i < 3; i++){ 11 | if (p1[i] < p2[i]) { 12 | min[i] = p1[i]; 13 | max[i] = p2[i]; 14 | } else { 15 | min[i] = p2[i]; 16 | max[i] = p1[i]; 17 | } 18 | min[i] -= margin; 19 | max[i] += margin; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/core2/code_B6C60.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | 6 | /* .bss */ 7 | s32 D_80384470; 8 | 9 | /* .code */ 10 | f32 func_8033DBF0(void){ 11 | return (f32)D_80384470; 12 | } 13 | 14 | void func_8033DC04(void){ 15 | D_80384470 = 0; 16 | } 17 | 18 | void func_8033DC10(void){} 19 | 20 | void func_8033DC18(void){} 21 | 22 | f32 func_8033DC20(void){ 23 | f32 out; 24 | D_80384470 = viMgr_func_8024BD94(); 25 | out = 0.016666666666666666*D_80384470; 26 | return out; 27 | } 28 | -------------------------------------------------------------------------------- /src/core2/code_B7F40.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void dummy_func_8033EF08(void); 6 | void dummy_func_8033EF10(void); 7 | 8 | /* .data */ 9 | void *gUnusedBlock = NULL; 10 | 11 | /* .code */ 12 | void dummy_func_8033EED0(void){ 13 | dummy_func_8033EF10(); 14 | dummy_func_8033EF08(); 15 | } 16 | 17 | void dummy_func_8033EEF8(void){} 18 | 19 | void dummy_func_8033EF00(void){} 20 | 21 | void dummy_func_8033EF08(void){} 22 | 23 | void dummy_func_8033EF10(void){} 24 | 25 | void dummy_func_8033EF18(s32 arg0, s32 arg1){ 26 | return; 27 | } 28 | 29 | void unallocUnusedBlock(void){ 30 | if(gUnusedBlock){ 31 | free(gUnusedBlock); 32 | } 33 | gUnusedBlock = NULL; 34 | } 35 | 36 | void allocUnusedBlock(void){ 37 | gUnusedBlock = malloc(80); 38 | } 39 | 40 | void dummy_func_8033EF7C(s32 arg0){ 41 | return; 42 | } 43 | 44 | void dummy_func_8033EF84(void){} 45 | 46 | void dummy_func_8033EF8C(void){} 47 | 48 | void dummy_func_8033EF94(s32 arg0){ 49 | return; 50 | } 51 | 52 | void dummy_func_8033EF9C(s32 arg0){ 53 | return; 54 | } 55 | -------------------------------------------------------------------------------- /src/core2/code_B8020.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | 6 | 7 | /* .bss */ 8 | BKSpriteTextureBlock *D_80384FF0; 9 | 10 | /* .code */ 11 | BKSpriteTextureBlock *func_8033EFB0(Struct84s *arg0, s32 arg1){ 12 | s32 *offset_ptr = &arg0->offset[arg1]; 13 | s32 mem_ptr; 14 | if(arg0->offset[arg1] == -1){ 15 | return D_80384FF0; 16 | } 17 | 18 | mem_ptr = *offset_ptr + (s32) &arg0[0].offset[arg0->count]; 19 | return (BKSpriteTextureBlock *)(mem_ptr); 20 | } 21 | -------------------------------------------------------------------------------- /src/core2/code_B8070.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void func_8033F000(const char *string, const char *file){} 6 | -------------------------------------------------------------------------------- /src/core2/code_C0B80.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | extern void func_80329904(ActorMarker *, s32, f32 *); 6 | 7 | void func_80347B10(Struct81s *arg0){ 8 | Actor *actor; 9 | actor = bundle_spawn_f32(BUNDLE_10__JIGGY, arg0->position); 10 | actor->unk54 = 3.0f; 11 | func_803333DC(arg0, actor); 12 | } 13 | 14 | void func_80347B54(Struct81s *arg0){ 15 | __spawnQueue_add_1((GenFunction_1)func_80347B10, reinterpret_cast(s32, arg0)); 16 | } 17 | 18 | void func_80347B80(Struct81s *arg0) { 19 | Actor *sp1C; 20 | Actor *temp_v0; 21 | 22 | sp1C = marker_getActor(arg0->marker); 23 | if (sp1C->unk54 > 0.0) { 24 | if (randf() < ((sp1C->unk54 / 3.0) * 2)) { 25 | func_8033E73C(arg0->marker, 5, func_80329904); 26 | func_8033E3F0(0xF, ((ActorMarker *)arg0->marker)->unk14_21); 27 | // func_8033E3F0(0xF, arg0->marker->unk14_21); 28 | } 29 | sp1C->unk54 -= time_getDelta(); 30 | } 31 | } 32 | 33 | void func_80347C5C(Struct81s *arg0, Gfx **arg1, Mtx **arg2, Vtx **arg3){} 34 | 35 | void func_80347C70(Struct81s *arg0){} 36 | -------------------------------------------------------------------------------- /src/core2/code_C0CF0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | extern void func_80329904(ActorMarker *, s32, f32 *); 6 | 7 | 8 | /* .code */ 9 | void func_80347C80(Struct81s *arg0){ 10 | Actor *actor; 11 | actor = actor_spawnWithYaw_f32(ACTOR_46_JIGGY, arg0->position, 0); 12 | actor->unk54 = 3.0f; 13 | func_803333DC(arg0, actor); 14 | } 15 | 16 | void func_80347CC8(Struct81s *arg0){ 17 | __spawnQueue_add_1((GenFunction_1)func_80347C80, reinterpret_cast(s32, arg0)); 18 | } 19 | 20 | void func_80347CF4(Struct81s *arg0) { 21 | Actor *sp1C; 22 | Actor *temp_v0; 23 | 24 | sp1C = marker_getActor(arg0->marker); 25 | if (sp1C->unk54 > 0.0) { 26 | if (randf() < ((sp1C->unk54 / 3.0) * 2)) { 27 | func_8033E73C(arg0->marker, 5, func_80329904); 28 | func_8033E3F0(0xF, ((ActorMarker *)arg0->marker)->unk14_21); 29 | } 30 | sp1C->unk54 -= time_getDelta(); 31 | } 32 | } 33 | 34 | void func_80347DD0(Struct81s * arg0, Gfx **gfx, Mtx** mtx, Vtx **vtx) 35 | {} 36 | 37 | void func_80347DE4(Struct81s * arg0) 38 | {} 39 | -------------------------------------------------------------------------------- /src/core2/code_C3A40.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | /* .code */ 6 | /* 7 | 1.0| ,----. 8 | | / \ 9 | | / \ 10 | 0.0|______/ \_____ arg1 11 | | | | | 12 | [2] [3] [0] [1] 13 | */ 14 | f32 func_8034A9D0(f32 arg0[4], f32 arg1) { 15 | if (arg0[1] <= arg1) { 16 | return 0.0f; 17 | } 18 | if (arg0[0] <= arg1) { 19 | return (arg0[1] - arg1) / (arg0[1] - arg0[0]); 20 | } 21 | if (arg0[3] <= arg1) { 22 | return 1.0f; 23 | } 24 | if (arg0[2] <= arg1) { 25 | return (arg1 - arg0[2]) / (arg0[3] - arg0[2]); 26 | } 27 | return 0.0f; 28 | } 29 | 30 | 31 | void func_8034AA70(f32 arg0[4]){ 32 | arg0[1] = 10000.0f; 33 | arg0[0] = 4000.0f; 34 | arg0[3] = 2000.0f; 35 | arg0[2] = -500.0f; 36 | } 37 | -------------------------------------------------------------------------------- /src/core2/code_C5AF0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | /* .code */ 6 | void func_8034CA80(s32 arg0, BKVtxRef *arg1, Vtx *arg2, Struct6Fs *arg3){ 7 | s32 i; 8 | for(i = 0; i < 3; i++){ 9 | arg2->v.cn[i] = arg1->v.v.cn[i]*arg3->unk0; 10 | } 11 | } 12 | 13 | void func_8034CB5C(Struct6Fs *arg0){} 14 | 15 | void func_8034CB64(Struct6Fs *arg0, s32 arg1, BKModel *model, s32 arg3){ 16 | arg0->unk0 = 0.5f; 17 | arg0->unk4 = (arg1 +1)*0.01; 18 | } 19 | 20 | void func_8034CB9C(Struct6Fs *arg0, BKModel *model, s32 mesh_id) { 21 | arg0->unk0 += arg0->unk4 * time_getDelta(); 22 | if (arg0->unk0 >= 1.0f) { 23 | arg0->unk0 = 1.0f; 24 | arg0->unk4 = -arg0->unk4; 25 | } else if (arg0->unk0 < 0.3) { 26 | arg0->unk0 = 0.3f; 27 | arg0->unk4 = -arg0->unk4; 28 | } 29 | BKModel_transformMesh(model, mesh_id, func_8034CA80, (s32) arg0); 30 | } 31 | -------------------------------------------------------------------------------- /src/core2/code_C5F00.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void func_8034CE90(s32 arg0, BKVtxRef *arg1, Vtx *arg2, Struct72s *arg3){ 6 | s32 i; 7 | 8 | for(i = 0; i < 3; i++){ 9 | arg2->v.cn[i] = arg1->v.v.cn[i] * arg3->unk0; 10 | } 11 | } 12 | 13 | void func_8034CF6C(Struct72s *arg0){} 14 | 15 | void func_8034CF74(Struct72s *arg0, s32 arg1, BKModel *arg2, s32 arg3){ 16 | arg0->unk0 = 1.0f; 17 | } 18 | 19 | void func_8034CF90(Struct72s *arg0, BKModel *arg1, s32 arg2) { 20 | arg0->unk0 += randf2(-0.04f, 0.04f); 21 | arg0->unk0 = (arg0->unk0 > 1.0f) ? 1.0f : arg0->unk0; 22 | arg0->unk0 = (arg0->unk0 < 0.8) ? 0.8 : arg0->unk0; 23 | BKModel_transformMesh(arg1, arg2, func_8034CE90, (s32) arg0); 24 | } 25 | 26 | void func_8034D048(Struct72s *arg0, BKModel *arg1, s32 arg2) { 27 | arg0->unk0 -= 0.04; 28 | arg0->unk0 += (osGetCount() & 0x1F) / 387.5; 29 | arg0->unk0 = (arg0->unk0 > 1.0f) ? 1.0f : arg0->unk0; 30 | arg0->unk0 = (arg0->unk0 < 0.8) ? 0.8 : arg0->unk0; 31 | BKModel_transformMesh(arg1, arg2, func_8034CE90, (s32) arg0); 32 | } 33 | -------------------------------------------------------------------------------- /src/core2/code_C61C0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | typedef struct { 6 | f32 unk0; 7 | s16 unk4; 8 | u8 pad6[2]; 9 | f32 unk8; 10 | f32 unkC; 11 | }Struct_core2_C61C0_0; 12 | 13 | void func_8034D150(s32 mesh_id, BKVtxRef *src, Vtx *dst, Struct_core2_C61C0_0 *arg3){ 14 | dst->v.tc[1] = src->v.v.tc[1] + arg3->unk4; 15 | } 16 | 17 | void func_8034D168(Struct_core2_C61C0_0 * arg0){} 18 | 19 | void func_8034D170(Struct_core2_C61C0_0 *arg0, s32 arg1, BKModel *model, s32 arg3){ 20 | arg0->unk0 = 0.0f; 21 | arg0->unk8 = (f32)arg1; 22 | arg0->unkC = 0.0f; 23 | } 24 | 25 | void func_8034D194(Struct_core2_C61C0_0 *arg0, BKModel *model, s32 mesh_id) { 26 | arg0->unk0 += arg0->unk8 * 64.0f * time_getDelta(); 27 | if ((s32)arg0->unk0 >= 0x4001) { 28 | arg0->unk0 -= 16384.0f; 29 | } 30 | arg0->unk4 = (s16)arg0->unk0; 31 | BKModel_transformMesh(model, mesh_id, func_8034D150, (s32) arg0); 32 | } 33 | -------------------------------------------------------------------------------- /src/core2/code_C8230.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | 6 | void func_8034F1C0(s32 arg0, BKVtxRef *ref, Vtx *dst, Struct75s *arg3) { 7 | s32 temp_f4; 8 | s32 i; 9 | 10 | for(i = 0; i < 3; i++){ 11 | temp_f4 = (s32) (ref->v.v.cn[i] + arg3->unk0 * 50.0f); 12 | dst->v.cn[i] = (temp_f4 < 0xFF) ? temp_f4 : 0xFF; 13 | } 14 | } 15 | 16 | void func_8034F248(Struct75s arg0){} 17 | 18 | func_8034F250(Struct75s *arg0, UNK_TYPE(s32) arg1, UNK_TYPE(s32) arg2, UNK_TYPE(s32) arg3){ 19 | arg0->unk0 = 0.0f; 20 | } 21 | 22 | void func_8034F268(Struct75s *arg0, BKModel *arg1, s32 arg2) { 23 | void *temp_v0; 24 | 25 | temp_v0 = func_8034C448(arg2 - 0x64); 26 | if (temp_v0 != NULL) { 27 | arg0->unk0 = func_8034F560(temp_v0) / 255.0; 28 | } else { 29 | arg0->unk0 = 0.0f; 30 | } 31 | BKModel_transformMesh(arg1, arg2, func_8034F1C0, (s32) arg0); 32 | } 33 | -------------------------------------------------------------------------------- /src/core2/code_C8360.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | typedef struct struct_core2_C8360_0{ 6 | f32 unk0; 7 | }struct_core2_C8360_0; 8 | 9 | /* .code */ 10 | void func_8034F2F0(s32 arg0, BKVtxRef *ref, Vtx *dst, struct_core2_C8360_0 *arg3) { 11 | s32 temp_f4; 12 | s32 i; 13 | 14 | for(i = 0; i < 3; i++){ 15 | temp_f4 = ref->v.v.cn[i] + (arg3->unk0 * 50.0f); 16 | dst->v.cn[i] = (temp_f4 < 0xFF) ? temp_f4 : 0xFF; 17 | } 18 | } 19 | 20 | void func_8034F378(struct_core2_C8360_0 *arg0){} 21 | 22 | void func_8034F380(struct_core2_C8360_0 *arg0, s32 arg1, s32 arg2, s32 arg3){ 23 | arg0->unk0 = 0.0f; 24 | } 25 | 26 | void func_8034F398(f32 *arg0, BKModel *arg1, s32 arg2) { 27 | void *temp_v0; 28 | 29 | temp_v0 = func_8034C344(arg2 - 0x64); 30 | if (temp_v0 != 0) { 31 | *arg0 = func_8034F560(temp_v0) / 255.0; 32 | } else { 33 | *arg0 = 0.0f; 34 | } 35 | BKModel_transformMesh(arg1, arg2, func_8034F2F0, (s32) arg0); 36 | } 37 | -------------------------------------------------------------------------------- /src/core2/code_C9E70.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | #include "code_C9E70.h" 6 | 7 | extern struct FF_StorageStruct *D_8037DCB8; 8 | 9 | void func_80350E00(void){ 10 | quizQuestionAskedBitfield_defrag(); 11 | gcquiz_defrag(); 12 | if(D_8037DCB8 == NULL) 13 | return; 14 | 15 | if(D_8037DCB8->unk20){ 16 | gczoombox_defrag(D_8037DCB8->unk20); 17 | D_8037DCB8->unk20 = (GcZoombox *)defrag(D_8037DCB8->unk20); 18 | } 19 | D_8037DCB8->unk48 = (struct FF_StorageStruct_48 *)defrag(D_8037DCB8->unk48); 20 | D_8037DCB8 = (struct FF_StorageStruct *) defrag(D_8037DCB8); 21 | } 22 | -------------------------------------------------------------------------------- /src/core2/code_DC4B0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void func_80363500(Actor *this); 6 | 7 | /* .data */ 8 | ActorInfo D_80373DC0= { 9 | 0x1EE, ACTOR_3BA_UNKNOWN, 0, 10 | 0, NULL, 11 | func_80363500, actor_update_func_80326224, func_80325340, 12 | 0, 0, 0.0f, 0 13 | }; 14 | 15 | /* .code */ 16 | void func_80363440(void){ 17 | func_8034DEB4(func_8034C528(0x1F1), -5000.0f); 18 | } 19 | 20 | void func_80363470(void){ 21 | func_8034DEB4(func_8034C528(0x1F2), -5000.0f); 22 | func_8034DEB4(func_8034C528(0x1F3), 0.0f); 23 | func_80363440(); 24 | } 25 | 26 | void func_803634BC(void){ 27 | func_8034DEB4(func_8034C528(0x1F3), -5000.0f); 28 | func_8034DEB4(func_8034C528(0x1F2), 0.0f); 29 | } 30 | 31 | void func_80363500(Actor *this){ 32 | if(!this->volatile_initialized){ 33 | if(!chmole_learnedAllSpiralMountainAbilities()){ 34 | func_803634BC(); 35 | } 36 | else{ 37 | func_80363440(); 38 | marker_despawn(this->marker); 39 | } 40 | this->volatile_initialized = TRUE; 41 | }//L8036355C 42 | 43 | if(chmole_learnedAllSpiralMountainAbilities()){ 44 | func_80363470(); 45 | marker_despawn(this->marker); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/core2/code_EE40.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | #include "core2/ba/physics.h" 5 | 6 | /* .bss */ 7 | struct{ 8 | f32 unk0[3]; 9 | f32 unkC[3]; 10 | u8 unk18; 11 | u8 pad19[3]; 12 | } D_8037C3C0; 13 | 14 | /* .code */ 15 | void func_80295DD0(void){ 16 | s32 sp24[3]; 17 | s32 sp18[3]; 18 | 19 | mapModel_getBounds(sp18, sp24); 20 | ml_vec3w_to_vec3f(D_8037C3C0.unkC, sp18); 21 | ml_vec3w_to_vec3f(D_8037C3C0.unk0, sp24); 22 | D_8037C3C0.unkC[0] -= 400.0f; 23 | D_8037C3C0.unkC[1] = -8000.0f; 24 | D_8037C3C0.unkC[2] -= 400.0f; 25 | D_8037C3C0.unk0[0] += 400.0f; 26 | D_8037C3C0.unk0[1] += 1000.0f; 27 | D_8037C3C0.unk0[2] += 400.0f; 28 | D_8037C3C0.unk18 = 0; 29 | 30 | 31 | } 32 | 33 | void func_80295E74(void){ 34 | f32 sp1C[3]; 35 | _player_getPosition(sp1C); 36 | if(!ml_vec3f_inside_box_vec3f(sp1C, D_8037C3C0.unkC, D_8037C3C0.unk0)){ 37 | if(D_8037C3C0.unk18 == 0){ 38 | D_8037C3C0.unk18 = 1; 39 | func_8029B6F0(); 40 | } 41 | else{ 42 | baphysics_set_type(BA_PHYSICS_FREEZE); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/core2/fx/common1score.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | /* .bss */ 6 | struct7s D_803815A0; 7 | 8 | /* .code */ 9 | struct7s *fxcommon1score_new(enum asset_e item_id){ 10 | return &D_803815A0; 11 | } 12 | 13 | void fxcommon1score_update(enum item_e item_id, struct8s *arg1){} 14 | 15 | void fxcommon1score_draw(enum item_e item_id, struct8s *arg1, Gfx **arg2, Mtx **arg3, Vtx **arg4){} 16 | 17 | void fxcommon1score_free(enum item_e item_id, struct8s *arg1){} 18 | -------------------------------------------------------------------------------- /src/core2/nc/dynamicCamD.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | /* .data */ 6 | f32 D_80365D90 = 30.0f; 7 | 8 | /* .code */ 9 | void ncDynamicCamD_init(void){ 10 | func_802BE244(4.0f, 16.0f); 11 | func_802BE230(1.4f, 14.0f); 12 | } 13 | 14 | void ncDynamicCamD_end(void){} 15 | 16 | void ncDynamicCamD_func_802BF2C0(f32 arg0){ 17 | D_80365D90 = arg0; 18 | } 19 | 20 | void ncDynamicCamD_update(void) { 21 | f32 sp54[3]; 22 | f32 sp48[3]; 23 | f32 sp3C[3]; 24 | f32 sp30[3]; 25 | f32 sp2C; 26 | 27 | player_getPosition(sp3C); 28 | sp3C[1] += 120.0f; 29 | ncDynamicCamera_getPosition(sp54); 30 | func_80257F18(sp3C, sp54, &sp2C); 31 | func_80256E24(sp30, 0.0f, sp2C, 0.0f, 0.0f, 200.0f); 32 | sp3C[0] += sp30[0]; 33 | sp3C[1] += sp30[1]; 34 | sp3C[2] += sp30[2]; 35 | func_802BE190(sp3C); 36 | ncDynamicCamera_getPosition(sp54); 37 | player_getPosition(sp3C); 38 | sp3C[1] += D_80365D90; 39 | func_8025727C(sp3C[0], sp3C[1], sp3C[2], sp54[0], sp54[1], sp54[2], &sp48[0], &sp48[1]); 40 | sp48[0] = mlNormalizeAngle(-sp48[0]); 41 | func_802BD904(sp48); 42 | } 43 | -------------------------------------------------------------------------------- /src/core2/nc/dynamicCamF.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "core1/core1.h" 3 | #include "functions.h" 4 | 5 | static f32 __playerStartPosition[3]; 6 | 7 | void ncDynamicCamF_init(void){ 8 | f32 sp24[3]; 9 | f32 sp12[3]; 10 | 11 | viewport_getPosition_vec3f(sp24); 12 | viewport_getRotation_vec3f(sp12); 13 | ncDynamicCamera_setPosition(sp24); 14 | ncDynamicCamera_setRotation(sp12); 15 | player_getPosition(__playerStartPosition); 16 | func_80291488(5); 17 | } 18 | 19 | void ncDynamicCamF_end(void){} 20 | 21 | void ncDynamicCamF_update(void){ 22 | f32 player_position[3]; 23 | f32 d_position[3]; 24 | 25 | player_getPosition(player_position); 26 | ml_vec3f_diff_copy(d_position, __playerStartPosition, player_position); 27 | if( !(gu_sqrtf(d_position[0]*d_position[0] + d_position[1]*d_position[1] + d_position[2]*d_position[2]) < 2.0f)){ 28 | func_80291488(2); 29 | ncDynamicCamera_setState(0xB); 30 | func_802BE720(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/core2/quizquestionaskedbitfield.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | #define FF_QUESTION_ASKED_BITFIELD_SIZE 0x33 6 | 7 | /* .bss */ 8 | u8* quizQuestionAskedBitfield; 9 | 10 | /* .code */ 11 | bool quizQuestionAskedBitfield_get(s32 index){ 12 | return bitfield_get_bit(quizQuestionAskedBitfield, index); 13 | } 14 | 15 | void quizQuestionAskedBitfield_free(void){ 16 | free(quizQuestionAskedBitfield); 17 | quizQuestionAskedBitfield = NULL; 18 | } 19 | 20 | void quizQuestionAskedBitfield_init(void){ 21 | int i; 22 | quizQuestionAskedBitfield =(u8*) malloc(FF_QUESTION_ASKED_BITFIELD_SIZE); 23 | for(i = 0; i < FF_QUESTION_ASKED_BITFIELD_SIZE; i++){ 24 | quizQuestionAskedBitfield[i] = 0; 25 | } 26 | } 27 | 28 | void quizQuestionAskedBitfield_set(s32 index, bool value){ 29 | bitfield_set_bit(quizQuestionAskedBitfield, index, value); 30 | } 31 | 32 | void quizQuestionAskedBitfield_defrag(void){ 33 | if(quizQuestionAskedBitfield != NULL) 34 | quizQuestionAskedBitfield = (u8*)defrag(quizQuestionAskedBitfield); 35 | } 36 | -------------------------------------------------------------------------------- /src/core2/snackerctl.h: -------------------------------------------------------------------------------- 1 | #ifndef __BANJO_KAZOOIE_CORE2_SNACKER_CTL_H__ 2 | #define __BANJO_KAZOOIE_CORE2_SNACKER_CTL_H__ 3 | 4 | typedef enum { 5 | SNACKER_CTL_STATE_0_INACTIVE, 6 | SNACKER_CTL_STATE_1_RBB, 7 | SNACKER_CTL_STATE_2_TTC 8 | } SnackerCtlState; 9 | 10 | void snackerctl_reset(void); 11 | void snackerctl_update(void); 12 | SnackerCtlState snackerctl_get_state(void); 13 | 14 | #endif // __BANJO_KAZOOIE_CORE2_SNACKER_CTL_H__ 15 | -------------------------------------------------------------------------------- /src/core2/time.c: -------------------------------------------------------------------------------- 1 | #include "time.h" 2 | 3 | #include "core1/vimgr.h" 4 | 5 | /*.data*/ 6 | static f32 s_timeMultiplier = 1.0f; 7 | 8 | /* .bss */ 9 | static f32 s_dTimeReal_sec; 10 | static s32 s_dTimeReal_frames; 11 | 12 | /* .code */ 13 | void time_reset(void){ 14 | s_dTimeReal_sec = 0.01f; 15 | s_timeMultiplier = 1.0f; 16 | s_dTimeReal_frames = 0; 17 | } 18 | 19 | void time_setDeltaReal_sec(f32 d_seconds){ 20 | if(d_seconds != 0.0f){ 21 | s_dTimeReal_sec = MIN(d_seconds, 0.05); 22 | } 23 | else{ 24 | s_dTimeReal_sec = 0.01f; 25 | } 26 | } 27 | 28 | void time_setDeltaReal_frames(s32 d_frames){ 29 | s_dTimeReal_frames = MAX(MIN(0xf, d_frames) , 1); 30 | time_setDeltaReal_sec(s_dTimeReal_frames*(1/60.0)); 31 | } 32 | 33 | s32 time_getDeltaReal_frames(void){ 34 | return s_dTimeReal_frames; 35 | } 36 | 37 | f32 time_getDelta(void){ 38 | return s_dTimeReal_sec*s_timeMultiplier; 39 | } 40 | 41 | f32 time_func_8033DDB8(void){ 42 | return viMgr_func_8024BD94()*(1/60.0); 43 | } 44 | 45 | f32 time_getDelta_frames(void){ 46 | return time_getDelta()*30.0; 47 | } 48 | 49 | void time_setMultiplier(f32 multiplier){ 50 | s_timeMultiplier = multiplier; 51 | } 52 | -------------------------------------------------------------------------------- /src/cutscenes/bss_pad.c: -------------------------------------------------------------------------------- 1 | char pad_cutscenes_8038E9E0[0x10]; 2 | -------------------------------------------------------------------------------- /src/done/bk_boot_1050.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "rarezip.h" 3 | 4 | #define ENTRY_STACK_LEN 0x2000 5 | #define ENTRY_STACK_LEN_U64 (ENTRY_STACK_LEN / sizeof(u64)) 6 | 7 | u64 gEntryStack[ENTRY_STACK_LEN_U64]; 8 | 9 | extern u8 core1_rzip_ROM_START[]; 10 | extern u8 core1_rzip_ROM_END[]; 11 | extern u8 D_8002D500; 12 | extern u8 core1_VRAM; 13 | extern u32 D_803FFE00[4]; 14 | 15 | void func_80000594(u8 **, u8 **); 16 | void func_8023DA20(s32); 17 | 18 | void func_80000450(s32 arg0){ 19 | u8 *tmp; 20 | u8 *dst; 21 | 22 | tmp = &D_8002D500; 23 | dst = &core1_VRAM; 24 | osInitialize(); 25 | osPiRawStartDma(OS_READ, core1_rzip_ROM_START, tmp, core1_rzip_ROM_END - core1_rzip_ROM_START); 26 | while(osPiGetStatus() & PI_STATUS_DMA_BUSY); 27 | func_8000055C(); 28 | func_80000594(&tmp, &dst); 29 | D_803FFE00[0] = crc1; 30 | D_803FFE00[1] = crc2; 31 | func_80000594(&tmp, &dst); 32 | D_803FFE00[2] = crc1; 33 | D_803FFE00[3] = crc2; 34 | overlay_table_init(); 35 | (&func_8023DA20)(arg0); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/done/cartrominit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | OSPiHandle CartRomHandle; 6 | OSPiHandle *osCartRomInit(void) 7 | { 8 | u32 domain; 9 | u32 saveMask; 10 | 11 | domain = 0; 12 | 13 | if (CartRomHandle.baseAddress == PHYS_TO_K1(PI_DOM1_ADDR2)) 14 | return &CartRomHandle; 15 | 16 | CartRomHandle.type = DEVICE_TYPE_CART; 17 | CartRomHandle.baseAddress = PHYS_TO_K1(PI_DOM1_ADDR2); 18 | osPiRawReadIo(NULL, &domain); 19 | CartRomHandle.latency = domain & 0xff; 20 | CartRomHandle.pulse = (domain >> 8) & 0xff; 21 | CartRomHandle.pageSize = (domain >> 0x10) & 0xf; 22 | CartRomHandle.relDuration = (domain >> 0x14) & 0xf; 23 | CartRomHandle.domain = PI_DOMAIN1; 24 | CartRomHandle.speed = 0; 25 | 26 | bzero(&CartRomHandle.transferInfo, sizeof(__OSTranxInfo)); 27 | 28 | saveMask = __osDisableInt(); 29 | CartRomHandle.next = __osPiTable; 30 | __osPiTable = &CartRomHandle; 31 | __osRestoreInt(saveMask); 32 | 33 | return &CartRomHandle; 34 | } 35 | -------------------------------------------------------------------------------- /src/done/createmesgqueue.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | extern OSThread __osThreadTail; 6 | 7 | void osCreateMesgQueue(OSMesgQueue *mq, OSMesg *msg, s32 msgCount) 8 | { 9 | mq->mtqueue = (OSThread *)&__osThreadTail; 10 | mq->fullqueue = (OSThread *)&__osThreadTail; 11 | mq->validCount = 0; 12 | mq->first = 0; 13 | mq->msgCount = msgCount; 14 | mq->msg = msg; 15 | } 16 | -------------------------------------------------------------------------------- /src/done/createthread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | #define __osCleanupThread __osCleanupThread 6 | 7 | void __osCleanupThread(void); 8 | extern OSThread *__osActiveQueue; 9 | void osCreateThread(OSThread *t, OSId id, void (*entry)(void *), void *arg, void *sp, OSPri p) 10 | { 11 | register u32 saveMask; 12 | OSIntMask mask; 13 | t->id = id; 14 | t->priority = p; 15 | t->next = NULL; 16 | t->queue = NULL; 17 | t->context.pc = (u32)entry; 18 | t->context.a0 = (u64)arg; 19 | t->context.sp = (u64)sp - 16; 20 | t->context.ra = (u64)__osCleanupThread; 21 | mask = OS_IM_ALL; 22 | t->context.sr = SR_IMASK | SR_EXL | SR_IE; 23 | t->context.rcp = (mask & RCP_IMASK) >> RCP_IMASKSHIFT; 24 | t->context.fpcsr = (u32)(FPCSR_FS | FPCSR_EV); 25 | t->fp = 0; 26 | t->state = OS_STATE_STOPPED; 27 | t->flags = 0; 28 | saveMask = __osDisableInt(); 29 | t->tlnext = __osActiveQueue; 30 | __osActiveQueue = t; 31 | __osRestoreInt(saveMask); 32 | } 33 | -------------------------------------------------------------------------------- /src/done/destroythread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "osint.h" 3 | 4 | void osDestroyThread(OSThread *t) 5 | { 6 | register u32 saveMask; 7 | register OSThread *pred; 8 | register OSThread *succ; 9 | saveMask = __osDisableInt(); 10 | if (t == NULL) 11 | { 12 | t = __osRunningThread; 13 | } 14 | else 15 | { 16 | if (t->state != OS_STATE_STOPPED) 17 | { 18 | __osDequeueThread(t->queue, t); 19 | } 20 | } 21 | if (__osActiveQueue == t) 22 | { 23 | __osActiveQueue = __osActiveQueue->tlnext; 24 | } 25 | else 26 | { 27 | pred = __osActiveQueue; 28 | succ = pred->tlnext; 29 | while (succ) 30 | { 31 | if (succ == t) 32 | { 33 | pred->tlnext = t->tlnext; 34 | break; 35 | } 36 | pred = succ; 37 | succ = pred->tlnext; 38 | } 39 | } 40 | if (t == __osRunningThread) 41 | { 42 | __osDispatchThread(); 43 | } 44 | __osRestoreInt(saveMask); 45 | } 46 | -------------------------------------------------------------------------------- /src/done/epirawdma.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | #include "piint.h" 5 | 6 | extern OSPiHandle *__osCurrentHandle[2]; 7 | 8 | s32 osEPiRawStartDma(OSPiHandle *pihandle, s32 direction, u32 devAddr, void *dramAddr, u32 size) 9 | { 10 | u32 stat; 11 | u32 domain; 12 | 13 | EPI_SYNC(pihandle, stat, domain); 14 | 15 | IO_WRITE(PI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr)); 16 | IO_WRITE(PI_CART_ADDR_REG, K1_TO_PHYS(pihandle->baseAddress | devAddr)); 17 | switch (direction) 18 | { 19 | case OS_READ: 20 | IO_WRITE(PI_WR_LEN_REG, size - 1); 21 | break; 22 | case OS_WRITE: 23 | IO_WRITE(PI_RD_LEN_REG, size - 1); 24 | break; 25 | default: 26 | return -1; 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /src/done/epirawread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "piint.h" 4 | 5 | s32 osEPiRawReadIo(OSPiHandle *pihandle, u32 devAddr, u32 *data) 6 | { 7 | register u32 stat; 8 | register u32 domain; 9 | 10 | WAIT_ON_IOBUSY(stat); 11 | 12 | *data = IO_READ(pihandle->baseAddress | devAddr); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /src/done/epirawwrite.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "piint.h" 3 | 4 | s32 osEPiRawWriteIo(OSPiHandle *pihandle, u32 devAddr, u32 data) 5 | { 6 | register u32 stat; 7 | register u32 domain; 8 | 9 | WAIT_ON_IOBUSY(stat); 10 | 11 | IO_WRITE(pihandle->baseAddress | devAddr, data); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /src/done/getthreadpri.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | #include "osint.h" 5 | 6 | OSPri osGetThreadPri(OSThread *thread) 7 | { 8 | if (thread == NULL) 9 | thread = __osRunningThread; 10 | return thread->priority; 11 | } 12 | -------------------------------------------------------------------------------- /src/done/kdebugserver.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | OSThread __osThreadSave; 4 | -------------------------------------------------------------------------------- /src/done/leodiskinit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | OSPiHandle LeoDiskHandle; 6 | OSPiHandle *__osDiskHandle; 7 | OSPiHandle *osLeoDiskInit() 8 | { 9 | u32 saveMask; 10 | LeoDiskHandle.type = DEVICE_TYPE_64DD; 11 | LeoDiskHandle.baseAddress = PHYS_TO_K1(PI_DOM2_ADDR1); 12 | LeoDiskHandle.latency = 3; 13 | LeoDiskHandle.pulse = 6; 14 | LeoDiskHandle.pageSize = 6; 15 | LeoDiskHandle.relDuration = 2; 16 | LeoDiskHandle.domain = PI_DOMAIN2; 17 | IO_WRITE(PI_BSD_DOM2_LAT_REG, LeoDiskHandle.latency); 18 | IO_WRITE(PI_BSD_DOM2_PWD_REG, LeoDiskHandle.pulse); 19 | IO_WRITE(PI_BSD_DOM2_PGS_REG, LeoDiskHandle.pageSize); 20 | IO_WRITE(PI_BSD_DOM2_RLS_REG, LeoDiskHandle.relDuration); 21 | LeoDiskHandle.speed = 0; 22 | bzero(&LeoDiskHandle.transferInfo, sizeof(__OSTranxInfo)); 23 | saveMask = __osDisableInt(); 24 | LeoDiskHandle.next = __osPiTable; 25 | __osPiTable = &LeoDiskHandle; 26 | __osDiskHandle = &LeoDiskHandle; 27 | __osRestoreInt(saveMask); 28 | return &LeoDiskHandle; 29 | } 30 | -------------------------------------------------------------------------------- /src/done/piacs.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define PI_Q_BUF_LEN 1 4 | u32 __osPiAccessQueueEnabled = 0; 5 | static OSMesg piAccessBuf[PI_Q_BUF_LEN]; 6 | OSMesgQueue __osPiAccessQueue; 7 | void __osPiCreateAccessQueue(void) 8 | { 9 | 10 | __osPiAccessQueueEnabled = 1; 11 | osCreateMesgQueue(&__osPiAccessQueue, piAccessBuf, PI_Q_BUF_LEN); 12 | osSendMesg(&__osPiAccessQueue, NULL, OS_MESG_NOBLOCK); 13 | } 14 | void __osPiGetAccess(void) 15 | { 16 | OSMesg dummyMesg; 17 | if (!__osPiAccessQueueEnabled) 18 | __osPiCreateAccessQueue(); 19 | osRecvMesg(&__osPiAccessQueue, &dummyMesg, OS_MESG_BLOCK); 20 | } 21 | void __osPiRelAccess(void) 22 | { 23 | osSendMesg(&__osPiAccessQueue, NULL, OS_MESG_NOBLOCK); 24 | } 25 | -------------------------------------------------------------------------------- /src/done/pigetstat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | u32 osPiGetStatus(void) { 6 | return IO_READ(PI_STATUS_REG); 7 | } 8 | -------------------------------------------------------------------------------- /src/done/pirawdma.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | #define WAIT_ON_IOBUSY(stat) \ 6 | stat = IO_READ(PI_STATUS_REG); \ 7 | while (stat & (PI_STATUS_IO_BUSY | PI_STATUS_DMA_BUSY)) \ 8 | stat = IO_READ(PI_STATUS_REG); 9 | 10 | s32 osPiRawStartDma(s32 direction, u32 devAddr, void *dramAddr, u32 size) 11 | { 12 | register u32 stat; 13 | WAIT_ON_IOBUSY(stat); 14 | IO_WRITE(PI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr)); 15 | IO_WRITE(PI_CART_ADDR_REG, K1_TO_PHYS((u32)osRomBase | devAddr)); 16 | switch (direction) 17 | { 18 | case OS_READ: 19 | IO_WRITE(PI_WR_LEN_REG, size - 1); 20 | break; 21 | case OS_WRITE: 22 | IO_WRITE(PI_RD_LEN_REG, size - 1); 23 | break; 24 | default: 25 | return -1; 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /src/done/pirawread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "piint.h" 3 | 4 | s32 osPiRawReadIo(u32 devAddr, u32 *data) 5 | { 6 | register u32 stat; 7 | WAIT_ON_IOBUSY(stat); 8 | *data = IO_READ((u32)osRomBase | devAddr); 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /src/done/rarezip.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "rarezip.h" 3 | 4 | struct huft *D_80007270; 5 | 6 | u32 func_800005C0(u8*, u8*, struct huft *); 7 | u32 func_80000618(u8**, u8**, struct huft *); 8 | 9 | extern void *D_803FBE00; 10 | 11 | u32 func_80000550(u8*arg0){ 12 | return *((u32*)(arg0 +2)); 13 | } 14 | 15 | void func_8000055C(void){ 16 | D_80007270 = (struct huft*) &D_803FBE00; 17 | } 18 | 19 | u32 func_80000570(u8 *inPtr, u8 *outPtr){ 20 | return func_800005C0(inPtr, outPtr, D_80007270); 21 | } 22 | 23 | //rareunzip 24 | u32 func_80000594(u8 **inPtr, u8 **outPtr){ 25 | return func_80000618(inPtr, outPtr, D_80007270); 26 | } 27 | 28 | void func_800005B8(void){} 29 | 30 | u32 func_800005C0(u8* in, u8* out, struct huft *arg2){ 31 | inbuf = in; //inbuf 32 | D_80007284 = out; //slide 33 | D_80007290 = arg2; 34 | inbuf += 6; //skip 6 byte bk header 35 | wp = 0; //wp 36 | inptr = 0; //inptr 37 | 38 | bkboot_inflate(); //inflate 39 | return wp; //return uncompressed size 40 | } 41 | 42 | u32 func_80000618(u8 **inPtr, u8 **outPtr, struct huft *arg2){ 43 | u32 size = func_800005C0(*inPtr, *outPtr, arg2); 44 | *outPtr += wp; 45 | *outPtr = ((u32)(*outPtr) & 0xF) ? (u8 *) ((u32)(*outPtr) & ~0xF) + 0x10 : *outPtr; 46 | *inPtr += inptr + 6; 47 | return size; 48 | } 49 | -------------------------------------------------------------------------------- /src/done/recvmesg.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "osint.h" 3 | 4 | s32 osRecvMesg(OSMesgQueue *mq, OSMesg *msg, s32 flags) 5 | { 6 | register u32 saveMask; 7 | saveMask = __osDisableInt(); 8 | 9 | while (MQ_IS_EMPTY(mq)) 10 | { 11 | if (flags == OS_MESG_NOBLOCK) 12 | { 13 | __osRestoreInt(saveMask); 14 | return -1; 15 | } 16 | __osRunningThread->state = OS_STATE_WAITING; 17 | __osEnqueueAndYield(&mq->mtqueue); 18 | } 19 | 20 | if (msg != NULL) 21 | { 22 | *msg = mq->msg[mq->first]; 23 | } 24 | mq->first = (mq->first + 1) % mq->msgCount; 25 | mq->validCount--; 26 | if (mq->fullqueue->next != NULL) 27 | { 28 | osStartThread(__osPopThread(&mq->fullqueue)); 29 | } 30 | __osRestoreInt(saveMask); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /src/done/resetglobalintmask.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void __osResetGlobalIntMask(OSHWIntr interrupt) 5 | { 6 | register u32 saveMask = __osDisableInt(); 7 | 8 | //not sure about these constants, SR_IBIT3 is external level 3 INT0, which I think corresponds to the rcp 9 | //os.h has several masks defined that end in 401 but non that are just 401 10 | __OSGlobalIntMask &= ~(interrupt & ~(SR_IBIT3 | SR_IE)); 11 | 12 | __osRestoreInt(saveMask); 13 | } 14 | -------------------------------------------------------------------------------- /src/done/sendmesg.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "osint.h" 3 | 4 | s32 osSendMesg(OSMesgQueue *mq, OSMesg msg, s32 flags) 5 | { 6 | register u32 saveMask; 7 | register s32 last; 8 | saveMask = __osDisableInt(); 9 | while (MQ_IS_FULL(mq)) 10 | { 11 | if (flags == OS_MESG_BLOCK) 12 | { 13 | __osRunningThread->state = OS_STATE_WAITING; 14 | __osEnqueueAndYield(&mq->fullqueue); 15 | } 16 | else 17 | { 18 | __osRestoreInt(saveMask); 19 | return -1; 20 | } 21 | } 22 | last = (mq->first + mq->validCount) % mq->msgCount; 23 | mq->msg[last] = msg; 24 | mq->validCount++; 25 | if (mq->mtqueue->next != NULL) 26 | { 27 | osStartThread(__osPopThread(&mq->mtqueue)); 28 | } 29 | __osRestoreInt(saveMask); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /src/done/seteventmesg.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "osint.h" 3 | __OSEventState __osEventStateTab[OS_NUM_EVENTS]; 4 | void osSetEventMesg(OSEvent event, OSMesgQueue *mq, OSMesg msg) 5 | { 6 | register u32 saveMask = __osDisableInt(); 7 | __OSEventState *es; 8 | 9 | es = &__osEventStateTab[event]; 10 | es->messageQueue = mq; 11 | es->message = msg; 12 | __osRestoreInt(saveMask); 13 | } 14 | -------------------------------------------------------------------------------- /src/done/setglobalintmask.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void __osSetGlobalIntMask(OSHWIntr mask) 5 | { 6 | register u32 saveMask = __osDisableInt(); 7 | __OSGlobalIntMask |= mask; 8 | __osRestoreInt(saveMask); 9 | } 10 | -------------------------------------------------------------------------------- /src/done/setthreadpri.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "osint.h" 3 | 4 | void osSetThreadPri(OSThread *t, OSPri pri) 5 | { 6 | register u32 saveMask = __osDisableInt(); 7 | if (t == NULL) 8 | t = __osRunningThread; 9 | if (t->priority != pri) 10 | { 11 | t->priority = pri; 12 | if (t != __osRunningThread && t->state != OS_STATE_STOPPED) 13 | { 14 | __osDequeueThread(t->queue, t); 15 | __osEnqueueThread(t->queue, t); 16 | } 17 | if (__osRunningThread->priority < __osRunQueue->priority) 18 | { 19 | __osRunningThread->state = OS_STATE_RUNNABLE; 20 | __osEnqueueAndYield(&__osRunQueue); 21 | } 22 | } 23 | __osRestoreInt(saveMask); 24 | } 25 | -------------------------------------------------------------------------------- /src/done/si.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | int __osSiDeviceBusy() 6 | { 7 | register u32 stat = IO_READ(SI_STATUS_REG); 8 | if (stat & (SI_STATUS_DMA_BUSY | SI_STATUS_RD_BUSY)) 9 | return 1; 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /src/done/sirawread.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | s32 __osSiRawReadIo(u32 devAddr, u32 *data) 4 | { 5 | if (__osSiDeviceBusy()) 6 | return -1; 7 | *data = IO_READ(devAddr); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /src/done/sirawwrite.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | s32 __osSiRawWriteIo(u32 devAddr, u32 data) 4 | { 5 | if (__osSiDeviceBusy()) 6 | return -1; 7 | IO_WRITE(devAddr, data); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /src/done/startthread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "osint.h" 3 | 4 | void osStartThread(OSThread *t) 5 | { 6 | register u32 saveMask = __osDisableInt(); 7 | switch (t->state) 8 | { 9 | case OS_STATE_WAITING: 10 | t->state = OS_STATE_RUNNABLE; 11 | __osEnqueueThread(&__osRunQueue, t); 12 | break; 13 | case OS_STATE_STOPPED: 14 | if (t->queue == NULL || t->queue == &__osRunQueue) 15 | { 16 | t->state = OS_STATE_RUNNABLE; 17 | __osEnqueueThread(&__osRunQueue, t); 18 | } 19 | else 20 | { 21 | t->state = OS_STATE_WAITING; 22 | __osEnqueueThread(t->queue, t); 23 | __osEnqueueThread(&__osRunQueue, __osPopThread(t->queue)); 24 | } 25 | break; 26 | } 27 | if (__osRunningThread == NULL) 28 | { 29 | __osDispatchThread(); 30 | } 31 | else 32 | { 33 | if (__osRunningThread->priority < __osRunQueue->priority) 34 | { 35 | __osRunningThread->state = OS_STATE_RUNNABLE; 36 | __osEnqueueAndYield(&__osRunQueue); 37 | } 38 | } 39 | __osRestoreInt(saveMask); 40 | } 41 | -------------------------------------------------------------------------------- /src/done/thread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "osint.h" 3 | 4 | struct __osThreadTail __osThreadTail = {0, -1}; 5 | OSThread *__osRunQueue = (OSThread *)&__osThreadTail; 6 | OSThread *__osActiveQueue = (OSThread *)&__osThreadTail; 7 | OSThread *__osRunningThread = {0}; 8 | OSThread *__osFaultedThread = {0}; 9 | void __osDequeueThread(OSThread **queue, OSThread *t) 10 | { 11 | register OSThread *pred; 12 | register OSThread *succ; 13 | pred = (OSThread *)queue; //this is actually legit.. 14 | succ = pred->next; 15 | while (succ != NULL) 16 | { 17 | if (succ == t) 18 | { 19 | pred->next = t->next; 20 | return; 21 | } 22 | pred = succ; 23 | succ = pred->next; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/done/virtualtophysical.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "osint.h" 4 | 5 | u32 osVirtualToPhysical(void *addr) 6 | { 7 | if (IS_KSEG0(addr)) 8 | { 9 | return K0_TO_PHYS(addr); 10 | } 11 | else if (IS_KSEG1(addr)) 12 | { 13 | return K1_TO_PHYS(addr); 14 | } 15 | else 16 | { 17 | return __osProbeTLB(addr); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/done/yieldthread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "osint.h" 3 | 4 | void osYieldThread(void){ 5 | register u32 saveMask = __osDisableInt(); 6 | __osRunningThread->state = OS_STATE_RUNNABLE; 7 | __osEnqueueAndYield(&__osRunQueue); 8 | __osRestoreInt(saveMask); 9 | } 10 | -------------------------------------------------------------------------------- /src/emptyLvl/code_0.c: -------------------------------------------------------------------------------- 1 | unsigned char emptyLvl = 0; 2 | unsigned char emptyLvlBss[0x20]; 3 | 4 | void emptyLvl_func_803863F0(void){} 5 | -------------------------------------------------------------------------------- /src/fight/chbossshadow.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | #include "fight.h" 5 | 6 | ActorInfo chBossShadow = { MARKER_288_GRUNTY_SHADOW, ACTOR_3AF_GRUNTY_SHADOW, ASSET_3BF_MODEL_PLAYER_SHADOW, 1, NULL, chBossShadow_update, actor_update_func_80326224, chBossShadow_draw, 0, 0, 0.0f, 0 }; 7 | 8 | Actor *chBossShadow_draw(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx) { 9 | f32 rotation[3]; 10 | f32 scale; 11 | Actor *actor_bossshadow; 12 | 13 | // unk1C[0] of ACTOR_3AF_GRUNTY_SHADOW is set in chfinalboss_update to the distance between Gruntilda and the floor triangle below her 14 | actor_bossshadow = marker_getActorAndRotation(marker, rotation); 15 | scale = actor_bossshadow->scale * ml_map_f(actor_bossshadow->unk1C[0], 0.0f, 1000.0f, 1.75f, 0.9f); 16 | 17 | modelRender_setDepthMode(MODEL_RENDER_DEPTH_COMPARE); 18 | modelRender_draw(gfx, mtx, actor_bossshadow->position, rotation, scale, NULL, marker_loadModelBin(marker)); 19 | 20 | return actor_bossshadow; 21 | } 22 | 23 | void chBossShadow_update(Actor *this) { 24 | actor_collisionOff(this); 25 | } 26 | -------------------------------------------------------------------------------- /src/lair/bss_pad.c: -------------------------------------------------------------------------------- 1 | static char pad_lair_80395350[0x10]; //padding 2 | -------------------------------------------------------------------------------- /src/lair/code_A430.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "functions.h" 3 | #include "variables.h" 4 | 5 | void func_80390820(Actor *this); 6 | 7 | /* .data */ 8 | ActorInfo D_80394980 = { 0x299, 0x3C3, 0x0, 0x0, NULL, func_80390820, actor_update_func_80326224, func_80325340, 0, 0, 0.0f, 0}; 9 | 10 | /* .code */ 11 | void func_80390820(Actor *this) 12 | { 13 | if (!this->unk38_0 && func_80329530(this, 200)) 14 | { 15 | FUNC_8030E624(SFX_61_CARTOONY_FALL, 0.8f, 32000); 16 | timed_playSfx(0.5f, SFX_31_BANJO_OHHWAAOOO, 1, 32000); 17 | this->unk38_0 = TRUE; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tools/decomp_me_ctx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./tools/m2ctx.py $1 4 | 5 | sed -i 's/sizeof(long)/8/g' ctx.c 6 | -------------------------------------------------------------------------------- /tools/mips_to_c_ctx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./tools/m2ctx.py $1 4 | 5 | sed -i 's/\[\]/\[0\]/g' ctx.c 6 | sed -i 's/sizeof(long)/8/g' ctx.c 7 | -------------------------------------------------------------------------------- /tools/rareunzip.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import zlib 3 | 4 | 5 | def runzip_with_leftovers(data): 6 | d = zlib.decompressobj(wbits=-15) # raw deflate bytestream 7 | res = d.decompress(data[4:]) # drop 4 byte length header 8 | return (res, d.unused_data) 9 | 10 | def runzip(data): 11 | res, leftovers = runzip_with_leftovers(data) 12 | return res 13 | 14 | def main(): 15 | with open(sys.argv[1], "rb") as f: 16 | with open(sys.argv[2], "wb") as o: 17 | data = f.read() 18 | # banjo header 19 | if data[:2] == b'\x11\x72': 20 | data = data[2:] 21 | o.write(runzip(data)) 22 | 23 | 24 | if __name__ == '__main__': 25 | if len(sys.argv) < 3: 26 | print("usage %s infile outfile" % sys.argv[0]) 27 | else: 28 | main() 29 | -------------------------------------------------------------------------------- /tools/set_o32abi_bit.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import argparse, struct, sys 3 | 4 | if __name__ == '__main__': 5 | parser = argparse.ArgumentParser() 6 | 7 | parser.add_argument('file', help='input file') 8 | args = parser.parse_args() 9 | 10 | with open(args.file, 'r+b') as f: 11 | magic = struct.unpack('>I', f.read(4))[0] 12 | if magic != 0x7F454C46: 13 | print('Error: Not an ELF file') 14 | sys.exit(1) 15 | 16 | f.seek(36) 17 | flags = struct.unpack('>I', f.read(4))[0] 18 | if flags & 0xF0000000 != 0x20000000: # test for mips3 19 | print('Error: Architecture not mips3') 20 | sys.exit(1) 21 | 22 | flags |= 0x00001000 # set EF_MIPS_ABI_O32 23 | f.seek(36) 24 | f.write(struct.pack('>I', flags)) 25 | 26 | -------------------------------------------------------------------------------- /tools/sound_func_val_unwrap: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SFX_ID=$(( $1 & 0x7ff)) 4 | VOLUME=$(echo "$((($1 >> 21) & 0x7ff)).0 / 1023.0" | bc -l) 5 | SAMPLE_RATE=$(((($1 >> 11) & 0x3ff)<<5)) 6 | printf "SFX_%X, %f, %d\n" $SFX_ID $VOLUME $SAMPLE_RATE 7 | --------------------------------------------------------------------------------