0 Members and 1 Guest are viewing this topic.
#include <os.h>//addresses#define SCREEN_ADDRESS 0xA4000100 ;//prototypsvoid set_screen (void) ;void set_value(int address, unsigned int value) ;void clear_screen(void) ;//global variablesint screen_cords[240][180] ;int main(void){ set_screen() ; clear_screen() ; while ( !isKeyPressed ( KEY_NSPIRE_ESC) ) { set_value( screen_cords[100][100] , 0x00 ) ; set_value( screen_cords[100][101] , 0x00 ) ; set_value( screen_cords[100][102] , 0x00 ) ; set_value( screen_cords[101][100] , 0x00 ) ; set_value( screen_cords[101][101] , 0x00 ) ; set_value( screen_cords[101][102] , 0x00 ) ; set_value( screen_cords[102][100] , 0x0F ) ; set_value( screen_cords[102][101] , 0xFF ) ; set_value( screen_cords[102][102] , 0x00 ) ; set_value( screen_cords[103][100] , 0xF0 ) ; set_value( screen_cords[103][101] , 0x00 ) ; set_value( screen_cords[103][102] , 0xF0 ) ; set_value( screen_cords[104][100] , 0xF0 ) ; set_value( screen_cords[104][101] , 0x00 ) ; set_value( screen_cords[104][102] , 0xF0 ) ; set_value( screen_cords[105][100] , 0xFF ) ; set_value( screen_cords[105][101] , 0xFF ) ; set_value( screen_cords[105][102] , 0xF0 ) ; set_value( screen_cords[106][100] , 0xF0 ) ; set_value( screen_cords[106][101] , 0x00 ) ; set_value( screen_cords[106][102] , 0xF0 ) ; set_value( screen_cords[107][100] , 0xF0 ) ; set_value( screen_cords[107][101] , 0x00 ) ; set_value( screen_cords[107][102] , 0xF0 ) ; set_value( screen_cords[108][100] , 0xF0 ) ; set_value( screen_cords[108][101] , 0x00 ) ; set_value( screen_cords[108][102] , 0xF0 ) ; set_value( screen_cords[110][100] , 0xFF ) ; set_value( screen_cords[110][101] , 0xFF ) ; set_value( screen_cords[110][102] , 0xFF ) ; } return 0;}void set_screen(void){ int ycordinate, xcordinate ; int screen_address = SCREEN_ADDRESS ; for ( ycordinate = 1 ; ycordinate == 240 ; ycordinate++ ) { for ( xcordinate = 1 ; xcordinate == 180 ; xcordinate++ ) { screen_cords[ycordinate][xcordinate] = (screen_address + (xcordinate-1) + (ycordinate-1)*180) ; } }}void set_value(int address, unsigned int value){ (*(volatile unsigned*)address) = value ;}void clear_screen(void){ int ycordinate, xcordinate ; for ( ycordinate = 1 ; ycordinate == 240 ; ycordinate++ ) { for ( xcordinate = 1 ; xcordinate == 180 ; xcordinate++ ) { set_value(screen_cords[ycordinate][xcordinate] , 0x00 ) ; } }}
void clrscr(void) { memset(SCREEN_BASE_ADDRESS, 0xFF, SCREEN_BYTES_SIZE);}
You only need "volatile" when writing to memory-mapped I/O ports. In this case, it will suffice to use *(unsigned*)b = a;
And 0xF is actually a white pixel, might you have been expecting black?