From ed6d42b2e28a7a9149e6bb77e794a5bcc917c5fa Mon Sep 17 00:00:00 2001 From: Matthew Berry Date: Sun, 7 Feb 2021 11:52:28 -0800 Subject: [PATCH] fixed golden sun saves (return 64k flash id for 64k chips) --- src/crab/storage/flash.cr | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/crab/storage/flash.cr b/src/crab/storage/flash.cr index f1c0912..c1a05f6 100644 --- a/src/crab/storage/flash.cr +++ b/src/crab/storage/flash.cr @@ -20,18 +20,20 @@ class Flash < Storage SET_BANK = 0xB0 end - SANYO = 0x1362_u16 - @state = State::READY @bank = 0_u8 def initialize(@type : Type) @memory = Bytes.new(@type.bytes, 0xFF) + @id = case @type + when Type::FLASH1M then 0x1362 # Sanyo + else 0x1B32 # Panasonic + end end def [](index : Int) : Byte if @state.includes?(State::IDENTIFICATION) && 0 <= index <= 1 - (SANYO >> (8 * index) & 0xFF).to_u8! + (@id >> (8 * index) & 0xFF).to_u8! else @memory[0x10000 * @bank + index] end