aboutsummaryrefslogtreecommitdiff
path: root/backends/PalmOS/Src/arm/copy_rect.cpp
blob: 64aa1df69c018975d6ccb0e2c3e013a8cfd20734 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "PACEInterfaceLib.h"
#include "ArmNative.h"
#include "endianutils.h"
#include "../shared.h"

unsigned long OSystem_PALMOS_copy_rect(void *userData68KP) {
	UInt8* dataP = (UInt8 *)userData68KP;

	UInt8 *dst = (UInt8 *)ReadUnaligned32(dataP + 2);		// ->dst
	UInt8 *buf = (UInt8 *)ReadUnaligned32(dataP + 6);		// ->buf
	UInt32 pitch = ReadUnaligned32(dataP + 10);				// ->pitch
	UInt32 _offScreenPitch = ReadUnaligned32(dataP + 14);	// ->_offScreenPitch
	UInt32 w = ReadUnaligned32(dataP + 18);					// ->w
	UInt32 h = ReadUnaligned32(dataP + 22);					// ->h

	if (_offScreenPitch == pitch && pitch == w) {
		MemMove(dst, buf, h * w);
	} else {
		do {
			MemMove(dst, buf, w);
			dst += _offScreenPitch;
			buf += pitch;
		} while (--h);
	}

	return 0;
}