----------------------------------------
-- dZ80 configuration file
----------------------------------------

----------------------------------------
-- Disassembly control
----------------------------------------

cpu="z80"
inputfile="XPATCH-5510.bin"
outputfile="XPATCH-5510.asm"
--fileheadersize=27
filebaseaddr=20572
disstart=0
disend=23724
--disstart=0
--disend=3584
--quiet=0
labelledoutput=1

----------------------------------------
-- Layout
----------------------------------------

labelreference=1
addresscolumn=1
opcodecolumn=1
relativejumpcomment=1
uppercase=1
autoblanklines=1
db="db"
comment="; "
radix=16
numprefix="0"
numsuffix="H"

----------------------------------------
-- Scripts
----------------------------------------

--script="scripts\\spectrum.lua"

----------------------------------------
-- References
----------------------------------------

referencefile="XPATCH-5510.ref"
inportreference=1
outportreference=1
addressreference=1
indirectaddressreference=1
limitreferences=1

----------------------------------------
-- Opcode mapfile and code/data areas
----------------------------------------

--opmapfile="mayhem.map"

-- Code Region isnt required as v2.x sets the entire region to code unless a data region overrides it.
d_SetCodeRegion(20572, 3152)

-- Set the known data regions, either as a data region (byte), word or string. The type affects the assembly output definitions and word
-- regions will attempt to map to an address, ie. jump tables will be setup with labels rather than constants.
d_SetDataRegion(    hex("507D"),       27)
d_SetStringRegion(  hex("507D"),       11)
d_SetStringRegion(  hex("5089"),       15)
d_SetDataRegion(    hex("5255"),       23)
d_SetStringRegion(  hex("5257"),        4)
d_SetStringRegion(  hex("525C"),       15)

d_SetDataRegion(    hex("5446"),       31)
d_SetStringRegion(  hex("5446"),       12)
d_SetStringRegion(  hex("5453"),       17)
d_SetDataRegion(    hex("5465"),        8)
d_SetStringRegion(  hex("55B3"),       18)
d_SetStringRegion(  hex("55F8"),       25)

d_SetDataRegion(    hex("5807"),       49)
d_SetStringRegion(  hex("5807"),       23)
--d_SetStringRegion(  hex("581F"),       5)
d_SetStringRegion(  hex("5827"),       5)
d_SetStringRegion(  hex("582F"),       5)

d_SetDataRegion(    hex("585D"),      45)
d_SetStringRegion(  hex("585D"),       4)
d_SetStringRegion(  hex("5862"),       5)
d_SetStringRegion(  hex("5868"),       7)
d_SetStringRegion(  hex("5870"),       5)
d_SetStringRegion(  hex("5876"),       3)
d_SetStringRegion(  hex("587A"),       5)
d_SetStringRegion(  hex("5880"),       3)
d_SetStringRegion(  hex("5884"),       3)

--d_SetStringRegion(  hex("585D"),       4)
--d_SetDataRegion(    hex("58A5"),      59)
--d_SetStringRegion(  hex("58A5"),      17)
--d_SetStringRegion(  hex("58B7"),      40)

d_SetDataRegion(    hex("59C7"),      25)
d_SetStringRegion(  hex("59C7"),      24)

d_SetDataRegion(    hex("5A04"),      56)
d_SetWordRegion(    hex("5A04"),      28)

-- Reserved key words.
d_SetDataRegion(    hex("5A20"),      28)
d_SetStringRegion(  hex("5A20"),      3)     -- LINE
d_SetStringRegion(  hex("5A24"),      3)     -- AUTO
d_SetStringRegion(  hex("5A28"),      2)     -- CLR
d_SetStringRegion(  hex("5A2B"),      3)     -- MOVE
d_SetStringRegion(  hex("5A2F"),      5)     -- COPY/P
d_SetStringRegion(  hex("5A35"),      5)     -- PAGE/P

d_SetDataRegion(    hex("5A52"),      17)
d_SetStringRegion(  hex("5A52"),      15)

-- Create a mapping table of known Sharp I/O ports and 8 bit constants.
--
-- Format           Addr      IsAddr   Label            : IsAddr = 0, value is a constant, = 1, value is an address.
d_SetByteEquate(hex("FE")   ,   1,     "PRTC"       )
d_SetByteEquate(hex("FF")   ,   1,     "PRTD"       )

