From eab946a0517999f3016301d9641af3333ec04a07 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sat, 14 Sep 2019 23:22:05 -0400 Subject: [PATCH] interlace: re-cycle count sample/ornament load --- interlace_demo/pt3_lib_sample_ornament.s | 43 +++++++++++++----------- pt3_player/pt3_lib_core.s | 8 +++-- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/interlace_demo/pt3_lib_sample_ornament.s b/interlace_demo/pt3_lib_sample_ornament.s index a678b7bd..4c71b1f2 100644 --- a/interlace_demo/pt3_lib_sample_ornament.s +++ b/interlace_demo/pt3_lib_sample_ornament.s @@ -6,15 +6,23 @@ ;=========================== ; Load Ornament 0/Sample 1 ;=========================== + ; these only called by init so in theory are not cycle critical load_ornament0_sample1: lda #0 ; 2 jsr load_ornament ; 6 +load_sample1: + lda #1 ; 2 ; fall through + ;=========================== ;=========================== ; Load Sample ;=========================== + ;=========================== + ; cycles: 72 (NOTE SAMPLES MUST NOT CROSS PAGE BOUNDARY) + ;=========================== + ;=========================== ; sample in A ; which note offset in X @@ -26,11 +34,6 @@ load_ornament0_sample1: ; and then leave SAMPLE_H:SAMPLE_L pointing to begnning of ; the sample data - ; Optimization: - ; see comments on ornament setting - -load_sample1: - lda #1 ; 2 load_sample: @@ -59,34 +62,38 @@ load_sample: ldy #0 ; 2 lda (SAMPLE_L),Y ; 5+ - sta note_a+NOTE_SAMPLE_LOOP,X ; 5 + sta note_a+NOTE_SAMPLE_LOOP,X ; 4 ; Set the length value ; a->sample_length=pt3->data[a->sample_pointer]; iny ; 2 lda (SAMPLE_L),Y ; 5+ - sta note_a+NOTE_SAMPLE_LENGTH,X ; 5 + sta note_a+NOTE_SAMPLE_LENGTH,X ; 4 ; Set pointer to beginning of samples lda SAMPLE_L ; 3 adc #$2 ; 2 - sta note_a+NOTE_SAMPLE_POINTER_L,X ; 5 + sta note_a+NOTE_SAMPLE_POINTER_L,X ; 4 lda SAMPLE_H ; 3 adc #$0 ; 2 - sta note_a+NOTE_SAMPLE_POINTER_H,X ; 5 + sta note_a+NOTE_SAMPLE_POINTER_H,X ; 4 ldy PT3_TEMP ; 3 rts ; 6 ;============ - ; 76 + ; 72 ;=========================== ; Load Ornament ;=========================== + ;=========================== + ; cycles: 78 (NOTE SAMPLES MUST NOT CROSS PAGE BOUNDARY) + ;=========================== + ;=========================== ; ornament value in A ; note offset in X @@ -127,38 +134,34 @@ load_ornament: sta ORNAMENT_H ; 3 lda #0 ; 2 - sta note_a+NOTE_ORNAMENT_POSITION,X ; 5 + sta note_a+NOTE_ORNAMENT_POSITION,X ; 4 tay ; 2 ; Set the loop value ; a->ornament_loop=pt3->data[a->ornament_pointer]; lda (ORNAMENT_L),Y ; 5+ - sta note_a+NOTE_ORNAMENT_LOOP,X ; 5 + sta note_a+NOTE_ORNAMENT_LOOP,X ; 4 ; Set the length value ; a->ornament_length=pt3->data[a->ornament_pointer]; iny ; 2 lda (ORNAMENT_L),Y ; 5+ - sta note_a+NOTE_ORNAMENT_LENGTH,X ; 5 + sta note_a+NOTE_ORNAMENT_LENGTH,X ; 4 ; Set the pointer to the value past the length lda ORNAMENT_L ; 3 adc #$2 ; 2 - sta note_a+NOTE_ORNAMENT_POINTER_L,X ; 5 + sta note_a+NOTE_ORNAMENT_POINTER_L,X ; 4 lda ORNAMENT_H ; 3 adc #$0 ; 2 - sta note_a+NOTE_ORNAMENT_POINTER_H,X ; 5 + sta note_a+NOTE_ORNAMENT_POINTER_H,X ; 4 ldy PT3_TEMP ; restore Y value ; 3 rts ; 6 ;============ - ; 83 - - - - + ; 78 diff --git a/pt3_player/pt3_lib_core.s b/pt3_player/pt3_lib_core.s index 1118b5ae..6af8f98e 100644 --- a/pt3_player/pt3_lib_core.s +++ b/pt3_player/pt3_lib_core.s @@ -232,14 +232,20 @@ note_c: end_vars: .endif + ; this is only called by lib_init load_ornament0_sample1: lda #0 ; 2 jsr load_ornament ; 6 ; fall through +load_sample1: + lda #1 ; 2 + + ;=========================== ;=========================== ; Load Sample ;=========================== + ;=========================== ; sample in A ; which note offset in X @@ -254,8 +260,6 @@ load_ornament0_sample1: ; Optimization: ; see comments on ornament setting -load_sample1: - lda #1 ; 2 load_sample: