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
1738194a
Commit
1738194a
authored
Sep 26, 2010
by
alistert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed sprite loading issue. Introduced optional upper limit for loading of shorts.
parent
b3ef0f9a
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
93 additions
and
68 deletions
+93
-68
bonus.cpp
src/bonus/bonus.cpp
+5
-5
file.cpp
src/io/file.cpp
+20
-1
file.h
src/io/file.h
+1
-0
font.cpp
src/io/gfx/font.cpp
+8
-5
demolevel.cpp
src/level/demolevel.cpp
+2
-2
levelload.cpp
src/level/levelload.cpp
+40
-38
main.cpp
src/main.cpp
+2
-2
sceneload.cpp
src/scene/sceneload.cpp
+15
-15
No files found.
src/bonus/bonus.cpp
View file @
1738194a
...
@@ -62,7 +62,7 @@ int Bonus::loadSprites () {
...
@@ -62,7 +62,7 @@ int Bonus::loadSprites () {
file
->
seek
(
2
,
true
);
file
->
seek
(
2
,
true
);
sprites
=
file
->
loadShort
();
sprites
=
file
->
loadShort
(
256
);
spriteSet
=
new
Sprite
[
sprites
];
spriteSet
=
new
Sprite
[
sprites
];
for
(
count
=
0
;
count
<
sprites
;
count
++
)
{
for
(
count
=
0
;
count
<
sprites
;
count
++
)
{
...
@@ -71,8 +71,8 @@ int Bonus::loadSprites () {
...
@@ -71,8 +71,8 @@ int Bonus::loadSprites () {
spriteSet
[
count
].
yOffset
=
0
;
spriteSet
[
count
].
yOffset
=
0
;
// Load dimensions
// Load dimensions
width
=
file
->
loadShort
();
width
=
file
->
loadShort
(
SW
);
height
=
file
->
loadShort
();
height
=
file
->
loadShort
(
SH
);
pixelsLength
=
file
->
loadShort
();
pixelsLength
=
file
->
loadShort
();
maskLength
=
file
->
loadShort
();
maskLength
=
file
->
loadShort
();
...
@@ -83,10 +83,10 @@ int Bonus::loadSprites () {
...
@@ -83,10 +83,10 @@ int Bonus::loadSprites () {
// Masked
// Masked
width
<<=
2
;
width
<<=
2
;
pos
=
file
->
tell
()
+
(
pixelsLength
<<
2
)
+
maskLength
;
pos
=
file
->
tell
()
+
(
pixelsLength
<<
2
)
+
maskLength
;
// Read scrambled, masked pixel data
// Read scrambled, masked pixel data
pixels
=
file
->
loadPixels
(
width
*
height
,
0
);
pixels
=
file
->
loadPixels
(
width
*
height
,
0
);
spriteSet
[
count
].
setPixels
(
pixels
,
width
,
height
,
0
);
spriteSet
[
count
].
setPixels
(
pixels
,
width
,
height
,
0
);
delete
[]
pixels
;
delete
[]
pixels
;
...
...
src/io/file.cpp
View file @
1738194a
...
@@ -169,6 +169,25 @@ unsigned short int File::loadShort () {
...
@@ -169,6 +169,25 @@ unsigned short int File::loadShort () {
}
}
unsigned
short
int
File
::
loadShort
(
unsigned
short
int
max
)
{
unsigned
short
int
val
;
val
=
loadShort
();
if
(
val
>
max
)
{
logError
(
"Oversized value in file"
,
filePath
);
return
max
;
}
return
val
;
}
void
File
::
storeShort
(
unsigned
short
int
val
)
{
void
File
::
storeShort
(
unsigned
short
int
val
)
{
fputc
(
val
&
255
,
file
);
fputc
(
val
&
255
,
file
);
...
@@ -387,7 +406,7 @@ unsigned char* File::loadPixels (int length) {
...
@@ -387,7 +406,7 @@ unsigned char* File::loadPixels (int length) {
}
}
unsigned
char
*
File
::
loadPixels
(
int
length
,
int
key
)
{
unsigned
char
*
File
::
loadPixels
(
int
length
,
int
key
)
{
unsigned
char
*
pixels
;
unsigned
char
*
pixels
;
unsigned
char
*
sorted
;
unsigned
char
*
sorted
;
...
...
src/io/file.h
View file @
1738194a
...
@@ -50,6 +50,7 @@ class File {
...
@@ -50,6 +50,7 @@ class File {
unsigned
char
loadChar
();
unsigned
char
loadChar
();
void
storeChar
(
unsigned
char
val
);
void
storeChar
(
unsigned
char
val
);
unsigned
short
int
loadShort
();
unsigned
short
int
loadShort
();
unsigned
short
int
loadShort
(
unsigned
short
int
max
);
void
storeShort
(
unsigned
short
int
val
);
void
storeShort
(
unsigned
short
int
val
);
signed
long
int
loadInt
();
signed
long
int
loadInt
();
void
storeInt
(
signed
long
int
val
);
void
storeInt
(
signed
long
int
val
);
...
...
src/io/gfx/font.cpp
View file @
1738194a
...
@@ -82,7 +82,7 @@ Font::Font (const char* fileName) {
...
@@ -82,7 +82,7 @@ Font::Font (const char* fileName) {
size
=
file
->
loadShort
();
size
=
file
->
loadShort
();
if
(
size
)
{
if
(
size
>
4
)
{
pixels
=
file
->
loadRLE
(
size
);
pixels
=
file
->
loadRLE
(
size
);
...
@@ -91,7 +91,10 @@ Font::Font (const char* fileName) {
...
@@ -91,7 +91,10 @@ Font::Font (const char* fileName) {
height
=
pixels
[
2
];
height
=
pixels
[
2
];
height
+=
pixels
[
3
]
<<
8
;
height
+=
pixels
[
3
]
<<
8
;
characters
[
count
]
=
createSurface
(
pixels
+
4
,
width
,
height
);
if
(
size
-
4
>=
width
*
height
)
characters
[
count
]
=
createSurface
(
pixels
+
4
,
width
,
height
);
else
characters
[
count
]
=
createSurface
(
blank
,
3
,
1
);
delete
[]
pixels
;
delete
[]
pixels
;
...
@@ -230,7 +233,7 @@ Font::Font (bool bonus) {
...
@@ -230,7 +233,7 @@ Font::Font (bool bonus) {
fileSize
=
file
->
getSize
();
fileSize
=
file
->
getSize
();
nCharacters
=
file
->
loadShort
();
nCharacters
=
file
->
loadShort
(
256
);
if
(
bonus
)
{
if
(
bonus
)
{
...
@@ -264,8 +267,8 @@ Font::Font (bool bonus) {
...
@@ -264,8 +267,8 @@ Font::Font (bool bonus) {
}
}
width
=
file
->
loadShort
();
width
=
file
->
loadShort
(
SW
);
height
=
file
->
loadShort
();
height
=
file
->
loadShort
(
SH
);
if
(
bonus
)
width
=
(
width
+
3
)
&
~
3
;
if
(
bonus
)
width
=
(
width
+
3
)
&
~
3
;
else
width
<<=
2
;
else
width
<<=
2
;
...
...
src/level/demolevel.cpp
View file @
1738194a
...
@@ -61,8 +61,8 @@ DemoLevel::DemoLevel (const char* fileName) {
...
@@ -61,8 +61,8 @@ DemoLevel::DemoLevel (const char* fileName) {
if
(
file
->
loadShort
()
==
0
)
throw
E_DEMOTYPE
;
if
(
file
->
loadShort
()
==
0
)
throw
E_DEMOTYPE
;
// Level file to load
// Level file to load
lNum
=
file
->
loadShort
();
lNum
=
file
->
loadShort
(
9
);
wNum
=
file
->
loadShort
();
wNum
=
file
->
loadShort
(
999
);
levelFile
=
createFileName
(
F_LEVEL
,
lNum
,
wNum
);
levelFile
=
createFileName
(
F_LEVEL
,
lNum
,
wNum
);
// Difficulty
// Difficulty
...
...
src/level/levelload.cpp
View file @
1738194a
...
@@ -155,20 +155,20 @@ void Level::loadSprite (File* file, Sprite* sprite) {
...
@@ -155,20 +155,20 @@ void Level::loadSprite (File* file, Sprite* sprite) {
maskOffset
=
file
->
loadShort
();
maskOffset
=
file
->
loadShort
();
pos
=
file
->
loadShort
()
<<
2
;
pos
=
file
->
loadShort
()
<<
2
;
// Sprites can be either masked or not masked.
// Sprites can be either masked or not masked.
if
(
maskOffset
)
{
if
(
maskOffset
)
{
// Masked
// Masked
height
++
;
height
++
;
// Skip to mask
// Skip to mask
file
->
seek
(
maskOffset
,
false
);
file
->
seek
(
maskOffset
,
false
);
// Find the end of the data
// Find the end of the data
pos
+=
file
->
tell
()
+
((
width
>>
2
)
*
height
);
pos
+=
file
->
tell
()
+
((
width
>>
2
)
*
height
);
// Read scrambled, masked pixel data
// Read scrambled, masked pixel data
pixels
=
file
->
loadPixels
(
width
*
height
,
SKEY
);
pixels
=
file
->
loadPixels
(
width
*
height
,
SKEY
);
sprite
->
setPixels
(
pixels
,
width
,
height
,
SKEY
);
sprite
->
setPixels
(
pixels
,
width
,
height
,
SKEY
);
...
@@ -199,7 +199,8 @@ int Level::loadSprites (char * fileName) {
...
@@ -199,7 +199,8 @@ int Level::loadSprites (char * fileName) {
File
*
mainFile
=
NULL
;
File
*
mainFile
=
NULL
;
File
*
specFile
=
NULL
;
File
*
specFile
=
NULL
;
int
count
;
int
count
;
bool
loaded
;
// Open fileName
// Open fileName
...
@@ -214,7 +215,7 @@ int Level::loadSprites (char * fileName) {
...
@@ -214,7 +215,7 @@ int Level::loadSprites (char * fileName) {
}
}
// This function loads all the sprites, not
f
ust those in fileName
// This function loads all the sprites, not
j
ust those in fileName
try
{
try
{
mainFile
=
new
File
(
F_MAINCHAR
,
false
);
mainFile
=
new
File
(
F_MAINCHAR
,
false
);
...
@@ -228,7 +229,7 @@ int Level::loadSprites (char * fileName) {
...
@@ -228,7 +229,7 @@ int Level::loadSprites (char * fileName) {
}
}
sprites
=
specFile
->
loadShort
();
sprites
=
specFile
->
loadShort
(
256
);
// Include space in the sprite set for the blank sprite at the end
// Include space in the sprite set for the blank sprite at the end
spriteSet
=
new
Sprite
[
sprites
+
1
];
spriteSet
=
new
Sprite
[
sprites
+
1
];
...
@@ -248,47 +249,48 @@ int Level::loadSprites (char * fileName) {
...
@@ -248,47 +249,48 @@ int Level::loadSprites (char * fileName) {
// Loop through all the sprites to be loaded
// Loop through all the sprites to be loaded
for
(
count
=
0
;
count
<
sprites
;
count
++
)
{
for
(
count
=
0
;
count
<
sprites
;
count
++
)
{
loaded
=
false
;
if
(
mainFile
->
loadChar
()
==
0xFF
)
{
// Go to the next sprite/file indicator
mainFile
->
seek
(
1
,
false
);
}
else
{
// Return to the start of the sprite
mainFile
->
seek
(
-
1
,
false
);
// Load the individual sprite data
loadSprite
(
mainFile
,
spriteSet
+
count
);
loaded
=
true
;
}
if
(
specFile
->
loadChar
()
==
0xFF
)
{
if
(
specFile
->
loadChar
()
==
0xFF
)
{
// Go to the next sprite/file indicator
// Go to the next sprite/file indicator
specFile
->
seek
(
1
,
false
);
specFile
->
seek
(
1
,
false
);
if
(
mainFile
->
loadChar
()
==
0xFF
)
{
// Go to the next sprite/file indicator
mainFile
->
seek
(
1
,
false
);
/* Both fileName and mainchar.000 have file indicators, so
create a blank sprite */
spriteSet
[
count
].
clearPixels
();
continue
;
}
else
{
// Return to the start of the sprite
mainFile
->
seek
(
-
1
,
false
);
// Load the individual sprite data
loadSprite
(
mainFile
,
spriteSet
+
count
);
}
}
else
{
}
else
{
// Return to the start of the sprite
// Return to the start of the sprite
specFile
->
seek
(
-
1
,
false
);
specFile
->
seek
(
-
1
,
false
);
// Go to the main file's next sprite/file indicator
mainFile
->
seek
(
2
,
false
);
// Load the individual sprite data
// Load the individual sprite data
loadSprite
(
specFile
,
spriteSet
+
count
);
loadSprite
(
specFile
,
spriteSet
+
count
);
loaded
=
true
;
}
}
/* If both fileName and mainchar.000 have file indicators, create a
blank sprite */
if
(
!
loaded
)
spriteSet
[
count
].
clearPixels
();
// Check if the next sprite exists
// Check if the next sprite exists
// If not, create blank sprites for the remainder
// If not, create blank sprites for the remainder
if
(
specFile
->
tell
()
>=
specFile
->
getSize
())
{
if
(
specFile
->
tell
()
>=
specFile
->
getSize
())
{
...
@@ -848,8 +850,8 @@ int Level::load (char* fileName, unsigned char diff, bool checkpoint) {
...
@@ -848,8 +850,8 @@ int Level::load (char* fileName, unsigned char diff, bool checkpoint) {
// The players' initial coordinates
// The players' initial coordinates
startX
=
file
->
loadShort
();
startX
=
file
->
loadShort
(
LW
);
startY
=
file
->
loadShort
()
+
1
;
startY
=
file
->
loadShort
(
LH
)
+
1
;
// Next level
// Next level
...
...
src/main.cpp
View file @
1738194a
...
@@ -211,8 +211,8 @@ int loadMain (int argc, char *argv[]) {
...
@@ -211,8 +211,8 @@ int loadMain (int argc, char *argv[]) {
if
(
file
&&
(
file
->
loadChar
()
==
3
))
{
if
(
file
&&
(
file
->
loadChar
()
==
3
))
{
// Read video settings
// Read video settings
screenW
=
file
->
loadShort
();
screenW
=
file
->
loadShort
(
7680
);
screenH
=
file
->
loadShort
();
screenH
=
file
->
loadShort
(
4800
);
scaleFactor
=
file
->
loadChar
();
scaleFactor
=
file
->
loadChar
();
#ifndef FULLSCREEN_ONLY
#ifndef FULLSCREEN_ONLY
...
...
src/scene/sceneload.cpp
View file @
1738194a
...
@@ -285,7 +285,7 @@ void Scene::loadAni (File *f, int dataIndex) {
...
@@ -285,7 +285,7 @@ void Scene::loadAni (File *f, int dataIndex) {
}
}
}
else
if
(
type
==
EPlayListAniHeader
)
{
// PL
}
else
if
(
type
==
EPlayListAniHeader
)
{
// PL
int
pos
=
f
->
tell
();
int
pos
=
f
->
tell
();
int
nextPos
=
f
->
tell
();
int
nextPos
=
f
->
tell
();
LOG
(
"PL Read position"
,
pos
);
LOG
(
"PL Read position"
,
pos
);
...
@@ -354,13 +354,13 @@ void Scene::loadAni (File *f, int dataIndex) {
...
@@ -354,13 +354,13 @@ void Scene::loadAni (File *f, int dataIndex) {
case
EFFAniHeader
:
case
EFFAniHeader
:
{
{
unsigned
char
*
blockData
=
f
->
loadBlock
(
size
);
unsigned
char
*
blockData
=
f
->
loadBlock
(
size
);
animations
->
addFrame
(
EFFAniHeader
,
blockData
,
size
);
animations
->
addFrame
(
EFFAniHeader
,
blockData
,
size
);
}
}
break
;
break
;
case
ERNAniHeader
:
case
ERNAniHeader
:
case
ERBAniHeader
:
case
ERBAniHeader
:
case
ERLAniHeader
:
case
ERLAniHeader
:
case
EMXAniHeader
:
case
EMXAniHeader
:
break
;
break
;
case
ERRAniHeader
:
// Reverse animation when end found
case
ERRAniHeader
:
// Reverse animation when end found
...
@@ -374,9 +374,9 @@ void Scene::loadAni (File *f, int dataIndex) {
...
@@ -374,9 +374,9 @@ void Scene::loadAni (File *f, int dataIndex) {
}
break
;
}
break
;
case
ESquareAniHeader
:
// Full screen animation frame, that does n't clear the screen first.
case
ESquareAniHeader
:
// Full screen animation frame, that does n't clear the screen first.
{
{
unsigned
char
*
blockData
=
f
->
loadBlock
(
size
);
unsigned
char
*
blockData
=
f
->
loadBlock
(
size
);
animations
->
addFrame
(
ESquareAniHeader
,
blockData
,
size
);
animations
->
addFrame
(
ESquareAniHeader
,
blockData
,
size
);
}
}
break
;
break
;
...
@@ -477,11 +477,11 @@ void Scene::loadData (File *f) {
...
@@ -477,11 +477,11 @@ void Scene::loadData (File *f) {
LOG
(
"Data Type"
,
"Image"
);
LOG
(
"Data Type"
,
"Image"
);
LOG
(
"Data Type Image index"
,
loop
);
LOG
(
"Data Type Image index"
,
loop
);
unsigned
short
int
width
=
f
->
loadShort
();
// get width
unsigned
short
int
width
=
f
->
loadShort
(
SW
);
// get width
unsigned
short
int
height
;
unsigned
short
int
height
;
if
(
type
==
3
)
height
=
f
->
loadChar
();
// Get height
if
(
type
==
3
)
height
=
f
->
loadChar
();
// Get height
else
height
=
f
->
loadShort
();
// Get height
else
height
=
f
->
loadShort
(
SH
);
// Get height
f
->
seek
(
-
2
,
false
);
f
->
seek
(
-
2
,
false
);
images
=
new
SceneImage
(
images
);
images
=
new
SceneImage
(
images
);
...
@@ -520,7 +520,7 @@ void Scene::loadScripts (File *f) {
...
@@ -520,7 +520,7 @@ void Scene::loadScripts (File *f) {
int
textAlignment
=
0
;
int
textAlignment
=
0
;
int
textFont
=
0
;
int
textFont
=
0
;
int
textShadow
=
-
1
;
int
textShadow
=
-
1
;
for
(
loop
=
0
;
loop
<
scriptItems
;
loop
++
)
{
for
(
loop
=
0
;
loop
<
scriptItems
;
loop
++
)
{
LOG
(
"
\n
Parse Script"
,
loop
);
LOG
(
"
\n
Parse Script"
,
loop
);
...
@@ -563,12 +563,12 @@ void Scene::loadScripts (File *f) {
...
@@ -563,12 +563,12 @@ void Scene::loadScripts (File *f) {
case
ESceneAnimation
:
case
ESceneAnimation
:
{
{
pages
[
loop
].
animLoops
=
f
->
loadInt
();
pages
[
loop
].
animLoops
=
f
->
loadInt
();
pages
[
loop
].
animSpeed
=
f
->
loadShort
();
pages
[
loop
].
animSpeed
=
f
->
loadShort
();
pages
[
loop
].
animIndex
=
f
->
loadShort
();
pages
[
loop
].
animIndex
=
f
->
loadShort
();
LOG
(
"ESceneAnimation loops"
,
pages
[
loop
].
animLoops
);
LOG
(
"ESceneAnimation loops"
,
pages
[
loop
].
animLoops
);
LOG
(
"ESceneAnimation speed"
,
pages
[
loop
].
animSpeed
);
LOG
(
"ESceneAnimation speed"
,
pages
[
loop
].
animSpeed
);
LOG
(
"ESceneAnimation anim num"
,
pages
[
loop
].
animIndex
);
LOG
(
"ESceneAnimation anim num"
,
pages
[
loop
].
animIndex
);
}
}
break
;
break
;
...
@@ -584,7 +584,7 @@ void Scene::loadScripts (File *f) {
...
@@ -584,7 +584,7 @@ void Scene::loadScripts (File *f) {
{
{
unsigned
char
fadein
=
f
->
loadChar
();
unsigned
char
fadein
=
f
->
loadChar
();
LOG
(
"ESceneFadeType"
,
fadein
);
LOG
(
"ESceneFadeType"
,
fadein
);
}
}
...
@@ -742,7 +742,7 @@ void Scene::loadScripts (File *f) {
...
@@ -742,7 +742,7 @@ void Scene::loadScripts (File *f) {
f
->
loadChar
();
// Skip this value since shadows are turned off
f
->
loadChar
();
// Skip this value since shadows are turned off
textShadow
=
-
1
;
// Turn off shadow , -1 means no shadow colour
textShadow
=
-
1
;
// Turn off shadow , -1 means no shadow colour
}
}
LOG
(
"ESceneTextShadow"
,
textShadow
);
LOG
(
"ESceneTextShadow"
,
textShadow
);
}
}
...
@@ -828,7 +828,7 @@ void Scene::loadScripts (File *f) {
...
@@ -828,7 +828,7 @@ void Scene::loadScripts (File *f) {
text
->
alignment
=
textAlignment
;
text
->
alignment
=
textAlignment
;
text
->
fontId
=
textFont
;
text
->
fontId
=
textFont
;
text
->
shadowColour
=
textShadow
;
text
->
shadowColour
=
textShadow
;
if
(
textPosX
!=
-
1
)
{
if
(
textPosX
!=
-
1
)
{
text
->
x
=
textPosX
;
text
->
x
=
textPosX
;
...
...
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