-- Create a mapping table of known Sharp MZ BIOS/Memory Mapped Hardware addresses which dz80 
-- can use to replace an address with the label. The EQU list will also be output at the start
-- of the disassembly file so it can compile.
-- Format           Addr      IsAddr   Label            : IsAddr = 0, value is a constant, = 1, value is an address.
d_SetWordEquate(hex("0003"),    1,     "GETL"       )
d_SetWordEquate(hex("0006"),    1,     "LETNL"      )
d_SetWordEquate(hex("0009"),    1,     "NL"         )
d_SetWordEquate(hex("000C"),    1,     "PRNTS"      )
d_SetWordEquate(hex("000F"),    1,     "PRNTT"      )
d_SetWordEquate(hex("0012"),    1,     "PRNT"       )
d_SetWordEquate(hex("0015"),    1,     "MSG"        )
d_SetWordEquate(hex("0018"),    1,     "MSGX"       )
d_SetWordEquate(hex("001B"),    1,     "GETKY"      )
d_SetWordEquate(hex("001E"),    1,     "BRKEY"      )
d_SetWordEquate(hex("0021"),    1,     "?WRI"       )
d_SetWordEquate(hex("0024"),    1,     "?WRD"       )
d_SetWordEquate(hex("0027"),    1,     "?RDI"       )
d_SetWordEquate(hex("002A"),    1,     "?RDD"       )
d_SetWordEquate(hex("002D"),    1,     "?VRFY"      )
d_SetWordEquate(hex("0030"),    1,     "MELDY"      )
d_SetWordEquate(hex("0033"),    1,     "?TMST"      )
d_SetWordEquate(hex("003B"),    1,     "TIMRD"      )
d_SetWordEquate(hex("003E"),    1,     "BELL"       )
d_SetWordEquate(hex("0041"),    1,     "XTEMP"      )
d_SetWordEquate(hex("0044"),    1,     "MSTA"       )
d_SetWordEquate(hex("0047"),    1,     "MSTP"       )
d_SetWordEquate(hex("0000"),    1,     "MONIT"      )
d_SetWordEquate(hex("0089"),    1,     "SS"         )
d_SetWordEquate(hex("0095"),    1,     "ST1"        )
d_SetWordEquate(hex("0410"),    1,     "HLHEX"      )
d_SetWordEquate(hex("041F"),    1,     "_2HEX"      )
d_SetWordEquate(hex("074D"),    1,     "?MODE"      )
d_SetWordEquate(hex("08CA"),    1,     "?KEY"       )
d_SetWordEquate(hex("096C"),    1,     "PRNT3"      )
d_SetWordEquate(hex("0BB9"),    1,     "?ADCN"      )
d_SetWordEquate(hex("0BCE"),    1,     "?DACN"      )
d_SetWordEquate(hex("0DB5"),    1,     "?DSP"       )
d_SetWordEquate(hex("0DA6"),    1,     "?BLNK"      )
d_SetWordEquate(hex("0DDC"),    1,     "?DPCT"      )
d_SetWordEquate(hex("03BA"),    1,     "PRTHL"      )
d_SetWordEquate(hex("03C3"),    1,     "PRTHX"      )
d_SetWordEquate(hex("03DA"),    1,     "ASC"        )
d_SetWordEquate(hex("03F9"),    1,     "HEX"        )
d_SetWordEquate(hex("0DDC"),    1,     "DPCT"       )
d_SetWordEquate(hex("0DA7"),    1,     "DLY12"      )
d_SetWordEquate(hex("0DAA"),    1,     "DLY12A"     )
d_SetWordEquate(hex("0EE6"),    1,     "?RSTR1"     )
d_SetWordEquate(hex("06A3"),    1,     "MOTOR"      )
d_SetWordEquate(hex("071A"),    1,     "CKSUM"      )
d_SetWordEquate(hex("077A"),    1,     "GAP"        )
d_SetWordEquate(hex("0485"),    1,     "WTAPE"      )
d_SetWordEquate(hex("0700"),    1,     "MSTOP"      )
d_SetWordEquate(hex("11FD"),    1,     "TAPECOPY"   )
d_SetWordEquate(hex("1200"),    1,     "COLDSTRT"   )
d_SetWordEquate(hex("1250"),    1,     "WARMSTRTMON")
d_SetWordEquate(hex("15A8"),    1,     "CMDWORDTBL" )
d_SetWordEquate(hex("1BB2"),    1,     "CMDJMPTBL"  )
d_SetWordEquate(hex("2E33"),    1,     "CMTBUF"     )
d_SetWordEquate(hex("2E34"),    1,     "CMTFNAME"   )

