This repository has been archived by the owner on Nov 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SLIST.CPP
executable file
·180 lines (133 loc) · 4.48 KB
/
SLIST.CPP
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
//routines for intepreting split screens and the like
#include <stdlib.h>
#include <string.h>
#include "message.h"
#include "nes.h"
#include "nesvideo.h"
#include "slist.h"
#include "mmc.h"
#include "r2img.h"
#include "font.h"
#include "dd.h"
#include "m6502.h"
void sevent::print(int x,int y)
{
if (type>=SE_VROM1K)
font[5]->printf(x,y,"line=%d vrom1k%d=%d",line,type-SE_VROM1K,data);
else
switch (type)
{
case SE_NATABLE: font[1]->printf(x,y,"line=%d natable=%d",line,data); break; //t[0],pc); break;
case SE_SCROLLX: font[1]->printf(x,y,"line=%d scrollx=%d",line,data); break; //t[0],pc); break;
case SE_SCROLLY: font[1]->printf(x,y,"line=%d scrolly=%d",line,data); break; //t[0],pc); break;
case SE_SPRITE: font[1]->printf(x,y,"line=%d sprites=%s",line,data ? "on" : "off"); break; //t[0],pc); break;
case SE_BG: font[1]->printf(x,y,"line=%d bg=%s",line,data ? "on" : "off"); break; //t[0],pc); break;
case SE_FRAMESTART: font[2]->printf(x,y,"line=%d vframe start",line); break; //t[0],pc); break;
case SE_BGPT: font[1]->printf(x,y,"line=%d bgptable=%d",line,data); break; //t[0],pc); break;
case SE_SPRITEPT: font[1]->printf(x,y,"line=%d spriteptable=%d",line,data); break; //t[0],pc); break;
case SE_IRQLINE: font[2]->printf(x,y,"line=%d IRQ!",line,data); break; //t[0],pc); break;
case SE_VROM8K: font[5]->printf(x,y,"line=%d vrom8k=%d",line,data); break; //t[0],pc); break;
case SE_VROM4K0: font[5]->printf(x,y,"line=%d vrom4k0=%d",line,data); break; //t[0],pc); break;
case SE_VROM4K1: font[5]->printf(x,y,"line=%d vrom4k1=%d",line,data); break; //t[0],pc); break;
}
}
void seventlist::print(int x,int y)
{for (int i=0; i<num; i++,y+=10) s[i].print(x,y);}
int getvblankscanline();
extern byte hitflag;
void seventlist::add(sevent &t)
{
if (num>0 && s[num-1]==t) return;
if (num>511) return;
t.line=getscanline(); //(getscanline()+3)&(~7);
s[num++]=t;
} //add event
//integrate event into screen context
void scontext::operator +=(sevent &e)
{
int i;
switch (e.type)
{
case SE_NATABLE: natable=e.data; break;
case SE_SCROLLX: sx=e.data; break;
case SE_SCROLLY:
if (e.data<=239) sy=e.data;
break;
case SE_SPRITE: sprites=e.data ? 1 : 0; break;
case SE_BG: bg=e.data ? 1 : 0; break;
case SE_BGPT: bgpt=e.data ? 1 : 0; break;
case SE_SPRITEPT: spritept=e.data ? 1 : 0; break;
case SE_VROM8K:
for (i=0; i<4; i++)
{
ptn[0].setbank(i,e.data*8+i);
ptn[1].setbank(i,e.data*8+i+4);
}
break;
case SE_VROM4K0:
case SE_VROM4K1:
for (i=0; i<4; i++)
ptn[e.type-SE_VROM4K0].setbank(i,e.data*4+i);
break;
case SE_VROM1K:
case SE_VROM1K1:
case SE_VROM1K2:
case SE_VROM1K3: ptn[0].setbank(e.type-SE_VROM1K,e.data); break;
case SE_VROM1K4:
case SE_VROM1K5:
case SE_VROM1K6:
case SE_VROM1K7: ptn[1].setbank(e.type-SE_VROM1K4,e.data); break;
}
if (line) line=e.line;
// msg.printf(2,"%d",line);
}
void scontextlist::add(scontext &t)
{
if (scnum>0 && t==sc[scnum-1]) return; //dont add if last was the same
sc[scnum++]=t;
}
extern byte doIRQ;
//create contexts list from eventlist
void scontextlist::create(seventlist &el)
{
scnum=0;
//create first context
c.setline(0); //top of screen
// add(c); //add it
for (int i=0; i<el.num; i++) //process all events
if (el.s[i].line<=c.line+4) c+=el.s[i]; //does event apply to current context?
else
{
add(c); //add current context to list
c.setline(el.s[i].line); //start context at new line
c+=el.s[i]; //integrate event
}
add(c);
//add screen height to end
sc[scnum].line=nv->yw;
//force lines to boundaries
// if (!doIRQ)
// for (i=0; i<scnum; i++)
// sc[i].line=(sc[i].line+2)&(~7);
// if (sc[i].line)
// sc[i].line=(sc[i].line+16)&(~7);
//resolve all heights
for (i=0; i<scnum; i++)
sc[i].setheight(sc[i+1].line);
//find context with the greatest height
int maxheight=0;
for (i=0; i<scnum; i++)
if (sc[i].height>maxheight)
{maxheight=sc[i].height; biggestsc=&sc[i];}
//set default for next time
c=sc[scnum-1];
}
void scontext::print(int x,int y)
{
font[this==nv->sc.biggestsc ? 2 : 1]->printf(x,y,"line=%d ht=%d scroll=%d,%d na=%d sp=%d pt=%d",line,height,sx,sy,natable,sprites,bgpt);
}
void scontextlist::print(int x,int y)
{
for (int i=0; i<scnum; i++,y+=10)
sc[i].print(x,y);
}