Skip to content

Commit dd3181a

Browse files
author
JulianoFlores
committed
updated to lastest PSGLib
Updated to lastest PSGlib to fix the ringing ch.2 psg tone when playing pickup.psg
1 parent 9074868 commit dd3181a

File tree

6 files changed

+124
-59
lines changed

6 files changed

+124
-59
lines changed

README.MD

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ levels designed using [Tiled](http://mapeditor.org)
1414
music done using [Furnace](https://tildearrow.org/furnace/)
1515

1616

17+
compiled using [SDCC](https://sdcc.sourceforge.net)
18+
19+
1720
To build it, you need a working copy of SDCC and SMSDevkit, with crt0, lib(SMSlib) and PSGlib inside their own folders, relative to main.c, if you're in a windows enviroment, then all you need to do is run build.bat.
1821
Otherwise you might need to execute the commands yourself.
1922

@@ -23,7 +26,7 @@ There's a PHP companion tool, to convert Tiled's CSV output to C Array used in t
2326
- Move the ship with the D-Pad
2427
- Hold Button 1 to use the speed boost.
2528

26-
Your mission, choose you accept it is to recover all the satelittes without getting shot by the turrets, good luck.
29+
Your mission, choose you accept it is to recover all the sattelites without getting shot by the turrets, good luck.
2730
Oh yeah, there's a time limit also. oops.
2831

2932
All the assets (code, graphics and music) were created by tibonev.
@@ -32,6 +35,15 @@ Everything is licensed under the MIT License (check out LICENSE for more info).
3235

3336
### Version History:
3437

38+
V0.17 (01/04/24)
39+
- Updated to lastest version of PSGLib, fixed the ringing tone on Square Channel 2, after an sfx has played.
40+
- Altered death-loop situation, now the level always fully reset (all sattelites and time resets) at each death.
41+
- Fixed bug 'not loading "TIME:" tiles upon screen-reload after a death.
42+
43+
V0.16 (28/03/24)
44+
- Fixed pickup sound bug (line 926 / can't enable channel 2 on that line?)
45+
- Fixed 'showing lives after fixed world is over' bug.
46+
3547
V0.15 (26/03/24)
3648
- Added Fixed World Levels.
3749
- Adjusted player bounderies within the screen.
@@ -107,7 +119,11 @@ V0.01: (20/02/24)
107119
- Collision detection of both player-pellet / player-enemy shot are working
108120

109121
### To do:
110-
- sfx continue playing bug? primary focus, V15 has "pickup_psg" disabled.
111122
- Re-add Scrolling (how to shift all the collisions without slowing down?)
112123
- Separate code into files / makefile (will require re-write, not worth the effort?)
113-
- hi-score sram? (understand how to make sram work)
124+
- hi-score sram? (understand how to make sram work)
125+
126+
127+
128+
129+

bank2.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ extern const unsigned char en_shot_psg[22];
5555
extern const unsigned char menu_tick_psg[21];
5656
#define menu_tick_psg_size 21
5757
#define menu_tick_psg_bank 2
58+
extern const unsigned char pickup_psg[18];
59+
#define pickup_psg_size 18
60+
#define pickup_psg_bank 2
5861
extern const unsigned char level_sprites_bin[16];
5962
#define level_sprites_bin_size 16
6063
#define level_sprites_bin_bank 2
@@ -64,9 +67,6 @@ extern const unsigned char title_screen_1_bin[16];
6467
extern const unsigned char title_screen_2_bin[16];
6568
#define title_screen_2_bin_size 16
6669
#define title_screen_2_bin_bank 2
67-
extern const unsigned char pickup_psg[12];
68-
#define pickup_psg_size 12
69-
#define pickup_psg_bank 2
7070
extern const unsigned char tiles_bin[10];
7171
#define tiles_bin_size 10
7272
#define tiles_bin_bank 2

bank2.rel

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A _DABS size 0 flags 8 addr 0
99
A _HOME size 0 flags 0 addr 0
1010
A _GSINIT size 0 flags 0 addr 0
1111
A _GSFINAL size 0 flags 0 addr 0
12-
A _BANK2 size 1CD5 flags 0 addr 0
12+
A _BANK2 size 1CDB flags 0 addr 0
1313
S _title_screen_psgcompr Def000000
1414
S _raposa_1_psg Def000902
1515
S _level_bg_psgcompr Def000D7D
@@ -29,18 +29,18 @@ S _level_bg_stmcompr Def001C07
2929
S _bg_stmcompr Def001C26
3030
S _en_shot_psg Def001C40
3131
S _menu_tick_psg Def001C56
32-
S _level_sprites_bin Def001C6B
33-
S _title_screen_1_bin Def001C7B
34-
S _title_screen_2_bin Def001C8B
35-
S _pickup_psg Def001C9B
36-
S _tiles_bin Def001CA7
37-
S _tiles2_bin Def001CB1
38-
S _tiles3_bin Def001CBB
39-
S _tiles4_bin Def001CC4
40-
S _bg_psgcompr Def001CCD
41-
S _bg2_bin Def001CD0
42-
S _level_bg_bin Def001CD2
43-
S _bg_bin Def001CD4
32+
S _pickup_psg Def001C6B
33+
S _level_sprites_bin Def001C7D
34+
S _title_screen_1_bin Def001C8D
35+
S _title_screen_2_bin Def001C9D
36+
S _tiles_bin Def001CAD
37+
S _tiles2_bin Def001CB7
38+
S _tiles3_bin Def001CC1
39+
S _tiles4_bin Def001CCA
40+
S _bg_psgcompr Def001CD3
41+
S _bg2_bin Def001CD6
42+
S _level_bg_bin Def001CD8
43+
S _bg_bin Def001CDA
4444
A _INITIALIZER size 0 flags 0 addr 0
4545
A _CABS size 0 flags 8 addr 0
4646
T 00 00 00
@@ -1219,55 +1219,57 @@ T 63 1C 00 38 38 38 38 38 38 3D 00
12191219
R 00 00 07 00
12201220
T 6B 1C 00
12211221
R 00 00 07 00
1222-
T 6B 1C 00 3F 0F 3E 2F 2A 15 0B 20 34 2D 27 01 19
1222+
T 6B 1C 00 C9 4A D0 38 C3 4B 38 C9 4A 38 C3 4B 39
12231223
R 00 00 07 00
1224-
T 78 1C 00 2E 03 07
1224+
T 78 1C 00 C7 56 DF 38 00
12251225
R 00 00 07 00
1226-
T 7B 1C 00
1226+
T 7D 1C 00
12271227
R 00 00 07 00
1228-
T 7B 1C 00 00 00 00 01 05 15 02 03 03 06 0A 0B 0F
1228+
T 7D 1C 00 3F 0F 3E 2F 2A 15 0B 20 34 2D 27 01 19
12291229
R 00 00 07 00
1230-
T 88 1C 00 2A 3F 3F
1230+
T 8A 1C 00 2E 03 07
12311231
R 00 00 07 00
1232-
T 8B 1C 00
1232+
T 8D 1C 00
12331233
R 00 00 07 00
1234-
T 8B 1C 00 00 00 00 01 15 02 03 03 06 07 0B 0B 0F
1234+
T 8D 1C 00 00 00 00 01 05 15 02 03 03 06 0A 0B 0F
12351235
R 00 00 07 00
1236-
T 98 1C 00 2A 3F 3F
1236+
T 9A 1C 00 2A 3F 3F
12371237
R 00 00 07 00
1238-
T 9B 1C 00
1238+
T 9D 1C 00
12391239
R 00 00 07 00
1240-
T 9B 1C 00 E7 F0 3B E7 3B E7 3B E7 3B FF 3B 00
1240+
T 9D 1C 00 00 00 00 01 15 02 03 03 06 07 0B 0B 0F
12411241
R 00 00 07 00
1242-
T A7 1C 00
1242+
T AA 1C 00 2A 3F 3F
12431243
R 00 00 07 00
1244-
T A7 1C 00 15 20 2A 2F 2F 3E 00 11 0F 3F
1244+
T AD 1C 00
12451245
R 00 00 07 00
1246-
T B1 1C 00
1246+
T AD 1C 00 15 20 2A 2F 2F 3E 00 11 0F 3F
12471247
R 00 00 07 00
1248-
T B1 1C 00 15 01 2A 2F 2F 3E 00 04 38 3F
1248+
T B7 1C 00
12491249
R 00 00 07 00
1250-
T BB 1C 00
1250+
T B7 1C 00 15 01 2A 2F 2F 3E 00 04 38 3F
12511251
R 00 00 07 00
1252-
T BB 1C 00 15 00 2A 2F 2F 3E 2E 0B 3F
1252+
T C1 1C 00
12531253
R 00 00 07 00
1254-
T C4 1C 00
1254+
T C1 1C 00 15 00 2A 2F 2F 3E 2E 0B 3F
12551255
R 00 00 07 00
1256-
T C4 1C 00 15 10 2A 2F 2F 3E 00 3F 2E
1256+
T CA 1C 00
12571257
R 00 00 07 00
1258-
T CD 1C 00
1258+
T CA 1C 00 15 10 2A 2F 2F 3E 00 3F 2E
12591259
R 00 00 07 00
1260-
T CD 1C 00 01 00 00
1260+
T D3 1C 00
12611261
R 00 00 07 00
1262-
T D0 1C 00
1262+
T D3 1C 00 01 00 00
12631263
R 00 00 07 00
1264-
T D0 1C 00 00 2F
1264+
T D6 1C 00
12651265
R 00 00 07 00
1266-
T D2 1C 00
1266+
T D6 1C 00 00 2F
12671267
R 00 00 07 00
1268-
T D2 1C 00 00 2F
1268+
T D8 1C 00
12691269
R 00 00 07 00
1270-
T D4 1C 00
1270+
T D8 1C 00 00 2F
12711271
R 00 00 07 00
1272-
T D4 1C 00 00
1272+
T DA 1C 00
1273+
R 00 00 07 00
1274+
T DA 1C 00 00
12731275
R 00 00 07 00

bank2/pickup.psg

6 Bytes
Binary file not shown.

build.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ 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
55
makesms main.ihx game.sms
6-
6+
c:\smsdev\emulicious\emulicious game.sms

main.c

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ unsigned int level_pellet_num = 0; // how many pellets are in a level
4949
unsigned int level_pellet_collected = 0; // how many pellets have been collected
5050
int level_fixed_current = 1; // current level of the fixed world
5151
int pellets_x_y[32][2]; // array used to draw/check collision (max of 32 pellet sprites, 2 coordinates per sprite (x,y))
52+
int r_pellets_x_y[32][2]; // array used to reset the random level //
5253

5354
unsigned int level_walls_num = 0;
5455
int walls_x_y[64][2]; // walls position, max of 64 tiles, and 2 coordinates per tile (x,y);
56+
int r_walls_x_y[64][2]; // used to reset the random level //
5557
int walls_col_dir = -1;
5658

5759
unsigned int bg_scroll_x = 0; // used to control the background scroll //
@@ -240,6 +242,13 @@ void level_bg_load(void) {
240242
SMS_setTileatXY(1,21,105);
241243
SMS_setTileatXY(31,0,106);
242244
SMS_setTileatXY(31,21,106);
245+
246+
// TIME: //
247+
SMS_setTileatXY(3,22,210);
248+
SMS_setTileatXY(4,22,211);
249+
SMS_setTileatXY(5,22,212);
250+
SMS_setTileatXY(6,22,213);
251+
SMS_setTileatXY(7,22,214);
243252

244253
}
245254

@@ -765,6 +774,9 @@ void level_load(int level, int seed) {
765774
if(level == 0) {
766775
srand(seed); // re-seed the random number generator each time //
767776

777+
int r_pellet_x = 0;
778+
int r_pellet_y = 0;
779+
768780
level_pellet_num = rand_num(5,20);
769781
level_walls_num = rand_num(5,15);
770782
en_l_y = rand_num(en_lim_top, en_lim_bot);
@@ -774,8 +786,13 @@ void level_load(int level, int seed) {
774786
level_pellet_collected = 0;
775787
// Pellets //
776788
for(int i = 0; i < level_pellet_num; i++ ) {
777-
pellets_x_y[i][0] = rand_num(pl_lim_left, pl_lim_right);
778-
pellets_x_y[i][1] = rand_num(pl_lim_top, pl_lim_bottom);
789+
r_pellet_x = rand_num(pl_lim_left, pl_lim_right);
790+
r_pellet_y = rand_num(pl_lim_top, pl_lim_bottom);
791+
792+
pellets_x_y[i][0] = r_pellet_x;
793+
pellets_x_y[i][1] = r_pellet_y;
794+
r_pellets_x_y[i][0] = pellets_x_y[i][0];
795+
r_pellets_x_y[i][1] = pellets_x_y[i][1];
779796
}
780797

781798
// Walls //
@@ -787,7 +804,8 @@ void level_load(int level, int seed) {
787804
if(wall_pellet_col == 0) {
788805
walls_x_y[i][0] = w_x;
789806
walls_x_y[i][1] = w_y;
790-
807+
r_walls_x_y[i][0] = w_x;
808+
r_walls_x_y[i][1] = w_y;
791809
}
792810
i++;
793811
}
@@ -807,6 +825,28 @@ void level_reset(void) {
807825
level_counter = 10;
808826
}
809827

828+
void random_level_reset_arrays(void) {
829+
int i;
830+
831+
832+
for(i = 0; i < level_walls_num; i++) {
833+
walls_x_y[i][0] = r_walls_x_y[i][0];
834+
walls_x_y[i][1] = r_walls_x_y[i][1];
835+
}
836+
837+
for(i = 0; i < level_pellet_num; i++) {
838+
pellets_x_y[i][0] = r_pellets_x_y[i][0];
839+
pellets_x_y[i][1] = r_pellets_x_y[i][1];
840+
}
841+
842+
en_l_y = rand_num(en_lim_top, en_lim_bot);
843+
en_l_dir = 0;
844+
en_r_y = rand_num(en_lim_top+10, en_lim_bot-10);
845+
en_r_dir = 1;
846+
level_pellet_collected = 0;
847+
848+
}
849+
810850
// Player Related Stuff //
811851
void player_draw(void) {
812852

@@ -923,7 +963,7 @@ void player_pellet_collision(void) {
923963
pellets_x_y[i][0] = 200; //remove pellet//
924964
pellets_x_y[i][1] = 200;
925965
level_pellet_collected++;
926-
//PSGSFXPlay(pickup_psg,SFX_CHANNEL3);
966+
PSGSFXPlay(pickup_psg,SFX_CHANNEL2);
927967
score += 10;
928968
}
929969
}
@@ -1579,13 +1619,11 @@ void main(void) {
15791619
// Level Complete //
15801620
if(gamestate == 3) {
15811621
PSGStop();
1622+
level_fixed_current++;
1623+
if(gamemode == 1) { if(level_fixed_current > 10) { gamestate = 0; checkHiScore(); doGameEnd(); }}
15821624
doLivesScreen();
15831625
level_reset();
1584-
level_fixed_current++;
1585-
if(gamemode == 1) {
1586-
if(level_fixed_current > 10) { gamestate = 0; checkHiScore(); doGameEnd(); }
1587-
level_load(level_fixed_current,c);
1588-
}
1626+
if(gamemode == 1) { level_load(level_fixed_current,c); }
15891627
if(gamemode == 0) { level_load(0,c); }
15901628
}
15911629

@@ -1596,10 +1634,19 @@ void main(void) {
15961634
reset_enemy_variables();
15971635
reset_player_variables();
15981636
doLivesScreen();
1599-
walls_draw();
1600-
if(gamemode == 0) { PSGPlay(random_world_psg); }
1601-
if(gamemode == 1) { PSGPlay(fixed_world_psg); }
1602-
if(level_counter == 0) { level_counter = 10; }
1637+
1638+
if(gamemode == 0) {
1639+
random_level_reset_arrays();
1640+
walls_draw();
1641+
PSGPlay(random_world_psg);
1642+
}
1643+
if(gamemode == 1) {
1644+
level_reset();
1645+
level_load(level_fixed_current,c);
1646+
PSGPlay(fixed_world_psg);
1647+
}
1648+
// if(level_counter == 0) { level_counter = 10; }
1649+
level_counter = 10;
16031650
frame_counter = 0;
16041651
gamestate = 1;
16051652
}

0 commit comments

Comments
 (0)