-- Known BASIC SA-5510 labels/addresses.
d_SetWordEquate(hex("1C3C"),    1,     "CMDREMDATA" )
d_SetWordEquate(hex("13AB"),    1,     "SYNTAXERR"  )
d_SetWordEquate(hex("2D12"),    1,     "CMDREAD"    )
d_SetWordEquate(hex("1C4D"),    1,     "CMDLIST"    )
d_SetWordEquate(hex("1E91"),    1,     "CMDRUN"     )
d_SetWordEquate(hex("1C42"),    1,     "CMDNEW"     )
d_SetWordEquate(hex("2B0D"),    1,     "CMDPRINT"   )
d_SetWordEquate(hex("1D6A"),    1,     "CMDLET"     )
d_SetWordEquate(hex("1F2B"),    1,     "CMDFOR"     )
d_SetWordEquate(hex("21AD"),    1,     "CMDIF"      )
d_SetWordEquate(hex("13AB"),    1,     "CMDTHEN"    )
d_SetWordEquate(hex("1EA6"),    1,     "CMDGOTO"    )
d_SetWordEquate(hex("1EC7"),    1,     "CMDGOSUB"   )
d_SetWordEquate(hex("1EF8"),    1,     "CMDRETURN"  )
d_SetWordEquate(hex("1FC0"),    1,     "CMDNEXT"    )
d_SetWordEquate(hex("1D2C"),    1,     "CMDSTOP"    )
d_SetWordEquate(hex("1D15"),    1,     "CMDEND"     )
d_SetWordEquate(hex("203E"),    1,     "CMDON"      )
d_SetWordEquate(hex("2D75"),    1,     "CMDLOAD"    )
d_SetWordEquate(hex("2D82"),    1,     "CMDSAVE"    )
d_SetWordEquate(hex("2EB3"),    1,     "CMDVERIFY"  )
d_SetWordEquate(hex("2191"),    1,     "CMDPOKE"    )
d_SetWordEquate(hex("2080"),    1,     "CMDDIM"     )
d_SetWordEquate(hex("2201"),    1,     "CMDDEFFN"   )
d_SetWordEquate(hex("2BFF"),    1,     "CMDINPUT"   )
d_SetWordEquate(hex("1D4D"),    1,     "CMDRESTORE" )
d_SetWordEquate(hex("21A6"),    1,     "CMDCLS"     )
d_SetWordEquate(hex("2269"),    1,     "CMDMUSIC"   )
d_SetWordEquate(hex("2282"),    1,     "CMDTEMPO"   )
d_SetWordEquate(hex("2942"),    1,     "CMDUSRN"    )
d_SetWordEquate(hex("2D9F"),    1,     "CMDWOPEN"   )
d_SetWordEquate(hex("2D92"),    1,     "CMDROPEN"   )
d_SetWordEquate(hex("2DAD"),    1,     "CMDCLOSE"   )
d_SetWordEquate(hex("28B6"),    1,     "CMDMON"     )
d_SetWordEquate(hex("2967"),    1,     "CMDLIMIT"   )
d_SetWordEquate(hex("29CE"),    1,     "CMDCONT"    )
d_SetWordEquate(hex("2902"),    1,     "CMDGET"     )
d_SetWordEquate(hex("29FE"),    1,     "CMDINP"     )
d_SetWordEquate(hex("2A1C"),    1,     "CMDOUT"     )
d_SetWordEquate(hex("28B9"),    1,     "CMDCURSOR"  )
d_SetWordEquate(hex("2AA6"),    1,     "CMDSET"     )
d_SetWordEquate(hex("2AAA"),    1,     "CMDRESET"   )
d_SetWordEquate(hex("2A2F"),    1,     "CMDAUTO"    )
d_SetWordEquate(hex("33AB"),    1,     "CMDCOPY"    )
d_SetWordEquate(hex("32D4"),    1,     "CMDPAGE"    )

