credits: use generic move_letters code

This commit is contained in:
Vince Weaver 2018-09-26 22:41:10 -04:00
parent 261661cd5d
commit c601179695
2 changed files with 205 additions and 149 deletions

View File

@ -1,6 +1,7 @@
;
; Cycle-counting text/hgr/lowres demo
; by Vince Weaver
;
.include "zp.inc"
@ -17,6 +18,7 @@
BLARGH = $69
MBASE = $97
MBOFFSET = $98
WAITING = $99
;===================
; init screen
@ -96,20 +98,20 @@ no_init_mb:
; Wait
jsr wait_until_keypressed
; jsr wait_until_keypressed
; GR part
bit LORES
bit SET_GR
bit FULLGR
; bit LORES
; bit SET_GR
; bit FULLGR
jsr draw_bottom_green ; 6
; jsr draw_bottom_green ; 6
; Wait
; jsr wait_until_keypressed
bit HIRES
; bit HIRES
; Wait
@ -561,22 +563,21 @@ loop6:
jsr move_letters ; 6+110
jsr move_letters ; 6+126
; Blanking time: 4550
; move_letters -116
; move_letters -132
; JMP at end -3
;========================4431 cycles
;========================4415 cycles
; Try X=176 Y=5 cycles=4431
; Try X=24 Y=35 cycles=4411 R4
; lda #0 ; 2
; lda #0 ; 2
ldy #5 ; 2
loop7:
ldx #176 ; 2
loop8:
dex ; 2
nop
nop
ldy #35 ; 2
loop7: ldx #24 ; 2
loop8: dex ; 2
bne loop8 ; 2nt/3
dey ; 2
bne loop7 ; 2nt/3
@ -763,133 +764,8 @@ green_loop:
; 4 + (40*55) + 6 - 1
;===============================================
; Move Letters
;===============================================
; Normal =10+25+38+9 = 82 need 28 (28)
; End of line =10+25+38+37 = 110
; Next line =10+5+12+34 = 61 need 49 (28+21)
; done entirely =10+5+9 = 24 need 86 (28+21+37)
; all forced to be 109
move_letters:
ldy #0 ; 2
lda (LETTERL),Y ; 5
sta LETTER ; 3
;==========
; 10
bmi letter_special
; 2
lda LETTERY ; 3
asl ; 2
tay ; 2
lda gr_offsets,Y ; lookup low-res memory address ; 4
sta BASL ; store out low byte of addy ; 3
lda gr_offsets+1,Y ; look up high byte ; 4
sta BASH ; 3
lda #0 ; cycle-killer ; 2
;==========
; 25
ldy #0 ; erase old char with space ; 2
lda #' '|$80 ; 2
ldy LETTERX ; 3
sta (BASL),Y ; 6
dey ; draw new char ; 2
sty LETTERX ; 3
lda LETTER ; 3
ora #$80 ; 2
ldy LETTERX ; 3
sta (BASL),Y ; 6
lda LETTERX ; 3
cmp LETTERD ; 3
;===========
; 38
beq letter_next
; 2
lda #0 ; 2
lda #0 ; 2
jmp waste_28 ; 3
;==========
; 9
letter_next:
; 3
clc ; 2
lda LETTERL ; 3
adc #1 ; 2
sta LETTERL ; 3
lda LETTERH ; 3
adc #0 ; 2
sta LETTERH ; 3
inc LETTERD ; 5
lda #39 ; 2
sta LETTERX ; 3
rts ; 6
;===========
; 37
letter_special:
; 3
cmp #$ff ; 2
;==========
; 5
beq letter_done
; 2
ldy #1 ; 2
lda (LETTERL),Y ; 5
sta LETTERY ; 3
;===========
; 12
iny ; 2
lda (LETTERL),Y ; 5
sta LETTERD ; 3
clc ; 2
lda LETTERL ; 3
adc #3 ; 2
sta LETTERL ; 3
lda LETTERH ; 3
adc #0 ; 2
sta LETTERH ; 3
lda LETTERH ; waste ; 3
jmp waste_21 ; 3
;===========
; 34
letter_done:
; 3
lda LETTERH ; 3
lda LETTERH ; 3
waste_37:
ldx #0 ; 2
inc BLARGH ; 5
inc BLARGH ; 5
inc BLARGH ; 5
inc BLARGH ; 5
inc BLARGH ; 5
inc BLARGH ; 5
inc BLARGH ; 5
waste_21:
ldx #0 ; 2
ldx #0 ; 2
ldx #0 ; 2
inc BLARGH ; 5
inc BLARGH ; 5
inc BLARGH ; 5
waste_28:
ldx #0 ; 2
inc BLARGH ; 5
inc BLARGH ; 5
inc BLARGH ; 5
inc BLARGH ; 5
rts ; 6
.align $100
letters:
;.byte 1,15
@ -911,16 +787,12 @@ letters:
.byte 3,16,"IS HARD!"
.byte 255
.include "vapor_lock.s"
.include "delay_a.s"
.include "gr_hline.s"
.include "../asm_routines/text_print.s"
.include "move_letters.s"
.include "mockingboard.s"
.include "../asm_routines/keypress.s"
;.include "../asm_routines/keypress.s"
.align $100
.include "tfv_sprites.inc"

