GSRomBaseL equ #0000
GSRomBaseH equ #c000

BTICK   EQU 750

DAC0    EQU #6000
DAC1    EQU #6100
DAC2    EQU #6200
DAC3    EQU #6300
VOL0    EQU #06
VOL1    EQU #07
VOL2    EQU #08
VOL3    EQU #09
FLAGS   EQU #04
OUTRG   EQU #03
DATRG   EQU #02
COMRG   EQU #01
RSCOM   EQU #05
PAGE    EQU #00

CHSTAT  EQU #00
CHFLAGS EQU #01
CHCURL  EQU #02
CHCURH  EQU #03
CHCURP  EQU #04
CHENDL  EQU #05
CHENDH  EQU #06
CHENDP  EQU #07
CHLPBL  EQU #08
CHLPBH  EQU #09
CHLPBP  EQU #0A
CHLPEL  EQU #0B
CHLPEH  EQU #0C
CHLPEP  EQU #0D
CHCNTL  EQU #0E
CHCNTH  EQU #0F
CHFRQL  EQU #10
CHFRQH  EQU #11
CHPERL  EQU #12
CHPERH  EQU #13
CHREAL  EQU #14
CHFINE  EQU #15
CHRLNT  EQU #16
CHPAN   EQU #17
CHEPAN  EQU #18
CHVOL   EQU #19
CHMVOL  EQU #1A
CHEVOL  EQU #1B
CHFVOL  EQU #1C
CHDELVL EQU #1D
CHDELVH EQU #1E
CHDELSL EQU #1F
CHDELSH EQU #20
CHFADVL EQU #21
CHFADVH EQU #22
CHFADSL EQU #23
CHFADSH EQU #24
CHRDR   EQU #25
CHRDRI  EQU #26
CHRDN   EQU #27
CHNOTE  EQU #28
CHINS   EQU #29
CHSMP   EQU #2A
CHCOM   EQU #2B
CHPARM  EQU #2C
CHVCMD  EQU #2D
CHPORT  EQU #2E
CHWNT   EQU #2F
CHVIBCM EQU #30
CHVIBPS EQU #31
CHTRMCM EQU #32
CHTRMPS EQU #33
CHPATPS EQU #34
CHLPCNT EQU #35
CHOFFST EQU #36
CHSLUP  EQU #37
CHSLDN  EQU #38
CHPRIOR EQU #39
CHSQZ   EQU #3A
;CH      EQU #3B
;CH      EQU #3C
;CH      EQU #3D
;CH      EQU #3E
CHOLDV  EQU #3F

CHANLEN EQU #40

CHNS    EQU #04
SMPBEG  EQU #00         ;+00 SAMPLE START ADRESS
SMPEND  EQU #03         ;+03 SAMPLE END ADRESS
SMPFT   EQU #06         ;+06 SAMPLE FINETUNE
SMPVOL  EQU #07         ;+07 SAMPLE VOLUME
SMPLPB  EQU #08         ;+08 SAMPLE LOOP START
SMPLPE  EQU #0B         ;+0B SAMPLE LOOP END




SMPTYPE EQU #00
SMPBEGL EQU #01
SMPBEGM EQU #02
SMPBEGH EQU #03
SMPENDL EQU #04
SMPENDM EQU #05
SMPENDH EQU #06
SMPFINE EQU #08
SMPLPBL EQU #09
SMPLPBM EQU #0A
SMPLPBH EQU #0B
SMPLPEL EQU #0C
SMPLPEM EQU #0D
SMPLPEH EQU #0E
SMPREL  EQU #0F
SMPPAN  EQU #10
SMPCNT  EQU #11
SMPSQZ  EQU #12
SMPFRQL EQU #13
SMPFRQH EQU #14
SMPPERL EQU #15
SMPPERH EQU #16
SMPCHAN EQU #17


STACK   EQU #4400

