From 2c6631c87e03d52e9fdcdfd0b653a5f80b135955 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 6 Dec 2016 02:51:01 -0800 Subject: [PATCH] Added more things to macros in my_custom --- my_custom.asm | 6 + test_gfx.asm | 301 +++++++------------------------------------------- 2 files changed, 45 insertions(+), 262 deletions(-) diff --git a/my_custom.asm b/my_custom.asm index a2aed50..1c8da29 100644 --- a/my_custom.asm +++ b/my_custom.asm @@ -34,3 +34,9 @@ sta $2122 ;sta $2122 .ENDM + +.MACRO Set_Screen_Brightness +lda #\1 +sta $2100 + +.ENDM diff --git a/test_gfx.asm b/test_gfx.asm index 440c838..314cbf6 100644 --- a/test_gfx.asm +++ b/test_gfx.asm @@ -1,34 +1,11 @@ .include "header.inc" .include "snes_init.asm" +.include "my_custom.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 @@ -45,160 +22,18 @@ Start: rep #%00010000 sep #%00100000 - - ; Load palette by writing to $2122 ; .db $00, $00, $E0, $7F, $1F, $00, $FF, $03 + Load_Palette_Color $00, $00 + Load_Palette_Color $00, $00 + Load_Palette_Color $00, $00 + Load_Palette_Color $ff, $0a -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 +;lda #%00000 -;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 + Set_Screen_Brightness %00001111 lda #%10000001 ; enable NMI and joypads sta $4200 @@ -206,59 +41,19 @@ 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 + Reset_Palette_Offset + Load_Palette_Color $00, $00 + Load_Palette_Color $00, $00 + Load_Palette_Color $00, $00 + Load_Palette_Color $ff, $0a 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 + Reset_Palette_Offset + Load_Palette_Color $ff, $a0 + Load_Palette_Color $00, $00 + Load_Palette_Color $00, $00 + Load_Palette_Color $ff, $0a jmp mainloop @@ -269,47 +64,29 @@ mainloop: .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 +Face: + .db %00000000 + .db %00000000 -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 + .db %11000011 + .db %11000011 -; 30 tiles (2 spaces) -; 480 bytes + .db %11000011 + .db %11000011 + + .db %00111000 + .db %00111000 + + .db %00111000 + .db %00111000 + + .db %10000001 + .db %10000001 + + .db %01000010 + .db %01000010 + + .db %00111100 + .db %00111100 .ENDS