Skip to content

Commit 359f976

Browse files
author
JulianoFlores
committed
V18 - SRAM / Bugfixes
- Added SDCC and SEGA Headers. - First version of SRAM Support. (saves highscore) (issue #2 on github). - Added function to clear SRAM by pressing pause on the title screen, it shows a screen to inform the player. - Updated build.bat to pad the rom to 64kb to be able to use SRAM. - Fixed issue #1 (player death not playing when gameover comes from a shot).
1 parent 0f33e86 commit 359f976

File tree

3 files changed

+65
-32
lines changed

3 files changed

+65
-32
lines changed

README.MD

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,29 @@ Otherwise you might need to execute the commands yourself.
2222

2323
There's a PHP companion tool, to convert Tiled's CSV output to C Array used in the code.
2424

25-
## Instructions:
26-
- Move the ship with the D-Pad
27-
- Hold Button 1 to use the speed boost.
25+
All the assets (code, graphics and music) were created by tibonev.
26+
Everything is licensed under the MIT License (check out LICENSE for more info).
27+
(c) 2024 tibonev.
2828

29+
## Game:
2930
Your mission, choose you accept it is to recover all the sattelites without getting shot by the turrets, good luck.
3031
Oh yeah, there's a time limit also. oops.
3132

32-
All the assets (code, graphics and music) were created by tibonev.
33-
Everything is licensed under the MIT License (check out LICENSE for more info).
34-
(c) 2024 tibonev.
33+
### Instructions:
34+
- Move the ship with the D-Pad
35+
- Hold Button 1 to use the speed boost.
36+
37+
- Clean the SRAM (delete save high score) press PAUSE on the title screen.
3538

3639
### Version History:
3740

41+
V0.18 (08/04/24)
42+
- Added SDCC and SEGA Headers.
43+
- First version of SRAM Support. (saves highscore) (issue #2 on github).
44+
- Added function to clear SRAM by pressing pause on the title screen, it shows a screen to inform the player.
45+
- Updated build.bat to pad the rom to 64kb to be able to use SRAM.
46+
- Fixed issue #1 (player death not playing when gameover comes from a shot).
47+
3848
V0.17 (01/04/24)
3949
- Updated to lastest version of PSGLib, fixed the ringing tone on Square Channel 2, after an sfx has played.
4050
- Altered death-loop situation, now the level always fully reset (all sattelites and time resets) at each death.
@@ -116,14 +126,4 @@ V0.02: (21/02/24)
116126
V0.01: (20/02/24)
117127
- Random Generated Levels
118128
- Player is controllable with 2 speeds
119-
- Collision detection of both player-pellet / player-enemy shot are working
120-
121-
### To do:
122-
- Re-add Scrolling (how to shift all the collisions without slowing down?)
123-
- Separate code into files / makefile (will require re-write, not worth the effort?)
124-
- hi-score sram? (understand how to make sram work)
125-
126-
127-
128-
129-
129+
- Collision detection of both player-pellet / player-enemy shot are working

build.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ call clean.bat
22
sdcc -c -mz80 main.c
33
sdcc -c -mz80 vdp.c
44
sdcc -o main.ihx -mz80 --no-std-crt0 --data-loc 0xC000 -Wl-b_BANK2=0x8000 crt0\crt0_sms.rel main.rel vdp.rel SMSlib.lib PSGlib\PSGlib.rel bank2.rel
5-
makesms main.ihx game.sms
6-
5+
makesms -pm main.ihx game.sms
6+
c:\smsdev\emulicious\emulicious game.sms

main.c

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,28 @@ void drawTimer(void) {
12531253
}
12541254

12551255
// Text Screens //
1256+
void doClearSRAMScreen(void) {
1257+
int i = 0;
1258+
1259+
clearHiScore();
1260+
1261+
black_bg_load();
1262+
SMS_setBGScrollX(0);
1263+
SMS_setBGScrollY(0);
1264+
vdp_clear_sprites();
1265+
1266+
SMS_autoSetUpTextRenderer();
1267+
SMS_printatXY(8,8, "DELETING HI-SCORE...");
1268+
SMS_printatXY(8,9, "PLEASE WAIT");
1269+
1270+
while(i < 150) {
1271+
PSGFrame();
1272+
SMS_waitForVBlank();
1273+
i++;
1274+
}
1275+
doTitleScreen();
1276+
}
1277+
12561278
void doTitleScreen(void) {
12571279
int a = 0;
12581280
int p = 0;
@@ -1294,6 +1316,10 @@ void doTitleScreen(void) {
12941316
while(a == 0) {
12951317
unsigned int key=SMS_getKeysStatus();
12961318
if(key & PORT_A_KEY_1) { a = 1; }
1319+
if (SMS_queryPauseRequested()) {
1320+
SMS_resetPauseRequest();
1321+
doClearSRAMScreen();
1322+
}
12971323
PSGFrame();
12981324
SMS_waitForVBlank();
12991325
p++;
@@ -1449,31 +1475,32 @@ void doGameEnd(void) {
14491475
//return;
14501476
}
14511477

1452-
//struct sram { unsigned int points; };
1453-
//struct sram *savegame = (struct sram*)(&SMS_SRAM);
1478+
struct sram { unsigned int points; };
1479+
struct sram *savegame = (struct sram*)(&SMS_SRAM);
14541480

14551481
void checkHiScore(void) {
14561482
if(score > hiscore) {
14571483
hiscore = score; // set the new hi-score //
1458-
//SMS_enableSRAM(); // enable save ram //
1459-
//savegame->points = hiscore;
1460-
//SMS_disableSRAM();
1484+
SMS_enableSRAM(); // enable save ram //
1485+
savegame->points = hiscore; // write the score to SRAM
1486+
SMS_disableSRAM();
14611487
return;
14621488
}
14631489
return;
14641490
}
14651491

14661492
void loadHiScore(void) {
1467-
//SMS_enableSRAM();
1468-
//hiscore = savegame->points;
1469-
//SMS_disableSRAM();
1493+
1494+
SMS_enableSRAM();
1495+
hiscore = savegame->points;
1496+
SMS_disableSRAM();
14701497
}
14711498

14721499
void clearHiScore(void) {
14731500
hiscore = 0;
1474-
//SMS_enableSRAM();
1475-
//savegame->points = hiscore;
1476-
//SMS_disableSRAM();
1501+
SMS_enableSRAM();
1502+
savegame->points = hiscore;
1503+
SMS_disableSRAM();
14771504
}
14781505

14791506
void doNewGame(void) {
@@ -1511,7 +1538,7 @@ void main(void) {
15111538

15121539
vdp_vram_clear();
15131540

1514-
clearHiScore();
1541+
//clearHiScore();
15151542
loadHiScore();
15161543

15171544
black_bg_load();
@@ -1609,6 +1636,7 @@ void main(void) {
16091636
// Game Over //
16101637
if(gamestate == 2) {
16111638
PSGStop();
1639+
explosion_draw();
16121640
checkHiScore();
16131641
doGameOver();
16141642
reset_enemy_variables();
@@ -1657,4 +1685,9 @@ void main(void) {
16571685
}
16581686

16591687
}
1660-
}
1688+
}
1689+
1690+
SMS_EMBED_SEGA_ROM_HEADER(9999,0); // code 9999 hopefully free, here this means 'homebrew'
1691+
SMS_EMBED_SDSC_HEADER(0,17, 2024,4,4, "tibonev", "Raposa do Sol",
1692+
"Clone of Solar Fox.\n"
1693+
"Built using devkitSMS & SMSlib - https://github.com/sverx/devkitSMS");

0 commit comments

Comments
 (0)