Skip to content

Commit 013f5ae

Browse files
authored
Merge pull request #25 from cormacj/template-work
fixed template W/B and updated pointer naming
2 parents 521f4f2 + 64db930 commit 013f5ae

File tree

2 files changed

+66
-8
lines changed

2 files changed

+66
-8
lines changed

amstrad_rom_template.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
0xc001,0xc001,b,ROM_MAJOR
1919
0xc002,0xc002,b,ROM_MARK
2020
0xc003,0xc003,b,ROM_MOD
21+
0xc3e6,0xc3e6,w,EXEC_RSX_CMD
2122

2223
;Now tag the pointer to the command names table
2324
0xc004,0xc004,p,CMD_TABLE_PTR

z80-disassembler.py

Lines changed: 65 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def check_for_pointer(addr):
300300
ptr.ispointer=True
301301
ptr.source=to_number(p_addr)
302302
ptr.destination=(bin_data[p_addr+1]*0x100)+(bin_data[p_addr]) #Get the address where the pointer is pointing to
303-
print("check for ptr:",hex(p_addr),hex(ptr.destination))
303+
# print("check for ptr:",hex(p_addr),hex(ptr.destination))
304304
return ptr
305305
else:
306306
#Not a pointer, just a number
@@ -384,19 +384,19 @@ def process_template(filename):
384384
# for loop in range(begin,end):
385385
# print(loop)
386386
# mark_handled(addr,1,"D")
387-
# case "b":
388-
# mark_handled(addr,2,"D")
387+
case "b":
388+
mark_handled(addr,2,"Db")
389389
case "w":
390-
mark_handled(addr,2,"D")
390+
mark_handled(addr,2,"Dw")
391391
case "c":
392392
# print("Code:",hex(begin),hex(end))
393393
for loop in range(begin,end):
394394
mark_handled(loop,1,"C")
395395
mark_handled(addr,3,"C")
396396
case "p":
397-
mark_handled(addr,2,"D")
397+
mark_handled(addr,2,"Dw")
398398
code_loc=begin #Get the address where the pointer is pointing to
399-
mark_handled(code_loc,2,"D")
399+
# mark_handled(code_loc,2,"Dw")
400400
case "s":
401401
for loop in range(begin,end-1):
402402
mark_handled(loop,1,"S")
@@ -714,6 +714,10 @@ def type_lookup(datatype):
714714
return "string"
715715
case "D":
716716
return "data"
717+
case "Db":
718+
return "data"
719+
case "Dw":
720+
return "data"
717721
case "C":
718722
return "code"
719723

@@ -735,7 +739,7 @@ def update_label_name(addr, type):
735739
case 1:
736740
result = type
737741
case 2:
738-
result=type_lookup(type)
742+
result = type_lookup(type)
739743
case _:
740744
result = type
741745

@@ -1192,6 +1196,18 @@ def findstring(memstart, memend):
11921196
)
11931197
)
11941198
program_counter += 1
1199+
elif identified(program_counter) == "Dw":
1200+
if is_in_code(program_counter):
1201+
tmp = get_from_code(program_counter,0) #code[loc][0]
1202+
out_tmp = (
1203+
f'"{chr(tmp)}"'
1204+
if 31 < tmp < 127
1205+
else (
1206+
f"('{chr(tmp - 0x80)}') + {hexstyle}80" if 31 < (tmp - 0x80) < 127 else hex(tmp)
1207+
)
1208+
)
1209+
# print(out_tmp)
1210+
program_counter += 1
11951211
elif identified(program_counter) == "C":
11961212
b = z80.decode(decode_buffer, 0)
11971213
conds = z80.disasm(b).split(",")[0] + ","
@@ -1479,7 +1495,7 @@ def findstring(memstart, memend):
14791495
# print(f'Bump 7 {hex(program_counter)}-->{hex(program_counter+str_sizes[program_counter])}')
14801496
program_counter += str_sizes[program_counter]
14811497
# elif identified(program_counter) == "D" and not stay_in_code:
1482-
elif identified(program_counter) == "D":
1498+
elif identified(program_counter) in ("D", "Db"):
14831499
# dump_code_array("---->",program_counter)
14841500

14851501
# debug("D2 - 2")
@@ -1499,6 +1515,47 @@ def findstring(memstart, memend):
14991515
code_output(program_counter, f"DEFB {hexstyle}{tmp:x}", list_address, f'{out_tmp}')
15001516
# debug("PC Bump")
15011517
program_counter += 1 #FIXME - tripping PC too much?
1518+
elif identified(program_counter) == "Dw":
1519+
# dump_code_array("---->",program_counter)
1520+
1521+
# debug("D2 - 2")
1522+
if is_in_code(program_counter):
1523+
# debug("D - 3")
1524+
tmpl = get_from_code(program_counter,0) #Low byte
1525+
tmph = get_from_code(program_counter+1,0) #High byte
1526+
tmp=((tmph*256)+tmpl) #make it a word
1527+
if (tmp in labels) or (tmp in template_labels):
1528+
if (tmp in template_labels):
1529+
labelname=template_labels[tmp]
1530+
# if labelname[0]=="0":
1531+
# print("1 used")
1532+
else:
1533+
labelname=lookup_label(tmp,1)
1534+
# if labelname[0]=="0":
1535+
# print("2 used")
1536+
out_tmp = (
1537+
f'"{chr(tmpl)}"'
1538+
if 31 < tmpl < 127
1539+
else (
1540+
f"('{chr(tmpl - 0x80)}') + {hexstyle}80" if 31 < (tmpl - 0x80) < 127 else hex(tmpl)
1541+
)
1542+
)
1543+
out_tmp = out_tmp+" "+(
1544+
f'"{chr(tmph)}"'
1545+
if 31 < tmph < 127
1546+
else (
1547+
f"('{chr(tmph - 0x80)}') + {hexstyle}80" if 31 < (tmph - 0x80) < 127 else hex(tmph)
1548+
)
1549+
)
1550+
if labelname[0]!="0":
1551+
out_tmp=f"Pointer to {labelname}"
1552+
#BUG: Causes defb 01 01 on -c 0
1553+
if commentlevel==0:
1554+
out_tmp="; "+out_tmp
1555+
# code_output(program_counter, f"DEFB {hexstyle}{tmp:x}", list_address, f'{out_tmp}')
1556+
code_output(program_counter, f"DEFB {labelname}", list_address, f'{out_tmp}')
1557+
# debug("PC Bump")
1558+
program_counter += 2 #FIXME - tripping PC too much?
15021559
elif identified(program_counter) == "C": # or (stay_in_code and identified(program_counter)!="C"):
15031560
# debug("C2 - 1")
15041561
b = z80.decode(decode_buffer, 0)

0 commit comments

Comments
 (0)