Re: 32-bit DOS games
Posted: September 21st, 2015, 5:55 pm
Jesus! I do not know. I'm just a Borland Turbo C 2.01 and Borland Turbo Assembler 4.1 programmer!
Keeping the classics alive... together
http://classicdosgames.com/forum/
I think 4-bit paletted graphics were quite common in the 1990s. 4 bits translates nicely into 16 colors which gives a good pallet while keeping the data footprint small.NY00123 wrote:Thus, it's really common that a 8-bits sized byte is used as the smallest unit of smallest addressable unit of memory nowadays, but there are still counterexamples.
Sorry to interrupt however I have been studying Borland Turbo C 2.01 now that I have completed my Borland Turbo Assembler 4.1 studies. There is a alloc and malloc function in Borland Turbo C 2.01. When you type cast in Borland Turbo C 2.01 it does tell the number of bytes. It is given that you already know CHAR to be 8 bits while INT and such to be accordingly sized (eg 16 bits, 2 bytes, etc.).NY00123 wrote:Heh, that's 4-bytes above, not 4-bitsdevelopertn wrote:Really? 4-bits is an unheard of number to me.
Actually, there are architectures with byte sizes differing from 8-bits. The C language has a macro named CHAR_BIT, telling the number of bits a char has. This macro is often defined to be 8, but it doesn't have to. At least as of C89 and later, the C standard mandates that CHAR_BIT >= 8. POSIX mandates the stricter requirement that CHAR_BIT == 8.
Thus, it's really common that a 8-bits sized byte is used as the smallest unit of smallest addressable unit of memory nowadays, but there are still counterexamples.
It's true that 16-colors graphics modes were commonly used back then. Technically, programming the EGA (or compatible, including the VGA) for drawing graphics in such modes is a bit of a feat, given that these modes are planar (see e.g., http://www.shikadi.net/moddingwiki/Raw_EGA_data). So, this special case should probably be ignored for now.Pixelfck wrote:I think 4-bit paletted graphics were quite common in the 1990s. 4 bits translates nicely into 16 colors which gives a good pallet while keeping the data footprint small.NY00123 wrote:Thus, it's really common that a 8-bits sized byte is used as the smallest unit of smallest addressable unit of memory nowadays, but there are still counterexamples.
Tried checking Turbo C's header files? There should (probably) be a limits.h header file with a definition of CHAR_BIT.developertn wrote:Speaking of CHAR_BIT since I don't think Borland Turbo C 2.01 has it, I've decided to write my own function that does the same thing.
Of course this will work, not only since it's manually implemented (as done by you on purpose), but also because the C standard mandates that sizeof(char) is always 1. A single byte, not matter how many bits does it consist of, should be used for storage of a char.developertn wrote:#include <alloc.h>
#include <stdio.h>
void CHAR_BIT(int nbytes)
{
printf("\n %d ", nbytes*sizeof(char)*8);
}
int main()
{
CHAR_BIT(2);
}