Skip to content

Commit

Permalink
Add new init routine
Browse files Browse the repository at this point in the history
  • Loading branch information
gilligan committed Apr 7, 2012
1 parent 12a162d commit 19f8823
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
2 changes: 1 addition & 1 deletion sfckit/lib/Makefile
@@ -1,6 +1,6 @@
include ../snes.rules include ../snes.rules


all: io.o swc.o serial.o dma.o joy.o debug.o snesmod.o assert.o all: io.o swc.o serial.o dma.o joy.o debug.o snesmod.o assert.o init.o


clean: clean:
-rm -rf *.lst *.o .cpp* >/dev/null -rm -rf *.lst *.o .cpp* >/dev/null
38 changes: 16 additions & 22 deletions sfckit/lib/init.asm
Expand Up @@ -7,33 +7,28 @@
.global init_snes .global init_snes


.a8 .a8
.i8 .i16
.smart .smart
.segment "CODE" .segment "CODE"


;---------------------------------------------------------------------- ;----------------------------------------------------------------------
.proc init_snes .proc init_snes
;---------------------------------------------------------------------- ;----------------------------------------------------------------------
pha
phx
phy
php
phd


sei ; disable interrupts .smart
sei ; disable interrupts
clc ; switch to native mode clc ; switch to native mode
xce ; xce ;
rep #38h ; mem/A/X/Y = 16bit rep #38h ; mem/A/X/Y = 16bit / decimal mode off
; decimal mode off ldx #1FFFh ; setup stack pointer

ldx #1FFFh ; setup stack pointer
txs ; txs ;
lda #0000h ; direct page = 0000h lda #0000h ; direct page = 0000h
tcd ; tcd ;
sep #20h ; 8bit A/mem sep #20h ; 8bit A/mem
lda #80h ; data bank = 80h lda #80h ; data bank = 80h
pha ; pha ;
plb ; plb ;
lda $FFD5 ; get map mode lda $FFD5 ; get map mode
lsr ; 21/31 jump to bank C0 lsr ; 21/31 jump to bank C0
bcs :+ ; 20/30 jump to bank 80 bcs :+ ; 20/30 jump to bank 80
Expand All @@ -43,7 +38,7 @@
;---------------------------------------------------------------------- ;----------------------------------------------------------------------
histart: histart:
;---------------------------------------------------------------------- ;----------------------------------------------------------------------

lda $FFD5 ; if map_mode & 10h lda $FFD5 ; if map_mode & 10h
bit #10h ; switch to hi-speed mode bit #10h ; switch to hi-speed mode
beq :+ ; beq :+ ;
Expand Down Expand Up @@ -205,13 +200,12 @@ _empty_data_segment: ;
rep #$38 ; rep #$38 ;
sep #$20 ; 8bit accu / 16bit index sep #$20 ; 8bit accu / 16bit index


pld ;
plp ; all hardware setup is done at this point
ply ;
plx ;
pla jmp main ; jump to main code entry point

;
rts
wram_fill_byte: wram_fill_byte:
.byte $00 .byte $00
Expand Down

0 comments on commit 19f8823

Please sign in to comment.