Skip to content

Commit

Permalink
new dump code work (inactive), new drive support, asus cfg refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
superg committed Jan 7, 2024
1 parent 4297d89 commit 3b3aced
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 33 deletions.
26 changes: 21 additions & 5 deletions cd/cd_dump_new.ixx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module;
#include <bit>
#include <cstdint>
#include <filesystem>
#include <fstream>
#include <numeric>
#include <span>
#include <string>
#include <vector>
Expand Down Expand Up @@ -297,14 +299,18 @@ export bool redumper_dump_cd_new(Context &ctx, const Options &options, DumpMode
if(read_as_data && options.dump_write_offset)
offset = -*options.dump_write_offset;

// DATA

write_entry(fs_scram, sector_buffer.data(), CD_DATA_SIZE, lba_index, 1, offset * CD_SAMPLE_SIZE);

// SUBCODE

if(subcode)
{
auto sc = sector_buffer.data() + CD_DATA_SIZE + CD_C2_SIZE;
auto subcode_data = sector_buffer.data() + CD_DATA_SIZE + CD_C2_SIZE;

ChannelQ Q;
subcode_extract_channel((uint8_t *)&Q, sc, Subchannel::Q);
subcode_extract_channel((uint8_t *)&Q, subcode_data, Subchannel::Q);
if(Q.isValid())
{
errors_q_last = errors_q;
Expand All @@ -322,13 +328,23 @@ export bool redumper_dump_cd_new(Context &ctx, const Options &options, DumpMode
++errors_q;
}

write_entry(fs_subcode, sc, CD_SUBCODE_SIZE, lba_index, 1, 0);
write_entry(fs_subcode, subcode_data, CD_SUBCODE_SIZE, lba_index, 1, 0);
}

std::vector<State> state = c2_to_state(std::span<uint8_t>(sector_buffer.data() + CD_DATA_SIZE, CD_C2_SIZE));
if(std::any_of(state.begin(), state.end(), [](State s){ return s == State::ERROR_C2; }))
// C2

auto c2_data = sector_buffer.data() + CD_DATA_SIZE;
auto c2_bits = std::accumulate(c2_data, c2_data + CD_C2_SIZE, (uint32_t)0, [](uint32_t a, uint8_t v){ return a + std::popcount(v); });
if(c2_bits)
{
++errors_c2;

if(options.verbose)
{
LOG_R("[LBA: {:6}] C2 error (bits: {:4})", lba, c2_bits);
}
}
std::vector<State> state = c2_to_state(std::span<uint8_t>(c2_data, CD_C2_SIZE));
write_entry(fs_state, (uint8_t *)state.data(), CD_DATA_SIZE_SAMPLES, lba_index, 1, offset);
}
else if(dump_mode == DumpMode::REFINE)
Expand Down
2 changes: 1 addition & 1 deletion debug.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ export void redumper_debug(Context &ctx, Options &options)
// LG/ASUS cache dump extract
if(0)
{
auto drive_type = DriveConfig::Type::LG_ASU83;
std::vector<uint8_t> cache = read_vector(cache_path);

auto drive_type = DriveConfig::Type::LG_ASU8C;
asus_cache_print_subq(cache, drive_type);

// auto asd = asus_cache_unroll(cache);
Expand Down
58 changes: 31 additions & 27 deletions drive.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ export struct DriveConfig
{
GENERIC,
PLEXTOR,
LG_ASU8,
LG_ASU83,
LG_ASU8A,
LG_ASU8B,
LG_ASU8C,
LG_ASU3,
LG_ASU2
} type;
Expand Down Expand Up @@ -99,8 +100,9 @@ static const std::map<DriveConfig::Type, std::string> TYPE_STRING =
{
{DriveConfig::Type::GENERIC, "GENERIC"},
{DriveConfig::Type::PLEXTOR, "PLEXTOR"},
{DriveConfig::Type::LG_ASU8, "LG_ASU8"},
{DriveConfig::Type::LG_ASU83, "LG_ASU83"},
{DriveConfig::Type::LG_ASU8A, "LG_ASU8A"},
{DriveConfig::Type::LG_ASU8B, "LG_ASU8B"},
{DriveConfig::Type::LG_ASU8C, "LG_ASU8C"},
{DriveConfig::Type::LG_ASU3, "LG_ASU3"},
{DriveConfig::Type::LG_ASU2, "LG_ASU2"}
};
Expand Down Expand Up @@ -175,27 +177,28 @@ static const std::vector<DriveConfig> KNOWN_DRIVES =
{"PLEXTOR", "DVDR PX-760A" , "1.07", "08/18/07 15:10", +30, 295, -75, DriveConfig::ReadMethod::D8, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::PLEXTOR}, // CHECKED

// LG/ASUS (8Mb/3Mb/2Mb cache)
{"ATAPI" , "iHBS112 2" , "PL06", "2012/09/17 10:50" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8}, // CHECKED: LITE-ON
{"HL-DT-ST", "BD-RE BU40N" , "1.00", "N003103MOAL36D3653" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU83},// RibShark
{"ASUS" , "BW-16D1HT" , "3.02", "W000800KL8J9NJ3134" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU3}, // CHECKED
{"HL-DT-ST", "BD-RE BH16NS55" , "1.02", "N000200SIK92G9OF211", +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU3}, // TheMuso
{"HL-DT-ST", "BD-RE BP50NB40" , "1.00", "N005505MD8F8BD0700" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU3}, // olofolleola4
{"Slimtype", "BD E DS4E1S" , "EA2B", "2009/11/13 15:21" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU2}, // olofolleola4
{"Optiarc", "BD RW BD-5300S" , "2.03", "2012/02/07 11:25" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8}, // olofolleola4
{"TEAC" , "BD-W512GSA" , "PT11", "2012/12/05 19:08" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8}, // olofolleola4
{"ASUS" , "BW-12B1ST" , "1.03", "2011/04/18 21:48" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8}, // olofolleola4
{"SONY" , "BD RW BWU-500S" , "2.63", "2012/02/07 11:48" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8}, // olofolleola4
{"PLDS" , "BD-RE DH-8B2SH" , "SD11", "2011/01/11 17:17" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8}, // olofolleola4
{"hp" , "BD B DH8B2SHB" , "SHDQ", "2012/05/09 11:33" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8}, // olofolleola4
{"PLEXTOR", "BD-R PX-B950SA" , "1.04", "2012/10/30 10:10" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8}, // olofolleola4
{"PLEXTOR", "BD-R PX-B950UE" , "1.05", "2012/10/30 10:10" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8}, // olofolleola4
{"PLEXTOR", "BD-R PX-LB950SA" , "1.04", "2012/10/30 10:10" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8}, // olofolleola4
{"PLEXTOR", "BD-R PX-LB950UE" , "1.05", "2012/10/30 10:10" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8}, // olofolleola4
{"HP" , "BD Writer bd335e", "YH23", "2011/09/09 13:10" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8}, // olofolleola4
{"HP" , "BD Writer bd335i", "QH21", "2011/05/26 13:49" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8}, // olofolleola4
{"ATAPI" , "eHBU212 2" , "ZL06", "2012/11/05 16:10" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8}, // olofolleola4
{"ATAPI" , "iHBS212 2" , "HL05", "2012/09/17 10:50" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8}, // olofolleola4
{"ATAPI" , "iHBS312 2" , "PL17", "2012/10/31 13:50" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8}, // olofolleola4
{"ATAPI" , "iHBS112 2" , "PL06", "2012/09/17 10:50" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8A}, // CHECKED: LITE-ON
{"HL-DT-ST", "BD-RE BU40N" , "1.00", "N003103MOAL36D3653" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8B},// RibShark
{"ASUS" , "BW-16D1HT" , "3.02", "W000800KL8J9NJ3134" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU3}, // CHECKED
{"HL-DT-ST", "BD-RE BH16NS55" , "1.02", "N000200SIK92G9OF211", +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU3}, // TheMuso
{"HL-DT-ST", "BD-RE BP50NB40" , "1.00", "N005505MD8F8BD0700" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU3}, // olofolleola4
{"Slimtype", "BD E DS4E1S" , "EA2B", "2009/11/13 15:21" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU2}, // olofolleola4
{"Optiarc" , "BD RW BD-5300S" , "2.03", "2012/02/07 11:25" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8A}, // olofolleola4
{"TEAC" , "BD-W512GSA" , "PT11", "2012/12/05 19:08" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8A}, // olofolleola4
{"ASUS" , "BW-12B1ST" , "1.03", "2011/04/18 21:48" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8A}, // olofolleola4
{"SONY" , "BD RW BWU-500S" , "2.63", "2012/02/07 11:48" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8A}, // olofolleola4
{"PLDS" , "BD-RE DH-8B2SH" , "SD11", "2011/01/11 17:17" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8A}, // olofolleola4
{"hp" , "BD B DH8B2SHB" , "SHDQ", "2012/05/09 11:33" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8A}, // olofolleola4
{"PLEXTOR" , "BD-R PX-B950SA" , "1.04", "2012/10/30 10:10" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8A}, // olofolleola4
{"PLEXTOR" , "BD-R PX-B950UE" , "1.05", "2012/10/30 10:10" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8A}, // olofolleola4
{"PLEXTOR" , "BD-R PX-LB950SA" , "1.04", "2012/10/30 10:10" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8A}, // olofolleola4
{"PLEXTOR" , "BD-R PX-LB950UE" , "1.05", "2012/10/30 10:10" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8A}, // olofolleola4
{"HP" , "BD Writer bd335e", "YH23", "2011/09/09 13:10" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8A}, // olofolleola4
{"HP" , "BD Writer bd335i", "QH21", "2011/05/26 13:49" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8A}, // olofolleola4
{"ATAPI" , "eHBU212 2" , "ZL06", "2012/11/05 16:10" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8A}, // olofolleola4
{"ATAPI" , "iHBS212 2" , "HL05", "2012/09/17 10:50" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8A}, // olofolleola4
{"ATAPI" , "iHBS312 2" , "PL17", "2012/10/31 13:50" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8A}, // olofolleola4
{"HL-DT-ST", "BD-RE WH14NS40" , "1.03", "N0A09A0K9HF6ND5914" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::LG_ASU8C}, // Lugamo

// OTHER
{"ASUS" , "BW-16D1HT" , "3.10", "WM01601KLZL4TG5625" , +6, 0, -135, DriveConfig::ReadMethod::BE_CDDA, DriveConfig::SectorOrder::DATA_C2_SUB, DriveConfig::Type::GENERIC}, // default or RibShark FW definition
Expand Down Expand Up @@ -252,8 +255,9 @@ constexpr uint32_t ASUS_CACHE_ENTRY_SIZE = 0xB00;

static const std::map<DriveConfig::Type, AsusConfig> ASUS_CACHE_CONFIG =
{
{DriveConfig::Type::LG_ASU8, {8, 2806}},
{DriveConfig::Type::LG_ASU83, {8, 1079}},
{DriveConfig::Type::LG_ASU8A, {8, 2806}},
{DriveConfig::Type::LG_ASU8B, {8, 1079}},
{DriveConfig::Type::LG_ASU8C, {8, 1268}},
{DriveConfig::Type::LG_ASU3, {3, 1070}},
{DriveConfig::Type::LG_ASU2, {2, 586}}
};
Expand Down
13 changes: 13 additions & 0 deletions redumper.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ void redumper_refine(Context &ctx, Options &options)
}


void redumper_refine_new(Context &ctx, Options &options)
{
if(!ctx.refine || *ctx.refine && options.retries)
{
if(profile_is_cd(ctx.current_profile))
redumper_dump_cd_new(ctx, options, DumpMode::REFINE);
else
redumper_dump_dvd(ctx, options, DumpMode::REFINE);
}
}


void redumper_verify(Context &ctx, Options &options)
{
if(profile_is_cd(ctx.current_profile))
Expand All @@ -134,6 +146,7 @@ const std::map<std::string, std::pair<bool, void (*)(Context &, Options &)>> COM
{ "dump" , { true , redumper_dump }},
{ "dumpnew" , { true , redumper_dump_new }},
{ "refine" , { true , redumper_refine }},
{ "refinenew" , { true , redumper_refine_new }},
{ "verify" , { true , redumper_verify }},
{ "dvdkey" , { true , redumper_dvdkey }},
{ "dvdisokey" , { false, redumper_dvdisokey }},
Expand Down

0 comments on commit 3b3aced

Please sign in to comment.