Skip to content

Commit

Permalink
Add volume control for playlist and PLAYLIST_VOLUME option in setting…
Browse files Browse the repository at this point in the history
…s.txt

Add thank you page to the intermission screens and increase delay between screens
Add another default track to the playlist from MotionRide
  • Loading branch information
10yard committed Nov 3, 2023
1 parent 3f1cd93 commit 4e09626
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 38 deletions.
72 changes: 56 additions & 16 deletions dk_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
CONTROL_EXIT = pygame.K_ESCAPE
CONTROL_TAB = pygame.K_TAB
CONTROL_SNAP = pygame.K_F12
CONTROL_PLAYLIST = pygame.K_p
CONTROL_SKIP = pygame.K_s

# Joystick Options and Button Assignments
USE_JOYSTICK = 0
Expand All @@ -58,7 +60,8 @@
SHOW_GAMETEXT = 1 # Show the game text description when Jumpman faces an arcade machine
ENABLE_HAMMERS = 1 # Show hammers and enable teleport between hammers in the frontend
ENABLE_SHUTDOWN = 0 # Allow system shutdown from menu
ENABLE_PLAYLIST = 0 # Play background music from playlist folder
ENABLE_PLAYLIST = 1 # Play background music from playlist folder
PLAYLIST_VOLUME = 5 # Volume of playlist music from 0 to 10

# DKWolf/Interface options
HIGH_SCORE_SAVE = 1 # Retain high scores (they are specific to each hack)
Expand Down Expand Up @@ -129,6 +132,12 @@
pygame.quit()
exit()

# Validate some settings
if PLAYLIST_VOLUME > 10: globals()["PLAYLIST_VOLUME"] = 10
if PLAYLIST_VOLUME < 0: globals()["PLAYLIST_VOLUME"] = 0
if SPEED_ADJUST > 8: globals()["SPEED_ADJUST"] = 8
if SPEED_ADJUST < 0: globals()["SPEED_ADJUST"] = 0

# Frontend version
VERSION = ''
if os.path.exists("VERSION"):
Expand Down Expand Up @@ -346,14 +355,14 @@
The coins thrown by Donkey
Kong must be collected by
Jumpman so he has money
to play the arcades.
Jumpman so he has money to
play the arcades.
Jumpman must play well to
win prizes and unlock
arcade machines as he works
his way to the top of the
building to rescue Pauline.
win prizes and unlock arcade
machines as he works his way
to the top of the building
to rescue Pauline.
Pauline will ♥ it when you
beat all of the machines.
Expand All @@ -373,20 +382,20 @@
Helpful hints
~~~~~~~~~~~~~
• You can navigate Jumpman
between stages using the
exit ladders or by
warping down an oilcan.
• You can navigate Jumpman
between stages using the
exit ladders or by warping
down an oilcan.
• You can teleport Jumpman
over short distances by
jumping up to a hammer.
• Help Jumpman get better
by using practice modes.
Maybe you can help him
reach the infamous
Donkey Kong killscreen.
• Help Jumpman get better by
using practice modes.
Maybe you can help him to
reach the infamous Donkey
Kong killscreen.
"""

Expand Down Expand Up @@ -420,6 +429,37 @@
Exit - Exit DKAFE
"""

THANKS_TO = """
Thanks to all these folks!
Donkey Kong rom hacks:
Paul Goes
Sockmaster
Jeff Kulczycki,
Mike Mika & Clay Cowgill
Don Hodges
Tim Appleton
Vic20 George
Kirai Shouen & 125scratch
The DK rom hacking resource:
furrykef
Feedback and feature ideas:
Superjustinbros
Playlist music:
LeviR.star's Music
MyNameIsBanks
SanHolo
Nintega Dario
MotionRide Music
"""

