Skip to content

Instantly share code, notes, and snippets.

@tndata
Last active April 25, 2023 20:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tndata/95b14a32c10a01124ce64f81234715e0 to your computer and use it in GitHub Desktop.
Save tndata/95b14a32c10a01124ce64f81234715e0 to your computer and use it in GitHub Desktop.
Sega MegaDrive hardware development kit firmware source code
* v 1.0 *
* BOOT ROM source for *
* for SEGA MEGADRIVE *
* 1991 Synchron Assembly *
* https://ww.tn-data.se *
**************************************
*sram start FF0000
_final:
ifd _final
dc.l $FFFE00 *Stack pointer
dc.l reset *Program start
org $80008
ENDC
reset:
clr.w $c0000
lea alive(pc),a0
lop: move.b (a0)+,d0
beq ut
bsr send_byte
bra lop
ut:
*wait for datapacket to be stored att $FF0000
lea $ff0000,a5
*get header
bsr receive_byte
cmp.b #$ea,d0
beq.s .ok
.lopaw: move.w d0,$c0000
addq.w #1,d0
bra .lopaw
.ok:
*get len hi, lo
bsr receive_byte
moveq #0,d3
move.b d0,d3
lsl.w #8,d3
bsr receive_byte
move.b d0,d3
mlop:
bsr receive_byte
move.b d0,(a5)+
dbra d3,mlop
move.w #"G",d0
bsr send_byte
move.w #"O",d0
bsr send_byte
jmp $ff0000
alive: dc.b "OK , I am alive, so what do do now!",0
even
*************************************************
*Send byte to Atari ST
*D0=char
send_byte:
and.w #255,d0
bset #8,d0 *Set strobe
move.w d0,$c0000
*wait for Ack high
.no: move.w $c0000,d1
btst #8,d1
beq.s .no
*Clear strobe
and.w #255,d0
move.w d0,$c0000
*wait for Ack low
.no1: move.w $c0000,d1
btst #8,d1
bne.s .no1
rts
*************************************************
*Wait for a byte from the ST, returns in d0
receive_byte:
mulu d1,d1
*wait for strobe high
.no: move.w $c0000,d1
btst #9,d1
beq.s .no
mulu d1,d1
move.w $c0000,d0
and.w #255,d0
*set ack high
moveq #0,d1
bset #9,d1
move.w d1,$c0000
mulu d1,d1
*wait for strobe low
.no1: move.w $c0000,d1
btst #9,d1
bne.s .no1
mulu d1,d1
*set ack low
moveq #0,d1
move.w d1,$c0000
rts
*************************************************
dc.l -1,-1
end
send data
* sega st
*
* write data
* wait for strobe
* set strobe high
*
* wait for ack
* set ack high
*
* wait for strobe low
* strobe low
* set ack low
* wait for ack low
*
*$c0000
*rw 0-7 data
*w 8 Send strobe from Sega To ST
*r 8 Send ack from ST to sega to ack sended byte
*w 9 recieve ack from Sega to ST
*r 9 Send strobe from ST to Sega
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment