From 79d7ecf19ea085322230f9677bd86c43b0cb6d20 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 6 Dec 2016 02:11:21 -0800 Subject: [PATCH] Add some helpful macros --- my_custom.asm | 36 ++++++++++++++++++++++ tic_tac.asm | 85 ++++++++++----------------------------------------- 2 files changed, 52 insertions(+), 69 deletions(-) create mode 100644 my_custom.asm diff --git a/my_custom.asm b/my_custom.asm new file mode 100644 index 0000000..a2aed50 --- /dev/null +++ b/my_custom.asm @@ -0,0 +1,36 @@ + +.MACRO Spin_Loop ARGS 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 + + +.MACRO Reset_Palette_Offset +stz $2121 +.ENDM + +.MACRO Load_Palette_Color ARGS BYTE1 BYTE2 + +lda #BYTE1 +sta $2122 +;lda #BYTE2 +;sta $2122 + +.ENDM diff --git a/tic_tac.asm b/tic_tac.asm index 440c838..00f3aec 100644 --- a/tic_tac.asm +++ b/tic_tac.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,36 +22,14 @@ 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 $e0, $7f + Load_Palette_Color $1f, $00 + Load_Palette_Color $ef, $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 - - -;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 @@ -206,7 +161,12 @@ sta $4200 mainloop: Spin_Loop $02 - stz $2121 + Reset_Palette_Offset + + Load_Palette_Color $00, $00 + Load_Palette_Color $e0, $7f + Load_Palette_Color $1f, $00 + Load_Palette_Color $ff, $0a lda #$00 sta $2122 @@ -234,25 +194,12 @@ mainloop: Spin_Loop $02 - lda #0 - sta $2121 + Reset_Palette_Offset - 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 + Load_Palette_Color $09, $00 + Load_Palette_Color $e0, $7f + Load_Palette_Color $1f, $00 + Load_Palette_Color $ff, $7f ;lda #$0f ;sta $2100