;
; Sega 32X SH-2-visible register definitions and helper macros
;

.DEFINE MARS_CART_ROM          $02000000
.DEFINE MARS_CART_ROM_MIRROR   $22000000
.DEFINE MARS_SDRAM             $06000000
.DEFINE MARS_CRAM              $20004200
.DEFINE MARS_FRAMEBUFFER       $24000000
.DEFINE MARS_OVERWRITE_IMG     $24020000

.DEFINE MARS_SYS_INTMSK        $20004000
.DEFINE MARS_SYS_DMACTR        $20004006
.DEFINE MARS_SYS_DMASAR        $20004008
.DEFINE MARS_SYS_DMADAR        $2000400C
.DEFINE MARS_SYS_DMALEN        $20004010
.DEFINE MARS_SYS_DMAFIFO       $20004012
.DEFINE MARS_SYS_VRESI_CLR     $20004014
.DEFINE MARS_SYS_VINT_CLR      $20004016
.DEFINE MARS_SYS_HINT_CLR      $20004018
.DEFINE MARS_SYS_CMDI_CLR      $2000401A
.DEFINE MARS_SYS_PWMI_CLR      $2000401C

.DEFINE MARS_SYS_COMM0         $20004020
.DEFINE MARS_SYS_COMM2         $20004022
.DEFINE MARS_SYS_COMM4         $20004024
.DEFINE MARS_SYS_COMM6         $20004026
.DEFINE MARS_SYS_COMM8         $20004028
.DEFINE MARS_SYS_COMM10        $2000402A
.DEFINE MARS_SYS_COMM12        $2000402C
.DEFINE MARS_SYS_COMM14        $2000402E

.DEFINE MARS_PWM_CTRL          $20004030
.DEFINE MARS_PWM_CYCLE         $20004032
.DEFINE MARS_PWM_LEFT          $20004034
.DEFINE MARS_PWM_RIGHT         $20004036
.DEFINE MARS_PWM_MONO          $20004038

.DEFINE MARS_VDP_DISPMODE      $20004100
.DEFINE MARS_VDP_FILLEN        $20004104
.DEFINE MARS_VDP_FILADR        $20004106
.DEFINE MARS_VDP_FILDAT        $20004108
.DEFINE MARS_VDP_FBCTL         $2000410A

.DEFINE MARS_SH2_ACCESS_VDP    $8000
.DEFINE MARS_68K_ACCESS_VDP    $0000
.DEFINE MARS_NTSC_FORMAT       $8000
.DEFINE MARS_PAL_FORMAT        $0000
.DEFINE MARS_VDP_PRIO_32X      $0080
.DEFINE MARS_VDP_PRIO_68K      $0000
.DEFINE MARS_224_LINES         $0000
.DEFINE MARS_240_LINES         $0040
.DEFINE MARS_VDP_MODE_OFF      $0000
.DEFINE MARS_VDP_MODE_256      $0001
.DEFINE MARS_VDP_MODE_32K      $0002
.DEFINE MARS_VDP_MODE_RLE      $0003
.DEFINE MARS_VDP_VBLK          $8000
.DEFINE MARS_VDP_HBLK          $4000
.DEFINE MARS_VDP_PEN           $2000
.DEFINE MARS_VDP_FEN           $0002
.DEFINE MARS_VDP_FS            $0001

.DEFINE MARS_PWM_CTRL_MONO     $0100
.DEFINE MARS_PWM_CTRL_LEFT     $0200
.DEFINE MARS_PWM_CTRL_RIGHT    $0400
.DEFINE MARS_PWM_CTRL_ENABLE   $0001
.DEFINE MARS_PWM_LCH_LEFT      $0001
.DEFINE MARS_PWM_LCH_RIGHT     $0002
.DEFINE MARS_PWM_RCH_RIGHT     $0004
.DEFINE MARS_PWM_RCH_LEFT      $0008
.DEFINE MARS_PWM_TIMER_1       $0100
.DEFINE MARS_PWM_CTRL_STEREO   (MARS_PWM_TIMER_1 | MARS_PWM_LCH_LEFT | MARS_PWM_RCH_RIGHT)

.DEFINE SH2_CCTL               $FFFFFE92
.DEFINE SH2_CCTL_CP            $10
.DEFINE SH2_CCTL_TW            $08
.DEFINE SH2_CCTL_CE            $01
.DEFINE SH2_FRT_TIER           $FFFFFE10
.DEFINE SH2_FRT_FTCSR          $FFFFFE11
.DEFINE SH2_FRT_FRCH           $FFFFFE12
.DEFINE SH2_FRT_FRCL           $FFFFFE13
.DEFINE SH2_FRT_OCRH           $FFFFFE14
.DEFINE SH2_FRT_OCRL           $FFFFFE15
.DEFINE SH2_FRT_TCR            $FFFFFE16
.DEFINE SH2_FRT_TOCR           $FFFFFE17
.DEFINE SH2_INT_IPRA           $FFFFFEE2
.DEFINE SH2_INT_IPRB           $FFFFFE60

.MACRO MARS_SH2_DISABLE_INTERRUPTS
  mov #15, r0
  shll2 r0
  shll2 r0
  ldc r0, sr
.ENDM

.MACRO MARS_SH2_ENABLE_INTERRUPTS
  mov #1, r0
  shll2 r0
  shll2 r0
  ldc r0, sr
.ENDM