Skip to content

Commit fc5d695

Browse files
committed
Add frame for PSP version
1 parent a981a2b commit fc5d695

11 files changed

Lines changed: 89 additions & 34 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ if(VITA)
6060
elseif(PSP)
6161
create_pbp_file(
6262
TARGET ${PROJECT_NAME}
63-
ICON_PATH NULL
63+
ICON_PATH ${CMAKE_SOURCE_DIR}/platform/psp/ICON0.PNG
6464
BACKGROUND_PATH NULL
6565
PREVIEW_PATH NULL
6666
TITLE "Laser Kombat"

assets/images16x16/logo.bmp

6.47 KB
Binary file not shown.

include/Draw.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ class Draw {
2222
void BlitText(char * text, TTF_Font * font, int x, int y, SDL_Color color={0, 0, 0, 255});
2323
void Flip();
2424

25+
#if __PSP__
26+
void BlitFrame(SDL_Texture * logoSprite);
27+
#endif
28+
2529
int animation;
2630

2731
private:

include/Textures.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ class Textures {
2828
SDL_Texture * getMainBlocksSprite() { return mainBlocksSprite; };
2929
SDL_Texture * getCreditsSprite() { return creditsSprite; };
3030

31+
#ifdef __PSP__
32+
SDL_Texture * getLogoSprite() { return logoSprite; };
33+
#endif
34+
3135
private:
3236

3337
SDL_Renderer * renderer;
@@ -41,11 +45,15 @@ class Textures {
4145
SDL_Texture * staticSprites;
4246
SDL_Texture * tankSprites;
4347
SDL_Texture * teeSprites;
48+
SDL_Texture * waterSprite;
4449

4550
SDL_Texture * mainKeysSprite;
4651
SDL_Texture * mainBlocksSprite;
4752
SDL_Texture * creditsSprite;
48-
SDL_Texture * waterSprite;
53+
54+
#ifdef __PSP__
55+
SDL_Texture * logoSprite;
56+
#endif
4957

5058
SDL_Texture * loadImage(const std::string &filename);
5159
};

include/Tile.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ class MessageDied : public Static
10591059
virtual void Display() {
10601060
#ifdef __PSP__
10611061
const char * messages[] = {
1062-
"Press X to restart",
1062+
"Press Start to restart",
10631063
"O to undo move"
10641064
};
10651065
#else
@@ -1091,7 +1091,7 @@ class MessageDefeated : public Static
10911091
virtual void Display() {
10921092
#ifdef __PSP__
10931093
const char * messages[] = {
1094-
"Press X to continue",
1094+
"Press Start to continue",
10951095
};
10961096
#else
10971097
const char * messages[] = {

include/constants.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,39 @@
11
#ifndef CONSTANTS_H
22
#define CONSTANTS_H
33

4+
inline constexpr int COLUMNS = 20;
5+
inline constexpr int ROWS = 15;
6+
47
#if defined(NXDK)
8+
inline constexpr int BLOCK_SIZE = 40;
59
inline constexpr int WINDOW_WIDTH = 640;
610
inline constexpr int WINDOW_HEIGHT = 480;
7-
inline constexpr int BLOCK_SIZE = 40;
11+
inline constexpr int OFFSET_X = 0;
12+
inline constexpr int OFFSET_Y = 0;
813
inline constexpr bool LARGE_TEXTURES_SUPPORTED = true;
914
#elif defined(__vita__)
15+
inline constexpr int BLOCK_SIZE = 40;
1016
inline constexpr int WINDOW_WIDTH = 960;
1117
inline constexpr int WINDOW_HEIGHT = 544;
12-
inline constexpr int BLOCK_SIZE = 40;
18+
inline constexpr int OFFSET_X = 0;
19+
inline constexpr int OFFSET_Y = 0;
1320
inline constexpr bool LARGE_TEXTURES_SUPPORTED = true;
1421
#elif defined(__PSP__)
22+
inline constexpr int BLOCK_SIZE = 16;
1523
inline constexpr int WINDOW_WIDTH = 480;
1624
inline constexpr int WINDOW_HEIGHT = 272;
17-
inline constexpr int BLOCK_SIZE = 16;
25+
inline constexpr int OFFSET_X = 80;
26+
inline constexpr int OFFSET_Y = 32;
1827
inline constexpr bool LARGE_TEXTURES_SUPPORTED = false;
1928
#else
29+
inline constexpr int BLOCK_SIZE = 40;
2030
inline constexpr int WINDOW_WIDTH = 800;
2131
inline constexpr int WINDOW_HEIGHT = 600;
22-
inline constexpr int BLOCK_SIZE = 40;
32+
inline constexpr int OFFSET_X = 0;
33+
inline constexpr int OFFSET_Y = 0;
2334
inline constexpr bool LARGE_TEXTURES_SUPPORTED = true;
2435
#endif
2536

26-
inline constexpr int COLUMNS = 20;
27-
inline constexpr int ROWS = 15;
28-
2937
inline constexpr int BEAM_PERSISTANCE = 4; //beam lasts for this many 0.025 second intervals
3038

3139
inline constexpr char* TITLE = (char*) "Laser Kombat";

platform/psp/ICON0.PNG

2.75 KB
Loading

src/Board.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,9 @@ void Board::Animate() {
310310
DisplayKeysHelp();
311311
DisplayBlocksHelp();
312312
DisplayLevelInfo();
313+
#ifdef __PSP__
314+
draw->BlitFrame(textures->getLogoSprite());
315+
#endif
313316
draw->Flip();
314317
AfterAnimate();
315318
}

src/Draw.cpp

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ void Draw::BlitSquare(SDL_Texture * texture, int x, int y, int dx, int dy) {
2727
y *= BLOCK_SIZE;
2828
dx *= BLOCK_SIZE;
2929
dy *= BLOCK_SIZE;
30-
SDL_Rect sr={x,y,BLOCK_SIZE, BLOCK_SIZE};
31-
SDL_Rect dr={dx,dy,BLOCK_SIZE, BLOCK_SIZE};
30+
SDL_Rect sr={x, y, BLOCK_SIZE, BLOCK_SIZE};
31+
SDL_Rect dr={dx + OFFSET_X, dy + OFFSET_Y, BLOCK_SIZE, BLOCK_SIZE};
3232
SDL_RenderCopy(renderer, texture, &sr, &dr);
3333
}
3434

@@ -40,26 +40,26 @@ void Draw::BlitWater(SDL_Texture * texture, int rotation, int dx, int dy) {
4040
rotation = rotation % BLOCK_SIZE;
4141
dx *= BLOCK_SIZE;
4242
dy *= BLOCK_SIZE;
43-
SDL_Rect dr={dx + rotation, dy, BLOCK_SIZE - rotation, BLOCK_SIZE};
43+
SDL_Rect dr={dx + rotation + OFFSET_X, dy + OFFSET_Y, BLOCK_SIZE - rotation, BLOCK_SIZE};
4444
SDL_Rect sr={0, 0, BLOCK_SIZE - rotation, BLOCK_SIZE};
4545
SDL_RenderCopy(renderer, texture, &sr, &dr);
4646
if (rotation > 0) {
47-
SDL_Rect dr2={dx, dy, rotation, BLOCK_SIZE};
47+
SDL_Rect dr2={dx + OFFSET_X, dy + OFFSET_Y, rotation, BLOCK_SIZE};
4848
SDL_Rect sr2={BLOCK_SIZE - rotation, 0, rotation, BLOCK_SIZE};
4949
SDL_RenderCopy(renderer, texture, &sr2, &dr2);
5050
}
5151
}
5252

5353
void Draw::BlitOther(SDL_Texture * texture, int x, int y, int dx, int dy, int w, int h) {
54-
SDL_Rect sr={x,y,w,h};
55-
SDL_Rect dr={dx,dy,w, h};
54+
SDL_Rect sr={x, y, w, h};
55+
SDL_Rect dr={dx + OFFSET_X, dy + OFFSET_Y, w, h};
5656
SDL_RenderCopy(renderer, texture, &sr, &dr);
5757
}
5858

5959
void Draw::BlackSquare(int x, int y) {
6060
x *= BLOCK_SIZE;
6161
y *= BLOCK_SIZE;
62-
SDL_Rect r={x,y,BLOCK_SIZE,BLOCK_SIZE};
62+
SDL_Rect r={x + OFFSET_X, y + OFFSET_Y, BLOCK_SIZE, BLOCK_SIZE};
6363
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
6464
SDL_RenderFillRect(renderer, &r);
6565
}
@@ -70,26 +70,26 @@ void Draw::BlitBeam(int rotation, int x, int y) {
7070
SDL_Rect r={0, 0, 0, 0};
7171
switch(rotation) {
7272
case 0:
73-
r.x = x;
74-
r.y = y + (BLOCK_SIZE / 2) - 1;
75-
r.w = BLOCK_SIZE / 2 ;
73+
r.x = x + OFFSET_X;
74+
r.y = y + (BLOCK_SIZE / 2) - 1 + OFFSET_Y;
75+
r.w = BLOCK_SIZE / 2;
7676
r.h = 2;
7777
break;
7878
case 1:
79-
r.x = x + (BLOCK_SIZE / 2) - 1;
80-
r.y = y;
79+
r.x = x + (BLOCK_SIZE / 2) - 1 + OFFSET_X;
80+
r.y = y + OFFSET_Y;
8181
r.w = 2;
8282
r.h = BLOCK_SIZE / 2;
8383
break;
8484
case 2:
85-
r.x = x + BLOCK_SIZE / 2;
86-
r.y = y + (BLOCK_SIZE / 2) - 1;
85+
r.x = x + BLOCK_SIZE / 2 + OFFSET_X;
86+
r.y = y + (BLOCK_SIZE / 2) - 1 + OFFSET_Y;
8787
r.w = BLOCK_SIZE / 2;
8888
r.h = 2;
8989
break;
9090
case 3:
91-
r.x = x + (BLOCK_SIZE / 2) - 1;
92-
r.y = y + (BLOCK_SIZE / 2);
91+
r.x = x + (BLOCK_SIZE / 2) - 1 + OFFSET_X;
92+
r.y = y + (BLOCK_SIZE / 2) + OFFSET_Y;
9393
r.w = 2;
9494
r.h = BLOCK_SIZE;
9595
break;
@@ -140,7 +140,7 @@ void Draw::BlitMessage(const char *title, const char **lines, int line_count) {
140140
}
141141

142142
// Draw outside box
143-
SDL_Rect box = {(COLUMNS * BLOCK_SIZE / 2) - ((widest_line + 20) / 2), (ROWS * BLOCK_SIZE / 2) - ((text_height + 20) / 2), widest_line + 20, text_height + 20};
143+
SDL_Rect box = {(WINDOW_WIDTH / 2) - ((widest_line + 20) / 2), (WINDOW_HEIGHT / 2) - ((text_height + 20) / 2), widest_line + 20, text_height + 20};
144144
BlitMessageBox(&box);
145145

146146
// Draw text
@@ -219,7 +219,7 @@ void Draw::BlitMessageBox(SDL_Rect *box) {
219219

220220
void Draw::BlitLevelInfo(int level, char *description, char *author) {
221221
// Draw outside box
222-
SDL_Rect box = {(COLUMNS * BLOCK_SIZE / 2) - 153, (ROWS * BLOCK_SIZE / 2) - 73, 306, 146};
222+
SDL_Rect box = {(WINDOW_WIDTH / 2) - 153, (WINDOW_HEIGHT / 2) - 73, 306, 146};
223223
BlitMessageBox(&box);
224224

225225
// Generate level text
@@ -272,7 +272,6 @@ void Draw::BlitLevelInfo(int level, char *description, char *author) {
272272
SDL_RenderDrawLine(renderer, description_background.x, description_background.y + description_background.h, description_background.x + description_background.w, description_background.y + description_background.h);
273273
SDL_RenderDrawLine(renderer, description_background.x + description_background.w, description_background.y, description_background.x + description_background.w, description_background.y + description_background.h);
274274

275-
276275
SDL_Rect author_background = {box.x + 52, box.y + 98, box.w - (52 * 2), 20};
277276
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
278277
SDL_RenderFillRect(renderer, &author_background);
@@ -287,13 +286,13 @@ void Draw::BlitLevelInfo(int level, char *description, char *author) {
287286

288287

289288
// Draw info from level file
290-
SDL_Rect description_rect = {(COLUMNS * BLOCK_SIZE / 2), (ROWS * BLOCK_SIZE / 2) - 21, 0, 0};
289+
SDL_Rect description_rect = {(WINDOW_WIDTH / 2), (WINDOW_HEIGHT / 2) - 21, 0, 0};
291290
SDL_QueryTexture(description_text, NULL, NULL, &description_rect.w, &description_rect.h);
292291
description_rect.x -= description_rect.w/2;
293292
description_rect.y -= description_rect.h/2;
294293
SDL_RenderCopy(renderer, description_text, NULL, &description_rect);
295294

296-
SDL_Rect author_info_rect = {(COLUMNS * BLOCK_SIZE / 2), (ROWS * BLOCK_SIZE / 2) + 34, 0, 0};
295+
SDL_Rect author_info_rect = {(WINDOW_WIDTH / 2), (WINDOW_HEIGHT / 2) + 34, 0, 0};
297296
SDL_QueryTexture(author_info_text, NULL, NULL, &author_info_rect.w, &author_info_rect.h);
298297
author_info_rect.x -= author_info_rect.w/2;
299298
author_info_rect.y -= author_info_rect.h/2;
@@ -314,10 +313,30 @@ void Draw::BlitText(char * text, TTF_Font * font, int x, int y, SDL_Color color)
314313

315314
void Draw::Flip() {
316315
SDL_RenderPresent(renderer);
317-
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
316+
#ifdef __PSP__
317+
SDL_SetRenderDrawColor(renderer, 3, 103, 107, 255);
318+
#else
319+
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
320+
#endif
318321
SDL_RenderClear(renderer);
319322
}
320323

324+
#if __PSP__
325+
void Draw::BlitFrame(SDL_Texture * logoSprite) {
326+
SDL_SetRenderDrawColor(renderer, 2, 59, 60, 255);
327+
SDL_RenderDrawLine(renderer, OFFSET_X - 1, OFFSET_Y - 1, COLUMNS * BLOCK_SIZE + OFFSET_X, OFFSET_Y - 1);
328+
SDL_RenderDrawLine(renderer, OFFSET_X - 1, OFFSET_Y, OFFSET_X - 1, ROWS * BLOCK_SIZE + OFFSET_Y);
329+
330+
SDL_SetRenderDrawColor(renderer, 87, 247, 249, 255);
331+
SDL_RenderDrawLine(renderer, COLUMNS * BLOCK_SIZE + OFFSET_X, OFFSET_Y, COLUMNS * BLOCK_SIZE + OFFSET_X, ROWS * BLOCK_SIZE + OFFSET_Y);
332+
333+
SDL_Rect logo_rect = {COLUMNS * BLOCK_SIZE + OFFSET_X, 5, 0, 0};
334+
SDL_QueryTexture(logoSprite, NULL, NULL, &logo_rect.w, &logo_rect.h);
335+
logo_rect.x -= logo_rect.w;
336+
SDL_RenderCopy(renderer, logoSprite, NULL, &logo_rect);
337+
}
338+
#endif
339+
321340
SDL_Texture * Draw::stringToTexture(SDL_Renderer * renderer, char * text, TTF_Font * font, SDL_Color color) {
322341
SDL_Surface * surface = TTF_RenderText_Solid(font, text, color);
323342
if (surface == NULL) {

src/Textures.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ Textures::~Textures() {
2525
SDL_DestroyTexture(mainBlocksSprite);
2626
SDL_DestroyTexture(creditsSprite);
2727
}
28+
29+
#ifdef __PSP__
30+
SDL_DestroyTexture(logoSprite);
31+
#endif
2832
}
2933

3034
bool Textures::load() {
@@ -45,6 +49,13 @@ bool Textures::load() {
4549
creditsSprite = loadImage("credits.bmp");
4650
}
4751

52+
#ifdef __PSP__
53+
logoSprite = loadImage("logo.bmp");
54+
if (logoSprite == nullptr) {
55+
return false;
56+
}
57+
#endif
58+
4859
return
4960
barSprites != nullptr &&
5061
groundSprites != nullptr &&

0 commit comments

Comments
 (0)