Download Sample Chapters from Book.
Transcript
© 2009 NURVE NETWORKS LLC “Inside the XGS PIC 16-Bit” Figure 15.10 – Interfacing with the 160x192 NTSC driver. Interfacing with the driver is very simple as shown in Figure 15.10. The main C application needs to declare 3 separate globally accessible pointers and 3 separate arrays that the pointers are pointing to. The first is g_CurrentVRAMBuf which is declared as an unsigned char * that points to a char array sized appropriately to fit the screen’s resolution. Next we have the color table or palettes that must be defined and pointed to with an unsigned char * named g_ColorTable. There may be one or many color tables but they all must be contained in continuous memory. Finally there needs to be an attribute table or as previously described a palette map that is an array of unsigned shorts (16-bit) pointed to with an unsigned short * named g_AttribTable. A sample declaration for a 160x192x2 driver with 3 color tables is given below. NOTE When using the XGS PIC API graphics library the variables: g_CurrentVRAMBuf, g_ColorTable, and g_AttribTable are already defined for you and you assign their values via function call. // The VRAM buffer must be allocated into far memory space because it is so large it will not fit into near unsigned char g_VRAMBuffer[160*192/4] __attribute__((far)); // [required] A 16-bit pointer set to the current VRAM Buffer unsigned char *g_CurrentVRAMBuf = g_VRAMBuffer; // Our Color Tables 3 of them each 4 bytes in size in 2-bit per pixel mode unsigned char g_Palettes[3*4]; // [required] A 16-bit pointer set to the color palettes array unsigned char *g_ColorTable = g_Palettes; // Table that contains which color palette to assign 8x8 group unsigned short g_PaletteMap[20*24]; // [required] A 16-bit pointer to the current palette map unsigned short *g_AttribTable = g_PaletteMap; 33