Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
openjazz
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
openjazz
Commits
411eaa5a
Commit
411eaa5a
authored
Mar 28, 2010
by
alistert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cutscene refactoring. Fixed in-game gfx stats.
parent
1174dd9f
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
263 additions
and
314 deletions
+263
-314
Makefile
Makefile
+2
-1
Makefile.arm
Makefile.arm
+2
-1
Makefile.debian
Makefile.debian
+2
-1
game.cpp
src/game/game.cpp
+1
-1
file.cpp
src/io/file.cpp
+9
-10
file.h
src/io/file.h
+2
-2
video.cpp
src/io/gfx/video.cpp
+1
-1
sound.cpp
src/io/sound.cpp
+2
-2
demolevel.cpp
src/level/demolevel.cpp
+1
-18
level.cpp
src/level/level.cpp
+7
-21
level.h
src/level/level.h
+2
-2
levelframe.cpp
src/level/levelframe.cpp
+31
-1
scene.cpp
src/scene/scene.cpp
+75
-72
scene.h
src/scene/scene.h
+38
-46
sceneload.cpp
src/scene/sceneload.cpp
+88
-135
No files found.
Makefile
View file @
411eaa5a
...
...
@@ -13,7 +13,8 @@ objects = src/bonus/bonus.o \
src/menu/gamemenu.o src/menu/mainmenu.o src/menu/menu.o
\
src/menu/menuutil.o src/menu/setupmenu.o
\
src/player/bird.o src/player/player.o src/player/playerframe.o
\
src/main.o src/movable.o src/planet.o src/scene.o src/util.o
\
src/scene/scene.o src/scene/sceneload.o
\
src/main.o src/movable.o src/planet.o src/util.o
\
src/io/gfx/scale2x/getopt.o src/io/gfx/scale2x/pixel.o
\
src/io/gfx/scale2x/scale2x.o
src/io/gfx/scale2x/scale3x.o
\
src/io/gfx/scale2x/scalebit.o
src/io/gfx/scale2x/simple2x.o
...
...
Makefile.arm
View file @
411eaa5a
...
...
@@ -37,7 +37,8 @@ OBJS = src/bonus/bonus.o \
src/menu/gamemenu.o src/menu/mainmenu.o src/menu/menu.o
\
src/menu/menuutil.o src/menu/setupmenu.o
\
src/player/bird.o src/player/player.o src/player/playerframe.o
\
src/main.o src/movable.o src/planet.o src/scene.o src/util.o
\
src/scene/scene.o src/scene/sceneload.o
\
src/main.o src/movable.o src/planet.o src/util.o
\
src/io/gfx/scale2x/getopt.o src/io/gfx/scale2x/pixel.o
\
src/io/gfx/scale2x/scale2x.o src/io/gfx/scale2x/scale3x.o
\
src/io/gfx/scale2x/scalebit.o src/io/gfx/scale2x/simple2x.o
...
...
Makefile.debian
View file @
411eaa5a
...
...
@@ -13,7 +13,8 @@ objects = src/bonus/bonus.o \
src/menu/gamemenu.o src/menu/mainmenu.o src/menu/menu.o
\
src/menu/menuutil.o src/menu/setupmenu.o
\
src/player/bird.o src/player/player.o src/player/playerframe.o
\
src/main.o src/movable.o src/planet.o src/scene.o src/util.o
\
src/scene/scene.o src/scene/sceneload.o
\
src/main.o src/movable.o src/planet.o src/util.o
\
src/io/gfx/scale2x/getopt.o src/io/gfx/scale2x/pixel.o
\
src/io/gfx/scale2x/scale2x.o src/io/gfx/scale2x/scale3x.o
\
src/io/gfx/scale2x/scalebit.o src/io/gfx/scale2x/simple2x.o
...
...
src/game/game.cpp
View file @
411eaa5a
...
...
@@ -67,7 +67,7 @@ Game::~Game () {
if
(
levelFile
)
delete
[]
levelFile
;
if
(
players
!=
NULL
)
delete
[]
players
;
if
(
players
)
delete
[]
players
;
localPlayer
=
NULL
;
return
;
...
...
src/io/file.cpp
View file @
411eaa5a
...
...
@@ -194,7 +194,7 @@ unsigned char * File::loadBlock (int length) {
}
unsigned
char
*
File
::
loadRLE
(
int
length
,
bool
dontseek
)
{
unsigned
char
*
File
::
loadRLE
(
int
length
)
{
unsigned
char
*
buffer
;
int
rle
,
pos
,
byte
,
count
,
next
;
...
...
@@ -236,9 +236,7 @@ unsigned char * File::loadRLE (int length, bool dontseek) {
}
if
(
!
dontseek
)
{
fseek
(
f
,
next
,
SEEK_SET
);
}
return
buffer
;
...
...
@@ -265,18 +263,18 @@ char * File::loadString () {
int
length
,
count
;
length
=
fgetc
(
f
);
count
=
0
;
if
(
length
)
{
string
=
new
char
[
length
+
1
];
f
or
(;
count
<
length
;
count
++
)
string
[
count
]
=
fgetc
(
f
);
f
read
(
string
,
1
,
length
,
f
);
}
else
{
// If the length is not given, assume it is an 8.3 file name
string
=
new
char
[
13
];
for
(;
count
<
9
;
count
++
)
{
for
(
count
=
0
;
count
<
9
;
count
++
)
{
string
[
count
]
=
fgetc
(
f
);
...
...
@@ -292,19 +290,20 @@ char * File::loadString () {
}
}
length
=
count
;
}
string
[
count
]
=
0
;
string
[
length
]
=
0
;
return
string
;
}
SDL_Surface
*
File
::
loadSurface
(
int
width
,
int
height
,
bool
dontseek
)
{
SDL_Surface
*
File
::
loadSurface
(
int
width
,
int
height
)
{
return
createSurface
(
loadRLE
(
width
*
height
,
dontseek
),
width
,
height
);
return
createSurface
(
loadRLE
(
width
*
height
),
width
,
height
);
}
...
...
src/io/file.h
View file @
411eaa5a
...
...
@@ -54,10 +54,10 @@ class File {
signed
long
int
loadInt
();
void
storeInt
(
signed
long
int
val
);
unsigned
char
*
loadBlock
(
int
length
);
unsigned
char
*
loadRLE
(
int
length
,
bool
dontseek
=
false
);
unsigned
char
*
loadRLE
(
int
length
);
void
skipRLE
();
char
*
loadString
();
SDL_Surface
*
loadSurface
(
int
width
,
int
height
,
bool
dontseek
=
false
);
SDL_Surface
*
loadSurface
(
int
width
,
int
height
);
void
loadPalette
(
SDL_Color
*
palette
);
};
...
...
src/io/gfx/video.cpp
View file @
411eaa5a
...
...
@@ -42,7 +42,7 @@ SDL_Surface * createSurface (unsigned char * pixels, int width, int height) {
// Set the surface's palette
SDL_SetPalette
(
ret
,
SDL_LOGPAL
,
logicalPalette
,
0
,
256
);
if
(
pixels
!=
NULL
)
{
if
(
pixels
)
{
// Upload pixel data to the surface
if
(
SDL_MUSTLOCK
(
ret
))
SDL_LockSurface
(
ret
);
...
...
src/io/sound.cpp
View file @
411eaa5a
...
...
@@ -330,7 +330,7 @@ void freeSounds () {
int
count
;
if
(
sounds
!=
NULL
)
{
if
(
sounds
)
{
for
(
count
=
0
;
count
<
nSounds
;
count
++
)
{
...
...
@@ -352,7 +352,7 @@ void playSound (int newSound) {
// Set the sound to be played
if
(
(
sounds
!=
NULL
)
&&
(
newSound
>=
0
))
sounds
[
newSound
].
position
=
0
;
if
(
sounds
&&
(
newSound
>=
0
))
sounds
[
newSound
].
position
=
0
;
return
;
...
...
src/level/demolevel.cpp
View file @
411eaa5a
...
...
@@ -97,9 +97,6 @@ int DemoLevel::play () {
int
ret
;
// Arbitrary initial value
smoothfps
=
50.0
f
;
tickOffset
=
globalTicks
;
ticks
=
16
;
prevStepTicks
=
0
;
...
...
@@ -170,26 +167,12 @@ int DemoLevel::play () {
// Draw the graphics
draw
();
draw
(
stats
);
fontmn1
->
showString
(
"DEMO"
,
(
canvasW
>>
1
)
-
36
,
32
);
// Draw graphics statistics
if
(
stats
&
S_SCREEN
)
{
drawRect
(
236
,
9
,
80
,
32
,
BLACK
);
panelBigFont
->
showNumber
(
canvasW
,
268
,
15
);
panelBigFont
->
showString
(
"x"
,
272
,
15
);
panelBigFont
->
showNumber
(
canvasH
,
308
,
15
);
panelBigFont
->
showString
(
"fps"
,
244
,
27
);
panelBigFont
->
showNumber
((
int
)
smoothfps
,
308
,
27
);
}
}
return
E_NONE
;
...
...
src/level/level.cpp
View file @
411eaa5a
...
...
@@ -56,8 +56,9 @@
Level
::
Level
()
{
// Do nothing
// Arbitrary initial value
smoothfps
=
50.0
f
;
return
;
}
...
...
@@ -73,6 +74,9 @@ Level::Level (char *fileName, unsigned char diff, bool checkpoint) {
if
(
ret
<
0
)
throw
ret
;
// Arbitrary initial value
smoothfps
=
50.0
f
;
return
;
}
...
...
@@ -574,9 +578,6 @@ int Level::play () {
int
width
;
// Arbitrary initial value
smoothfps
=
50.0
f
;
tickOffset
=
globalTicks
;
ticks
=
16
;
prevStepTicks
=
0
;
...
...
@@ -728,7 +729,7 @@ int Level::play () {
// Draw the graphics
draw
();
draw
(
stats
);
// If paused, draw "PAUSE"
...
...
@@ -766,21 +767,6 @@ int Level::play () {
}
// Draw graphics statistics
if
(
stats
&
S_SCREEN
)
{
drawRect
(
viewW
-
84
,
11
,
80
,
25
,
BLACK
);
panelBigFont
->
showNumber
(
canvasW
,
viewW
-
52
,
14
);
panelBigFont
->
showString
(
"x"
,
viewW
-
48
,
14
);
panelBigFont
->
showNumber
(
canvasH
,
viewW
-
12
,
14
);
panelBigFont
->
showString
(
"fps"
,
viewW
-
76
,
26
);
panelBigFont
->
showNumber
((
int
)
smoothfps
,
viewW
-
12
,
26
);
}
if
(
stage
==
LS_END
)
{
// The level is over, so draw play statistics & bonuses
...
...
src/level/level.h
View file @
411eaa5a
...
...
@@ -131,17 +131,17 @@ class Level {
fixed
waterLevelSpeed
;
fixed
energyBar
;
int
stage
;
float
smoothfps
;
int
loadSprites
(
char
*
fileName
);
int
loadTiles
(
char
*
fileName
);
protected
:
float
smoothfps
;
unsigned
int
tickOffset
,
prevStepTicks
,
prevTicks
,
ticks
;
int
load
(
char
*
fileName
,
unsigned
char
diff
,
bool
checkpoint
);
int
step
();
void
draw
();
void
draw
(
int
stats
);
void
timeCalcs
(
bool
paused
);
public
:
...
...
src/level/levelframe.cpp
View file @
411eaa5a
...
...
@@ -173,7 +173,7 @@ int Level::step () {
void
Level
::
draw
()
{
void
Level
::
draw
(
int
stats
)
{
GridElement
*
ge
;
Event
*
event
;
...
...
@@ -440,6 +440,36 @@ void Level::draw () {
drawRect
(
dst
.
x
,
canvasH
-
13
,
dst
.
w
,
7
,
BLACK
);
// Draw graphics statistics
if
(
stats
&
S_SCREEN
)
{
#ifdef SCALE
if
(
scaleFactor
>
1
)
drawRect
(
viewW
-
84
,
11
,
80
,
37
,
BLACK
);
else
#endif
drawRect
(
viewW
-
84
,
11
,
80
,
25
,
BLACK
);
panelBigFont
->
showNumber
(
screenW
,
viewW
-
52
,
14
);
panelBigFont
->
showString
(
"x"
,
viewW
-
48
,
14
);
panelBigFont
->
showNumber
(
screenH
,
viewW
-
12
,
14
);
panelBigFont
->
showString
(
"fps"
,
viewW
-
76
,
26
);
panelBigFont
->
showNumber
((
int
)
smoothfps
,
viewW
-
12
,
26
);
#ifdef SCALE
if
(
scaleFactor
>
1
)
{
panelBigFont
->
showNumber
(
canvasW
,
viewW
-
52
,
38
);
panelBigFont
->
showString
(
"x"
,
viewW
-
48
,
39
);
panelBigFont
->
showNumber
(
canvasH
,
viewW
-
12
,
38
);
}
#endif
}
return
;
}
...
...
src/scene/scene.cpp
View file @
411eaa5a
...
...
@@ -49,19 +49,38 @@
*
*/
ImageInfo
::
ImageInfo
(
)
{
SceneImage
::
SceneImage
(
SceneImage
*
newNext
)
{
next
=
newNext
;
image
=
NULL
;
}
ImageInfo
::~
ImageInfo
()
{
if
(
image
!=
NULL
)
SDL_FreeSurface
(
image
);
SceneImage
::~
SceneImage
()
{
if
(
next
)
delete
next
;
if
(
image
)
SDL_FreeSurface
(
image
);
}
ScriptText
::
ScriptText
()
{
ScenePalette
::
ScenePalette
(
ScenePalette
*
newNext
)
{
next
=
newNext
;
}
ScenePalette
::~
ScenePalette
()
{
if
(
next
)
delete
next
;
}
SceneText
::
SceneText
()
{
x
=
-
1
;
y
=
-
1
;
...
...
@@ -72,25 +91,25 @@ ScriptText::ScriptText() {
}
Sc
riptText
::~
Script
Text
()
{
Sc
eneText
::~
Scene
Text
()
{
if
(
text
)
delete
[]
text
;
}
Sc
riptPage
::
Script
Page
()
{
Sc
enePage
::
Scene
Page
()
{
pageTime
=
0
;
n
oScript
Texts
=
0
;
nTexts
=
0
;
backgrounds
=
0
;
music
f
ile
=
NULL
;
music
F
ile
=
NULL
;
paletteIndex
=
0
;
}
Sc
riptPage
::~
Script
Page
()
{
Sc
enePage
::~
Scene
Page
()
{
if
(
music
file
)
delete
[]
musicf
ile
;
if
(
music
File
)
delete
[]
musicF
ile
;
}
...
...
@@ -100,7 +119,7 @@ Scene::Scene (const char * fileName) {
File
*
file
;
int
loop
;
n
oScript
Fonts
=
0
;
nFonts
=
0
;
LOG
(
"
\n
Scene"
,
fileName
);
try
{
...
...
@@ -113,22 +132,22 @@ Scene::Scene (const char * fileName) {
}
image
Index
=
0
;
palette
Index
=
0
;
image
s
=
NULL
;
palette
s
=
NULL
;
file
->
seek
(
0x13
,
true
);
// Skip Digital Dimensions header
signed
long
int
dataOffset
=
file
->
loadInt
();
//get offset pointer to first data block
scriptItems
=
file
->
loadShort
();
// Get number of script items
scriptStarts
=
new
signed
long
int
[
scriptItems
];
scriptPages
=
new
Script
Page
[
scriptItems
];
pages
=
new
Scene
Page
[
scriptItems
];
LOG
(
"Scene: Script items"
,
scriptItems
);
for
(
loop
=
0
;
loop
<
scriptItems
;
loop
++
)
{
scriptStarts
[
loop
]
=
file
->
loadInt
();
// Load offset to script
LOG
(
"scriptStart
:
"
,
scriptStarts
[
loop
]);
LOG
(
"scriptStart"
,
scriptStarts
[
loop
]);
}
...
...
@@ -141,7 +160,7 @@ Scene::Scene (const char * fileName) {
for
(
loop
=
0
;
loop
<
dataItems
;
loop
++
)
{
dataOffsets
[
loop
]
=
file
->
loadInt
();
// Load offset to script
LOG
(
"dataOffsets
:
"
,
dataOffsets
[
loop
]);
LOG
(
"dataOffsets"
,
dataOffsets
[
loop
]);
}
...
...
@@ -159,30 +178,20 @@ Scene::Scene (const char * fileName) {
Scene
::~
Scene
()
{
delete
[]
scriptPages
;
}
ImageInfo
*
Scene
::
FindImage
(
int
dataIndex
)
{
int
loop
;
for
(
loop
=
0
;
loop
<
imageIndex
;
loop
++
)
{
if
(
imageInfos
[
loop
].
dataIndex
==
dataIndex
)
return
imageInfos
+
loop
;
}
delete
[]
pages
;
return
NULL
;
if
(
images
)
delete
images
;
if
(
palettes
)
delete
palettes
;
}
int
Scene
::
play
()
{
SDL_Rect
dst
;
unsigned
int
sceneIndex
=
0
;
ImageInfo
*
imageInfo
;
unsigned
int
pageTime
=
scriptP
ages
[
sceneIndex
].
pageTime
;
SceneImage
*
image
;
unsigned
int
pageTime
=
p
ages
[
sceneIndex
].
pageTime
;
unsigned
int
lastTicks
=
globalTicks
;
int
newpage
=
true
;
int
fadein
=
false
;
...
...
@@ -211,7 +220,7 @@ int Scene::play () {
// Get bg for this page
newpage
=
true
;
pageTime
=
scriptP
ages
[
sceneIndex
].
pageTime
;
pageTime
=
p
ages
[
sceneIndex
].
pageTime
;
}
...
...
@@ -223,24 +232,14 @@ int Scene::play () {
textRect
.
y
=
0
;
textRect
.
w
=
320
;
textRect
.
h
=
200
;
PaletteInfo
*
paletteInfo
=
NULL
;
for
(
int
palette
=
0
;
palette
<
paletteIndex
;
palette
++
)
{
if
(
paletteInfos
[
palette
].
dataIndex
==
scriptPages
[
sceneIndex
].
paletteIndex
)
{
ScenePalette
*
palette
=
palettes
;
paletteInfo
=
&
paletteInfos
[
palette
];
break
;
}
while
(
palette
&&
(
palette
->
id
!=
pages
[
sceneIndex
].
paletteIndex
))
palette
=
palette
->
next
;
}
if
(
paletteInfo
!=
NULL
)
{
if
(
palette
)
{
// usePalette(palette
Info->palette
);
currentPalette
=
palette
Info
->
palette
;
// usePalette(palette);
currentPalette
=
palette
->
palette
;
fadein
=
true
;
}
else
restorePalette
(
screen
);
...
...
@@ -250,17 +249,20 @@ int Scene::play () {
}
// First draw the backgrounds associated with this page
if
(
scriptPages
[
sceneIndex
].
backgrounds
>
0
)
{
if
(
pages
[
sceneIndex
].
backgrounds
>
0
)
{
for
(
int
bg
=
0
;
bg
<
pages
[
sceneIndex
].
backgrounds
;
bg
++
)
{
for
(
int
bg
=
0
;
bg
<
scriptPages
[
sceneIndex
].
backgrounds
;
bg
++
)
{
image
=
images
;
imageInfo
=
FindImage
(
scriptPages
[
sceneIndex
].
bgIndex
[
bg
]);
while
(
image
&&
(
image
->
id
!=
pages
[
sceneIndex
].
bgIndex
[
bg
]))
image
=
image
->
next
;
if
(
image
Info
!=
NULL
)
{
if
(
image
)
{
dst
.
x
=
(
scriptP
ages
[
sceneIndex
].
bgPos
[
bg
]
&
65535
)
*
2
+
(
canvasW
-
320
)
>>
1
;
dst
.
y
=
((
scriptP
ages
[
sceneIndex
].
bgPos
[
bg
]
&
(
~
65535
))
>>
16
)
*
2
+
(
canvasH
-
200
)
>>
1
;
SDL_BlitSurface
(
image
Info
->
image
,
NULL
,
canvas
,
&
dst
);
dst
.
x
=
(
p
ages
[
sceneIndex
].
bgPos
[
bg
]
&
65535
)
*
2
+
(
canvasW
-
320
)
>>
1
;
dst
.
y
=
((
p
ages
[
sceneIndex
].
bgPos
[
bg
]
&
(
~
65535
))
>>
16
)
*
2
+
(
canvasH
-
200
)
>>
1
;
SDL_BlitSurface
(
image
->
image
,
NULL
,
canvas
,
&
dst
);
}
...
...
@@ -274,16 +276,17 @@ int Scene::play () {
int
y
=
0
;
int
extraLineHeight
=
0
;
for
(
int
text
=
0
;
text
<
scriptPages
[
sceneIndex
].
noScriptTexts
;
tex
t
++
)
{
for
(
int
count
=
0
;
count
<
pages
[
sceneIndex
].
nTexts
;
coun
t
++
)
{
Font
*
font
=
NULL
;
SceneText
*
text
=
pages
[
sceneIndex
].
texts
+
count
;
Font
*
font
=
NULL
;
int
xOffset
,
yOffset
;
for
(
int
index
=
0
;
index
<
n
oScript
Fonts
;
index
++
)
{
for
(
int
index
=
0
;
index
<
nFonts
;
index
++
)
{
if
(
scriptPages
[
sceneIndex
].
scriptTexts
[
text
].
fontId
==
scriptFonts
[
index
].
fontI
d
)
{
if
(
text
->
fontId
==
fonts
[
index
].
i
d
)
{
font
=
scriptF
onts
[
index
].
font
;
font
=
f
onts
[
index
].
font
;
continue
;
...
...
@@ -291,31 +294,31 @@ int Scene::play () {
}
if
(
scriptPages
[
sceneIndex
].
scriptTexts
[
text
].
x
!=
-
1
)
{
if
(
text
->
x
!=
-
1
)
{
x
=
scriptPages
[
sceneIndex
].
scriptTexts
[
text
].
x
;
y
=
scriptPages
[
sceneIndex
].
scriptTexts
[
text
].
y
;
x
=
text
->
x
;
y
=
text
->
y
;
}
if
(
scriptPages
[
sceneIndex
].
scriptTexts
[
text
].
textRect
.
x
!=
-
1
)
{
if
(
text
->
textRect
.
x
!=
-
1
)
{
textRect
=
scriptPages
[
sceneIndex
].
scriptTexts
[
text
].
textRect
;
textRect
=
text
->
textRect
;
x
=
0
;
y
=
0
;
}
if
(
scriptPages
[
sceneIndex
].
scriptTexts
[
text
].
extraLineHeight
!=
-
1
)
{
if
(
text
->
extraLineHeight
!=
-
1
)
{
extraLineHeight
=
scriptPages
[
sceneIndex
].
scriptTexts
[
text
].
extraLineHeight
;
extraLineHeight
=
text
->
extraLineHeight
;
}
xOffset
=
((
canvasW
-
320
)
>>
1
)
+
textRect
.
x
+
x
;
yOffset
=
((
canvasH
-
200
)
>>
1
)
+
textRect
.
y
+
y
;
switch
(
scriptPages
[
sceneIndex
].
scriptTexts
[
text
].
alignment
)
{
switch
(
text
->
alignment
)
{
case
0
:
// left
...
...
@@ -323,13 +326,13 @@ int Scene::play () {
case
1
:
// right
xOffset
+=
textRect
.
w
-
font
->
getSceneStringWidth
(
scriptPages
[
sceneIndex
].
scriptTexts
[
text
].
text
);
xOffset
+=
textRect
.
w
-
font
->
getSceneStringWidth
(
text
->
text
);
break
;
case
2
:
// center
xOffset
+=
(
textRect
.
w
-
font
->
getSceneStringWidth
(
scriptPages
[
sceneIndex
].
scriptTexts
[
text
].
text
))
>>
1
;
xOffset
+=
(
textRect
.
w
-
font
->
getSceneStringWidth
(
text
->
text
))
>>
1
;
break
;
...
...
@@ -337,11 +340,11 @@ int Scene::play () {
// Drop shadow
font
->
mapPalette
(
0
,
256
,
0
,
1
);
font
->
showSceneString
(
scriptPages
[
sceneIndex
].
scriptTexts
[
text
].
text
,
xOffset
+
1
,
yOffset
+
1
);
font
->
showSceneString
(
text
->
text
,
xOffset
+
1
,
yOffset
+
1
);
font
->
restorePalette
();
// Text itself
font
->
showSceneString
(
scriptPages
[
sceneIndex
].
scriptTexts
[
text
].
text
,
xOffset
,
yOffset
);
font
->
showSceneString
(
text
->
text
,
xOffset
,
yOffset
);
y
+=
extraLineHeight
+
font
->
getHeight
()
/
2
;
...
...
src/scene/scene.h
View file @
411eaa5a
...
...
@@ -64,18 +64,7 @@ enum {
class
Font
;
class
ScriptFont
{
public
:
// This points to any of the available types (already loaded)
Font
*
font
;
// Font id given this font
int
fontId
;
};
class
ScriptText
{
class
SceneText
{
public
:
char
*
text
;
...
...
@@ -86,12 +75,12 @@ class ScriptText {
SDL_Rect
textRect
;
int
extraLineHeight
;
Sc
ript
Text
();
~
Sc
ript
Text
();
Sc
ene
Text
();
~
Sc
ene
Text
();
};
class
Sc
ript
Page
{
class
Sc
ene
Page
{
public
:
int
backgrounds
;
...
...
@@ -100,65 +89,68 @@ class ScriptPage {
// Length of the scene in seconds, or if zero = anim complete, or 256 = user interaction
int
pageTime
;
Sc
riptText
scriptT
exts
[
100
];
int
n
oScript
Texts
;
char
*
music
f
ile
;
Sc
eneText
t
exts
[
100
];
int
nTexts
;
char
*
music
F
ile
;
int
paletteIndex
;
Sc
ript
Page
();
~
Sc
ript
Page
();
Sc
ene
Page
();
~
Sc
ene
Page
();
};
class
ImageInfo
{
class
SceneImage
{
public
:
// SDL_Surface with the image
SceneImage
*
next
;
SDL_Surface
*
image
;
int
id
;
// data index of the image (not the palette) to compare with scripts
int
dataIndex
;
ImageInfo
();
~
ImageInfo
();
SceneImage
(
SceneImage
*
newNext
);
~
SceneImage
();
};
class
PaletteInfo
{
class
ScenePalette
{
public
:
// Palette associated with the image
public
:
ScenePalette
*
next
;
SDL_Color
palette
[
256
];
// data index of the image (not the palette) to compare with scripts
int
dataIndex
;
int
id
;
ScenePalette
(
ScenePalette
*
newNext
);
~
ScenePalette
();
};
class
SceneFont
{
public
:
Font
*
font
;
int
id
;
};
class
Scene
{
private
:
ImageInfo
imageInfos
[
100
];
PaletteInfo
paletteInfos
[
100
];
SceneImage
*
images
;
ScenePalette
*
palettes
;
SceneFont
fonts
[
5
];
int
nFonts
;
unsigned
short
int
scriptItems
;
unsigned
short
int
dataItems
;
signed
long
int
*
scriptStarts
;
signed
long
int
*
dataOffsets
;
int
imageIndex
;
int
paletteIndex
;
// Scripts all information needed to render script pages, text etc
Sc
riptPage
*
scriptP
ages
;
Sc
enePage
*
p
ages
;
void
loadScripts
(
File
*
f
);
void
loadData
(
File
*
f
);
void
loadAni
(
File
*
f
,
int
dataIndex
);
ImageInfo
*
FindImage
(
int
dataIndex
);
public
:
ScriptFont
scriptFonts
[
5
];
int
noScriptFonts
;
void
loadScripts
(
File
*
f
);
void
loadData
(
File
*
f
);
void
loadAni
(
File
*
f
,
int
dataIndex
);
public
:
Scene
(
const
char
*
fileName
);
~
Scene
();
...
...
src/scene/sceneload.cpp
View file @
411eaa5a
...
...
@@ -68,23 +68,21 @@ void Scene::loadAni (File *f, int dataIndex) {
unsigned
short
int
len
=
f
->
loadShort
();
unsigned
char
*
buffer
=
f
->
loadBlock
(
len
);
palettes
=
new
ScenePalette
(
palettes
);
for
(
int
count
=
0
;
count
<
256
;
count
++
)
{
// Palette entries are 6-bit
// Shift them upwards to 8-bit, and fill in the lower 2 bits
paletteInfos
[
paletteIndex
].
palette
[
count
].
r
=
(
buffer
[
count
*
3
]
<<
2
)
+
(
buffer
[
count
*
3
]
>>
4
);
paletteInfos
[
paletteIndex
].
palette
[
count
].
g
=
(
buffer
[(
count
*
3
)
+
1
]
<<
2
)
+
(
buffer
[(
count
*
3
)
+
1
]
>>
4
);
paletteInfos
[
paletteIndex
].
palette
[
count
].
b
=
(
buffer
[(
count
*
3
)
+
2
]
<<
2
)
+
(
buffer
[(
count
*
3
)
+
2
]
>>
4
);
palettes
->
palette
[
count
].
r
=
(
buffer
[
count
*
3
]
<<
2
)
+
(
buffer
[
count
*
3
]
>>
4
);
palettes
->
palette
[
count
].
g
=
(
buffer
[(
count
*
3
)
+
1
]
<<
2
)
+
(
buffer
[(
count
*
3
)
+
1
]
>>
4
);
palettes
->
palette
[
count
].
b
=
(
buffer
[(
count
*
3
)
+
2
]
<<
2
)
+
(
buffer
[(
count
*
3
)
+
2
]
>>
4
);
}
delete
[]
buffer
;
paletteInfos
[
paletteIndex
].
dataIndex
=
dataIndex
;
paletteIndex
++
;
palettes
->
id
=
dataIndex
;
unsigned
short
int
value
=
0x4646
;
int
items
=
0
;
...
...
@@ -97,11 +95,11 @@ void Scene::loadAni (File *f, int dataIndex) {
value
=
f
->
loadShort
();
LOG
(
"PL Read block start tag"
,
value
);
unsigned
short
int
size
=
f
->
loadShort
();
unsigned
short
int
size
=
f
->
loadShort
();
LOG
(
"PL Anim block size"
,
size
);
nextPos
=
f
->
tell
();
// next pos is intial position + size and four bytes header
nextPos
+=
(
size
)
;
nextPos
+=
size
;
switch
(
value
)
{
...
...
@@ -118,11 +116,13 @@ void Scene::loadAni (File *f, int dataIndex) {
// Skip back size header, this is read by the surface reader
f
->
seek
(
-
2
,
false
);
SDL_Surface
*
image
=
f
->
loadSurface
(
320
,
200
,
true
);
SDL_Surface
*
image
=
f
->
loadSurface
(
320
,
200
);
SDL_BlitSurface
(
image
,
NULL
,
canvas
,
NULL
);
SDL_FreeSurface
(
image
);
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
paletteInfos
[
paletteIndex
-
1
].
palette
,
0
,
256
);
currentPalette
=
paletteInfos
[
paletteIndex
-
1
].
palette
;
// Use the most recently loaded palette
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
palettes
->
palette
,
0
,
256
);
currentPalette
=
palettes
->
palette
;
}
...
...
@@ -134,8 +134,6 @@ void Scene::loadAni (File *f, int dataIndex) {
int
longvalue
=
f
->
loadInt
();
LOG
(
"PL Anim block value"
,
longvalue
);
// Skip back size header, this is read by the surface reader
//f->seek(-2, false);
while
(
size
)
{
...
...
@@ -176,6 +174,7 @@ void Scene::loadAni (File *f, int dataIndex) {
default
:
LOG
(
"PL Unknown type"
,
header
);
break
;
}
...
...
@@ -327,7 +326,7 @@ void Scene::loadData (File *f) {
int
loop
;
for
(
loop
=
0
;
loop
<
dataItems
;
loop
++
)
{
for
(
loop
=
0
;
loop
<
dataItems
;
loop
++
)
{
f
->
seek
(
dataOffsets
[
loop
],
true
);
// Seek to data start
unsigned
short
int
dataLen
=
f
->
loadShort
();
// Get get the length of the datablock
...
...
@@ -361,14 +360,10 @@ void Scene::loadData (File *f) {
if
(
type
==
3
)
height
=
f
->
loadChar
();
// Get height
else
height
=
f
->
loadShort
();
// Get height
if
(
imageIndex
<
100
)
{
f
->
seek
(
-
2
,
false
);
imageInfos
[
imageIndex
].
image
=
f
->
loadSurface
(
width
,
height
);
imageInfos
[
imageIndex
].
dataIndex
=
loop
;
imageIndex
++
;
}
f
->
seek
(
-
2
,
false
);
images
=
new
SceneImage
(
images
);
images
->
image
=
f
->
loadSurface
(
width
,
height
);
images
->
id
=
loop
;
}
...
...
@@ -376,16 +371,13 @@ void Scene::loadData (File *f) {
default
:
{
LOG
(
"Data Type"
,
"Palette"
);
LOG
(
"Data Type Palette index"
,
loop
);
f
->
seek
(
-
3
,
false
);
f
->
loadPalette
(
paletteInfos
[
paletteIndex
].
palette
);
paletteInfos
[
paletteIndex
].
dataIndex
=
loop
;
paletteIndex
++
;
LOG
(
"Data Type"
,
"Palette"
);
LOG
(
"Data Type Palette index"
,
loop
);
f
->
seek
(
-
3
,
false
);
}
palettes
=
new
ScenePalette
(
palettes
);
f
->
loadPalette
(
palettes
->
palette
);
palettes
->
id
=
loop
;
break
;
...
...
@@ -401,7 +393,6 @@ void Scene::loadData (File *f) {
void
Scene
::
loadScripts
(
File
*
f
)
{
int
loop
;
char
*
string
;
/*int bgIndex = 0;*/
int
textAlignment
=
0
;
int
textFont
=
0
;
...
...
@@ -420,10 +411,10 @@ void Scene::loadScripts (File *f) {
if
(
f
->
loadChar
()
==
0x50
)
{
// Script tag
unsigned
short
int
scriptid
=
f
->
loadShort
();
LOG
(
"Script id
:
"
,
scriptid
);
LOG
(
"Script id"
,
scriptid
);
int
palette
=
f
->
loadShort
();
LOG
(
"Script default palette"
,
palette
);
scriptP
ages
[
loop
].
paletteIndex
=
palette
;
p
ages
[
loop
].
paletteIndex
=
palette
;
unsigned
char
type
=
0
;
bool
breakloop
=
false
;
...
...
@@ -452,7 +443,7 @@ void Scene::loadScripts (File *f) {
{
unsigned
char
aniIndex
=
f
->
loadChar
();
LOG
(
"ESceneAnimationIndex
:
"
,
aniIndex
);
LOG
(
"ESceneAnimationIndex"
,
aniIndex
);
}
...
...
@@ -462,7 +453,7 @@ void Scene::loadScripts (File *f) {
{
unsigned
char
fadein
=
f
->
loadChar
();
LOG
(
"ESceneFadeType
:
"
,
fadein
);
LOG
(
"ESceneFadeType"
,
fadein
);
}
...
...
@@ -478,9 +469,9 @@ void Scene::loadScripts (File *f) {
LOG
(
"ESceneBackground: index"
,
bgImageIndex
);
LOG
(
"ESceneBackground: xpos"
,
xpos
);
LOG
(
"ESceneBackground: ypos"
,
ypos
);
scriptPages
[
loop
].
bgIndex
[
scriptP
ages
[
loop
].
backgrounds
]
=
bgImageIndex
;
scriptPages
[
loop
].
bgPos
[
scriptPages
[
loop
].
backgrounds
]
=
xpos
|
(
ypos
<<
16
);
scriptP
ages
[
loop
].
backgrounds
++
;
pages
[
loop
].
bgIndex
[
p
ages
[
loop
].
backgrounds
]
=
bgImageIndex
;
pages
[
loop
].
bgPos
[
pages
[
loop
].
backgrounds
]
=
xpos
|
(
ypos
<<
16
);
p
ages
[
loop
].
backgrounds
++
;
}
...
...
@@ -488,15 +479,9 @@ void Scene::loadScripts (File *f) {
case
ESceneMusic
:
{
// Music file name
string
=
f
->
loadString
();
LOG
(
"ESceneMusic: "
,
string
);
scriptPages
[
loop
].
musicfile
=
createString
(
string
);
delete
[]
string
;
}
// Music file name
pages
[
loop
].
musicFile
=
f
->
loadString
();
LOG
(
"ESceneMusic"
,
pages
[
loop
].
musicFile
);
break
;
...
...
@@ -513,45 +498,42 @@ void Scene::loadScripts (File *f) {
case
ESceneTextRect
:
// String
{
unsigned
short
x
=
textRect
.
x
=
f
->
loadShort
();
unsigned
short
y
=
textRect
.
y
=
f
->
loadShort
();
unsigned
short
w
=
textRect
.
w
=
f
->
loadShort
()
-
x
;
unsigned
short
h
=
textRect
.
h
=
f
->
loadShort
()
-
y
;
textRectValid
=
true
;
LOG
(
"Text rectangle xpos:"
,
x
);
LOG
(
"Text rectangle ypos:"
,
y
);
LOG
(
"Text rectangle w:"
,
w
);
LOG
(
"Text rectangle h:"
,
h
);
}
textRect
.
x
=
f
->
loadShort
();
textRect
.
y
=
f
->
loadShort
();
textRect
.
w
=
f
->
loadShort
()
-
textRect
.
x
;
textRect
.
h
=
f
->
loadShort
()
-
textRect
.
y
;
textRectValid
=
true
;
LOG
(
"Text rectangle xpos"
,
textRect
.
x
);
LOG
(
"Text rectangle ypos"
,
textRect
.
y
);
LOG
(
"Text rectangle w"
,
textRect
.
w
);
LOG
(
"Text rectangle h"
,
textRect
.
h
);
break
;
case
ESceneFontDefine
:
// Font defnition
{
if
(
nFonts
<
5
)
{
fonts
[
nFonts
].
id
=
f
->
loadShort
();
char
*
fontname
=
f
->
loadString
();
unsigned
short
fontid
=
f
->
loadShort
();
char
*
fontname
=
f
->
loadString
();
LOG
(
"ESceneFontDefine"
,
fontname
);
LOG
(
"ESceneFontDefine with id
="
,
font
id
);
LOG
(
"ESceneFontDefine with id
"
,
fonts
[
nFonts
].
id
);
if
(
strcmp
(
fontname
,
"FONT2"
)
==
0
)
scriptFonts
[
noScript
Fonts
].
font
=
font2
;
fonts
[
n
Fonts
].
font
=
font2
;
else
if
(
strcmp
(
fontname
,
"FONTBIG"
)
==
0
)
scriptFonts
[
noScript
Fonts
].
font
=
fontbig
;
fonts
[
n
Fonts
].
font
=
fontbig
;
else
if
(
strcmp
(
fontname
,
"FONTTINY"
)
==
0
)
scriptFonts
[
noScript
Fonts
].
font
=
fontiny
;
fonts
[
n
Fonts
].
font
=
fontiny
;
else
if
(
strcmp
(
fontname
,
"FONTMN1"
)
==
0
)
scriptFonts
[
noScript
Fonts
].
font
=
fontmn1
;
fonts
[
n
Fonts
].
font
=
fontmn1
;
else
if
(
strcmp
(
fontname
,
"FONTMN2"
)
==
0
)
scriptFonts
[
noScriptFonts
].
font
=
fontmn2
;
else
scriptFonts
[
noScriptFonts
].
font
=
font2
;
fonts
[
nFonts
].
font
=
fontmn2
;
else
fonts
[
nFonts
].
font
=
font2
;
nFonts
++
;
scriptFonts
[
noScriptFonts
].
fontId
=
fontid
;
noScriptFonts
++
;
delete
[]
fontname
;
}
...
...
@@ -560,16 +542,10 @@ void Scene::loadScripts (File *f) {
case
ESceneTextPosition
:
{
unsigned
short
newx
=
f
->
loadShort
();
unsigned
short
newy
=
f
->
loadShort
();
LOG
(
"TextPosition x"
,
newx
);
LOG
(
"TextPosition y"
,
newy
);
textPosX
=
newx
;
textPosY
=
newy
;
}
textPosX
=
f
->
loadShort
();
textPosY
=
f
->
loadShort
();
LOG
(
"TextPosition x"
,
textPosX
);
LOG
(
"TextPosition y"
,
textPosY
);
break
;
...
...
@@ -604,25 +580,15 @@ void Scene::loadScripts (File *f) {
case
ESceneFontIndex
:
{
unsigned
short
value
=
f
->
loadShort
();
LOG
(
"ESceneFontIndex"
,
value
);
textFont
=
value
;
}
textFont
=
f
->
loadShort
();
LOG
(
"ESceneFontIndex"
,
textFont
);
break
;
case
ESceneTextVAdjust
:
{
unsigned
short
value
=
f
->
loadShort
();
LOG
(
"ESceneTextVAdjust"
,
value
);
extraheight
=
value
;
}
extraheight
=
f
->
loadShort
();
LOG
(
"ESceneTextVAdjust"
,
extraheight
);
break
;
...
...
@@ -650,13 +616,8 @@ void Scene::loadScripts (File *f) {
case
ESceneTextAlign
:
{
unsigned
char
alignment
=
f
->
loadChar
();
LOG
(
"ESceneTextAlign"
,
alignment
);
textAlignment
=
alignment
;
}
textAlignment
=
f
->
loadChar
();
LOG
(
"ESceneTextAlign"
,
textAlignment
);
break
;
...
...
@@ -692,54 +653,50 @@ void Scene::loadScripts (File *f) {
{
unsigned
char
datalen
=
f
->
loadChar
();
LOG
(
"Text len="
,
datalen
);
LOG
(
"Text len"
,
datalen
);
SceneText
*
text
=
pages
[
loop
].
texts
+
pages
[
loop
].
nTexts
;
if
(
datalen
>
0
)
{
f
->
seek
(
-
1
,
false
);
char
*
block
=
f
->
loadString
();
text
->
text
=
f
->
loadString
();
// Convert number placeholders
for
(
int
pos
=
1
;
pos
<
datalen
;
pos
++
)
{
if
(
block
[
pos
]
==
-
117
)
{
if
(
text
->
text
[
pos
]
==
-
117
)
{
if
(
loop
>=
9
)
block
[
pos
-
1
]
=
((
loop
+
1
)
/
10
)
+
53
;
text
->
text
[
pos
-
1
]
=
((
loop
+
1
)
/
10
)
+
53
;
block
[
pos
]
=
((
loop
+
1
)
%
10
)
+
53
;
text
->
text
[
pos
]
=
((
loop
+
1
)
%
10
)
+
53
;
}
else
if
(
block
[
pos
]
==
-
118
)
{
}
else
if
(
text
->
text
[
pos
]
==
-
118
)
{
if
(
scriptItems
>=
10
)
block
[
pos
-
1
]
=
(
scriptItems
/
10
)
+
53
;
text
->
text
[
pos
-
1
]
=
(
scriptItems
/
10
)
+
53
;
block
[
pos
]
=
(
scriptItems
%
10
)
+
53
;
text
->
text
[
pos
]
=
(
scriptItems
%
10
)
+
53
;
}
}
scriptPages
[
loop
].
scriptTexts
[
scriptPages
[
loop
].
noScriptTexts
].
text
=
block
;
LOG
(
"Text data"
,(
char
*
)
scriptPages
[
loop
].
scriptTexts
[
scriptPages
[
loop
].
noScriptTexts
].
text
);
}
else
{
scriptPages
[
loop
].
scriptTexts
[
scriptPages
[
loop
].
noScriptTexts
].
text
=
new
char
[
1
];
scriptPages
[
loop
].
scriptTexts
[
scriptPages
[
loop
].
noScriptTexts
].
text
[
0
]
=
0
;
LOG
(
"Text data"
,
"Empty line"
);
text
->
text
=
new
char
[
1
];
text
->
text
[
0
]
=
0
;
}
scriptPages
[
loop
].
scriptTexts
[
scriptPages
[
loop
].
noScriptTexts
].
alignment
=
textAlignment
;
scriptPages
[
loop
].
scriptTexts
[
scriptPages
[
loop
].
noScriptTexts
].
fontId
=
textFont
;
text
->
alignment
=
textAlignment
;
text
->
fontId
=
textFont
;
if
(
textPosX
!=
-
1
)
{
scriptPages
[
loop
].
scriptTexts
[
scriptPages
[
loop
].
noScriptTexts
].
x
=
textPosX
;
scriptPages
[
loop
].
scriptTexts
[
scriptPages
[
loop
].
noScriptTexts
].
y
=
textPosY
;
text
->
x
=
textPosX
;
text
->
y
=
textPosY
;
textPosX
=
-
1
;
textPosY
=
-
1
;
...
...
@@ -747,19 +704,19 @@ void Scene::loadScripts (File *f) {
if
(
textRectValid
)
{
scriptPages
[
loop
].
scriptTexts
[
scriptPages
[
loop
].
noScriptTexts
].
textRect
=
textRect
;
text
->
textRect
=
textRect
;
textRectValid
=
false
;
}
if
(
extraheight
!=
-
1
)
{
scriptPages
[
loop
].
scriptTexts
[
scriptPages
[
loop
].
noScriptTexts
].
extraLineHeight
=
extraheight
;
text
->
extraLineHeight
=
extraheight
;
extraheight
=
-
1
;
}
scriptPages
[
loop
].
noScript
Texts
++
;
pages
[
loop
].
n
Texts
++
;
}
...
...
@@ -767,12 +724,8 @@ void Scene::loadScripts (File *f) {
case
ESceneTime
:
{
unsigned
short
int
sceneTime
=
f
->
loadShort
();
LOG
(
"Scene time"
,
sceneTime
&
255
);
scriptPages
[
loop
].
pageTime
=
sceneTime
&
255
;
}
pages
[
loop
].
pageTime
=
f
->
loadShort
()
&
255
;
LOG
(
"Scene time"
,
pages
[
loop
].
pageTime
);
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment