;LAST UPDATE: 25.05.2013 savelij
;version 08.03.2009
include macros.a80
GSDAT EQU 0XB3
GSCOM EQU 0XBB
GSCOD EQU 0X5100
OPISAT EQU 0X6000
ORG 0X8000
START EI
LD HL,0X0110
LD (0X5C09),HL
RES 3,(IY+48)
LD A,0XFE
IN A,(0XFE)
RRA
LD A,0
JR C,$+4
LD A,0X10
LD BC,0XEFF7
OUT (C),A
LD A,0X7F
IN A,(0XFE)
RRA
RRA
JR NC,LOOP21
LOOP31 LD B,0X30
XOR A
OUT (GSDAT),A
LD A,0X1D
OUT (GSCOM),A
LOOP22 HALT
DEC B
JR Z,LOOP21
IN A,(GSCOM)
RRA
JR C,LOOP22
IN A,(GSDAT)
CP 0X77
JP Z,LOOP13
CP 0X8B
JR Z,LOOP24
LOOP21 LD A,0X80
OUT (0X33),A
HALT
HALT
LD A,0XF3
OUT (GSCOM),A
LD B,0X30
LOOP25 HALT
HALT
DEC B
JP Z,NO__GS
IN A,(GSCOM)
RRA
JR C,LOOP25
LOOP24 LD BC,GSDAT
LD DE,FAT_END-GO_YES
LD HL,GSCOD
OUT (C),E
LD A,0X14
OUT (GSCOM),A
CALL WC
OUT (C),D
CALL WD
OUT (C),L
CALL WD
OUT (C),H
CALL WD
LD HL,GO_YES
LODCOD OUTI
CALL WD
DEC DE
LD A,D
OR E
JR NZ,LODCOD
LD HL,GSCOD
OUT (C),L
LD A,0X13
OUT (GSCOM),A
CALL WC
OUT (C),H
HALT
HALT
LOOP13 LD A,7
CALL CLS
LD DE,0X4800
LD HL,MESS20
CALL PRINT
XOR A
OUT (GSDAT),A
LD A,0X1D
OUT (GSCOM),A
LD B,0
CALL WAITGS
IN A,(GSDAT)
CP 0X77
JR Z,Warm
CP 0XEE
JR NZ,LOOP17
LD A,7
CALL CLS
LD HL,MESS13
LD DE,0X5000
LOOP20 CALL PRINT
LD HL,MESS15
LD DE,0X5040
CALL PRINT
LD HL,MESS16
LD DE,0X5080
CALL PRINT
JR LOOP16
LOOP17 CP 0XDD
JR NZ,LOOP26
LD A,7
CALL CLS
LD HL,MESS14
LD DE,0X5000
JR LOOP20
LOOP26 CP 0XBB
JR NZ,LOOP27
LD A,7
CALL CLS
LD HL,MESS23
LD DE,0X5000
JR LOOP20
LOOP27 CP 0XCC
JR NZ,LOOP13
JP NO_NGS
LOOP16 BIT 5,(IY+1)
JR Z,LOOP16
LD A,(IY-0X32)
RES 5,(IY+1)
CP 0X0D
JP Z,START
CP 0X20
JP Z,LOOP18
JR LOOP16
Warm LD A,7
CALL CLS
LD HL,MESS1
LD DE,0X4000
CALL PRINT
LD HL,MESS2
LD DE,0X4040
CALL PRINT
LD HL,MESS3
LD DE,0X4060
CALL PRINT
LD HL,MESS4
LD DE,0X4080
CALL PRINT
LD HL,MESS5
LD DE,0X40A0
CALL PRINT
LD HL,MESS6
LD DE,0X40C0
CALL PRINT
LD HL,MESS7
LD DE,0X4800
CALL PRINT
LD HL,MESS8
LD DE,0X4840
CALL PRINT
LD HL,MESS9
LD DE,0X4860
CALL PRINT
LD HL,MESS10
LD DE,0X48A0
CALL PRINT
LD HL,MESS11
LD DE,0X4880
CALL PRINT
LD HL,MESS12
LD DE,0X48C0
CALL PRINT
LD HL,MESS24
LD DE,0X48E5
CALL PRINT
LD HL,MESS26
LD DE,0X485C
CALL PRINT
LD HL,MESS27
LD DE,0X487C
CALL PRINT
CALL PRTTBL
LD HL,0X59E0
LD B,0X20
LD A,0X0C
OUT (GSCOM),A
CALL WN
IN A,(GSDAT)
LD C,A
CALL WN
IN A,(GSDAT)
LD A,C
AND 8
XOR 8
OR 0X31
LD (HL),A
INC L
DJNZ $-2
RES 5,(IY+1)
LD A,0X15
LD DE,0X400B
CALL READ5BT
;КОЛ-ВО НАЙДЕННОГО
CALL NAMELNG
CALL DAT_VTS
LOOP LD A,0X0B
LD DE,0X486B
CALL READSEC;ВРЕМЯ ИГРАНИЯ
CALL BITRATE
LD A,0X0C
OUT (GSCOM),A
CALL WN
IN A,(GSDAT)
LD H,A
CALL WN
IN A,(GSDAT)
BIT 5,H
CALL NZ,NAMELNG
LOOP14 BIT 5,(IY+1)
JR Z,LOOP
LD A,(IY-0X32)
RES 5,(IY+1)
CP 0X31
JR NZ,LOOP1
LD A,1
JR LOOP11
LOOP1 CP 0X32
JR NZ,LOOP2
LD A,2
JR LOOP11
LOOP2 CP 0X33
JR NZ,LOOP3
LD A,3
JR LOOP11
LOOP3 CP 0X34
JR NZ,LOOP4
LD A,4
JR LOOP11
LOOP4 CP 0X35
JR NZ,LOOP5
LD A,5
JR LOOP11
LOOP5 CP 0X30
JP Z,EJECT
LOOP7 CP 0X39
JR NZ,LOOP8
LD A,6
OUT (GSCOM),A
CALL WC
CALL PRTTBL
JP LOOP-3
LOOP8 CP 0X38
JR NZ,LOOP9
LD A,7
JR LOOP11
LOOP9 CP 0X36
JR NZ,LOOP10
LD A,9
JR LOOP11
LOOP10 CP 0X37
JR NZ,LOOP15
LD A,8
LOOP11 OUT (GSCOM),A
CALL WC
JP LOOP-3
LOOP15 CP 0X20
JR NZ,LOOP23
LOOP18 CALL NANYKEY
XOR A
LD BC,0X7FFD
OUT (C),A
JP 0
LOOP23 CP 0X0D
JR NZ,LOOP28
LD A,0X0A
JR LOOP11
LOOP28 CP 0X3A
JR NZ,LOOP29
LD A,0X17
JR LOOP11
LOOP29 CP 0X21
JR NZ,LOOP30
LD A,0X18
JR LOOP11
LOOP30 CP 0X25
JR NZ,LOOP32
LD A,0X19
JR LOOP11
LOOP32 CP 0X71
JR NZ,LOOP33;Q-FTREBLE
LD A,%00000011
JR LOOPTBL
LOOP33 CP 0X61
JR NZ,LOOP34;A-FTREBLE
LD A,%00000001
JR LOOPTBL
LOOP34 CP 0X77
JR NZ,LOOP35;W-UTREBLE
LD A,%00001100
JR LOOPTBL
LOOP35 CP 0X73
JR NZ,LOOP36;S-UTREBLE
LD A,%00000100
JR LOOPTBL
LOOP36 CP 0X65
JR NZ,LOOP37;E-FBASS
LD A,%00110000
JR LOOPTBL
LOOP37 CP 0X64
JR NZ,LOOP38;D-FBASS
LD A,%00010000
JR LOOPTBL
LOOP38 CP 0X72
JR NZ,LOOP39;R-UBASS
LD A,%11000000
JR LOOPTBL
LOOP39 CP 0X66
JP NZ,LOOP;F-UBASS
LD A,%01000000
LOOPTBL PUSH AF
LD A,0X1A
OUT (GSCOM),A
CALL WC
POP AF
OUT (GSDAT),A
CALL PRTTBL
JP LOOP
WAITGS LD E,B
LD D,0
LD HL,VENTIL
ADD HL,DE
LD A,(HL)
LD DE,0X481E
CALL PRISYM
LD C,6
HALT
DEC C
JR NZ,$-2
IN A,(GSCOM)
RRA
RET NC
INC B
LD A,4
CP B
JR NZ,WAITGS
LD B,0
JR WAITGS
NAMELNG LD A,0X16
LD DE,0X484D
CALL READ5BT
;ТЕКУЩИЙ НОМЕР ТРЕКА
LD HL,0X8000
LD A,0X11
OUT (GSCOM),A
CALL WC
;ПОЛУЧИТЬ ДЛИННОЕ ИМЯ
LD A,H
OUT (GSDAT),A
CALL WD
LD A,L
OUT (GSDAT),A
LD HL,OPISAT
LD E,0
PUSH HL
CALL INI_E
LD HL,0X5000
LD D,H
LD E,L
LD BC,0X07FF
INC E
LD (HL),L
LDIR
POP HL
LD B,0X20
LD DE,0X5000
CALL PRINT_B
LD B,0X20
LD DE,0X5020
CALL PRINT_B
LD B,0X20
LD DE,0X5040
CALL PRINT_B
LD B,0X20
LD DE,0X5060
CALL PRINT_B
LD B,0X20
LD DE,0X5080
CALL PRINT_B
LD B,0X20
LD DE,0X50A0
CALL PRINT_B
LD B,0X20
LD DE,0X50C0
CALL PRINT_B
LD B,0X20
LD DE,0X50E0
JP PRINT_B
RD2BYTE EX AF,AF'
LD A,0X1A
OUT (GSCOM),A
CALL WC
EX AF,AF'
OUT (GSDAT),A
LD B,0X10
DJNZ $
CALL WN
IN A,(GSDAT)
LD H,A
CALL WN
IN A,(GSDAT)
LD L,A
RET
DAT_VTS LD A,0X0C
OUT (GSCOM),A
CALL WN
IN A,(GSDAT)
LD H,A
CALL WN
IN A,(GSDAT)
LD L,A
LD DE,0X48AF
BIT 7,H
LD A,0X2B
JR NZ,$+4
LD A,0X2D
CALL PRISYM
BIT 0,H
LD A,0X2B
JR NZ,$+4
LD A,0X2D
LD DE,0X488D
CALL PRISYM
BIT 6,H
LD A,0X2B
JR NZ,$+4
LD A,0X2D
LD DE,0X48DF
CALL PRISYM
LD A,L
LD DE,0X48CE
CALL PRIHEX
;ТЕМБР,СУРРОУНД И ГРОМКОСТЬ
BIT 4,H
LD HL,MESS16+2
JR Z,DATVTS1
RES 5,(HL)
INC HL
RES 5,(HL)
INC HL
RES 5,(HL)
INC HL
RES 5,(HL)
JR DATVTS2
DATVTS1 SET 5,(HL)
INC HL
SET 5,(HL)
INC HL
SET 5,(HL)
INC HL
SET 5,(HL)
DATVTS2 LD HL,MESS16
LD DE,0X4014
CALL PRINT
PRTTBL LD A,0X0C
OUT (GSCOM),A
CALL WN
IN A,(GSDAT)
LD H,A
CALL WN
IN A,(GSDAT)
LD A,H
BIT 3,A
JR Z,EMPTSTR
BIT 7,A
JR Z,EMPTSTR
LD A,0X1B
OUT (GSCOM),A
CALL WC
LD HL,OPISAT+0X0100
LD E,8
PUSH HL
CALL INI_E
LD DE,0X48B1
LD B,2
POP HL
CALL PRINT_B
REPT 3
LD A,0X30
CALL PRISYM
ENDM
LD A,0X2F
CALL PRISYM
LD B,2
CALL PRINT_B
INC E
LD B,2
CALL PRINT_B
LD A,0X30
CALL PRISYM
LD A,0X2F
CALL PRISYM
LD B,2
JP PRINT_B
EMPTSTR LD HL,MESS25
LD DE,0X48B1
JP PRINT
BITRAT1 LD HL,MESS25
LD DE,0X4856
PUSH HL
LD B,5
CALL PRINT_B
LD DE,0X4878
LD B,3
POP HL
PUSH HL
CALL PRINT_B
POP HL
LD B,0X0C
LD DE,0X4834
JP PRINT_B
BITRATE LD A,0X1C
OUT (GSCOM),A
CALL WN
IN A,(GSDAT)
LD B,A
CALL WN
IN A,(GSDAT)
LD C,A
LD A,B
AND 0XE0
CP %10100000
JR Z,BITRAT1
LD A,C
AND 3
LD L,A
ADD A,A
ADD A,A
ADD A,L
LD L,A
LD H,0
LD A,C
RRCA
RRCA
AND 3
LD DE,SR0
JR Z,BITRAT3
DEC A
LD DE,SR1
JR Z,BITRAT3
LD DE,SR2
BITRAT3 ADD HL,DE
LD DE,0X4856
PUSH BC
LD B,5
CALL PRINT_B
POP BC
LD A,C
RLCA
RLCA
AND 3
ADD A,A
LD A,A
LD L,A
ADD A,A
ADD A,L
LD L,A
LD H,0
LD DE,REJCHAN
ADD HL,DE
PUSH BC
LD B,0X0C
LD DE,0X4834
CALL PRINT_B
POP BC
LD A,B
AND 0X0F
LD L,A
ADD A,A
ADD A,L
LD L,A
LD H,0
LD A,C
AND 0X0C
CP 0X0B
JR C,$+3
ADD HL,HL
LD A,C
AND 0X30
SUB 0X10
LD DE,L3ID0
JR Z,BITRAT2
SUB 0X10
LD DE,L2ID0
JR Z,BITRAT2
LD DE,L1ID0
BITRAT2 ADD HL,DE
LD B,3
LD DE,0X4878
JP PRINT_B
READ_GS OUT (GSCOM),A
CALL WN
IN A,(GSDAT)
LD H,A
CALL PRIHEX
CALL WN
IN A,(GSDAT)
LD L,A
JP PRIHEX
READ5BT OUT (GSCOM),A
REPT 4
CALL WN
IN A,(GSDAT)
CALL PRISYM
ENDM
CALL WN
IN A,(GSDAT)
JP PRISYM
READSEC OUT (GSCOM),A
REPT 2
CALL WN
IN A,(GSDAT)
CALL PRISYM
ENDM
LD A,0X3A
CALL PRISYM
REPT 2
CALL WN
IN A,(GSDAT)
CALL PRISYM
ENDM
LD A,0X3A
CALL PRISYM
CALL WN
IN A,(GSDAT)
CALL PRISYM
CALL WN
IN A,(GSDAT)
JP PRISYM
NO_NGS LD A,7
CALL CLS
LD DE,0X4809
LD HL,MESS17
CALL PRINT
LD DE,0X4846
LD HL,MESS19
CALL PRINT
CALL NANYKEY
CALL ANYKEY
CALL NANYKEY
BAS128 XOR A
LD BC,0X7FFD
OUT (C),A
JP 0
ANYKEY XOR A
IN A,(0XFE)
CPL
AND 0X1F
JR Z,$-6
RET
NANYKEY XOR A
IN A,(0XFE)
CPL
AND 0X1F
JR NZ,$-6
RET
NO__GS LD A,7
CALL CLS
LD DE,0X480A
LD HL,MESS18
CALL PRINT
LD DE,0X4846
LD HL,MESS19
CALL PRINT
CALL ANYKEY
CALL NANYKEY
JR BAS128
PRINT_B LD A,(HL)
AND A
RET Z
INC HL
CALL PRISYM
DJNZ PRINT_B
RET
PRINT LD A,(HL)
INC HL
AND A
RET Z
CALL PRISYM
JR PRINT
VENTIL DB 0XC4,0X5C,0X7C,0X2F
MESS1 DB "Found MP3: "
;0X4000 0X400b
DB " "
MESS16 DB 0X22,"Space",0X22," Exit",0
;0X4014
MESS2 DB "1 Prev. File "
DB "SS+1 Prev. DIR",0
MESS3 DB "2 Play File",0
MESS4 DB "3 Pause",0
MESS5 DB "4 Stop",0
MESS6 DB "5 Next File "
DB "SS+5 Next DIR",0
MESS7 DB "0 Eject SD Card",0
MESS8 DB "Play Number:",0
;0X4840 0X484D
MESS9 DB "Time Play:",0
;0X4860 0X486B
MESS10 DB "9 Treble/Bass:",0
;0X4880 0X4890
MESS11 DB "8 Surround:",0
;0X48A0 0X48Ad
MESS12 DB "<6-7> Volume: "
DB 0X22,"Enter",0X22," Mute",0
;0X48C0 0X48Ce
MESS13 DB "SD-Card Not Found",0
;0X5000
MESS14 DB "FAT not Found",0
;0X5000
MESS15 DB "Press ",0X22,"ENTER",0X22
DB " 4 Restart Init SD",0
MESS17 DB "Neo"
MESS18 DB "GS not found",0
MESS19 DB "Press any key for reset",0
MESS20 DB "Please wait, search MP3"
DB " files",0
MESS21 DB "Eject SD card or insert"
DB " new card",0
MESS22 DB "Press any key",0
MESS23 DB "MP3 file(s) not found",0
MESS24 DB "Neo Player Light v0.44",0
MESS25 DB " ",0
MESS26 DB "Hz",0
;0X487C
MESS27 DB "kbps",0
;0X489C
REJCHAN DB " stereo"
DB "joint stereo"
DB "dual channel"
DB " mono"
SR0 DB "11025110252205044100"
SR1 DB "12000120002400048000"
SR2 DB " 8000 80001600032000"
L3ID0
DB " - 32 40 48 56 64 80 96"
DB "112128160192224256320"
DB " - 8 16 24 32 40 48 56"
DB " 64 80 96112128144160"
L2ID0
DB " - 32 48 56 64 80 96112"
DB "128160192224256320384"
DB " - 8 16 24 32 40 48 56"
DB " 64 80 96112128144 160"
L1ID0
DB " - 32 64 96128160192224"
DB "256288320352384416448"
DB " - 32 48 56 64 80 96112"
DB "128144160176192224256"
EJECT LD A,4
OUT (GSCOM),A
CALL WC
LD A,7
CALL CLS
LD HL,MESS21
LD DE,0X4800
CALL PRINT
LD HL,MESS22
LD DE,0X4849
CALL PRINT
CALL NANYKEY
CALL ANYKEY
CALL NANYKEY
XOR A
OUT (GSCOM),A
JP LOOP13
CLS LD HL,0X4000
LD E,L
LD D,H
LD (HL),L
INC E
LD BC,0X1800
LDIR
CLSCLR LD (0X5C8D),A
LD (0X5C48),A
LD HL,0X5800
LD D,H
LD E,L
LD (HL),A
LD BC,0X02FF
INC E
LDIR
RRCA
RRCA
RRCA
AND 7
OUT (0XFE),A
RET
WC IN A,(GSCOM)
RRA
JR C,$-3
RET
WD IN A,(GSCOM)
RLA
JR C,$-3
RET
WN IN A,(GSCOM)
RLA
JR NC,$-3
RET
INI_E LD BC,GSDAT
CALL WN
INI
DEC E
JR NZ,$-6
RET
PRIHEX PUSH AF
RRA
RRA
RRA
RRA
CALL PHC
POP AF
PHC AND 0X0F
CP 0X0A
JR C,$+4
ADD A,7
ADD A,0X30
PRISYM PUSH HL
PUSH DE
PUSH DE
LD L,A
LD H,0
LD DE,CHARS
REPT 3
ADD HL,HL
ENDM
ADD HL,DE
POP DE
REPT 8
LD A,(HL)
LD (DE),A
INC HL
INC D
ENDM
POP DE
POP HL
INC E
RET
GO_YES
binclude unp_play4ngs.rom ; INCB "FATNGSC*"
FAT_END
CHARS binclude altstd.bin ; INCB "ALTSTD"