Skip to content

Commit

Permalink
Extend dkstart5 plugin to optionally practice a specific stage when p…
Browse files Browse the repository at this point in the history
…arameter (DKSTART5_PARAMETER) is provided.

Add stage practice options to launch menu for Crazy Kong and selected DK hacks.
  • Loading branch information
10yard committed Jul 29, 2022
1 parent 1c1053c commit 589db57
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 8 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.34
v0.35
1 change: 1 addition & 0 deletions dk_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions dk_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 19 additions & 2 deletions dkwolf/plugins/dkstart5/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion dkwolf/plugins/dkstart5/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion interface/globals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 9 additions & 1 deletion launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions romlist.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,,,,
Expand Down
6 changes: 6 additions & 0 deletions rpi4/preparing_release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.

Expand Down

0 comments on commit 589db57

Please sign in to comment.