Add some helpful macros

This commit is contained in:
greg 2016-12-06 02:11:21 -08:00
parent e406386507
commit 79d7ecf19e
2 changed files with 52 additions and 69 deletions

36
my_custom.asm Normal file
View File

@ -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

View File

@ -1,34 +1,11 @@
.include "header.inc" .include "header.inc"
.include "snes_init.asm" .include "snes_init.asm"
.include "my_custom.asm"
.BANK 0 SLOT 0 .BANK 0 SLOT 0
.org 0 .org 0
.section "Vblank" .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: VBlank:
rti rti
@ -45,36 +22,14 @@ Start:
rep #%00010000 rep #%00010000
sep #%00100000 sep #%00100000
; Load palette by writing to $2122 ; Load palette by writing to $2122
; .db $00, $00, $E0, $7F, $1F, $00, $FF, $03 ; .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 lda #33
sta $2121 ; address for CG RAM write sta $2121 ; address for CG RAM write
@ -206,7 +161,12 @@ sta $4200
mainloop: mainloop:
Spin_Loop $02 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 lda #$00
sta $2122 sta $2122
@ -234,25 +194,12 @@ mainloop:
Spin_Loop $02 Spin_Loop $02
lda #0 Reset_Palette_Offset
sta $2121
lda #$09 Load_Palette_Color $09, $00
sta $2122 Load_Palette_Color $e0, $7f
lda #$00 Load_Palette_Color $1f, $00
sta $2122 Load_Palette_Color $ff, $7f
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 ;lda #$0f
;sta $2100 ;sta $2100