Sprites??? Not working tho'

This commit is contained in:
Greg Shuflin 2022-06-17 20:00:00 -07:00
parent 63f37f69af
commit 1ca9426ab6
2 changed files with 199 additions and 2 deletions

View File

@ -54,6 +54,148 @@ charset:
.byte %00000000 .byte %00000000
.byte %11111111 .byte %11111111
; This is tile 0x02 in 2bpp mode (what the background uses), but tile
; 0x01 in 4bpp mode (what the sprites use). It's very strange to mix
; these, but my assumption is that by this point you've already got
; your own graphics pipeline of some sort and probably aren't using
; 2bpp graphics at all any more, so I'm sure you can figure out what'll
; work best for you on your own :)
.byte %11111111
.byte %00000000
.byte %11111111
.byte %00000000
.byte %11111111
.byte %00000000
.byte %11100000
.byte %00000000
.byte %11100000
.byte %00000000
.byte %11100000
.byte %00000000
.byte %11100000
.byte %00000000
.byte %11100000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %11111111
.byte %00000000
.byte %11111111
.byte %00000000
.byte %11111111
.byte %00000000
.byte %00000111
.byte %00000000
.byte %00000111
.byte %00000000
.byte %00000111
.byte %00000000
.byte %00000111
.byte %00000000
.byte %00000111
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
; normally you would put 14 other 8x8 tiles here, but we don't have
; any, so just fill it with zeros.
.repeat 14 * 32
.byte 0
.endrepeat
.byte %11100000
.byte %00000000
.byte %11100000
.byte %00000000
.byte %11100000
.byte %00000000
.byte %11100000
.byte %00000000
.byte %11100000
.byte %00000000
.byte %11111111
.byte %00000000
.byte %11111111
.byte %00000000
.byte %11111111
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000111
.byte %00000000
.byte %00000111
.byte %00000000
.byte %00000111
.byte %00000000
.byte %00000111
.byte %00000000
.byte %00000111
.byte %00000000
.byte %11111111
.byte %00000000
.byte %11111111
.byte %00000000
.byte %11111111
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
charset_end: charset_end:

View File

@ -11,6 +11,12 @@
nmi_count: .res 2 nmi_count: .res 2
.segment "BSS"
oam_lo_buffer: .res 512
oam_hi_buffer: .res 32
oam_buffer_end:
.segment "CODE" .segment "CODE"
VRAM_CHARS = $0000 VRAM_CHARS = $0000
@ -46,6 +52,16 @@ start:
lda #$7c lda #$7c
sta CGDATA sta CGDATA
; Set up sprite palette
lda #128 ;sprite palettes begin at cgdata index 128
sta CGADD
stz CGDATA
stz CGDATA
lda #$1f
sta CGDATA
stz CGDATA
; Graphics mode 0, 8x8 tiles ; Graphics mode 0, 8x8 tiles
stz BGMODE stz BGMODE
@ -115,13 +131,23 @@ start:
sta VMDATAL sta VMDATAL
stz VMDATAH stz VMDATAH
; Show bg1 ; Show bg1 + sprites
lda #%00000001 lda #%00010001
sta TM sta TM
lda #$0f lda #$0f
sta INIDISP sta INIDISP
lda #$0
sta OBSEL
ldx #0
@zero_oam:
stz oam_lo_buffer, x
inx
cpx #(oam_buffer_end - oam_lo_buffer)
bne @zero_oam
lda #%10000001 lda #%10000001
sta NMITIMEN sta NMITIMEN
@ -133,6 +159,35 @@ mainloop:
cmp nmi_count cmp nmi_count
beq nmi_check beq nmi_check
; set sprite 0 X position
ldx #$42
stx oam_lo_buffer
; set sprite 0 Y position
ldx #$69
stx oam_lo_buffer + 1
; Set sprite 0 to priority 3 and tile 0x01
ldx #((%00110000 << 8) | $0001)
stx oam_lo_buffer + 2
; Set sprite 0 to be large (16x16)
lda #%00000010
sta oam_hi_buffer
; Copy OAM data via DMA
stz OAMADDL
lda #$0
sta DMAP1
lda #<OAMDATA
sta BBAD1
ldx #.loword(oam_lo_buffer)
stx A1B1
ldx #(oam_buffer_end - oam_lo_buffer)
stx DAS1L
lda #%00000010
sta MDMAEN
lda JOY1L lda JOY1L
bit #JOYL_L bit #JOYL_L