Added flicker-free planets to Commodore 64 version
This commit is contained in:
parent
3dc852da53
commit
47c4d5f029
4 changed files with 858 additions and 18 deletions
|
|
@ -14,8 +14,17 @@
|
|||
# It does the following:
|
||||
#
|
||||
# * Decrypt the gma6 file
|
||||
# * Modify the gma6 file to draw flicker-free ships
|
||||
# * Modify the gma6 file to draw flicker-free ships and planets
|
||||
# * Encrypt the gma6 file
|
||||
#
|
||||
# * Decrypt the gma5 file
|
||||
# * Modify the gma5 file to draw flicker-free planets
|
||||
# * Encrypt the gma5 file
|
||||
#
|
||||
# * Decrypt the gma4 file
|
||||
# * Modify the gma4 file to draw flicker-free planets
|
||||
# * Encrypt the gma4 file
|
||||
#
|
||||
# * Modify the gma1 file to remove disk protection
|
||||
#
|
||||
# Run this script by changing directory to the folder containing the disk files
|
||||
|
|
@ -86,7 +95,7 @@ print()
|
|||
print("Modifying Commodore 64 Elite")
|
||||
print("Platform: {}".format(platform.upper()))
|
||||
|
||||
# Configuration variables
|
||||
# Configuration variables for gma6
|
||||
|
||||
load_address = 0x6A00 - 2
|
||||
seed = 0x49
|
||||
|
|
@ -288,9 +297,9 @@ insert_nops(data_block, 0x9FC1, 1)
|
|||
# NOP
|
||||
|
||||
insert_bytes(data_block, 0x9FD9, [
|
||||
0xC8, # INY
|
||||
0xB1, 0x5B, # LDA (V),Y
|
||||
0xAA # TAX
|
||||
0xC8, # INY
|
||||
0xB1, 0x5B, # LDA (V),Y
|
||||
0xAA # TAX
|
||||
])
|
||||
|
||||
lda_sta_block = get_offset(0x9FDD)
|
||||
|
|
@ -298,9 +307,9 @@ for n in range(lda_sta_block, lda_sta_block + 4 * 5):
|
|||
data_block[n] = data_block[n + 4]
|
||||
|
||||
insert_bytes(data_block, 0x9FF1, [
|
||||
0xC8, # INY
|
||||
0xB1, 0x5B, # LDA (V),Y
|
||||
0xAA # TAX
|
||||
0xC8, # INY
|
||||
0xB1, 0x5B, # LDA (V),Y
|
||||
0xAA # TAX
|
||||
])
|
||||
insert_nops(data_block, 0x9FF5, 2)
|
||||
|
||||
|
|
@ -316,7 +325,7 @@ insert_nops(data_block, 0x9FF5, 2)
|
|||
# To: JMP PATCH2
|
||||
|
||||
insert_bytes(data_block, 0xA010, [
|
||||
0x4C, patch2 % 256, patch2 // 256 # JMP PATCH2
|
||||
0x4C, patch2 % 256, patch2 // 256 # JMP PATCH2
|
||||
])
|
||||
|
||||
# LL9 (Part 11)
|
||||
|
|
@ -359,6 +368,91 @@ elite_file.close()
|
|||
|
||||
print("[ Modify ] append file extra.bin")
|
||||
|
||||
# We now move on to the routines for drawing flicker-free planets
|
||||
|
||||
# Set the addresses for the extra routines (LLX30, PATCH1, PATCH2) that we will
|
||||
# append to the end of the main game code (where there is a bit of free space)
|
||||
|
||||
erasep = 0xCD3B
|
||||
patch4 = 0x69D0
|
||||
patch5 = 0x69D5
|
||||
|
||||
# PL9 (Part 1 of 3)
|
||||
#
|
||||
# We have already assembled the modified part 1 of PL9 in BeebAsm and saved
|
||||
# it as the binary file pl9.bin, so now we drop this over the top of the
|
||||
# existing routine (the new routine is slightly bigger, so it ends by jumping
|
||||
# to PATCH6, which contains the spill-over).
|
||||
|
||||
insert_binary_file(data_block, 0x7D8C, "pl9.bin")
|
||||
|
||||
# PL9 (Part 2 of 3)
|
||||
#
|
||||
# The above modification moves PL20, so we need to modify the branch instruction
|
||||
# at the start of part 2 of PL9.
|
||||
|
||||
insert_bytes(data_block, 0x7DA8, [
|
||||
0x90, 0xEB # BCC PL20
|
||||
])
|
||||
|
||||
# PL9 (Part 3 of 3)
|
||||
#
|
||||
# The above modification moves PL20, so we need to modify the branch instruction
|
||||
# at the start of part 3 of PL9.
|
||||
|
||||
insert_bytes(data_block, 0x7DE2, [
|
||||
0x30, 0xB1 # BMI PL20
|
||||
])
|
||||
|
||||
# WPLS2
|
||||
#
|
||||
# We have already assembled the modified part 1 of PL9 in BeebAsm and saved
|
||||
# it as the binary file pl9.bin, so now we drop this over the top of the
|
||||
# existing routine (which is quite a bit longer, so there is room).
|
||||
|
||||
insert_binary_file(data_block, 0x80BB, "wpls2.bin")
|
||||
|
||||
# PLS22
|
||||
#
|
||||
# This is the modification on either side of PL40, with the label moving two
|
||||
# bytes backwards to accommodate the modified code.
|
||||
#
|
||||
# From: BCS PL40
|
||||
# ...
|
||||
# STA CNT2
|
||||
# JMP PLL4
|
||||
# .PL40
|
||||
# RTS
|
||||
#
|
||||
# To: BCS PL40
|
||||
# ...
|
||||
# JMP PATCH4
|
||||
# .PL40
|
||||
# JMP EraseRestOfPlanet
|
||||
|
||||
insert_bytes(data_block, 0x7F04, [
|
||||
0xB0, 0x0A # BCS PL40
|
||||
])
|
||||
insert_bytes(data_block, 0x7F0D, [
|
||||
0x4C, patch4 % 256, patch4 // 256, # JMP PATCH4
|
||||
0x4C, erasep % 256, erasep // 256 # JMP EraseRestOfPlanet
|
||||
])
|
||||
|
||||
# CIRCLE2
|
||||
#
|
||||
# This is the modification at the start of the routine.
|
||||
#
|
||||
# From: LDX #&FF
|
||||
# STX FLAG
|
||||
#
|
||||
# To: JSR PATCH5
|
||||
# NOP
|
||||
|
||||
insert_bytes(data_block, 0x805E, [
|
||||
0x20, patch5 % 256, patch5 // 256 # JSR PATCH5
|
||||
])
|
||||
insert_nops(data_block, 0x8061, 1)
|
||||
|
||||
# All the modifications are done, so write the output file for gma6.modified,
|
||||
# which we can use for debugging
|
||||
|
||||
|
|
@ -386,6 +480,165 @@ output_file.close()
|
|||
|
||||
print("[ Save ] gma6.encrypted")
|
||||
|
||||
# Configuration variables for gma5
|
||||
|
||||
load_address = 0x1D00 - 2
|
||||
seed = 0x36
|
||||
scramble_from = 0x1D00
|
||||
scramble_to = 0x1D00 + (0x21D4 - 3) # File size - 3
|
||||
|
||||
# Set up an array to hold the gma5 binary, so we can modify it
|
||||
|
||||
data_block = bytearray()
|
||||
|
||||
# Load the gma5 code file into data_block
|
||||
|
||||
elite_file = open("gma5", "rb")
|
||||
data_block.extend(elite_file.read())
|
||||
elite_file.close()
|
||||
|
||||
print()
|
||||
print("[ Read ] gma5")
|
||||
|
||||
# Decrypt the gma5 code file
|
||||
|
||||
updated_seed = seed
|
||||
|
||||
for n in range(scramble_to, scramble_from - 1, -1):
|
||||
new = (data_block[n - load_address] - updated_seed) % 256
|
||||
data_block[n - load_address] = new
|
||||
updated_seed = new
|
||||
|
||||
print("[ Decrypt ] gma5")
|
||||
|
||||
# Write an output file containing the decrypted but unmodified gma5 code, which
|
||||
# we can use for debugging
|
||||
|
||||
output_file = open("gma5.decrypted", "wb")
|
||||
output_file.write(data_block)
|
||||
output_file.close()
|
||||
|
||||
print("[ Save ] gma5.decrypted")
|
||||
|
||||
# BLINE
|
||||
#
|
||||
# We have already assembled the modified BLINE in BeebAsm and saved it as the
|
||||
# binary file bline.bin, so now we drop this over the top of the existing
|
||||
# routine (the new routine is slightly bigger, so it ends by jumping to PATCH3,
|
||||
# which contains the spill-over).
|
||||
|
||||
insert_binary_file(data_block, 0x2977, "bline.bin")
|
||||
|
||||
# All the modifications are done, so write the output file for gma5.modified,
|
||||
# which we can use for debugging
|
||||
|
||||
output_file = open("gma5.modified", "wb")
|
||||
output_file.write(data_block)
|
||||
output_file.close()
|
||||
|
||||
print("[ Save ] gma5.modified")
|
||||
|
||||
# Encrypt the gma5 code file
|
||||
|
||||
for n in range(scramble_from, scramble_to):
|
||||
data_block[n - load_address] = (data_block[n - load_address] + data_block[n + 1 - load_address]) % 256
|
||||
|
||||
data_block[scramble_to - load_address] = (data_block[scramble_to - load_address] + seed) % 256
|
||||
|
||||
print("[ Encrypt ] gma5.modified")
|
||||
|
||||
# Write the output file for gma5.encrypted, which contains our modified game
|
||||
# binary with the flicker-free code
|
||||
|
||||
output_file = open("gma5.encrypted", "wb")
|
||||
output_file.write(data_block)
|
||||
output_file.close()
|
||||
|
||||
print("[ Save ] gma5.encrypted")
|
||||
|
||||
# Configuration variables for gma4
|
||||
|
||||
load_address = 0x4000 - 2
|
||||
seed = 0x8E
|
||||
scramble_from = 0x75E4
|
||||
scramble_to = 0x865A
|
||||
|
||||
# Set up an array to hold the gma4 binary, so we can modify it
|
||||
|
||||
data_block = bytearray()
|
||||
|
||||
# Load the gma4 code file into data_block
|
||||
|
||||
elite_file = open("gma4", "rb")
|
||||
data_block.extend(elite_file.read())
|
||||
elite_file.close()
|
||||
|
||||
print()
|
||||
print("[ Read ] gma4")
|
||||
|
||||
# Decrypt the gma4 code file
|
||||
|
||||
updated_seed = seed
|
||||
|
||||
for n in range(scramble_to, scramble_from - 1, -1):
|
||||
new = (data_block[n - load_address] - updated_seed) % 256
|
||||
data_block[n - load_address] = new
|
||||
updated_seed = new
|
||||
|
||||
print("[ Decrypt ] gma4")
|
||||
|
||||
# Write an output file containing the decrypted but unmodified gma4 code, which
|
||||
# we can use for debugging
|
||||
|
||||
output_file = open("gma4.decrypted", "wb")
|
||||
output_file.write(data_block)
|
||||
output_file.close()
|
||||
|
||||
print("[ Save ] gma4.decrypted")
|
||||
|
||||
# We now insert the four extra routines required by the modifications into
|
||||
# the unused space just after the sprites:
|
||||
#
|
||||
# PATCH3
|
||||
# PATCH4
|
||||
# PATCH5
|
||||
# PATCH6
|
||||
#
|
||||
# We have already assembled these in BeebAsm and saved them as the binary file
|
||||
# extra2.bin, so we simply insert this file at the correct address. The contents
|
||||
# of the GMA4 file is moved after decryption, so although the routines end up at
|
||||
# $69C0, they actually get loaded and decrypted at $7C3A, so that's the address
|
||||
# we use when inserting the code into the gm4 file:
|
||||
|
||||
insert_binary_file(data_block, 0x7C3A, "extra2.bin")
|
||||
|
||||
# All the modifications are done, so write the output file for gma4.modified,
|
||||
# which we can use for debugging
|
||||
|
||||
output_file = open("gma4.modified", "wb")
|
||||
output_file.write(data_block)
|
||||
output_file.close()
|
||||
|
||||
print("[ Save ] gma4.modified")
|
||||
|
||||
# Encrypt the gma4 code file
|
||||
|
||||
for n in range(scramble_from, scramble_to):
|
||||
data_block[n - load_address] = (data_block[n - load_address] + data_block[n + 1 - load_address]) % 256
|
||||
|
||||
data_block[scramble_to - load_address] = (data_block[scramble_to - load_address] + seed) % 256
|
||||
|
||||
print("[ Encrypt ] gma4.modified")
|
||||
|
||||
# Write the output file for gma4.encrypted, which contains our modified game
|
||||
# binary with the flicker-free code
|
||||
|
||||
output_file = open("gma4.encrypted", "wb")
|
||||
output_file.write(data_block)
|
||||
output_file.close()
|
||||
|
||||
print("[ Save ] gma4.encrypted")
|
||||
|
||||
# Finally, we need to remove the disk protection from gma1, as described here:
|
||||
# https://www.lemon64.com/forum/viewtopic.php?t=67762&start=90
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue