2023-01-29 01:55:17 +00:00
|
|
|
|
#include "th01/hardware/egc.h"
|
|
|
|
|
#include "th01/formats/grp.h"
|
2020-10-01 14:34:46 +00:00
|
|
|
|
#include "th01/end/pic.hpp"
|
|
|
|
|
|
2023-02-06 01:12:18 +00:00
|
|
|
|
void end_pics_load_palette_show(const char *fn)
|
2020-05-24 17:04:55 +00:00
|
|
|
|
{
|
|
|
|
|
graph_accesspage_func(1);
|
2023-01-29 00:56:42 +00:00
|
|
|
|
grp_put(fn, GPF_PALETTE_SHOW);
|
2020-05-24 17:04:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void end_pic_show(int quarter)
|
|
|
|
|
{
|
|
|
|
|
egc_start_copy();
|
|
|
|
|
|
2020-08-21 18:13:08 +00:00
|
|
|
|
pixel_t src_left = ((quarter % 2) * PIC_W);
|
|
|
|
|
pixel_t src_top = ((quarter / 2) * PIC_H);
|
2020-08-21 17:18:28 +00:00
|
|
|
|
uvram_offset_t vram_offset_src = vram_offset_shift(src_left, src_top);
|
|
|
|
|
uvram_offset_t vram_offset_dst = vram_offset_shift(PIC_LEFT, PIC_TOP);
|
2020-08-21 18:13:08 +00:00
|
|
|
|
vram_word_amount_t vram_x;
|
|
|
|
|
pixel_t y;
|
2020-05-24 17:04:55 +00:00
|
|
|
|
|
2022-08-15 17:15:40 +00:00
|
|
|
|
// ZUN quirk: This EGC-"accelerated" copy operation ends up performing a
|
|
|
|
|
// total of ((320 / 16) × 200 × 2) = 8000 VRAM page switches, which are
|
|
|
|
|
// everything but instant. Even the optimal assembly instructions for a
|
|
|
|
|
// *single* page switch, `MOV AL, (0|1)` followed by `OUT 0xA6, AL`, take
|
|
|
|
|
// 12 cycles on a 386 and 17 cycles on a 486, and ZUN adds the bloat of a
|
|
|
|
|
// standard function call on top of even that.
|
2022-06-15 20:05:09 +00:00
|
|
|
|
// Optimizations aside, using the EGC can't give you a better algorithm,
|
2022-08-09 17:43:22 +00:00
|
|
|
|
// as its tile registers are limited to 16 dots. Expanding to at least 32
|
2022-06-15 20:05:09 +00:00
|
|
|
|
// dots would have really been nice for ≥386 CPUs...
|
2020-05-24 17:04:55 +00:00
|
|
|
|
for(y = 0; y < PIC_H; y++) {
|
2022-08-09 17:43:22 +00:00
|
|
|
|
for(vram_x = 0; vram_x < (PIC_VRAM_W / EGC_REGISTER_SIZE); vram_x++) {
|
|
|
|
|
egc_temp_t d;
|
2020-05-24 17:04:55 +00:00
|
|
|
|
|
2022-08-09 17:43:22 +00:00
|
|
|
|
graph_accesspage_func(1); d = egc_chunk(vram_offset_src);
|
|
|
|
|
graph_accesspage_func(0); egc_chunk(vram_offset_dst) = d;
|
2020-05-24 17:04:55 +00:00
|
|
|
|
|
2022-08-09 17:43:22 +00:00
|
|
|
|
vram_offset_src += EGC_REGISTER_SIZE;
|
|
|
|
|
vram_offset_dst += EGC_REGISTER_SIZE;
|
2020-05-24 17:04:55 +00:00
|
|
|
|
}
|
|
|
|
|
vram_offset_src += (ROW_SIZE - PIC_VRAM_W);
|
|
|
|
|
vram_offset_dst += (ROW_SIZE - PIC_VRAM_W);
|
|
|
|
|
}
|
|
|
|
|
egc_off();
|
|
|
|
|
}
|