Skip to content

Commit 140c314

Browse files
committed
Initial commit
0 parents  commit 140c314

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+52812
-0
lines changed

.gitattributes

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
7+
# Standard to msysgit
8+
*.doc diff=astextplain
9+
*.DOC diff=astextplain
10+
*.docx diff=astextplain
11+
*.DOCX diff=astextplain
12+
*.dot diff=astextplain
13+
*.DOT diff=astextplain
14+
*.pdf diff=astextplain
15+
*.PDF diff=astextplain
16+
*.rtf diff=astextplain
17+
*.RTF diff=astextplain

.gitignore

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Windows thumbnail cache files
2+
Thumbs.db
3+
ehthumbs.db
4+
ehthumbs_vista.db
5+
6+
# Folder config file
7+
Desktop.ini
8+
9+
# Recycle Bin used on file shares
10+
$RECYCLE.BIN/
11+
12+
# Windows Installer files
13+
*.cab
14+
*.msi
15+
*.msm
16+
*.msp
17+
18+
# Windows shortcuts
19+
*.lnk
20+
21+
# =========================
22+
# Operating System Files
23+
# =========================
24+
.vscode/tasks.json
25+
compile.txt
26+
elite-a-beebasm.code-workspace
27+
run.bat
28+
elite-header.h.asm

compile.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
beebasm -i "sources/a.tcode" -v > output/compile.txt
2+
beebasm -i "sources/a.dcode" -v >> output/compile.txt
3+
beebasm -i "sources/make1d.asm" -v >> output/compile.txt
4+
beebasm -i "sources/a.qcode" -v >> output/compile.txt
5+
beebasm -i "sources/a.qelite" -v >> output/compile.txt
6+
beebasm -i "sources/a.elite" -v >> output/compile.txt

convert.py

