Subversion Repositories Games.Rick Dangerous

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 pmbaty 1
/*
2
 * src/scroller.c
3
 *
4
 * Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
5
 *
6
 * The use and distribution terms for this software are contained in the file
7
 * named README, which can be found in the root of this distribution. By
8
 * using this software in any fashion, you are agreeing to be bound by the
9
 * terms of this license.
10
 *
11
 * You must not remove this notice, or any other, from this software.
12
 */
13
 
14
#include <stdlib.h>
15
 
16
#include "system.h"
17
#include "game.h"
18
#include "scroller.h"
19
 
20
#include "draw.h"
21
#include "maps.h"
22
#include "ents.h"
23
 
24
static U8 period;
25
 
26
/*
27
 * Scroll up
28
 *
29
 */
30
U8 scroll_up (void)
31
{
32
   U8 i, j;
33
   static U8 n = 0;
34
 
35
   /* last call: restore */
36
   if (n == 8)
37
   {
38
      n = 0;
39
      game_period = period;
40
      return SCROLL_DONE;
41
   }
42
 
43
   /* first call: prepare */
44
   if (n == 0)
45
   {
46
      period = game_period;
47
      game_period = SCROLL_PERIOD;
48
   }
49
 
50
   /* translate map */
51
   for (i = MAP_ROW_SCRTOP; i < MAP_ROW_HBBOT; i++)
52
      for (j = 0x00; j < 0x20; j++)
53
         map_map[i][j] = map_map[i + 1][j];
54
 
55
   /* translate entities */
56
   for (i = 0; ent_ents[i].n != 0xFF; i++)
57
   {
58
      if (ent_ents[i].n)
59
      {
60
         ent_ents[i].ysave -= 8;
61
         ent_ents[i].trig_y -= 8;
62
         ent_ents[i].y -= 8;
63
 
64
         if (ent_ents[i].y & 0x8000)
65
            ent_ents[i].n = 0; // map coord. from 0x0000 to 0x0140
66
      }
67
   }
68
 
69
   /* display */
70
   draw_map ();
71
   ent_draw ();
72
   draw_drawStatus ();
73
   map_frow++;
74
 
75
   /* loop */
76
   if (n++ == 7)
77
   {
78
      /* activate visible entities */
79
      ent_actvis ((U8) (map_frow + MAP_ROW_HBTOP), (U8) (map_frow + MAP_ROW_HBBOT));
80
 
81
      /* prepare map */
82
      map_expand ();
83
 
84
      /* display */
85
      draw_map ();
86
      ent_draw ();
87
      draw_drawStatus ();
88
   }
89
 
90
   game_rects = &draw_SCREENRECT;
91
 
92
   return SCROLL_RUNNING;
93
}
94
 
95
 
96
/*
97
 * Scroll down
98
 *
99
 */
100
U8 scroll_down (void)
101
{
102
   U8 i, j;
103
   static U8 n = 0;
104
 
105
   /* last call: restore */
106
   if (n == 8)
107
   {
108
      n = 0;
109
      game_period = period;
110
      return SCROLL_DONE;
111
   }
112
 
113
   /* first call: prepare */
114
   if (n == 0)
115
   {
116
      period = game_period;
117
      game_period = SCROLL_PERIOD;
118
   }
119
 
120
   /* translate map */
121
   for (i = MAP_ROW_SCRBOT; i > MAP_ROW_HTTOP; i--)
122
      for (j = 0x00; j < 0x20; j++)
123
         map_map[i][j] = map_map[i - 1][j];
124
 
125
   /* translate entities */
126
   for (i = 0; ent_ents[i].n != 0xFF; i++)
127
   {
128
      if (ent_ents[i].n)
129
      {
130
         ent_ents[i].ysave += 8;
131
         ent_ents[i].trig_y += 8;
132
         ent_ents[i].y += 8;
133
 
134
         if (ent_ents[i].y > 0x0140)
135
            ent_ents[i].n = 0; // map coord. from 0x0000 to 0x0140
136
      }
137
   }
138
 
139
   /* display */
140
   draw_map ();
141
   ent_draw ();
142
   draw_drawStatus ();
143
   map_frow--;
144
 
145
   /* loop */
146
   if (n++ == 7)
147
   {
148
      /* activate visible entities */
149
      ent_actvis ((U8) (map_frow + MAP_ROW_HTTOP), (U8) (map_frow + MAP_ROW_HTBOT));
150
 
151
      /* prepare map */
152
      map_expand ();
153
 
154
      /* display */
155
      draw_map ();
156
      ent_draw ();
157
      draw_drawStatus ();
158
   }
159
 
160
   game_rects = &draw_SCREENRECT;
161
 
162
   return SCROLL_RUNNING;
163
}