; This is designed to be serial-line downloaded to cdcode. ; ; Our memory map: ; ; [8c000000,8c010000) Stack (r15 set by cdcode) ; [8c010000,8c01????) cdcode ; [8c020000,8c030000) our data segment ; [8c030000,8c03????) our text segment .include "regs.s" .include "maple-bits.s" . = 0x8c020000 .align 32 cmds: .long [0 << XDESC_PORTSHIFT] | [1 << XDESC_LENSHIFT] .long iresp & DMA_ADDRMASK MapleFrame CMD_GETCOND, 0, ADDR_MAIN, 0, 0, 1 .long @BSL[FUNC_CONTROLLER] .long XDESC_LAST | [0 << XDESC_PORTSHIFT] | [[[2f-1f]/4] << XDESC_LENSHIFT] .long oresp & DMA_ADDRMASK MapleFrame CMD_BLOCKWRITE, 0, ADDR_SUB1, 0, 0, [2f-1f]/4 1: .long @BSL[FUNC_LCD] .long 0 ocopy: .space 192 2: .align 32 iresp: .space 1024 oresp: .space 1024 .align 4 curistate: .space 8 previstate: .space 8 obuf: .space 192 . = 0x8c030000 ; 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. bsr init_hw nop 1: bsr start_cmds nop bsr game_tick nop bsr await_cmds nop bsr copy_istate nop bsr nbgetchar nop cmp/pz r0 bf 1b 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: SETS.L #curistate,r1 SETS.L #previstate,r2 SETS.L #0x0000ffff,r3 mov.l r3,@r1 mov.l r3,@r2 SETS.L #0x80808080,r3 mov.l r3,@(4,r1) mov.l r3,@(4,r2) 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 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) 4553206d - wtf? 4553206d 4553206d 1c010005 0e000000 - func (clock, LCD, memory card) 403f7e7e - clock info 00100500 - LCD info 00410f00 - memory card info ff - area code 00 - connector direction 6956 - product name 6c617573 6d654d20 2079726f 20202020 20202020 20202020 20202020 646f7250 - product license 64656375 20794220 5520726f 7265646e 63694c20 65736e65 6f724620 4553206d 45204147 5245544e 53495250 4c2c5345 202e4454 20202020 007c - standby power (124) 0082 - max power (130) 4553206d - wtf? 4553206d 4553206d 03210008 01000000 0000ffff 80808080 .endif