#include #include #include #include #include "gr-sim.h" #define XSIZE 40 #define YSIZE 48 #define PIXEL_X_SCALE 14 #define PIXEL_Y_SCALE 8 static int xsize=XSIZE*PIXEL_X_SCALE; static int ysize=YSIZE*PIXEL_Y_SCALE; static unsigned char framebuffer[XSIZE][YSIZE]; /* 128kB of RAM */ unsigned char ram[128*1024]; static SDL_Surface *sdl_screen=NULL; int grsim_input(void) { SDL_Event event; int keypressed; while ( SDL_PollEvent(&event)) { switch(event.type) { case SDL_KEYDOWN: keypressed=event.key.keysym.sym; switch (keypressed) { case SDLK_ESCAPE: return 'q'; default: return keypressed; } break; case SDL_JOYBUTTONDOWN: case SDL_JOYAXISMOTION: default: printf("Unknown input action!\n"); break; } } return 0; } static unsigned int color[16]={ 0, /* 0 black */ 0xe31e60, /* 1 magenta */ 0x604ebd, /* 2 dark blue */ 0xff44fd, /* 3 purple */ 0x00a360, /* 4 dark green */ 0x9c9c9c, /* 5 grey 1 */ 0x14cffd, /* 6 medium blue */ 0xd0c3ff, /* 7 light blue */ 0x607203, /* 8 brown */ 0xff6a3c, /* 9 orange */ 0x9d9d9d, /* 10 grey 2 */ 0xffa0d0, /* 11 pink */ 0x14f53c, /* 12 bright green */ 0xd0dd8d, /* 13 yellow */ 0x72ffd0, /* 14 aqua */ 0xffffff, /* 15 white */ }; int grsim_update(void) { int x,y,i,j; unsigned int *t_pointer; t_pointer=((Uint32 *)sdl_screen->pixels); for(y=0;y40) { printf("X too big %d\n",x); return -1; } if (y>40) { printf("Y too big %d\n",y); return -1; } if (x<0) { printf("X too small %d\n",x); return -1; } if (y<0) { printf("Y too small %d\n",y); return -1; } framebuffer[x][y]=current_color; return 0; } int hlin(int x1, int x2, int at) { int i; for(i=x1;i