How to detect the SCC?

Page 1/5
| 2 | 3 | 4 | 5

By saccopharynx

Master (175)

saccopharynx's picture

16-10-2013, 23:13

Hi,

I would appreciate if somebody could tell me how to (programmatically in Assembly) detect the slot/subslot which an SCC is connected to. Actually, I need to know the indicators that tell that an SCC is connected.

Thanks,

S

Login or register to post comments

By Edwin

Paragon (1182)

Edwin's picture

16-10-2013, 23:27

Simple enough:
- select slot in page 2
- select rom page 63
- check if you can read/write in a wave ram location
- select rom page other than 63 (2 for instance)
- check if the wave ram location is read only
If all succesful, this a slot with an scc.

Repeat this test for all possible slots.

By saccopharynx

Master (175)

saccopharynx's picture

16-10-2013, 23:54

Great, many thanks.

By max_iwamoto

Hero (644)

max_iwamoto's picture

17-10-2013, 04:58

I just finished the code for automatic SCC & SCC+ search for Project Melancholia mapper version. It will scan all slots in search of SCC support, hope it helps:

; ---------------------------------------
 
ENASLT:		EQU	0024h
EXPTBL:		EQU	FCC1h


SCANSLT:
	XOR	A		; start from slot 0
	LD	HL,EXPTBL
.loop:
	LD	C,(HL)
	OR	C
.loop2:
	EXX

	LD	(CHK_SCC.c_slt),A	; save current slot

	PUSH	AF

	LD	H,80h
	CALL	ENASLT

	CALL	CHK_SCC

	POP	AF

	EXX

	ADD	A,%00000100	; increase subslot number
	LD	C,A		; C = new slot + subslot
	BIT	7,A		; check if slot expanded
	JR	Z,.next		; if not expanded go for next slot
	AND	%00001100	; check if already checked all subslots
	LD	A,C
	JR	NZ,.loop2	; still some subslots left
.next:
	INC	HL
	LD	A,C
	INC	A
	AND	%00000011
	RET	Z		; return if all slots & subslots are checked!
;
	JR	.loop

CHK_SCC:
	LD	HL,A000h
	LD	DE,BFFEh
	LD	BC,2000h	; C = 00h -> SCC = YES if found
	XOR	A
	LD	(DE),A		; SET ROM + SCC if SCC-I cartridge
	LD	A,(HL)
	INC	A
	LD	(HL),A
	CP	(HL)
	RET	Z		; found RAM -> return

	LD	HL,97FFh
	LD	(HL),L		; activate SCC write (write xx111111)
	INC	HL		; HL = 9800h
	LD	A,(HL)
	INC	A
	LD	(HL),A
	CP	(HL)
	RET	NZ
	DEC	A
	LD	(HL),A

.f_SCC:
	XOR	A
	DEC	HL
	LD	(HL),A		; disable write to SCC RAM

	LD	A,B
	LD	(DE),A		; SET ROM + SCC+ if SCC-I present
	LD	HL,B7FFh
	LD	(HL),L		; activate SCC+ write (write 1xxxxxxx)
	INC	HL		; HL = B800h
	LD	A,(HL)
	INC	A
	LD	(HL),A
	CP	(HL)
	JR	NZ,.setSCC
	DEC	A
	LD	(HL),A

.f_SCCI:
	INC	C		; C = 1 -> SCC+ = YES

.setSCC:
	XOR	A
	DEC	HL
	LD	(HL),A		; disable write to SCC+ RAM

	LD	A,00h	; register "A" will contain slot/subslot with SCC Cartridge
.c_slt:	EQU	$ - 1	; register "C" will contain "0" for SCC and "1" for SCC+


 [...your code here...]

	RET

You can search for more than one SCC cartridge and choose the "best" one. Also SCC data will remain undamaged after search is finished.

By saccopharynx

Master (175)

saccopharynx's picture

17-10-2013, 13:32

Thanks max_iwamoto, your code works fine ('A' contains the correct slot/subslot of the SCC), but I found a few problems:

1) two " pop af " are missing (one because of the PUSH AF and other because of calling CHK_SCC without returning).
2) I'm not sure if the data of the SCC remains undamaged since I get no sound after running the code. I will inspect what is going on.

