… | |
… | |
83 | mapcell *col; |
83 | mapcell *col; |
84 | } maprow; |
84 | } maprow; |
85 | |
85 | |
86 | typedef struct map { |
86 | typedef struct map { |
87 | int x, y, w, h; |
87 | int x, y, w, h; |
|
|
88 | int dx, dy; /* delayed map scrolling */ |
88 | int ox, oy; /* offset to virtual global coordinate system */ |
89 | int ox, oy; /* offset to virtual global coordinate system */ |
89 | int faces; |
90 | int faces; |
90 | mapface *face; |
91 | mapface *face; |
91 | |
92 | |
92 | int texs; |
93 | int texs; |
… | |
… | |
578 | tex->g = g; |
579 | tex->g = g; |
579 | tex->b = b; |
580 | tex->b = b; |
580 | tex->a = a; |
581 | tex->a = a; |
581 | } |
582 | } |
582 | |
583 | |
583 | void |
|
|
584 | scroll (CFClient::Map self, int dx, int dy) |
|
|
585 | CODE: |
|
|
586 | { |
|
|
587 | if (dx > 0) |
|
|
588 | map_blank (self, self->x, self->y, dx - 1, self->h); |
|
|
589 | else if (dx < 0) |
|
|
590 | map_blank (self, self->x + self->w + dx + 1, self->y, 1 - dx, self->h); |
|
|
591 | |
|
|
592 | if (dy > 0) |
|
|
593 | map_blank (self, self->x, self->y, self->w, dy - 1); |
|
|
594 | else if (dy < 0) |
|
|
595 | map_blank (self, self->x, self->y + self->h + dy + 1, self->w, 1 - dy); |
|
|
596 | |
|
|
597 | self->x += dx; self->ox += dx; |
|
|
598 | self->y += dy; self->oy += dy; |
|
|
599 | |
|
|
600 | while (self->y < 0) |
|
|
601 | { |
|
|
602 | Prepend (maprow, self->row, self->rows, MAP_EXTEND_Y); |
|
|
603 | |
|
|
604 | self->rows += MAP_EXTEND_Y; |
|
|
605 | self->y += MAP_EXTEND_Y; |
|
|
606 | } |
|
|
607 | } |
|
|
608 | |
|
|
609 | int |
584 | int |
610 | ox (CFClient::Map self) |
585 | ox (CFClient::Map self) |
611 | ALIAS: |
586 | ALIAS: |
612 | oy = 1 |
587 | oy = 1 |
613 | CODE: |
588 | CODE: |
… | |
… | |
618 | } |
593 | } |
619 | OUTPUT: |
594 | OUTPUT: |
620 | RETVAL |
595 | RETVAL |
621 | |
596 | |
622 | void |
597 | void |
|
|
598 | scroll (CFClient::Map self, int dx, int dy) |
|
|
599 | CODE: |
|
|
600 | { |
|
|
601 | self->dx += dx; self->ox += dx; |
|
|
602 | self->dy += dy; self->oy += dy; |
|
|
603 | } |
|
|
604 | |
|
|
605 | void |
623 | map1a_update (CFClient::Map self, SV *data_) |
606 | map1a_update (CFClient::Map self, SV *data_) |
624 | CODE: |
607 | CODE: |
625 | { |
608 | { |
|
|
609 | if (self->dx > 0) |
|
|
610 | map_blank (self, self->x, self->y, self->dx - 1, self->h); |
|
|
611 | else if (self->dx < 0) |
|
|
612 | map_blank (self, self->x + self->w + self->dx + 1, self->y, 1 - self->dx, self->h); |
|
|
613 | |
|
|
614 | if (self->dy > 0) |
|
|
615 | map_blank (self, self->x, self->y, self->w, self->dy - 1); |
|
|
616 | else if (self->dy < 0) |
|
|
617 | map_blank (self, self->x, self->y + self->h + self->dy + 1, self->w, 1 - self->dy); |
|
|
618 | |
|
|
619 | self->x += self->dx; self->dx = 0; |
|
|
620 | self->y += self->dy; self->dy = 0; |
|
|
621 | |
|
|
622 | while (self->y < 0) |
|
|
623 | { |
|
|
624 | Prepend (maprow, self->row, self->rows, MAP_EXTEND_Y); |
|
|
625 | |
|
|
626 | self->rows += MAP_EXTEND_Y; |
|
|
627 | self->y += MAP_EXTEND_Y; |
|
|
628 | } |
|
|
629 | |
626 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
630 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
627 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
631 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
628 | |
632 | |
629 | while (data < data_end) |
633 | while (data < data_end) |
630 | { |
634 | { |
631 | int flags = (data [0] << 8) + data [1]; data += 2; |
635 | int flags = (data [0] << 8) + data [1]; data += 2; |
632 | |
636 | |
633 | int x = ((flags >> 10) & 63) + self->x; |
637 | int x = ((flags >> 10) & 63) + self->x; |