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
30bfea2a
Commit
30bfea2a
authored
Apr 02, 2010
by
alistert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added #defines for 320 and 200. Changed some #defines to enums. Simplified panel data loading.
parent
93c4b9c1
Changes
24
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
222 additions
and
261 deletions
+222
-261
OpenJazz.h
src/OpenJazz.h
+11
-8
clientgame.cpp
src/game/clientgame.cpp
+3
-2
game.h
src/game/game.h
+4
-2
gamemode.cpp
src/game/gamemode.cpp
+10
-6
gamemode.h
src/game/gamemode.h
+22
-22
servergame.cpp
src/game/servergame.cpp
+2
-2
font.cpp
src/io/gfx/font.cpp
+32
-77
font.h
src/io/gfx/font.h
+1
-1
paletteeffects.cpp
src/io/gfx/paletteeffects.cpp
+1
-1
video.cpp
src/io/gfx/video.cpp
+4
-4
video.h
src/io/gfx/video.h
+9
-5
level.cpp
src/level/level.cpp
+3
-3
level.h
src/level/level.h
+12
-8
levelframe.cpp
src/level/levelframe.cpp
+7
-5
main.cpp
src/main.cpp
+23
-38
gamemenu.cpp
src/menu/gamemenu.cpp
+3
-3
mainmenu.cpp
src/menu/mainmenu.cpp
+5
-6
menu.cpp
src/menu/menu.cpp
+5
-5
menu.h
src/menu/menu.h
+7
-5
setupmenu.cpp
src/menu/setupmenu.cpp
+7
-6
player.cpp
src/player/player.cpp
+2
-2
player.h
src/player/player.h
+41
-42
scene.cpp
src/scene/scene.cpp
+7
-7
sceneload.cpp
src/scene/sceneload.cpp
+1
-1
No files found.
src/OpenJazz.h
View file @
30bfea2a
...
...
@@ -110,12 +110,6 @@
// Standard string length
#define STRING_LENGTH 32
// Loop return type
#define NORMAL_LOOP 0
#define TYPING_LOOP 1
#define SET_KEY_LOOP 2
#define SET_JOYSTICK_LOOP 3
// Return values
#define E_DATA -14
#define E_VERSION -13
...
...
@@ -151,6 +145,15 @@
#define DIV(x, y) (((x) << 10) / (y))
// Enum
enum
LoopType
{
NORMAL_LOOP
,
TYPING_LOOP
,
SET_KEY_LOOP
,
SET_JOYSTICK_LOOP
};
// Datatype
typedef
int
fixed
;
...
...
@@ -164,7 +167,7 @@ EXTERN unsigned int globalTicks;
// Functions in main.cpp
EXTERN
int
loop
(
int
type
);
EXTERN
int
loop
(
LoopType
type
);
// Functions in util.cpp
...
...
src/game/clientgame.cpp
View file @
30bfea2a
...
...
@@ -40,7 +40,8 @@ ClientGame::ClientGame (char *address) {
unsigned
char
buffer
[
BUFFER_LENGTH
];
unsigned
int
timeout
;
int
count
,
ret
,
mode
;
int
count
,
ret
;
GameModeType
mode
;
sock
=
net
->
join
(
address
);
...
...
@@ -108,7 +109,7 @@ ClientGame::ClientGame (char *address) {
printf
(
"Connected to server (version %d).
\n
"
,
buffer
[
2
]);
// Copy game parameters
mode
=
buffer
[
3
]
;
mode
=
GameModeType
(
buffer
[
3
])
;
difficulty
=
buffer
[
4
];
maxPlayers
=
buffer
[
5
];
nPlayers
=
buffer
[
6
];
...
...
src/game/game.h
View file @
30bfea2a
...
...
@@ -26,6 +26,8 @@
#define _GAME_H
#include "gamemode.h"
#include "io/network.h"
...
...
@@ -124,7 +126,7 @@ class ServerGame : public Game {
int
sock
;
public
:
ServerGame
(
int
mode
,
char
*
firstLevel
,
int
gameDifficulty
);
ServerGame
(
GameModeType
mode
,
char
*
firstLevel
,
int
gameDifficulty
);
~
ServerGame
();
int
setLevel
(
char
*
fileName
);
...
...
src/game/gamemode.cpp
View file @
30bfea2a
...
...
@@ -8,7 +8,7 @@
* 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
* the GNU General Public License, version 2.0
...
...
@@ -147,7 +147,7 @@ void TeamGameMode::drawScore () {
}
int
CoopGameMode
::
getMode
()
{
GameModeType
CoopGameMode
::
getMode
()
{
return
M_COOP
;
...
...
@@ -166,21 +166,21 @@ bool CoopGameMode::endOfLevel (Player *player, unsigned char gridX,
}
int
BattleGameMode
::
getMode
()
{
GameModeType
BattleGameMode
::
getMode
()
{
return
M_BATTLE
;
}
int
TeamBattleGameMode
::
getMode
()
{
GameModeType
TeamBattleGameMode
::
getMode
()
{
return
M_TEAMBATTLE
;
}
int
RaceGameMode
::
getMode
()
{
GameModeType
RaceGameMode
::
getMode
()
{
return
M_RACE
;
...
...
@@ -206,10 +206,14 @@ bool RaceGameMode::endOfLevel (Player *player, unsigned char gridX,
}
GameMode
*
createGameMode
(
int
mode
)
{
GameMode
*
createGameMode
(
GameModeType
mode
)
{
switch
(
mode
)
{
case
M_SINGLE
:
return
NULL
;
case
M_COOP
:
return
new
CoopGameMode
();
...
...
src/game/gamemode.h
View file @
30bfea2a
...
...
@@ -8,7 +8,7 @@
* 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
* the GNU General Public License, version 2.0
...
...
@@ -29,16 +29,18 @@
// Constants
// Game modes
#define M_SINGLE 0
#define M_COOP 1
#define M_BATTLE 2
#define M_TEAMBATTLE 3
#define M_RACE 4
#define MAX_PLAYERS (MAX_CLIENTS + 1)
// Enum
enum
GameModeType
{
M_SINGLE
=
0
,
M_COOP
=
1
,
M_BATTLE
=
2
,
M_TEAMBATTLE
=
3
,
M_RACE
=
4
};
// Classes
class
Player
;
...
...
@@ -46,13 +48,12 @@ class Player;
class
GameMode
{
public
:
virtual
int
getMode
()
=
0
;
virtual
GameModeType
getMode
()
=
0
;
virtual
unsigned
char
chooseTeam
()
=
0
;
virtual
void
drawScore
()
=
0
;
virtual
bool
hit
(
Player
*
source
,
Player
*
victim
);
virtual
bool
kill
(
Player
*
source
,
Player
*
victim
);
virtual
bool
endOfLevel
(
Player
*
player
,
unsigned
char
gridX
,
unsigned
char
gridY
);
virtual
bool
endOfLevel
(
Player
*
player
,
unsigned
char
gridX
,
unsigned
char
gridY
);
virtual
void
outOfTime
();
};
...
...
@@ -84,9 +85,8 @@ class TeamGameMode : public GameMode {
class
CoopGameMode
:
public
CooperativeGameMode
{
public
:
int
getMode
();
bool
endOfLevel
(
Player
*
player
,
unsigned
char
gridX
,
unsigned
char
gridY
);
GameModeType
getMode
();
bool
endOfLevel
(
Player
*
player
,
unsigned
char
gridX
,
unsigned
char
gridY
);
};
...
...
@@ -96,7 +96,7 @@ class BattleGameMode : public FreeForAllGameMode {
int
targetKills
;
public
:
int
getMode
();
GameModeType
getMode
();
};
...
...
@@ -106,7 +106,7 @@ class TeamBattleGameMode : public TeamGameMode {
int
targetKills
;
public
:
int
getMode
();
GameModeType
getMode
();
};
...
...
@@ -116,13 +116,13 @@ class RaceGameMode : public FreeForAllGameMode {
int
targetLaps
;
public
:
int
getMode
();
GameModeType
getMode
();
bool
hit
(
Player
*
source
,
Player
*
victim
);
bool
endOfLevel
(
Player
*
player
,
unsigned
char
gridX
,
unsigned
char
gridY
);
bool
endOfLevel
(
Player
*
player
,
unsigned
char
gridX
,
unsigned
char
gridY
);
};
// Variable
EXTERN
GameMode
*
gameMode
;
// NULL for single-player games
...
...
@@ -130,7 +130,7 @@ EXTERN GameMode *gameMode; // NULL for single-player games
// Function
GameMode
*
createGameMode
(
int
mode
);
GameMode
*
createGameMode
(
GameModeType
mode
);
#endif
...
...
src/game/servergame.cpp
View file @
30bfea2a
...
...
@@ -9,7 +9,7 @@
* 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
* the GNU General Public License, version 2.0
...
...
@@ -35,7 +35,7 @@
#include <string.h>
ServerGame
::
ServerGame
(
int
mode
,
char
*
firstLevel
,
int
gameDifficulty
)
{
ServerGame
::
ServerGame
(
GameModeType
mode
,
char
*
firstLevel
,
int
gameDifficulty
)
{
int
count
;
...
...
src/io/gfx/font.cpp
View file @
30bfea2a
...
...
@@ -150,101 +150,56 @@ Font::Font (const char * fileName) {
}
Font
::
Font
(
File
*
file
,
bool
big
)
{
Font
::
Font
(
unsigned
char
*
pixels
,
bool
big
)
{
unsigned
char
*
pixels
;
int
rle
,
pos
,
index
,
count
;
// Load font from panel.000
unsigned
char
*
chrPixels
;
int
count
,
y
;
if
(
big
)
lineHeight
=
8
;
else
lineHeight
=
7
;
pixels
=
new
unsigned
char
[
320
*
lineHeight
];
if
(
big
)
{
// Load the large panel font
// Starts at 4691 and goes 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-:.
chrPixels
=
new
unsigned
char
[
8
*
lineHeight
];
pixels
[
0
]
=
BLACK
;
pos
=
1
;
file
->
seek
(
4691
,
true
);
}
else
{
for
(
count
=
0
;
count
<
40
;
count
++
)
{
// Load the small panel font
// Starts at 6975 and goes 0123456789oo (where oo = infinity)
for
(
y
=
0
;
y
<
lineHeight
;
y
++
)
memcpy
(
chrPixels
+
(
y
*
8
),
pixels
+
(
count
*
8
)
+
(
y
*
SW
),
8
);
pos
=
0
;
file
->
seek
(
6975
,
true
);
characters
[
count
]
=
createSurface
(
chrPixels
,
8
,
lineHeight
);
}
// RLE decompression and horizontal to vertical character rearrangement
while
(
pos
<
320
*
lineHeight
)
{
rle
=
file
->
loadChar
();
if
(
rle
>=
128
)
{
index
=
file
->
loadChar
();
for
(
count
=
0
;
count
<
(
rle
&
127
);
count
++
)
{
pixels
[(
pos
&
7
)
+
((
pos
/
320
)
*
8
)
+
(((
pos
%
320
)
>>
3
)
*
8
*
lineHeight
)]
=
index
;
pos
++
;
}
}
else
if
(
rle
>
0
)
{
for
(
count
=
0
;
count
<
rle
;
count
++
)
{
pixels
[(
pos
&
7
)
+
((
pos
/
320
)
*
8
)
+
(((
pos
%
320
)
>>
3
)
*
8
*
lineHeight
)]
=
file
->
loadChar
();
pos
++
;
}
}
else
break
;
}
for
(
count
=
0
;
count
<
40
;
count
++
)
characters
[
count
]
=
createSurface
(
pixels
+
(
count
*
8
*
lineHeight
),
8
,
lineHeight
);
nCharacters
=
40
;
delete
[]
p
ixels
;
delete
[]
chrP
ixels
;
if
(
big
)
{
// Goes " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-:."
// Create ASCII->font map
for
(
count
=
0
;
count
<
45
;
count
++
)
map
[
count
]
=
39
;
map
[
45
]
=
3
6
;
map
[
46
]
=
3
8
;
for
(
count
=
47
;
count
<
48
;
count
++
)
map
[
count
]
=
39
;
for
(;
count
<
58
;
count
++
)
map
[
count
]
=
count
-
4
8
;
map
[
58
]
=
3
7
;
for
(
count
=
59
;
count
<
65
;
count
++
)
map
[
count
]
=
39
;
for
(;
count
<
91
;
count
++
)
map
[
count
]
=
count
-
5
5
;
for
(;
count
<
97
;
count
++
)
map
[
count
]
=
39
;
for
(;
count
<
123
;
count
++
)
map
[
count
]
=
count
-
8
7
;
for
(;
count
<
128
;
count
++
)
map
[
count
]
=
39
;
for
(
count
=
0
;
count
<
45
;
count
++
)
map
[
count
]
=
0
;
map
[
45
]
=
3
7
;
map
[
46
]
=
3
9
;
for
(
count
=
47
;
count
<
48
;
count
++
)
map
[
count
]
=
0
;
for
(;
count
<
58
;
count
++
)
map
[
count
]
=
count
-
4
7
;
map
[
58
]
=
3
8
;
for
(
count
=
59
;
count
<
65
;
count
++
)
map
[
count
]
=
0
;
for
(;
count
<
91
;
count
++
)
map
[
count
]
=
count
-
5
4
;
for
(;
count
<
97
;
count
++
)
map
[
count
]
=
0
;
for
(;
count
<
123
;
count
++
)
map
[
count
]
=
count
-
8
6
;
for
(;
count
<
128
;
count
++
)
map
[
count
]
=
0
;
}
else
{
// Goes " 0123456789oo" (where oo = infinity)
// Create ASCII->font map
for
(
count
=
0
;
count
<
48
;
count
++
)
map
[
count
]
=
12
;
for
(
count
=
0
;
count
<
48
;
count
++
)
map
[
count
]
=
0
;
// Use :; to represent the infinity symbol
for
(;
count
<
60
;
count
++
)
map
[
count
]
=
count
-
4
8
;
for
(;
count
<
128
;
count
++
)
map
[
count
]
=
12
;
for
(;
count
<
60
;
count
++
)
map
[
count
]
=
count
-
4
7
;
for
(;
count
<
128
;
count
++
)
map
[
count
]
=
0
;
}
...
...
src/io/gfx/font.h
View file @
30bfea2a
...
...
@@ -43,7 +43,7 @@ class Font {
public
:
Font
(
const
char
*
fileName
);
Font
(
File
*
file
,
bool
big
);
Font
(
unsigned
char
*
pixels
,
bool
big
);
~
Font
();
int
showString
(
const
char
*
s
,
int
x
,
int
y
);
...
...
src/io/gfx/paletteeffects.cpp
View file @
30bfea2a
...
...
@@ -387,7 +387,7 @@ void SkyPaletteEffect::apply (SDL_Color *shownPalette, bool direct, int mspf) {
position
=
viewY
+
(
viewH
<<
9
)
-
F4
;
if
(
canvasW
>
320
)
y
=
((
canvasH
-
1
)
/
100
)
+
1
;
if
(
canvasW
>
SW
)
y
=
((
canvasH
-
1
)
/
100
)
+
1
;
else
y
=
((
canvasH
-
34
)
/
100
)
+
1
;
count
=
(((
position
*
speed
)
/
y
)
>>
20
)
%
255
;
...
...
src/io/gfx/video.cpp
View file @
30bfea2a
...
...
@@ -67,18 +67,18 @@ void createScreen () {
#endif
#if defined(WIZ) || defined(GP2X)
screen
=
SDL_SetVideoMode
(
320
,
240
,
8
,
V_FULLSCREEN
);
screen
=
SDL_SetVideoMode
(
320
,
240
,
8
,
FULLSCREEN_FLAGS
);
#else
#ifdef FULLSCREEN_ONLY
screen
=
SDL_SetVideoMode
(
screenW
,
screenH
,
8
,
V_FULLSCREEN
);
screen
=
SDL_SetVideoMode
(
screenW
,
screenH
,
8
,
FULLSCREEN_FLAGS
);
#else
screen
=
SDL_SetVideoMode
(
screenW
,
screenH
,
8
,
fullscreen
?
V_FULLSCREEN
:
V_WINDOWED
);
screen
=
SDL_SetVideoMode
(
screenW
,
screenH
,
8
,
fullscreen
?
FULLSCREEN_FLAGS
:
WINDOWED_FLAGS
);
#endif
#endif
#ifdef SCALE
// Check that the scale will fit in the current resolution
while
(
((
screenW
/
320
<
scaleFactor
)
||
(
screenH
/
200
<
scaleFactor
))
&&
(
scaleFactor
>
1
)
)
{
while
(
((
screenW
/
SW
<
scaleFactor
)
||
(
screenH
/
SH
<
scaleFactor
))
&&
(
scaleFactor
>
1
)
)
{
scaleFactor
--
;
...
...
src/io/gfx/video.h
View file @
30bfea2a
...
...
@@ -20,8 +20,8 @@
*
*/
#ifndef _
GRAPHICS
_H
#define _
GRAPHICS
_H
#ifndef _
VIDEO
_H
#define _
VIDEO
_H
#include "OpenJazz.h"
...
...
@@ -31,12 +31,16 @@
// Constants
#define V_WINDOWED (SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE)
// Original screen dimensions
#define SW 320
#define SH 200
#define WINDOWED_FLAGS (SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE)
#if defined(WIZ) || defined(GP2X)
#define
V_FULLSCREEN
(SDL_FULLSCREEN | SDL_SWSURFACE | SDL_HWPALETTE)
#define
FULLSCREEN_FLAGS
(SDL_FULLSCREEN | SDL_SWSURFACE | SDL_HWPALETTE)
#else
#define
V_FULLSCREEN
(SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE)
#define
FULLSCREEN_FLAGS
(SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE)
#endif
#ifdef SCALE
...
...
src/level/level.cpp
View file @
30bfea2a
...
...
@@ -434,7 +434,7 @@ void Level::playSound (int sound) {
}
void
Level
::
setStage
(
int
newStage
)
{
void
Level
::
setStage
(
LevelStage
newStage
)
{
unsigned
char
buffer
[
MTL_L_STAGE
];
...
...
@@ -456,7 +456,7 @@ void Level::setStage (int newStage) {
}
int
Level
::
getStage
()
{
LevelStage
Level
::
getStage
()
{
return
stage
;
...
...
@@ -508,7 +508,7 @@ void Level::receive (unsigned char *buffer) {
case
MT_L_STAGE
:
stage
=
buffer
[
2
]
;
stage
=
LevelStage
(
buffer
[
2
])
;
break
;
...
...
src/level/level.h
View file @
30bfea2a
...
...
@@ -52,16 +52,20 @@
#define PATHS 16
#define TKEY 127
/* Tileset colour key */
// Stages
#define LS_NORMAL 0
#define LS_SUDDENDEATH 1
#define LS_END 2
// Fade delays
#define T_START 500
#define T_END 1000
// Enum
enum
LevelStage
{
LS_NORMAL
=
0
,
LS_SUDDENDEATH
=
1
,
LS_END
=
2
};
// Datatypes
typedef
struct
{
...
...
@@ -115,7 +119,7 @@ class Level : public BaseLevel {
fixed
waterLevelTarget
;
fixed
waterLevelSpeed
;
fixed
energyBar
;
int
stage
;
LevelStage
stage
;
int
loadSprites
(
char
*
fileName
);
int
loadTiles
(
char
*
fileName
);
...
...
@@ -153,8 +157,8 @@ class Level : public BaseLevel {
void
setWaterLevel
(
unsigned
char
gridY
);
fixed
getWaterLevel
();
void
playSound
(
int
sound
);
void
setStage
(
int
stage
);
int
getStage
();
void
setStage
(
LevelStage
stage
);
LevelStage
getStage
();
Scene
*
createScene
();
void
receive
(
unsigned
char
*
buffer
);
virtual
int
play
();
...
...
src/level/levelframe.cpp
View file @
30bfea2a
...
...
@@ -364,7 +364,7 @@ void Level::draw () {
dst
.
x
=
0
;
dst
.
y
=
canvasH
-
33
;
SDL_BlitSurface
(
panel
,
NULL
,
canvas
,
&
dst
);
drawRect
(
0
,
canvasH
-
1
,
320
,
1
,
BLACK
);
drawRect
(
0
,
canvasH
-
1
,
SW
,
1
,
BLACK
);
// Show panel data
...
...
@@ -400,10 +400,12 @@ void Level::draw () {
panelSmallFont
->
showNumber
(
levelNum
+
1
,
196
,
canvasH
-
13
);
// Show ammo
if
(
localPlayer
->
getAmmo
(
false
)
==
-
1
)
panelSmallFont
->
showString
(
":;"
,
225
,
canvasH
-
13
);
else
panelSmallFont
->
showNumber
(
localPlayer
->
getAmmo
(
true
),
245
,
canvasH
-
13
);
if
(
localPlayer
->
getAmmo
(
false
)
==
-
1
)
{
panelSmallFont
->
showString
(
":"
,
225
,
canvasH
-
13
);
panelSmallFont
->
showString
(
";"
,
233
,
canvasH
-
13
);
}
else
panelSmallFont
->
showNumber
(
localPlayer
->
getAmmo
(
true
),
245
,
canvasH
-
13
);
// Draw the health bar
...
...
src/main.cpp
View file @
30bfea2a
...
...
@@ -158,8 +158,8 @@ int loadMain (int argc, char *argv[]) {
// Default settings
// Video settings
screenW
=
320
;
screenH
=
200
;
screenW
=
SW
;
screenH
=
SH
;
#ifndef FULLSCREEN_ONLY
fullscreen
=
false
;
#endif
...
...
@@ -327,87 +327,73 @@ int loadMain (int argc, char *argv[]) {
}
// Load the panel background
panel
=
file
->
loadSurface
(
320
,
32
);
pixels
=
file
->
loadRLE
(
46272
);
delete
file
;
// Load the panel's ammo graphics
sorted
=
new
unsigned
char
[
64
*
27
];
// Create the panel background
panel
=
createSurface
(
pixels
,
SW
,
32
);
file
->
seek
(
7537
,
true
);
pixels
=
file
->
loadRLE
(
64
*
27
);
// De-scramble the panel's ammo graphics
sorted
=
new
unsigned
char
[
64
*
27
];
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)];
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
55
*
320
)
];
}
panelAmmo
[
0
]
=
createSurface
(
sorted
,
64
,
27
);
delete
[]
pixels
;
file
->
seek
(
8264
,
true
);
pixels
=
file
->
loadRLE
(
64
*
27
);
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)];
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
61
*
320
)
];
}
panelAmmo
[
1
]
=
createSurface
(
sorted
,
64
,
27
);
delete
[]
pixels
;
file
->
seek
(
9550
,
true
);
pixels
=
file
->
loadRLE
(
64
*
27
);
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)];
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
68
*
320
)
];
}
panelAmmo
[
2
]
=
createSurface
(
sorted
,
64
,
27
);
delete
[]
pixels
;
file
->
seek
(
11060
,
true
);
pixels
=
file
->
loadRLE
(
64
*
27
);
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)];
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
74
*
320
)
];
}
panelAmmo
[
3
]
=
createSurface
(
sorted
,
64
,
27
);
delete
[]
pixels
;
file
->
seek
(
12258
,
true
);
pixels
=
file
->
loadRLE
(
64
*
27
);
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)];
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
86
*
320
)
];
}
panelAmmo
[
4
]
=
createSurface
(
sorted
,
64
,
27
);
delete
[]
pixels
;
delete
[]
sorted
;
// Load fonts
panelBigFont
=
NULL
;
panelSmallFont
=
NULL
;
font2
=
NULL
;
...
...
@@ -417,8 +403,8 @@ int loadMain (int argc, char *argv[]) {
try
{
panelBigFont
=
new
Font
(
file
,
true
);
panelSmallFont
=
new
Font
(
file
,
false
);
panelBigFont
=
new
Font
(
pixels
+
(
40
*
320
)
,
true
);
panelSmallFont
=
new
Font
(
pixels
+
(
48
*
320
)
,
false
);
font2
=
new
Font
(
"font2.0fn"
);
fontbig
=
new
Font
(
"fontbig.0fn"
);
fontiny
=
new
Font
(
"fontiny.0fn"
);
...
...
@@ -434,6 +420,8 @@ int loadMain (int argc, char *argv[]) {
if
(
fontiny
)
delete
fontiny
;
if
(
fontmn1
)
delete
fontmn1
;
delete
[]
pixels
;
SDL_FreeSurface
(
panel
);
SDL_FreeSurface
(
panelAmmo
[
0
]);
SDL_FreeSurface
(
panelAmmo
[
1
]);
...
...
@@ -447,14 +435,11 @@ int loadMain (int argc, char *argv[]) {
delete
firstPath
;
delete
file
;
return
e
;
}
delete
file
;
delete
[]
pixels
;
// Establish arbitrary timing
...
...
@@ -578,7 +563,7 @@ void freeMain () {
}
int
loop
(
int
type
)
{
int
loop
(
LoopType
type
)
{
SDL_Color
shownPalette
[
256
];
SDL_Event
event
;
...
...
src/menu/gamemenu.cpp
View file @
30bfea2a
...
...
@@ -36,7 +36,7 @@
#include "io/sound.h"
int
Menu
::
newGameDifficulty
(
int
mode
,
int
levelNum
,
int
worldNum
)
{
int
Menu
::
newGameDifficulty
(
GameModeType
mode
,
int
levelNum
,
int
worldNum
)
{
const
char
*
options
[
4
]
=
{
"easy"
,
"medium"
,
"hard"
,
"turbo"
};
char
*
firstLevel
;
...
...
@@ -153,7 +153,7 @@ int Menu::newGameDifficulty (int mode, int levelNum, int worldNum) {
}
int
Menu
::
newGameLevel
(
int
mode
)
{
int
Menu
::
newGameLevel
(
GameModeType
mode
)
{
int
option
,
worldNum
,
levelNum
;
...
...
@@ -220,7 +220,7 @@ int Menu::newGameLevel (int mode) {
}
int
Menu
::
newGameEpisode
(
int
mode
)
{
int
Menu
::
newGameEpisode
(
GameModeType
mode
)
{
const
char
*
options
[
12
]
=
{
"episode 1"
,
"episode 2"
,
"episode 3"
,
"episode 4"
,
"episode 5"
,
"episode 6"
,
"episode a"
,
"episode b"
,
...
...
src/menu/mainmenu.cpp
View file @
30bfea2a
...
...
@@ -89,8 +89,7 @@ int Menu::main () {
}
else
{
if
(
newGameEpisode
(
suboption
)
==
E_QUIT
)
return
E_QUIT
;
if
(
newGameEpisode
(
GameModeType
(
suboption
))
==
E_QUIT
)
return
E_QUIT
;
}
...
...
@@ -237,8 +236,8 @@ int Menu::main () {
dst
.
y
=
canvasH
-
(
canvasH
>>
2
);
SDL_BlitSurface
(
screens
[
14
],
NULL
,
canvas
,
&
dst
);
dst
.
x
=
(
canvasW
-
320
)
>>
1
;
dst
.
y
=
(
canvasH
-
200
)
>>
1
;
dst
.
x
=
(
canvasW
-
SW
)
>>
1
;
dst
.
y
=
(
canvasH
-
SH
)
>>
1
;
SDL_BlitSurface
(
screens
[
0
],
NULL
,
canvas
,
&
dst
);
switch
(
option
)
{
...
...
@@ -299,8 +298,8 @@ int Menu::main () {
}
dst
.
x
=
((
canvasW
-
320
)
>>
1
)
+
src
.
x
;
dst
.
y
=
((
canvasH
-
200
)
>>
1
)
+
src
.
y
;
dst
.
x
=
((
canvasW
-
SW
)
>>
1
)
+
src
.
x
;
dst
.
y
=
((
canvasH
-
SH
)
>>
1
)
+
src
.
y
;
SDL_BlitSurface
(
screens
[
1
],
&
src
,
canvas
,
&
dst
);
}
...
...
src/menu/menu.cpp
View file @
30bfea2a
...
...
@@ -84,8 +84,8 @@ Menu::Menu () {
// Load the main menu graphics
file
->
loadPalette
(
palettes
[
0
]);
screens
[
0
]
=
file
->
loadSurface
(
320
,
200
);
screens
[
1
]
=
file
->
loadSurface
(
320
,
200
);
screens
[
0
]
=
file
->
loadSurface
(
SW
,
SH
);
screens
[
1
]
=
file
->
loadSurface
(
SW
,
SH
);
if
(
file
->
getSize
()
>
200000
)
{
...
...
@@ -98,8 +98,8 @@ Menu::Menu () {
SDL_FreeSurface
(
screens
[
0
]);
SDL_FreeSurface
(
screens
[
1
]);
file
->
loadPalette
(
palettes
[
0
]);
screens
[
0
]
=
file
->
loadSurface
(
320
,
200
);
screens
[
1
]
=
file
->
loadSurface
(
320
,
200
);
screens
[
0
]
=
file
->
loadSurface
(
SW
,
SH
);
screens
[
1
]
=
file
->
loadSurface
(
SW
,
SH
);
}
else
{
...
...
@@ -117,7 +117,7 @@ Menu::Menu () {
// Load the difficulty graphics
file
->
loadPalette
(
palettes
[
1
]);
screens
[
2
]
=
file
->
loadSurface
(
320
,
200
);
screens
[
2
]
=
file
->
loadSurface
(
SW
,
SH
);
SDL_SetColorKey
(
screens
[
2
],
SDL_SRCCOLORKEY
,
0
);
// Default difficulty setting
...
...
src/menu/menu.h
View file @
30bfea2a
...
...
@@ -8,7 +8,7 @@
* 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
* the GNU General Public License, version 2.0
...
...
@@ -24,6 +24,8 @@
#define _MENU_H
#include "game/gamemode.h"
#include "OpenJazz.h"
#include <SDL/SDL.h>
...
...
@@ -46,9 +48,9 @@ class Menu {
int
message
(
const
char
*
text
);
int
generic
(
const
char
**
optionNames
,
int
options
,
int
*
chosen
);
int
textInput
(
const
char
*
request
,
char
**
text
);
int
newGameDifficulty
(
int
mode
,
int
levelNum
,
int
worldNum
);
int
newGameLevel
(
int
mode
);
int
newGameEpisode
(
int
mode
);
int
newGameDifficulty
(
GameModeType
mode
,
int
levelNum
,
int
worldNum
);
int
newGameLevel
(
GameModeType
mode
);
int
newGameEpisode
(
GameModeType
mode
);
int
joinGame
();
int
loadGame
();
int
setupKeyboard
();
...
...
src/menu/setupmenu.cpp
View file @
30bfea2a
...
...
@@ -267,10 +267,10 @@ int Menu::setupResolution () {
#ifndef FULLSCREEN_ONLY
if
(
!
fullscreen
)
resolutions
=
SDL_ListModes
(
NULL
,
V_WINDOWED
);
resolutions
=
SDL_ListModes
(
NULL
,
WINDOWED_FLAGS
);
else
#endif
resolutions
=
SDL_ListModes
(
NULL
,
V_FULLSCREEN
);
resolutions
=
SDL_ListModes
(
NULL
,
FULLSCREEN_FLAGS
);
#if defined(WIZ) || defined(GP2X)
...
...
@@ -283,8 +283,9 @@ int Menu::setupResolution () {
maxH
=
1200
;
}
else
{
maxW
=
320
;
maxH
=
200
;
maxW
=
SW
;
maxH
=
SH
;
for
(
count
=
0
;
resolutions
[
count
]
!=
NULL
;
count
++
)
{
...
...
@@ -360,7 +361,7 @@ int Menu::setupResolution () {
if
(
controls
.
release
(
C_DOWN
))
{
if
((
!
dimension
)
&&
(
screenW
>
320
))
{
if
((
!
dimension
)
&&
(
screenW
>
SW
))
{
count
=
13
;
...
...
@@ -371,7 +372,7 @@ int Menu::setupResolution () {
}
if
(
dimension
&&
(
screenH
>
200
))
{
if
(
dimension
&&
(
screenH
>
SH
))
{
count
=
16
;
...
...
src/player/player.cpp
View file @
30bfea2a
...
...
@@ -870,9 +870,9 @@ void Player::receive (unsigned char *buffer) {
}
int
Player
::
reacted
(
unsigned
int
ticks
)
{
PlayerReaction
Player
::
reacted
(
unsigned
int
ticks
)
{
int
oldReaction
;
PlayerReaction
oldReaction
;
if
((
reaction
!=
PR_NONE
)
&&
(
reactionTime
<
ticks
))
{
...
...
src/player/player.h
View file @
30bfea2a
...
...
@@ -77,16 +77,6 @@
#define PA_RSPRING 36
#define PA_LSPRING 37
/* Surely these are the wrong way round? */
// Player facing
#define PF_LEFT 0
#define PF_RIGHT 1
// Player reactions
#define PR_NONE 0
#define PR_HURT 1
#define PR_KILLED 2
#define PR_INVINCIBLE 3
// Player reaction times
#define PRT_HURT 1000
#define PRT_HURTANIM 200
...
...
@@ -159,6 +149,15 @@
#define PCONTROLS 8
/* Number of player controls. */
// Enum
enum
PlayerReaction
{
PR_NONE
,
PR_HURT
,
PR_KILLED
,
PR_INVINCIBLE
};
// Classes
class
Anim
;
...
...
@@ -187,7 +186,7 @@ class Player : public Movable {
unsigned
char
eventY
;
/* Position of an event (spring, platform, bridge) */
int
event
;
/* 0 = none, 1 = spring, 2 = float up, 3 = platform, 4 = bridge */
int
lookTime
;
/* Negative if looking up, positive if looking down, 0 if neither */
int
reaction
;
PlayerReaction
reaction
;
unsigned
int
reactionTime
;
int
fireSpeed
;
unsigned
int
fireTime
;
...
...
@@ -241,7 +240,7 @@ class Player : public Movable {
void
bonusStep
(
unsigned
int
ticks
,
int
msps
);
void
view
(
unsigned
int
ticks
,
int
mspf
);
void
draw
(
unsigned
int
ticks
,
int
change
);
int
reacted
(
unsigned
int
ticks
);
PlayerReaction
reacted
(
unsigned
int
ticks
);
};
...
...
src/scene/scene.cpp
View file @
30bfea2a
...
...
@@ -195,7 +195,7 @@ int Scene::play () {
unsigned
int
lastTicks
=
globalTicks
;
int
newpage
=
true
;
int
fadein
=
false
;
SDL_Rect
textRect
=
{
0
,
0
,
320
,
200
};
SDL_Rect
textRect
=
{
0
,
0
,
SW
,
SH
};
while
(
true
)
{
...
...
@@ -230,8 +230,8 @@ int Scene::play () {
textRect
.
x
=
0
;
textRect
.
y
=
0
;
textRect
.
w
=
320
;
textRect
.
h
=
200
;
textRect
.
w
=
SW
;
textRect
.
h
=
SH
;
ScenePalette
*
palette
=
palettes
;
while
(
palette
&&
(
palette
->
id
!=
pages
[
sceneIndex
].
paletteIndex
))
palette
=
palette
->
next
;
...
...
@@ -260,8 +260,8 @@ int Scene::play () {
if
(
image
)
{
dst
.
x
=
(
pages
[
sceneIndex
].
bgPos
[
bg
]
&
65535
)
*
2
+
(
canvasW
-
320
)
>>
1
;
dst
.
y
=
((
pages
[
sceneIndex
].
bgPos
[
bg
]
&
(
~
65535
))
>>
16
)
*
2
+
(
canvasH
-
200
)
>>
1
;
dst
.
x
=
(
pages
[
sceneIndex
].
bgPos
[
bg
]
&
65535
)
*
2
+
(
canvasW
-
SW
)
>>
1
;
dst
.
y
=
((
pages
[
sceneIndex
].
bgPos
[
bg
]
&
(
~
65535
))
>>
16
)
*
2
+
(
canvasH
-
SH
)
>>
1
;
SDL_BlitSurface
(
image
->
image
,
NULL
,
canvas
,
&
dst
);
}
...
...
@@ -315,8 +315,8 @@ int Scene::play () {
}
xOffset
=
((
canvasW
-
320
)
>>
1
)
+
textRect
.
x
+
x
;
yOffset
=
((
canvasH
-
200
)
>>
1
)
+
textRect
.
y
+
y
;
xOffset
=
((
canvasW
-
SW
)
>>
1
)
+
textRect
.
x
+
x
;
yOffset
=
((
canvasH
-
SH
)
>>
1
)
+
textRect
.
y
+
y
;
switch
(
text
->
alignment
)
{
...
...
src/scene/sceneload.cpp
View file @
30bfea2a
...
...
@@ -116,7 +116,7 @@ void Scene::loadAni (File *f, int dataIndex) {
// Skip back size header, this is read by the surface reader
f
->
seek
(
-
2
,
false
);
SDL_Surface
*
image
=
f
->
loadSurface
(
320
,
200
);
SDL_Surface
*
image
=
f
->
loadSurface
(
SW
,
SH
);
SDL_BlitSurface
(
image
,
NULL
,
canvas
,
NULL
);
SDL_FreeSurface
(
image
);
...
...
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