Skip to content

Instantly share code, notes, and snippets.

@magical
Last active April 30, 2021 03:04
Show Gist options
  • Save magical/e9fe1896ccfc3da4090a98e554d674a2 to your computer and use it in GitHub Desktop.
Save magical/e9fe1896ccfc3da4090a98e554d674a2 to your computer and use it in GitHub Desktop.
# http://bjoern.spruck.net/lynx/blog/chips.xhtml
# UnpackgenerateCode_L1D08:
# LDX #$00
# STZ $44
# STZ $45
# LoopGenerateCode_L1D0E:
# JSR GenerateCodeFunk1_L1D3C
# STA $1280,X
# JSR GenerateCodeFunk1_L1D3C
# STA $1380,X
# JSR GenerateCodeFunk1_L1D3C
# STA $1480,X
# JSR GenerateCodeFunk1_L1D3C
# STA $1580,X
# DEX
# BNE LoopGenerateCode_L1D0E
# JSR GenerateCodeFunk1_L1D3C
# STA $12e1
# JSR GenerateCodeFunk1_L1D3C
# STA $12ea
# JSR GenerateCodeFunk1_L1D3C
# STA $12f1
# RTS
# ​
# GenerateCodeFunk1_L1D3C:
# JSR GenerateCodeFunk2_L3BDC
# AND #$1f
# CMP #$1a
# BCS GenerateCodeFunk1_L1D3C
# ADC #$0c
# RTS
#
# And at some other position in the code:
#
# GenerateCodeFunk2_L3BDC:
# LDA $44
# LSR
# LSR
# SBC $44
# LSR
# ROL $45
# ROR $44
# LDA $44
# EOR $45
# RTS
def unpack():
global x44
global x45
x44 = 0
x45 = 0
x1280 = [0]*256
x1380 = [0]*256
x1480 = [0]*256
x1580 = [0]*256
x = 0
while True:
x1280[x] = funk1()
x1380[x] = funk1()
x1480[x] = funk1()
x1580[x] = funk1()
x = (x - 1)&0xff
if x == 0:
break
x1280[0xe1-0x80] = funk1()
x1280[0xea-0x80] = funk1()
x1280[0xf1-0x80] = funk1()
pws = [''.join(chr(65+c) for c in x) for x in zip(x1280,x1380,x1480,x1580)]
print(pws)
def funk1():
while 1:
a = funk2()
a &= 0x1f
if a < 0x1a:
break
return a
def funk2():
global x44
global x45
a = x44
a >>= 1
carry = (a & 1)
a >>= 1
a = (a - x44 - (carry^1)) & 0xff
carry = (x45 >> 7)&1
x45 = ((x45<<1)&0xff) | (a&1)
x44 = (x44>>1) | (carry<<7)
a = x44 ^ x45
return a
unpack()
['BDHP', 'JXMJ', 'ECBQ', 'YMCJ', 'TQKB', 'WNLP', 'FXQO', 'NHAG', 'KCRE', 'VUWS', 'CNPE', 'WVHI', 'OCKS', 'BTDY', 'COZQ', 'SKKK', 'AJMG', 'HMJL', 'MRHR', 'KGFP', 'UGRW', 'WZIN', 'HUVE', 'UNI
Z', 'PQGV', 'YVYJ', 'IGGZ', 'UJDD', 'QGOL', 'BQZP', 'RYMS', 'PEFS', 'BQSN', 'NQFI', 'VDTM', 'NXIS', 'VQNK', 'BIFA', 'ICXY', 'YWFH', 'GKWD', 'LMFU', 'UJDP', 'TXHL', 'OVPZ', 'HDQJ', 'LXPP', '
JYSF', 'PPXI', 'QBDH', 'IGGJ', 'PPHT', 'CGNX', 'ZMGC', 'SJES', 'FCJE', 'UBXU', 'YBLT', 'BLDM', 'ZYVI', 'RMOW', 'TIGW', 'GOHX', 'IJPQ', 'UPUN', 'ZIKZ', 'GGJA', 'RTDI', 'NLLY', 'GCCG', 'LAJM'
, 'EKFT', 'QCCR', 'MKNH', 'MJDV', 'NMRH', 'FHIC', 'GRMO', 'JINU', 'EVUG', 'SCWF', 'LLIO', 'OVPJ', 'UVEO', 'LEBX', 'FLHH', 'YJYS', 'WZYV', 'VCZO', 'OLLM', 'JPQG', 'DTMI', 'REKF', 'EWCS', 'BI
FQ', 'WVHY', 'IOCS', 'TKWD', 'XUVU', 'QJXR', 'RPIR', 'VDDU', 'PTAC', 'KWNL', 'YNEG', 'NXYB', 'ECRE', 'LIOC', 'KZQR', 'XBAO', 'KRQJ', 'NJLA', 'PTAS', 'JWNL', 'EGRW', 'HXMF', 'FPZT', 'OSCW',
'PHTY', 'FLXP', 'BPYS', 'SJUM', 'YKZE', 'TASX', 'MYRT', 'QRLD', 'JMWZ', 'FTLA', 'HEAN', 'XHIZ', 'FIRD', 'ZYFA', 'TIGG', 'XPPH', 'LYWO', 'LUZL', 'HPPX', 'LUJT', 'VLHH', 'SJUK', 'MCJE', 'UCRY
', 'OKOR', 'GVXQ', 'YBLI', 'JHEN', 'COZA', 'RGSK', 'DIGW', 'GNLP', 'ACKS', 'BQZP', 'XUFS', 'EBHR', 'YWNL', 'CFPD', 'HHDA', 'REZT', 'ZMWO', 'GBUS', 'JDFE', 'OGFP', 'YJPA', 'KBIV', 'ZDTQ', 'L
QSN', 'WKWD', 'TQJM', 'RABT', 'URPI', 'ARLT', 'NMSB', 'VLNA', 'MNAN', 'JNTT', 'FHYK', 'XTIW', 'EJTX', 'QRLT', 'CSOZ', 'CZMG', 'KBYM', 'MJLA', 'MIZX', 'KWTT', 'UGRW', 'BIFQ', 'URPI', 'DEZT',
'GONT', 'ASHA', 'LHXD', 'EFMV', 'ICNP', 'ZUNX', 'FHYK', 'FEOO', 'TPLM', 'PLYR', 'DEJD', 'EKFD', 'IGWB', 'LXHT', 'DVMV', 'XLUZ', 'DHPP', 'IVIR', 'DQKB', 'XPPH', 'HAGO', 'SJUN', 'USJE', 'WCS
R', 'LDFU', 'DMYB', 'ZXMJ', 'BIVY', 'TLAK', 'GZIF', 'RLYG', 'HYRA', 'PQGF', 'KRQZ', 'ZQRA', 'WCSO', 'HNAE', 'SGNH', 'TIOC', 'ZUKF', 'BPIK', 'LEBH', 'RDXH', 'CFLY', 'PHDA', 'KJXP', 'UNXY', '
RUSJ', 'HQSS', 'VHIC', 'BAOG', 'ICNM', 'PYCX', 'SFER', 'ICXI', 'DASX', 'BDHH', 'UGZQ', 'PXMF', 'GNXP', 'OCKS', 'PHTY', 'ZTHP', 'EBHM', 'PPXL', 'CFLX', 'PHDA']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment