;
; Sega Mega Drive/Genesis MC68000 register definitions and helper macros
;

.DEFINE REG_MD_Z80_RAM       $A00000
.DEFINE REG_MD_YM2612_A0     $A04000
.DEFINE REG_MD_YM2612_D0     $A04001
.DEFINE REG_MD_YM2612_A1     $A04002
.DEFINE REG_MD_YM2612_D1     $A04003
.DEFINE REG_MD_Z80_BUSREQ    $A11100
.DEFINE REG_MD_Z80_RESET     $A11200
.DEFINE REG_MD_TMSS          $A14000

.DEFINE REG_MD_IO_VERSION    $A10001
.DEFINE REG_MD_IO_DATA1      $A10003
.DEFINE REG_MD_IO_DATA2      $A10005
.DEFINE REG_MD_IO_DATA3      $A10007
.DEFINE REG_MD_IO_CTRL1      $A10009
.DEFINE REG_MD_IO_CTRL2      $A1000B
.DEFINE REG_MD_IO_CTRL3      $A1000D
.DEFINE REG_MD_IO_TX1        $A1000F
.DEFINE REG_MD_IO_RX1        $A10011
.DEFINE REG_MD_IO_SCTRL1     $A10013
.DEFINE REG_MD_IO_TX2        $A10015
.DEFINE REG_MD_IO_RX2        $A10017
.DEFINE REG_MD_IO_SCTRL2     $A10019
.DEFINE REG_MD_IO_TX3        $A1001B
.DEFINE REG_MD_IO_RX3        $A1001D
.DEFINE REG_MD_IO_SCTRL3     $A1001F

.DEFINE REG_MD_VDP_DATA      $C00000
.DEFINE REG_MD_VDP_CTRL      $C00004
.DEFINE REG_MD_VDP_HV        $C00008
.DEFINE REG_MD_PSG           $C00011

.DEFINE REG_MD_SSF_BANK1     $A130F2
.DEFINE REG_MD_SSF_BANK2     $A130F4
.DEFINE REG_MD_SSF_BANK3     $A130F6
.DEFINE REG_MD_SSF_BANK4     $A130F8
.DEFINE REG_MD_SSF_BANK5     $A130FA
.DEFINE REG_MD_SSF_BANK6     $A130FC
.DEFINE REG_MD_SSF_BANK7     $A130FE

.MACRO MD_WRITE_TMSS
  move.l #$53454741, REG_MD_TMSS
.ENDM

.MACRO MD_Z80_REQUEST_BUS
  move.w #$0100, REG_MD_Z80_BUSREQ
.ENDM

.MACRO MD_Z80_RELEASE_BUS
  move.w #$0000, REG_MD_Z80_BUSREQ
.ENDM

.MACRO MD_Z80_HOLD_RESET
  move.w #$0000, REG_MD_Z80_RESET
.ENDM

.MACRO MD_Z80_RELEASE_RESET
  move.w #$0100, REG_MD_Z80_RESET
.ENDM

.MACRO MD_VDP_WRITE_REG
  move.w #($8000 | ((\1 & $1F) << 8) | (\2 & $FF)), REG_MD_VDP_CTRL
.ENDM

.MACRO MD_VDP_SET_ADDR_VRAM_WRITE
  move.l #($40000000 | (((\1) & $3FFF) << 16) | (((\1) & $C000) >> 14)), REG_MD_VDP_CTRL
.ENDM

.MACRO MD_SSF_BANK
  move.b #\2, (REG_MD_SSF_BANK1 + ((\1 - 1) * 2))
.ENDM
