2024-01-24 09:18:02 +00:00
|
|
|
#pragma option -zCSHARED -k-
|
2021-03-10 21:13:50 +00:00
|
|
|
|
|
|
|
#include <mem.h>
|
|
|
|
#include "platform.h"
|
|
|
|
#include "pc98.h"
|
|
|
|
#include "planar.h"
|
|
|
|
#include "decomp.hpp"
|
|
|
|
#include "master.hpp"
|
2023-02-12 14:59:00 +00:00
|
|
|
#include "platform/x86real/flags.hpp"
|
2022-04-02 04:19:18 +00:00
|
|
|
extern "C" {
|
2021-03-10 21:13:50 +00:00
|
|
|
#include "th04/hardware/bgimage.hpp"
|
|
|
|
|
|
|
|
inline void memcpy_movsd(
|
|
|
|
uint16_t, uint16_t dst_off, uint16_t, uint16_t src_off, size_t size
|
|
|
|
) {
|
|
|
|
_SI = src_off;
|
|
|
|
_DI = dst_off;
|
|
|
|
_CX = (size / sizeof(uint32_t));
|
|
|
|
REP MOVSD;
|
|
|
|
}
|
|
|
|
|
2022-02-12 22:36:00 +00:00
|
|
|
#define bgimage_push() _asm { \
|
2021-03-10 21:13:50 +00:00
|
|
|
push SEG_PLANE_E; \
|
|
|
|
push word ptr [bgimage.E]; \
|
|
|
|
push SEG_PLANE_G; \
|
|
|
|
push word ptr [bgimage.G]; \
|
|
|
|
push SEG_PLANE_R; \
|
|
|
|
push word ptr [bgimage.R]; \
|
|
|
|
push SEG_PLANE_B; \
|
|
|
|
push word ptr [bgimage.B]; \
|
|
|
|
}
|
|
|
|
|
|
|
|
void bgimage_snap(void)
|
|
|
|
{
|
2022-06-26 09:32:25 +00:00
|
|
|
if(bgimage.B == nullptr) {
|
2022-11-10 01:58:18 +00:00
|
|
|
bgimage.B = HMem<dots8_t>::alloc(PLANE_SIZE);
|
|
|
|
bgimage.R = HMem<dots8_t>::alloc(PLANE_SIZE);
|
|
|
|
bgimage.G = HMem<dots8_t>::alloc(PLANE_SIZE);
|
|
|
|
bgimage.E = HMem<dots8_t>::alloc(PLANE_SIZE);
|
2021-03-10 21:13:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_DL = PLANE_COUNT;
|
2022-02-13 04:15:27 +00:00
|
|
|
_asm { push ds; }
|
2021-03-10 21:13:50 +00:00
|
|
|
bgimage_push();
|
|
|
|
do {
|
2022-02-12 22:36:00 +00:00
|
|
|
_asm { pop es; }
|
|
|
|
_asm { pop ds; }
|
2021-03-10 21:13:50 +00:00
|
|
|
memcpy_movsd(_ES, 0, _DS, 0, PLANE_SIZE);
|
|
|
|
_DL--;
|
|
|
|
} while(!FLAGS_ZERO);
|
2022-02-12 22:36:00 +00:00
|
|
|
_asm { pop ds; }
|
2021-03-10 21:13:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void bgimage_put(void)
|
|
|
|
{
|
|
|
|
_DL = PLANE_COUNT;
|
2022-02-13 04:15:27 +00:00
|
|
|
_asm { push ds; }
|
2021-03-10 21:13:50 +00:00
|
|
|
bgimage_push();
|
|
|
|
do {
|
2022-02-12 22:36:00 +00:00
|
|
|
_asm { pop ds; }
|
|
|
|
_asm { pop es; }
|
2021-03-10 21:13:50 +00:00
|
|
|
memcpy_movsd(_ES, 0, _DS, 0, PLANE_SIZE);
|
|
|
|
_DL--;
|
|
|
|
} while(!FLAGS_ZERO);
|
2022-02-12 22:36:00 +00:00
|
|
|
_asm { pop ds; }
|
2021-03-10 21:13:50 +00:00
|
|
|
}
|
|
|
|
#pragma codestring "\x90"
|
|
|
|
|
|
|
|
void bgimage_free(void)
|
|
|
|
{
|
2022-06-26 09:32:25 +00:00
|
|
|
if(bgimage.B != nullptr) {
|
2021-04-16 10:29:57 +00:00
|
|
|
HMem<dots8_t>::free(bgimage.B);
|
|
|
|
HMem<dots8_t>::free(bgimage.R);
|
|
|
|
HMem<dots8_t>::free(bgimage.G);
|
|
|
|
HMem<dots8_t>::free(bgimage.E);
|
2022-06-26 09:32:25 +00:00
|
|
|
bgimage.B = nullptr;
|
2021-03-10 21:13:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|