# Sound setup
pygame.mixer.init(frequency=48000)
background_channel = pygame.mixer.Channel(1)
Expand Down
51 changes: 38 additions & 13 deletions launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,12 @@ def check_for_input(force_exit=False):
_g.showslots = not _g.showslots
if event.key == CONTROL_SNAP:
take_screenshot()
if event.key == CONTROL_SKIP:
if ENABLE_PLAYLIST and playlist.get_busy():
play_from_tracklist()
if event.key == CONTROL_PLAYLIST:
globals()["ENABLE_PLAYLIST"] = not ENABLE_PLAYLIST
set_playlist(None, ENABLE_PLAYLIST, external=True) # Fix pygamemenu issue

# Optional joystick controls
if USE_JOYSTICK:
Expand Down Expand Up @@ -555,7 +561,10 @@ def build_menus(initial=False):
('+8', 8)], default=SPEED_ADJUST, onchange=set_speed)
_g.setmenu.add_vertical_margin(10)
_g.setmenu.add_selector('Highscore Save: ', [('Off', 0), ('On', 1)], default=HIGH_SCORE_SAVE, onchange=set_high)
_g.setmenu.add_selector(' Music Playlist: ', [('Off', 0), ('On', 1)], default=ENABLE_PLAYLIST, onchange=set_playlist)
_g.setmenu.add_selector('Music Playlist: ', [('Off', 0), ('On', 1)], default=ENABLE_PLAYLIST, onchange=set_playlist)
_g.setmenu.add_selector(' Music Volume: ',
[('0%', 0), ('10%', 1), ('20%', 2), ('30%', 3), ('40%', 4), ('50%', 5), ('60%', 6),
('70%', 7), ('80%', 8), ('90%', 9), ('100%', 10)], default=PLAYLIST_VOLUME, onchange=set_volume)
_g.setmenu.add_vertical_margin(10)
_g.setmenu.add_button('Save Changes to File', save_menu_settings)
_g.setmenu.add_button('Close Menu', close_menu)
Expand Down Expand Up @@ -657,6 +666,8 @@ def save_menu_settings():
f_out.write(f"HIGH_SCORE_SAVE = {HIGH_SCORE_SAVE}\n")
elif "ENABLE_PLAYLIST=" in line_packed:
f_out.write(f"ENABLE_PLAYLIST = {ENABLE_PLAYLIST}\n")
elif "PLAYLIST_VOLUME=" in line_packed:
f_out.write(f"PLAYLIST_VOLUME = {PLAYLIST_VOLUME}\n")
else:
f_out.write(line)
write_text(text=" Changes have been saved ", font=dk_font, y=232, fg=PINK, bg=RED)
Expand All @@ -679,17 +690,14 @@ def set_speed(_, setting_value):
globals()["SPEED_ADJUST"] = setting_value


def set_high(_, setting_value):
globals()["HIGH_SCORE_SAVE"] = setting_value
def set_volume(_, setting_value):
globals()["PLAYLIST_VOLUME"] = setting_value
playlist.set_volume(setting_value / 10)


def set_playlist(_, setting_value):
globals()["ENABLE_PLAYLIST"] = setting_value
if setting_value == 1:
background_channel.stop()
else:
background_channel.play(pygame.mixer.Sound('sounds/background.wav'), -1)
playlist.stop()

def set_high(_, setting_value):
globals()["HIGH_SCORE_SAVE"] = setting_value


def set_confirm(_, setting_value):
Expand All @@ -702,11 +710,27 @@ def set_gametext(_, setting_value, external=False):
if external:
# Hack to fix pygamemenu when updating outside the menu
for i, w in enumerate(_g.setmenu._widgets):
if w._title.startswith("Show Game Text"):
if "Show Game Text" in w._title:
_g.setmenu._widgets[i]._index = int(SHOW_GAMETEXT)
break


# noinspection PyProtectedMember
def set_playlist(_, setting_value, external=False):
globals()["ENABLE_PLAYLIST"] = setting_value
if setting_value == 1:
background_channel.stop()
else:
background_channel.play(pygame.mixer.Sound('sounds/background.wav'), -1)
playlist.stop()
if external:
# Hack to fix pygamemenu when updating outside the menu
for i, w in enumerate(_g.setmenu._widgets):
if "Music Playlist" in w._title:
_g.setmenu._widgets[i]._index = int(ENABLE_PLAYLIST)
break


