; This is designed to be serial-line downloaded to cdcode. ; ; Our memory map: ; ; [8c000000,8c010000) Stack (r15 set by cdcode) ; [8c010000,8c01????) cdcode ; [8c020000,8c02????) Us .include "regs.s" .include "maple-bits.s" DELAY_TIME = 10000000 . = 0x8c020000 .sz any .pr any SETS.L #main,r0 jmp @r0 nop SETCONST ; Our "data segment". .align 32 cmd_first: .long XDESC_LAST | [0 << XDESC_PORTSHIFT] | [0 << XDESC_LENSHIFT] .long resp & DMA_ADDRMASK MapleFrame CMD_DEVINFO, 0, ADDR_MAIN, 0, 0, 0 .align 32 cmd_repeat: .long XDESC_LAST | [0 << XDESC_PORTSHIFT] | [1 << XDESC_LENSHIFT] .long resp & DMA_ADDRMASK MapleFrame CMD_GETCOND, 0, ADDR_MAIN, 0, 0, 1 .long @BSL[FUNC_CONTROLLER] .align 32 resp: .space 1024 ; Destroys r0 delay: SETS.L #DELAY_TIME,r0 1: dt r0 bf 1b nop rts nop crlf: sts.l pr,@-r15 bsr putchar mov #13,r1 bsr putchar mov #10,r1 lds.l @r15+,pr rts nop ; The only things startup.s sets up that cdcode hasn't already done for ; us are (1) fpscr and (2) clearing bss. We don't have bss because we ; aren't linked by a conventional linker, and we don't use floating ; point so we don't care about fpscr. So we have nothing to do here. ; Just dive straight into the code. .align 2 main: bsr init_hw nop SETS.L #cmd_first,r0 bsr do_cmd nop bsr print_state nop bsr crlf nop ; lds r11,pr ; rts ; nop 1: bsr delay nop SETS.L #cmd_repeat,r0 bsr do_cmd nop bsr print_state nop bsr nbgetchar nop cmp/pz r0 bf 1b bsr crlf nop lds r11,pr rts nop init_hw: mova 9f,r0 1: mov.l @r0+,r1 tst r1,r1 bt 1f mov.l @r0+,r2 bra 1b mov.l r2,@r1 1: rts nop .align 4 9: .long BUS_RESET, BUS_RESET_VALUE .long BUS_RESET2, BUS_RESET2_VALUE .long BUS_SPEED, SPEED_2MBPS|[50000< 2 no < 2 no v 2 no ^ 2 no D no X yes Y yes Z no > yes < yes v yes ^ yes START yes A yes B yes C no CMD_EXTINFO on ADDR_MAIN on a controller on port A with a VMU in the top socket returns: 06 - RESP_EXTINFO 00 - receiving ID (port 0, Dreamcast) 21 - sending ID (port 0, ADDR_MAIN | ADDR_SUB1) 30 - count of following words 01000000 - func (controller) 00003021 - controller info 00000000 - unused 00000000 - unused ff - area code 00 - connector direction 7244 - product name ("Dreamcast Controller ") 636d6165 20747361 746e6f43 6c6c6f72 20207265 20202020 20202020 646f7250 - product license ("Produced By or Under License From SEGA ENTERPRISES,LTD. ") 64656375 20794220 5520726f 7265646e 63694c20 65736e65 6f724620 4553206d 45204147 5245544e 53495250 4c2c5345 202e4454 20202020 01ae - standby power (430) 01f4 - max power (500) 73726556 - versionstring ("Version 1.000,1998/05/11,315-6125-AB ,Analog Module : The 4th Edition. 05/08 ") 206e6f69 30302e31 39312c30 302f3839 31312f35 3531332c 3231362d 42412d35 2c202020 6c616e41 4d20676f 6c75646f 203a2065 20656854 20687434 74696445 2e6e6f69 2f353020 20203830 CMD_EXTINFO on ADDR_SUB1 on a controller on port A with a VMU in the top socket returns: 06 - RESP_EXTINFO 00 - receiving ID (port 0, Dreamcast) 01 - sending ID (port 0, ADDR_SUB1) 30 - count of following words 0e000000 - func (clock, LCD, memory) 403f7e7e - clock info 00100500 - LCD info 00410f00 - memory card info ff - region code 00 - connector direction 6956 - product name ("Visual Memory ") 6c617573 6d654d20 2079726f 20202020 20202020 20202020 20202020 646f7250 - product license ("Produced By or Under License From SEGA ENTERPRISES,LTD. ") 64656375 20794220 5520726f 7265646e 63694c20 65736e65 6f724620 4553206d 45204147 5245544e 53495250 4c2c5345 202e4454 20202020 007c - standby power (124) 0082 - max power (130) 73726556 - versionstring ("Version 1.005,1999/10/26,315-6208-05,SEGA Visual Memory System BIOS Produced by ") 206e6f69 30302e31 39312c35 312f3939 36322f30 3531332c 3032362d 35302d38 4745532c 69562041 6c617573 6d654d20 2079726f 74737953 42206d65 20534f49 646f7250 64656375 20796220 CMD_DEVINFO on ADDR_MAIN on a keyboard on port B: 05 - RESP_DEVINFO 40 - receiving ID (port 1, Dreamcast) 60 - sending ID (port 1, ADDR_MAIN) 1c - count of following words 40000000 - func (keyboard) 80000502 - keyboard info (02 - US keyboard) 00000000 - unused 00000000 - unused 01 - region code 00 - connector direction 654b - product name ("Keyboard ") 616f6279 20206472 20202020 20202020 20202020 20202020 20202020 646f7250 - product license ("Produced By or Under License From SEGA ENTERPRISES,LTD. ") 64656375 20794220 5520726f 7265646e 63694c20 65736e65 6f724620 4553206d 45204147 5245544e 53495250 4c2c5345 202e4454 20202020 012c - standby power (300) 0190 - max power (400) CMD_GETCOND on ADDR_MAIN on a keyboard on port B: 08 - RESP_DATA 40 - receiving ID (port 1, Dreamcast) 60 - sending ID (port 1, ADDR_MAIN) 03 - count 40000000 - func (keyboard) 00 - shift state 0x01 - left Ctrl 0x02 - left Shift 0x04 - left Alt 0x08 - (left) S1 0x10 - right Ctrl 0x20 - right Shift 0x40 - right Alt 0x80 - (right) S2 00 - LED state (?) 0000 - up to 6 keys down; any value < 4 terminates the list 00000000 04 A 05 B 06 C 07 D 08 E 09 F 0a G 0b H 0c I 0d J 0e K 0f L 10 M 11 N 12 O 13 P 14 Q 15 R 16 S 17 T 18 U 19 V 1a W 1b X 1c Y 1d Z 1e 1 ! 1f 2 @ 20 3 # 21 4 $ 22 5 % 23 6 ^ 24 7 & 25 8 * 26 9 ( 27 0 ) 28 Enter 29 Esc 2a Backspace 2b Tab 2c space 2d - _ 2e = + 2f [ { 30 ] } 31 \ | 33 ; : 34 ' " 35 ` ~ 36 , < 37 . > 38 / ? 39 CapsLock 3a F1 3b F2 3c F3 3d F4 3e F5 3f F6 40 F7 41 F8 42 F9 43 F10 44 F11 45 F12 46 PrtScr/SysRq 47 ScrollLock 48 Pause/Break 49 Insert 4a Home 4b PageUp 4c Delete 4d End 4e PageDown 4f rightarrow 50 leftarrow 51 downarrow 52 uparrow 53 NumLock 54 (keypad) / 55 (keypad) * 56 (keypad) - 57 (keypad) + 58 (keypad) Enter 59 (keypad) 1 5a (keypad) 2 5b (keypad) 3 5c (keypad) 4 5d (keypad) 5 5e (keypad) 6 5f (keypad) 7 60 (keypad) 8 61 (keypad) 9 62 (keypad) 0 63 (keypad) . 65 S3 .endif