Code: Select all
org $000200
START:
;------------------------------------------------------------------------------
; First things first: Satisfy the TMSS.
;------------------------------------------------------------------------------
move.b ($A10001),d0 ; Get System Type.
andi.b #$F,d0 ; If it isn't type 0...
beq.b .0 ; ...
move.l #'SEGA',($A14000) ; ...write "SEGA" to TMSS register.
.0: ;
move.w #$2700,sr ; Disable Interrupts.
;------------------------------------------------------------------------------
; Initialize Joypads.
;------------------------------------------------------------------------------
moveq #$40,d0 ; Load the value $40.
lea $A10009,a0 ; Point to $A10009.
move.b d0,(a0) ; Write $40 to $A10009.
move.b d0,2(a0) ; Write $40 to $A1000B.
move.b d0,4(a0) ; Write $40 to $A1000D.
;------------------------------------------------------------------------------
; Initialize VDP Registers.
;------------------------------------------------------------------------------
lea $C00000,a0 ; Load VDP Data Port.
lea 4(a0),a1 ; Load VDP Control Port.
move.w #$8000,d0 ; Load Register Command.
moveq #22,d1 ; Initialize Loop Counter.
lea .2(pc),a2 ; Point to Register Data.
.1: ;
move.b (a2)+,d0 ; Get Value.
move.w d0,(a1) ; Load Value into Register.
add.w #$100,d0 ; Increment Register.
dbra d1,.1 ; Loop for next Register.
bra.b .3 ; Branch to next code.
.2: ;
dc.b $06 ; Register $80
dc.b $74 ; Register $81
dc.b $30 ; Register $82
dc.b $2C ; Register $83
dc.b $07 ; Register $84
dc.b $56 ; Register $85
dc.b $00 ; Register $86
dc.b $00 ; Register $87
dc.b $00 ; Register $88
dc.b $00 ; Register $89
dc.b $FF ; Register $8A
dc.b $00 ; Register $8B
dc.b $81 ; Register $8C
dc.b $2A ; Register $8D
dc.b $00 ; Register $8E
dc.b $02 ; Register $8F
dc.b $11 ; Register $90
dc.b $00 ; Register $91
dc.b $00 ; Register $92
dc.b $00 ; Register $93
dc.b $00 ; Register $94
dc.b $00 ; Register $95
dc.b $00 ; Register $96
dc.b $00 ; Register $97 - Doesn't need to be initialized
.3: ;
;------------------------------------------------------------------------------
; Clear CRAM.
;------------------------------------------------------------------------------
moveq #0,d0 ; Load 0 value.
moveq #$1F,d1 ; Initialize Loop Counter.
move.l #$C0000000,(a1) ; Point to Beginning of VRAM.
.6: ;
move.l d0,(a0) ; Clear out CRAM.
dbra d1,.6 ; Loop for next iteration.
;------------------------------------------------------------------------------
; Clear VRAM.
;------------------------------------------------------------------------------
lsr.w #2,d1 ; Initialize Loop Counter.
move.l #$40000000,(a1) ; Point to Beginning of VRAM.
.4: ;
move.l d0,(a0) ; Clear out VRAM.
dbra d1,.4 ; Loop for next iteration.
;------------------------------------------------------------------------------
; Clear RAM.
;------------------------------------------------------------------------------
move.l d0,a6 ; Point to End of RAM.
lsr.w #2,d1 ; Initialize Loop Counter.
.5: ;
move.l d0,-(a6) ; Clear out RAM.
dbra d1,.5 ; Loop for next iteration.
;------------------------------------------------------------------------------
; Clear Registers.
;------------------------------------------------------------------------------
movem.l (a6)+,d0-a7 ; Clear all registers.
sub.l a6,a6 ;
move.l a0,usp ; Clear USP.
move.w #$2000,sr ; Enable Interrupts.