animations MGF works

This commit is contained in:
Ondřej Novák 2025-01-29 19:57:25 +01:00
parent 4f9f985918
commit 2be84e406c
10 changed files with 224 additions and 293 deletions

View file

@ -3,6 +3,7 @@
#include <mgfplay.h>
#include <bgraph.h>
#include <assert.h>
void show_full_lfb12e(void *target, void *buff, void *paleta) {
uint16_t *edi = (uint16_t *)target;
@ -20,77 +21,6 @@ void show_full_lfb12e(void *target, void *buff, void *paleta) {
dl--;
} while (dl != 0);
}
/*
void show_full_lfb12e(void *target,void *buff,void *paleta)
{
__asm
{
mov edi,target
mov esi,buff
mov ebx,paleta
;edi - target
;esi - source
;ebx - palette
push ebp
mov dl,180
shfl2: mov ecx,160
shfl1: lodsw
movzx ebp,al
movzx ebp,short ptr ds:[ebp*2+ebx]
movzx eax,ah
movzx eax,short ptr ds:[eax*2+ebx]
shl eax,16
or eax,ebp
stosd
dec ecx
jnz shfl1
dec dl
jnz shfl2
pop ebp
}
}
*/
/*
void show_delta_lfb12e(void *target, void *buff, void *paleta) {
uint8_t *edi = (uint8_t *)target;
uint8_t *esi = (uint8_t *)buff + 4; // skip pointer
uint8_t *ebx = (uint8_t *)paleta;
uint8_t cl = 180; // remaining lines
uint8_t ch, al;
uint16_t *edx = (uint16_t *)esi; // start of delta map
esi += *(uint32_t *)(esi - 4); // start of data
while (cl > 0) {
uint8_t *line_address = edi; // save line address
ch = *edx++; // read _skip_ value
al = ch;
al |= 0x3F; // test if the two highest bits are set
al++;
if (al == 0) { // if yes - skip lines
ch &= 0x3F; // mask the upper 2 bits
edi += (ch == 0) ? 640 : 0; // skip line if ch is 0
cl--; // decrement line counter
continue; // continue to next iteration
}
uint32_t eax = (uint32_t)ch; // expand _skip_ value to eax
edi += eax * 4; // calculate new position on screen
ch = *edx++; // read _copy_ value
for (uint8_t i = 0; i < ch; i++) {
uint16_t ebp = *(uint16_t *)(ebx + (al * 2)); // get color from palette
uint16_t color = *(uint16_t *)(ebx + (eax * 2)); // get color from palette
eax = (color << 16) | ebp; // combine colors
*(uint32_t *)edi = eax; // store the color
edi += 4; // move to the next pixel
}
edi += 640; // skip line
cl--; // decrement line counter
}
}
*/
static __inline uint32_t read_uint32(uint8_t *from) {
uint32_t a = from[0];
uint32_t b = from[1];
@ -117,6 +47,7 @@ void show_delta_lfb12e(void *target,void *buff,void *paleta)
uint8_t cl = 180;
// mov cl,180 ;cl pocet zbyvajicich radek
uint32_t offset = read_uint32(esi);
assert(offset != 0);
// add esi,4 ;preskoc ukazatel
esi += 4;
uint8_t *edx = esi;
@ -132,7 +63,7 @@ void show_delta_lfb12e(void *target,void *buff,void *paleta)
// inc edx
// or al,03fh ;test zda jsou 2 nejvyssi bity nastaveny
// inc al
if ((ch & 0xC0) == 0) {
if ((ch & 0xC0) != 0xC0) {
// jz shdl3 ;ano - preskakovani radku
edi += ((uint32_t)ch) << 1;
// movzx eax,ch ;expanduj _skip_ hodnotu do eax
@ -141,6 +72,7 @@ void show_delta_lfb12e(void *target,void *buff,void *paleta)
// mov ch,[edx] ;cti _copy_ hodnotu
// inc edx
assert(ch <= 160);
while (ch) {
uint8_t a = *data++;
*edi++ = ebx[a];
@ -162,10 +94,15 @@ void show_delta_lfb12e(void *target,void *buff,void *paleta)
// jmp shdl2 ;pokracuj _skip_ hodnotou
} else {
ch &= 0x3F;
++ch;
if (ch > cl) ch = cl;
line_beg += 320*ch;
cl -= ch;
if (ch == 0) {
line_beg += 320;
--cl;
} else {
++ch;
assert(ch <= cl);
cl-=ch;
line_beg += 320*(int)ch;
}
edi = line_beg;
}