forked from keendreams/keen
-
Notifications
You must be signed in to change notification settings - Fork 2
/
id_rf_a.c
117 lines (102 loc) · 3.38 KB
/
id_rf_a.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
/* Keen Dreams (SDL2/Steam Port) Source Code
* Copyright (C) 2015 David Gow <[email protected]>
* Copyright (C) 2014 Braden Obrzut
*
* 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.
*/
// Stubs for ID_RF_A.ASM
#include "id_heads.h"
#define TILESWIDE 21
#define TILESHIGH 14
//=================
//
// RFL_NewTile
//
// Draws a composit two plane tile to the master screen and sets the update
// spot to 1 in both update pages, forcing the tile to be copied to the
// view pages the next two refreshes
//
// Called to draw newlly scrolled on strips and animating tiles
//
// Assumes write mode 0
//
//=================
void RFL_NewTile (unsigned updateoffset)
{
updatestart[1][updateoffset] = updatestart[0][updateoffset] = 1;
unsigned tileofs = originmap + updatemapofs[updateoffset];
uint8_t *dst = &vw_videomem[masterofs] + blockstarts[updateoffset];
uint16_t fg = mapsegs[1][tileofs/2];
uint16_t bg = mapsegs[0][tileofs/2];
if(grsegs[STARTTILE16+bg])
VW_UnmaskedToPAL8(grsegs[STARTTILE16+bg], dst, 0, 0, linewidth, 16, 16);
if(fg && grsegs[STARTTILE16M+fg])
VW_MaskedBlitToPAL8(grsegs[STARTTILE16M+fg], dst, 0, 0, linewidth, 16, 16);
}
//=================
//
// RFL_MaskForegroundTiles
//
// Scan through update looking for 3's. If the foreground tile there is a
// masked foreground tile, draw it to the screen
//
//=================
void RFL_MaskForegroundTiles (void)
{
byte *cur = updateptr;
byte *end = cur + (TILESWIDE+1)*TILESHIGH;
do
{
unsigned updateoffset = (unsigned)(cur - updateptr);
if (cur >= end) break;
if (*cur++ != 3) continue;
unsigned tileofs = originmap + updatemapofs[updateoffset];
uint16_t fg = mapsegs[1][tileofs/2];
if(fg == 0 || !(tinf[INTILE+fg] & 0x80)) continue;
uint8_t* dst = &vw_videomem[bufferofs] + blockstarts[updateoffset];
VW_MaskedBlitToPAL8(grsegs[STARTTILE16M+fg], dst, 0, 0, linewidth, 16, 16);
}
while(cur < end);
}
//=================
//
// RFL_UpdateTiles
//
// Scans through the update matrix pointed to by updateptr, looking for 1s.
// A 1 represents a tile that needs to be copied from the master screen to the
// current screen (a new row or an animated tiled). If more than one adjacent
// tile in a horizontal row needs to be copied, they will be copied as a group.
//
// Assumes write mode 1
//
//=================
void RFL_UpdateTiles (void)
{
byte *cur = updateptr;
byte *end = cur + (TILESWIDE+1)*TILESHIGH;
do
{
unsigned updateoffset = (unsigned)(cur - updateptr);
unsigned copy = 16;
if (cur >= end) break;
if (*cur++ != 1) continue;
// while (cur < end && *cur++ == 1)
// copy += 16;
unsigned dst = bufferofs + blockstarts[updateoffset];
unsigned src = masterofs + blockstarts[updateoffset];
VW_ScreenToScreen(src, dst, copy, 16);
}
while(cur < end);
}