Automap

version 4 by Mark Tilford

  • Home page
  • Beginning
  • Previous
  • Next



  • Section 4 - Displaying the map
        
    [ Adapted from Emily Short's Basic Screen Effects ]
    To fill status bar with (selected table - a table-name) and map:
    let __n be the number of rows in the selected table;
        if the current zoom is map absent begin;
         deepen status line to __n rows;
        otherwise;
         deepen status line to __n + map height rows;
        end if;
        let __index be 1;
    repeat through selected table
    begin;
    move cursor to __index;
    say "[left entry]";
    center central entry at row __index;
    right align cursor to __index;
    say "[right entry]";
    now __index is __index + 1;
    end repeat;
        if the map is drawn and the current zoom is not map absent, display the map at line __n;
        [if __b and the current zoom is not map absent, display the map at line __n + 1;]
            
    Before constructing the status line (this is the automap add adjacent rooms to map rule) : if the automap manual exploration option is not active and the location is a mappable room and the location is not explored, say "Error exploring [location]."

    Rule for constructing the status line (this is the automap standard status line rule):
        fill status bar with table of ordinary status and map.

    To display the map at line (n - a number):
        (- I6_Draw_Map_At ({n}); -).


    Include (-


    ! From fizmo's _streams_z_ucs_output
    Array Automap_Unicode_Conv -->
    0 $2500 $2502 63 63 63 63 63 63 63 63 11 12 13 14 15 ! 0 - 15
    16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ! 16 - 31
    32 $2190 $2192 47 92 32 $2500 $2500 $2502 $2502 $2534 $252c $251c $2524 $2301 $2308 ! 32 - 47
    ! 32 $2190 $2192 $2571 $2572 32 $2500 $2500 $2502 $2502 $2534 $252c $251c $2524 $2301 $2308 ! 32 - 47
    $2309 $230b $2534 $252c $251c $2524 $2588 $2580 $2584 $258c $2590 $2584 $2580 $258c $2590 $259d ! 48 - 63
    $2597 $2596 $2598 $259d $2597 $2596 $2598 43 43 43 43 $2594 95 $23b9 $2595 32 ! 64 - 79
    $258f $258e $258d $258c $258b $258a $2589 $2588 $2595 $258f $2573 $253c $2191 $2193 $2195 $25a2 ! 80 - 95
    63 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 ! 96 - 111
    112 113 114 115 116 117 118 119 120 121 122 $2191 $2193 $2195 63 127 ! 112 - 127
    ;

    Array Automap_Font_0_Conv -> 0 45 124 73 79 73 105 111 105 63 63 11 12 13 14 15 ! 0 - 15
    16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ! 16 - 31
    32 33 34 47 92 32 45 45 124 124 43 43 43 43 111 111 ! 32 - 47
    111 111 47 92 47 92 42 42 42 42 42 42 42 42 42 42 ! 48 - 63
    42 42 42 42 42 42 42 71 72 73 74 75 76 77 78 79 ! 64 - 79
    80 81 82 83 84 85 86 87 88 89 88 43 85 68 59 111 ! 80 - 95
    96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 ! 96 - 111
    112 113 114 115 116 117 118 119 120 121 122 117 100 59 126 127 ! 112 - 127
    ;
    Array Automap_Font_3_Conv -> 0 38 40 96 96 96 126 126 126 96 126 11 12 13 14 15 ! 0 - 15
    16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ! 16 - 31
    32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 ! 32 - 47
    48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 ! 48 - 63
    64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 ! 64 - 79
    80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 ! 80 - 95
    96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 ! 96 - 111
    112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 ! 112 - 127
    ;



    [ I6_Draw_Map_At line_n width posa posb ctr ch graphic_mode transform_table hyperlink_room;
        ++ line_n;
        posa = line_n + 1;
        width = VM_ScreenWidth();
        graphic_mode = 0;

        if ( (+ current displayness +) == (+ map display fancy +) or (+ map display automatic +) ) {
            #Ifdef TARGET_ZCODE;
            @set_font 3 graphic_mode; ! TODO: Make this glulx friendly
            #endif;
            if ( (+ current displayness +) == (+ map display fancy +) ) {
                graphic_mode = 3;
            }
        }
        if ( (+ current displayness +) == (+ map display unicode +) ) {
            #ifdef TARGET_ZCODE;
                graphic_mode = -1;
            #ifnot;
                if (unicode_gestalt_ok) {
                    graphic_mode = -1;
                } else {
                    graphic_mode = 0;
                }
            #endif;
        }
        transform_table = Automap_Font_0_Conv;
        if (graphic_mode == 0) {
            #ifdef AUTOMAP_VISIBLE_BACKGROUND;
                transform_table->32 = '.';
            #endif;
        } else if (graphic_mode == -1) {
            transform_table = Automap_Unicode_Conv;
            #ifdef AUTOMAP_VISIBLE_BACKGROUND;
                transform_table-->32 = 71;
            #endif;
        } else {
            transform_table = Automap_Font_3_Conv;
            #ifdef AUTOMAP_VISIBLE_BACKGROUND;
                transform_table->32 = 71;
            #endif;
        }
        #ifdef TARGET_ZCODE;
        @set_window 1;
        #ifnot;
        ! TODO
        #endif;

        ctr = 0;
        for (posa = line_n: posa < MAP_HEIGHT + line_n: ++ posa) {
            posb = width - MAP_WIDTH - 1;
            VM_MoveCursorInStatusLine (posa, posb);;

            for (posb = 0: posb < MAP_WIDTH: ++ posb) {
                #ifdef AUTOMAP_HYPERLINKS;
                hyperlink_room = Automap_links --> (ctr);
                if (hyperlink_room ~= 0) {
                    ! TODO copy-pasted from Basic Hyperlinks - Is there a way to call instead?
                    if (glk_gestalt(gestalt_Hyperlinks, 0)) glk_set_hyperlink(hyperlink_room);
                    ! set room link to hyperlink_room;
                    ! !say "[set slink hyperlink_room]"; ;
                }
                if (graphic_mode == -1) {
                    #ifdef TARGET_ZCODE;
                        ch = transform_table-->(Automap_Chars->( ctr ++ ));
                        @print_unicode ch;
                    #ifnot;
                        glk_put_char_uni (transform_table-->(Automap_Chars->( ctr ++ )));
                    #endif;
                } else
                    print (char) transform_table->(Automap_Chars->( ctr ++ ));

                if (hyperlink_room ~= 0) {
                    ! TODO copy-pasted from Basic Hyperlinks - Is there a way to call instead?
                    if (glk_gestalt(gestalt_Hyperlinks, 0)) glk_set_hyperlink(0);
                    !end room link;
                }
                ! say "[end xlink]"; ;
                #ifnot;
                    if (graphic_mode == -1) {
                        #ifdef TARGET_ZCODE;
                            ch = transform_table-->(Automap_Chars->( ctr ++ ));
                            @print_unicode ch;
                        #ifnot;
                            glk_put_char_uni (transform_table-->(Automap_Chars->( ctr ++ )));
                        #endif;
                    } else
                        print (char) transform_table->(Automap_Chars->( ctr ++ ));
                #endif;
            }
        }
        #ifdef TARGET_ZCODE;
        if (graphic_mode > 0)
            @set_font 1 posa;
        style roman;
        font on;
        #ifnot;
        ! TODO
        #endif;
        #ifdef AUTOMAP_HYPERLINKS;
        glk_request_hyperlink_event(gg_statuswin);
        #endif;
    ];
    -);


    The automap size is a number that varies. The automap size is usually 9. When play begins: if automap size is at least 1, reserve automap memory of automap size rows.

    To say (n - a number) blank lines:
        while n > 0:
            say "[line break]";
            decrease n by 1.