menu: speed up print routine, move tilemap buffers to bank $7E
This commit is contained in:
parent
45b67d0f1a
commit
14a2136be7
@ -26,8 +26,8 @@ print_src .word 0 ;source data address
|
|||||||
print_bank .byt 0 ;source data bank
|
print_bank .byt 0 ;source data bank
|
||||||
print_pal .word 0 ;palette number for text output
|
print_pal .word 0 ;palette number for text output
|
||||||
print_temp .word 0 ;work variable
|
print_temp .word 0 ;work variable
|
||||||
print_count .byt 0 ;how many characters may be printed?
|
print_ptr .byt 0,0,0 ;read pointer
|
||||||
print_count_tmp .byt 0 ;work variable
|
print_count .word 0 ;how many characters may be printed?
|
||||||
print_done .word 0 ;how many characters were printed?
|
print_done .word 0 ;how many characters were printed?
|
||||||
print_over .byt 0 ;was the string printed incompletely?
|
print_over .byt 0 ;was the string printed incompletely?
|
||||||
;----------parameters for dma----------
|
;----------parameters for dma----------
|
||||||
|
|||||||
@ -138,11 +138,11 @@ setup_gfx:
|
|||||||
stz $420b
|
stz $420b
|
||||||
stz $420c
|
stz $420c
|
||||||
;clear tilemap buffers
|
;clear tilemap buffers
|
||||||
ldx #$0000
|
ldx #$8000
|
||||||
stx $2181
|
stx $2181
|
||||||
lda #$01
|
lda #$00
|
||||||
sta $2183
|
sta $2183
|
||||||
DMA0(#$08, #0, #^zero, #!zero, #$80)
|
DMA0(#$08, #$8000, #^zero, #!zero, #$80)
|
||||||
|
|
||||||
;generate fonts
|
;generate fonts
|
||||||
jsr genfonts
|
jsr genfonts
|
||||||
|
|||||||
@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
#define OAM_TILE_BASE $6000
|
#define OAM_TILE_BASE $6000
|
||||||
|
|
||||||
#define BG1_TILE_BUF $7FB000
|
#define BG1_TILE_BUF $7EB000
|
||||||
#define BG2_TILE_BUF $7FA000
|
#define BG2_TILE_BUF $7EA000
|
||||||
|
|
||||||
#define BG1_TILE_BAK $7F9000
|
#define BG1_TILE_BAK $7E9000
|
||||||
#define BG2_TILE_BAK $7F8000
|
#define BG2_TILE_BAK $7E8000
|
||||||
|
|
||||||
#define AVR_CMD $307000
|
#define AVR_CMD $307000
|
||||||
#define AVR_PARAM $307004
|
#define AVR_PARAM $307004
|
||||||
|
|||||||
214
snes/text.a65
214
snes/text.a65
@ -1,146 +1,95 @@
|
|||||||
.text
|
.text
|
||||||
#include "memmap.i65"
|
#include "memmap.i65"
|
||||||
.byt "===HIPRINT==="
|
.byt "===HIPRINT==="
|
||||||
|
; input:
|
||||||
|
; print_count
|
||||||
|
; print_x
|
||||||
|
; print_y
|
||||||
|
; print_src
|
||||||
|
; print_bank
|
||||||
|
; print_pal
|
||||||
|
;
|
||||||
|
; output:
|
||||||
|
; print_done (# of chars printed)
|
||||||
|
; print_over (char after print_count)
|
||||||
|
|
||||||
hiprint:
|
hiprint:
|
||||||
|
php
|
||||||
sep #$20 : .as
|
sep #$20 : .as
|
||||||
lda print_count
|
rep #$10 : .xl
|
||||||
sta print_count_tmp
|
ldx print_src
|
||||||
stz print_over
|
stx print_ptr
|
||||||
rep #$30 : .xl : .al
|
lda print_bank
|
||||||
stz print_done
|
sta print_ptr+2
|
||||||
lda print_x
|
phb
|
||||||
and #$00ff
|
lda #$7e
|
||||||
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_temp
|
|
||||||
lda !print_y
|
|
||||||
and #$00ff
|
|
||||||
asl
|
|
||||||
asl
|
|
||||||
asl
|
|
||||||
asl
|
|
||||||
asl
|
|
||||||
clc
|
|
||||||
adc !print_temp
|
|
||||||
asl ; double the offset for WRAM addressing
|
|
||||||
tay ; zonday
|
|
||||||
plx
|
|
||||||
phy ; offset from tilemap start
|
|
||||||
stx !print_temp
|
|
||||||
clc
|
|
||||||
adc !print_temp
|
|
||||||
; 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
|
|
||||||
bne +
|
|
||||||
jmp print_end2
|
|
||||||
+ asl
|
|
||||||
sta @$2180
|
|
||||||
lda @print_pal
|
|
||||||
asl
|
|
||||||
asl
|
|
||||||
adc #$00
|
|
||||||
ora #$20
|
|
||||||
sta @$2180
|
|
||||||
lda @print_done
|
|
||||||
inc
|
|
||||||
sta @print_done
|
|
||||||
inx
|
|
||||||
lda !0,x
|
|
||||||
beq print_loop2
|
|
||||||
inx
|
|
||||||
lda !0,x
|
|
||||||
beq print_loop2
|
|
||||||
lda @print_count_tmp
|
|
||||||
dec
|
|
||||||
dec
|
|
||||||
sta @print_count_tmp
|
|
||||||
beq print_loop2
|
|
||||||
bmi print_loop2
|
|
||||||
bra print_loop_inner
|
|
||||||
print_loop2
|
|
||||||
lda @print_count
|
|
||||||
dec
|
|
||||||
sta @print_count_tmp
|
|
||||||
beq print_end2
|
|
||||||
lda #$00
|
|
||||||
pha
|
pha
|
||||||
plb
|
plb
|
||||||
rep #$30 : .al : .xl
|
rep #$30 : .al : .xl
|
||||||
ply ; source addr
|
lda print_pal
|
||||||
iny
|
and #$00ff
|
||||||
pla ; offset from tilemap start
|
xba
|
||||||
plx ; other tilemap addr
|
asl
|
||||||
stx !print_temp
|
asl
|
||||||
|
ora #$2000
|
||||||
|
sta print_temp
|
||||||
|
lda print_count
|
||||||
|
and #$00ff
|
||||||
|
beq hiprint_end
|
||||||
|
tay
|
||||||
|
lda print_x
|
||||||
|
and #$00ff
|
||||||
|
sta print_x
|
||||||
|
lda print_y
|
||||||
|
and #$00ff
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
clc
|
clc
|
||||||
adc !print_temp ; tilemap+offset
|
adc print_x
|
||||||
sta $2181
|
and #$fffe
|
||||||
tyx
|
tax
|
||||||
|
lda print_x
|
||||||
|
lsr
|
||||||
|
bcs hiprint_bg1
|
||||||
|
hiprint_bg2
|
||||||
|
lda [print_ptr]
|
||||||
|
and #$00ff
|
||||||
|
beq hiprint_end
|
||||||
|
inc print_ptr
|
||||||
|
asl
|
||||||
|
ora print_temp
|
||||||
|
sta !BG2_TILE_BUF, x
|
||||||
|
dey
|
||||||
|
beq hiprint_end
|
||||||
|
hiprint_bg1
|
||||||
|
lda [print_ptr]
|
||||||
|
and #$00ff
|
||||||
|
beq hiprint_end
|
||||||
|
inc print_ptr
|
||||||
|
asl
|
||||||
|
ora print_temp
|
||||||
|
sta !BG1_TILE_BUF, x
|
||||||
|
inx
|
||||||
|
inx
|
||||||
|
dey
|
||||||
|
beq hiprint_end
|
||||||
|
bra hiprint_bg2
|
||||||
|
hiprint_end
|
||||||
|
plb
|
||||||
sep #$20 : .as
|
sep #$20 : .as
|
||||||
lda print_bank
|
lda [print_ptr]
|
||||||
pha
|
sta print_over
|
||||||
plb
|
tya
|
||||||
print_loop2_inner
|
sec
|
||||||
lda !0,x
|
sbc print_count
|
||||||
bne +
|
eor #$ff
|
||||||
jmp print_end
|
|
||||||
+ asl
|
|
||||||
sta @$2180
|
|
||||||
lda @print_pal
|
|
||||||
asl
|
|
||||||
asl
|
|
||||||
adc #$00
|
|
||||||
ora #$20
|
|
||||||
sta @$2180
|
|
||||||
lda @print_done
|
|
||||||
inc
|
inc
|
||||||
sta @print_done
|
sta print_done
|
||||||
inx
|
plp
|
||||||
lda !0,x
|
|
||||||
beq print_end
|
|
||||||
lda @print_count_tmp
|
|
||||||
dec
|
|
||||||
dec
|
|
||||||
sta @print_count_tmp
|
|
||||||
beq print_end
|
|
||||||
bmi print_end
|
|
||||||
inx
|
|
||||||
lda !0,x
|
|
||||||
beq print_end
|
|
||||||
bra print_loop2_inner
|
|
||||||
print_end2 ; clean up the stack (6 bytes)
|
|
||||||
ply
|
|
||||||
ply
|
|
||||||
ply
|
|
||||||
print_end
|
|
||||||
lda !0,x
|
|
||||||
sta @print_over
|
|
||||||
lda #$00
|
|
||||||
pha
|
|
||||||
plb
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
@ -290,6 +239,7 @@ draw_window:
|
|||||||
sta print_count
|
sta print_count
|
||||||
jsr hiprint
|
jsr hiprint
|
||||||
lda print_done
|
lda print_done
|
||||||
|
clc
|
||||||
adc print_x
|
adc print_x
|
||||||
sta print_x
|
sta print_x
|
||||||
lda #^window_tr
|
lda #^window_tr
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user