From 49dc0f4037ae5caef24af766ee55a816e6c1977b Mon Sep 17 00:00:00 2001 From: aerinon Date: Thu, 29 Oct 2020 15:58:05 -0600 Subject: [PATCH] DR Code Init Commit Rails for Mixed Travel --- LTTP_RND_GeneralBugfixes.asm | 2 + doorrando.asm | 43 +++ doortables.asm | 643 +++++++++++++++++++++++++++++++++++ drhooks.asm | 173 ++++++++++ edges.asm | 293 ++++++++++++++++ gfx.asm | 67 ++++ hudadditions.asm | 206 +++++++++++ keydoors.asm | 42 +++ keydropshuffle.asm | 170 +++++++++ math.asm | 66 ++++ normal.asm | 304 +++++++++++++++++ overrides.asm | 114 +++++++ roomloading.asm | 137 +++++++- scroll.asm | 206 +++++++++++ spiral.asm | 211 ++++++++++++ 15 files changed, 2674 insertions(+), 3 deletions(-) create mode 100644 doorrando.asm create mode 100644 doortables.asm create mode 100644 drhooks.asm create mode 100644 edges.asm create mode 100644 gfx.asm create mode 100644 hudadditions.asm create mode 100644 keydoors.asm create mode 100644 keydropshuffle.asm create mode 100644 math.asm create mode 100644 normal.asm create mode 100644 overrides.asm create mode 100644 scroll.asm create mode 100644 spiral.asm diff --git a/LTTP_RND_GeneralBugfixes.asm b/LTTP_RND_GeneralBugfixes.asm index a43c171..eb97868 100644 --- a/LTTP_RND_GeneralBugfixes.asm +++ b/LTTP_RND_GeneralBugfixes.asm @@ -223,6 +223,8 @@ incsrc contrib.asm org $A38000 incsrc stats/main.asm +incsrc doorrando.asm + org $308000 ; bank #$30 incsrc tables.asm warnpc $318000 diff --git a/doorrando.asm b/doorrando.asm new file mode 100644 index 0000000..e5e5706 --- /dev/null +++ b/doorrando.asm @@ -0,0 +1,43 @@ +!add = "clc : adc" +!addl = "clc : adc.l" +!sub = "sec : sbc" +!bge = "bcs" +!blt = "bcc" + +; Free RAM notes +; Normal doors use $AB-AC for scrolling indicator +; Normal doors use $FE to store the trap door indicator +; Spiral doors use $045e to store stair type +; Gfx uses $b1 to for sub-sub-sub-module thing + +; Hooks into various routines +incsrc drhooks.asm + +;Main Code +org $278000 ;138000 +db $44, $52 ;DR +DRMode: +dw 0 +DRFlags: +dw 0 +DRScroll: +db 0 +OffsetTable: +dw -8, 8 + +incsrc normal.asm +incsrc scroll.asm +incsrc spiral.asm +incsrc gfx.asm +incsrc keydoors.asm +incsrc overrides.asm +incsrc edges.asm +incsrc math.asm +incsrc hudadditions.asm +warnpc $279700 + +incsrc doortables.asm +warnpc $288000 + +; deals with own hooks +incsrc keydropshuffle.asm diff --git a/doortables.asm b/doortables.asm new file mode 100644 index 0000000..ab23c60 --- /dev/null +++ b/doortables.asm @@ -0,0 +1,643 @@ +org $279700 +KeyDoorOffset: +; 0 1 2 3 4 5 6 7 8 9 a b c d e f --Offset Ruler +dw $0000,$0001,$0003,$0000,$0006,$0000,$000b,$0000,$0000,$0000,$000c,$000d,$0010,$0011,$0012,$0000 +dw $0000,$0015,$0018,$001c,$001e,$0025,$0027,$0000,$0000,$002b,$002d,$0033,$0035,$0038,$0039,$003d +dw $003f,$0040,$0043,$0045,$0047,$0000,$004f,$0000,$0053,$0000,$0055,$005b,$0000,$0000,$005f,$0000 +dw $0060,$0062,$0064,$0065,$0066,$0068,$006e,$0074,$007a,$007c,$007e,$0081,$0000,$0082,$0086,$0088 +dw $0089,$008a,$0000,$008b,$008e,$0092,$0096,$0000,$0000,$0099,$009d,$00a2,$00a5,$00a6,$00a8,$00aa +dw $00ab,$00ad,$00af,$00b2,$0000,$0000,$00b5,$00b9,$00bf,$00c5,$00c9,$00ca,$00cc,$00ce,$00d1,$00d5 +dw $00d6,$00dc,$00e3,$00e9,$00ec,$00ed,$00ee,$00f2,$00f5,$0000,$00f7,$00f8,$00fc,$00ff,$0102,$0000 +dw $0000,$0103,$0106,$0107,$010a,$010c,$010e,$0112,$0000,$0000,$0000,$0114,$0117,$011b,$011e,$0121 +dw $0000,$0123,$0000,$0124,$0127,$0128,$0000,$012c,$0000,$0000,$0000,$012e,$0133,$0139,$013e,$0000 +dw $013f,$0140,$0141,$0146,$0000,$0149,$014b,$014d,$014f,$0150,$0000,$0153,$0156,$015a,$015d,$0161 +dw $0163,$0164,$0166,$016a,$016c,$016d,$0000,$0000,$0170,$0176,$017c,$0182,$0184,$0000,$0185,$0186 +dw $0188,$018b,$018f,$0197,$019c,$019d,$019e,$01a3,$01a4,$01a6,$01aa,$01ad,$01b3,$0000,$01bb,$01be +dw $01bf,$01c2,$01ca,$01d2,$01d9,$01da,$01dd,$01e3,$01e6,$01e7,$0000,$01ec,$01ed,$0000,$01f0,$0000 +dw $01f1,$01f3,$01f7,$0000,$0000,$01f8,$01fa,$0000,$01fd,$0200,$0203,$0204,$0206,$0000,$0000,$0000 +dw $0207 + + +org $279E00 +SpiralOffset: +; 0 1 2 3 4 5 6 7 8 9 a b c d e f --Offset Ruler +db $00,$01,$02,$00,$03,$00,$00,$04,$00,$05,$07,$00,$08,$00,$0b,$00 +db $00,$0c,$00,$00,$00,$0d,$0e,$0f,$00,$00,$11,$00,$13,$14,$15,$00 +db $00,$00,$00,$00,$00,$00,$16,$19,$1b,$00,$00,$00,$00,$00,$00,$00 +db $00,$1c,$00,$00,$1f,$00,$00,$00,$20,$00,$21,$00,$00,$00,$00,$22 +db $23,$24,$25,$00,$00,$26,$00,$00,$00,$00,$27,$00,$29,$2a,$2b,$00 +db $00,$00,$00,$2c,$2d,$00,$00,$00,$00,$00,$00,$00,$2e,$2f,$00,$30 +db $00,$00,$00,$35,$36,$00,$37,$00,$00,$00,$38,$3a,$3b,$00,$3c,$00 +db $3d,$40,$41,$00,$00,$00,$42,$45,$00,$00,$00,$00,$00,$00,$00,$49 +db $4a,$00,$00,$00,$00,$00,$00,$4b,$00,$00,$00,$00,$4f,$00,$53,$00 +db $00,$54,$00,$55,$00,$00,$00,$56,$57,$58,$00,$00,$00,$00,$59,$00 +db $5a,$00,$5b,$00,$00,$5c,$5d,$00,$00,$00,$00,$5e,$00,$00,$5f,$00 +db $60,$00,$00,$00,$00,$63,$64,$00,$00,$00,$00,$00,$65,$00,$66,$00 +db $67,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +db $6a,$6d,$6e,$00,$00,$00,$00,$00,$00,$00,$6f,$00,$00,$00,$00,$00 +db $70 + +org $279F00 +DoorOffset: +db $00,$01,$02,$00,$03,$00,$04,$00,$00,$00,$00,$00,$9A,$05,$99,$00 +db $00,$06,$07,$08,$09,$0A,$0B,$00,$00,$0C,$0D,$0E,$00,$0F,$10,$11 +db $12,$13,$14,$15,$16,$00,$17,$00,$98,$00,$18,$19,$00,$00,$1A,$00 +db $1B,$00,$1C,$1D,$1E,$1F,$20,$21,$22,$23,$24,$25,$00,$26,$27,$00 +db $96,$28,$97,$29,$2A,$2B,$2C,$00,$00,$2D,$2E,$2F,$30,$31,$32,$00 +db $33,$34,$35,$36,$00,$00,$37,$38,$39,$3A,$3B,$3C,$3D,$3E,$3F,$40 +db $41,$42,$43,$A0,$00,$00,$44,$45,$46,$00,$47,$48,$49,$4A,$4B,$00 +; 0 1 2 3 4 5 6 7 8 9 a b c d e f --Offset Ruler +db $00,$4C,$00,$00,$00,$4D,$4E,$9E,$00,$00,$00,$4F,$50,$51,$52,$53 +db $00,$54,$00,$9C,$9D,$55,$00,$00,$00,$00,$00,$56,$57,$58,$59,$00 +db $5A,$5B,$5C,$5D,$00,$5E,$5F,$00,$9B,$60,$00,$61,$62,$63,$64,$65 +db $66,$67,$68,$69,$6A,$6B,$00,$00,$6C,$6D,$6E,$6F,$70,$00,$71,$72 +db $00,$73,$74,$75,$76,$77,$78,$79,$7A,$7B,$7C,$7D,$7E,$00,$7F,$80 +db $00,$81,$82,$83,$84,$85,$86,$87,$88,$89,$00,$8A,$8B,$00,$8C,$00 +db $00,$8D,$8E,$00,$00,$8F,$90,$00,$91,$92,$93,$94,$95,$00,$00,$00 +db $9f + +org $27A000 +DoorTable: +;; NW 00 N 01 N 02 WN 00 W 01 WS 02 SW 00 S 01 SE 02 EN 00 E 01 ES 02 - Door ruler +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Default/Garbage row +dw $0003, $0003, $0003, $0450, $0003, $0003, $0003, $0003, $0003, $0452, $0003, $0003 ; HC Back Hall (x01) +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Sewer Switches (x02) +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Crystaroller +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Arghus +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Aga 2 +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Sewer Secret Room +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Sanc +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TR Pokey +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TR Lava Pipe +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TR Pipes n Ledge +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Swap Canal +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Pod dark Maze +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Pod Bridge +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Pod Eye Statue +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT Pre Aga +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Ice Cross +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Ice BK +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; x20 Aga1 +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Sewer Key Rat +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Sewer Waters +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TR Eye Entrance +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TR Chest Entrance +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Swamp Statue +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; PoD Arena (x2a) +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; PoD Statue (x2b) +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Ice Compass +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; x30 Aga's Altar +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Dark Cross +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Lanmolas +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Swamp West Wing +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Flooded Key +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Swamp Main Hub (x36) +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Swamp Hammer Time +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Swamp First Basement +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Drop to the Moth +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Pod 3 Catwalks +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Pod Conveyor +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT Minihelma +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Ice Conveyor +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Sewers +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Desert Torches +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TT Big Chest +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TT Cellblock +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Swamp Compass Loop +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Skull3 Torches +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Pod Entrance +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Pod Mimics 1 +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT Conveyor Ice +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT Moldorm +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; IPBJ +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0401, $0003, $0003 ; HC West Hall (x50) +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; HC Throne Room (x51) +dw $0003, $0003, $0003, $0401, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; HC East Hall (x52) +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Desert Tiles 1 +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Skull 2 Left Entrance +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Skull 2 Right Entrance +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Skull 1 Entrance +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Skull 3 Entrance +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Helmasaur +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT Spike Switch +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT Cannonball +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Gauntlet 1 +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Ice Choice Cross +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Iced U +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; HC West Lobby (x60) +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; HC Main Lobby (x61) +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; HC East Lobby (x62) +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; x66 Swamp Waterfall +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; x67 Skull 1 Left Drop +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; x68 Skull 1 Pinball +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; x6a Pod Rupees +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; x6b GT Mimics +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; x6c GT Lanmolas +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; x6d Gauntlet 2 +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; x6e Ice Gators +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; HC Armory +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Desert BK Chest +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Swamp Flooded Chests +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT DM's Tile +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT Randoroom +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT Warp Maze +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Ice Freezors +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Ice Hookpit +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; HC Catawalk +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Desert Right Entrance +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT Left +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT Hopeful Torch +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT Right +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Ice Lonely Freezor +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Vitreous (x90) +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Mire Rain +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Mire Dark Crystals +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Mire Blockswitch +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT Fallbridge +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT Torch Cross +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Eastern Darkness +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT Warp Maze 2 +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT Invis Bridge +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT Compass Room +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Ice Big Chests +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Icy Pots +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Mire Pre-Vitreous (xa0) +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Mire Fishbone +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Mire Bridges +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Mire Corner +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Trinexx (xa4) +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT Wizzrobes +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Eastern Compass (xa8) +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Eastern Courtyard (xa9) +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Eastern Map (xaa) +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TT Switch +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Blind +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Iced T +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Ice Slipway +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Mire Warpzone +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Mire ???? +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Mire Spikes +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TR Refill +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TR Dark Maze +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TR Chainchomp +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TR Rollers +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Eastern Big Key +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Easter Cannonball +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Eastern Dark Circle +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TT Hellway +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TT Bossway +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Ice Blockswitch +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Ice Backtracker +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Mire Tiles +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Mire Main Hub +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Mire Big Chest +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TR Switch Maze +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TR Narrow +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TR Early Hub +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TR Floating Torches +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Armos +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Eastern Entrance +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TT NW Quad +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TT NE Quad +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Ice Boss Drop +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Mire BK +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Mire 2 +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TR Laser Bridge +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TR Main Entrance +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Eastern Eyegores +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Eastern Attic Switches +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Eastern Attic Start +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TT Entrance Quad +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; TT SE Quad +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Aga 6F +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Sewers Rope +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Swamp Lobby +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Ice Lobby +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; GT Lobby +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Mire Lobby +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Desert West Lobby +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Desert Main Lobby +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Hera Lobby +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Tower Lobby +dw $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003, $0003 ; Desert Back Lobby +; this should end at 27AF18 about (160 * 24 bytes = 3840 or F18) +; some values you can hardcode for spirals +;dw $0070, $36a0 ; ->HC Stairwell +;dw $0072, $4ff8 ; ->HC Map Room +;dw $0080, $1f50 ; ->zelda's cellblock + +org $27B000 +SpiralTable: ;113 4 byte entries - should end at 27B44C +dw $0203, $8080 ;null row +dw $0203, $8080 ;HC Backhallway +dw $0203, $8080 ;Sewer Pull +dw $0203, $8080 ;Crystaroller +dw $0203, $8080 ;Moldorm +dw $0203, $8080, $0203, $8080 ;Pod Basement +dw $0203, $8080 ;Pod Stalfos +dw $0203, $8080, $0203, $8080, $0203, $8080 ;GT Entrance +dw $0203, $8080 ;Ice Entrance +dw $0203, $8080 ;Escape +dw $0203, $8080 ;TR Pipe Ledge +dw $0203, $8080 ;Swamp Way +dw $0203, $8080, $0203, $8080 ;Hera Fallplace +dw $0203, $8080, $0203, $8080 ;PoD Bridge +dw $0203, $8080 ;GT Ice +dw $0203, $8080 ;GT F8 +dw $0203, $8080 ;Ice Cross +dw $0203, $8080, $0203, $8080, $0203, $8080 ;Swamp Statue +dw $0203, $8080, $0203, $8080 ;Hera Big +dw $0203, $8080 ;Swamp Ent +dw $0203, $8080, $0203, $8080, $0203, $8080 ;Hera Startiles (middle value unused) +dw $0203, $8080 ;West Swamp +dw $0203, $8080 ;Swamp Basement +dw $0203, $8080 ;Pod Drops +dw $0203, $8080 ;Ice Hammer +dw $0203, $8080 ;Aga Guards +dw $0203, $8080 ;Sewer Begin +dw $0203, $8080 ;Sewer Rope +dw $0203, $8080 ;TT Cellblock +dw $0203, $8080, $0203, $8080 ;Pod Entrance +dw $0203, $8080 ;GT Icespike +dw $0203, $8080 ;GT Moldorm +dw $0203, $8080 ;IPBJ +dw $0203, $8080 ;Desert Prep +dw $0203, $8080 ;Swamp Attic +dw $0203, $8080 ;GT Cannonball +dw $0203, $8080 ;GT Gauntlet1 +dw $0203, $8080, $0203, $8080, $0203, $8080, $0203, $8080, $0203, $8080 ;Ice U (1st three values unused) +dw $0203, $8080 ;Desert Back +dw $0203, $8080 ;TT Attic L +dw $0203, $8080 ;Swamp Waterf +dw $0203, $8080 ;Pod Rupees +dw $0203, $8080 ;Pod Rupees +dw $0203, $8080 ;GT Mimics +dw $0203, $8080 ;GT Lanmo +dw $0203, $8080 ;Ice Gators +dw $0203, $8080, $0203, $8080, $0203, $8080 ;HC Tiny (first value placeholder) +dw $0203, $8080 ;HC Boomer +dw $0203, $8080 ;HC Pits1 +dw $0203, $8080, $0203, $8080, $0203, $8080 ;Swamp Sunken +dw $0203, $8080, $0203, $8080, $0203, $8080, $0203, $8080 ;Hera Entrance (first value unused) +dw $0203, $8080 ;Ice Hookshot +dw $0203, $8080 ;HC Cellblock +dw $0203, $8080, $0203, $8080, $0203, $8080, $0203, $8080 ;Hera Basement (first and third values unused) +dw $0203, $8080, $0203, $8080, $0203, $8080, $0203, $8080 ;GT Circle (third value unused) +dw $0203, $8080 ;Ice Last Freeze +dw $0203, $8080 ;Mire Drops +dw $0203, $8080 ;Mire Block +dw $0203, $8080 ;Mire Attic +dw $0203, $8080 ;Mire Entrance +dw $0203, $8080 ;East Dark +dw $0203, $8080 ;Ice Big +dw $0203, $8080 ;Mire Previtreous +dw $0203, $8080 ;Mire Bridges +dw $0203, $8080 ;GT Wizzrobes +dw $0203, $8080 ;GT Spikepit +dw $0203, $8080 ;TT Switch +dw $0203, $8080 ;Ice T +dw $0203, $8080, $0203, $8080, $0203, $8080 ;Tower Usains (2nd value unused) +dw $0203, $8080 ;TR PlatMaze +dw $0203, $8080 ;TR Chainchomp +dw $0203, $8080 ;TT Bossway +dw $0203, $8080 ;Ice FallZone +dw $0203, $8080, $0203, $8080, $0203, $8080 ;Tower Dark2 (2nd value unused) +dw $0203, $8080, $0203, $8080, $0203, $8080 ;Tower Dark1 (2nd value unused) +dw $0203, $8080 ;Mire BK Thang +dw $0203, $8080 ;Mire2 +dw $0203, $8080 ;East Attic Start +dw $0203, $8080 ;Tower Entrance + + +org $27C000 ;ends around 27C418 +PairedDoorTable: +dw $0000 ; the bad template +dw $0000,$0000 +dw $0000,$0000,$0000 +dw $0000,$0000,$0000,$0000,$0000 +dw $0000 +dw $0000 +dw $0000,$0000,$0000 +dw $0000 +dw $0000 +dw $0000,$0000,$0000 + +dw $0000,$0000,$8021 +dw $0000,$0000,$0000,$0000 +dw $4014,$0000 +dw $8024,$8013,$0000,$0000,$0000,$0000,$0000 +dw $0000,$0000 +dw $0000,$0000,$0000,$0000 +dw $201a,$401a +dw $0000,$4019,$8019,$402a,$0000,$0000 +dw $0000,$0000 +dw $0000,$0000,$0000 +dw $0000 +dw $0000,$0000,$0000,$0000 +dw $0000,$0000 + +dw $0000 +dw $2011,$0000,$0000 +dw $8032,$0000 +dw $0000,$0000 +dw $8014,$0000,$0000,$0000,$0000,$0000,$0000,$0000 +dw $4036,$0000,$0000,$0000 +dw $0000,$0000 +dw $0000,$101a,$402b,$0000,$0000,$0000 +dw $0000,$202a,$0000,$0000 +dw $0000 + +dw $0000,$0000 +dw $0000,$0000 +dw $8022 +dw $0000 +dw $0000,$0000 +dw $2036,$0000,$0000,$0000,$0000,$0000 +dw $8037,$8026,$8035,$0000,$0000,$0000 +dw $8036,$8038,$0000,$4038,$0000,$0000 +dw $4037,$1037 +dw $0000,$0000 +dw $204a,$0000,$0000 +dw $0000 +dw $0000,$0000,$804d,$0000 +dw $0000,$404e +dw $0000 + +dw $0000 +dw $0000 +dw $0000,$0000,$2053 +dw $0000,$0000,$0000,$0000 +dw $0000,$0000,$0000,$0000 +dw $0000,$0000,$0000 +dw $0000,$0000,$8059,$0000 +dw $0000,$0000,$803a,$0000,$0000 +dw $0000,$0000,$0000 +dw $0000 +dw $203d,$0000 +dw $0000,$403e +dw $0000 ; this is the odd extra room - shouldn't be used + +dw $0000,$0000 +dw $0000,$0000 +dw $0000,$0000,$0000 +dw $0000,$0000,$2043 +dw $0000,$0000,$0000,$0000 +dw $0000,$0000,$4058,$0000,$0000,$0000 +dw $0000,$2057,$4068,$0000,$0000,$0000 +dw $2049,$0000,$0000,$0000 +dw $0000 +dw $806b,$0000 +dw $0000,$0000 +dw $0000,$0000,$0000 +dw $805f,$0000,$0000,$0000 +dw $805e + +dw $0000,$0000,$0000,$0000,$0000,$0000 +dw $0000,$0000,$0000,$0000,$0000,$0000,$0000 +dw $0000,$0000,$0000,$0000,$0000,$0000 +dw $0000,$0000,$0000 +dw $0000 +dw $0000 +dw $0000,$0000,$0000,$0000 +dw $0000,$0000,$0000 +dw $0000,$2058 +dw $0000 +dw $805b,$0000,$0000,$0000 +dw $0000,$0000,$0000 +dw $0000,$0000,$0000 +dw $0000 + +dw $0000,$0000,$0000 +dw $0000 +dw $0000,$0000,$0000 +dw $0000,$0000 +dw $0000,$0000 +dw $0000,$0000,$0000,$0000 +dw $0000,$0000 +dw $0000,$207c,$0000 +dw $0000,$407d,$407b,$0000 +dw $0000,$407c,$0000 +dw $808e,$0000,$0000 +dw $0000,$0000 + +dw $0000 +dw $0000,$0000,$0000 +dw $0000 +dw $0000,$0000,$0000,$0000 +dw $0000,$0000 +dw $0000,$0000,$0000,$0000,$0000 +dw $0000,$0000,$0000,$0000,$0000,$0000 +dw $0000,$0000,$0000,$0000,$0000 +dw $807e + +dw $0000 +dw $0000 +dw $0000,$0000,$0000,$0000,$0000 +dw $0000,$0000,$0000 +dw $0000,$0000 +dw $0000,$0000 +dw $0000,$0000 +dw $0000 +dw $0000,$20a9,$0000 +dw $0000,$0000,$0000 +dw $0000,$0000,$0000,$0000 +dw $0000,$0000,$0000 +dw $0000,$0000,$0000,$0000 +dw $0000,$0000 + +dw $0000 +dw $40b1,$0000 +dw $80b2,$0000,$0000,$0000 +dw $0000,$0000 +dw $0000 +dw $0000,$0000,$0000 +dw $0000,$0000,$80b8,$0000,$0000,$0000 +dw $0000,$0000,$4099,$0000,$0000,$0000 +dw $0000,$0000,$0000,$0000,$0000,$0000 +dw $0000,$0000 +dw $0000 +dw $0000 +dw $0000,$0000 + +dw $0000,$0000,$0000 +dw $0000,$80a1,$0000,$0000 +dw $80a2,$0000,$0000,$0000,$0000,$0000,$0000,$0000 +dw $0000,$0000,$0000,$0000,$0000 +dw $0000 +dw $0000 +dw $0000,$0000,$80c6,$0000,$0000 +dw $0000 +dw $20a8,$0000 +dw $80ba,$0000,$0000,$0000 +dw $80b9,$0000,$0000 +dw $0000,$0000,$0000,$0000,$0000,$0000 +dw $0000,$80cc,$0000,$40cc,$0000,$0000,$0000,$0000 +dw $0000,$80bf,$0000 +dw $40be + +dw $0000,$0000,$0000 +dw $0000,$40c2,$0000,$0000,$0000,$0000,$0000,$0000 +dw $80c3,$40c1,$0000,$0000,$0000,$0000,$0000,$0000 +dw $80c2,$0000,$0000,$0000,$0000,$0000,$0000 +dw $80c5 +dw $80c4,$0000,$0000 +dw $20b6,$0000,$0000,$0000,$0000,$0000 +dw $0000,$0000,$0000 +dw $0000 +dw $0000,$0000,$0000,$0000,$0000 +dw $20cc +dw $40bc,$10bc,$80cb +dw $0000 + +dw $0000,$0000 +dw $0000,$0000,$0000,$0000 +dw $0000 +dw $0000,$0000 +dw $0000,$0000,$0000 +dw $0000,$0000,$0000 +dw $0000,$0000,$0000 +dw $0000 +dw $0000,$0000 +dw $0000 +dw $0000,$0000,$0000,$0000 +dw $ffff ; indicates the end - we can drop this + +; Edge Transition Table (Target Room, Flags, MultiDiv ratio for edges) +org $27C500 ;ends around 27C5F(9) 4 bytes would be 27C649 +;I kind of want to split the 3rd byte into two +NorthOpenEdge: +db $00,$80,$11, $00,$80,$11, $00,$80,$11, $00,$80,$11 +db $00,$80,$11, $00,$80,$11, $00,$80,$11, $00,$80,$11 +db $00,$80,$11, $00,$80,$11, $00,$80,$11 +SouthOpenEdge: +db $00,$80,$11, $00,$80,$11, $00,$80,$11, $00,$80,$11 +db $00,$80,$11, $00,$80,$11, $00,$80,$11, $00,$80,$11 +db $00,$80,$11, $00,$80,$11, $00,$80,$11 +WestOpenEdge: +db $00,$80,$11, $00,$80,$11, $00,$80,$11 +db $00,$80,$11, $00,$80,$11, $00,$80,$11 +db $00,$80,$11, $00,$80,$11, $00,$80,$11 +EastOpenEdge: +db $00,$80,$11, $00,$80,$11, $00,$80,$11 +db $00,$80,$11, $00,$80,$11, $00,$80,$11 +db $00,$80,$11, $00,$80,$11, $00,$80,$11 +; Edge Info Table (Midpoint, Width, Min Coord) +; I kind of want to add a fourth byte to help indicate quadrant info on min coord +NorthEdgeInfo: +db $a8,$10,$a0, $2c,$08,$28 ;HC +db $b8,$20,$a8 ; DP West Wing +db $38,$20,$28, $f8,$a0,$a8, $b8,$20,$a8 ; DP Main +db $78,$20,$68 ; DP East Wing +db $f8,$10,$f0, $7c,$18,$70 ; TT Lobby +db $74,$18,$68, $f8,$10,$f0 ; TT Compass +SouthEdgeInfo: +db $a8,$10,$a0, $2c,$08,$28 ; HC +db $b8,$20,$a8 ; DP Sandworm +db $38,$20,$28, $f8,$a0,$a8, $b8,$20,$a8 ; DP North Hall & Dead End +db $78,$20,$68 ; DP Arrow Pot +db $f8,$10,$f0, $7c,$18,$70 ; TT Ambush +db $74,$18,$68, $f8,$10,$f0 ; TT BK Corner +WestEdgeInfo: +db $78,$30,$60 ; TT Attic +db $40,$20,$30 ; DP North Hall +db $40,$20,$30 ; DP Arrow Pot +db $84,$18,$78, $68,$10,$60 ; HC South +db $a0,$a0,$50 ; DP East Wing +db $58,$50,$30, $98,$50,$70 ; TT BK Corner +db $58,$50,$30 ; TT Compass +EastEdgeInfo: +db $78,$30,$60 ; TT Attic +db $40,$20,$30 ; DP Sandworm +db $40,$20,$30 ; DP North Hall +db $68,$10,$60, $84,$18,$78 ; HC Guards +db $a0,$a0,$50 ; DP Main Lobby +db $58,$50,$30, $98,$50,$70 ; TT Ambush +db $58,$50,$30 ; TT Nook +MultDivInfo: ; (1, 2, 3, 4, 5, 6, 10, 20) +db $01, $02, $03, $04, $05, $06, $0a, $14 +; indices: 0-7 + + +; dungeon tables +; HC HC EP DP AT SP PD MM SW IP TH TT TR GT +org $27f000 +CompassBossIndicator: +dw $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 +TotalKeys: ;27f01c +db $04, $04, $02, $04, $04, $06, $06, $06, $05, $06, $01, $03, $06, $08 +ChestKeys: ;27f02a +db $01, $01, $00, $01, $02, $01, $06, $03, $03, $02, $01, $01, $04, $04 +BigKeyStatus: ;27f038 (status 2 indicate BnC guard) +dw $0002, $0002, $0001, $0001, $0000, $0001, $0001, $0001, $0001, $0001, $0001, $0001, $0001, $0001 +DungeonReminderTable: ;27f054 +dw $2D50, $2D50, $2D51, $2D52, $2D54, $2D56, $2D55, $2D5A, $2D57, $2D59, $2D53, $2D58, $2D5B, $2D5C +TotalLocationsLow: ;27f070 +db $08, $08, $06, $06, $02, $00, $04, $08, $08, $08, $06, $08, $02, $07 +TotalLocationsHigh: ;27f07e +db $00, $00, $00, $00, $00, $01, $01, $00, $00, $00, $00, $00, $01, $02 +;27F08C + +; Vert 0,6,0 Horz 2,0,8 +org $27f090 +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 +;27f0ae 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 +PaletteTable: +db $21,$00,$00,$07,$00,$08,$00,$00,$07,$00,$00,$00,$00,$00,$00,$21 +db $21,$00,$00,$00,$00,$00,$00,$00,$07,$00,$00,$00,$00,$00,$00,$00 +db $00,$00,$00,$00,$00,$00,$00,$00,$00,$0e,$00,$00,$07,$00,$00,$07 +db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$07,$00,$00,$00 +db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$13 +db $00,$00,$00,$00,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +; 0 1 2 3 4 5 6 7 8 9 a b c d e f --Offset Ruler +db $00,$00,$00,$00,$00,$00,$00,$06,$00,$00,$00,$00,$00,$00,$00,$00 +db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 +db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$14,$20 +db $00,$07,$20,$20,$07,$07,$07,$07,$07,$20,$20,$07,$20,$20,$20,$20 +db $07,$07,$02,$02,$02,$02,$07,$07,$07,$20,$20,$07,$20,$20,$20,$07 + +;27f300 diff --git a/drhooks.asm b/drhooks.asm new file mode 100644 index 0000000..66d283a --- /dev/null +++ b/drhooks.asm @@ -0,0 +1,173 @@ +org $02b5c4 ; -- moving right routine 135c4 +jsl WarpRight +org $02b665 ; -- moving left routine +jsl WarpLeft +org $02b713 ; -- moving down routine +jsl WarpDown +org $02b7b4 ; -- moving up routine +jsl WarpUp +org $02bd80 +jsl AdjustTransition +nop + +;turn off linking doors -- see .notRoomLinkDoor label in Bank02.asm +org $02b5a8 ; <- 135a8 - Bank02.asm : 8368 (LDA $7EC004 : STA $A0) +jsl CheckLinkDoorR +bcc NotLinkDoor1 +org $02b5b6 +NotLinkDoor1: +org $02b649 ; <- 135a8 - Bank02.asm : 8482 (LDA $7EC004 : STA $A0) +jsl CheckLinkDoorL +bcc NotLinkDoor2 +org $02b657 +NotLinkDoor2: + + +; Staircase routine +org $01c3d4 ; <- c3d4 - Bank01.asm : 9762-4 (Dungeon_DetectStaircase-> STA $A0 : LDA $063D, X) +jsl RecordStairType : nop +org $02a1e7 ;(PC: 121e7) +jsl SpiralWarp + +org $0291b3 ; <- Bank02.asm : 3303 (LDA $0462 : AND.b #$04) +jsl SpiralPriorityHack : nop +org $0290f9 ; <- Bank02.asm : 3188 (LDA $0462 : AND.b #$04) +jsl SpiralPriorityHack : nop + +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 $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) +Splicer: +jsl GfxFixer +lda $b1 : beq .done +rts +nop #5 +.done + +org $01b618 ; Bank01.asm : 7963 Dungeon_LoadHeader (REP #$20 : INY : LDA [$0D], Y) +nop : jsl OverridePaletteHeader + +org $00d377 ;Bank 00 line 3185 +DecompDungAnimatedTiles: +org $00fda4 ;Bank 00 line 8882 +Dungeon_InitStarTileCh: +org $00d6ae ;(PC: 56ae) +LoadTransAuxGfx: +org $00d739 ; +LoadTransAuxGfx_Alt: +org $00df5a ;(PC: 5f5a) +PrepTransAuxGfx: +org $0ffd65 ;(PC: 07fd65) +Dungeon_LoadCustomTileAttr: +org $01feb0 +Dungeon_ApproachFixedColor: +;org $01fec1 +;Dungeon_ApproachFixedColor_variable: +;org $a0f972 ; Rando version +;LoadRoomHook: +org $1bee74 ;(PC: 0dee74) +Palette_DungBgMain: +org $1bec77 +Palette_SpriteAux3: +org $1becc5 +Palette_SpriteAux2: +org $1bece4 +Palette_SpriteAux1: + + +org $0DFA53 +jsl.l LampCheckOverride +org $028046 ; <- 10046 - Bank02.asm : 217 (JSL EnableForceBlank) (Start of Module_LoadFile) +jsl.l OnFileLoadOverride +org $07A93F ; < 3A93F - Bank07.asm 6548 (LDA $8A : AND.b #$40 - Mirror checks) +jsl.l MirrorCheckOverride + +org $05ef47 +Sprite_HeartContainer_Override: ;sprite_heart_upgrades.asm : 96-100 (LDA $040C : CMP.b #$1A : BNE .not_in_ganons_tower) +jsl GtBossHeartCheckOverride : bcs .not_in_ganons_tower +nop : stz $0dd0, X : rts +.not_in_ganons_tower + + +;org $208206 +org $20820E +jsl MirrorCheckOverride2 +;org $208270 +org $20827C +jsl MirrorCheckOverride2 +org $07a955 ; <- Bank07.asm : around 6564 (JP is a bit different) (STZ $05FC : STZ $05FD) +jsl BlockEraseFix +nop #2 + +org $02b82a +jsl FixShopCode + +org $1ddeea ; <- Bank1D.asm : 286 (JSL Sprite_LoadProperties) +jsl VitreousKeyReset + +org $1ed024 ; f5024 sprite_guruguru_bar.asm : 27 (LDA $040C : CMP.b #$12 : INY #2 +jsl GuruguruFix : bra .next +nop #3 +.next + +org $028fc9 +nop #2 : jsl BlindAtticFix + +org $028409 +jsl SuctionOverworldFix + +; also rando's hooks.asm line 1360 +; 106e4e -> goes to a0ee4e +;org $a0ee8a ; <- 6FC4C - headsup_display.asm : 836 (LDA $7EF36E : AND.w #$00FF : ADD.w #$0007 : AND.w #$FFF8 : TAX) +org $a0eeab +jsl DrHudOverride +org $0ded04 ; <- rando's hooks.asm line 2192 - 6ED04 - equipment.asm : 1963 (REP #$30) +jsl DrHudDungeonItemsAdditions +;org $098638 ; rando's hooks.asm line 2192 +;jsl CountChestKeys +org $06D192 ; rando's hooks.asm line 457 +jsl CountAbsorbedKeys +; rando's hooks.asm line 1020 +;org $05FC7E ; <- 2FC7E - sprite_dash_item.asm : 118 (LDA $7EF36F : INC A : STA $7EF36F) +;jsl CountBonkItem + +org $019dbd ; <- Bank01.asm : 4465 of Object_Draw8xN (LDA $9B52, Y : STA $7E2000, X) +jsl CutoffEntranceRug : bra .nextTile : nop +.nextTile + +; These two, if enabled together, have implications for vanilla BK doors in IP/Hera/Mire +; IPBJ is common enough to consider not doing this. Mire is not a concern for vanilla - maybe glitched modes +; Hera BK door back can be seen with Pot clipping - likely useful for no logic seeds + +;Kill big key (1e) check for south doors +;org $1aa90 +;DontCheck: +;bra .done +;nop #3 +;.done + +;Enable south facing bk graphic +;org $4e24 +;dw $2ac8 + +org $01b714 ; PC: b714 +OpenableDoors: +jsl CheckIfDoorsOpen +bcs .normal +rts +.normal diff --git a/edges.asm b/edges.asm new file mode 100644 index 0000000..2b9c222 --- /dev/null +++ b/edges.asm @@ -0,0 +1,293 @@ +HorzEdge: + cpy #$ff : beq + + jsr DetectWestEdge : ldy #$02 : bra ++ + + jsr DetectEastEdge + ++ cmp #$ff : beq + + sta $00 : asl : !add $00 : tax + cpy #$ff : beq ++ + jsr LoadWestData : bra .main + ++ jsr LoadEastData + .main + jsr LoadEdgeRoomHorz + sec : rts + + clc : rts + +VertEdge: + cpy #$ff : beq + + jsr DetectNorthEdge : bra ++ + + jsr DetectSouthEdge + ++ cmp #$ff : beq + + sta $00 : asl : !add $00 : tax + cpy #$ff : beq ++ + jsr LoadNorthData : bra .main + ++ jsr LoadSouthData + .main + jsr LoadEdgeRoomVert + sec : rts + + clc : rts + +LoadEdgeRoomHorz: + lda $03 : sta $a0 + sty $06 + and.b #$0f : asl a : !sub $23 : !add $06 : sta $02 + ldy #$00 : jsr ShiftVariablesMainDir + + lda $04 : and #$80 : bne .edge + lda $04 : sta $01 ; load up flags in $01 + jsr PrepScrollToNormal + bra .scroll + + .edge + lda $04 : and #$10 : beq + + lda #$01 + + sta $ee ; layer stuff + + jsr MathHorz + + .scroll + jsr ScrollY + rts + +LoadEdgeRoomVert: + lda $03 : sta $a0 + sty $06 + and.b #$f0 : lsr #3 : !sub $21 : !add $06 : sta $02 + ldy #$01 : jsr ShiftVariablesMainDir + + lda $04 : and #$80 : bne .edge + lda $04 : sta $01 ; load up flags in $01 + jsr PrepScrollToNormal + bra .scroll + + .edge + lda $04 : and #$10 : beq + + lda #$01 + + sta $ee ; layer stuff + + jsr MathVert + lda $03 + + .scroll + jsr ScrollX + rts + + +MathHorz: + jsr MathStart : lda $20 + jsr MathMid : and #$0040 + jsr MathEnd + rts + +MathVert: + jsr MathStart : lda $22 + jsr MathMid : and #$0020 + jsr MathEnd + rts + +MathStart: + rep #$30 + lda $08 : and #$00ff : sta $00 + rts + +MathMid: + and #$01ff : !sub $00 : and #$00ff : sta $00 + ; nothing should be bigger than $a0 at this point + + lda $05 : and #$00f0 : lsr #4 : tax + lda MultDivInfo, x : and #$00ff : tay + lda $00 : jsr MultiplyByY : sta $02 + + lda $07 : and #$00ff : jsr MultiplyByY : tax + + lda $05 : and #$000f : tay + lda MultDivInfo, y : and #$00ff : tay + lda $02 : jsr DivideByY : sta $00 + lda $0c : and #$00ff : sta $02 + lda $04 + rts + +MathEnd: + beq + + lda #$0100 + + !add $02 : !add $00 + sta $04 + sep #$30 + rts + +; don't need midpoint of edge Link is leaving (formerly in $06 - used by dir indicator) +; don't need width of edge Link is going to (currently in $0b) +LoadNorthData: + lda NorthOpenEdge, x : sta $03 : inx ; target room + lda NorthEdgeInfo, x : sta $07 ; needed for maths - (divide by 2 anyway) + lda NorthOpenEdge, x : sta $04 : inx ; bit field + lda NorthEdgeInfo, x : sta $08 ; needed for maths + lda NorthOpenEdge, x : sta $05 ; ratio + lda $04 : jsr LoadSouthMidpoint : inx ; needed now, and for nrml transition + lda SouthEdgeInfo, x : sta $0b : inx ; probably not needed todo: remove + lda SouthEdgeInfo, x : sta $0c ; needed for maths + rts + +LoadSouthMidpoint: + and #$0f : sta $00 : asl : !add $00 : tax + lda SouthEdgeInfo, x : sta $0a ; needed now, and for nrml transition + rts + +LoadSouthData: + lda SouthOpenEdge, x : sta $03 : inx + lda SouthEdgeInfo, x : sta $07 + lda SouthOpenEdge, x : sta $04 : inx + lda SouthEdgeInfo, x : sta $08 + lda SouthOpenEdge, x : sta $05 + lda $04 : jsr LoadNorthMidpoint : inx + lda NorthEdgeInfo, x : sta $0b : inx + lda NorthEdgeInfo, x : sta $0c + rts + +LoadNorthMidpoint: + and #$0f : sta $00 : asl : !add $00 : tax + lda NorthEdgeInfo, x : sta $0a ; needed now, and for nrml transition + rts + +LoadWestData: + lda WestOpenEdge, x : sta $03 : inx + lda WestEdgeInfo, x : sta $07 + lda WestOpenEdge, x : sta $04 : inx + lda WestEdgeInfo, x : sta $08 + lda WestOpenEdge, x : sta $05 + lda $04 : jsr LoadEastMidpoint : inx + lda EastEdgeInfo, x : sta $0b : inx + lda EastEdgeInfo, x : sta $0c + rts + +LoadEastMidpoint: + and #$0f : sta $00 : asl : !add $00 : tax + lda EastEdgeInfo, x : sta $0a ; needed now, and for nrml transition + rts + +LoadEastData: + lda EastOpenEdge, x : sta $03 : inx + lda EastEdgeInfo, x : sta $07 + lda EastOpenEdge, x : sta $04 : inx + lda EastEdgeInfo, x : sta $08 + lda EastOpenEdge, x : sta $05 + lda $04 : jsr LoadWestMidpoint : inx + lda WestEdgeInfo, x : sta $0b : inx + lda WestEdgeInfo, x : sta $0c + + +LoadWestMidpoint: + and #$0f : sta $00 : asl : !add $00 : tax + lda WestEdgeInfo, x : sta $0a ; needed now, and for nrml transition + rts + + +DetectNorthEdge: + ldx #$ff + lda $a2 + cmp #$82 : bne + + lda $22 : cmp #$50 : bcs ++ + ldx #$01 : bra .end + ++ ldx #$00 : bra .end + + cmp #$83 : bne + + ldx #$02 : bra .end + + cmp #$84 : bne + + lda $a9 : beq ++ + lda $22 : cmp #$78 : bcs +++ + ldx #$04 : bra .end + +++ ldx #$05 : bra .end + ++ lda $22 : cmp #$78 : bcs ++ + ldx #$03 : bra .end + ++ ldx #$04 : bra .end + + cmp #$85 : bne + + ldx #$06 : bra .end + + cmp #$db : bne + + lda $a9 : beq ++ + lda $22 : beq ++ + ldx #$08 : bra .end + ++ ldx #$07 : bra .end + + cmp #$dc : bne .end + lda $a9 : bne ++ + lda $22 : cmp #$b0 : bcs ++ + ldx #$09 : bra .end + ++ ldx #$0a + .end txa : rts + +DetectSouthEdge: + ldx #$ff + lda $a2 + cmp #$72 : bne + + lda $22 : cmp #$50 : bcs ++ + ldx #$01 : bra .end + ++ ldx #$00 : bra .end + + cmp #$73 : bne + + ldx #$02 : bra .end + + cmp #$74 : bne + + lda $a9 : beq ++ + lda $22 : cmp #$78 : bcs +++ + ldx #$04 : bra .end + +++ ldx #$05 : bra .end + ++ lda $22 : cmp #$78 : bcs ++ + ldx #$03 : bra .end + ++ ldx #$04 : bra .end + + cmp #$75 : bne + + ldx #$06 : bra .end + + cmp #$cb : bne + + lda $a9 : beq ++ + lda $22 : beq ++ + ldx #$08 : bra .end + ++ ldx #$07 : bra .end + + cmp #$cc : bne .end + lda $a9 : bne ++ + lda $22 : cmp #$b0 : bcs ++ + ldx #$09 : bra .end + ++ ldx #$0a + .end txa : rts + +DetectWestEdge: + ldx #$ff + lda $a2 + cmp #$65 : bne + + ldx #$00 : bra .end + + cmp #$74 : bne + + ldx #$01 : bra .end + + cmp #$75 : bne + + ldx #$02 : bra .end + + cmp #$82 : bne + + lda $aa : beq ++ + ldx #$03 : bra .end + ++ ldx #$04 : bra .end + + cmp #$85 : bne + + ldx #$05 : bra .end + + cmp #$cc : bne + + lda $aa : beq ++ + ldx #$06 : bra .end + ++ ldx #$07 : bra .end + + cmp #$dc : bne .end + ldx #$08 + .end txa : rts + +DetectEastEdge: + ldx #$ff + lda $a2 + cmp #$64 : bne + + ldx #$00 : bra .end + + cmp #$73 : bne + + ldx #$01 : bra .end + + cmp #$74 : bne + + ldx #$02 : bra .end + + cmp #$81 : bne + + lda $aa : beq ++ + ldx #$04 : bra .end + ++ ldx #$03 : bra .end + + cmp #$84 : bne + + ldx #$05 : bra .end + + cmp #$cb : bne + + lda $aa : beq ++ + ldx #$06 : bra .end + ++ ldx #$07 : bra .end + + cmp #$db : bne .end + ldx #$08 + .end txa : rts + + + diff --git a/gfx.asm b/gfx.asm new file mode 100644 index 0000000..6d72dca --- /dev/null +++ b/gfx.asm @@ -0,0 +1,67 @@ +GfxFixer: +{ + lda.l DRMode : bne + + jsl LoadRoomHook ;this is the code we overwrote + jsl Dungeon_InitStarTileCh + jsl LoadTransAuxGfx_Alt + inc $b0 + rtl + + lda $b1 : bne .stage2 + jsl LoadRoomHook ; this is the rando version - let's only call this guy once - may fix star tiles and slower loads + jsl Dungeon_InitStarTileCh + jsl LoadTransAuxGfx + jsl Dungeon_LoadCustomTileAttr + jsl PrepTransAuxGfx + lda.l DRMode : cmp #$02 : bne + ; only do this in crossed mode + ldx $a0 : lda.l TilesetTable, x + cmp $0aa1 : beq + ; already eq no need to decomp + sta $0aa1 + tax : lda $02802e, x : tay + jsl DecompDungAnimatedTiles + + + lda #$09 : sta $17 : sta $0710 + jsl Palette_SpriteAux3 + jsl Palette_SpriteAux2 + jsl Palette_SpriteAux1 + jsl Palette_DungBgMain + jsr CgramAuxToMain + inc $b1 + rtl + .stage2 + lda #$0a : sta $17 : sta $0710 + stz $b1 : inc $b0 + rtl +} + +CgramAuxToMain: ; ripped this from bank02 because it ended with rts +{ + rep #$20 + ldx.b #$00 + + .loop + lda $7EC300, X : sta $7EC500, x + lda $7EC340, x : sta $7EC540, x + lda $7EC380, x : sta $7EC580, x + lda $7EC3C0, x : sta $7EC5C0, x + lda $7EC400, x : sta $7EC600, x + lda $7EC440, x : sta $7EC640, x + lda $7EC480, x : sta $7EC680, x + lda $7EC4C0, x : sta $7EC6C0, x + + inx #2 : cpx.b #$40 : bne .loop + sep #$20 + + ; tell NMI to upload new CGRAM data + inc $15 + rts +} + +OverridePaletteHeader: + lda.l DRMode : cmp #$02 : bne + + cpx #$01c2 : !bge + + rep #$20 + txa : lsr : tax + lda.l PaletteTable, x + iny : rtl + + rep #$20 : iny : lda [$0D], Y ; what we wrote over +rtl \ No newline at end of file diff --git a/hudadditions.asm b/hudadditions.asm new file mode 100644 index 0000000..4e5b316 --- /dev/null +++ b/hudadditions.asm @@ -0,0 +1,206 @@ +DrHudOverride: +{ + jsl.l NewDrawHud + jsr HudAdditions + rtl +} + +HudAdditions: +{ + lda.l DRFlags : and #$0008 : beq ++ + lda $7EF423 : and #$00ff + jsr HudHexToDec4DigitCopy + LDX.b $05 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+10 ; draw 100's digit + LDX.b $06 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+12 ; draw 10's digit + LDX.b $07 : TXA : ORA.w #$2400 : STA !GOAL_DRAW_ADDRESS+14 ; draw 1's digit + ++ + + ldx $040c : cpx #$ff : bne + : rts : + + lda.l DRMode : bne + : rts : + + phb : phk : plb + lda $7ef364 : and.l $0098c0, x : beq + + lda.w CompassBossIndicator, x : and #$00ff : cmp $a0 : bne + + lda $1a : and #$0010 : beq + + lda #$345e : sta $7ec790 : bra .next + + lda #$207f : sta $7ec790 + .next lda.w DRMode : and #$0002 : bne + : plb : rts : + + lda $7ef36d : and #$00ff : beq + + lda.w DungeonReminderTable, x : bra .reminder + + lda #$207f + .reminder sta $7ec702 + + lda.w DRFlags : and #$0004 : beq .restore + lda $7ef368 : and.l $0098c0, x : beq .restore + txa : lsr : tax + + lda.l GenericKeys : and #$00ff : bne + + lda $7ef4e0, x : jsr ConvertToDisplay : sta $7ec7a2 + lda #$2830 : sta $7ec7a4 + + + lda.w ChestKeys, x : jsr ConvertToDisplay : sta $7ec7a6 + ; todo 4b0 no longer in use + + .restore + plb : rts +} + +;column distance for BK/Smalls +HudOffsets: +; none hc east desert aga swamp pod mire skull ice hera tt tr gt +dw $fffe, $0000, $0006, $0008, $0002, $0010, $000e, $0018, $0012, $0016, $000a, $0014, $001a, $001e + +; offset from 1644 +RowOffsets: +dw $0000, $0000, $0040, $0080, $0000, $0080, $0040, $0080, $00c0, $0040, $00c0, $0000, $00c0, $0000 + +ColumnOffsets: +dw $0000, $0000, $0000, $0000, $000a, $000a, $000a, $0014, $000a, $0014, $0000, $0014, $0014, $001e + + +DrHudDungeonItemsAdditions: +{ + jsl DrawHUDDungeonItems + lda.l HUDDungeonItems : and #$ff : bne + : rtl : + + lda.l DRMode : cmp #$02 : beq + : rtl : + + + phx : phy : php + rep #$30 + + lda.w #$24f5 : sta $1606 : sta $1610 : sta $161a : sta $1624 + sta $1644 : sta $164a : sta $1652 : sta $1662 : sta $1684 : sta $16c4 + ldx #$0000 + - sta $1704, x : sta $170e, x : sta $1718, x + inx #2 : cpx #$0008 : !blt - + + lda !HUD_FLAG : and.w #$0020 : beq + : brl ++ : + + lda HUDDungeonItems : and.w #$0007 : bne + : brl ++ : + + ; bk symbols + lda.w #$2811 : sta $1606 : sta $1610 : sta $161a : sta $1624 + ; sm symbols + lda.w #$2810 : sta $160a : sta $1614 : sta $161e : sta $16e4 + ; blank out stuff + lda.w #$24f5 : sta $1724 + + ldx #$0002 + - lda #$0000 : !addl RowOffsets,x : !addl ColumnOffsets, x : tay + lda.l DungeonReminderTable, x : sta $1644, y : iny #2 + lda.w #$24f5 : sta $1644, y + lda $7ef368 : and.l $0098c0, x : beq + ; must have map + jsr BkStatus : sta $1644, y : bra .smallKey ; big key status + + lda $7ef366 : and.l $0098c0, x : beq .smallKey + lda.w #$2826 : sta $1644, y + .smallKey + + iny #2 + cpx #$001a : bne + + tya : !add #$003c : tay + + stx $00 + txa : lsr : tax + lda.w #$24f5 : sta $1644, y + lda.l $7ef37c, x : beq + + jsr ConvertToDisplay2 : sta $1644, y + + iny #2 : lda.w #$24f5 : sta $1644, y + phx : ldx $00 + lda $7ef368 : and.l $0098c0, x : beq + ; must have map + plx : lda.l ChestKeys, x : jsr ConvertToDisplay2 : sta $1644, y ; small key totals + bra .skipStack + + plx + .skipStack iny #2 + cpx #$000d : beq + + lda.w #$24f5 : sta $1644, y + + + ldx $00 + + inx #2 : cpx #$001b : bcs ++ : brl - + ++ + lda !HUD_FLAG : and.w #$0020 : bne + : brl ++ : + + lda HUDDungeonItems : and.w #$000c : bne + : brl ++ : + + ; map symbols (do I want these) ; note compass symbol is 2c20 + lda.w #$2821 : sta $1606 : sta $1610 : sta $161a : sta $1624 + ; blank out a couple thing from old hud + lda.w #$24f5 : sta $16e4 : sta $1724 + sta $160a : sta $1614 : sta $161e ; blank out sm key indicators + ldx #$0002 + - lda #$0000 ; start of hud area + !addl RowOffsets, x : !addl ColumnOffsets, x : tay + lda.l DungeonReminderTable, x : sta $1644, y + iny #2 + lda.w #$24f5 : sta $1644, y ; blank out map spot + lda $7ef368 : and.l $0098c0, x : beq + ; must have map + lda #$2826 : sta $1644, y ; check mark + + iny #2 + cpx #$001a : bne + + tya : !add #$003c : tay + + lda $7ef364 : and.l $0098c0, x : beq + ; must have compass + phx ; total chest counts + txa : lsr : tax + lda.l TotalLocationsHigh, x : jsr ConvertToDisplay2 : sta $1644, y : iny #2 + lda.l TotalLocationsLow, x : jsr ConvertToDisplay2 : sta $1644, y + plx + bra .skipBlanks + + lda.w #$24f5 : sta $1644, y : iny #2 : sta $1644, y + .skipBlanks iny #2 + cpx #$001a : beq + + lda.w #$24f5 : sta $1644, y ; blank out spot + + inx #2 : cpx #$001b : bcc - + ++ + plp : ply : plx : rtl +} + +BkStatus: + lda $7ef366 : and.l $0098c0, x : bne +++ ; has the bk already + lda.l BigKeyStatus, x : bne ++ + lda #$2827 : rts ; 0/O for no BK + ++ cmp #$0002 : bne + + lda #$2420 : rts ; symbol for BnC + + lda #$24f5 : rts ; black otherwise + +++ lda #$2826 : rts ; check mark + +ConvertToDisplay: + and.w #$00ff : cmp #$000a : !blt + + !add #$2553 : rts + + !add #$2490 : rts + +ConvertToDisplay2: + and.w #$00ff : beq ++ + cmp #$000a : !blt + + !add #$2553 : rts + + !add #$2816 : rts + ++ lda #$2827 : rts ; 0/O for 0 or placeholder digit ;2483 + +CountAbsorbedKeys: + jsl IncrementSmallKeysNoPrimary : phx + lda $040c : cmp #$ff : beq + + lsr : tax + lda $7ef4b0, x : inc : sta $7ef4b0, x + + plx : rtl + +;================================================================================ +; 16-bit A, 8-bit X +; in: A(b) - Byte to Convert +; out: $04 - $07 (high - low) +;================================================================================ +HudHexToDec4DigitCopy: + LDY.b #$90 + - + CMP.w #1000 : !BLT + + INY + SBC.w #1000 : BRA - + + + STY $04 : LDY #$90 ; Store 1000s digit & reset Y + - + CMP.w #100 : !BLT + + INY + SBC.w #100 : BRA - + + + STY $05 : LDY #$90 ; Store 100s digit & reset Y + - + CMP.w #10 : !BLT + + INY + SBC.w #10 : BRA - + + + STY $06 : LDY #$90 ; Store 10s digit & reset Y + CMP.w #1 : !BLT + + - + INY + DEC : BNE - + + + STY $07 ; Store 1s digit +RTS \ No newline at end of file diff --git a/keydoors.asm b/keydoors.asm new file mode 100644 index 0000000..1ec10c3 --- /dev/null +++ b/keydoors.asm @@ -0,0 +1,42 @@ +; code to un-pair or re-pair doors + +; doorlist is loaded into 19A0 but no terminator +; new room is in A0 +; for "each" door do the following: (each could mean the first four doors?) +; in lookup table, grab room and corresponding position +; find the info at 7ef000, x where x is twice the paired room +; check the corresponding bit (there are only 4) +; set the bit in 068C + +; Note the carry bit is used to indicate if we should aborted (set) or not +CheckIfDoorsOpen: { + jsr TrapDoorFixer ; see normal.asm + ; note we are 16bit mode right now + lda.l DRMode : beq + + lda $040c : cmp #$00ff : bne .gtg + + lda $a0 : dec : tax : and #$000f ; hijacked code + sec : rtl ; set carry to indicate normal behavior + + .gtg + phb : phk : plb + stx $00 : ldy #$0000 + .nextDoor + lda $a0 : asl : tax + lda.w KeyDoorOffset, x : beq .skipDoor + asl : sty $05 : !add $05 : tax + lda.w PairedDoorTable, x : beq .skipDoor + sta $02 : and #$00ff : asl a : tax + lda $02 : and #$ff00 : sta $03 + lda $7ef000, x : and #$f000 : and $03 : beq .skipDoor + tyx : lda $068c : ora $0098c0,x : sta $068c + .skipDoor + iny #2 : cpy $00 : bne .nextDoor + plb : clc : rtl +} + +; outstanding issues +; how to indicate opening for other (non-first four doors?) +; Bank01 Door Register stores the 4 bits in 068c to 400 (depending on type) +; Key collision and others depend on F0-F3 attribute not sure if extendable to other numbers +; Dungeon_ProcessTorchAndDoorInteractives.isOpenableDoor is the likely culprit for collision problems +; Saving open status to other unused rooms is tricky -- Bank 2 13947 (line 8888) \ No newline at end of file diff --git a/keydropshuffle.asm b/keydropshuffle.asm new file mode 100644 index 0000000..90a21c4 --- /dev/null +++ b/keydropshuffle.asm @@ -0,0 +1,170 @@ +org $06926e ; <- 3126e - sprite_prep.asm : 2664 (LDA $0B9B : STA $0CBA, X) +jsl SpriteKeyPrep : nop #2 + +org $06d049 ; <- 35049 sprite_absorbable : 31-32 (JSL Sprite_DrawRippleIfInWater : JSR Sprite_DrawAbsorbable) +jsl SpriteKeyDrawGFX : bra + : nop : + + +org $06d180 +jsl BigKeyGet : bcs $07 : nop #5 + +org $06d18d ; <- 3518D - sprite_absorbable.asm : 274 (LDA $7EF36F : INC A : STA $7EF36F) +jsl KeyGet + +org $06f9f3 ; bank06.asm : 6732 (JSL Sprite_LoadProperties) +jsl LoadProperties_PreserveItemMaybe + + + + +org $06d23a +Sprite_DrawAbsorbable: +org $1eff81 +Sprite_DrawRippleIfInWater: +org $0db818 +Sprite_LoadProperties: + +org $288000 ;140000 +ShuffleKeyDrops: +db 0 +ShuffleKeyDropsReserved: +db 0 + +LootTable: ;PC: 140002 +db $0e, $00, $24 ;; ice jelly key +db $13, $00, $24 ;; pokey 2 +db $16, $00, $24 ;; swamp waterway pot +db $21, $00, $24 ;; key rat +db $35, $00, $24 ;; swamp trench 2 pot +db $36, $00, $24 ;; hookshot pot +db $37, $00, $24 ;; trench 1 pot +db $38, $00, $24 ;; pot row pot +db $39, $00, $24 ;; skull gibdo +db $3d, $00, $24 ;; gt minihelma +db $3e, $00, $24 ;; ice conveyor +db $3f, $00, $24 ;; ice hammer block ??? is this a dungeon secret? +db $43, $00, $24 ;; tiles 2 pot +db $53, $00, $24 ;; beamos hall pot +db $56, $00, $24 ;; skull west lobby pot +db $63, $00, $24 ;; desert tiles 1 pot +db $71, $00, $24 ;; boomerang guard +db $72, $00, $24 ;; hc map guard +db $7b, $00, $24 ;; gt star pits pot +db $80, $00, $32 ;; a big key (for the current dungeon) +db $8b, $00, $24 ;; gt conv cross block +db $9b, $00, $24 ;; gt dlb switch pot +db $9f, $00, $24 ;; ice many pots +db $99, $00, $24 ;; eastern eyegore +db $a1, $00, $24 ;; mire fishbone pot +db $ab, $00, $24 ;; tt spike switch pot +db $b0, $00, $24 ;; tower circle of pots usain +db $b3, $00, $24 ;; mire spikes pot +db $b6, $00, $24 ;; pokey 1 +db $ba, $00, $24 ;; eastern dark pot +db $bc, $00, $24 ;; tt hallway pot +db $c0, $00, $24 ;; tower dark archer +db $c1, $00, $24 ;; mire glitchy jelly +db $ff, $00, $ff +;140068 + +KeyTable: +db $a0, $a0, $a2, $a3, $a4, $a5, $a6, $a7, $a8, $a9, $aa, $ab, $ac, $ad + +SpriteKeyPrep: +{ + lda $0b9b : sta $0cba, x ; what we wrote over + pha + lda.l ShuffleKeyDrops : beq + + phx + ldx #$fd + - inx #3 : lda.l LootTable, x : cmp #$ff : beq ++ : cmp $a0 : bne - + inx : lda.l LootTable, x : sta !MULTIWORLD_SPRITEITEM_PLAYER_ID + inx : lda.l LootTable, x + plx : sta $0e80, x + cmp #$24 : bne +++ + lda $a0 : cmp #$80 : bne + : lda #$24 + +++ jsl PrepDynamicTile : bra + + ++ plx : lda #$24 : sta $0e80, x + + pla + rtl +} + +SpriteKeyDrawGFX: +{ + jsl Sprite_DrawRippleIfInWater + pha + lda.l ShuffleKeyDrops : bne + + - pla + phk : pea.w .jslrtsreturn-1 + pea.w $068014 ; an rtl address - 1 in Bank06 + jml Sprite_DrawAbsorbable + .jslrtsreturn + rtl + + lda $0e80, x + cmp #$24 : bne + + lda $a0 : cmp #$80 : bne - : lda #$24 + + jsl DrawDynamicTile ; see DrawHeartPieceGFX if problems + cmp #$03 : bne + + pha : lda $0e60, x : ora.b #$20 : sta $0E60, x : pla + + + jsl.l Sprite_DrawShadowLong + + pla : rtl +} + +KeyGet: +{ + lda $7ef36f ; what we wrote over + pha + lda.l ShuffleKeyDrops : bne + + pla : rtl + + + ldy $0e80, x + phy + jsr KeyGetPlayer : sta !MULTIWORLD_ITEM_PLAYER_ID + jsl.l $0791b3 ; Player_HaltDashAttackLong + jsl.l Link_ReceiveItem + pla : sta $00 + lda !MULTIWORLD_ITEM_PLAYER_ID : bne .end + phx + lda $040c : lsr : tax + lda $00 : cmp KeyTable, x : bne + + - plx : pla : rtl + + cmp #$af : beq - ; universal key + cmp #$24 : beq - ; small key for this dungeon + plx + .end + pla : dec : rtl +} + + +BigKeyGet: +{ + lda.l ShuffleKeyDrops : bne + + - stz $02e9 : ldy.b #$32 ; what we wrote over + phx : jsl Link_ReceiveItem : plx ; what we wrote over + clc : rtl + + + ldy $0e80, x + cpy #$32 : beq - + + sec : rtl +} + +KeyGetPlayer: +{ + phx + ldx #$fd + - inx #3 : lda.l LootTable, x : cmp #$ff : beq ++ : cmp $a0 : bne - + ++ inx : lda.l LootTable, x + plx + rts +} + +LoadProperties_PreserveItemMaybe: +{ + lda.l ShuffleKeyDrops : bne + + jsl Sprite_LoadProperties : rtl + + lda $0e80, x : pha + jsl Sprite_LoadProperties + pla : sta $0e80, x + rtl +} diff --git a/math.asm b/math.asm new file mode 100644 index 0000000..03cd46a --- /dev/null +++ b/math.asm @@ -0,0 +1,66 @@ +;divide by 2 example +; 0 1 2 3 4 5 6 7 8 9 a b c d e f 10--Offset Ruler +;v 00 01 01 02 02 03 03 04 04 04 05 05 06 06 07 07 08 + +;divide by 3 example +; 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13 14 15 16 17 18 +;00 00 01 01 01 02 02 02 03 03 03 04 04 04 05 05 05 06 06 06 07 07 07 08 08 + +MultiplyByY: +.loop cpy #$0001 : beq .done +cpy #$0003 : bne ++ + jsr MultiBy3 : bra .done +++ cpy #$0005 : bne ++ + jsr MultiBy5 : bra .done +++ asl : sta $00 : tya : lsr : tay : lda $00 : bra .loop +.done rts + +;Divisor in Y. Width of division is in X for rounding toward middle +DivideByY: +.loop +cpy #$0000 : beq .done +cpy #$0001 : beq .done +cpy #$0003 : bne ++ + jsr DivideBy3 : bra .done +++ cpy #$0005 : bne ++ + jsr DivideBy5 : bra .done +++ jsr DivideBy2 : sta $00 +tya : lsr : tay +txa : lsr : tax +lda $00 : bra .loop +.done rts + +MultiBy3: +sta $00 : asl : !add $00 +rts + +MultiBy5: +sta $00 : asl #2 : !add $00 +rts + +;width of divison in x: rounds toward X/2 +DivideBy2: +sta $00 +lsr : bcc .done +sta $02 : txa : lsr : cmp $00 : !blt + + lda $02 : inc : bra .done ++ lda $02 +.done rts + +DivideBy3: +sta $00 +ldx #$0000 +lda #$0002 +.loop cmp $00 : !bge .store + inx : !add #$0003 : bra .loop +.store txa +rts + +DivideBy5: +sta $00 +ldx #$0000 +lda #$0003 +.loop cmp $00 : !bge .store + inx : !add #$0005 : bra .loop +.store txa +rts \ No newline at end of file diff --git a/normal.asm b/normal.asm new file mode 100644 index 0000000..5d8b604 --- /dev/null +++ b/normal.asm @@ -0,0 +1,304 @@ +WarpLeft: + lda.l DRMode : beq .end + lda $040c : cmp.b #$ff : beq .end + lda $20 : ldx $aa + jsr CalcIndex + !add #$06 : ldy #$01 ; offsets in A, Y + jsr LoadRoomHorz +.end + jsr Cleanup + rtl + +WarpRight: + lda.l DRMode : beq .end + lda $040c : cmp.b #$ff : beq .end + lda $20 : ldx $aa + jsr CalcIndex + !add #$12 : ldy #$ff ; offsets in A, Y + jsr LoadRoomHorz +.end + jsr Cleanup + rtl + +WarpUp: + lda.l DRMode : beq .end + lda $040c : cmp.b #$ff : beq .end + lda $22 : ldx $a9 + jsr CalcIndex + ldy #$02 ; offsets in A, Y + jsr LoadRoomVert +.end + jsr Cleanup + rtl + +WarpDown: + lda.l DRMode : beq .end + lda $040c : cmp.b #$ff : beq .end + lda $22 : ldx $a9 + jsr CalcIndex + !add #$0c : ldy #$ff ; offsets in A, Y + jsr LoadRoomVert +.end + jsr Cleanup + rtl + +; carry set = use link door like normal +; carry clear = we are in dr mode, never use linking doors +CheckLinkDoorR: + lda.l DRMode : bne + + lda $7ec004 : sta $a0 ; what we wrote over + sec : rtl + + clc : rtl + +CheckLinkDoorL: + lda.l DRMode : bne + + lda $7ec003 : sta $a0 ; what we wrote over + sec : rtl + + clc : rtl + +TrapDoorFixer: + lda $fe : and #$0038 : beq .end + xba : asl #2 : sta $00 + stz $0468 : lda $068c : ora $00 : sta $068c + .end + stz $fe ; clear our fe here because we don't need it anymore + rts + +Cleanup: + stz $047a + inc $11 + lda $ef + rts + +;A needs be to the low coordinate, x needs to be either 0 for left,upper or non-zero for right,down +; This sets A (00,02,04) and stores half that at $04 for later use, (src door) +CalcIndex: ; A->low byte of Link's Coord, X-> Link's quadrant, DoorOffset x 2 -> A, DoorOffset -> $04 (vert/horz agnostic) + cpx.b #00 : bne .largeDoor + cmp.b #$d0 : bcc .smallDoor + lda #$01 : bra .done ; Middle Door + .smallDoor lda #$00 : bra .done + .largeDoor lda #$02 + .done + sta $04 + asl + rts + +; Y is an adjustment for main direction of travel +; A is a door table row offset +LoadRoomHorz: +{ + phb : phk : plb + sty $06 : sta $07 : lda $a0 : pha ; Store normal room on stack + lda $07 : jsr LookupNewRoom ; New room is in A, Room Data is in $00-$01 + lda $00 : cmp #$03 : bne .gtg + jsr HorzEdge : pla : bcs .end + sta $a0 : bra .end ; Restore normal room, abort (straight staircases and open edges can get in this routine) + + .gtg ;Good to Go! + pla ; Throw away normal room (don't fill up the stack) + lda $a0 : and.b #$0F : asl a : !sub $23 : !add $06 : sta $02 + ldy #$00 : jsr ShiftVariablesMainDir + + lda $01 : and #$80 : beq .normal + ldy $06 : cpy #$ff : beq + + lda $01 : jsr LoadEastMidpoint : bra ++ + + lda $01 : jsr LoadWestMidpoint + ++ jsr PrepScrollToEdge : bra .scroll + + .normal + jsr PrepScrollToNormal + .scroll + lda $01 : and #$40 : pha + jsr ScrollY + pla : beq .end + ldy #$06 : jsr ApplyScroll + .end + plb ; restore db register + rts +} + +; Y is an adjustment for main direction of travel (stored at $06) +; A is a door table row offset (stored a $07) +LoadRoomVert: +{ + phb : phk : plb + sty $06 : sta $07 : lda $a0 : pha ; Store normal room on stack + lda $07 : jsr LookupNewRoom ; New room is in A, Room Data is in $00-$01 + lda $00 : cmp #$03 : bne .gtg + jsr VertEdge : pla : bcs .end + sta $a0 : bra .end ; Restore normal room, abort (straight staircases and open edges can get in this routine) + .gtg ;Good to Go! + pla ; Throw away normal room (don't fill up the stack) + lda $a0 : and.b #$F0 : lsr #3 : !sub $21 : !add $06 : sta $02 + ldy #$01 : jsr ShiftVariablesMainDir + + lda $01 : and #$80 : beq .normal + ldy $06 : cpy #$ff : beq + + lda $01 : jsr LoadSouthMidpoint : bra ++ + + lda $01 : jsr LoadNorthMidpoint + ++ jsr PrepScrollToEdge : bra .scroll + + .normal + jsr PrepScrollToNormal + .scroll + lda $01 : and #$40 : pha + jsr ScrollX + pla : beq .end + ldy #$00 : jsr ApplyScroll + .end + plb ; restore db register + rts +} + +LookupNewRoom: ; expects data offset to be in A +{ + rep #$30 : and #$00FF ;sanitize A reg (who knows what is in the high byte) + sta $00 ; offset in 00 + lda $a2 : tax ; probably okay loading $a3 in the high byte + lda.w DoorOffset,x : and #$00FF ;we only want the low byte + asl #3 : sta $02 : !add $02 : !add $02 ;multiply by 24 (data size) + !add $00 ; should now have the offset of the address I want to load + tax : lda.w DoorTable,x : sta $00 + and #$00FF : sta $a0 ; assign new room + sep #$30 + rts +} + +; INPUTS-- Y: Direction Index , $02: Shift Value +; Sets high bytes of various registers +ShiftVariablesMainDir: +{ + lda.w CoordIndex,y : tax + lda $21,x : !add $02 : sta $21,x ; coordinate update + lda.w CameraIndex,y : tax + lda $e3,x : !add $02 : sta $e3,x ; scroll register high byte + lda.w CamQuadIndex,y : tax + lda $0605,x : !add $02 : sta $0605,x ; high bytes of these guys + lda $0607,x : !add $02 : sta $0607,x + lda $0601,x : !add $02 : sta $0601,x + lda $0603,x : !add $02 : sta $0603,x + rts +} + + +; Target pixel should be in A, other info in $01 +; Sets $04 $05 and $ee +PrepScrollToEdge: +{ + sta $04 : lda $01 : and #$20 : beq + + lda #01 + + sta $05 + lda $01 : and #$10 : beq + + lda #01 + + sta $ee : bne + + stz $0476 + + rts +} + +; Normal Flags should be in $01 +; Sets $04 $05 and $ee, and $fe +PrepScrollToNormal: +{ + lda $01 : sta $fe : and #$04 : lsr #2 : sta $ee ; trap door and layer + bne + + stz $0476 + + stz $05 : lda #$78 : sta $04 + lda $01 : and #$03 : beq .end + cmp #$02 : !bge + + lda #$f8 : sta $04 : bra .end + + inc $05 + .end rts +} + +StraightStairsAdj: +{ + stx $0464 : sty $012e ; what we wrote over + lda.l 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.l 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.l 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.l DRMode : bne + + !add $20 : sta $20 ;what we wrote over + + rtl +} + +StraightStairLayerFix: +{ + lda.l DRMode : beq + + lda $ee : rtl + + lda $01c322, x : rtl ; what we wrote over +} + +DoorToStraight: +{ + pha + lda.l 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/overrides.asm b/overrides.asm new file mode 100644 index 0000000..07bb83e --- /dev/null +++ b/overrides.asm @@ -0,0 +1,114 @@ +;================================================================================ +; Lamp Mantle & Light Cone Fix +;-------------------------------------------------------------------------------- +; Output: 0 for darkness, 1 for lamp cone +;-------------------------------------------------------------------------------- +LampCheckOverride: + LDA $7F50C4 : CMP.b #$01 : BNE + : RTL : + + CMP.b #$FF : BNE + : INC : RTL : + + + LDA $7EF34A : BNE .done ; skip if we already have lantern + + LDA $7EF3CA : BNE + + .lightWorld + LDA $040C : CMP.b #$02 : BNE ++ ; check if we're in HC + LDA LampConeSewers : BRA .done + ++ + LDA LampConeLightWorld : BRA .done + + + .darkWorld + LDA LampConeDarkWorld + .done + ;BNE + : STZ $1D : + ; remember to turn cone off after a torch +RTL + +GtBossHeartCheckOverride: + lda $a0 : cmp #$1c : beq ++ + cmp #$6c : beq ++ + cmp #$4d : bne + + ++ lda.l DRFlags : and #$01 : bne ++ ;skip if flag on + lda $403 : ora #$80 : sta $403 + ++ clc +rtl + + sec +rtl + +OnFileLoadOverride: + jsl OnFileLoad ; what I wrote over + lda.l DRFlags : and #$80 : beq + ;flag is off + lda $7ef086 : ora #$80 : sta $7ef086 + + lda.l DRFlags : and #$02 : beq + + lda $7ef353 : bne + + lda #$01 : sta $7ef353 ++ rtl + +MirrorCheckOverride: + lda.l DRFlags : and #$02 : beq ++ + lda $7ef353 : cmp #$01 : beq + + ++ lda $8A : and #$40 ; what I wrote over + rtl + + lda.l DRScroll : rtl + +MirrorCheckOverride2: + lda $7ef353 : and #$02 : rtl + + +BlockEraseFix: + lda $7ef353 : and #$02 : beq + + stz $05fc : stz $05fd + + rtl + +FixShopCode: + cpx #$300 : !bge + + sta $7ef000, x + + rtl + +VitreousKeyReset: + lda.l DRMode : beq + + stz $0cba, x + + jsl $0db818 ;restore old code + rtl + +GuruguruFix: + lda $a0 : cmp #$df : !bge + + and #$0f : cmp #$0e : !blt + + iny #2 + + rtl + +BlindAtticFix: + lda.l DRMode : beq + + lda #$01 : rtl + + lda $7EF3CC : cmp.b #$06 + rtl + +SuctionOverworldFix: + stz $50 : stz $5e + lda.l DRMode : beq + + stz $49 + + rtl + +; TT Alcove, Mire bridges, pod falling, SW torch room, TR Pipe room, Bob's Room, Ice Many Pots, Mire Hub +; swamp waterfall, Gauntlet 3, Eastern Push block +CutoffRooms: +db $bc, $a2, $1a, $49, $14, $8c, $9f, $c2 +db $66, $5d, $a8 + +CutoffEntranceRug: + pha : phx + lda.l DRMode : beq .norm + lda $04 : cmp #$000A : beq + + cmp #$000C : bne .norm + + lda $a0 : sep #$20 : ldx #$0000 + - cmp.l CutoffRooms, x : beq .check + inx : cpx #$0009 : !blt - ; CutoffRoom Count is here! + rep #$20 + .norm plx : pla : lda $9B52, y : sta $7E2000, x ; what we wrote over +rtl + .check + rep #$20 + lda $0c : cmp #$0006 : !bge .skip + lda $0e : cmp #$0008 : !bge .skip + cmp #$0004 : !blt .skip + bra .norm +.skip plx : pla : rtl + diff --git a/roomloading.asm b/roomloading.asm index 29f584d..2640e57 100644 --- a/roomloading.asm +++ b/roomloading.asm @@ -15,6 +15,9 @@ LoadRoomHook: dl IcePalaceBombosNE ; 03 dl CastleEastEntrance ; 04 dl CastleWestEntrance ; 05 + dl PoDFallingBridge ; 06 + dl PoDArena ; 07 + dl MireBKPond ; 08 NoCallback: RTL @@ -145,10 +148,138 @@ CastleWestEntrance: SEP #$20 ; 8 A RTL +PoDFallingBridge: + LDA.l DRFlags : AND #$10 : BNE + : RTL : + + + REP #$20 ; 16 A + LDA.w #$08e1 ; square peg + %writeTileAt(5,7,0,1) + %writeTileAt(11,7,0,1) + INC ;horizontal rail + %writeTileAt(6,7,0,1) + %writeTileAt(7,7,0,1) + %writeTileAt(8,7,0,1) + %writeTileAt(9,7,0,1) + %writeTileAt(10,7,0,1) + SEP #$20 ; 8 A + + REP #$20 ; 16 A + LDA.w #$08e0 ; corner top left + %writeTileAt(5,6,0,1) + %writeTileAt(10,6,0,1) + LDA.w #$48e0 ; corner top right + %writeTileAt(6,6,0,1) + %writeTileAt(11,6,0,1) + LDA.w #$08f4 ; top mid + %writeTileAt(7,6,0,1) + %writeTileAt(8,6,0,1) + %writeTileAt(9,6,0,1) + + LDA.w #$08f1 ; corner mid left + %writeTileAt(5,7,0,1) + %writeTileAt(10,7,0,1) + LDA.w #$48f1 ; corner mid right + %writeTileAt(6,7,0,1) + %writeTileAt(11,7,0,1) + LDA.w #$08f2 ; mid mid + %writeTileAt(7,7,0,1) + %writeTileAt(8,7,0,1) + %writeTileAt(9,7,0,1) + + LDA.w #$08e4 ; corner lower left + %writeTileAt(5,8,0,1) + %writeTileAt(10,8,0,1) + LDA.w #$48e4 ; corner lower right + %writeTileAt(6,8,0,1) + %writeTileAt(11,8,0,1) + LDA.w #$08e5 ; lower mid + %writeTileAt(7,8,0,1) + %writeTileAt(8,8,0,1) + %writeTileAt(9,8,0,1) + SEP #$20 ; 8 A + RTL + +;08e0 48e0 08f4 08f4 08e0 48e0 +;08f1 48f1 08f2 08f2 08f1 48f1 +;08e4 48e4 08e5 08e5 08e4 48e4 +; +;(54,42) 22,10,1,1 42 85 2720 2742 156C +;(54,43) 22,11,1,1 43 87 2784 2806 15EC +;(54,44) 22,12,1,1 44 89 2848 2870 166C +PoDArena: + LDA.l DRFlags : AND #$10 : BNE + : RTL : + + + REP #$20 ; 16 A + LDA.w #$08e0 ; corner top left + %writeTileAt(22,10,1,1) + %writeTileAt(25,10,1,1) + LDA.w #$48e0 ; corner top right + %writeTileAt(23,10,1,1) + %writeTileAt(26,10,1,1) + LDA.w #$08f4 ; top mid + %writeTileAt(24,10,1,1) + + LDA.w #$08f1 ; corner mid left + %writeTileAt(22,11,1,1) + %writeTileAt(25,11,1,1) + LDA.w #$48f1 ; corner mid right + %writeTileAt(23,11,1,1) + %writeTileAt(26,11,1,1) + LDA.w #$08f2 ; mid mid + %writeTileAt(24,11,1,1) + + LDA.w #$08e4 ; corner lower left + %writeTileAt(22,12,1,1) + %writeTileAt(25,12,1,1) + LDA.w #$48e4 ; corner lower right + %writeTileAt(23,12,1,1) + %writeTileAt(26,12,1,1) + LDA.w #$08e5 ; lower mid + %writeTileAt(24,12,1,1) + SEP #$20 ; 8 A + RTL + +MireBKPond: + LDA.l DRFlags : AND #$10 : BNE + : RTL : + + + REP #$20 ; 16 A + LDA.w #$08e0 ; corner top left + %writeTileAt(13,11,1,1) + %writeTileAt(17,11,1,1) + LDA.w #$48e0 ; corner top right + %writeTileAt(14,11,1,1) + %writeTileAt(18,11,1,1) + LDA.w #$08f4 ; top mid + %writeTileAt(15,11,1,1) + %writeTileAt(16,11,1,1) + + LDA.w #$08f1 ; corner mid left + %writeTileAt(13,12,1,1) + %writeTileAt(17,12,1,1) + LDA.w #$48f1 ; corner mid right + %writeTileAt(14,12,1,1) + %writeTileAt(18,12,1,1) + LDA.w #$08f2 ; mid mid + %writeTileAt(15,12,1,1) + %writeTileAt(16,12,1,1) + + LDA.w #$08e4 ; corner lower left + %writeTileAt(13,13,1,1) + %writeTileAt(17,13,1,1) + LDA.w #$48e4 ; corner lower right + %writeTileAt(14,13,1,1) + %writeTileAt(18,13,1,1) + LDA.w #$08e5 ; lower mid + %writeTileAt(15,13,1,1) + %writeTileAt(16,13,1,1) + SEP #$20 ; 8 A + RTL + RoomCallbackTable: + ; 0 1 2 3 4 5 6 7 8 9 A B C D E F db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $00 ; 00x - db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 01x - db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 02x + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $06, $00, $00, $00, $00, $00 ; 01x + db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $07, $00, $00, $00, $00, $00 ; 02x db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 03x db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 04x db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 05x @@ -159,7 +290,7 @@ RoomCallbackTable: db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Ax db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Bx db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Cx - db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $03, $00 ; 0Dx + db $00, $08, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $03, $00 ; 0Dx db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Ex db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Fx db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 ; 0Fx diff --git a/scroll.asm b/scroll.asm new file mode 100644 index 0000000..133f4d1 --- /dev/null +++ b/scroll.asm @@ -0,0 +1,206 @@ +AdjustTransition: +{ + lda $ab : and #$01ff : beq .reset + phy : ldy #$06 ; operating on vertical registers during horizontal trans + cpx.b #$02 : bcs .horizontalScrolling + ldy #$00 ; operate on horizontal regs during vert trans + .horizontalScrolling + cmp #$0008 : bcs + + pha : lda $ab : and #$0200 : beq ++ + pla : bra .add + ++ pla : eor #$ffff : inc ; convert to negative + .add jsr AdjustCamAdd : ply : bra .reset + + lda $ab : and #$0200 : xba : tax + lda.l OffsetTable,x : jsr AdjustCamAdd + lda $ab : !sub #$0008 : sta $ab + ply : bra .done + .reset ; clear the $ab variable so to not disturb intra-tile doors + stz $ab + .done + lda $00 : and #$01fc + rtl +} + +AdjustCamAdd: + !add $00E2,y : pha + and #$01ff : cmp #$0111 : !blt + + cmp #$01f8 : !bge ++ + pla : and #$ff10 : pha : bra + + ++ pla : and #$ff00 : !add #$0100 : pha + + pla : sta $00E2,y : sta $00E0,y : rts + +; expects target quad in $05 (either 0 or 1) and target pixel in $04, target room should be in $a0 +; $06 is either $ff or $01/02 +; uses $00-$03 and $0e for calculation +; also set up $ac +ScrollY: ;change the Y offset variables + lda $a0 : and.b #$f0 : lsr #3 : sta $0603 : inc : sta $0607 + + lda $05 : bne + + lda $603 : sta $00 : stz $01 : bra ++ + + lda $607 : sta $00 : lda #$02 : sta $01 + ++ ; $01 now contains 0 or 2 and $00 contains the correct lat + + stz $0e + rep #$30 + lda $00 : pha + + lda $e8 : and #$01ff : sta $02 + lda $04 : jsr LimitYCamera : sta $00 + jsr CheckRoomLayoutY : bcc + + lda $00 : cmp #$0080 : !bge ++ + cmp #$0010 : !blt .cmpSrll + lda #$0010 : bra .cmpSrll + ++ cmp #$0100 : !bge .cmpSrll + lda #$0100 + .cmpSrll sta $00 + + ; figures out scroll amt + + lda $00 : cmp $02 : bne + + lda #$0000 : bra .next + + !blt + + !sub $02 : inc $0e : bra .next + + lda $02 : !sub $00 + + .next + sta $ab + jsr AdjustCameraBoundsY + + pla : sta $00 + sep #$30 + lda $04 : sta $20 + lda $00 : sta $21 : sta $0601 : sta $0605 + lda $01 : sta $aa + lda $0e : asl : ora $ac : sta $ac + lda $e9 : and #$01 : asl #2 : tax : lda $0603, x : sta $e9 + rts + +LimitYCamera: + cmp #$006c : !bge + + lda #$0000 : bra .end + + cmp #$017d : !blt + + lda #$0110 : bra .end + + !sub #$006c + .end rts + +CheckRoomLayoutY: + jsr LoadRoomLayout ;switches to 8-bit + cmp #$00 : beq .lock + cmp #$07 : beq .free + cmp #$01 : beq .free + cmp #$04 : !bge .lock + cmp #$02 : bne + + lda $06 : cmp #$ff : beq .lock + + cmp #$03 : bne .free + lda $06 : cmp #$ff : bne .lock + .free rep #$30 : clc : rts + .lock rep #$30 : sec : rts + +AdjustCameraBoundsY: + jsr CheckRoomLayoutY : bcc .free + + ; layouts that are camera locked (quads only) + lda $04 : and #$00ff : cmp #$007d : !blt + + lda #$0088 : bra ++ + + cmp #$006d : !bge + + lda #$0078 : bra ++ + + !add #$000b + + ; I think we no longer need the $02 variable + ++ sta $02 : lda $04 : and #$0100 : !add $02 : bra .setBounds + + ; layouts where the camera is free + .free lda $04 : cmp #$006c : !bge + + lda #$0077 : bra .setBounds + + cmp #$017c : !blt + + lda #$0187 : bra .setBounds + + !add #$000b + .setBounds sta $0618 : inc #2 : sta $061a + rts + +LoadRoomLayout: + lda $a0 : asl : !add $a0 : tax + lda $1f8001, x : sta $b8 + lda $1f8000, x : sta $b7 + sep #$30 + ldy #$01 : lda [$b7], y : and #$1c : lsr #2 + rts + +; expects target quad in $05 (either 0 or 1) and target pixel in $04, target room should be in $a0 +; uses $00-$03 and $0e for calculation +; also set up $ac +ScrollX: ;change the X offset variables + lda $a0 : and.b #$0f : asl : sta $060b : inc : sta $060f + + lda $05 : bne + + lda $60b : sta $00 : stz $01 : bra ++ + + lda $60f : sta $00 : lda #$01 : sta $01 + ++ ; $01 now contains 0 or 1 and $00 contains the correct long + + stz $0e ; pos/neg indicator + rep #$30 + lda $00 : pha + + lda $e2 : and #$01ff : sta $02 + lda $04 : jsr LimitXCamera : sta $00 + jsr CheckRoomLayoutX : bcc + + lda $00 : cmp #$0080 : !bge ++ + lda #$0000 : bra .cmpSrll + ++ lda #$0100 + .cmpSrll sta $00 + + ;figures out scroll amt + + lda $00 : cmp $02 : bne + + lda #$0000 : bra .next + + !blt + + !sub $02 : inc $0e : bra .next + + lda $02 : !sub $00 + + .next + sta $ab : lda $04 + + cmp #$0078 : !bge + + lda #$007f : bra ++ + + cmp #$0178 : !blt + + lda #$017f : bra ++ + + !add #$0007 + ++ sta $061c : inc #2 : sta $061e + + pla : sta $00 + sep #$30 + lda $04 : sta $22 + lda $00 : sta $23 : sta $0609 : sta $060d + lda $01 : sta $a9 + lda $0e : asl : ora $ac : sta $ac + lda $e3 : and #$01 : asl #2 : tax : lda $060b, x : sta $e3 + + rts + +LimitXCamera: + cmp #$0080 : !bge + + lda #$0000 : bra .end + + cmp #$0181 : !blt + + lda #$0180 + + !sub #$0080 + .end rts + +CheckRoomLayoutX: + jsr LoadRoomLayout ;switches to 8-bit + cmp #$04 : !blt .lock + cmp #$05 : bne + + lda $04 : cmp #$f8 : beq .lock + + cmp #$06 : bne .free + lda $04 : cmp #$f8 : bne .lock + .free rep #$30 : clc : rts + .lock rep #$30 : sec : rts + +ApplyScroll: + rep #$30 + lda $ab : and #$01ff : sta $00 + lda $ab : and #$0200 : beq + + lda $00e2, y : !add $00 : bra .end + + lda $00e2, y : !sub $00 + .end + sta $00e2, y + sta $00e0, y + stz $ab : sep #$30 : rts \ No newline at end of file diff --git a/spiral.asm b/spiral.asm new file mode 100644 index 0000000..2329c33 --- /dev/null +++ b/spiral.asm @@ -0,0 +1,211 @@ +RecordStairType: { + pha + lda.l 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 +} + +SpiralWarp: { + lda.l DRMode : beq .abort ; abort if not DR + lda $040c : cmp.b #$ff : beq .abort ; abort if not in dungeon + lda $045e : cmp #$5e : beq .gtg ; abort if not spiral - intended room is in A! + cmp #$5f : beq .gtg + .abort + stz $045e : lda $a2 : and #$0f : rtl ; clear,run hijacked code and get out + + .gtg + phb : phk : plb : phx : phy ; push stuff + jsr LookupSpiralOffset + rep #$30 : and #$00FF : asl #2 : tax + lda.w SpiralTable, x : sta $00 + lda.w SpiralTable+2, x : sta $02 + sep #$30 + lda $00 : sta $a0 + ; shift quadrant if necessary + stz $07 ; this is a x quad adjuster for those blasted staircase on the edges + lda $01 : and #$01 : !sub $a9 + bne .xQuad + lda $0462 : and #$04 : bne .xqCont + inc $07 + .xqCont lda $22 : bne .skipXQuad ; this is an edge case + dec $23 : bra .skipXQuad ; need to -1 if $22 is 0 + .xQuad sta $06 : !add $a9 : sta $a9 + lda $0462 : and #$04 : bne .xCont + inc $07 ; up stairs are going to -1 the quad anyway during transition, need to add this back + .xCont ldy #$00 : jsr ShiftQuadSimple + + .skipXQuad + lda $aa : lsr : sta $06 : lda $01 : and #$02 : lsr : !sub $06 + beq .skipYQuad + sta $06 : asl : !add $aa : sta $aa + ldy #$01 : jsr ShiftQuadSimple + + .skipYQuad + lda $01 : and #$04 : lsr : sta $048a ;fix layer calc 0->0 2->1 + lda $01 : and #$08 : lsr #2 : sta $0492 ;fix from layer calc 0->0 2->1 + ; shift lower coordinates + lda $02 : sta $22 : bne .adjY : lda $23 : !add $07 : sta $23 + .adjY lda $03 : sta $20 : bne .upDownAdj : inc $21 + .upDownAdj ldx #$08 + lda $0462 : and #$04 : beq .upStairs + ldx #$fd + lda $01 : and #$80 : bne .set53 + ; if target is also down adjust by (6,-15) + lda #$06 : !add $20 : sta $20 : lda #$eb : !add $22 : sta $22 : bra .set53 + .upStairs + lda $01 : and #$80 : beq .set53 + ; if target is also up adjust by (-6, 14) + lda #$fa : !add $20 : sta $20 : lda #$14 : !add $22 : sta $22 + bne .set53 : inc $23 + .set53 + txa : !add $22 : sta $53 + + lda $01 : and #$10 : sta $07 ; zeroHzCam check + ldy #$00 : jsr SetCamera + lda $01 : and #$20 : sta $07 ; zeroVtCam check + ldy #$01 : jsr SetCamera + + stz $045e ; clear the staircase flag + + ; animated tiles fix + lda.l DRMode : cmp #$02 : bne + ; only do this in crossed mode + ldx $a0 : lda.l TilesetTable, x + cmp $0aa1 : beq + ; already eq no need to decomp + sta $0aa1 + tax : lda $02802e, x : tay + jsl DecompDungAnimatedTiles + + + stz $047a + ply : plx : plb ; pull the stuff we pushed + lda $a2 : and #$0f ; this is the code we are hijacking + rtl +} + +;Sets the offset in A +LookupSpiralOffset: { + ;where link currently is in $a2: quad in a8 & #$03 + ;count doors + stz $00 : ldx #$00 : stz $01 + + .loop + lda $047e, x : cmp $00 : bcc .continue + sta $00 + .continue inx #2 + cpx #$08 : bcc .loop + + lda $00 : lsr + cmp #$01 : beq .done + + ; look up the quad + lda $a9 : ora $aa : and #$03 : beq .quad0 + cmp #$01 : beq .quad1 + cmp #$02 : beq .quad2 + cmp #$03 : beq .quad3 + .quad0 + inc $01 : lda $a2 + cmp #$0c : beq .q0diff ;gt ent + cmp #$70 : bne .done ;hc stairwell + .q0diff lda $22 : cmp #$00 : beq .secondDoor + cmp #$98 : bcc .done ;gt ent and hc stairwell + .secondDoor inc $01 : bra .done + .quad1 + lda $a2 + cmp #$1a : beq .q1diff ;pod compass + cmp #$26 : beq .q1diff ;swamp elbows + cmp #$6a : beq .q1diff ;pod dark basement + cmp #$76 : bne .done ;swamp drain + .q1diff lda $22 : cmp #$98 : bcc .done + inc $01 : bra .done + .quad2 + lda #$03 : sta $01 : lda $a2 + cmp #$5f : beq .iceu ;ice u room + cmp #$3f : bne .done ;hammer ice exception + stz $01 : bra .done + .iceu lda $22 : cmp #$78 : bcc .done + inc $01 : bra .done + .quad3 + lda $a2 : cmp #$40 : beq .done ; top of aga exception + lda #$02 : sta $01 ; always 2 + + .done + lda $a2 : tax : lda.w SpiralOffset,x + !add $01 ;add a thing (0 in easy case) + rts +} + +ShiftQuadSimple: { + lda.w CoordIndex,y : tax + lda $20,x : beq .skip + lda $21,x : !add $06 : sta $21,x ; coordinate update + .skip + lda.w CamQuadIndex,y : tax + lda $0601,x : !add $06 : sta $0601,x + lda $0605,x : !add $06 : sta $0605,x ; high bytes of these guys + rts +} + +SetCamera: { + stz $04 + tyx : lda $a9,x : bne .nonZeroHalf + lda.w CamQuadIndex,y : tax : lda $607,x : pha + lda.w CameraIndex,y : tax : pla : cmp $e3, x : bne .noQuadAdj + dec $e3,x + + .noQuadAdj + lda $07 : bne .adj0 + lda.w CoordIndex,y : tax + lda $20,x : beq .oddQuad + cmp #$79 : bcc .adj0 + !sub #$78 : sta $04 + tya : asl : !add #$04 : tax : jsr AdjCamBounds : bra .done + .oddQuad + lda #$80 : sta $04 : bra .adj1 ; this is such a weird case - quad cross boundary + .adj0 + tya : asl : tax : jsr AdjCamBounds : bra .done + + .nonZeroHalf ;meaning either right half or bottom half + lda $07 : bne .setQuad + lda.w CoordIndex,y : tax + lda $20,x : cmp #$78 : bcs .setQuad + !add #$78 : sta $04 + lda.w CamQuadIndex,y : tax : lda $0603, x : pha + lda.w CameraIndex,y : tax : pla : sta $e3, x + .adj1 + tya : asl : !add #$08 : tax : jsr AdjCamBounds : bra .done + + .setQuad + lda.w CamQuadIndex,y : tax : lda $0607, x : pha + lda.w CameraIndex,y : tax : pla : sta $e3, x + tya : asl : !add #$0c : tax : jsr AdjCamBounds : bra .done + + .done + lda.w CameraIndex,y : tax + lda $04 : sta $e2, x + rts +} + +; input, expects X to be an appropriate offset into the CamBoundBaseLine table +; when $04 is 0 no coordinate are added +AdjCamBounds: { + rep #$20 : lda.w CamBoundBaseLine, x : sta $05 + lda $04 : and #$00ff : beq .common + lda.w CoordIndex,y : tax + lda $20, x : and #$00ff : !add $05 : sta $05 + .common + lda.w OppCamBoundIndex,y : tax + lda $05 : sta $0618, x + inc #2 : sta $061A, x : sep #$20 + rts +} + +SpiralPriorityHack: { + lda.l DRMode : beq + + lda #$01 : rtl ; always skip the priority code - until I figure out how to fix it + + lda $0462 : and #$04 ; what we wrote over + rtl +} \ No newline at end of file