+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
import re
2+
3+
4+
# Config
5+
source_folder = "original/"
6+
source_files = ["a.global",
7+
"a.tcode", "a.tcode_1", "a.tcode_2", "a.tcode_3",
8+
"a.dcode", "a.dcode_1", "a.dcode_2", "a.dcode_3",
9+
"a.icode", "a.icode_1", "a.icode_2", "a.icode_3",
10+
"a.qcode", "a.qcode_1", "a.qcode_2", "a.qcode_3", "a.qcode_4", "a.qcode_5", "a.qcode_6",
11+
"a.qship_1", "a.qship_2",
12+
"a.qelite",
13+
"a.elite"
14+
]
15+
dest_folder = "sources/"
16+
17+
re_label = re.compile(r'^([a-z0-9A-Z_]+):?(\s+.*)*$')
18+
re_llabel = re.compile(r'(l_[0-9A-F]{4})')
19+
re_instruction = re.compile(r'^\s*(.+)$')
20+
re_equa = re.compile(r'^\s*EQUA\s*"(.+)"$')
21+
re_opt = re.compile(r'^\s*OPT.+$')
22+
re_var = re.compile(r'^([a-z0-9A-Z_]+):?\s*EQU \s*(\$?)(.+)$')
23+
re_get = re.compile(r'^\s+GET\s*"(.+)"$')
24+
re_labelinstruction = re.compile(r'^([a-z0-9A-Z_]+):?\s+(.+)$')
25+
26+
27+
def process_file(input_file, output_file, source_file):
28+
for line in input_file:
29+
# Manual fixes for scoping and case issues that trigger BeebAsm errors
30+
if source_file == "a.qcode_4":
31+
line = line.replace("jmp_start3", "jmp_start3_dup")
32+
if source_file == "a.qcode_3":
33+
line = line.replace("_07c0", "_07C0")
34+
line = line.replace("_07e0", "_07E0")
35+
36+
if line.endswith("..<\n"):
37+
continue
38+
39+
a = re_llabel.search(line)
40+
while a and a.group(1) != a.group(1).lower():
41+
line = line.replace(a.group(1), a.group(1).lower())
42+
a = re_llabel.search(line)
43+
m = re_label.search(line)
44+
n = re_equa.search(line)
45+
p = re_instruction.search(line)
46+
q = re_var.search(line)
47+
r = re_get.search(line)
48+
s = re_labelinstruction.search(line)
49+
if "EQUD 2#" in line:
50+
line = line.replace("EQUD 2#", "EQUD %")
51+
elif s and not s.group(2).startswith("EQU "):
52+
line = "\n." + s.group(1) + "\n\n"
53+
if s.group(2).startswith("EQUA"):
54+
z = re_equa.search(s.group(2))
55+
line += ' EQUS "' + convert_equa(z.group(1)) + '"\n'
56+
else:
57+
line += " " + s.group(2).replace("$", "&") + "\n"
58+
elif q:
59+
amp = q.group(2).replace("$", "&")
60+
line = q.group(1) + " = " + amp + q.group(3) + "\n"
61+
elif m:
62+
line = "\n." + m.group(1) + "\n\n"
63+
elif n:
64+
line = ' EQUS "' + convert_equa(n.group(1)) + '"\n'
65+
elif r:
66+
line = 'INCLUDE "sources/' + r.group(1).replace(":0.", "").replace(":2.", "") + '"\n'
67+
elif p:
68+
if p.group(1).startswith("LOAD"):
69+
line = line.replace("$FFFF", "$").replace("\tLOAD $", "LOAD% = &")
70+
elif p.group(1).startswith("EXEC"):
71+
line = line.replace("$FFFF", "$").replace("\tEXEC $", "EXEC% = &").replace("\tEXEC ", "\\EXEC = ")
72+
elif p.group(1).startswith("ORG"):
73+
line = line.replace("$FFFF", "$").replace("\tORG $", "CODE% = &") + "ORG CODE%\n"
74+
elif p.group(1).startswith("OPT"):
75+
line = line.replace("\tOPT", "\\OPT")
76+
else:
77+
line = " " + p.group(1).replace("$", "&") + "\n"
78+
output_file.write(line)
79+
80+
81+
def convert_equa(equa):
82+
result = ""
83+
ctrl = False
84+
excl = False
85+
86+
for char in equa:
87+
if ctrl:
88+
if char == '!':
89+
excl = True
90+
ctrl = False
91+
continue
92+
if char == '|':
93+
ascii = ord(char)
94+
else:
95+
ascii = ord(char) - 0x40
96+
if ascii < 0:
97+
ascii += 0x80
98+
if excl:
99+
ascii += 0x80
100+
result += '", &' + ('%02x' % ascii).upper() + ', "'
101+
ctrl = False
102+
excl = False
103+
elif char == '|':
104+
ctrl = True
105+
else:
106+
if excl:
107+
ascii = ord(char) + 0x80
108+
if ascii < 0:
109+
ascii += 0x80
110+
result += '", &' + ('%02x' % ascii).upper() + ', "'
111+
else:
112+
result += char
113+
ctrl = False
114+
excl = False
115+
116+
return result
117+
118+
119+
for source_file in source_files:
120+
input = source_folder + source_file
121+
122+
with open(input, "r", encoding="latin-1") as input_file:
123+
output = dest_folder + source_file
124+
print(".", end="", flush=True)
125+
126+
with open(output, "w") as output_file:
127+
process_file(input_file, output_file, source_file)
128+
129+
if source_file == "a.tcode":
130+
output_file.write('\nSAVE "output/tcode.bin", CODE%, P%, LOAD%')
131+
if source_file == "a.dcode":
132+
output_file.write('\nSAVE "output/1.F.bin", CODE%, P%, LOAD%')
133+
if source_file == "a.icode":
134+
output_file.write('\nSAVE "output/1.E.bin", CODE%, P%, LOAD%')
135+
if source_file == "a.qcode":
136+
output_file.write('\nSAVE "output/2.T.bin", CODE%, P%, LOAD%')
137+
if source_file == "a.qelite":
138+
output_file.write('\nSAVE "output/2.H.bin", CODE%, P%, LOAD%')
139+
if source_file == "a.elite":
140+
output_file.write('\nSAVE "output/Elite.bin", CODE%, P%, LOAD%')
141+
142+
print()

extracted/$.Elite

4.97 KB
Binary file not shown.

extracted/$.tcode

17 KB
Binary file not shown.

extracted/1.D

19.5 KB
Binary file not shown.

extracted/1.D-patched

19.5 KB
Binary file not shown.

extracted/1.E

16.4 KB
Binary file not shown.

extracted/1.F

17 KB
Binary file not shown.

extracted/2.H

