From 4d8b79c4f65154a0e17cc1334be199b9ac313f0e Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Wed, 1 Nov 2023 00:36:45 -0400 Subject: [PATCH] second: blurgh found bug in pt3 player if more than 42 patterns multiply by 3 for channels and by 2 for word offset and you overflow 8-bits :( of course our pt3 player has 51 channels --- demos/second/pt3_lib_core.s | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/demos/second/pt3_lib_core.s b/demos/second/pt3_lib_core.s index 1118b5ae..89a5f2d5 100644 --- a/demos/second/pt3_lib_core.s +++ b/demos/second/pt3_lib_core.s @@ -1541,18 +1541,44 @@ not_done: ; set up the three pattern address pointers - asl ; mul pattern offset by two, as word sized ; 2 - tay ; 2 + ; BUG BUG BUG + ; pattern offset can be bigger than 128, and if we multiply + ; by two to get word size it will overflow + ; for example I have a .pt3 where pattern #48 ($30*3=$90) is used + +; asl ; mul pattern offset by two, as word sized ; 2 +; tay ; 2 ; point PATTERN_H/PATTERN_L to the pattern address table - clc ; 2 - lda PT3_LOC+PT3_PATTERN_LOC_L ; 4 - sta PATTERN_L ; 3 +; clc ; 2 +; lda PT3_LOC+PT3_PATTERN_LOC_L ; 4 +; sta PATTERN_L ; 3 +; lda PT3_LOC+PT3_PATTERN_LOC_H ; 4 +; adc #>PT3_LOC ; assume page boundary ; 2 +; sta PATTERN_H ; 3 + + clc + sta PATTERN_L + adc PT3_LOC+PT3_PATTERN_LOC_L + adc PATTERN_L + sta PATTERN_L + lda PT3_LOC+PT3_PATTERN_LOC_H ; 4 adc #>PT3_LOC ; assume page boundary ; 2 sta PATTERN_H ; 3 +; clc +; tya +; adc PATTERN_L +; adc PATTERN_L +; sta PATTERN_L +; lda #0 +; adc PATTERN_H +; sta PATTERN_H + + ldy #0 + ; First 16-bits points to the Channel A address lda (PATTERN_L),Y ; 5+ sta note_a+NOTE_ADDR_L ; 4