processor 65c816 option output-file,"main.lib" option output-format,lib option +address24 org $8000 bank 0 ; Initialise SNES ; include "snes.inc" include "macros.inc" import "tiles.lib",labels import "maps.lib",labels sei clc xce INDEX16 ldx #$1fff txs ACC8 INDEX8 jsr InitSNES cli ; Clear VRAM ; lda #$80 sta VMAIN stz VMADDL stz VMADDH DMA 9,zero,$18,0 ; Copy 4-colour tiles ; stz VMADDL stz VMADDH DMA 1,Col4Tiles,$18,Col4TilesLen ; Copy 16-colour tiles ; stz VMADDL lda #$10 sta VMADDH DMA 1,Col16Tiles,$18,Col16TilesLen ; Copy sprites ; stz VMADDL lda #$a0 sta VMADDH DMA 1,SpriteData,$18,SpriteDataLen ; Copy palette ; stz CGADD DMA 0,PaletteData,$22,PaletteDataLen ; Copy BG3 ; copybg3: INDEX16 ldx #$0 ldy #32*32 stz VMADDL lda #$40 sta VMADDH .loop lda BG3Map,x sta VMDATAL stz VMDATAH inx dey bne loop X8 ; Initialise the screen ; lda #$01 sta BGMODE lda #$1f sta TM lda #$44 sta BG12NBA stz BG34NBA lda #$60 sta BG1SC lda #$80 sta BG2SC lda #$40 sta BG3SC lda #$0f sta INIDISP ; Loop forever. Forever: jmp Forever InitSNES: lda #$8F sta INIDISP stz OBSEL stz OAMADDL stz OAMADDH stz BGMODE stz MOSAIC stz BG1SC stz BG2SC stz BG3SC stz BG4SC stz BG12NBA stz BG34NBA stz BG1VOFS stz BG1VOFS stz BG2VOFS stz BG2VOFS stz BG3VOFS stz BG3VOFS stz BG4VOFS stz BG4VOFS stz BG1HOFS stz BG1HOFS stz BG2HOFS stz BG2HOFS stz BG3HOFS stz BG3HOFS stz BG4HOFS stz BG4HOFS lda #$80 sta VMAIN stz VMADDL stz VMADDH stz M7SEL stz M7A lda #$01 sta M7A stz M7B stz M7B stz M7C stz M7C stz M7D sta M7D stz M7X stz M7X stz M7Y stz M7Y stz CGADD stz W12SEL stz W34SEL stz WOBJSEL stz WH0 stz WH1 stz WH2 stz WH3 stz WBGLOG stz WOBJLOG sta TM stz TS stz TMW stz TSW lda #$30 sta CGWSEL stz CGADSUB lda #$E0 sta COLDATA stz SETINI stz NMITIMEN lda #$FF sta WRIO stz WRMPYA stz WRMPYB stz WRDIVL stz WRDIVH stz WRDIVB stz HTIMEL stz HTIMEH stz VTIMEL stz VTIMEH stz MDMAEN stz HDMAEN stz MEMSEL rts ; IRQ vectors ; vbl_handler: rti irq_handler: rti zero: db 0