Konami SCC/SCC+ Programming
Links
SCC Detection
Routine to detect SCC-slot: (See SlotID)
SCCDETECT: ;---------------------------------------------------- ; SCCDETECT (Made by : NYYRIKKI) ; Input: (None) ; Output: ; Success: ; CF = NC ; A = SlotID ; B = Number of untested slots ; (SCC SLOT on #8000-#BFFF) ; ; Fail: ; CF = C ; B = 0 ; (Random slot on #8000-#BFFF) ; Changes: All registers ;---------------------------------------------------- LD B,16 SCCDETECT_NEXT: ;----------------------------------------------------- ; Call this address if you need to detect another SCC ; Input: B = Value returned by SCCDETECT (must be >0) ;----------------------------------------------------- LD H,#FC .SLOTLOOP DEC B LD A,B AND 3 ADD A,#C1 LD L,A LD A,(HL) AND 128 OR B CP 12 CALL NC,.TESTSLOT RET NC INC B DJNZ .SLOTLOOP RET .TESTSLOT: XOR 12 LD C,A PUSH BC 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 OR (HL) JR NZ,.NOSCC DEC A LD (HL),A LD A,(HL) INC A JR NZ,.NOSCC LD A,(#9000) XOR #3F JR NZ,.EXIT .NOSCC LD (HL),E LD A,D LD (#9000),A SCF .EXIT POP HL POP BC LD A,C RET
SCC+ Detection
Routine to detect SCC+ slot:
;------------------------------------------ ; SCC+ detection routine by gdx ; Input: None ; Output: A = SCC Slot ID if found else 0 ; F = Carry is 0 if SCC found else 1 ; Page 8000h-BFFFh = First SCC+ found slot or random slot if SCC not found ; Changes: All registers ;------------------------------------------ SCCDetect: call Slt_Num_conv ld c,a ; C = Current slot number jr nz,SltPrim ; Jump if not primary slot ld a,3 ld (Sec_SLT),a ; Sec_SLT =3 if primary slot to skip secondary slots SltPrim: ld a,c call CHK_SLT ld a,c ; A = Current slot number ret nc ; Back if SCC+ found ld a,(Sec_SLT) inc a and 3 ; Sec_SLT = 0~3 only ld (Sec_SLT),a jr nz,SCCDetect ; Jump if Sec_SLT <> 0 ld a,(Prim_SLT) inc a cp 4 ld (Prim_SLT),a jr nz,SCCDetect ; Jump if all primary slots are not scanned xor a scf ret CHK_SLT: push bc ld h,080h call ENASLT ld a,020h ld (0BFFEh),a ; Set ROM mode for all page & SCC+ mode ld hl,0AFFFh ld d,(hl) ld a,d ; Store the value ld (hl),a cp d jr nz,SCCpNotFnd ; Jump if the read value is not the same cpl ld (hl),a ld a,(hl) cp d jr nz,SCCpNotFnd ; Jump if the read value remains the same ld hl,0B800h ld e,(hl) ld a,e ; Store the value cpl ld (hl),a ld a,(hl) jr nz,SCCpNotFnd ; Jump if the read value remains the same ld a,080h ld (0B000h),a ; Enable the SCC+ registers ld a,255 ld (hl),a ld a,(hl) cp 255 jr nz,SCCpNotFnd ; Jump if the read value is not 255 inc a ld (hl),a ld a,(hl) or a jr nz,SCCpNotFnd ; Jump if the read value is not 0 xor a jr SCRCH_End SCCpNotFnd: ld a,d ld (0AFFFh),a ld (hl),e scf SCRCH_End: pop bc ret ; Convert Prim_SLT and Sec_SLT values to slot number format ; Entry: Prim_SLT, Sec_SLT ; Output: A = Slot number (FxxxPPSS) ; Modify: A, BC, HL Slt_Num_conv: ld a,(Prim_SLT) ld c,a ld b,0 ld hl,EXPTBL add hl,bc ld a,(hl) and 80h ld a,c ret z ; Back if primary slot ld a,(Sec_SLT) rlca rlca or c or 080h ret Prim_SLT: db 0 ; Current primary slot number Sec_SLT: db 1 ; Current secondary slot number
Note: Routine not optimized.