Unit Hardware;

Interface
Uses Exec;

Type
  tCIA = Record
		  ciapra: ShortInt;
		  pad0: Array [0..254] of ShortInt;
		  ciaprb: ShortInt;
		  pad1: Array [0..254] of ShortInt;
		  ciaddra: ShortInt;
		  pad2: Array [0..254] of ShortInt;
		  ciaddrb: ShortInt;
		  pad3: Array [0..254] of ShortInt;
		  ciatalo: ShortInt;
		  pad4: Array [0..254] of ShortInt;
		  ciatahi: ShortInt;
		  pad5: Array [0..254] of ShortInt;
		  ciatblo: ShortInt;
		  pad6: Array [0..254] of ShortInt;
		  ciatbhi: ShortInt;
		  pad7: Array [0..254] of ShortInt;
		  ciatodlow: ShortInt;
		  pad8: Array [0..254] of ShortInt;
		  ciatodmid: ShortInt;
		  pad9: Array [0..254] of ShortInt;
		  ciatodhi: ShortInt;
		  pad10: Array [0..254] of ShortInt;
		  unusedreg: ShortInt;
		  pad11: Array [0..254] of ShortInt;
		  ciasdr: ShortInt;
		  pad12: Array [0..254] of ShortInt;
		  ciaicr: ShortInt;
		  pad13: Array [0..254] of ShortInt;
		  ciacra: ShortInt;
		  pad14: Array [0..254] of ShortInt;
		  ciacrb: ShortInt;
		End;

  pAudChannel = ^tAudChannel;
  tAudChannel = Record
		  ac_ptr: pInteger;
		  ac_len: Integer;
		  ac_per: Integer;
		  ac_vol: Integer;
		  ac_dat: Integer;
		  ac_pad: Array [0..1] of Integer;
		End;

  pSpriteDef = ^tSpriteDef;
  tSpriteDef = Record
		  pos: Integer;
		  ctl: Integer;
		  dataa: Integer;
		  datab: Integer;
		End;

  tCustom = Record
		  bltddat: Integer;
		  dmaconr: Integer;
		  vposr: Integer;
		  vhposr: Integer;
		  dskdatr: Integer;
		  joy0dat: Integer;
		  joy1dat: Integer;
		  clxdat: Integer;
		  adkconr: Integer;
		  pot0dat: Integer;
		  pot1dat: Integer;
		  potinp: Integer;
		  serdatr: Integer;
		  dskbytr: Integer;
		  intenar: Integer;
		  intreqr: Integer;
		  dskpt: Pointer;
		  dsklen: Integer;
		  dskdat: Integer;
		  refptr: Integer;
		  vposw: Integer;
		  vhposw: Integer;
		  copcon: Integer;
		  serdat: Integer;
		  serper: Integer;
		  potgo: Integer;
		  joytest: Integer;
		  strequ: Integer;
		  strvbl: Integer;
		  strhor: Integer;
		  strlong: Integer;
		  bltcon0: Integer;
		  bltcon1: Integer;
		  bltafwm: Integer;
		  bltalwm: Integer;
		  bltcpt: Pointer;
		  bltbpt: Pointer;
		  bltapt: Pointer;
		  bltdpt: Pointer;
		  bltsize: Integer;
		  pad2d: Array [0..2] of Integer;
		  bltcmod: Integer;
		  bltbmod: Integer;
		  bltamod: Integer;
		  bltdmod: Integer;
		  pad34: Array [0..3] of Integer;
		  bltcdat: Integer;
		  bltbdat: Integer;
		  bltadat: Integer;
		  pad3b: Array [0..3] of Integer;
		  dsksync: Integer;
		  cop1lc: LongInt;
		  cop2lc: LongInt;
		  copjmp1: Integer;
		  copjmp2: Integer;
		  copins: Integer;
		  diwstrt: Integer;
		  diwstop: Integer;
		  ddfstrt: Integer;
		  ddfstop: Integer;
		  dmacon: Integer;
		  clxcon: Integer;
		  intena: Integer;
		  intreq: Integer;
		  adkcon: Integer;
		  aud: Array [0..3] of tAudChannel;
		  bplpt: Pointer;
		  pad7c: Array [0..3] of Integer;
		  bplcon0: Integer;
		  bplcon1: Integer;
		  bplcon2: Integer;
		  pad83: Integer;
		  bpl1mod: Integer;
		  bpl2mod: Integer;
		  pad86: Array [0..1] of Integer;
		  bpldat: Array [0..5] of Integer;
		  pad8e: Array [0..1] of Integer;
		  sprpt: Pointer;
		  spr: Array [0..7] of tSpriteDef;
		  color: Array [0..31] of Integer;
		End;

  pbltnode = ^tbltnode;
  tbltnode = Record
		  n: pbltnode;
		  function_: pPointer;
		  stat: ShortInt;
		  blitsize: Integer;
		  beamsync: Integer;
		  cleanup: pPointer;
		End;



  pCIA = ^tCIA;
  pCustom = ^tCustom;