d_SetWordEquate(hex("13AE"),    1,     "OVFLERR"    )
d_SetWordEquate(hex("13B1"),    1,     "ILDATERR"   )
d_SetWordEquate(hex("13B4"),    1,     "DATMISERR"  )
d_SetWordEquate(hex("13B7"),    1,     "STRLENERR"  )
d_SetWordEquate(hex("13BA"),    1,     "MEMERR"     )
d_SetWordEquate(hex("13C0"),    1,     "LINELENERR" )
d_SetWordEquate(hex("13C3"),    1,     "GOSUBERR"   )
d_SetWordEquate(hex("13C6"),    1,     "FORNEXTERR" )
d_SetWordEquate(hex("13C9"),    1,     "FUNCERR"    )
d_SetWordEquate(hex("13CC"),    1,     "NEXTFORERR" )
d_SetWordEquate(hex("13CF"),    1,     "RETGOSBERR" )
d_SetWordEquate(hex("13D2"),    1,     "UNDEFFNERR" )
d_SetWordEquate(hex("13D5"),    1,     "LINEERR"    )
d_SetWordEquate(hex("13D8"),    1,     "CONTERR"    )
d_SetWordEquate(hex("13DB"),    1,     "BADWRERR"   )
d_SetWordEquate(hex("13DE"),    1,     "CMDSTMTERR" )
d_SetWordEquate(hex("13E1"),    1,     "READDATAERR")
d_SetWordEquate(hex("13E4"),    1,     "OPENERR"    )
d_SetWordEquate(hex("13E7"),    1,     "UNKNWNERR"  )
d_SetWordEquate(hex("13EA"),    1,     "OUTFILEERR" )
d_SetWordEquate(hex("13ED"),    1,     "PRTNRDYERR" )
d_SetWordEquate(hex("13F0"),    1,     "PRTHWERR"   )
d_SetWordEquate(hex("13F3"),    1,     "PRTPAPERERR")
d_SetWordEquate(hex("13F6"),    1,     "CHKSUMERR"  )

d_SetWordEquate(hex("1347"),    1,     "TITLEMSG"   )
d_SetWordEquate(hex("1364"),    1,     "COPYRMSG"   )
d_SetWordEquate(hex("1384"),    1,     "READYMSG"   )
d_SetWordEquate(hex("138A"),    1,     "ERRORMSG"   )
d_SetWordEquate(hex("1391"),    1,     "INMSG"      )
d_SetWordEquate(hex("1395"),    1,     "BREAKMSG"   )
d_SetWordEquate(hex("139C"),    1,     "BYTESMSG"   )
d_SetWordEquate(hex("13A3"),    1,     "ERRCODE"    )

d_SetWordEquate(hex("1332"),    1,     "MSGNL"      )
d_SetWordEquate(hex("167B"),    1,     "UNUSEDTBL1" )
d_SetWordEquate(hex("167D"),    1,     "UNUSEDTBL2" )
d_SetWordEquate(hex("124E"),    1,     "WARMSTRT"   )
d_SetWordEquate(hex("167F"),    1,     "OPERATORTBL")
d_SetWordEquate(hex("17FC"),    1,     "STRTONUM"   )
d_SetWordEquate(hex("1E88"),    1,     "GETNUM"     )
d_SetWordEquate(hex("173F"),    1,     "SKIPSPACE"  )
d_SetWordEquate(hex("173E"),    1,     "INCSKIPSPCE")
d_SetWordEquate(hex("177B"),    1,     "EXECHL"     )
d_SetWordEquate(hex("1795"),    1,     "EXECNOTCHR" )
d_SetWordEquate(hex("17A3"),    1,     "MATCHCHR"   )
d_SetWordEquate(hex("490D"),    0,     "LINEBUFR"   )

-- XPATCH labels/addresses.
d_SetWordEquate(hex("5A63"),    1,     "XPINIT"     )
d_SetWordEquate(hex("5B55"),    1,     "RELOC3302"  )
d_SetWordEquate(hex("5BB0"),    1,     "RELOC4806"  )
 