FXHEAD  EQU #41C0
TBUFFER EQU #4200
ISTACK  EQU #4400
CHANSFX EQU #4400
CHANS   EQU #4600
SMPADR  EQU #4800
FXADR   EQU #4C00
INSTAB  EQU #4E00
SMPTAB  EQU #4F00
PATDC0  EQU #5000
PATDC1  EQU #5200
PATDC2  EQU #5400
PATDC3  EQU #5600
BUFFER  EQU #5800

	ORG #8000	;dummy
        PHASE #4000

RAMPG   DEFS #3F
ROMPG   DEFS #01
INTAREA DEFS #40

NUMPG   DEFS #01
CPAGE   DEFS #01
SYSTEM  DEFS #01
SDPAGE  DEFS #01

PROCESS DEFS #01
PLAYING DEFS #01
BUSY    DEFS #01
INGEN   DEFS #01
INT     DEFS #01
INTYPE  DEFS #01
INTADR  DEFS #02

QTFREE  DEFS #02
QTBUSY  DEFS #02

CNTMOD  DEFS #01
CNTSMP  DEFS #01
CNTFX   DEFS #01
CNTTRK  DEFS #02
CNTCHN  DEFS #01

CURMOD  DEFS #01
CURSMP  DEFS #01
CURFX   DEFS #01
CURTRK  DEFS #02
CURCHN  DEFS #01

CURCHAN DEFS #02

MODULE  DEFS #01


GSCHNS  DEFS #01
FXCHNS  DEFS #01
PLCHNS  DEFS #01 ; << PAIR
MDCHNS  DEFS #01 ; <<
MTCHNS  DEFS #01

MODVOL  DEFS #01
FXVOL   DEFS #01
FXMVOL  DEFS #01
MODFADE DEFS #01
FXFADE  DEFS #01

MODSWCH DEFS #01
FILLALL DEFS #01

INFO    DEFS #01

MODSLEN DEFS #03
FXSLEN  DEFS #03

ERRCODE DEFS #01
SGENOFF DEFS #01
CHANNEL DEFS #01

MODPLT  DEFS #01
MODSPLT DEFS #01

CONVERT DEFS #01

LSTCHN  DEFS #01
LSTFX   DEFS #01
LSTMOD  DEFS #01
LSTTRC  DEFS #02

FXTICK  DEFS #02
FXTCLEN DEFS #02


TADR    DEFS 2
TLEN    DEFS 2
TBUFLEN DEFS 2
TBUFBEG DEFS 2
TBUFLN2 DEFS 2
TBUFBG2 DEFS 2
TBUFOLD DEFS 1
TERROR  DEFS 1
TGLBL   DEFS 2
TGLBH   DEFS 1
TLDDL   DEFS 2
TLDDH   DEFS 1
TRQLENL DEFS 2
TRQLENH DEFS 1
TSIZE   DEFS 2
TCRC    DEFS 1
TBURST  DEFS 1
TMODE   DEFS 1  ;#00-MODULE,#FF-SAMPLE
TMODL   DEFS 2
TMODH   DEFS 1
TSMPL   DEFS 2
TSMPH   DEFS 1

LBCOUNT DEFS 1

	UNPHASE
        PHASE #4100-48

RAMBOT  DEFS #03
PTR1    DEFS #03
PTR2    DEFS #03
MEMBOT  DEFS #03
PTR3    DEFS #03
PTR4    DEFS #03
MEMTOP  DEFS #03
PTR5    DEFS #03
PTR6    DEFS #03
PTR7    DEFS #03
PTR8    DEFS #03
PTR9    DEFS #03
PTRA    DEFS #03
PTRB    DEFS #03
PTRC    DEFS #03
RAMTOP  DEFS #03

	UNPHASE
	PHASE #4100
QTMAP   DEFS #20
VOLTAB  DEFS #20
CHNVOL  DEFS #08
VOLRQTB DEFS #08


