Thanks for the component lists and photos. And good to know that the GAL could be EPL16P8BP or GAL16V8B, and that the PSS51 cart does actually have different logic stored in the GAL.
Post them here as attachment? Unless you are worried about copyright issues (I think copyright isn't much of an issue for that kind out of production logic chips).
I've no idea how to disassemble the GAL binary into source-code-style logic functions, I hope somebody in the forum knows how to do that...
If you want to spend some hours on it: Start using a multimeter to search 0 ohm connections between the CPU pins and cartridge slot pins. The pinouts for the SNES CPU are well known (the Z80 HD64180RF6 chips are probably also documented somewhere), and the trick is simply to find out which pins on the cartridge slot they do connect to.
If you want to cheat: The WRAM and ROM chips have bigger solder pads, so it may be easier to use that pins instead of the CPU pins (and hope that D0..D7 and A0..A14 are actually wired to the corresponding CPU pins) (on the other hand, with LoROM carts, it's well known that ROM.A15 and up do NOT directly correspond to CPU.A15 and up).
That isn't very difficultl. The whole GROM code contains only 150 lines of code (and that is also including the SRAM mapping, the code for the ROM mapping is even smaller). But before changing the GROM code, you would first need to understand how the mapping logic working...
That would require knowing pinouts for cartridge slot, and the wiring of the GAL pins, and ROM chipselect pins... And to find the Port C0h/C1h latches that contain the mapping state. They might be somewhere on the main board, or are that two 74HC273 chips on each cartridge board? Wherever they are, their inputs should go to the Z80 databus, and their outputs should probably go to the GAL.
PS. Below is a disassembly of the PSS61 GROM opcodes. It's really simple and could be easily changed -- as long as you understand your mapping logic and know what values you want to write to which registers what for.
Code: Select all
Incoming paramters:
A=function (00h=Change Mapping, FFh=Boot Callback, other=Reserved)
BC=ptr to 10-bytes
E=same as [BC+5]
[BC+0] ROM Slot (0 or 1) ;Cartridge Slot 0-1
[BC+1] ROM Socket (0..3) ;from GROM[8]
[BC+2] Mapmode (0=LoROM, 1=HiROM, 2=GSU) ;from GROM[P0+16h]
[BC+3] Used Chipset (bit0=SRAM, bit1=DSP) ;from GROM[P0+2Ah]
[BC+4] SRAM Size (0=None, 1=2K, 3=8K, 5=32K) ;from GROM[P0+17h]
[BC+5] SRAM Base (0..3) (0..7 when 2 chips) ;from GROM[P0+1Ch]
[BC+6] Slot 1 Chipset (bit0=SRAM, bit1=DSP, bit2=GSU?) ;from Slot1.GROM[4]
[BC+7] Slot 0 Chipset (bit0=SRAM, bit1=DSP, bit2=GSU?) ;from Slot0.GROM[4]
[BC+8] Copy of Port[C0h] ;\the function must update these values alongside
[BC+9] Copy of Port[C1h] ;/with the new values written to Port C0h/C1h
Port [C0h].W - SNES Mapping Register 0
0-1 ROM Socket (0=ROM5, 1=ROM1/7/12, 2=ROM3/9, 3=IC20)
2 ROM Slot (0=Slot0, 1=Slot1)
3 SRAM Enable (0=Disable, 1=Enable)
4 SRAM Slot (0=Slot0, 1=Slot1)
5 DSP Enable (0=Disable, 1=Enable)
6 DSP Slot (0=Slot0, 1=Slot1)
7 ROM, DSP, and/or SRAM Mapping (0=LoROM, 1=HiROM)
Port [C1h].W - SNES Mapping Register 1
0-1 ROM, DSP, and/or SRAM Mapping (0=Reserved, 1=GSU, 2=LoROM, 3=HiROM)
2-3 SRAM Base (in 32Kbyte units) (range 0..3)
4 GSU Slot (0=Slot0, 1=Slot1)
5 Zero/Unused?
6-7 SRAM Size (0=2K, 1=8K, 2=Reserved, 3=32K)
;------------------
grom_function_entrypoint:
0030 B7 or a,a ;\
0031 28 01 jr z,@@cont ; exit if a<>00h
0033 C9 ret ;
@@cont: ;/
0034 DD 21 00 00 ld ix,0000 ;\set ix=bc
0038 DD 09 add ix,bc ;/
003A DD 4E 00 ld c,[ix+00] ;-(c=[ix+0] for below)
003D DD 46 01 ld b,[ix+01] ;-b=ROM Socket (b=[ix+0]) (bit0-1)
0040 79 ld a,c ;=[ix+00] ;\
0041 B7 or a,a ; ROM Slot
0042 28 04 jr z,@@cont2 ; if [ix+0]<>0 then b=b or 04h
0044 3E 04 ld a,04 ;
0046 B0 or a,b ;
0047 47 ld b,a ;
@@cont2: ;/
;- - -
0048 DD 7E 02 ld a,[ix+02] ;(mapmode/speed)
004B DD 56 03 ld d,[ix+03] ;(set/skip flags)
004E DD 6E 06 ld l,[ix+06]
0051 FE 00 cmp a,00
0053 28 08 jr z,005D ;@@ix2_is_00h_or_03h_and_up
0055 FE 01 cmp a,01
0057 28 0C jr z,0065 ;@@ix2_is_01h
0059 FE 02 cmp a,02
005B 28 10 jr z,006D ;@@ix2_is_02h
@@ix2_is_00h_or_03h_and_up: ;\
005D 78 ld a,b ; if [ix+2]=00h or [ix+2]>2
005E F6 00 or a,00 ;blah ; b=b OR 00h ;\LoROM
0060 47 ld b,a ; c=02h ;/
0061 0E 02 ld c,02 ;
0063 18 18 jr 007D ;@@ix2_done ;/
@@ix2_is_01h: ;\
0065 78 ld a,b ; if [ix+2]=01h
0066 F6 80 or a,80 ; b=b OR 80h ;\HiROM
0068 47 ld b,a ; c=03h ;/
0069 0E 03 ld c,03 ;
006B 18 10 jr 007D ;@@ix2_done ;/
@@ix2_is_02h: ;\
006D 78 ld a,b ; if [ix+2]=02h
006E F6 00 or a,00 ;blah ; b=b OR 00h ;\
0070 47 ld b,a ; if [ix+0]=00h ; LoROM
0071 DD 7E 00 ld a,[ix+00] ; c=01h ;slot0 ; GSU
0074 B7 or a,a ; else ;
0075 28 04 jr z,007B ;@@set_c_01h ; c=11h ;slot1 ;/
0077 0E 11 ld c,11 ;
0079 18 02 jr 007D ;@@ix2_done ;
@@set_c_01h: ;
007B 0E 01 ld c,01 ;/
@@ix2_done:
;- - -
007D 7A ld a,d ;=[ix+03]
007E E6 01 and a,01
0080 28 69 jr z,00EB ;@@skip_part1 -----> skip SRAM part !!!
;- - -
0082 7D ld a,l ;=[ix+06] ;\SRAM Slot Part I
0083 E6 01 and a,01 ;
0085 B7 or a,a ;blah ; If SRAM exists in
0086 28 04 jr z,008C ; Slot1, then "default"
0088 CB E0 set 4,b ; to that slot
008A 18 02 jr 008E ;
@@ ; B.Bit4 = [ix+6].Bit0
008C CB A0 res 4,b ;
@@ ;/
008E CB D8 set 3,b ;-SRAM Enable (B.Bit3=1)
;- - -
0090 7B ld a,e ;=incoming "E=[ix+5]" ;\SRAM Slot Part II
0091 E6 04 and a,04 ;
0093 28 0E jr z,00A3 ;@@incoming_e_done ; If SRAM bank 4..7,
0095 7D ld a,l ;=[ix+06] ;slot1 ; and SRAM exists in
0096 E6 01 and a,01 ; BOTH Slots, then
0098 28 09 jr z,00A3 ;@@incoming_e_done ; change above "default"
009A DD 7E 07 ld a,[ix+07] ;slot0 ; to Slot 0
009D E6 01 and a,01 ;
009F 28 02 jr z,00A3 ;@@incoming_e_done ;
00A1 CB A0 res 4,b ;
@@incoming_e_done: ;/
;- - -
00A3 DD 7E 04 ld a,[ix+04] ;... SRAM size
00A6 FE 01 cmp a,01
00A8 28 08 jr z,00B2 ;@@ix4_is_01h_or_other_value
00AA FE 03 cmp a,03
00AC 28 0A jr z,00B8 ;@@ix4_is_03h
00AE FE 05 cmp a,05
00B0 28 0C jr z,00BE ;@@ix4_is_05h
@@ix4_is_01h_or_other_value: ;\
00B2 CB B9 res 7,c ; if [ix+4]=01h (or 00h,02h,04h, or 06h..FFh)
00B4 CB B1 res 6,c ; then C.Bit7-6 = 0
00B6 18 0A jr 00C2 ;@@ix4_done ;/
@@ix4_is_03h: ;\
00B8 CB B9 res 7,c ; if [ix+4]=03h
00BA CB F1 set 6,c ; then C.Bit7-6 = 1
00BC 18 04 jr 00C2 ;@@ix4_done ;/
@@ix4_is_05h: ;\
00BE CB F9 set 7,c ; if [ix+4]=03h
00C0 CB F1 set 6,c ; then C.Bit7-6 = 3
@@ix4_done: ;/
;- - -
00C2 DD 7E 05 ld a,[ix+05] ;... SRAM base
;GLITCH: should do "AND A,03" here (strip "SLOT"-bit)
00C5 FE 00 cmp a,00
00C7 28 0C jr z,00D5 ;@@ix5_is_00h_or_other_value
00C9 FE 01 cmp a,01
00CB 28 0E jr z,00DB ;@@ix5_is_01h
00CD FE 02 cmp a,02
00CF 28 10 jr z,00E1 ;@@ix5_is_02h
00D1 FE 03 cmp a,03
00D3 28 12 jr z,00E7 ;@@ix5_is_03h
@@ix5_is_00h_or_other_value: ;\
00D5 CB 99 res 3,c ; if [ix+5]=00h (or 04h..FFh)
00D7 CB 91 res 2,c ; then C.Bit3-2 = 0
00D9 18 10 jr 00EB ;@@ix5_done ;/
@@ix5_is_01h: ;\
00DB CB 99 res 3,c ; if [ix+5]=01h
00DD CB D1 set 2,c ; then C.Bit3-2 = 1
00DF 18 0A jr 00EB ;@@ix5_done ;/
@@ix5_is_02h: ;\
00E1 CB D9 set 3,c ; if [ix+5]=02h
00E3 CB 91 res 2,c ; then C.Bit3-2 = 2
00E5 18 04 jr 00EB ;@@ix5_done ;/
@@ix5_is_03h: ;\
00E7 CB D9 set 3,c ; if [ix+5]=03h
00E9 CB D1 set 2,c ; then C.Bit3-2 = 3
@@ix5_done: ;/
;- - -
@@skip_part1:
;- - -
00EB 7A ld a,d ;=[ix+03] ;\
00EC E6 02 and a,02 ; skipped if no DSP ?
00EE 28 0E jr z,00FE ;@@skip_part2 ;
00F0 7D ld a,l ;=[ix+06] ;
00F1 E6 02 and a,02 ; if [ix+3].Bit1=1
00F3 B7 or a,a ;blah ; B.Bit6 = [ix+6].Bit1
00F4 28 04 jr z,00FA ; B.Bit5 = 1
00F6 CB F0 set 6,b ;
00F8 18 02 jr 00FC ;
@@ ;
00FA CB B0 res 6,b ;DSP slot ;
@@ ;
00FC CB E8 set 5,b ;DSP enable ;
@@skip_part2: ;/
;- - -
00FE 78 ld a,b ;\
00FF DD 77 08 ld [ix+08],a ;
0102 ED 39 C0 out0 [C0],a ;/
0105 79 ld a,c ;\
0106 DD 77 09 ld [ix+09],a ;
0109 ED 39 C1 out0 [C1],a ;/
010C C9 ret