def set_fullscreen(_, setting_value):
if FULLSCREEN != setting_value:
globals()["FULLSCREEN"] = setting_value
Expand Down Expand Up @@ -1110,11 +1134,11 @@ def inactivity_check():
if _g.timer.duration - _g.lastmove > INACTIVE_TIME:
_g.ready = False # Jumpman status changed to be not ready to play.
_g.facing = 1
pause_mod = ((pygame.time.get_ticks() - _g.pause_ticks) % 39000) - 3000
pause_mod = ((pygame.time.get_ticks() - _g.pause_ticks) % 51000) - 3000
if pause_mod < 0:
_g.screen.blit(get_image(f"artwork/intro/f{randint(0, 1)}.png"), TOPLEFT)
else:
lines = (INSTRUCTION, MORE_INSTRUCTION, CONTROLS)[floor(pause_mod / 12000)]
lines = (INSTRUCTION, MORE_INSTRUCTION, CONTROLS, THANKS_TO)[floor(pause_mod / 12000)]
for i, line in enumerate(lines.split("\n")):
write_text(line + (" " * 28), y=i * 8 + 20, fg=CYAN, bg=BLACK, font=dk_font)
show_score()
Expand Down Expand Up @@ -1233,6 +1257,7 @@ def main(initial=True):
_g.tracklist = _s.glob("playlist/*.mp3") + _s.glob("playlist/*.ogg")
if not ENABLE_PLAYLIST:
background_channel.play(pygame.mixer.Sound('sounds/background.wav'), -1)
playlist.set_volume(PLAYLIST_VOLUME / 10)

# Main game loop
while True:
Expand Down
Binary file added playlist/MotionRide - Donkey Kong Arcade.mp3
Binary file not shown.
23 changes: 17 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,12 @@ The stage to start the frontend on. 0 is barrels stage. 1 is rivets stage.
`HIGH_SCORE_SAVE = 1`
Save your high score tables for each game.

`ENABLE_PLAYLIST = 0`
`ENABLE_PLAYLIST = 1`
1 to play music files from the **playlist** folder instead of the regular Donkey kong background music.

'PLAYLIST_VOLUME = 5'
Playlist music volume from 0 (minimum) to 10 (maximum).

`ENABLE_MENU=1`
1 to enable the game list when P2 Start button is pressed to quickly launch an available game via the menu.

