[rfk-dev] RFK that fills your terminal

Paul J Collins sneakums@zork.net
10 Mar 2001 01:42:25 +0000


Got a big terminal?  Feel it's wasted having robotfindskitten huddle
in the corner?  This patch is for you.

This is against HEAD, not my freaky branch.

*** src/robotfindskitten.c      2001/02/22 04:29:33     1.15
--- src/robotfindskitten.c      2001/03/10 01:38:07
***************
*** 36,41 ****
--- 36,42 ----
  
  
  #include <signal.h>
+ #include <stdlib.h>
  
  /*The messages go in a separate file because they are collectively
    huge, and you might want to modify them. It would be nice to load
***************
*** 86,94 ****
  #define KEY_REDRAW ('L' - 64)
  /*Screen dimensions.*/
  #define X_MIN 0
! #define X_MAX 79
  #define Y_MIN 3
! #define Y_MAX 23
  
  /*Macros for generating numbers in different ranges*/
  #define randx() rand() % X_MAX+1
--- 87,95 ----
  #define KEY_REDRAW ('L' - 64)
  /*Screen dimensions.*/
  #define X_MIN 0
! #define X_MAX (COLS - 1)
  #define Y_MIN 3
! #define Y_MAX (LINES - 1)
  
  /*Macros for generating numbers in different ranges*/
  #define randx() rand() % X_MAX+1
***************
*** 148,154 ****
   array is bigger than it needs to be, as we don't need to keep track
   of the first few rows of the screen. But that requires making an
   offset function and using that everywhere. So not right now. */
! int screen[X_MAX+1][Y_MAX+1];
  
  #include "draw.h"
  
--- 149,155 ----
   array is bigger than it needs to be, as we don't need to keep track
   of the first few rows of the screen. But that requires making an
   offset function and using that everywhere. So not right now. */
! int** screen = NULL;
  
  #include "draw.h"
  
***************
*** 386,394 ****
  void initialize_arrays()
  {
    int counter, counter2;
  
    /*Initialize the empty object.*/
-   screen_object empty;
    empty.x = -1;
    empty.y = -1;
    empty.color = 0;
--- 387,403 ----
  void initialize_arrays()
  {
    int counter, counter2;
+   screen_object empty;
+   int i = 0;
  
+   /* Allocate memory for the screen. */
+   screen = malloc (sizeof (int*) * (X_MAX + 1));
+   for (i = 0; i < (X_MAX + 1); ++i) {
+           /* XXX: blah blah blah check for NULL */
+           screen[i] = malloc (sizeof (int) * (Y_MAX + 1));
+   }
+   
    /*Initialize the empty object.*/
    empty.x = -1;
    empty.y = -1;
    empty.color = 0;
***************
*** 566,571 ****
--- 575,582 ----
     randchar() macro. */
     printf("%c%c%c",27,'(','U');
  
+   initialize_ncurses();  
+ 
    initialize_arrays();
  
    /*
***************
*** 575,581 ****
    initialize_kitten();
    initialize_bogus();
  
-   initialize_ncurses();  
    instructions();  
  
    initialize_screen();
--- 586,591 ----


-- 
"Pity has no place at my table."
      -- Dr Hannibal Lecter