Var
  ciaa:		pCIA	absolute $BFE001;
  ciab:		pCIA	absolute $BFD000;
  custom:	pCustom	absolute $DFF000;
Const
  ADKF_PRE000NS = $0;
  VSIZEBITS = $A;
  DMAF_BLITTER = $40;
  INTF_PORTS = $8;
  DEST = $100;
  OCTANT1 = $10;
  CIAICRF_FLG = $10;
  OCTANT2 = $0;
  ADKB_MSBSYNC = $9;
  ADKF_UARTBRK = $800;
  OCTANT3 = $8;
  CIAB_DSKTRACK0 = $4;
  CIAB_OVERLAY = $0;
  CIAF_DSKSTEP = $1;
  OCTANT4 = $14;
  CIAB_DSKCHANGE = $2;
  ADKF_PRE140NS = $2000;
  OCTANT5 = $1C;
  OCTANT6 = $C;
  ADKB_USE3PN = $7;
  ADKF_MSBSYNC = $200;
  OCTANT7 = $4;
  CIACRAB_RUNMODE = $3;
  CIAB_PRTRBUSY = $0;
  CIAF_DSKTRACK0 = $10;
  CIAF_OVERLAY = $1;
  OCTANT8 = $18;
  CIACRBB_RUNMODE = $3;
  CIAB_DSKPROT = $3;
  CIAF_DSKCHANGE = $4;
  INTB_RBF = $B;
  INTB_TBE = $0;
  ADKF_PRE280NS = $4000;
  CIACRAB_OUTMODE = $2;
  ADKF_USE3PN = $80;
  ADKF_PRE560NS = $6000;
  CIACRBB_OUTMODE = $2;
  CIACRAF_RUNMODE = $8;
  CIAB_GAMEPORT0 = $6;
  CIAF_PRTRBUSY = $1;
  CIACRBF_RUNMODE = $8;
  CIAB_GAMEPORT1 = $7;
  CIAB_PRTRPOUT = $1;
  CIAF_DSKPROT = $8;
  INTF_RBF = $800;
  ADKB_USE3VN = $3;
  CIAB_PRTRSEL = $2;
  INTF_TBE = $1;
  CIACRAB_INMODE = $5;
  CIACRAF_OUTMODE = $4;
  CIAB_COMDSR = $3;
  CLEANUP = $40;
  CIACRBF_OUTMODE = $4;
  CIAB_COMDTR = $7;
  CIAB_COMCTS = $4;
  CIAF_GAMEPORT0 = $40;
  CIAF_GAMEPORT1 = $80;
  CIAF_PRTRPOUT = $2;
  ADKF_USE3VN = $8;
  FILL_CARRYIN = $4;
  CIAB_COMCD = $5;
  CIAF_PRTRSEL = $4;
  CIACRAF_INMODE = $20;
  CIAF_COMDSR = $8;
  CIAF_COMDTR = $80;
  CIAF_COMCTS = $10;
  DMAB_COPPER = $7;
  ASHIFTSHIFT = $C;
  CIAF_COMCD = $20;
  ADKB_SETCLR = $F;
  BSHIFTSHIFT = $C;
  CIAB_DSKRDY = $5;
  DMAB_MASTER = $9;
  AUL = $4;
  DMAF_COPPER = $80;
  DMAB_SETCLR = $F;
  ADKF_SETCLR = $50000;
  CIACRAB_SPMODE = $6;
  CIAF_DSKRDY = $20;
  DMAF_MASTER = $200;
  NANBNC = $1;
  BC1F_DESC = $2;
  DMAF_SETCLR = $8000;
  DMAB_RASTER = $8;
  CIAICRB_TA = $0;
  CIACRAF_SPMODE = $40;
  CIAB_COMRTS = $6;
  INTB_DSKSYNC = $C;
  BLITREVERSE = $2;
  CIAICRB_TB = $1;
  DMAB_AUD0 = $0;
  INTB_DSKBLK = $1;
  DMAF_RASTER = $100;
  DMAB_AUD1 = $1;
  BC0B_SRCA = $B;
  FILL_XOR = $10;
  DMAB_AUD2 = $2;
  BC0B_SRCB = $A;
  SUD = $10;
  CIAICRF_TA = $1;
  CIAF_COMRTS = $40;
  DMAB_AUD3 = $3;
  DMAB_SPRITE = $5;
  INTF_DSKSYNC = $1000;
  BC0B_SRCC = $9;
  CIAICRF_TB = $2;
  DMAF_AUD0 = $1;
  INTF_DSKBLK = $2;
  CIAICRB_IR = $7;
  DMAF_AUD1 = $2;
  BC0F_SRCA = $800;
  CIACRBB_ALARM = $7;
  DMAF_AUD2 = $4;
  BC0F_SRCB = $400;
  DMAF_AUDIO = $F;
  DMAF_AUD3 = $8;
  DMAF_SPRITE = $20;
  INTB_SOFTINT = $2;
  BC0F_SRCC = $200;
  CIAICRB_SETCLR = $7;
  BC0B_DEST = $8;
  CIAICRF_IR = $80;
  CIACRBF_ALARM = $80;
  ADKB_PRECOMP0 = $D;
  SUL = $8;
  CIAB_DSKDIREC = $1;
  INTF_SOFTINT = $4;
  ADKB_PRECOMP1 = $E;
  OVFLAG = $20;
  CIAICRF_SETCLR = $80;
  BC0F_DEST = $100;
  CIAICRB_SP = $3;
  ADKF_PRECOMP0 = $2000;
  FILL_OR = $8;
  CIAF_DSKDIREC = $2;
  ADKF_PRECOMP1 = $4000;
  CIAICRF_SP = $8;
  INTB_SETCLR = $F;
  CIACRBF_IN_CNT = $20;
  ANBNC = $10;
  NABNC = $4;
  NANBC = $2;
  ONEDOT = $2;
  CIACRAB_TODIN = $7;
  INTF_SETCLR = $50000;
  INTB_AUD0 = $7;
  CIACRAF_TODIN = $80;
  INTB_AUD1 = $8;
  INTB_AUD2 = $9;
  INTB_AUD3 = $A;
  CIACRAB_LOAD = $4;
  CIAB_DSKSEL0 = $3;
  INTF_AUD0 = $80;
  CIACRBB_LOAD = $4;
  CIAB_DSKSEL1 = $4;
  INTF_AUD1 = $100;
  CIAB_DSKSEL2 = $5;
  INTF_AUD2 = $200;
  CIACRBB_INMODE0 = $5;
  CIAB_DSKSEL3 = $6;
  INTF_AUD3 = $400;
  CIACRBB_INMODE1 = $6;
  CIACRAF_LOAD = $10;
  CIAF_DSKSEL0 = $8;
  DMAB_DISK = $4;
  ADKB_FAST = $8;
  CIACRBF_LOAD = $10;
  CIAF_DSKSEL1 = $10;
  A_XOR_C = $5A;
  CIAF_DSKSEL2 = $20;
  INTB_COPER = $4;
  CIACRBF_INMODE0 = $20;
  CIAF_DSKSEL3 = $40;
  CIACRBF_INMODE1 = $40;
  DMAF_DISK = $10;
  ADKF_FAST = $100;
  CIACRAB_START = $0;
  CIACRBB_START = $0;
  INTF_COPER = $10;
  CIACRBF_IN_TA = $40;
  INTB_INTEN = $E;
  CIACRAF_START = $1;
  ABNC = $40;
  ANBC = $20;
  NABC = $8;
  CIACRBF_START = $1;
  CIAB_LED = $1;
  CIACRAB_PBON = $1;
  INTF_INTEN = $4000;
  ADKB_USE0P1 = $4;
  CIACRBB_PBON = $1;
  INTB_VERTB = $5;
  CIAB_DSKSIDE = $2;
  ADKB_USE1P2 = $5;
  A_OR_B = $FC;
  CIAF_LED = $2;
  A_OR_C = $FA;
  CIACRAF_PBON = $2;
  ADKB_USE2P3 = $6;
  ADKF_USE0P1 = $10;
  CIAICRB_ALRM = $2;
  CIACRBF_PBON = $2;
  INTF_VERTB = $20;
  HSIZEMASK = $3F;
  CIAF_DSKSIDE = $4;
  INTB_EXTER = $D;
  ADKB_USE0V1 = $0;
  ADKF_USE1P2 = $20;
  A_TO_D = $F0;
  SIGNFLAG = $40;
  ADKB_MFMPREC = $C;
  DMAB_BLTDONE = $E;
  ADKB_USE1V2 = $1;
  ADKF_USE2P3 = $40;
  LINEMODE = $1;
  CIAICRF_ALRM = $4;
  CIAB_DSKMOTOR = $7;
  DMAB_BLITHOG = $A;
  INTF_EXTER = $2000;
  ADKB_USE2V3 = $2;
  ADKF_USE0V1 = $1;
  DMAB_BLTNZERO = $D;
  ADKF_MFMPREC = $1000;
  HSIZEBITS = $6;
  DMAF_ALL = $1FF;
  DMAF_BLTDONE = $4000;
  ADKF_USE1V2 = $2;
  CIAF_DSKMOTOR = $80;
  DMAF_BLITHOG = $400;
  INTB_BLIT = $6;
  ADKF_USE2V3 = $4;
  MAXBYTESPERROW = $80;
  DMAF_BLTNZERO = $2000;
  CIACRBF_IN_CNT_TA = $60;
  ADKB_WORDSYNC = $A;
  INTF_BLIT = $40;
  VSIZEMASK = $3FF;
  SRCA = $800;
  SRCB = $400;
  CIACRBF_IN_PHI2 = $0;
  ADKF_WORDSYNC = $400;
  ABC = $80;
  SRCC = $200;
  CLEANME = $40;
  DMAB_BLITTER = $6;
  INTB_PORTS = $3;
  CIAICRB_FLG = $4;
  ADKB_UARTBRK = $B;
  CIAB_DSKSTEP = $0;




End.
