?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. ; ports description and include file
  2. ;for NeoGS software projects, v0.3
  3. ;
  4. ; bits degisnation:
  5. ; B_* - bit position (0,1,2,3,4,5,6,7),
  6. ; M_* - bit mask (1,2,4,8,#10,#20,#40,#80)
  7. ; C_* - constants to be used
  8. ;
  9. ; part of NeoGS project
  10. ;
  11. ; (c) 2008 NedoPC
  12.  
  13. ;ZX-side ports
  14.  
  15. GSCOM   EQU #BB ;write-only, command for NGS
  16.  
  17. GSSTAT  EQU #BB ;read-only, command and data bits
  18.                 ; (positions given immediately below)
  19.  
  20. B_CBIT  EQU 0 ;Command   position
  21. M_CBIT  EQU 1 ;       BIT        and mask
  22.  
  23. B_DBIT  EQU 7   ;Data   position
  24. M_DBIT  EQU #80 ;    BIT        and mask
  25.  
  26.  
  27. GSDAT   EQU #B3 ; read-write, data transfer register for NGS
  28.  
  29. GSCTR   EQU #33 ; write-only, control register for NGS:
  30.                 ;constants available given immediately below
  31.  
  32. C_GRST  EQU #80 ; reset constant to be written into GSCTR
  33. C_GNMI  EQU #40 ; NMI constant to be written into GSCTR
  34. C_GLED  EQU #20 ; LED toggle constant
  35.  
  36.  
  37. ;GS-side ports
  38.  
  39. MPAG    EQU #00 ; write-only, Memory PAGe port
  40.                 ;(big pages at 8000-FFFF or small at 8000-BFFF)
  41. MPAGEX  EQU #10 ; write-only, Memory PAGe EXtended
  42.                 ;(only small pages at C000-FFFF)
  43.  
  44. ZXCMD   EQU #01 ; read-only, ZX CoMmanD port: here is the byte
  45.                 ;written by ZX into GSCOM
  46.  
  47. ZXDATRD EQU #02 ; read-only, ZX DATa ReaD: a byte written by ZX
  48.                 ;into GSDAT appears here;
  49.                 ; upon reading this port, data bit is cleared
  50.  
  51. ZXDATWR EQU #03 ; write-only, ZX DATa WRite: a byte written here
  52.                 ;is available for ZX in GSDAT;
  53.                 ; upon writing here, data bit is set
  54.  
  55. ZXSTAT  EQU #04 ; read-only, read ZX STATus:
  56.                 ;command and data bits.
  57.                ;positions are defined by *_CBIT and *_DBIT above
  58.  
  59. CLRCBIT EQU #05 ; read-write, upon either reading or writing
  60.                 ;this port, the Command BIT is CLeaRed
  61.  
  62. VOL1    EQU #06 ; write-only, volumes for sound channels 1-8
  63. VOL2    EQU #07
  64. VOL3    EQU #08
  65. VOL4    EQU #09
  66. VOL5    EQU #16
  67. VOL6    EQU #17
  68. VOL7    EQU #18
  69. VOL8    EQU #19
  70.  
  71. ; following two ports are useless and very odd. They have been
  72. ;made just because they were on the original GS and for that
  73. ; strange case when somebody too crazy have used them.
  74. ;Nevertheless, DO NOT USE THEM! They can disappear or even
  75. ;radically change functionality in future firmware releases.
  76. DAMNPORT1 EQU #0A ; writing or reading this port sets data bit
  77.                   ;to the inverse of bit 0 into MPAG port
  78. DAMNPORT2 EQU #0B ; the same as DAMNPORT1, but instead command
  79.            ;bit involved, which is made equal to 5th bit of VOL4
  80.  
  81. LEDCTR  EQU #01 ; write-only, controls on-board LED.
  82.                 ;D0=0 - LED is on, D0=1 - LED is off
  83.                 ; reset state is LED on.
  84.  
  85. GSCFG0  EQU #0F ; read-write, GS ConFiG port 0:
  86.                 ;acts as memory cell, reads previously written
  87.                 ;value. Bits and fields follow:
  88.  
  89. B_NOROM EQU 0 ; =0 - there is ROM everywhere except 4000-7FFF,
  90.               ; =1 - the RAM is all around
  91. M_NOROM EQU 1
  92.  
  93. B_RAMRO EQU 1 ; =1 - ram absolute addresses 0000-7FFF
  94.                ;(zeroth big page) are write-protected
  95. M_RAMRO EQU 2
  96.  
  97. B_8CHANS EQU 2 ; =1 - 8 channels mode
  98. M_8CHANS EQU 4
  99.  
  100. B_EXPAG EQU 3 ; =1 - extended paging: both MPAG and MPAGEX are
  101.                ;used to switch two memory windows
  102. M_EXPAG EQU 8
  103.  
  104. B_CKSEL0 EQU 4   ;these bits should be set according to the
  105.                  ;C_**MHZ constants below
  106. M_CKSEL0 EQU #10
  107. B_CKSEL1 EQU 5
  108. M_CKSEL1 EQU #20
  109.  
  110. C_10MHZ EQU #30
  111. C_12MHZ EQU #10
  112. C_20MHZ EQU #20
  113. C_24MHZ EQU #00
  114.  
  115. B_PAN4CH EQU 6  ; =1 - 4 channels, panning
  116. ;(every channel is on left and right with two volumes)
  117. M_PAN4CH EQU #40
  118.  
  119. B_SETNCLR EQU 7
  120. M_SETNCLR EQU #80
  121.  
  122.  
  123. SCTRL   EQU #11 ;Serial ConTRoL: read-write,
  124.                 ;read: current state of below bits,
  125.                 ;write - see GS_info
  126.  
  127. B_SDNCS EQU 0
  128. M_SDNCS EQU 1
  129.  
  130. B_MCNCS EQU 1
  131. M_MCNCS EQU 2
  132.  
  133. B_MPXRS EQU 2
  134. M_MPXRS EQU 4
  135.  
  136. B_MCSPD0 EQU 3
  137. M_MCSPD0 EQU 8
  138.  
  139. B_MDHLF EQU 4
  140. M_MDHLF EQU #10
  141.  
  142. B_MCSPD1 EQU 5
  143. M_MCSPD1 EQU #20
  144.  
  145.  
  146. SSTAT EQU #12 ;Serial STATus:
  147.               ;read-only, reads state of below bits
  148.  
  149. B_MDDRQ EQU 0
  150. M_MDDRQ EQU 1
  151.  
  152. B_SDDET EQU 1
  153. M_SDDET EQU 2
  154.  
  155. B_SDWP  EQU 2
  156. M_SDWP  EQU 4
  157.  
  158. B_MCRDY EQU 3
  159. M_MCRDY EQU 8
  160.  
  161.  
  162. SD_SEND EQU #13 ;SD card SEND, write-only,
  163.           ;when written, byte transfer starts with written byte
  164. SD_READ EQU #13 ;SD card READ, read-only,
  165.           ;reads byte received in previous byte transfer
  166. SD_RSTR EQU #14 ;SD card Read and STaRt, read-only, reads
  167. ;previously received byte and starts new byte transfer with #FF
  168.  
  169. MD_SEND EQU #14 ;Mp3 Data SEND, write-only,
  170.           ;sends byte to the mp3 data interface
  171.  
  172. MC_SEND EQU #15 ;Mp3 Control SEND, write-only,
  173.           ;sends byte to the mp3 control interface
  174. MC_READ EQU #15 ;Mp3 Control READ, read-only,
  175. ;reads byte that was received during previous sending of byte
  176.  
  177. DMA_MOD EQU     #1B
  178. DMA_HAD EQU     #1C
  179. DMA_MAD EQU     #1D
  180. DMA_LAD EQU     #1E
  181. DMA_CST EQU     #1F
  182.  
  183. ;Послать код команды в регистр команд
  184.         MACRO SC par
  185.         LD A,par
  186.         OUT (GSCOM),A
  187.         ENDM
  188.  
  189. ;Ожидание сброса Command bit
  190.         MACRO WC
  191.         ;LOCAL
  192. ;WCLP
  193.         IN A,(GSCOM)
  194.         RRCA
  195.         JR C,$-3;WCLP
  196.         ;ENDL
  197.         ENDM
  198.  
  199. ;Послать данные в регистр данных
  200.         MACRO SD par
  201.         LD A,par
  202.         OUT (GSDAT),A
  203.         ENDM
  204.  
  205. ;Ожидание сброса Data bit
  206. ;по сути,ожидание,пока GS не примет посланные ему данные
  207.         MACRO WD
  208.         ;LOCAL
  209. ;WDLP
  210.         IN A,(GSCOM)
  211.         RLCA
  212.         JR C,$-3;WDLP
  213.         ;ENDL
  214.         ENDM
  215.  
  216. ;Принять данные из регистра данных
  217.         MACRO GD
  218.         IN A,(GSDAT)
  219.         ENDM
  220.  
  221. ;Ожидание установки Data bit
  222. ;по сути,ожидание очередных данных от GS
  223.         MACRO WN
  224.         ;LOCAL
  225. ;WNLP
  226.         IN A,(GSCOM)
  227.         RLCA
  228.         JR NC,$-3;WNLP
  229.         ;ENDL
  230.         ENDM
  231.