Support Overlays #2
|
@ -47,7 +47,7 @@ namespace JabyEngine {
|
|||
};
|
||||
|
||||
void read_file(FileInfo file_info, const SectorBufferAllocator& buffer_allocator);
|
||||
bool continue_reading();
|
||||
void continue_reading();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace JabyEngine {
|
|||
|
||||
// Upload SplashScreen picture
|
||||
auto state = FileProcessor::create(&__boot_loader_end, SimpleTIM(32, 0, 0, 0));
|
||||
while(state.process(bytes_ready) == Progress::InProgress);
|
||||
state.process(bytes_ready);
|
||||
|
||||
Display::enable();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ namespace JabyEngine {
|
|||
static constexpr auto DataSectorMode = Mode_t::from(Mode_t::DoubleSpeed, Mode_t::DataSector);
|
||||
|
||||
static SectorBufferAllocator sector_allocator;
|
||||
static uint16_t sectors_left;
|
||||
static uint16_t cur_lba;
|
||||
static uint16_t dst_lba;
|
||||
|
||||
static void pause_cd() {
|
||||
CD_IO::PortIndex0::change_to();
|
||||
|
@ -31,9 +32,14 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
// Requires Index0
|
||||
static void start_reading_cd() {
|
||||
static void read_cd(uint16_t lba) {
|
||||
const auto loc = CDTimeStamp::from(lba);
|
||||
|
||||
Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetLoc, loc.get_min_cd(), loc.get_sec_cd(), loc.get_sector_cd());
|
||||
Command::send<CD_IO::PortIndex0>(CD_IO::Command::ReadN);
|
||||
current_state = State::Reading;
|
||||
|
||||
printf("Now reading: %i(%i:%i:%i)\n", lba, loc.get_min_cd(), loc.get_sec_cd(), loc.get_sector_cd());
|
||||
}
|
||||
|
||||
static void read_sector_dma(CD_IO::DataSector& sector) {
|
||||
|
@ -66,23 +72,6 @@ namespace JabyEngine {
|
|||
// Doesn't seem to important when we can use DMA
|
||||
}
|
||||
|
||||
static bool try_read_sector() {
|
||||
// Obtain sector content here
|
||||
auto* sector = sector_allocator.allocate_sector();
|
||||
if(sector) {
|
||||
//Now obtain sector
|
||||
read_sector_to(*sector);
|
||||
|
||||
sectors_left--;
|
||||
if(sectors_left == 0) {
|
||||
current_state = State::Done;
|
||||
pause_cd();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static InterruptVerifierResult interrupt_verifier() {
|
||||
if(Interrupt::is_irq(Interrupt::CDROM)) {
|
||||
const uint8_t old_status = CD_IO::IndexStatus;
|
||||
|
@ -93,8 +82,20 @@ namespace JabyEngine {
|
|||
CD_IO::Interrupt::ack(CD_IO::PortIndex1::InterruptFlag);
|
||||
|
||||
if(cur_irq == CD_IO::Interrupt::DataReady) {
|
||||
//Obtain sector content here
|
||||
if(!try_read_sector()) {
|
||||
// Obtain sector content here
|
||||
auto* sector = sector_allocator.allocate_sector();
|
||||
if(sector) {
|
||||
//Now obtain sector
|
||||
read_sector_to(*sector);
|
||||
|
||||
cur_lba++;
|
||||
if(cur_lba == dst_lba) {
|
||||
current_state = State::Done;
|
||||
pause_cd();
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
current_state = State::BufferFull;
|
||||
pause_cd();
|
||||
}
|
||||
|
@ -128,35 +129,20 @@ namespace JabyEngine {
|
|||
};
|
||||
|
||||
void read_file(FileInfo file_info, const SectorBufferAllocator& buffer_allocator) {
|
||||
cur_lba = file_info.lba;
|
||||
dst_lba = file_info.lba + file_info.sectors;
|
||||
sector_allocator = buffer_allocator;
|
||||
sectors_left = file_info.sectors;
|
||||
|
||||
CD_IO::PortIndex0::change_to();
|
||||
Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetMode, DataSectorMode);
|
||||
|
||||
const auto loc = CDTimeStamp::from(file_info);
|
||||
Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetLoc, loc.get_min_cd(), loc.get_sec_cd(), loc.get_sector_cd());
|
||||
start_reading_cd();
|
||||
|
||||
printf("Now reading: %i(%i:%i:%i)\n", file_info.lba, loc.get_min_cd(), loc.get_sec_cd(), loc.get_sector_cd());
|
||||
read_cd(file_info.lba);
|
||||
}
|
||||
|
||||
bool continue_reading() {
|
||||
if(current_state != State::BufferFull) {
|
||||
return true;
|
||||
}
|
||||
|
||||
printf(">>> Trying to read buffer from continue_reading\n");
|
||||
CD_IO::PortIndex1::change_to();
|
||||
if(!try_read_sector()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(current_state != State::Done) {
|
||||
CD_IO::PortIndex0::change_to();
|
||||
start_reading_cd();
|
||||
}
|
||||
return true;
|
||||
void continue_reading() {
|
||||
if(current_state == State::BufferFull) {
|
||||
read_cd(cur_lba);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
namespace JabyEngine {
|
||||
static constexpr auto NormalCircularBufferSize = 64;
|
||||
static constexpr auto NormalCircularBufferSize = 5;
|
||||
|
||||
void CDFileProcessor :: start_cur_job() {
|
||||
using CD::internal::FileInfo;
|
||||
|
@ -89,7 +89,8 @@ namespace JabyEngine {
|
|||
|
||||
case CD::internal::State::BufferFull:
|
||||
/* We processd data and unpause the CD drive */
|
||||
return CD::internal::continue_reading() ? Progress::InProgress : Progress::Error;
|
||||
CD::internal::continue_reading();
|
||||
return Progress::InProgress;
|
||||
|
||||
case CD::internal::State::Reading:
|
||||
return Progress::InProgress;
|
||||
|
|
Loading…
Reference in New Issue