Skip to content

Commit

Permalink
When using emulator that is not default (dkwolf):
Browse files Browse the repository at this point in the history
- Check plugin exists before launching
- Fix playback problem

"Extreme Galakong" improvements

Update to about folder artwork
  • Loading branch information
10yard committed Jul 13, 2022
1 parent 08ff121 commit 784de24
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 20 deletions.
Binary file modified artwork/about/frontend.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 modified artwork/about/gameinfo.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 modified artwork/about/launchmenu.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 modified artwork/about/patches.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 modified artwork/about/slots.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions dk_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@
COACH_FRIENDLY = ["dkongspringy", "dkongbarrels", "dkongcb", "dkonghrd"]
CHORUS_FRIENDLY = ["dkongspringy", "dkongbarrels", "dkongcb", "dkonghrd", "dkongrivets", "dkongrnd",
"dkongwbh", "dkongpies", "dkongjapan", "dkongpe", "dkongfr", "dkongl05", "dkongce", "dkongrev"]
SHOOT_FRIENDLY = ["dkongspringy", "dkongbarrels", "dkongpies", "dkongrivets", "dkongpac", "dkongwbh"]
SHOOT_FRIENDLY = ["dkongspringy", "dkongbarrels", "dkongpies", "dkongrivets", "dkongpac"]
START5_FRIENDLY = ["dkongspringy", "dkongbarrels", "dkongpies", "dkongrivets", "dkongksfix"]

# Roms that don't support some DKAFE features fully
HUD_UNFRIENDLY = ["dkongwizardry", "dkongduet"]
HUD_UNFRIENDLY = ["dkongwizardry", "dkongduet", "dkongkonkey"]
AUTOSTART_UNFRIENDLY = ["dkongbarpal", "dkongrndmzr"]
AUTHOR_UNFRIENDLY = ["dkongwizardry", "dkongbarpal", "dkongrndmzr"]

Expand Down
19 changes: 14 additions & 5 deletions dk_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from datetime import datetime
from time import sleep, time
from glob import glob
from shutil import copy, move
from shutil import copy, move, copytree
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1'
from dk_config import *
from dk_interface import lua_interface
Expand Down Expand Up @@ -95,16 +95,18 @@ def get_inp_dir(emu):
return os.path.join(os.path.dirname(get_emulator(emu).split(" ")[0]), "inp")


def get_inp_files(emu, name, sub, num):
def get_inp_files(rec, name, sub, num):
# Return the 5 most recent .inp recordings for the specified rom
return sorted(glob(os.path.join(get_inp_dir(emu), f"{name}_{sub}_*.inp")), reverse=True)[:num]
return sorted(glob(os.path.join(get_inp_dir(rec), f"{name}_{sub}_*.inp")), reverse=True)[:num]


def build_launch_command(info, basic_mode=False, launch_plugin=None):
def build_launch_command(info, basic_mode=False, launch_plugin=None, playback=False):
# Receives subfolder (optional), name, emulator, unlock and target scores from info
# If mame emulator supports a rompath (recommended) then the rom can be launched direct from the subfolder
# otherwise the file will be copied over the main rom to avoid a CRC check fail. See ALLOW_ROM_OVERWRITE option.
subfolder, name, emu, rec, unlock, score3, score2, score1 = info
if playback: # playback using the original emulator/settings
emu = rec
emu_args = get_emulator(emu)
inp_file = f"{name}_{subfolder}_{get_datetime()}_0m.inp"
emu_args = emu_args.replace("<RECORD_ID>", inp_file)
Expand All @@ -130,7 +132,14 @@ def build_launch_command(info, basic_mode=False, launch_plugin=None):
for plugin, plugin_folder in PLUGINS:
if plugin == subfolder:
launch_command += f" -plugin {plugin_folder}"
break

if "dkwolf" not in launch_directory.lower():
# Not using standard emulator so check the plugin path exists and copy if necessary
plugin_target = os.path.join(launch_directory, "plugins", plugin_folder)
if not os.path.exists(plugin_target):
plugin_source = os.path.join(ROOT_DIR, "dkwolf", "plugins", plugin_folder)
copytree(plugin_source, plugin_target)
break

else:
launch_command = launch_command.replace("<ROM_DIR>", ROM_DIR)
Expand Down
57 changes: 47 additions & 10 deletions dkwolf/plugins/galakong/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
-- SET GALAKONG_NOSTARS=1
-- SET GALAKONG_NOEXPLOSIONS=1
--
-- The hack becomes "Extreme Galakong" when used in combination with the "Wild Barrel Hack" rom.
--
-- Minimum start up arguments:
-- mame dkong -plugin galakong
-----------------------------------------------------------------------------------------
Expand Down Expand Up @@ -60,6 +62,7 @@ function galakong.startplugin()
local howhigh_ready = false
local end_of_level = false
local dead = false
local extreme = false
local name_entry = 0

local score = "000000"
Expand Down Expand Up @@ -177,6 +180,13 @@ function galakong.startplugin()
" + +",
" ++"}