-- Comments to be added at fixed addresses.
d_SetComment(   hex("1250"),    "Sharp defined BASIC restart location from Monitor." )
d_SetComment(   hex("5B55"),    "Relocated to 0x3302 for 0x5B bytes." )
d_SetComment(   hex("5BB0"),    "Relocated to 0x4806 for 0xF8 bytes." )
d_SetComment(   hex("5CA8"),    "End of Relocated code." )

-- Known Sharp Constants.
d_SetWordEquate(hex("10F0"),    0,     "ATRB"       ) -- ATTRIBUTE
d_SetWordEquate(hex("10F1"),    0,     "NAME"       ) -- FILE NAME
d_SetWordEquate(hex("1102"),    0,     "SIZE"       ) -- BYTESIZE
d_SetWordEquate(hex("1104"),    0,     "DTADR"      ) -- DATA ADDRESS
d_SetWordEquate(hex("1106"),    0,     "EXADR"      ) -- EXECUTION ADDRESS
d_SetWordEquate(hex("1108"),    0,     "COMNT"      ) -- COMMENT
d_SetWordEquate(hex("1164"),    0,     "SWPW"       ) -- SWEEP WORK
d_SetWordEquate(hex("116E"),    0,     "KDATW"      ) -- KEY WORK
d_SetWordEquate(hex("1170"),    0,     "KANAF"      ) -- KANA FLAG (01=GRAPHIC MODE)
d_SetWordEquate(hex("1171"),    0,     "DSPXY"      ) -- DISPLAY COORDINATES
d_SetWordEquate(hex("1173"),    0,     "MANG"       ) -- COLUMN MANAGEMENT
d_SetWordEquate(hex("1179"),    0,     "MANGE"      ) -- COLUMN MANAGEMENT END
d_SetWordEquate(hex("117A"),    0,     "PBIAS"      ) -- PAGE BIAS
d_SetWordEquate(hex("117B"),    0,     "ROLTOP"     ) -- ROLL TOP BIAS
d_SetWordEquate(hex("117C"),    0,     "MGPNT"      ) -- COLUMN MANAG. POINTER
d_SetWordEquate(hex("117D"),    0,     "PAGETP"     ) -- PAGE TOP
d_SetWordEquate(hex("117F"),    0,     "ROLEND"     ) -- ROLL END
d_SetWordEquate(hex("118E"),    0,     "FLASH"      ) -- FLASHING DATA
d_SetWordEquate(hex("118F"),    0,     "SFTLK"      ) -- SHIFT LOCK
d_SetWordEquate(hex("1190"),    0,     "REVFLG"     ) -- REVERSE FLAG
d_SetWordEquate(hex("1191"),    0,     "SPAGE"      ) -- PAGE CHANGE
d_SetWordEquate(hex("1192"),    0,     "FLSDT"      ) -- CURSOR DATA
d_SetWordEquate(hex("1193"),    0,     "STRGF"      ) -- STRING FLAG
d_SetWordEquate(hex("1194"),    0,     "DPRNT"      ) -- TAB COUNTER
d_SetWordEquate(hex("1195"),    0,     "TMCNT"      ) -- TAPE MARK COUNTER
d_SetWordEquate(hex("1197"),    0,     "SUMDT"      ) -- CHECK SUM DATA
d_SetWordEquate(hex("1199"),    0,     "CSMDT"      ) -- FOR COMPARE SUM DATA
d_SetWordEquate(hex("119B"),    0,     "AMPM"       ) -- AMPM DATA
d_SetWordEquate(hex("119C"),    0,     "TIMFG"      ) -- TIME FLAG
d_SetWordEquate(hex("119D"),    0,     "SWRK"       ) -- KEY SOUND FLAG
d_SetWordEquate(hex("119E"),    0,     "TEMPW"      ) -- TEMPO WORK
d_SetWordEquate(hex("119F"),    0,     "ONTYO"      ) -- ONTYO WORK
d_SetWordEquate(hex("11A0"),    0,     "OCTV"       ) -- OCTAVE WORK
d_SetWordEquate(hex("11A1"),    0,     "RATIO"      ) -- ONPU RATIO
d_SetWordEquate(hex("11A3"),    0,     "BUFER"      ) -- GET LINE BUFFER


----------------------------------------
-- End of configuration file
----------------------------------------
