// Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // // $Id:$ // // Copyright (C) 1993-1996 by id Software, Inc. // // This source is available for distribution and/or modification // only under the terms of the DOOM Source Code License as // published by id Software. All rights reserved. // // The source is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License // for more details. // // $Log:$ // // DESCRIPTION: // DOOM graphics stuff for Nspire // //----------------------------------------------------------------------------- //static const char rcsid[] = "$Id: i_x.c,v 1.6 1997/02/03 22:45:10 b1 Exp $"; #include #include "doomstat.h" #include "i_system.h" #include "v_video.h" #include "d_main.h" #include "doomdef.h" #include "charmap.h" #include "screen.h" //Pallette data //High byte: 4 MSBs declare B //Low byte: 4 LSBs declare R //Theoretically, we COULD have saved it in the WAD file somewhere, but fuck that //Hardcoded = Awesome //short = 2 bytes = 16 bits = palette word length //4 LSBs declare R channel, 4 MSBs the high channel short pallette_r[256] = { // CX port 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, }; short pallette_g[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, }; short pallette_l[256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, }; //Define the default palette (required because when we exit, we don't want the OS to be using the Doom palette! ^_^) //Fuck, got it the wrong way around again... short defpal[16] = { 0x00FF,0x00FE,0x00FD,0x00FC,0x00FB,0x00FA,0x00F9,0x00F8,0x0007,0x0006,0x0005,0x0004,0x0003,0x0002,0x0001,0x0000 }; //Pointer to the 8bpp LCD buffer void* LCD_BUFFER; //NB: Screen buffer starts at getScreen() unsigned int* orig_address; // CX port unsigned int orig_contrast; // CX port int ginited=0; int gshutdown=1; void I_DisableGraphics(void) { if(gshutdown) return; // CX port gshutdown=1; // CX port //Reset the GPU unsigned int gmode = *(volatile unsigned*)GCNF_ADDR; // CX port gmode = gmode & ~0b100001110; // CX port clear screen mode + RGB mode if(has_colors) gmode = gmode | 0b100000000; // CX port BGR mode *(volatile unsigned*)GCNF_ADDR= gmode; // CX port if(has_colors) lcd_incolor(); else lcd_ingray(); //reset the LCD buffer *(volatile unsigned*)BFS_ADDR= orig_address; // CX2 port ////Reset contrast - we're not changing it in I_InitGraphics anymore, since the palette is so awesome now *(volatile unsigned*)LCD_CNTRST = orig_contrast; // CX port //Reset palette memcpy((byte *)PAL_ADDR,defpal,32); //Blank the screen (SCREEN_BYTES_SIZE, because we're now back to 4bpp mode!) memset(orig_address, 0x00, has_colors?320*240*2:320*240/2); // CX port } void I_ShutdownGraphics(void) { I_DisableGraphics(); //Free the screen buffers free(screens[0]); free(LCD_BUFFER); // CX2 port } void myBlit8CR4(uint8_t* buffer) { uint16_t x=0,y=0; uint8_t* ptr_in=buffer; uint8_t* ptr_out_orig=LCD_BUFFER+SCREENOFFSET/SCREEN_WIDTH; uint8_t* ptr_out=ptr_out_orig; while(y=0) { *ptr_out=*ptr_in; ptr_in++; if(x==SCREENWIDTH-1) { x=0; y--; ptr_out=ptr_out_orig+y; } else { x++; ptr_out+=SCREEN_HEIGHT; } } } // // I_Flip // void I_Flip (void) { //Flip the active buffer to the LCD controller buffer //PROBLEM: FROM where? I know where to copy TO, and how much of it, but the damn SOURCE ADDRESS is a fucking problem... //Hmm, is it screens[0]??? It could be, but I honestly have no idea... //Where and how do the buffers get switched anyway? Let's check v_video... //Bah, it says nothing... since I_ReadScreen() uses screens[0] as its source, I'll just do that and see what happens... //memcpy (dest, src, width); if(nl_hwsubtype() >= 2) myBlit8CX2(screens[0]); // CX2 port else if(nl_ndless_rev() >= 2004 && screenType()==SCR_240x320_565) // CX2 port myBlit8CR4(screens[0]); else memcpy (LCD_BUFFER + SCREENOFFSET, screens[0], SCREENWIDTH*SCREENHEIGHT); } // // I_TogglePallette //Set the RGB/BGR register on the Nspire GPU to input value //This switches between the two stored pallettes //To further differentiate between taking damage and item pickup, switch the dark/light palettes // void I_TogglePalette (boolean sfx, boolean dark) { //sfx= true > BGR mode //sfx= false > RGB mode if(has_colors) // CX port { if (sfx && !dark) // CX port memcpy((byte *)PAL_ADDR,pallette_g,512); // CX port else if (dark) memcpy((byte *)PAL_ADDR,pallette_r,512); // CX port else memcpy((byte *)PAL_ADDR,pallette_l,512); // CX port } // CX port else // CX port { // CX port unsigned int gmode = *(volatile unsigned*)GCNF_ADDR; // CX port if (sfx) gmode |= 0b100000000; // CX port BGR mode else gmode &= ~0b100000000; // CX port RGB mode *(volatile unsigned*)GCNF_ADDR= gmode; if (dark) memcpy((byte *)PAL_ADDR,pallette_r,512); // CX port else memcpy((byte *)PAL_ADDR,pallette_l,512); } } // // I_ReadScreen // void I_ReadScreen (byte* scr) { memcpy (scr, screens[0], SCREENWIDTH*SCREENHEIGHT); } extern unsigned char sscreen[SCREEN_SIZE]; void I_DispHeader() { memcpy(getScreen(),sscreen,SCREEN_SIZE); //LOADING text //Oldschool hardcoded graphics rule! } // // I_PrepScreen // void I_PrepScreen(void) { I_DispHeader(); // CX port; drwBufStr(getScreen(), 0, 8*CHAR_HEIGHT, "Forward/Back :Arrows 2 8", 0, 1); drwBufStr(getScreen(), 0, 9*CHAR_HEIGHT, "Turn left/right:Arrows 4 6", 0, 1); drwBufStr(getScreen(), 0, 10*CHAR_HEIGHT, "Strafe left :Tab Doc x^2 /", 0, 1); drwBufStr(getScreen(), 0, 11*CHAR_HEIGHT, "Strafe right :Menu ScratchPad x ^", 0, 1); drwBufStr(getScreen(), 0, 12*CHAR_HEIGHT, "Run :Click Trig = |", 0, 1); drwBufStr(getScreen(), 0, 13*CHAR_HEIGHT, "Shoot :Ctrl Del 5 . (-)", 0, 1); drwBufStr(getScreen(), 0, 14*CHAR_HEIGHT, "Choose Weapon :A B C D E F G", 0, 1); drwBufStr(getScreen(), 0, 15*CHAR_HEIGHT, "Action :Shift Space 0 Enter Ret", 0, 1); drwBufStr(getScreen(), 0, 16*CHAR_HEIGHT, "Map :Home ? ?!>", 0, 1); drwBufStr(getScreen(), 0, 17*CHAR_HEIGHT, "Save State :Var", 0, 1); drwBufStr(getScreen(), 0, 18*CHAR_HEIGHT, "Load State :Library", 0, 1); drwBufStr(getScreen(), 0, 19*CHAR_HEIGHT, "Contrast :+ -", 0, 1); } // // I_InitGraphics //Copy the double-pallette (four bits in R, four bits in B) over to the Nspire GPU //Set a 8bpp mode for the display buffer // void I_EnableGraphics(void) { if(!gshutdown || !ginited) return; // CX port; gshutdown=0; // CX port //Reconfig the GPU unsigned int gmode = *(volatile unsigned*)GCNF_ADDR; // CX port gmode = gmode & ~0b100001110; // CX port RGB mode + clear screen mode gmode = gmode | 0b000000110; // CX port 8-bits indexed mode *(volatile unsigned*)GCNF_ADDR= gmode; // CX port //configure the LCD buffer *(volatile unsigned*)BFS_ADDR= (unsigned)LCD_BUFFER; // CX2 port } void I_InitGraphics(void) { ginited=1; //new= (*(volatile unsigned*)GCNF_ADDR & 0xFFF0) | (0xFFFF & 0x000E); //printf ("%x \n", *(volatile unsigned*)GCNF_ADDR); //Gives 0x0C55 //memcpy (dest, src, width); int i, t; // CX port if(has_colors) // CX port { // CX port unsigned int t_pallette_l[256] = { // CX port 0x000000,0x1F170B,0x170F07,0x4B4B4B,0xFFFFFF,0x1B1B1B,0x131313,0x0B0B0B,0x070707,0x2F371F,0x232B0F,0x171F07,0x0F1700,0x4F3B2B,0x473323,0x3F2B1B, // CX port 0xFFB7B7,0xF7ABAB,0xF3A3A3,0xEB9797,0xE78F8F,0xDF8787,0xDB7B7B,0xD37373,0xCB6B6B,0xC76363,0xBF5B5B,0xBB5757,0xB34F4F,0xAF4747,0xA73F3F,0xA33B3B, // CX port 0x9B3333,0x972F2F,0x8F2B2B,0x8B2323,0x831F1F,0x7F1B1B,0x771717,0x731313,0x6B0F0F,0x670B0B,0x5F0707,0x5B0707,0x530707,0x4F0000,0x470000,0x430000, // CX port 0xFFEBDF,0xFFE3D3,0xFFDBC7,0xFFD3BB,0xFFCFB3,0xFFC7A7,0xFFBF9B,0xFFBB93,0xFFB383,0xF7AB7B,0xEFA373,0xE79B6B,0xDF9363,0xD78B5B,0xCF8353,0xCB7F4F, // CX port 0xBF7B4B,0xB37347,0xAB6F43,0xA36B3F,0x9B633B,0x8F5F37,0x875733,0x7F532F,0x774F2B,0x6B4727,0x5F4323,0x533F1F,0x4B371B,0x3F2F17,0x332B13,0x2B230F, // CX port 0xEFEFEF,0xE7E7E7,0xDFDFDF,0xDBDBDB,0xD3D3D3,0xCBCBCB,0xC7C7C7,0xBFBFBF,0xB7B7B7,0xB3B3B3,0xABABAB,0xA7A7A7,0x9F9F9F,0x979797,0x939393,0x8B8B8B, // CX port 0x838383,0x7F7F7F,0x777777,0x6F6F6F,0x6B6B6B,0x636363,0x5B5B5B,0x575757,0x4F4F4F,0x474747,0x434343,0x3B3B3B,0x373737,0x2F2F2F,0x272727,0x232323, // CX port 0x77FF6F,0x6FEF67,0x67DF5F,0x5FCF57,0x5BBF4F,0x53AF47,0x4B9F3F,0x439337,0x3F832F,0x37732B,0x2F6323,0x27531B,0x1F4317,0x17330F,0x13230B,0x0B1707, // CX port 0xBFA78F,0xB79F87,0xAF977F,0xA78F77,0x9F876F,0x9B7F6B,0x937B63,0x8B735B,0x836B57,0x7B634F,0x775F4B,0x6F5743,0x67533F,0x5F4B37,0x574333,0x533F2F, // CX port 0x9F8363,0x8F7753,0x836B4B,0x775F3F,0x675333,0x5B472B,0x4F3B23,0x43331B,0x7B7F63,0x6F7357,0x676B4F,0x5B6347,0x53573B,0x474F33,0x3F472B,0x373F27, // CX port 0xFFFF73,0xEBDB57,0xD7BB43,0xC39B2F,0xAF7B1F,0x9B5B13,0x874307,0x732B00,0xFFFFFF,0xFFDBDB,0xFFBBBB,0xFF9B9B,0xFF7B7B,0xFF5F5F,0xFF3F3F,0xFF1F1F, // CX port 0xFF0000,0xEF0000,0xE30000,0xD70000,0xCB0000,0xBF0000,0xB30000,0xA70000,0x9B0000,0x8B0000,0x7F0000,0x730000,0x670000,0x5B0000,0x4F0000,0x430000, // CX port 0xE7E7FF,0xC7C7FF,0xABABFF,0x8F8FFF,0x7373FF,0x5353FF,0x3737FF,0x1B1BFF,0x0000FF,0x0000E3,0x0000CB,0x0000B3,0x00009B,0x000083,0x00006B,0x000053, // CX port 0xFFFFFF,0xFFEBDB,0xFFD7BB,0xFFC79B,0xFFB37B,0xFFA35B,0xFF8F3B,0xFF7F1B,0xF37317,0xEB6F0F,0xDF670F,0xD75F0B,0xCB5707,0xC34F00,0xB74700,0xAF4300, // CX port 0xFFFFFF,0xFFFFD7,0xFFFFB3,0xFFFF8F,0xFFFF6B,0xFFFF47,0xFFFF23,0xFFFF00,0xA73F00,0x9F3700,0x932F00,0x872300,0x4F3B27,0x432F1B,0x372313,0x2F1B0B, // CX port 0x000053,0x000047,0x00003B,0x00002F,0x000023,0x000017,0x00000B,0x000000,0xFF9F43,0xFFE74B,0xFF7BFF,0xFF00FF,0xCF00CF,0x9F009B,0x6F006B,0xA76B6B // CX port }; // CX port for(i=0;i<256;i++) // CX port { t=t_pallette_l[i]; // CX port pallette_l[i]=(t>>19)|((t&0x00F800)>>6)|((t&0x0000F8)<<7); // CX port pallette_g[i]=(t>>19)|(((t&0x00F800)|0x001800)>>6)|(((t&0x0000F8)|0x000018)<<7); // CX port pallette_r[i]=((t|0xF80000)>>19)|((t&0x00F800)>>6)|((t&0x0000F8)<<7); // CX port } // CX port } // CX port else // CX port { // CX port short t_pallette_l[256] = { // CX port 0x001E,0x081C,0x081C,0x1016,0x7800,0x081C,0x081C,0x001E,0x001E,0x1818,0x101A,0x081C,0x081C,0x1818,0x1818,0x101A, 0x6006,0x6006,0x5808,0x5808,0x500A,0x500A,0x480C,0x480C,0x400E,0x400E,0x3810,0x3810,0x3012,0x3012,0x2814,0x2814, 0x2814,0x1016,0x1016,0x1016,0x1818,0x1818,0x1818,0x1818,0x101A,0x101A,0x101A,0x101A,0x081C,0x081C,0x081C,0x081C, 0x7800,0x7002,0x7002,0x6804,0x6804,0x6804,0x6006,0x6006,0x6006,0x5808,0x5808,0x500A,0x500A,0x480C,0x480C,0x480C, 0x400E,0x400E,0x3810,0x3810,0x3012,0x3012,0x3012,0x2814,0x2814,0x1016,0x1016,0x1016,0x1818,0x1818,0x101A,0x101A, 0x7002,0x7002,0x6804,0x6804,0x6804,0x6006,0x6006,0x5808,0x5808,0x5808,0x500A,0x500A,0x480C,0x480C,0x480C,0x400E, 0x400E,0x3810,0x3810,0x3012,0x3012,0x3012,0x2814,0x2814,0x1016,0x1016,0x1016,0x1818,0x1818,0x101A,0x101A,0x101A, 0x6006,0x5808,0x500A,0x500A,0x480C,0x400E,0x3810,0x3810,0x3012,0x2814,0x1016,0x1016,0x1818,0x101A,0x081C,0x081C, 0x500A,0x500A,0x480C,0x480C,0x400E,0x400E,0x400E,0x3810,0x3810,0x3012,0x3012,0x2814,0x2814,0x1016,0x1016,0x1016, 0x400E,0x3810,0x3012,0x3012,0x2814,0x1016,0x1818,0x1818,0x3810,0x3012,0x3012,0x2814,0x2814,0x1016,0x1016,0x1818, 0x7800,0x6804,0x5808,0x480C,0x400E,0x3012,0x2814,0x1818,0x7800,0x7002,0x6006,0x5808,0x500A,0x400E,0x3810,0x3012, 0x1016,0x1016,0x1016,0x1016,0x1818,0x1818,0x1818,0x1818,0x101A,0x101A,0x101A,0x101A,0x081C,0x081C,0x081C,0x081C, 0x7002,0x6006,0x5808,0x480C,0x400E,0x3012,0x1016,0x1818,0x081C,0x081C,0x081C,0x081C,0x081C,0x001E,0x001E,0x001E, 0x7800,0x7002,0x7002,0x6804,0x6006,0x5808,0x500A,0x480C,0x400E,0x400E,0x400E,0x3810,0x3810,0x3012,0x3012,0x2814, 0x7800,0x7800,0x7800,0x7800,0x7002,0x7002,0x7002,0x7002,0x2814,0x2814,0x1016,0x1818,0x1818,0x1818,0x101A,0x081C, 0x001E,0x001E,0x001E,0x001E,0x001E,0x001E,0x001E,0x001E,0x5808,0x6804,0x5808,0x3012,0x2814,0x1016,0x101A,0x3810 }; //FUUUUUCK! It's bits 1-4 that determine R, not 0-3! That's why the palette was so bad before... let's try and fix this short t_pallette_r[256] = { // CX port 0x001E,0x101C,0x101C,0x4016,0xF000,0x101C,0x101C,0x001E,0x001E,0x3018,0x201A,0x101C,0x101C,0x3018,0x3018,0x201A, 0xC006,0xC006,0xB008,0xB008,0xA00A,0xA00A,0x900C,0x900C,0x800E,0x800E,0x7010,0x7010,0x6012,0x6012,0x5014,0x5014, 0x5014,0x4016,0x4016,0x4016,0x3018,0x3018,0x3018,0x3018,0x201A,0x201A,0x201A,0x201A,0x101C,0x101C,0x101C,0x101C, 0xF000,0xE002,0xE002,0xD004,0xD004,0xD004,0xC006,0xC006,0xC006,0xB008,0xB008,0xA00A,0xA00A,0x900C,0x900C,0x900C, 0x800E,0x800E,0x7010,0x7010,0x6012,0x6012,0x6012,0x5014,0x5014,0x4016,0x4016,0x4016,0x3018,0x3018,0x201A,0x201A, 0xE002,0xE002,0xD004,0xD004,0xD004,0xC006,0xC006,0xB008,0xB008,0xB008,0xA00A,0xA00A,0x900C,0x900C,0x900C,0x800E, 0x800E,0x7010,0x7010,0x6012,0x6012,0x6012,0x5014,0x5014,0x4016,0x4016,0x4016,0x3018,0x3018,0x201A,0x201A,0x201A, 0xC006,0xB008,0xA00A,0xA00A,0x900C,0x800E,0x7010,0x7010,0x6012,0x5014,0x4016,0x4016,0x3018,0x201A,0x101C,0x101C, 0xA00A,0xA00A,0x900C,0x900C,0x800E,0x800E,0x800E,0x7010,0x7010,0x6012,0x6012,0x5014,0x5014,0x4016,0x4016,0x4016, 0x800E,0x7010,0x6012,0x6012,0x5014,0x4016,0x3018,0x3018,0x7010,0x6012,0x6012,0x5014,0x5014,0x4016,0x4016,0x3018, 0xF000,0xD004,0xB008,0x900C,0x800E,0x6012,0x5014,0x3018,0xF000,0xE002,0xC006,0xB008,0xA00A,0x800E,0x7010,0x6012, 0x4016,0x4016,0x4016,0x4016,0x3018,0x3018,0x3018,0x3018,0x201A,0x201A,0x201A,0x201A,0x101C,0x101C,0x101C,0x101C, 0xE002,0xC006,0xB008,0x900C,0x800E,0x6012,0x4016,0x3018,0x101C,0x101C,0x101C,0x101C,0x101C,0x001E,0x001E,0x001E, 0xF000,0xE002,0xE002,0xD004,0xC006,0xB008,0xA00A,0x900C,0x800E,0x800E,0x800E,0x7010,0x7010,0x6012,0x6012,0x5014, 0xF000,0xF000,0xF000,0xF000,0xE002,0xE002,0xE002,0xE002,0x5014,0x5014,0x4016,0x3018,0x3018,0x3018,0x201A,0x101C, 0x001E,0x001E,0x001E,0x001E,0x001E,0x001E,0x001E,0x001E,0xB008,0xD004,0xB008,0x6012,0x5014,0x4016,0x201A,0x7010 }; for(i=0;i<256;i++) // CX port { pallette_l[i]=t_pallette_l[i]; // CX port pallette_r[i]=t_pallette_r[i]; // CX port } // CX port } // CX port orig_address = *(volatile unsigned*)BFS_ADDR; // CX port orig_contrast = *(volatile unsigned*)LCD_CNTRST; // CX port LCD_BUFFER= malloc(SCREEN_PIXELS); // CX2 port //Floodfill the entire Nspire screen, to eliminate garbage pixels memset(LCD_BUFFER, 0x00, SCREEN_PIXELS); /*C.O.E. DEBUG*/ //Upload the palette memcpy((byte *)PAL_ADDR,pallette_l,512); I_EnableGraphics(); // CX port; }