local extreme_logo_table = {
"!! ! ! !!! !! !! !!! !!",
"! ! ! ! ! ! ! ! ! ! !",
"!! ! ! !! !! ! ! ! !!",
"! ! ! ! ! ! ! ! ! ! !",
"!! ! ! ! ! ! !! ! ! ! !!"}

local explode1_table = {
"",
"",
Expand Down Expand Up @@ -326,9 +336,9 @@ function galakong.startplugin()
-- Position of shield pickup by stage number
local pickup_table = {}
pickup_table[1] = {15, 212}
pickup_table[2] = {8, 208}
pickup_table[2] = {8, 161}
pickup_table[3] = {121, 73}
pickup_table[4] = {8, 192}
pickup_table[4] = {8, 161}

-- Point scored for multiple missile hits and associated sprite display
local bonus_table = {}
Expand Down Expand Up @@ -411,6 +421,12 @@ function galakong.startplugin()
s_cpu = mac.devices[":soundcpu"]
s_mem = s_cpu.spaces["data"]

-- Is this the wild barrel hack (i.e. extreme galakong)? Offset 3FBA to 3FBF is not used in regular DK
if emu.romname() == "dkong" and mem:read_direct_u64(0x3fba) == 0x4d212153c31977dd then
extreme = true
pickup_table[1] = {10, 96} -- easier pickup location on barrels
end

change_title()

--Generate a starfield
Expand All @@ -433,12 +449,7 @@ function galakong.startplugin()

--Add more delay to the GAME OVER screen
mem:write_direct_u8(0x132f, 0xff)

-- Is this the wild barrel hack? Offset 3FBA to 3FBF is not used in regular DK
if emu.romname() == "dkong" and mem:read_direct_u32(0x3fba) == 0xc31977dd and mem:read_direct_u16(0x3fbe) == 0x2153 then
pickup_table[1] = {10, 5} -- make pickup location easier on barrels
end


-- Donkey Kong Junior specific initialisation
if emu.romname() == "dkongjr" then
enemy_table =
Expand Down Expand Up @@ -480,6 +491,24 @@ function galakong.startplugin()
local left, right, fire
local _frame = scr:frame_number()

if extreme then
-- Adjust start level for extreme Galakong
if level == 1 then
mem:write_u8(0x6229, 5) -- update to level 5
mem:write_u16(0x622a, 0x3a73) -- update screen sequence
end
-- Switch palette for extreme Galakong
if stage == 1 then -- Girders
mem:write_u8(0xc7d86, 1)
mem:write_u8(0xc7d87, 0)
elseif stage == 2 then -- Pies/Conveyors
mem:write_u8(0xc7d86, 0)
mem:write_u8(0xc7d87, 1)
elseif stage == 4 then -- Rivets
mem:write_u8(0xc7d86, 0)
end
end

if mode2 == 0x1 then -- Initial screen
started = false

Expand All @@ -499,6 +528,10 @@ function galakong.startplugin()
draw_graphic(yard_logo_table, 19, 175)
write_ram_message(0x77be, " VERSION "..exports.version)

if extreme then
draw_graphic(extreme_logo_table, 224, 59)
end

-- Alternative coin entry sound
if mem:read_u8(0x6083) == 2 then
clear_sounds()
Expand Down Expand Up @@ -576,7 +609,7 @@ function galakong.startplugin()
if mode2 >= 0xb and mode2 <= 0xd then -- during gameplay
jumpman_x = mem:read_u8(0x6203) - 15
jumpman_y = mem:read_u8(0x6205)

if pickup then
-- shield was collected, the ship can now be controlled
left, right, fire = get_inputs()
Expand Down Expand Up @@ -1048,7 +1081,11 @@ function galakong.startplugin()
-- change "HIGH SCORE" to "DK SHOOTER"
-- HIGH SCORE is 10 characters, pad with space if necessary
-- 1234567890
write_rom_message(0x36b4," GALAKONG ")
if extreme then
write_rom_message(0x36b4,"X-GALAKONG")
else
write_rom_message(0x36b4," GALAKONG ")
end

-- Change "HOW HIGH CAN YOU GET" text in rom to "HOW UP CAN YOU SCHMUP ?"
-- how high is 23 characters, pad with space if necessary
Expand Down
5 changes: 2 additions & 3 deletions launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ def check_for_input(force_exit=False):

# Optional joystick controls
if USE_JOYSTICK:
print(event.type)
if event.type == pygame.JOYAXISMOTION:
_g.active = True
_g.lastmove = _g.timer.duration
Expand Down Expand Up @@ -531,7 +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
inps = _s.get_inp_files(emu, name, sub, 12 - show_coach - show_chorus - show_shoot - show_start5)
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,
theme=dkafe_theme, onclose=close_menu)
Expand Down Expand Up @@ -735,7 +734,7 @@ def launch_rom(info, launch_plugin=None, override_emu=None):

def playback_rom(info, inpfile):
"""playback the specified inp file"""
launch_command, launch_directory, competing, _ = _s.build_launch_command(info, True, False)
launch_command, launch_directory, competing, _ = _s.build_launch_command(info, True, False, True)
if os.path.exists(launch_directory):
close_menu()
clear_screen(and_reset_display=True)
Expand Down

0 comments on commit 784de24

Please sign in to comment.