-
Notifications
You must be signed in to change notification settings - Fork 173
/
id_rf.c
2355 lines (1924 loc) · 50.8 KB
/
id_rf.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Keen Dreams Source Code
* Copyright (C) 2014 Javier M. Chavez
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
// ID_RF.C
/*
=============================================================================
notes
-----
scrolling more than one tile / refresh forces a total redraw
two overlapping sprites of equal priority can change drawing order when
updated
=============================================================================
*/
#include "ID_HEADS.H"
#pragma hdrstop
/*
=============================================================================
LOCAL CONSTANTS
=============================================================================
*/
#define SCREENTILESWIDE 20
#define SCREENTILESHIGH 13
#define SCREENSPACE (SCREENWIDTH*240)
#define FREEEGAMEM (0x10000l-3l*SCREENSPACE)
//
// the update array must have enough space for two screens that can float
// up two two tiles each way
//
// (PORTTILESWIDE+1)*PORTTILESHIGH must be even so the arrays can be cleared
// by word width instructions
#define UPDATESCREENSIZE (UPDATEWIDE*PORTTILESHIGH+2)
#define UPDATESPARESIZE (UPDATEWIDE*2+4)
#define UPDATESIZE (UPDATESCREENSIZE+2*UPDATESPARESIZE)
#define G_EGASX_SHIFT 7 // global >> ?? = screen x
#define G_CGASX_SHIFT 6 // global >> ?? = screen x
#define G_SY_SHIFT 4 // global >> ?? = screen y
unsigned SX_T_SHIFT; // screen x >> ?? = tile EGA = 1, CGA = 2;
#define SY_T_SHIFT 4 // screen y >> ?? = tile
#define EGAPORTSCREENWIDE 42
#define CGAPORTSCREENWIDE 84
#define PORTSCREENHIGH 224
#define UPDATESCREENSIZE (UPDATEWIDE*PORTTILESHIGH+2)
#define UPDATESPARESIZE (UPDATEWIDE*2+4)
#define UPDATESIZE (UPDATESCREENSIZE+2*UPDATESPARESIZE)
/*
=============================================================================
LOCAL TYPES
=============================================================================
*/
typedef struct spriteliststruct
{
int screenx,screeny;
int width,height;
unsigned grseg,sourceofs,planesize;
drawtype draw;
unsigned tilex,tiley,tilewide,tilehigh;
int priority,updatecount;
struct spriteliststruct **prevptr,*nextsprite;
} spritelisttype;
typedef struct
{
int screenx,screeny;
int width,height;
} eraseblocktype;
typedef struct
{
unsigned current; // foreground tiles have high bit set
int count;
} tiletype;
typedef struct animtilestruct
{
unsigned x,y,tile;
tiletype *chain;
unsigned far *mapplane;
struct animtilestruct **prevptr,*nexttile;
} animtiletype;
/*
=============================================================================
GLOBAL VARIABLES
=============================================================================
*/
unsigned tics;
long lasttimecount;
boolean compatability; // crippled refresh for wierdo SVGAs
unsigned mapwidth,mapheight,mapbyteswide,mapwordswide
,mapbytesextra,mapwordsextra;
unsigned mapbwidthtable[MAXMAPHEIGHT];
//
// Global : Actor coordinates are in this, at 1/16 th of a pixel, to allow
// for fractional movement and acceleration.
//
// Tiles : Tile offsets from the upper left corner of the current map.
//
// Screen : Graphics level offsets from map origin, x in bytes, y in pixels.
// originxscreen is the same spot as originxtile, just with extra precision
// so graphics don't need to be done in tile boundaries.
//
unsigned originxglobal,originyglobal;
unsigned originxtile,originytile;
unsigned originxscreen,originyscreen;
unsigned originmap;
unsigned originxmin,originxmax,originymin,originymax;
unsigned originxtile,originytile;
unsigned masterofs;
//
// Table of the offsets from bufferofs of each tile spot in the
// view port. The extra wide tile should never be drawn, but the space
// is needed to account for the extra 0 in the update arrays. Built by
// RF_Startup
//
unsigned blockstarts[UPDATEWIDE*UPDATEHIGH];
unsigned updatemapofs[UPDATEWIDE*UPDATEHIGH];
unsigned uwidthtable[PORTTILESHIGH]; // lookup instead of multiply
byte update[2][UPDATESIZE];
byte *updateptr,*baseupdateptr, // current start of update window
*updatestart[2],
*baseupdatestart[2];
/*
=============================================================================
LOCAL VARIABLES
=============================================================================
*/
static char scratch[20],str[20];
tiletype allanims[MAXANIMTYPES];
unsigned numanimchains;
void (*refreshvector) (void);
unsigned screenstart[3] =
{0,SCREENSPACE,SCREENSPACE*2};
unsigned xpanmask; // prevent panning to odd pixels
unsigned screenpage; // screen currently being displayed
unsigned otherpage;
#if GRMODE == EGAGR
unsigned tilecache[NUMTILE16];
#endif
spritelisttype spritearray[MAXSPRITES],*prioritystart[PRIORITIES],
*spritefreeptr;
animtiletype animarray[MAXANIMTILES],*animhead,*animfreeptr;
int animfreespot;
eraseblocktype eraselist[2][MAXSPRITES],*eraselistptr[2];
/*
=============================================================================
LOCAL PROTOTYPES
=============================================================================
*/
void RFL_NewTile (unsigned updateoffset);
void RFL_MaskForegroundTiles (void);
void RFL_UpdateTiles (void);
void RFL_CalcOriginStuff (long x, long y);
void RFL_InitSpriteList (void);
void RFL_InitAnimList (void);
void RFL_CheckForAnimTile (unsigned x, unsigned y);
void RFL_AnimateTiles (void);
void RFL_RemoveAnimsOnX (unsigned x);
void RFL_RemoveAnimsOnY (unsigned y);
void RFL_EraseBlocks (void);
void RFL_UpdateSprites (void);
/*
=============================================================================
GRMODE INDEPENDANT ROUTINES
=============================================================================
*/
/*
=====================
=
= RF_Startup
=
=====================
*/
static char *ParmStrings[] = {"comp",""};
void RF_Startup (void)
{
int i,x,y;
unsigned *blockstart;
if (grmode == EGAGR)
for (i = 1;i < _argc;i++)
if (US_CheckParm(_argv[i],ParmStrings) == 0)
{
compatability = true;
break;
}
for (i=0;i<PORTTILESHIGH;i++)
uwidthtable[i] = UPDATEWIDE*i;
originxmin = originymin = MAPBORDER*TILEGLOBAL;
eraselistptr[0] = &eraselist[0][0];
eraselistptr[1] = &eraselist[1][0];
if (grmode == EGAGR)
{
SX_T_SHIFT = 1;
baseupdatestart[0] = &update[0][UPDATESPARESIZE];
baseupdatestart[1] = &update[1][UPDATESPARESIZE];
screenpage = 0;
otherpage = 1;
displayofs = screenstart[screenpage];
bufferofs = screenstart[otherpage];
masterofs = screenstart[2];
updateptr = baseupdatestart[otherpage];
blockstart = &blockstarts[0];
for (y=0;y<UPDATEHIGH;y++)
for (x=0;x<UPDATEWIDE;x++)
*blockstart++ = SCREENWIDTH*16*y+x*TILEWIDTH;
xpanmask = 6; // dont pan to odd pixels
}
else if (grmode == CGAGR)
{
SX_T_SHIFT = 2;
updateptr = baseupdateptr = &update[0][UPDATESPARESIZE];
bufferofs = 0;
masterofs = 0x8000;
blockstart = &blockstarts[0];
for (y=0;y<UPDATEHIGH;y++)
for (x=0;x<UPDATEWIDE;x++)
*blockstart++ = SCREENWIDTH*16*y+x*TILEWIDTH;
}
}
/*
=====================
=
= RF_Shutdown
=
=====================
*/
void RF_Shutdown (void)
{
}
//===========================================================================
/*
=====================
=
= RF_NewMap
=
= Makes some convienient calculations based on maphead->
=
=====================
*/
void RF_NewMap (void)
{
int i,x,y;
unsigned spot,*table;
mapwidth = mapheaderseg[mapon]->width;
mapbyteswide = 2*mapwidth;
mapheight = mapheaderseg[mapon]->height;
mapwordsextra = mapwidth-PORTTILESWIDE;
mapbytesextra = 2*mapwordsextra;
//
// make a lookup table for the maps left edge
//
spot = 0;
for (i=0;i<mapheight;i++)
{
mapbwidthtable[i] = spot;
spot += mapbyteswide;
}
//
// fill in updatemapofs with the new width info
//
table = &updatemapofs[0];
for (y=0;y<PORTTILESHIGH;y++)
for (x=0;x<UPDATEWIDE;x++)
*table++ = mapbwidthtable[y]+x*2;
//
// the y max value clips off the bottom half of a tile so a map that is
// 13 + MAPBORDER*2 tile high will not scroll at all vertically
//
originxmax = (mapwidth-MAPBORDER-SCREENTILESWIDE)*TILEGLOBAL;
originymax = (mapheight-MAPBORDER-SCREENTILESHIGH)*TILEGLOBAL;
if (originxmax<originxmin) // for very small maps
originxmax=originxmin;
if (originymax<originymin)
originymax=originymin;
//
// clear out the lists
//
RFL_InitSpriteList ();
RFL_InitAnimList ();
lasttimecount = TimeCount; // setup for adaptive timing
tics = 1;
}
//===========================================================================
/*
==========================
=
= RF_MarkTileGraphics
=
= Goes through mapplane[0/1] and marks all background/foreground tiles
= needed, then follows all animation sequences to make sure animated
= tiles get all the stages. Every unique animating tile is given an
= entry in allanims[], so every instance of that tile will animate at the
= same rate. The info plane for each animating tile will hold a pointer
= into allanims[], therefore you can't have both an animating foreground
= and background tile in the same spot!
=
==========================
*/
void RF_MarkTileGraphics (void)
{
unsigned size;
int tile,next,anims;
unsigned far *start,far *end,far *info;
unsigned i,tilehigh;
memset (allanims,0,sizeof(allanims));
numanimchains = 0;
size = mapwidth*mapheight;
//
// background plane
//
start = mapsegs[0];
info = mapsegs[2];
end = start+size;
do
{
tile = *start++;
if (tile>=0) // <0 is a tile that is never drawn
{
CA_MarkGrChunk(STARTTILE16+tile);
if (tinf[ANIM+tile])
{
// this tile will animated
for (i=0;i<numanimchains;i++)
if (allanims[i].current == tile)
{
*info = (unsigned)&allanims[i];
goto nextback;
}
// new chain of animating tiles
if (i>=MAXANIMTYPES)
Quit ("RF_MarkTileGraphics: Too many unique animated tiles!");
allanims[i].current = tile;
allanims[i].count = tinf[SPEED+tile];
*info = (unsigned)&allanims[i];
numanimchains++;
anims = 0;
next = tile+(signed char)(tinf[ANIM+tile]);
while (next != tile)
{
CA_MarkGrChunk(STARTTILE16+next);
next += (signed char)(tinf[ANIM+next]);
if (++anims > 20)
Quit ("MarkTileGraphics: Unending animation!");
}
}
}
nextback:
info++;
} while (start<end);
//
// foreground plane
//
start = mapsegs[1];
info = mapsegs[2];
end = start+size;
do
{
tile = *start++;
if (tile>=0) // <0 is a tile that is never drawn
{
CA_MarkGrChunk(STARTTILE16M+tile);
if (tinf[MANIM+tile])
{
// this tile will animated
tilehigh = tile | 0x8000; // foreground tiles have high bit
for (i=0;i<numanimchains;i++)
if (allanims[i].current == tilehigh)
{
*info = (unsigned)&allanims[i];
goto nextfront;
}
// new chain of animating tiles
if (i>=MAXANIMTYPES)
Quit ("RF_MarkTileGraphics: Too many unique animated tiles!");
allanims[i].current = tilehigh;
allanims[i].count = tinf[MSPEED+tile];
*info = (unsigned)&allanims[i];
numanimchains++;
anims = 0;
next = tile+(signed char)(tinf[MANIM+tile]);
while (next != tile)
{
CA_MarkGrChunk(STARTTILE16M+next);
next += (signed char)(tinf[MANIM+next]);
if (++anims > 20)
Quit ("MarkTileGraphics: Unending animation!");
}
}
}
nextfront:
info++;
} while (start<end);
}
//===========================================================================
/*
=========================
=
= RFL_InitAnimList
=
= Call to clear out the entire animating tile list and return all of them to
= the free list.
=
=========================
*/
void RFL_InitAnimList (void)
{
int i;
animfreeptr = &animarray[0];
for (i=0;i<MAXANIMTILES-1;i++)
animarray[i].nexttile = &animarray[i+1];
animarray[i].nexttile = NULL;
animhead = NULL; // nothing in list
}
/*
====================
=
= RFL_CheckForAnimTile
=
====================
*/
void RFL_CheckForAnimTile (unsigned x, unsigned y)
{
unsigned tile,offset,speed,lasttime,thistime,timemissed;
unsigned far *map;
animtiletype *anim,*next;
// the info plane of each animating tile has a near pointer into allanims[]
// which gives the current state of all concurrently animating tiles
offset = mapbwidthtable[y]/2+x;
//
// background
//
map = mapsegs[0]+offset;
tile = *map;
if (tinf[ANIM+tile])
{
if (!animfreeptr)
Quit ("RF_CheckForAnimTile: No free spots in tilearray!");
anim = animfreeptr;
animfreeptr = animfreeptr->nexttile;
next = animhead; // stick it at the start of the list
animhead = anim;
if (next)
next->prevptr = &anim->nexttile;
anim->nexttile = next;
anim->prevptr = &animhead;
anim->x = x;
anim->y = y;
anim->tile = tile;
anim->mapplane = map;
anim->chain = (tiletype *)*(mapsegs[2]+offset);
}
//
// foreground
//
map = mapsegs[1]+offset;
tile = *map;
if (tinf[MANIM+tile])
{
if (!animfreeptr)
Quit ("RF_CheckForAnimTile: No free spots in tilearray!");
anim = animfreeptr;
animfreeptr = animfreeptr->nexttile;
next = animhead; // stick it at the start of the list
animhead = anim;
if (next)
next->prevptr = &anim->nexttile;
anim->nexttile = next;
anim->prevptr = &animhead;
anim->x = x;
anim->y = y;
anim->tile = tile;
anim->mapplane = map;
anim->chain = (tiletype *)*(mapsegs[2]+offset);
}
}
/*
====================
=
= RFL_RemoveAnimsOnX
=
====================
*/
void RFL_RemoveAnimsOnX (unsigned x)
{
animtiletype *current,*next;
current = animhead;
while (current)
{
if (current->x == x)
{
*(void **)current->prevptr = current->nexttile;
if (current->nexttile)
current->nexttile->prevptr = current->prevptr;
next = current->nexttile;
current->nexttile = animfreeptr;
animfreeptr = current;
current = next;
}
else
current = current->nexttile;
}
}
/*
====================
=
= RFL_RemoveAnimsOnY
=
====================
*/
void RFL_RemoveAnimsOnY (unsigned y)
{
animtiletype *current,*next;
current = animhead;
while (current)
{
if (current->y == y)
{
*(void **)current->prevptr = current->nexttile;
if (current->nexttile)
current->nexttile->prevptr = current->prevptr;
next = current->nexttile;
current->nexttile = animfreeptr;
animfreeptr = current;
current = next;
}
else
current = current->nexttile;
}
}
/*
====================
=
= RFL_AnimateTiles
=
====================
*/
void RFL_AnimateTiles (void)
{
animtiletype *current;
unsigned updateofs,tile,x,y;
tiletype *anim;
//
// animate the lists of tiles
//
anim = &allanims[0];
while (anim->current)
{
anim->count-=tics;
while ( anim->count < 1)
{
if (anim->current & 0x8000)
{
tile = anim->current & 0x7fff;
tile += (signed char)tinf[MANIM+tile];
anim->count += tinf[MSPEED+tile];
tile |= 0x8000;
}
else
{
tile = anim->current;
tile += (signed char)tinf[ANIM+tile];
anim->count += tinf[SPEED+tile];
}
anim->current = tile;
}
anim++;
}
//
// traverse the list of animating tiles
//
current = animhead;
while (current)
{
tile =current->chain->current;
if ( tile != current->tile)
{
// tile has animated
//
// remove tile from master screen cache,
// change a tile to its next state, set the structure up for
// next animation, and post an update region to both update pages
//
current->tile = tile;
*(current->mapplane) = tile & 0x7fff; // change in map
#if GRMODE == EGAGR
if (tile<0x8000) // background
tilecache[tile] = 0;
#endif
x = current->x-originxtile;
y = current->y-originytile;
if (x>=PORTTILESWIDE || y>=PORTTILESHIGH)
Quit ("RFL_AnimateTiles: Out of bounds!");
updateofs = uwidthtable[y] + x;
RFL_NewTile(updateofs); // puts "1"s in both pages
}
current = current->nexttile;
}
}
//===========================================================================
/*
=========================
=
= RFL_InitSpriteList
=
= Call to clear out the entire sprite list and return all of them to
= the free list.
=
=========================
*/
void RFL_InitSpriteList (void)
{
int i;
spritefreeptr = &spritearray[0];
for (i=0;i<MAXSPRITES-1;i++)
spritearray[i].nextsprite = &spritearray[i+1];
spritearray[i].nextsprite = NULL;
// NULL in all priority levels
memset (prioritystart,0,sizeof(prioritystart));
}
//===========================================================================
/*
=================
=
= RFL_CalcOriginStuff
=
= Calculate all the global variables for a new position
= Long parms so position can be clipped to a maximum near 64k
=
=================
*/
void RFL_CalcOriginStuff (long x, long y)
{
if (x<originxmin)
x=originxmin;
else if (x>originxmax)
x=originxmax;
if (y<originymin)
y=originymin;
else if (y>originymax)
y=originymax;
originxglobal = x;
originyglobal = y;
originxtile = originxglobal>>G_T_SHIFT;
originytile = originyglobal>>G_T_SHIFT;
originxscreen = originxtile<<SX_T_SHIFT;
originyscreen = originytile<<SY_T_SHIFT;
originmap = mapbwidthtable[originytile] + originxtile*2;
#if GRMODE == EGAGR
panx = (originxglobal>>G_P_SHIFT) & 15;
pansx = panx & 8;
pany = pansy = (originyglobal>>G_P_SHIFT) & 15;
panadjust = panx/8 + ylookup[pany];
#endif
#if GRMODE == CGAGR
panx = (originxglobal>>G_P_SHIFT) & 15;
pansx = panx & 12;
pany = pansy = (originyglobal>>G_P_SHIFT) & 15;
panadjust = pansx/4 + ylookup[pansy];
#endif
}
//===========================================================================
/*
=====================
=
= RF_SetRefreshHook
=
=====================
*/
void RF_SetRefreshHook (void (*func) (void) )
{
refreshvector = func;
}
/*
=================
=
= RFL_NewRow
=
= Bring a new row of tiles onto the port, spawning animating tiles
=
=================
*/
void RFL_NewRow (int dir)
{
unsigned count,updatespot,updatestep;
int x,y,xstep,ystep;
switch (dir)
{
case 0: // top row
updatespot = 0;
updatestep = 1;
x = originxtile;
y = originytile;
xstep = 1;
ystep = 0;
count = PORTTILESWIDE;
break;
case 1: // right row
updatespot = PORTTILESWIDE-1;
updatestep = UPDATEWIDE;
x = originxtile + PORTTILESWIDE-1;
y = originytile;
xstep = 0;
ystep = 1;
count = PORTTILESHIGH;
break;
case 2: // bottom row
updatespot = UPDATEWIDE*(PORTTILESHIGH-1);
updatestep = 1;
x = originxtile;
y = originytile + PORTTILESHIGH-1;
xstep = 1;
ystep = 0;
count = PORTTILESWIDE;
break;
case 3: // left row
updatespot = 0;
updatestep = UPDATEWIDE;
x = originxtile;
y = originytile;
xstep = 0;
ystep = 1;
count = PORTTILESHIGH;
break;
default:
Quit ("RFL_NewRow: Bad dir!");
}
while (count--)
{
RFL_NewTile(updatespot);
RFL_CheckForAnimTile (x,y);
updatespot+=updatestep;
x+=xstep;
y+=ystep;
}
}
//===========================================================================
/*
=====================
=
= RF_ForceRefresh
=
=====================
*/
void RF_ForceRefresh (void)
{
RF_NewPosition (originxglobal,originyglobal);
RF_Refresh ();
RF_Refresh ();
}
/*
=============================================================================
EGA specific routines
=============================================================================
*/
#if GRMODE == EGAGR
/*
=====================
=
= RF_NewPosition EGA
=
=====================
*/
void RF_NewPosition (unsigned x, unsigned y)
{
int mx,my;
byte *page0ptr,*page1ptr;
unsigned updatenum;
//
// calculate new origin related globals
//
RFL_CalcOriginStuff (x,y);
//
// clear out all animating tiles
//
RFL_InitAnimList ();
//
// set up the new update arrays at base position
//
memset (tilecache,0,sizeof(tilecache)); // old cache is invalid
updatestart[0] = baseupdatestart[0];
updatestart[1] = baseupdatestart[1];
page0ptr = updatestart[0]+PORTTILESWIDE; // used to stick "0"s after rows
page1ptr = updatestart[1]+PORTTILESWIDE;
updatenum = 0; // start at first visable tile