Copy ASM files, etc. from parent project.

This commit is contained in:
Lyle Mantooth 2022-05-23 09:47:51 -04:00
parent 476f01fad3
commit cd76b9f2f1
Signed by: IslandUsurper
GPG key ID: 6DB52EAE123A5789
72 changed files with 4171 additions and 0 deletions

72
assembly/src/DMA.asm Normal file
View file

@ -0,0 +1,72 @@
!DISP_REG = $2100 ; Screen Display Register
!VMAIN_REG = $2115 ; Video Port Control Register
!VRAM_LOW_REG = $2116 ; VRAM Address Registers (Low)
!VRAM_HIGH_REG = $2117 ; VRAM Address Registers (High)
!VRAM_WRITE_REG = #$18 ; VRAM Data Write Registers (Low) (you always store it to the dest register so no need for the actual address)
!DMA0_REG = $4300 ; DMA Control Register - channel 0
!DMA0_DEST_REG = $4301 ; DMA Destination Register
!DMA0_SRC_LOW_REG = $4302 ; DMA Source Address Register (Low)
!DMA0_SRC_HIGH_REG = $4303 ; DMA Source Address Register (High)
!DMA0_SRC_BANK_REG = $4304 ; DMA Source Address Register (Bank)
!DMA0_SIZE_LOW_REG = $4305 ; DMA Size Registers (Low)
!DMA0_SIZE_HIGH_REG = $4306 ; DMA Size Registers (Low)
!DMA_ENABLE_REG = $420B ; DMA Enable Register
macro DMA_VRAM(VRAM_HIGH,VRAM_LOW,SRC_BANK,SRC_HIGH,SRC_LOW,LENGTH_HIGH,LENGTH_LOW)
PHA
; --- preserve DMA registers ----------------------------------------------------
LDA !DMA0_REG : PHA
LDA !DMA0_DEST_REG : PHA
LDA !DMA0_SRC_LOW_REG : PHA
LDA !DMA0_SRC_HIGH_REG : PHA
LDA !DMA0_SRC_BANK_REG : PHA
LDA !DMA0_SIZE_LOW_REG : PHA
LDA !DMA0_SIZE_HIGH_REG : PHA
; -------------------------------------------------------------------------------
;LDA.b #$80 : STA !DISP_REG ; force vblank
LDA #$80 : STA !VMAIN_REG
; write to vram at $<VRAM_HIGH><VRAM_LOW>
LDA <VRAM_LOW> : STA !VRAM_LOW_REG ; Set VRAM destination address low byte
LDA <VRAM_HIGH> : STA !VRAM_HIGH_REG ; Set VRAM destination address high byte
; Set DMA0 to write a word at a time.
LDA #$01
STA !DMA0_REG
; Write to $2118 & $2119 - VRAM Data Write Registers (Low) & VRAM Data Write Registers (High)
; setting word write mode on DMA0_REG causes a write to $2118 and then $2119
; $21xx is assumed
LDA #$18
STA !DMA0_DEST_REG
; Read from $<SRC_BANK>:<SRC_HIGH><SRC_LOW>.
LDA.b <SRC_LOW>
STA !DMA0_SRC_LOW_REG ; set src address low byte
LDA.b <SRC_HIGH>
STA !DMA0_SRC_HIGH_REG ; set src address high byte
LDA.b <SRC_BANK>
STA !DMA0_SRC_BANK_REG ; set src address bank byte
; total bytes to copy: #$1000 bytes.
LDA <LENGTH_LOW> : STA $4305 ; length low byte
LDA <LENGTH_HIGH> : STA $4306 ; length high byte
; start DMA on channel 0
LDA #$01 ; channel select bitmask
STA !DMA_ENABLE_REG
; --- restore DMA registers -----------------------------------------------------
PLA : STA !DMA0_SIZE_HIGH_REG
PLA : STA !DMA0_SIZE_LOW_REG
PLA : STA !DMA0_SRC_BANK_REG
PLA : STA !DMA0_SRC_HIGH_REG
PLA : STA !DMA0_SRC_LOW_REG
PLA : STA !DMA0_DEST_REG
PLA : STA !DMA0_REG
; -------------------------------------------------------------------------------
PLA
endmacro

53
assembly/src/NMI.asm Normal file
View file

@ -0,0 +1,53 @@
;-------------
NMIHookAction:
{
;-----------------------------------------
; do our shell stuff
PHA
PHP
SEP #$20 ; get into 8-bit mode
LDA !SHELL_DMA_FLAG : BEQ .return ; check our draw flag
AND #$01 : BNE .loadKholdstare
LDA !SHELL_DMA_FLAG : AND #$02 : BNE .loadTrinexx
BRA .return ; just in case
;BIT #$01 : BEQ .loadKholdstare
;BIT #$02 : BEQ .loadTrinexx
.loadKholdstare
JSL DMAKholdstare
LDA #$00 : STA !SHELL_DMA_FLAG ; clear our draw flag
BRA .return
.loadTrinexx
JSL DMATrinexx
LDA #$00 : STA !SHELL_DMA_FLAG ; clear our draw flag
.return
PLP
PLA
;-----------------------------------------
; restore code Bank00.asm (164-167)
PHB
; Sets DP to $0000
LDA.w #$0000 : TCD
JML.l NMIHookReturn
}
DMAKholdstare:
{
;#GFX_Kholdstare_Shell>>16
%DMA_VRAM(#$34,#$00,#GFX_Kholdstare_Shell>>16&$FF,#GFX_Kholdstare_Shell>>8&$FF,#GFX_Kholdstare_Shell&$FF,#$10,#$00)
RTL
}
DMATrinexx:
{
; TODO: change this to trinexx gfx
%DMA_VRAM(#$34,#$00,#GFX_Trinexx_Shell>>16,#GFX_Trinexx_Shell>>8&$FF,#GFX_Trinexx_Shell&$FF,#$08,#$00)
%DMA_VRAM(#$3A,#$A0,#GFX_Trinexx_Shell2>>16,#GFX_Trinexx_Shell2>>8&$FF,#GFX_Trinexx_Shell2&$FF,#$00,#$C0)
RTL
}

View file

@ -0,0 +1,9 @@
;================================================================================
; NMI Hook
;--------------------------------------------------------------------------------
; rando already hooks the Bank00.asm : 164 (PHA : PHX : PHY : PHD : PHB) so we have to hook after that
org $0080D0 ; <- D0 - Bank00.asm : 164-167 (PHB, LDA.w #$0000)
JML.l NMIHookAction
org $0080D5 ; <- D5 - Bank00.asm : 164-167 (PHB, LDA.w #$0000)
NMIHookReturn:
;--------------------------------------------------------------------------------

24
assembly/src/agahnim.asm Normal file
View file

@ -0,0 +1,24 @@
newAgahBall:
{
;IF DAMAGE
CLC ;Clear carry
STZ $0D90, X ;not sent by the player anymore prevent agahnim from taking damage from the ball
LDA #$60 : STA $0DF0
LDA !AGAHNIM_FUN_BALLS : BEQ .damage
JSL GetRandomInt : BMI .no_damage
.damage
PHX ;keep the current sprite id? not sure why
LDA.b #$A0 : STA $00;?
INC $0D90, X ;sent by the player anymore
LDA.b #$10 ;?
LDX.b #$00 ;Damage class used by the next jump
JSL $06EDCB ;Jump to damage part stuff
PLX ;restore the current sprite id? not sure why again
STZ $0DD0, X ;Set sprite state of energy ball to "Dead"
LDA $0D50, X : STA $0F40 ;Load x velocity of energy ball and store it in agahnim recoiling x
LDA $0D40, X : STA $0F30 ;Load y velocity of energy ball and store it in agahnim recoiling y
SEC;Set carry if we did damage
.no_damage
RTL
}

View file

@ -0,0 +1,8 @@
; 0xF5ABA
org $1EDABA ; Agahnim Ball - Code replaced above
JSL newAgahBall
BCS .hasbeendamaged ;IF Carry set
JMP $DA46 ; 1EDA46 - routine for agahnim ball where it set speed and direction toward link
.hasbeendamaged
NOP #$13 ;Remove unused code that is in our new function

View file

@ -0,0 +1,8 @@
org $1DF65D
Sprite_SpawnDynamically:
; patch this in c# side so we can turn it off if need bee
; ; from rando
; org $308060 ; PC 0x180060
; ProgrammableItemLogicJump_1:
; JSL.l $000000 : RTL

16
assembly/src/bees.asm Normal file
View file

@ -0,0 +1,16 @@
Spawn_Bees:
{
LDA #$79
JSL Sprite_SpawnDynamically
BMI .done
LDA $22
STA $0D10, Y
LDA $23
STA $0D30, Y
LDA $20
STA $0D00, Y
LDA $21
STA $0D20, Y
.done
RTL
}

View file

@ -0,0 +1,14 @@
;================================================================================
; Blind Boss fight
;--------------------------------------------------------------------------------
check_blind_boss_room:
LDA $A0 ; load room index (low byte)
CMP #172 : BNE + ; Is is Thieve Town Boss Room
LDA $09DE81 : BEQ + ; Blind maiden does not need rescuing
LDA $7EF3CC : JML Check_for_Blind_Fight
+
JML Initialize_Blind_Fight

View file

@ -0,0 +1,11 @@
;================================================================================
; Blind Boss fight
;--------------------------------------------------------------------------------
org $1DA081 ; Original Code
JML check_blind_boss_room
Check_for_Blind_Fight:
org $1DA090
Initialize_Blind_Fight:

View file

@ -0,0 +1,11 @@
;================================================================================
; Blind door close
;--------------------------------------------------------------------------------
;
org $028849 ; Bank02.asm(1588) - original code : JSL $078000 //Hook on player main when transition are over execute player code
JSL check_special_action ;using the variable 7E0CF3 if it not 00 then trap the player in that room
;could be changed easily to support more than only 1 function
;--------------------------------------------------------------------------------
org $078000
Player_Main:

View file

@ -0,0 +1,8 @@
;================================================================================
; Remove bolder check for top quadrant so they work everywhere
;--------------------------------------------------------------------------------
; maybe this should be done in c# side?
;remove the Y scrolling check for boulders
org $09B72E
NOP #$0A
;--------------------------------------------------------------------------------

22
assembly/src/bossdrop.asm Normal file
View file

@ -0,0 +1,22 @@
;================================================================================
; Fix boss item drop position to 'center' of screen
;================================================================================
change_heartcontainer_position:
{
PHA
LDA.b #$78 : STA $0D10, X
STA $0D00, X
LDA $23 : STA $0D30, X
LDA $21 : STA $0D20, X
LDA $A0 : CMP #$07 : BNE .not_moldorm_room
LDA $22 : STA $0D10, X
LDA $20 : STA $0D00, X
.not_moldorm_room
PLA
JSL $0684BD
RTL
}

View file

@ -0,0 +1,6 @@
;================================================================================
; Change heart container drop location
;--------------------------------------------------------------------------------
org $05EF62
JSL change_heartcontainer_position
;--------------------------------------------------------------------------------

View file

@ -0,0 +1,208 @@
; ;================================================================================
; ; insert kholdstare & trinexx shell gfx file
; ;--------------------------------------------------------------------------------
; ; pc file address = 0x123000
; org $24B000
; GFX_Kholdstare_Shell:
; incbin shell.gfx
; warnpc $24C001 ; should have written 0x1000 bytes and apparently we need to go 1 past that or it'll yell at us
; org $24C000
; GFX_Trinexx_Shell:
; incbin rocks.gfx
; warnpc $24C801
; GFX_Trinexx_Shell2:
; incbin rocks2.gfx
; warnpc $24C8C1
; ;--------------------------------------------------------------------------------
; ; *$4C290-$4C2D4 LOCAL
; Dungeon_LoadSprites:
; *$4C114-$4C174 LONG
org $9C114
Dungeon_ResetSprites: ; Bank09.asm(822)
; *$4C44E-$4C498 LONG
org $9C44E
Sprite_ResetAll: ; Bank09.asm(1344)
;================================================================================
; fix skull woods gibdo key drop
;--------------------------------------------------------------------------------
;Gibdo key drop hardcoded in skullwoods to fix problems
;some bosses are dropping a key when there's a key drop avaiable in
;the previous room
; org $09DD74 ; Gibdo draw code (JSL Sprite_DrawShadowLong)
; db #$00, #$00 ; Remove key drop in skull woods
; org $1EBB37 ; Gibdo draw code (JSL Sprite_DrawShadowLong)
; JSL gibdo_drop_key
;--------------------------------------------------------------------------------
;================================================================================
; Move All Bosses Sprites in Top Left Quadrant
;--------------------------------------------------------------------------------
; sprite values for rooms, with coordinates changed
;Trinexx
org $09E5BA ; 0x4E5BA ; [0xB]
db $00 ; "Sort Spr" in Hyrule Magic
db $05, $07, $CB ; trinexx body? ; 15 07 CB
db $05, $07, $CC ; trinexx ice head? ; 15 07 CC
db $05, $07, $CD ; trinexx fire head? ; 15 07 CD
db $FF ; terminator
;Armos - Eastern
org $09E887 ; 0x4E887 ; [0x17]
db $00 ; "Sort Spr" in Hyrule Magic
db $05, $04, $53 ; armos ;15 14 53
db $05, $07, $53 ; armos ;15 17 53
db $05, $0A, $53 ; armos ;15 1A 53
db $08, $0A, $53 ; armos ;18 1A 53
db $08, $07, $53 ; armos ;18 17 53
db $08, $04, $53 ; armos ;18 14 53
db $08, $E7, $19 ; armos overlord ;18 F7 19
db $FF ; terminator
;Kholdstare
org $09EA01 ; 0x4EA01 ; [0xB]
db $00 ; "Sort Spr" in Hyrule Magic
db $05, $07, $A3 ; kholdstare shell ;05 17 A3
db $05, $07, $A4 ; fallling ice ;05 17 A4
db $05, $07, $A2 ; kholdstare ;05 17 A2
db $FF ; terminator
;Arrghus
org $09D997 ; 0x4D997 ; [0x2C]
db $00 ; "Sort Spr" in Hyrule Magic
db $07, $07, $8C ; arrghus ;17 07 8C
db $07, $07, $8D ; spawn ;17 07 8D
db $07, $07, $8D ; spawn ;17 07 8D
db $07, $07, $8D ; spawn ;17 07 8D
db $07, $07, $8D ; spawn ;17 07 8D
db $07, $07, $8D ; spawn ;17 07 8D
db $07, $07, $8D ; spawn ;17 07 8D
db $07, $07, $8D ; spawn ;17 07 8D
db $07, $07, $8D ; spawn ;17 07 8D
db $07, $07, $8D ; spawn ;17 07 8D
db $07, $07, $8D ; spawn ;17 07 8D
db $07, $07, $8D ; spawn ;17 07 8D
db $07, $07, $8D ; spawn ;17 07 8D
db $07, $07, $8D ; spawn ;17 07 8D
db $FF ; terminator
;Moldorm - ToH
org $09D9C3 ; 0x4D9C3 ; [0x5]
db $00 ; "Sort Spr" in Hyrule Magic
db $09, $09, $09 ; moldorm ;0E 12 09
db $FF ; terminator
;Mothula
org $09DC31 ; 0x4DC31 ; [0x5] (really [0x8])
db $00 ; "Sort Spr" in Hyrule Magic
db $06, $08, $88 ; mothula ;16 18 88
; truncated moving floor overlord ;16 E7 07
db $FF ; terminator
;Lanmolas - Desert
org $09DCCB ; 0x4DCCB ; [0xB]
db $00 ; "Sort Spr" in Hyrule Magic
db $07, $06, $54 ; lanmolas ;17 06 54
db $07, $09, $54 ; lanmolas ;17 09 54
db $09, $07, $54 ; lanmolas ;19 07 54
db $FF ; terminator
;Helmasaure
org $09E049 ; 0x4E049 ; [0x5]
db $00 ; "Sort Spr" in Hyrule Magic
db $06, $07, $92 ; helmasaur ;16 17 92
db $FF ; terminator
;Vitreous
org $09E457 ; 0x4E457 ; [0x5]
db $00 ; "Sort Spr" in Hyrule Magic
db $05, $07, $BD ; vitreous ;15 07 BD
db $FF ; terminator
;Blind
org $09E654 ; 0x4E654 ; [0x5]
db $00 ; "Sort Spr" in Hyrule Magic
db $05, $09, $CE ; blind ;15 19 CE
db $FF ; terminator
; Armos - GT ; this shouldn't get used unless boss randomization is turned off
org $09DB23 ; 0x4DB23 ; [0x23] // need 0x38 to fit arrghus+spawn and fairies (use 0x4D87E-)
db $00
db $05, $04, $53 ; armos ;15 14 53
db $05, $07, $53 ; armos ;15 17 53
db $05, $0A, $53 ; armos ;15 1A 53
db $08, $0A, $53 ; armos ;18 1A 53
db $08, $07, $53 ; armos ;18 17 53
db $08, $04, $53 ; armos ;18 14 53
db $08, $E7, $19 ; armos overlord ;18 F7 19
db $07, $07, $E3 ; fairy ;07 07 E3
db $07, $08, $E3 ; fairy ;07 08 E3
db $08, $07, $E3 ; fairy ;08 07 E3
db $08, $08, $E3 ; fairy ;08 08 E3
db $FF
; Lanmola - GT ; this shouldn't get used unless boss randomization is turned off
org $09E1BE ; 0x4E1BE ; [0x11] // need 0x32 to fit arrghus+spawn and bunny beam+medusa (use 0x4D8B6-)
db $00
db $07, $06, $54 ; lanmolas ;17 06 54
db $07, $09, $54 ; lanmolas ;17 09 54
db $09, $07, $54 ; lanmolas ;19 07 54
db $18, $17, $D1 ; bunny beam ;18 17 D1
db $1C, $03, $C5 ; medusa ;1C 03 C5
db $FF
; Moldorm - GT ; this shouldn't get used unless boss randomization is turned off
org $09DF1E ; 0x4DF1E ; [0x5]
db $00 ; "Sort Spr" in Hyrule Magic
db $09, $09, $09 ; moldorm ;0E 12 09
db $FF ; terminator
;--------------------------------------------------------------------------------
;================================================================================
; On Room Transition -> Move Sprite depending on the room loaded
;--------------------------------------------------------------------------------
org $028979 ; JSL Dungeon_ResetSprites ; REPLACE THAT (Sprite initialization) original jsl : $09C114
JSL boss_move
org $028C16 ; JSL Dungeon_ResetSprites ; REPLACE THAT (Sprite initialization) original jsl : $09C114
JSL boss_move
org $029338 ; JSL Dungeon_ResetSprites ; REPLACE THAT (Sprite initialization) original jsl : $09C114
JSL boss_move
org $028256 ; JSL Dungeon_ResetSprites ; REPLACE THAT (Sprite initialization) original jsl : $09C114
JSL boss_move
;--------------------------------------------------------------------------------
;================================================================================
; water tiles removed in arrghus room
;--------------------------------------------------------------------------------
org $1FA15C
db $FF, $FF, $FF, $FF, $F0, $FF, $61, $18, $FF, $FF
; Arrghus can stand on ground
org $0DB6BE
db $00
;--------------------------------------------------------------------------------
;================================================================================
; Draw kholdstare shell
;--------------------------------------------------------------------------------
org $0DD97F ; jump point
Kholdstare_Draw:
org $1E9518 ; sprite_kholdstare.asm (154) : JSL Kholdstare_Draw
JSL new_kholdstare_code ; Write new gfx in the vram
;--------------------------------------------------------------------------------
;================================================================================
; Draw trinexx shell
;--------------------------------------------------------------------------------
org $1DAD67 ; sprite_trinexx.asm (62) : LDA.b #$03 : STA $0DC0, X
JSL new_trinexx_code
;--------------------------------------------------------------------------------

View file

@ -0,0 +1,304 @@
;================================================================================
; Move the bosses to the right screen location depending on the room
;--------------------------------------------------------------------------------
boss_move:
{
; TODO: should probably double check that we don't need to preserve registers (A,X)...
JSL Dungeon_ResetSprites ; Restore the dungeon_resetsprites
LDA $A0 ; load room index (low byte)
LDX $A1 ; (high byte)
CMP #7 : BNE + ; Is is Hera Tower Boss Room
CPX #$00 : BNE +
JSL Sprite_ResetAll ; reset sprites twice in that room for some reasons (fix bug with kholdstare)
JSL Dungeon_ResetSprites ; Restore the dungeon_resetsprites
BRL .move_to_middle
+
CMP #200 : BNE + ; Is is Eastern Palace Boss Room
JSL Sprite_ResetAll ; reset sprites twice in that room for some reasons (fix bug with kholdstare)
JSL Dungeon_ResetSprites ; Restore the dungeon_resetsprites
BRL .move_to_bottom_right
+
CMP #41 : BNE + ; Is is Skull Woods Boss Room
; TODO: Add moving floor sprite
JSL Sprite_ResetAll ; reset sprites twice in that room for some reasons (fix bug with kholdstare)
JSL Dungeon_ResetSprites ; Restore the dungeon_resetsprites
LDA #$07 : STA $0B00;Spawn the moving floor sprite
STZ $0B28
INC $0B08
BRL .move_to_bottom_right
+
CMP #51 : BNE + ; Is is Desert Palace Boss Room
JSL Sprite_ResetAll ; reset sprites twice in that room for some reasons (fix bug with kholdstare)
JSL Dungeon_ResetSprites ; Restore the dungeon_resetsprites
BRL .move_to_bottom_left
+
CMP #90 : BNE + ; Is is Palace of darkness Boss Room
JSL Sprite_ResetAll ; reset sprites twice in that room for some reasons (fix bug with kholdstare)
JSL Dungeon_ResetSprites ; Restore the dungeon_resetsprites
BRL .move_to_bottom_right
+
CMP #144 : BNE + ; Is is Misery Mire Boss Room
JSL Sprite_ResetAll ; reset sprites twice in that room for some reasons (fix bug with kholdstare)
JSL Dungeon_ResetSprites ; Restore the dungeon_resetsprites
BRL .move_to_bottom_left
+
CMP #172 : BNE + ; Is is Thieve Town Boss Room
; IF MAIDEN IS NOT RESCUED -> DO NOTHING
; IF MAIDEN IS ALREADY RESCUED -> spawn sprites normally
JSL Sprite_ResetAll ; removes sprites in thieve town boss room
JSL Dungeon_ResetSprites ; Restore the dungeon_resetsprites
;Close the door if !BLIND_DOOR_FLAG == 1
LDA !BLIND_DOOR_FLAG : BEQ .no_blind_door
INC $0468 ; $0468[0x02] - Flag that is set when trap doors are down.
STZ $068E ; $068E[0x02] - (Dungeon) ???? related to trap doors and if they are open ; possibly bomb doors too? Update: module 0x07.0x4 probably uses this to know whether it's a key door or big key door to open.
STZ $0690 ; $0690[0x02] - (Overworld) Generally is used as an animation step indicator, only for doors that animate when they open, such as the Santuary and Hyrule Castle doors. This variable is incremented up to a value of 3, at which point a logic check kicks in and stops animating the opening of a door.
INC $0CF3 ; $0CF3[0x01] - free ram
; ;That must be called after the room load!
.no_blind_door
BRL .move_to_bottom_right
+
CMP #6 : BNE + ; Is is Swamp Palace Boss Room
CPX #$00 : BNE +
JSL Sprite_ResetAll ; reset sprites twice in that room for some reasons (fix bug with kholdstare)
JSL Dungeon_ResetSprites ; Restore the dungeon_resetsprites
BRL .move_to_bottom_left
+
CMP #222 : BNE + ; Is is Ice Palace Boss Room
JSL Sprite_ResetAll ; reset sprites twice in that room for some reasons (fix bug with kholdstare)
JSL Dungeon_ResetSprites ; Restore the dungeon_resetsprites
BRL .move_to_top_right
+
CMP #164 : BNE + ; Is is Turtle Rock Boss Room
JSL Sprite_ResetAll ; reset sprites twice in that room for some reasons (fix bug with kholdstare)
JSL Dungeon_ResetSprites ; Restore the dungeon_resetsprites
BRL .move_to_bottom_left
+
CMP #28 : BNE + ; Is is Gtower (Armos2) Boss Room
CPX #$00 : BNE +
JSL Sprite_ResetAll ; reset sprites twice in that room for some reasons (fix bug with kholdstare)
JSL Dungeon_ResetSprites ; Restore the dungeon_resetsprites
BRL .move_to_bottom_right
+
CMP #108 : BNE + ; Is is Gtower (Lanmo2) Boss Room
JSL Sprite_ResetAll ; reset sprites twice in that room for some reasons (fix bug with kholdstare)
JSL Dungeon_ResetSprites ; Restore the dungeon_resetsprites
BRL .move_to_bottom_left
+
CMP #77 : BNE + ; Is is Gtower (Moldorm2) Boss Room
JSL Sprite_ResetAll ; reset sprites twice in that room for some reasons (fix bug with kholdstare)
JSL Dungeon_ResetSprites ; Restore the dungeon_resetsprites
BRL .move_to_middle
+
BRL .return
; $0D00[0x10] - The lower byte of a sprite's Y - coordinate.
; $0D10[0x10] - The lower byte of a sprite's X - coordinate.
; $0D20[0x10] - The high byte of a sprite's Y - coordinate.
; $0D30[0x10] - The high byte of a sprite's X - coordinate.
; $0B08[0x08] - (Overlord) X coordinate low byte.
; $0B18[0x08] - (Overlord) Y coordinate low byte.
; $0B10[0x08] - (Overlord) X coordinate high byte.
; $0B20[0x08] - (Overlord) Y coordinate high byte.
.move_to_middle
;load all sprite of that room and overlord
LDX #$00
.loop_middle ; move sprites
LDA $0E20, X
CMP #$E3 : BNE + ;is it a fairy?? if not check next
BRA .no_change
+
CMP #$D1 : BNE + ;is it a bunny changer
BRA .no_change
+
CMP #$C5 : BNE + ;is it a medusa head
BRA .no_change
+
LDA $0D10, X : !ADD #$68 : STA $0D10, X
LDA $0D00, X : !ADD #$68 : STA $0D00, X
.no_change
INX : CPX #$10 : BNE .loop_middle
LDX #$00
.loop_middle2 ; move overlords
LDA $0B00, X
CMP #$E3 : BNE + ;is it moving floor?
BRA .no_change_ov
+
LDA $0B08, X : !ADD #$68 : STA $0B08, X
LDA $0B18, X : !ADD #$68 : STA $0B18, X
.no_change_ov
INX : CPX #$08 : BNE .loop_middle2
BRL .return
.move_to_top_right
LDX #$00
.loop_top_right ; move sprites
LDA $0E20, X
CMP #$E3 : BNE + ;is it a fairy?? if not check next
BRA .no_change2
+
CMP #$D1 : BNE + ;is it a bunny changer
BRA .no_change2
+
CMP #$C5 : BNE + ;is it a medusa head
BRA .no_change2
+
LDA $0D20, X : !ADD #$00 : STA $0D20, X
LDA $0D30, X : !ADD #$01 : STA $0D30, X
.no_change2
INX : CPX #$10 : BNE .loop_top_right
LDX #$00
.loop_top_right2 ; move overlords
LDA $0B00, X
CMP #$E3 : BNE + ;is it moving floor?
BRA .no_change_ov2
+
LDA $0B10, X : !ADD #$01 : STA $0B10, X
LDA $0B20, X : !ADD #$00 : STA $0B20, X
.no_change_ov2
INX : CPX #$08 : BNE .loop_top_right2
BRL .return
.move_to_bottom_right
LDX #$00
.loop_bottom_right ; move sprites
LDA $0E20, X
CMP #$E3 : BNE + ;is it a fairy?? if not check next
BRA .no_change3
+
CMP #$D1 : BNE + ;is it a bunny changer
BRA .no_change3
+
CMP #$C5 : BNE + ;is it a medusa head
BRA .no_change3
+
LDA $0D20, X : !ADD #$01 : STA $0D20, X
LDA $0D30, X : !ADD #$01 : STA $0D30, X
.no_change3
INX : CPX #$10 : BNE .loop_bottom_right
LDX #$00
.loop_bottom_right2 ; move overlords
LDA $0B00, X
CMP #$E3 : BNE + ;is it moving floor?
BRA .no_change_ov3
+
LDA $0B10, X : !ADD #$01 : STA $0B10, X
LDA $0B20, X : !ADD #$01 : STA $0B20, X
.no_change_ov3
INX : CPX #$08 : BNE .loop_bottom_right2
BRL .return
.move_to_bottom_left
LDX #$00
.loop_bottom_left ; move sprites
LDA $0E20, X
CMP #$E3 : BNE + ;is it a fairy?? if not check next
BRA .no_change4
+
CMP #$D1 : BNE + ;is it a bunny changer
BRA .no_change4
+
CMP #$C5 : BNE + ;is it a medusa head
BRA .no_change4
+
LDA $0D20, X : !ADD #$01 : STA $0D20, X
LDA $0D30, X : !ADD #$00 : STA $0D30, X
.no_change4
INX : CPX #$10 : BNE .loop_bottom_left
LDX #$00
.loop_bottom_left2 ; move overlords
LDA $0B00, X
CMP #$E3 : BNE + ;is it moving floor?
BRA .no_change_ov4
+
LDA $0B10, X : !ADD #$00 : STA $0B10, X
LDA $0B20, X : !ADD #$01 : STA $0B20, X
.no_change_ov4
INX : CPX #$08 : BNE .loop_bottom_left2
BRL .return
.return
RTL
}
;================================================================================
; Fix the gibdo key drop in skull woods before the boss room - USELESS CODE
;--------------------------------------------------------------------------------
;gibdo_drop_key:
; LDA $A0 : CMP #$39 : BNE .no_key_drop ; Check if the room id is skullwoods before boss
; LDA $0DD0, X : CMP #$09 : BNE .no_key_drop ; Check if the sprite is alive
; LDA #$01 : STA $0CBA, X;set key
;
;.no_key_drop
; JSL $06DC5C ;Restore draw shadow
; RTL
;--------------------------------------------------------------------------------
;================================================================================
; Set a flag to draw kholdstare shell on next NMI
;--------------------------------------------------------------------------------
new_kholdstare_code:
LDA $0CBA : BNE .already_iced
LDA #$01 : STA $0CBA
LDA #$01 : STA !SHELL_DMA_FLAG ; tell our NMI to draw the shell
.already_iced
; restore code
JSL Kholdstare_Draw ; sprite_kholdstare.asm (154) : JSL Kholdstare_Draw
RTL
;--------------------------------------------------------------------------------
;================================================================================
; Set a flag to draw trinexx shell on next NMI
;--------------------------------------------------------------------------------
new_trinexx_code:
LDA $0CBA : BNE .already_rocked
LDA #$01 : STA $0CBA
LDA #$02 : STA !SHELL_DMA_FLAG ; tell our NMI to draw the shell
.already_rocked
; restore code
LDA.b #$03 : STA $0DC0, X ; sprite_trinexx.asm (62) : LDA.b #$03 : STA $0DC0, X
RTL
;--------------------------------------------------------------------------------

68
assembly/src/bushes.asm Normal file
View file

@ -0,0 +1,68 @@
; this is set inside randomizer application
; org $1AFBBB ;Increases chance of getting enemies under random bush
; db $01, $0F, $0F, $0F, $0F, $0F, $0F, $12
; db $0F, $01, $0F, $0F, $11, $0F, $0F, $03
; sprite_bush_spawn_table:
; {
; ; SPRITE DATA TABLE GENERATED BY ENEMIZER
; .overworld
; ; Skip 0x80(overworld) + 0x128 (dungeons)
; skip #$80
; .dungeons
; skip #$128
; ;Old sprite table - Could be changed as well (for the item id 04)
; .random_sprites ; if item == 04
; db #$00, #$D8, #$E3, #$D8
; }
sprite_bush_spawn:
{
STY $0D ; restored code
LDA !BUSHES_FLAG ; That byte is the flag to activate random enemies under bush
BNE .continue
CPY.b #$04 : BNE .not_random_old
JSL GetRandomInt : AND.b #$03 : !ADD.b #$13 : TAY
.not_random_old
LDA $81F3, Y;restored code
RTL
.continue
PHX : PHY ; save x,y just to be safe
PHB : PHK : PLB ; setbank to 40
CPY.b #$04 : BNE .not_random
JSL GetRandomInt : AND.b #$03 : TAY
LDA.w sprite_bush_spawn_table_random_sprites, Y
BRL .return
.item_table
db #$00, #$D9, #$3E, #$79, #$D9, #$DC, #$D8, #$DA, #$E4, #$E1, #$DC
db #$D8, #$DF, #$E0, #$0B, #$42, #$D3, #$41, #$D4, #$D9, #$E3, #$D8
.not_random
CPY.b #$0F : BEQ .newSpriteSpawn
CPY.b #$11 : BEQ .newSpriteSpawn
CPY.b #$10 : BEQ .newSpriteSpawn
;CPY.b #$0E : BEQ .newSpriteSpawn
LDA .item_table, Y
BRA .return
.newSpriteSpawn
LDA $7E040A : TAY ; load the area ID
LDA $7EF3C5 : CMP.b #$03 : !BLT .dontGoPhase2 ; check if agahnim 1 is alive
; aga1 is dead
LDA $7E040A : CMP.b #$40 : !BGE .dontGoPhase2 ; check if we are in DW, if so we can skip shifting table index
!ADD #$90 : TAY ; agahnim 1 is dead, so we need to go to the 2nd phase table for LW
.dontGoPhase2
LDA sprite_bush_spawn_table_overworld, Y ;LDA 408000 + area id
.return
PLB ; restore bank to where it was
PLY : PLX ; restore x,y
RTL
}

View file

@ -0,0 +1,8 @@
;================================================================================
; New bush mob randomization
;--------------------------------------------------------------------------------
org $068279
NOP #$0A
JSL sprite_bush_spawn
NOP ; we keep the branch
;--------------------------------------------------------------------------------

View file

@ -0,0 +1,13 @@
sprite_bush_spawn_table:
{
; SPRITE DATA TABLE GENERATED BY ENEMIZER
.overworld
; Skip 0x128(overworld [way overkill]) + 0x128 (dungeons)
skip $128
.dungeons
skip $128
;Old sprite table - Could be changed as well (for the item id 04)
.random_sprites ; if item == 04
db #$00, #$D8, #$E3, #$D8
}

11
assembly/src/damage.asm Normal file
View file

@ -0,0 +1,11 @@
CheckIfLinkShouldDie:
; before this we should have:
; LDA $7EF36D - this gets hooked, but we should have LDA at the end of it
CMP $00 : BCC .dead
SEC : SBC $00
BRA .done
.dead
LDA #$00
.done
RTL

View file

@ -0,0 +1,12 @@
org $780CA ; Bank07.asm(179)
JSL CheckIfLinkShouldDie : NOP : NOP : NOP
;SEC : SBC.b $00 : CMP #$00 : BEQ .linkIsDead ; Bank07.asm(179) -
org $780D1
BNE linkNotDead : NOP : NOP ; Bank07.asm(183) - CMP.b #$A8 : BCC .linkNotDead
org $780D5
linkIsDead:
org $780F7
linkNotDead:

View file

@ -0,0 +1,3 @@
enemizer_info_table:
skip $100
; contains information about settings and enemizer version used to generate rom

View file

@ -0,0 +1,42 @@
; ;Enemizer Flags
EnemizerFlags:
.randomize_bushes
db #$00 ;408100 : 200100 ; Enable random enemy under bushes
.close_blind_door
db #$00 ;408101 : 200101 ; Enable blind's door closing for other bosses
.moldorm_eye_count
db #$01 ;408102 : 200102 ; Moldorm eye count, default to 2 eyes (1)
.randomize_sprites
db #$00 ;408103 : 200103 ; Randomize Sprites.
.agahnim_fun_balls
db #$00 ;408104 : 200104 ; make Agahnim balls deflect back
.enable_mimic_override
db #$00 ;408105 : 200105 ; toggle mimic code between new and old
.enable_terrorpin_ai_fix
db #$00 ;408106 : 200106 ; toggle to turn on terrorpin ai "fix"
db #$00 ;408107 : 200107
db #$00 ;408108 : 200108
db #$00 ;408109 : 200109
db #$00 ;40810A : 20010A
db #$00 ;40810B : 20010B
db #$00 ;40810C : 20010C
db #$00 ;40810D : 20010D
db #$00 ;40810E : 20010E
db #$00 ;40810F : 20010F
db #$00 ;408110 : 200110
db #$00 ;408111 : 200111
db #$00 ;408112 : 200112
db #$00 ;408113 : 200113
db #$00 ;408114 : 200114
db #$00 ;408115 : 200115
db #$00 ;408116 : 200116
db #$00 ;408117 : 200117
db #$00 ;408118 : 200118
db #$00 ;408119 : 200119
db #$00 ;40811A : 20011A
db #$00 ;40811B : 20011B
db #$00 ;40811C : 20011C
db #$00 ;40811D : 20011D
db #$00 ;40811E : 20011E
db #$00 ;40811F : 20011F

View file

@ -0,0 +1,32 @@
;export.open exported_symbols.txt
;export.label EnemizerTablesStart
;export.label EnemizerCodeStart
;export.label sprite_bush_spawn_table_overworld
;export.label sprite_bush_spawn_table_dungeons
;export.label sprite_bush_spawn_table_random_sprites
;export.label EnemizerFlags
;export.label EnemizerFlags_randomize_bushes
;export.label EnemizerFlags_close_blind_door
;export.label EnemizerFlags_moldorm_eye_count
;export.label EnemizerFlags_randomize_sprites
;export.label EnemizerFlags_agahnim_fun_balls
;export.label EnemizerFlags_enable_mimic_override
;export.label EnemizerFlags_enable_terrorpin_ai_fix
;export.label room_header_table
;export.label enemizer_info_table
;export.label moved_room_header_bank_value_address
;export.label modified_room_object_table
;export.label DMAKholdstare
;export.label swordgfx
;export.label shieldgfx
;export.label Spawn_Bees
;export.label notItemSprite_Mimic
;export.label sprite_bush_spawn_item_table
;export.label
;export.label
;export.label
;export.label
;export.label
;export.label
;export.label
;export.close

View file

@ -0,0 +1,37 @@
; this isn't hooked up in z3rando yet so we can't use it
org $298000 ; 0x148000
Ext_OnFileCreate: ;x
RTL : RTL : RTL : RTL : RTL
Ext_OnFileLoad: ;x immediately after load
;JSL.l OnFileLoad : RTL
RTL : RTL : RTL : RTL : RTL
Ext_OnFileSave: ;x immediately before save
RTL : RTL : RTL : RTL : RTL
Ext_OnPlayerDeath: ;x
RTL : RTL : RTL : RTL : RTL
Ext_OnMapUse: ;x
RTL : RTL : RTL : RTL : RTL
Ext_OnFairyRevive: ;x
RTL : RTL : RTL : RTL : RTL
Ext_OnYItemUse: ;x
RTL : RTL : RTL : RTL : RTL
Ext_OnIemMenuOpen: ;x
RTL : RTL : RTL : RTL : RTL
Ext_OnItemMenuClose: ;x
RTL : RTL : RTL : RTL : RTL
Ext_OnItemChange: ;x
RTL : RTL : RTL : RTL : RTL
Ext_OnPlayerDamaged: ;x
RTL : RTL : RTL : RTL : RTL
Ext_OnPlayerAttack: ;x
RTL : RTL : RTL : RTL : RTL
Ext_OnBossDeath: ;x
RTL : RTL : RTL : RTL : RTL
Ext_OnDungeonEnter: ;x
RTL : RTL : RTL : RTL : RTL
Ext_OnDungeonExit: ;x
RTL : RTL : RTL : RTL : RTL
Ext_OnDungeonCompleted: ;x
RTL : RTL : RTL : RTL : RTL
Ext_OnZeldaRescued: ;x
RTL : RTL : RTL : RTL : RTL

46
assembly/src/hooks.asm Normal file
View file

@ -0,0 +1,46 @@
incsrc NMI_hook.asm
incsrc terrorpin_hooks.asm
incsrc bushes_hooks.asm
incsrc bossdrop_hooks.asm
;;incsrc bolder_hooks.asm ; remove this for now because it needs to be rewritten
incsrc blinddoor_hooks.asm
incsrc bosses_hooks.asm
incsrc moldorm_hooks.asm
;incsrc sprite_randomizer_hooks.asm
incsrc kodongo_hooks.asm
incsrc mimic_hooks.asm
incsrc soundfx_hooks.asm
; don't need this unless testing
;;incsrc location_select_hook.asm
incsrc load_file_hooks.asm
; needs to be fixed
;;incsrc sprite_damage_hooks.asm
incsrc damage_hooks.asm
; leave this out until we make it toggle
;incsrc sword_and_shield_hooks.asm
incsrc overworld_sprite_hooks.asm
incsrc bee_hooks.asm
incsrc vitreous_hooks.asm
;incsrc agahnim_hooks.asm
incsrc blindboss_hooks.asm

11
assembly/src/init.asm Normal file
View file

@ -0,0 +1,11 @@
OnInitFileSelect:
{
LDA.b #$10 : STA $BC
LDA !RANDOM_SPRITE_FLAG : BEQ .continue
JSL GetRandomInt : AND #$1F : !ADD #$60 : STA $BC
.continue
LDA #$00 : STA !SOUNDFX_LOADED
JSL $00893D;Restore the previous code
RTL
}

View file

@ -0,0 +1,9 @@
newKodongoCollision:
{
LDA $0DE0, X : INC A : AND.b #$03 : STA $0DE0, X
;If they collide more than 32time then kill them !
LDA $0DA0, X : INC A : STA $0DA0, X : CMP #$20 : BCC .continue
STZ $0DD0, X
.continue
RTL
}

View file

@ -0,0 +1,3 @@
org $1EC147
JSL newKodongoCollision
NOP #$05

View file

@ -0,0 +1,5 @@
LoadFile:
JSL LoadNewSoundFx
LDA.b #$00 : STA $7EC011 ; restore what we overwrote
RTL

View file

@ -0,0 +1,5 @@
org $028118 ; Bank02.asm(342) : LDA.b #$00 : STA $7EC011
Module_LoadFile_indoors:
;aka Module_LoadGame.indoors
; LDA.b #$00 : STA $7EC011
JSL.l LoadFile : NOP : NOP

View file

@ -0,0 +1,5 @@
LocationMenuHook:
; JSL LoadNewSoundFx
JSL Messaging_Text ; restore what we overwrote
RTL

View file

@ -0,0 +1,6 @@
org $0EEE10
Messaging_Text:
org $28484 ; Bank02.asm(946) : Module_LocationMenu
Module_LocationMenu:
JSL LocationMenuHook

88
assembly/src/main.asm Normal file
View file

@ -0,0 +1,88 @@
lorom
;================================================================================
!ADD = "CLC : ADC"
!SUB = "SEC : SBC"
!BLT = "BCC"
!BGE = "BCS"
; org $00FFD7 ; Set rom on 2mb
; db #$0C
; org $3FFFFF ; write at the last position to expand on 2mb
; db #$00
;=Constants======================================================================
!BUSHES_FLAG = "$368100"
!BLIND_DOOR_FLAG = "$368101"
!MOLDORM_EYES_FLAG = "$368102"
!RANDOM_SPRITE_FLAG = "$368103"
!AGAHNIM_FUN_BALLS = "$368104"
!ENABLE_MIMIC_OVERRIDE = "$368105"
!ENABLE_TERRORPIN_AI_FIX = "$368106"
; Enemizer reserved memory
; $7F50B0 - $7F50BF - Downstream Reserved (Enemizer)
!SHELL_DMA_FLAG = "$7F50B0"
!SOUNDFX_LOADED = "$7F50B1"
;================================================================================
incsrc hooks.asm
incsrc DMA.asm
;incsrc testing.asm ; make sure to comment this out for release!!!
incsrc externalhooks.asm ; this is from z3randomizer source. be sure to check for updates
;================================================================================
org $368000
EnemizerTablesStart:
incsrc enemizer_info_table.asm
incsrc enemizerflags.asm
incsrc bushes_table.asm
incsrc room_header_table.asm
; code
EnemizerCodeStart:
incsrc bushes.asm
incsrc NMI.asm
incsrc init.asm
incsrc terrorpin.asm
incsrc special_action.asm
incsrc bosses_moved.asm
;incsrc sprite_damage.asm
incsrc damage.asm
incsrc bossdrop.asm
incsrc moldorm.asm
;incsrc sprite_randomizer.asm
incsrc kodongo_fixes.asm
incsrc mimic_fixes.asm
;incsrc location_menu.asm
incsrc load_file.asm
incsrc soundfx_changes.asm
incsrc sword_and_shield.asm
incsrc overworld_sprites.asm
incsrc bees.asm
incsrc vitreous_fixes.asm
;incsrc agahnim.asm
incsrc blindboss.asm
; data
incsrc room_object_table.asm
incsrc shell_gfx.asm
warnpc $36FFFF ;if we hit this we need to split stuff by bank
;================================================================================
incsrc export_symbols.asm
org $0DBA71
GetRandomInt:
org $0DBB67
Sound_SetSfxPanWithPlayerCoords:
org $0DBB8A
Sound_SetSfx3PanLong:
org $1EC6FA ;F46FA
SpritePrep_Eyegore:

3
assembly/src/main.rs Normal file
View file

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

View file

@ -0,0 +1,68 @@
; replace SpritePrep_Eyegore if flag is on
SpritePrep_EyegoreNew:
{
LDA !ENABLE_MIMIC_OVERRIDE : BNE .new
; old
JSL SpritePrep_Eyegore
RTL
.new
LDA $0E20, X : CMP.b #$B8 : BEQ .mimic ;If sprite id == debugger sprite
JSL $1EC71A ; 0xF471A set eyegore to be only eyegore (.not_goriya?)
RTL
.mimic
LDA #$83 : STA $0E20, X : JSL $0DB818 ; 0x6B818 Sprite_LoadProperties of green eyegore
LDA #$B8 : STA $0E20, X ; set the sprite back to mimic
LDA $0CAA, X : AND #$FB : ORA #$80 : STA $0CAA, X ; STZ $0CAA, X
;INC $0DA0, X
JSL $1EC70D ;0xF470D set eyegore to be mimic (.is_goriya?)
RTL
}
resetSprite_Mimic:
{
LDA !ENABLE_MIMIC_OVERRIDE : BEQ .notMimic ; skip to what it would have done normally
LDA $0E20, X
CMP.b #$B8 : BNE .notMimic
LDA #$83 : STA $0E20, X ; overwrite the sprite id with green eyegore id
.notMimic
; restore code
LDA $0E20, X
CMP.b #$7A
RTL
}
notItemSprite_Mimic:
{ ; don't change this unless you go update SetKillableThief in c# side since it assumes +4 bytes to update the value on the CMP from B8 to C4
; if we set killable thief we want to update the sprite id so it can be killed
LDA $0E20, X
CMP.b #$B8 : BEQ .changeSpriteId ; thief #$C4
; if we don't have mimic code turned on we want to skip, but we also need to reload the sprite id because we just smoked it with this LDA
LDA !ENABLE_MIMIC_OVERRIDE : BEQ .reloadSpriteIdAndSkipMimic ; skip to what it would have done normally
LDA $0E20, X ; I hate assembly
CMP.b #$B8 : BNE .continue ; "mimic" (dialogue test sprite we hijacked). skip to vanilla behavior if it's not a "mimic"
.changeSpriteId
LDA #$83 ; load green eyegore sprite id so we can kill the thing
JMP .continue
.reloadSpriteIdAndSkipMimic
LDA $0E20, X
.continue
; restore code
REP #$20 : ASL #2
;REP #$20 : ASL #4 : ORA $0CF2 : PHX : REP #$10 : TAX
;SEP #$20
;LDA $7F6000, X : STA $02
;SEP #$10
RTL
}

View file

@ -0,0 +1,39 @@
;Hooks
; sprite_prep.asm (2466) -> SpritePrep_EyegoreTrampoline:
org $0691B6 ; 0311B6 1E:C6FA? ; SpriteActive3_Transfer?
JSL SpritePrep_EyegoreNew ;set eyegore to be only eyegore
; sprite_prep.asm (203) -> dw SpritePrep_DoNothing ; 0xB8 - Dialogue Testing Sprite
org $0687CB ; 0307CB replace debugged sprite create by eyegore
dw #$91B6 ; SpritePrep_Eyegore jump table
; Bank1E.asm (140) -> dw Sprite_DialogueTester ; 0xB8 - debug artifact, dialogue tester
org $1E8BB1
dw #$C795 ;Sprite_Eyegore jump table
; table starts at 6B8F1
org $0DB9A9
db $00 ; sprite B8 needs a damage type
org $06EC08 ; Bank06.asm (4593) - damage calcs
{
JSL resetSprite_Mimic
NOP
}
org $06EDA6 ; Bank06.asm (4876) - .notItemSprite
{
; original
; REP #$20 : ASL #4 : ORA $0CF2 : PHX : REP #$10 : TAX ;C2 20 : 0A 0A 0A 0A : 0D F2 0C : DA : C2 10 : AA
; SEP #$20 ;E2 20
; LDA $7F6000, X : STA $02 ;BF 00 60 7F : 85 02
; SEP #$10
JSL notItemSprite_Mimic ; C2 20 : 0A 0A
;NOP : NOP : NOP : NOP : NOP : NOP : NOP : NOP : NOP ; 0A 0A : 0D F2 0C : DA : C2 10 : AA
;NOP : NOP ; E2 20
;NOP : NOP : NOP : NOP : NOP : NOP ; BF 00 60 7F : 85 02
;NOP ;
}

14
assembly/src/moldorm.asm Normal file
View file

@ -0,0 +1,14 @@
Moldorm_UpdateOamPosition:
{
PHX
LDA !MOLDORM_EYES_FLAG : TAX
.more_eyes
LDA $90 : CLC : ADC.w #$0004 : STA $90
LDA $92 : CLC : ADC.w #$0001 : STA $92
DEX : BPL .more_eyes ; X >= 0
PLX
RTL
}

View file

@ -0,0 +1,20 @@
; adjust oam position after drawing eyes
;ED88E
org $1DD88E
{
; original: GiantMoldorm_Draw+5lines (sprite_giant_moldorm.asm)
; lda $90 : add.w #$0008 : sta $90
; INC $92 : INC $92
JSL Moldorm_UpdateOamPosition
NOP #08
}
; set number of eyes
org $1DDBB2 ;$0EDBB2
{
; LDX.b #$01
; number of eyes (-1)
;0EDBB2 0EDBB3
LDX.b #$07
}

124
assembly/src/msu1.asm Normal file
View file

@ -0,0 +1,124 @@
;=======================================
;
; MSU-1 Enhanced Audio Patch
; ZeLDA no Densetsu - Kamigami no Triforce
; Modified for VT Randomizer
;
; Author: qwertymodo
;
; Modified for use with Enemizer
;=======================================
track_list:
DB $00,$01,$03,$03,$03,$03,$03,$03
DB $01,$03,$01,$03,$03,$03,$03,$03
DB $03,$03,$03,$01,$03,$03,$03,$03
DB $03,$03,$03,$03,$03,$01,$03,$03
DB $03,$01,$01
msu_main:
LDA $4210
LDA !REG_MSU_ID_01
CMP !VAL_MSU_ID_01
BEQ .continue
.nomsu
SEP #$30
JML spc_continue
.continue
LDA !REG_MSU_ID_23
CMP !VAL_MSU_ID_23
BNE .nomsu
LDA !REG_MSU_ID_45
CMP !VAL_MSU_ID_45
BNE .nomsu
SEP #$30
LDX !REG_MUSIC_CONTROL
BNE command_ff
do_fade:
LDA !REG_CURRENT_VOLUME
CMP !REG_TARGET_VOLUME
BNE .continue
JML spc_continue
.continue
BCC .increment
.decrement
SBC !VAL_VOLUME_DECREMENT
BCS .set
.mute
STZ !REG_CURRENT_VOLUME
STZ !REG_MSU_CONTROL
STZ !REG_CURRENT_MSU_TRACK
BRA .set
.increment
ADC !VAL_VOLUME_INCREMENT
BCC .set
LDA !VAL_VOLUME_FULL
.set
STA !REG_CURRENT_VOLUME
STA !REG_MSU_VOLUME
JML spc_continue
command_ff:
CPX !VAL_COMMAND_LOAD_NEW_BANK
BNE command_f3
JML spc_continue
command_f3:
CPX !VAL_COMMAND_FULL_VOLUME
BNE command_f2
STX !REG_SPC_CONTROL
LDA !VAL_VOLUME_FULL
STA !REG_TARGET_VOLUME
JML spc_continue
command_f2:
CPX !VAL_COMMAND_FADE_HALF
BNE command_f1
STX !REG_SPC_CONTROL
LDA !VAL_VOLUME_HALF
STA !REG_TARGET_VOLUME
JML spc_continue
command_f1:
CPX !VAL_COMMAND_FADE_OUT
BNE load_track
STX !REG_SPC_CONTROL
STZ !REG_TARGET_VOLUME
JML spc_continue
load_track:
CPX !REG_CURRENT_MSU_TRACK
BNE .continue
CPX #$1B
BEQ .continue
JML spc_continue
.continue
STX !REG_MSU_TRACK_LO
STZ !REG_MSU_TRACK_HI
STZ !REG_MSU_CONTROL
LDA !VAL_VOLUME_FULL
STA !REG_TARGET_VOLUME
STA !REG_CURRENT_VOLUME
STA !REG_MSU_VOLUME
msu_check_busy:
LDA !REG_MSU_STATUS
BIT !FLAG_MSU_STATUS_AUDIO_BUSY
BNE msu_check_busy
BIT !FLAG_MSU_STATUS_TRACK_MISSING
BEQ msu_play
spc_fallback:
STZ !REG_MSU_CONTROL
STZ !REG_CURRENT_MSU_TRACK
STZ !REG_TARGET_VOLUME
STZ !REG_CURRENT_VOLUME
STZ !REG_MSU_VOLUME
JML spc_continue
msu_play:
LDA track_list,x
STA !REG_MSU_CONTROL
STX !REG_CURRENT_MSU_TRACK
JML spc_continue

View file

@ -0,0 +1,80 @@
;=======================================
;
; MSU-1 Enhanced Audio Patch
; ZeLDA no Densetsu - Kamigami no Triforce
; Modified for VT Randomizer
;
; Author: qwertymodo
;
; Modified for use with Enemizer
;=======================================
!REG_MSU_STATUS = $2000
!REG_MSU_ID_0 = $2002
!REG_MSU_ID_1 = $2003
!REG_MSU_ID_2 = $2004
!REG_MSU_ID_3 = $2005
!REG_MSU_ID_4 = $2006
!REG_MSU_ID_5 = $2007
!REG_MSU_ID_01 = $2002
!REG_MSU_ID_23 = $2004
!REG_MSU_ID_45 = $2006
!VAL_MSU_ID_0 = #$53 ; 'S'
!VAL_MSU_ID_1 = #$2D ; '-'
!VAL_MSU_ID_2 = #$4D ; 'M'
!VAL_MSU_ID_3 = #$53 ; 'S'
!VAL_MSU_ID_4 = #$55 ; 'U'
!VAL_MSU_ID_5 = #$31 ; '1'
!VAL_MSU_ID_01 = #$2D53 ; 'S-'
!VAL_MSU_ID_23 = #$534D ; 'MS'
!VAL_MSU_ID_45 = #$3155 ; 'U1'
!REG_MSU_TRACK = $2004
!REG_MSU_TRACK_LO = $2004
!REG_MSU_TRACK_HI = $2005
!REG_MSU_VOLUME = $2006
!REG_MSU_CONTROL = $2007
!FLAG_MSU_PLAY = #$01
!FLAG_MSU_REPEAT = #$02
!FLAG_MSU_STATUS_TRACK_MISSING = #$08
!FLAG_MSU_STATUS_AUDIO_PLAYING = #$10
!FLAG_MSU_STATUS_AUDIO_REPEATING = #$20
!FLAG_MSU_STATUS_AUDIO_BUSY = #$40
!FLAG_MSU_STATUS_DATA_BUSY = #$80
!REG_CURRENT_VOLUME = $0127
!REG_TARGET_VOLUME = $0129
!REG_CURRENT_MSU_TRACK = $012B
!REG_MUSIC_CONTROL = $012C
!REG_CURRENT_TRACK = $0130
!REG_CURRENT_COMMAND = $0133
!REG_SPC_CONTROL = $2140
!REG_NMI_FLAGS = $4210
!VAL_COMMAND_FADE_OUT = #$F1
!VAL_COMMAND_FADE_HALF = #$F2
!VAL_COMMAND_FULL_VOLUME = #$F3
!VAL_COMMAND_LOAD_NEW_BANK = #$FF
!VAL_VOLUME_INCREMENT = #$10
!VAL_VOLUME_DECREMENT = #$02
!VAL_VOLUME_HALF = #$80
!VAL_VOLUME_FULL = #$FF
ORG $0080D7
spc_nmi:
JML msu_main
NOP
spc_continue:

View file

@ -0,0 +1,359 @@
;----------------------------------------------------------------------------------------------------------------------------------
;Sprites Variables, X is the sprite ID - All informations come from the Zelda_3_Ram.log file
;----------------------------------------------------------------------------------------------------------------------------------
;$0B58, X ; Timers for stunned enemies. Counts down from 0xFF.
;$0B6B, X ; Multiples Bits Data [ttttacbp]
;t - 'Tile Interaction Hit Box', a, c, b - 'Dies like a boss', p - Sprite ignores falling into a pit when frozen?
;$0B89, X ; Object priority stuff for sprites?
;$0BA0, X ; Seems to indicate that it ignores all projectile interactions if set.
;$0BB0, X ; For sprites that interact with speical objects, the special object will identify its type to the sprite via this location.
;$0BE0, X ; [iwbspppp]
;i - If set, disable tile interactions for the sprite, such as falling into holes, moving floors, and conveyor belts
;w - set if in water whether that's deep water or shallow water
;b - If set, the sprite can be blocked by a shield
;s - If set, play the 'enemy taking damage' sound effect. Otherwise, play the basic 'sprite getting hit' sound effect
;p - Prize pack to grant
;$0C9A, X ; Room or Area number that the sprite has been loaded to. (If in a dungeon, only contains the lower byte)
;$0CAA, X ; Multiples Bits Data [abcdefgh]
;a - If set... creates some condition where it may or may not die
;b - Same as bit 'a' in some contexts (Zora in particular)
;c - While this is set and unset in a lot of places for various sprites, its
; status doesn't appear to ever be queried. Based on the pattern of its
; usage, however, the best deduction I can make is that this was a flag
; intended to signal that a sprite is an interactive object that Link can
; push against, pull on, or otherwise exerts a physical presence.
; In general, it might have indicated some kind of A button (action
; button) affinity for the sprite, but I think this is merely informative
; rather than something relevant to gameplay.
;d - If hit from front, deflect Ice Rod, Somarian missile,
; boomerang, hookshot, and sword beam, and arrows stick in
; it harmlessly. If bit 1 is also set, frontal arrows will
; instead disappear harmlessly. No monsters have bit 4 set
; in the ROM data, but it was functional and interesting
; enough to include.
;e - If set, makes the sprite collide with less tiles than usual
;f - If set, makes sprite impervious to sword and hammer type attacks
;g - ???? Seems to make sprite impervious to arrows, but may have other additional meanings.
;h - disabled???
;$0CBA, X ; Sprite drop when he die:
;0x00: nothing happens. / 0x01: leaves a normal key. / 0x03: single green rupee. / anything else: Big Key
;$0CD2, X ; Bump damage the sprite can inflict on the player.
;$0CE2, X ; When the sprite is hit, this is written to with the amount of damage to subtract from the sprite's HP.
;$0CF2, X ; Damage type determiner
;$0D00, X ; The lower byte of a sprite's Y - coordinate.
;$0D10, X ; The lower byte of a sprite's X - coordinate.
;$0D20, X ; The high byte of a sprite's Y - coordinate.
;$0D30, X ; The high byte of a sprite's X - coordinate.
;$0D40, X ; Y velocity
;$0D50, X ; X velocity
;$0D60, X ; Y "second derivative" to give a path a more rounded shape when needed.
;$0D70, X ; X "second derivative" to give a path a more rounded shape when needed.
;$0D80, X ; Controls whether the sprite has been spawned yet. 0 - no. Not 0 - yes. Also used as an AI pointer
;$0D90, X ; In some creatures, used as an index for determining $0DC0 *Unused by sprite Test can be used for anything*
;$0DA0, X ; usage varies considerably for each sprite type **USED by the sprite Test to intialize the sprite**
;$0DB0, X ; Various usages *Unused by sprite Test can be used for anything*
;$0DC0, X ; Designate which graphic to use.
;$0DD0, X ; Sprite State:
;0x00 - Sprite is dead, totally inactive
;0x01 - Sprite falling into a pit with generic animation.
;0x02 - Sprite transforms into a puff of smoke, often producing an item
;0x03 - Sprite falling into deep water (optionally making a fish jump up?)
;0x04 - Death Mode for Bosses (lots of explosions).
;0x05 - Sprite falling into a pit that has a special animation (e.g. Soldier)
;0x06 - Death Mode for normal creatures.
;0x08 - Sprite is being spawned at load time. An initialization routine will
; be run for one frame, and then move on to the active state (0x09) the very next frame.
;0x09 - Sprite is in the normal, active mode.
;0x0A - Sprite is being carried by the player.
;0x0B - Sprite is frozen and / or stunned.
;$0DE0, X ; Sprite Directions *Unused by sprite Test can be used for anything*
;$0DF0, X ; Main delay timer [decreased every frames from sprites routine until it reach 0]
;$0E00, X ; Main Delay Timer 1 [decreased every frames from sprites routine until it reach 0]
;$0E10, X ; Main Delay Timer 2 [decreased every frames from sprites routine until it reach 0]
;$0E20, X ; ID of the sprite that control which sprite type the sprite is
;$0E30, X ; Subtype designation 1?
;$0E40, X ; Bits 0-4: If zero, the sprite is invisible. Otherwise, visible.
;$0E50, X ; Health of the sprite
;$0E60, X ; [niospppu]
;n - If set, don't draw extra death animation sprites over the sprite as it is expiring.
;i - if set, sprite is impervious to all attacks (also collisions?)
;o - If set, adjust coordinates of sprites spawned off of this one, such as water splashes. In general this would roughly approximate the
; concept of 'width' of the sprite, and for this reason usually absorbable items like arrows, rupees, and heart refills utilize this.
;s - If set, draw a shadow for the sprite when doing OAM handling
;p - (Note: 3-bit) Palette into that actually is not used by this variable, but ends up getting copied to the array $0F50 (bitwise and with 0x0F).
;u - unused?
;$0E70, X ; Bit set When a sprite is moving and has hit a wall: ----udlr
;$0E80, X ; Subtype Designation 2?
;$0E90, X ; When a Pikit grabs something from you it gets stored here. *Unused by sprite Test can be used for anything*
;$0EA0, X ; When sprite is taking damage. palette cycling index 0x80 - Signal that the recoil process has finished and will terminate
;$0EB0, X ; For sprites that have a head set the direction of the head *Unused by sprite Test can be used for anything*
;$0EC0, X ; Animation Clock? *Unused by sprite Test can be used for anything*
;$0ED0, X ; ??? *Unused by sprite Test can be used for anything*
;$0EE0, X ; Auxiliary Delay Timer 3 [decreased every frames from sprites routine until it reach 0]
;$0EF0, X ; Death Timer [abbbbbbb]
;a - start death timer?
;b - death timer?
;$0F00, X ; Pause button for sprites apparently. If nonzero they don't do anything.
;$0F10, X ; Auxiliary Delay Timer 4 [decreased every frames from sprites routine until it reach 0]
;$0F20, X ; Floor the sprite stand on
;$0F30, X ; Recoiling Y Velocity when sprite being hit
;$0F40, X ; Recoiling X Velocity when sprite being hit
;$0F50, X ; OAM Related - [vhoopppN]
;v - vflip
;h - hflip
;o - priority
;p - palette
;N - name table
;$0F60, X ; [isphhhhh]
;i - Ignore collision settings and always check tile interaction on the same layer that the sprite is on.
;s - 'Statis'. If set, indicates that the sprite should not be considered as "alive" in routines that try
; to check that property. Functionally, the sprites might not actually be considered to be in statis though.
; Example: Bubbles (aka Fire Faeries) are not considered alive for the purposes of puzzles, because it's
; not expected that you always have the resources to kill them. Thus, they always have this bit set.
;p - 'Persist' If set, keeps the sprite from being deactivated from being too far offscreen from the camera.
; The sprite will continue to move and interact with the game map and other sprites that are also active.
;h - 5-bit value selecting the sprite's hit box dimensions and perhaps other related parameters.
;$0F70, X ; Height value (how far the enemy is from its shadow)
;$0F80, X ; Height Velocity for jump/fall if sprite_move_z is used else can be used for anything
;$0F90, X ; Subpixel portion of altitude.
;$0FC7, X ; Affects something to do with prizes...?
;==================================================================================================================================
;Sprite_Main
;----------------------------------------------------------------------------------------------------------------------------------
;The core of the sprite that is executing all the subfunctions OnCreate, OnInit, OnUpdate, OnDeath, OnTimer1-3, OnDamage, Draw
;==================================================================================================================================
Sprite_Test_Main:
{
;Call Create once
LDA $0DA0, X : BNE .already_created
INC : STA $0DA0, X ; set 0DA0 to 1 to prevent coming back here
JSR Sprite_Test_OnCreate ; Call OnCreate
.already_created
JSR Sprite_Test_Draw ; Call Draw every frames
JSL Sprite_CheckIfActive ; Prevent the sprite from moving when we are in menu/transitioning
LDA $0DA0, X : CMP #$01 : BNE .already_init
INC : STA $0DA0, X ; set 0DA0 to 2 to prevent coming back here
JSR Sprite_Test_OnInit ; Call OnInit
.already_init
.not_defeated_yet
;Call Update every frames
JSR Sprite_Test_OnUpdate
;Timer 1
LDA $0E00, X : BNE .timer1_not_over
JSR Sprite_Test_OnTimer1
.timer1_not_over
;Timer 2
LDA $0E10, X : BNE .timer2_not_over
JSR Sprite_Test_OnTimer2
.timer2_not_over
;Timer 3
LDA $0EE0, X : BNE .timer3_not_over
JSR Sprite_Test_OnTimer3
.timer3_not_over
;Timer 4
LDA $0DF0, X : BNE .timer4_not_over
JSR Sprite_Test_OnTimer4
.timer4_not_over
;Timer 5 (special timer?)
LDA $0F10, X : BNE .timer5_not_over
JSR Sprite_Test_OnTimer5
.timer5_not_over
;If the sprite has received damage
LDA $0CE2, X : BEQ .not_damaged
JSR Sprite_Test_OnDamageFromPlayer
.not_damaged
;Check if the sprite is still active
LDA $0DD0, X : BEQ .not_active
LDA $0E50, X : DEC : BMI .not_dead_yet ;health is lower than 0 so the sprite is dying
JSR Sprite_Test_OnDeath
.not_dead_yet
.not_active
RTL
}
;----------------------------------------------------------------------------------------------------------------------------------
;Sprite_Test_OnCreate
;Executed once when the sprite is created
;Executed during screen transitions
;----------------------------------------------------------------------------------------------------------------------------------
Sprite_Test_OnCreate:
{
RTS
}
;----------------------------------------------------------------------------------------------------------------------------------
;Sprite_Test_OnInit
;Executed once when the sprite is initialized
;Executed when the screen transition is completed
;----------------------------------------------------------------------------------------------------------------------------------
Sprite_Test_OnInit:
{
RTS
}
;----------------------------------------------------------------------------------------------------------------------------------
;Sprite_Test_OnUpdate
;Executed once every frames after the intializations
;----------------------------------------------------------------------------------------------------------------------------------
Sprite_Test_OnUpdate:
{
RTS
}
;----------------------------------------------------------------------------------------------------------------------------------
;Sprite_Test_OnDamageFromPlayer
;Executed once when the sprite receive damage
;----------------------------------------------------------------------------------------------------------------------------------
Sprite_Test_OnDamageFromPlayer:
{
RTS
}
;----------------------------------------------------------------------------------------------------------------------------------
;Sprite_Test_OnTimer1
;Executed once when the timer1[$0E00, X] reach 0
;----------------------------------------------------------------------------------------------------------------------------------
Sprite_Test_OnTimer1:
{
RTS
}
;----------------------------------------------------------------------------------------------------------------------------------
;Sprite_Test_OnTimer2
;Executed once when the timer2[$0E10, X] reach 0
;----------------------------------------------------------------------------------------------------------------------------------
Sprite_Test_OnTimer2:
{
RTS
}
;----------------------------------------------------------------------------------------------------------------------------------
;Sprite_Test_OnTimer3
;Executed once when the timer3[$0EE0, X] reach 0
;----------------------------------------------------------------------------------------------------------------------------------
Sprite_Test_OnTimer3:
{
RTS
}
;----------------------------------------------------------------------------------------------------------------------------------
;Sprite_Test_OnTimer4
;Executed once when the timer3[$0DF0, X] reach 0
;----------------------------------------------------------------------------------------------------------------------------------
Sprite_Test_OnTimer4:
{
RTS
}
;----------------------------------------------------------------------------------------------------------------------------------
;Sprite_Test_OnTimer4
;Executed once when the timer3[$0F10, X] reach 0
;----------------------------------------------------------------------------------------------------------------------------------
Sprite_Test_OnTimer5:
{
RTS
}
;----------------------------------------------------------------------------------------------------------------------------------
;Sprite_Test_OnDeath
;Executed once when the sprite is about to turn into a death cloud
;----------------------------------------------------------------------------------------------------------------------------------
Sprite_Test_OnDeath:
{
RTS
}
;16x16 Draw Test
;----------------------------------------------------------------------------------------------------------------------------------
;Sprite_Test_Draw
;Executed every frames to draw the sprite
;----------------------------------------------------------------------------------------------------------------------------------
Sprite_Test_Draw:
{
JSL Sprite_OAM_AllocateDeferToPlayer ; Mostly used for NPC (draw the sprite under link depending on the positions)
LDA #$EA : STA $06 : STZ $07 ; Save tile index in $06, load the gfx part used 00-01 saved in $07
JSL Sprite_PrepOamCoord ; Set the oam coordinate
JSL Sprite_DrawSingle16 ; Draw one 16x16 sprite $0DC0, X = frame index
RTS
}

View file

@ -0,0 +1,4 @@
OnFileLoad:
{
RTL
}

View file

@ -0,0 +1,54 @@
org $9C50B ; 0x4C50B
{
; .loadData
; ; $4C50B-
; STA $01 ; 85 01
; ; $4C50D-
; LDY.w #$0000 ; A0 00 00
JSL LoadOverworldSprites
NOP
}
org $9C510 ; 0x4C510
LDA [$00], Y ; replace LDA ($00), Y
; CMP.b #$FF : BEQ .stopLoading
; INY #2
org $9C518 ; 0x4C518
LDA [$00], Y ; replace LDA ($00), Y
; DEY #2 : CMP.b #$F4 : BNE .notFallingRocks
; INC $0FFD
; INY #3
; BRA .nextSprite
; .notFallingRocks ; Anything other than falling rocks.
org $9C528 ; 0x4C528
LDA [$00], Y ; replace LDA ($00), Y
; PHA : LSR #4 : ASL #2 :
org $9C531 ; 0x4C531
STA $0A ; STA $02
; INY
org $9C534 ; 0x4C534
LDA [$00], Y ; replace LDA ($00), Y
; LSR #4 : CLC
org $9C53B ; 0x4C53B
ADC $0A ; ADC $02
; STA $06
; PLA : ASL #4 : STA $07
org $9C546 ; 0x4C546
LDA [$00], Y ; replace LDA ($00), Y
; AND.b #$0F : ORA $07 : STA $05
; INY
org $9C54F ; 0x4C54F
LDA [$00], Y ; replace LDA ($00), Y
; LDX $05 : INC A : STA $7FDF80, X
; ; $4C558-
; ; Move on to the next sprite / overlord.
; INY ; C8
; ; $4C559-
; BRA .nextSprite ; 80 B5
; .stopLoading
; ; $4C55B-
; SEP #$10 ; E2 10
; ; $4C55D-
; RTS ; 60

View file

@ -0,0 +1,8 @@
LoadOverworldSprites:
; restore code
STA $01 ; 85 01
LDY.w #$0000 ; A0 00 00
; set bank
LDA #$09 : STA $02 ; default is bank 9
RTL

Binary file not shown.

BIN
assembly/src/rocks.gfx Normal file

Binary file not shown.

BIN
assembly/src/rocks2.gfx Normal file

Binary file not shown.

View file

@ -0,0 +1,6 @@
moved_room_header_bank_value_address:
db #$36 ; use above to index to this
room_header_table:
skip $1180
; new location for room header table

View file

@ -0,0 +1,3 @@
modified_room_object_table:
; Enemizer will write to here
skip $1000

BIN
assembly/src/shell.gfx Normal file

Binary file not shown.

View file

@ -0,0 +1,12 @@
;================================================================================
; insert kholdstare & trinexx shell gfx file
;--------------------------------------------------------------------------------
GFX_Kholdstare_Shell:
incbin shell.gfx
GFX_Trinexx_Shell:
incbin rocks.gfx
GFX_Trinexx_Shell2:
incbin rocks2.gfx
;--------------------------------------------------------------------------------

BIN
assembly/src/shields.gfx Normal file

Binary file not shown.

View file

@ -0,0 +1,45 @@
NewLoadSoundBank_Intro:
; restore
SEI
JSL Sound_LoadSongBank ; change to be JSL
RTL
NewLoadSoundBank:
; restore
SEI
JSL Sound_LoadSongBank ; change to be JSL
RTL
LoadNewSoundFx:
{
LDA !SOUNDFX_LOADED : BEQ +
RTL
+
LDA #$01 : STA !SOUNDFX_LOADED
SEI
; Shut down NMI until music loads
STZ $4200
; Stop all HDMA
STZ $420C
STZ $0136
LDA.b #$FF : STA $2140 ; tell N-SPC to load data
; new code
; load up our new instrument and sample incbin
LDA.b #$00 : STA $00
LDA.b #$80 : STA $01
LDA.b #$26 : STA $02
JSL Sound_LoadSongBank
; Re-enable NMI and joypad
LDA.b #$81 : STA $4200
CLI
;JSL $00893D;Restore the previous code
RTL
}

View file

@ -0,0 +1,59 @@
org $8888
Sound_LoadSongBank:
org $8900 ; change Sound_LoadSongBank to be JSL instead of JSR
RTL
org $890D ; change Sound_LoadIntroSongBank to JSL to Sound_LoadSongBank
JSL NewLoadSoundBank_Intro
org $891F ;
JSL NewLoadSoundBank
;---------------------------------------------------------
; hack new soundfx in and change item get sound fx to new one
; set heart pick up sound to item get
; org $08C4CF
; db #$0F ; default is #$0B
; this is in C# side so it can be turned off
; ; sound fx 3, #$0F background note
; org $1A8D58
; db $00
; ; sound fx 3, #$0F background note #2? not sure what this does exactly
; org $1A8D97
; db $00
; ; 0xD1869
; org $1A9869 ; sound fx 3, #$0F tracker data
; ; original is E0 0B 10 78 B9 BA BB 60 BC 00
; db $E0, $19 ; set instrument $0B
; db $7f ; length
; ;db $ed, $e0
; db $97 ; note to play
; db $00 ; end
; sample 19 - FFFF FFFF in vanila
org $198068
db $88, $31, $FC, $38
; sfx instrument 19
org $268000
db $09, $00, $E1, $3E
; Format: 9 bytes per sample instrument.
; Byte 0: Left volume
; Byte 1: Right volume
; Byte 2: Starting pitch 1
; Byte 3: Starting pitch 2
; Byte 4: Sample (SRCN) number
; Byte 5: ADSR 1 / GAIN
; Byte 6: ADSR 2
; Byte 7: GAIN
; Byte 8: Tuning
db $7F, $7F, $00, $00, $19, $FF, $F0, $70, $04
; what.brr ; 774bytes -> ARAM $3188
db $74, $07, $88, $31
incbin what4.brr
db $00, $00, $00, $08

View file

@ -0,0 +1,12 @@
;================================================================================
; Special action
;================================================================================
check_special_action:
{
LDA $7E0CF3 : BEQ .no_special_action
LDA.b #$05 : STA $11 ; $11[0x01] - (Main) Submodule Index (See $B0)
STZ $0CF3 ; $0CF3[0x01] - free ram
.no_special_action
JSL Player_Main
RTL
}

View file

@ -0,0 +1,13 @@
new_sprites_damage:
{
LDA $7EF35B : STA $00 ; set armor value in $00
LDA $0CD2, X : AND.b #$7F ;load damage the sprite is doing
CPY $00 : BEQ .no_mail
.have_mail
LSR : DEY ;decrease A by half
CPY $00 : BNE .have_mail ;while $00 > 0 then loop back and decrease damage by half
.no_mail
TAY
STA $00 : STA $0373
RTL
}

View file

@ -0,0 +1,4 @@
;org $06F3F6 ;change sprites damage to go up to 128 instead of using 8 damage classes
;original code : LDA $0CD2, X : AND.b #$0F : STA $00 : ASL A : ADC $00 : ADD $7EF35B : TAY
JSL new_sprites_damage
;NOP #$12 ; Remove the 12 bytes remainings

View file

@ -0,0 +1,76 @@
Palette_ArmorAndGloves:
{
;DEDF9
LDA !RANDOM_SPRITE_FLAG : BNE .continue
LDA.b #$10 : STA $BC ; Load Original Sprite Location
REP #$21
LDA $7EF35B
JSL $1BEDFF;Read Original Palette Code
RTL
.part_two
SEP #$30
LDA !RANDOM_SPRITE_FLAG : BNE .continue
REP #$30
LDA $7EF354
JSL $1BEE21;Read Original Palette Code
RTL
.continue
PHX : PHY : PHA
; Load armor palette
PHB : PHK : PLB
REP #$20
; Check what Link's armor value is.
LDA $7EF35B : AND.w #$00FF : TAX
; (DEC06, X)
LDA $1BEC06, X : AND.w #$00FF : ASL A : ADC.w #$F000 : STA $00
;replace D308 by 7000 and search
REP #$10
LDA.w #$01E2 ; Target SP-7 (sprite palette 6)
LDX.w #$000E ; Palette has 15 colors
TXY : TAX
;LDA $7EC178 : AND #$00FF : STA $02
LDA.b $BC : AND #$00FF : STA $02
.loop
LDA [$00] : STA $7EC300, X : STA $7EC500, X
INC $00 : INC $00
INX #2
DEY : BPL .loop
SEP #$30
PLB
INC $15
PLA : PLY : PLX
RTL
}
change_sprite:
{
;JSL $09C114 ; Restore the dungeon_resetsprites
LDA !RANDOM_SPRITE_FLAG : BEQ .continue
JSL GetRandomInt : AND #$1F : !ADD #$60 : STA $BC
STA $7EC178
JSL Palette_ArmorAndGloves
STZ $0710
.continue
LDA $0E20, X : CMP.b #$61 ; Restored Code Bank06.asm(5967) ; LDA $0E20, X : CMP.b #$61 : BNE .not_beamos_laser
RTL
}

View file

@ -0,0 +1,20 @@
org $008A01
LDA $BC
org $1BEDF9
JSL Palette_ArmorAndGloves ;4bytes
RTL ;1byte
NOP #$01
org $1BEE1B
JSL Palette_ArmorAndGloves_part_two
RTL
org $06F40C
JSL change_sprite : NOP #$01 ;LDA $0E20, X : CMP.b #$61
; TODO: move this to main hooks
org $0CCD9D
JSL OnInitFileSelect

View file

@ -0,0 +1,46 @@
swordgfx:
;incbin swords.gfx
skip $1000
shieldgfx:
;incbin shields.gfx
skip $C00
CopySword:
{
PHB : PHK : PLB
PHP ;push processor byte
REP #$30 ; set everything to 16-bit
LDY #$0000
LDA $7EF359 : AND.w #$00FF : ASL : TAX ;Load Sword Value
LDA.w .sword_positon_gfx, X : TAX
.loop_copy
LDA.l swordgfx, X : PHX : TYX : STA $7E9000, X : PLX
LDA.l swordgfx+$200, X : PHX : TYX : STA $7E9180, X : PLX
INX : INX : INY : INY
CPY #$0180 : BCC .loop_copy
PLP ;pull processor byte
PLB
RTL
.sword_positon_gfx
dw #$0000, #$0000, #$0400, #$0800, #$0C00 ; swords position in gfx file
}
CopyShield:
{
PHB : PHK : PLB
PHP ;push processor byte
REP #$30 ; set everything to 16-bit
LDY #$0300
LDA $7EF35A : AND.w #$00FF : ASL : TAX ;Load Shield value
LDA.w .shield_positon_gfx, X : TAX
.loop_copy
LDA.l shieldgfx, X : PHX : TYX : STA $7E9000, X : PLX
LDA.l shieldgfx+$200, X : PHX : TYX : STA $7E90C0, X : PLX
INX : INX : INY : INY
CPY #$03C0 : BCC .loop_copy
PLP ;pull processor byte
PLB
RTL
.shield_positon_gfx
dw #$0000,#$0000, #$0400, #$0800
}

View file

@ -0,0 +1,12 @@
org $00D348
PHB : PHK : PLB
JSL CopyShield
PLB
RTL
org $00D308
PHB : PHK : PLB
JSL CopySword
PLB
RTL

BIN
assembly/src/swords.gfx Normal file

Binary file not shown.

BIN
assembly/src/temp.bin Normal file

Binary file not shown.

View file

@ -0,0 +1,19 @@
;================================================================================
; Terrorpin AI Fixes
;================================================================================
FixTerrorpin:
{
PHA ;save A so that checking the option doesn't smoke A
LDA !ENABLE_TERRORPIN_AI_FIX : BNE .new ; check if option is on
PLA ;restore A
; do the old code that smokes A
AND.b #$03 : STA $0DE0, X
RTL
.new
PLA ; Restore A
PHA ; save A so the orignal code doesn't kill it
AND.b #$03 : STA $0DE0, X ; restore what we overwrote
PLA ; restore A so the AND/BNE in the original code actually does something
RTL
}

View file

@ -0,0 +1,7 @@
;================================================================================
; Terrorpin AI fix
;--------------------------------------------------------------------------------
org $1EB2B1 ; sprite_terrorpin.asm(57) : AND.b #$03 : STA $0DE0, X ; 5 bytes
JSL FixTerrorpin ; 4 bytes
NOP ; 1 byte
;--------------------------------------------------------------------------------

BIN
assembly/src/test.bin Normal file

Binary file not shown.

1245
assembly/src/testing.asm Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,4 @@
VitreousKeyReset:
STZ $0CBA, X
JSL $0DB818 ;restore old code
RTL

View file

@ -0,0 +1,2 @@
org $1DDEEA
JSL VitreousKeyReset

View file

@ -0,0 +1,635 @@
; *$5FFA8-$5FFF5 LONG
WallMaster_SendPlayerToLastEntrance:
{
JSL Dungeon_SaveRoomData.justKeys
JSL Dungeon_SaveRoomQuadrantData
JSL Sprite_ResetAll
; Don't use a starting point entrance.
STZ $04AA ; 9C AA 04
;$04AA[0x02] -
; Flag, that if nonzero, tells us to load using a starting point entrance
; value rather than a normal entrance value.
;$04AA[0x01] - This is used when you die and choose to save & continue
; It is the dungeon entrance to put Link into.
; This variable is only used if you die in a dungeon, and is set to the
; last dungeon entrance you went into.
; Falling into an overworld hole mode.
LDA.b #$11 : STA $10
;$10[0x01] - (Main)
; Main Module index. This controls which top level subprogram we're currently
; in.
; 0x11 - Happens when you fall into a hole from the OW.
STZ $11
;$11[0x01] - (Main)
; Submodule Index (See $B0)
;$B0[0x01] - Sub-submodule index. (Submodules of the $11 submodule index.)
STZ $14
;$14[0x01] - (NMI)
; Value based flag, that if nonzero, causes the tilemap to update from one of
; several source addresses. Some are in ram, but most are in rom. However,
; the ram address $001000 is most commonly used as the source address buffer.
; The others are used for highly specific parts of the game code, such as
; the intro.
; *$5FFBF ALTERNATE ENTRY POINT
STZ $0345
;$0345[0x01] - (Player)
; Set to 1 when we are in deep water. 0 otherwise.
; \wtf 0x11? Written here? I thought these were all even.
STA $005E
;$5E[0x01] - (Player)
; Speed setting for Link. The different values this can be set to index into
; a table that sets his real speed. Some common values:
; 0x00 - Normal walking speed
; 0x02 - Walking (or dashing) on stairs
; 0x10 - Dashing
STZ $03F3
;$03F3[0x01] - ????
STZ $0322
;$0322[0x01] - ????
STZ $02E4
;$02E4[0x01] - (Player)
; Flag that, if nonzero, will not allow Link to move.
; Requires further research as to its generalized usage.
; Also... Link cannot bring down the menu if this is nonzero.
; Additionally.
STZ $0ABD
;$0ABD[0x01] - (Palette)
; Used in order to swap palettes under certain special circumstances.
; Apparently related almost entirely to the flute boy ghost and the ponds of wishing.
; When zero, doesn't induce any behavior change, but when nonzero, it will cause
; SP-0 and SP-7 (full) to swap and SP-5 and SP-3 (second halves) to swap.
STZ $036B
;$036B[0x01] - ????
STZ $0373
;$0373[0x01] - (Player)
; Putting a non zero value here indicates how much life to subtract from Link.
; (quick reference: 0x08 = one heart)
STZ $27
;$27[0x01] - (Player)
; Link's Recoil for vertical collisions
STZ $28
;$28[0x01] - (Player)
; Link's Recoil for horizontal collisions
STZ $29
;$29[0x01] - (Player)
; Vertical resistance
STZ $24
;$24[0x02] - (Dungeon, Overworld)
; 0xFFFF usually, but if Link is elevated off the ground it is considered to
; be his Z coordinate. That is, it's his height off of the ground.
STZ $0351
;$0351[0x01] - (PlayerOam)
; Value that, if set to 1, draws the water ripples around the player sprite
; while standing in water. The drawing, of course, uses sprites.
; If the value is 2, then a patch of tall grass is instead. Any value other
; than 2 (besides 0) produces the water effect.
STZ $0316
;$0316[0x02] - ???? bunny stuffs?
STZ $031F
;$031F[0x01] -
; Countdown timer that, when it's set, causes Link's sprite to
; blink, i.e. flash on and off
LDA.b #$00 : STA $5D
;$5D[0x01] - Player Handler or "State"
; 0x00 - ground state
STZ $4B
;$4B[0x01] -
; Link's visibility status. If set to 0x0C, Link will disappear.
; *$5FFEE ALTERNATE ENTRY POINT
JSL Ancilla_TerminateSelectInteractives
JML Player_ResetState
}
; *$121B1-$121E4 LONG (Bank02.asm)
Dungeon_SaveRoomData:
{
LDA $040C : CMP.b #$FF : BEQ .notInPalace
LDA.b #$19 : STA $11
STZ $B0
LDA.b #$33 : STA $012E
JSL Dungeon_SaveRoomQuadrantData
; *$121C7 ALTERNATE ENTRY POINT (Bank02.asm)
.justKeys
; branch if in a non palace interior.
LDA $040C : CMP.b #$FF : BEQ .return
;$040C[0x02] - (Dungeon)
; Map index for dungeons. If it's equal to 0xFF, that means there is no map
; for that area.
; 0x00 - 0x1A (multiple of 2)
; Is it the Sewer?
CMP.b #$02 : BNE .notSewer
; 0x02 - Hyrule Castle
; If it's the sewer, put them in the same slot as Hyrule Castles's. annoying :p
LDA.b #$00
.notSewer
LSR A : TAX
; Load our current count of keys for this dungeon.
; Save it to an appropriate slot.
LDA $7EF36F : STA $7EF37C, X
;$7EF36F = current key count
;$7EF37C,X = dungeon key count
.return
RTL
.notInPalace ; we never get here from wallmaster
; Play the error sound effect
LDA.b #$3C : STA $012E
RTL
}
.......
; *$13929 ALTERNATE ENTRY POINT (Bank02.asm)
shared Dungeon_SaveRoomQuadrantData:
; figures out which Quadrants Link has visited in a room.
; Mapped to bit 3.
LDA $A7 : ASL #2 : STA $00
; Mapped to bit 2.
LDA $A6 : ASL A : ORA $00
;$A6[0x01] - Set to 0 or 2, but it depends upon the dungeon room's layout
; and the quadrant it was entered from. Further investigation seems
; to indicate that its purpose is to control the camera / scrolling
; boundaries in dungeons.
;$A7[0x01] - Same as $A6, but for vertical camera scrolling.
; Mapped to bit 1.
ORA $AA
;$AA[0x01] - 2 if you are the lower half of the room. 0 if you are on the upper half.
; Mapped to bit 0.
ORA $A9
;$A9[0x01] - 0 if you are on the left half of the room. 1 if you are on the right half.
; X ranges from 0x00 to 0x0F
TAX
; These determine the quadrants Link has seen in this room.
LDA $02B5CC, X : ORA $0408 : STA $0408
; ; $135CC-$135DB ($02B5CC)
; {
; db $08, $04, $02, $01, $0C, $0C, $03, $03
; db $0A, $05, $0A, $05, $0F, $0F, $0F, $0F
; }
;$0408[0x02] - Only lowest 4 bits are used. Record of the quadrants that Link
; has visited in the current room.
JSR $B947 ; $13947 IN ROM ; Save the room data and exit.
RTL
}
; *$13947-$13967 LOCAL
{
; Saves data for the current room
REP #$30
; What room are we in... use it as an index.
LDA $A0 : ASL A : TAX
;$A0[0x02] - The index used for loading a dungeon room. There are 296 rooms all in all. (mirrored in other variables).
; Store other data, like chests opened, bosses killed, etc.
LDA $0402 : LSR #4 : STA $06
;$0402[0x01] - Certainly related to $0403, but contains other information I haven<65>t looked at yet.
;$00[0x10] - (Main)
; Mainly used as work registers. Storage of addresses and values.
; Store information about this room when it changes.
LDA $0400 : AND.w #$F000 : ORA $0408 : ORA $06 : STA $7EF000, X
;$0400[0x02] - Tops four bits: In a given room, each bit corresponds to a
; door being opened. If set, it has been opened by some means
; (bomb, key, etc.)
;$0408[0x02] - Only lowest 4 bits are used. Record of the quadrants that Link
; has visited in the current room.
;$7EF000[0x500] - Save Game Memory, which gets mapped to a slot in SRAM when
; you save your game. SRAM slots are at $70:0000, $70:0500,
; and $70:0A00. They are also mirrored in the next three
; slots. See the sram documentation for more details.
SEP #$30
RTS
}
; *$4C44E-$4C498 LONG (Bank09.asm)
Sprite_ResetAll:
{
JSL Sprite_DisableAll ; $4C22F IN ROM
; *$4C452 ALTERNATE ENTRY POINT
.justBuffers
STZ $0FDD : STZ $0FDC : STZ $0FFD
STZ $02F0 : STZ $0FC6 : STZ $0B6A
STZ $0FB3
LDA $7EF3CC : CMP.b #$0D
; branch if Link has the super bomb tagalong following him
BEQ .superBomb
LDA.b #$FE : STA $04B4
.superBomb
REP #$10
LDX.w #$0FFF
LDA.b #$00
.clearLocationBuffer
STA $7FDF80, X : DEX
BPL .clearLocationBuffer
LDX.w #$01FF
.clearDeathBuffer
STA $7FEF80, X : DEX
BPL .clearDeathBuffer
SEP #$10
LDY.b #$07
LDA.b #$FF
.clearRecentRoomsList
STA $0B80, Y : DEY
BPL .clearRecentRoomsList
RTL
}
; *$4AC6B-$4ACF2 LONG (Bank09.asm)
Ancilla_TerminateSelectInteractives:
{
PHB : PHK : PLB
LDX.b #$05
.nextObject
; check for 3D crystal
LDA $0C4A, X : CMP.b #$3E : BNE .not3DCrystal
TXY
BRA .checkIfCarryingObject
.not3DCrystal
; checks if any cane of somaria blocks are in play?
LDA $0C4A, X : CMP.b #$2C : BNE .checkIfCarryingObject
STZ $0646
LDA $48 : AND.b #$80 : BEQ .checkIfCarryingObject
; reset Link's grabby status
STZ $48 : STZ $5E
.checkIfCarryingObject
LDA $0308 : BPL .notCarryingAnything
TXA : INC A : CMP $02EC : BEQ .spareObject
BRA .terminateObject
.notCarryingAnything
TXA : INC A : CMP $02EC : BNE .terminateObject
STZ $02EC
.terminateObject
STZ $0C4A, X
.spareObject
DEX : BPL .nextObject
LDA $037A : AND.b #$10 : BEQ .theta
STZ $46
STZ $037A
.theta
; Reset flute playing interval timer.
STZ $03F0
; Reset tagalong detatchment timer.
STZ $02F2
; Only place this is written to. Never read.
STZ $02F3
STZ $035F
STZ $03FC
STZ $037B
STZ $03FD
STZ $0360
LDA $5D : CMP.b #$13 : BNE .notUsingHookshot
LDA.b #$00 : STA $5D
LDA $3A : AND.b #$BF : STA $3A
LDA $50 : AND.b #$FE : STA $50
LDA $037A : AND.b #$FB : STA $037A
STZ $037E
.notUsingHookshot
PLB
RTL
}
; *$3F1A3-$3F259 LONG
Player_ResetState:
{
STZ $26 ;$26[0x01] - (Player) The direction(s) that Link is pushing against.
STZ $67 ;$67[0x01] - (Player) Indicates which direction Link is walking (even if not going anywhere).
STZ $031F ;$031F[0x01] - Countdown timer that, when it's set, causes Link's sprite to blink, i.e. flash on and off
STZ $034A ;$034A[0x01] - (Player) Flag indicating whether Link is moving or not. (I think)
JSL Player_ResetSwimState
STZ $02E1 ;$02E1[0x01] - (Player) Link is transforming? (Poofing in a cloud to transform into something else.)
STZ $031F ;$031F[0x01] - Countdown timer that, when it's set, causes Link's sprite to blink, i.e. flash on and off
STZ $03DB ;$03DB[0x06] - (Ancilla) Special Object ram.
STZ $02E0 ;$02E0[0x01] - (Player) Flag for Link's graphics set. 0 - Normal Link
STZ $56 ;$56[0x01] - (PlayerOam) Link's graphic status. 1 - bunny link, 0 - real link.
STZ $03F5 ;$03F5[0x02] - (Player) The timer for Link's tempbunny state.
STZ $03F7 ;$03F7[0x01] - (Player) Flag indicating whether the "poof" needs to occur for Link to transform into the tempbunny.
STZ $03FC ;$03FC[0x01] - ????
STZ $03F8 ;$03F8[0x01] - Flag set if you are near a PullForRupees sprite
STZ $03FA ;$03FA[0x02] - Relates to Link's OAM routine in Bank 0D somehow. Appears to be the 9th bit of the X coordinate of some sprite(s).
STZ $03E9 ;$03E9[0x01] - Flag that seems to set when moving gravestones are in play and puzzle sound is playing.
STZ $0373 ;$0373[0x01] - (Player) Putting a non zero value here indicates how much life to subtract from Link. (quick reference: 0x08 = one heart)
STZ $031E ;$031E[0x01] - used as an offset for a table to retrieve values for $031C. The offset comes in increments of four, depending on which direction Link is facing when he begins to spin. This makes sense, given that he always spins the same direction, and allows for reusability between the different directions, each one being a sub set of the full sequence.
STZ $02F2 ;$02F2[0x01] - (Tagalong) Used as a bitfield of event flags of a temporary nature relating to Tagalongs.
STZ $02F8 ;$02F8[0x01] - Flag used to make Link make a noise when he gets done bouncing after a wall he's dashed into. Thus, it only has any use in relation to dashing.
STZ $02FA ;$02FA[0x01] - Flag that is set if you are near a moveable statue (close enough to grab it)
STZ $02E9 ;$02E9[0x01] - Item Receipt Method. 0 - Receiving item from an NPC or message
STZ $02DB ;$02DB[0x01] - (Player) Triggered by the Whirlpool sprite (but only when touched in Area 0x1B). The Whirlpool sprite used is not visible to the player, and is placed in the open perimeter gate to Hyrule Castle after beating Agahnim. I guess they needed some mechanism to make that happen, and that sprite was specialized in order to do so. Apparently this is set when warping to the Dark World?
; *$3F1E6 ALTERNATE ENTRY POINT
; called by mirror warping.
STZ $02F5 ;$02F5[0x01] - (Player) 0 - Not on a Somaria Platform.
STZ $0079 ;$79[0x01] - (Player) Controls whether to do a spin attack or not? Update: Actually looks more like a step counter for the spin attack...
STZ $0302 ;$0302[0x01] - (Player) ????
STZ $02F4 ;$02F4[0x01] - Only use is for caching the current value of $0314 in some instances
STZ $48 ;$48[0x01] - (PlayerOam) If set, when the A button is pressed, the player sprite will enter the "grabbing at something" state.
STZ $5A ;$5A[0x01] - (Player) ????
STZ $5B ;$5B[0x01] - (Player) 0 - indicates nothing, 1 - Player is dangerously near the edge of a pit, 2 - Player is falling
; \wtf Why zeroed twice? probably a typo on the programmer's end.
; Or maybe it was aliased to two different names...
STZ $5B ; "
; *$3F1FA ALTERNATE ENTRY POINT
; called by some odd balls.
STZ $036C ;$036C[0x01] - Action index when interacting with tiles, like pots, rocks, or chests. 0 - ???, 1 - Picks up a pot or bush.
STZ $031C ;$031C[0x01] - (Player) tells us the actual graphic/state to use on the given step of a spin attack
STZ $031D ;$031D[0x01] - (Player) step counter for the spin attack
STZ $0315 ;$0315[0x01] - Seems to be a flag that is set to 0 if Link is not moving, and 1 if he is moving. However it doesn't seem to get reset to zero.
STZ $03EF ;$03EF[0x01] - (Player, PlayerOam) Normally zero. If set to nonzero, it forces Link to the pose where he is holding his sword up. One example of where this is used is right after Ganon is defeated.
STZ $02E3 ;$02E3[0x01] - (Player) (Slightly uncertain about this) Delay timer between attacks involving the sword. In essence, the repeat rate at which you are able to swing your sword. May have an impact on other types of sword attacks like stabbing and dash attacks.
STZ $02F6 ;$02F6[0x02] - (Player) Bitfield for interaction with Blue Rupee, Grabbable, and Key Door tiles
STZ $0301 ;$0301[0x01] - (Player) [bmuaethr] When non zero, Link has something in his hand, poised to strike. It's intended that only one bit in this flag be set at any time, though.
STZ $037A ;$037A[0x01] - (Player) Puts Link in various positions, 1 - shovel, 2 - praying, etc... cane of somaria. May also have something to do with bombs?
STZ $020B ;$020B[0x01] - Seems to be a debug value for Module 0x0E.0x01
STZ $0350 ;$0350[0x01] - (WriteOnly) free ram, though it would need to be reclaimed from the game engine as it's currently used in several places as an apparent debug variable. Specifically, it always written to, but never read.
STZ $030D ;$030D[0x01] - ????
STZ $030E ;$030E[0x01] - Always seems to be set to 0, and only read during OAM handling of the player sprite.
STZ $030A ;$030A[0x01] - (PlayerOam) Step counter used with $030B. Also, $030A-B seem to be used for the opening of the desert palace
STZ $3B ;$3B[0x01] - (Player) Bitfield for the A button
STZ $3A ;$3A[0x01] - Bitfield for the B and Y buttons
STZ $3C ;$3C[0x01] - (Player) Lower Nibble: How many frames the B button has been held, approximately. Upper nibble: set to 9 on spin attack release.
STZ $0308 ;$0308[0x01] - Bit 7 - is set when Link is carrying something. Bit 1 - set when Link is praying?
STZ $0309 ;$0309[0x01] - 0 - nothing. 1 - picking up something. 2 - throwing something or halfway done picking up something.
STZ $0376 ;$0376[0x01] - bit 0: Link is grabbing a wall.
STZ $50 ;$50[0x01] - (Player) A flag indicating whether a change of the direction Link is facing is possible. For example, when the B button is held down with a sword. 0 - Can change
STZ $4D ;$4D[0x01] - An Auxiliary Link handler. As far as I know, 0x00 - ground state (normal)
STZ $46 ;$46[0x01] - (Player) A countdown timer that incapacitates Link when damaged or in recoil state. If nonzero, no movement input is recorded for Link.
STZ $0360 ;$0360[0x01] - A flag that, when nonzero, causes Link to be electrocuted when touching an enemy. This seems counterintuitive to me, but whatever.
STZ $02DA ;$02DA[0x01] - (Player) Flag indicating whether Link is in the pose used to hold an item or not. 0 - no extra pose.
STZ $55 ;$55[0x01] - Cape flag, when set, makes you invisible and invincible. You can also go through objects, such as bungies.
JSR $9D84 ; $39D84 IN ROM (BRANCH_EPSILON)
STZ $037B ;$037B[0x01] - (Player) If nonzero, disables Link's ability to receive hits from sprites. (But not pits)
STZ $0300 ;$0300[0x01] - Link's state changes? Happens when using boomerang. Also related to electrocution maybe?
STZ $037E ;$037E[0x01] - (Player), (Hookshot) Bit 0 - Hookshot is dragging Link somewhere. Bit 1 - ???? seems like it gets toggled every 3 frames, or something like that.
STZ $02EC ;$02EC[0x01] - seems to be a flag for (Link's) collision with bombs. Maybe other uses
STZ $0314 ;$0314[0x01] - (Player) The index (the X in $0DD0 for example) of the sprite that Link is "touching"
STZ $03F8 ;$03F8[0x01] - Flag set if you are near a PullForRupees sprite
STZ $02FA ;$02FA[0x01] - Flag that is set if you are near a moveable statue (close enough to grab it)
RTL
}
; *$39D84-$39E62 LOCAL
{
BRANCH_EPSILON:
; Bring Link to stop
STZ $5E
LDA $48 : AND.b #$F6 : STA $48
; Stop any animations Link is doing
STZ $3D
STZ $3C
; Nullify button input on the B button
LDA $3A : AND.b #$7E : STA $3A
; Make it so Link can change direction if need be
LDA $50 : AND.b #$FE : STA $50
BRL BRANCH_ALPHA
; *$39D9F ALTERNATE ENTRY POINT
BIT $48 : BNE BRANCH_BETA
LDA $48 : AND.b #$09 : BNE BRANCH_GAMMA
BRANCH_BETA:
LDA $47 : BEQ BRANCH_DELTA
CMP.b #$01 : BEQ BRANCH_EPSILON
BRANCH_GAMMA:
LDA $3C : CMP.b #$09 : BNE BRANCH_ZETA
LDX.b #$0A : STX $3C
LDA $9CBF, X : STA $3D
BRANCH_ZETA:
DEC $3D : BPL BRANCH_THETA
LDA $3C : INC A : CMP.b #$0D : BNE BRANCH_KAPPA
LDA $7EF359 : INC A : AND.b #$FE : BEQ BRANCH_LAMBDA
LDA $48 : AND.b #$09 : BEQ BRANCH_LAMBDA
LDY.b #$01
LDA.b #$1B
JSL AddWallTapSpark ; $49395 IN ROM
LDA $48 : AND.b #$08 : BNE BRANCH_MUNU
LDA $05 : JSR Player_DoSfx2
BRA BRANCH_XI
BRANCH_MUNU:
LDA.b #$06 : JSR Player_DoSfx2
BRANCH_XI:
; Do sword interaction with tiles
LDY.b #$01
JSR $D077 ; $3D077 IN ROM
BRANCH_LAMBDA:
LDA.b #$0A
BRANCH_KAPPA:
STA $3C : TAX
LDA $9CBF, X : STA $3D
BRANCH_THETA:
BRA BRANCH_RHO
BRANCH_DELTA:
LDA.b #$09 : STA $3C
LDA.b #$01 : TSB $50
STZ $3D
LDA $5E
CMP.b #$04 : BEQ BRANCH_RHO
CMP.b #$10 : BEQ BRANCH_RHO
LDA.b #$0C : STA $5E
LDA $7EF359 : INC A : AND.b #$FE : BEQ BRANCH_ALPHA
LDX.b #$04
BRANCH_PHI:
LDA $0C4A, X
CMP.b #$30 : BEQ BRANCH_ALPHA
CMP.b #$31 : BEQ BRANCH_ALPHA
DEX : BPL BRANCH_PHI
LDA $79 : CMP.b #$06 : BCC BRANCH_CHI
LDA $1A : AND.b #$03 : BNE BRANCH_CHI
JSL AncillaSpawn_SwordChargeSparkle
BRANCH_CHI:
LDA $79 : CMP.b #$40 : BCS BRANCH_ALPHA
INC $79 : LDA $79 : CMP.b #$30 : BNE BRANCH_ALPHA
LDA.b #$37 : JSR Player_DoSfx2
JSL AddChargedSpinAttackSparkle
BRA BRANCH_ALPHA
BRANCH_RHO:
JSR $9E63 ; $39E63 IN ROM
BRANCH_ALPHA:
RTS
}

BIN
assembly/src/what4.brr Normal file

Binary file not shown.

BIN
assembly/src/whatsmall.brr Normal file

Binary file not shown.