Skip to content

Commit

Permalink
Show players on screen.
Browse files Browse the repository at this point in the history
Merge pull request #2 from haroldo-ok/players
  • Loading branch information
haroldo-ok authored Mar 4, 2022
2 parents 5d07361 + d8229ad commit d0be35b
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 9 deletions.
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@ OBJS := data.rel actor.rel rpg_battle.rel

all: $(PRJNAME).sms

data.c: data/*
data.c: data/* data/player_1_tiles.psgcompr data/player_2_tiles.psgcompr data/player_3_tiles.psgcompr
folder2c data data

data/player_1_tiles.psgcompr: data/img/player_1.png
BMP2Tile.exe data/img/player_1.png -noremovedupes -8x16 -palsms -fullpalette -savetiles data/player_1_tiles.psgcompr -savepalette data/player_1_palette.bin

data/player_2_tiles.psgcompr: data/img/player_2.png
BMP2Tile.exe data/img/player_2.png -noremovedupes -8x16 -palsms -fullpalette -savetiles data/player_2_tiles.psgcompr -savepalette data/player_2_palette.bin

data/player_3_tiles.psgcompr: data/img/player_3.png
BMP2Tile.exe data/img/player_3.png -noremovedupes -8x16 -palsms -fullpalette -savetiles data/player_3_tiles.psgcompr -savepalette data/player_3_palette.bin

data/%.path: data/path/%.spline.json
node tool/convert_splines.js $< $@

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# rpg-battle-poc
This is a proof-of-concept RPG battle system for the Sega Master System; originally made for the 2022 SMSPower! Coding Competition.
This is a quick-and-dirty test to get extra sprite colors on the Sega Master System by changing the palette between scanlines.



* Player sprites taken from: https://www.spriters-resource.com/snes/ff5/
Binary file added data/img/player_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/img/player_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/img/player_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/player_1_palette.bin
Binary file not shown.
Binary file added data/player_1_tiles.psgcompr
Binary file not shown.
Binary file added data/player_2_palette.bin
Binary file not shown.
Binary file added data/player_2_tiles.psgcompr
Binary file not shown.
Binary file added data/player_3_palette.bin
Binary file not shown.
Binary file added data/player_3_tiles.psgcompr
Binary file not shown.
50 changes: 43 additions & 7 deletions rpg_battle.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,35 @@
char line_counter;

void interrupt_handler() {
SMS_setBGPaletteColor(0, line_counter);
SMS_setSpritePaletteColor(0, line_counter);
// SMS_setBGPaletteColor(0, line_counter);
switch (line_counter) {
case 2:
SMS_loadSpritePalette(player_1_palette_bin);
break;

case 3:
SMS_loadSpritePalette(player_2_palette_bin);
break;

case 4:
SMS_loadSpritePalette(player_2_palette_bin);
break;

default:
SMS_loadSpritePalette(player_3_palette_bin);
}


line_counter++;
if (line_counter > 5) line_counter = 1;
if (line_counter > 4) line_counter = 0;
}

void draw_player(char x, char y, char tile) {
SMS_addSprite(x, y, tile);
SMS_addSprite(x + 8, y, tile + 2);
y += 16;
SMS_addSprite(x, y, tile + 4);
SMS_addSprite(x + 8, y, tile + 6);
}

void main() {
Expand All @@ -22,14 +47,26 @@ void main() {

SMS_displayOff();

SMS_setBGPaletteColor(0, 0);
SMS_setSpritePaletteColor(0, 0);
SMS_setBGPaletteColor(0, 0x04);

SMS_loadPSGaidencompressedTiles(player_1_tiles_psgcompr, 2);
SMS_loadPSGaidencompressedTiles(player_2_tiles_psgcompr, 10);
SMS_loadPSGaidencompressedTiles(player_3_tiles_psgcompr, 18);

line_counter = 0;
SMS_setLineInterruptHandler(&interrupt_handler);
SMS_setLineCounter(32);
SMS_enableLineInterrupt();

SMS_initSprites();

draw_player(200, 64, 18);
draw_player(200, 100, 2);
draw_player(200, 136, 10);

SMS_finalizeSprites();
SMS_copySpritestoSAT();

SMS_displayOn();

while (1) {
Expand All @@ -38,8 +75,7 @@ void main() {
}

SMS_EMBED_SEGA_ROM_HEADER(9999,0); // code 9999 hopefully free, here this means 'homebrew'
SMS_EMBED_SDSC_HEADER(0,1, 2022,02,28, "Haroldo-OK\\2022", "RPG Battle POC",
SMS_EMBED_SDSC_HEADER(0,1, 2022,03,03, "Haroldo-OK\\2022", "RPG Battle POC",
"A proof-of-concept RPG Battle System.\n"
"Made for the SMS Power! Competition 2022 - https://www.smspower.org/forums/18879-Competitions2022DeadlineIs27thMarch\n"
"Built using devkitSMS & SMSlib - https://github.com/sverx/devkitSMS");

0 comments on commit d0be35b

Please sign in to comment.