Manual complement Probably the biggest WTF in the main docs is the complete lack of information on how to read the controller. No, seriously - it says how to access the I/O ports, but it completely forgets to mention how the standard controller is meant to be read. I guess Sega just assumed that developers would use the subroutine in the Logo Demo. That said, the "Genesis Technical Bulletin #28" makes a mention to a complement manual: I never saw any such doc. Am I missing something or that one hasn't been leaked yet? RAM disk In the "Genesis Technical Bulletin #4", the following code can be found: Code (ASM): ;*******************************************************; ; ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; ; input a6.l = controller port address ; ; output d7.b == $00 Modem ; ; $0d Mega Drive Joy Stick ; ; $0e Ram Disk ; ; $0f ETC. or None ; ; use d0,a0 ; ;*******************************************************; RAM disk? Huh? o_O At first I thought it could have been a generic drive thingy. For instance, the bit in $A10001 that was meant to indicate the presence of a floppy drive later got reused to indicate the presence of a Mega CD. Now, of course, the Mega CD is not connected to any of the standard I/O ports... and in fact, I can't think on any drive-like device that does. Does anybody know anything about this? To make it worse, the subroutine code is incomplete, at least in the copy I have. Maybe somebody else has the full code. Here's what I have of the code (which is as useless as shit): Code (ASM): cont set $0006 con_port: movem.l d1-d2/a5,-(sp) ; register push dis z80_diw lea ??and_data(pc),a5 ; data table address set move.b (a5),cont(a6) ; Th bit set output moveq.l #0,d7 ; rerturn register initial moveq.l #$08,d1 ; counter set Can somebody look for that piece of code in the leaked devkits, please? (sidenote: "con_port" may be wrong, the second and third letters are unreadable...) Wordram at $600000? In the 32x runlength demo, the following piece of code is in "68K/MD.I": Code (ASM): wordram equ $600000 What the fuck? First I checked the 32x docs just in case, and indeed there is no memory at that address (at least, documented). I noticed that the SH2 RAM addresses are at a similar place... except it's $6000000, not $600000. Also, this file is used by the 68k code, not SH2 code. All other addresses in the file seem to be OK as well... Oh, and a last thing: the 68k code never references this label, at all. Was the 32x planned to have extra 68k RAM at some point, maybe? Sega Subor System Cartridge There is one ROM image floating around labeled "Sega Subor System Cartridge (Unl).bin". If you try to run it, the program will not boot. When I tried this, the first thing I thought was that the program required custom hardware, just like about every single unlicensed crap out there =/ But then I checked into the ROM image, and huh... Code (Text): $000100 ... 4145 4141 004D 4547 0020 4052 4056 0020 AEAA.MEG. @R@V. $000110 ... 0043 0858 5858 0020 3030 3030 0444 4143 .C.XXX. 0000.DAC $000120 ... 8081 9397 809E 8888 0020 8080 9092 8088 ......... ...... $000130 ... 8486 2020 2020 2020 2020 2020 2020 2020 .. $000140 ... 2020 2020 2020 2020 2020 2020 2020 2020 $000150 ... 4445 4052 4849 4647 0053 4454 2020 2020 [email protected] $000160 ... 2020 2020 2020 2020 2020 2020 2020 2020 $000170 ... 2020 2020 2020 2020 2020 2020 2020 2020 $000180 ... 454D 2030 3030 3030 3030 202D 3030 0000 EM 0000000 -00.. $000190 ... 0020 2020 2020 2020 2020 2020 2020 2020 . $0001A0 ... 0000 0000 0004 0000 00FF 0000 00FF FFFF ................ $0001B0 ... 2020 2020 2020 2020 2020 2020 2020 2020 $0001C0 ... 2020 2020 2020 2020 2020 2020 2020 2020 $0001D0 ... 2020 2020 2020 2020 2020 2020 2020 2020 $0001E0 ... 2020 2020 2020 2020 2020 2020 2020 2020 $0001F0 ... 4055 0020 2020 2020 2020 2020 2020 2020 @U. Looks like a bad dump. Does anybody know if there's a good dump of this thing?
I don't know much about the other stuff, but I think I can answer this question: I believe this is the 256K Word Ram for the Sega CD when a cartridge is running. According to a Sega CD manual I read and Mask of Destiny's Transfer Suite website, there is a pin in the cartridge, B32 to be exact, that determines whether to boot from the cartridge or the expansion port, where the Sega CD is connected. When it is high, it boots the cartridge and sets the expansion port's memory to the next 4MB. When the pin is low (used for Sega CD ram expansions), they are swapped. Since the Word Ram starts at address $200000 when the Sega CD boots, it would make sense to start at address $200000 + $400000, or $600000, when a cartridge boots.
I do believe this is correct. As to the controllers, SEGA put out some sample code which isn't very good, so most devs just make their own. Here's my controller code for 3 button, 6 button, and the MegaMouse - feel free to use it as you wish. Code (Text): | get current pad value | entry: a0 = pad control port | exit: d2 = pad value (0 0 0 1 M X Y Z S A C B R L D U) or (0 0 0 0 0 0 0 0 S A C B R L D U) get_pad: bsr.b get_input /* - 0 s a 0 0 d u - 1 c b r l d u */ move.w d0,d1 andi.w #0x0C00,d0 bne.b no_pad bsr.b get_input /* - 0 s a 0 0 d u - 1 c b r l d u */ bsr.b get_input /* - 0 s a 0 0 0 0 - 1 c b m x y z */ move.w d0,d2 bsr.b get_input /* - 0 s a 1 1 1 1 - 1 c b r l d u */ andi.w #0x0F00,d0 /* 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 */ cmpi.w #0x0F00,d0 beq.b common /* six button pad */ move.w #0x010F,d2 /* three button pad */ common: lsl.b #4,d2 /* - 0 s a 0 0 0 0 m x y z 0 0 0 0 */ lsl.w #4,d2 /* 0 0 0 0 m x y z 0 0 0 0 0 0 0 0 */ andi.w #0x303F,d1 /* 0 0 s a 0 0 0 0 0 0 c b r l d u */ move.b d1,d2 /* 0 0 0 0 m x y z 0 0 c b r l d u */ lsr.w #6,d1 /* 0 0 0 0 0 0 0 0 s a 0 0 0 0 0 0 */ or.w d1,d2 /* 0 0 0 0 m x y z s a c b r l d u */ eori.w #0x1FFF,d2 /* 0 0 0 1 M X Y Z S A C B R L D U */ rts no_pad: move.w #0xF000,d2 rts | read single phase from controller get_input: move.b #0x00,(a0) nop nop move.b (a0),d0 move.b #0x40,(a0) lsl.w #8,d0 move.b (a0),d0 rts | get current mouse value | entry: a0 = mouse control port | exit: d0 = mouse value (0 0 0 0 0 0 0 0 YO XO YS XS S M R L X7 X6 X5 X4 X3 X2 X1 X0 Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0) or -2 (timeout) or -1 (no mouse) get_mky: move.w sr,d2 move.w #0x2700,sr /* disable ints */ move.b #0x60,6(a0) /* set direction bits */ nop nop move.b #0x60,(a0) /* first phase of mouse packet */ nop nop 0: btst #4,(a0) beq.b 0b /* wait on handshake */ move.b (a0),d0 andi.b #15,d0 bne mky_err /* not 0 means not mouse */ move.b #0x20,(a0) /* next phase */ move.w #254,d1 /* number retries before timeout */ 1: btst #4,(a0) bne.b 2f /* handshake */ dbra d1,1b bra timeout_err 2: move.b (a0),d0 andi.b #15,d0 move.b #0,(a0) /* next phase */ cmpi.b #11,d0 bne mky_err /* not 11 means not mouse */ 3: btst #4,(a0) beq.b 4f /* handshake */ dbra d1,3b bra timeout_err 4: move.b (a0),d0 /* specs say should be 15 */ nop nop move.b #0x20,(a0) /* next phase */ nop nop 5: btst #4,(a0) bne.b 6f dbra d1,5b bra timeout_err 6: move.b (a0),d0 /* specs say should be 15 */ nop nop move.b #0,(a0) /* next phase */ moveq #0,d0 /* clear reg to hold packet */ nop 7: btst #4,(a0) beq.b 8f /* handshake */ dbra d1,7b bra timeout_err 8: move.b (a0),d0 /* YO XO YS XS */ move.b #0x20,(a0) /* next phase */ lsl.w #8,d0 /* save nibble */ 9: btst #4,(a0) bne.b 10f /* handshake */ dbra d1,9b bra timeout_err 10: move.b (a0),d0 /* S M R L */ move.b #0,(a0) /* next phase */ lsl.b #4,d0 /* YO XO YS XS S M R L 0 0 0 0 */ lsl.l #4,d0 /* YO XO YS XS S M R L 0 0 0 0 0 0 0 0 */ 11: btst #4,(a0) beq.b 12f /* handshake */ dbra d1,11b bra timeout_err 12: move.b (a0),d0 /* X7 X6 X5 X4 */ move.b #0x20,(a0) /* next phase */ lsl.b #4,d0 /* YO XO YS XS S M R L X7 X6 X5 X4 0 0 0 0 */ lsl.l #4,d0 /* YO XO YS XS S M R L X7 X6 X5 X4 0 0 0 0 0 0 0 0 */ 13: btst #4,(a0) bne.b 14f /* handshake */ dbra d1,13b bra timeout_err 14: move.b (a0),d0 /* X3 X2 X1 X0 */ move.b #0,(a0) /* next phase */ lsl.b #4,d0 /* YO XO YS XS S M R L X7 X6 X5 X4 X3 X2 X1 X0 0 0 0 0 */ lsl.l #4,d0 /* YO XO YS XS S M R L X7 X6 X5 X4 X3 X2 X1 X0 0 0 0 0 0 0 0 0 */ 15: btst #4,(a0) beq.b 16f /* handshake */ dbra d1,15b bra timeout_err 16: move.b (a0),d0 /* Y7 Y6 Y5 Y4 */ move.b #0x20,(a0) /* next phase */ lsl.b #4,d0 /* YO XO YS XS S M R L X7 X6 X5 X4 X3 X2 X1 X0 Y7 Y6 Y5 Y4 0 0 0 0 */ lsl.l #4,d0 /* YO XO YS XS S M R L X7 X6 X5 X4 X3 X2 X1 X0 Y7 Y6 Y5 Y4 0 0 0 0 0 0 0 0*/ 17: btst #4,(a0) beq.b 18f /* handshake */ dbra d1,17b bra timeout_err 18: move.b (a0),d0 /* Y3 Y2 Y1 Y0 */ move.b #0x60,(a0) /* first phase */ lsl.b #4,d0 /* YO XO YS XS S M R L X7 X6 X5 X4 X3 X2 X1 X0 Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 0 0 0 0 */ lsr.l #4,d0 /* YO XO YS XS S M R L X7 X6 X5 X4 X3 X2 X1 X0 Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */ 19: btst #4,(a0) beq.b 19b /* wait on handshake */ move.w d2,sr /* restore int status */ rts timeout_err: move.b #0x60,(a0) /* first phase */ nop nop 0: btst #4,(a0) beq.b 0b /* wait on handshake */ move.w d2,sr /* restore int status */ moveq #-2,d0 rts mky_err: move.b #0x40,6(a0) /* set direction bits */ nop nop move.b #0x40,(a0) move.w d2,sr /* restore int status */ moveq #-1,d0 rts If you wish to also use SMS controllers with the same code, replace the code after no_pad: above with this Code (Text): | no pad found, so we're going to ASSUME an SMS (compatible) pad no_pad: lea 0xA10003,a0 move.b (a0),d0 /* - 1 c b r l d u */ andi.w #0x003F,d0 /* 0 0 0 0 0 0 0 0 0 0 c b r l d u */ eori.w #0x003F,d0 /* 0 0 0 0 0 0 0 0 0 0 C B R L D U */ move.l (sp)+,d2 rts
Good catch. It still doesn't explain the RAM disk thing though, which seems to have been coded at some point. That's what I'm interested on right now. By the way, wasn't Sega meant to make a keyboard and a floppy drive, and then dropped the idea because the Mega Modem wasn't popular? I think we may have something there.
Never seen nor heard of the "ram disk". SEGA had a number of ram carts for development, none of which were controlled via the ports.
Can somebody try to localize that code on the leaked devkits, anyways? Also whatever happened to that complement manual? That one would be interesting too.
That IOID code? The only version I've seen is this Code (Text): *---------------------------------------------------------------------------- * _JSID: does initial id checking for I/O devices attached to * joystick id code get * this routine figures out if some kind of controller is * attached to the ports. Essentially distinguishes between * regular controllers(3 but,6but,activator,optical) and * handshaking controllers(mouse,). This identification * scheme is based on Addendum #1 in the Genesis Software Manual * port 1 and 2 on the genesis. * * void _JSID( ) * * in d1.w : port number ( 0..2 ) * * out d0.l : ID * equ $0f * ????? unknown/nothing connected * equ $0d * (MDpad,FP6B) * equ $03 * MOUSE * equ $07 * SEGA TEAM PLAYER * equ $ff * input error(incorrect port number) * * author: NG (SOJ) * MODS * name date comments * ---- -------- ------------------------------------------- * UP 06/29/1993 fixed bugs * UP 01/14/1994 (increased time between each TH transition * based on SOJ MD TECHNICAL INFO #7 01/11/94) * * copyright SEGA OF AMERICA *--------------------------------------------------------------------------- xdef JSID dc.l 0 JSID: cmp.b #3,d1 blt _JSID_10 moveq #-1,d0 rts _JSID_10: movem.l d2-d3/a0,-(sp) Z80di ;disable the Z80 off the bus move.l #$00a10003,a0 moveq #0,d0 move.b d1,d0 add.l d0,d0 adda.l d0,a0 moveq #0,d0 move.l d0,d1 move.b 6(a0),d3; save original status of control port swap d3 move.b (a0),d3 ; original status of I/O port move.b #%01000000,6(a0); I/O control : TH out move.b #%01000000,(a0) ; TH - Hi nop nop nop nop move.b (a0),d0 move.b #%00000000,(a0) ; TH - Low nop nop nop nop move.b (a0),d1 move.b #%01000000,(a0) ; TH - Hi move.w d0,d2 lsr.b #1,d0 ror.w #1,d0 lsr.b #1,d0 rol.w #1,d0 ror.w #1,d2 lsr.b #1,d2 rol.w #1,d2 or.b d2,d0 ;ID2=(PD6=1)&(PD1 OR PD0) and.w #$03,d0 lsl.b #2,d0 move.w d1,d2 lsr.b #1,d1 ror.w #1,d1 lsr.b #1,d1 rol.w #1,d1 ror.w #1,d2 lsr.b #1,d2 rol.w #1,d2 or.b d2,d1 ;ID0=(PD6=0)&(PD1 OR PD0) and.w #$03,d1 or.b d1,d0 ;return id value move.b d3,(a0) ; restore original status of I/O port swap d3 move.b d3,6(a0) ; restore original status of control port Z80ei ; Z80 bus release movem.l (sp)+,d2-d3/a0 rts