; Copyright 2018 faddenSoft. All Rights Reserved.
; See the LICENSE.txt file for distribution terms (Apache 2.0).
;
; Sources:
;   NiftyList, by Dave Lyons
;   Various Apple II reference materials found online

*SYNOPSIS Symbols from the Cxxx I/O area, common to most Apple II models.

; There's a lot here that you wouldn't find on an Apple ][+, but since
; this is for a disassembler it's okay to have extra stuff so long as it
; doesn't conflict.
KBD             < $C000     ;R last key pressed + 128
CLR80COL        > $C000     ;W use $C002-C005 for aux mem (80STOREOFF)
SET80COL        @ $C001     ;W use PAGE2 for aux mem (80STOREON)
RDMAINRAM       @ $C002     ;W if 80STORE off: read main mem $0200-BFFF
RDCARDRAM       @ $C003     ;W if 80STORE off: read aux mem $0200-BFFF
WRMAINRAM       @ $C004     ;W if 80STORE off: write main mem $0200-BFFF
WRCARDRAM       @ $C005     ;W if 80STORE off: write aux mem $0200-BFFF
SETSLOTCXROM    @ $C006     ;W use peripheral ROM ($C100-CFFF)
SETINTCXROM     @ $C007     ;W use internal ROM ($C100-CFFF)
SETSTDZP        @ $C008     ;W use main stack and zero page
SETALTZP        @ $C009     ;W use aux stack and zero page
SETINTC3ROM     @ $C00A     ;W use internal slot 3 ROM
SETSLOTC3ROM    @ $C00B     ;W use external slot 3 ROM
CLR80VID        @ $C00C     ;W disable 80-column display mode
SET80VID        @ $C00D     ;W enable 80-column display mode
CLRALTCHAR      @ $C00E     ;W use primary char set
SETALTCHAR      @ $C00F     ;W use alternate char set
KBDSTRB         @ $C010     ;RW keyboard strobe
RDLCBNK2        @ $C011     ;R bit 7: reading from LC bank 2 ($Dx)?
RDLCRAM         @ $C012     ;R bit 7: reading from LC RAM?
RDRAMRD         @ $C013     ;R bit 7: reading from aux/alt 48K?
RDRAMWRT        @ $C014     ;R bit 7: writing to aux/alt 48K?
RDCXROM         @ $C015     ;R bit 7: using internal slot ROM?
RDALTZP         @ $C016     ;R bit 7: using alt zero page, stack, & LC?
RDC3ROM         @ $C017     ;R bit 7: using external (slot 3) ROM?
RD80COL         @ $C018     ;R bit 7: 80STORE is on?
RDVBLBAR        @ $C019     ;R bit 7: not VBL (VBL signal is low)?
RDTEXT          @ $C01A     ;R bit 7: using text mode?
RDMIX           @ $C01B     ;R bit 7: using mixed mode?
RDPAGE2         @ $C01C     ;R bit 7: using page 2?
RDHIRES         @ $C01D     ;R bit 7: using hi-res graphics?
ALTCHARSET      @ $C01E     ;R bit 7: using alt char set?
RD80VID         @ $C01F     ;R bit 7: using 80 columns?
TAPEOUT         @ $C020     ;RW toggle caseette tape output
MONOCOLOR       @ $C021     ;W color/mono
TBCOLOR         @ $C022     ;RW screen color (low is BG, high is FG)
VGCINT          @ $C023     ;R VGC interrupts
MOUSEDATA       @ $C024     ;R mouse data: high bit is button
KEYMODREG       @ $C025     ;R modifier key state
DATAREG         @ $C026     ;RW ADB command/data
KMSTATUS        @ $C027     ;RW ADB status
ROMBANK         @ $C028     ;RW ROM bank select (IIc Plus)
NEWVIDEO        @ $C029     ;RW video select (SHR)
LANGSEL         @ $C02B     ;RW ROM bank select
CHARROM         @ $C02C     ;R addr for character ROM test
SLTROMSEL       @ $C02D     ;RW slot vs. ROM selection
VERTCNT         @ $C02E     ;R read video counter bits (V5-VB)
HORIZCNT        @ $C02F     ;R read video counter bits (VA-H0)
SPKR            @ $C030     ;RW toggle speaker
DISKREG         @ $C031     ;RW disk interface
SCANINT         @ $C032     ;W VGC interrupt clear
CLOCKDATA       @ $C033     ;RW battery RAM interface
CLOCKCTL        @ $C034     ;RW bits 0-3 = border color
SHADOW          @ $C035     ;RW inhibit shadowing
CYAREG          @ $C036     ;RW Configure Your Apple
DMAREG          @ $C037     ;RW
SCCBREG         @ $C038     ;RW SCC command channel B
SCCAREG         @ $C039     ;RW SCC command channel A
SCCBDATA        @ $C03A     ;RW SCC data channel B
SCCADATA        @ $C03B     ;RW SCC data channel A
SOUNDCTL        @ $C03C     ;RW sound settings (0-3=volume)
SOUNDDATA       @ $C03D     ;RW sound data
SOUNDADRL       @ $C03E     ;RW low pointer
SOUNDADRH       @ $C03F     ;RW high pointer
STROBE          @ $C040     ;R game I/O strobe
INTEN           @ $C041     ;RW read VBL interrupt

MMDELTAX        @ $C044     ;R mouse delta movement X
MMDELTAY        @ $C045     ;R mouse delta movement Y
DIAGTYPE        @ $C046     ;W self-test diagnostics
CLRVBLINT       @ $C047     ;W clear VBL interrupt
CLRXYINT        @ $C048     ;W clear XY interrupt

EMUBYTE         @ $C04F     ;RW used by emulators to identify themselves

TXTCLR          @ $C050     ;RW display graphics
TXTSET          @ $C051     ;RW display text
MIXCLR          @ $C052     ;RW display full screen
MIXSET          @ $C053     ;RW display split screen
TXTPAGE1        @ $C054     ;RW display page 1
TXTPAGE2        @ $C055     ;RW display page 2 (or read/write aux mem)
LORES           @ $C056     ;RW display lo-res graphics
HIRES           @ $C057     ;RW display hi-res graphics
SETAN0          @ $C058     ;RW annunciator 0 off
CLRAN0          @ $C059     ;RW annunciator 0 on
SETAN1          @ $C05A     ;RW annunciator 1 off
CLRAN1          @ $C05B     ;RW annunciator 1 on
SETAN2          @ $C05C     ;RW annunciator 2 off
CLRAN2          @ $C05D     ;RW annunciator 2 on
SETAN3          @ $C05E     ;RW annunciator 3 off
SETDHIRES       = $C05E     ;W if IOUDIS set, turn on double hi-res
CLRAN3          @ $C05F     ;RW annunciator 3 on
CLRDHIRES       = $C05F     ;W if IOUDIS set, turn off double hi-res
TAPEIN          @ $C060     ;R read cassette input
BUTN3           = $C060     ;R switch input 3
BUTN0           @ $C061     ;R switch input 0 / open-apple
BUTN1           @ $C062     ;R switch input 1 / closed-apple
BUTN2           @ $C063     ;R switch input 2 / shift key
PADDL0          @ $C064     ;R analog input 0
PADDL1          @ $C065     ;R analog input 1
PADDL2          @ $C066     ;R analog input 2
PADDL3          @ $C067     ;R analog input 3
STATEREG        @ $C068     ;RW address state

TESTREG         @ $C06D     ;test mode
CLTRM           @ $C06E     ;clear test mode
ENTM            @ $C06F     ;enable test mode
PTRIG           @ $C070     ;RW analog input reset

RDIOUDIS        < $C07E     ;R status of IOU disabling
SETIOUDIS       > $C07E     ;W disable IOU
RDDHIRES        < $C07F     ;R status of double hi-res
CLRIOUDIS       > $C07F     ;W enable IOU

;                 $C080     ;RW read RAM bank 2, write off
ROMIN           @ $C081     ;RWx2 read ROM, write RAM bank 2
ROMIN_RO        @ $C082     ;RW read ROM, no write
LCBANK2         @ $C083     ;RWx2 read/write RAM bank 2
; C084-C087 repeats
;                 $C088     ;RW read RAM bank 1, write off
;                 $C089     ;RW read ROM, write RAM bank 1
;                 $C08A     ;RW read ROM, no write
LCBANK1         @ $C08B     ;RWx2 read/write RAM bank 1
; C08C-C08F repeats

CLRROM          @ $CFFF     ;disable slot C8 ROM

; Disk ][ I/O locations.
;
; A few things hard-code slot 6 for disk access, in which case addresses
; like $C0E8 will work here.  It's far more common for code to use indexed
; addressing like "LDA $C088,X", which clashes with the slot 0
; definitions.  We define these symbols as constants so they're not
; applied automatically but are available for use.
IWM_PH0_OFF     = $C080     ;IWM phase 0 off
IWM_PH0_ON      = $C081     ;IWM phase 0 on
IWM_PH1_OFF     = $C082     ;IWM phase 1 off
IWM_PH1_ON      = $C083     ;IWM phase 1 on
IWM_PH2_OFF     = $C084     ;IWM phase 2 off
IWM_PH2_ON      = $C085     ;IWM phase 2 on
IWM_PH3_OFF     = $C086     ;IWM phase 3 off
IWM_PH3_ON      = $C087     ;IWM phase 3 on
IWM_MOTOR_OFF   = $C088     ;IWM motor off
IWM_MOTOR_ON    = $C089     ;IWM motor on
IWM_DRIVE_1     = $C08A     ;IWM select drive 1
IWM_DRIVE_2     = $C08B     ;IWM select drive 2
IWM_Q6_OFF      = $C08C     ;IWM read
IWM_Q6_ON       = $C08D     ;IWM WP-sense
IWM_Q7_OFF      = $C08E     ;IWM WP-sense/read
IWM_Q7_ON       = $C08F     ;IWM write


; Not strictly I/O locations, but they're in the neighborhood.
ROM_AUXMOVE     @ $C311
ROM_XFER        @ $C314


;
; I/O scratchpad RAM addresses
;
; Each slot has 8 bytes of storage available in the "screen holes" in
; text page 1.  See Apple II Reference Manual table page 83,
; "Peripheral Slot Scratchpad RAM", and
; https://retrocomputing.stackexchange.com/a/2541/56
;
; Slot number:
;   *     1     2     3     4     5     6     7
; $0478 $0479 $047A $047B $047C $047D $047E $047F
; $04F8 $04F9 $04FA $04FB $04FC $04FD $04FE $04FF
; $0578 $0579 $057A $057B $057C $057D $057E $057F
; $05F8 $05F9 $05FA $05FB $05FC $05FD $0SFE $05FF
; $0678 $0679 $067A $067B $067C $067D $067E $067F
; $06F8 $06F9 $06FA $06FB $06FC $06FD $06FE $06FF
; $0778 $0779 $077A $077B $077C $077D $077E $077F
; $07F8 $07F9 $07FA $07FB $07FC $07FD $07FE $07FF
;
; The slot 0 holes are shared among peripheral cards and the operating
; system, e.g. DOS puts the slot number of the peripheral card from
; which it was booted into $5F8.
;
SCRNHOLE0       @   $0478 8 ;text page 1 screen holes
SCRNHOLE1       @   $04F8 8 ;text page 1 screen holes
SCRNHOLE2       @   $0578 8 ;text page 1 screen holes
SCRNHOLE3       @   $05F8 8 ;text page 1 screen holes
SCRNHOLE4       @   $0678 8 ;text page 1 screen holes
SCRNHOLE5       @   $06F8 8 ;text page 1 screen holes
SCRNHOLE6       @   $0778 8 ;text page 1 screen holes
SCRNHOLE7       @   $07F8 8 ;text page 1 screen holes

ACTV_PERIP_SLOT @   $07F8   ;slot num ($Cn) of active peripheral card
