LADX: apworld (#1665)

This commit is contained in:
zig-for 2023-04-06 11:06:34 -07:00 committed by GitHub
parent eef8f7af1a
commit ece6598b09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 17 deletions

View File

@ -71,6 +71,7 @@ apworlds: set = {
"Timespinner",
"Minecraft",
"The Messenger",
"Links Awakening DX",
}

View File

@ -115,8 +115,8 @@ class Tokenizer:
assert kind is not None
value: Union[str, int] = mo.group()
if kind == 'MISMATCH':
print(code.split("\n")[line_num-1])
raise RuntimeError("Syntax error on line: %d: %s\n%s", line_num, value)
line = code.split("\n")[line_num - 1]
raise RuntimeError(f"Syntax error on line: {line_num}: {kind}:`{line}`")
elif kind == 'SKIP':
pass
elif kind == 'COMMENT':

View File

@ -1,5 +1,7 @@
import os
import binascii
import pkgutil
from ..assembler import ASM
from ..utils import formatText
@ -13,7 +15,6 @@ ItemNameStringBufferStart = ItemNameLookupTable + \
def addBank34(rom, item_list):
my_path = os.path.dirname(__file__)
rom.patch(0x34, 0x0000, ItemNameLookupTable, ASM("""
; Get the pointer in the lookup table, doubled as it's two bytes
ld hl, $2080
@ -74,7 +75,7 @@ def addBank34(rom, item_list):
.notCavesA:
add hl, de
ret
""" + open(os.path.join(my_path, "bank3e.asm/message.asm"), "rt").read(), 0x4000), fill_nop=True)
""" + pkgutil.get_data(__name__, os.path.join("bank3e.asm", "message.asm")).decode().replace("\r", ""), 0x4000), fill_nop=True)
nextItemLookup = ItemNameStringBufferStart
nameLookup = {

View File

@ -3,6 +3,7 @@ import binascii
from ..assembler import ASM
from ..utils import formatText
import pkgutil
def hasBank3E(rom):
return rom.banks[0x3E][0] != 0x00
@ -54,7 +55,9 @@ def addBank3E(rom, seed, player_id, player_name_list):
ret
"""))
my_path = os.path.dirname(__file__)
def get_asm(name):
return pkgutil.get_data(__name__, os.path.join("bank3e.asm", name)).decode().replace("\r", "")
rom.patch(0x3E, 0x0000, 0x2F00, ASM("""
call MainJumpTable
pop af
@ -204,15 +207,15 @@ LocalOnlyItemAndMessage:
call GiveItemFromChest
call ItemMessage
ret
""" + open(os.path.join(my_path, "bank3e.asm/multiworld.asm"), "rt").read()
+ open(os.path.join(my_path, "bank3e.asm/link.asm"), "rt").read()
+ open(os.path.join(my_path, "bank3e.asm/chest.asm"), "rt").read()
+ open(os.path.join(my_path, "bank3e.asm/bowwow.asm"), "rt").read()
+ open(os.path.join(my_path, "bank3e.asm/message.asm"), "rt").read()
+ open(os.path.join(my_path, "bank3e.asm/itemnames.asm"), "rt").read()
""" + get_asm("multiworld.asm")
+ get_asm("link.asm")
+ get_asm("chest.asm")
+ get_asm("bowwow.asm")
+ get_asm("message.asm")
+ get_asm("itemnames.asm")
+ "".join(generate_name(["The Server"] + player_name_list, i ) for i in range(100)) # allocate
+ 'db "another world", $ff\n'
+ open(os.path.join(my_path, "bank3e.asm/owl.asm"), "rt").read(), 0x4000), fill_nop=True)
+ get_asm("owl.asm"), 0x4000), fill_nop=True)
# 3E:3300-3616: Multiworld flags per room (for both chests and dropped keys)
# 3E:3800-3B16: DroppedKey item types
# 3E:3B16-3E2C: Owl statue or trade quest items

View File

@ -1,6 +1,6 @@
from ..assembler import ASM
import os
import pkgutil
def updateEndScreen(rom):
# Call our custom data loader in bank 3F
@ -134,6 +134,6 @@ loadLoop2:
"""))
addr = 0x1000
for c in open(os.path.join(os.path.dirname(__file__), "nyan.bin"), "rb").read():
rom.banks[0x3F][addr] = c
addr += 1
data = pkgutil.get_data(__name__, "nyan.bin")
rom.banks[0x3F][addr : addr + len(data)] = data

View File

@ -7,7 +7,7 @@ h2b = binascii.unhexlify
class ROM:
def __init__(self, filename):
data = open(Utils.local_path(filename), "rb").read()
data = open(Utils.user_path(filename), "rb").read()
#assert len(data) == 1024 * 1024
self.banks = []
for n in range(0x40):