Enemizer migration

This commit is contained in:
aerinon
2022-09-20 16:38:20 -06:00
parent 6b853222f2
commit 5e93e59727
27 changed files with 1133 additions and 5 deletions

72
enemizer/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
enemizer/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
}

23
enemizer/bossdrop.asm Normal file
View File

@@ -0,0 +1,23 @@
;================================================================================
; Fix boss item drop position to 'center' of screen
;================================================================================
change_heartcontainer_position:
{
PHA
LDA.l !CENTER_BOSS_DROP_FLAG : BEQ .not_moldorm_room
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 ; not moldorm room
LDA $22 : STA $0D10, X
LDA $20 : STA $0D00, X
.not_moldorm_room
PLA
JSL Sprite_Get16BitCoords_long
RTL
}

304
enemizer/bosses_moved.asm Normal file
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
enemizer/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
}

13
enemizer/bushes_table.asm Normal file
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
enemizer/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,3 @@
enemizer_info_table:
skip $100
; contains information about settings and enemizer version used to generate rom

View File

@@ -0,0 +1,44 @@
; ;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"
.center_boss_drops
db #$00 ;368107
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

@@ -1 +1,21 @@
incsrc blindboss_hooks.asm
incsrc hooks/NMI_hook.asm
incsrc hooks/bushes_hooks.asm
incsrc hooks/bossdrop_hooks.asm
incsrc hooks/blinddoor_hooks.asm
incsrc hooks/bosses_hooks.asm
incsrc hooks/moldorm_hooks.asm
incsrc hooks/kodongo_hooks.asm
incsrc hooks/mimic_hooks.asm
incsrc hooks/damage_hooks.asm
incsrc hooks/overworld_sprite_hooks.asm
incsrc hooks/blindboss_hooks.asm

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:
;--------------------------------------------------------------------------------

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,6 @@
;================================================================================
; Change heart container drop location
;--------------------------------------------------------------------------------
org $05EF62
JSL change_heartcontainer_position
;--------------------------------------------------------------------------------

View File

@@ -0,0 +1,210 @@
; ;================================================================================
; ; 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
;--------------------------------------------------------------------------------
; todo make the boss data change dynamic
;================================================================================
; 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
;--------------------------------------------------------------------------------
; todo make arghuss room change dynamic
;================================================================================
; 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,8 @@
;================================================================================
; New bush mob randomization
;--------------------------------------------------------------------------------
org $068279
NOP #$0A
JSL sprite_bush_spawn
NOP ; we keep the branch
;--------------------------------------------------------------------------------

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,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,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 ;
}

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
}

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

@@ -17,7 +17,8 @@ lorom
!RANDOM_SPRITE_FLAG = "$368103"
!AGAHNIM_FUN_BALLS = "$368104"
!ENABLE_MIMIC_OVERRIDE = "$368105"
!ENABLE_TERRORPIN_AI_FIX = "$368106"
;!ENABLE_TERRORPIN_AI_FIX = "$368106" # moved to baserom already
!CENTER_BOSS_DROP_FLAG = "$368107"
; Enemizer reserved memory
; $7F50B0 - $7F50BF - Downstream Reserved (Enemizer)
@@ -26,10 +27,43 @@ lorom
;================================================================================
incsrc hooks.asm
incsrc DMA.asm
org $B78000 ; the original org is 368000, but I'm putting this here for migration purposes, and I think B6 is the same bank but fastrom
org $B68000 ; the original org is 368000 and B6 is the same bank but fastrom
EnemizerTablesStart:
;none migrated yet
incsrc enemizer_info_table.asm
incsrc enemizerflags.asm
incsrc bushes_table.asm
; todo: room header table
EnemizerCodeStart:
incsrc blindboss.asm
incsrc bushes.asm
incsrc NMI.asm
incsrc special_action.asm
incsrc bosses_moved.asm
incsrc damage.asm
incsrc bossdrop.asm
incsrc moldorm.asm
incsrc kodongo_fixes.asm
incsrc mimic_fixes.asm
; todo: vitreous key fix for boss shuffle
incsrc overworld_sprites.asm
incsrc blindboss.asm
warnpc $B6FFFF ;if we hit this we need to split stuff by bank
org $0684BD
Sprite_Get16BitCoords_long:
org $0DBA71
GetRandomInt:
org $0DBB67
Sound_SetSfxPanWithPlayerCoords:
org $0DBB8A
Sound_SetSfx3PanLong:
org $1EC6FA ;F46FA
SpritePrep_Eyegore:

68
enemizer/mimic_fixes.asm Normal file
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
}

14
enemizer/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,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

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
}