From 589db577724d941adf0629dd14a41fd670c7410c Mon Sep 17 00:00:00 2001 From: 10yard Date: Fri, 29 Jul 2022 23:24:42 +0100 Subject: [PATCH] Extend dkstart5 plugin to optionally practice a specific stage when parameter (DKSTART5_PARAMETER) is provided. Add stage practice options to launch menu for Crazy Kong and selected DK hacks. --- VERSION | 2 +- dk_config.py | 1 + dk_system.py | 4 ++++ dkwolf/plugins/dkstart5/init.lua | 21 +++++++++++++++++++-- dkwolf/plugins/dkstart5/plugin.json | 2 +- interface/globals.lua | 2 +- launch.py | 10 +++++++++- romlist.csv | 3 +-- rpi4/preparing_release.txt | 6 ++++++ 9 files changed, 43 insertions(+), 8 deletions(-) diff --git a/VERSION b/VERSION index fb6beee..abd4e88 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.34 \ No newline at end of file +v0.35 \ No newline at end of file diff --git a/dk_config.py b/dk_config.py index 92da3fc..ce485ce 100644 --- a/dk_config.py +++ b/dk_config.py @@ -159,6 +159,7 @@ HUD_UNFRIENDLY = ["dkongwizardry", "dkongduet", "dkongkonkey"] AUTOSTART_UNFRIENDLY = ["dkongbarpal", "dkongrndmzr"] AUTHOR_UNFRIENDLY = ["dkongwizardry", "dkongbarpal", "dkongrndmzr"] +STAGE_FRIENDLY = ["dkongwizardry", "dkongpac", "dkongrev", "dkongpe", "dkongitd", "dkonghrd", "dkong40", "dkongf"] # Colours RED = (232, 7, 10) diff --git a/dk_system.py b/dk_system.py index 9f73102..6b893bc 100644 --- a/dk_system.py +++ b/dk_system.py @@ -146,6 +146,10 @@ def build_launch_command(info, basic_mode=False, launch_plugin=None, playback=Fa # Are we using a plugin? if launch_plugin and "-plugin" not in launch_command: + # Are there any parameters for the plugin? + if ":" in launch_plugin: + launch_plugin, parameter, *_ = launch_plugin.split(":") + os.environ[launch_plugin + "_PARAMETER"] = parameter launch_command += f" -plugin {launch_plugin}" if not FULLSCREEN: diff --git a/dkwolf/plugins/dkstart5/init.lua b/dkwolf/plugins/dkstart5/init.lua index fef45f6..39a3959 100644 --- a/dkwolf/plugins/dkstart5/init.lua +++ b/dkwolf/plugins/dkstart5/init.lua @@ -4,21 +4,30 @@ -- Tested with latest MAME version 0.245 -- Compatible with MAME versions from 0.196 -- +--A simple plugin to start the game at level 5 for practice purposes. +--You can also play a specific stage by setting a parameter before launching MAME +--e.g. +--SET DKSTART5_PARAMETER=4 +-- -- Minimum start up arguments: -- mame dkong -plugin dkstart5 ----------------------------------------------------------------------------------------- local exports = {} exports.name = "dkstart5" -exports.version = "0.1" +exports.version = "0.2" exports.description = "DK Start 5" exports.license = "GNU GPLv3" exports.author = { name = "Jon Wilson (10yard)" } + local dkstart5 = exports function dkstart5.startplugin() + local stage function initialize() + local _s + -- MAME LUA machine initialisation -- Handles historic changes back to MAME v0.196 release if tonumber(emu.app_version()) >= 0.196 then @@ -35,14 +44,22 @@ function dkstart5.startplugin() cpu = mac.devices[":maincpu"] mem = cpu.spaces["program"] end + + _s = tonumber(os.getenv("DKSTART5_PARAMETER")) or nil + if _s >= 1 and _s <= 4 then + stage = _s + end end function main() - if mem ~= nil then + if mem ~= nil then if mem:read_u8(0x6229) == 1 then mem:write_u8(0x6229, 5) -- update to level 5 mem:write_u16(0x622a, 0x3a73) -- update screen sequence end + if stage then + mem:write_u8(0x6227, stage) -- play a specific stage only + end end end diff --git a/dkwolf/plugins/dkstart5/plugin.json b/dkwolf/plugins/dkstart5/plugin.json index 2f4b8d9..c924178 100644 --- a/dkwolf/plugins/dkstart5/plugin.json +++ b/dkwolf/plugins/dkstart5/plugin.json @@ -2,7 +2,7 @@ "plugin": { "name": "dkstart5", "description": "DK Start 5", -"version": "0.1", +"version": "0.2", "author": "Jon Wilson (10yard)", "type": "plugin", "start": "false" diff --git a/interface/globals.lua b/interface/globals.lua index d91bc12..270435b 100644 --- a/interface/globals.lua +++ b/interface/globals.lua @@ -28,7 +28,7 @@ if mac ~= nil then screen = mac.screens[":screen"] cpu = mac.devices[":maincpu"] mem = cpu.spaces["program"] - soundcpu = mac.devices[":soundcpu"] + soundcpu = mac.devices[":soundcpu"] soundmem = soundcpu.spaces["data"] end diff --git a/launch.py b/launch.py index 3e37eae..56aa2d4 100644 --- a/launch.py +++ b/launch.py @@ -530,6 +530,7 @@ def build_launch_menu(): show_chorus = sub in CHORUS_FRIENDLY or (name == "dkong" and sub == "") show_start5 = sub in START5_FRIENDLY or (name == "dkong" and sub == "") show_shoot = sub in SHOOT_FRIENDLY + show_stage = sub in STAGE_FRIENDLY or (name == "ckongpt2" and sub == "") inps = _s.get_inp_files(rec, name, sub, 12 - show_coach - show_chorus - show_shoot - show_start5) _g.launchmenu = pymenu.Menu(256, 224, _g.selected.center(26), mouse_visible=False, mouse_enabled=False, @@ -562,6 +563,13 @@ def build_launch_menu(): if show_shoot: _g.launchmenu.add_button('▲ Launch with shooter ', launch_rom, nearby, "galakong") + if show_stage: + _g.launchmenu.add_vertical_margin(10) + _g.launchmenu.add_button('- Practice barrels ', launch_rom, nearby, "dkstart5:1") + _g.launchmenu.add_button('- Practice pies ', launch_rom, nearby, "dkstart5:2") + _g.launchmenu.add_button('- Practice springs ', launch_rom, nearby, "dkstart5:3") + _g.launchmenu.add_button('- Practice rivets ', launch_rom, nearby, "dkstart5:4") + _g.launchmenu.add_vertical_margin(10) _g.launchmenu.add_button('Close', close_menu) @@ -900,7 +908,7 @@ def process_interrupts(): # Purge coins _g.coins = [i for i in _g.coins if i[0] > -10] - # DK shouts out the launch options + # Pauline shouts out the launch options if _g.ready: if since_last_move() % 4 <= 2: write_text("Push P1 START for options...", x=108, y=38, bg=MAGENTA, fg=PINK, bubble=True) diff --git a/romlist.csv b/romlist.csv index 4b638a8..7ba3956 100644 --- a/romlist.csv +++ b/romlist.csv @@ -14,7 +14,7 @@ dkong,dkongrndmzr,DK RNDMZR,DK RNDMZR,18,1,2,14000,10000,20000,40000 dkong,dkongitd,DK Dark,DK Into The Dark,19,1,2,16000,8000,15000,35000 dkongx11,dkongxmas,DK Xmas,DK Christmas Remix,20,1,2,18000,10000,15000,30000 dkong,dkongvector,VectorKong,Vector Kong,21,1,2,20000,10000,20000,40000 -dkongjr,dkongjrgala,Gala JR,Galakong JR,22,1,2,22000,10000,20000,30000 +dkongjr,dkongjrgala,Gala JR,GalaKong Junior,22,1,2,22000,10000,20000,30000 dkong,dkong2600,DK 2600,DK Atari 2600 Graphics,22,1,2,22000,10000,20000,40000 dkong,dkongotr,DK OnTheRun,DK On The Run,24,1,2,24000,10000,15000,30000 dkongx,dkongd2k,D2K,D2K Jumpman Returns,25,1,2,26000,5000,10000,25000 @@ -37,7 +37,6 @@ dkong,dkongbarrels,DK Barrels,DK Barrels Only,99,1,2,,,, dkong,dkonghrd,DK Hard,,99,1,2,,,, dkong,dkongrnd,DK Random,DK Randomized,99,1,2,,,, dkong,dkongfr,DK FreeRun,DK Freerun Edition,99,1,2,,,, -dkong,dkongpac,DK Pac-Man,,99,1,2,,,, dkong,dkongtrn,DK Trainer,,99,1,2,,,, dkongf,dkongst2,DK Springs Trainer,,99,1,2,,,, dkong,dkongpace,DK Pace,,99,1,2,,,, diff --git a/rpi4/preparing_release.txt b/rpi4/preparing_release.txt index 92fd621..b59ce54 100644 --- a/rpi4/preparing_release.txt +++ b/rpi4/preparing_release.txt @@ -10,6 +10,9 @@ $ ls There may be existing "dkafe_bin" folders at /boot/dkafe_bin and /home/pi/dkafe_bin These will be automatically removed by the build script. +$ sudo bleachbit +Run this occasionally to clean up system. Avoid the "Memory" option. + $ git clone https://github.com/10yard/dkafe.git Should create a "dkafe" folder containing the sources @@ -33,6 +36,9 @@ $ lsblk We can see the USB drive size and mountpoint. Assuming the drive is named "USB" The mountpoint used in commands below is /media/pi/USB +$ history -c && history -w +To clear the terminal history + $ sudo dd if=/dev/mmcblk0 of=/media/pi/USB/dkafe_sdcard.img bs=1M This will make an image of the SD Card (mmcblk0) and save to USB stick. It will take a while.