S

By max_iwamoto

Hero (644)

max_iwamoto's picture

17-10-2013, 17:54

saccopharynx wrote:

Thanks max_iwamoto, your code works fine ('A' contains the correct slot/subslot of the SCC), but I found a few problems:

1) two " pop af " are missing (one because of the PUSH AF and other because of calling CHK_SCC without returning).
2) I'm not sure if the data of the SCC remains undamaged since I get no sound after running the code. I will inspect what is going on.

S

1) As I mention before, I am not stopping search after I found first available SCC. I am making a table of all available sound cartridges. But if you want exit as soon as you found one, you can indeed do 2 x POP + RET.

2) Technically there is no need to leave wave tables untouched, because most of the time you do check before music player even load them with any data and usually they are contain "00" at the start...

But if you have music re-player for SCC-I and you have found a regular SCC, you need to patch the player to hear any sound. But I could help more if I knew what you trying to achieve.

Max

By NYYRIKKI

Enlighted (6067)

NYYRIKKI's picture

17-10-2013, 20:01

My pretty simple version:

;------------------------------------------
; SCCDETECT (Made by : NYYRIKKI)
; Input: (None)
; Output:
;   Success:
;     CF = NC
;     SCC SLOT #8000-#BFFF
;     A = SlotID
;
;   Fail:
;     CF = C
;     (Random slot on #8000-#BFFF)
; Changes: All registers
;------------------------------------------

SCCDETECT:
         LD D,#FF
         LD HL,#FCC1

.MAINL:
         INC D
         LD A,4
         CP D
         SCF
         RET Z

         LD A,(HL)
         INC HL
         AND #80
         JR Z,.MAINTST
         CALL .SUBTST
         JR C,.MAINL
         RET

.MAINTST:
         LD A,D
         CALL .TESTSLOT
         JR C,.MAINL
         LD A,D
         RET

;-----------------------
.SUBTST
         LD E,#FC
.SUBLOOP:
         LD A,4
         ADD A,E
         CP 16
         SCF
         RET Z
         LD E,A
         OR D
         OR #80
         LD C,A
         CALL .TESTSLOT
         JR C,.SUBLOOP
         LD A,C
         RET


.TESTSLOT:
         PUSH BC
         PUSH DE
         PUSH HL

         LD H,#80
         CALL #24


         LD A,(#9000)
         LD D,A
         LD A,#3F
         LD (#9000),A
         LD HL,#9800
         LD E,(HL)
         XOR A
         LD (HL),A
         LD A,(HL)
         OR A
         JR NZ,.NOSCC
         DEC A
         LD (HL),A
         LD A,(HL)
         INC A
         JR NZ,.NOSCC
         LD A,(#9000)
         CP #3F
         JR Z,.NOSCC
         XOR A
         JR .EXIT
.NOSCC
         LD (HL),E
         LD A,D
         LD (#9000),A
         SCF
.EXIT
         POP HL
         POP DE
         POP BC
         RET

By saccopharynx

Master (175)

saccopharynx's picture

18-10-2013, 01:12

Thanks to you both. It is working fine now.

By max_iwamoto

Hero (644)

max_iwamoto's picture

22-10-2013, 07:05

saccopharynx wrote:

Thanks to you both. It is working fine now.

No problem.

Here is screenshot from openMSX with 8 x SCC/SCC-I cartridges attached Wink

I tried to insert image directly to this post, but it didn't work properly. So this is the direct link:

https://docs.google.com/file/d/0B1kyb4fqWeQ9eGpZTWRMczI3SVU/...

By ARTRAG

Enlighted (6935)

ARTRAG's picture

06-08-2014, 08:29

Sorry for resurrecting this post but the subject is related.
Is there any reason for this code to not work on bluemsx when an SCC-I is plugged ?
The SCC-I should start in SCC mode at boot, never the less, on bluemsx it is not properly detected.

;------------------------------------------------------------
; SCC-search v1.0
; by Alwin Henseler
; using method described in bulletin # 18 MSX-club Enschede
; input: none
; output: B=slot that contains SCC (=255 if no SCC found)

enaslt:          equ #0024
exptbl:          equ #fcc1
slttbl:          equ #fcc5




begin:
				MAP #c000
                 in a,(#a8)        ; read prim. slotregister
                 rra
                 rra
                 rra
                 rra
                 and %00000011     ; A = prim.slot page 2
                 ld b,0
                 ld c,a
                 ld hl,exptbl
                 add hl,bc
                 bit 7,(hl)        ; page 2-slot expanded ?
                 jr z,scctest
                 ld hl,slttbl
                 add hl,bc
                 ld a,(hl)         ; A = sec.sel.reg. of page 2-slot
                 rra
                 rra
                 and %00001100     ; bit 1/2 = sec.slot page 2
                 or c
                 set 7,a           ; compose sec.slot-code
scctest:         push af           ; save page 2-slot on the stack
                 ld a,(exptbl)     ; 1st slot to test

testslot:        push af           ; save test-slot on the stack
                 ld h,#80
                 call enaslt       ; switch slot-to-test in 8000-bfffh
                 ld hl,#9000
                 ld b,(hl)         ; save contents of address 9000h
                 ld (hl),#3f       ; activate SCC (if present)
                 ld h,#9c          ; address of SCC-register mirrors
                 ld de,#9800       ; 9800h = address of SCC-registers
testreg:         ld a,(de)
                 ld c,a            ; save contents of address 98xxh
                 ld a,(hl)         ; read byte from address 9cxxh
                 cpl               ; and invert it
                 ld (de),a         ; write inverted byte to 98xxh
                 cp (hl)           ; same value on 9cxxh ?
                 ld a,c
                 ld (de),a         ; restore value on 98xxh
                 jr nz,nextslot    ; unequal -> no SCC -> continue search
                 inc hl
                 inc de            ; next test-addresses
                 bit 7,l           ; 128 addresses (registers) tested ?
                 jr z,testreg      ; no -> repeat mirror-test
                 ld a,b
                 ld (#9000),a      ; restore value on 9000h
                 pop bc            ; retrieve slotcode (=SCC-slot) from stack
                 jr done           ; SCC found, restore page 2-slot & return

nextslot:        ld a,b
                 ld (#9000),a      ; restore value on 9000h
                 pop bc            ; retrieve slotcode from stack
                 bit 7,b           ; test-slot = sec.slot ?
                 jr z,nextprim
                 ld a,b
                 add a,4           ; increase sec.slotnumber
                 bit 4,a           ; sec.slot = 4 ?
                 jr z,testslot
nextprim:        ld a,b
                 and %00000011
                 cp 3              ; prim.slot = 3 ?
                 jr z,noscc
                 inc a             ; increase prim.slotnumber
                 ld d,0
                 ld e,a
                 ld hl,exptbl
                 add hl,de
                 or (hl)           ; combine slot-expansion with slotcode
                 jr testslot

noscc:           ld b,255          ; code for no SCC
done:            pop af            ; retrieve page 2-slot from stack
                 push bc
                 ld h,#80
                 call enaslt       ; restore original page 2-slot
                 pop bc
                 ei
                 ret
end:
				 endmap				 
; -------------------------------------------------------------


; ====================
;    Initialization
; ====================
SCCINIT
				ld	hl,begin
				ld	de,0C000H
				ld	bc,end-begin+1
				ldir
				call	0C000H
				ld	a,b
				ld	(SCC),a
				ret

Needless to say it seems a bluemsx relate bug, as it works fine on openmsx.

By Metalion

Paragon (1625)

Metalion's picture

04-08-2021, 14:15

Sorry to unearth this old topic, but I'd like to make some first steps with the SCC soundchip.
If I use the SCCDETECT routine written by Nyryikki a few messages above, how you go on using the SCC afterwards ?
Do you have to switch to the SCC slot at every access ?

Something like :

scc_on:	call	SCCDETECT
	ret	c	; SCC not found
	ld	(slot),a
	ret

scc_write:
	ld	a,(slot)
	ld	h,80h
	call	ENASLT
	(then write to SCC registers)

Is that correct ?

Page 1/5
| 2 | 3 | 4 | 5