1.91 KB
Binary file not shown.

extracted/2.T

42.1 KB
Binary file not shown.

extracted/S.T

2.5 KB
Binary file not shown.

original/a.dcode

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
\ a.dcode - ELITE III in-flight code GET ":0.a.global" ORG $11E3 LOAD $11E3 EXEC $11E3dcode_in: JMP startboot_in: JMP startwrch_in: JMP wrchdst EQUW $114Bbrk_in: JMP brkdst GET "a.dcode_1" GET "a.dcode_2" GET "a.dcode_3"

original/a.dcode_1

+1
Large diffs are not rendered by default.

original/a.dcode_2

+1
Large diffs are not rendered by default.

original/a.dcode_3

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
l_54c8: STA $87l_54ca: JSR vdu_80 JSR l_360a STA $0343 STA $034A STA $034B LDX #$60l_54dc JSR l_42a1 INX CPX #$78 BNE l_54dc LDX $2F BEQ l_54eb JSR l_30acl_54eb: LDY #$01 STY cursor_y LDA $87 BNE l_5507 LDY #$0B STY cursor_x LDA view_dirn ORA #$60 JSR l_339a JSR l_3142 LDA #$AF JSR l_339al_5507 LDX #$00 STX $34 STX $35 STX vdu_stat DEX STX $36 JSR l_1868 LDA #$02 STA $34 STA $36 JSR l_551el_551e JSR l_5521l_5521 LDA #$00 STA $35 LDA #$BF STA $37 DEC $34 DEC $36 JMP l_16c4l_5530: JSR l_55f7 DEY BNE l_5530 RTSl_5537: LDA #$14 STA cursor_y LDA #$75 STA ptr+$01 LDA #$07 STA ptr JSR l_2b60 LDA #$00 JSR l_5550 INC ptr+$01 INY STY cursor_xl_5550 LDY #$E9l_5552 STA (ptr),Y DEY BNE l_5552l_5557 RTSiff_xor EQUB $00, $00, $0F \, $FF, $F0 overlapiff_base EQUB $FF, $F0, $FF, $F0, $FFl_5558: LDA $65 AND #$10 BEQ l_5557 LDA $8C BMI l_5557 JSR iff_index LDA iff_base,X STA $91 LDA iff_xor,X STA $37 LDA $47 ORA $4A ORA $4D AND #$C0 BNE l_5557 LDA $47 CLC LDX $48 BPL l_5581 EOR #$FF ADC #$01l_5581 ADC #$7B STA $34 LDA $4D LSR A LSR A CLC LDX $4E BPL l_5591 EOR #$FF SECl_5591 ADC #$23 EOR #$FF STA ptr LDA $4A LSR A CLC LDX $4B BMI l_55a2 EOR #$FF SECl_55a2 ADC ptr BPL l_55b0 CMP #$C2 BCS l_55ac LDA #$C2l_55ac CMP #$F7 BCC l_55b2l_55b0 LDA #$F6l_55b2 STA $35 SEC SBC ptr\ PHP PHA JSR l_36a7 LDA pixels+$11,X TAX AND $91 \ iff STA $34 TXA AND $37 STA $35 PLA\ PLP TAX BEQ l_55da\ BCC l_55db BMI l_55dbl_55ca DEY BPL l_55d1 LDY #$07 DEC ptr+$01l_55d1 LDA $34 EOR $35 \ iff STA $34 \ iff EOR (ptr),Y STA (ptr),Y DEX BNE l_55cal_55da RTSl_55db INY CPY #$08 BNE l_55e4 LDY #$00 INC ptr+$01l_55e4 INY CPY #$08 BNE l_55ed LDY #$00 INC ptr+$01l_55ed LDA $34 EOR $35 \ iff STA $34 \ iff EOR (ptr),Y STA (ptr),Y INX BNE l_55e4 RTSl_55f7: LDA #$00 STA $8Bl_55fb LDA $8B BEQ l_55fb RTS

original/a.elite

+1
Large diffs are not rendered by default.

