state_space.html
6.93 KB
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type"
content="text/html; charset=windows-1252">
<title>Game State Space Management</title>
</head>
<body>
<h2 align="center">Game State Space Management</h2>
<div align="center">$Revision: 1.8 $<br>
$Date: 2004/11/16 23:55:12 $<br>
</div>
<br>
Overall space management on the flash card is done in two completely separate
regimes: <br>
<ul>
<li>60MB is reserved for the game ROM files (in either reencrypted form
or before reencryption), not including the Club App. The depot, iQue@Home
and the viewer all are aware of the 60MB limit. These applications deal
in units of 256KB, so they all treat the card as if it contained 240 of these
units of space (3840 blocks in terms of actual flash blocks).</li>
<li>4MB is reserved for all other data.</li>
</ul>
<b>Other Data or "Dark Matter"</b><br>
<br>
The following data falls into the 4MB "other" category (sizes specified
in 16KB flash blocks):<br>
<ul>
<li>64 blocks for SKSA</li>
<li>16 blocks for FAT</li>
<li>64 blocks reserved for bad blocks</li>
<li>8 blocks free in order for reencryption to work</li>
<li>11 blocks for system files (<i>id.sys</i>, <i>pak.bnd</i>, <i>user.sys</i>,
<i>depot.sys</i>, <i>crl.sys</i> ...)</li>
<li>33 blocks for a maximal <i>ticket.sys</i> file (48 tickets, 11488
bytes each)</li>
<li>35 blocks for Club App (current size)</li>
<li>all game state files (.<i>sta</i>, .<i>pak</i>, .<i>u0x</i>)<br>
</li>
</ul>
A more detailed breakdown of the system files and state saving requirements
of individual games can be found <a href="card_space.html">here</a>.<br>
<br>
4MB = 256 blocks. Adding up the other data sizes above gives a total of
231 blocks. That leaves a total of 25 blocks for all game state files combined.
The issue is obviously as the number of games grows, there won't be enough
space for game state files.
<p><b>Proposed Solution</b></p>
<p>In order to achieve a simple usage model from a user's point of view,
we propose not to let user manage the game state files separately. We would
erase the space "boundary" between the 60M of game content and 4M of Dark
Matter. Space would be managed by the depot or <a
href="mailto:iQue@Home">iQue@Home</a> at game download time. More specifically,
before a game is downloaded to the card, depot would check if there's enough
space for user to launch the game, i.e., if there's enough space on the
card to create the .sta and .u0x files for the game. </p>
<p><b>Space Calculation API</b></p>
<p>int BBCStats2(BBCHandle h, int *cardSize, int *sysSpace, int *contentSpace,
int *freeSpace); </p>
<ul>
<li>returns BBC_OK if successful, otherwise an error code</li>
<li>all sizes are in KB</li>
<li>*cardSize = *sysSpace + *contentSpace + *freeSpace</li>
<li>*contentSpace returns the size of all the *.app and *.rec files on
card (not including club app)</li>
<li>
<p style="margin-bottom: 0pt;">*sysSpace = </p>
</li>
</ul>
<p style="margin-bottom: 0pt;"> (reserved blocks) +
/* SKSA area + FAT */</p>
<p style="margin-top: 0pt; margin-bottom: 0pt;"> (maximum
bad blocks allowed) + </p>
<p style="margin-top: 0pt; margin-bottom: 0pt;"> sizeof
(various system files) + /* the system files include: </p>
<p style="margin-top: 0pt; margin-bottom: 0pt;">
id.sys, recrypt.sys, cert.sys, crl.sys, user.sys</p>
<p style="margin-top: 0pt; margin-bottom: 0pt;">
timer.sys, pcstime.tmp, temp.tmp, pak.bnd, </p>
<p style="margin-top: 0pt; margin-bottom: 0pt;">
sig.db, depot.sys</p>
<p style="margin-top: 0pt; margin-bottom: 0pt;">
each file defaults to 1 block if non-existent */</p>
<p style="margin-top: 0pt; margin-bottom: 0pt;"> 2 *
sizeof (ticket.sys) + /* defaults to 0 if non-existent. need
two copies in <br>
order to update the ticket file */</p>
<p style="margin-top: 0pt; margin-bottom: 0pt;"> RECRYPT_BLOCKS
+ /* 8 blocks for reencryption */<br>
size of club app + /* if club app
is found */<br>
</p>
<p style="margin-top: 0pt; margin-bottom: 0pt;"> state
size; </p>
<p style="margin-top: 0pt; margin-bottom: 0pt;"> /* if
(ticket.sys exists) </p>
<p style="margin-top: 0pt; margin-bottom: 0pt;"> {</p>
<p style="margin-top: 0pt; margin-bottom: 0pt;">
state size = CPAK_BLOCKS + /* 24 blocks for 12 *.pak
files */</p>
<p style="margin-top: 0pt; margin-bottom: 0pt;">
state sizes of all contents on card according to ticket.sys + </p>
<p style="margin-top: 0pt; margin-bottom: 0pt;">
sizeof(all *.sta and *.u0x files on card whose cids are not in ticket.sys);</p>
<p style="margin-top: 0pt; margin-bottom: 0pt;"> }
else {</p>
<p style="margin-top: 0pt; margin-bottom: 0pt;">
state size = CPAK_BLOCKS + /* 24 blocks for 12 *.pak
files */</p>
<p style="margin-top: 0pt; margin-bottom: 0pt;">
sizeof (all *.sta files and *.u0x files on card);</p>
<p style="margin-top: 0pt; margin-bottom: 0pt;"> }</p>
<p style="margin-top: 0pt; margin-bottom: 0pt;"> */</p>
<p>In order to figure out if there's enough space to put a game on the card
(and to be able to launch it), depot / <a href="mailto:depot/iQue@home">iQue@home</a>
should check to see if: </p>
<p> sizeof (the content to be downloaded) + 256KB <= *freeSpace;
</p>
<p>The number "256KB" is an estimate of the to-be-downloaded game state
size plus the size of the game ticket, <font color="#ff0000">assuming the
number of .u0x files for a 1Mb flash game (such as Animal Forest) is <=
3!</font> </p>
<p><b>To Dos</b></p>
<p>1. check with iQue on the number of *.u0x files for Animal Forest. </p>
<p>2. check with iQue if we can remove the club app from the card. Only use
<a href="mailto:iQue@Home">iQue@Home</a> to do user registration. </p>
<br>
</body>
</html>