From 467507b505bc3fec8bca370ed7042b15756f8d2a Mon Sep 17 00:00:00 2001 From: aerinon Date: Tue, 28 Apr 2020 17:05:58 -0600 Subject: [PATCH] Straight Stairs trap doors Straight Stairs adjustment for different door types --- BaseClasses.py | 15 +------- DoorShuffle.py | 15 ++++---- DungeonGenerator.py | 21 ++---------- asm/doorrando.asm | 25 ++------------ asm/doortables.asm | 64 +++++++++++++++++++++++----------- asm/drhooks.asm | 14 ++++++-- asm/normal.asm | 83 +++++++++++++++++++++++++++++++++++++++++++-- asm/spiral.asm | 12 ++++--- 8 files changed, 159 insertions(+), 90 deletions(-) diff --git a/BaseClasses.py b/BaseClasses.py index e7c8da34..96752d8f 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -1038,10 +1038,6 @@ class Hook(Enum): South = 2 East = 3 Stairs = 4 - NEdge = 5 - SEdge = 6 - WEdge = 7 - EEdge = 8 hook_dir_map = { @@ -1051,21 +1047,12 @@ hook_dir_map = { Direction.East: Hook.East, } -edge_map = { - Direction.North: Hook.NEdge, - Direction.South: Hook.SEdge, - Direction.West: Hook.WEdge, - Direction.East: Hook.EEdge, -} - def hook_from_door(door): if door.type == DoorType.SpiralStairs: return Hook.Stairs - if door.type == DoorType.Normal: + if door.type in [DoorType.Normal, DoorType.Open, DoorType.StraightStairs]: return hook_dir_map[door.direction] - if door.type == DoorType.Open: - return edge_map[door.direction] return None diff --git a/DoorShuffle.py b/DoorShuffle.py index 14aa20c6..b16872bf 100644 --- a/DoorShuffle.py +++ b/DoorShuffle.py @@ -8,7 +8,6 @@ from enum import unique, Flag from functools import reduce from BaseClasses import RegionType, Door, DoorType, Direction, Sector, CrystalBarrier from Regions import key_only_locations -from Dungeons import hyrule_castle_regions, eastern_regions, desert_regions, hera_regions, tower_regions, pod_regions from Dungeons import dungeon_regions, region_starts, split_region_starts, flexible_starts from Dungeons import drop_entrances, dungeon_bigs, dungeon_keys, dungeon_hints from Items import ItemFactory @@ -55,10 +54,11 @@ def link_doors(world, player): connect_two_way(world, entrance, ext, player) within_dungeon(world, player) elif world.doorShuffle[player] == 'crossed': - for entrance, ext in open_edges: - connect_two_way(world, entrance, ext, player) - for entrance, ext in straight_staircases: - connect_two_way(world, entrance, ext, player) + if not world.experimental[player]: + for entrance, ext in open_edges: + connect_two_way(world, entrance, ext, player) + for entrance, ext in straight_staircases: + connect_two_way(world, entrance, ext, player) cross_dungeon(world, player) else: logging.getLogger('').error('Invalid door shuffle setting: %s' % world.doorShuffle[player]) @@ -494,9 +494,10 @@ def cross_dungeon(world, player): entrances_map, potentials, connections = determine_entrance_list(world, player) connections_tuple = (entrances_map, potentials, connections) - all_sectors = [] + all_sectors, all_regions = [], [] for key in dungeon_regions.keys(): - all_sectors.extend(convert_to_sectors(dungeon_regions[key], world, player)) + all_regions += dungeon_regions[key] + all_sectors.extend(convert_to_sectors(all_regions, world, player)) dungeon_builders = create_dungeon_builders(all_sectors, connections_tuple, world, player) for builder in dungeon_builders.values(): builder.entrance_list = list(entrances_map[builder.name]) diff --git a/DungeonGenerator.py b/DungeonGenerator.py index 08dfe884..fb07b10f 100644 --- a/DungeonGenerator.py +++ b/DungeonGenerator.py @@ -14,9 +14,6 @@ from Regions import key_only_locations, dungeon_events, flooded_keys_reverse from Dungeons import dungeon_regions, split_region_starts - - - class GraphPiece: def __init__(self): @@ -522,11 +519,7 @@ type_map = { Hook.North: Hook.South, Hook.South: Hook.North, Hook.West: Hook.East, - Hook.East: Hook.West, - Hook.NEdge: Hook.SEdge, - Hook.SEdge: Hook.NEdge, - Hook.EEdge: Hook.WEdge, - Hook.WEdge: Hook.EEdge, + Hook.East: Hook.West } @@ -542,21 +535,11 @@ hang_dir_map = { } -edge_map_back = { - Direction.North: Hook.SEdge, - Direction.South: Hook.NEdge, - Direction.West: Hook.EEdge, - Direction.East: Hook.WEdge, -} - - def hanger_from_door(door): if door.type == DoorType.SpiralStairs: return Hook.Stairs - if door.type == DoorType.Normal: + if door.type in [DoorType.Normal, DoorType.Open, DoorType.StraightStairs]: return hang_dir_map[door.direction] - if door.type == DoorType.Open: - return edge_map_back[door.direction] return None diff --git a/asm/doorrando.asm b/asm/doorrando.asm index 2392623c..52828b6a 100644 --- a/asm/doorrando.asm +++ b/asm/doorrando.asm @@ -22,7 +22,6 @@ incsrc keydoors.asm incsrc overrides.asm incsrc edges.asm incsrc math.asm -incsrc hudadditions.asm warnpc $279000 ; Data Section @@ -36,26 +35,8 @@ dw 0 DRScroll: db 0 -; Vert 0,6,0 Horz 2,0,8 -org $279010 -CoordIndex: ; Horizontal 1st -db 2, 0 ; Coordinate Index $20-$23 -OppCoordIndex: -db 0, 2 ; Swapped coordinate Index $20-$23 (minor optimization) -CameraIndex: ; Horizontal 1st -db 0, 6 ; Camera Index $e2-$ea -CamQuadIndex: ; Horizontal 1st -db 8, 0 ; Camera quadrants $600-$60f -ShiftQuadIndex: -db 2, 1 ; see ShiftQuad func (relates to $a9,$aa) -CamBoundIndex: ; Horizontal 1st -db 0, 4 ; Camera Bounds $0618-$61f -OppCamBoundIndex: ; Horizontal 1st -db 4, 0 ; Camera Bounds $0618-$61f -CamBoundBaseLine: ; X camera stuff is 1st column todo Y camera needs more testing -dw $007f, $0077 ; Left/Top camera bounds when at edge or layout frozen -dw $0007, $000b ; Left/Top camera bounds when not frozen + appropriate low byte $22/$20 (preadj. by #$78/#$6c) -dw $00ff, $010b ; Right/Bot camera bounds when not frozen + appropriate low byte $20/$22 -dw $017f, $0187 ; Right/Bot camera bound when at edge or layout frozen +org $279030 +incsrc hudadditions.asm +warnpc $279700 incsrc doortables.asm diff --git a/asm/doortables.asm b/asm/doortables.asm index 44f87bb0..96fc26d5 100644 --- a/asm/doortables.asm +++ b/asm/doortables.asm @@ -1,23 +1,3 @@ -org $279500 -TilesetTable: -; 0 1 2 3 4 5 6 7 8 9 a b c d e f --Offset Ruler -db $13,$04,$04,$06,$0d,$ff,$08,$05,$06,$07,$07,$07,$0e,$0e,$0b,$ff -db $13,$04,$04,$0d,$0d,$0d,$08,$05,$06,$07,$07,$07,$0e,$0e,$0b,$0b -db $04,$04,$04,$0d,$0d,$ff,$08,$05,$08,$09,$07,$07,$06,$ff,$0b,$06 -db $04,$05,$04,$12,$08,$08,$08,$08,$08,$09,$07,$07,$06,$0e,$0b,$0b -db $04,$04,$04,$12,$0a,$0a,$08,$ff,$ff,$09,$07,$07,$0e,$0e,$0b,$0b -db $04,$04,$04,$12,$08,$01,$09,$09,$09,$09,$07,$0e,$0e,$0e,$0b,$0b -db $04,$04,$04,$12,$0a,$0a,$08,$09,$09,$ff,$07,$0e,$0e,$0e,$0b,$ff -db $04,$04,$04,$12,$12,$12,$08,$05,$ff,$ff,$ff,$0e,$0e,$0e,$0b,$0b -db $04,$04,$04,$12,$12,$12,$ff,$05,$ff,$05,$ff,$0e,$0e,$0e,$0b,$ff -db $0c,$0c,$0c,$0c,$ff,$0e,$0e,$0c,$0c,$05,$ff,$0e,$0e,$0e,$0b,$0b -db $0c,$0c,$0c,$0c,$0d,$0e,$0e,$05,$05,$05,$05,$0a,$0a,$ff,$0b,$0b -db $04,$0c,$0c,$0c,$0d,$0d,$0d,$0d,$05,$05,$05,$0a,$0a,$ff,$0b,$0b -db $04,$0c,$0c,$0c,$0d,$0d,$0d,$0d,$05,$05,$ff,$0a,$0a,$ff,$0b,$ff -db $04,$0c,$0c,$ff,$ff,$0d,$0d,$ff,$05,$05,$05,$0a,$0a,$ff,$0b,$06 -db $04,$06,$06,$06,$06,$06,$06,$06,$06,$ff,$06,$06,$ff,$06,$06,$06 -db $06,$06,$03,$03,$03,$03,$ff,$ff,$06,$06,$06,$06,$ff,$06,$06,$06 - org $279700 KeyDoorOffset: ; 0 1 2 3 4 5 6 7 8 9 a b c d e f --Offset Ruler @@ -582,3 +562,47 @@ DungeonReminderTable: ;27f054 dw $2D50, $2D50, $2D51, $2D52, $2D54, $2D56, $2D55, $2D5A, $2D57, $2D59, $2D53, $2D58, $2D5B, $2D5C ;27f070 +; Vert 0,6,0 Horz 2,0,8 +org $27f080 +CoordIndex: ; Horizontal 1st +db 2, 0 ; Coordinate Index $20-$23 +OppCoordIndex: +db 0, 2 ; Swapped coordinate Index $20-$23 (minor optimization) +CameraIndex: ; Horizontal 1st +db 0, 6 ; Camera Index $e2-$ea +CamQuadIndex: ; Horizontal 1st +db 8, 0 ; Camera quadrants $600-$60f +ShiftQuadIndex: +db 2, 1 ; see ShiftQuad func (relates to $a9,$aa) +CamBoundIndex: ; Horizontal 1st +db 0, 4 ; Camera Bounds $0618-$61f +OppCamBoundIndex: ; Horizontal 1st +db 4, 0 ; Camera Bounds $0618-$61f +CamBoundBaseLine: ; X camera stuff is 1st column todo Y camera needs more testing +dw $007f, $0077 ; Left/Top camera bounds when at edge or layout frozen +dw $0007, $000b ; Left/Top camera bounds when not frozen + appropriate low byte $22/$20 (preadj. by #$78/#$6c) +dw $00ff, $010b ; Right/Bot camera bounds when not frozen + appropriate low byte $20/$22 +dw $017f, $0187 ; Right/Bot camera bound when at edge or layout frozen +;27f09e next free byte + +org $27f100 +TilesetTable: +; 0 1 2 3 4 5 6 7 8 9 a b c d e f --Offset Ruler +db $13,$04,$04,$06,$0d,$ff,$08,$05,$06,$07,$07,$07,$0e,$0e,$0b,$ff +db $13,$04,$04,$0d,$0d,$0d,$08,$05,$06,$07,$07,$07,$0e,$0e,$0b,$0b +db $04,$04,$04,$0d,$0d,$ff,$08,$05,$08,$09,$07,$07,$06,$ff,$0b,$06 +db $04,$05,$04,$12,$08,$08,$08,$08,$08,$09,$07,$07,$06,$0e,$0b,$0b +db $04,$04,$04,$12,$0a,$0a,$08,$ff,$ff,$09,$07,$07,$0e,$0e,$0b,$0b +db $04,$04,$04,$12,$08,$01,$09,$09,$09,$09,$07,$0e,$0e,$0e,$0b,$0b +db $04,$04,$04,$12,$0a,$0a,$08,$09,$09,$ff,$07,$0e,$0e,$0e,$0b,$ff +db $04,$04,$04,$12,$12,$12,$08,$05,$ff,$ff,$ff,$0e,$0e,$0e,$0b,$0b +db $04,$04,$04,$12,$12,$12,$ff,$05,$ff,$05,$ff,$0e,$0e,$0e,$0b,$ff +db $0c,$0c,$0c,$0c,$ff,$0e,$0e,$0c,$0c,$05,$ff,$0e,$0e,$0e,$0b,$0b +db $0c,$0c,$0c,$0c,$0d,$0e,$0e,$05,$05,$05,$05,$0a,$0a,$ff,$0b,$0b +db $04,$0c,$0c,$0c,$0d,$0d,$0d,$0d,$05,$05,$05,$0a,$0a,$ff,$0b,$0b +db $04,$0c,$0c,$0c,$0d,$0d,$0d,$0d,$05,$05,$ff,$0a,$0a,$ff,$0b,$ff +db $04,$0c,$0c,$ff,$ff,$0d,$0d,$ff,$05,$05,$05,$0a,$0a,$ff,$0b,$06 +db $04,$06,$06,$06,$06,$06,$06,$06,$06,$ff,$06,$06,$ff,$06,$06,$06 +db $06,$06,$03,$03,$03,$03,$ff,$ff,$06,$06,$06,$06,$ff,$06,$06,$06 +;27f200 + diff --git a/asm/drhooks.asm b/asm/drhooks.asm index e4a506a3..72c06a83 100644 --- a/asm/drhooks.asm +++ b/asm/drhooks.asm @@ -29,13 +29,21 @@ jsl RecordStairType : nop org $02a1e7 ;(PC: 121e7) jsl SpiralWarp - +org $029369 ; <- 11369 - Bank02.asm : 3610 (STX $0464 : STY $012E) +jsl StraightStairsAdj : nop #2 org $029383 ; <- 11384 - Bank02.asm : 3629 (.walkingDownStaircase-> ADD $20 : STA $20) jsl StraightStairsFix : nop org $0293aa ; <- 113aa - Bank02.asm : 3653 (ADD $20 : STA $20) jsl StraightStairsFix : nop -org $029396 ; <- 11384 - Bank02.asm : 3641 (LDA $01C322, X) +org $0293d1 ; <- 113d1 - Bank02.asm : 3683 (ADD $20 : STA $20 BRANCH_IOTA) +jsl StraightStairsFix : nop +org $029396 ; <- 11396 - Bank02.asm : 3641 (LDA $01C322, X) jsl StraightStairLayerFix +org $02c06d ; <- Bank02.asm : 9874 (LDX $0418, CMP.b #$02) +jsl DoorToStraight : nop +org $02941a ; <- Bank02.asm : 3748 module 7.12.11 (LDA $0464 : BNE BRANCH_$11513 : INC $B0 : RTS) +jsl StraightStairsTrapDoor : rts + ; Graphics fix org $02895d ; Bank 02 line 1812 (JSL Dungeon_LoadRoom : JSL Dungeon_InitStarTileChr : JSL $00D6F9 : INC $B0) @@ -58,6 +66,8 @@ org $00df5a ;(PC: 5f5a) PrepTransAuxGfx: org $0ffd65 ;(PC: 07fd65) Dungeon_LoadCustomTileAttr: +org $01feb0 +Dungeon_ApproachFixedColor: ;org $01fec1 ;Dungeon_ApproachFixedColor_variable: ;org $a0f972 ; Rando version diff --git a/asm/normal.asm b/asm/normal.asm index 30e19e0c..f06f3249 100644 --- a/asm/normal.asm +++ b/asm/normal.asm @@ -206,10 +206,56 @@ PrepScrollToNormal: .end rts } +StraightStairsAdj: +{ + stx $0464 : sty $012e ; what we wrote over + lda DRMode : beq + + jsr GetTileAttribute : tax + lda $11 : cmp #$12 : beq .goingNorth + lda $a2 : cmp #$51 : bne ++ + rep #$20 : lda #$0018 : !add $20 : sta $20 : sep #$20 ; special fix for throne room + jsr GetTileAttribute : tax + ++ lda StepAdjustmentDown, X : bra .end +; lda $ee : beq .end +; rep #$20 : lda #$ffe0 : !add $20 : sta $20 : sep #$20 + .goingNorth + cpx #$00 : bne ++ + lda $a0 : cmp #$51 : bne ++ + lda #$36 : bra .end ; special fix for throne room + ++ ldy $ee : cpy #$00 : beq ++ + inx + ++ lda StepAdjustmentUp, X + .end + pha : lda $0462 : and #$04 : bne ++ + pla : !add #$f6 : pha + ++ pla : !add $0464 : sta $0464 + + rtl +} + +GetTileAttribute: +{ + phk : pea.w .jslrtsreturn-1 + pea.w $02802c + jml $02c11d ; mucks with x/y sets a to Tile Attribute, I think + .jslrtsreturn + rts +} + +; 0 open edge +; 1 nrm door high +; 2 straight str +; 3 nrm door low +; 4 trap door high +; 5 trap door low (none of these exist on North direction) +StepAdjustmentUp: ; really North Stairs +db $00, $f6, $1a, $18, $16, $38 +StepAdjustmentDown: ; really South Stairs +db $d0, $f6, $10, $1a, $f0, $00 + StraightStairsFix: { lda DRMode : bne + - !add $20 : sta $20 + !add $20 : sta $20 ;what we wrote over + rtl } @@ -217,5 +263,38 @@ StraightStairLayerFix: { lda DRMode : beq + lda $ee : rtl - + lda $01c322, x : rtl + + lda $01c322, x : rtl ; what we wrote over +} + +DoorToStraight: +{ + pha + lda DRMode : beq .skip + pla : bne .end + pha + lda $a0 : cmp #$51 : bne .skip + lda #$04 : sta $4e + .skip pla + .end ldx $0418 : cmp #$02 ;what we wrote over + rtl +} + +StraightStairsTrapDoor: +{ + lda $0464 : bne + + ; reset function + phk : pea.w .jslrtsreturn-1 + pea.w $02802c + jml $028c73 ; $10D71 .reset label of Bank02 + .jslrtsreturn + lda $0468 : bne ++ + lda $a0 : cmp.b #$ac : bne .animateTraps + lda $0403 : and.b #$20 : bne .animateTraps + lda $0403 : and.b #$10 : beq ++ + .animateTraps + lda #$05 : sta $11 + inc $0468 : stz $068e : stz $0690 + ++ rtl + + jsl Dungeon_ApproachFixedColor ; what we wrote over + .end rtl } \ No newline at end of file diff --git a/asm/spiral.asm b/asm/spiral.asm index 9cef8886..deff85a1 100644 --- a/asm/spiral.asm +++ b/asm/spiral.asm @@ -1,8 +1,12 @@ RecordStairType: { - pha : lda DRMode : beq + - lda $0e : sta $045e : pla : bra .end - + pla : sta $a0 - .end lda $063d, x + pha + lda DRMode : beq .norm + lda $040c : cmp #$ff : beq .norm + lda $0e : sta $045e + cmp #$26 : beq .norm ; skipping in-floor staircases + pla : bra + + .norm pla : sta $a0 + + lda $063d, x rtl }