From d25f8efc9362ee1f924003580261041386be313d Mon Sep 17 00:00:00 2001 From: nn <53490794+nn357@users.noreply.github.com> Date: Wed, 26 Aug 2026 05:24:00 +0900 Subject: [PATCH 01/10] initial comit todo: sum the nothings / not placed and write them to rom should be complete: item count addition on item collection, newgame with starting items increases number, credits displayed as a fraction is not 100 items placed. --- patches/ips/escape.ips | Bin 1813 -> 1764 bytes patches/ips/escape_items.ips | Bin 121 -> 50 bytes patches/ips/item_count.ips | Bin 0 -> 304 bytes patches/ips/new_game.ips | Bin 466 -> 480 bytes patches/rom_map/Bank DF.txt | 2 + patches/rom_map/RAM.txt | 4 +- patches/src/escape.asm | 16 ++-- patches/src/escape_items.asm | 52 +++++------ patches/src/item_count.asm | 170 +++++++++++++++++++++++++++++++++++ patches/src/new_game.asm | 6 ++ rust/maprando/src/patch.rs | 17 ++++ 11 files changed, 231 insertions(+), 36 deletions(-) create mode 100644 patches/ips/item_count.ips create mode 100644 patches/src/item_count.asm diff --git a/patches/ips/escape.ips b/patches/ips/escape.ips index 14c924830ebb49d02888895c5b7b475a84748af9..f80451da6943db47e0c69692c0afca353abf36bb 100644 GIT binary patch delta 12 TcmbQr_k?%D1;)*cOd_lRAL|3< delta 61 zcmaFDJC$$41x5qbXVDDIi=-G>pCvLd+c5lO{mH-}!^oh(z{0>Fz{J48z`)4B1mrp} OG%&CLiOuI3MOgvRRSawZ diff --git a/patches/ips/escape_items.ips b/patches/ips/escape_items.ips index 0c1a28af8c345832b743112598adcbb6bf955d01..0c832380f8fcfa57df3fb69658f6be966e4457ac 100644 GIT binary patch delta 29 lcmb<45)W_;arO{7E5yK}RPcMH$nOFM8Kt#PCQgi#1^|h@3P}I} literal 121 zcmWG=3~}~g;$&iAR$%zd#Hk6T10ZxU0|RgG63(@;@{$Y;y|MBMtk3j;G6~;Vzb7zo z0fm8*i#Qk(M9vB^uqYM$UMcdsfI&%V?URXXmv92ruhjqEyNDC0XeChlB~B&1Sq(~d Kvl_Bp{oMe7ZY2!> diff --git a/patches/ips/item_count.ips b/patches/ips/item_count.ips new file mode 100644 index 0000000000000000000000000000000000000000..5e643160ba7d40be1878be21706cc6decffada93 GIT binary patch literal 304 zcmWG=3~}~g;!tGZ@mTwgQ>ynJ=ZO;;2}~Rx7?^z&JD51dp|l;8PKDCVP2w!Nh>>0f_ { "fix_dust_torizo", "fix_choot", "resource_collection_hudcap", + "item_count", ]; patches.push("new_game"); @@ -2317,6 +2318,22 @@ impl Patcher<'_> { .into_iter() .collect(); + let mut starting_item_count: isize = 0; + for x in self.starting_items { + if x.count == 0 { + continue; + } + match x.item { + Item::Missile | Item::ETank | Item::ReserveTank | Item::Super | Item::PowerBomb => { + starting_item_count += x.count as isize; + } + _ => { + starting_item_count += 1; + } + } + } + self.rom.write_u16(snes2pc(0xDFFF10), starting_item_count)?; + for x in self.starting_items { if x.count == 0 { continue; From 199e510a887c5590514fbe653125b051de71d7a7 Mon Sep 17 00:00:00 2001 From: nn <53490794+nn357@users.noreply.github.com> Date: Wed, 26 Aug 2026 19:57:23 +0900 Subject: [PATCH 02/10] add custom '/' tile to fractional end credits --- patches/ips/item_count.ips | Bin 304 -> 475 bytes patches/rom_map/Bank DF.txt | 3 +- patches/src/item_count.asm | 83 ++++++++++++++++++++++++++++++++---- 3 files changed, 77 insertions(+), 9 deletions(-) diff --git a/patches/ips/item_count.ips b/patches/ips/item_count.ips index 5e643160ba7d40be1878be21706cc6decffada93..e9cf61c30348fd1ff29c1739e85eb25917465893 100644 GIT binary patch delta 242 zcmdnMbenlX665iS$&QBRim4qVfBxM7#49nGFU6*q}lM{=gNj&QAHpjrnu6hS6p!=V=sgAN{L=Z z=anVBOwKDG^)frJyx+^>yi%c;)p-t^Gf)Ay6GXiyNc|MJDr5y3*$gni&nC%ZETIPD fG8jTx5-A2}5@s-bfJ>k;^#AiQFflN=`nv%DB=|`Q delta 70 zcmcc3yn$ʘ{C$&R|liHARfCQI{EMf!EE1N9( X7Z}&AoHX%j80UXJ1||juSARDE`0yLn diff --git a/patches/rom_map/Bank DF.txt b/patches/rom_map/Bank DF.txt index f5b35a72df..8e421113f3 100644 --- a/patches/rom_map/Bank DF.txt +++ b/patches/rom_map/Bank DF.txt @@ -2,7 +2,8 @@ D4DF - D761: ; credits.asm D91B - DF0A: ; credits.asm E000 - E127: ; credits.asm E200 - E212: ; alternate_door_colors.asm -E212 - FEEF: [free] +E212 - E2B4: ; item_count.asm +E2B4 - FEEF: [free] FEF0 - FEFF: seed name (null-terminated ASCII string) FF00 - FF03: display seed / internal seed hash FF04 - FF04: [FREE] diff --git a/patches/src/item_count.asm b/patches/src/item_count.asm index 210da394e0..e8f4cceac2 100644 --- a/patches/src/item_count.asm +++ b/patches/src/item_count.asm @@ -109,22 +109,23 @@ org $8be627 bra .percent_symbol .fractional + jsl load_fractional_tiles ; transfer custom '/' tile to VRAM lda #$0064 sec sbc !unplaced_total - sta $14 ; denominator + sta $14 - lda !item_count ; numerator + lda !item_count ldx #$0000 jsr .digit2 - lda $14 ; denominator + lda $14 ldx #$0006 jsr .digit2 - lda #$3882 ; FIXME: come up with a better slash. + lda #$3888 ; add custom '/' tile to tilemap sta $7e33a0 - lda #$3892 + lda #$3898 sta $7e33e0 bra .finished @@ -165,6 +166,72 @@ org $8be627 sta $7e33de,x rts -assert pc() <= $8be741; Tilemap values for decimal digits: - -;8BE6ED \ No newline at end of file +assert pc() <= $8be741 ; Tilemap values for decimal digits: + +;8BE6ED + +org $dfe212 + +load_fractional_tiles: + + php + sep #$30 +WaitVB: + lda $4212 + and #$80 + beq WaitVB + + lda #$80 ; top_slash → $4880 + sta $2115 + lda #$80 + sta $2116 + lda #$48 + sta $2117 + + lda #$01 + sta $4300 + lda #$18 + sta $4301 + lda.b #top_slash + sta $4302 + lda.b #top_slash>>8 + sta $4303 + lda #$DF + sta $4304 + lda #$20 + sta $4305 + stz $4306 + lda #$01 + sta $420B + + lda #$80 ; bottom_slash → $4980 + sta $2116 + lda #$49 + sta $2117 + + lda.b #bottom_slash + sta $4302 + lda.b #bottom_slash>>8 + sta $4303 + lda #$20 + sta $4305 + stz $4306 + lda #$01 + sta $420B + + plp + rtl + +top_slash: + db $00,$00,$00,$00,$00,$00,$00,$00 + db $00,$0F,$06,$19,$0C,$33,$18,$26 + db $00,$00,$00,$00,$00,$00,$00,$00 + db $00,$00,$00,$00,$00,$00,$00,$00 + +bottom_slash: + db $18,$64,$30,$CC,$60,$98,$00,$F0 + db $00,$00,$00,$00,$00,$00,$00,$00 + db $00,$00,$00,$00,$00,$00,$00,$00 + db $00,$00,$00,$00,$00,$00,$00,$00 + +assert pc() <= $dfe2b4 \ No newline at end of file From f20f1f4eb76e4aa3abd2ba60048c281e61ed486e Mon Sep 17 00:00:00 2001 From: nn <53490794+nn357@users.noreply.github.com> Date: Wed, 26 Aug 2026 20:09:57 +0900 Subject: [PATCH 03/10] Update patch.rs --- rust/maprando/src/patch.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rust/maprando/src/patch.rs b/rust/maprando/src/patch.rs index 5afb241e90..4c660fea20 100644 --- a/rust/maprando/src/patch.rs +++ b/rust/maprando/src/patch.rs @@ -840,6 +840,7 @@ impl Patcher<'_> { } fn place_items(&mut self) -> Result<()> { + let mut nothing_count: isize = 0; for (&item, &loc) in iter::zip( &self.randomization.item_placement, &self.game_data.item_locations, @@ -849,6 +850,7 @@ impl Patcher<'_> { let new_plm_type = item_to_plm_type(item, orig_plm_type); self.rom.write_u16(item_plm_ptr, new_plm_type)?; if item == Item::Nothing { + nothing_count += 1; let idx = self.rom.read_u16(item_plm_ptr + 4).unwrap() as usize; self.nothing_item_bitmask[idx >> 3] |= 1 << (idx & 7); @@ -860,6 +862,7 @@ impl Patcher<'_> { } } } + self.rom.write_u16(snes2pc(0xdfff0e), nothing_count)?; Ok(()) } From 210378b98aba1c1669b009bc4301413caa6734b2 Mon Sep 17 00:00:00 2001 From: nn <53490794+nn357@users.noreply.github.com> Date: Wed, 26 Aug 2026 23:05:26 +0900 Subject: [PATCH 04/10] add exception for escape seeds otherwise it displays as 0/00 due to nothings being placed everywhere. --- patches/rom_map/Bank DF.txt | 2 +- patches/src/item_count.asm | 11 +++++++++-- rust/maprando/src/patch.rs | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/patches/rom_map/Bank DF.txt b/patches/rom_map/Bank DF.txt index 8e421113f3..03e44e61e8 100644 --- a/patches/rom_map/Bank DF.txt +++ b/patches/rom_map/Bank DF.txt @@ -6,7 +6,7 @@ E212 - E2B4: ; item_count.asm E2B4 - FEEF: [free] FEF0 - FEFF: seed name (null-terminated ASCII string) FF00 - FF03: display seed / internal seed hash -FF04 - FF04: [FREE] +FF04 - FF04: ; item_count.asm (set to non zero for escape seeds in patch.rs) FF05 - FF06: randomizer settings: - bitmask $0001: walljump-boots item enabled - bitmask $0002: split speedbooster item enabled diff --git a/patches/src/item_count.asm b/patches/src/item_count.asm index e8f4cceac2..472fc78e32 100644 --- a/patches/src/item_count.asm +++ b/patches/src/item_count.asm @@ -8,11 +8,15 @@ ; credits % is displayed as a fraction if every item isn't placed. ; nn_357 -!unplaced_total = $dfff0e ; overwritten by patch.rs, contains the sum of 'nothing' and 'not_placed' +!escape_seed = $dfff04 ; overwritten in patch.rs +!unplaced_total = $dfff0e ; overwritten by patch.rs, contains the sum of 'nothing' and 'not_placed' !item_count = $09ee org !unplaced_total dw $0000 + +org !escape_seed + db $00 org $848821 ;;; $8821: Unused. Instruction - set the boss bits [[Y]] ;;; New routine - Update sum of items collected. preserves [A] unnecessary? item_count: @@ -82,13 +86,16 @@ org $8be627 rep #$30 phx phy + lda !escape_seed + and #$00ff + bne .is_100 lda !unplaced_total bne .fractional lda !item_count cmp #$0064 bne .not_100 - ;100% completion +.is_100 ; 100% completion / escape seed. lda $e745 sta $7e339c lda $e747 diff --git a/rust/maprando/src/patch.rs b/rust/maprando/src/patch.rs index 4c660fea20..d4af55bbf6 100644 --- a/rust/maprando/src/patch.rs +++ b/rust/maprando/src/patch.rs @@ -2434,12 +2434,13 @@ impl Patcher<'_> { let initial_area_addr = snes2pc(0xB5FE00); let initial_load_station_addr = snes2pc(0xB5FE02); let initial_boss_bits = snes2pc(0xB5FE0C); + let is_escape_seed = snes2pc(0xDFFF04); if self.settings.start_location_settings.mode == StartLocationMode::Escape { // Use Tourian load station 2, set up in escape_autosave.asm self.rom.write_u16(initial_area_addr, 5)?; self.rom.write_u16(initial_load_station_addr, 2)?; - + self.rom.write_u8(is_escape_seed, 1)?; // Set all bosses defeated: self.rom.write_n(initial_boss_bits, &[7, 7, 7, 7, 7, 7])?; From e712ada7ff60e2567dace575664c0b7cc1b759c4 Mon Sep 17 00:00:00 2001 From: nn <53490794+nn357@users.noreply.github.com> Date: Thu, 27 Aug 2026 01:11:05 +0900 Subject: [PATCH 05/10] add updated item_count.ips --- patches/ips/item_count.ips | Bin 475 -> 485 bytes patches/rom_map/Bank DF.txt | 2 +- patches/src/item_count.asm | 58 ++++++++++++++++++++++-------------- rust/maprando/src/patch.rs | 2 -- 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/patches/ips/item_count.ips b/patches/ips/item_count.ips index e9cf61c30348fd1ff29c1739e85eb25917465893..77ea3c4374523163d20874a302218cc1792b6b8e 100644 GIT binary patch delta 113 zcmcc3{FHe@lGsI#ZtvBH3~oiO=lg&E1IKv*Aj#A)vA{&rauE}Q!ro^MhDt(@?ypQ? zuy_wrv9DER?K{pz3?QkcB8%97^u*K0`PrFx**Muad4ze4B-A8SCNE?Z=Jqi-kuW1+ Og2M)e2b1?R$^ZZ<(Jfv8 delta 117 zcmaFLe4BYf65nx-ZtvBH3~oiO=lg&E!o&&_b@N3`3<{f{HRvk|J-WX#g~8%IP^ML6 x?K{pz3?PZ6B8%97^u(*jbs3<5pG}g-SV9fPh0ziz24@mxFnoaUC!b`L0RT@VBn|)o diff --git a/patches/rom_map/Bank DF.txt b/patches/rom_map/Bank DF.txt index 03e44e61e8..22dceb1a9f 100644 --- a/patches/rom_map/Bank DF.txt +++ b/patches/rom_map/Bank DF.txt @@ -6,7 +6,7 @@ E212 - E2B4: ; item_count.asm E2B4 - FEEF: [free] FEF0 - FEFF: seed name (null-terminated ASCII string) FF00 - FF03: display seed / internal seed hash -FF04 - FF04: ; item_count.asm (set to non zero for escape seeds in patch.rs) +FF04 - FF04: [free] FF05 - FF06: randomizer settings: - bitmask $0001: walljump-boots item enabled - bitmask $0002: split speedbooster item enabled diff --git a/patches/src/item_count.asm b/patches/src/item_count.asm index 472fc78e32..9cf9d1b0d2 100644 --- a/patches/src/item_count.asm +++ b/patches/src/item_count.asm @@ -6,17 +6,18 @@ ; $09ee contains number of collected items. ; ; credits % is displayed as a fraction if every item isn't placed. -; nn_357 +; nn_357 / StagShot -!escape_seed = $dfff04 ; overwritten in patch.rs -!unplaced_total = $dfff0e ; overwritten by patch.rs, contains the sum of 'nothing' and 'not_placed' +; !escape_seed = $dfff04 ; overwritten in patch.rs +!starting_items_count = $dfff10 ; overwritten in patch.rs, also referenced in new_game.asm +!unplaced_total = $dfff0e ; overwritten by patch.rs, contains the sum of 'nothing' !item_count = $09ee org !unplaced_total dw $0000 -org !escape_seed - db $00 +; org !escape_seed + ; db $00 org $848821 ;;; $8821: Unused. Instruction - set the boss bits [[Y]] ;;; New routine - Update sum of items collected. preserves [A] unnecessary? item_count: @@ -86,17 +87,19 @@ org $8be627 rep #$30 phx phy - lda !escape_seed - and #$00ff - bne .is_100 - lda !unplaced_total - bne .fractional + lda !unplaced_total ; everything placed? + beq .check_100 + cmp !starting_items_count ; nothing count = same as starting items? (seed has starting items / escape seed) + beq .check_100 + + bra .fractional ; seed has more nothings than starting items (desolate / small map / stop item placement) + +.check_100: lda !item_count cmp #$0064 bne .not_100 - -.is_100 ; 100% completion / escape seed. - lda $e745 +.is_100 + lda $e745 ; 100% completion sta $7e339c lda $e747 sta $7e33dc @@ -120,6 +123,7 @@ org $8be627 lda #$0064 sec sbc !unplaced_total + beq .is_100 ; if you set enough starting items / higher difficulty nothing will be placed, this can result in a xx/00, in which case just display 100%. sta $14 lda !item_count @@ -230,15 +234,25 @@ WaitVB: rtl top_slash: - db $00,$00,$00,$00,$00,$00,$00,$00 - db $00,$0F,$06,$19,$0C,$33,$18,$26 - db $00,$00,$00,$00,$00,$00,$00,$00 - db $00,$00,$00,$00,$00,$00,$00,$00 - + db $00, $07, $02, $0D, $06, $09, $06, $09 + db $0C, $13, $0C, $32, $18, $26, $18, $24 + db $00, $00, $00, $00, $00, $00, $00, $00 + db $00, $00, $00, $00, $00, $00, $00, $00 + +; db $00,$00,$00,$00,$00,$00,$00,$00 +; db $00,$0F,$06,$19,$0C,$33,$18,$26 +; db $00,$00,$00,$00,$00,$00,$00,$00 +; db $00,$00,$00,$00,$00,$00,$00,$00 + bottom_slash: - db $18,$64,$30,$CC,$60,$98,$00,$F0 - db $00,$00,$00,$00,$00,$00,$00,$00 - db $00,$00,$00,$00,$00,$00,$00,$00 - db $00,$00,$00,$00,$00,$00,$00,$00 + db $18, $64, $30, $4C, $30, $C8, $60, $98 + db $60, $90, $40, $B0, $00, $E0, $00, $00 + db $00, $00, $00, $00, $00, $00, $00, $00 + db $00, $00, $00, $00, $00, $00, $00, $00 + +; db $18,$64,$30,$CC,$60,$98,$00,$F0 +; db $00,$00,$00,$00,$00,$00,$00,$00 +; db $00,$00,$00,$00,$00,$00,$00,$00 +; db $00,$00,$00,$00,$00,$00,$00,$00 assert pc() <= $dfe2b4 \ No newline at end of file diff --git a/rust/maprando/src/patch.rs b/rust/maprando/src/patch.rs index d4af55bbf6..553bad69a4 100644 --- a/rust/maprando/src/patch.rs +++ b/rust/maprando/src/patch.rs @@ -2434,13 +2434,11 @@ impl Patcher<'_> { let initial_area_addr = snes2pc(0xB5FE00); let initial_load_station_addr = snes2pc(0xB5FE02); let initial_boss_bits = snes2pc(0xB5FE0C); - let is_escape_seed = snes2pc(0xDFFF04); if self.settings.start_location_settings.mode == StartLocationMode::Escape { // Use Tourian load station 2, set up in escape_autosave.asm self.rom.write_u16(initial_area_addr, 5)?; self.rom.write_u16(initial_load_station_addr, 2)?; - self.rom.write_u8(is_escape_seed, 1)?; // Set all bosses defeated: self.rom.write_n(initial_boss_bits, &[7, 7, 7, 7, 7, 7])?; From 41c938ce563a2ca8108d70b2751dee3a1f9df7a5 Mon Sep 17 00:00:00 2001 From: nn <53490794+nn357@users.noreply.github.com> Date: Thu, 27 Aug 2026 21:37:17 +0900 Subject: [PATCH 06/10] use itembits instead of modifying plms --- patches/ips/item_count.ips | Bin 485 -> 713 bytes patches/ips/new_game.ips | Bin 480 -> 460 bytes patches/rom_map/Bank 8B.txt | 1 + patches/rom_map/Bank DF.txt | 3 +- patches/src/item_count.asm | 191 ++++++++++++++++-------------------- patches/src/new_game.asm | 9 -- rust/maprando/src/patch.rs | 16 --- 7 files changed, 89 insertions(+), 131 deletions(-) diff --git a/patches/ips/item_count.ips b/patches/ips/item_count.ips index 77ea3c4374523163d20874a302218cc1792b6b8e..542658baa044efdc27809bb3043404eab415ad2f 100644 GIT binary patch literal 713 zcmWG=3~}~geWuQEmZRHy^&x{>Q3}#O*Yo|qf5C34kmi4elPL@rbk@2)@1J8_x7Pi6 z{~aLZ_`H7}kaB+Be-FZ20O36_u4}MZ#KfSm^I3y|g5A%RDGV0xfkw58fQ?$j0FqfM zvWN{tuk5hs2kKin!=fLgk8fp`MgJlozsjQjk#Swsuhkj}y(~_T6jpNevN^p1gF^~y zMVz>}R_t_qJ|F0uozBnagPbD<69YO5BnEU;0_#s{#>X6w3|2C<3N2vR_u%LLf*W;~ z?|-h^`|qbjs!*%Yi39u>UT7o$m8=zV(rozfb7e!Xs3MRMQ(WoME3UYbv6sPlr9>~I z^U4LiOwKER_A)!K?Cxc8Ua8Q_>O6AW)@a9b`DN10YM?*|Nr0r|0nI?Vl%U_u%h!};vhK|R#rAb^62Ve`apVF+1S`A)lbNL Zbo*fTg6w8vXXnuW&&R;Tz~Jid1^~8qxW51Z delta 245 zcmX@f`jojoz%j(xgNZ|tfyZO*J5H(Icbq3qWF#Gj)cG9Npfl4;kEwTF>|Y{s)fp0zi_f!3JpC$rOf(%DS4Cit9c74fY4kAxT&P5iIIUDC_syz)^m uv-8UPll2&-C8ogn3cak(bJ(0$GWK#iX=G1MWOU%t|If$3#K7R{?*;(-gi*Ty diff --git a/patches/ips/new_game.ips b/patches/ips/new_game.ips index 6662e8f981c062d4da307df971a1f8ab2cdecba2..8cb3a2425891fcd4621809f1a8fc194550e3a80e 100644 GIT binary patch delta 82 zcmV-Y0ImPv1Iz=ECp$>>p#g2v00ts#^`YwO0dCp=0Ur?b00D_2GWDVG157RTuLAzH ojf)457TJEU0RFX&p9hZ^*?x^%ACYO1k^!6nGLxMFIRiycMz=&FQ2+n{ delta 102 zcmV-s0Ga>H1K>8 sta $4303 - lda #$DF + lda #$8b sta $4304 lda #$20 sta $4305 @@ -231,7 +185,7 @@ WaitVB: sta $420B plp - rtl + rts top_slash: db $00, $07, $02, $0D, $06, $09, $06, $09 @@ -239,20 +193,49 @@ top_slash: db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 -; db $00,$00,$00,$00,$00,$00,$00,$00 -; db $00,$0F,$06,$19,$0C,$33,$18,$26 -; db $00,$00,$00,$00,$00,$00,$00,$00 -; db $00,$00,$00,$00,$00,$00,$00,$00 - bottom_slash: db $18, $64, $30, $4C, $30, $C8, $60, $98 db $60, $90, $40, $B0, $00, $E0, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 -; db $18,$64,$30,$CC,$60,$98,$00,$F0 -; db $00,$00,$00,$00,$00,$00,$00,$00 -; db $00,$00,$00,$00,$00,$00,$00,$00 -; db $00,$00,$00,$00,$00,$00,$00,$00 - -assert pc() <= $dfe2b4 \ No newline at end of file +offsettable: + db $00,$01,$02,$03,$04,$05,$06,$07,$08,$09,$0A,$10,$11,$12,$13 + +masktable: ; collected item bits + db %11111111 ; $00 - all + db %11111111 ; $01 - all + db %11101111 ; $02 - not bit 4 + db %11111111 ; $03 - all + db %11111110 ; $04 - not bit 0 + db %00011111 ; $05 - not bits 5,6,7 + db %11111111 ; $06 - all + db %11111111 ; $07 - all + db %11011111 ; $08 - no bit 5 + db %11111110 ; $09 - not bit 0 + db %00000001 ; $0A - only bit 0 + db %11111111 ; $10 - all + db %11111111 ; $11 - all + db %11111111 ; $12 - all + db %00000101 ; $13 - only bits 0 and 2 + +bitcounttable: + db $00,$01,$01,$02,$01,$02,$02,$03,$01,$02,$02,$03,$02,$03,$03,$04 + db $01,$02,$02,$03,$02,$03,$03,$04,$02,$03,$03,$04,$03,$04,$04,$05 + db $01,$02,$02,$03,$02,$03,$03,$04,$02,$03,$03,$04,$03,$04,$04,$05 + db $02,$03,$03,$04,$03,$04,$04,$05,$03,$04,$04,$05,$04,$05,$05,$06 + db $01,$02,$02,$03,$02,$03,$03,$04,$02,$03,$03,$04,$03,$04,$04,$05 + db $02,$03,$03,$04,$03,$04,$04,$05,$03,$04,$04,$05,$04,$05,$05,$06 + db $02,$03,$03,$04,$03,$04,$04,$05,$03,$04,$04,$05,$04,$05,$05,$06 + db $03,$04,$04,$05,$04,$05,$05,$06,$04,$05,$05,$06,$05,$06,$06,$07 + db $01,$02,$02,$03,$02,$03,$03,$04,$02,$03,$03,$04,$03,$04,$04,$05 + db $02,$03,$03,$04,$03,$04,$04,$05,$03,$04,$04,$05,$04,$05,$05,$06 + db $02,$03,$03,$04,$03,$04,$04,$05,$03,$04,$04,$05,$04,$05,$05,$06 + db $03,$04,$04,$05,$04,$05,$05,$06,$04,$05,$05,$06,$05,$06,$06,$07 + db $02,$03,$03,$04,$03,$04,$04,$05,$03,$04,$04,$05,$04,$05,$05,$06 + db $03,$04,$04,$05,$04,$05,$05,$06,$04,$05,$05,$06,$05,$06,$06,$07 + db $03,$04,$04,$05,$04,$05,$05,$06,$04,$05,$05,$06,$05,$06,$06,$07 + db $04,$05,$05,$06,$05,$06,$06,$07,$05,$06,$06,$07,$06,$07,$07,$08 + + +assert pc() <= !bank_8b_free_space_end \ No newline at end of file diff --git a/patches/src/new_game.asm b/patches/src/new_game.asm index 762f804ca6..546771aeb0 100644 --- a/patches/src/new_game.asm +++ b/patches/src/new_game.asm @@ -36,10 +36,6 @@ incsrc "constants.asm" !initial_max_power_bombs = $B5FE66 !initial_save_map_coords = $702602 !spin_lock_enabled = $1F70 -!starting_items_count = $DFFF10 ; overwritten in patch.rs - -org $dfff10 ; starting items count. -dw $0000 ;;; Hijack code that runs during initialization org $82801d @@ -86,8 +82,6 @@ startup: sta $1F5B ; Initialize items/flags collected/equipped: - lda !starting_items_count - sta $09ee lda !initial_items_collected sta $09A4 lda !initial_items_equipped @@ -133,9 +127,6 @@ startup: dex bne .item_bits_loop - ; Set items collected for escape (to make item collection rate show 100%, only applicable for "Escape" start): - lda #$F32F - sta $1F5D ; Unlock Tourian statues room (to avoid camera glitching when entering from bottom, and also to ensure game is ; beatable since we don't take it into account as an obstacle in the item randomization logic) diff --git a/rust/maprando/src/patch.rs b/rust/maprando/src/patch.rs index 553bad69a4..52e4f4e5e2 100644 --- a/rust/maprando/src/patch.rs +++ b/rust/maprando/src/patch.rs @@ -2321,22 +2321,6 @@ impl Patcher<'_> { .into_iter() .collect(); - let mut starting_item_count: isize = 0; - for x in self.starting_items { - if x.count == 0 { - continue; - } - match x.item { - Item::Missile | Item::ETank | Item::ReserveTank | Item::Super | Item::PowerBomb => { - starting_item_count += x.count as isize; - } - _ => { - starting_item_count += 1; - } - } - } - self.rom.write_u16(snes2pc(0xDFFF10), starting_item_count)?; - for x in self.starting_items { if x.count == 0 { continue; From 475837a42b4ee036c30d8d457354d3ee0a59abc8 Mon Sep 17 00:00:00 2001 From: nn <53490794+nn357@users.noreply.github.com> Date: Thu, 27 Aug 2026 23:27:48 +0900 Subject: [PATCH 07/10] mask off any initially set starting bits. fix count for desolate seeds. --- patches/ips/item_count.ips | Bin 713 -> 719 bytes patches/rom_map/Bank 8B.txt | 2 +- patches/src/item_count.asm | 21 +++++++++++++-------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/patches/ips/item_count.ips b/patches/ips/item_count.ips index 542658baa044efdc27809bb3043404eab415ad2f..00911fa3805870a92b23e694021bd58f8734e61c 100644 GIT binary patch delta 68 zcmV-K0K5Om1 Date: Fri, 28 Aug 2026 17:46:56 +0900 Subject: [PATCH 08/10] formatting / remove obsolete references --- patches/rom_map/Bank DF.txt | 1 - patches/src/item_count.asm | 215 ++++++++++++++++++------------------ 2 files changed, 106 insertions(+), 110 deletions(-) diff --git a/patches/rom_map/Bank DF.txt b/patches/rom_map/Bank DF.txt index 6dd952def4..270a1b95f6 100644 --- a/patches/rom_map/Bank DF.txt +++ b/patches/rom_map/Bank DF.txt @@ -13,4 +13,3 @@ FF07 - FF08: number of frames of artificial lag to add to the unpause black scre FF09 - FF0D: randomizer settings: skill/progression/qol/objectives/maplayout (autotracker use) - stored as single byte ordinal numbers, if a setting has a custom option then byte is set to 0 FF0E - FF0F: sum of unplaced / nothing items (used for item credits fractional display with stop item placement early) -FF10 - FF11: sum of starting items ; written by patch.rs. (added to collection % during new game) \ No newline at end of file diff --git a/patches/src/item_count.asm b/patches/src/item_count.asm index 3c95d77b1c..de15c59c49 100644 --- a/patches/src/item_count.asm +++ b/patches/src/item_count.asm @@ -7,7 +7,6 @@ !bank_8b_free_space_end = $8bfb06 !nothing_item_total = $dfff0e ; overwritten by patch.rs, contains the sum of 'nothing' !initial_item_bits = $b5fe12 - !item_count = $12 org !nothing_item_total @@ -25,7 +24,7 @@ itempercent: phx phy jsr countitems - lda !nothing_item_total ; everything placed? + lda !nothing_item_total bne .fractional lda !item_count @@ -33,7 +32,7 @@ itempercent: cmp #$0064 bne .not_100 - lda $e745 ; 100% completion + lda $e745 ; 100% completion sta $7e339c lda $e747 sta $7e33dc @@ -53,7 +52,7 @@ itempercent: bra .percent_symbol .fractional - jsr load_fractional_tiles ; transfer custom '/' tile to VRAM + jsr load_fractional_tiles lda #$0064 sec sbc !nothing_item_total @@ -68,7 +67,7 @@ itempercent: ldx #$0006 jsr .digit2 - lda #$3888 ; add custom '/' tile to tilemap + lda #$3888 ; add custom '/' tile to tilemap sta $7e33a0 lda #$3898 sta $7e33e0 @@ -111,87 +110,85 @@ itempercent: sta $7e33de,x rts -print pc -assert pc() <= $8be741 ; Tilemap values for decimal digits: - +assert pc() <= $8be741 ; Tilemap values for decimal digits: org !bank_8b_free_space_start countitems: - php - sep #$30 - - lda #$00 - sta $12 - ldy #$00 + php + sep #$30 + + lda #$00 + sta $12 + ldy #$00 .loop - ldx offsettable,y - lda !initial_item_bits,x - eor #$ff - and $7ed870,x - and masktable,y - tax - lda bitcounttable,x - clc - adc !item_count - sta !item_count - - iny - cpy #$0f - bne .loop - - plp - rts + ldx offsettable,y + lda !initial_item_bits,x + eor #$ff + and $7ed870,x + and masktable,y + tax + lda bitcounttable,x + clc + adc !item_count + sta !item_count + + iny + cpy #$0f + bne .loop + + plp + rts load_fractional_tiles: - php - sep #$30 + php + sep #$30 WaitVB: - lda $4212 - and #$80 - beq WaitVB - - lda #$80 ; top_slash → $4880 - sta $2115 - lda #$80 - sta $2116 - lda #$48 - sta $2117 - - lda #$01 - sta $4300 - lda #$18 - sta $4301 - lda.b #top_slash - sta $4302 - lda.b #top_slash>>8 - sta $4303 - lda #$8b - sta $4304 - lda #$20 - sta $4305 - stz $4306 - lda #$01 - sta $420B - - lda #$80 ; bottom_slash → $4980 - sta $2116 - lda #$49 - sta $2117 - - lda.b #bottom_slash - sta $4302 - lda.b #bottom_slash>>8 - sta $4303 - lda #$20 - sta $4305 - stz $4306 - lda #$01 - sta $420B - - plp - rts + lda $4212 + and #$80 + beq WaitVB + + lda #$80 ; top_slash → $4880 + sta $2115 + lda #$80 + sta $2116 + lda #$48 + sta $2117 + + lda #$01 + sta $4300 + lda #$18 + sta $4301 + lda.b #top_slash + sta $4302 + lda.b #top_slash>>8 + sta $4303 + lda #$8b + sta $4304 + lda #$20 + sta $4305 + stz $4306 + lda #$01 + sta $420B + + lda #$80 ; bottom_slash → $4980 + sta $2116 + lda #$49 + sta $2117 + + lda.b #bottom_slash + sta $4302 + lda.b #bottom_slash>>8 + sta $4303 + lda #$20 + sta $4305 + stz $4306 + lda #$01 + sta $420B + + plp + rts top_slash: db $00, $07, $02, $0D, $06, $09, $06, $09 @@ -206,41 +203,41 @@ bottom_slash: db $00, $00, $00, $00, $00, $00, $00, $00 offsettable: - db $00,$01,$02,$03,$04,$05,$06,$07,$08,$09,$0A,$10,$11,$12,$13 + db $00,$01,$02,$03,$04,$05,$06,$07,$08,$09,$0A,$10,$11,$12,$13 masktable: ; collected item bits - db %11111111 ; $00 - all - db %11111111 ; $01 - all - db %11101111 ; $02 - not bit 4 - db %11111111 ; $03 - all - db %11111110 ; $04 - not bit 0 - db %00011111 ; $05 - not bits 5,6,7 - db %11111111 ; $06 - all - db %11111111 ; $07 - all - db %11011111 ; $08 - no bit 5 - db %11111110 ; $09 - not bit 0 - db %00000001 ; $0A - only bit 0 - db %11111111 ; $10 - all - db %11111111 ; $11 - all - db %11111111 ; $12 - all - db %00000101 ; $13 - only bits 0 and 2 + db %11111111 ; $00 - all + db %11111111 ; $01 - all + db %11101111 ; $02 - not bit 4 + db %11111111 ; $03 - all + db %11111110 ; $04 - not bit 0 + db %00011111 ; $05 - not bits 5,6,7 + db %11111111 ; $06 - all + db %11111111 ; $07 - all + db %11011111 ; $08 - no bit 5 + db %11111110 ; $09 - not bit 0 + db %00000001 ; $0A - only bit 0 + db %11111111 ; $10 - all + db %11111111 ; $11 - all + db %11111111 ; $12 - all + db %00000101 ; $13 - only bits 0 and 2 bitcounttable: - db $00,$01,$01,$02,$01,$02,$02,$03,$01,$02,$02,$03,$02,$03,$03,$04 - db $01,$02,$02,$03,$02,$03,$03,$04,$02,$03,$03,$04,$03,$04,$04,$05 - db $01,$02,$02,$03,$02,$03,$03,$04,$02,$03,$03,$04,$03,$04,$04,$05 - db $02,$03,$03,$04,$03,$04,$04,$05,$03,$04,$04,$05,$04,$05,$05,$06 - db $01,$02,$02,$03,$02,$03,$03,$04,$02,$03,$03,$04,$03,$04,$04,$05 - db $02,$03,$03,$04,$03,$04,$04,$05,$03,$04,$04,$05,$04,$05,$05,$06 - db $02,$03,$03,$04,$03,$04,$04,$05,$03,$04,$04,$05,$04,$05,$05,$06 - db $03,$04,$04,$05,$04,$05,$05,$06,$04,$05,$05,$06,$05,$06,$06,$07 - db $01,$02,$02,$03,$02,$03,$03,$04,$02,$03,$03,$04,$03,$04,$04,$05 - db $02,$03,$03,$04,$03,$04,$04,$05,$03,$04,$04,$05,$04,$05,$05,$06 - db $02,$03,$03,$04,$03,$04,$04,$05,$03,$04,$04,$05,$04,$05,$05,$06 - db $03,$04,$04,$05,$04,$05,$05,$06,$04,$05,$05,$06,$05,$06,$06,$07 - db $02,$03,$03,$04,$03,$04,$04,$05,$03,$04,$04,$05,$04,$05,$05,$06 - db $03,$04,$04,$05,$04,$05,$05,$06,$04,$05,$05,$06,$05,$06,$06,$07 - db $03,$04,$04,$05,$04,$05,$05,$06,$04,$05,$05,$06,$05,$06,$06,$07 - db $04,$05,$05,$06,$05,$06,$06,$07,$05,$06,$06,$07,$06,$07,$07,$08 + db $00,$01,$01,$02,$01,$02,$02,$03,$01,$02,$02,$03,$02,$03,$03,$04 + db $01,$02,$02,$03,$02,$03,$03,$04,$02,$03,$03,$04,$03,$04,$04,$05 + db $01,$02,$02,$03,$02,$03,$03,$04,$02,$03,$03,$04,$03,$04,$04,$05 + db $02,$03,$03,$04,$03,$04,$04,$05,$03,$04,$04,$05,$04,$05,$05,$06 + db $01,$02,$02,$03,$02,$03,$03,$04,$02,$03,$03,$04,$03,$04,$04,$05 + db $02,$03,$03,$04,$03,$04,$04,$05,$03,$04,$04,$05,$04,$05,$05,$06 + db $02,$03,$03,$04,$03,$04,$04,$05,$03,$04,$04,$05,$04,$05,$05,$06 + db $03,$04,$04,$05,$04,$05,$05,$06,$04,$05,$05,$06,$05,$06,$06,$07 + db $01,$02,$02,$03,$02,$03,$03,$04,$02,$03,$03,$04,$03,$04,$04,$05 + db $02,$03,$03,$04,$03,$04,$04,$05,$03,$04,$04,$05,$04,$05,$05,$06 + db $02,$03,$03,$04,$03,$04,$04,$05,$03,$04,$04,$05,$04,$05,$05,$06 + db $03,$04,$04,$05,$04,$05,$05,$06,$04,$05,$05,$06,$05,$06,$06,$07 + db $02,$03,$03,$04,$03,$04,$04,$05,$03,$04,$04,$05,$04,$05,$05,$06 + db $03,$04,$04,$05,$04,$05,$05,$06,$04,$05,$05,$06,$05,$06,$06,$07 + db $03,$04,$04,$05,$04,$05,$05,$06,$04,$05,$05,$06,$05,$06,$06,$07 + db $04,$05,$05,$06,$05,$06,$06,$07,$05,$06,$06,$07,$06,$07,$07,$08 assert pc() <= !bank_8b_free_space_end \ No newline at end of file From 9132890de2fad2667feb091ec60a7787e451f532 Mon Sep 17 00:00:00 2001 From: nn <53490794+nn357@users.noreply.github.com> Date: Fri, 28 Aug 2026 17:53:52 +0900 Subject: [PATCH 09/10] Update RAM.txt missed updating this. --- patches/rom_map/RAM.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/patches/rom_map/RAM.txt b/patches/rom_map/RAM.txt index 202a1a9d75..43f496c4e6 100644 --- a/patches/rom_map/RAM.txt +++ b/patches/rom_map/RAM.txt @@ -2,10 +2,9 @@ $95: temporary variable (unused debug location) - used by extended messageboxes, $9B: decompression.asm $CF: vanilla_bugfixes.asm (used by crash dialogues to prevent unpause from resetting gamestate.) $09EC: number of disabled ETanks (saved to SRAM) -$09EE: collected item_count (saved to SRAM) $0A1A: previous reserve health (reserve_hud.asm) $1F5B: map area (like $079F) -$1F5D: [free] - previously used as escape items snapshot. +$1F5D: [free]. $1F60: fast_reload.asm $1F62: map area backup in pause menu (like $079F) $1F64: escape refill complete From 3886ddd3d724386332a373c2a6f44029a08000bf Mon Sep 17 00:00:00 2001 From: nn <53490794+nn357@users.noreply.github.com> Date: Sat, 29 Aug 2026 14:07:24 +0900 Subject: [PATCH 10/10] update bank docs --- patches/rom_map/Bank B5.txt | 2 +- patches/src/item_count.asm | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/rom_map/Bank B5.txt b/patches/rom_map/Bank B5.txt index 7466a087ef..09881a7414 100644 --- a/patches/rom_map/Bank B5.txt +++ b/patches/rom_map/Bank B5.txt @@ -8,7 +8,7 @@ FE06 - FE07: Initial items equipped (to be copied to $09A2) FE08 - FE09: Initial beams collected (to be copied to $09A8) FE0A - FE0B: Initial beams equipped (to be copied to $09A6) FE0C - FE11: Initial boss bits (to be copied to $7ED828-2E) -FE12 - FE51: Initial item bits (to be copied to $7ED870-B0) +FE12 - FE51: Initial item bits (to be copied to $7ED870-B0); [new_game.asm, item_count.asm] FE52 - FE53: Initial energy (to be copied to $09C2) FE54 - FE55: Initial max energy (to be copied to $09C4) FE56 - FE57: Initial reserves (to be copied to $09D6) diff --git a/patches/src/item_count.asm b/patches/src/item_count.asm index de15c59c49..4bedec3992 100644 --- a/patches/src/item_count.asm +++ b/patches/src/item_count.asm @@ -6,7 +6,7 @@ !bank_8b_free_space_start = $8bf91b !bank_8b_free_space_end = $8bfb06 !nothing_item_total = $dfff0e ; overwritten by patch.rs, contains the sum of 'nothing' -!initial_item_bits = $b5fe12 +!initial_item_bits = $b5fe12 ; modified by patch.rs, also used in new_game.asm !item_count = $12 org !nothing_item_total @@ -119,7 +119,7 @@ countitems: sep #$30 lda #$00 - sta $12 + sta !item_count ldy #$00 .loop