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 1/5] 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 2/5] 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 3/5] 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 4/5] 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 5/5] 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])?;