sd2snes/snes/text.a65
2009-10-21 00:51:36 +02:00

147 lines
2.1 KiB
Plaintext

.text
#include "memmap.i65"
hiprint:
rep #$30 : .xl : .al
lda !print_x
and #$00ff
lsr
bcs print_bg1
ldx #!BG1_TILE_BUF ; for 2nd loop
phx
ldx #!BG2_TILE_BUF ; for 1st loop
phx
bra print_bg_cont
print_bg1
ldx #!BG2_TILE_BUF+2 ; for 2nd loop
phx
ldx #!BG1_TILE_BUF ; for 1st loop da whoop
phx
bra print_bg_cont
print_bg_cont
sta !print_x
lda !print_y
and #$00ff
asl
asl
asl
asl
asl
clc
adc !print_x
asl ; double the offset for WRAM addressing
tay ; zonday
plx
phy ; offset from tilemap start
stx !print_x
clc
adc !print_x
; we need to transfer to WRAM and from there to VRAM via DMA during VBLANK
; because VRAM can only be accessed during VBLANK and forced blanking.
sta $2181
sep #$20 : .as
lda #$7f ;we really only need bit 0. full bank given for clarity
sta $2183
print_loop
ldx !print_src
lda !print_bank
pha
plb
phx ; source addr
print_loop_inner
lda !0,x
asl
sta @$2180
lda #$00
adc #$00
sta @$2180
inx
lda !0,x
beq print_loop2
inx
lda !0,x
beq print_loop2
bra print_loop_inner
print_loop2
lda #$00
pha
plb
rep #$30 : .al : .xl
ply ; source addr
iny
pla ; offset from tilemap start
plx ; other tilemap addr
stx !print_x
clc
adc print_x ; tilemap+offset
sta $2181
tyx
sep #$20 : .as
lda print_bank
pha
plb
print_loop2_inner
lda !0,x
asl
sta @$2180
lda #$00
adc #$00
sta @$2180
inx
lda !0,x
beq print_end
inx
lda !0,x
beq print_end
bra print_loop2_inner
print_end
lda #$00
pha
plb
rts
loprint:
rep #$30 : .xl : .al
lda !print_x
and #$00ff
asl ;double the offset for WRAM addressing
clc
adc #!BG2_TILE_BUF
sta !print_x
lda !print_y
and #$00ff
asl
asl
asl
asl
asl
asl ;double the offset for WRAM addressing
clc
adc !print_x
; we need to transfer to WRAM and from there to VRAM via DMA during VBLANK
; because VRAM can only be accessed during VBLANK and forced blanking.
sta $2181
sep #$20 : .as
lda #$7f ;we really only need bit 0. full bank given for clarity
sta $2183
ldx !print_src
lda !print_bank
pha
plb
loprint_loop_inner
lda !0,x
beq loprint_end
sta @$2180
lda #$00
adc #$00
ora #$20
sta @$2180
inx
bra loprint_loop_inner
loprint_end
lda #$00
pha
plb
rts