diff --git a/my_custom.asm b/my_custom.asm index ac2a7b9..2ee9b3f 100644 --- a/my_custom.asm +++ b/my_custom.asm @@ -45,3 +45,29 @@ lda #\1 sta $2100 ; $2100 is the screen brightness register .ENDM + + + +; loads, in a loop, an alternating grid of tiles +.MACRO Tile_Load_Loop + + ldx #$0400 ; load $0400 (VRAM address of tile data) +TileLoadLoop: + + stx $2116 ; store VRAM address of tile data to VRAM address word-sized register + + lda #$01 ; smile tile + sta $2118 ;store tile map entry to the address specified in $2116 - this increments or not based on 2115 + + inx + stx $2116 + + lda #$00 ; blank tile + sta $2118 + + inx + + cpx #$0780 ; $400 - $780 seems to be limit of snes screen tile memory + bne TileLoadLoop + +.ENDM diff --git a/test_gfx.asm b/test_gfx.asm index 6a783a1..7e2d326 100644 --- a/test_gfx.asm +++ b/test_gfx.asm @@ -36,7 +36,7 @@ VBlank: sta $4304 ; store bank into DMA source bank sty $4305 ; store size of block - lda #$01 + lda #$01 sta $4300 ; set DMA mode (word, normal increment) lda #$18 @@ -77,27 +77,9 @@ Start: lda #%00000001 sta $212c ; enable bkg 1, -; Load_Block_to_VRAM TileMap, $0400, 16 - Load_Block_to_VRAM Tiles, $0000, (8*2*2), + Load_Block_to_VRAM Tiles, $0000, (8*2*3), - ldx #$0400 ; load $0400 (VRAM address of tile data) -TileLoadLoop: - - stx $2116 ; store VRAM address of tile data to VRAM address word-sized register - - lda #$01 ; smile tile - sta $2118 ;store tile map entry to the address specified in $2116 - this increments or not based on 2115 - - inx - stx $2116 - - lda #$00 ; blank tile - sta $2118 - - inx - - cpx #$0780 ; $400 - $780 seems to be limit of snes screen tile memory - bne TileLoadLoop + Load_Block_to_VRAM TileMap, $0400, 4 lda #%10000001 ; enable NMI and joypads sta $4200 @@ -159,14 +141,37 @@ Tiles: .db %00111100 .db %00111100 -TileMap: - .db $00, $01 - .db $00, $01 - .db $00, $01 - .db $00, $01 - .db $00, $01 - .db $00, $01 - .db $00, $01 - .db $00, $01 +; different face + .db %11111111 + .db %00000000 + .db %11111111 + .db %00000000 + + .db %11000011 + .db %00000000 + + .db %00111000 + .db %00111000 + + .db %00111000 + .db %00111000 + + .db %10000001 + .db %10000001 + + .db %01000010 + .db %01000010 + + .db %00111100 + .db %00111100 + + +; each entry in the tile map is two bytes long +; here is the format: +;High Low v: vertical flip h: horizontal flip +;vhopppcc cccccccc o: priority bit p: palette number +; c: Starting character (tile) number +TileMap: + .db $02, $00, $02, $00 .ENDS