184
split_screen/move_letters.s Normal file
View File

@ -0,0 +1,184 @@
;===============================================
; Move Letters
;===============================================
; Normal P0 =6+13+2+22+46+37 = 126
; Normal P1 =6+13+2+22+46+37 = 126
; End of line =6+13+2+22+46+9+(28) = 126
; Next line =6+13+5+14+34+(26+28) = 126
; done entirely =6+13+5+(6+42+26+28) = 126
; Waiting =6+7+(11+6+42+26+28) = 126
; all forced to be 126
move_letters:
ldy WAITING ; 3
beq not_waiting ; 3
;============
; 6
;-1
dec WAITING ; 5
jmp wait_it_out ; 3
;===========
; 7
not_waiting:
; load letter from pointer, save into LETTER
ldy #0 ; 2
lda (LETTERL),Y ; 5
sta LETTER ; 3
; if high bit set, is special case
bmi letter_special ; 3
;==========
; 13
; just regular letter
;-1
lda LETTERY ; get letter Y ; 3
bmi letter_page1
;==========
; 2
letter_page0: ; -1
asl ; map to memory address ; 2
tay ; 2
lda gr_offsets,Y ; lookup low-res memory address ; 4
sta BASL ; store out low byte of addy ; 3
lda gr_offsets+1,Y ; look up high byte ; 4
sta BASH ; 3
lda #0 ; cycle-killer ; 2
jmp letter_erase ; 3
;==========
; 22
letter_page1:
asl ; map to memory address ; 2
tay ; 2
lda gr_offsets,Y ; lookup low-res memory address ; 4
sta BASL ; store out low byte of addy ; 3
lda gr_offsets+1,Y ; look up high byte ; 4
clc ; 2
adc #$4 ; adjust to page1 ; 2
sta BASH ; 3
;==========
; 22
;============================
letter_erase:
ldy LETTERX ; nop ; 3
nop ; nop ; 5
ldy #0 ; erase old char with space ; 2
lda #' '|$80 ; 2
ldy LETTERX ; 3
sta (BASL),Y ; 6
dey ; draw new char ; 2
sty LETTERX ; 3
lda LETTER ; 3
ora #$80 ; 2
ldy LETTERX ; 3
sta (BASL),Y ; 6
lda LETTERX ; see if we are at destination ; 3
cmp LETTERD ; 3
beq letter_next ; 3
;===========
; 46
;-1
lda #0 ; 2
lda #0 ; 2
jmp waste_28 ; 3
;==========
; 9
letter_next:
clc ; 16-bit inc letter pointer ; 2
lda LETTERL ; 3
adc #1 ; 2
sta LETTERL ; 3
lda LETTERH ; 3
adc #0 ; 2
sta LETTERH ; 3
inc LETTERD ; inc destination X ; 5
lda #39 ; start at right of screen ; 2
sta LETTERX ; 3
rts ; 6
;===========
; 37
letter_special:
cmp #$ff ; handle FF, we're done ; 2
beq letter_done ; 3
;==========
; 5
; -1
and #$7f ; clear top ; 2
sta WAITING ; this is waiting value ; 3
ldy #1 ; otherwise, Y,X pair ; 2
lda (LETTERL),Y ; get Y, put in LETTERY ; 5
sta LETTERY ; 3
;===========
; 14
iny ; get dest ; 2
lda (LETTERL),Y ; 5
sta LETTERD ; put in LETTERD ; 3
clc ; skip 3 bytes to begin of letters ; 2
lda LETTERL ; 16-bit add ; 3
adc #3 ; 2
sta LETTERL ; 3
lda LETTERH ; 3
adc #0 ; 2
sta LETTERH ; 3
lda LETTERH ; waste ; 3
jmp waste_26 ; 3
;===========
; 34
wait_it_out:
; wait 11
inc BLARGH ; 5
lda LETTERH ; 3
lda LETTERH ; 3
letter_done:
lda LETTERH ; 3
lda LETTERH ; 3
waste_42:
ldx #0 ; 2
inc BLARGH ; 5
inc BLARGH ; 5
inc BLARGH ; 5
inc BLARGH ; 5
inc BLARGH ; 5
inc BLARGH ; 5
inc BLARGH ; 5
inc BLARGH ; 5
waste_26:
ldx #0 ; 2
ldx #0 ; 2
ldx #0 ; 2
inc BLARGH ; 5
inc BLARGH ; 5
inc BLARGH ; 5
inc BLARGH ; 5
waste_28:
ldx #0 ; 2
inc BLARGH ; 5
inc BLARGH ; 5
inc BLARGH ; 5
inc BLARGH ; 5
rts ; 6