316 lines
6.8 KiB
NASM
316 lines
6.8 KiB
NASM
|
.include "header.inc"
|
||
|
.include "snes_init.asm"
|
||
|
|
||
|
.BANK 0 SLOT 0
|
||
|
.org 0
|
||
|
.section "Vblank"
|
||
|
|
||
|
.MACRO Spin_Loop ARGS XCOUNT
|
||
|
|
||
|
; it is fucktarded that this macro doesn't work properly with immediates
|
||
|
;ldx XCOUNT
|
||
|
ldx #XCOUNT
|
||
|
lvl3\@:
|
||
|
lda #$ff
|
||
|
lvl2\@:
|
||
|
xba
|
||
|
lda #$ff
|
||
|
lvl1\@:
|
||
|
dea
|
||
|
cmp #$00
|
||
|
bne lvl1\@
|
||
|
xba
|
||
|
dea
|
||
|
cmp #$00
|
||
|
bne lvl2\@
|
||
|
dex
|
||
|
txa
|
||
|
cmp #$00
|
||
|
bne lvl3\@
|
||
|
.ENDM
|
||
|
|
||
|
VBlank:
|
||
|
rti
|
||
|
|
||
|
.ENDS
|
||
|
|
||
|
.BANK 0 SLOT 0
|
||
|
.ORG 0
|
||
|
.section "Main"
|
||
|
|
||
|
Start:
|
||
|
Snes_Init
|
||
|
|
||
|
; 16-bit xy, 8-bit a
|
||
|
rep #%00010000
|
||
|
sep #%00100000
|
||
|
|
||
|
|
||
|
|
||
|
; Load palette by writing to $2122
|
||
|
; .db $00, $00, $E0, $7F, $1F, $00, $FF, $03
|
||
|
|
||
|
|
||
|
lda #$00
|
||
|
sta $2122
|
||
|
lda #$00
|
||
|
sta $2122
|
||
|
lda #$e0
|
||
|
sta $2122
|
||
|
lda #$7f
|
||
|
sta $2122
|
||
|
lda #$1f
|
||
|
sta $2122
|
||
|
lda #$00
|
||
|
sta $2122
|
||
|
lda #$ff
|
||
|
sta $2122
|
||
|
lda #$0a
|
||
|
sta $2122
|
||
|
|
||
|
|
||
|
;ldx #$0000
|
||
|
;- lda UntitledPalette.l, x
|
||
|
;sta $2122 ; $2122 - data for CG RAM write
|
||
|
;inx
|
||
|
;cpx #8
|
||
|
;bne -
|
||
|
|
||
|
lda #33
|
||
|
sta $2121 ; address for CG RAM write
|
||
|
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 #$5000
|
||
|
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 ; $2105 is the mode for bg mode + tile size
|
||
|
|
||
|
lda #$50 ; data starts from $4000
|
||
|
sta $2107 ; for bg1 ; $2107 is address of tile map location for BG1
|
||
|
; tile map location registers:
|
||
|
; %aaaaaass
|
||
|
; a's <- tile map address location, << 11
|
||
|
; ss <- 32x32, 32x64, 32x64, 64x64
|
||
|
|
||
|
lda #60 ; and $6000
|
||
|
sta $2108 ; for bg2 ; and $2108 is tile map location 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
|
||
|
|
||
|
mainloop:
|
||
|
Spin_Loop $02
|
||
|
|
||
|
stz $2121
|
||
|
|
||
|
lda #$00
|
||
|
sta $2122
|
||
|
lda #$00
|
||
|
sta $2122
|
||
|
lda #$e0
|
||
|
sta $2122
|
||
|
lda #$7f
|
||
|
sta $2122
|
||
|
lda #$1f
|
||
|
sta $2122
|
||
|
lda #$00
|
||
|
sta $2122
|
||
|
lda #$ff
|
||
|
sta $2122
|
||
|
lda #$0a
|
||
|
sta $2122
|
||
|
|
||
|
;change brightness
|
||
|
;lda #%00000011
|
||
|
;sta $2100
|
||
|
|
||
|
;lda #%00110000
|
||
|
;sta $2105
|
||
|
|
||
|
Spin_Loop $02
|
||
|
|
||
|
lda #0
|
||
|
sta $2121
|
||
|
|
||
|
lda #$09
|
||
|
sta $2122
|
||
|
lda #$00
|
||
|
sta $2122
|
||
|
lda #$e0
|
||
|
sta $2122
|
||
|
lda #$7f
|
||
|
sta $2122
|
||
|
lda #$1f
|
||
|
sta $2122
|
||
|
lda #$00
|
||
|
sta $2122
|
||
|
lda #$ff
|
||
|
sta $2122
|
||
|
lda #$7f
|
||
|
sta $2122
|
||
|
|
||
|
;lda #$0f
|
||
|
;sta $2100
|
||
|
|
||
|
;lda #%00000000
|
||
|
;sta $2105
|
||
|
|
||
|
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:
|
||
|
;color schema here is %0RRRRRBB BBBGGGGG
|
||
|
; final 2 bytes seem to be grid
|
||
|
;.db %00000000, %00000000, %11100000, %01111111, %00011111, %00000000, %00000011 %11111111
|
||
|
.db $00, $00, $E0, $7F, $1F, $00, $FF, $03
|
||
|
Palette2:
|
||
|
.db $E0, $7F
|
||
|
|
||
|
; 30 tiles (2 spaces)
|
||
|
; 480 bytes
|
||
|
|
||
|
.ENDS
|