MTTYPE  DEFS #01
MTSTAT  DEFS #01
MTFLAGS DEFS #01
TICKLEN DEFS #02
TCKLEFT DEFS #02
MTBPM   DEFS #01
MTSPEED DEFS #01
MTCOUNT DEFS #01
MTPATPS DEFS #01
MTSNGPS DEFS #01
MTSNGSZ DEFS #01
MTSNGLP DEFS #01
MTPDT2  DEFS #01
MTPDT   DEFS #01

MTBRKFL DEFS #01
MTBRKPS DEFS #01
MTJMPFL DEFS #01
MTFILTR DEFS #01
MTROWS  DEFS #01
MTVOL   DEFS #01
        DEFS #01
        DEFS #01

MODDIR  DEFS 8*6
CURADR  DEFS 3

SMPS    DEFS #03
PATTS   DEFS #01
MODTP   DEFS #01

	UNPHASE



        ORG GSRomBaseL	;clear low ROM
        DEFS #4000,#FF

        ORG GSRomBaseH	;clear high ROM
        DEFS #4000,#FF



        ORG GSRomBaseL

        DI
        JP INIT

        DEFB #04 ;LOW	(in BCD!)
        DEFB #01 ;HIGH	(in BCD!)
ROMCRC  ;DEFS #02
	DW #e428	;CRC from original rom, corrupted!?

        ORG GSRomBaseL+#0030
        JP #2030

        ORG GSRomBaseL+#0038

INT8    EX AF,AF'
        PUSH DE
        LD E,A
        LD D,HX
        LD A,(DE)
        INC D
        LD A,(DE)
        INC D
        LD A,(DE)
        INC D
        LD A,(DE)
        INC E
        JR Z,INT8_
        LD A,E
        POP DE
        EX AF,AF'
        EI
        RET
INT8_   JP QTDONE

        ORG GSRomBaseL+#0066
NMILP   POP HL
        LD A,L
        OUT (OUTRG),A
NMILP2  IN A,(FLAGS)
        RLCA
        JR C,NMILP2
        LD A,H
        OUT (OUTRG),A
NMILP3  IN A,(FLAGS)
        RLCA
        JR C,NMILP3
        JP NMILP



        ORG GSRomBaseL+#0100
        DEFM "General  Sound (tm)  ROM"
        DEFM "Copyright   1997 Stinger"
        DEFM "Version 1.04 Beta PreRls"




        ; LOW ROM INCLUDES

        INCLUDE "INIT_L.a80"
        INCLUDE "COM_L.a80"
        INCLUDE "MEM_L.a80"
      ; INCLUDE "TRANSF_L.a80"
        INCLUDE "LOAD_L.a80"
        INCLUDE "PLAY.a80"
        INCLUDE "QUANTUM.a80"
        INCLUDE "INTTST.a80"
        INCLUDE "COMM.a80"
        INCLUDE "GEN_L.a80"
        INCLUDE "TABLES_L.a80"
BPMTAB  INCLUDE "_BPM.a80"
	INCLUDE "_trash.a80"	;comes from original ROM!
Free1

        ORG GSRomBaseL+#2000
SGEN    INCLUDE "SGEN_ASM.a80"

        ORG GSRomBaseL+#3E00
DIVTAB3 INCLUDE "_DIVTAB3.a80"
___LEND


        ; HIGH ROM INCLUDES
        ORG GSRomBaseH
;        PHASE #c000

        INCLUDE "INIT_H.a80"
        INCLUDE "COM_H.a80"
        INCLUDE "MEM_H.a80"
        INCLUDE "ENGINE_L.a80"
        INCLUDE "FX_H.a80"
        INCLUDE "VOL_H.a80"
        INCLUDE "TEST_H.a80"
        INCLUDE "TABLES_H.a80"
        INCLUDE "DIHO.a80"
___END

;	UNPHASE
        ORG GSRomBaseH+#2000
	
	INCLUDE "_GSFRQTB.a80"
	INCLUDE "_AMFRQTB.a80"
	INCLUDE "_AMTOGS.a80"


GSFRQTB EQU #E000
AMFRQTB EQU #EC00
AMTOGS  EQU #F800


