.include "header.inc" .include "snes_init.asm" .BANK 0 SLOT 0 .org 0 .section "Vblank" VBlank: rti .ENDS .BANK 0 SLOT 0 .ORG 0 .section "Main" Start: Snes_Init ; 16-bit xy, 8-bit a rep #%00010000 sep #%00100000 ldx #$0000 - lda UntitledPalette.l, x sta $2122 inx cpx #8 bne - lda #33 sta $2121 lda.l Palette2 sta $2122 lda.l Palette2 + 1 sta $2122 ldx #UntitledData lda #:UntitledData ldy #(15*16*2) ;$43X0 is DMA register X, X from 0 to 7 stx $4302 ;A address low byte sta $4304 ;A address bank sty $4305 ;number of bytes to transfer lda #%00000001 ;set mode transfer words sta $4300 lda #$18 ; $211[89]: VRAM data write sta $4301 ; set destination ldy #$0000 sty $2116 lda #%00000001 sta $420b ;start DMA ; write to BG1 lda #%10000000 ; VRAM writing mode sta $2115 ldx #$4000 stx $2116 ; write to VRAM ;ugly code starts here - it writes the # shape I mentioned before. .rept 2 ;X|X|X .rept 2 ldx #$0000 ; tile 0 ( ) stx $2118 ldx #$0002 ; tile 2 (|) stx $2118 .endr ldx #$0000 stx $2118 ;first line finished, add BG's .rept 27 stx $2118 ; X=0 .endr ;beginning of 2nd line ;-+-+- .rept 2 ldx #$0004 ; tile 4 (-) stx $2118 ldx #$0006 ; tile 6 (+) stx $2118 .endr ldx #$0004 ; tile 4 (-) stx $2118 ldx #$0000 .rept 27 stx $2118 .endr .endr .rept 2 ldx #$0000 ; tile 0 ( ) stx $2118 ldx #$0002 ; tile 2 (|) stx $2118 .endr ; BG2 starts at $6000 ldx #$6000 stx $2116 ldx #$000c ;and contains one tile stx $2118 ;data for VRAM write register ; set up the screen lda #%00110000 ; 16x16 tiles, mode 0 sta $2105 lda #%01000000 ; data starts from $4000 sta $2107 ; for bg1 lda #%0110000 ; and $6000 sta $2108 ; for bg2 stz $210b ; BG1 and BG2 use the $0000 tiles lda #%00000011 ; enable bg1 and 2 sta $212C ;The PPU doesn't process the top line, so we scroll down 1 line. rep #$20 ; 16bit a lda #$07FF ; this is -1 for BG1 sep #$20 ; 8bit a sta $210E ; BG1 vert scroll xba sta $210E rep #$20 ; 16bit a lda #$FFFF ; this is -1 for BG2 sep #$20 ; 8bit a sta $2110 ; BG2 vert scroll xba sta $2110 lda #%00001111 ; enable screen, set brightness to 15 sta $2100 lda #%10000001 ; enable NMI and joypads sta $4200 ;sep #$30 ; get 8-bit registers ;stz $2121 ; write to CGRAM from $0 ;lda #%10000000 ; this is ;ldx #%00111100 ; a green color ;sta $2122 ; write it ;stx $2122 ; to CGRAM ;lda #%00001111 ; turn on screen ;sta $2100 ; here mainloop: jmp mainloop .ENDS .BANK 1 SLOT 0 .org 0 .section "TileData" UntitledData: .db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 .db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 .db $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03 .db $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0 .db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $FF, $FF, $FF, $FF .db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $FF, $FF, $FF, $FF .db $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $FF, $FF, $FF, $FF .db $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $FF, $FF, $FF, $FF .db $00, $C0, $00, $E0, $00, $70, $00, $38, $00, $1C, $00, $0E, $00, $07, $00, $03 .db $00, $03, $00, $07, $00, $0E, $00, $1C, $00, $38, $00, $70, $00, $E0, $00, $C0 .db $00, $07, $00, $0F, $00, $18, $00, $30, $00, $60, $00, $C0, $00, $C0, $00, $C0 .db $00, $E0, $00, $F0, $00, $18, $00, $0C, $00, $06, $00, $03, $00, $03, $00, $03 .db $FC, $00, $F8, $00, $F0, $00, $E0, $00, $C0, $00, $80, $00, $00, $00, $00, $00 .db $3F, $00, $1F, $00, $0F, $00, $07, $00, $03, $00, $01, $00, $00, $00, $00, $00 .db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 .db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 .db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 .db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 .db $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03 .db $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0 .db $FF, $FF, $FF, $FF, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 .db $FF, $FF, $FF, $FF, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 .db $FF, $FF, $FF, $FF, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03, $03 .db $FF, $FF, $FF, $FF, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0 .db $00, $03, $00, $07, $00, $0E, $00, $1C, $00, $38, $00, $70, $00, $E0, $00, $C0 .db $00, $C0, $00, $E0, $00, $70, $00, $38, $00, $1C, $00, $0E, $00, $07, $00, $03 .db $00, $C0, $00, $C0, $00, $C0, $00, $60, $00, $30, $00, $18, $00, $0F, $00, $07 .db $00, $03, $00, $03, $00, $03, $00, $06, $00, $0C, $00, $18, $00, $F0, $00, $E0 .db $00, $00, $00, $00, $80, $00, $C0, $00, $E0, $00, $F0, $00, $F8, $00, $FC, $00 .db $00, $00, $00, $00, $01, $00, $03, $00, $07, $00, $0F, $00, $1F, $00, $3F, $00 UntitledPalette: .db $00, $00, $E0, $7F, $1F, $00, $FF, $03 Palette2: .db $E0, $7F ; 30 tiles (2 spaces) ; 480 bytes .ENDS