Expand Down Expand Up @@ -427,6 +430,8 @@ CONTROL_INFO = 5
CONTROL_EXIT = escape
CONTROL_SETTINGS = tab
CONTROL_SNAP = F12
CONTROL_SKIP = s
CONTROL_PLAYLIST = p
```

IMPORTANT NOTE: The controls configured in the frontend do not apply to the emulator. If your controls are not default then you will also have to configure your controls in the emulator menu (tab).
Expand Down Expand Up @@ -475,7 +480,8 @@ dtoverlay=gpio-key,gpio=26,keycode=1,label="KEY_ESC"
You can override the default Donkey Kong background music by setting `ENABLE_PLAYLIST = 1` in the settings.txt file.
Several default music files are provided for your enjoyment. These files can be removed and replaced with your own favourite music tracks in **.mp3** or **.ogg** format.

The "Music Playlist" can also be activated via the frontend settings menu (by pressing the TAB key).
The "Music Playlist" can also be activated via the frontend settings menu (by pressing the TAB key) or it can be toggle on/off by pressing the CONTROL_PLAYLIST key (p).
When music is playing you can skip to the next track by pressing the CONTROL_SKIP key (s).


### How to use romlist.csv
Expand Down Expand Up @@ -558,6 +564,7 @@ I would love to get to the infamous killscreen on level 22. My current PB is 51
- Create an alternative frontend for vertical arcade games (like 60-in-1 board) with DK, Pacman, Ms Pacman, Galaga, Burger Time, Frogger etc. No roms will be provided.
- Add support for console versions of DK


## Thanks to

The Donkey Kong rom hacking resource
Expand All @@ -580,18 +587,22 @@ https://docs.mamedev.org/
WolfMAME by Mahlemiut
https://github.com/mahlemiut/wolfmame

The VRC6 Project by LeviR.star's Music. 4 DK remix tracks are used in the default playlist folder
The VRC6 Project by LeviR.star's Music. 4 DK remix tracks are included in the default playlist folder
https://www.youtube.com/watch?v=Ufd9UC2wUpA

DonkeyKong Classic Remix Music by MyNameIsBanks. This track is used in the default playlist folder.
DonkeyKong Classic Remix Music by MyNameIsBanks. This track is included in the default playlist folder.
https://www.youtube.com/watch?v=MDw2goJSi4k

Donkey Kong Remix Music by SanHolo. This track is used in the default playlist folder.
Donkey Kong Remix Music by SanHolo. This track is included in the default playlist folder.
https://www.youtube.com/watch?v=_kdgB5SRqHw

Main Theme Remix Music by Nintega Dario. This track is used in the default playlist folder.
Main Theme Remix Music by Nintega Dario. This track is included in the default playlist folder.
https://www.youtube.com/watch?v=VPT42lfFNMY

Donkey Kong Arcade by MotionRide Music. This track is included in the default playlist folder.
https://www.youtube.com/watch?v=gy0C2a5QEu8


## License

DKAFE is a free, open source, cross-platform front-end for emulators.
Expand Down
22 changes: 20 additions & 2 deletions rpi4/settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ SPEED_ADJUST = 0
SKILL_LEVEL = 1
START_STAGE = 0
HIGH_SCORE_SAVE = 1
ENABLE_PLAYLIST = 0
ENABLE_PLAYLIST = 1
PLAYLIST_VOLUME = 5

# Emulator Settings
ROM_DIR = <ROOT>/roms
Expand All @@ -33,7 +34,7 @@ OPTIONS = -rompath <ROM_DIR> -view "Screen 0 Pixel Aspect (7:8)" -nofilter -vide
EMU_1 = <ROOT>/dkwolf/dkwolfrpi <OPTIONS>
EMU_2 = <ROOT>/dkwolf/dkwolfrpi <OPTIONS> -nvram_directory /dev/null -record <RECORD_ID>

# Interface Settings
# DKWolf/Interface Settings
CREDITS = 1
AUTOSTART = 1
ALLOW_SKIP_INTRO = 1
Expand All @@ -42,6 +43,8 @@ SHOW_AWARD_TARGETS = 1
SHOW_HUD = 1

# Controls
# NOTE: These controls apply to the DKAFE frontend only.
# If you change controls here then you should also change controls in your emulator menu (accessed using tab key).
CONTROL_LEFT = left
CONTROL_RIGHT = right
CONTROL_UP = up
Expand All @@ -53,3 +56,18 @@ CONTROL_P2 = 2
CONTROL_COIN = 5
CONTROL_EXIT = escape
CONTROL_SETTINGS = tab

# Optional Joystick and Button Assignments
# Note: DPAD and first analog axis are automatically mapped to directions
# Device 1 buttons start from 0, Device 2 buttons start from 20
USE_JOYSTICK = 0
BUTTON_JUMP = 0
BUTTON_ACTION = 1
BUTTON_P1 = 9
BUTTON_P2 = 29
BUTTON_EXIT = 6
BUTTON_COIN = 7

#
# For a complete list of settings visit - https://github.com/10yard/dkafe#frontend-settings
#
3 changes: 2 additions & 1 deletion settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ SPEED_ADJUST = 0
SKILL_LEVEL = 1
START_STAGE = 0
HIGH_SCORE_SAVE = 1
ENABLE_PLAYLIST = 0
ENABLE_PLAYLIST = 1
PLAYLIST_VOLUME = 5

# Emulator Settings
ROM_DIR = <ROOT>/roms
Expand Down

0 comments on commit 4e09626

Please sign in to comment.