Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions frontend/iris.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,55 @@ void update_window(iris::instance* iris) {

DockSpaceOverViewport(0, GetMainViewport(), ImGuiDockNodeFlags_PassthruCentralNode);

// Drop file fade animation
if (iris->drop_file_active) {
iris->drop_file_alpha += iris->drop_file_alpha_delta;

if (iris->drop_file_alpha_delta > 0.0f) {
if (iris->drop_file_alpha >= 1.0f) {
iris->drop_file_alpha = 1.0f;
iris->drop_file_alpha_delta = 0.0f;
}
} else {
if (iris->drop_file_alpha <= 0.0f) {
iris->drop_file_alpha = 0.0f;
iris->drop_file_alpha_delta = 0.0f;
iris->drop_file_active = false;
}
}

GetForegroundDrawList()->AddRectFilled(
ImVec2(0, 0),
ImVec2(iris->window_width, iris->window_height),
ImColor(0.0f, 0.0f, 0.0f, iris->drop_file_alpha * 0.35f)
);

ImVec2 text_size = CalcTextSize("Drop file here to launch");

PushFont(iris->font_icons_big);

ImVec2 icon_size = CalcTextSize(ICON_MS_DOWNLOAD);

ImVec2 total_size = ImVec2(
std::max(icon_size.x, text_size.x),
icon_size.y + text_size.y
);

GetForegroundDrawList()->AddText(
ImVec2(iris->window_width / 2 - icon_size.x / 2, iris->window_height / 2 - icon_size.y),
ImColor(1.0f, 1.0f, 1.0f, iris->drop_file_alpha),
ICON_MS_DOWNLOAD
);

PopFont();

GetForegroundDrawList()->AddText(
ImVec2(iris->window_width / 2 - text_size.x / 2, iris->window_height / 2),
ImColor(1.0f, 1.0f, 1.0f, iris->drop_file_alpha),
"Drop file here to launch"
);
}

if (iris->show_ee_control) show_ee_control(iris);
if (iris->show_ee_state) show_ee_state(iris);
if (iris->show_ee_logs) show_ee_logs(iris);
Expand Down
5 changes: 5 additions & 0 deletions frontend/iris.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ struct instance {
struct ds_state* ds[2] = { nullptr };
struct mcd_state* mcd[2] = { nullptr };

float drop_file_alpha = 0.0f;
float drop_file_alpha_delta = 0.0f;
float drop_file_alpha_target = 0.0f;
bool drop_file_active = false;

// Debug
std::vector <elf_symbol> symbols;
std::vector <uint8_t> strtab;
Expand Down
14 changes: 14 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,20 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) {
handle_keyup_event(iris, event->key);
} break;

case SDL_EVENT_DROP_BEGIN: {
iris->drop_file_active = true;
iris->drop_file_alpha = 0.0f;
iris->drop_file_alpha_delta = 1.0f / 10.0f;
iris->drop_file_alpha_target = 1.0f;
} break;

case SDL_EVENT_DROP_COMPLETE: {
iris->drop_file_active = true;
iris->drop_file_alpha = iris->drop_file_alpha_target;
iris->drop_file_alpha_delta = -(1.0f / 10.0f);
iris->drop_file_alpha_target = 0.0f;
} break;

case SDL_EVENT_DROP_FILE: {
if (!event->drop.data)
break;
Expand Down
95 changes: 84 additions & 11 deletions src/ee/dmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,18 +740,54 @@ void dmac_handle_sif1_transfer(struct ps2_dmac* dmac) {
void dmac_handle_sif2_transfer(struct ps2_dmac* dmac) {
printf("ee: SIF2 channel unimplemented\n"); exit(1);
}

void dmac_spr_from_interleave(struct ps2_dmac* dmac) {
uint32_t sqwc = dmac->sqwc & 0xff;
uint32_t tqwc = (dmac->sqwc >> 16) & 0xff;

// Note: When TQWC=0, it is set to QWC instead (undocumented)
if (tqwc == 0)
tqwc = dmac->spr_to.qwc;

while (dmac->spr_from.qwc) {
for (int i = 0; i < tqwc && dmac->spr_from.qwc; i++) {
uint128_t q = ps2_ram_read128(dmac->spr, dmac->spr_from.sadr);

ee_bus_write128(dmac->bus, dmac->spr_from.madr, q);

dmac->spr_from.madr += 0x10;
dmac->spr_from.sadr += 0x10;
dmac->spr_from.sadr &= 0x3ff0;
dmac->spr_from.qwc--;
}

dmac->spr_from.madr += sqwc * 16;

if (dmac->spr_from.qwc == 0)
return;
}
}
void dmac_handle_spr_from_transfer(struct ps2_dmac* dmac) {
dmac_set_irq(dmac, DMAC_SPR_FROM);

dmac->spr_from.chcr &= ~0x100;

// printf("ee: spr_from start data=%08x dir=%d mod=%d tte=%d madr=%08x qwc=%08x tadr=%08x sadr=%08x\n",
// dmac->spr_from.chcr,
// dmac->spr_from.chcr & 1,
// (dmac->spr_from.chcr >> 2) & 3,
// !!(dmac->spr_from.chcr & 0x40),
// dmac->spr_from.madr,
// dmac->spr_from.qwc,
// dmac->spr_from.tadr,
// dmac->spr_from.sadr
// );

int mode = (dmac->spr_from.chcr >> 2) & 3;

// Interleave mode unimplemented yet
if (mode == 2) {
printf("dmac: SPR from interleave mode unimplemented (mod=%d)\n", mode);

dmac->spr_from.qwc = 0;
dmac_spr_from_interleave(dmac);

return;
}
Expand All @@ -763,6 +799,7 @@ void dmac_handle_spr_from_transfer(struct ps2_dmac* dmac) {

dmac->spr_from.madr += 0x10;
dmac->spr_from.sadr += 0x10;
dmac->spr_from.sadr &= 0x3ff0;
}

dmac->spr_from.qwc = 0;
Expand All @@ -777,7 +814,7 @@ void dmac_handle_spr_from_transfer(struct ps2_dmac* dmac) {
uint128_t tag = dmac_read_qword(dmac, dmac->spr_from.sadr, 1);

dmac->spr_from.sadr += 0x10;
dmac->spr_from.sadr &= 0x3fff;
dmac->spr_from.sadr &= 0x3ff0;

dmac->spr_from.tag.qwc = tag.u32[0] & 0xffff;
dmac->spr_from.tag.id = (tag.u32[0] >> 28) & 0x7;
Expand Down Expand Up @@ -806,30 +843,57 @@ void dmac_handle_spr_from_transfer(struct ps2_dmac* dmac) {

dmac->spr_from.madr += 0x10;
dmac->spr_from.sadr += 0x10;
dmac->spr_from.sadr &= 0x3fff;
dmac->spr_from.sadr &= 0x3ff0;
}
} while (!channel_is_done(&dmac->spr_from));
}

void dmac_spr_to_interleave(struct ps2_dmac* dmac) {
uint32_t sqwc = dmac->sqwc & 0xff;
uint32_t tqwc = (dmac->sqwc >> 16) & 0xff;

// Note: When TQWC=0, it is set to QWC instead (undocumented)
if (tqwc == 0)
tqwc = dmac->spr_to.qwc;

while (dmac->spr_to.qwc) {
for (int i = 0; i < tqwc && dmac->spr_to.qwc; i++) {
uint128_t q = dmac_read_qword(dmac, dmac->spr_to.madr, 0);

ps2_ram_write128(dmac->spr, dmac->spr_to.sadr, q);

dmac->spr_to.madr += 0x10;
dmac->spr_to.sadr += 0x10;
dmac->spr_to.sadr &= 0x3ff0;
dmac->spr_to.qwc--;
}

dmac->spr_to.madr += sqwc * 16;

if (dmac->spr_to.qwc == 0)
return;
}
}
void dmac_handle_spr_to_transfer(struct ps2_dmac* dmac) {
dmac_set_irq(dmac, DMAC_SPR_TO);

dmac->spr_to.chcr &= ~0x100;

int mode = (dmac->spr_to.chcr >> 2) & 3;

// printf("ee: spr_to start data=%08x dir=%d mod=%d tte=%d madr=%08x qwc=%08x tadr=%08x\n",
// printf("ee: spr_to start data=%08x dir=%d mod=%d tte=%d madr=%08x qwc=%08x tadr=%08x sadr=%08x\n",
// dmac->spr_to.chcr,
// dmac->spr_to.chcr & 1,
// (dmac->spr_to.chcr >> 2) & 3,
// !!(dmac->spr_to.chcr & 0x40),
// dmac->spr_to.madr,
// dmac->spr_to.qwc,
// dmac->spr_to.tadr
// dmac->spr_to.tadr,
// dmac->spr_to.sadr
// );

// Interleave mode unimplemented yet
if (mode == 2) {
printf("dmac: SPR to interleave mode unimplemented (mod=%d)\n", mode);
dmac_spr_to_interleave(dmac);

return;
}
Expand All @@ -841,6 +905,7 @@ void dmac_handle_spr_to_transfer(struct ps2_dmac* dmac) {

dmac->spr_to.madr += 0x10;
dmac->spr_to.sadr += 0x10;
dmac->spr_to.sadr &= 0x3ff0;
}

dmac->spr_to.qwc = 0;
Expand Down Expand Up @@ -875,6 +940,7 @@ void dmac_handle_spr_to_transfer(struct ps2_dmac* dmac) {

dmac->spr_to.madr += 0x10;
dmac->spr_to.sadr += 0x10;
dmac->spr_to.sadr &= 0x3ff0;
}

if (dmac->spr_to.tag.id == 1) {
Expand Down Expand Up @@ -944,12 +1010,19 @@ void ps2_dmac_write32(struct ps2_dmac* dmac, uint32_t addr, uint64_t data) {
dmac_handle_channel_start(dmac, addr);
}
} return;
case 0x10: c->madr = data; return;
case 0x10: {
c->madr = data;

// Clear MADR's MSB on SPR channels
if (c == &dmac->spr_to || c == &dmac->spr_from) {
c->madr &= 0x7fffffff;
}
} return;
case 0x20: c->qwc = data & 0xffff; return;
case 0x30: c->tadr = data; return;
case 0x40: c->asr0 = data; return;
case 0x50: c->asr1 = data; return;
case 0x80: c->sadr = data; return;
case 0x80: c->sadr = data & 0x3ff0; return;
}

// printf("dmac: Unknown channel register %02x\n", addr & 0xff);
Expand Down
Loading