Post reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.
Name:
Email:
Subject:
Message icon:

Verification:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?:

shortcuts: hit alt+s to submit/post or alt+p to preview


Topic Summary

Posted by: Sam.
« on: July 19, 2017, 02:08:34 PM »

@Argent77
That is exactly what I needed, thank you!

@The Imp
A nibble is half of a byte (so 4 bits) and stores a value from 0 to 15.  The problem is that the smallest value traditionally used to read from / write to a file is a byte, so low level bit manipulations (something I've never been able to wrap my head around) are required to get at the two 4-bit nibbles in the byte.  That's where Argent77's code comes in.  As far as my need to do this, 4-bit bitmaps (the format used by area search maps) have a 16 color palette, and each pixel is a 4-bit nibble that is a pointer into the palette.  So each byte stores two pixels, but in order to change the pixels one must access each nibble.
Posted by: GeN1e
« on: July 17, 2017, 07:21:02 PM »

Half a byte.  Use >>/<<, as Argent says.
Posted by: The Imp
« on: July 16, 2017, 05:35:57 AM »

Nibbles ?
It's not like the snacks have fortunes written in them or anything... ok, joking aside, I have never ran in to these in weidu, so care to elaborate ? Not that you need to.
Posted by: Argent77
« on: July 16, 2017, 04:42:45 AM »

Try this:
Code: [Select]
SET nibbleL = (BYTE_AT offset) & 0x0f
SET nibbleH = ((BYTE_AT offset) >> 4) & 0x0f

WRITE_BYTE offset ((THIS & 0xf0) | nibbleL)
WRITE_BYTE offset ((THIS & 0x0f) | (nibbleH << 4))
Posted by: Sam.
« on: July 15, 2017, 08:24:48 PM »

How do I read/write nibbles with WeiDU?