@@ -574,8 +574,8 @@ parse(ch)
574574 case 'b' : /*move south west*/
575575 pager = 0 ;
576576 selector = 0 ;
577- xcurs -- ;
578- ycurs ++ ;
577+ if ( XREAL > 0 ) xcurs -- ;
578+ if ( YREAL < MAPY - 1 ) ycurs ++ ;
579579 break ;
580580 case 'B' : /*budget*/
581581 redraw = FULL ;
@@ -620,13 +620,14 @@ parse(ch)
620620 case 'H' : /*scroll west*/
621621 pager = 0 ;
622622 selector = 0 ;
623- xcurs -= ((COLS - 22 )/4 );
623+ if (XREAL > (COLS - 22 )/4 ) xcurs -= ((COLS - 22 )/4 );
624+ else xcurs = - xoffset ;
624625 break ;
625626 case '4' :
626627 case 'h' : /*move west*/
627628 pager = 0 ;
628629 selector = 0 ;
629- xcurs -- ;
630+ if ( XREAL > 0 ) xcurs -- ;
630631 break ;
631632 case 'I' : /*campaign information*/
632633 camp_info ();
@@ -635,35 +636,39 @@ parse(ch)
635636 case 'J' : /*scroll down*/
636637 pager = 0 ;
637638 selector = 0 ;
638- ycurs += ((SCREEN_Y_SIZE )/2 );
639+ if (YREAL + (SCREEN_Y_SIZE )/2 < MAPY )
640+ ycurs += ((SCREEN_Y_SIZE )/2 );
641+ else ycurs = MAPY - yoffset - 1 ;
639642 break ;
640643 case '2' :
641644 case 'j' : /*move down*/
642645 pager = 0 ;
643646 selector = 0 ;
644- ycurs ++ ;
647+ if ( YREAL < MAPY - 1 ) ycurs ++ ;
645648 break ;
646649 case '8' :
647650 case 'k' : /*move up*/
648651 pager = 0 ;
649652 selector = 0 ;
650- ycurs -- ;
653+ if ( YREAL > 0 ) ycurs -- ;
651654 break ;
652655 case 'K' : /*scroll up*/
653656 pager = 0 ;
654657 selector = 0 ;
655- ycurs -= ((SCREEN_Y_SIZE )/2 );
658+ if (YREAL > (SCREEN_Y_SIZE )/2 ) ycurs -= ((SCREEN_Y_SIZE )/2 );
659+ else ycurs = - yoffset ;
656660 break ;
657661 case '6' :
658662 case 'l' : /*move east*/
659663 pager = 0 ;
660664 selector = 0 ;
661- xcurs ++ ;
665+ if ( XREAL < MAPX - 1 ) xcurs ++ ;
662666 break ;
663667 case 'L' : /*scroll east*/
664668 pager = 0 ;
665669 selector = 0 ;
666- xcurs += ((COLS - 22 )/4 );
670+ if (XREAL + (COLS - 22 )/4 < MAPX ) xcurs += ((COLS - 22 )/4 );
671+ else xcurs = MAPX - xoffset - 1 ;
667672 break ;
668673 case 'm' : /*move selected item to new x,y */
669674 mymove ();
@@ -680,8 +685,8 @@ parse(ch)
680685 case 'n' : /*move south-east*/
681686 pager = 0 ;
682687 selector = 0 ;
683- ycurs ++ ;
684- xcurs ++ ;
688+ if ( YREAL < MAPY - 1 ) ycurs ++ ;
689+ if ( XREAL < MAPX - 1 ) xcurs ++ ;
685690 break ;
686691 case 'N' : /*read newspaper */
687692 redraw = PART ;
@@ -762,14 +767,16 @@ parse(ch)
762767 case 'u' : /*move north-east*/
763768 pager = 0 ;
764769 selector = 0 ;
765- ycurs -- ;
766- xcurs ++ ;
770+ if ( YREAL > 0 ) ycurs -- ;
771+ if ( XREAL < MAPX - 1 ) xcurs ++ ;
767772 break ;
768773 case 'U' : /* scroll north-east */
769774 pager = 0 ;
770775 selector = 0 ;
771- xcurs += ((COLS - 22 )/4 );
772- ycurs -= ((SCREEN_Y_SIZE )/2 );
776+ if (XREAL + (COLS - 22 )/4 < MAPX ) xcurs += ((COLS - 22 )/4 );
777+ else xcurs = MAPX - xoffset - 1 ;
778+ if (YREAL > (SCREEN_Y_SIZE )/2 ) ycurs -= ((SCREEN_Y_SIZE )/2 );
779+ else ycurs = - yoffset ;
773780 break ;
774781 case 'v' : /* version credits */
775782 credits ();
@@ -801,14 +808,16 @@ parse(ch)
801808 case 'y' : /*move north-west*/
802809 pager = 0 ;
803810 selector = 0 ;
804- ycurs -- ;
805- xcurs -- ;
811+ if ( YREAL > 0 ) ycurs -- ;
812+ if ( XREAL > 0 ) xcurs -- ;
806813 break ;
807814 case 'Y' : /* scroll north-west */
808815 pager = 0 ;
809816 selector = 0 ;
810- xcurs -= ((COLS - 22 )/4 );
811- ycurs -= ((SCREEN_Y_SIZE )/2 );
817+ if (XREAL < (COLS - 22 )/4 ) xcurs = - xoffset ;
818+ else xcurs -= ((COLS - 22 )/4 );
819+ if (YREAL < (SCREEN_Y_SIZE )/2 ) ycurs = - yoffset ;
820+ else ycurs -= ((SCREEN_Y_SIZE )/2 );
812821 break ;
813822 case 'Z' : /*move civilians up to 2 spaces*/
814823 moveciv ();
0 commit comments