The wiki has been upgraded to MediaWiki 1.43. The wiki's theme is still being adapted to work with the new version, and may appear broken for the time being. --RanAS

Hitman Tool UberASM guide

From SnesLab
Jump to: navigation, search
English Português Español 日本語

With Hitman Tool, a level script in UberASM can check whether an object collides with Mario without using a sprite slot.

Set up UberASMTool

After configuring PIXI in the Hitman Tool menu, enter the UberASMTool folder. Enter its list too if your UberASM code links any .hitboxinfo files. If the code only calls Hitman routines, you can leave the list blank. Hitman Tool links HitmanDefines.asm from UberASMTool's macro library.

Run ht without -use-settings to change the saved configuration. See the Quick Start for the installation steps.

Check if an object collides with Mario

For an object with one box, store its position in FreeRAM and set its width and height in the ASM. PlayerClippingRoutine loads Mario's hitbox for you.

Reserve four bytes at an address that is free in your project and define !FreeRAM_ObjetoNivel with that address. Use two bytes for X and two for Y. Set the coordinates when the level loads and update them when the object moves.

!ObjetoX = !FreeRAM_ObjetoNivel
!ObjetoY = !FreeRAM_ObjetoNivel+2
!ObjetoAncho = $0010
!ObjetoAlto = $0010

main:
    ; A and indices are 8-bit. Use the game's direct page.
    JSL !Hitman_Base_PlayerClippingRoutine  ; Load Mario's box into HB2.

    REP #$21
    LDA !ObjetoX
    ADC.w #$0100
    STA !HitmanHB1Left
    CLC
    ADC.w #!ObjetoAncho
    STA !HitmanHB1Right

    LDA !ObjetoY
    CLC
    ADC.w #$0100
    STA !HitmanHB1Top
    CLC
    ADC.w #!ObjetoAlto
    STA !HitmanHB1Bottom

    SEP #$20
    JSL !Hitman_Base_CheckContact
    BCC .SinChoque
    ; Handle the collision with Mario here.
.SinChoque
    RTL

PlayerClippingRoutine leaves Mario's box in HB2 using Hitman's coordinate system. Add $0100 to the object's coordinates when preparing HB1. CheckContact compares the boxes and sets Carry if they collide. For this example, configuring the UberASMTool folder is enough. See Prepare and compare boxes.

Use several hitboxes in one pose

Suppose your object has a base and a moving arm. Save this as ObjetoNivel.hitboxinfo next to the level ASM. Pose 0 uses just the base. Pose 1 uses both boxes.

HitboxesPerPose:
    .Pose0 0
    .Pose1 0,1

Hitbox0:
    .Width $10
    .Height $10

Hitbox1:
    .XOffset $10
    .YOffset $04
    .Width $10
    .Height $08

Add ;#inchbi "ObjetoNivel.hitboxinfo" to the main ASM file and give Hitman the UberASMTool list so it can find the file. Keep the !ObjetoX and !ObjetoY defines from the previous example and use this main. Mario's box still goes in HB2. Hitman works out the object's boxes from its position and pose.

main:
    ; A and indices are 8-bit. Use the game's direct page.
    JSL !Hitman_Base_PlayerClippingRoutine
    STZ !HitmanSprite1Flip

    REP #$21
    LDA !ObjetoX
    ADC.w #$0100
    STA !HitmanSprite1X
    LDA !ObjetoY
    CLC
    ADC.w #$0100
    STA !HitmanSprite1Y

    LDA.w #!ObjetoNivelHitboxContext+1
    JSL !Hitman_Base_ProcessHitBoxesWithoutCallback
    BCC .SinChoque
    ; Mario collided with the base or the arm.
.SinChoque
    RTL

The call checks pose 1 and leaves the first box that collided in HB1. If the object changes poses, keep the current pose index in FreeRAM and add it to the base context instead of adding 1. See ProcessHitBoxesWithoutCallback.

Check two sprites already in the level

If your UberASM code already knows the slots of two Normal sprites, put one in X and the other in Y. Call JSL !Hitman_Base_CheckNormalPair with A and the index registers in 8-bit mode. Hitman uses the configured hitboxes for both and sets Carry if they collide. If one is an Extended sprite, call CheckExtendedNormalPair with the Normal sprite in X and the Extended sprite in Y. See Manual interaction routines.

Install the code

  1. Add the level ASM to the UberASMTool list.
  2. Run Hitman Tool.
  3. If your project uses PIXI sprites with Hitman, run PIXI again on the output ROM.
  4. Run UberASMTool on that same ROM.