diff --git a/021.calling_c/c_code.c b/021.calling_c/c_code.c index 79657c0..8b42c58 100644 --- a/021.calling_c/c_code.c +++ b/021.calling_c/c_code.c @@ -1,3 +1,8 @@ +typedef union { + unsigned char* ptr; + unsigned short word[2]; +} word_extract_t; + void PokeBitplanePointers(unsigned short* copper, unsigned char* bitplanes, unsigned offset, unsigned numBitplanes, unsigned screenWidthBytes) { @@ -5,8 +10,10 @@ PokeBitplanePointers(unsigned short* copper, unsigned char* bitplanes, unsigned copper += offset; for (i = 0; i < numBitplanes; i++) { - *(copper+1) = (unsigned)bitplanes; - *(copper+3) = ((unsigned)bitplanes >> 16); + word_extract_t extract; + extract.ptr = bitplanes; + *(copper+1) = extract.word[1]; + *(copper+3) = extract.word[0]; bitplanes += screenWidthBytes; copper += 4; }