original/a.global

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
OPT TABS=16
2+
3+
key_table: EQU $04
4+
ptr: EQU $07
5+
font: EQU $1C
6+
cursor_x: EQU $2C
7+
cursor_y: EQU $2D
8+
vdu_stat: EQU $72
9+
brk_line: EQU $FD
10+
last_key: EQU $300
11+
ship_type: EQU $311
12+
cabin_t: EQU $342
13+
target: EQU $344
14+
view_dirn: EQU $345
15+
laser_t: EQU $347
16+
adval_x: EQU $34C
17+
adval_y: EQU $34D
18+
cmdr_mission: EQU $358
19+
cmdr_homex: EQU $359
20+
cmdr_homey: EQU $35A
21+
cmdr_gseed: EQU $35B
22+
cmdr_money: EQU $361
23+
cmdr_fuel: EQU $365
24+
cmdr_galxy: EQU $367
25+
cmdr_laser: EQU $368
26+
cmdr_ship: EQU $36D
27+
cmdr_hold: EQU $36E
28+
cmdr_cargo: EQU $36F
29+
cmdr_ecm: EQU $380
30+
cmdr_scoop: EQU $381
31+
cmdr_bomb: EQU $382
32+
cmdr_eunit: EQU $383
33+
cmdr_dock: EQU $384
34+
cmdr_ghype: EQU $385
35+
cmdr_escape: EQU $386
36+
cmdr_cour: EQU $387
37+
cmdr_courx: EQU $389
38+
cmdr_coury: EQU $38A
39+
cmdr_misl: EQU $38B
40+
cmdr_legal: EQU $38C
41+
cmdr_avail: EQU $38D
42+
cmdr_price: EQU $39E
43+
cmdr_kills: EQU $39F
44+
f_shield: EQU $3A5
45+
r_shield: EQU $3A6
46+
energy: EQU $3A7
47+
home_econ: EQU $3AC
48+
home_govmt: EQU $3AE
49+
home_tech: EQU $3AF
50+
data_econ: EQU $3B8
51+
data_govm: EQU $3B9
52+
data_tech: EQU $3BA
53+
data_popn: EQU $3BB
54+
data_gnp: EQU $3BD
55+
hype_dist: EQU $3BF
56+
data_homex: EQU $3C1
57+
data_homey: EQU $3C2
58+
s_flag: EQU $3C6
59+
cap_flag: EQU $3C7
60+
a_flag: EQU $3C8
61+
x_flag: EQU $3C9
62+
f_flag: EQU $3CA
63+
y_flag: EQU $3CB
64+
j_flag: EQU $3CC
65+
k_flag: EQU $3CD
66+
b_flag: EQU $3CE
67+
\
68+
save_lock: EQU $233
69+
new_file: EQU $234
70+
new_posn: EQU $235
71+
new_type: EQU $36D
72+
new_pulse: EQU $3D0
73+
new_beam: EQU $3D1
74+
new_military: EQU $3D2
75+
new_mining: EQU $3D3
76+
new_mounts: EQU $3D4
77+
new_missiles: EQU $3D5
78+
new_shields: EQU $3D6
79+
new_energy: EQU $3D7
80+
new_speed: EQU $3D8
81+
new_hold: EQU $3D9
82+
new_range: EQU $3DA
83+
new_costs: EQU $3DB
84+
new_max: EQU $3DC
85+
new_min: EQU $3DD
86+
new_space: EQU $3DE
87+
\new_: EQU $3DF
88+
new_name: EQU $74D
89+
\
90+
iff_index: EQU $D7A
91+
altitude: EQU $FD1
92+
irq1: EQU $114B
93+
commander: EQU $1189
94+
brkdst: EQU $11D5
95+
ship_data: EQU $55FE
96+
l_563d: EQU $563D
97+
osfile: EQU $FFDD
98+
oswrch: EQU $FFEE
99+
osword: EQU $FFF1
100+
osbyte: EQU $FFF4
101+
oscli: EQU $FFF7

original/a.icode

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
\ a.icode - ELITE III encyclopedia GET ":0.a.global" ORG $11E3 LOAD $11E3 EXEC $11E3dcode_in: JMP dcode_2boot_in: JMP dcode_2wrch_in: JMP wrchdst EQUW $114Bbrk_in: JMP brk_go GET "a.icode_1" GET "a.icode_2" GET "a.icode_3"

original/a.icode_1

+1
Large diffs are not rendered by default.

original/a.icode_2

+1
Large diffs are not rendered by default.

original/a.icode_3

+1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)