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
6a0cbf3f
Commit
6a0cbf3f
authored
Apr 09, 2010
by
alistert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reverted to stdio.h due to portability issues. Created Video class. Refactored linked lists.
parent
4bca7986
Changes
39
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
872 additions
and
799 deletions
+872
-799
baselevel.cpp
src/baselevel.cpp
+8
-8
baselevel.h
src/baselevel.h
+1
-1
bonus.cpp
src/bonus/bonus.cpp
+14
-14
clientgame.cpp
src/game/clientgame.cpp
+9
-12
servergame.cpp
src/game/servergame.cpp
+5
-10
file.cpp
src/io/file.cpp
+93
-94
file.h
src/io/file.h
+3
-3
font.cpp
src/io/gfx/font.cpp
+1
-1
paletteeffects.cpp
src/io/gfx/paletteeffects.cpp
+57
-68
paletteeffects.h
src/io/gfx/paletteeffects.h
+34
-43
sprite.cpp
src/io/gfx/sprite.cpp
+1
-1
sprite.h
src/io/gfx/sprite.h
+5
-5
video.cpp
src/io/gfx/video.cpp
+187
-19
video.h
src/io/gfx/video.h
+57
-25
bullet.cpp
src/level/bullet.cpp
+37
-50
bullet.h
src/level/bullet.h
+13
-13
demolevel.cpp
src/level/demolevel.cpp
+2
-2
bridge.cpp
src/level/event/bridge.cpp
+10
-7
event.cpp
src/level/event/event.cpp
+25
-20
event.h
src/level/event/event.h
+25
-24
eventframe.cpp
src/level/event/eventframe.cpp
+40
-43
guardians.cpp
src/level/event/guardians.cpp
+12
-12
guardians.h
src/level/event/guardians.h
+4
-4
level.cpp
src/level/level.cpp
+12
-26
level.h
src/level/level.h
+46
-43
levelframe.cpp
src/level/levelframe.cpp
+13
-50
levelload.cpp
src/level/levelload.cpp
+18
-18
main.cpp
src/main.cpp
+47
-91
gamemenu.cpp
src/menu/gamemenu.cpp
+6
-6
mainmenu.cpp
src/menu/mainmenu.cpp
+3
-3
menuutil.cpp
src/menu/menuutil.cpp
+2
-2
setupmenu.cpp
src/menu/setupmenu.cpp
+15
-12
bird.cpp
src/player/bird.cpp
+9
-9
bird.h
src/player/bird.h
+12
-12
player.cpp
src/player/player.cpp
+3
-4
playerframe.cpp
src/player/playerframe.cpp
+1
-1
scene.cpp
src/scene/scene.cpp
+4
-4
sceneload.cpp
src/scene/sceneload.cpp
+1
-1
util.cpp
src/util.cpp
+37
-38
No files found.
src/baselevel.cpp
View file @
6a0cbf3f
...
@@ -93,7 +93,7 @@ void BaseLevel::timeCalcs () {
...
@@ -93,7 +93,7 @@ void BaseLevel::timeCalcs () {
}
}
void
BaseLevel
::
drawStats
(
int
stats
)
{
void
BaseLevel
::
drawStats
(
int
stats
,
unsigned
char
bg
)
{
int
count
,
width
;
int
count
,
width
;
...
@@ -102,20 +102,20 @@ void BaseLevel::drawStats (int stats) {
...
@@ -102,20 +102,20 @@ void BaseLevel::drawStats (int stats) {
if
(
stats
&
S_SCREEN
)
{
if
(
stats
&
S_SCREEN
)
{
#ifdef SCALE
#ifdef SCALE
if
(
scaleFactor
>
1
)
if
(
video
.
getScaleFactor
()
>
1
)
drawRect
(
canvasW
-
84
,
11
,
80
,
37
,
BLACK
);
drawRect
(
canvasW
-
84
,
11
,
80
,
37
,
bg
);
else
else
#endif
#endif
drawRect
(
canvasW
-
84
,
11
,
80
,
25
,
BLACK
);
drawRect
(
canvasW
-
84
,
11
,
80
,
25
,
bg
);
panelBigFont
->
showNumber
(
screenW
,
canvasW
-
52
,
14
);
panelBigFont
->
showNumber
(
video
.
getWidth
()
,
canvasW
-
52
,
14
);
panelBigFont
->
showString
(
"x"
,
canvasW
-
48
,
14
);
panelBigFont
->
showString
(
"x"
,
canvasW
-
48
,
14
);
panelBigFont
->
showNumber
(
screenH
,
canvasW
-
12
,
14
);
panelBigFont
->
showNumber
(
video
.
getHeight
()
,
canvasW
-
12
,
14
);
panelBigFont
->
showString
(
"fps"
,
canvasW
-
76
,
26
);
panelBigFont
->
showString
(
"fps"
,
canvasW
-
76
,
26
);
panelBigFont
->
showNumber
((
int
)
smoothfps
,
canvasW
-
12
,
26
);
panelBigFont
->
showNumber
((
int
)
smoothfps
,
canvasW
-
12
,
26
);
#ifdef SCALE
#ifdef SCALE
if
(
scaleFactor
>
1
)
{
if
(
video
.
getScaleFactor
()
>
1
)
{
panelBigFont
->
showNumber
(
canvasW
,
canvasW
-
52
,
38
);
panelBigFont
->
showNumber
(
canvasW
,
canvasW
-
52
,
38
);
panelBigFont
->
showString
(
"x"
,
canvasW
-
48
,
39
);
panelBigFont
->
showString
(
"x"
,
canvasW
-
48
,
39
);
...
@@ -136,7 +136,7 @@ void BaseLevel::drawStats (int stats) {
...
@@ -136,7 +136,7 @@ void BaseLevel::drawStats (int stats) {
if
(
panelBigFont
->
getStringWidth
(
players
[
count
].
getName
())
>
width
)
if
(
panelBigFont
->
getStringWidth
(
players
[
count
].
getName
())
>
width
)
width
=
panelBigFont
->
getStringWidth
(
players
[
count
].
getName
());
width
=
panelBigFont
->
getStringWidth
(
players
[
count
].
getName
());
drawRect
((
canvasW
>>
1
)
-
48
,
11
,
width
+
57
,
(
nPlayers
*
12
)
+
1
,
BLACK
);
drawRect
((
canvasW
>>
1
)
-
48
,
11
,
width
+
57
,
(
nPlayers
*
12
)
+
1
,
bg
);
for
(
count
=
0
;
count
<
nPlayers
;
count
++
)
{
for
(
count
=
0
;
count
<
nPlayers
;
count
++
)
{
...
...
src/baselevel.h
View file @
6a0cbf3f
...
@@ -68,7 +68,7 @@ class BaseLevel {
...
@@ -68,7 +68,7 @@ class BaseLevel {
LevelStage
stage
;
LevelStage
stage
;
void
timeCalcs
();
void
timeCalcs
();
void
drawStats
(
int
stats
);
void
drawStats
(
int
stats
,
unsigned
char
bg
);
public
:
public
:
BaseLevel
();
BaseLevel
();
...
...
src/bonus/bonus.cpp
View file @
6a0cbf3f
...
@@ -197,16 +197,16 @@ Bonus::Bonus (char * fileName, unsigned char diff) {
...
@@ -197,16 +197,16 @@ Bonus::Bonus (char * fileName, unsigned char diff) {
// Palette animations
// Palette animations
// Free any existing palette effects
// Free any existing palette effects
if
(
firstPE
)
delete
firstPE
;
if
(
paletteEffects
)
delete
paletteEffects
;
// Spinny whirly thing
// Spinny whirly thing
firstPE
=
new
RotatePaletteEffect
(
112
,
16
,
F32
,
NULL
);
paletteEffects
=
new
RotatePaletteEffect
(
112
,
16
,
F32
,
NULL
);
// Track sides
// Track sides
firstPE
=
new
RotatePaletteEffect
(
192
,
16
,
F32
,
firstPE
);
paletteEffects
=
new
RotatePaletteEffect
(
192
,
16
,
F32
,
paletteEffects
);
// Bouncy things
// Bouncy things
firstPE
=
new
RotatePaletteEffect
(
240
,
16
,
-
F32
,
firstPE
);
paletteEffects
=
new
RotatePaletteEffect
(
240
,
16
,
-
F32
,
paletteEffects
);
// Adjust fontsFont to use bonus level palette
// Adjust fontsFont to use bonus level palette
...
@@ -221,10 +221,10 @@ Bonus::Bonus (char * fileName, unsigned char diff) {
...
@@ -221,10 +221,10 @@ Bonus::Bonus (char * fileName, unsigned char diff) {
Bonus
::~
Bonus
()
{
Bonus
::~
Bonus
()
{
// Free the palette effects
// Free the palette effects
if
(
firstPE
)
{
if
(
paletteEffects
)
{
delete
firstPE
;
delete
paletteEffects
;
firstPE
=
NULL
;
paletteEffects
=
NULL
;
}
}
...
@@ -457,7 +457,7 @@ int Bonus::play () {
...
@@ -457,7 +457,7 @@ int Bonus::play () {
returnTime
=
0
;
returnTime
=
0
;
use
Palette
(
palette
);
video
.
set
Palette
(
palette
);
while
(
true
)
{
while
(
true
)
{
...
@@ -502,16 +502,16 @@ int Bonus::play () {
...
@@ -502,16 +502,16 @@ int Bonus::play () {
if
(
!
gameMode
)
{
if
(
!
gameMode
)
{
// Don't want palette effects in setup menu
// Don't want palette effects in setup menu
levelPE
=
firstPE
;
levelPE
=
paletteEffects
;
firstPE
=
NULL
;
paletteEffects
=
NULL
;
if
(
menu
->
setup
()
==
E_QUIT
)
return
E_QUIT
;
if
(
menu
->
setup
()
==
E_QUIT
)
return
E_QUIT
;
// Restore level palette
// Restore level palette
use
Palette
(
palette
);
video
.
set
Palette
(
palette
);
// Restore palette effects
// Restore palette effects
firstPE
=
levelPE
;
paletteEffects
=
levelPE
;
}
}
...
@@ -552,7 +552,7 @@ int Bonus::play () {
...
@@ -552,7 +552,7 @@ int Bonus::play () {
else
if
(
count
)
{
else
if
(
count
)
{
stage
=
LS_END
;
stage
=
LS_END
;
firstPE
=
new
WhiteOutPaletteEffect
(
T_BONUS_END
,
firstPE
);
paletteEffects
=
new
WhiteOutPaletteEffect
(
T_BONUS_END
,
paletteEffects
);
returnTime
=
ticks
+
T_BONUS_END
;
returnTime
=
ticks
+
T_BONUS_END
;
}
}
...
@@ -570,7 +570,7 @@ int Bonus::play () {
...
@@ -570,7 +570,7 @@ int Bonus::play () {
fontsFont
->
showString
(
"pause"
,
(
canvasW
>>
1
)
-
44
,
32
);
fontsFont
->
showString
(
"pause"
,
(
canvasW
>>
1
)
-
44
,
32
);
// Draw statistics
// Draw statistics
drawStats
(
stats
);
drawStats
(
stats
,
0
);
// Draw the menu
// Draw the menu
if
(
pmenu
)
{
if
(
pmenu
)
{
...
...
src/game/clientgame.cpp
View file @
6a0cbf3f
...
@@ -33,7 +33,6 @@
...
@@ -33,7 +33,6 @@
#include "menu/menu.h"
#include "menu/menu.h"
#include "player/player.h"
#include "player/player.h"
#include <iostream>
#include <string.h>
#include <string.h>
...
@@ -107,7 +106,7 @@ ClientGame::ClientGame (char* address) {
...
@@ -107,7 +106,7 @@ ClientGame::ClientGame (char* address) {
}
}
std
::
cout
<<
"Connected to server (version "
<<
int
(
buffer
[
2
])
<<
").
\n
"
;
printf
(
"Connected to server (version %d).
\n
"
,
buffer
[
2
]);
// Copy game parameters
// Copy game parameters
mode
=
GameModeType
(
buffer
[
3
]);
mode
=
GameModeType
(
buffer
[
3
]);
...
@@ -116,8 +115,7 @@ ClientGame::ClientGame (char* address) {
...
@@ -116,8 +115,7 @@ ClientGame::ClientGame (char* address) {
nPlayers
=
buffer
[
6
];
nPlayers
=
buffer
[
6
];
clientID
=
buffer
[
7
];
clientID
=
buffer
[
7
];
std
::
cout
<<
"Game mode "
<<
mode
<<
", difficulty "
<<
difficulty
<<
", "
<<
printf
(
"Game mode %d, difficulty %d, %d of %d players.
\n
"
,
mode
,
difficulty
,
nPlayers
,
maxPlayers
);
nPlayers
<<
" of "
<<
maxPlayers
<<
" players.
\n
"
;
if
(
nPlayers
>
maxPlayers
)
{
if
(
nPlayers
>
maxPlayers
)
{
...
@@ -249,14 +247,14 @@ int ClientGame::setLevel (char* fileName) {
...
@@ -249,14 +247,14 @@ int ClientGame::setLevel (char* fileName) {
int
ret
;
int
ret
;
// Free the palette effects
// Free the palette effects
if
(
firstPE
)
{
if
(
paletteEffects
)
{
delete
firstPE
;
delete
paletteEffects
;
firstPE
=
NULL
;
paletteEffects
=
NULL
;
}
}
use
Palette
(
menu
->
palettes
[
1
]);
video
.
set
Palette
(
menu
->
palettes
[
1
]);
// Wait for level data to start arriving
// Wait for level data to start arriving
while
(
!
file
&&
levelFile
)
{
while
(
!
file
&&
levelFile
)
{
...
@@ -398,7 +396,7 @@ int ClientGame::step (unsigned int ticks) {
...
@@ -398,7 +396,7 @@ int ClientGame::step (unsigned int ticks) {
if
((
recvBuffer
[
1
]
==
MT_G_PJOIN
)
&&
if
((
recvBuffer
[
1
]
==
MT_G_PJOIN
)
&&
(
recvBuffer
[
3
]
<
maxPlayers
))
{
(
recvBuffer
[
3
]
<
maxPlayers
))
{
std
::
cout
<<
"Player "
<<
int
(
recvBuffer
[
3
])
<<
" joined the game.
\n
"
;
printf
(
"Player %d joined the game.
\n
"
,
recvBuffer
[
3
]);
// Add the new player, and any that have been missed
// Add the new player, and any that have been missed
...
@@ -408,8 +406,7 @@ int ClientGame::step (unsigned int ticks) {
...
@@ -408,8 +406,7 @@ int ClientGame::step (unsigned int ticks) {
recvBuffer
+
5
,
recvBuffer
[
4
]);
recvBuffer
+
5
,
recvBuffer
[
4
]);
resetPlayer
(
players
+
count
,
false
);
resetPlayer
(
players
+
count
,
false
);
std
::
cout
<<
"Player "
<<
count
<<
" joined team "
<<
printf
(
"Player %d joined team %d.
\n
"
,
count
,
recvBuffer
[
4
]);
recvBuffer
[
4
]
<<
".
\n
"
;
}
}
...
@@ -423,7 +420,7 @@ int ClientGame::step (unsigned int ticks) {
...
@@ -423,7 +420,7 @@ int ClientGame::step (unsigned int ticks) {
if
((
recvBuffer
[
1
]
==
MT_G_PQUIT
)
&&
if
((
recvBuffer
[
1
]
==
MT_G_PQUIT
)
&&
(
recvBuffer
[
2
]
<
nPlayers
))
{
(
recvBuffer
[
2
]
<
nPlayers
))
{
std
::
cout
<<
"Player "
<<
int
(
recvBuffer
[
2
])
<<
" left the game.
\n
"
;
printf
(
"Player %d left the game.
\n
"
,
recvBuffer
[
2
]);
// Remove the player
// Remove the player
...
...
src/game/servergame.cpp
View file @
6a0cbf3f
...
@@ -32,7 +32,6 @@
...
@@ -32,7 +32,6 @@
#include "level/level.h"
#include "level/level.h"
#include "player/player.h"
#include "player/player.h"
#include <iostream>
#include <string.h>
#include <string.h>
...
@@ -248,8 +247,7 @@ int ServerGame::step (unsigned int ticks) {
...
@@ -248,8 +247,7 @@ int ServerGame::step (unsigned int ticks) {
if
((
recvBuffers
[
count
][
1
]
==
MT_G_PJOIN
)
&&
if
((
recvBuffers
[
count
][
1
]
==
MT_G_PJOIN
)
&&
(
clientPlayer
[
count
]
==
-
1
))
{
(
clientPlayer
[
count
]
==
-
1
))
{
std
::
cout
<<
"Player "
<<
nPlayers
<<
" (client "
<<
printf
(
"Player %d (client %d) joined the game.
\n
"
,
nPlayers
,
count
);
count
<<
") joined the game.
\n
"
;
// Set up the new player
// Set up the new player
...
@@ -261,8 +259,7 @@ int ServerGame::step (unsigned int ticks) {
...
@@ -261,8 +259,7 @@ int ServerGame::step (unsigned int ticks) {
recvBuffers
[
count
][
4
]);
recvBuffers
[
count
][
4
]);
players
[
nPlayers
].
reset
();
players
[
nPlayers
].
reset
();
std
::
cout
<<
"Player "
<<
nPlayers
<<
" joined team "
<<
printf
(
"Player %d joined team %d.
\n
"
,
nPlayers
,
recvBuffers
[
count
][
4
]);
recvBuffers
[
count
][
4
]
<<
".
\n
"
;
recvBuffers
[
count
][
3
]
=
clientPlayer
[
count
]
=
recvBuffers
[
count
][
3
]
=
clientPlayer
[
count
]
=
nPlayers
;
nPlayers
;
...
@@ -330,7 +327,7 @@ int ServerGame::step (unsigned int ticks) {
...
@@ -330,7 +327,7 @@ int ServerGame::step (unsigned int ticks) {
if
(
clientSock
[
count
]
!=
-
1
)
{
if
(
clientSock
[
count
]
!=
-
1
)
{
std
::
cout
<<
"Client "
<<
count
<<
" connected.
\n
"
;
printf
(
"Client %d connected.
\n
"
,
count
);
clientPlayer
[
count
]
=
-
1
;
clientPlayer
[
count
]
=
-
1
;
received
[
count
]
=
0
;
received
[
count
]
=
0
;
...
@@ -385,8 +382,7 @@ int ServerGame::step (unsigned int ticks) {
...
@@ -385,8 +382,7 @@ int ServerGame::step (unsigned int ticks) {
if
(
!
(
net
->
isConnected
(
clientSock
[
count
])))
{
if
(
!
(
net
->
isConnected
(
clientSock
[
count
])))
{
std
::
cout
<<
"Client "
<<
count
<<
" disconnected (code: "
<<
printf
(
"Client %d disconnected (code: %d).
\n
"
,
count
,
net
->
getError
());
net
->
getError
()
<<
").
\n
"
;
// Disconnect client
// Disconnect client
net
->
close
(
clientSock
[
count
]);
net
->
close
(
clientSock
[
count
]);
...
@@ -396,8 +392,7 @@ int ServerGame::step (unsigned int ticks) {
...
@@ -396,8 +392,7 @@ int ServerGame::step (unsigned int ticks) {
// Remove the client's player
// Remove the client's player
std
::
cout
<<
"Player "
<<
clientPlayer
[
count
]
<<
printf
(
"Player %d (client %d) left the game.
\n
"
,
clientPlayer
[
count
],
count
);
" (client "
<<
count
<<
") left the game.
\n
"
;
nPlayers
--
;
nPlayers
--
;
...
...
src/io/file.cpp
View file @
6a0cbf3f
...
@@ -49,7 +49,7 @@ File::File (const char* name, bool write) {
...
@@ -49,7 +49,7 @@ File::File (const char* name, bool write) {
File
::~
File
()
{
File
::~
File
()
{
stream
.
close
(
);
fclose
(
file
);
#ifdef VERBOSE
#ifdef VERBOSE
log
(
"Closed file"
,
filePath
);
log
(
"Closed file"
,
filePath
);
...
@@ -68,10 +68,9 @@ bool File::open (const char* path, const char* name, bool write) {
...
@@ -68,10 +68,9 @@ bool File::open (const char* path, const char* name, bool write) {
filePath
=
createString
(
path
,
name
);
filePath
=
createString
(
path
,
name
);
// Open the file from the path
// Open the file from the path
stream
.
clear
();
file
=
fopen
(
filePath
,
write
?
"wb"
:
"rb"
);
stream
.
open
(
filePath
,
(
write
?
std
::
ios
::
out
:
std
::
ios
::
in
)
|
std
::
ios
::
binary
);
if
(
stream
.
is_open
()
&&
stream
.
good
()
)
{
if
(
file
)
{
#ifdef VERBOSE
#ifdef VERBOSE
log
(
"Opened file"
,
filePath
);
log
(
"Opened file"
,
filePath
);
...
@@ -89,30 +88,30 @@ bool File::open (const char* path, const char* name, bool write) {
...
@@ -89,30 +88,30 @@ bool File::open (const char* path, const char* name, bool write) {
int
File
::
getSize
()
{
int
File
::
getSize
()
{
int
pos
,
size
;
pos
=
stream
.
tellg
();
stream
.
seekg
(
0
,
std
::
ios
::
end
);
int
pos
,
size
;
size
=
stream
.
tellg
();
pos
=
ftell
(
file
);
stream
.
seekg
(
pos
,
std
::
ios
::
beg
);
fseek
(
file
,
0
,
SEEK_END
);
size
=
ftell
(
file
);
fseek
(
file
,
pos
,
SEEK_SET
);
return
size
;
return
size
;
}
}
int
File
::
tell
()
{
int
File
::
tell
()
{
return
stream
.
tellg
(
);
return
ftell
(
file
);
}
}
void
File
::
seek
(
int
offset
,
bool
reset
)
{
void
File
::
seek
(
int
offset
,
bool
reset
)
{
stream
.
seekg
(
offset
,
reset
?
std
::
ios
::
beg
:
std
::
ios
::
cur
);
fseek
(
file
,
offset
,
reset
?
SEEK_SET
:
SEEK_CUR
);
return
;
return
;
...
@@ -120,14 +119,14 @@ void File::seek (int offset, bool reset) {
...
@@ -120,14 +119,14 @@ void File::seek (int offset, bool reset) {
unsigned
char
File
::
loadChar
()
{
unsigned
char
File
::
loadChar
()
{
return
stream
.
get
(
);
return
fgetc
(
file
);
}
}
void
File
::
storeChar
(
unsigned
char
val
)
{
void
File
::
storeChar
(
unsigned
char
val
)
{
stream
.
put
(
val
);
fputc
(
val
,
file
);
return
;
return
;
...
@@ -138,8 +137,8 @@ unsigned short int File::loadShort () {
...
@@ -138,8 +137,8 @@ unsigned short int File::loadShort () {
unsigned
short
int
val
;
unsigned
short
int
val
;
val
=
stream
.
get
();
val
=
fgetc
(
file
);
val
+=
stream
.
get
()
<<
8
;
val
+=
fgetc
(
file
)
<<
8
;
return
val
;
return
val
;
...
@@ -148,22 +147,22 @@ unsigned short int File::loadShort () {
...
@@ -148,22 +147,22 @@ unsigned short int File::loadShort () {
void
File
::
storeShort
(
unsigned
short
int
val
)
{
void
File
::
storeShort
(
unsigned
short
int
val
)
{
stream
.
put
(
val
&
255
);
fputc
(
val
&
255
,
file
);
stream
.
put
(
val
>>
8
);
fputc
(
val
>>
8
,
file
);
return
;
return
;
}
}
signed
long
int
File
::
loadInt
()
{
signed
long
int
File
::
loadInt
()
{
unsigned
long
int
val
;
unsigned
long
int
val
;
val
=
stream
.
get
();
val
=
fgetc
(
file
);
val
+=
stream
.
get
()
<<
8
;
val
+=
fgetc
(
file
)
<<
8
;
val
+=
stream
.
get
()
<<
16
;
val
+=
fgetc
(
file
)
<<
16
;
val
+=
stream
.
get
()
<<
24
;
val
+=
fgetc
(
file
)
<<
24
;
return
*
((
signed
long
int
*
)
&
val
);
return
*
((
signed
long
int
*
)
&
val
);
...
@@ -176,23 +175,23 @@ void File::storeInt (signed long int val) {
...
@@ -176,23 +175,23 @@ void File::storeInt (signed long int val) {
uval
=
*
((
unsigned
long
int
*
)
&
val
);
uval
=
*
((
unsigned
long
int
*
)
&
val
);
stream
.
put
(
uval
&
255
);
fputc
(
uval
&
255
,
file
);
stream
.
put
((
uval
>>
8
)
&
255
);
fputc
((
uval
>>
8
)
&
255
,
file
);
stream
.
put
((
uval
>>
16
)
&
255
);
fputc
((
uval
>>
16
)
&
255
,
file
);
stream
.
put
(
uval
>>
24
);
fputc
(
uval
>>
24
,
file
);
return
;
return
;
}
}
unsigned
char
*
File
::
loadBlock
(
int
length
)
{
unsigned
char
*
File
::
loadBlock
(
int
length
)
{
unsigned
char
*
buffer
;
unsigned
char
*
buffer
;
buffer
=
new
unsigned
char
[
length
];
buffer
=
new
unsigned
char
[
length
];
stream
.
read
((
char
*
)
buffer
,
length
);
fread
(
buffer
,
1
,
length
,
file
);
return
buffer
;
return
buffer
;
...
@@ -205,9 +204,9 @@ unsigned char* File::loadRLE (int length) {
...
@@ -205,9 +204,9 @@ unsigned char* File::loadRLE (int length) {
int
rle
,
pos
,
byte
,
count
,
next
;
int
rle
,
pos
,
byte
,
count
,
next
;
// Determine the offset that follows the block
// Determine the offset that follows the block
next
=
stream
.
get
();
next
=
fgetc
(
file
);
next
+=
stream
.
get
()
<<
8
;
next
+=
fgetc
(
file
)
<<
8
;
next
+=
stream
.
tellg
();
next
+=
ftell
(
file
);
buffer
=
new
unsigned
char
[
length
];
buffer
=
new
unsigned
char
[
length
];
...
@@ -215,11 +214,11 @@ unsigned char* File::loadRLE (int length) {
...
@@ -215,11 +214,11 @@ unsigned char* File::loadRLE (int length) {
while
(
pos
<
length
)
{
while
(
pos
<
length
)
{
rle
=
stream
.
get
(
);
rle
=
fgetc
(
file
);
if
(
rle
&
128
)
{
if
(
rle
&
128
)
{
byte
=
stream
.
get
(
);
byte
=
fgetc
(
file
);
for
(
count
=
0
;
count
<
(
rle
&
127
);
count
++
)
{
for
(
count
=
0
;
count
<
(
rle
&
127
);
count
++
)
{
...
@@ -232,16 +231,16 @@ unsigned char* File::loadRLE (int length) {
...
@@ -232,16 +231,16 @@ unsigned char* File::loadRLE (int length) {
for
(
count
=
0
;
count
<
rle
;
count
++
)
{
for
(
count
=
0
;
count
<
rle
;
count
++
)
{
buffer
[
pos
++
]
=
stream
.
get
(
);
buffer
[
pos
++
]
=
fgetc
(
file
);
if
(
pos
>=
length
)
break
;
if
(
pos
>=
length
)
break
;
}
}
}
else
buffer
[
pos
++
]
=
stream
.
get
(
);
}
else
buffer
[
pos
++
]
=
fgetc
(
file
);
}
}
stream
.
seekg
(
next
,
std
::
ios
::
beg
);
fseek
(
file
,
next
,
SEEK_SET
);
return
buffer
;
return
buffer
;
...
@@ -252,42 +251,42 @@ void File::skipRLE () {
...
@@ -252,42 +251,42 @@ void File::skipRLE () {
int
next
;
int
next
;
next
=
stream
.
get
();
next
=
fgetc
(
file
);
next
+=
stream
.
get
()
<<
8
;
next
+=
fgetc
(
file
)
<<
8
;
stream
.
seekg
(
next
,
std
::
ios
::
cur
);
return
;
}
char
*
File
::
loadString
()
{
char
*
string
;
int
length
,
count
;
length
=
stream
.
get
();
if
(
length
)
{
string
=
new
char
[
length
+
1
];
stream
.
read
(
string
,
length
);
}
else
{
// If the length is not given, assume it is an 8.3 file name
string
=
new
char
[
13
];
for
(
count
=
0
;
count
<
9
;
count
++
)
{
fseek
(
file
,
next
,
SEEK_CUR
);
string
[
count
]
=
stream
.
get
();
return
;
}
char
*
File
::
loadString
()
{
char
*
string
;
int
length
,
count
;
length
=
fgetc
(
file
);
if
(
length
)
{
string
=
new
char
[
length
+
1
];
fread
(
string
,
1
,
length
,
file
);
}
else
{
// If the length is not given, assume it is an 8.3 file name
string
=
new
char
[
13
];
for
(
count
=
0
;
count
<
9
;
count
++
)
{
string
[
count
]
=
fgetc
(
file
);
if
(
string
[
count
]
==
'.'
)
{
if
(
string
[
count
]
==
'.'
)
{
string
[
++
count
]
=
stream
.
get
(
);
string
[
++
count
]
=
fgetc
(
file
);
string
[
++
count
]
=
stream
.
get
(
);
string
[
++
count
]
=
fgetc
(
file
);
string
[
++
count
]
=
stream
.
get
(
);
string
[
++
count
]
=
fgetc
(
file
);
count
++
;
count
++
;
break
;
break
;
...
...
src/io/file.h
View file @
6a0cbf3f
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#include "OpenJazz.h"
#include "OpenJazz.h"
#include <SDL/SDL.h>
#include <SDL/SDL.h>
#include <
fstream
>
#include <
stdio.h
>
// Classes
// Classes
...
@@ -35,8 +35,8 @@
...
@@ -35,8 +35,8 @@
class
File
{
class
File
{
private
:
private
:
std
::
fstream
stream
;
FILE
*
file
;
char
*
filePath
;
char
*
filePath
;
bool
open
(
const
char
*
path
,
const
char
*
name
,
bool
write
);
bool
open
(
const
char
*
path
,
const
char
*
name
,
bool
write
);
...
...
src/io/gfx/font.cpp
View file @
6a0cbf3f
...
@@ -478,7 +478,7 @@ void Font::restorePalette () {
...
@@ -478,7 +478,7 @@ void Font::restorePalette () {
int
count
;
int
count
;
for
(
count
=
0
;
count
<
nCharacters
;
count
++
)
for
(
count
=
0
;
count
<
nCharacters
;
count
++
)
::
restor
ePalette
(
characters
[
count
]);
video
.
restoreSurfac
ePalette
(
characters
[
count
]);
return
;
return
;
...
...
src/io/gfx/paletteeffects.cpp
View file @
6a0cbf3f
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#include <string.h>
#include <string.h>
PaletteEffect
::
PaletteEffect
(
PaletteEffect
*
nextPE
)
{
PaletteEffect
::
PaletteEffect
(
PaletteEffect
*
nextPE
)
{
next
=
nextPE
;
next
=
nextPE
;
...
@@ -48,7 +48,7 @@ PaletteEffect::~PaletteEffect () {
...
@@ -48,7 +48,7 @@ PaletteEffect::~PaletteEffect () {
}
}
void
PaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
)
{
void
PaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
)
{
// Apply the next palette effect
// Apply the next palette effect
if
(
next
)
next
->
apply
(
shownPalette
,
direct
,
mspf
);
if
(
next
)
next
->
apply
(
shownPalette
,
direct
,
mspf
);
...
@@ -58,8 +58,8 @@ void PaletteEffect::apply (SDL_Color *shownPalette, bool direct, int mspf) {
...
@@ -58,8 +58,8 @@ void PaletteEffect::apply (SDL_Color *shownPalette, bool direct, int mspf) {
}
}
WhiteInPaletteEffect
::
WhiteInPaletteEffect
(
fixed
newDuration
,
WhiteInPaletteEffect
::
WhiteInPaletteEffect
PaletteEffect
*
nextPE
)
:
PaletteEffect
(
nextPE
)
{
(
fixed
newDuration
,
PaletteEffect
*
nextPE
)
:
PaletteEffect
(
nextPE
)
{
duration
=
newDuration
;
duration
=
newDuration
;
whiteness
=
F1
+
FH
;
whiteness
=
F1
+
FH
;
...
@@ -69,8 +69,7 @@ WhiteInPaletteEffect::WhiteInPaletteEffect (fixed newDuration,
...
@@ -69,8 +69,7 @@ WhiteInPaletteEffect::WhiteInPaletteEffect (fixed newDuration,
}
}
void
WhiteInPaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
void
WhiteInPaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
)
{
int
mspf
)
{
int
count
;
int
count
;
...
@@ -101,16 +100,15 @@ void WhiteInPaletteEffect::apply (SDL_Color *shownPalette, bool direct,
...
@@ -101,16 +100,15 @@ void WhiteInPaletteEffect::apply (SDL_Color *shownPalette, bool direct,
}
}
if
(
direct
)
if
(
direct
)
video
.
changePalette
(
shownPalette
,
0
,
256
);
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
shownPalette
,
0
,
256
);
return
;
return
;
}
}
FadeInPaletteEffect
::
FadeInPaletteEffect
(
int
newDuration
,
FadeInPaletteEffect
::
FadeInPaletteEffect
PaletteEffect
*
nextPE
)
:
PaletteEffect
(
nextPE
)
{
(
int
newDuration
,
PaletteEffect
*
nextPE
)
:
PaletteEffect
(
nextPE
)
{
duration
=
newDuration
;
duration
=
newDuration
;
blackness
=
F1
+
FH
;
blackness
=
F1
+
FH
;
...
@@ -120,8 +118,7 @@ FadeInPaletteEffect::FadeInPaletteEffect (int newDuration,
...
@@ -120,8 +118,7 @@ FadeInPaletteEffect::FadeInPaletteEffect (int newDuration,
}
}
void
FadeInPaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
void
FadeInPaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
)
{
int
mspf
)
{
int
count
;
int
count
;
...
@@ -152,16 +149,15 @@ void FadeInPaletteEffect::apply (SDL_Color *shownPalette, bool direct,
...
@@ -152,16 +149,15 @@ void FadeInPaletteEffect::apply (SDL_Color *shownPalette, bool direct,
}
}
if
(
direct
)
if
(
direct
)
video
.
changePalette
(
shownPalette
,
0
,
256
);
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
shownPalette
,
0
,
256
);
return
;
return
;
}
}
WhiteOutPaletteEffect
::
WhiteOutPaletteEffect
(
int
newDuration
,
WhiteOutPaletteEffect
::
WhiteOutPaletteEffect
PaletteEffect
*
nextPE
)
:
PaletteEffect
(
nextPE
)
{
(
int
newDuration
,
PaletteEffect
*
nextPE
)
:
PaletteEffect
(
nextPE
)
{
duration
=
newDuration
;
duration
=
newDuration
;
whiteness
=
0
;
whiteness
=
0
;
...
@@ -171,8 +167,7 @@ WhiteOutPaletteEffect::WhiteOutPaletteEffect (int newDuration,
...
@@ -171,8 +167,7 @@ WhiteOutPaletteEffect::WhiteOutPaletteEffect (int newDuration,
}
}
void
WhiteOutPaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
void
WhiteOutPaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
)
{
int
mspf
)
{
int
count
;
int
count
;
...
@@ -201,16 +196,15 @@ void WhiteOutPaletteEffect::apply (SDL_Color *shownPalette, bool direct,
...
@@ -201,16 +196,15 @@ void WhiteOutPaletteEffect::apply (SDL_Color *shownPalette, bool direct,
}
else
whiteness
+=
ITOF
(
mspf
)
/
duration
;
}
else
whiteness
+=
ITOF
(
mspf
)
/
duration
;
if
(
direct
)
if
(
direct
)
video
.
changePalette
(
shownPalette
,
0
,
256
);
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
shownPalette
,
0
,
256
);
return
;
return
;
}
}
FadeOutPaletteEffect
::
FadeOutPaletteEffect
(
int
newDuration
,
FadeOutPaletteEffect
::
FadeOutPaletteEffect
PaletteEffect
*
nextPE
)
:
PaletteEffect
(
nextPE
)
{
(
int
newDuration
,
PaletteEffect
*
nextPE
)
:
PaletteEffect
(
nextPE
)
{
duration
=
newDuration
;
duration
=
newDuration
;
blackness
=
-
(
F2
+
F1
);
blackness
=
-
(
F2
+
F1
);
...
@@ -220,8 +214,7 @@ FadeOutPaletteEffect::FadeOutPaletteEffect (int newDuration,
...
@@ -220,8 +214,7 @@ FadeOutPaletteEffect::FadeOutPaletteEffect (int newDuration,
}
}
void
FadeOutPaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
void
FadeOutPaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
)
{
int
mspf
)
{
int
count
;
int
count
;
...
@@ -249,17 +242,17 @@ void FadeOutPaletteEffect::apply (SDL_Color *shownPalette, bool direct,
...
@@ -249,17 +242,17 @@ void FadeOutPaletteEffect::apply (SDL_Color *shownPalette, bool direct,
}
else
blackness
+=
ITOF
(
mspf
)
/
duration
;
}
else
blackness
+=
ITOF
(
mspf
)
/
duration
;
if
(
direct
)
if
(
direct
)
video
.
changePalette
(
shownPalette
,
0
,
256
);
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
shownPalette
,
0
,
256
);
return
;
return
;
}
}
FlashPaletteEffect
::
FlashPaletteEffect
(
unsigned
char
newRed
,
FlashPaletteEffect
::
FlashPaletteEffect
unsigned
char
newGreen
,
unsigned
char
newBlue
,
int
newDuration
,
(
unsigned
char
newRed
,
unsigned
char
newGreen
,
unsigned
char
newBlue
,
PaletteEffect
*
nextPE
)
:
PaletteEffect
(
nextPE
)
{
int
newDuration
,
PaletteEffect
*
nextPE
)
:
PaletteEffect
(
nextPE
)
{
duration
=
newDuration
;
duration
=
newDuration
;
progress
=
-
F1
;
progress
=
-
F1
;
...
@@ -272,8 +265,7 @@ FlashPaletteEffect::FlashPaletteEffect (unsigned char newRed,
...
@@ -272,8 +265,7 @@ FlashPaletteEffect::FlashPaletteEffect (unsigned char newRed,
}
}
void
FlashPaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
void
FlashPaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
)
{
int
mspf
)
{
int
count
;
int
count
;
...
@@ -312,16 +304,15 @@ void FlashPaletteEffect::apply (SDL_Color *shownPalette, bool direct,
...
@@ -312,16 +304,15 @@ void FlashPaletteEffect::apply (SDL_Color *shownPalette, bool direct,
}
}
if
(
direct
)
if
(
direct
)
video
.
changePalette
(
shownPalette
,
0
,
256
);
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
shownPalette
,
0
,
256
);
return
;
return
;
}
}
RotatePaletteEffect
::
RotatePaletteEffect
(
unsigned
char
newFirst
,
RotatePaletteEffect
::
RotatePaletteEffect
int
newAmount
,
fixed
newSpeed
,
PaletteEffect
*
nextPE
)
:
(
unsigned
char
newFirst
,
int
newAmount
,
fixed
newSpeed
,
PaletteEffect
*
nextPE
)
:
PaletteEffect
(
nextPE
)
{
PaletteEffect
(
nextPE
)
{
first
=
newFirst
;
first
=
newFirst
;
...
@@ -334,14 +325,16 @@ RotatePaletteEffect::RotatePaletteEffect (unsigned char newFirst,
...
@@ -334,14 +325,16 @@ RotatePaletteEffect::RotatePaletteEffect (unsigned char newFirst,
}
}
void
RotatePaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
void
RotatePaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
)
{
int
mspf
)
{
SDL_Color
*
currentPalette
;
int
count
;
int
count
;
// Apply the next palette effect
// Apply the next palette effect
if
(
next
)
next
->
apply
(
shownPalette
,
direct
,
mspf
);
if
(
next
)
next
->
apply
(
shownPalette
,
direct
,
mspf
);
currentPalette
=
video
.
getPalette
();
for
(
count
=
0
;
count
<
amount
;
count
++
)
{
for
(
count
=
0
;
count
<
amount
;
count
++
)
{
...
@@ -354,18 +347,17 @@ void RotatePaletteEffect::apply (SDL_Color *shownPalette, bool direct,
...
@@ -354,18 +347,17 @@ void RotatePaletteEffect::apply (SDL_Color *shownPalette, bool direct,
position
-=
(
mspf
*
speed
)
>>
10
;
position
-=
(
mspf
*
speed
)
>>
10
;
while
(
position
<
0
)
position
+=
ITOF
(
amount
);
while
(
position
<
0
)
position
+=
ITOF
(
amount
);
if
(
direct
)
if
(
direct
)
video
.
changePalette
(
shownPalette
+
first
,
first
,
amount
);
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
shownPalette
+
first
,
first
,
amount
);
return
;
return
;
}
}
SkyPaletteEffect
::
SkyPaletteEffect
(
unsigned
char
newFirst
,
SkyPaletteEffect
::
SkyPaletteEffect
int
newAmount
,
fixed
newSpeed
,
SDL_Color
*
newSkyPalette
,
(
unsigned
char
newFirst
,
int
newAmount
,
fixed
newSpeed
,
PaletteEffect
*
nextPE
)
:
PaletteEffect
(
nextPE
)
{
SDL_Color
*
newSkyPalette
,
PaletteEffect
*
nextPE
)
:
PaletteEffect
(
nextPE
)
{
skyPalette
=
newSkyPalette
;
skyPalette
=
newSkyPalette
;
first
=
newFirst
;
first
=
newFirst
;
...
@@ -377,7 +369,7 @@ SkyPaletteEffect::SkyPaletteEffect (unsigned char newFirst,
...
@@ -377,7 +369,7 @@ SkyPaletteEffect::SkyPaletteEffect (unsigned char newFirst,
}
}
void
SkyPaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
)
{
void
SkyPaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
)
{
int
position
,
count
,
y
;
int
position
,
count
,
y
;
...
@@ -396,15 +388,12 @@ void SkyPaletteEffect::apply (SDL_Color *shownPalette, bool direct, int mspf) {
...
@@ -396,15 +388,12 @@ void SkyPaletteEffect::apply (SDL_Color *shownPalette, bool direct, int mspf) {
if
(
count
>
255
-
amount
)
{
if
(
count
>
255
-
amount
)
{
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
skyPalette
+
count
,
first
,
video
.
changePalette
(
skyPalette
+
count
,
first
,
255
-
count
);
255
-
count
);
video
.
changePalette
(
skyPalette
,
first
+
(
255
-
count
),
count
+
amount
-
255
);
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
skyPalette
,
first
+
(
255
-
count
),
count
+
amount
-
255
);
}
else
{
}
else
{
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
skyPalette
+
count
,
video
.
changePalette
(
skyPalette
+
count
,
first
,
amount
);
first
,
amount
);
}
}
...
@@ -431,8 +420,8 @@ void SkyPaletteEffect::apply (SDL_Color *shownPalette, bool direct, int mspf) {
...
@@ -431,8 +420,8 @@ void SkyPaletteEffect::apply (SDL_Color *shownPalette, bool direct, int mspf) {
}
}
P2DPaletteEffect
::
P2DPaletteEffect
(
unsigned
char
newFirst
,
P2DPaletteEffect
::
P2DPaletteEffect
int
newAmount
,
fixed
newSpeed
,
PaletteEffect
*
nextPE
)
:
(
unsigned
char
newFirst
,
int
newAmount
,
fixed
newSpeed
,
PaletteEffect
*
nextPE
)
:
PaletteEffect
(
nextPE
)
{
PaletteEffect
(
nextPE
)
{
first
=
newFirst
;
first
=
newFirst
;
...
@@ -444,14 +433,16 @@ P2DPaletteEffect::P2DPaletteEffect (unsigned char newFirst,
...
@@ -444,14 +433,16 @@ P2DPaletteEffect::P2DPaletteEffect (unsigned char newFirst,
}
}
void
P2DPaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
)
{
void
P2DPaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
)
{
SDL_Color
*
currentPalette
;
int
count
,
x
,
y
,
j
;
int
count
,
x
,
y
,
j
;
// Apply the next palette effect
// Apply the next palette effect
if
(
next
)
next
->
apply
(
shownPalette
,
direct
,
mspf
);
if
(
next
)
next
->
apply
(
shownPalette
,
direct
,
mspf
);
currentPalette
=
video
.
getPalette
();
x
=
FTOI
(((
256
*
32
)
-
FTOI
(
viewX
))
*
speed
);
x
=
FTOI
(((
256
*
32
)
-
FTOI
(
viewX
))
*
speed
);
y
=
FTOI
(((
64
*
32
)
-
FTOI
(
viewY
))
*
speed
);
y
=
FTOI
(((
64
*
32
)
-
FTOI
(
viewY
))
*
speed
);
...
@@ -467,17 +458,15 @@ void P2DPaletteEffect::apply (SDL_Color *shownPalette, bool direct, int mspf) {
...
@@ -467,17 +458,15 @@ void P2DPaletteEffect::apply (SDL_Color *shownPalette, bool direct, int mspf) {
}
}
if
(
direct
)
if
(
direct
)
video
.
changePalette
(
shownPalette
+
first
,
first
,
amount
);
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
shownPalette
+
first
,
first
,
amount
);
return
;
return
;
}
}
P1DPaletteEffect
::
P1DPaletteEffect
(
unsigned
char
newFirst
,
P1DPaletteEffect
::
P1DPaletteEffect
int
newAmount
,
fixed
newSpeed
,
PaletteEffect
*
nextPE
)
:
(
unsigned
char
newFirst
,
int
newAmount
,
fixed
newSpeed
,
PaletteEffect
*
nextPE
)
:
PaletteEffect
(
nextPE
)
{
PaletteEffect
(
nextPE
)
{
first
=
newFirst
;
first
=
newFirst
;
...
@@ -489,8 +478,9 @@ P1DPaletteEffect::P1DPaletteEffect (unsigned char newFirst,
...
@@ -489,8 +478,9 @@ P1DPaletteEffect::P1DPaletteEffect (unsigned char newFirst,
}
}
void
P1DPaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
)
{
void
P1DPaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
)
{
SDL_Color
*
currentPalette
;
fixed
position
;
fixed
position
;
int
count
;
int
count
;
...
@@ -498,6 +488,7 @@ void P1DPaletteEffect::apply (SDL_Color *shownPalette, bool direct, int mspf) {
...
@@ -498,6 +488,7 @@ void P1DPaletteEffect::apply (SDL_Color *shownPalette, bool direct, int mspf) {
if
(
next
)
next
->
apply
(
shownPalette
,
direct
,
mspf
);
if
(
next
)
next
->
apply
(
shownPalette
,
direct
,
mspf
);
currentPalette
=
video
.
getPalette
();
position
=
viewX
+
viewY
;
position
=
viewX
+
viewY
;
for
(
count
=
0
;
count
<
amount
;
count
++
)
{
for
(
count
=
0
;
count
<
amount
;
count
++
)
{
...
@@ -509,16 +500,14 @@ void P1DPaletteEffect::apply (SDL_Color *shownPalette, bool direct, int mspf) {
...
@@ -509,16 +500,14 @@ void P1DPaletteEffect::apply (SDL_Color *shownPalette, bool direct, int mspf) {
}
}
if
(
direct
)
if
(
direct
)
video
.
changePalette
(
shownPalette
+
first
,
first
,
amount
);
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
shownPalette
+
first
,
first
,
amount
);
return
;
return
;
}
}
WaterPaletteEffect
::
WaterPaletteEffect
(
fixed
newDepth
,
PaletteEffect
*
nextPE
)
WaterPaletteEffect
::
WaterPaletteEffect
(
fixed
newDepth
,
PaletteEffect
*
nextPE
)
:
PaletteEffect
(
nextPE
)
{
:
PaletteEffect
(
nextPE
)
{
depth
=
newDepth
;
depth
=
newDepth
;
...
@@ -528,15 +517,16 @@ WaterPaletteEffect::WaterPaletteEffect (fixed newDepth, PaletteEffect * nextPE)
...
@@ -528,15 +517,16 @@ WaterPaletteEffect::WaterPaletteEffect (fixed newDepth, PaletteEffect * nextPE)
}
}
void
WaterPaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
void
WaterPaletteEffect
::
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
)
{
int
mspf
)
{
SDL_Color
*
currentPalette
;
int
position
,
count
;
int
position
,
count
;
// Apply the next palette effect
// Apply the next palette effect
if
(
next
)
next
->
apply
(
shownPalette
,
direct
,
mspf
);
if
(
next
)
next
->
apply
(
shownPalette
,
direct
,
mspf
);
currentPalette
=
video
.
getPalette
();
position
=
localPlayer
->
getY
()
-
level
->
getWaterLevel
();
position
=
localPlayer
->
getY
()
-
level
->
getWaterLevel
();
if
(
position
<=
0
)
return
;
if
(
position
<=
0
)
return
;
...
@@ -556,8 +546,7 @@ void WaterPaletteEffect::apply (SDL_Color *shownPalette, bool direct,
...
@@ -556,8 +546,7 @@ void WaterPaletteEffect::apply (SDL_Color *shownPalette, bool direct,
}
else
memset
(
shownPalette
,
0
,
sizeof
(
SDL_Color
)
*
256
);
}
else
memset
(
shownPalette
,
0
,
sizeof
(
SDL_Color
)
*
256
);
if
(
direct
)
if
(
direct
)
video
.
changePalette
(
shownPalette
,
0
,
256
);
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
shownPalette
,
0
,
256
);
return
;
return
;
...
...
src/io/gfx/paletteeffects.h
View file @
6a0cbf3f
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -49,13 +49,13 @@
...
@@ -49,13 +49,13 @@
class
PaletteEffect
{
class
PaletteEffect
{
protected
:
protected
:
PaletteEffect
*
next
;
// Next effect to use
PaletteEffect
*
next
;
// Next effect to use
public
:
public
:
PaletteEffect
(
PaletteEffect
*
nextPE
);
PaletteEffect
(
PaletteEffect
*
nextPE
);
virtual
~
PaletteEffect
();
virtual
~
PaletteEffect
();
virtual
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
virtual
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
};
};
...
@@ -67,9 +67,9 @@ class WhiteInPaletteEffect : public PaletteEffect {
...
@@ -67,9 +67,9 @@ class WhiteInPaletteEffect : public PaletteEffect {
fixed
whiteness
;
fixed
whiteness
;
public
:
public
:
WhiteInPaletteEffect
(
int
newDuration
,
PaletteEffect
*
nextPE
);
WhiteInPaletteEffect
(
int
newDuration
,
PaletteEffect
*
nextPE
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
};
};
...
@@ -81,9 +81,9 @@ class FadeInPaletteEffect : public PaletteEffect {
...
@@ -81,9 +81,9 @@ class FadeInPaletteEffect : public PaletteEffect {
fixed
blackness
;
fixed
blackness
;
public
:
public
:
FadeInPaletteEffect
(
int
newDuration
,
PaletteEffect
*
nextPE
);
FadeInPaletteEffect
(
int
newDuration
,
PaletteEffect
*
nextPE
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
};
};
...
@@ -95,9 +95,9 @@ class WhiteOutPaletteEffect : public PaletteEffect {
...
@@ -95,9 +95,9 @@ class WhiteOutPaletteEffect : public PaletteEffect {
fixed
whiteness
;
fixed
whiteness
;
public
:
public
:
WhiteOutPaletteEffect
(
int
newDuration
,
PaletteEffect
*
nextPE
);
WhiteOutPaletteEffect
(
int
newDuration
,
PaletteEffect
*
nextPE
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
};
};
...
@@ -109,9 +109,9 @@ class FadeOutPaletteEffect : public PaletteEffect {
...
@@ -109,9 +109,9 @@ class FadeOutPaletteEffect : public PaletteEffect {
fixed
blackness
;
fixed
blackness
;
public
:
public
:
FadeOutPaletteEffect
(
int
newDuration
,
PaletteEffect
*
nextPE
);
FadeOutPaletteEffect
(
int
newDuration
,
PaletteEffect
*
nextPE
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
};
};
...
@@ -125,9 +125,9 @@ class FlashPaletteEffect : public PaletteEffect {
...
@@ -125,9 +125,9 @@ class FlashPaletteEffect : public PaletteEffect {
public
:
public
:
FlashPaletteEffect
(
unsigned
char
newRed
,
unsigned
char
newGreen
,
FlashPaletteEffect
(
unsigned
char
newRed
,
unsigned
char
newGreen
,
unsigned
char
newBlue
,
int
newDuration
,
PaletteEffect
*
nextPE
);
unsigned
char
newBlue
,
int
newDuration
,
PaletteEffect
*
nextPE
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
};
};
...
@@ -135,18 +135,16 @@ class FlashPaletteEffect : public PaletteEffect {
...
@@ -135,18 +135,16 @@ class FlashPaletteEffect : public PaletteEffect {
class
RotatePaletteEffect
:
public
PaletteEffect
{
class
RotatePaletteEffect
:
public
PaletteEffect
{
private
:
private
:
unsigned
char
first
;
/* The first palette index affected by the
unsigned
char
first
;
/* The first palette index affected */
effect */
int
amount
;
/* The number of (consecutive) palette indices affected */
int
amount
;
/* The number of (consecutive) palette indices
affected by the effect */
fixed
speed
;
// Rotations per second
fixed
speed
;
// Rotations per second
fixed
position
;
fixed
position
;
public
:
public
:
RotatePaletteEffect
(
unsigned
char
newFirst
,
int
newAmount
,
RotatePaletteEffect
(
unsigned
char
newFirst
,
int
newAmount
,
fixed
newSpeed
,
PaletteEffect
*
nextPE
);
fixed
newSpeed
,
PaletteEffect
*
nextPE
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
};
};
...
@@ -155,17 +153,15 @@ class SkyPaletteEffect : public PaletteEffect {
...
@@ -155,17 +153,15 @@ class SkyPaletteEffect : public PaletteEffect {
private
:
private
:
SDL_Color
*
skyPalette
;
SDL_Color
*
skyPalette
;
unsigned
char
first
;
/* The first palette index affected by the
unsigned
char
first
;
/* The first palette index affected */
effect */
int
amount
;
/* The number of (consecutive) palette indices affected */
int
amount
;
/* The number of (consecutive) palette
indices affected by the effect */
fixed
speed
;
// Relative Y speed - as in Jazz 2
fixed
speed
;
// Relative Y speed - as in Jazz 2
public
:
public
:
SkyPaletteEffect
(
unsigned
char
newFirst
,
int
newAmount
,
SkyPaletteEffect
(
unsigned
char
newFirst
,
int
newAmount
,
fixed
newSpeed
,
SDL_Color
*
newSkyPalette
,
PaletteEffect
*
nextPE
);
fixed
newSpeed
,
SDL_Color
*
newSkyPalette
,
PaletteEffect
*
nextPE
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
};
};
...
@@ -173,17 +169,15 @@ class SkyPaletteEffect : public PaletteEffect {
...
@@ -173,17 +169,15 @@ class SkyPaletteEffect : public PaletteEffect {
class
P2DPaletteEffect
:
public
PaletteEffect
{
class
P2DPaletteEffect
:
public
PaletteEffect
{
private
:
private
:
unsigned
char
first
;
/* The first palette index affected by the
unsigned
char
first
;
/* The first palette index affected */
effect */
int
amount
;
/* The number of (consecutive) palette indices affected */
int
amount
;
/* The number of (consecutive) palette indices
affected by the effect */
fixed
speed
;
// Relative X & Y speed - as in Jazz 2
fixed
speed
;
// Relative X & Y speed - as in Jazz 2
public
:
public
:
P2DPaletteEffect
(
unsigned
char
newFirst
,
int
newAmount
,
P2DPaletteEffect
(
unsigned
char
newFirst
,
int
newAmount
,
fixed
newSpeed
,
PaletteEffect
*
nextPE
);
fixed
newSpeed
,
PaletteEffect
*
nextPE
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
};
};
...
@@ -191,17 +185,15 @@ class P2DPaletteEffect : public PaletteEffect {
...
@@ -191,17 +185,15 @@ class P2DPaletteEffect : public PaletteEffect {
class
P1DPaletteEffect
:
public
PaletteEffect
{
class
P1DPaletteEffect
:
public
PaletteEffect
{
private
:
private
:
unsigned
char
first
;
/* The first palette index affected by the
unsigned
char
first
;
/* The first palette index affected */
effect */
int
amount
;
/* The number of (consecutive) palette indices affected */
int
amount
;
/* The number of (consecutive) palette indices
affected by the effect */
fixed
speed
;
// Relative X & Y speed - as in Jazz 2
fixed
speed
;
// Relative X & Y speed - as in Jazz 2
public
:
public
:
P1DPaletteEffect
(
unsigned
char
newFirst
,
int
newAmount
,
P1DPaletteEffect
(
unsigned
char
newFirst
,
int
newAmount
,
fixed
newSpeed
,
PaletteEffect
*
nextPE
);
fixed
newSpeed
,
PaletteEffect
*
nextPE
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
};
};
...
@@ -209,20 +201,19 @@ class P1DPaletteEffect : public PaletteEffect {
...
@@ -209,20 +201,19 @@ class P1DPaletteEffect : public PaletteEffect {
class
WaterPaletteEffect
:
public
PaletteEffect
{
class
WaterPaletteEffect
:
public
PaletteEffect
{
private
:
private
:
fixed
depth
;
/* Number of pixels between water surface and total
fixed
depth
;
/* Number of pixels between water surface and total darkness */
darkness */
public
:
public
:
WaterPaletteEffect
(
fixed
newDepth
,
PaletteEffect
*
nextPE
);
WaterPaletteEffect
(
fixed
newDepth
,
PaletteEffect
*
nextPE
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
void
apply
(
SDL_Color
*
shownPalette
,
bool
direct
,
int
mspf
);
};
};
// Variable
// Variable
EXTERN
PaletteEffect
*
firstPE
;
EXTERN
PaletteEffect
*
paletteEffects
;
#endif
#endif
...
...
src/io/gfx/sprite.cpp
View file @
6a0cbf3f
...
@@ -118,7 +118,7 @@ void Sprite::flashPalette (int index) {
...
@@ -118,7 +118,7 @@ void Sprite::flashPalette (int index) {
void
Sprite
::
restorePalette
()
{
void
Sprite
::
restorePalette
()
{
::
restor
ePalette
(
pixels
);
video
.
restoreSurfac
ePalette
(
pixels
);
return
;
return
;
...
...
src/io/gfx/sprite.h
View file @
6a0cbf3f
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
// Constant
// Constant
#define SKEY
254
/* Sprite colour key */
#define SKEY 254
/* Sprite colour key */
// Class
// Class
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
class
Sprite
{
class
Sprite
{
private
:
private
:
SDL_Surface
*
pixels
;
SDL_Surface
*
pixels
;
public
:
public
:
unsigned
char
xOffset
;
unsigned
char
xOffset
;
...
@@ -48,11 +48,11 @@ class Sprite {
...
@@ -48,11 +48,11 @@ class Sprite {
~
Sprite
();
~
Sprite
();
void
clearPixels
();
void
clearPixels
();
void
setPixels
(
unsigned
char
*
data
,
int
width
,
int
height
);
void
setPixels
(
unsigned
char
*
data
,
int
width
,
int
height
);
int
getWidth
();
int
getWidth
();
int
getHeight
();
int
getHeight
();
void
draw
(
int
x
,
int
y
);
void
draw
(
int
x
,
int
y
);
void
setPalette
(
SDL_Color
*
palette
,
int
start
,
int
amount
);
void
setPalette
(
SDL_Color
*
palette
,
int
start
,
int
amount
);
void
flashPalette
(
int
index
);
void
flashPalette
(
int
index
);
void
restorePalette
();
void
restorePalette
();
...
...
src/io/gfx/video.cpp
View file @
6a0cbf3f
...
@@ -26,11 +26,16 @@
...
@@ -26,11 +26,16 @@
*/
*/
#include "paletteeffects.h"
#include "video.h"
#include "video.h"
#ifdef SCALE
#include "io/gfx/scale2x/scalebit.h"
#endif
#include <string.h>
#include <string.h>
unsigned
char
*
sortPixels
(
unsigned
char
*
pixels
,
int
length
)
{
unsigned
char
*
sortPixels
(
unsigned
char
*
pixels
,
int
length
)
{
unsigned
char
*
sorted
;
unsigned
char
*
sorted
;
...
@@ -50,7 +55,7 @@ unsigned char * sortPixels (unsigned char * pixels, int length) {
...
@@ -50,7 +55,7 @@ unsigned char * sortPixels (unsigned char * pixels, int length) {
}
}
SDL_Surface
*
createSurface
(
unsigned
char
*
pixels
,
int
width
,
int
height
)
{
SDL_Surface
*
createSurface
(
unsigned
char
*
pixels
,
int
width
,
int
height
)
{
SDL_Surface
*
ret
;
SDL_Surface
*
ret
;
int
y
;
int
y
;
...
@@ -59,7 +64,7 @@ SDL_Surface * createSurface (unsigned char * pixels, int width, int height) {
...
@@ -59,7 +64,7 @@ SDL_Surface * createSurface (unsigned char * pixels, int width, int height) {
ret
=
SDL_CreateRGBSurface
(
SDL_HWSURFACE
,
width
,
height
,
8
,
0
,
0
,
0
,
0
);
ret
=
SDL_CreateRGBSurface
(
SDL_HWSURFACE
,
width
,
height
,
8
,
0
,
0
,
0
,
0
);
// Set the surface's palette
// Set the surface's palette
SDL_SetPalette
(
ret
,
SDL_LOGPAL
,
logicalPalette
,
0
,
256
);
video
.
restoreSurfacePalette
(
ret
);
if
(
pixels
)
{
if
(
pixels
)
{
...
@@ -78,8 +83,38 @@ SDL_Surface * createSurface (unsigned char * pixels, int width, int height) {
...
@@ -78,8 +83,38 @@ SDL_Surface * createSurface (unsigned char * pixels, int width, int height) {
}
}
void
createScreen
()
{
Video
::
Video
()
{
int
count
;
screen
=
NULL
;
screenW
=
SW
;
screenH
=
SH
;
#ifdef SCALE
scaleFactor
=
1
;
#endif
#ifndef FULLSCREEN_ONLY
fullscreen
=
false
;
#endif
// Generate the logical palette
for
(
count
=
0
;
count
<
256
;
count
++
)
logicalPalette
[
count
].
r
=
logicalPalette
[
count
].
g
=
logicalPalette
[
count
].
b
=
count
;
currentPalette
=
logicalPalette
;
return
;
}
bool
Video
::
create
(
int
width
,
int
height
)
{
screenW
=
width
;
screenH
=
height
;
#ifdef SCALE
#ifdef SCALE
if
(
canvas
!=
screen
)
SDL_FreeSurface
(
canvas
);
if
(
canvas
!=
screen
)
SDL_FreeSurface
(
canvas
);
...
@@ -94,6 +129,9 @@ void createScreen () {
...
@@ -94,6 +129,9 @@ void createScreen () {
screen
=
SDL_SetVideoMode
(
screenW
,
screenH
,
8
,
fullscreen
?
FULLSCREEN_FLAGS
:
WINDOWED_FLAGS
);
screen
=
SDL_SetVideoMode
(
screenW
,
screenH
,
8
,
fullscreen
?
FULLSCREEN_FLAGS
:
WINDOWED_FLAGS
);
#endif
#endif
#endif
#endif
if
(
!
screen
)
return
false
;
#ifdef SCALE
#ifdef SCALE
// Check that the scale will fit in the current resolution
// Check that the scale will fit in the current resolution
...
@@ -121,8 +159,7 @@ void createScreen () {
...
@@ -121,8 +159,7 @@ void createScreen () {
#endif
#endif
#if !(defined(WIZ) || defined(GP2X))
#if !(defined(WIZ) || defined(GP2X))
SDL_SetPalette
(
screen
,
SDL_LOGPAL
,
logicalPalette
,
0
,
256
);
expose
();
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
currentPalette
,
0
,
256
);
#endif
#endif
...
@@ -137,12 +174,12 @@ void createScreen () {
...
@@ -137,12 +174,12 @@ void createScreen () {
// TODO: Find a better way
// TODO: Find a better way
fakePalette
=
true
;
fakePalette
=
true
;
return
;
return
true
;
}
}
void
use
Palette
(
SDL_Color
*
palette
)
{
void
Video
::
set
Palette
(
SDL_Color
*
palette
)
{
// Make palette changes invisible until the next draw. Hopefully.
// Make palette changes invisible until the next draw. Hopefully.
clearScreen
(
SDL_MapRGB
(
screen
->
format
,
0
,
0
,
0
));
clearScreen
(
SDL_MapRGB
(
screen
->
format
,
0
,
0
,
0
));
...
@@ -156,22 +193,152 @@ void usePalette (SDL_Color *palette) {
...
@@ -156,22 +193,152 @@ void usePalette (SDL_Color *palette) {
return
;
return
;
}
}
SDL_Color
*
Video
::
getPalette
()
{
return
currentPalette
;
}
void
Video
::
changePalette
(
SDL_Color
*
palette
,
unsigned
char
first
,
unsigned
char
amount
)
{
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
palette
,
first
,
amount
);
return
;
}
void
restorePalette
(
SDL_Surface
*
surface
)
{
void
Video
::
restoreSurfacePalette
(
SDL_Surface
*
surface
)
{
SDL_SetPalette
(
surface
,
SDL_LOGPAL
,
logicalPalette
,
0
,
256
);
SDL_SetPalette
(
surface
,
SDL_LOGPAL
,
logicalPalette
,
0
,
256
);
return
;
return
;
}
int
Video
::
getWidth
()
{
return
screenW
;
}
int
Video
::
getHeight
()
{
return
screenH
;
}
int
Video
::
getScaleFactor
()
{
return
scaleFactor
;
}
void
Video
::
setScaleFactor
(
int
newScaleFactor
)
{
scaleFactor
=
newScaleFactor
;
if
(
screen
)
create
(
screenW
,
screenH
);
return
;
}
#ifndef FULLSCREEN_ONLY
bool
Video
::
isFullscreen
()
{
return
fullscreen
;
}
#endif
#ifndef FULLSCREEN_ONLY
void
Video
::
flipFullscreen
()
{
fullscreen
=
!
fullscreen
;
SDL_ShowCursor
(
fullscreen
?
SDL_DISABLE
:
SDL_ENABLE
);
if
(
screen
)
create
(
screenW
,
screenH
);
return
;
}
#endif
void
Video
::
expose
()
{
SDL_SetPalette
(
screen
,
SDL_LOGPAL
,
logicalPalette
,
0
,
256
);
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
currentPalette
,
0
,
256
);
return
;
}
void
Video
::
flip
(
int
mspf
)
{
SDL_Color
shownPalette
[
256
];
#ifdef SCALE
if
(
canvas
!=
screen
)
{
// Copy everything that has been drawn so far
scale
(
scaleFactor
,
screen
->
pixels
,
screen
->
pitch
,
canvas
->
pixels
,
canvas
->
pitch
,
screen
->
format
->
BytesPerPixel
,
canvas
->
w
,
canvas
->
h
);
}
#endif
// Apply palette effects
if
(
paletteEffects
)
{
/* If the palette is being emulated, compile all palette changes and
apply them all at once.
If the palette is being used directly, apply all palette effects
directly. */
if
(
fakePalette
)
{
memcpy
(
shownPalette
,
currentPalette
,
sizeof
(
SDL_Color
)
*
256
);
paletteEffects
->
apply
(
shownPalette
,
false
,
mspf
);
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
shownPalette
,
0
,
256
);
}
else
{
paletteEffects
->
apply
(
shownPalette
,
true
,
mspf
);
}
}
// Show what has been drawn
SDL_Flip
(
screen
);
return
;
}
}
void
clearScreen
(
int
index
)
{
void
clearScreen
(
int
index
)
{
#if defined(WIZ) || defined(GP2X)
#if defined(WIZ) || defined(GP2X)
// always 240 lines cleared to black
// always 240 lines cleared to black
memset
(
screen
->
pixels
,
index
,
320
*
240
);
memset
(
video
->
pixels
,
index
,
320
*
240
);
#else
#else
SDL_FillRect
(
canvas
,
NULL
,
index
);
SDL_FillRect
(
canvas
,
NULL
,
index
);
#endif
#endif
...
@@ -195,3 +362,4 @@ void drawRect (int x, int y, int width, int height, int index) {
...
@@ -195,3 +362,4 @@ void drawRect (int x, int y, int width, int height, int index) {
return
;
return
;
}
}
src/io/gfx/video.h
View file @
6a0cbf3f
...
@@ -48,41 +48,73 @@
...
@@ -48,41 +48,73 @@
#define MAX_SCALE 4
#define MAX_SCALE 4
#endif
#endif
// Black palette index
#define BLACK 31
// Class
class
Video
{
private
:
SDL_Surface
*
screen
;
// Palettes
SDL_Color
*
currentPalette
;
SDL_Color
logicalPalette
[
256
];
bool
fakePalette
;
int
screenW
,
screenH
;
#ifdef SCALE
int
scaleFactor
;
#endif
#ifndef FULLSCREEN_ONLY
bool
fullscreen
;
#endif
public
:
Video
();
bool
create
(
int
width
,
int
height
);
void
setPalette
(
SDL_Color
*
palette
);
SDL_Color
*
getPalette
();
void
changePalette
(
SDL_Color
*
palette
,
unsigned
char
first
,
unsigned
char
amount
);
void
restoreSurfacePalette
(
SDL_Surface
*
surface
);
int
getWidth
();
int
getHeight
();
#ifdef SCALE
int
getScaleFactor
();
void
setScaleFactor
(
int
newScaleFactor
);
#endif
#ifndef FULLSCREEN_ONLY
bool
isFullscreen
();
void
flipFullscreen
();
#endif
void
expose
();
void
flip
(
int
mspf
);
};
// Variables
// Variables
EXTERN
SDL_Surface
*
screen
,
*
canvas
;
EXTERN
SDL_Surface
*
canvas
;
EXTERN
int
viewH
,
canvasW
,
canvasH
,
screenW
,
screenH
;
EXTERN
int
viewH
,
canvasW
,
canvasH
;
#define viewW canvasW
#define viewW canvasW
#ifdef SCALE
EXTERN
int
scaleFactor
;
#endif
#ifndef FULLSCREEN_ONLY
EXTERN
bool
fullscreen
;
#endif
EXTERN
bool
fakePalette
;
// Palettes
EXTERN
SDL_Color
*
currentPalette
;
EXTERN
SDL_Color
logicalPalette
[
256
];
// Panel
// Panel
EXTERN
SDL_Surface
*
panel
;
EXTERN
SDL_Surface
*
panel
;
EXTERN
SDL_Surface
*
panelAmmo
[
5
];
EXTERN
SDL_Surface
*
panelAmmo
[
5
];
EXTERN
Video
video
;
// Functions
// Functions
EXTERN
unsigned
char
*
sortPixels
(
unsigned
char
*
pixels
,
int
length
);
EXTERN
unsigned
char
*
sortPixels
(
unsigned
char
*
pixels
,
int
length
);
EXTERN
SDL_Surface
*
createSurface
(
unsigned
char
*
pixels
,
int
width
,
int
height
);
EXTERN
SDL_Surface
*
createSurface
(
unsigned
char
*
pixels
,
int
width
,
int
height
);
EXTERN
void
createScreen
();
EXTERN
void
clearScreen
(
int
index
);
EXTERN
void
usePalette
(
SDL_Color
*
palette
);
EXTERN
void
drawRect
(
int
x
,
int
y
,
int
width
,
int
height
,
int
index
);
EXTERN
void
restorePalette
(
SDL_Surface
*
surface
);
EXTERN
void
clearScreen
(
int
index
);
EXTERN
void
drawRect
(
int
x
,
int
y
,
int
width
,
int
height
,
int
index
);
#endif
#endif
...
...
src/level/bullet.cpp
View file @
6a0cbf3f
...
@@ -32,9 +32,9 @@
...
@@ -32,9 +32,9 @@
#include "player/player.h"
#include "player/player.h"
Bullet
::
Bullet
(
Player
*
sourcePlayer
,
bool
lower
,
unsigned
int
ticks
)
{
Bullet
::
Bullet
(
Player
*
sourcePlayer
,
bool
lower
,
unsigned
int
ticks
)
{
Anim
*
anim
;
Anim
*
anim
;
// Properties based on the player
// Properties based on the player
...
@@ -48,7 +48,7 @@ Bullet::Bullet (Player *sourcePlayer, bool lower, unsigned int ticks) {
...
@@ -48,7 +48,7 @@ Bullet::Bullet (Player *sourcePlayer, bool lower, unsigned int ticks) {
}
else
{
}
else
{
next
=
level
->
firstBullet
;
next
=
level
->
bullets
;
}
}
...
@@ -66,7 +66,7 @@ Bullet::Bullet (Player *sourcePlayer, bool lower, unsigned int ticks) {
...
@@ -66,7 +66,7 @@ Bullet::Bullet (Player *sourcePlayer, bool lower, unsigned int ticks) {
time
=
ticks
+
T_TNT
;
time
=
ticks
+
T_TNT
;
// Red flash
// Red flash
firstPE
=
new
FlashPaletteEffect
(
255
,
0
,
0
,
T_TNT
,
firstPE
);
paletteEffects
=
new
FlashPaletteEffect
(
255
,
0
,
0
,
T_TNT
,
paletteEffects
);
}
else
{
}
else
{
...
@@ -88,13 +88,13 @@ Bullet::Bullet (Player *sourcePlayer, bool lower, unsigned int ticks) {
...
@@ -88,13 +88,13 @@ Bullet::Bullet (Player *sourcePlayer, bool lower, unsigned int ticks) {
}
}
Bullet
::
Bullet
(
Event
*
sourceEvent
,
bool
facing
,
unsigned
int
ticks
)
{
Bullet
::
Bullet
(
Event
*
sourceEvent
,
bool
facing
,
unsigned
int
ticks
)
{
Anim
*
anim
;
Anim
*
anim
;
// Properties based on the event
// Properties based on the event
next
=
level
->
firstBullet
;
next
=
level
->
bullets
;
source
=
NULL
;
source
=
NULL
;
type
=
sourceEvent
->
getProperty
(
E_BULLET
);
type
=
sourceEvent
->
getProperty
(
E_BULLET
);
direction
=
facing
?
1
:
0
;
direction
=
facing
?
1
:
0
;
...
@@ -114,7 +114,7 @@ Bullet::Bullet (Event *sourceEvent, bool facing, unsigned int ticks) {
...
@@ -114,7 +114,7 @@ Bullet::Bullet (Event *sourceEvent, bool facing, unsigned int ticks) {
}
}
Bullet
::
Bullet
(
Bird
*
sourceBird
,
bool
lower
,
unsigned
int
ticks
)
{
Bullet
::
Bullet
(
Bird
*
sourceBird
,
bool
lower
,
unsigned
int
ticks
)
{
// Properties based on the bird and its player
// Properties based on the bird and its player
...
@@ -127,7 +127,7 @@ Bullet::Bullet (Bird *sourceBird, bool lower, unsigned int ticks) {
...
@@ -127,7 +127,7 @@ Bullet::Bullet (Bird *sourceBird, bool lower, unsigned int ticks) {
}
else
{
}
else
{
next
=
level
->
firstBullet
;
next
=
level
->
bullets
;
}
}
...
@@ -149,55 +149,42 @@ Bullet::Bullet (Bird *sourceBird, bool lower, unsigned int ticks) {
...
@@ -149,55 +149,42 @@ Bullet::Bullet (Bird *sourceBird, bool lower, unsigned int ticks) {
Bullet
::~
Bullet
()
{
Bullet
::~
Bullet
()
{
if
(
next
)
delete
next
;
return
;
return
;
}
}
Bullet
*
Bullet
::
getNext
()
{
Bullet
*
Bullet
::
remove
()
{
return
next
;
Bullet
*
oldNext
;
}
oldNext
=
next
;
next
=
NULL
;
delete
this
;
void
Bullet
::
removeNext
()
{
return
oldNext
;
Bullet
*
newNext
;
}
if
(
next
)
{
newNext
=
next
->
getNext
();
Player
*
Bullet
::
getSource
()
{
delete
next
;
next
=
newNext
;
}
return
;
}
Player
*
Bullet
::
getSource
()
{
return
source
;
return
source
;
}
}
bool
Bullet
::
step
(
unsigned
int
ticks
,
int
msps
)
{
Bullet
*
Bullet
::
step
(
unsigned
int
ticks
,
int
msps
)
{
signed
char
*
set
;
signed
char
*
set
;
Event
*
event
;
Event
*
event
;
int
count
;
int
count
;
// Process the next bullet
// Process the next bullet
if
(
next
)
{
if
(
next
)
next
=
next
->
step
(
ticks
,
msps
);
if
(
next
->
step
(
ticks
,
msps
))
removeNext
();
}
if
(
level
->
getStage
()
!=
LS_END
)
{
if
(
level
->
getStage
()
!=
LS_END
)
{
...
@@ -209,7 +196,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
...
@@ -209,7 +196,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
// If the bullet is TNT, hit all destructible events nearby twice
// If the bullet is TNT, hit all destructible events nearby twice
if
(
type
==
-
1
)
{
if
(
type
==
-
1
)
{
event
=
level
->
firstEvent
;
event
=
level
->
events
;
while
(
event
)
{
while
(
event
)
{
...
@@ -228,13 +215,13 @@ bool Bullet::step (unsigned int ticks, int msps) {
...
@@ -228,13 +215,13 @@ bool Bullet::step (unsigned int ticks, int msps) {
}
}
// Destroy the bullet
// Destroy the bullet
return
true
;
return
remove
()
;
}
}
// If this is TNT, don't need to do anything else
// If this is TNT, don't need to do anything else
if
(
type
==
-
1
)
return
false
;
if
(
type
==
-
1
)
return
this
;
// Check if a player has been hit
// Check if a player has been hit
...
@@ -244,7 +231,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
...
@@ -244,7 +231,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
ITOF
(
sprite
->
getWidth
()),
ITOF
(
sprite
->
getHeight
())))
{
ITOF
(
sprite
->
getWidth
()),
ITOF
(
sprite
->
getHeight
())))
{
// If the hit was successful, destroy the bullet
// If the hit was successful, destroy the bullet
if
(
players
[
count
].
hit
(
source
,
ticks
))
return
true
;
if
(
players
[
count
].
hit
(
source
,
ticks
))
return
remove
()
;
}
}
...
@@ -255,7 +242,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
...
@@ -255,7 +242,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
// Check if an event has been hit
// Check if an event has been hit
event
=
level
->
firstEvent
;
event
=
level
->
events
;
while
(
event
)
{
while
(
event
)
{
...
@@ -264,7 +251,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
...
@@ -264,7 +251,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
ITOF
(
sprite
->
getWidth
()),
ITOF
(
sprite
->
getHeight
())))
{
ITOF
(
sprite
->
getWidth
()),
ITOF
(
sprite
->
getHeight
())))
{
// If the event is hittable, hit it and destroy the bullet
// If the event is hittable, hit it and destroy the bullet
if
(
event
->
hit
(
source
,
ticks
))
return
true
;
if
(
event
->
hit
(
source
,
ticks
))
return
remove
()
;
}
}
...
@@ -285,7 +272,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
...
@@ -285,7 +272,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
level
->
playSound
(
set
[
B_FINISHSOUND
]);
level
->
playSound
(
set
[
B_FINISHSOUND
]);
return
true
;
return
remove
()
;
}
}
...
@@ -309,7 +296,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
...
@@ -309,7 +296,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
// Do not destroy the bullet
// Do not destroy the bullet
return
false
;
return
this
;
}
}
...
...
src/level/bullet.h
View file @
6a0cbf3f
...
@@ -56,24 +56,24 @@ class Sprite;
...
@@ -56,24 +56,24 @@ class Sprite;
class
Bullet
:
public
Movable
{
class
Bullet
:
public
Movable
{
private
:
private
:
Bullet
*
next
;
Bullet
*
next
;
Player
*
source
;
// If NULL, was fired by an event
Player
*
source
;
// If NULL, was fired by an event
Sprite
*
sprite
;
Sprite
*
sprite
;
int
type
;
// -1 is TNT, otherwise indexes the bullet set
int
type
;
// -1 is TNT, otherwise indexes the bullet set
int
direction
;
// 0: Left, 1: Right, 2: L (lower), 3: R (lower)
int
direction
;
// 0: Left, 1: Right, 2: L (lower), 3: R (lower)
unsigned
int
time
;
// Time at which the bullet will self-destruct
unsigned
int
time
;
// Time at which the bullet will self-destruct
Bullet
*
remove
();
public
:
public
:
Bullet
(
Player
*
sourcePlayer
,
bool
lower
,
unsigned
int
ticks
);
Bullet
(
Player
*
sourcePlayer
,
bool
lower
,
unsigned
int
ticks
);
Bullet
(
Event
*
sourceEvent
,
bool
facing
,
unsigned
int
ticks
);
Bullet
(
Event
*
sourceEvent
,
bool
facing
,
unsigned
int
ticks
);
Bullet
(
Bird
*
sourceBird
,
bool
lower
,
unsigned
int
ticks
);
Bullet
(
Bird
*
sourceBird
,
bool
lower
,
unsigned
int
ticks
);
~
Bullet
();
~
Bullet
();
Bullet
*
getNext
();
Player
*
getSource
();
void
removeNext
();
Bullet
*
step
(
unsigned
int
ticks
,
int
msps
);
Player
*
getSource
();
void
draw
(
int
change
);
bool
step
(
unsigned
int
ticks
,
int
msps
);
void
draw
(
int
change
);
};
};
...
...
src/level/demolevel.cpp
View file @
6a0cbf3f
...
@@ -103,7 +103,7 @@ int DemoLevel::play () {
...
@@ -103,7 +103,7 @@ int DemoLevel::play () {
stats
=
0
;
stats
=
0
;
use
Palette
(
palette
);
video
.
set
Palette
(
palette
);
while
(
true
)
{
while
(
true
)
{
...
@@ -170,7 +170,7 @@ int DemoLevel::play () {
...
@@ -170,7 +170,7 @@ int DemoLevel::play () {
// Draw the graphics
// Draw the graphics
draw
();
draw
();
drawStats
(
stats
);
drawStats
(
stats
,
BLACK
);
fontsFont
->
showString
(
"demo"
,
(
canvasW
>>
1
)
-
36
,
32
);
fontsFont
->
showString
(
"demo"
,
(
canvasW
>>
1
)
-
36
,
32
);
...
...
src/level/event/bridge.cpp
View file @
6a0cbf3f
...
@@ -31,9 +31,9 @@
...
@@ -31,9 +31,9 @@
#include "player/player.h"
#include "player/player.h"
Bridge
::
Bridge
(
unsigned
char
gX
,
unsigned
char
gY
,
Event
*
nextEvent
)
{
Bridge
::
Bridge
(
unsigned
char
gX
,
unsigned
char
gY
)
{
signed
char
*
set
;
signed
char
*
set
;
set
=
level
->
getEvent
(
gX
,
gY
);
set
=
level
->
getEvent
(
gX
,
gY
);
...
@@ -42,7 +42,7 @@ Bridge::Bridge (unsigned char gX, unsigned char gY, Event *nextEvent) {
...
@@ -42,7 +42,7 @@ Bridge::Bridge (unsigned char gX, unsigned char gY, Event *nextEvent) {
dx
=
0
;
dx
=
0
;
dy
=
0
;
dy
=
0
;
next
=
nextEvent
;
next
=
level
->
events
;
gridX
=
gX
;
gridX
=
gX
;
gridY
=
gY
;
gridY
=
gY
;
animType
=
E_LEFTANIM
;
animType
=
E_LEFTANIM
;
...
@@ -58,16 +58,16 @@ Bridge::Bridge (unsigned char gX, unsigned char gY, Event *nextEvent) {
...
@@ -58,16 +58,16 @@ Bridge::Bridge (unsigned char gX, unsigned char gY, Event *nextEvent) {
}
}
bool
Bridge
::
step
(
unsigned
int
ticks
,
int
msps
)
{
Event
*
Bridge
::
step
(
unsigned
int
ticks
,
int
msps
)
{
signed
char
*
set
;
signed
char
*
set
;
int
count
;
int
count
;
fixed
bridgeLength
,
playerDipX
,
playerDipY
;
fixed
bridgeLength
,
playerDipX
,
playerDipY
;
set
=
prepareStep
(
ticks
,
msps
);
set
=
prepareStep
(
ticks
,
msps
);
if
(
!
set
)
return
true
;
if
(
!
set
)
return
remove
()
;
bridgeLength
=
set
[
E_MULTIPURPOSE
]
*
set
[
E_BRIDGELENGTH
]
*
F4
;
bridgeLength
=
set
[
E_MULTIPURPOSE
]
*
set
[
E_BRIDGELENGTH
]
*
F4
;
...
@@ -105,7 +105,7 @@ bool Bridge::step (unsigned int ticks, int msps) {
...
@@ -105,7 +105,7 @@ bool Bridge::step (unsigned int ticks, int msps) {
}
}
return
false
;
return
this
;
}
}
...
@@ -118,6 +118,9 @@ void Bridge::draw (unsigned int ticks, int change) {
...
@@ -118,6 +118,9 @@ void Bridge::draw (unsigned int ticks, int change) {
fixed
bridgeLength
,
leftDipY
,
rightDipY
;
fixed
bridgeLength
,
leftDipY
,
rightDipY
;
if
(
next
)
next
->
draw
(
ticks
,
change
);
// Get the event properties
// Get the event properties
set
=
level
->
getEvent
(
gridX
,
gridY
);
set
=
level
->
getEvent
(
gridX
,
gridY
);
...
...
src/level/event/event.cpp
View file @
6a0cbf3f
...
@@ -50,14 +50,14 @@ Event::Event () {
...
@@ -50,14 +50,14 @@ Event::Event () {
}
}
Event
::
Event
(
unsigned
char
gX
,
unsigned
char
gY
,
Event
*
nextEvent
)
{
Event
::
Event
(
unsigned
char
gX
,
unsigned
char
gY
)
{
x
=
TTOF
(
gX
);
x
=
TTOF
(
gX
);
y
=
TTOF
(
gY
+
1
);
y
=
TTOF
(
gY
+
1
);
dx
=
0
;
dx
=
0
;
dy
=
0
;
dy
=
0
;
next
=
nextEvent
;
next
=
level
->
events
;
gridX
=
gX
;
gridX
=
gX
;
gridY
=
gY
;
gridY
=
gY
;
flashTime
=
0
;
flashTime
=
0
;
...
@@ -93,7 +93,29 @@ Event::Event (unsigned char gX, unsigned char gY, Event *nextEvent) {
...
@@ -93,7 +93,29 @@ Event::Event (unsigned char gX, unsigned char gY, Event *nextEvent) {
}
}
Event
::~
Event
()
{
if
(
next
)
delete
next
;
return
;
}
Event
*
Event
::
remove
()
{
Event
*
oldNext
;
oldNext
=
next
;
next
=
NULL
;
delete
this
;
return
oldNext
;
}
Event
*
Event
::
getNext
()
{
Event
*
Event
::
getNext
()
{
return
next
;
return
next
;
...
@@ -101,23 +123,6 @@ Event * Event::getNext () {
...
@@ -101,23 +123,6 @@ Event * Event::getNext () {
}
}
void
Event
::
removeNext
()
{
Event
*
newNext
;
if
(
next
)
{
newNext
=
next
->
getNext
();
delete
next
;
next
=
newNext
;
}
return
;
}
void
Event
::
destroy
(
unsigned
int
ticks
)
{
void
Event
::
destroy
(
unsigned
int
ticks
)
{
level
->
setEventTime
(
gridX
,
gridY
,
ticks
+
T_FINISH
);
level
->
setEventTime
(
gridX
,
gridY
,
ticks
+
T_FINISH
);
...
...
src/level/event/event.h
View file @
6a0cbf3f
...
@@ -80,31 +80,32 @@ class Player;
...
@@ -80,31 +80,32 @@ class Player;
class
Event
:
public
Movable
{
class
Event
:
public
Movable
{
protected
:
protected
:
Event
*
next
;
Event
*
next
;
unsigned
char
gridX
,
gridY
;
// Grid position of the event
unsigned
char
gridX
,
gridY
;
// Grid position of the event
unsigned
char
animType
;
// E_LEFTANIM, etc, or 0
unsigned
char
animType
;
// E_LEFTANIM, etc, or 0
unsigned
char
frame
;
unsigned
char
frame
;
unsigned
int
flashTime
;
unsigned
int
flashTime
;
Event
();
Event
();
void
destroy
(
unsigned
int
ticks
);
Event
*
remove
();
fixed
getWidth
();
void
destroy
(
unsigned
int
ticks
);
fixed
getHeight
();
fixed
getWidth
();
signed
char
*
prepareStep
(
unsigned
int
ticks
,
int
msps
);
fixed
getHeight
();
signed
char
*
prepareStep
(
unsigned
int
ticks
,
int
msps
);
public
:
public
:
Event
(
unsigned
char
gX
,
unsigned
char
gY
,
Event
*
nextEvent
);
Event
(
unsigned
char
gX
,
unsigned
char
gY
);
virtual
~
Event
();
Event
*
getNext
();
void
removeNext
();
Event
*
getNext
();
bool
hit
(
Player
*
source
,
unsigned
int
ticks
);
bool
hit
(
Player
*
source
,
unsigned
int
ticks
);
bool
isEnemy
();
bool
isEnemy
();
bool
isFrom
(
unsigned
char
gX
,
unsigned
char
gY
);
bool
isFrom
(
unsigned
char
gX
,
unsigned
char
gY
);
virtual
bool
overlap
(
fixed
left
,
fixed
top
,
fixed
width
,
fixed
height
);
virtual
bool
overlap
(
fixed
left
,
fixed
top
,
fixed
width
,
fixed
height
);
signed
char
getProperty
(
unsigned
char
property
);
signed
char
getProperty
(
unsigned
char
property
);
virtual
bool
step
(
unsigned
int
ticks
,
int
msps
);
virtual
Event
*
step
(
unsigned
int
ticks
,
int
msps
);
virtual
void
draw
(
unsigned
int
ticks
,
int
change
);
virtual
void
draw
(
unsigned
int
ticks
,
int
change
);
};
};
...
@@ -115,10 +116,10 @@ class Bridge : public Event {
...
@@ -115,10 +116,10 @@ class Bridge : public Event {
fixed
rightDipX
;
fixed
rightDipX
;
public
:
public
:
Bridge
(
unsigned
char
gX
,
unsigned
char
gY
,
Event
*
nextEvent
);
Bridge
(
unsigned
char
gX
,
unsigned
char
gY
);
bool
step
(
unsigned
int
ticks
,
int
msps
);
Event
*
step
(
unsigned
int
ticks
,
int
msps
);
void
draw
(
unsigned
int
ticks
,
int
change
);
void
draw
(
unsigned
int
ticks
,
int
change
);
};
};
...
...
src/level/event/eventframe.cpp
View file @
6a0cbf3f
...
@@ -38,16 +38,12 @@
...
@@ -38,16 +38,12 @@
#include <math.h>
#include <math.h>
signed
char
*
Event
::
prepareStep
(
unsigned
int
ticks
,
int
msps
)
{
signed
char
*
Event
::
prepareStep
(
unsigned
int
ticks
,
int
msps
)
{
signed
char
*
set
;
signed
char
*
set
;
// Process the next event
// Process the next event
if
(
next
)
{
if
(
next
)
next
=
next
->
step
(
ticks
,
msps
);
if
(
next
->
step
(
ticks
,
msps
))
removeNext
();
}
// Get the event properties
// Get the event properties
...
@@ -85,10 +81,10 @@ signed char * Event::prepareStep (unsigned int ticks, int msps) {
...
@@ -85,10 +81,10 @@ signed char * Event::prepareStep (unsigned int ticks, int msps) {
}
}
bool
Event
::
step
(
unsigned
int
ticks
,
int
msps
)
{
Event
*
Event
::
step
(
unsigned
int
ticks
,
int
msps
)
{
fixed
width
,
height
;
fixed
width
,
height
;
signed
char
*
set
;
signed
char
*
set
;
int
count
;
int
count
;
fixed
offset
;
fixed
offset
;
float
angle
;
float
angle
;
...
@@ -96,7 +92,7 @@ bool Event::step (unsigned int ticks, int msps) {
...
@@ -96,7 +92,7 @@ bool Event::step (unsigned int ticks, int msps) {
set
=
prepareStep
(
ticks
,
msps
);
set
=
prepareStep
(
ticks
,
msps
);
if
(
!
set
)
return
true
;
if
(
!
set
)
return
remove
()
;
// Find dimensions
// Find dimensions
...
@@ -696,7 +692,7 @@ bool Event::step (unsigned int ticks, int msps) {
...
@@ -696,7 +692,7 @@ bool Event::step (unsigned int ticks, int msps) {
animType
=
E_LEFTANIM
;
animType
=
E_LEFTANIM
;
}
}
break
;
break
;
case
32
:
case
32
:
...
@@ -845,13 +841,13 @@ bool Event::step (unsigned int ticks, int msps) {
...
@@ -845,13 +841,13 @@ bool Event::step (unsigned int ticks, int msps) {
// The event has been destroyed, so remove it
// The event has been destroyed, so remove it
level
->
clearEvent
(
gridX
,
gridY
);
level
->
clearEvent
(
gridX
,
gridY
);
return
true
;
return
remove
()
;
}
else
if
(
animType
==
E_LSHOOTANIM
)
{
}
else
if
(
animType
==
E_LSHOOTANIM
)
{
if
((
set
[
E_BULLET
]
<
32
)
&&
if
((
set
[
E_BULLET
]
<
32
)
&&
(
level
->
getBullet
(
set
[
E_BULLET
])[
B_SPRITE
]
!=
0
))
(
level
->
getBullet
(
set
[
E_BULLET
])[
B_SPRITE
]
!=
0
))
level
->
firstBullet
=
new
Bullet
(
this
,
false
,
ticks
);
level
->
bullets
=
new
Bullet
(
this
,
false
,
ticks
);
animType
=
E_LEFTANIM
;
animType
=
E_LEFTANIM
;
...
@@ -859,7 +855,7 @@ bool Event::step (unsigned int ticks, int msps) {
...
@@ -859,7 +855,7 @@ bool Event::step (unsigned int ticks, int msps) {
if
((
set
[
E_BULLET
]
<
32
)
&&
if
((
set
[
E_BULLET
]
<
32
)
&&
(
level
->
getBullet
(
set
[
E_BULLET
])[
B_SPRITE
+
1
]
!=
0
))
(
level
->
getBullet
(
set
[
E_BULLET
])[
B_SPRITE
+
1
]
!=
0
))
level
->
firstBullet
=
new
Bullet
(
this
,
true
,
ticks
);
level
->
bullets
=
new
Bullet
(
this
,
true
,
ticks
);
animType
=
E_RIGHTANIM
;
animType
=
E_RIGHTANIM
;
...
@@ -872,43 +868,41 @@ bool Event::step (unsigned int ticks, int msps) {
...
@@ -872,43 +868,41 @@ bool Event::step (unsigned int ticks, int msps) {
}
}
if
(
level
->
getStage
()
==
LS_END
)
return
false
;
if
(
level
->
getStage
()
==
LS_END
)
return
this
;
if
((
animType
==
E_LFINISHANIM
)
||
(
animType
==
E_RFINISHANIM
))
return
this
;
// Handle contact with player
// Handle contact with player
if
((
animType
!=
E_LFINISHANIM
)
&&
(
animType
!=
E_RFINISHANIM
))
{
for
(
count
=
0
;
count
<
nPlayers
;
count
++
)
{
for
(
count
=
0
;
count
<
nPlayers
;
count
++
)
{
// Check if the player is touching the event
// Check if the player is touching the event
if
(
set
[
E_MODIFIER
]
==
6
)
{
if
(
set
[
E_MODIFIER
]
==
6
)
{
if
(
width
&&
height
&&
players
[
count
].
overlap
(
x
,
y
-
height
,
width
-
F8
,
F8
)
&&
(
players
[
count
].
getY
()
<=
F8
+
((
PYS_FALL
*
msps
)
>>
10
)
+
y
-
height
)
&&
!
level
->
checkMaskDown
(
players
[
count
].
getX
()
+
PXO_MID
,
PYO_TOP
+
y
-
height
))
{
// Player is on a platform
if
(
width
&&
height
&&
players
[
count
].
overlap
(
x
,
y
-
height
,
width
-
F8
,
F8
)
&&
(
players
[
count
].
getY
()
<=
F8
+
((
PYS_FALL
*
msps
)
>>
10
)
+
y
-
height
)
&&
!
level
->
checkMaskDown
(
players
[
count
].
getX
()
+
PXO_MID
,
PYO_TOP
+
y
-
height
))
{
players
[
count
].
setEvent
(
gridX
,
gridY
);
// Player is on a platform
players
[
count
].
setPosition
(
players
[
count
].
getX
()
+
((
dx
*
msps
)
>>
10
),
F4
+
y
-
height
);
}
else
players
[
count
].
clearEvent
(
gridX
,
gridY
);
players
[
count
].
setEvent
(
gridX
,
gridY
);
players
[
count
].
setPosition
(
players
[
count
].
getX
()
+
((
dx
*
msps
)
>>
10
),
F4
+
y
-
height
);
}
else
{
}
else
players
[
count
].
clearEvent
(
gridX
,
gridY
);
// Check if the player is touching the event
}
else
{
if
(
width
&&
height
&&
players
[
count
].
overlap
(
x
,
y
-
height
,
width
,
height
))
{
// If the player picks up the event, destroy i
t
// Check if the player is touching the even
t
if
(
players
[
count
].
touchEvent
(
gridX
,
gridY
,
ticks
,
msps
))
if
(
width
&&
height
&&
destroy
(
ticks
);
players
[
count
].
overlap
(
x
,
y
-
height
,
width
,
height
))
{
}
// If the player picks up the event, destroy it
if
(
players
[
count
].
touchEvent
(
gridX
,
gridY
,
ticks
,
msps
))
destroy
(
ticks
);
}
}
...
@@ -917,18 +911,21 @@ bool Event::step (unsigned int ticks, int msps) {
...
@@ -917,18 +911,21 @@ bool Event::step (unsigned int ticks, int msps) {
}
}
return
false
;
return
this
;
}
}
void
Event
::
draw
(
unsigned
int
ticks
,
int
change
)
{
void
Event
::
draw
(
unsigned
int
ticks
,
int
change
)
{
Anim
*
anim
;
Anim
*
anim
;
signed
char
*
set
;
signed
char
*
set
;
int
count
;
int
count
;
if
(
next
)
next
->
draw
(
ticks
,
change
);
// Uncomment the following to see the area of the event
// Uncomment the following to see the area of the event
/*drawRect(FTOI(getDrawX(change) - viewX),
/*drawRect(FTOI(getDrawX(change) - viewX),
FTOI(getDrawY(change) - (viewY + getHeight())), FTOI(getWidth()),
FTOI(getDrawY(change) - (viewY + getHeight())), FTOI(getWidth()),
...
...
src/level/event/guardians.cpp
View file @
6a0cbf3f
...
@@ -32,14 +32,14 @@
...
@@ -32,14 +32,14 @@
#include "player/player.h"
#include "player/player.h"
DeckGuardian
::
DeckGuardian
(
unsigned
char
gX
,
unsigned
char
gY
,
Event
*
nextEvent
)
{
DeckGuardian
::
DeckGuardian
(
unsigned
char
gX
,
unsigned
char
gY
)
{
x
=
TTOF
(
gX
);
x
=
TTOF
(
gX
);
y
=
TTOF
(
gY
+
1
);
y
=
TTOF
(
gY
+
1
);
dx
=
0
;
dx
=
0
;
dy
=
0
;
dy
=
0
;
next
=
nextEvent
;
next
=
level
->
events
;
gridX
=
gX
;
gridX
=
gX
;
gridY
=
gY
;
gridY
=
gY
;
flashTime
=
0
;
flashTime
=
0
;
...
@@ -70,15 +70,15 @@ bool DeckGuardian::overlap (fixed left, fixed top, fixed width, fixed height) {
...
@@ -70,15 +70,15 @@ bool DeckGuardian::overlap (fixed left, fixed top, fixed width, fixed height) {
}
}
bool
DeckGuardian
::
step
(
unsigned
int
ticks
,
int
msps
)
{
Event
*
DeckGuardian
::
step
(
unsigned
int
ticks
,
int
msps
)
{
signed
char
*
set
;
signed
char
*
set
;
int
count
;
int
count
;
set
=
prepareStep
(
ticks
,
msps
);
set
=
prepareStep
(
ticks
,
msps
);
if
(
!
set
)
return
true
;
if
(
!
set
)
return
remove
()
;
// Handle behaviour
// Handle behaviour
...
@@ -111,7 +111,7 @@ bool DeckGuardian::step (unsigned int ticks, int msps) {
...
@@ -111,7 +111,7 @@ bool DeckGuardian::step (unsigned int ticks, int msps) {
// The event has been destroyed, so remove it
// The event has been destroyed, so remove it
level
->
clearEvent
(
gridX
,
gridY
);
level
->
clearEvent
(
gridX
,
gridY
);
return
true
;
return
remove
()
;
}
else
{
}
else
{
...
@@ -122,21 +122,21 @@ bool DeckGuardian::step (unsigned int ticks, int msps) {
...
@@ -122,21 +122,21 @@ bool DeckGuardian::step (unsigned int ticks, int msps) {
}
}
if
(
level
->
getStage
()
==
LS_END
)
return
false
;
return
this
;
return
false
;
}
}
void
DeckGuardian
::
draw
(
unsigned
int
ticks
,
int
change
)
{
void
DeckGuardian
::
draw
(
unsigned
int
ticks
,
int
change
)
{
Anim
*
anim
;
Anim
*
anim
;
signed
char
*
set
;
signed
char
*
set
;
int
count
;
int
count
;
if
(
next
)
next
->
draw
(
ticks
,
change
);
// Get the event properties
// Get the event properties
set
=
level
->
getEvent
(
gridX
,
gridY
);
set
=
level
->
getEvent
(
gridX
,
gridY
);
...
...
src/level/event/guardians.h
View file @
6a0cbf3f
...
@@ -35,11 +35,11 @@ class DeckGuardian : public Event {
...
@@ -35,11 +35,11 @@ class DeckGuardian : public Event {
int
stage
;
int
stage
;
public
:
public
:
DeckGuardian
(
unsigned
char
gX
,
unsigned
char
gY
,
Event
*
nextEvent
);
DeckGuardian
(
unsigned
char
gX
,
unsigned
char
gY
);
bool
overlap
(
fixed
left
,
fixed
top
,
fixed
width
,
fixed
height
);
bool
overlap
(
fixed
left
,
fixed
top
,
fixed
width
,
fixed
height
);
bool
step
(
unsigned
int
ticks
,
int
msps
);
Event
*
step
(
unsigned
int
ticks
,
int
msps
);
void
draw
(
unsigned
int
ticks
,
int
change
);
void
draw
(
unsigned
int
ticks
,
int
change
);
};
};
...
...
src/level/level.cpp
View file @
6a0cbf3f
...
@@ -92,32 +92,18 @@ Level::~Level () {
...
@@ -92,32 +92,18 @@ Level::~Level () {
stopMusic
();
stopMusic
();
// Free the palette effects
// Free the palette effects
if
(
firstPE
)
{
if
(
paletteEffects
)
{
delete
firstPE
;
delete
paletteEffects
;
firstPE
=
NULL
;
paletteEffects
=
NULL
;
}
}
// Free events
// Free events
if
(
firstEvent
)
{
if
(
events
)
delete
events
;
while
(
firstEvent
->
getNext
())
firstEvent
->
removeNext
();
delete
firstEvent
;
firstEvent
=
NULL
;
}
// Free bullets
// Free bullets
if
(
firstBullet
)
{
if
(
bullets
)
delete
bullets
;
while
(
firstBullet
->
getNext
())
firstBullet
->
removeNext
();
delete
firstBullet
;
firstBullet
=
NULL
;
}
for
(
count
=
0
;
count
<
PATHS
;
count
++
)
{
for
(
count
=
0
;
count
<
PATHS
;
count
++
)
{
...
@@ -527,7 +513,7 @@ int Level::play () {
...
@@ -527,7 +513,7 @@ int Level::play () {
timeBonus
=
-
1
;
timeBonus
=
-
1
;
perfect
=
0
;
perfect
=
0
;
use
Palette
(
palette
);
video
.
set
Palette
(
palette
);
while
(
true
)
{
while
(
true
)
{
...
@@ -580,16 +566,16 @@ int Level::play () {
...
@@ -580,16 +566,16 @@ int Level::play () {
if
(
!
gameMode
)
{
if
(
!
gameMode
)
{
// Don't want palette effects in setup menu
// Don't want palette effects in setup menu
levelPE
=
firstPE
;
levelPE
=
paletteEffects
;
firstPE
=
NULL
;
paletteEffects
=
NULL
;
if
(
menu
->
setup
()
==
E_QUIT
)
return
E_QUIT
;
if
(
menu
->
setup
()
==
E_QUIT
)
return
E_QUIT
;
// Restore level palette
// Restore level palette
use
Palette
(
palette
);
video
.
set
Palette
(
palette
);
// Restore palette effects
// Restore palette effects
firstPE
=
levelPE
;
paletteEffects
=
levelPE
;
}
}
...
@@ -659,7 +645,7 @@ int Level::play () {
...
@@ -659,7 +645,7 @@ int Level::play () {
// Draw statistics
// Draw statistics
drawStats
(
stats
);
drawStats
(
stats
,
BLACK
);
if
(
stage
==
LS_END
)
{
if
(
stage
==
LS_END
)
{
...
@@ -697,7 +683,7 @@ int Level::play () {
...
@@ -697,7 +683,7 @@ int Level::play () {
if
(
timeBonus
==
0
)
{
if
(
timeBonus
==
0
)
{
returnTime
=
ticks
+
T_END
;
returnTime
=
ticks
+
T_END
;
firstPE
=
new
WhiteOutPaletteEffect
(
T_END
,
firstPE
);
paletteEffects
=
new
WhiteOutPaletteEffect
(
T_END
,
paletteEffects
);
::
playSound
(
S_UPLOOP
);
::
playSound
(
S_UPLOOP
);
}
}
...
...
src/level/level.h
View file @
6a0cbf3f
...
@@ -52,6 +52,9 @@
...
@@ -52,6 +52,9 @@
#define PATHS 16
#define PATHS 16
#define TKEY 127
/* Tileset colour key */
#define TKEY 127
/* Tileset colour key */
// Black palette index
#define BLACK 31
// Fade delays
// Fade delays
#define T_START 500
#define T_START 500
#define T_END 1000
#define T_END 1000
...
@@ -72,10 +75,10 @@ typedef struct {
...
@@ -72,10 +75,10 @@ typedef struct {
typedef
struct
{
typedef
struct
{
short
int
*
x
;
short
int
*
x
;
short
int
*
y
;
short
int
*
y
;
unsigned
char
length
;
unsigned
char
length
;
unsigned
char
node
;
unsigned
char
node
;
}
EventPath
;
}
EventPath
;
...
@@ -90,42 +93,42 @@ class Scene;
...
@@ -90,42 +93,42 @@ class Scene;
class
Level
:
public
BaseLevel
{
class
Level
:
public
BaseLevel
{
private
:
private
:
char
*
sceneFile
;
char
*
sceneFile
;
Sprite
*
spriteSet
;
// 208 of which are usually in mainchar.000
Sprite
*
spriteSet
;
// 208 of which are usually in mainchar.000
Anim
animSet
[
ANIMS
];
Anim
animSet
[
ANIMS
];
char
miscAnims
[
4
];
char
miscAnims
[
4
];
signed
char
bulletSet
[
BULLETS
][
BLENGTH
];
signed
char
bulletSet
[
BULLETS
][
BLENGTH
];
signed
char
eventSet
[
EVENTS
][
ELENGTH
];
signed
char
eventSet
[
EVENTS
][
ELENGTH
];
char
mask
[
240
][
64
];
// At most 240 tiles, all with 8 * 8 masks
char
mask
[
240
][
64
];
// At most 240 tiles, all with 8 * 8 masks
GridElement
grid
[
LH
][
LW
];
// All levels are the same size
GridElement
grid
[
LH
][
LW
];
// All levels are the same size
int
soundMap
[
32
];
int
soundMap
[
32
];
SDL_Color
skyPalette
[
256
];
SDL_Color
skyPalette
[
256
];
bool
sky
;
bool
sky
;
unsigned
char
skyOrb
;
unsigned
char
skyOrb
;
int
sprites
;
int
sprites
;
int
levelNum
,
worldNum
,
nextLevelNum
,
nextWorldNum
;
int
levelNum
,
worldNum
,
nextLevelNum
,
nextWorldNum
;
unsigned
char
difficulty
;
unsigned
char
difficulty
;
int
enemies
;
int
enemies
;
fixed
waterLevel
;
fixed
waterLevel
;
fixed
waterLevelTarget
;
fixed
waterLevelTarget
;
fixed
waterLevelSpeed
;
fixed
waterLevelSpeed
;
fixed
energyBar
;
fixed
energyBar
;
int
loadSprites
(
char
*
fileName
);
int
loadSprites
(
char
*
fileName
);
int
loadTiles
(
char
*
fileName
);
int
loadTiles
(
char
*
fileName
);
protected
:
protected
:
int
load
(
char
*
fileName
,
unsigned
char
diff
,
bool
checkpoint
);
int
load
(
char
*
fileName
,
unsigned
char
diff
,
bool
checkpoint
);
int
step
();
int
step
();
void
draw
();
void
draw
();
public
:
public
:
Event
*
firstEvent
;
Event
*
events
;
Bullet
*
firstBullet
;
Bullet
*
bullets
;
EventPath
path
[
PATHS
];
EventPath
path
[
PATHS
];
Level
();
Level
();
Level
(
char
*
fileName
,
unsigned
char
diff
,
bool
checkpoint
);
Level
(
char
*
fileName
,
unsigned
char
diff
,
bool
checkpoint
);
virtual
~
Level
();
virtual
~
Level
();
bool
checkMask
(
fixed
x
,
fixed
y
);
bool
checkMask
(
fixed
x
,
fixed
y
);
...
@@ -133,23 +136,23 @@ class Level : public BaseLevel {
...
@@ -133,23 +136,23 @@ class Level : public BaseLevel {
bool
checkSpikes
(
fixed
x
,
fixed
y
);
bool
checkSpikes
(
fixed
x
,
fixed
y
);
void
setNext
(
int
nextLevel
,
int
nextWorld
);
void
setNext
(
int
nextLevel
,
int
nextWorld
);
void
setTile
(
unsigned
char
gridX
,
unsigned
char
gridY
,
unsigned
char
tile
);
void
setTile
(
unsigned
char
gridX
,
unsigned
char
gridY
,
unsigned
char
tile
);
signed
char
*
getEvent
(
unsigned
char
gridX
,
unsigned
char
gridY
);
signed
char
*
getEvent
(
unsigned
char
gridX
,
unsigned
char
gridY
);
unsigned
char
getEventHits
(
unsigned
char
gridX
,
unsigned
char
gridY
);
unsigned
char
getEventHits
(
unsigned
char
gridX
,
unsigned
char
gridY
);
unsigned
int
getEventTime
(
unsigned
char
gridX
,
unsigned
char
gridY
);
unsigned
int
getEventTime
(
unsigned
char
gridX
,
unsigned
char
gridY
);
void
clearEvent
(
unsigned
char
gridX
,
unsigned
char
gridY
);
void
clearEvent
(
unsigned
char
gridX
,
unsigned
char
gridY
);
int
hitEvent
(
unsigned
char
gridX
,
unsigned
char
gridY
,
Player
*
source
);
int
hitEvent
(
unsigned
char
gridX
,
unsigned
char
gridY
,
Player
*
source
);
void
setEventTime
(
unsigned
char
gridX
,
unsigned
char
gridY
,
unsigned
int
time
);
void
setEventTime
(
unsigned
char
gridX
,
unsigned
char
gridY
,
unsigned
int
time
);
signed
char
*
getBullet
(
unsigned
char
bullet
);
signed
char
*
getBullet
(
unsigned
char
bullet
);
Sprite
*
getSprite
(
unsigned
char
sprite
);
Sprite
*
getSprite
(
unsigned
char
sprite
);
Anim
*
getAnim
(
unsigned
char
anim
);
Anim
*
getAnim
(
unsigned
char
anim
);
Anim
*
getMiscAnim
(
unsigned
char
anim
);
Anim
*
getMiscAnim
(
unsigned
char
anim
);
void
setWaterLevel
(
unsigned
char
gridY
);
void
setWaterLevel
(
unsigned
char
gridY
);
fixed
getWaterLevel
();
fixed
getWaterLevel
();
void
playSound
(
int
sound
);
void
playSound
(
int
sound
);
void
setStage
(
LevelStage
stage
);
void
setStage
(
LevelStage
stage
);
LevelStage
getStage
();
LevelStage
getStage
();
Scene
*
createScene
();
Scene
*
createScene
();
void
receive
(
unsigned
char
*
buffer
);
void
receive
(
unsigned
char
*
buffer
);
virtual
int
play
();
virtual
int
play
();
};
};
...
@@ -158,10 +161,10 @@ class Level : public BaseLevel {
...
@@ -158,10 +161,10 @@ class Level : public BaseLevel {
class
DemoLevel
:
public
Level
{
class
DemoLevel
:
public
Level
{
private
:
private
:
unsigned
char
*
macro
;
unsigned
char
*
macro
;
public
:
public
:
DemoLevel
(
const
char
*
fileName
);
DemoLevel
(
const
char
*
fileName
);
~
DemoLevel
();
~
DemoLevel
();
int
play
();
int
play
();
...
@@ -171,7 +174,7 @@ class DemoLevel : public Level {
...
@@ -171,7 +174,7 @@ class DemoLevel : public Level {
// Variables
// Variables
EXTERN
Level
*
level
;
EXTERN
Level
*
level
;
EXTERN
fixed
viewX
,
viewY
;
EXTERN
fixed
viewX
,
viewY
;
#endif
#endif
...
...
src/level/levelframe.cpp
View file @
6a0cbf3f
...
@@ -42,8 +42,7 @@
...
@@ -42,8 +42,7 @@
int
Level
::
step
()
{
int
Level
::
step
()
{
Bullet
*
nextBullet
;
Event
*
event
;
Event
*
nextEvent
;
int
x
,
y
;
int
x
,
y
;
int
msps
;
int
msps
;
...
@@ -62,37 +61,37 @@ int Level::step () {
...
@@ -62,37 +61,37 @@ int Level::step () {
if
((
x
>=
0
)
&&
(
y
>=
0
)
&&
(
x
<
LW
)
&&
(
y
<
LH
)
&&
if
((
x
>=
0
)
&&
(
y
>=
0
)
&&
(
x
<
LW
)
&&
(
y
<
LH
)
&&
grid
[
y
][
x
].
event
&&
(
grid
[
y
][
x
].
event
<
121
))
{
grid
[
y
][
x
].
event
&&
(
grid
[
y
][
x
].
event
<
121
))
{
nextEvent
=
firstEvent
;
event
=
events
;
while
(
nextE
vent
)
{
while
(
e
vent
)
{
// If the event has been found, stop searching
// If the event has been found, stop searching
if
(
nextE
vent
->
isFrom
(
x
,
y
))
break
;
if
(
e
vent
->
isFrom
(
x
,
y
))
break
;
nextEvent
=
nextE
vent
->
getNext
();
event
=
e
vent
->
getNext
();
}
}
// If the event wasn't found, create it
// If the event wasn't found, create it
if
(
!
nextE
vent
)
{
if
(
!
e
vent
)
{
switch
(
getEvent
(
x
,
y
)[
E_BEHAVIOUR
])
{
switch
(
getEvent
(
x
,
y
)[
E_BEHAVIOUR
])
{
case
28
:
case
28
:
firstEvent
=
new
Bridge
(
x
,
y
,
firstEvent
);
events
=
new
Bridge
(
x
,
y
);
break
;
break
;
case
60
:
case
60
:
firstEvent
=
new
DeckGuardian
(
x
,
y
,
firstEvent
);
events
=
new
DeckGuardian
(
x
,
y
);
break
;
break
;
default
:
default
:
firstEvent
=
new
Event
(
x
,
y
,
firstEvent
);
events
=
new
Event
(
x
,
y
);
break
;
break
;
...
@@ -115,32 +114,12 @@ int Level::step () {
...
@@ -115,32 +114,12 @@ int Level::step () {
for
(
x
=
0
;
x
<
PATHS
;
x
++
)
path
[
x
].
node
=
(
ticks
>>
5
)
%
path
[
x
].
length
;
for
(
x
=
0
;
x
<
PATHS
;
x
++
)
path
[
x
].
node
=
(
ticks
>>
5
)
%
path
[
x
].
length
;
if
(
firstEvent
)
{
if
(
events
)
events
=
events
->
step
(
ticks
,
msps
);
if
(
firstEvent
->
step
(
ticks
,
msps
))
{
nextEvent
=
firstEvent
->
getNext
();
delete
firstEvent
;
firstEvent
=
nextEvent
;
}
}
// Process bullets
// Process bullets
if
(
firstBullet
)
{
if
(
bullets
)
bullets
=
bullets
->
step
(
ticks
,
msps
);
if
(
firstBullet
->
step
(
ticks
,
msps
))
{
nextBullet
=
firstBullet
->
getNext
();
delete
firstBullet
;
firstBullet
=
nextBullet
;
}
}
// Apply as much of those trajectories as possible, without going into the
// Apply as much of those trajectories as possible, without going into the
...
@@ -193,8 +172,6 @@ int Level::step () {
...
@@ -193,8 +172,6 @@ int Level::step () {
void
Level
::
draw
()
{
void
Level
::
draw
()
{
GridElement
*
ge
;
GridElement
*
ge
;
Event
*
event
;
Bullet
*
bullet
;
SDL_Rect
src
,
dst
;
SDL_Rect
src
,
dst
;
int
vX
,
vY
;
int
vX
,
vY
;
int
x
,
y
,
bgScale
;
int
x
,
y
,
bgScale
;
...
@@ -294,14 +271,7 @@ void Level::draw () {
...
@@ -294,14 +271,7 @@ void Level::draw () {
// Show active events
// Show active events
event
=
firstEvent
;
if
(
events
)
events
->
draw
(
ticks
,
change
);
while
(
event
)
{
event
->
draw
(
ticks
,
change
);
event
=
event
->
getNext
();
}
// Show the players
// Show the players
...
@@ -310,14 +280,7 @@ void Level::draw () {
...
@@ -310,14 +280,7 @@ void Level::draw () {
// Show bullets
// Show bullets
bullet
=
firstBullet
;
if
(
bullets
)
bullets
->
draw
(
change
);
while
(
bullet
)
{
bullet
->
draw
(
change
);
bullet
=
bullet
->
getNext
();
}
...
...
src/level/levelload.cpp
View file @
6a0cbf3f
...
@@ -472,7 +472,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
...
@@ -472,7 +472,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
}
}
use
Palette
(
menu
->
palettes
[
1
]);
video
.
set
Palette
(
menu
->
palettes
[
1
]);
clearScreen
(
0
);
clearScreen
(
0
);
...
@@ -909,7 +909,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
...
@@ -909,7 +909,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
sky
=
false
;
sky
=
false
;
// Free any existing palette effects
// Free any existing palette effects
if
(
firstPE
)
delete
firstPE
;
if
(
paletteEffects
)
delete
paletteEffects
;
switch
(
type
)
{
switch
(
type
)
{
...
@@ -918,35 +918,35 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
...
@@ -918,35 +918,35 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
sky
=
true
;
sky
=
true
;
// Sky background effect
// Sky background effect
firstPE
=
new
SkyPaletteEffect
(
156
,
100
,
FH
,
skyPalette
,
NULL
);
paletteEffects
=
new
SkyPaletteEffect
(
156
,
100
,
FH
,
skyPalette
,
NULL
);
break
;
break
;
case
8
:
case
8
:
// Parallaxing background effect
// Parallaxing background effect
firstPE
=
new
P2DPaletteEffect
(
128
,
64
,
FE
,
NULL
);
paletteEffects
=
new
P2DPaletteEffect
(
128
,
64
,
FE
,
NULL
);
break
;
break
;
case
9
:
case
9
:
// Diagonal stripes "parallaxing" background effect
// Diagonal stripes "parallaxing" background effect
firstPE
=
new
P1DPaletteEffect
(
128
,
32
,
FH
,
NULL
);
paletteEffects
=
new
P1DPaletteEffect
(
128
,
32
,
FH
,
NULL
);
break
;
break
;
case
11
:
case
11
:
// The deeper below water, the darker it gets
// The deeper below water, the darker it gets
firstPE
=
new
WaterPaletteEffect
(
TTOF
(
32
),
NULL
);
paletteEffects
=
new
WaterPaletteEffect
(
TTOF
(
32
),
NULL
);
break
;
break
;
default
:
default
:
// No effect
// No effect
firstPE
=
NULL
;
paletteEffects
=
NULL
;
break
;
break
;
...
@@ -958,31 +958,31 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
...
@@ -958,31 +958,31 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
// be
// be
// In Diamondus: The red/yellow palette animation
// In Diamondus: The red/yellow palette animation
firstPE
=
new
RotatePaletteEffect
(
112
,
4
,
F32
,
firstPE
);
paletteEffects
=
new
RotatePaletteEffect
(
112
,
4
,
F32
,
paletteEffects
);
// In Diamondus: The waterfall palette animation
// In Diamondus: The waterfall palette animation
firstPE
=
new
RotatePaletteEffect
(
116
,
8
,
F16
,
firstPE
);
paletteEffects
=
new
RotatePaletteEffect
(
116
,
8
,
F16
,
paletteEffects
);
// The following were discoverd by Unknown/Violet
// The following were discoverd by Unknown/Violet
firstPE
=
new
RotatePaletteEffect
(
124
,
3
,
F16
,
firstPE
);
paletteEffects
=
new
RotatePaletteEffect
(
124
,
3
,
F16
,
paletteEffects
);
if
((
type
!=
PE_1D
)
&&
(
type
!=
PE_2D
))
if
((
type
!=
PE_1D
)
&&
(
type
!=
PE_2D
))
firstPE
=
new
RotatePaletteEffect
(
132
,
8
,
F16
,
firstPE
);
paletteEffects
=
new
RotatePaletteEffect
(
132
,
8
,
F16
,
paletteEffects
);
if
((
type
!=
PE_SKY
)
&&
(
type
!=
PE_2D
))
if
((
type
!=
PE_SKY
)
&&
(
type
!=
PE_2D
))
firstPE
=
new
RotatePaletteEffect
(
160
,
32
,
-
F16
,
firstPE
);
paletteEffects
=
new
RotatePaletteEffect
(
160
,
32
,
-
F16
,
paletteEffects
);
if
(
type
!=
PE_SKY
)
{
if
(
type
!=
PE_SKY
)
{
firstPE
=
new
RotatePaletteEffect
(
192
,
32
,
-
F32
,
firstPE
);
paletteEffects
=
new
RotatePaletteEffect
(
192
,
32
,
-
F32
,
paletteEffects
);
firstPE
=
new
RotatePaletteEffect
(
224
,
16
,
F16
,
firstPE
);
paletteEffects
=
new
RotatePaletteEffect
(
224
,
16
,
F16
,
paletteEffects
);
}
}
// Level fade-in/white-in effect
// Level fade-in/white-in effect
if
(
checkpoint
)
firstPE
=
new
FadeInPaletteEffect
(
T_START
,
firstPE
);
if
(
checkpoint
)
paletteEffects
=
new
FadeInPaletteEffect
(
T_START
,
paletteEffects
);
else
firstPE
=
new
WhiteInPaletteEffect
(
T_START
,
firstPE
);
else
paletteEffects
=
new
WhiteInPaletteEffect
(
T_START
,
paletteEffects
);
file
->
seek
(
1
,
false
);
file
->
seek
(
1
,
false
);
...
@@ -1000,8 +1000,8 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
...
@@ -1000,8 +1000,8 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
endTime
=
(
5
-
difficulty
)
*
2
*
60
*
1000
;
endTime
=
(
5
-
difficulty
)
*
2
*
60
*
1000
;
firstBullet
=
NULL
;
events
=
NULL
;
firstEvent
=
NULL
;
bullets
=
NULL
;
energyBar
=
0
;
energyBar
=
0
;
...
...
src/main.cpp
View file @
6a0cbf3f
...
@@ -55,17 +55,16 @@
...
@@ -55,17 +55,16 @@
extern
char
KOpenJazzPath
[
256
];
extern
char
KOpenJazzPath
[
256
];
#endif
#endif
#ifdef SCALE
#include "io/gfx/scale2x/scalebit.h"
#endif
int
loadMain
(
int
argc
,
char
*
argv
[])
{
int
loadMain
(
int
argc
,
char
*
argv
[])
{
File
*
file
;
File
*
file
;
unsigned
char
*
pixels
,
*
sorted
;
unsigned
char
*
pixels
,
*
sorted
;
int
count
,
x
,
y
;
int
count
,
x
,
y
;
#ifndef SCALE
int
screenW
,
screenH
;
int
scaleFactor
;
int
scaleFactor
;
#ifndef FULLSCREEN_ONLY
bool
fullscreen
;
#endif
#endif
...
@@ -156,14 +155,17 @@ int loadMain (int argc, char *argv[]) {
...
@@ -156,14 +155,17 @@ int loadMain (int argc, char *argv[]) {
// Default settings
// Default settings
// Video settings
// Video settings
screenW
=
SW
;
screenW
=
SW
;
screenH
=
SH
;
screenH
=
SH
;
#ifdef SCALE
scaleFactor
=
1
;
#endif
#ifndef FULLSCREEN_ONLY
#ifndef FULLSCREEN_ONLY
fullscreen
=
false
;
fullscreen
=
false
;
#endif
#endif
// Sound settings
// Sound settings
#if defined(WIZ) || defined(GP2X)
#if defined(WIZ) || defined(GP2X)
volume
=
40
;
volume
=
40
;
...
@@ -208,8 +210,10 @@ int loadMain (int argc, char *argv[]) {
...
@@ -208,8 +210,10 @@ int loadMain (int argc, char *argv[]) {
#ifndef FULLSCREEN_ONLY
#ifndef FULLSCREEN_ONLY
fullscreen
=
scaleFactor
&
1
;
fullscreen
=
scaleFactor
&
1
;
#endif
#endif
#ifdef SCALE
scaleFactor
>>=
1
;
scaleFactor
>>=
1
;
if
(
scaleFactor
>
4
)
scaleFactor
=
1
;
if
(
scaleFactor
>
4
)
scaleFactor
=
1
;
#endif
// Read controls
// Read controls
...
@@ -263,25 +267,21 @@ int loadMain (int argc, char *argv[]) {
...
@@ -263,25 +267,21 @@ int loadMain (int argc, char *argv[]) {
#endif
#endif
// Generate the logical palette
for
(
count
=
0
;
count
<
256
;
count
++
)
logicalPalette
[
count
].
r
=
logicalPalette
[
count
].
g
=
logicalPalette
[
count
].
b
=
count
;
// Create the game's window
// Create the game's window
currentPalette
=
logicalPalette
;
canvas
=
NULL
;
canvas
=
screen
=
NULL
;
#ifndef FULLSCREEN_ONLY
if
(
fullscreen
)
#endif
SDL_ShowCursor
(
SDL_DISABLE
);
createScreen
();
#ifdef SCALE
video
.
setScaleFactor
(
scaleFactor
);
if
(
!
screen
)
{
#endif
#ifdef FULLSCREEN_ONLY
SDL_ShowCursor
(
SDL_DISABLE
);
#else
if
(
fullscreen
)
video
.
flipFullscreen
();
#endif
if
(
!
video
.
create
(
screenW
,
screenH
))
{
logError
(
"Could not set video mode"
,
SDL_GetError
());
logError
(
"Could not set video mode"
,
SDL_GetError
());
...
@@ -299,9 +299,7 @@ int loadMain (int argc, char *argv[]) {
...
@@ -299,9 +299,7 @@ int loadMain (int argc, char *argv[]) {
if
(
SDL_NumJoysticks
()
>
0
)
SDL_JoystickOpen
(
0
);
if
(
SDL_NumJoysticks
()
>
0
)
SDL_JoystickOpen
(
0
);
restorePalette
(
screen
);
paletteEffects
=
NULL
;
firstPE
=
NULL
;
// Set up audio
// Set up audio
...
@@ -461,9 +459,7 @@ void freeMain () {
...
@@ -461,9 +459,7 @@ void freeMain () {
File
*
file
;
File
*
file
;
int
count
;
int
count
;
#ifndef SCALE
int
scaleFactor
;
int
scaleFactor
=
1
;
#endif
delete
net
;
delete
net
;
...
@@ -482,10 +478,14 @@ void freeMain () {
...
@@ -482,10 +478,14 @@ void freeMain () {
SDL_FreeSurface
(
panelAmmo
[
3
]);
SDL_FreeSurface
(
panelAmmo
[
3
]);
SDL_FreeSurface
(
panelAmmo
[
4
]);
SDL_FreeSurface
(
panelAmmo
[
4
]);
#ifdef SCALE
#ifdef SCALE
if
(
canvas
!=
screen
)
SDL_FreeSurface
(
canvas
);
scaleFactor
=
video
.
getScaleFactor
();
#endif
if
(
scaleFactor
>
1
)
SDL_FreeSurface
(
canvas
);
#else
scaleFactor
=
1
;
#endif
closeAudio
();
closeAudio
();
...
@@ -507,11 +507,11 @@ void freeMain () {
...
@@ -507,11 +507,11 @@ void freeMain () {
file
->
storeChar
(
2
);
file
->
storeChar
(
2
);
// Write video settings
// Write video settings
file
->
storeShort
(
screenW
);
file
->
storeShort
(
video
.
getWidth
()
);
file
->
storeShort
(
screenH
);
file
->
storeShort
(
video
.
getHeight
());
scaleFactor
<<=
1
;
scaleFactor
<<=
1
;
#ifndef FULLSCREEN_ONLY
#ifndef FULLSCREEN_ONLY
scaleFactor
|=
fullscreen
?
1
:
0
;
scaleFactor
|=
video
.
isFullscreen
()
?
1
:
0
;
#endif
#endif
file
->
storeChar
(
scaleFactor
);
file
->
storeChar
(
scaleFactor
);
...
@@ -567,53 +567,16 @@ void freeMain () {
...
@@ -567,53 +567,16 @@ void freeMain () {
int
loop
(
LoopType
type
)
{
int
loop
(
LoopType
type
)
{
SDL_Color
shownPalette
[
256
];
SDL_Event
event
;
SDL_Event
event
;
int
prevTicks
,
ret
;
int
prevTicks
,
ret
;
#ifdef SCALE
if
(
canvas
!=
screen
)
{
// Copy everything that has been drawn so far
scale
(
scaleFactor
,
screen
->
pixels
,
screen
->
pitch
,
canvas
->
pixels
,
canvas
->
pitch
,
screen
->
format
->
BytesPerPixel
,
canvas
->
w
,
canvas
->
h
);
}
#endif
// Update tick count
// Update tick count
prevTicks
=
globalTicks
;
prevTicks
=
globalTicks
;
globalTicks
=
SDL_GetTicks
();
globalTicks
=
SDL_GetTicks
();
// Apply palette effects
if
(
firstPE
)
{
/* If the palette is being emulated, compile all palette changes and
apply them all at once.
If the palette is being used directly, apply all palette effects
directly. */
if
(
fakePalette
)
{
memcpy
(
shownPalette
,
currentPalette
,
sizeof
(
SDL_Color
)
*
256
);
firstPE
->
apply
(
shownPalette
,
false
,
globalTicks
-
prevTicks
);
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
shownPalette
,
0
,
256
);
}
else
{
firstPE
->
apply
(
shownPalette
,
true
,
globalTicks
-
prevTicks
);
}
}
// Show what has been drawn
// Show what has been drawn
SDL_Flip
(
screen
);
video
.
flip
(
globalTicks
-
prevTicks
);
// Process system events
// Process system events
...
@@ -628,10 +591,7 @@ int loop (LoopType type) {
...
@@ -628,10 +591,7 @@ int loop (LoopType type) {
if
((
event
.
key
.
keysym
.
sym
==
SDLK_RETURN
)
&&
if
((
event
.
key
.
keysym
.
sym
==
SDLK_RETURN
)
&&
(
event
.
key
.
keysym
.
mod
&
KMOD_ALT
))
{
(
event
.
key
.
keysym
.
mod
&
KMOD_ALT
))
{
fullscreen
=
!
fullscreen
;
video
.
flipFullscreen
();
SDL_ShowCursor
(
fullscreen
?
SDL_DISABLE
:
SDL_ENABLE
);
createScreen
();
}
}
#endif
#endif
...
@@ -668,17 +628,13 @@ int loop (LoopType type) {
...
@@ -668,17 +628,13 @@ int loop (LoopType type) {
#ifndef FULLSCREEN_ONLY
#ifndef FULLSCREEN_ONLY
case
SDL_VIDEORESIZE
:
case
SDL_VIDEORESIZE
:
screenW
=
event
.
resize
.
w
;
video
.
create
(
event
.
resize
.
w
,
event
.
resize
.
h
);
screenH
=
event
.
resize
.
h
;
createScreen
();
break
;
break
;
case
SDL_VIDEOEXPOSE
:
case
SDL_VIDEOEXPOSE
:
SDL_SetPalette
(
screen
,
SDL_LOGPAL
,
logicalPalette
,
0
,
256
);
video
.
expose
();
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
currentPalette
,
0
,
256
);
break
;
break
;
#endif
#endif
...
...
src/menu/gamemenu.cpp
View file @
6a0cbf3f
...
@@ -43,7 +43,7 @@ int Menu::newGameDifficulty (GameModeType mode, int levelNum, int worldNum) {
...
@@ -43,7 +43,7 @@ int Menu::newGameDifficulty (GameModeType mode, int levelNum, int worldNum) {
SDL_Rect
src
,
dst
;
SDL_Rect
src
,
dst
;
int
count
;
int
count
;
use
Palette
(
palettes
[
1
]);
video
.
set
Palette
(
palettes
[
1
]);
while
(
true
)
{
while
(
true
)
{
...
@@ -159,7 +159,7 @@ int Menu::newGameLevel (GameModeType mode) {
...
@@ -159,7 +159,7 @@ int Menu::newGameLevel (GameModeType mode) {
worldNum
=
levelNum
=
option
=
0
;
worldNum
=
levelNum
=
option
=
0
;
use
Palette
(
palettes
[
1
]);
video
.
set
Palette
(
palettes
[
1
]);
while
(
true
)
{
while
(
true
)
{
...
@@ -209,7 +209,7 @@ int Menu::newGameLevel (GameModeType mode) {
...
@@ -209,7 +209,7 @@ int Menu::newGameLevel (GameModeType mode) {
if
(
newGameDifficulty
(
mode
,
levelNum
,
worldNum
)
==
E_QUIT
)
if
(
newGameDifficulty
(
mode
,
levelNum
,
worldNum
)
==
E_QUIT
)
return
E_QUIT
;
return
E_QUIT
;
use
Palette
(
palettes
[
1
]);
video
.
set
Palette
(
palettes
[
1
]);
}
}
...
@@ -230,7 +230,7 @@ int Menu::newGameEpisode (GameModeType mode) {
...
@@ -230,7 +230,7 @@ int Menu::newGameEpisode (GameModeType mode) {
SDL_Rect
dst
;
SDL_Rect
dst
;
int
episode
,
count
,
worldNum
;
int
episode
,
count
,
worldNum
;
use
Palette
(
palettes
[
2
]);
video
.
set
Palette
(
palettes
[
2
]);
for
(
count
=
0
;
count
<
10
;
count
++
)
{
for
(
count
=
0
;
count
<
10
;
count
++
)
{
...
@@ -242,7 +242,7 @@ int Menu::newGameEpisode (GameModeType mode) {
...
@@ -242,7 +242,7 @@ int Menu::newGameEpisode (GameModeType mode) {
exists
[
count
]
=
fileExists
(
check
);
exists
[
count
]
=
fileExists
(
check
);
delete
[]
check
;
delete
[]
check
;
if
(
exists
[
count
])
restor
ePalette
(
screens
[
count
+
3
]);
if
(
exists
[
count
])
video
.
restoreSurfac
ePalette
(
screens
[
count
+
3
]);
else
else
SDL_SetPalette
(
screens
[
count
+
3
],
SDL_LOGPAL
,
palettes
[
3
],
0
,
256
);
SDL_SetPalette
(
screens
[
count
+
3
],
SDL_LOGPAL
,
palettes
[
3
],
0
,
256
);
...
@@ -327,7 +327,7 @@ int Menu::newGameEpisode (GameModeType mode) {
...
@@ -327,7 +327,7 @@ int Menu::newGameEpisode (GameModeType mode) {
}
}
use
Palette
(
palettes
[
2
]);
video
.
set
Palette
(
palettes
[
2
]);
}
}
...
...
src/menu/mainmenu.cpp
View file @
6a0cbf3f
...
@@ -52,7 +52,7 @@ int Menu::main () {
...
@@ -52,7 +52,7 @@ int Menu::main () {
option
=
suboption
=
0
;
option
=
suboption
=
0
;
use
Palette
(
palettes
[
0
]);
video
.
set
Palette
(
palettes
[
0
]);
// Demo timeout
// Demo timeout
idleTime
=
globalTicks
+
T_DEMO
;
idleTime
=
globalTicks
+
T_DEMO
;
...
@@ -171,7 +171,7 @@ int Menu::main () {
...
@@ -171,7 +171,7 @@ int Menu::main () {
}
}
// Restore the main menu palette
// Restore the main menu palette
use
Palette
(
palettes
[
0
]);
video
.
set
Palette
(
palettes
[
0
]);
// New demo timeout
// New demo timeout
idleTime
=
globalTicks
+
T_DEMO
;
idleTime
=
globalTicks
+
T_DEMO
;
...
@@ -222,7 +222,7 @@ int Menu::main () {
...
@@ -222,7 +222,7 @@ int Menu::main () {
playMusic
(
"menusng.psm"
);
playMusic
(
"menusng.psm"
);
// Restore the main menu palette
// Restore the main menu palette
use
Palette
(
palettes
[
0
]);
video
.
set
Palette
(
palettes
[
0
]);
idleTime
=
globalTicks
+
T_DEMO
;
idleTime
=
globalTicks
+
T_DEMO
;
...
...
src/menu/menuutil.cpp
View file @
6a0cbf3f
...
@@ -39,7 +39,7 @@ int Menu::message (const char* text) {
...
@@ -39,7 +39,7 @@ int Menu::message (const char* text) {
// Display a message to the user
// Display a message to the user
use
Palette
(
palettes
[
1
]);
video
.
set
Palette
(
palettes
[
1
]);
while
(
true
)
{
while
(
true
)
{
...
@@ -68,7 +68,7 @@ int Menu::generic (const char** optionNames, int options, int& chosen) {
...
@@ -68,7 +68,7 @@ int Menu::generic (const char** optionNames, int options, int& chosen) {
int
count
;
int
count
;
use
Palette
(
palettes
[
1
]);
video
.
set
Palette
(
palettes
[
1
]);
if
(
chosen
>=
options
)
chosen
=
0
;
if
(
chosen
>=
options
)
chosen
=
0
;
...
...
src/menu/setupmenu.cpp
View file @
6a0cbf3f
...
@@ -260,13 +260,16 @@ int Menu::setupResolution () {
...
@@ -260,13 +260,16 @@ int Menu::setupResolution () {
int
heightOptions
[]
=
{
200
,
240
,
300
,
384
,
400
,
480
,
576
,
600
,
720
,
768
,
int
heightOptions
[]
=
{
200
,
240
,
300
,
384
,
400
,
480
,
576
,
600
,
720
,
768
,
800
,
864
,
900
,
960
,
1024
,
1080
,
1200
};
800
,
864
,
900
,
960
,
1024
,
1080
,
1200
};
SDL_Rect
**
resolutions
;
SDL_Rect
**
resolutions
;
int
count
,
maxW
,
maxH
;
int
count
,
screenW
,
screenH
,
maxW
,
maxH
;
bool
dimension
;
bool
dimension
;
screenW
=
video
.
getWidth
();
screenH
=
video
.
getHeight
();
dimension
=
false
;
dimension
=
false
;
#ifndef FULLSCREEN_ONLY
#ifndef FULLSCREEN_ONLY
if
(
!
fullscreen
)
if
(
!
video
.
isFullscreen
()
)
resolutions
=
SDL_ListModes
(
NULL
,
WINDOWED_FLAGS
);
resolutions
=
SDL_ListModes
(
NULL
,
WINDOWED_FLAGS
);
else
else
#endif
#endif
...
@@ -389,7 +392,7 @@ int Menu::setupResolution () {
...
@@ -389,7 +392,7 @@ int Menu::setupResolution () {
if
(
count
)
{
if
(
count
)
{
playSound
(
S_ORB
);
playSound
(
S_ORB
);
createScreen
(
);
video
.
create
(
screenW
,
screenH
);
}
}
...
@@ -403,8 +406,10 @@ int Menu::setupResolution () {
...
@@ -403,8 +406,10 @@ int Menu::setupResolution () {
#ifdef SCALE
#ifdef SCALE
int
Menu
::
setupScaling
()
{
int
Menu
::
setupScaling
()
{
int
oldScaleFactor
;
int
scaleFactor
;
scaleFactor
=
video
.
getScaleFactor
();
if
(
scaleFactor
<
MIN_SCALE
||
scaleFactor
>
MAX_SCALE
)
if
(
scaleFactor
<
MIN_SCALE
||
scaleFactor
>
MAX_SCALE
)
scaleFactor
=
1
;
scaleFactor
=
1
;
...
@@ -432,7 +437,7 @@ int Menu::setupScaling () {
...
@@ -432,7 +437,7 @@ int Menu::setupScaling () {
fontmn2
->
mapPalette
(
240
,
8
,
114
,
16
);
fontmn2
->
mapPalette
(
240
,
8
,
114
,
16
);
// Scale
// Scale
fontmn2
->
showNumber
(
scaleFactor
,
(
canvasW
>>
2
)
+
32
,
canvasH
>>
1
);
fontmn2
->
showNumber
(
video
.
getScaleFactor
()
,
(
canvasW
>>
2
)
+
32
,
canvasH
>>
1
);
// X
// X
fontmn2
->
showString
(
"x"
,
(
canvasW
>>
2
)
+
40
,
canvasH
>>
1
);
fontmn2
->
showString
(
"x"
,
(
canvasW
>>
2
)
+
40
,
canvasH
>>
1
);
...
@@ -440,17 +445,15 @@ int Menu::setupScaling () {
...
@@ -440,17 +445,15 @@ int Menu::setupScaling () {
fontmn2
->
restorePalette
();
fontmn2
->
restorePalette
();
oldScaleFactor
=
scaleFactor
;
if
((
controls
.
release
(
C_DOWN
)
||
controls
.
release
(
C_LEFT
))
&&
(
scaleFactor
>
MIN_SCALE
))
scaleFactor
--
;
if
((
controls
.
release
(
C_DOWN
)
||
controls
.
release
(
C_LEFT
))
&&
(
scaleFactor
>
MIN_SCALE
))
scaleFactor
--
;
if
((
controls
.
release
(
C_UP
)
||
controls
.
release
(
C_RIGHT
))
&&
(
scaleFactor
<
MAX_SCALE
))
scaleFactor
++
;
if
((
controls
.
release
(
C_UP
)
||
controls
.
release
(
C_RIGHT
))
&&
(
scaleFactor
<
MAX_SCALE
))
scaleFactor
++
;
// Check for a scaling change
// Check for a scaling change
if
(
scaleFactor
!=
oldScaleFactor
)
{
if
(
scaleFactor
!=
video
.
getScaleFactor
()
)
{
playSound
(
S_ORB
);
playSound
(
S_ORB
);
createScreen
(
);
video
.
setScaleFactor
(
scaleFactor
);
}
}
...
...
src/player/bird.cpp
View file @
6a0cbf3f
...
@@ -80,7 +80,7 @@ void Bird::hit () {
...
@@ -80,7 +80,7 @@ void Bird::hit () {
bool
Bird
::
step
(
unsigned
int
ticks
,
int
msps
)
{
bool
Bird
::
step
(
unsigned
int
ticks
,
int
msps
)
{
Event
*
nextE
vent
;
Event
*
e
vent
;
bool
target
;
bool
target
;
if
(
fleeing
)
{
if
(
fleeing
)
{
...
@@ -156,25 +156,25 @@ bool Bird::step (unsigned int ticks, int msps) {
...
@@ -156,25 +156,25 @@ bool Bird::step (unsigned int ticks, int msps) {
// Check for nearby targets
// Check for nearby targets
target
=
false
;
target
=
false
;
nextEvent
=
level
->
firstEvent
;
event
=
level
->
events
;
if
(
player
->
getFacing
())
{
if
(
player
->
getFacing
())
{
while
(
nextE
vent
&&
!
target
)
{
while
(
e
vent
&&
!
target
)
{
target
=
nextEvent
->
isEnemy
()
&&
nextE
vent
->
overlap
(
x
,
y
,
F160
,
F100
);
target
=
event
->
isEnemy
()
&&
e
vent
->
overlap
(
x
,
y
,
F160
,
F100
);
nextEvent
=
nextE
vent
->
getNext
();
event
=
e
vent
->
getNext
();
}
}
}
else
{
}
else
{
while
(
nextE
vent
&&
!
target
)
{
while
(
e
vent
&&
!
target
)
{
target
=
nextEvent
->
isEnemy
()
&&
nextE
vent
->
overlap
(
x
-
F160
,
y
,
F160
,
F100
);
target
=
event
->
isEnemy
()
&&
e
vent
->
overlap
(
x
-
F160
,
y
,
F160
,
F100
);
nextEvent
=
nextE
vent
->
getNext
();
event
=
e
vent
->
getNext
();
}
}
...
@@ -183,7 +183,7 @@ bool Bird::step (unsigned int ticks, int msps) {
...
@@ -183,7 +183,7 @@ bool Bird::step (unsigned int ticks, int msps) {
// If there is a target in the vicinity, generate bullets
// If there is a target in the vicinity, generate bullets
if
(
target
)
{
if
(
target
)
{
level
->
firstBullet
=
new
Bullet
(
this
,
false
,
ticks
);
level
->
bullets
=
new
Bullet
(
this
,
false
,
ticks
);
fireTime
=
ticks
+
T_BIRD_FIRE
;
fireTime
=
ticks
+
T_BIRD_FIRE
;
...
...
src/player/bird.h
View file @
6a0cbf3f
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -45,19 +45,19 @@ class Player;
...
@@ -45,19 +45,19 @@ class Player;
class
Bird
:
public
Movable
{
class
Bird
:
public
Movable
{
private
:
private
:
Player
*
player
;
Player
*
player
;
bool
fleeing
;
bool
fleeing
;
unsigned
int
fireTime
;
unsigned
int
fireTime
;
public
:
public
:
Bird
(
Player
*
player
,
unsigned
char
gX
,
unsigned
char
gY
);
Bird
(
Player
*
player
,
unsigned
char
gX
,
unsigned
char
gY
);
~
Bird
();
~
Bird
();
void
reset
();
void
reset
();
Player
*
getPlayer
();
Player
*
getPlayer
();
void
hit
();
void
hit
();
bool
step
(
unsigned
int
ticks
,
int
msps
);
bool
step
(
unsigned
int
ticks
,
int
msps
);
void
draw
(
unsigned
int
ticks
,
int
change
);
void
draw
(
unsigned
int
ticks
,
int
change
);
};
};
...
...
src/player/player.cpp
View file @
6a0cbf3f
...
@@ -407,7 +407,7 @@ bool Player::takeEvent (unsigned char gridX, unsigned char gridY, unsigned int t
...
@@ -407,7 +407,7 @@ bool Player::takeEvent (unsigned char gridX, unsigned char gridY, unsigned int t
if
(
game
)
game
->
setBonus
(
0
);
if
(
game
)
game
->
setBonus
(
0
);
// Yellow flash
// Yellow flash
firstPE
=
new
FlashPaletteEffect
(
255
,
255
,
0
,
320
,
firstPE
);
paletteEffects
=
new
FlashPaletteEffect
(
255
,
255
,
0
,
320
,
paletteEffects
);
break
;
break
;
...
@@ -459,8 +459,7 @@ bool Player::touchEvent (unsigned char gridX, unsigned char gridY, unsigned int
...
@@ -459,8 +459,7 @@ bool Player::touchEvent (unsigned char gridX, unsigned char gridY, unsigned int
warpTime
=
ticks
+
T_WARP
;
warpTime
=
ticks
+
T_WARP
;
// White flash
// White flash
firstPE
=
paletteEffects
=
new
FlashPaletteEffect
(
255
,
255
,
255
,
T_WARP
,
paletteEffects
);
new
FlashPaletteEffect
(
255
,
255
,
255
,
T_WARP
,
firstPE
);
}
}
...
@@ -595,7 +594,7 @@ void Player::kill (Player *source, unsigned int ticks) {
...
@@ -595,7 +594,7 @@ void Player::kill (Player *source, unsigned int ticks) {
}
}
if
(
!
gameMode
)
firstPE
=
new
FadeOutPaletteEffect
(
T_END
,
firstPE
);
if
(
!
gameMode
)
paletteEffects
=
new
FadeOutPaletteEffect
(
T_END
,
paletteEffects
);
return
;
return
;
...
...
src/player/playerframe.cpp
View file @
6a0cbf3f
...
@@ -309,7 +309,7 @@ void Player::control (unsigned int ticks, int msps) {
...
@@ -309,7 +309,7 @@ void Player::control (unsigned int ticks, int msps) {
if
(
platform
)
animType
=
facing
?
PA_RSHOOT
:
PA_LSHOOT
;
if
(
platform
)
animType
=
facing
?
PA_RSHOOT
:
PA_LSHOOT
;
// Create new bullet
// Create new bullet
level
->
firstBullet
=
new
Bullet
(
this
,
false
,
ticks
);
level
->
bullets
=
new
Bullet
(
this
,
false
,
ticks
);
// Set when the next bullet can be fired
// Set when the next bullet can be fired
if
(
fireSpeed
)
fireTime
=
ticks
+
(
1000
/
fireSpeed
);
if
(
fireSpeed
)
fireTime
=
ticks
+
(
1000
/
fireSpeed
);
...
...
src/scene/scene.cpp
View file @
6a0cbf3f
...
@@ -230,7 +230,7 @@ int Scene::play () {
...
@@ -230,7 +230,7 @@ int Scene::play () {
if
(
newpage
)
{
if
(
newpage
)
{
//
firstPE = new FadeOutPaletteEffect(250, firstPE
);
//
paletteEffects = new FadeOutPaletteEffect(250, paletteEffects
);
textRect
.
x
=
0
;
textRect
.
x
=
0
;
textRect
.
y
=
0
;
textRect
.
y
=
0
;
...
@@ -242,12 +242,12 @@ int Scene::play () {
...
@@ -242,12 +242,12 @@ int Scene::play () {
if
(
palette
)
{
if
(
palette
)
{
use
Palette
(
palette
->
palette
);
video
.
set
Palette
(
palette
->
palette
);
// Fade in from black
// Fade in from black
firstPE
=
new
FadeInPaletteEffect
(
250
,
firstPE
);
paletteEffects
=
new
FadeInPaletteEffect
(
250
,
paletteEffects
);
}
else
restorePalette
(
screen
);
}
newpage
=
0
;
newpage
=
0
;
...
...
src/scene/sceneload.cpp
View file @
6a0cbf3f
...
@@ -117,7 +117,7 @@ void Scene::loadAni (File *f, int dataIndex) {
...
@@ -117,7 +117,7 @@ void Scene::loadAni (File *f, int dataIndex) {
if
(
!
background
)
background
=
f
->
loadSurface
(
SW
,
SH
);
if
(
!
background
)
background
=
f
->
loadSurface
(
SW
,
SH
);
// Use the most recently loaded palette
// Use the most recently loaded palette
use
Palette
(
palettes
->
palette
);
video
.
set
Palette
(
palettes
->
palette
);
break
;
break
;
...
...
src/util.cpp
View file @
6a0cbf3f
...
@@ -31,7 +31,6 @@
...
@@ -31,7 +31,6 @@
#include "io/file.h"
#include "io/file.h"
#include <iostream>
#include <string.h>
#include <string.h>
...
@@ -40,7 +39,7 @@ bool fileExists (const char * fileName) {
...
@@ -40,7 +39,7 @@ bool fileExists (const char * fileName) {
File
*
file
;
File
*
file
;
#ifdef VERBOSE
#ifdef VERBOSE
std
::
cout
<<
"Check: "
;
printf
(
"Check: "
)
;
#endif
#endif
try
{
try
{
...
@@ -152,39 +151,39 @@ char * createEditableString (const char *string) {
...
@@ -152,39 +151,39 @@ char * createEditableString (const char *string) {
}
}
void
log
(
const
char
*
message
)
{
void
log
(
const
char
*
message
)
{
std
::
cout
<<
message
<<
std
::
endl
;
printf
(
"%s
\n
"
,
message
);
return
;
return
;
}
}
void
log
(
const
char
*
message
,
const
char
*
detail
)
{
void
log
(
const
char
*
message
,
const
char
*
detail
)
{
std
::
cout
<<
message
<<
": "
<<
detail
<<
std
::
endl
;
printf
(
"%s: %s
\n
"
,
message
,
detail
);
return
;
return
;
}
}
void
log
(
const
char
*
message
,
int
number
)
{
void
log
(
const
char
*
message
,
int
number
)
{
std
::
cout
<<
message
<<
": "
<<
number
<<
std
::
endl
;
printf
(
"%s: %d
\n
"
,
message
,
number
);
return
;
return
;
}
}
void
logError
(
const
char
*
message
,
const
char
*
detail
)
{
void
logError
(
const
char
*
message
,
const
char
*
detail
)
{
std
::
cerr
<<
message
<<
": "
<<
detail
<<
std
::
endl
;
fprintf
(
stderr
,
"%s: %s
\n
"
,
message
,
detail
);
return
;
return
;
}
}
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